From cf7aecf84b6884751f6f3429ce13632a85c87cd7 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leroy Date: Sat, 21 Sep 2024 17:31:33 -0400 Subject: [PATCH] more macro work --- include/yorel/yomm2/macros.hpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/include/yorel/yomm2/macros.hpp b/include/yorel/yomm2/macros.hpp index 99e97a43..7864249a 100644 --- a/include/yorel/yomm2/macros.hpp +++ b/include/yorel/yomm2/macros.hpp @@ -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 - #define YOMM2_DECLARE(NAME, ARGS, ...) \ yOMM2_DECLARE(yOMM2_WHEN_NOT_STATIC, NAME, ARGS, __VA_ARGS__) @@ -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 \ + 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::fn( \ BOOST_PP_REPEAT(BOOST_PP_TUPLE_SIZE(ARGS), yOMM2_ALIST, ARGS)); \ } @@ -79,7 +68,8 @@ struct _yOMM2_select; \ template \ struct _yOMM2_select { \ - using type = decltype(yOMM2_SELECTOR(NAME)(std::declval()...)); \ + using type = \ + decltype(yorel_yomm2_detail_##NAME##_guide(std::declval()...)); \ }; \ using _yOMM2_method = _yOMM2_select::type; \ using _yOMM2_return_t = _yOMM2_method::return_type;