view gcc/testsuite/g++.dg/cpp1y/lambda-deduce-mult.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// Testcase for an extension to allow return type deduction when the lambda
// contains more than just a single return-statement.

// { dg-do run { target c++14 } }

bool b;
template <class T>
T f (T t)
{
  return [=] {
    auto i = t+1;
    if (b)
      return i+1;
    else
      return i+1;
  }();
}

int main()
{
  // Pointless, but well-formed.
  [] { return 1; return 2; }();

  if (f(1) != 3)
    return 1;
}