N
none
I've seen forum posts here and there asking "How do I create an STL
container of arrays?" Or, equivalently, "How do I fix this syntax:"
std::vector<float[20]> v;
The answers to these questions are generally one of two things:
1) Use a boost::array, or
2) Put the array in a struct, like so:
// In header file
stuct wrapper { float f[20]; };
// In CPP file
std::vector<wrapper> v;
I was under the impression that things stored in STL containers needed to
be copyable and assignable. That second option seems incorrect to me,
unless the compiler is expected to generate both an operator= and a copy
constructor for the struct that perform a memcpy() for the contents of f.
Is it?
container of arrays?" Or, equivalently, "How do I fix this syntax:"
std::vector<float[20]> v;
The answers to these questions are generally one of two things:
1) Use a boost::array, or
2) Put the array in a struct, like so:
// In header file
stuct wrapper { float f[20]; };
// In CPP file
std::vector<wrapper> v;
I was under the impression that things stored in STL containers needed to
be copyable and assignable. That second option seems incorrect to me,
unless the compiler is expected to generate both an operator= and a copy
constructor for the struct that perform a memcpy() for the contents of f.
Is it?