Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::function<R(Args...)>::operator=

      From cppreference.com
      <cpp‎ |experimental‎ |function
       
       
       
       
       
      function& operator=(const function& other);
      (1)(library fundamentals TS)
      function& operator=( function&& other);
      (2)(library fundamentals TS)
      function& operator=(std::nullptr_t)noexcept;
      (3)(library fundamentals TS)
      template<class F>
      function& operator=( F&& f);
      (4)(library fundamentals TS)
      (5)
      template<class F>
      function& operator=(std::reference_wrapper<F> f);
      (library fundamentals TS)
      template<class F>
      function& operator=(std::reference_wrapper<F> f)noexcept;
      (library fundamentals TS v3)

      Assigns a newtarget tostd::experimental::function. In the description below, letALLOCATOR_OF(f) be the allocator specified in the construction off, orthe value ofstd::experimental::pmr::get_default_resource()(until library fundamentals TS v3)the default-constructedstd::pmr::polymorphic_allocator<> value(library fundamentals TS v3) at the time of construction if no allocator was specified.

      1) Assigns a copy oftarget ofother, as if by executingfunction(std::allocator_arg, ALLOCATOR_OF(*this), other).swap(*this);.
      2) Moves thetarget ofother to*this, as if by executingfunction(std::allocator_arg, ALLOCATOR_OF(*this), std::move(other)).swap(*this);.other is in a valid state with an unspecified value.
      3) Destroys thetarget of*this.*this isempty after the call. The memory resource returned byget_memory_resource() after the assignment is equivalent to the memory resource before the assignment, but the address may change.
      4) Sets thetarget of*this to the callablef, as if by executingfunction(std::allocator_arg, ALLOCATOR_OF(*this),std::forward<F>(f)).swap(*this);. This operator does not participate in overload resolution unlessf isCallable for argument typesArgs... and return typeR.
      5) Sets thetarget of*this to a copy off, as if by executingfunction(std::allocator_arg, ALLOCATOR_OF(*this), f).swap(*this);.

      Contents

      [edit]Parameters

      other - anotherstd::experimental::function object to copy or move from
      f - a callable to initialize thetarget with
      Type requirements
      -
      F must meet the requirements ofCallable.

      [edit]Return value

      *this

      [edit]Exceptions

      1,2,4) Exception thrown on needed allocation of the storage or initialization of the target of*this, if any.
      5) (none)

      [edit]Notes

      The move assignment operator may need to allocate storage ifget_memory_resource()!= other.get_memory_resource()(until library fundamentals TS v3)get_allocator()!= other.get_allocator()(library fundamentals TS v3)

      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/function/operator%3D&oldid=154959"

      [8]ページ先頭

      ©2009-2025 Movatter.jp