Debian Codegraph @

gcc/testsuite/g++.dg/template/builtin-speculation-overloads1.C

raw
1 /* Check that overloaded builtins can be used in templates with SFINAE. */
2 // { dg-do compile { target c++17 } }
3 // { dg-additional-options "-Dtrue_def=true" { target speculation_barrier_defined } }
4 // { dg-additional-options "-Dtrue_def=false" { target { ! speculation_barrier_defined } } }
5
6 /* Checks performed here:
7 Various types (some that work, some that don't). */
8 #define SFINAE_TYPE_CHECK(PARAMS, SHORTENED_PARAMS, INVALID_PARAMS) \
9 template <typename T, typename = void> \
10 struct is_available : std::false_type {}; \
11 template <typename T> \
12 struct is_available<T, \
13 std::void_t<decltype(__builtin_speculation_safe_value PARAMS) >> \
14 : std::true_type {};
15
16 /* Success according to type of argument. */
17 #define MAKE_SPECULATION_ASSERT(TYPE, SUCCESS) \
18 static_assert(is_available<TYPE>::value == SUCCESS);
19
20 #include "builtin-speculation-overloads.def"