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

Clarification of gsl::not_null supported types, and ease-of-use members #1901

Closed
dmitrykobets-msft opened this issue Mar 21, 2022 · 1 comment
Assignees

Comments

@dmitrykobets-msft
Copy link

What is the guidelines' current position on adding "useful" methods to not_null to support ease-of-use for more general "nullable" types?

A recent issue in the ms-gsl repo microsoft/GSL#1039 is asking whether gsl::not_null can be made to support operator() for std::function.

Two similar issues existed in the ms-gsl repo in the past, but were closed due to not_null being only for pointers-to-objects and for standard smart pointers.

However, it seems that the guidelines now define gsl::not_null more generally as

not_null // T is usually a pointer type (e.g., not_null<int*> and not_null<owner<Foo*>>) that must not be nullptr. T can be any type for which ==nullptr is meaningful.

@hsutter hsutter self-assigned this Apr 7, 2022
@hsutter
Copy link
Contributor

hsutter commented Apr 7, 2022

Editors call: No. not_null is currently intended for pointers to single objects.

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