|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | + |
| 9 | +// REQUIRES: std-at-least-c++23 |
| 10 | + |
| 11 | +// These compilers don't support std::reference_converts_from_temporary yet. |
| 12 | +// UNSUPPORTED: android, apple-clang-15, apple-clang-16, clang-18, clang-19.1 |
| 13 | + |
| 14 | +// <type_traits> |
| 15 | + |
| 16 | +// template<class T, class U> struct reference_converts_from_temporary; |
| 17 | + |
| 18 | +// template<class T, class U> |
| 19 | +// constexpr bool reference_converts_from_temporary_v |
| 20 | +// = reference_converts_from_temporary<T, U>::value; |
| 21 | + |
| 22 | +#include <type_traits> |
| 23 | + |
| 24 | +#if !__has_warning("-Winvalid-specialization") |
| 25 | +// expected-no-diagnostics |
| 26 | +#else |
| 27 | + |
| 28 | +// expected-error@+2 {{'reference_converts_from_temporary' cannot be specialized: Users are not allowed to specialize this standard library entity}} |
| 29 | +template <> |
| 30 | +struct std::reference_converts_from_temporary<int, int> { |
| 31 | +}; //expected-error 0-1 {{explicit specialization of 'std::reference_converts_from_temporary<int, int>' after instantiation}} |
| 32 | + |
| 33 | +// expected-error@+2 {{'reference_converts_from_temporary' cannot be specialized: Users are not allowed to specialize this standard library entity}} |
| 34 | +template <typename T, typename U> |
| 35 | +struct std::reference_converts_from_temporary<T&, U&> {}; |
| 36 | + |
| 37 | +// expected-error@+2 {{'reference_converts_from_temporary_v' cannot be specialized: Users are not allowed to specialize this standard library entity}} |
| 38 | +template <> |
| 39 | +inline constexpr bool std::reference_converts_from_temporary_v<int, int> = |
| 40 | + false; // expected-error 0-1 {{explicit specialization of 'std::reference_converts_from_temporary_v<int, int>' after instantiation}} |
| 41 | + |
| 42 | +// expected-error@+2 {{'reference_converts_from_temporary_v' cannot be specialized: Users are not allowed to specialize this standard library entity}} |
| 43 | +template <class T, class U> |
| 44 | +inline constexpr bool std::reference_converts_from_temporary_v<T&, U&> = false; |
| 45 | + |
| 46 | +#endif |
0 commit comments