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

HINSTANCE is no longer assigned to nullptr #40

Conversation

martin-olivier
Copy link
Owner

fix: HINSTANCE is not assigned to nullptr anymore since it's not officially a pointer (replaced by 0)

@martin-olivier martin-olivier added the enhancement New feature or request label Jun 2, 2022
@martin-olivier martin-olivier self-assigned this Jun 2, 2022
@martin-olivier martin-olivier linked an issue Jun 2, 2022 that may be closed by this pull request
@martin-olivier martin-olivier merged commit 3d5ab97 into dev Jun 3, 2022
@martin-olivier martin-olivier deleted the 37-cant-use-nullptr-for-handle-when-you-dont-know-its-a-pointer branch June 3, 2022 09:31
@@ -89,7 +89,7 @@ class dylib {
dylib& operator=(const dylib&) = delete;

dylib(dylib &&other) noexcept : m_handle(other.m_handle) {
other.m_handle = nullptr;
other.m_handle = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

0 is not really much different than nullptr - it assumes HINSTANCE can be initialized by an integer. You might as well keep the nullptr. If you don't want to do something fancier/more complex, you could at least add a comment regarding the assumption somewhere. Maybe even here.

@@ -215,7 +215,7 @@ class dylib {
}

protected:
native_handle_type m_handle{nullptr};
native_handle_type m_handle{};
Copy link
Contributor

Choose a reason for hiding this comment

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

Now you're making two assumptions: constructible from 0 and default constructible :-P

@martin-olivier
Copy link
Owner Author

Mhhh to be honest i don't understand your point on that 😅
Could you make me a pull request targeting dev ?

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

Successfully merging this pull request may close these issues.

Can't use nullptr for handle when you don't know it's a pointer
2 participants