Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::copyable_function::copyable_function

      From cppreference.com
      <cpp‎ |utility‎ |functional‎ |copyable function
       
       
      Utilities library
       
      Function objects
      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*)
       
       
      copyable_function()noexcept;
      (1)(since C++26)
      copyable_function(std::nullptr_t)noexcept;
      (2)(since C++26)
      copyable_function(const copyable_function& other);
      (3)(since C++26)
      copyable_function( copyable_function&& other)noexcept;
      (4)(since C++26)
      template<class F>
      copyable_function( F&& f);
      (5)(since C++26)
      template<class T,class...CArgs>
      explicit copyable_function(std::in_place_type_t<T>, CArgs&&...args);
      (6)(since C++26)
      template<class T,class U,class...CArgs>

      explicit copyable_function(std::in_place_type_t<T>,

                                 std::initializer_list<U> il, CArgs&&...args);
      (7)(since C++26)

      Creates a newstd::copyable_function.

      1,2) Default constructor and the constructor takingnullptr construct an emptystd::copyable_function.
      3) Copy constructor constructs astd::copyable_function whose target is a copy of the target ofother. Otherwise, constructs an emptystd::copyable_function ifother is empty.
      4) Move constructor constructs astd::copyable_function whose target is that ofother.other is in a valid but unspecified state after move construction.
      5) LetVT bestd::decay_t<F>. Iff is a null function pointer, a null pointer to member value, or an emptystd::copyable_function (may be any other specialization), then constructs an emptystd::copyable_function. Otherwise, constructs astd::copyable_function whose target is of typeVT and direct-non-list-initialized withstd::forward<F>(f).
      6) LetVT bestd::decay_t<T>. Constructs astd::copyable_function whose target is of typeVT and direct-non-list-initialized withstd::forward<CArgs>(args)....
      7) LetVT bestd::decay_t<T>. Constructs astd::copyable_function whose target is of typeVT and direct-non-list-initialized withil,std::forward<CArgs>(args)....

      For constructors(5-7), the behavior is undefined unlessVT satisfies bothDestructible andCopyConstructible requirements.

      The constant/*is-callable-from*/<VT> is dependent oncv,ref, andnoex in the template parameter ofstd::copyable_function as below:

      cvrefnoexcept(noex)/*is-callable-from*/<VT>
      noexcept(false)std::is_invocable_r_v<R, VT, Args...>&&

      std::is_invocable_r_v<R, VT&, Args...>

      noexcept(true)std::is_nothrow_invocable_r_v<R, VT, Args...>&&

      std::is_nothrow_invocable_r_v<R, VT&, Args...>

      constnoexcept(false)std::is_invocable_r_v<R,const VT, Args...>&&

      std::is_invocable_r_v<R,const VT&, Args...>

      constnoexcept(true)std::is_nothrow_invocable_r_v<R,const VT, Args...>&&

      std::is_nothrow_invocable_r_v<R,const VT&, Args...>

      &noexcept(false)std::is_invocable_r_v<R, VT&, Args...>
      &noexcept(true)std::is_nothrow_invocable_r_v<R, VT&, Args...>
      const&noexcept(false)std::is_invocable_r_v<R,const VT&, Args...>
      const&noexcept(true)std::is_nothrow_invocable_r_v<R,const VT&, Args...>
      &&noexcept(false)std::is_invocable_r_v<R, VT, Args...>
      &&noexcept(true)std::is_nothrow_invocable_r_v<R, VT, Args...>
      const&&noexcept(false)std::is_invocable_r_v<R,const VT, Args...>
      const&&noexcept(true)std::is_nothrow_invocable_r_v<R,const VT, Args...>

      Contents

      [edit]Parameters

      other - anotherstd::copyable_function to copy or move from
      f - a function or aCallable object to wrap
      args - arguments to construct the target object
      il -std::initializer_list to construct the target object

      [edit]Exceptions

      3) May throwstd::bad_alloc on allocation failure or propagate the exception thrown by the initialization of the target.
      5-7) May throwstd::bad_alloc on allocation failure or propagate the exception thrown by the initialization of the target. No exception is thrown ifVT is a function pointer type or a specialization ofstd::reference_wrapper.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      constructs a newstd::function instance
      (public member function ofstd::function<R(Args...)>)[edit]
      constructs a newstd::move_only_function object
      (public member function ofstd::move_only_function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/functional/copyable_function/copyable_function&oldid=178047"

      [8]ページ先頭

      ©2009-2025 Movatter.jp