#pragma once #include namespace base { namespace details { template struct ValueType { using TType = typename std::remove_reference_t::value_type; }; template using TValueType = typename ValueType::TType; } // namespace details // Use this function to cast one collection to annother. // I.E. list const myList = collection_cast(vector{1, 2, 4, 5}); // More examples: // auto const mySet = collection_cast("aaabcccd"); // auto const myMap = collection_cast(vector>{{1, 2}, {3, 4}}); template class TTo, typename TFrom> auto collection_cast(TFrom && from) -> TTo> { return TTo>(begin(from), end(from)); } } // namespace base