weired behaviour of std::vector at() function
Hello all,
I am trying to port my code from Win (VC6) to Linux (gcc 2.95).
I am getting a weired compilation error while using the at() function in STL's std::vector.
I want to use at() instead of [] because Mark Allen Weiss in his "Data Structures and Problem .. C++" claims the following::
Range checking can be done by using at; a.at(i) is the same as a[i], except that an error is signalled if i is out-of-bounds.
Code:::
-------
boundsMin.x = my_min(boundsMin.x, vertices.at(ii).x);
boundsMin.y = my_min(boundsMin.y, vertices[ii].y);
boundsMin.z = my_min(boundsMin.z, vertices.at(ii).z);
boundsMin is of type TVec3<double>;
vertices is of type std::vector<TVec3<double>>;
Note that the first and third lines use at(ii). the second line uses [ii];
error:::
--------
Box3D.cpp: In method `Box3D::Box3D(const Vec3DArray &)':
Box3D.cpp:53: no matching function for call to `vector<TVec3<double>,allocator<TVec3<double> > >::at (int &) const'
Box3D.cpp:55: no matching function for call to `vector<TVec3<double>,allocator<TVec3<double> > >::at (int &) const'
I want to clarify the following two points.
1. I don't understand what's wrong with the above code. It runs fine in VC6.
2. I gave only only one argument to at(), but the allocator<TVec3<double>> is automatically added by the compiler. What's going on there ?
Thanks.
Ragu
I request banning of User Andreas Masur
Quote:
Well...what do you expect from a guy who puts the following in his resume...
The above post pertains nothing to the topic of programming
and seriously violated my privacy, and as well as violated my copyright, by posting my resume, without my written consensus. Hence it breaks the rule of this board.
This behavior is totally unacceptable. If the moderator continue
to allow people to reveal other user's privacies on this board unchecked, not only this board can not survive for long, it could also break the US laws.
I am hereby requesting that the moderator of this board ban
Andreas Masur from accessing this board. I also reserve the right to pursue this issue through the legal channel should Mr. Andreas Masur's violation of my privacy continues.
Finally, Mr. Andreas Masur should be able to contact my former employer and find out that I am indeed adequately describing myself in my resume. BTW, both me and boss are pretty happy with what I am doing on my current job and probably won't need to write another resume for a while.