Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:59:01

0001 //-----------------------------------------------------------------------------
0002 // boost variant/detail/apply_visitor_delayed.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
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_APPLY_VISITOR_DELAYED_HPP
0014 #define BOOST_VARIANT_DETAIL_APPLY_VISITOR_DELAYED_HPP
0015 
0016 #include <boost/variant/detail/apply_visitor_unary.hpp>
0017 #include <boost/variant/detail/apply_visitor_binary.hpp>
0018 #include <boost/variant/variant_fwd.hpp>
0019 
0020 
0021 #include <boost/variant/detail/has_result_type.hpp>
0022 #include <boost/core/enable_if.hpp>
0023 
0024 namespace boost {
0025 
0026 //////////////////////////////////////////////////////////////////////////
0027 // function template apply_visitor(visitor)
0028 //
0029 // Returns a function object, overloaded for unary and binary usage, that
0030 // visits its arguments using visitor (or a copy of visitor) via
0031 //  * apply_visitor( visitor, [argument] )
0032 // under unary invocation, or
0033 //  * apply_visitor( visitor, [argument1], [argument2] )
0034 // under binary invocation.
0035 //
0036 // NOTE: Unlike other apply_visitor forms, the visitor object must be
0037 //   non-const; this prevents user from giving temporary, to disastrous
0038 //   effect (i.e., returned function object would have dead reference).
0039 //
0040 
0041 template <typename Visitor>
0042 class apply_visitor_delayed_t
0043 {
0044 public: // visitor typedefs
0045 
0046     typedef typename Visitor::result_type
0047         result_type;
0048 
0049 private: // representation
0050 
0051     Visitor& visitor_;
0052 
0053 public: // structors
0054 
0055     explicit apply_visitor_delayed_t(Visitor& visitor) BOOST_NOEXCEPT
0056       : visitor_(visitor)
0057     {
0058     }
0059 
0060 public: // N-ary visitor interface
0061     template <typename... Visitables>
0062     result_type operator()(Visitables&... visitables) const
0063     {
0064         return apply_visitor(visitor_, visitables...);
0065     }
0066 
0067 private:
0068     apply_visitor_delayed_t& operator=(const apply_visitor_delayed_t&);
0069 
0070 };
0071 
0072 template <typename Visitor>
0073 inline typename boost::enable_if<
0074         boost::detail::variant::has_result_type<Visitor>,
0075         apply_visitor_delayed_t<Visitor>
0076     >::type apply_visitor(Visitor& visitor)
0077 {
0078     return apply_visitor_delayed_t<Visitor>(visitor);
0079 }
0080 
0081 #if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO)
0082 
0083 template <typename Visitor>
0084 class apply_visitor_delayed_cpp14_t
0085 {
0086 private: // representation
0087     Visitor& visitor_;
0088 
0089 public: // structors
0090 
0091     explicit apply_visitor_delayed_cpp14_t(Visitor& visitor) BOOST_NOEXCEPT
0092       : visitor_(visitor)
0093     {
0094     }
0095 
0096 public: // N-ary visitor interface
0097     template <typename... Visitables>
0098     decltype(auto) operator()(Visitables&... visitables) const
0099     {
0100         return apply_visitor(visitor_, visitables...);
0101     }
0102 
0103 private:
0104     apply_visitor_delayed_cpp14_t& operator=(const apply_visitor_delayed_cpp14_t&);
0105 
0106 };
0107 
0108 template <typename Visitor>
0109 inline  typename boost::disable_if<
0110         boost::detail::variant::has_result_type<Visitor>,
0111         apply_visitor_delayed_cpp14_t<Visitor>
0112     >::type apply_visitor(Visitor& visitor)
0113 {
0114     return apply_visitor_delayed_cpp14_t<Visitor>(visitor);
0115 }
0116 
0117 #endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO)
0118 
0119 
0120 } // namespace boost
0121 
0122 #endif // BOOST_VARIANT_DETAIL_APPLY_VISITOR_DELAYED_HPP