Skip to main content
updated to support member functions
Source Link
Fedor
  • 24.1k
  • 43
  • 59
  • 183

As was mentioned in other questions, B::x is a pointer to member of the type int B::*. Your concept can be based on the fact that such pointer cannot be cast to void* unlike normal pointers:

template <typename T>
concept C = requires { static_cast<void*>reinterpret_cast<void*>(&T::x); };

It works with all tested compilers: https://gcc.godbolt.org/z/9q8rG5eeohttps://gcc.godbolt.org/z/nr9ecb564

As was mentioned in other questions, B::x is a pointer to member of the type int B::*. Your concept can be based on the fact that such pointer cannot be cast to void* unlike normal pointers:

template <typename T>
concept C = requires { static_cast<void*>(&T::x); };

It works with all tested compilers: https://gcc.godbolt.org/z/9q8rG5eeo

As was mentioned in other questions, B::x is a pointer to member of the type int B::*. Your concept can be based on the fact that such pointer cannot be cast to void* unlike normal pointers:

template <typename T>
concept C = requires { reinterpret_cast<void*>(&T::x); };

It works with all tested compilers: https://gcc.godbolt.org/z/nr9ecb564

Source Link
Fedor
  • 24.1k
  • 43
  • 59
  • 183

As was mentioned in other questions, B::x is a pointer to member of the type int B::*. Your concept can be based on the fact that such pointer cannot be cast to void* unlike normal pointers:

template <typename T>
concept C = requires { static_cast<void*>(&T::x); };

It works with all tested compilers: https://gcc.godbolt.org/z/9q8rG5eeo