diff options
Diffstat (limited to 'runtime/base/stl_util.h')
-rw-r--r-- | runtime/base/stl_util.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/runtime/base/stl_util.h b/runtime/base/stl_util.h index d5f375a5d9..cfe27f3811 100644 --- a/runtime/base/stl_util.h +++ b/runtime/base/stl_util.h @@ -194,6 +194,17 @@ static inline void MergeSets(std::set<T>& to_update, const std::set<T>& other) { to_update.insert(other.begin(), other.end()); } +// Returns a copy of the passed vector that doesn't memory-own its entries. +template <typename T> +static inline std::vector<T*> MakeNonOwningPointerVector(const std::vector<std::unique_ptr<T>>& src) { + std::vector<T*> result; + result.reserve(src.size()); + for (const std::unique_ptr<T>& t : src) { + result.push_back(t.get()); + } + return result; +} + } // namespace art #endif // ART_RUNTIME_BASE_STL_UTIL_H_ |