MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / FindFirstBit

Function FindFirstBit

src/core/bitmath_func.hpp:189–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187 */
188template <typename T>
189constexpr uint8_t FindFirstBit(T x)
190{
191 if (x == 0) return 0;
192
193 if constexpr (std::is_enum_v<T>) {
194 return std::countr_zero<std::underlying_type_t<T>>(x);
195 } else {
196 return std::countr_zero(x);
197 }
198}
199
200/**
201 * Search the last set bit in a value.

Callers 15

CalculateRefitMasksFunction · 0.85
ExploreSegmentFunction · 0.85
TrainControllerFunction · 0.85
NextIDMethod · 0.85
CheckFlatLandRoadStopFunction · 0.85
RoadFindPathToDestFunction · 0.85
GetWidgetStringMethod · 0.85
MxAllocateChannelFunction · 0.85
AllocateMethod · 0.85
RemoveFirstTrackFunction · 0.85
RemoveFirstTrackdirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected