compare_pointees.hpp should permit a predicate

Open
#72 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
tooling

Research direction

Start by reading compare_pointees.hpp and trace how equal_pointees handles null and non-null values. Define the predicate behavior for both optional states and determine how the requested equality and less-than use cases fit the existing interface. Done means the header supports predicate-based pointee comparison without changing nullness handling.

Written by the indexing model from the issue text.

Description

Suppose I have

std::optional<std::pair<int, float>> a, b;

and I want to test equality (or less-than-ness) of the float part, still treating them as optional. That is, thinking of them as optional floats. If equal_pointees had a predicate argument, I could do

equal_pointees(a, b, [](auto& x, auto& y) { return std::get<float>(x) == std::get<float>(y); });

The particular case I'd use this is where I've got a big struct representing the state of a view. For the current frame, I have a pointer to the previous one and a pointer to the current one and I want to decide if I have to a certain part of the work of redrawing. That is, either they have different nullness that's different, or if they are both non-null then compare a projection of them that pertains to the thing I care about.

Dominant language
C++
Stars
51
Forks
71
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

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.

More from boostorg/utility

All issues in boostorg/utility

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.