http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58713

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Daniel Krügler from comment #3)
> guess is that this would also improve the diagnostics in this case, is that
> right?

Even if it worked (which it doesn't, as Marc also discovered) it would only
help a little bit, because G++ still prints all the candidates even if they are
not viable due to substitution failure. (Usually I love this feature, but when
there are a very large number of overloads, such as anything using operator<<,
the diagnostics can be overwhelming.)

(In reply to Daniel Krügler from comment #6)
> 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>

This does look better.  I thought I'd experimented with a similar trait(*) and
found the results disappointing.

(*)
https://gitorious.org/redistd/redistd/source/33d8d3a4f49da25e71ca87aab674d3b88500d302:include/redi/printers.h

Reply via email to