16
16
#include < stdexcept>
17
17
#include < string>
18
18
#include < string_view>
19
+ #include < tuple>
19
20
#include < utility>
20
21
#include < vector>
21
22
22
- #include < boost/fusion/container/generation/make_cons.hpp>
23
- #include < boost/fusion/include/make_cons.hpp>
24
- #include < boost/fusion/container/list.hpp>
25
- #include < boost/fusion/include/list.hpp>
26
- #include < boost/fusion/algorithm/transformation/join.hpp>
27
- #include < boost/fusion/include/join.hpp>
28
- #include < boost/fusion/sequence/io.hpp>
29
- #include < boost/fusion/include/io.hpp>
30
- #include < boost/fusion/sequence/intrinsic/at.hpp>
31
- #include < boost/fusion/include/at.hpp>
32
- #include < boost/fusion/container/list/convert.hpp>
33
- #include < boost/fusion/include/as_list.hpp>
34
- #include < boost/algorithm/string.hpp>
35
- #include < boost/function_types/function_type.hpp>
36
- #include < boost/fusion/functional/invocation/invoke.hpp>
37
- #include < boost/functional/factory.hpp>
38
-
39
23
namespace match {
40
24
41
- using boost::fusion::list;
42
- using boost::fusion::join;
43
- using boost::fusion::make_cons;
44
- using boost::fusion::as_list;
45
- namespace result_of = boost::fusion::result_of;
25
+ template <typename ... input_t >
26
+ using tuple_cat_t = decltype(std::tuple_cat(std::declval<input_t >()...));
46
27
47
28
// iterates over the split up parts of the item being matched.
48
29
using part_iterator = std::vector<std::string_view>::const_iterator;
@@ -93,20 +74,18 @@ template <typename Self> struct ops {
93
74
template <typename LeftType, typename RightType>
94
75
struct match_and : public ops <match_and<LeftType, RightType> > {
95
76
96
- using match_type = typename result_of::as_list<typename result_of::join<
97
- typename LeftType::match_type,
98
- typename RightType::match_type>::type>::type;
77
+ using match_type = tuple_cat_t <typename LeftType::match_type, typename RightType::match_type>;
99
78
100
79
match_and (const LeftType &l, const RightType &r) : lhs(l), rhs(r) {}
101
80
102
81
std::pair<match_type, bool > match (part_iterator &begin, const part_iterator &end) const {
103
82
auto [ lval, lerror ] = lhs.match (begin, end);
104
83
if (lerror)
105
- return {as_list ( join ( typename LeftType::match_type (), typename RightType::match_type () )), true };
84
+ return {std::tuple_cat ( typename LeftType::match_type (), typename RightType::match_type ()), true };
106
85
auto [ rval, rerror ] = rhs.match (begin, end);
107
86
if (rerror)
108
- return {as_list ( join ( typename LeftType::match_type (), typename RightType::match_type () )), true };
109
- return {as_list ( join ( lval, rval) ), false };
87
+ return {std::tuple_cat ( typename LeftType::match_type (), typename RightType::match_type ()), true };
88
+ return {std::tuple_cat ( lval, rval), false };
110
89
}
111
90
112
91
private:
@@ -119,7 +98,7 @@ struct match_and : public ops<match_and<LeftType, RightType> > {
119
98
*/
120
99
struct match_string : public ops <match_string> {
121
100
// doesn't return anything, simply fails if the string doesn't match.
122
- using match_type = list <>;
101
+ using match_type = std::tuple <>;
123
102
124
103
// implicit constructor intended, so that the use of this class is
125
104
// hidden and easier / nicer to read.
@@ -138,7 +117,7 @@ struct match_string : public ops<match_string> {
138
117
* match an OSM ID, returning it in the match tuple.
139
118
*/
140
119
struct match_osm_id : public ops <match_osm_id> {
141
- using match_type = list <osm_nwr_id_t >;
120
+ using match_type = std::tuple <osm_nwr_id_t >;
142
121
match_osm_id () = default ;
143
122
std::pair<match_type, bool > match (part_iterator &begin, const part_iterator &end) const noexcept ;
144
123
};
@@ -149,7 +128,7 @@ struct match_osm_id : public ops<match_osm_id> {
149
128
* without needing explicit constructors for the string literal matches.
150
129
*/
151
130
struct match_begin : public ops <match_begin> {
152
- using match_type = list <>;
131
+ using match_type = std::tuple <>;
153
132
match_begin () = default ;
154
133
inline std::pair<match_type, bool > match (part_iterator &begin, const part_iterator &end) const noexcept {
155
134
return {match_type (), false };
0 commit comments