Chris@16
|
1 //-----------------------------------------------------------------------------
|
Chris@16
|
2 // boost variant/static_visitor.hpp header file
|
Chris@16
|
3 // See http://www.boost.org for updates, documentation, and revision history.
|
Chris@16
|
4 //-----------------------------------------------------------------------------
|
Chris@16
|
5 //
|
Chris@16
|
6 // Copyright (c) 2002-2003
|
Chris@16
|
7 // Eric Friedman
|
Chris@16
|
8 //
|
Chris@16
|
9 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
10 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
11 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
12
|
Chris@16
|
13 #ifndef BOOST_VARIANT_STATIC_VISITOR_HPP
|
Chris@16
|
14 #define BOOST_VARIANT_STATIC_VISITOR_HPP
|
Chris@16
|
15
|
Chris@16
|
16 #include "boost/config.hpp"
|
Chris@16
|
17 #include "boost/detail/workaround.hpp"
|
Chris@16
|
18
|
Chris@16
|
19 #include "boost/mpl/if.hpp"
|
Chris@16
|
20 #include "boost/type_traits/is_base_and_derived.hpp"
|
Chris@16
|
21
|
Chris@16
|
22 // should be the last #include
|
Chris@16
|
23 #include "boost/type_traits/detail/bool_trait_def.hpp"
|
Chris@16
|
24
|
Chris@16
|
25 namespace boost {
|
Chris@16
|
26
|
Chris@16
|
27 //////////////////////////////////////////////////////////////////////////
|
Chris@16
|
28 // class template static_visitor
|
Chris@16
|
29 //
|
Chris@16
|
30 // An empty base class that typedefs the return type of a deriving static
|
Chris@16
|
31 // visitor. The class is analogous to std::unary_function in this role.
|
Chris@16
|
32 //
|
Chris@16
|
33
|
Chris@16
|
34 namespace detail {
|
Chris@16
|
35
|
Chris@16
|
36 struct is_static_visitor_tag { };
|
Chris@16
|
37
|
Chris@16
|
38 typedef void static_visitor_default_return;
|
Chris@16
|
39
|
Chris@16
|
40 } // namespace detail
|
Chris@16
|
41
|
Chris@16
|
42 template <typename R = ::boost::detail::static_visitor_default_return>
|
Chris@16
|
43 class static_visitor
|
Chris@16
|
44 : public detail::is_static_visitor_tag
|
Chris@16
|
45 {
|
Chris@16
|
46 public: // typedefs
|
Chris@16
|
47
|
Chris@16
|
48 typedef R result_type;
|
Chris@16
|
49
|
Chris@16
|
50 protected: // for use as base class only
|
Chris@101
|
51 #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
|
Chris@101
|
52 static_visitor() = default;
|
Chris@101
|
53 ~static_visitor() = default;
|
Chris@101
|
54 #else
|
Chris@101
|
55 static_visitor() BOOST_NOEXCEPT { }
|
Chris@101
|
56 ~static_visitor() BOOST_NOEXCEPT { }
|
Chris@101
|
57 #endif
|
Chris@16
|
58 };
|
Chris@16
|
59
|
Chris@16
|
60 //////////////////////////////////////////////////////////////////////////
|
Chris@16
|
61 // metafunction is_static_visitor
|
Chris@16
|
62 //
|
Chris@16
|
63 // Value metafunction indicates whether the specified type derives from
|
Chris@16
|
64 // static_visitor<...>.
|
Chris@16
|
65 //
|
Chris@16
|
66 // NOTE #1: This metafunction does NOT check whether the specified type
|
Chris@16
|
67 // fulfills the requirements of the StaticVisitor concept.
|
Chris@16
|
68 //
|
Chris@16
|
69 // NOTE #2: This template never needs to be specialized!
|
Chris@16
|
70 //
|
Chris@16
|
71
|
Chris@16
|
72 namespace detail {
|
Chris@16
|
73
|
Chris@16
|
74 template <typename T>
|
Chris@16
|
75 struct is_static_visitor_impl
|
Chris@16
|
76 {
|
Chris@16
|
77 BOOST_STATIC_CONSTANT(bool, value =
|
Chris@16
|
78 (::boost::is_base_and_derived<
|
Chris@16
|
79 detail::is_static_visitor_tag,
|
Chris@16
|
80 T
|
Chris@16
|
81 >::value));
|
Chris@16
|
82 };
|
Chris@16
|
83
|
Chris@16
|
84 } // namespace detail
|
Chris@16
|
85
|
Chris@16
|
86 BOOST_TT_AUX_BOOL_TRAIT_DEF1(
|
Chris@16
|
87 is_static_visitor
|
Chris@16
|
88 , T
|
Chris@16
|
89 , (::boost::detail::is_static_visitor_impl<T>::value)
|
Chris@16
|
90 )
|
Chris@16
|
91
|
Chris@16
|
92 } // namespace boost
|
Chris@16
|
93
|
Chris@16
|
94 #include "boost/type_traits/detail/bool_trait_undef.hpp"
|
Chris@16
|
95
|
Chris@16
|
96 #endif // BOOST_VARIANT_STATIC_VISITOR_HPP
|