1 // PR c++/69995
2 // { dg-do compile { target c++14 } }
3 
4 #define assert(X) static_assert((X),#X)
5 
6 #define CONSTEXPR constexpr
7 
8 template <typename T, unsigned long Size>
9 struct array {
10     T elems_[Size];
11 
12     constexpr T const& operator[](unsigned long n) const
13     { return elems_[n]; }
14 
15     constexpr T& operator[](unsigned long n)
16     { return elems_[n]; }
17 };
18 
19 template <typename T>
my_swap(T & a,T & b)20 CONSTEXPR void my_swap(T& a, T& b) {
21     T tmp = a;
22     a = b;
23     b = tmp;
24 }
25 
rotate2()26 CONSTEXPR auto rotate2() {
27     array<array<int, 2>, 2> result{};
28     array<int, 2> a{{0, 1}};
29 
30     result[0] = a;
31     my_swap(a[0], a[1]);
32     result[1] = a;
33 
34     return result;
35 }
36 
main()37 int main() {
38     CONSTEXPR auto indices = rotate2();
39     assert(indices[0][0] == 0);
40     assert(indices[0][1] == 1);
41     assert(indices[1][0] == 1);
42     assert(indices[1][1] == 0);
43 }
44