forked from Bananymous/banan-os
BAN: Implement distance() for iterators
This commit is contained in:
parent
19604015de
commit
bf3e9eabd5
|
@ -36,6 +36,25 @@ namespace BAN
|
||||||
return it - count;
|
return it - count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename It>
|
||||||
|
size_t distance(It it1, It it2)
|
||||||
|
{
|
||||||
|
size_t dist = 0;
|
||||||
|
while (it1 != it2)
|
||||||
|
{
|
||||||
|
++it1;
|
||||||
|
++dist;
|
||||||
|
}
|
||||||
|
return dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename It>
|
||||||
|
requires requires(It it1, It it2) { requires is_integral_v<decltype(it2 - it1)>; }
|
||||||
|
size_t distance(It it1, It it2)
|
||||||
|
{
|
||||||
|
return it2 - it1;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, typename Container, bool CONST>
|
template<typename T, typename Container, bool CONST>
|
||||||
class IteratorSimpleGeneral
|
class IteratorSimpleGeneral
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue