I have this odd problem
vector<unsigned int[3]> tris;
for (unsigned int i = 0; i < idx.size() - 2; i++) {
unsigned int push[] = {idx[i], idx[i+1], idx[i+2]};
tris.push_back(push); //<- this is where it goes belly up
}
The code piece is supposed to unravel a triangle strip index list into triangle indices but wont compile under vs10. Thoughts?
No, unless you wrap your arrays into a struct
or use something like std::array
.
The naked C-style array type is not copyable or assignable, which makes it ineligible to serve as a standard container element.
P.S. It should be noted though that C++11 switched to a more elaborate (per-method) approach to specifying requirements to container element type, instead of the more broad approach used by C++03. The above ineligibility claim is based on C++03. I'm not ready to say that it is so unconditionally true for C++11 as well... But it is certainly true even in C++11 if you insist on using push_back
in your code.
P.P.S. In C++11 one can probably get away with std::list
of naked C-style arrays and using emplace
to construct new elements. But not with std::vector
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With