Files
cppdraft_translate/cppdraft/functional/syn.md
2025-10-25 03:02:53 +03:00

10 KiB

[functional.syn]

22 General utilities library [utilities]

22.10 Function objects [function.objects]

22.10.2 Header synopsis [functional.syn]

🔗

namespace std {// [func.invoke], invoketemplate<class F, class... Args>constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args) // freestandingnoexcept(is_nothrow_invocable_v<F, Args...>); template<class R, class F, class... Args>constexpr R invoke_r(F&& f, Args&&... args) // freestandingnoexcept(is_nothrow_invocable_r_v<R, F, Args...>); // [refwrap], reference_wrappertemplate class reference_wrapper; // freestandingtemplate constexpr reference_wrapper ref(T&) noexcept; // freestandingtemplate constexpr reference_wrapper cref(const T&) noexcept; // freestandingtemplate void ref(const T&&) = delete; // freestandingtemplate void cref(const T&&) = delete; // freestandingtemplateconstexpr reference_wrapper ref(reference_wrapper) noexcept; // freestandingtemplateconstexpr reference_wrapper cref(reference_wrapper) noexcept; // freestanding// [refwrap.common.ref], common_reference related specializationstemplate<class R, class T, template class RQual, template class TQual>requires see belowstruct basic_common_reference<R, T, RQual, TQual>; template<class T, class R, template class TQual, template class RQual>requires see belowstruct basic_common_reference<T, R, TQual, RQual>; // [arithmetic.operations], arithmetic operationstemplate struct plus; // freestandingtemplate struct minus; // freestandingtemplate struct multiplies; // freestandingtemplate struct divides; // freestandingtemplate struct modulus; // freestandingtemplate struct negate; // freestandingtemplate<> struct plus; // freestandingtemplate<> struct minus; // freestandingtemplate<> struct multiplies; // freestandingtemplate<> struct divides; // freestandingtemplate<> struct modulus; // freestandingtemplate<> struct negate; // freestanding// [comparisons], comparisonstemplate struct equal_to; // freestandingtemplate struct not_equal_to; // freestandingtemplate struct greater; // freestandingtemplate struct less; // freestandingtemplate struct greater_equal; // freestandingtemplate struct less_equal; // freestandingtemplate<> struct equal_to; // freestandingtemplate<> struct not_equal_to; // freestandingtemplate<> struct greater; // freestandingtemplate<> struct less; // freestandingtemplate<> struct greater_equal; // freestandingtemplate<> struct less_equal; // freestanding// [comparisons.three.way], class compare_three_waystruct compare_three_way; // freestanding// [logical.operations], logical operationstemplate struct logical_and; // freestandingtemplate struct logical_or; // freestandingtemplate struct logical_not; // freestandingtemplate<> struct logical_and; // freestandingtemplate<> struct logical_or; // freestandingtemplate<> struct logical_not; // freestanding// [bitwise.operations], bitwise operationstemplate struct bit_and; // freestandingtemplate struct bit_or; // freestandingtemplate struct bit_xor; // freestandingtemplate struct bit_not; // freestandingtemplate<> struct bit_and; // freestandingtemplate<> struct bit_or; // freestandingtemplate<> struct bit_xor; // freestandingtemplate<> struct bit_not; // freestanding// [func.identity], identitystruct identity; // freestanding// [func.not.fn], function template not_fntemplate constexpr unspecified not_fn(F&& f); // freestandingtemplate constexpr unspecified not_fn() noexcept; // freestanding// [func.bind.partial], function templates bind_front and bind_backtemplate<class F, class... Args>constexpr unspecified bind_front(F&&, Args&&...); // freestandingtemplate<auto f, class... Args>constexpr unspecified bind_front(Args&&...); // freestandingtemplate<class F, class... Args>constexpr unspecified bind_back(F&&, Args&&...); // freestandingtemplate<auto f, class... Args>constexpr unspecified bind_back(Args&&...); // freestanding// [func.bind], bindtemplate struct is_bind_expression; // freestandingtemplateconstexpr bool is_bind_expression_v = // freestanding is_bind_expression::value; template struct is_placeholder; // freestandingtemplateconstexpr int is_placeholder_v = // freestanding is_placeholder::value; template<class F, class... BoundArgs>constexpr unspecified bind(F&&, BoundArgs&&...); // freestandingtemplate<class R, class F, class... BoundArgs>constexpr unspecified bind(F&&, BoundArgs&&...); // freestandingnamespace placeholders {// M is the implementation-defined number of placeholderssee below _1; // freestandingsee below _2; // freestanding ⋮ see below _M; // freestanding}// [func.memfn], member function adaptorstemplate<class R, class T>constexpr unspecified mem_fn(R T::*) noexcept; // freestanding// [func.wrap], polymorphic function wrappers// [func.wrap.badcall], class bad_function_callclass bad_function_call; // [func.wrap.func], class template functiontemplate class function; // not definedtemplate<class R, class... ArgTypes> class function<R(ArgTypes...)>; // [func.wrap.func.alg], function specialized algorithmstemplate<class R, class... ArgTypes>void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept; // [func.wrap.func.nullptr], function null pointer comparison operator functionstemplate<class R, class... ArgTypes>bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept; // [func.wrap.move], move-only wrappertemplate<class... S> class move_only_function; // not definedtemplate<class R, class... ArgTypes>class move_only_function<R(ArgTypes...) cv ref noexcept(noex)>; // see below// [func.wrap.copy], copyable wrappertemplate<class... S> class copyable_function; // not definedtemplate<class R, class... ArgTypes>class copyable_function<R(ArgTypes...) cv ref noexcept(noex)>; // see below// [func.wrap.ref], non-owning wrappertemplate<class... S> class function_ref; // freestanding, not definedtemplate<class R, class... ArgTypes>class function_ref<R(ArgTypes...) cv noexcept(noex)>; // freestanding, see below// [func.search], searcherstemplate<class ForwardIterator1, class BinaryPredicate = equal_to<>>class default_searcher; // freestandingtemplate<class RandomAccessIterator, class Hash = hash<typename iterator_traits::value_type>, class BinaryPredicate = equal_to<>>class boyer_moore_searcher; template<class RandomAccessIterator, class Hash = hash<typename iterator_traits::value_type>, class BinaryPredicate = equal_to<>>class boyer_moore_horspool_searcher; // [unord.hash], class template hashtemplatestruct hash; // freestandingnamespace ranges {// [range.cmp], concept-constrained comparisonsstruct equal_to; // freestandingstruct not_equal_to; // freestandingstruct greater; // freestandingstruct less; // freestandingstruct greater_equal; // freestandingstruct less_equal; // freestanding}template<class Fn, class... Args>concept callable = // exposition onlyrequires (Fn&& fn, Args&&... args) { std::forward(fn)(std::forward(args)...); }; template<class Fn, class... Args>concept nothrow-callable = // exposition onlycallable<Fn, Args...> &&requires (Fn&& fn, Args&&... args) {{ std::forward(fn)(std::forward(args)...) } noexcept; }; template<class Fn, class... Args>using call-result-t = decltype(declval()(declval()...)); // exposition onlytemplate<const auto& T>using decayed-typeof = decltype(auto(T)); // exposition only}

1

#

[Example 1:

If a C++ program wants to have a by-element addition of two vectors a and b containing double and put the result into a, it can do:transform(a.begin(), a.end(), b.begin(), a.begin(), plus());

— end example]

2

#

[Example 2:

To negate every element of a:

transform(a.begin(), a.end(), a.begin(), negate()); — end example]