Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::inplace_vector<T,N>::append_range

      From cppreference.com
      <cpp‎ |container‎ |inplace vector

      [edit template]
       
       
       
      std::inplace_vector
      Member types
      Member functions
      Non-member functions
       
      template<container-compatible-range<T> R>
      constexprvoid append_range( R&& rg);
      (since C++26)

      Inserts copies of elements from the rangerg beforeend(), in non-reversing order.


      Each iterator inrg is dereferenced exactly once.

      Contents

      [edit]Parameters

      rg - acontainer compatible range, that is, aninput_range whose elements are convertible toT
      Type requirements
      -
      IfT is notEmplaceConstructible intoinplace_vector from*ranges::begin(rg), the behavior is undefined.

      [edit]Complexity

      Linear in size ofrg. The number of calls to the constructor ofT is exactly equal to thestd::ranges::size(rg)).

      [edit]Exceptions

      Throwsstd::bad_alloc ifstd::ranges::size(rg)> N.If an exception is thrown other than by the copy constructor, move constructor, assignment operator, or move assignment operator ofT or by anyInputIterator operation, there are no effects.Otherwise, if an exception is thrown, thensize()>= n and elements in the range[0n) are not modified,wheren is the value ofsize() before this call.

      [edit]Example

      Run this code
      #include <cassert>#include <inplace_vector>#include <iostream> int main(){using I=std::inplace_vector<int,8>; auto head= I{1,2,3,4};constauto tail={-5,-6,-7};    head.append_range(tail);assert(head.size()==7 and(head== I{1,2,3,4,-5,-6,-7})); try{        head.append_range(tail);// throws: no space}catch(conststd::bad_alloc&){std::cout<<"std::bad_alloc\n";}}

      Output:

      std::bad_alloc

      [edit]See also

      tries to add a range of elements to the end
      (public member function)
      inserts a range of elements
      (public member function)
      adds an element to the end
      (public member function)
      constructs an element in-place at the end
      (public member function)
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/container/inplace_vector/append_range&oldid=175474"

      [8]ページ先頭

      ©2009-2026 Movatter.jp