Reputation: 169
I'm trying to build an entity-component class which stores components in a vector of std::arrays of std::unique_ptrs of derived Component pointers, like so:
vector<pair<int, array<unique_ptr<Component>, 32>>> components;
When trying to create a new array for a new component, though, even using move(), I wind up getting the following error:
this->count++;
vector<pair<int, array<unique_ptr<Component>, 32>>> component_set;
this->components.emplace_back(make_pair(this->count, move(component_set)));
Error 1 error C2248: 'std::unique_ptr<_Ty>::unique_ptr' :
cannot access private member declared in class 'std::unique_ptr<_Ty>'
c:\program files\microsoft visual studio 11.0\vc\include\array 211 1
entity
is this a problem with using the std::array class, or am I just doing this entirely wrong (which is possible?)
Upvotes: 0
Views: 834
Reputation: 154045
It seems the use of emplace_back()
jumps through a std::pair<...>
where it really shouldn't. Try
this->componets.emplace_back(int, std::array<std::unique_ptr<Component>, 32>());
You actually try add something into component
which seems to be of a type would contain an entity of the type of components
.
Upvotes: 1