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
25 << h.word_ << std::dec;
26 return os;
27 }
28};
29
30} // namespace utility
31} // namespace packing
32
33#endif // PACKING_UTILITY_HEX_H_
A very simple wrapper enabling us to more easily tell the output stream to style the input word in he...
Definition Hex.h:18