[libcxx-commits] [PATCH] D102135: [libcxx][ranges] adds _`copyable-box`_
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 6 12:55:47 PDT 2021
ldionne marked an inline comment as done.
ldionne added inline comments.
================
Comment at: libcxx/include/__ranges/copyable_box.h:118
+ class __copyable_box<_Tp> {
+ [[no_unique_address]] _Tp __val_;
+
----------------
Mordante wrote:
> Is there a reason to use `[[no_unique_address]]` here? Don't the same justifications hold true as stated in the primary template?
Assuming you mean the justifications that I said above, then those were incorrect, so they don't apply.
But regardless, in this case `no_unique_address`'s value here is clearer, since it means the class can occupy no space at all if `_Tp` is empty. And this will most likely be the case quite often, since I expect this class will end up holding stateless function objects (probably often through a lambda's closure type) quite often.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102135/new/
https://reviews.llvm.org/D102135
More information about the libcxx-commits
mailing list