#include /* Use std::remove_pointer_t here in order to make `int *` fail when using the INVALID_PARAMETERS block. Pointers of two different types are allowed in __builtin_speculation_safe_value, it's one argument of a pointer and another argument that is not a pointer that give errors. */ #define SPECULATION_SFINAES \ SFINAE_TYPE_CHECK ((std::declval (), std::declval ()), \ (std::declval ()), \ (std::declval> (), std::declval ())) SPECULATION_SFINAES class X{}; class Large { public: int arr[10]; }; class Incomplete; /* Using `true_def` in order to account for the fact that if this target * doesn't support __builtin_speculation_safe_value at all everything fails to * substitute. */ #define SPECULATION_ASSERTS \ MAKE_SPECULATION_ASSERT (int, true_def) \ MAKE_SPECULATION_ASSERT (float, false) \ MAKE_SPECULATION_ASSERT (X, false) \ MAKE_SPECULATION_ASSERT (Large, false) \ MAKE_SPECULATION_ASSERT (Incomplete, false) \ MAKE_SPECULATION_ASSERT (int *, true_def) \ MAKE_SPECULATION_ASSERT (long, true_def) int main() { SPECULATION_ASSERTS return 0; }