aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/explicit13.C
blob: 4747ebd3df4a3cd81f0d9a2acdfecf730bd9ea4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// P0892R2
// { dg-do compile }
// { dg-options "-std=c++2a" }

template<int M = 0> struct A {
  template<typename T, int N = 0>
  explicit(N + M) operator T();
};

template<int M = 1> struct B {
  template<typename T, int N = 1>
  explicit(N * M) operator T();
};

void
bar ()
{
  A a;
  int i = a;

  A<0> a0;
  int i0 = a0;

  A<1> a1;
  int i1 = a1; // { dg-error "cannot convert" }

  B b;
  int j = b; // { dg-error "cannot convert" }

  B<0> b0;
  int j0 = b0;

  B<1> b1;
  int j1 = b1; // { dg-error "cannot convert" }
}