3 ms·
I don't think std::array is from the Template Library but is instead simply a type provided by the C++ standard library itself. Accordingly it isn't a great fit
by tialaramex 5y ago
I don't think std::array is from the Template Library but is instead simply a type provided by the C++ standard library itself. Accordingly it isn't a great fit for the STL's container concept and has to be special-cased.
Also, once again bad defaults in C++. The default array accessor should be bounds checked. If I'm quite sure I wish to risk unchecked access that is an explicit decision signified by using a different accessor. This is the same mistake as discussed below for integer overflow, if the programmer doesn't specify a non-default behaviour that doesn't mean they spent ages agonising over the fine details of whatever the default behaviour happens to be, it means they didn't realise it mattered. Accordingly obey the principle of least surprise and don't do crazy things by default.
- pjmlp 5y agoWhile the defaults isn't what security minded folks would wish for, ISO C++ doesn't prevent a compliant implementatio to have them bounds checked, as such all major C++ compilers do provide compiler options to enable all uses of operator[]() as bounds checked, including interator invalidation. In C++ circles although STL has long moved beyond its original purpose, most people do refer to the C++ standard library as STL.