diff options
author | Olivier Gayot <og@satcom1.com> | 2017-11-18 13:43:31 +0100 |
---|---|---|
committer | Olivier Gayot <og@satcom1.com> | 2017-11-19 14:01:08 +0100 |
commit | c029a456f410ef45f4803bc7e209fbab81b3c42a (patch) | |
tree | f2c56e8ec679d9a2dbde7d7aca7849de1745deb1 | |
parent | acab244a6342be7597d0f2d22dc90a43f425fbb8 (diff) |
Allow a number to be used in an ostream object
When a number is streamed into a ostream object, the hexadecimal
representation of the number is given to the stream.
Signed-off-by: Olivier Gayot <og@satcom1.com>
-rw-r--r-- | number.cpp | 6 | ||||
-rw-r--r-- | number.h | 3 |
2 files changed, 9 insertions, 0 deletions
@@ -145,3 +145,9 @@ number::operator!=(const number &n) const } /* }}} */ + +std::ostream & +operator<<(std::ostream &os, const number &n) +{ + return os << n.to_hex_string(); +} @@ -1,6 +1,7 @@ #pragma once #include <list> +#include <ostream> #include <cstdint> @@ -77,3 +78,5 @@ private: /* First item is the least significant. */ std::list<std::uint64_t> _operands; }; + +std::ostream &operator<<(std::ostream &, const number &); |