1 | //----------------------------------------------------------------------------- |
---|
2 | // boost variant/detail/over_sequence.hpp header file |
---|
3 | // See http://www.boost.org for updates, documentation, and revision history. |
---|
4 | //----------------------------------------------------------------------------- |
---|
5 | // |
---|
6 | // Copyright (c) 2003 |
---|
7 | // Eric Friedman |
---|
8 | // |
---|
9 | // Portions Copyright (C) 2002 David Abrahams |
---|
10 | // |
---|
11 | // Distributed under the Boost Software License, Version 1.0. (See |
---|
12 | // accompanying file LICENSE_1_0.txt or copy at |
---|
13 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
14 | |
---|
15 | #ifndef BOOST_VARIANT_DETAIL_OVER_SEQUENCE_HPP |
---|
16 | #define BOOST_VARIANT_DETAIL_OVER_SEQUENCE_HPP |
---|
17 | |
---|
18 | #include "boost/mpl/aux_/config/ctps.hpp" |
---|
19 | #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
---|
20 | # include "boost/mpl/eval_if.hpp" |
---|
21 | # include "boost/mpl/bool.hpp" |
---|
22 | # include "boost/mpl/identity.hpp" |
---|
23 | # include "boost/type.hpp" |
---|
24 | #endif |
---|
25 | |
---|
26 | |
---|
27 | namespace boost { |
---|
28 | namespace detail { namespace variant { |
---|
29 | |
---|
30 | /////////////////////////////////////////////////////////////////////////////// |
---|
31 | // (detail) class over_sequence |
---|
32 | // |
---|
33 | // Wrapper used to indicate bounded types for variant are from type sequence. |
---|
34 | // |
---|
35 | template <typename Types> |
---|
36 | struct over_sequence |
---|
37 | { |
---|
38 | typedef Types type; |
---|
39 | }; |
---|
40 | |
---|
41 | /////////////////////////////////////////////////////////////////////////////// |
---|
42 | // (detail) metafunction is_over_sequence (modeled on code by David Abrahams) |
---|
43 | // |
---|
44 | // Indicates whether the specified type is of form over_sequence<...> or not. |
---|
45 | // |
---|
46 | |
---|
47 | #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
---|
48 | |
---|
49 | template <typename T> |
---|
50 | struct is_over_sequence |
---|
51 | : mpl::false_ |
---|
52 | { |
---|
53 | }; |
---|
54 | |
---|
55 | template <typename Types> |
---|
56 | struct is_over_sequence< over_sequence<Types> > |
---|
57 | : mpl::true_ |
---|
58 | { |
---|
59 | }; |
---|
60 | |
---|
61 | #else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
---|
62 | |
---|
63 | typedef char (&yes_over_sequence_t)[1]; |
---|
64 | typedef char (&no_over_sequence_t)[2]; |
---|
65 | |
---|
66 | no_over_sequence_t is_over_sequence_test(...); |
---|
67 | |
---|
68 | template<typename T> |
---|
69 | yes_over_sequence_t is_over_sequence_test( |
---|
70 | type< ::boost::detail::variant::over_sequence<T> > |
---|
71 | ); |
---|
72 | |
---|
73 | template<typename T> |
---|
74 | struct is_over_sequence_impl |
---|
75 | { |
---|
76 | BOOST_STATIC_CONSTANT(bool, value = ( |
---|
77 | sizeof(is_over_sequence_test(type<T>())) |
---|
78 | == sizeof(yes_over_sequence_t) |
---|
79 | )); |
---|
80 | }; |
---|
81 | |
---|
82 | template <typename T> |
---|
83 | struct is_over_sequence |
---|
84 | : mpl::bool_< |
---|
85 | ::boost::detail::variant::is_over_sequence_impl<T>::value |
---|
86 | > |
---|
87 | { |
---|
88 | }; |
---|
89 | |
---|
90 | #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround |
---|
91 | |
---|
92 | }} // namespace detail::variant |
---|
93 | } // namespace boost |
---|
94 | |
---|
95 | #endif // BOOST_VARIANT_DETAIL_OVER_SEQUENCE_HPP |
---|