Template Function mrpt::containers::copy_container_typecasting

Function Documentation

template<typename src_container, typename dst_container>
void mrpt::containers::copy_container_typecasting(const src_container &src, dst_container &trg)

Copy all the elements in a container (vector, deque, list) into a different one performing the appropriate typecasting. The target container is automatically resized to the appropriate size, and previous contents are lost. This can be used to assign std::vector’s of different types:

std::vector<int>    vi(10);
std::vector<float>  vf;
vf = vi;   // Compiler error
mrpt::containers::copy_container_typecasting(v1,vf);  // Ok