Created
March 15, 2022 06:23
-
-
Save cppcooper/9b96a3164c3f658a4150ebd8391afdbe to your computer and use it in GitHub Desktop.
member detection with templates/macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#define DECLARE_HASA(what) \ | |
template<typename T, typename = int> struct has_##what : std::false_type { };\ | |
template<typename T> struct has_##what<T, decltype((void) T::what, 0)> : std::true_type {}; | |
DECLARE_HASA(when) //declares above statement with 'when' replacing 'what' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment