]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/x3/support/traits/variant_find_substitute.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / x3 / support / traits / variant_find_substitute.hpp
1 /*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
3 http://spirit.sourceforge.net/
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8 #if !defined(BOOST_SPIRIT_X3_VARIANT_FIND_SUBSTITUTE_APR_18_2014_930AM)
9 #define BOOST_SPIRIT_X3_VARIANT_FIND_SUBSTITUTE_APR_18_2014_930AM
10
11 #include <boost/spirit/home/x3/support/traits/is_substitute.hpp>
12
13 namespace boost { namespace spirit { namespace x3 { namespace traits
14 {
15 template <typename Variant, typename Attribute>
16 struct variant_find_substitute
17 {
18 // Get the type from the variant that can be a substitute for Attribute.
19 // If none is found, just return Attribute
20
21 typedef Variant variant_type;
22 typedef typename variant_type::types types;
23 typedef typename mpl::end<types>::type end;
24
25 typedef typename
26 mpl::find_if<types, is_same<mpl::_1, Attribute> >::type
27 iter_1;
28
29 typedef typename
30 mpl::eval_if<
31 is_same<iter_1, end>,
32 mpl::find_if<types, traits::is_substitute<mpl::_1, Attribute> >,
33 mpl::identity<iter_1>
34 >::type
35 iter;
36
37 typedef typename
38 mpl::eval_if<
39 is_same<iter, end>,
40 mpl::identity<Attribute>,
41 mpl::deref<iter>
42 >::type
43 type;
44 };
45
46 template <typename Variant>
47 struct variant_find_substitute<Variant, Variant>
48 : mpl::identity<Variant> {};
49
50 }}}}
51
52 #endif