Skip to content

Commit

Permalink
more macro work
Browse files Browse the repository at this point in the history
  • Loading branch information
jll63 committed Sep 22, 2024
1 parent 0e32aee commit f89774a
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions include/yorel/yomm2/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,20 @@
::yorel::yomm2::detail::remove_virtual<BOOST_PP_TUPLE_ELEM(I, A)>>( \
BOOST_PP_CAT(a, I))

#define yOMM2_RLIST(N, I, A) \
BOOST_PP_COMMA_IF(I) \
BOOST_PP_CAT(a, I)

#define yOMM2_WHEN_STATIC(CODE1, CODE2) CODE1
#define yOMM2_WHEN_NOT_STATIC(CODE1, CODE2) CODE2
#define yOMM2_RLIST(N, I, A) BOOST_PP_COMMA_IF(I) BOOST_PP_CAT(a, I)

#define YOMM2_METHOD(NAME, ARGS, ...) \
YOREL_YOMM2_DETAIL_DECLARE(yOMM2_WHEN_NOT_STATIC, NAME, ARGS, __VA_ARGS__)
YOREL_YOMM2_DETAIL_DECLARE(, NAME, ARGS, __VA_ARGS__)

#define YOMM2_STATIC_METHOD(NAME, ARGS, ...) \
YOREL_YOMM2_DETAIL_DECLARE(yOMM2_WHEN_STATIC, NAME, ARGS, __VA_ARGS__)
YOREL_YOMM2_DETAIL_DECLARE(static, NAME, ARGS, __VA_ARGS__)

#define YOREL_YOMM2_DETAIL_DECLARE(IF_STATIC, NAME, ARGS, ...) \
#define YOREL_YOMM2_DETAIL_DECLARE(STATIC, NAME, ARGS, ...) \
struct YOMM2_METHOD_NAME(NAME); \
IF_STATIC(static, ) \
::yorel::yomm2::method<YOMM2_METHOD_NAME(NAME) ARGS, __VA_ARGS__> \
STATIC ::yorel::yomm2::method<YOMM2_METHOD_NAME(NAME) ARGS, __VA_ARGS__> \
BOOST_PP_CAT(YOMM2_METHOD_NAME(NAME), guide_)( \
BOOST_PP_REPEAT(BOOST_PP_TUPLE_SIZE(ARGS), yOMM2_PLIST, ARGS)); \
IF_STATIC(static, ) \
inline decltype(auto) NAME( \
STATIC inline decltype(auto) NAME( \
BOOST_PP_REPEAT(BOOST_PP_TUPLE_SIZE(ARGS), yOMM2_PLIST, ARGS)) { \
return ::yorel::yomm2:: \
method<YOMM2_METHOD_NAME(NAME) ARGS, __VA_ARGS__>::fn( \
Expand All @@ -56,7 +49,7 @@
struct yorel_yomm2_detail_locate_method_aux; \
template<typename... A> \
struct yorel_yomm2_detail_locate_method_aux<void(A...)> { \
using type = decltype(NAME##guide_(std::declval<A>()...)); \
using type = decltype(NAME##guide_(std::declval<A>()...)); \
}; \
using method_type = yorel_yomm2_detail_locate_method_aux<void ARGS>::type;

Expand Down

0 comments on commit f89774a

Please sign in to comment.