invoke_int_0.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. 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