| 1 |
// RUN: %clang_cc1 -std=c++2c -fexperimental-new-constant-interpreter -verify=expected,both %s |
| 2 |
// RUN: %clang_cc1 -std=c++2c -verify=ref,both %s |
| 3 |
|
| 4 |
// both-no-diagnostics |
| 5 |
|
| 6 |
namespace std { |
| 7 |
inline namespace __1 { |
| 8 |
template <class _Tp> class unique_ptr; |
| 9 |
template <class _Tp> class unique_ptr<_Tp[]> { |
| 10 |
public: |
| 11 |
_Tp* __ptr_; |
| 12 |
|
| 13 |
public: |
| 14 |
constexpr _Tp& |
| 15 |
operator[](unsigned i) const { |
| 16 |
return __ptr_[i]; |
| 17 |
}; |
| 18 |
}; |
| 19 |
} // namespace __1 |
| 20 |
} // namespace std |
| 21 |
struct WithTrivialDtor { |
| 22 |
int x = 6; |
| 23 |
constexpr friend void operator==(WithTrivialDtor const &x, |
| 24 |
WithTrivialDtor const &y) { |
| 25 |
(void)(x.x == y.x); |
| 26 |
} |
| 27 |
}; |
| 28 |
constexpr bool test() { |
| 29 |
|
| 30 |
WithTrivialDtor array[50]; |
| 31 |
std::unique_ptr<WithTrivialDtor[]> p(&array[0]); |
| 32 |
(void)(p[1] == WithTrivialDtor()); |
| 33 |
|
| 34 |
return true; |
| 35 |
} |
| 36 |
static_assert(test()); |