diff options
Diffstat (limited to 'test/CXX/over/over.match')
-rw-r--r-- | test/CXX/over/over.match/over.match.best/p1.cpp | 6 | ||||
-rw-r--r-- | test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp | 68 |
2 files changed, 68 insertions, 6 deletions
diff --git a/test/CXX/over/over.match/over.match.best/p1.cpp b/test/CXX/over/over.match/over.match.best/p1.cpp index fad5bf9a72ee..a933f62a3061 100644 --- a/test/CXX/over/over.match/over.match.best/p1.cpp +++ b/test/CXX/over/over.match/over.match.best/p1.cpp @@ -25,13 +25,13 @@ namespace deduction_guide_example { // FIXME: The standard's example is wrong; we add a remove_ref<...> here to // fix it. - template<typename T, int N = remove_ref<T>::value> A(T&&, int*) -> A<T>; + template<typename T, int N = remove_ref<T>::value> A(T&&, int*) -> A<T**>; A a{1, 0}; extern A<int> a; - A b{a, 0}; + A b{a, 0}; // uses the implicit ctor that is more specialized A<int> *pa = &a; - A<A<int>&> *pb = &b; + A<int> *pb = &b; } // Partial ordering of function template specializations will be tested diff --git a/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp b/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp index fe1b6a63d75b..cb9541caaddd 100644 --- a/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp +++ b/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp @@ -6,9 +6,10 @@ namespace Explicit { template<typename T> struct A { A(T); A(T*); + A(...); }; template<typename T> A(T) -> A<T>; - template<typename T> explicit A(T*) -> A<T>; // expected-note {{explicit}} + template<typename T> explicit A(T*) -> A<T**>; // expected-note {{explicit}} int *p; A a(p); @@ -16,10 +17,71 @@ namespace Explicit { A c{p}; A d = {p}; // expected-error {{selected an explicit deduction guide}} - using X = A<int>; - using Y = A<int*>; + using X = A<int**>; + using Y = A<int>; // uses the implicit guide, being more specialized than the eligible user-defined deduction guides. using X = decltype(a); using Y = decltype(b); using X = decltype(c); } + + +namespace std { + template<typename T> struct initializer_list { + const T *ptr; + __SIZE_TYPE__ size; + initializer_list(); + }; +} + +namespace p0702r1 { + template<typename T> struct X { // expected-note {{candidate}} + X(std::initializer_list<T>); // expected-note {{candidate}} + }; + + X xi = {0}; + X xxi = {xi}; + extern X<int> xi; + // Prior to P0702R1, this is X<X<int>>. + extern X<int> xxi; + + struct Y : X<int> {}; + Y y {{0}}; + X xy {y}; + extern X<int> xy; + + struct Z : X<int>, X<float> {}; + Z z = {{0}, {0.0f}}; + // This is not X<Z> even though that would work. Instead, it's ambiguous + // between X<int> and X<float>. + X xz = {z}; // expected-error {{no viable constructor or deduction guide}} +} +namespace pr34970 { +//https://bugs.llvm.org/show_bug.cgi?id=34970 + +template <typename X, typename Y> struct IsSame { + static constexpr bool value = false; +}; + +template <typename Z> struct IsSame<Z, Z> { + static constexpr bool value = true; +}; + +template <typename T> struct Optional { + template <typename U> Optional(U&&) { } +}; + +template <typename A> Optional(A) -> Optional<A>; + +int main() { + Optional opt(1729); + Optional dupe(opt); + + static_assert(IsSame<decltype(opt), Optional<int>>::value); + static_assert(IsSame<decltype(dupe), Optional<int>>::value); + static_assert(!IsSame<decltype(dupe), Optional<Optional<int>>>::value); + return 0; +} + + +}
\ No newline at end of file |