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

gsl::not_null conversion operator #1832

Open
JordanMaples opened this issue Sep 15, 2021 · 3 comments
Open

gsl::not_null conversion operator #1832

JordanMaples opened this issue Sep 15, 2021 · 3 comments

Comments

@JordanMaples
Copy link

An issue raised on the Microsoft/GSL that requests a conversion operator on gsl::not_null for non-copy constructible types (microsoft/GSL#991).

Would the Guidelines editors like to see something like this added for gsl::not_null?

@jwakely
Copy link
Contributor

jwakely commented Sep 16, 2021

This is consistent with what we've done for the base() members of iterator adaptors in C++20, to support move-only iterators.

Should the const& one really return a reference though? My gut feeling is that for this type both should return by value, although I haven't given it much thought.

@hsutter
Copy link
Contributor

hsutter commented Sep 30, 2021

Editors call: Would you please write up some pros and cons?

@mbeutel
Copy link

mbeutel commented Aug 12, 2023

This issue had come up in gsl-lite as well, and we decided to always return a value type from implicit conversion operators. The reasons are discussed in the comment here:

https://github.com/gsl-lite/gsl-lite/blob/a8c7e5bbbd08841836f9b92d72747fb8769dbec4/include/gsl/gsl-lite.hpp#L3007-L3034

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

4 participants