std::experi...al::function(3)
π¦ NAME π¦
okay bestie, meet std::experimental::function β yes that's the whole name section, it literally just says its own name back at you π
. This page lives in the C++ Standard Libary manual (section 3), and we're gonna get you comfy with it, fr fr.
β¨ Synopsis β¨
So first things first, it's chillin' in this header:
Defined in header <experimental/functional>
and here's the shape of it β the primary template is lowkey undefined, which is giving "do not touch" energy:
template< class >
class function; /* undefined */
template< class R, class... Args >
class function<R(Args...)>
both of those are (library fundamentals TS) by the way π«Ά
And what is it? Okay so β std::experimental::function is a modified version of std::function with support for type-erased allocators. That's the whole glow-up. Periodt. π
π Member types π
allocator_typeβ defined asstd::experimental::erased_type(library fundamentals TS) β until library fundamentals TS v3allocator_typeβ defined asstd::pmr::polymorphic_allocator<>(library fundamentals TS v3) π¦
(yes, allocator_type shows up twice β the definition switches over at TS v3, iykyk)
π Member functions π
constructorβ constructs a newstd::experimental::functioninstance (public member function)operator=β assigns a new target (public member function)swapβ swaps the contents (public member function)get_memory_resourceβ retrieves a pointer to the memory resource used by this object to allocate memory (public member function) β removed in library fundamentals TS v3 β°οΈget_allocatorβ retrieves a type-erasedstd::pmr::polymorphic_allocatorused by this object to allocate memory (public member function) β library fundamentals TS v3 β¨
πΈ Non-member functions πΈ
std::experimental::swap(std::experimental::function)β specializes theswapalgorithm (function template)operator==/operator!=β compares anstd::experimental::functionwithnullptr(function template) β removed in library fundamentals TS v3 π
π§ Helper classes π§
std::uses_allocator<std::experimental::function>β specializes thestd::uses_allocatortype trait (class template specialization) β removed in library fundamentals TS v3 π
π Members identical to std::function π
bestie, everything under here is the same as std::function β no cap, it's a straight carryover π«Ά
β Member types β
result_typeβR
π Member types removed in Library Fundamental TS v3 π
argument_typeβTifsizeof...(Args) == 1andTis the first and only type inArgs...first_argument_typeβT1ifsizeof...(Args) == 2andT1is the first of the two types inArgs...second_argument_typeβT2ifsizeof...(Args) == 2andT2is the second of the two types inArgs...
little note: member typesargument_type,first_argument_type, andsecond_argument_typeare removed, because the corresponding member types ofstd::functionare removed in C++20. they're gone-gone, (library fundamentals TS v3) said so π
π Member functions π
- destructor β destroys a
std::functioninstance (public member function ofstd::function<R(Args...)>) operator boolβ checks if a target is contained (public member function ofstd::function<R(Args...)>)operator()β invokes the target (public member function ofstd::function<R(Args...)>)
π Target access π
target_typeβ obtains thetypeidof the stored target (public member function ofstd::function<R(Args...)>)targetβ obtains a pointer to the stored target (public member function ofstd::function<R(Args...)>)
okay that's the whole page and you ate it up, I'm so proud ππ this came from cppreference.com, dated 2024.06.10, and it's the std::experi...al::function(3) page of the C++ Standard Libary manual β go forth and allocator-erase, bestie ππ¦β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms