-
Notifications
You must be signed in to change notification settings - Fork 740
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
Missing swap
for gsl::not_null
for move-only types
#1129
Comments
gsl::not_null
for move-only types
gsl::not_null
for move-only typesswap
for gsl::not_null
for move-only types
Hi @christianbrugger, thanks for the question; I'll bring it up in the next maintainers' sync. |
Maintainers call: Yes, there should be a homogeneous |
Wait, is specializing function templates from Edit: the cppreference.com documentation on std::swap discusses this:
|
Thanks! I think you're correct, we should overload (not specialize) in |
fixes: microsoft#1129 * create gsl::swap<T>(T&, T&) which wraps std::swap * specialize gsl::swap<T>(gsl::not_null<T>&, gsl::not_null<T>&) * add tests
I want to exchange the content of two
gsl::not_null<std::unique_ptr<int>>
.I was pretty sure a swap would work, but couldn't get it working.
https://godbolt.org/z/64na6e356
This gives an error:
I understand that its not possible to move from such a pointer.
However, not even enabling swap for smart-pointers makes
std::not_null
even less useful.Is there anything against implementing a custom
swap
, that takes twonot_null
pointers and swaps the underlying, as we know they are both not null?The text was updated successfully, but these errors were encountered: