C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Generic code, not the API you are looking for

From: Zhihao Yuan <zy_at_[hidden]>
Date: Sat, 20 Aug 2022 22:52:25 +0000
On Saturday, August 20th, 2022 at 6:27 AM, Jason McKesson via Std-Proposals <std-proposals_at_[hidden]> wrote:

> >

> > In the protocols/generics model "the concept" is an entity by itself, much like Zhihao said. Inside func, the code will actually ask String itself for methods, not directly the class that it is instantiated with.
>

> That ship sailed when C++20 standardized a concept model that was
> fundamentally incapable of definition checking. C++20 concepts are
> exactly and only a way to constrain a template declaration, nothing
> more. And there's no simple way to turn them into something more.

I don't know why "concept model" is brought
up here. A generic function is a form of
function, in the way "member function" being
a form of a function. A function template is
a form of a template, not even a function.
If you want to constrain a template, use
a concept. To declare a generic function,
you need a protocol, just like to use subtype
polymorphism, you need a type with virtual
functions.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

Received on 2022-08-20 22:52:35