(E-Mail Removed) wrote:

> Is it possible to use SFINAE to provide different implementations of

> some function depending on the fact that operator << is overloaded for

> some type?
It should be: what is your problem?

>

> 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
I do not really see the reason to do it with SFINAE (Substitution

Failure Is Not An Error). The most obvious way to do solve your problem

would be to provide operator<< for those classes. If that is not

appropriate, I believe I would simply provide:

template <typename T>

void my_output(T const& t) { std::cout << t; }

/Peter