Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:32

0001 //-----------------------------------------------------------------------------
0002 // boost variant/detail/variant_io.hpp header file
0003 // See http://www.boost.org for updates, documentation, and revision history.
0004 //-----------------------------------------------------------------------------
0005 //
0006 // Copyright (c) 2002-2003
0007 // Eric Friedman, Itay Maman
0008 //
0009 // Distributed under the Boost Software License, Version 1.0. (See
0010 // accompanying file LICENSE_1_0.txt or copy at
0011 // http://www.boost.org/LICENSE_1_0.txt)
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 // function template operator<<
0027 //
0028 // Outputs the content of the given variant to the given ostream.
0029 //
0030 
0031 // forward declare (allows output of embedded variant< variant< ... >, ... >)
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: // representation
0049 
0050     OStream& out_;
0051 
0052 public: // structors
0053 
0054     explicit printer(OStream& out)
0055         : out_( out )
0056     {
0057     }
0058 
0059 public: // visitor interface
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 }} // namespace detail::variant
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 } // namespace boost
0094 
0095 #endif // BOOST_VARIANT_DETAIL_VARIANT_IO_HPP