Date: Thu, 18 Mar 2021 01:01:51 +0000
On Mar 17, 2021, at 5:33 PM, Phil Bouchard via Std-Proposals <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>> wrote:
This message was sent from a non-IU address. Please exercise caution when clicking links or opening attachments from external sources.
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?
It’s neither simpler nor clearer to programmers that have experience with concepts, which already exist. They are designed to provide exactly what you’re asking for. You should spend some time looking into them.
In particular, you can easily create an `is_container` concept from your `Container` base class template, should you like. An off-the-cuff version is like https://godbolt.org/z/jYj7W8.
Luke
--
Phil Bouchard
Founder
C.: (819) 328-4743
[Fornux Logo]<http://www.fornux.com/>
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]<mailto:Std-Proposals_at_[hidden]>
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2021-03-17 20:02:10