view gcc/testsuite/g++.dg/cpp2a/explicit8.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
line wrap: on
line source

// P0892R2
// { dg-do compile }
// { dg-options "-std=c++2a" }

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

int
main ()
{
  X x;
  int i = x; // { dg-error "cannot convert" }
  int i2{x};
  double d = x; // { dg-error "cannot convert" }
  double d2{x};
  char c = x; // { dg-error "cannot convert" }
  char c2{x};
  long l = x; // { dg-error "cannot convert" }
  long l2{x};
  int *p = x; // { dg-error "cannot convert" }
  int *p2{x};
}