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

Unexpected results from compare operators. #32

Closed
yachoor opened this issue Aug 29, 2016 · 1 comment
Closed

Unexpected results from compare operators. #32

yachoor opened this issue Aug 29, 2016 · 1 comment
Labels

Comments

@yachoor
Copy link
Contributor

yachoor commented Aug 29, 2016

After span's comparison functions have been made free functions in release 0.9.0, they now give incorrect results when comparing spans differing in constness:

char data[] = {'a', 'b'};
gsl::string_span a = gsl::as_span(data);
gsl::cstring_span b = gsl::as_span(data).last(1);

assert(a != b); // previously worked as expected, now converts to bool and compares equal!
@martinmoene
Copy link
Collaborator

Resolved by issue #33 and commit 53dfc40:

Allow comparison of spans only differing in cv-ness

Note: The C++ standard does not allow to compare containers that only differ in cv-ness.

This also holds for M-GSL. However M-GSL does allow to compare string_span with cstring_span.

The comparation of string_span in GSL Lite (as it is now) is the same as that of span.
To continue allowing to compare string_span with cstring_span in GSL Lite, it is now possible to compare spans differing in cv-ness.

Perhaps a configuration flag that allows to switch between this behavior and the strict behavior is in order.

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

No branches or pull requests

2 participants