view gcc/testsuite/g++.dg/cpp0x/constexpr-fwctor1.C @ 158:494b0b89df80 default tip

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

// PR c++/66450
// { dg-do compile { target c++11 } }

struct foo {
  constexpr foo(int a);
  constexpr foo(int a, int b, int c): a{a}, b{b}, c{c} {}

  int a, b, c;
};

constexpr foo make_foo(int a) { return foo{a, a+1, a+2}; }
constexpr foo::foo(int a): foo{make_foo(a)} {}

int main() {
  constexpr const foo f{3};
  static_assert(f.a == 3, "");
  static_assert(f.b == 4, "");
  static_assert(f.c == 5, "");
}