C++ Logo


Advanced search

Re: C++ create a class with array members which are not constructed.

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Wed, 2 Sep 2020 21:06:22 +0200
On 02/09/2020 20:44, Steve Hearnden via Std-Proposals wrote:
> It would have been handy to have a class which implemented something
> like std::vector, but with a **small** buffer of values to use as an
> alternative piece of memory when the vector size was below a threshold.
> Unfortunately, an array of the constructed type, would cause the
> constructor to be called for each array element, and for complex types,
> could undo the benefit of the pre-bought memory.
> My proposal would be for classes (or structures) to have the ability
> for a member to be declared with an attribute

What's wrong at just using one of the many small-vector classes
available around? More to the point, can't you simply use
aligned_storage_t to achieve what you need?

Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

Received on 2020-09-02 14:09:55