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

string_view::remove_prefix(npos) #10

Open
OlafvdSpek opened this issue Jan 29, 2018 · 4 comments
Open

string_view::remove_prefix(npos) #10

OlafvdSpek opened this issue Jan 29, 2018 · 4 comments

Comments

@OlafvdSpek
Copy link

Undefined behavior for std, defined behavior for Boost.

Wouldn't it be better to have the same behavior for both?

@mclow
Copy link
Owner

mclow commented Feb 5, 2018

I'm confused. Are you asking for "consistent undefined behavior"?

@OlafvdSpek
Copy link
Author

Maybe
A debug assert or maybe even a trap in release might be nice to avoid any surprises when substituting boost::string_view for the std one.

@mclow
Copy link
Owner

mclow commented Feb 6, 2018

The whole point of undefined behavior is that you have no guarantees - of anything. The C people used to say "and demons will fly out of my nose". You can run a program with UB twice in a row on the same machine with the same inputs, and once it might give you the right answer, and the second time it might cause your cat to become pregnant.

@OlafvdSpek
Copy link
Author

I know. The problem is that boost::string_view::remove_prefix(npos) is well-defined, while std::string_view::remove_prefix(npos) is undefined.
So people that rely on the boost one and will be bitten when they switch to the std one.

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