This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcc 3.2 compilation problem]


Hello.

I just upgraded to gcc3.2 and I'm trying to compile this code:

------------------- cut here ---------------------

#include <string>
#include <algorithm>
#include <cctype>
#include <iostream

using namespace std;

std::string& lower( std::string& p_str )
{
   std::transform( p_str.begin(), p_str.end(), p_str.begin(), tolower );
   return p_str;
}

int main()
{
   string      s( "AbRacaDABRA" );
   lower( s );
   cout << s << endl;
   return 0;
}

------------------- cut here ---------------------

I get this error:

c.cpp:16: no matching function for call to `transform(
  __gnu_cxx::__normal_iterator, std::allocator > >,
  __gnu_cxx::__normal_iterator, std::allocator > >,
  __gnu_cxx::__normal_iterator, std::allocator > >, )'


If I define a wrapper function for "tolower" in this way:

inline int my_tolower( int x )
{
   return tolower(x);
}

and use it in std::transform:

std::transform( p_str.begin(), p_str.end(), p_str.begin(), my_tolower );

everything works just fine.

Can you please give me an explanation for this?

Thank you.






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]