C++ Logo

std-proposals

Advanced search

Re: Request for opinion: Leaning on strong typing in STL.

From: Nikolay Mihaylov <nmmm_at_[hidden]>
Date: Thu, 23 Jul 2020 11:00:39 +0300
>> An alternative solution might be named arguments.

or tags, e.g. for

Complex(T r, T i, complex_t);
Complex(T angle, T radius, complex_angle t);

however this means completely changing the container API...


On Thu, Jul 23, 2020 at 10:55 AM Olaf van der Spek via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Wed, Jul 22, 2020 at 7:51 PM Scott Michaud via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> > Do the library maintainers have any established opinion about strongly
> typing parameters that can be ambiguous?
> >
> > I'll illustrate what I mean with a concrete use case: std::vector.
> >
> > In C++, there is a constructor that takes a single size_type and creates
> a vector with n default-constructed elements. I need to frequently bounce
> between languages, and other languages (such as Java and C#) have their
> analogous constructor initialize the capacity without creating initial
> elements. This makes it difficult to remember how any given language's
> standard library behaves.
>
> An alternative solution might be named arguments.
>
> --
> Olaf
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2020-07-23 03:04:35