1#pragma once
2
3#include <iterator>
4
5namespace ext
6{
7 /** \brief Returns collection of specified container-type.
8 * Retains stored value_type, constructs resulting collection using iterator range. */
9 template <template <typename...> class ResultCollection, typename Collection>
10 auto collection_cast(const Collection & collection)
11 {
12 using value_type = typename Collection::value_type;
13
14 return ResultCollection<value_type>(std::begin(collection), std::end(collection));
15 }
16
17 /** \brief Returns collection of specified type.
18 * Performs implicit conversion of between source and result value_type, if available and required. */
19 template <typename ResultCollection, typename Collection>
20 auto collection_cast(const Collection & collection)
21 {
22 return ResultCollection(std::begin(collection), std::end(collection));
23 }
24}
25