aboutsummaryrefslogtreecommitdiffstats
path: root/libdevcore
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-07 19:42:02 +0800
committerGitHub <noreply@github.com>2018-11-07 19:42:02 +0800
commita459b8c81ec92f39be67c2d373d120eb86140e00 (patch)
tree3ff90d9e6afde63d1217b37ed62ab6e98d1139fc /libdevcore
parent88aee34c22d86a004848ae8bdc818b5168dd94cb (diff)
parentab0de38f16a9eff13ee5a32a3408b890d87941f6 (diff)
downloaddexon-solidity-a459b8c81ec92f39be67c2d373d120eb86140e00.tar
dexon-solidity-a459b8c81ec92f39be67c2d373d120eb86140e00.tar.gz
dexon-solidity-a459b8c81ec92f39be67c2d373d120eb86140e00.tar.bz2
dexon-solidity-a459b8c81ec92f39be67c2d373d120eb86140e00.tar.lz
dexon-solidity-a459b8c81ec92f39be67c2d373d120eb86140e00.tar.xz
dexon-solidity-a459b8c81ec92f39be67c2d373d120eb86140e00.tar.zst
dexon-solidity-a459b8c81ec92f39be67c2d373d120eb86140e00.zip
Merge pull request #5359 from ethereum/cpp17-forward-compat
Eliminate `byte`-typedef and use `uint8_t` in all their places instead.
Diffstat (limited to 'libdevcore')
-rw-r--r--libdevcore/Common.h8
-rw-r--r--libdevcore/CommonData.cpp2
-rw-r--r--libdevcore/CommonData.h6
-rw-r--r--libdevcore/FixedHash.h16
4 files changed, 15 insertions, 17 deletions
diff --git a/libdevcore/Common.h b/libdevcore/Common.h
index 0363d9a2..6208424e 100644
--- a/libdevcore/Common.h
+++ b/libdevcore/Common.h
@@ -64,15 +64,13 @@
#include <functional>
#include <string>
-using byte = uint8_t;
-
namespace dev
{
// Binary data types.
-using bytes = std::vector<byte>;
-using bytesRef = vector_ref<byte>;
-using bytesConstRef = vector_ref<byte const>;
+using bytes = std::vector<uint8_t>;
+using bytesRef = vector_ref<uint8_t>;
+using bytesConstRef = vector_ref<uint8_t const>;
// Numeric types.
using bigint = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<>>;
diff --git a/libdevcore/CommonData.cpp b/libdevcore/CommonData.cpp
index fa1a5353..91c60ffe 100644
--- a/libdevcore/CommonData.cpp
+++ b/libdevcore/CommonData.cpp
@@ -64,7 +64,7 @@ bytes dev::fromHex(std::string const& _s, WhenError _throw)
int h = fromHex(_s[i], WhenError::DontThrow);
int l = fromHex(_s[i + 1], WhenError::DontThrow);
if (h != -1 && l != -1)
- ret.push_back((byte)(h * 16 + l));
+ ret.push_back((uint8_t)(h * 16 + l));
else if (_throw == WhenError::Throw)
BOOST_THROW_EXCEPTION(BadHexCharacter());
else
diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h
index 0782fabc..fedd3af2 100644
--- a/libdevcore/CommonData.h
+++ b/libdevcore/CommonData.h
@@ -88,7 +88,7 @@ inline std::string asString(bytesConstRef _b)
/// Converts a string to a byte array containing the string's (byte) data.
inline bytes asBytes(std::string const& _b)
{
- return bytes((byte const*)_b.data(), (byte const*)(_b.data() + _b.size()));
+ return bytes((uint8_t const*)_b.data(), (uint8_t const*)(_b.data() + _b.size()));
}
// Big-endian to/from host endian conversion functions.
@@ -117,7 +117,7 @@ inline T fromBigEndian(_In const& _bytes)
{
T ret = (T)0;
for (auto i: _bytes)
- ret = (T)((ret << 8) | (byte)(typename std::make_unsigned<typename _In::value_type>::type)i);
+ ret = (T)((ret << 8) | (uint8_t)(typename std::make_unsigned<typename _In::value_type>::type)i);
return ret;
}
inline bytes toBigEndian(u256 _val) { bytes ret(32); toBigEndian(_val, ret); return ret; }
@@ -135,7 +135,7 @@ inline bytes toCompactBigEndian(T _val, unsigned _min = 0)
toBigEndian(_val, ret);
return ret;
}
-inline bytes toCompactBigEndian(byte _val, unsigned _min = 0)
+inline bytes toCompactBigEndian(uint8_t _val, unsigned _min = 0)
{
return (_min || _val) ? bytes{ _val } : bytes{};
}
diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h
index cd6e1da1..24b89840 100644
--- a/libdevcore/FixedHash.h
+++ b/libdevcore/FixedHash.h
@@ -79,7 +79,7 @@ public:
operator Arith() const { return fromBigEndian<Arith>(m_data); }
/// @returns true iff this is the empty hash.
- explicit operator bool() const { return std::any_of(m_data.begin(), m_data.end(), [](byte _b) { return _b != 0; }); }
+ explicit operator bool() const { return std::any_of(m_data.begin(), m_data.end(), [](uint8_t _b) { return _b != 0; }); }
// The obvious comparison operators.
bool operator==(FixedHash const& _c) const { return m_data == _c.m_data; }
@@ -90,9 +90,9 @@ public:
FixedHash operator~() const { FixedHash ret; for (unsigned i = 0; i < N; ++i) ret[i] = ~m_data[i]; return ret; }
/// @returns a particular byte from the hash.
- byte& operator[](unsigned _i) { return m_data[_i]; }
+ uint8_t& operator[](unsigned _i) { return m_data[_i]; }
/// @returns a particular byte from the hash.
- byte operator[](unsigned _i) const { return m_data[_i]; }
+ 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()); }
@@ -104,19 +104,19 @@ public:
bytesConstRef ref() const { return bytesConstRef(m_data.data(), N); }
/// @returns a mutable byte pointer to the object's data.
- byte* data() { return m_data.data(); }
+ uint8_t* data() { return m_data.data(); }
/// @returns a constant byte pointer to the object's data.
- byte const* data() const { return m_data.data(); }
+ uint8_t const* data() const { return m_data.data(); }
/// @returns a copy of the object's data as a byte vector.
bytes asBytes() const { return bytes(data(), data() + N); }
/// @returns a mutable reference to the object's data as an STL array.
- std::array<byte, N>& asArray() { return m_data; }
+ std::array<uint8_t, N>& asArray() { return m_data; }
/// @returns a constant reference to the object's data as an STL array.
- std::array<byte, N> const& asArray() const { return m_data; }
+ std::array<uint8_t, N> const& asArray() const { return m_data; }
/// Returns the index of the first bit set to one, or size() * 8 if no bits are set.
inline unsigned firstBitSet() const
@@ -137,7 +137,7 @@ public:
void clear() { m_data.fill(0); }
private:
- std::array<byte, N> m_data; ///< The binary data.
+ std::array<uint8_t, N> m_data; ///< The binary data.
};
/// Stream I/O for the FixedHash class.