tagfile: Support hexadecimal integer tags

This commit is contained in:
2023-01-15 22:23:54 -05:00
parent e5b347c70f
commit d3ed054bbb
2 changed files with 27 additions and 0 deletions

View File

@@ -272,4 +272,27 @@ public:
};
template<typename Int, typename = typename std::enable_if<std::is_integral<Int>::value>::type>
struct as_hex {
Int value;
as_hex(Int value) : value(value) {}
operator Int() { return value; }
};
template<typename Int>
inline std::ostream& operator<<(std::ostream& os, const as_hex<Int>& value) {
auto f = os.flags();
os << std::hex << value.value;
os.flags(f);
return os;
}
template<typename Int>
inline std::istream& operator>>(std::istream& is, as_hex<Int>& ref) {
auto f = is.flags();
is >> std::hex >> ref.value;
is.flags(f);
return is;
}
#endif