C++ Logo

std-proposals

Advanced search

Re: New "static_virtual" keyword

From: Phil Bouchard <boost_at_[hidden]>
Date: Wed, 17 Mar 2021 20:33:23 -0400
On 3/17/21 8:19 PM, Jason McKesson via Std-Proposals wrote:
>
> I'm not sure I understand the point of this. Or rather, I don't
> understand the point of this as distinct from the point of just having
> a concept and a template:
>
> ```
> template<typename C>
> concept Container = requires(C c)
> {
> {c.begin()} -> is_pointer_type;
> {c.end()} -> is_pointer_type;
> {c.end()} -> std::is_same<decltype(c.begin())>;
> //etc.
> };
>
> template<Container C>
> auto &operator<<(std::ostream&, C const&c);
> ```
>
> If there is no vtable, and the lookup is all done at compile-time,
> then I see no need to restrict everything to such a coarse mechanism
> as overriding specific functions by signature. Concepts are the
> compile-time way to define statically-polymorphic prototypes, and
> concept-checking is how we declare that a function takes a
> statically-polymorphic prototype.

Ok sorry, I was unfamiliar with the latest standards. But my approach is
much simpler / cleaner to write for inheritance. What can't we do with
inheritance in the first place anyway?


-- 
*Phil Bouchard*
Founder
C.: (819) 328-4743
Fornux Logo <http://www.fornux.com>

Received on 2021-03-17 19:33:27