Skip to content

Conversation

@AnyOldName3
Copy link
Contributor

Adds a std::nullptr_t constructor overload for vsg::ref_ptr, allowing ref_ptr to be constructed from nullptr. This is more consistent with other smart pointer implementations, like std::shared_ptr, and makes some things less verbose that previously needed an explicitly-default-constructed-explicitly-typed ref_ptr for templates to resolve more concise.

I've demonstrated that change in a few places that I'd already worked on, but there are more that could benefit if it's more consistent with the project's desired code style. A repo-wide regex search for ref_ptr<[^()]*>\(\) will reveal them. Even if it's not wanted for the VSG itself, the overload is still a good thing to have.

@robertosfield
Copy link
Collaborator

I merged not expecting any problems but now get LOTS of warnings and errors when building on Kubuntu 22.04 with gcc 11.4.0. I have had to revert the merge, once fixes can be found I will be happy to merge.

The warnings/errors are in the form:

home/robert/Dev/VulkanSceneGraph/include/vsg/core/ref_ptr.h:63:16: warning: unnecessary parentheses in declaration of ‘nullptr_t’ [-Wparentheses]
63 | ref_ptr(std::nullptr_t) noexcept :
| ^~~~~~~~~~~~~~~~
/home/robert/Dev/VulkanSceneGraph/include/vsg/core/ref_ptr.h:63:16: note: remove parentheses
63 | ref_ptr(std::nullptr_t) noexcept :
| ^~~~~~~~~~~~~~~~
| - -
/home/robert/Dev/VulkanSceneGraph/include/vsg/core/ref_ptr.h:63:17: error: invalid use of ‘::’
63 | ref_ptr(std::nullptr_t) noexcept :
| ^~~
/home/robert/Dev/VulkanSceneGraph/include/vsg/core/ref_ptr.h:63:31: error: expected ‘;’ at end of member declaration
63 | ref_ptr(std::nullptr_t) noexcept :
| ^
| ;
/home/robert/Dev/VulkanSceneGraph/include/vsg/core/ref_ptr.h:63:33: error: expected unqualified-id before ‘noexcept’
63 | ref_ptr(std::nullptr_t) noexcept :
| ^~~~~~~~

@AnyOldName3
Copy link
Contributor Author

I forgot #include <cstddef> (because apparently MSVC doesn't need it, despite it being required by the standard). If you don't want ref_ptr.h to include headers, decltype(nullptr) is guaranteed by the standard to be the same type.

@robertosfield
Copy link
Collaborator

decltype(nullptr) is a bit hacky but better than including another header.

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

Successfully merging this pull request may close these issues.

2 participants