AT:
#include <string>
void f( char const*, char const* = "" ) {
}
template<class StringType1,class StringType2> inline
void g( StringType1 const &s1, StringType2 const &s2 = "" ) {
f( s1.c_str(), s2.c_str() );
}
template<class StringType> inline
void h( StringType const &s1, StringType const &s2 = "" ) {
f( s1.c_str(), s2.c_str() );
}
int main() {
std::string s;
g( s );
h( s );
return 0;
}
the compiler does not match the call g()because it has 2 template arguments, but it matches perfectly h(). Why?
FYI: my code base actually uses several highly specialized string classes, so I want to allow maximum flexibility when the first and second arguments can have different types of strings.
source
share