`touches` is poorly specified
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
Direzione di ricerca
Start with include/boost/icl/concept/interval.hpp at the touches implementation linked in the issue, then compare its behavior with the documented function reference and the two reproductions. Decide and implement consistent behavior for reversed argument order and empty intervals, updating documentation and tests to define the expected cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The implementation of touches:
assumes that left is to the left of right, yet this precondition is not documented:
touches(x,y)Between the disjoint intervalsxandyare no elements.
So, we end up with touches not being symmetric (https://godbolt.org/z/7zPoe6hYj):
#include <boost/icl/interval.hpp>
#include <iostream>
int main()
{
boost::icl::closed_interval<int> x(0, 1), y(2, 3);
std::cout << touches(x, y) << "\n"; // outputs 1
std::cout << touches(y, x) << "\n"; // outputs 0
}
Additionally, empty intervals are handled in a way that is inconsistent with interval equality (https://godbolt.org/z/dxjGbsYr8):
#include <boost/icl/interval.hpp>
#include <iostream>
int main()
{
boost::icl::right_open_interval<int> empty0(0, 0), empty1(5, 5), y(0, 1);
std::cout << (empty0 == empty1) << "\n"; // outputs 1
std::cout << touches(empty0, y) << "\n"; // outputs 1
std::cout << touches(empty1, y) << "\n"; // outputs 0
}
In the example empty0 and empty1 are equal, yet one touches y and the other does not, thus breaking the generally assumed equality preservation property.
My suggestions for improvement are:
- Document the precondition that
xmust precedeyintouches(x, y)or else maketouchesbehave symmetrically (touches(x, y) == touches(y, x)whenevertouches(x, y)is well defined). - Clarify what "
xtouchesy" means when one or both ofx,yare empty, or else explicitly disqualify passing empty intervals totouches. - If empty intervals are allowed, make the implementation of
touchesequality-preserving when an empty interval is replaced by another empty interval.
- Lingua principale
- C++
- Stelle
- 15
- Fork
- 51
- Merge medio
- 8g 6h
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di boostorg/icl
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
sprintf deprecatedAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
Tutte le issue di boostorg/icl
Issue simili
-
agent:WSL code-review linux pri:medium refactoring
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
kind/enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
psi29a/d2decomped#691 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
CachyOS/packageinstaller#144 ·
I maintainer di solito rispondono entro 1 giorno
-
(S1 - Need confirmation)
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
CleverRaven/Cataclysm-DDA#89715 ·
I maintainer di solito rispondono entro 1 giorno