]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/spirit/home/x3/support/traits/variant_find_substitute.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / spirit / home / x3 / support / traits / variant_find_substitute.hpp
CommitLineData
7c673cae
FG
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>
92f5a8d4 12#include <boost/mpl/find.hpp>
7c673cae
FG
13
14namespace boost { namespace spirit { namespace x3 { namespace traits
15{
1e59de90 16 template <typename Variant, typename T>
7c673cae
FG
17 struct variant_find_substitute
18 {
1e59de90
TL
19 // Get the type from the Variant that can be a substitute for T.
20 // If none is found, just return T
7c673cae
FG
21
22 typedef Variant variant_type;
23 typedef typename variant_type::types types;
24 typedef typename mpl::end<types>::type end;
25
1e59de90 26 typedef typename mpl::find<types, T>::type iter_1;
7c673cae
FG
27
28 typedef typename
29 mpl::eval_if<
30 is_same<iter_1, end>,
1e59de90 31 mpl::find_if<types, traits::is_substitute<T, mpl::_1> >,
7c673cae
FG
32 mpl::identity<iter_1>
33 >::type
34 iter;
35
36 typedef typename
37 mpl::eval_if<
38 is_same<iter, end>,
1e59de90 39 mpl::identity<T>,
7c673cae
FG
40 mpl::deref<iter>
41 >::type
42 type;
43 };
44
45 template <typename Variant>
46 struct variant_find_substitute<Variant, Variant>
47 : mpl::identity<Variant> {};
48
49}}}}
50
51#endif