| Last change
 on this file since 2989d6f was             f4e3419d, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago | 
        
          | 
restructure paper documents
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            802 bytes | 
      
      
| Rev | Line |  | 
|---|
| [0d10090] | 1 | #pragma once | 
|---|
|  | 2 | #include <iomanip> | 
|---|
|  | 3 | #include <iostream> | 
|---|
| [c87cd93] | 4 | #include "cpp-pair.hpp" | 
|---|
| [0d10090] | 5 |  | 
|---|
| [a381b46] | 6 | template<typename T> void print(std::ostream& out, const T& x) { out << x; } | 
|---|
| [0d10090] | 7 |  | 
|---|
| [a381b46] | 8 | template<> void print<bool>(std::ostream& out, const bool& x) { out << (x ? "true" : "false"); } | 
|---|
| [0d10090] | 9 |  | 
|---|
| [a381b46] | 10 | template<> void print<char>(std::ostream& out, const char& x ) { | 
|---|
| [0d10090] | 11 | if ( 0x20 <= x && x <= 0x7E ) { out << "'" << x << "'"; } | 
|---|
|  | 12 | else { out << "'\\" << std::hex << (unsigned int)x << std::setbase(0) << "'"; } | 
|---|
|  | 13 | } | 
|---|
|  | 14 |  | 
|---|
| [a381b46] | 15 | template<typename R, typename S> | 
|---|
| [c87cd93] | 16 | std::ostream& operator<< (std::ostream& out, const pair<R, S>& x) { | 
|---|
| [0d10090] | 17 | out << "["; | 
|---|
|  | 18 | print(out, x.first); | 
|---|
|  | 19 | out << ", "; | 
|---|
|  | 20 | print(out, x.second); | 
|---|
|  | 21 | return out << "]"; | 
|---|
|  | 22 | } | 
|---|
|  | 23 |  | 
|---|
| [a381b46] | 24 | template<typename T, typename... Args> | 
|---|
| [0d10090] | 25 | void print(std::ostream& out, const T& arg, const Args&... rest) { | 
|---|
|  | 26 | out << arg; | 
|---|
|  | 27 | print(out, rest...); | 
|---|
|  | 28 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.