2010-05-12 03:42:16 +08:00
|
|
|
// -*- C++ -*-
|
2021-07-01 21:25:35 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
2019-01-19 18:56:40 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_FUNCTIONAL
|
|
|
|
#define _LIBCPP_FUNCTIONAL
|
|
|
|
|
|
|
|
/*
|
|
|
|
functional synopsis
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
|
|
|
|
template <class Arg, class Result>
|
|
|
|
struct unary_function
|
|
|
|
{
|
|
|
|
typedef Arg argument_type;
|
|
|
|
typedef Result result_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Arg1, class Arg2, class Result>
|
|
|
|
struct binary_function
|
|
|
|
{
|
|
|
|
typedef Arg1 first_argument_type;
|
|
|
|
typedef Arg2 second_argument_type;
|
|
|
|
typedef Result result_type;
|
|
|
|
};
|
|
|
|
|
2010-08-21 03:36:46 +08:00
|
|
|
template <class T>
|
2010-05-12 03:42:16 +08:00
|
|
|
class reference_wrapper
|
|
|
|
: public unary_function<T1, R> // if wrapping a unary functor
|
|
|
|
: public binary_function<T1, T2, R> // if wraping a binary functor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// types
|
|
|
|
typedef T type;
|
|
|
|
typedef see below result_type; // Not always defined
|
|
|
|
|
|
|
|
// construct/copy/destroy
|
2020-12-06 08:37:41 +08:00
|
|
|
template<class U>
|
|
|
|
reference_wrapper(U&&);
|
2011-05-29 01:59:48 +08:00
|
|
|
reference_wrapper(const reference_wrapper<T>& x) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
// assignment
|
2011-05-29 01:59:48 +08:00
|
|
|
reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
// access
|
2011-05-29 01:59:48 +08:00
|
|
|
operator T& () const noexcept;
|
|
|
|
T& get() const noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
// invoke
|
|
|
|
template <class... ArgTypes>
|
2013-09-22 01:58:58 +08:00
|
|
|
typename result_of<T&(ArgTypes&&...)>::type
|
2010-05-12 03:42:16 +08:00
|
|
|
operator() (ArgTypes&&...) const;
|
|
|
|
};
|
|
|
|
|
2020-12-06 08:37:41 +08:00
|
|
|
template <class T>
|
|
|
|
reference_wrapper(T&) -> reference_wrapper<T>;
|
|
|
|
|
2011-05-29 01:59:48 +08:00
|
|
|
template <class T> reference_wrapper<T> ref(T& t) noexcept;
|
2010-08-21 03:36:46 +08:00
|
|
|
template <class T> void ref(const T&& t) = delete;
|
2011-05-29 01:59:48 +08:00
|
|
|
template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2011-05-29 01:59:48 +08:00
|
|
|
template <class T> reference_wrapper<const T> cref(const T& t) noexcept;
|
2010-08-21 03:36:46 +08:00
|
|
|
template <class T> void cref(const T&& t) = delete;
|
2011-05-29 01:59:48 +08:00
|
|
|
template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2018-12-03 22:03:27 +08:00
|
|
|
template <class T> struct unwrap_reference; // since C++20
|
|
|
|
template <class T> struct unwrap_ref_decay : unwrap_reference<decay_t<T>> { }; // since C++20
|
|
|
|
template <class T> using unwrap_reference_t = typename unwrap_reference<T>::type; // since C++20
|
|
|
|
template <class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type; // since C++20
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct plus {
|
2010-05-12 03:42:16 +08:00
|
|
|
T operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct minus {
|
2010-05-12 03:42:16 +08:00
|
|
|
T operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct multiplies {
|
2010-05-12 03:42:16 +08:00
|
|
|
T operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct divides {
|
2010-05-12 03:42:16 +08:00
|
|
|
T operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct modulus {
|
2010-05-12 03:42:16 +08:00
|
|
|
T operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct negate {
|
2010-05-12 03:42:16 +08:00
|
|
|
T operator()(const T& x) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct equal_to {
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct not_equal_to {
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct greater {
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct less {
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct greater_equal {
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct less_equal {
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2021-07-29 11:40:29 +08:00
|
|
|
// [comparisons.three.way], class compare_three_way
|
|
|
|
struct compare_three_way;
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct logical_and {
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct logical_or {
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const T& x, const T& y) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct logical_not {
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const T& x) const;
|
|
|
|
};
|
|
|
|
|
2013-07-29 22:21:53 +08:00
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct bit_and {
|
2021-03-08 09:22:03 +08:00
|
|
|
T operator()(const T& x, const T& y) const;
|
2013-07-29 22:21:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct bit_or {
|
2021-03-08 09:22:03 +08:00
|
|
|
T operator()(const T& x, const T& y) const;
|
2013-07-29 22:21:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class T> // <class T=void> in C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct bit_xor {
|
2021-03-08 09:22:03 +08:00
|
|
|
T operator()(const T& x, const T& y) const;
|
2013-07-29 22:21:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class T=void> // C++14
|
2021-05-26 02:34:18 +08:00
|
|
|
struct bit_not {
|
2021-03-08 09:22:03 +08:00
|
|
|
T operator()(const T& x) const;
|
2013-07-29 22:21:53 +08:00
|
|
|
};
|
|
|
|
|
2021-03-19 01:21:35 +08:00
|
|
|
struct identity; // C++20
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class Predicate>
|
2021-05-25 06:36:17 +08:00
|
|
|
class unary_negate // deprecated in C++17, removed in C++20
|
2010-05-12 03:42:16 +08:00
|
|
|
: public unary_function<typename Predicate::argument_type, bool>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit unary_negate(const Predicate& pred);
|
|
|
|
bool operator()(const typename Predicate::argument_type& x) const;
|
|
|
|
};
|
|
|
|
|
2021-05-25 06:36:17 +08:00
|
|
|
template <class Predicate> // deprecated in C++17, removed in C++20
|
[libc++] Add deprecated attributes to many deprecated components
Summary:
These deprecation warnings are opt-in: they are only enabled when the
_LIBCXX_DEPRECATION_WARNINGS macro is defined, which is not the case
by default. Note that this is a first step in the right direction, but
I wasn't able to get an exhaustive list of all deprecated components
per standard, so there's certainly stuff that's missing. The list of
components this commit marks as deprecated is:
in C++11:
- auto_ptr, auto_ptr_ref
- binder1st, binder2nd, bind1st(), bind2nd()
- pointer_to_unary_function, pointer_to_binary_function, ptr_fun()
- mem_fun_t, mem_fun1_t, const_mem_fun_t, const_mem_fun1_t, mem_fun()
- mem_fun_ref_t, mem_fun1_ref_t, const_mem_fun_ref_t, const_mem_fun1_ref_t, mem_fun_ref()
in C++14:
- random_shuffle()
in C++17:
- unary_negate, binary_negate, not1(), not2()
<rdar://problem/18168350>
Reviewers: mclow.lists, EricWF
Subscribers: christof, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D48912
llvm-svn: 342843
2018-09-24 02:35:00 +08:00
|
|
|
unary_negate<Predicate> not1(const Predicate& pred);
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class Predicate>
|
2021-05-25 06:36:17 +08:00
|
|
|
class binary_negate // deprecated in C++17, removed in C++20
|
2010-05-12 03:42:16 +08:00
|
|
|
: public binary_function<typename Predicate::first_argument_type,
|
|
|
|
typename Predicate::second_argument_type,
|
|
|
|
bool>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit binary_negate(const Predicate& pred);
|
|
|
|
bool operator()(const typename Predicate::first_argument_type& x,
|
|
|
|
const typename Predicate::second_argument_type& y) const;
|
|
|
|
};
|
|
|
|
|
2021-05-25 06:36:17 +08:00
|
|
|
template <class Predicate> // deprecated in C++17, removed in C++20
|
[libc++] Add deprecated attributes to many deprecated components
Summary:
These deprecation warnings are opt-in: they are only enabled when the
_LIBCXX_DEPRECATION_WARNINGS macro is defined, which is not the case
by default. Note that this is a first step in the right direction, but
I wasn't able to get an exhaustive list of all deprecated components
per standard, so there's certainly stuff that's missing. The list of
components this commit marks as deprecated is:
in C++11:
- auto_ptr, auto_ptr_ref
- binder1st, binder2nd, bind1st(), bind2nd()
- pointer_to_unary_function, pointer_to_binary_function, ptr_fun()
- mem_fun_t, mem_fun1_t, const_mem_fun_t, const_mem_fun1_t, mem_fun()
- mem_fun_ref_t, mem_fun1_ref_t, const_mem_fun_ref_t, const_mem_fun1_ref_t, mem_fun_ref()
in C++14:
- random_shuffle()
in C++17:
- unary_negate, binary_negate, not1(), not2()
<rdar://problem/18168350>
Reviewers: mclow.lists, EricWF
Subscribers: christof, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D48912
llvm-svn: 342843
2018-09-24 02:35:00 +08:00
|
|
|
binary_negate<Predicate> not2(const Predicate& pred);
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2020-12-26 03:48:39 +08:00
|
|
|
template <class F>
|
|
|
|
constexpr unspecified not_fn(F&& f); // C++17, constexpr in C++20
|
2016-06-02 09:25:41 +08:00
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template<class T> struct is_bind_expression;
|
|
|
|
template<class T> struct is_placeholder;
|
|
|
|
|
2016-09-22 08:23:15 +08:00
|
|
|
// See C++14 20.9.9, Function object binders
|
2018-01-03 01:17:01 +08:00
|
|
|
template <class T> inline constexpr bool is_bind_expression_v
|
2016-09-22 08:23:15 +08:00
|
|
|
= is_bind_expression<T>::value; // C++17
|
2018-01-03 01:17:01 +08:00
|
|
|
template <class T> inline constexpr int is_placeholder_v
|
2016-09-22 08:23:15 +08:00
|
|
|
= is_placeholder<T>::value; // C++17
|
|
|
|
|
|
|
|
|
2010-08-22 08:02:43 +08:00
|
|
|
template<class Fn, class... BoundArgs>
|
2020-12-26 03:48:39 +08:00
|
|
|
constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20
|
2010-08-22 08:02:43 +08:00
|
|
|
template<class R, class Fn, class... BoundArgs>
|
2020-12-26 03:48:39 +08:00
|
|
|
constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2019-04-04 01:54:37 +08:00
|
|
|
template<class F, class... Args>
|
2020-12-26 03:48:39 +08:00
|
|
|
constexpr // constexpr in C++20
|
2019-04-04 01:54:37 +08:00
|
|
|
invoke_result_t<F, Args...> invoke(F&& f, Args&&... args) // C++17
|
|
|
|
noexcept(is_nothrow_invocable_v<F, Args...>);
|
|
|
|
|
2010-08-22 08:02:43 +08:00
|
|
|
namespace placeholders {
|
|
|
|
// M is the implementation-defined number of placeholders
|
2010-05-12 03:42:16 +08:00
|
|
|
extern unspecified _1;
|
|
|
|
extern unspecified _2;
|
2010-08-22 08:02:43 +08:00
|
|
|
.
|
|
|
|
.
|
|
|
|
.
|
2011-11-30 02:15:50 +08:00
|
|
|
extern unspecified _Mp;
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Operation>
|
2017-04-14 02:25:32 +08:00
|
|
|
class binder1st // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
: public unary_function<typename Operation::second_argument_type,
|
|
|
|
typename Operation::result_type>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
Operation op;
|
|
|
|
typename Operation::first_argument_type value;
|
|
|
|
public:
|
|
|
|
binder1st(const Operation& x, const typename Operation::first_argument_type y);
|
|
|
|
typename Operation::result_type operator()( typename Operation::second_argument_type& x) const;
|
|
|
|
typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Operation, class T>
|
2017-04-14 02:25:32 +08:00
|
|
|
binder1st<Operation> bind1st(const Operation& op, const T& x); // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class Operation>
|
2017-04-14 02:25:32 +08:00
|
|
|
class binder2nd // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
: public unary_function<typename Operation::first_argument_type,
|
|
|
|
typename Operation::result_type>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
Operation op;
|
|
|
|
typename Operation::second_argument_type value;
|
|
|
|
public:
|
|
|
|
binder2nd(const Operation& x, const typename Operation::second_argument_type y);
|
|
|
|
typename Operation::result_type operator()( typename Operation::first_argument_type& x) const;
|
|
|
|
typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Operation, class T>
|
2017-04-14 02:25:32 +08:00
|
|
|
binder2nd<Operation> bind2nd(const Operation& op, const T& x); // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2017-04-14 02:25:32 +08:00
|
|
|
template <class Arg, class Result> // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
class pointer_to_unary_function : public unary_function<Arg, Result>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit pointer_to_unary_function(Result (*f)(Arg));
|
|
|
|
Result operator()(Arg x) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Arg, class Result>
|
2017-04-14 02:25:32 +08:00
|
|
|
pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg)); // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2017-04-14 02:25:32 +08:00
|
|
|
template <class Arg1, class Arg2, class Result> // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
|
|
|
|
Result operator()(Arg1 x, Arg2 y) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Arg1, class Arg2, class Result>
|
2017-04-14 02:25:32 +08:00
|
|
|
pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2)); // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2017-04-14 02:25:32 +08:00
|
|
|
template<class S, class T> // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
class mem_fun_t : public unary_function<T*, S>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit mem_fun_t(S (T::*p)());
|
|
|
|
S operator()(T* p) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class S, class T, class A>
|
2017-04-14 02:25:32 +08:00
|
|
|
class mem_fun1_t : public binary_function<T*, A, S> // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit mem_fun1_t(S (T::*p)(A));
|
|
|
|
S operator()(T* p, A x) const;
|
|
|
|
};
|
|
|
|
|
2017-04-14 02:25:32 +08:00
|
|
|
template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)()); // deprecated in C++11, removed in C++17
|
|
|
|
template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)); // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template<class S, class T>
|
2017-04-14 02:25:32 +08:00
|
|
|
class mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit mem_fun_ref_t(S (T::*p)());
|
|
|
|
S operator()(T& p) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class S, class T, class A>
|
2017-04-14 02:25:32 +08:00
|
|
|
class mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit mem_fun1_ref_t(S (T::*p)(A));
|
|
|
|
S operator()(T& p, A x) const;
|
|
|
|
};
|
|
|
|
|
2017-04-14 02:25:32 +08:00
|
|
|
template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); // deprecated in C++11, removed in C++17
|
|
|
|
template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A)); // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class S, class T>
|
2017-04-14 02:25:32 +08:00
|
|
|
class const_mem_fun_t : public unary_function<const T*, S> // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit const_mem_fun_t(S (T::*p)() const);
|
|
|
|
S operator()(const T* p) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class S, class T, class A>
|
2017-04-14 02:25:32 +08:00
|
|
|
class const_mem_fun1_t : public binary_function<const T*, A, S> // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit const_mem_fun1_t(S (T::*p)(A) const);
|
|
|
|
S operator()(const T* p, A x) const;
|
|
|
|
};
|
|
|
|
|
2017-04-14 02:25:32 +08:00
|
|
|
template <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const); // deprecated in C++11, removed in C++17
|
|
|
|
template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const); // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class S, class T>
|
2017-04-14 02:25:32 +08:00
|
|
|
class const_mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit const_mem_fun_ref_t(S (T::*p)() const);
|
|
|
|
S operator()(const T& p) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class S, class T, class A>
|
2017-04-14 02:25:32 +08:00
|
|
|
class const_mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
|
|
|
|
S operator()(const T& p, A x) const;
|
|
|
|
};
|
|
|
|
|
2017-04-14 02:25:32 +08:00
|
|
|
template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); // deprecated in C++11, removed in C++17
|
|
|
|
template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2020-12-26 03:48:39 +08:00
|
|
|
template<class R, class T>
|
|
|
|
constexpr unspecified mem_fn(R T::*); // constexpr in C++20
|
2010-08-21 03:36:46 +08:00
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
class bad_function_call
|
|
|
|
: public exception
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2010-08-21 03:36:46 +08:00
|
|
|
template<class> class function; // undefined
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-08-21 03:36:46 +08:00
|
|
|
template<class R, class... ArgTypes>
|
2010-05-12 03:42:16 +08:00
|
|
|
class function<R(ArgTypes...)>
|
|
|
|
: public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and
|
|
|
|
// ArgTypes contains T1
|
|
|
|
: public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
|
|
|
|
// ArgTypes contains T1 and T2
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef R result_type;
|
|
|
|
|
2010-08-21 03:36:46 +08:00
|
|
|
// construct/copy/destroy:
|
2011-05-29 01:59:48 +08:00
|
|
|
function() noexcept;
|
|
|
|
function(nullptr_t) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
function(const function&);
|
2011-05-29 01:59:48 +08:00
|
|
|
function(function&&) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
template<class F>
|
|
|
|
function(F);
|
|
|
|
template<Allocator Alloc>
|
2016-10-14 05:06:03 +08:00
|
|
|
function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
template<Allocator Alloc>
|
2016-10-14 05:06:03 +08:00
|
|
|
function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
template<Allocator Alloc>
|
2016-10-14 05:06:03 +08:00
|
|
|
function(allocator_arg_t, const Alloc&, const function&); // removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
template<Allocator Alloc>
|
2016-10-14 05:06:03 +08:00
|
|
|
function(allocator_arg_t, const Alloc&, function&&); // removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
template<class F, Allocator Alloc>
|
2016-10-14 05:06:03 +08:00
|
|
|
function(allocator_arg_t, const Alloc&, F); // removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
function& operator=(const function&);
|
2011-05-29 01:59:48 +08:00
|
|
|
function& operator=(function&&) noexcept;
|
2011-05-29 21:53:56 +08:00
|
|
|
function& operator=(nullptr_t) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
template<class F>
|
2010-08-21 03:36:46 +08:00
|
|
|
function& operator=(F&&);
|
2010-05-12 03:42:16 +08:00
|
|
|
template<class F>
|
2011-05-29 01:59:48 +08:00
|
|
|
function& operator=(reference_wrapper<F>) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
~function();
|
|
|
|
|
2010-08-21 03:36:46 +08:00
|
|
|
// function modifiers:
|
2011-05-29 01:59:48 +08:00
|
|
|
void swap(function&) noexcept;
|
2010-08-21 03:36:46 +08:00
|
|
|
template<class F, class Alloc>
|
2016-01-26 01:29:55 +08:00
|
|
|
void assign(F&&, const Alloc&); // Removed in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-08-21 03:36:46 +08:00
|
|
|
// function capacity:
|
2011-05-29 01:59:48 +08:00
|
|
|
explicit operator bool() const noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-08-21 03:36:46 +08:00
|
|
|
// function invocation:
|
2010-05-12 03:42:16 +08:00
|
|
|
R operator()(ArgTypes...) const;
|
|
|
|
|
2010-08-21 03:36:46 +08:00
|
|
|
// function target access:
|
2011-05-29 01:59:48 +08:00
|
|
|
const std::type_info& target_type() const noexcept;
|
|
|
|
template <typename T> T* target() noexcept;
|
|
|
|
template <typename T> const T* target() const noexcept;
|
2010-08-21 03:36:46 +08:00
|
|
|
};
|
|
|
|
|
2019-07-19 03:50:56 +08:00
|
|
|
// Deduction guides
|
|
|
|
template<class R, class ...Args>
|
|
|
|
function(R(*)(Args...)) -> function<R(Args...)>; // since C++17
|
|
|
|
|
|
|
|
template<class F>
|
|
|
|
function(F) -> function<see-below>; // since C++17
|
|
|
|
|
2010-08-22 08:02:43 +08:00
|
|
|
// Null pointer comparisons:
|
|
|
|
template <class R, class ... ArgTypes>
|
2011-05-29 01:59:48 +08:00
|
|
|
bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-08-22 08:02:43 +08:00
|
|
|
template <class R, class ... ArgTypes>
|
2011-05-29 01:59:48 +08:00
|
|
|
bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-08-22 08:02:43 +08:00
|
|
|
template <class R, class ... ArgTypes>
|
2011-05-29 01:59:48 +08:00
|
|
|
bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-08-22 08:02:43 +08:00
|
|
|
template <class R, class ... ArgTypes>
|
2011-05-29 01:59:48 +08:00
|
|
|
bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-08-22 08:02:43 +08:00
|
|
|
// specialized algorithms:
|
|
|
|
template <class R, class ... ArgTypes>
|
2011-05-29 01:59:48 +08:00
|
|
|
void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class T> struct hash;
|
|
|
|
|
|
|
|
template <> struct hash<bool>;
|
|
|
|
template <> struct hash<char>;
|
|
|
|
template <> struct hash<signed char>;
|
|
|
|
template <> struct hash<unsigned char>;
|
2020-12-09 02:39:56 +08:00
|
|
|
template <> struct hash<char8_t>; // since C++20
|
2010-05-12 03:42:16 +08:00
|
|
|
template <> struct hash<char16_t>;
|
|
|
|
template <> struct hash<char32_t>;
|
|
|
|
template <> struct hash<wchar_t>;
|
|
|
|
template <> struct hash<short>;
|
|
|
|
template <> struct hash<unsigned short>;
|
|
|
|
template <> struct hash<int>;
|
|
|
|
template <> struct hash<unsigned int>;
|
|
|
|
template <> struct hash<long>;
|
|
|
|
template <> struct hash<long long>;
|
|
|
|
template <> struct hash<unsigned long>;
|
|
|
|
template <> struct hash<unsigned long long>;
|
|
|
|
|
|
|
|
template <> struct hash<float>;
|
|
|
|
template <> struct hash<double>;
|
|
|
|
template <> struct hash<long double>;
|
|
|
|
|
|
|
|
template<class T> struct hash<T*>;
|
2017-03-23 14:20:18 +08:00
|
|
|
template <> struct hash<nullptr_t>; // C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
} // std
|
|
|
|
|
|
|
|
POLICY: For non-variadic implementations, the number of arguments is limited
|
|
|
|
to 3. It is hoped that the need for non-variadic implementations
|
|
|
|
will be minimal.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2021-06-29 23:33:16 +08:00
|
|
|
#include <__algorithm/search.h>
|
2021-07-29 11:40:29 +08:00
|
|
|
#include <__compare/compare_three_way.h>
|
2010-05-12 03:42:16 +08:00
|
|
|
#include <__config>
|
2021-05-13 11:04:03 +08:00
|
|
|
#include <__debug>
|
2021-07-01 21:25:35 +08:00
|
|
|
#include <__functional/binary_function.h> // TODO: deprecate
|
|
|
|
#include <__functional/binary_negate.h>
|
2022-01-07 22:45:05 +08:00
|
|
|
#include <__functional/bind.h>
|
2021-08-10 03:41:26 +08:00
|
|
|
#include <__functional/bind_back.h>
|
2021-07-01 21:25:35 +08:00
|
|
|
#include <__functional/bind_front.h>
|
|
|
|
#include <__functional/binder1st.h>
|
|
|
|
#include <__functional/binder2nd.h>
|
2021-08-10 03:41:26 +08:00
|
|
|
#include <__functional/compose.h>
|
2021-07-01 21:25:35 +08:00
|
|
|
#include <__functional/default_searcher.h>
|
|
|
|
#include <__functional/function.h>
|
2021-06-10 07:10:17 +08:00
|
|
|
#include <__functional/hash.h>
|
2021-07-01 21:25:35 +08:00
|
|
|
#include <__functional/identity.h>
|
|
|
|
#include <__functional/invoke.h>
|
|
|
|
#include <__functional/mem_fn.h> // TODO: deprecate
|
|
|
|
#include <__functional/mem_fun_ref.h>
|
|
|
|
#include <__functional/not_fn.h>
|
|
|
|
#include <__functional/operations.h>
|
|
|
|
#include <__functional/pointer_to_binary_function.h>
|
|
|
|
#include <__functional/pointer_to_unary_function.h>
|
|
|
|
#include <__functional/ranges_operations.h>
|
|
|
|
#include <__functional/reference_wrapper.h>
|
|
|
|
#include <__functional/unary_function.h> // TODO: deprecate
|
|
|
|
#include <__functional/unary_negate.h>
|
2021-06-10 07:10:17 +08:00
|
|
|
#include <__functional/unwrap_ref.h>
|
2021-06-05 10:47:47 +08:00
|
|
|
#include <__utility/forward.h>
|
2021-04-23 08:33:04 +08:00
|
|
|
#include <concepts>
|
2010-05-12 03:42:16 +08:00
|
|
|
#include <exception>
|
|
|
|
#include <memory>
|
|
|
|
#include <tuple>
|
2021-05-19 23:57:04 +08:00
|
|
|
#include <type_traits>
|
|
|
|
#include <typeinfo>
|
2017-01-21 08:02:12 +08:00
|
|
|
#include <utility>
|
2018-09-13 03:41:40 +08:00
|
|
|
#include <version>
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2011-10-18 04:05:10 +08:00
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
2010-05-12 03:42:16 +08:00
|
|
|
#pragma GCC system_header
|
2011-10-18 04:05:10 +08:00
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2021-04-21 00:03:32 +08:00
|
|
|
#endif // _LIBCPP_FUNCTIONAL
|