Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. constexpr iterator T_fill_insert(difference_type offset, size_type n, const T &x) {
  2.             const auto old_size = size_;
  3.             /* check if reallocation is needed */
  4.             T_grow(size_ + n);
  5.             size_ += n;
  6.             /* get the iterator at offset */
  7.             iterator pos = begin() + offset;
  8.             /* we can move already initialized parts of memory
  9.              * that we can move */
  10.             std::move(pos,begin()+old_size-n,pos+n);
  11.             std::uninitialized_move(pos+old_size-n, end(), end()-n);
  12.             std::uninitialized_fill(pos, pos + n, x);
  13.             return pos;
  14.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement