1// Boost.TypeErasure library
2//
3// Copyright 2011 Steven Watanabe
4//
5// Distributed under the Boost Software License Version 1.0. (See
6// accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9// $Id$
10
11#ifndef BOOST_TYPE_ERASURE_RELAXED_HPP_INCLUDED
12#define BOOST_TYPE_ERASURE_RELAXED_HPP_INCLUDED
13
14#include <boost/mpl/vector.hpp>
15#include <boost/mpl/bool.hpp>
16#include <boost/mpl/is_sequence.hpp>
17#include <boost/mpl/find_if.hpp>
18#include <boost/mpl/not.hpp>
19#include <boost/mpl/end.hpp>
20#include <boost/type_traits/is_same.hpp>
21
22namespace boost {
23namespace type_erasure {
24
25template<class T>
26struct is_relaxed;
27
28namespace detail {
29
30template<class T>
31struct is_relaxed_impl :
32 ::boost::mpl::not_<
33 typename ::boost::is_same<
34 typename ::boost::mpl::find_if<
35 T,
36 ::boost::type_erasure::is_relaxed< ::boost::mpl::_1>
37 >::type,
38 typename ::boost::mpl::end<T>::type
39 >::type
40 >::type
41{};
42
43}
44
45/**
46 * This special concept enables various useful default behavior that
47 * makes @ref any act like an ordinary object. By default @ref any
48 * forwards all operations to the underlying type, and provides only
49 * the operations that are specified in its @c Concept.
50 *
51 * In detail, @ref relaxed enables the following:
52 * - A raw value can be assigned to an @ref any. This will replace
53 * the value stored by the @ref any. (But note that if @ref assignable
54 * is present, it takes priority.)
55 * - assignment of @ref any uses the constructor if it can't
56 * use @ref assignable (either because @ref assignable is missing,
57 * or because the stored types do not match).
58 * - default construction of @ref any is allowed and creates a null any.
59 * - @ref equality_comparable "equality_comparable": If the types do not
60 * match, it will return false.
61 * - @ref less_than_comparable "less_than_comparable": If the types do not
62 * match, the ordering will be according to
63 * @c std::type_info::before.
64 * - if the arguments to any other function do not match, it will throw
65 * a @ref bad_function_call exception instead of having undefined
66 * behavior.
67 */
68struct relaxed : ::boost::mpl::vector0<> {};
69
70/**
71 * A metafunction indicating whether @c Concept
72 * includes @ref relaxed.
73 */
74template<class Concept>
75struct is_relaxed :
76 ::boost::mpl::eval_if< ::boost::mpl::is_sequence<Concept>,
77 ::boost::type_erasure::detail::is_relaxed_impl<Concept>,
78 ::boost::mpl::false_
79 >::type
80{};
81
82/** INTERNAL ONLY */
83template<>
84struct is_relaxed< ::boost::type_erasure::relaxed> :
85 ::boost::mpl::true_
86{};
87
88}
89}
90
91#endif
92

source code of boost/libs/type_erasure/include/boost/type_erasure/relaxed.hpp