This commit is contained in:
2020-06-23 08:48:54 +02:00
parent 9d3bbc0a68
commit 1d53dc65cd
5 changed files with 46 additions and 23 deletions

View File

@ -111,6 +111,16 @@ ToStringHex(const T &value) {
return os.str();
}
/** Conversion of integer types, do not remove trailing zeros */
template <typename T>
typename std::enable_if<std::is_integral<T>::value, std::string>::type
ToStringHex(const T &value, int width) {
std::ostringstream os;
os << "0x" << std::hex << std::setfill('0') << std::setw(width) << value
<< std::dec;
return os.str();
}
/**
* hex
* For a container loop over all elements and call ToString on the element