`distance` returns incorrect results for descending intervals
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
The issue points to include/boost/icl/concept/interval.hpp, lines 1453–1493, where distance subtracts the closest interval ends. Read that implementation and check how it handles is_increasing<DomainT, Compare>::value; reproduce the examples for descending discrete and continuous intervals. Done means both return the expected distances (2 and 3) while existing increasing interval behavior remains correct.
Written by the indexing model from the issue text.
Description
As shown at https://godbolt.org/z/dfEzPx1rf:
#include <boost/icl/interval.hpp>
#include <functional>
#include <iostream>
int main()
{
using discrete = boost::icl::discrete_interval<int, std::greater>;
discrete x = discrete::closed(9, 8), y = discrete::closed(5, 3);
std::cout << distance(x, y) << "\n"; // outputs -4, should be 2
using continuous = boost::icl::continuous_interval<double, std::greater>;
continuous a = continuous::closed(9, 8), b = continuous::closed(5, 3);
std::cout << distance(a, b) << "\n"; // outputs -3, should be 3
}
Both discrete and continuous intervals are affected. This is not solved, not even partially, by (pending) #60. The offending code simply subtracts the closest ends of the intervals without checking is_increasing<DomainT, Compare>::value:
https://github.com/boostorg/icl/blob/b587925c05ab626436822a5d5e3317a5da97f320/include/boost/icl/concept/interval.hpp#L1453-L1493
- Dominant language
- C++
- Stars
- 15
- Forks
- 51
- Avg merge
- 8d 6h
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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.
More from boostorg/icl
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
-
sprintf deprecatedOpen
Difficulty 1/5 Under an hour Newbie friendliness 62/100
-
Difficulty 3/5 1-2 days Newbie friendliness 56/100
-
`touches` is poorly specifiedPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Similar issues
-
agent:WSL code-review linux pri:medium refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
kind/enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
psi29a/d2decomped#691 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
CachyOS/packageinstaller#144 ·
Maintainers usually reply within 1 day
-
(S1 - Need confirmation)
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
CleverRaven/Cataclysm-DDA#89715 ·
Maintainers usually reply within 1 day