1 // Boost.TypeErasure library
3 // Copyright 2011 Steven Watanabe
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)
11 #ifndef BOOST_TYPE_ERASURE_RELAXED_HPP_INCLUDED
12 #define BOOST_TYPE_ERASURE_RELAXED_HPP_INCLUDED
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>
23 namespace type_erasure {
31 struct is_relaxed_impl :
33 typename ::boost::is_same<
34 typename ::boost::mpl::find_if<
36 ::boost::type_erasure::is_relaxed< ::boost::mpl::_1>
38 typename ::boost::mpl::end<T>::type
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.
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 * - copy assignment of @ref any uses the copy 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
68 struct relaxed : ::boost::mpl::vector0<> {};
71 * A metafunction indicating whether @c Concept
72 * includes @ref relaxed.
74 template<class Concept>
76 ::boost::mpl::eval_if< ::boost::mpl::is_sequence<Concept>,
77 ::boost::type_erasure::detail::is_relaxed_impl<Concept>,
84 struct is_relaxed< ::boost::type_erasure::relaxed> :