C++ Logo

std-proposals

Advanced search

Re: Are constrained type barred from std:: implementations?

From: Jens Maurer <Jens.Maurer_at_[hidden]>
Date: Fri, 20 Aug 2021 20:23:53 +0200
On 20/08/2021 19.51, DBJ via Std-Proposals wrote:
> Many thanks to all on replies. Let me try and clarify.
>
> I was specifically told by one of the STL authors, the standard allows for illegal types to be defined from std:: templates.
>
> Examples given were:
>
> using bad_type_1 = tuple<void>; using bad_type_2 = basic_string_view<void ***>;

These are typedefs, which do not cause template instantiation.

Any actual use of these types to create an object will be cause
instantiation and be ill-formed.

> I also understood the standard is barring STL authors to constrain the types and use (for example) enable_if<> for C++ < 20 or requires for C++ >= 20 , thus they are using static_assert().
>
> AFAIK static_assert() is instantiation constraint not type definition constraint.
>
> This is not a rant or similar, I am just looking for a confirmation.

I'm still not understanding the problem you're trying to solve.

Do you want to make the formation of the template-id tuple<void>
ill-formed, and guarantee such ill-formedness in the standard?

What would be the benefit of doing so, as opposed to the status quo?

Jens

Received on 2021-08-20 13:24:00