brintos

brintos / llvm-project-archived public Read only

0
0
Text · 924 B · 4d66700 Raw
32 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s2 3template <typename T1, typename T2> struct is_same {4  static constexpr bool value = false;5};6 7template <typename T> struct is_same<T, T> {8  static constexpr bool value = true;9};10 11template <class T, class U>12concept SameHelper = is_same<T, U>::value;13template <class T, class U>14concept same_as = SameHelper<T, U> && SameHelper<U, T>;15 16namespace deferred_instantiation {17template <class X> constexpr X do_not_instantiate() { return nullptr; }18 19struct T {20  template <same_as<float> X> explicit(do_not_instantiate<X>()) T(X) {}21 22  T(int) {}23};24 25T 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}}30T t2(5.0f);31} // namespace deferred_instantiation32