libtcspc C++ API
Streaming TCSPC and time tag data processing
Loading...
Searching...
No Matches
npint_ops.hpp
1/*
2 * This file is part of libtcspc
3 * Copyright 2019-2026 Board of Regents of the University of Wisconsin System
4 * SPDX-License-Identifier: MIT
5 */
6
7#pragma once
8
9#include "npint.hpp"
10
11#include <bit>
12
13namespace tcspc::internal {
14
15template <typename F>
16inline void for_each_set_bit(u32np bits, F func) noexcept(noexcept(func(0))) {
17 while (bits != 0_u32np) {
18 func(std::countr_zero(bits.value()));
19 bits = bits & (bits - 1_u32np); // Clear the handled bit
20 }
21}
22
23} // namespace tcspc::internal
npint< u32 > u32np
Non-promoted unsigned 32-bit integer.
Definition npint.hpp:306