std::basic_string<_CharT> ( is a dependent scope?)

E

eric

Dear advanced c++ programers:

When i tried to compile a example code with some modification on
book(c++ cookbook) chapter 4, section 6: Splitting a String. by
suggestion of author change string to basic_string<T> to make the
example above a function template that accepts any kind of character
is trivial; just parameterize the character type.
book's example code is here
http://examples.oreilly.com/9780596007614/
-------------------------------
g++ Example4-10.cpp
Example4-10.cpp: In function ‘void split(const
std::basic_string said:
Example4-10.cpp:11:3: error: need ‘typename’ before
‘std::basic_string<_CharT>::size_type’ because
‘std::basic_string<_CharT>’ is a dependent scope
Example4-10.cpp:11:30: error: expected ‘;’ before ‘i’
 
M

Michael DOUBEZ

Dear advanced c++ programers:

  When i tried to compile a example code with some modification on
book(c++ cookbook) chapter 4, section 6: Splitting a String.   by
suggestion of author change string to basic_string<T> to make the
example above a function template that accepts any kind of character
is trivial; just parameterize the character type.
book's example code is herehttp://examples.oreilly.com/9780596007614/
-------------------------------
g++ Example4-10.cpp
Example4-10.cpp: In function ‘void split(const
std::basic_string<_CharT>&, T, std::vector<std::basic_string<_CharT>>&)’:

Example4-10.cpp:11:3: error: need ‘typename’ before
‘std::basic_string<_CharT>::size_type’ because
‘std::basic_string<_CharT>’ is a dependent scope
Example4-10.cpp:11:30: error: expected ‘;’ before ‘i’

The compiler told you: add 'typename' before
std::basic_string<_CharT>::size_type. It even told you the reason: see
about dependent name
http://www.parashift.com/c++-faq-lite/templates.html#faq-35.18
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top