LCOV - code coverage report
Current view: top level - include/xo/ratio - ratio_iostream.hpp (source / functions) Hit Total Coverage
Test: out3.info Lines: 5 5 100.0 %
Date: 1980-01-01 00:00:00 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /** @file ratio_iostream.hpp
       2             :  *
       3             :  *  Author: Roland Conybeare
       4             :  **/
       5             : 
       6             : #pragma once
       7             : 
       8             : #include "ratio.hpp"
       9             : #include <ostream>
      10             : 
      11             : namespace xo {
      12             :     namespace ratio {
      13             :         /** @brief print ratio x on stream os.
      14             :          *
      15             :          *  Example:
      16             :          *  @code
      17             :          *  print_ratio(std::cerr, make_ratio(1,2); // outputs "<ratio 1/2>"
      18             :          *  @endcode
      19             :          **/
      20             :         template <typename Int>
      21             :         void
      22        2521 :         print_ratio (std::ostream & os, const ratio<Int> & x) {
      23        2521 :             os << "<ratio " << x.num() << "/" << x.den() << ">";
      24        2521 :         }
      25             : 
      26             :         /** @brief print ratio x on stream os.
      27             :          *
      28             :          *  Example:
      29             :          *  @code
      30             :          *  std::cout << make_ratio(2,3); // outputs "<ratio 2/3>"
      31             :          *  @endcode
      32             :          **/
      33             :         template <typename Int>
      34             :         inline std::ostream &
      35        2521 :         operator<< (std::ostream & os, const ratio<Int> & x) {
      36        2521 :             print_ratio(os, x);
      37             :             return os;
      38             :         }
      39             :     }
      40             : }
      41             : 
      42             : /** end ratio_iostream.hpp **/

Generated by: LCOV version 1.0