Hey guys...having a bit of problem with g++ 3.2.2 using the following code:
string CApp::ToLowerCase(string toLower)
{
string::iterator it;
// convert to lowercase
for(it = toLower.begin(); it != toLower.end(); it++)
toLower.replace(it, it+1, 1, tolower(*it));
return toLower;
}
g++ chokes on the line "string::iterator it":
/usr/include/c++/3.2.2/bits/stl_iterator_base_types.h: In instantiation of `std::iterator_traits<int>':
/usr/include/c++/3.2.2/bits/basic_string.h:688: instantiated from `std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT,
_Traits, _Alloc>::replace(__gnu_cxx::__normal_iterator<_Alloc::Pointer, std::basic_string<_CharT, _Traits, _Alloc> >, __gnu_cxx::__normal_iterator<_Alloc::Pointer, std::basic_string<_CharT, _Traits, _Alloc> >, _InputIterator, _InputIterator) [with _InputIterator = int, _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'
app.cpp:575: instantiated from here
/usr/include/c++/3.2.2/bits/stl_iterator_base_types.h:123: `int' is not a
class, struct, or union type
/usr/include/c++/3.2.2/bits/stl_iterator_base_types.h:124: `int' is not a
class, struct, or union type
/usr/include/c++/3.2.2/bits/stl_iterator_base_types.h:125: `int' is not a
class, struct, or union type
/usr/include/c++/3.2.2/bits/stl_iterator_base_types.h:126: `int' is not a
class, struct, or union type
/usr/include/c++/3.2.2/bits/stl_iterator_base_types.h:127: `int' is not a
class, struct, or union type
/usr/include/c++/3.2.2/bits/basic_string.h: In member function
`std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT,
_Traits, _Alloc>::replace(__gnu_cxx::__normal_iterator<_Alloc::Pointer,
std::basic_string<_CharT, _Traits, _Alloc> >,
__gnu_cxx::__normal_iterator<_Alloc::Pointer, std::basic_string<_CharT,
_Traits, _Alloc> >, _InputIterator, _InputIterator) [with _InputIterator =
int, _CharT = char, _Traits = std::char_traits<char>, _Alloc =
std::allocator<char>]':
app.cpp:575: instantiated from here
/usr/include/c++/3.2.2/bits/basic_string.h:688: no type named `
iterator_category' in `struct std::iterator_traits<int>'
make: *** [main] Error 1
I checked the help docs at gcc's website, but found no answers. I have no trouble declaring iterators to other STL structures, just with the string class. Namespace is not an issue either. The code compiles and functions without a hitch in .NET 2003. Thanks in advance.
EDIT: formatting issues
[edited by - iamjoesname on March 28, 2004 9:22:36 PM]