http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58713
--- Comment #6 from Daniel Krügler <daniel.kruegler at googlemail dot com> --- (In reply to Daniel Krügler from comment #5) > Thanks for your test, Marc. I will reflect upon the problem in a bit more > detail My current guess is that my suggested approach should work, assuming a proper helper trait template will be used. Here is the model code that I used for testing: //--------------------------- #include <type_traits> #include <utility> namespace xstd { template<class CharT = char> struct OStream { OStream& operator<<(int); OStream& operator<<(short); OStream& operator<<(double); OStream& operator<<(const void*); }; struct is_ostreamable_impl { template<class CharT, class T, class = decltype(std::declval<OStream<CharT>&>() << std::declval<T>())> static std::true_type test(int); template<class, class> static std::false_type test(...); }; template<class CharT, class T> struct is_ostreamable : decltype(is_ostreamable_impl::test<CharT, T>(0))::type { }; template<class CharT, class T, typename std::enable_if< is_ostreamable<CharT, const T&>::value, bool >::type = false> OStream<CharT>& operator<<(OStream<CharT>&& os, const T& t) { return os << t; } OStream<> out; } struct A {}; int main() { A a; xstd::out << 1; xstd::out << a; } //--------------------------- The diagnostics of my gcc current 4.9.0 is <quote> main.cpp||In function 'int main()':| main.cpp|50|error: no match for 'operator<<' (operand types are 'xstd::OStream<>' and 'A')| main.cpp|50|note: candidates are:| main.cpp|9|note: xstd::OStream<CharT>& xstd::OStream<CharT>::operator<<(int) [with CharT = char]| main.cpp|9|note: no known conversion for argument 1 from 'A' to 'int'| main.cpp|10|note: xstd::OStream<CharT>& xstd::OStream<CharT>::operator<<(short int) [with CharT = char]| main.cpp|10|note: no known conversion for argument 1 from 'A' to 'short int'| main.cpp|11|note: xstd::OStream<CharT>& xstd::OStream<CharT>::operator<<(double) [with CharT = char]| main.cpp|11|note: no known conversion for argument 1 from 'A' to 'double'| main.cpp|12|note: xstd::OStream<CharT>& xstd::OStream<CharT>::operator<<(const void*) [with CharT = char]| main.cpp|12|note: no known conversion for argument 1 from 'A' to 'const void*'| main.cpp|36|note: template<class CharT, class T, typename std::enable_if<xstd::is_ostreamable<CharT, const T&>::value, bool>::type <anonymous> > xstd::OStream<CharT>& xstd::operator<<(xstd::OStream<CharT>&&, const T&)| main.cpp|36|note: template argument deduction/substitution failed:| main.cpp|35|error: no type named 'type' in 'struct std::enable_if<false, bool>'| main.cpp|35|note: invalid template non-type parameter| </quote>