aboutsummaryrefslogtreecommitdiffstats
path: root/libdevcore
diff options
context:
space:
mode:
Diffstat (limited to 'libdevcore')
-rw-r--r--libdevcore/CommonData.h7
-rw-r--r--libdevcore/FixedHash.h2
2 files changed, 4 insertions, 5 deletions
diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h
index 4118907c..0a8c37d2 100644
--- a/libdevcore/CommonData.h
+++ b/libdevcore/CommonData.h
@@ -61,12 +61,11 @@ enum class HexCase
/// Convert a series of bytes to the corresponding string of hex duplets.
/// @param _w specifies the width of the first of the elements. Defaults to two - enough to represent a byte.
/// @example toHex("A\x69") == "4169"
-template <class T>
-std::string toHex(T const& _data, int _w = 2, HexPrefix _prefix = HexPrefix::DontAdd, HexCase _case = HexCase::Lower)
+inline std::string toHex(bytes const& _data, int _w = 2, HexPrefix _prefix = HexPrefix::DontAdd, HexCase _case = HexCase::Lower)
{
std::ostringstream ret;
int rix = _data.size() - 1;
- for (auto datum: _data)
+ for (uint8_t c: _data)
{
// switch hex case every four hexchars
auto hexcase = std::nouppercase;
@@ -76,7 +75,7 @@ std::string toHex(T const& _data, int _w = 2, HexPrefix _prefix = HexPrefix::Don
hexcase = (rix-- & 2) == 0 ? std::nouppercase : std::uppercase;
ret << std::hex << hexcase << std::setfill('0') << std::setw(_w)
- << +static_cast<typename std::make_unsigned<decltype(datum)>::type>(datum);
+ << size_t(c);
}
return (_prefix == HexPrefix::Add) ? "0x" + ret.str() : ret.str();
diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h
index 24b89840..9245d726 100644
--- a/libdevcore/FixedHash.h
+++ b/libdevcore/FixedHash.h
@@ -95,7 +95,7 @@ public:
uint8_t operator[](unsigned _i) const { return m_data[_i]; }
/// @returns the hash as a user-readable hex string.
- std::string hex() const { return toHex(ref()); }
+ std::string hex() const { return toHex(asBytes()); }
/// @returns a mutable byte vector_ref to the object's data.
bytesRef ref() { return bytesRef(m_data.data(), N); }