Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

constructor from any const char* and std::string #44

Open
Raildex opened this issue Oct 13, 2022 · 3 comments
Open

constructor from any const char* and std::string #44

Raildex opened this issue Oct 13, 2022 · 3 comments

Comments

@Raildex
Copy link

Raildex commented Oct 13, 2022

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.

@unterumarmung
Copy link
Owner

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.

@Raildex
Copy link
Author

Raildex commented Oct 14, 2022

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

@unterumarmung
Copy link
Owner

unterumarmung commented Oct 25, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants