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_HAS_SUBSTITUTE_APR_18_2014_925AM)
9 #define BOOST_SPIRIT_X3_VARIANT_HAS_SUBSTITUTE_APR_18_2014_925AM
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_has_substitute_impl
18 // Find a type from the variant that can be a substitute for Attribute.
19 // return true_ if one is found, else false_
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>>,
37 typedef mpl::not_<is_same<iter, end>> type;
40 template <typename Variant, typename Attribute>
41 struct variant_has_substitute
42 : variant_has_substitute_impl<Variant, Attribute>::type {};
44 template <typename Attribute>
45 struct variant_has_substitute<unused_type, Attribute> : mpl::true_ {};
47 template <typename Attribute>
48 struct variant_has_substitute<unused_type const, Attribute> : mpl::true_ {};