Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp1z/constexpr-lambda6.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 // Testcase from P0170R1 | 1 // Testcase from P0170R1 |
2 // { dg-options -std=c++17 } | 2 // { dg-do compile { target c++17 } } |
3 | 3 |
4 auto monoid = [](auto v) { return [=] { return v; }; }; | 4 auto monoid = [](auto v) { return [=] { return v; }; }; |
5 auto add = [](auto m1) constexpr { | 5 auto add = [](auto m1) constexpr { |
6 auto ret = m1(); | 6 auto ret = m1(); |
7 return [=](auto m2) mutable { | 7 return [=](auto m2) mutable { |
22 // member function call operator can not perform an lvalue-to-rvalue conversion | 22 // member function call operator can not perform an lvalue-to-rvalue conversion |
23 // on one of its subobjects (that represents its capture) in a constant | 23 // on one of its subobjects (that represents its capture) in a constant |
24 // expression. | 24 // expression. |
25 auto two = monoid(2); | 25 auto two = monoid(2); |
26 if (!(two() == 2)) __builtin_abort(); // OK, not a constant expression. | 26 if (!(two() == 2)) __builtin_abort(); // OK, not a constant expression. |
27 static_assert(add(one)(one)() == two()); // { dg-error "" } two() is not a constant expression | 27 static_assert(add(one)(one)() == two()); // { dg-error "|in .constexpr. expansion of " } two() is not a constant expression |
28 static_assert(add(one)(one)() == monoid(2)()); // OK | 28 static_assert(add(one)(one)() == monoid(2)()); // OK |
29 } | 29 } |