Vin?cius dos Santos Oliveira
Em qua., 27 de nov. de 2019 ?s 13:36, Phil Endecott via Boost < boost@lists.boost.org> 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.