[libcxx-commits] [PATCH] D99873: [libcxx] adds `std::ranges::iter_move` and `std::iter_rvalue_reference_t`

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 16 08:52:23 PDT 2021


Quuxplusone added inline comments.


================
Comment at: libcxx/include/concepts:250-253
+concept __class_or_enum =
+  is_class_v<remove_cvref_t<_Tp>> ||
+  is_union_v<remove_cvref_t<_Tp>> ||
+  is_enum_v<remove_cvref_t<_Tp>>;
----------------
ldionne wrote:
> I really think the `remove_cvref_t` doesn't belong here. It belongs to the callers of this concept.
> 
> Even though this concept is just a private helper, I think we should strive to make it meaningful on its own.
Re this and your above comment pinging @tcanens: I believe the intent of the spec is that "class [including struct and union] or enumeration types" are exactly the set of types which are allowed to...

(in the case of `iter_move`) ...have their own overloaded `operator*`. (Enums can have a free-function `operator*` found by ADL. Primitive types cannot have an overloaded `operator*` at all.)

(in the case of `swap`) ...have their own free-function `swap` that might reasonably do something different from the normal `swap`. (Pointer types //can// have associated namespaces which end up producing associated `swap` functions, but those `swap` functions aren't semantically allowed to do anything except swap the pointers. If this weren't true, our strategy of specializing `std::sort` for pointer types would be non-conforming. https://godbolt.org/z/G8d6GKbME )

It might be reasonable to rename this concept/trait to something like `__causes_adl` — but I think `__class_or_enum` is reasonable too, in that it matches the Standardese term-of-art for "the kind of thing that suffers from ADL." I also think, under this rationale, it makes perfect sense to want to move the cvref-dequalification into the concept/trait itself, because the cvref-qualification of a type doesn't have any effect on whether it suffers from ADL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99873



More information about the libcxx-commits mailing list