aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/debug
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-03-25 10:28:28 +0000
committerJonathan Wakely <jwakely@redhat.com>2022-05-04 16:24:56 +0100
commitef8d5ac08b5e60f35c52087d88c0235c8ce6b65b (patch)
tree3fc9436691a09e050ad8890048b56c23c2a751bf /libstdc++-v3/include/debug
parent9c6a4beeed572f9e235f881e00ad8c63b6bcc9df (diff)
downloadgcc-ef8d5ac08b5e60f35c52087d88c0235c8ce6b65b.zip
gcc-ef8d5ac08b5e60f35c52087d88c0235c8ce6b65b.tar.gz
gcc-ef8d5ac08b5e60f35c52087d88c0235c8ce6b65b.tar.bz2
libstdc++: Simplify std::array accessors [PR104719]
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.
Diffstat (limited to 'libstdc++-v3/include/debug')
0 files changed, 0 insertions, 0 deletions