Design and implement a way to copy containers that maintains the capacity of the right-hand-size. For example (psedo-ish code):
template<typename LHST, typename RHST>
LHST
capacity_copy_construct(const RHST& rhs)
{
// default implementation
LHST a{ rhs };
a.reserve(rhs.capacity());
return a;
}
template<>
cetl::VariableLengthArray<std::size_t>
capacity_copy_construct<std::vector<std::size_t>, std::vector<std::size_t>>(const std::vector<std::size_t>& rhs)
{
// do special stuff here to copy construct VLA with the rhs.capacity()
}
Design and implement a way to copy containers that maintains the capacity of the right-hand-size. For example (psedo-ish code):