invoke_int_0.pass.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02c
1//===----------------------------------------------------------------------===//
2//
3// ��������������������The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <functional>
11
12// class function<R(ArgTypes...)>
13
14// R operator()(ArgTypes... args) const
15
16#include <functional>
17#include <cassert>
18
19// 0 args, return int
20
21int count = 0;
22
23int f_int_0()
24{
25    return 3;
26}
27
28struct A_int_0
29{
30    int operator()() {return 4;}
31};
32
33void
34test_int_0()
35{
36    // function
37    {
38    std::function<int ()> r1(f_int_0);
39    assert(r1() == 3);
40    }
41    // function pointer
42    {
43    int (*fp)() = f_int_0;
44    std::function<int ()> r1(fp);
45    assert(r1() == 3);
46    }
47    // functor
48    {
49    A_int_0 a0;
50    std::function<int ()> r1(a0);
51    assert(r1() == 4);
52    }
53}
54
55int main()
56{
57    test_int_0();
58}
59