libstdc++: Rearrange some range adaptors' data members
authorPatrick Palka <ppalka@redhat.com>
Mon, 28 Sep 2020 16:05:32 +0000 (12:05 -0400)
committerPatrick Palka <ppalka@redhat.com>
Mon, 28 Sep 2020 16:05:32 +0000 (12:05 -0400)
commit361e32eeaa8e80c2c3b4879518756cf131e8f938
treecb8e49f29fe2d9db63d085bc704400e3a3925866
parentea51fba504d05e94f7ac97e7f278652d684418b2
libstdc++: Rearrange some range adaptors' data members

Since the standard range adaptors are specified to derive from the empty
class view_base, having their first data member store the underlying
view is suboptimal, for if the underlying view also derives from
view_base then the two view_base subobjects will be adjacent; this
prevents the compiler from applying the empty base optimization to elide
away the storage for these two empty bases.

This patch improves the situation by declaring the _M_base data member
last instead of first in each range adaptor that has more than one data
member, so that the empty base optimization can apply in more cases.

libstdc++-v3/ChangeLog:

* include/std/ranges (filter_view): Declare the data member
_M_base last instead of first, and adjust constructors' member
initializer lists accordingly.
(transform_view): Likewise.
(take_view): Likewise.
(take_while_view): Likewise.
(drop_view): Likewise.
(drop_while_view): Likewise.
(join_view): Likewise.
(split_view): Likewise (and tweak nearby formatting).
(reverse_view): Likewise.
* testsuite/std/ranges/adaptors/sizeof.cc: Update expected
sizes.
libstdc++-v3/include/std/ranges
libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc