Why am I getting an error on the search algorithm? If I put e in place of s.end() it works but I'm just wondering why it won't work as it is now.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
string splitDate(string s)
{
typedef string::const_iterator iter;
string ret;
string searchVal = ": ";
iter b = s.begin();
iter e = s.end();
while (b != s.end())
{
b = search(b, s.end(), searchVal.begin(), searchVal.end());
// It works if I put e in place of s.end()
b += searchVal.size();
if (b != s.end())
ret = string(b, s.end());
}
return ret;
}
Error 2 error C2782: '_FwdIt1 std::search(_FwdIt1,_FwdIt1,_FwdIt2,_FwdIt2)' : template parameter '_FwdIt1' is ambiguous c:\users\dj\documents\visual studio 2010\projects\work hour manager\work hour manager\split.cpp 15
5 IntelliSense: no instance of "search" matches the argument list c:\users\dj\documents\visual studio 2010\projects\work hour manager\work hour manager\split.cpp 15
Bumped since I'm having the same problem on another project now and I find it really stupid how I need to define a new iterator in order to use the algorithm.