[libcxx-commits] [PATCH] D116278: [libc++][ranges] Add ranges::in_in_result

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 12 16:39:01 PST 2022


philnik added inline comments.


================
Comment at: libcxx/test/std/algorithms/algorithms.results/no_unique_address.compile.pass.cpp:24
+static_assert(sizeof(std::ranges::in_in_result<int, Empty>) == sizeof(int));
+static_assert(sizeof(std::ranges::in_in_result<Empty, Empty>) == 2 * sizeof(Empty));
----------------
Mordante wrote:
> Quuxplusone wrote:
> > Mordante wrote:
> > > Why `2 * sizeof(Empty)`?
> > Because of the ["empty-base exclusion principle"](https://quuxplusone.github.io/blog/2021/05/07/std-iterator-as-a-base-class/#so-it-contains-two-empty-base-cl).
> > FWIW, I would have just said `== 2);` since `sizeof`-an-empty-class is `1` by definition AFAIK.
> Seems there's always a blog post :-)
> I thought `[[no_unique_address]]` allows it to be 1. Reading your blog and looking in the standard I see
> the answer in [intro.object]/9 "Two objects with overlapping lifetimes that are not bit-fields may have the same address if one is nested within the other, or if at least one is a subobject of zero size and they are of different types; otherwise, they have distinct addresses and occupy disjoint bytes of storage."
> 
> Thanks.
> 
> 
> 
I thought `2 * sizeof(Empty)` would be clearer than just `2`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116278/new/

https://reviews.llvm.org/D116278



More information about the libcxx-commits mailing list