LDMX Software
Hex.h
1#ifndef PACKING_UTILITY_HEX_H_
2#define PACKING_UTILITY_HEX_H_
3
4#include <iomanip>
5
6namespace packing {
7namespace utility {
8
17template <typename WordType>
18struct Hex {
19 static const std::size_t WIDTH{8 * sizeof(WordType)};
20 WordType& word_;
21 Hex(WordType& w) : word_{w} {}
22 friend inline std::ostream& operator<<(
23 std::ostream& os, const packing::utility::Hex<WordType>& h) {
24 os << "0x" << std::setfill('0') << std::setw(h.WIDTH) << std::hex << h.word_
25 << std::dec;
26 return os;
27 }
28};
29
30} // namespace utility
31} // namespace packing
32
33#endif // PACKING_UTILITY_HEX_H_