ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 3fb7f5e was
0d10090,
checked in by Aaron Moss <a3moss@…>, 7 years ago
|
Add printing code to benchmark
|
-
Property mode set to
100644
|
File size:
801 bytes
|
Rev | Line | |
---|
[0d10090] | 1 | #pragma once |
---|
| 2 | |
---|
| 3 | #include <iomanip> |
---|
| 4 | #include <iostream> |
---|
| 5 | #include <utility> |
---|
| 6 | |
---|
| 7 | template<typename T> |
---|
| 8 | void print(std::ostream& out, const T& x) { out << x; } |
---|
| 9 | |
---|
| 10 | template<> |
---|
| 11 | void print<bool>(std::ostream& out, const bool& x) { out << (x ? "true" : "false"); } |
---|
| 12 | |
---|
| 13 | template<> |
---|
| 14 | void print<char>(std::ostream& out, const char& x ) { |
---|
| 15 | if ( 0x20 <= x && x <= 0x7E ) { out << "'" << x << "'"; } |
---|
| 16 | else { out << "'\\" << std::hex << (unsigned int)x << std::setbase(0) << "'"; } |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | template<typename R, typename S> |
---|
| 20 | std::ostream& operator<< (std::ostream& out, const std::pair<R, S>& x) { |
---|
| 21 | out << "["; |
---|
| 22 | print(out, x.first); |
---|
| 23 | out << ", "; |
---|
| 24 | print(out, x.second); |
---|
| 25 | return out << "]"; |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | template<typename T, typename... Args> |
---|
| 29 | void print(std::ostream& out, const T& arg, const Args&... rest) { |
---|
| 30 | out << arg; |
---|
| 31 | print(out, rest...); |
---|
| 32 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.