From b0a11724c9e744f04fd3986969d8ef9edd450c02 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sun, 9 Oct 2005 21:22:07 +0000 Subject: [PATCH] Implementa operator>> desde un istream. --- src/number.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/number.h b/src/number.h index 8c37df6..bc1e5c2 100644 --- a/src/number.h +++ b/src/number.h @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #ifdef _WIN32 @@ -478,6 +480,20 @@ std::ostream& operator<< (std::ostream& os, const number< NN, EE >& n) return os; } +template < typename N, typename E > +std::istream& operator>> (std::istream& is, number< N, E >& n) +{ + std::string str; + is >> str; + unsigned base = 10; + if (is.flags() & std::ios_base::hex) // Si lo piden en hexa + base = 16; + if (is.flags() & std::ios_base::oct) // Si lo piden en octal + base = 8; + n = number< N, E >(str, base); + return is; +} + template < typename N, typename E > std::string numberToHex(const number< N, E >& n) { -- 2.43.0