C++ Logo

std-proposals

Advanced search

Re: Make class template parameters available externally

From: Jake Arkinstall <jake.arkinstall_at_[hidden]>
Date: Wed, 30 Oct 2019 22:15:14 +0000
On Wed, 30 Oct 2019, 22:04 Ville Voutilainen via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> > First of all, it turns out that they are a crucial part of an interface
> and often or always are of interest to end-users. A quick survey of STL
> shows that all containers declare all their template parameters and make
> them available to users.
>
> My quick survey shows that none of them do, not with those names. And
> a library implementation of what is specified to
> be
> template<class T, size_t N>
> struct array
> doesn't mention "T" or "N" anywhere in it.
>

Not literally. It takes in the type as an arbitrary name and then I'm
pretty sure most containers do then make that type accessible through a
reasonable name such as value_type, first_type/second_type, etc.

This seems to be starting a journey on the road where the benefit
>
is not worth the cost.
>

>From where I stand the cost is worth it. Fewer junk names, cleaner STL
code, I'm all for it.

I'd request that non-type template parameters (e.g. a size_t value) be
automatically added as constexpr static values too, for consistency.

>

Received on 2019-10-30 17:17:39