fix doc example typo
[boost.git] / boost / variant / static_visitor.hpp
blobb59b6f5a6a2f31bb19bc90b80bf1249a91724523
1 //-----------------------------------------------------------------------------
2 // boost variant/static_visitor.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
5 //
6 // Copyright (c) 2002-2003
7 // Eric Friedman
8 //
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 #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
23 # include "boost/type_traits/is_same.hpp"
24 #endif
26 // should be the last #include
27 #include "boost/type_traits/detail/bool_trait_def.hpp"
29 namespace boost {
31 //////////////////////////////////////////////////////////////////////////
32 // class template static_visitor
34 // An empty base class that typedefs the return type of a deriving static
35 // visitor. The class is analogous to std::unary_function in this role.
38 namespace detail {
40 struct is_static_visitor_tag { };
42 typedef void static_visitor_default_return;
44 } // namespace detail
46 template <typename R = ::boost::detail::static_visitor_default_return>
47 class static_visitor
48 : public detail::is_static_visitor_tag
50 public: // typedefs
52 typedef R result_type;
54 protected: // for use as base class only
56 static_visitor() { }
57 ~static_visitor() { }
61 //////////////////////////////////////////////////////////////////////////
62 // metafunction is_static_visitor
64 // Value metafunction indicates whether the specified type derives from
65 // static_visitor<...>.
67 // NOTE #1: This metafunction does NOT check whether the specified type
68 // fulfills the requirements of the StaticVisitor concept.
70 // NOTE #2: This template never needs to be specialized!
73 namespace detail {
75 template <typename T>
76 struct is_static_visitor_impl
78 BOOST_STATIC_CONSTANT(bool, value =
79 (::boost::is_base_and_derived<
80 detail::is_static_visitor_tag,
82 >::value));
85 } // namespace detail
87 BOOST_TT_AUX_BOOL_TRAIT_DEF1(
88 is_static_visitor
89 , T
90 , (::boost::detail::is_static_visitor_impl<T>::value)
93 } // namespace boost
95 #include "boost/type_traits/detail/bool_trait_undef.hpp"
97 #endif // BOOST_VARIANT_STATIC_VISITOR_HPP