GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 7 / 0 / 7
Functions: -% 0 / 1 / 1
Branches: -% 0 / 0 / 0

src/opt/bsearch/lib.hpp
Line Branch Exec Source
1 #pragma once
2
3 #include "../../util/alias/num/lib.hpp"
4
5 namespace tifa_libs {
6
7 template <class F>
8 requires requires(F pred, u32 x) {
9 { pred(x) } -> std::same_as<bool>;
10 }
11 36732636 CEXP u32 bsearch(F&& pred) NE {
12 36732636 u32 ok = 0, ng = 1;
13 94180551 while (pred(ng)) ng *= 2;
14 94180551 while (abs(i32(ok - ng)) > 1) {
15 57447915 cu32 mid = ok + (ng - ok) / 2;
16 57447915 (pred(mid) ? ok : ng) = mid;
17 }
18 36732636 return ok;
19 }
20
21 } // namespace tifa_libs
22