Sign in to follow this  
supagu

yet another gcc compile problem

Recommended Posts

i have another problem porting visual studio code to gcc: std::transform(name.begin(), name.end(), name.begin(), std::tolower); doesnt compile, i get the following error: /home/bronson/workspace/Project/AirBlimbs/Source/Entity/PhysicsModel.cpp:83: error: no matching function for call to ‘transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unresolved overloaded function type>)’ i suspect its complianing about the std::tolower part

Share this post


Link to post
Share on other sites
std::tolower is a template function, you need to specify the template paramaters because gcc is unable to infer them from the context as the paramater is to transform is also a template.

Example:

void foo(char (*tolowerfunc)(char))
{
}

template<typename T>
void bar(T tolowerfunc)
{
}

int main()
{
// The standard dictates that this should infer the template paramater for
// std::tolower as being char from the type of the thing being initialized
foo(std::tolower);

// However there is no contextual information here to infer the template
// parameter for std::tolower so you get ambiguity errors/unresolved
// overload errors if you don't include the template parameters
bar(std::tolower<char>);
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this