std::experi...on::function(3)
π
std::experi...on::function(3) π
okay so welcome to the std::experi...on::function(3) page from the C++ Standard Libary β yes bestie, that's the manual name, I'm folding it in here instead of copying the header line, periodt. π
β¨ NAME β¨
std::experimental::function::function - std::experimental::function::function
π Synopsis π
okay so here's the overload lineup, kept exactly as the page gives it, with the <lavender>library fundamentals TS</lavender> / <lavender>library fundamentals TS v3</lavender> notes where they belong:
function() noexcept;β (1) β library fundamentals TSfunction( std::nullptr_t ) noexcept;β (2) β library fundamentals TSfunction( const function& other );β (3) β library fundamentals TSfunction( function&& other );β (4) β library fundamentals TStemplate< class F > function( F f );β (5) β library fundamentals TStemplate< class Alloc > function( std::allocator_arg_t, const Alloc& alloc ) noexcept;β library fundamentals TSfunction( std::allocator_arg_t, const allocator_type& alloc ) noexcept;β library fundamentals TS v3template< class Alloc > function( std::allocator_arg_t, const Alloc& alloc, std::nullptr_t ) noexcept;β library fundamentals TSfunction( std::allocator_arg_t, const allocator_type& alloc, std::nullptr_t ) noexcept;β library fundamentals TS v3template< class Alloc > function( std::allocator_arg_t, const Alloc& alloc, const function& other );β (6) β library fundamentals TSfunction( std::allocator_arg_t, const allocator_type& alloc, const function& other );β (7) β library fundamentals TS v3template< class Alloc > function( std::allocator_arg_t, const Alloc& alloc, function&& other );β (8) β library fundamentals TSfunction( std::allocator_arg_t, const allocator_type& alloc, function&& other );β (9) β library fundamentals TS v3template< class F, class Alloc > function( std::allocator_arg_t, const Alloc& alloc, F f );β (10) β library fundamentals TSfunction( std::allocator_arg_t, const allocator_type& alloc, F f );β library fundamentals TS v3
Constructs a std::experimental::function from a variety of sources. iconic behavior honestly π
- 1,2) Creates an empty
function. - 3) Copies the target of
otherto the target of*this. Ifotheris empty,*thiswill be empty after the call too. - 4) Moves the target of
otherto the target of*this. Ifotheris empty,*thiswill be empty after the call too. After construction,*thisstores a copy ofother.get_allocator(). (library fundamentals TS v3) - 5) Initializes the target with a copy of
f. Iffis a null pointer to function or null pointer to member,*thiswill be empty after the call. This constructor does not participate in overload resolution unlessfisCallablefor argument typesArgs...and return typeR. - 6-10) Same as (1-5) except that
allocis used to allocate memory for any internal data structures that the function might use. These constructors treatallocas a type-erased allocator (see below). (until library fundamentals TS v3)
After construction via (1-5), this->get_memory_resource() returns the same value as std::experimental::pmr::get_default_resource() during construction. (library fundamentals TS) (until library fundamentals TS v3)
After construction via (1-3) and (5), *this stores a default constructed std::pmr::polymorphic_allocator<>. (library fundamentals TS v3)
When the target is a function pointer or a std::reference_wrapper, small object optimization is guaranteed β that is, these targets are always directly stored inside the std::experimental::function object, and no dynamic allocation takes place. Other large objects may be constructed in dynamic allocated storage and accessed by the std::experimental::function object through a pointer. π¦
If a constructor moves or copies a function object, including an instance of std::experimental::function, then that move or copy is performed by using-allocator construction with allocator this->get_memory_resource() (until library fundamentals TS v3) this->get_allocator() (library fundamentals TS v3).
π Parameters π
otherβ the function object used to initialize*thisfβ a callable used to initialize*thisallocβ an allocator used for internal memory allocation
π Type requirements π
Fmust meet the requirements ofCallableandCopyConstructible.
π Exceptions π
- 3,8) Does not throw if
other's target is a function pointer or astd::reference_wrapper, otherwise may throwstd::bad_allocor any exception thrown by the copy constructor of the stored callable object. - 4) (none)
- 5,10) Does not throw if
fis a function pointer or astd::reference_wrapper, otherwise may throwstd::bad_allocor any exception thrown by the copy constructor of the stored callable object. - 9) (none)
π₯ Example π₯
This section is incomplete
Reason: no example
β Category β
* Todo no example
okay bestie, that's the whole page, no skips, no missing flags, no invented lore π
Source/version/date sign-off: this one came from http://cppreference.com, dated 2024.06.10, and the footer label is std::experi...on::function(3). πβ¨π«Ά
π¦ 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