diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -1239,13 +1239,22 @@ return X.capacity_in_bytes(); } +template +using ValueTypeFromRangeType = + typename std::remove_const()))>::type>::type; + /// 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> +SmallVector, Size> to_vector(R &&Range) { + return {std::begin(Range), std::end(Range)}; +} +template +SmallVector, + CalculateSmallVectorDefaultInlinedElements< + ValueTypeFromRangeType>::value> to_vector(R &&Range) { return {std::begin(Range), std::end(Range)}; }