What the efficient way to create a vector of point clouds used as a buffer in order to store multi-scanning point clouds
Starting C++11, you can use std::vector
as an RAII buffer.
Instead of allocating the space yourself using new
and then having to delete
the pointer to avoid memory leaks, you can simply create an std::vector
and pre-allocate it so that it can be used a a buffer:
(some of this is some pseudo code since I'm not familiar with point clouds)
#include <vector>
constexpr unsigned int numberOfPoints = 100;
std::vector<point_clouds> buffer(numberOfPoints);
scan_point_clound_func(buffer.data(), buffer.size());
point_cloud p = buffer[0];