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 // template<Returnable R, class T> unspecified mem_fn(R T::* pm);
12 
13 #include <functional>
14 #include <cassert>
15 
16 struct A
17 {
18     double data_;
19 };
20 
21 template <class F>
22 void
23 test(F f)
24 {
25     {
26     A a;
27     f(a) = 5;
28     assert(a.data_ == 5);
29     A* ap = &a;
30     f(ap) = 6;
31     assert(a.data_ == 6);
32     const A* cap = ap;
33     assert(f(cap) == f(ap));
34     const F& cf = f;
35     assert(cf(ap) == f(ap));
36     }
37 }
38 
39 int main(int, char**)
40 {
41     test(std::mem_fn(&A::data_));
42 
43   return 0;
44 }
45