source: NonGTP/Boost/boost/variant/static_visitor.hpp @ 857

Revision 857, 2.6 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]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)
12
13#ifndef BOOST_VARIANT_STATIC_VISITOR_HPP
14#define BOOST_VARIANT_STATIC_VISITOR_HPP
15
16#include "boost/config.hpp"
17#include "boost/detail/workaround.hpp"
18
19#include "boost/mpl/if.hpp"
20#include "boost/type_traits/is_base_and_derived.hpp"
21
22#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
23#   include "boost/type_traits/is_same.hpp"
24#endif
25
26// should be the last #include
27#include "boost/type_traits/detail/bool_trait_def.hpp"
28
29namespace boost {
30
31//////////////////////////////////////////////////////////////////////////
32// class template static_visitor
33//
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.
36//
37
38namespace detail {
39
40    struct is_static_visitor_tag { };
41
42    typedef void static_visitor_default_return;
43
44} // namespace detail
45
46template <typename R = ::boost::detail::static_visitor_default_return>
47class static_visitor
48    : public detail::is_static_visitor_tag
49{
50public: // typedefs
51
52    typedef R result_type;
53
54protected: // for use as base class only
55
56    static_visitor() { }
57    ~static_visitor() { }
58
59};
60
61//////////////////////////////////////////////////////////////////////////
62// metafunction is_static_visitor
63//
64// Value metafunction indicates whether the specified type derives from
65// static_visitor<...>.
66//
67// NOTE #1: This metafunction does NOT check whether the specified type
68//  fulfills the requirements of the StaticVisitor concept.
69//
70// NOTE #2: This template never needs to be specialized!
71//
72
73namespace detail {
74
75template <typename T>
76struct is_static_visitor_impl
77{
78    BOOST_STATIC_CONSTANT(bool, value =
79        (::boost::is_base_and_derived<
80            detail::is_static_visitor_tag,
81            T
82        >::value));
83};
84
85} // namespace detail
86
87BOOST_TT_AUX_BOOL_TRAIT_DEF1(
88      is_static_visitor
89    , T
90    , (::boost::detail::is_static_visitor_impl<T>::value)
91    )
92
93} // namespace boost
94
95#include "boost/type_traits/detail/bool_trait_undef.hpp"
96
97#endif // BOOST_VARIANT_STATIC_VISITOR_HPP
Note: See TracBrowser for help on using the repository browser.