1 | |
2 | // (C) Copyright Tobias Schwinger |
3 | // |
4 | // Use modification and distribution are subject to the boost Software License, |
5 | // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt). |
6 | |
7 | //------------------------------------------------------------------------------ |
8 | |
9 | #ifndef BOOST_FT_DETAIL_TAGS_HPP_INCLUDED |
10 | #define BOOST_FT_DETAIL_TAGS_HPP_INCLUDED |
11 | |
12 | #include <cstddef> |
13 | |
14 | #include <boost/type_traits/integral_constant.hpp> |
15 | #include <boost/mpl/bitxor.hpp> |
16 | |
17 | |
18 | namespace boost { namespace function_types { |
19 | |
20 | namespace detail |
21 | { |
22 | typedef long bits_t; |
23 | |
24 | template<bits_t Value> struct constant |
25 | : boost::integral_constant<bits_t,Value> |
26 | { }; |
27 | |
28 | template<bits_t Bits, bits_t Mask> struct property_tag |
29 | { |
30 | typedef constant<Bits> bits; |
31 | typedef constant<Mask> mask; |
32 | }; |
33 | |
34 | template<typename T> struct bits : T::bits { }; |
35 | template<typename T> struct mask : T::mask { }; |
36 | |
37 | // forward declaration, defined in pp_tags |
38 | template<bits_t Bits, bits_t CCID> struct encode_bits_impl; |
39 | |
40 | // forward declaration, defined in pp_tags |
41 | template<bits_t LHS_bits, bits_t LHS_mask, |
42 | bits_t RHS_bits, bits_t RHS_mask> |
43 | struct tag_ice; |
44 | |
45 | // forward declaration, defined in retag_default_cc |
46 | template<class Tag, class RegTag = Tag> struct retag_default_cc; |
47 | |
48 | template<bits_t Bits, bits_t CCID> struct encode_bits |
49 | : constant< |
50 | ::boost::function_types::detail::encode_bits_impl<Bits,CCID>::value |
51 | > |
52 | { }; |
53 | |
54 | template<class LHS, class RHS> struct compound_tag |
55 | { |
56 | typedef constant< |
57 | ::boost::function_types::detail::tag_ice |
58 | < ::boost::function_types::detail::bits<LHS>::value |
59 | , ::boost::function_types::detail::mask<LHS>::value |
60 | , ::boost::function_types::detail::bits<RHS>::value |
61 | , ::boost::function_types::detail::mask<RHS>::value |
62 | >::combined_bits |
63 | > bits; |
64 | |
65 | typedef constant< |
66 | ::boost::function_types::detail::tag_ice |
67 | < ::boost::function_types::detail::bits<LHS>::value |
68 | , ::boost::function_types::detail::mask<LHS>::value |
69 | , ::boost::function_types::detail::bits<RHS>::value |
70 | , ::boost::function_types::detail::mask<RHS>::value |
71 | >::combined_mask |
72 | > mask; |
73 | }; |
74 | |
75 | template <class Base, class PropOld, class PropNew> |
76 | struct changed_tag |
77 | : Base |
78 | { |
79 | typedef mpl::bitxor_ |
80 | <typename Base::bits, typename PropOld::bits, typename PropNew::bits> |
81 | bits; |
82 | }; |
83 | |
84 | template<class Tag, class QueryTag> struct represents_impl |
85 | : boost::integral_constant<bool, |
86 | ::boost::function_types::detail::tag_ice |
87 | < ::boost::function_types::detail::bits<Tag>::value |
88 | , ::boost::function_types::detail::mask<Tag>::value |
89 | , ::boost::function_types::detail::bits<QueryTag>::value |
90 | , ::boost::function_types::detail::mask<QueryTag>::value |
91 | >::match |
92 | > |
93 | { }; |
94 | |
95 | } // namespace detail |
96 | |
97 | typedef detail::property_tag<0,0> null_tag; |
98 | |
99 | template<class Tag1, class Tag2, class Tag3 = null_tag, class Tag4 = null_tag> |
100 | struct tag |
101 | : detail::compound_tag< detail::compound_tag<Tag1,Tag2>, |
102 | detail::compound_tag<Tag3,Tag4> > |
103 | { }; |
104 | |
105 | template<class Tag1, class Tag2, class Tag3> struct tag<Tag1,Tag2,Tag3,null_tag> |
106 | : detail::compound_tag<detail::compound_tag<Tag1,Tag2>,Tag3> |
107 | { }; |
108 | template<class Tag1, class Tag2> struct tag<Tag1,Tag2,null_tag,null_tag> |
109 | : detail::compound_tag<Tag1,Tag2> |
110 | { }; |
111 | template<class Tag1> struct tag<Tag1,null_tag,null_tag,null_tag> |
112 | : Tag1 |
113 | { }; |
114 | |
115 | |
116 | template<class Tag, class QueryTag> struct represents |
117 | : detail::represents_impl<Tag, detail::retag_default_cc<QueryTag,Tag> > |
118 | { }; |
119 | |
120 | |
121 | template<class Tag, class QueryTag> struct |
122 | { |
123 | typedef detail::constant< |
124 | ::boost::function_types::detail::tag_ice |
125 | < ::boost::function_types::detail::bits<Tag>::value |
126 | , ::boost::function_types::detail::mask<Tag>::value |
127 | , ::boost::function_types::detail::bits<QueryTag>::value |
128 | , ::boost::function_types::detail::mask<QueryTag>::value |
129 | >::extracted_bits |
130 | > ; |
131 | |
132 | typedef detail::constant< |
133 | ::boost::function_types::detail::mask<QueryTag>::value |
134 | > ; |
135 | }; |
136 | |
137 | } } // namespace ::boost::function_types |
138 | |
139 | #include <boost/function_types/detail/pp_tags/preprocessed.hpp> |
140 | |
141 | namespace boost { namespace function_types { |
142 | #define BOOST_FT_cc_file <boost/function_types/detail/pp_tags/cc_tag.hpp> |
143 | #include <boost/function_types/detail/pp_loop.hpp> |
144 | } } // namespace boost::function_types |
145 | |
146 | #endif |
147 | |
148 | |