Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:02:38

0001 /*=============================================================================
0002     Copyright (c) 2001-2014 Joel de Guzman
0003     http://spirit.sourceforge.net/
0004 
0005     Distributed under the Boost Software License, Version 1.0. (See accompanying
0006     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 =============================================================================*/
0008 #if !defined(BOOST_SPIRIT_X3_VARIANT_FIND_SUBSTITUTE_APR_18_2014_930AM)
0009 #define BOOST_SPIRIT_X3_VARIANT_FIND_SUBSTITUTE_APR_18_2014_930AM
0010 
0011 #include <boost/spirit/home/x3/support/traits/is_substitute.hpp>
0012 #include <boost/mpl/find.hpp>
0013 
0014 namespace boost { namespace spirit { namespace x3 { namespace traits
0015 {
0016     template <typename Variant, typename T>
0017     struct variant_find_substitute
0018     {
0019         // Get the type from the Variant that can be a substitute for T.
0020         // If none is found, just return T
0021 
0022         typedef Variant variant_type;
0023         typedef typename variant_type::types types;
0024         typedef typename mpl::end<types>::type end;
0025 
0026         typedef typename mpl::find<types, T>::type iter_1;
0027 
0028         typedef typename
0029             mpl::eval_if<
0030                 is_same<iter_1, end>,
0031                 mpl::find_if<types, traits::is_substitute<T, mpl::_1> >,
0032                 mpl::identity<iter_1>
0033             >::type
0034         iter;
0035 
0036         typedef typename
0037             mpl::eval_if<
0038                 is_same<iter, end>,
0039                 mpl::identity<T>,
0040                 mpl::deref<iter>
0041             >::type
0042         type;
0043     };
0044     
0045     template <typename Variant>
0046     struct variant_find_substitute<Variant, Variant>
0047         : mpl::identity<Variant> {};
0048 
0049 }}}}
0050 
0051 #endif