2015-10-16 11:20:33 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-06-20 11:32:45 +00:00
|
|
|
#include <iterator>
|
2015-10-16 11:20:33 +00:00
|
|
|
|
|
|
|
namespace ext
|
|
|
|
{
|
2017-06-06 17:10:04 +00:00
|
|
|
/** \brief Returns collection of specified container-type.
|
|
|
|
* Retains stored value_type, constructs resulting collection using iterator range. */
|
|
|
|
template <template <typename...> class ResultCollection, typename Collection>
|
|
|
|
auto collection_cast(const Collection & collection)
|
|
|
|
{
|
|
|
|
using value_type = typename Collection::value_type;
|
2015-10-16 11:20:33 +00:00
|
|
|
|
2017-06-06 17:10:04 +00:00
|
|
|
return ResultCollection<value_type>(std::begin(collection), std::end(collection));
|
2018-08-10 04:02:56 +00:00
|
|
|
}
|
2015-10-16 11:20:33 +00:00
|
|
|
|
2017-06-06 17:10:04 +00:00
|
|
|
/** \brief Returns collection of specified type.
|
|
|
|
* Performs implicit conversion of between source and result value_type, if available and required. */
|
|
|
|
template <typename ResultCollection, typename Collection>
|
|
|
|
auto collection_cast(const Collection & collection)
|
|
|
|
{
|
|
|
|
return ResultCollection(std::begin(collection), std::end(collection));
|
|
|
|
}
|
2015-10-16 11:20:33 +00:00
|
|
|
}
|