gcc 3.2 compilation problem]

Paul Marculescu mpaul@gecadsoftware.com
Mon Nov 18 12:12:00 GMT 2002


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.







More information about the Libstdc++ mailing list