File indexing completed on 2025-07-15 08:51:18
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 #include <boost/variant/static_visitor.hpp>
0020
0021 namespace boost {
0022
0023
0024
0025
0026
0027
0028
0029
0030 template <class CharT, class Trait, typename... U>
0031 inline std::basic_ostream<CharT, Trait>& operator<<(
0032 std::basic_ostream<CharT, Trait>& out, const variant<U...>& rhs
0033 );
0034
0035 namespace detail { namespace variant {
0036
0037 template <typename OStream>
0038 class printer
0039 : public boost::static_visitor<>
0040 {
0041 private:
0042
0043 OStream& out_;
0044
0045 public:
0046
0047 explicit printer(OStream& out)
0048 : out_( out )
0049 {
0050 }
0051
0052 public:
0053
0054 template <typename T>
0055 void operator()(const T& operand) const
0056 {
0057 out_ << operand;
0058 }
0059
0060 private:
0061 printer& operator=(const printer&);
0062
0063 };
0064
0065 }}
0066
0067 template <class CharT, class Trait, typename... U>
0068 inline std::basic_ostream<CharT, Trait>& operator<<(
0069 std::basic_ostream<CharT, Trait>& out, const variant<U...>& rhs
0070 )
0071 {
0072 detail::variant::printer<
0073 std::basic_ostream<CharT, Trait>
0074 > visitor(out);
0075
0076 rhs.apply_visitor(visitor);
0077
0078 return out;
0079 }
0080
0081 }
0082
0083 #endif