Skip to content

Commit 049043b

Browse files
committed
[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.
1 parent d9957c7 commit 049043b

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

llvm/include/llvm/ADT/STLExtras.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#define LLVM_ADT_STLEXTRAS_H
1818

1919
#include "llvm/ADT/Optional.h"
20-
#include "llvm/ADT/SmallVector.h"
2120
#include "llvm/ADT/iterator.h"
2221
#include "llvm/ADT/iterator_range.h"
2322
#include "llvm/Config/abi-breaking.h"
@@ -51,10 +50,6 @@ namespace detail {
5150
template <typename RangeT>
5251
using IterOfRange = decltype(std::begin(std::declval<RangeT &>()));
5352

54-
template <typename RangeT>
55-
using ValueOfRange = typename std::remove_reference<decltype(
56-
*std::begin(std::declval<RangeT &>()))>::type;
57-
5853
} // end namespace detail
5954

6055
//===----------------------------------------------------------------------===//
@@ -1334,15 +1329,6 @@ bool is_splat(R &&Range) {
13341329
std::equal(adl_begin(Range) + 1, adl_end(Range), adl_begin(Range)));
13351330
}
13361331

1337-
/// Given a range of type R, iterate the entire range and return a
1338-
/// SmallVector with elements of the vector. This is useful, for example,
1339-
/// when you want to iterate a range and then sort the results.
1340-
template <unsigned Size, typename R>
1341-
SmallVector<typename std::remove_const<detail::ValueOfRange<R>>::type, Size>
1342-
to_vector(R &&Range) {
1343-
return {adl_begin(Range), adl_end(Range)};
1344-
}
1345-
13461332
/// Provide a container algorithm similar to C++ Library Fundamentals v2's
13471333
/// `erase_if` which is equivalent to:
13481334
///

llvm/include/llvm/ADT/SmallVector.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,17 @@ inline size_t capacity_in_bytes(const SmallVector<T, N> &X) {
907907
return X.capacity_in_bytes();
908908
}
909909

910+
/// Given a range of type R, iterate the entire range and return a
911+
/// SmallVector with elements of the vector. This is useful, for example,
912+
/// when you want to iterate a range and then sort the results.
913+
template <unsigned Size, typename R>
914+
SmallVector<typename std::remove_const<typename std::remove_reference<
915+
decltype(*std::begin(std::declval<R &>()))>::type>::type,
916+
Size>
917+
to_vector(R &&Range) {
918+
return {std::begin(Range), std::end(Range)};
919+
}
920+
910921
} // end namespace llvm
911922

912923
namespace std {

0 commit comments

Comments
 (0)