Does anybody know of a method for specializing a template depending on whether a non-member method is defined? I know there are numerous ways for specializing if a member fu
If you are using C++0x, you could simply use decltype.
template<typename Char, typename CharTraits, typename T>
decltype(
*(std::basic_ostream<Char, CharTraits>*)(nullptr) << *(T*)(nullptr)
)
That'll certainly cause a substitution failure if a T cannot be output. You could probably do something similar in C++03, but I'm not sure how.
Edit: Just realised that the decltype expression doesn't actually produce a true or false value and won't compile. But you get the picture. Try this.