Files
gcc-reflection/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda17.C
Marek Polacek be515b4ce0 *.C: Use target c++17 instead of explicit dg-options.
* g++.dg/*.C: Use target c++17 instead of explicit dg-options.
	* lib/g++-dg.exp: Don't test C++11 by default.  Add C++17 to
	the list of default stds to test.

From-SVN: r265343
2018-10-20 17:21:19 +00:00

31 lines
580 B
C

// PR c++/78131
// { dg-do compile { target c++17 } }
template <typename TF>
constexpr auto f(TF)
{
return [](auto...) constexpr { return true; };
}
// Compiles and works as intended.
template <typename T0>
void ok_0(T0)
{
static_assert(f([](auto x) -> decltype(x){})(T0{}));
}
// Compiles and works as intended.
template <typename T0>
void ok_1(T0)
{
constexpr auto a = f([](auto x) -> decltype(x){})(T0{});
if constexpr(a) { }
}
// Compile-time error!
template <typename T0>
void fail_0(T0)
{
if constexpr(f([](auto x) -> decltype(x){})(T0{})) { }
}