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 21, 2024
1 parent 4226b02 commit cf7aecf
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions include/yorel/yomm2/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@
#define yOMM2_WHEN_STATIC(CODE1, CODE2) CODE1
#define yOMM2_WHEN_NOT_STATIC(CODE1, CODE2) CODE2

#define yOMM2_OPEN_BRACE {
#define yOMM2_CLOSE_BRACE }

#define yOMM2_SELECTOR(NAME) NAME##_yOMM2_selector_

// Find method given the arguments. We cannot detect if __VAR_ARGS__ is empty,
// so we cannot express the 'method<...>' type directly. Instead, we wrap
// __VAR_ARGS__ in 'types<...>' and use 'method_va_args_first' find the method.

#define yOMM2_method(NAME, ARGS, ...) \
::yorel::yomm2::method<YOMM2_SYMBOL(NAME) ARGS, __VA_ARGS__>

#define YOMM2_DECLARE(NAME, ARGS, ...) \
yOMM2_DECLARE(yOMM2_WHEN_NOT_STATIC, NAME, ARGS, __VA_ARGS__)

Expand All @@ -58,12 +46,13 @@
#define yOMM2_DECLARE(IF_STATIC, NAME, ARGS, ...) \
struct YOMM2_SYMBOL(NAME); \
IF_STATIC(static, ) \
yOMM2_method(NAME, ARGS, __VA_ARGS__) yOMM2_SELECTOR(NAME)( \
BOOST_PP_REPEAT(BOOST_PP_TUPLE_SIZE(ARGS), yOMM2_PLIST, ARGS)); \
::yorel::yomm2::method<YOMM2_SYMBOL(NAME) ARGS, __VA_ARGS__> \
yorel_yomm2_detail_##NAME##_guide( \
BOOST_PP_REPEAT(BOOST_PP_TUPLE_SIZE(ARGS), yOMM2_PLIST, ARGS)); \
IF_STATIC(static, ) \
inline decltype(auto) NAME( \
BOOST_PP_REPEAT(BOOST_PP_TUPLE_SIZE(ARGS), yOMM2_PLIST, ARGS)) { \
return yOMM2_method(NAME, ARGS, __VA_ARGS__)::fn( \
return ::yorel::yomm2::method<YOMM2_SYMBOL(NAME) ARGS, __VA_ARGS__>::fn( \
BOOST_PP_REPEAT(BOOST_PP_TUPLE_SIZE(ARGS), yOMM2_ALIST, ARGS)); \
}

Expand All @@ -79,7 +68,8 @@
struct _yOMM2_select; \
template<typename... A> \
struct _yOMM2_select<void(A...)> { \
using type = decltype(yOMM2_SELECTOR(NAME)(std::declval<A>()...)); \
using type = \
decltype(yorel_yomm2_detail_##NAME##_guide(std::declval<A>()...)); \
}; \
using _yOMM2_method = _yOMM2_select<void ARGS>::type; \
using _yOMM2_return_t = _yOMM2_method::return_type;
Expand Down

0 comments on commit cf7aecf

Please sign in to comment.