I am a newbie to this list. Thanks for GCC, g++ the C++ standard
library and GDB! Apologies in advance if I have missed a web page where
this question is answered. Perhaps this question belongs on the
libstdc++ list.
With g++ 4:4.7.2-1 and libstdc++6 4.7.2-4, installed on 64 bit Debian,
using the -std=c++11 compiler option, I attempted to compile code such as:
aa1.at(1) = aa1.at(2) + aa1.at(3);
cout << aa1.size() << endl;
where aa1 is an array of ints. The error message was:
error: request for member 'at' in 'aa1', which is of
non-class type 'int [4]'.
Yet these lines for vectors and deques:
vv1.at(1) = vv1.at(2) + vv1.at(3);
dd1.at(1) = dd1.at(2) + dd1.at(3);
compiled and worked fine. Both of these lines were implemented with
bounds checking.
According to my understanding of the near-final draft standard
n3242-1.pdf, page 729, in the last item of Table 101, the member
function at() should provide bounds checked access to:
basic_string, string, array, deque and vector.
As far as I can tell, this does not work for arrays in 4.7.2. Am I
missing a compiler option?
I think the .at() member function should apply to arrays, according to:
http://en.cppreference.com/w/cpp/container/array/at
and page 265 of N. M. Josuttis "The C++ Standard Library 2nd Ed.".
I couldn't see specific mention of this at:
http://gcc.gnu.org/onlinedocs/gcc-4.7.2/libstdc++/manual/manual/status.html#status.iso.2011
other than the line:
23.2.3 Sequence containers Y
I am not sure if this functionality would be in g++ or libstdc++ or both
and I am not sure where to look in the documentation to see if it is or
will be implemented. I didn't make any progress Googling for the
compiler error text or for any relevant terms I could think of.
Thanks again for GCC!
- Robin