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

remove null check during access and allow non-copyable pointer types like unique_ptr #650

Closed
wants to merge 4 commits into from

Conversation

xaxxon
Copy link
Contributor

@xaxxon xaxxon commented Mar 30, 2018

as discussed here: #649

the constructor/assignment operators already check that ptr_ is never set to null, so a runtime check during reads isn't necessary.

fixes #604 fixes #550 fixes #325 fixes #89 fixes #651

@xaxxon xaxxon changed the title remove null check during access remove null check during access and allow non-copyable pointer types like unique_ptr Apr 13, 2018
@xaxxon
Copy link
Contributor Author

xaxxon commented Apr 13, 2018

Updated pull request to include changes for supporting unique_ptr as discussed here:

#651

@xaxxon xaxxon mentioned this pull request Apr 13, 2018
@xaxxon
Copy link
Contributor Author

xaxxon commented Apr 13, 2018

I'm not sure what the point of the static_assert that you could assign nullptr_t but it was blocking what seemed to be valid test cases, so I removed it.

Also, the is_convertible was also stopping a better construction path so I updated that, as well.

@@ -68,10 +68,9 @@ using owner = T;
template <class T>
class not_null
{
public:
static_assert(std::is_assignable<T&, std::nullptr_t>::value, "T cannot be assigned nullptr.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cppcoreguidelines says in http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#gslview-views the following about not_null<T : "T can be any type for which ==nullptr is meaningful.", so I guess it would make sense to static_assert on this kind of type trait instead : https://ideone.com/nuYfaB

@xaxxon
Copy link
Contributor Author

xaxxon commented Apr 14, 2018 via email

@neilmacintosh
Copy link
Collaborator

@xaxxon this PR makes two separate changes. Can you separate them out, so that we are not forced to take one to get the other? The part of the change that is easy to accept is removing the Ensures (as discussed in the relevant issue). There is still some discussion going on support for smart pointers.

@xaxxon
Copy link
Contributor Author

xaxxon commented Apr 17, 2018 via email

@xaxxon
Copy link
Contributor Author

xaxxon commented Apr 17, 2018

Also, my interest in putting more effort into this PR is directly tied to the interest this project puts into not breaking my existing code. I've spent a lot of time putting together benchmarks and such and am concerned that #659 is going to make me put a lot of time into adjusting my API to the point where I will be (again) deciding if I should just use my own fork.

@xaxxon xaxxon closed this Apr 17, 2018
@xaxxon
Copy link
Contributor Author

xaxxon commented Apr 17, 2018

wrong button.

@xaxxon xaxxon reopened this Apr 17, 2018
@beinhaerter
Copy link
Contributor

Do you know how to do that in github?

@xaxxon You do one fork of the GSL repository, then create two (or more) branches in your fork. For each branch you can create a pull request. If you want so see this in action you can look at my fork https://github.com/beinhaerter/GSL with three branches (https://github.com/beinhaerter/GSL/branches), each for a different PR (https://github.com/Microsoft/GSL/pulls/beinhaerter).

@xaxxon
Copy link
Contributor Author

xaxxon commented Apr 25, 2018

closing all my issues/PRs because GSL isn't at the maturity level of a library I can depend on.

@xaxxon xaxxon closed this Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants