I noticed that when I initialize array like so:
std::array<int,3> myarray;
myarray[0] = 9;
myarray[1] = 8;
myarray[2] = 7;
myarray[3] = 6;
myarray[4] = 5;
I do not get an error, even though I have more array elements than was defined in <int,3>
I am on Mac with g++ and it's C++11.
So i guess my question is: why is that, that there are no errors? Is it correct behavior? Or do I expect too much form my compiler?
Also what is this method of initialization called? Someone called it "buggy construction". I think they meant it as a joke though.
P.S. I understand that this method is undesirable.
Aucun commentaire:
Enregistrer un commentaire