#ifndef SPROUT_RATIONAL_IO_HPP #define SPROUT_RATIONAL_IO_HPP #include #include #include #include #include namespace sprout { // // operator>> // operator<< // template inline std::basic_istream& operator>>(std::basic_istream& lhs, sprout::rational& rhs) { IntType n = IntType(0); IntType d = IntType(1); Elem c = 0; sprout::detail::io::ios_flags_saver saver(lhs); lhs >> n; c = lhs.get(); if (c != Elem('/')) { lhs.clear(std::istream::badbit); } lhs >> std::noskipws; lhs >> d; if (lhs) { rhs.assign(n, d); } return lhs; } template inline std::basic_ostream& operator<<(std::basic_ostream& lhs, sprout::rational const& rhs) { return lhs << rhs.numerator() << Elem('/') << rhs.denominator(); } } // namespace sprout #endif // SPROUT_RATIONAL_IO_HPP