Repository navigation
feat(ptr): not_null_ptr, fix not_null hash, make_not_null, release and swap - #17
Merged
Merged
Conversation
…d swap not_null_ptr<T> is not_null<T*>: the template argument names the pointee like move_ptr<T> and unique_not_null<T>, const goes in the argument (not_null_ptr<T const>). fixes: - std::hash<not_null> used not_null::pointer, which does not exist. It hashes the value of get() now: the pointer for unique_not_null. - make_not_null had a non deducible Adapt without a default, so no call compiled. Null and Adapt come first now and have defaults, T is deduced. It is constexpr and noexcept only when the constructor is. - release() on a raw pointer did not compile: the noexcept spec called T::release() and the if constexpr had no else. - swap() only took the default Null and Adapt.
codethinki
enabled auto-merge (squash)
October 18, 2026 22:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
not_null_ptr<T>=not_null<T*>. The argument names the pointee likemove_ptr<T>andunique_not_null<T>, const goes in the argument:not_null_ptr<T const>. The converting constructor givesnot_null_ptr<T>->not_null_ptr<T const>.std::hash<not_null>usednot_null::pointer, which does not exist, so nonot_nullwas hashable. It hashes the value ofget()now (the raw pointer forunique_not_null).make_not_nullhadAdaptwithout a default and not deducible, so no call compiled. The order is<Null = nullptr, Adapt = false, T>now:make_not_null(&x),make_not_null<VK_NULL_HANDLE>(handle). It isconstexpr, andnoexceptonly when the constructor is (debug builds check the value).release()on a raw pointer did not compile: thenoexceptspec calledT::release()and theif constexprhad noelse.swap()only took the defaultNullandAdapt.For cth_engine, which replaces its
not_null<X const*>withnot_null_ptr<X const>.Test plan