Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::polymorphic<T, Allocator>::swap

      From cppreference.com
      <cpp‎ |memory‎ |polymorphic
       
       
      Memory management library
      (exposition only*)
      Allocators
      Uninitialized memory algorithms
      Constrained uninitialized memory algorithms
      Memory resources
      Uninitialized storage(until C++20)
      (until C++20*)
      (until C++20*)
      Garbage collector support(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
       
       
      constexprvoid swap( polymorphic& other)noexcept(/* see below */);
      (since C++26)

      Swaps the contents with those ofother.

      In the description below,swap_allocators refers tostd::allocator_traits<Allocator>::propagate_on_container_swap::value.

      Swaps the states of*this andother, exchanging owned objects or valueless states.

      • Ifswap_allocators istrue, then executesusingstd::swap;
        swap(alloc , other.alloc );
        .
      • Otherwise, the allocators are not swapped.

      If one of the following conditions is satisfied, the behavior is undefined:

      • swap_allocators istrue, andAllocator does not satisfy the requirements ofSwappable.
      • swap_allocators isfalse, andget_allocator()== other.get_allocator() isfalse.

      Contents

      [edit]Parameters

      other - thepolymorphic object to exchange the contents with

      [edit]Exceptions

      noexcept specification:  
      noexcept(std::allocator_traits<Allocator>::propagate_on_container_swap::value
                   ||std::allocator_traits<Allocator>::is_always_equal::value)

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      specializes thestd::swap algorithm
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/memory/polymorphic/swap&oldid=182608"

      [8]ページ先頭

      ©2009-2025 Movatter.jp