Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::copyable_function

      From cppreference.com
      <cpp‎ |utility‎ |functional
       
       
      Utilities library
       
      Function objects
      Function wrappers
      (C++11)
      copyable_function
      (C++26)
      (C++11)
      Function invocation
      (C++17)(C++23)
      Identity function object
      (C++20)
      Old binders and adaptors
      (until C++17*)
      (until C++17*)
      (until C++17*)
      (until C++17*)  
      (until C++17*)
      (until C++17*)(until C++17*)(until C++17*)(until C++17*)
      (until C++20*)
      (until C++20*)
      (until C++17*)(until C++17*)
      (until C++17*)(until C++17*)

      (until C++17*)
      (until C++17*)(until C++17*)(until C++17*)(until C++17*)
      (until C++20*)
      (until C++20*)
       
       
      Defined in header<functional>
      template<class...>
      class copyable_function;// not defined
      (1)(since C++26)
      template<class R,class...Args>

      class copyable_function<R(Args...)>;
      template<class R,class...Args>
      class copyable_function<R(Args...)noexcept>;
      template<class R,class...Args>
      class copyable_function<R(Args...)&>;
      template<class R,class...Args>
      class copyable_function<R(Args...)&noexcept>;
      template<class R,class...Args>
      class copyable_function<R(Args...)&&>;
      template<class R,class...Args>
      class copyable_function<R(Args...)&&noexcept>;
      template<class R,class...Args>
      class copyable_function<R(Args...)const>;
      template<class R,class...Args>
      class copyable_function<R(Args...)constnoexcept>;
      template<class R,class...Args>
      class copyable_function<R(Args...)const&>;
      template<class R,class...Args>
      class copyable_function<R(Args...)const&noexcept>;
      template<class R,class...Args>
      class copyable_function<R(Args...)const&&>;
      template<class R,class...Args>

      class copyable_function<R(Args...)const&&noexcept>;
      (2)(since C++26)

      Class templatestd::copyable_function is a general-purpose polymorphic function wrapper.std::copyable_function objects can store and invoke anyCopyConstructibleCallabletarget — functions,lambda expressions,bind expressions, or other function objects, as well as pointers to member functions and pointers to member objects.

      The stored callable object is called thetarget ofstd::copyable_function. If astd::copyable_function contains no target, it is calledempty. Unlikestd::function, invoking anemptystd::copyable_function results in undefined behavior.

      std::copyable_functions supports every possible combination ofcv-qualifiers (not includingvolatile),ref-qualifiers, andnoexcept-specifiers provided in its template parameter. These qualifiers and specifier (if any) are added to itsoperator().

      std::copyable_function satisfies the requirements ofCopyConstructible andCopyAssignable.

      Contents

      [edit]Member types

      Type Definition
      result_typeR

      [edit]Member functions

      constructs a newstd::copyable_function object
      (public member function)[edit]
      destroys astd::copyable_function object
      (public member function)[edit]
      replaces or destroys the target
      (public member function)[edit]
      swaps the targets of twostd::copyable_function objects
      (public member function)[edit]
      checks if thestd::copyable_function has a target
      (public member function)[edit]
      invokes the target
      (public member function)[edit]

      [edit]Non-member functions

      overloads thestd::swap algorithm
      (function)[edit]
      (C++26)
      compares astd::copyable_function withnullptr
      (function)[edit]

      [edit]Notes

      Implementations may store a callable object of small size within thestd::copyable_function object. Such small object optimization is effectively required for function pointers andstd::reference_wrapper specializations, and can only be applied to typesT for whichstd::is_nothrow_move_constructible_v<T> istrue.

      Feature-test macroValueStdFeature
      __cpp_lib_copyable_function202306L(C++26)std::copyable_function

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      (C++11)
      copyable wrapper of any copy constructible callable object
      (class template)[edit]
      move-only wrapper of any callable object that supports qualifiers in a given call signature
      (class template)[edit]
      non-owning wrapper of any callable object
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/functional/copyable_function&oldid=178281"

      [8]ページ先頭

      ©2009-2025 Movatter.jp