1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template<Returnable R, class T, CopyConstructible... Args>
12 // unspecified mem_fn(R (T::* pm)(Args...));
17 #include "test_macros.h"
21 TEST_CONSTEXPR_CXX14
char test0() {return 'a';}
22 TEST_CONSTEXPR_CXX14
char test1(int) {return 'b';}
23 TEST_CONSTEXPR_CXX14
char test2(int, double) {return 'c';}
27 TEST_CONSTEXPR_CXX20
bool
36 assert(cf(ap
) == 'a');
42 TEST_CONSTEXPR_CXX20
bool
47 assert(f(a
, 1) == 'b');
49 assert(f(ap
, 2) == 'b');
51 assert(cf(ap
, 2) == 'b');
57 TEST_CONSTEXPR_CXX20
bool
62 assert(f(a
, 1, 2) == 'c');
64 assert(f(ap
, 2, 3.5) == 'c');
66 assert(cf(ap
, 2, 3.5) == 'c');
73 test0(std::mem_fn(&A::test0
));
74 test1(std::mem_fn(&A::test1
));
75 test2(std::mem_fn(&A::test2
));
76 #if TEST_STD_VER >= 11
77 static_assert((noexcept(std::mem_fn(&A::test0
))), ""); // LWG#2489
80 #if TEST_STD_VER >= 20
81 static_assert(test0(std::mem_fn(&A::test0
)));
82 static_assert(test1(std::mem_fn(&A::test1
)));
83 static_assert(test2(std::mem_fn(&A::test2
)));