diff options
Diffstat (limited to 'llvm/include/llvm/ADT/SmallVector.h')
-rw-r--r-- | llvm/include/llvm/ADT/SmallVector.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index 17586904d212..8c46aa906905 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -907,6 +907,17 @@ inline size_t capacity_in_bytes(const SmallVector<T, N> &X) { return X.capacity_in_bytes(); } +/// Given a range of type R, iterate the entire range and return a +/// SmallVector with elements of the vector. This is useful, for example, +/// when you want to iterate a range and then sort the results. +template <unsigned Size, typename R> +SmallVector<typename std::remove_const<typename std::remove_reference< + decltype(*std::begin(std::declval<R &>()))>::type>::type, + Size> +to_vector(R &&Range) { + return {std::begin(Range), std::end(Range)}; +} + } // end namespace llvm namespace std { |