##// END OF EJS Templates
[CPP utils] Added function alias macro...
jeandet -
r39:cc47cd67a7b3
parent child
Show More
@@ -1,21 +1,29
1 1 #ifndef CPP_UTILS_H
2 2 #define CPP_UTILS_H
3 3
4 4 #include <type_traits>
5 5
6 6 template< class... >
7 7 using void_t = void;
8 8
9 9 #define HAS_METHOD(method)\
10 10 template <class T, class=void>\
11 11 struct _has_##method : std::false_type{};\
12 12 \
13 13 template <class T>\
14 14 struct _has_##method<T, void_t<std::is_member_function_pointer<decltype(&T::method)>>>\
15 15 : std::true_type{};\
16 16 \
17 17 template< class T>\
18 18 static inline constexpr bool has_##method = _has_##method<T>::value;
19 19
20 //taken from here https://www.fluentcpp.com/2017/10/27/function-aliases-cpp/
21 #define ALIAS_TEMPLATE_FUNCTION(highLevelF, lowLevelF) \
22 template <typename... Args> \
23 inline auto highLevelF(Args &&... args)->decltype(lowLevelF(std::forward<Args>(args)...)) \
24 { \
25 return lowLevelF(std::forward<Args>(args)...); \
26 }
27
20 28
21 29 #endif // CPP_UTILS_H
General Comments 0
You need to be logged in to leave comments. Login now