fixed_string icon indicating copy to clipboard operation
fixed_string copied to clipboard

constructor from any const char* and std::string

Open Raildex opened this issue 3 years ago • 3 comments

You can't construct a fixed string from anything other than fixed strings or char[N] where N is the same size as the fixed string's size. It would be great to have convenience constructors that take any string and just truncate them.

Raildex avatar Oct 13 '22 17:10 Raildex

There are 2 cases for such a constructor:

  1. The source string is larger than the destination one
  2. The source string is smaller than the destination one

In the first situation we can truncate the string.

But I do not understand what we should do in the second one with the rest of the destination string. Fill with '\0'? This is kinda weird.

unterumarmung avatar Oct 13 '22 18:10 unterumarmung

std::string has separate size and capacity. I would expect fixed string to be a string of fixed capacity.

Raildex avatar Oct 14 '22 18:10 Raildex

std::string has separate size and capacity. I would expect fixed string to be a string of fixed capacity.

As it stated in the documentation, fixstr::fixed_string has the std::array's semantics of fixed size, not capacity.

unterumarmung avatar Oct 25 '22 09:10 unterumarmung