File indexing completed on 2025-01-18 09:53:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_VARIANT_DETAIL_VARIANT_IO_HPP
0014 #define BOOST_VARIANT_DETAIL_VARIANT_IO_HPP
0015
0016 #include <iosfwd> // for std::basic_ostream forward declare
0017
0018 #include <boost/variant/variant_fwd.hpp>
0019
0020 #include <boost/detail/templated_streams.hpp>
0021 #include <boost/variant/static_visitor.hpp>
0022
0023 namespace boost {
0024
0025
0026
0027
0028
0029
0030
0031
0032 template <
0033 BOOST_TEMPLATED_STREAM_ARGS(E,T)
0034 BOOST_TEMPLATED_STREAM_COMMA
0035 BOOST_VARIANT_ENUM_PARAMS(typename U)
0036 >
0037 inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<(
0038 BOOST_TEMPLATED_STREAM(ostream, E,T)& out
0039 , const variant< BOOST_VARIANT_ENUM_PARAMS(U) >& rhs
0040 );
0041
0042 namespace detail { namespace variant {
0043
0044 template <typename OStream>
0045 class printer
0046 : public boost::static_visitor<>
0047 {
0048 private:
0049
0050 OStream& out_;
0051
0052 public:
0053
0054 explicit printer(OStream& out)
0055 : out_( out )
0056 {
0057 }
0058
0059 public:
0060
0061 template <typename T>
0062 void operator()(const T& operand) const
0063 {
0064 out_ << operand;
0065 }
0066
0067 private:
0068 printer& operator=(const printer&);
0069
0070 };
0071
0072 }}
0073
0074 template <
0075 BOOST_TEMPLATED_STREAM_ARGS(E,T)
0076 BOOST_TEMPLATED_STREAM_COMMA
0077 BOOST_VARIANT_ENUM_PARAMS(typename U)
0078 >
0079 inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<(
0080 BOOST_TEMPLATED_STREAM(ostream, E,T)& out
0081 , const variant< BOOST_VARIANT_ENUM_PARAMS(U) >& rhs
0082 )
0083 {
0084 detail::variant::printer<
0085 BOOST_TEMPLATED_STREAM(ostream, E,T)
0086 > visitor(out);
0087
0088 rhs.apply_visitor(visitor);
0089
0090 return out;
0091 }
0092
0093 }
0094
0095 #endif