19 namespace itk::utils {
22 std::string to_string(
const std::span<const uint8_t> data);
23 std::string to_string(
const std::span<const uint16_t> data);
24 std::string to_string(
const std::span<const uint32_t> data);
25 std::string to_string(
const std::span<const uint64_t> data);
30 template <u
int n,
typename T>
31 inline void trunc_bits(T& val) {
32 static_assert(std::is_unsigned<T>(),
"Unsigned type must be passed");
33 constexpr T mask =
static_cast<T
>(~(
static_cast<T
>(~0) << n));
40 inline uint32_t hex_to_int(
const std::string &str) {
42 uint32_t res = stol(str, &pos, 16);
43 if (str.length() != pos) {
44 throw std::runtime_error(
"incorrect hex string.");
50 inline uint delta_msec(std::chrono::steady_clock::duration delta) {
51 using namespace std::chrono;
52 return duration_cast<milliseconds>(delta).count();