isocpp / isocpp/CppCoreGuidelines

About the mixed gsl::not_null equality comparison functions

Open
#1,521 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.