On Fri, Mar 8, 2013 at 12:42 AM, Robin Whittle <r...@firstpr.com.au> wrote: > 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.
It doesn't belong to gcc@gcc.gnu.org, which is for discussion of the development of the compiler. The user support list is gcc-h...@gcc.gnu.org. As your question is really more about C++ than about GCC, you might also try a generic C++ forum. > 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? No, but you do need to read about the difference between (buiilt-in) arrays and instances of std::array types. std::array has at; built-in arrays such as int[4] do not have member functions (only classes do). -- James