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// reference_wrapper
13
14// template <class... ArgTypes>
15//   requires Callable<T, ArgTypes&&...>
16//   Callable<T, ArgTypes&&...>::result_type
17//   operator()(ArgTypes&&... args) const;
18
19#include <functional>
20#include <cassert>
21
22// member data pointer:  cv qualifiers should transfer from argument to return type
23
24struct A_int_1
25{
26    A_int_1() : data_(5) {}
27
28    int data_;
29};
30
31void
32test_int_1()
33{
34    // member data pointer
35    {
36    int A_int_1::*fp = &A_int_1::data_;
37    std::reference_wrapper<int A_int_1::*> r1(fp);
38    A_int_1 a;
39    assert(r1(a) == 5);
40    r1(a) = 6;
41    assert(r1(a) == 6);
42    const A_int_1* ap = &a;
43    assert(r1(ap) == 6);
44    r1(ap) = 7;
45    assert(r1(ap) == 7);
46    }
47}
48
49int main()
50{
51    test_int_1();
52}
53