C++ Logo


Advanced search

Re: No attributes for concepts in C++20

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Tue, 15 Sep 2020 19:59:26 +0300
On Tue, 15 Sep 2020 at 17:24, Jean Guegant via Std-Discussion
<std-discussion_at_[hidden]> wrote:
> Hello everyone,
> I recently noticed that there is no way to attach C++ attributes to concepts introduced in C++20. More precisely, the C++ grammar doesn't have any placeholder for starting an attribute specifier sequence. In practice, this means that you cannot deprecate a concept using the [[deprecated]] attribute introduced in C++14 for instance. It also means that you cannot really extend that new C++ feature using custom attributes. Apparently this limitation of the language has been discovered by other people and it feels that this could have been an oversight from the committee when integrating concepts to the language.
> I was considering to report this problem as a standard issue but I would like to seek
> advice here first:
> Firstly, was there any reason that I missed to not add attributes to concepts?
> Secondly, if this was not considered at the time of designing concepts, is that sufficiently important to escalate it as an issue rather than a proposal for C++23? It feels to me that this should have been part of C++20 and is quite unexpected. Clang even has special error handling (here and here) to help people trying to use attributes with concepts. This clearly highlights that users assume that attributes should work somehow with concepts.
> Finally, if I go for an issue or a proposal, what would be the best place to introduce the attribute specifier sequence? Depending on how we think of concepts, the 3 following notations look possible to me:
> template <class T> [[here]] concept bla = ...; - akin to attributes for variables or class/struct)
> template <class T> concept [[here]] bla = ...; - akin to attributes for class/struct
> template <class T> concept bla [[here]] = ...; - akin to attributes for alias templates
> I would really appreciate some help here.

Attributes for concepts are in the pipeline as an issue to resolve.
Being able to deprecate a concept seems
like a semi-obvious use case. A fix for the issue will not hit the
published C++20 standard, and it looks like
a specific proposal is still needed.

Received on 2020-09-15 12:08:30