<experimental/functional> synopsis#include <functional>
namespace std {
namespace experimental::inline fundamentals_v3 {
template<class> class function; // not defined
template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
template<class R, class... ArgTypes>
void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
template<class R, class... ArgTypes>
bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
} // namespace experimental::inline fundamentals_v3
} // namespace std
function
The specification of all declarations within subclause std::experimental::function uses
std::bad_function_call, there is no additional type std::experimental::bad_function_call
namespace std {
namespace experimental::inline fundamentals_v3 {
template<class> class function; // undefined
template<class R, class... ArgTypes>
class function<R(ArgTypes...)> {
public:
using result_type = R;
using allocator_type = std::pmr::polymorphic_allocator<>;
function() noexcept;
function(nullptr_t) noexcept;
function(const function&);
function(function&&);
template<class F> function(F);
function(allocator_arg_t, const allocator_type&) noexcept;
function(allocator_arg_t, const allocator_type&, nullptr_t) noexcept;
function(allocator_arg_t, const allocator_type&, const function&);
function(allocator_arg_t, const allocator_type&, function&&);
template<class F> function(allocator_arg_t, const allocator_type&, F);
function& operator=(const function&);
function& operator=(function&&);
function& operator=(nullptr_t) noexcept;
template<class F> function& operator=(F&&);
template<class F> function& operator=(reference_wrapper<F>);
~function();
void swap(function&);
explicit operator bool() const noexcept;
R operator()(ArgTypes...) const;
const type_info& target_type() const noexcept;
template<class T> T* target() noexcept;
template<class T> const T* target() const noexcept;
allocator_type get_allocator() const noexcept;
};
template <class R, class... ArgTypes>
function(R(*)(ArgTypes...)) -> function<R(ArgTypes...)>;
template<class F>
function(F) -> function<see below>;
} // namespace experimental::inline fundamentals_v3
} // namespace std
A function object stores an allocator object of type std::pmr::polymorphic_allocator<>,
which it uses to allocate memory for its internal data structures.
In the function constructors, the allocator is initialized
(before the target object, if any) as follows:
f.get_allocator(), where f is the
parameter of the constructor.
allocator_arg_t,
the allocator is initialized from the second parameter.
In all cases, the allocator of a parameter having type function&& is unchanged.
If the constructor creates a target object, that target object is initialized
by uses-allocator construction with the allocator and other target object constructor arguments.
experimental::function&&
has an allocator equal to that of the object being constructed,
the implementation can often transfer ownership of the target rather than constructing a new one.
The deduction guide template<class F> function(F) -> function<see below>;
is specified in
function(allocator_arg, get_allocator(), f).swap(*this);*this.function(allocator_arg, get_allocator(), std::move(f)).swap(*this);*this.*this != nullptr, destroys the target of this.!(*this).
*this.declval<decay_t<F>&>() is ArgTypes... and return type R.
function(allocator_arg, get_allocator(), std::forward<F>(f)).swap(*this);*this.function(allocator_arg, get_allocator(), f).swap(*this);*this.this->get_allocator() == other.get_allocator().*this and other.*this and other are not interchanged.