1 /*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
3 Copyright (c) 2001-2012 Hartmut Kaiser
4 http://spirit.sourceforge.net/
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #if !defined(BOOST_SPIRIT_X3_MAKE_ATTRIBUTE_JAN_8_2012_0721PM)
10 #define BOOST_SPIRIT_X3_MAKE_ATTRIBUTE_JAN_8_2012_0721PM
12 #include <boost/mpl/if.hpp>
13 #include <boost/type_traits/remove_const.hpp>
14 #include <boost/type_traits/add_reference.hpp>
15 #include <boost/spirit/home/x3/support/unused.hpp>
17 namespace boost { namespace spirit { namespace x3 { namespace traits
19 template <typename Attribute>
20 struct make_attribute_base
22 static Attribute call(unused_type)
24 // synthesize the attribute/parameter
29 static T& call(T& value)
31 return value; // just pass the one provided
35 template <typename Attribute, typename ActualAttribute>
36 struct make_attribute : make_attribute_base<Attribute>
38 typedef ActualAttribute& type;
39 typedef ActualAttribute value_type;
42 template <typename Attribute>
43 struct make_attribute<Attribute, unused_type>
44 : make_attribute_base<Attribute>
46 typedef typename remove_const<Attribute>::type attribute_type;
47 typedef attribute_type type;
48 typedef attribute_type value_type;
51 template <typename Attribute, typename ActualAttribute>
52 struct make_attribute<Attribute&, ActualAttribute>
53 : make_attribute<Attribute, ActualAttribute> {};
55 template <typename Attribute, typename ActualAttribute>
56 struct make_attribute<Attribute const&, ActualAttribute>
57 : make_attribute<Attribute const, ActualAttribute> {};
59 template <typename ActualAttribute>
60 struct make_attribute<unused_type, ActualAttribute>
62 typedef unused_type type;
63 typedef unused_type value_type;
64 static unused_type call(unused_type)
71 struct make_attribute<unused_type, unused_type>
73 typedef unused_type type;
74 typedef unused_type value_type;
75 static unused_type call(unused_type)