#ifndef CPP_UTILS_H #define CPP_UTILS_H #include #include #include template using void_t = void; #define HAS_METHOD(method) \ template struct _has_##method : std::false_type \ {}; \ \ template \ struct _has_##method< \ T, void_t>> \ : std::true_type \ {}; \ \ template \ static inline constexpr bool has_##method = _has_##method::value; // taken from here https://www.fluentcpp.com/2017/10/27/function-aliases-cpp/ #define ALIAS_TEMPLATE_FUNCTION(highLevelF, lowLevelF) \ template \ inline auto highLevelF(Args&&... args) \ ->decltype(lowLevelF(std::forward(args)...)) \ { \ return lowLevelF(std::forward(args)...); \ } template constexpr T diff(const std::pair& p) { return p.second - p.first; } #endif // CPP_UTILS_H