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...) const);
17 #include "test_macros.h"
21 TEST_CONSTEXPR
char test0() const {return 'a';}
22 TEST_CONSTEXPR
char test1(int) const {return 'b';}
23 TEST_CONSTEXPR
char test2(int, double) const {return 'c';}
27 TEST_CONSTEXPR_CXX20
bool
36 assert(f(cap
) == 'a');
38 assert(cf(ap
) == 'a');
44 TEST_CONSTEXPR_CXX20
bool
49 assert(f(a
, 1) == 'b');
51 assert(f(ap
, 2) == 'b');
53 assert(f(cap
, 2) == 'b');
55 assert(cf(ap
, 2) == 'b');
61 TEST_CONSTEXPR_CXX20
bool
66 assert(f(a
, 1, 2) == 'c');
68 assert(f(ap
, 2, 3.5) == 'c');
70 assert(f(cap
, 2, 3.5) == 'c');
72 assert(cf(ap
, 2, 3.5) == 'c');
79 test0(std::mem_fn(&A::test0
));
80 test1(std::mem_fn(&A::test1
));
81 test2(std::mem_fn(&A::test2
));
83 #if TEST_STD_VER >= 20
84 static_assert(test0(std::mem_fn(&A::test0
)));
85 static_assert(test1(std::mem_fn(&A::test1
)));
86 static_assert(test2(std::mem_fn(&A::test2
)));