K
kaalus
Is it possible to use SFINAE to provide different implementations of
some function depending on the fact that operator << is overloaded for
some type?
For example:
template<class T>
void output1(const T &t)
{
// This implementation should be in effect for types that support
<<
std::cout << t;
}
template<class T>
void output2(const T &t)
{
// This implementation should be in effect for types that do not
support <<
my_output(t);
}
So that this usage is possible:
T t;
output(t); // uses output1 or output2 depending on << operator
defined for T
some function depending on the fact that operator << is overloaded for
some type?
For example:
template<class T>
void output1(const T &t)
{
// This implementation should be in effect for types that support
<<
std::cout << t;
}
template<class T>
void output2(const T &t)
{
// This implementation should be in effect for types that do not
support <<
my_output(t);
}
So that this usage is possible:
T t;
output(t); // uses output1 or output2 depending on << operator
defined for T