1 //-----------------------------------------------------------------------------
2 // boost variant/static_visitor.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
6 // Copyright (c) 2002-2003
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
13 #ifndef BOOST_VARIANT_STATIC_VISITOR_HPP
14 #define BOOST_VARIANT_STATIC_VISITOR_HPP
16 #include <boost/config.hpp>
17 #include <boost/detail/workaround.hpp>
19 #include <boost/mpl/if.hpp>
20 #include <boost/type_traits/is_base_and_derived.hpp>
22 #include <boost/type_traits/integral_constant.hpp>
23 #include <boost/mpl/aux_/lambda_support.hpp>
27 //////////////////////////////////////////////////////////////////////////
28 // class template static_visitor
30 // An empty base class that typedefs the return type of a deriving static
31 // visitor. The class is analogous to std::unary_function in this role.
36 struct is_static_visitor_tag { };
38 typedef void static_visitor_default_return;
42 template <typename R = ::boost::detail::static_visitor_default_return>
44 : public detail::is_static_visitor_tag
48 typedef R result_type;
50 protected: // for use as base class only
51 #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
52 static_visitor() = default;
54 static_visitor() BOOST_NOEXCEPT { }
58 //////////////////////////////////////////////////////////////////////////
59 // metafunction is_static_visitor
61 // Value metafunction indicates whether the specified type derives from
62 // static_visitor<...>.
64 // NOTE #1: This metafunction does NOT check whether the specified type
65 // fulfills the requirements of the StaticVisitor concept.
67 // NOTE #2: This template never needs to be specialized!
73 struct is_static_visitor_impl
75 BOOST_STATIC_CONSTANT(bool, value =
76 (::boost::is_base_and_derived<
77 detail::is_static_visitor_tag,
84 template< typename T > struct is_static_visitor
85 : public ::boost::integral_constant<bool,(::boost::detail::is_static_visitor_impl<T>::value)>
88 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_static_visitor,(T))
93 #endif // BOOST_VARIANT_STATIC_VISITOR_HPP