C++ Logo

std-proposals

Advanced search

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

From: Olaf van der Spek <ml_at_[hidden]>
Date: Thu, 23 Jul 2020 09:54:51 +0200
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

Received on 2020-07-23 02:58:22