File indexing completed on 2025-01-19 09:47:55
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_SPIRIT_MODIFY_OCTOBER_25_2008_0142PM
0009 #define BOOST_SPIRIT_MODIFY_OCTOBER_25_2008_0142PM
0010
0011 #if defined(_MSC_VER)
0012 #pragma once
0013 #endif
0014
0015 #include <boost/type_traits/is_base_of.hpp>
0016 #include <boost/spirit/home/support/unused.hpp>
0017
0018 namespace boost { namespace spirit
0019 {
0020 template <typename Domain, typename T, typename Enable = void>
0021 struct is_modifier_directive;
0022
0023
0024
0025 template <typename Modifiers, typename T>
0026 struct has_modifier
0027 : is_base_of<T, Modifiers> {};
0028
0029
0030 template <typename Current, typename New, typename Enable = void>
0031 struct compound_modifier : Current, New
0032 {
0033 compound_modifier()
0034 : Current(), New() {}
0035
0036 compound_modifier(Current const& current, New const& new_)
0037 : Current(current), New(new_) {}
0038 };
0039
0040
0041 template <typename Current, typename New>
0042 struct compound_modifier<
0043 Current, New, typename enable_if<has_modifier<Current, New> >::type>
0044 : Current
0045 {
0046 compound_modifier()
0047 : Current() {}
0048
0049 compound_modifier(Current const& current, New const&)
0050 : Current(current) {}
0051 };
0052
0053
0054 template <typename New, typename Enable>
0055 struct compound_modifier<unused_type, New, Enable> : New
0056 {
0057 compound_modifier()
0058 : New() {}
0059
0060 compound_modifier(unused_type, New const& new_)
0061 : New(new_) {}
0062 };
0063
0064
0065
0066
0067
0068 template <typename Domain, typename Enable = void>
0069 struct modify
0070 {
0071 typedef void proto_is_callable_;
0072
0073 template <typename Sig>
0074 struct result;
0075
0076 template <typename This, typename Tag, typename Modifiers>
0077 struct result<This(Tag, Modifiers)>
0078 {
0079 typedef typename remove_const<
0080 typename remove_reference<Tag>::type>::type
0081 tag_type;
0082 typedef typename remove_const<
0083 typename remove_reference<Modifiers>::type>::type
0084 modifiers_type;
0085
0086 typedef typename mpl::if_<
0087 is_modifier_directive<Domain, tag_type>
0088 , compound_modifier<modifiers_type, tag_type>
0089 , Modifiers>::type
0090 type;
0091 };
0092
0093 template <typename Tag, typename Modifiers>
0094 typename result<modify(Tag, Modifiers)>::type
0095 operator()(Tag tag, Modifiers modifiers) const
0096 {
0097 return op(tag, modifiers, is_modifier_directive<Domain, Tag>());
0098 }
0099
0100 template <typename Tag, typename Modifiers>
0101 Modifiers
0102 op(Tag , Modifiers modifiers, mpl::false_) const
0103 {
0104 return modifiers;
0105 }
0106
0107 template <typename Tag, typename Modifiers>
0108 compound_modifier<Modifiers, Tag>
0109 op(Tag tag, Modifiers modifiers, mpl::true_) const
0110 {
0111 return compound_modifier<Modifiers, Tag>(modifiers, tag);
0112 }
0113 };
0114 }}
0115
0116 #endif