std::experi...on::function(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… 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 TS
  • function( std::nullptr_t ) noexcept; β€” (2) β€” library fundamentals TS
  • function( const function& other ); β€” (3) β€” library fundamentals TS
  • function( function&& other ); β€” (4) β€” library fundamentals TS
  • template< class F > function( F f ); β€” (5) β€” library fundamentals TS
  • template< class Alloc > function( std::allocator_arg_t, const Alloc& alloc ) noexcept; β€” library fundamentals TS
  • function( std::allocator_arg_t, const allocator_type& alloc ) noexcept; β€” library fundamentals TS v3
  • template< class Alloc > function( std::allocator_arg_t, const Alloc& alloc, std::nullptr_t ) noexcept; β€” library fundamentals TS
  • function( std::allocator_arg_t, const allocator_type& alloc, std::nullptr_t ) noexcept; β€” library fundamentals TS v3
  • template< class Alloc > function( std::allocator_arg_t, const Alloc& alloc, const function& other ); β€” (6) β€” library fundamentals TS
  • function( std::allocator_arg_t, const allocator_type& alloc, const function& other ); β€” (7) β€” library fundamentals TS v3
  • template< class Alloc > function( std::allocator_arg_t, const Alloc& alloc, function&& other ); β€” (8) β€” library fundamentals TS
  • function( std::allocator_arg_t, const allocator_type& alloc, function&& other ); β€” (9) β€” library fundamentals TS v3
  • template< class F, class Alloc > function( std::allocator_arg_t, const Alloc& alloc, F f ); β€” (10) β€” library fundamentals TS
  • function( 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 other to the target of *this. If other is empty, *this will be empty after the call too.
  • 4) Moves the target of other to the target of *this. If other is empty, *this will be empty after the call too. After construction, *this stores a copy of other.get_allocator(). (library fundamentals TS v3)
  • 5) Initializes the target with a copy of f. If f is a null pointer to function or null pointer to member, *this will be empty after the call. This constructor does not participate in overload resolution unless f is Callable for argument types Args... and return type R.
  • 6-10) Same as (1-5) except that alloc is used to allocate memory for any internal data structures that the function might use. These constructors treat alloc as 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 *this
  • f β€” a callable used to initialize *this
  • alloc β€” an allocator used for internal memory allocation

πŸŽ€ Type requirements πŸŽ€

  • F must meet the requirements of Callable and CopyConstructible.

πŸ’… Exceptions πŸ’…

  • 3,8) Does not throw if other's target is a function pointer or a std::reference_wrapper, otherwise may throw std::bad_alloc or any exception thrown by the copy constructor of the stored callable object.
  • 4) (none)
  • 5,10) Does not throw if f is a function pointer or a std::reference_wrapper, otherwise may throw std::bad_alloc or 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