Implementing the Linux Kernel's __is_constexpr (ICE_P) macro in pure C++
问题 After reading about the standard C11 version of Martin Uecker's ICE_P predicate, I tried to implement it in pure C++. The C11 version, making use of _Generic selection is as follows: #define ICE_P(x) _Generic((1? (void *) ((x)*0) : (int *) 0), int*: 1, void*: 0) The obvious approach for C++ is to replace _Generic by a template and decltype , such as: template<typename T> struct is_ice_helper; template<> struct is_ice_helper<void*> { enum { value = false }; }; template<> struct is_ice_helper