Insert Iterators Adapters in C++
December 6, 2020
Let’s slightly modify the example from The Move Iterator Adapter in C++ post:
#include
#include
#include
#include
/// @warning BUG! PLEASE, DON'T USE!
auto deep_copy_to_list(const std::vector& src)
{
std::list dst; // constructs the empty list
copy(cbegin(src), cend(src), begin(dst)); // cause memory corruption (if !src.empty())!
return dst;
}
In the example above the object of…

