summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-std-function.C
blob: 26c09fdb119ce215e01d0a096103fcf3740ab87d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Test using std::function wrapper.
// { dg-do run }
// { dg-options -std=c++0x }

#include <functional>

typedef std::function<int()> FN;

template<typename T>
FN f(T fn)
{
  return [fn]{return fn(2);};
}

int main()
{
  auto fn = f([](int i){return i*21;});

  if (fn() != 42)
    return 1;
  return 0;
}