Boost logo

Boost :

From: Eric Friedman (ebf_at_[hidden])
Date: 2003-07-26 00:08:00

In adding output streaming support for variant, I've realized the
standard library packaged with gcc 2.9.7 and below does not support the
templated stream classes. I've also realized that Boost.Tuple features a
workaround addressing this same problem, with a comment to add a defect
macro to boost/config.hpp in the future.

Therefore, I think the time to add BOOST_NO_TEMPLATED_STREAMS is now.

I believe the test is as simple as follows, but I'll leave it up to
others who are more knowledgeable of the numerous streaming classes than

  #include <iosfwd>
  using namespace std;

  template <typename E, typename T>
  void basic_ostream_check( basic_ostream<E,T>& );

  template <typename E, typename T>
  void basic_istream_check( basic_istream<E,T>& );

  // ...and so on...

However, I believe this is only a partial solution. Even with
BOOST_NO_TEMPLATED_STREAMS appropriately defined, much is still left on
library implementors. Indeed, this can be seen in the redundancy of the
workarounds in "boost/tuple/tuple_io.hpp".

I propose several helper macros to address this redundancy. I've added
the helper macros in the main CVS under
boost/detail/templated_streams.hpp and demonstrate their use in
boost/variant/detail/variant_io.hpp and in boost/empty.hpp.

I'd greatly appreciate input.


P.S. For those who do not have time to check my code in CVS, the basic
idea is that the macros can be used as in the following:

inline BOOST_TEMPLATED_STREAM(ostream, Elem,Traits)& operator<<(
      BOOST_TEMPLATED_STREAM(ostream, Elem,Traits)& out
    , const my_class& rhs

Or for class templates:

template <
      typename T
inline BOOST_TEMPLATED_STREAM(ostream, Elem,Traits)& operator<<(
      BOOST_TEMPLATED_STREAM(ostream, Elem,Traits)& out
    , const my_class_template<T>& rhs

Boost list run by bdawes at, gregod at, cpdaniel at, john at