Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::deque<T,Allocator>::assign_range

      From cppreference.com
      <cpp‎ |container‎ |deque

      [edit template]
       
       
       
      std::deque
      Member types
      Member functions
      Non-member functions
      (until C++20)(until C++20)(until C++20)(until C++20)(until C++20)
      Deduction guides(C++17)
       
      template<container-compatible-range<T> R>
      void assign_range( R&& rg);
      (since C++23)
      (constexpr since C++26)

      Replaces elements in the container with a copy of each element inrg.

      All iterators (including theend() iterator) and all references to the elements are invalidated.

      Each iterator in the rangerg is dereferenced exactly once.

      Ifrg overlaps with*this, the behavior is undefined.

      Contents

      [edit]Parameters

      rg - aninput_range with reference type convertible to the element type of the container
      Type requirements
      -
      Ifstd::assignable_from<T&,ranges::range_reference_t<R>> is not modeled, the program is ill-formed.
      -
      IfT is notEmplaceConstructible intodeque from*ranges::begin(rg), the behavior is undefined.

      Notes

      Feature-test macroValueStdFeature
      __cpp_lib_containers_ranges202202L(C++23)Ranges-aware construction and insertion

      [edit]Example

      Run this code
      #include <algorithm>#include <cassert>#include <deque>#include <list> int main(){constauto source=std::list{2,7,1};auto destination=std::deque{3,1,4};#ifdef __cpp_lib_containers_ranges    destination.assign_range(source);#else    destination.assign(source.cbegin(), source.cend());#endifassert(std::ranges::equal(source, destination));}

      [edit]See also

      inserts a range of elements
      (public member function)
      adds a range of elements to the beginning
      (public member function)
      adds a range of elements to the end
      (public member function)
      assigns values to the container
      (public member function)
      assigns values to the container
      (public member function)
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/container/deque/assign_range&oldid=154716"

      [8]ページ先頭

      ©2009-2025 Movatter.jp