Merge pull request #1393 from VoR0220/giveBytesOstream

add ostream to bytes for ease of development
This commit is contained in:
chriseth 2016-11-23 14:57:02 +01:00 committed by GitHub
commit a7c2509adf

View File

@ -135,6 +135,17 @@ inline u256 s2u(s256 _u)
return u256(c_end + _u);
}
inline std::ostream& operator<<(std::ostream& os, bytes const& _bytes)
{
std::ostringstream ss;
ss << std::hex;
std::copy(_bytes.begin(), _bytes.end(), std::ostream_iterator<int>(ss, ","));
std::string result = ss.str();
result.pop_back();
os << "[" + result + "]";
return os;
}
template <size_t n> inline u256 exp10()
{
return exp10<n - 1>() * u256(10);