[libcxx-commits] [PATCH] D99854: [libcxx] adds `cpp17-.*iterator` concepts (as `__legacy_.*iterator`)

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 14 14:57:15 PDT 2021


zoecarver added inline comments.


================
Comment at: libcxx/include/iterator:532
+concept __can_reference = requires {
+  typename __with_reference<_Tp>;
+};
----------------
Quuxplusone wrote:
> CaseyCarter wrote:
> > ldionne wrote:
> > > I was surprised to see that we can't simply write `typename _Tp&`. I'm not sure what part of the concepts spec disallows it, do you know?
> > > 
> > > Would it make sense to rename this to `__referenceable`? Then below we would have
> > > 
> > > ```
> > > concept __dereferenceable = requires(_Tp& __t) {
> > >   { *__t } -> __referenceable;
> > > };
> > > ```
> > > 
> > > which I think is nicely consistent.
> > > I was surprised to see that we can't simply write `typename _Tp&`. I'm not sure what part of the concepts spec disallows it, do you know?
> > 
> > So was I! The _type-requirement_ grammar is "_type-requirement_: `typename` _nested-name-specifier<sub>opt</sub>_ _type-name_ `;`", which doesn't allow any kind of adornments. From a very high level I suppose this makes sense - `_Tp&` is a type, but not the _name_ of a type - but it does mean that some things we expect to work don't.
> > 
> > There's probably material here for a 1-2 page paper to propose a change.
> Re `__can_reference` versus `__referenceable`: This is matching the (current) draft wording in http://eel.is/c++draft/iterator.synopsis#concept:can-reference so I think it's defensible.
> 
I agree, `__referenceable` does sound better. But I think it's not outweighed by the benefit of having this code more or less match the standard wording verbatim. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99854



More information about the libcxx-commits mailing list