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

null_char_size has wrong size #50

Open
xezon opened this issue Dec 18, 2024 · 4 comments
Open

null_char_size has wrong size #50

xezon opened this issue Dec 18, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@xezon
Copy link

xezon commented Dec 18, 2024

null_char_size has wrong size.

Is

        /// \brief Size it takes to store the null '\0' char
        /// Of course we could just write 1 in the code, but this gives us
        /// better semantics
        static constexpr size_type null_char_size = '\0';

Should be

        static constexpr size_type null_char_size = sizeof('\0');
@xezon xezon added the bug Something isn't working label Dec 18, 2024
@alandefreitas
Copy link
Owner

Oh... :)

@xezon
Copy link
Author

xezon commented Dec 19, 2024

I think it can be simply written as 1, because sizeof('\0') looks confusing when looking at a string made of 2 byte or 4 byte characters.

@alandefreitas
Copy link
Owner

Is it always 1, though? I don't think C++ reached a consensus on that yet even though it's 1 byte on almost all platforms.

@xezon
Copy link
Author

xezon commented Dec 20, 2024

I would expect it is 1x sizeof(char) for chars, 1x sizeof(wchar_t) for multi byte and so on. But I do not know for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants