@@ -1,21 +1,29 | |||||
1 | #ifndef CPP_UTILS_H |
|
1 | #ifndef CPP_UTILS_H | |
2 | #define CPP_UTILS_H |
|
2 | #define CPP_UTILS_H | |
3 |
|
3 | |||
4 | #include <type_traits> |
|
4 | #include <type_traits> | |
5 |
|
5 | |||
6 | template< class... > |
|
6 | template< class... > | |
7 | using void_t = void; |
|
7 | using void_t = void; | |
8 |
|
8 | |||
9 | #define HAS_METHOD(method)\ |
|
9 | #define HAS_METHOD(method)\ | |
10 | template <class T, class=void>\ |
|
10 | template <class T, class=void>\ | |
11 | struct _has_##method : std::false_type{};\ |
|
11 | struct _has_##method : std::false_type{};\ | |
12 | \ |
|
12 | \ | |
13 | template <class T>\ |
|
13 | template <class T>\ | |
14 | struct _has_##method<T, void_t<std::is_member_function_pointer<decltype(&T::method)>>>\ |
|
14 | struct _has_##method<T, void_t<std::is_member_function_pointer<decltype(&T::method)>>>\ | |
15 | : std::true_type{};\ |
|
15 | : std::true_type{};\ | |
16 | \ |
|
16 | \ | |
17 | template< class T>\ |
|
17 | template< class T>\ | |
18 | static inline constexpr bool has_##method = _has_##method<T>::value; |
|
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 | #endif // CPP_UTILS_H |
|
29 | #endif // CPP_UTILS_H |
General Comments 0
You need to be logged in to leave comments.
Login now