source: doc/papers/general/evaluation/cpp-print.hpp @ 6926a6d

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumwith_gc
Last change on this file since 6926a6d was 604e76d, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

initial setup for general and concurrency papers

  • Property mode set to 100644
File size: 802 bytes
RevLine 
[604e76d]1#pragma once
2#include <iomanip>
3#include <iostream>
4#include "cpp-pair.hpp"
5
6template<typename T> void print(std::ostream& out, const T& x) { out << x; }
7
8template<> void print<bool>(std::ostream& out, const bool& x) { out << (x ? "true" : "false"); }
9
10template<> void print<char>(std::ostream& out, const char& x ) {
11        if ( 0x20 <= x && x <= 0x7E ) { out << "'" << x << "'"; }
12        else { out << "'\\" << std::hex << (unsigned int)x << std::setbase(0) << "'"; }
13}
14
15template<typename R, typename S> 
16std::ostream& operator<< (std::ostream& out, const pair<R, S>& x) {
17        out << "[";
18        print(out, x.first);
19        out << ", ";
20        print(out, x.second);
21        return out << "]";
22}
23
24template<typename T, typename... Args> 
25void 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.