在以下情况下选择正确的函数重载的正确方法是什么?
#include <iostream>
#include <algorithm>
/** the correct overload **/
bool predicate( const char& c )
{
return c == '0';
}
/** the wrong overload **/
template< typename CharType >
bool predicate( const CharType& c, int some_other_parameters )
{
return c == '0';
}
std::string
process_string( const std::string& str )
{
std::string result;
std::copy_if( str.begin( ),
str.end( ),
std::back_inserter( result ),
predicate );
return result;
}
int main()
{
std::cout << process_string("AK0NNDK0ASDAS0") << std::endl;
return 0;
}