1050b064fSChristopher Di Bella // -*- C++ -*-
2050b064fSChristopher Di Bella //===----------------------------------------------------------------------===//
3050b064fSChristopher Di Bella //
4050b064fSChristopher Di Bella // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5050b064fSChristopher Di Bella // See https://llvm.org/LICENSE.txt for license information.
6050b064fSChristopher Di Bella // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7050b064fSChristopher Di Bella //
8050b064fSChristopher Di Bella //===----------------------------------------------------------------------===//
9050b064fSChristopher Di Bella
10050b064fSChristopher Di Bella #ifndef _LIBCPP___FUNCTIONAL_BINDER2ND_H
11050b064fSChristopher Di Bella #define _LIBCPP___FUNCTIONAL_BINDER2ND_H
12050b064fSChristopher Di Bella
13050b064fSChristopher Di Bella #include <__config>
14050b064fSChristopher Di Bella #include <__functional/unary_function.h>
15050b064fSChristopher Di Bella
16050b064fSChristopher Di Bella #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17050b064fSChristopher Di Bella # pragma GCC system_header
18050b064fSChristopher Di Bella #endif
19050b064fSChristopher Di Bella
20050b064fSChristopher Di Bella _LIBCPP_BEGIN_NAMESPACE_STD
21050b064fSChristopher Di Bella
22050b064fSChristopher Di Bella #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
23050b064fSChristopher Di Bella
241e24b4d3SNikolas Klauser template <class _Operation>
25050b064fSChristopher Di Bella class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
26*9783f28cSLouis Dionne : public __unary_function<typename _Operation::first_argument_type, typename _Operation::result_type> {
27050b064fSChristopher Di Bella protected:
281e24b4d3SNikolas Klauser _Operation op;
291e24b4d3SNikolas Klauser typename _Operation::second_argument_type value;
30*9783f28cSLouis Dionne
31050b064fSChristopher Di Bella public:
binder2nd(const _Operation & __x,const typename _Operation::second_argument_type __y)32*9783f28cSLouis Dionne _LIBCPP_HIDE_FROM_ABI binder2nd(const _Operation& __x, const typename _Operation::second_argument_type __y)
33050b064fSChristopher Di Bella : op(__x), value(__y) {}
34*9783f28cSLouis Dionne _LIBCPP_HIDE_FROM_ABI typename _Operation::result_type
operator()35*9783f28cSLouis Dionne operator()(typename _Operation::first_argument_type& __x) const {
36*9783f28cSLouis Dionne return op(__x, value);
37*9783f28cSLouis Dionne }
38*9783f28cSLouis Dionne _LIBCPP_HIDE_FROM_ABI typename _Operation::result_type
operator()39*9783f28cSLouis Dionne operator()(const typename _Operation::first_argument_type& __x) const {
40*9783f28cSLouis Dionne return op(__x, value);
41*9783f28cSLouis Dionne }
42050b064fSChristopher Di Bella };
43050b064fSChristopher Di Bella
441e24b4d3SNikolas Klauser template <class _Operation, class _Tp>
45*9783f28cSLouis Dionne _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI binder2nd<_Operation>
bind2nd(const _Operation & __op,const _Tp & __x)46*9783f28cSLouis Dionne bind2nd(const _Operation& __op, const _Tp& __x) {
47*9783f28cSLouis Dionne return binder2nd<_Operation>(__op, __x);
48*9783f28cSLouis Dionne }
49050b064fSChristopher Di Bella
50050b064fSChristopher Di Bella #endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
51050b064fSChristopher Di Bella
52050b064fSChristopher Di Bella _LIBCPP_END_NAMESPACE_STD
53050b064fSChristopher Di Bella
54050b064fSChristopher Di Bella #endif // _LIBCPP___FUNCTIONAL_BINDER2ND_H
55