This is strange... VC++ gives me this error:
if I try to overload my ToUpper() function template like this:error C2780: 'void StrUtils::ToUpper(std::basic_string<_Elem,_Traits, _Alloc> &,const std::locale &)' : expects 2 arguments - 4 provided
but it compiles fine if I specify the template parameters:Code:template <typename E> class ToUpperFunctor : public std::binary_function<E, std::locale, E> { public: E operator()( E ch, const std::locale& loc = std::locale() ) const { return std::toupper( ch, loc ); } }; template <typename E, typename InIt, typename OutIt> void ToUpper( InIt start1, InIt end1, OutIt start2, const std::locale& loc = std::locale() ) { std::transform( start1, end1, start2, std::bind2nd( ToUpperFunctor<E>(), loc ) ); } template <typename E, typename T, typename A> void ToUpper( std::basic_string<E, T, A>& str, const std::locale& loc = std::locale() ) { typedef std::basic_string<E, T, A>::iterator iter; ToUpper( str.begin(), str.end(), str.begin(), loc ); }
But both template functions take the same number of template parameters, so how could that possibly help, and why doesn't it know which function I'm talking about to begin with?Code:template <typename E> class ToUpperFunctor : public std::binary_function<E, std::locale, E> { public: E operator()( E ch, const std::locale& loc = std::locale() ) const { return std::toupper( ch, loc ); } }; template <typename E, typename InIt, typename OutIt> void ToUpper( InIt start1, InIt end1, OutIt start2, const std::locale& loc = std::locale() ) { std::transform( start1, end1, start2, std::bind2nd( ToUpperFunctor<E>(), loc ) ); } template <typename E, typename T, typename A> void ToUpper( std::basic_string<E, T, A>& str, const std::locale& loc = std::locale() ) { typedef std::basic_string<E, T, A>::iterator iter; ToUpper<E, iter, iter>( str.begin(), str.end(), str.begin(), loc ); }



LinkBack URL
About LinkBacks



CornedBee
