From 049043b598ef5b12a5894c0c22db8608be70f517 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 20 Nov 2019 15:59:16 -0800 Subject: [PATCH] [ADT] Move to_vector from STLExtras.h to SmallVector.h Nothing breaks, so this probably has zero impact, but it seems nice, since to_vector is more like makeArrayRef, and should really live in SmallVector.h. --- llvm/include/llvm/ADT/STLExtras.h | 14 -------------- llvm/include/llvm/ADT/SmallVector.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h index 32b052e..f0fe4fd 100644 --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -17,7 +17,6 @@ #define LLVM_ADT_STLEXTRAS_H #include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Config/abi-breaking.h" @@ -51,10 +50,6 @@ namespace detail { template using IterOfRange = decltype(std::begin(std::declval())); -template -using ValueOfRange = typename std::remove_reference()))>::type; - } // end namespace detail //===----------------------------------------------------------------------===// @@ -1334,15 +1329,6 @@ bool is_splat(R &&Range) { std::equal(adl_begin(Range) + 1, adl_end(Range), adl_begin(Range))); } -/// 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 -SmallVector>::type, Size> -to_vector(R &&Range) { - return {adl_begin(Range), adl_end(Range)}; -} - /// Provide a container algorithm similar to C++ Library Fundamentals v2's /// `erase_if` which is equivalent to: /// diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index 1758690..8c46aa9 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 &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 +SmallVector()))>::type>::type, + Size> +to_vector(R &&Range) { + return {std::begin(Range), std::end(Range)}; +} + } // end namespace llvm namespace std { -- 2.7.4