Skip to content

Commit

Permalink
Use BOOST_PP_VARIADIC_SIZE instead of custom implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Feb 8, 2022
1 parent ee3d3bd commit 56fe97a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 110 deletions.
111 changes: 2 additions & 109 deletions include/turtle/constraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/stringize.hpp>
#include <boost/preprocessor/variadic/to_array.hpp>
#include <boost/preprocessor/variadic/size.hpp>
#include <functional>
#include <type_traits>

Expand Down Expand Up @@ -178,118 +178,11 @@ const constraint<detail::not_<Constraint>> operator!(const constraint<Constraint
#define MOCK_CONSTRAINT_EXT(Name, n, Args, Expr) \
BOOST_PP_IF(n, MOCK_NARY_CONSTRAINT, MOCK_UNARY_CONSTRAINT)(Name, n, Args, Expr)

#ifdef BOOST_MSVC
# define MOCK_VARIADIC_SIZE(...) \
BOOST_PP_CAT(MOCK_VARIADIC_SIZE_I(__VA_ARGS__, \
32, \
31, \
30, \
29, \
28, \
27, \
26, \
25, \
24, \
23, \
22, \
21, \
20, \
19, \
18, \
17, \
16, \
15, \
14, \
13, \
12, \
11, \
10, \
9, \
8, \
7, \
6, \
5, \
4, \
3, \
2, \
1, ), )
#else // BOOST_MSVC
# define MOCK_VARIADIC_SIZE(...) \
MOCK_VARIADIC_SIZE_I(__VA_ARGS__, \
32, \
31, \
30, \
29, \
28, \
27, \
26, \
25, \
24, \
23, \
22, \
21, \
20, \
19, \
18, \
17, \
16, \
15, \
14, \
13, \
12, \
11, \
10, \
9, \
8, \
7, \
6, \
5, \
4, \
3, \
2, \
1, )
#endif // BOOST_MSVC
#define MOCK_VARIADIC_SIZE_I(e0, \
e1, \
e2, \
e3, \
e4, \
e5, \
e6, \
e7, \
e8, \
e9, \
e10, \
e11, \
e12, \
e13, \
e14, \
e15, \
e16, \
e17, \
e18, \
e19, \
e20, \
e21, \
e22, \
e23, \
e24, \
e25, \
e26, \
e27, \
e28, \
e29, \
e30, \
e31, \
size, \
...) \
size

#define MOCK_CONSTRAINT_AUX_AUX(Name, n, Array) \
MOCK_CONSTRAINT_EXT(Name, n, BOOST_PP_ARRAY_TO_TUPLE(BOOST_PP_ARRAY_POP_BACK(Array)), BOOST_PP_ARRAY_ELEM(n, Array))

#define MOCK_CONSTRAINT_AUX(Name, Size, Tuple) MOCK_CONSTRAINT_AUX_AUX(Name, BOOST_PP_DEC(Size), (Size, Tuple))

#define MOCK_CONSTRAINT(Name, ...) MOCK_CONSTRAINT_AUX(Name, MOCK_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))
#define MOCK_CONSTRAINT(Name, ...) MOCK_CONSTRAINT_AUX(Name, BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))

#endif // MOCK_CONSTRAINT_HPP_INCLUDED
2 changes: 1 addition & 1 deletion include/turtle/detail/function_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ namespace mock { namespace detail {
wrapper& in(sequence& s0, MockSequences&... s)
{
using expander = int[];
(void)expander{ (e_->add(s0), 0), (e_->add(s), 0)... };
(void)expander{ (this->e_->add(s0), 0), (this->e_->add(s), 0)... };
return *this;
}

Expand Down

0 comments on commit 56fe97a

Please sign in to comment.