So I've tried searching here, but haven't quite found the same issue. I can't seem to figure out how to properly use this tracked vector. Ultimately, I want a vector of an array (length == 2) of vectors. It's not that I'm getting an index out of bound message, it's that when I try to compile, it says:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\memory(631): error C2440: '<function-style-cast>' : cannot convert from 'int' to 'std::vector<_Ty> '
1> with
1> [
1> _Ty=int
1> ]
//code
int main() {
typedef vector<int> feature_points[2];
vector< feature_points >tracked;
tracked.resize(10);
}
I suppose I could do vector<vector<vector<int>>>, but since the array portion will always be a length of 2, I'd like to just use it as an array of 2, thereby not having to check for index out of bounds exceptions.
Thank you for your thoughts and suggestions.
<vector>@OP, use:std::array<std::vector<int>, 2>>for thetypedef, it'll work.. Vector's allocator requires the type passed to be constructible, assignable, copyable.operator[]) out of bounds is undefined behavior, exactly as it is with an array. Of course, in the case of vector, you do have the option of having an exception thrown, by using theat()member function. But just because an exception is thrown, doesn't mean you have to check for it.