Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / depr / depr.lib.binders / depr.lib.binder.2nd / binder2nd.pass.cpp
blobc4c65eff481d027026a80b32869e1721e64cca7a
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 //===----------------------------------------------------------------------===//
9 // <functional>
11 // template <class Fn>
12 // class binder2nd
13 // : public unary_function<typename Fn::first_argument_type, typename Fn::result_type>
14 // {
15 // protected:
16 // Fn op;
17 // typename Fn::second_argument_type value;
18 // public:
19 // binder2nd(const Fn& x, const typename Fn::second_argument_type& y);
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 // };
25 // REQUIRES: c++03 || c++11 || c++14
26 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
28 #include <functional>
29 #include <type_traits>
30 #include <cassert>
32 #include "test_macros.h"
33 #include "../test_func.h"
35 class test
36 : public std::binder2nd<test_func>
38 typedef std::binder2nd<test_func> base;
39 public:
40 test() : std::binder2nd<test_func>(test_func(3), 4.5) {}
42 void do_test()
44 static_assert((std::is_base_of<
45 std::unary_function<test_func::first_argument_type,
46 test_func::result_type>,
47 test>::value), "");
48 assert(op.id() == 3);
49 assert(value == 4.5);
51 int i = 5;
52 assert((*this)(i) == 22.5);
53 assert((*this)(5) == 0.5);
57 int main(int, char**)
59 test t;
60 t.do_test();
62 return 0;