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 // mem_fun_t 12 13 // REQUIRES: c++03 || c++11 || c++14 14 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS 15 16 #include <functional> 17 #include <type_traits> 18 #include <cassert> 19 20 #include "test_macros.h" 21 22 struct A 23 { a1A24 char a1() {return 5;} a2A25 short a2(int i) {return short(i+1);} a3A26 int a3() const {return 1;} a4A27 double a4(unsigned i) const {return i-1;} 28 }; 29 main(int,char **)30int main(int, char**) 31 { 32 typedef std::mem_fun_t<char, A> F; 33 static_assert((std::is_base_of<std::unary_function<A*, char>, F>::value), ""); 34 const F f(&A::a1); 35 A a; 36 assert(f(&a) == 5); 37 38 return 0; 39 } 40