1 // P2280R4 - Using unknown pointers and references in constant expressions
3 // { dg-do compile { target c++11 } }
5 using size_t = decltype(sizeof(42));
7 template <typename T, size_t N>
8 constexpr auto array_size(T (&)[N]) -> size_t {
13 constexpr int i = array_size (r);
15 void check(int const (¶m)[3]) {
16 int local[] = {1, 2, 3};
17 constexpr auto s0 = array_size(local);
18 constexpr auto s1 = array_size(param);
21 template <typename T, size_t N>
22 constexpr size_t array_size_ptr(T (*)[N]) {
26 void check_ptr(int const (*param)[3]) {
27 constexpr auto s2 = array_size_ptr(param); // { dg-error "not a constant" }
32 constexpr int f() { return 42; }
33 void g() { constexpr int i = f(); }
34 void g2() { constexpr int i = this->f(); }
38 constexpr static bool b = false;
39 void g() noexcept(b) { }
40 void g2() noexcept(this->b) { }