libdpf/test/tests/helpers/domain_walk.hpp
Ryan Henry e4e666f459 Initial import of libdpf.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-24 14:08:32 -06:00

24 lines
903 B
C++

#ifndef LIBDPF_TEST_TESTS_HELPERS_DOMAIN_WALK_HPP__
#define LIBDPF_TEST_TESTS_HELPERS_DOMAIN_WALK_HPP__
// eval_interval / eval_full emit points in integer order of the input bits
// (the same order as operator++ for ordinary integers). xor_wrapper::operator++
// is characteristic-2 addition, XOR 1, so it does not walk that domain.
template <typename InputT>
InputT next_domain_point(InputT cur)
{
if constexpr (dpf::utils::has_characteristic_two_v<InputT>)
{
using narrow = dpf::utils::integral_type_from_bitlength_t<dpf::utils::bitlength_of_v<InputT>>;
auto bits = static_cast<narrow>(dpf::utils::to_integral_type<InputT>{}(cur));
bits = static_cast<narrow>(bits + narrow{1});
return dpf::utils::make_from_integral_value<InputT>{}(bits);
}
else
{
++cur;
return cur;
}
}
#endif // LIBDPF_TEST_TESTS_HELPERS_DOMAIN_WALK_HPP__