ef8d5ac08b
This removes the __array_traits::_S_ref and __array_traits::_S_ptr accessors, which only exist to make the special case of std::array<T, 0> syntactically well-formed. By changing the empty type used as the std::array<T, 0>::_M_elems data member to support operator[] and conversion to a pointer, we can write code using the natural syntax. The indirection through _S_ref and _S_ptr is removed for the common case, and a function call is only used for the special case of zero-size arrays. The invalid member access for zero-sized arrays is changed to use __builtin_trap() instead of a null dereference. This guarantees a runtime error if it ever gets called, instead of undefined behaviour that is likely to get optimized out as unreachable. libstdc++-v3/ChangeLog: PR libstdc++/104719 * include/std/array (__array_traits::_S_ref): Remove. (__array_traits::_S_ptr): Remove. (__array_traits<T, 0>::_Type): Define operator[] and operator T* to provide an array-like API. (array::_AT_Type): Remove public typeef. (array::operator[], array::at, array::front, array::back): Use index operator to access _M_elems instead of _S_ref. (array::data): Use implicit conversion from _M_elems to pointer. (swap(array&, array&)): Use __enable_if_t helper. (get<I>): Use index operator to access _M_elems. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust dg-error line numbers. |
||
---|---|---|
.. | ||
17_intro | ||
18_support | ||
19_diagnostics | ||
20_util | ||
21_strings | ||
22_locale | ||
23_containers | ||
24_iterators | ||
25_algorithms | ||
26_numerics | ||
27_io | ||
28_regex | ||
29_atomics | ||
30_threads | ||
abi | ||
backward | ||
config | ||
data | ||
decimal | ||
experimental | ||
ext | ||
lib | ||
libstdc++-abi | ||
libstdc++-dg | ||
libstdc++-prettyprinters | ||
libstdc++-xmethods | ||
performance | ||
special_functions | ||
std | ||
tr1 | ||
tr2 | ||
util | ||
Makefile.am | ||
Makefile.in |