C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Requires-clause for data members

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Thu, 15 Feb 2024 10:22:24 +0000
On Thu, 15 Feb 2024 at 09:54, Tiago Freire via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> And what exactly would this do?
>

Exactly what the standard does for subrange::size_ in
[range.subrange.general]


*make-unsigned-like-t*<iter_difference_t<I>> *size_* = 0; // *exposition
only; present only*
                                                      // *if** StoreSize *
*is* true





> -----Original Message-----
> Subject: [std-proposals] Requires-clause for data members
>
> Has there been any discussion of requires-clauses for data members?
> Something like:
>
> > template<int N>
> > struct numbers {
> > int x requires (N >= 1) = 0; // leading
> > int y requires (N >= 2) = 0; // trailing };
>
> It seems grammatically possible if you mandate parentheses, and it would
> certainly help people reduce the use of partial specializations in these
> places.
>

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3613.pdf#section.5
has some discussion of an earlier idea like this, based on features in the
D language.

Received on 2024-02-15 10:23:40