Boost logo

Boost :

From: Vinícius dos Santos Oliveira (vini.ipsmaker_at_[hidden])
Date: 2019-11-27 18:16:25


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:
https://github.com/18/fixed_string/blob/9730545e0fa37b43299559fca8253c434c67a491/include/boost/fixed_string/fixed_string.hpp#L51

I'm concerned about this alignment and I'd rather have the size being
computed by searching for the NULL-terminator (or also stored in a byte).
Maybe a policy template parameter could be used to select the
implementation. I don't really care about which solution is chosen as long
as I can opt-in for a struct which has the same alignment as char (and it
is trivially copyable).

-- 
Vinícius dos Santos Oliveira
https://vinipsmaker.github.io/

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