[all-commits] [llvm/llvm-project] 5d10b8: [ADT] Add resize_for_overwrite method to SmallVector.

Nathan James via All-commits all-commits at lists.llvm.org
Tue Dec 22 09:23:34 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 5d10b8ad595da87bec8c66ad70a8daf86cd9266b
      https://github.com/llvm/llvm-project/commit/5d10b8ad595da87bec8c66ad70a8daf86cd9266b
  Author: Nathan James <n.james93 at hotmail.co.uk>
  Date:   2020-12-22 (Tue, 22 Dec 2020)

  Changed paths:
    M llvm/include/llvm/ADT/SmallVector.h
    M llvm/unittests/ADT/SmallVectorTest.cpp

  Log Message:
  -----------
  [ADT] Add resize_for_overwrite method to SmallVector.

Analagous to the std::make_(unqiue|shared)_for_overwrite added in c++20.
If T is POD, and the container gets larger, any new values added wont be initialized.
This is useful when using SmallVector as a buffer where its planned to overwrite any potential new values added.
If T is not POD, `new (Storage) T` functions identically to `new (Storage) T()` so this will function identically to `resize(size_type)`.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93532




More information about the All-commits mailing list