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 // REQUIRES: c++03 || c++11 || c++14
11 
12 // const_mem_fun1_ref_t
13 
14 #define _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 **)30 int main(int, char**)
31 {
32     typedef std::const_mem_fun1_ref_t<double, A, unsigned> F;
33     static_assert((std::is_base_of<std::binary_function<A, unsigned, double>, F>::value), "");
34     const F f(&A::a4);
35     const A a = A();
36     assert(f(a, 6) == 5);
37 
38   return 0;
39 }
40