Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::not_fn

      From cppreference.com
      <cpp‎ |experimental
       
       
       
       
      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

      [edit] Parameters

      f - the object from which theCallable object held by the wrapper is constructed

      [edit]Return value

      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.

      [edit] Remarks

      Iffd is notCallable, orstd::is_constructible<FD, F>::value is nottrue, the behavior is undefined.

      [edit] Exceptions

      Throws no exceptions, unless the construction offd throws.

      [edit] Possible implementation

      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)};}

      [edit] Notes

      not_fn is intended to replace the C++03-era negatorsstd::not1 andstd::not2.

      [edit] See also

      (C++17)
      creates a function object that returns the complement of the result of the function object it holds
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/not_fn&oldid=103392"

      [8]ページ先頭

      ©2009-2025 Movatter.jp