1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <functional>
10 
11 // class function<R(ArgTypes...)>
12 
13 // R operator()(ArgTypes... args) const
14 
15 #include <functional>
16 #include <cassert>
17 
18 // member data pointer:  cv qualifiers should transfer from argument to return type
19 
20 struct A_int_1
21 {
A_int_1A_int_122     A_int_1() : data_(5) {}
23 
24     int data_;
25 };
26 
27 void
test_int_1()28 test_int_1()
29 {
30     // member data pointer
31     {
32         int A_int_1::*fp = &A_int_1::data_;
33         A_int_1 a;
34         std::function<int& (const A_int_1*)> r2(fp);
35         const A_int_1* ap = &a;
36         assert(r2(ap) == 6);
37         r2(ap) = 7;
38         assert(r2(ap) == 7);
39     }
40 }
41 
main(int,char **)42 int main(int, char**)
43 {
44     test_int_1();
45 
46   return 0;
47 }
48