Here, three_d_struct_v
is of type vector<vector<vector<MyStruct>>>
, i.e. a vector
of vector<vector<MyStruct>>
, so you need to add element of type vector<vector<MyStruct>>
(likewise for nested dimensions). However, in your code, you are adding element of type MyStruct
directly.
You need to change to something like:
for(size_t i = 0; i < max_i; i++) {
vector<vector<MyStruct>> v1;
for(size_t j = 0; j < max_j; j++) {
vector<MyStruct> v2;
for(size_t k = 0; k < max_k; k++) {
MyStruct a = {k, 'x', false, nullptr};
v2.emplace_back(move(a));
}
v1.emplace_back(move(v2));
}
three_d_struct_v.emplace_back(move(v1));
}
Check out ideone for the whole code.