Defined in header
<functional> | ||
---|---|---|
template< class F> /*unspecified*/ not_fn( F&& f ); | (since C++17) |
Creates a forwarding call wrapper that returns the complement of the callable object it holds.
f | - | the object from which the Callable object held by the wrapper is constructed |
Type requirements | ||
-
std::decay_t<F> must meet the requirements of Callable and MoveConstructible . |
||
-
std::is_constructible_v<std::decay_t<F>, F> is required to be true |
A function object of unspecified type T. It has the following members:
The return type of std::not_fn
holds a member object of type std::decay_t<F>
.
explicit T(F&& f); | (1) | |
T(T&& f) = default; T(const T& f) = default; | (2) |
std::decay_t<F>
) from std::forward<F>(f)
. Throws any exception thrown by the constructor selectedstd::decay_t<F>
is required to be MoveConstructible
, the returned call wrapper is always MoveConstructible
, and is CopyConstructible
if std::decay_t<F>
is CopyConstructible
.operator()
template<class... Args> auto operator()(Args&&... args) & -> decltype(!std::declval<std::result_of_t<std::decay_t<F>&(Args...)>>()); template<class... Args> auto operator()(Args&&... args) const& -> decltype(!std::declval<std::result_of_t<std::decay_t<F> const&(Args...)>>()); | (1) | |
template<class... Args> auto operator()(Args&&... args) && -> decltype(!std::declval<std::result_of_t<std::decay_t<F>(Args...)>>()); template<class... Args> auto operator()(Args&&... args) const&& -> decltype(!std::declval<std::result_of_t<std::decay_t<F> const(Args...)>>()); | (2) |
return !std::invoke(fd, std::forward<Args>(args)...)
return !std::invoke(std::move(fd), std::forward<Args>(args)...)
where fd
is the member object of type std::decay_t<F>
Throws no exceptions, unless the construction of fd
throws.
not_fn
is intended to replace the C++03-era negators std::not1
and std::not2
.
(deprecated)
| constructs custom std::unary_negate object (function template) |
(deprecated)
| constructs custom std::binary_negate object (function template) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/utility/functional/not_fn