I am currently working on a college assignment and right now I'm struggling with vectors.
I am supposed to return a unique ID for an object and then add that object to a vector.
The object is a struct defined as follows:
struct VertexPuller{
std::vector<InVertex> head_settings;
std::vector<IndexType> indexing;
};
and the vector I am trying to push to is:
std::vector<std::unique_ptr<VertexPuller>> vertex_puller_tables;
The function I wrote looks like this:
auto vertex_puller= std::make_unique<VertexPuller>;
auto vp_id = reinterpret_cast<VertexPullerID>(vertex_puller);
vertex_puller_tables.push_back(std::move(vertex_puller));
return vp_id;
However at the second-to-last line, when i try to push the vertex puller into the vector, I get the error - No matching member function for call to 'push_back'.
I've been stuck on this for quite some time and i have no idea what may cause this, probably pointers, as usual with C and me. Thanks for the suggestions!
vertex_puller
is a std::make_unique<VertexPuller>
function. It's not a unique_ptr<VertexPuller>
. You have to call the function and pass any parameters you would pass to a VertexPuller
constructor.
auto vertex_puller= std::make_unique<VertexPuller>(); // note the parentheses