1 /*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
3 http://spirit.sourceforge.net/
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
11 #include <boost/spirit/home/x3/support/traits/is_substitute.hpp>
13 namespace boost { namespace spirit { namespace x3 { namespace traits
15 template <typename Variant, typename Attribute>
16 struct variant_find_substitute
18 // Get the type from the variant that can be a substitute for Attribute.
19 // If none is found, just return Attribute
21 typedef Variant variant_type;
22 typedef typename variant_type::types types;
23 typedef typename mpl::end<types>::type end;
26 mpl::find_if<types, is_same<mpl::_1, Attribute> >::type
32 mpl::find_if<types, traits::is_substitute<mpl::_1, Attribute> >,
40 mpl::identity<Attribute>,
46 template <typename Variant>
47 struct variant_find_substitute<Variant, Variant>
48 : mpl::identity<Variant> {};