| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s |
| 2 |
|
| 3 |
template <typename T1, typename T2> struct is_same { |
| 4 |
static constexpr bool value = false; |
| 5 |
}; |
| 6 |
|
| 7 |
template <typename T> struct is_same<T, T> { |
| 8 |
static constexpr bool value = true; |
| 9 |
}; |
| 10 |
|
| 11 |
template <class T, class U> |
| 12 |
concept SameHelper = is_same<T, U>::value; |
| 13 |
template <class T, class U> |
| 14 |
concept same_as = SameHelper<T, U> && SameHelper<U, T>; |
| 15 |
|
| 16 |
namespace deferred_instantiation { |
| 17 |
template <class X> constexpr X do_not_instantiate() { return nullptr; } |
| 18 |
|
| 19 |
struct T { |
| 20 |
template <same_as<float> X> explicit(do_not_instantiate<X>()) T(X) {} |
| 21 |
|
| 22 |
T(int) {} |
| 23 |
}; |
| 24 |
|
| 25 |
T t(5); |
| 26 |
// expected-error@17{{cannot initialize}} |
| 27 |
// expected-note@20{{in instantiation of function template specialization}} |
| 28 |
// expected-note@30{{while substituting deduced template arguments}} |
| 29 |
// expected-note@30{{in instantiation of function template specialization}} |
| 30 |
T t2(5.0f); |
| 31 |
} // namespace deferred_instantiation |