| Technical Specification | ||||
| Filesystem library(filesystem TS) | ||||
| Library fundamentals(library fundamentals TS) | ||||
| Library fundamentals 2(library fundamentals TS v2) | ||||
| Library fundamentals 3(library fundamentals TS v3) | ||||
| Extensions for parallelism(parallelism TS) | ||||
| Extensions for parallelism 2(parallelism TS v2) | ||||
| Extensions for concurrency(concurrency TS) | ||||
| Extensions for concurrency 2(concurrency TS v2) | ||||
| Concepts(concepts TS) | ||||
| Ranges(ranges TS) | ||||
| Reflection(reflection TS) | ||||
| Mathematical special functions(special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
experimental::not_fn | ||||
![]() | Merged into ISO C++ The functionality described on this page was merged into the mainline ISO C++ standard as of 3/2016, seestd::not_fn(since C++17) |
Defined in header <experimental/functional> | ||
template<class F> /*unspecified*/ not_fn( F&& f); | (library fundamentals TS v2) | |
Creates a forwarding call wrapper that returns the complement of the callable object it holds.
Contents |
| f | - | the object from which theCallable object held by the wrapper is constructed |
LetFD bestd::decay_t<F> andfd be an lvalue of typeFD constructed fromstd::forward<F>(f).
not_fn returns a forwarding call wrapperfn of unspecified type such thatfn(a1, a2, ..., aN) is equivalent to!INVOKE(fd, a1, ..., aN), whereINVOKE is the operation described inCallable.
The returned call wrapper is alwaysMoveConstructible, and isCopyConstructible if FD isCopyConstructible.
Iffd is notCallable, orstd::is_constructible<FD, F>::value is nottrue, the behavior is undefined.
Throws no exceptions, unless the construction offd throws.
namespace detail{template<class F>struct not_fn_t{ F f;template<class...Args>auto operator()(Args&&...args)noexcept(noexcept(!std::invoke(f,std::forward<Args>(args)...)))-> decltype(!std::invoke(f,std::forward<Args>(args)...)){return!std::invoke(f,std::forward<Args>(args)...);} // cv-qualified overload for QoItemplate<class...Args>auto operator()(Args&&...args)constnoexcept(noexcept(!std::invoke(f,std::forward<Args>(args)...)))-> decltype(!std::invoke(f,std::forward<Args>(args)...)){return!std::invoke(f,std::forward<Args>(args)...);} template<class...Args>auto operator()(Args&&...args)volatilenoexcept(noexcept(!std::invoke(f,std::forward<Args>(args)...)))-> decltype(!std::invoke(f,std::forward<Args>(args)...)){return!std::invoke(f,std::forward<Args>(args)...);}template<class...Args>auto operator()(Args&&...args)constvolatilenoexcept(noexcept(!std::invoke(f,std::forward<Args>(args)...)))-> decltype(!std::invoke(f,std::forward<Args>(args)...)){return!std::invoke(f,std::forward<Args>(args)...);}};} template<class F>detail::not_fn_t<std::decay_t<F>> not_fn(F&& f){return{std::forward<F>(f)};} |
not_fn is intended to replace the C++03-era negatorsstd::not1 andstd::not2.
(C++17) | creates a function object that returns the complement of the result of the function object it holds (function template)[edit] |