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 <class Fn>
12// class binder1st
13// : public unary_function<typename Fn::second_argument_type, typename Fn::result_type>
14// {
15// protected:
16// Fn op;
17// typename Fn::first_argument_type value;
18// public:
19// binder2nd(const Fn& x, const typename Fn::second_argument_type& y);
20//
21// typename Fn::result_type operator()(const typename Fn::first_argument_type& x) const;
22// typename Fn::result_type operator()(typename Fn::first_argument_type& x) const;
23// };
24
25// REQUIRES: c++03 || c++11 || c++14
26// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
27
28#include <functional>
29#include <type_traits>
30#include <cassert>
31
32#include "test_macros.h"
33#include "../test_func.h"
34
35class test
36 : public std::binder1st<test_func>
37{
38 typedef std::binder1st<test_func> base;
39public:
40 test() : std::binder1st<test_func>(test_func(2), 30) {}
41
42 void do_test()
43 {
44 static_assert((std::is_base_of<
45 std::unary_function<test_func::second_argument_type,
46 test_func::result_type>,
47 test>::value), "");
48 assert(op.id() == 2);
49 assert(value == 30);
50
51 double d = 5;
52 assert((*this)(d) == 35);
53 assert((*this)(5) == 25);
54 }
55};
56
57int main(int, char**)
58{
59 test t;
60 t.do_test();
61
62 return 0;
63}
64

source code of libcxx/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp