isocpp / isocpp/CppCoreGuidelines
About the mixed gsl::not_null equality comparison functions
Open
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 45.3k
- Forks
- 5.6k
- PR merge metrics
- No merged PRs in 30d
Description
As a not_null cannot be null, I was wondering if we should delete the mixed equality operations operations as these operations will always result as false, and having code that ask for them seems to be wrong.
template <class T>
bool operator==(const not_null<T>& lhs, std::nullptr_t rhs) = delete;
template <class T>
bool operator==(std::nullptr_t rhs, const not_null<T>& lhs) = delete;
template <class T>
bool operator!=(const not_null<T>& lhs, std::nullptr_t rhs) = delete;
template <class T>
bool operator!=(std::nullptr_t lhs, const not_null<T>& rhs) = delete;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names gsl::not_null and its mixed equality comparison overloads but no file or test. Locate those overloads first, review how not_null comparisons are currently specified, and check existing tests or examples involving nullptr; done means the intended comparison behavior is clearly reflected in the implementation and its tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100