111
|
1 // { dg-do compile { target c++11 } }
|
|
2
|
|
3 // From N2235
|
|
4
|
|
5 // 4.5.3 constant expressions
|
|
6
|
|
7 // p 4
|
|
8 struct A {
|
|
9 constexpr A(int i) : val(i) { }
|
|
10 constexpr operator int() const { return val; }
|
|
11 constexpr operator long() const { return -1; }
|
|
12 private:
|
|
13 int val;
|
|
14 };
|
|
15
|
|
16 template<int I> struct X { static const int i = I; };
|
|
17 constexpr A a = 42;
|
|
18
|
|
19 X<a> x; // OK: unique conversion to int
|
|
20 int ar[X<a>::i]; // also OK
|
131
|
21 int ary[a]; // { dg-error "could not convert|ambiguous|conversion|array" } ambiguous conversion
|
111
|
22
|