template question

G

Guest

In the code bellow, I have this compiler error in line 2:
error C2947: expecting '>' to terminate template-argument-list, found '>>'
Why?
------------------------------------------------------
template<typename C> // C can be: char, wchar_t, unsigned long
vector<basic_string<C>> explode(const basic_string<C> &delimiter, const basic_string<C> &s, unsigned int part = -1)
{
vector<basic_string<C>> e;
int a, b = 0;
for(;;)
{
a = s.find(delimiter, b);
if (a == basic_string<C>::npos) { e.push_back(s.substr(b)); return e; }
e.push_back(s.substr(b, a - b));
b = a + 1;
if(!(--part)) return e;
}
}
------------------------------------------------------
 
L

lallous

In the code bellow, I have this compiler error in line 2:
error C2947: expecting '>' to terminate template-argument-list, found '>>'
Why?
basic_string said:
{
vector<basic_string<C>> e;
int a, b = 0;
for(;;)
{
a = s.find(delimiter, b);
if (a == basic_string<C>::npos) { e.push_back(s.substr(b)); return e; }
e.push_back(s.substr(b, a - b));
b = a + 1;
if(!(--part)) return e;
}
}
Hello

Put space between the '>>' as: '> >' in this:
vector<basic_string<C>(here put space)> explode(const basic_string<C>
&delimiter, const basic_string<C> &s, unsigned int part = -1)
 
G

Guest

Put space between the '>>' as: '> >' in this:
&delimiter, const basic_string<C> &s, unsigned int part = -1)

I understand! C++ confused with operator >>
Thanks!
 

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

Members online

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,426
Latest member
MrMet

Latest Threads

Top