Debian Codegraph @

libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.compile.fail.cpp

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