From: Leandro Lucarella Date: Sun, 9 Oct 2005 21:22:07 +0000 (+0000) Subject: Implementa operator>> desde un istream. X-Git-Tag: darcs_import~5 X-Git-Url: https://git.llucax.com/z.facultad/75.29/dale.git/commitdiff_plain/b0a11724c9e744f04fd3986969d8ef9edd450c02 Implementa operator>> desde un istream. --- 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) {