source: NonGTP/Boost/boost/variant/detail/over_sequence.hpp @ 857

Revision 857, 2.5 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]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
27namespace boost {
28namespace 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//
35template <typename Types>
36struct 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
49template <typename T>
50struct is_over_sequence
51    : mpl::false_
52{
53};
54
55template <typename Types>
56struct is_over_sequence< over_sequence<Types> >
57    : mpl::true_
58{
59};
60
61#else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
62
63typedef char (&yes_over_sequence_t)[1];
64typedef char (&no_over_sequence_t)[2];
65
66no_over_sequence_t is_over_sequence_test(...);
67
68template<typename T>
69yes_over_sequence_t is_over_sequence_test(
70      type< ::boost::detail::variant::over_sequence<T> >
71    );
72
73template<typename T>
74struct 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
82template <typename T>
83struct 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
Note: See TracBrowser for help on using the repository browser.