Skip to content

Commit

Permalink
tf: add initializer_list assignment and insertion to TfSmallVector
Browse files Browse the repository at this point in the history
(Internal change: 2076065)
  • Loading branch information
jloy authored and pixar-oss committed Jun 15, 2020
1 parent 907c30b commit 6526bf1
Show file tree
Hide file tree
Showing 2 changed files with 207 additions and 53 deletions.
20 changes: 20 additions & 0 deletions pxr/base/tf/smallVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <initializer_list>
#include <iterator>
#include <limits>
#include <memory>
Expand Down Expand Up @@ -317,6 +318,13 @@ class TfSmallVector
return *this;
}

/// Replace existing contents with the contents of \p ilist.
///
TfSmallVector &operator=(std::initializer_list<T> ilist) {
assign(ilist.begin(), ilist.end());
return *this;
}

/// Swap two vector instances.
///
void swap(TfSmallVector &rhs) {
Expand Down Expand Up @@ -481,6 +489,12 @@ class TfSmallVector
_size = newSize;
}

/// Replace existing contents with the contents of \p ilist.
///
void assign(std::initializer_list<T> ilist) {
assign(ilist.begin(), ilist.end());
}

/// Emplace an entry at the back of the vector.
///
template < typename... Args >
Expand Down Expand Up @@ -597,6 +611,12 @@ class TfSmallVector
_size += numNewElems;
}

/// Insert elements from \p ilist starting at position \p pos.
///
void insert(iterator pos, std::initializer_list<T> ilist) {
insert(pos, ilist.begin(), ilist.end());
}

/// Remove the entry at the back of the vector.
///
void pop_back() {
Expand Down
Loading

0 comments on commit 6526bf1

Please sign in to comment.