File indexing completed on 2025-01-31 10:02:38
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_SPIRIT_X3_SUPPORT_TRAITS_ATTRIBUTE_OF_BINARY
0008 #define BOOST_SPIRIT_X3_SUPPORT_TRAITS_ATTRIBUTE_OF_BINARY
0009
0010 #include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
0011 #include <boost/spirit/home/x3/support/unused.hpp>
0012 #include <boost/type_traits/type_identity.hpp>
0013
0014 namespace boost { namespace spirit { namespace x3 { namespace detail
0015 {
0016 template <typename... T>
0017 struct type_sequence
0018 {
0019 using type = type_sequence;
0020
0021 static const int size = sizeof...(T);
0022
0023 template <typename... U>
0024 using append = type_sequence<T..., U...>;
0025
0026 template <typename... U>
0027 using prepend = type_sequence<U..., T...>;
0028
0029 template <typename U>
0030 using extend = typename U::template prepend<T...>;
0031
0032 template <template <typename...> class U>
0033 using transfer_to = U<T...>;
0034 };
0035
0036 template <typename Attribute>
0037 struct types_of_binary_init : type_sequence<Attribute> {};
0038 template <>
0039 struct types_of_binary_init<unused_type> : type_sequence<> {};
0040 template <>
0041 struct types_of_binary_init<unused_type const> : type_sequence<> {};
0042
0043 template <template <typename, typename> class B, typename P, typename C>
0044 struct get_types_of_binary
0045 : types_of_binary_init<typename traits::attribute_of<P, C>::type> {};
0046 template <template <typename, typename> class B, typename L, typename R, typename C>
0047 struct get_types_of_binary<B, B<L, R>, C>
0048 : get_types_of_binary<B, L, C>::template extend<get_types_of_binary<B, R, C>> {};
0049
0050 template <template <typename...> class A, typename T, int = T::size>
0051 struct type_sequence_to_attribute { using type = typename T::template transfer_to<A>; };
0052 template <template <typename...> class A, typename T>
0053 struct type_sequence_to_attribute<A, T, 1> : T::template transfer_to<type_identity> {};
0054 template <template <typename...> class A, typename T>
0055 struct type_sequence_to_attribute<A, T, 0> { using type = unused_type; };
0056
0057 template <template <typename...> class A, template <typename, typename> class B,
0058 typename L, typename R, typename C>
0059 using attribute_of_binary = type_sequence_to_attribute<A,
0060 typename get_types_of_binary<B, B<L, R>, C>::type>;
0061 }}}}
0062 #endif