[bugfix] Don't implent operator<< templated wrt the stream
When implementing operator<<(S& , const T&)
to provide character
stream support for a custom type T
, the overload should be specific
to S=std::ostream
and not be templated wrt S
. Otherwise this may
lead to ambiguous overloads downstream.
To give two examples for problematic cases:
Here we defined an overload
template<class Stream, class T, std::size_t N>
inline Stream& operator<<(Stream&, const std::array<T,N>&)
If a downstream module wants to defines an overload
template<class A>
inline std::ostream& operator<<(std::ostream&, const A&)
for a custom type A
derived from std::array<T,N>
,
this leads to ambiguity.
If a custom class S
that does not represent a character stream
wants to use the s << t
syntax in anoter context, this cannot
be done for cases where t
is an std::array
. Furtermore
the overload that we provide here may in general not make any
sense in this context.
BTW: One may argue that defining overloads for std::
types
is in general a very bad idea. Imagine that another library
does the same - then we cannot use it together with dune, because
both claim to be the authority over std::
.