GCC-5 compatibility: ambiguity in overload resolution
we have a catch-all template operator to get a string converted or pretty printed output from "any object". Unfortunately this overload counts equivalent to another overload by the IO manipulators. Solution is to define both operarators similar in the first argument, thus turing the overload for the IO manipulators into the more specific overload due to the explicitly given second argument
This commit is contained in:
parent
37cdfaba54
commit
d29e4e2d6f
1 changed files with 6 additions and 6 deletions
|
|
@ -76,9 +76,9 @@ namespace std {
|
|||
|
||||
|
||||
/** generic overload to use custom string conversions in output */
|
||||
template<typename X, typename = enable_StringConversion<X>>
|
||||
ostream&
|
||||
operator<< (ostream& os, X const& obj)
|
||||
template<typename _CharT, typename _Traits, typename X, typename = enable_StringConversion<X>>
|
||||
inline basic_ostream<_CharT, _Traits>&
|
||||
operator<< (basic_ostream<_CharT, _Traits>& os, X const& obj)
|
||||
{
|
||||
return os << util::StringConv<X>::invoke (obj);
|
||||
}
|
||||
|
|
@ -88,9 +88,9 @@ namespace std {
|
|||
* @note possibly also invokes custom string conversion,
|
||||
* in case the pointee defines one
|
||||
*/
|
||||
template<typename X, typename = enable_StringConversion<X>>
|
||||
ostream&
|
||||
operator<< (ostream& os, X const* ptr)
|
||||
template<typename _CharT, typename _Traits, typename X, typename = enable_StringConversion<X>>
|
||||
inline basic_ostream<_CharT, _Traits>&
|
||||
operator<< (basic_ostream<_CharT, _Traits>& os, X const* ptr)
|
||||
{
|
||||
if (ptr)
|
||||
return util::showAddr(os, ptr) << " ↗" << util::StringConv<X>::invoke (*ptr);
|
||||
|
|
|
|||
Loading…
Reference in a new issue