Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-15 08:51:18

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 #include <boost/variant/static_visitor.hpp>
0020 
0021 namespace boost {
0022 
0023 ///////////////////////////////////////////////////////////////////////////////
0024 // function template operator<<
0025 //
0026 // Outputs the content of the given variant to the given ostream.
0027 //
0028 
0029 // forward declare (allows output of embedded variant< variant< ... >, ... >)
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: // representation
0042 
0043     OStream& out_;
0044 
0045 public: // structors
0046 
0047     explicit printer(OStream& out)
0048         : out_( out )
0049     {
0050     }
0051 
0052 public: // visitor interface
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 }} // namespace detail::variant
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 } // namespace boost
0082 
0083 #endif // BOOST_VARIANT_DETAIL_VARIANT_IO_HPP