• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // member data pointer:  cv qualifiers should transfer from argument to return type
20 
21 struct A_int_1
22 {
A_int_1A_int_123     A_int_1() : data_(5) {}
24 
25     int data_;
26 };
27 
28 void
test_int_1()29 test_int_1()
30 {
31     // member data pointer
32     {
33         int A_int_1::*fp = &A_int_1::data_;
34         A_int_1 a;
35         std::function<int& (const A_int_1*)> r2(fp);
36         const A_int_1* ap = &a;
37         assert(r2(ap) == 6);
38         r2(ap) = 7;
39         assert(r2(ap) == 7);
40     }
41 }
42 
main()43 int main()
44 {
45     test_int_1();
46 }
47