Could someone tell what is the correct way to work with a vector of arrays?
I declared a vector of arrays (vector<float[4]>) but got error: conversion from 'int' to non-scalar type 'float [4]' requested when trying to resize it. What is going wrong?
You cannot store arrays in a
vectoror any other container. The type of the elements to be stored in a container (called the container’s value type) must be both copy constructible and assignable. Arrays are neither.You can, however, use an
arrayclass template, like the one provided by Boost, TR1, and C++0x:(You’ll want to replace
std::arraywithstd::tr1::arrayto use the template included in C++ TR1, orboost::arrayto use the template from the Boost libraries. Alternatively, you can write your own; it’s quite straightforward.)