Boost logo

Boost :

From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2019-11-28 14:07:08


Vin?cius dos Santos Oliveira <vini.ipsmaker_at_[hidden]> wrote:
> Em qua., 27 de nov. de 2019 ?s 13:36, Phil Endecott via Boost <
> boost_at_[hidden]> escreveu:
>
>> struct NameAndAddress {
>> static_string<14> firstname;
>> static_string<14> surname;
>> static_string<30> address_line_1;
>> static_string<22> city;
>> static_string<10> postcode;
>> };
>>
>
> I was going to write a review, but I think I can borrow your example to
> show the single point I'm concerned about.
>
> char[N] has alignment of char. std::size_t has not and structs like this
> will consume much more memory because this single member

This is avoided if you use an appropriate smaller type for
the size, i.e. uint8_t when capacity <= 255.

> I'd rather have the size being
> computed by searching for the NULL-terminator

Yes a string that does this can also be useful, particularly for the
very smallest strings, but I would not suggest trying to combine it
with this implementation.

Regards, Phil.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk