Changeset a381b46 for doc/generic_types/evaluation/cpp-print.hpp
- Timestamp:
- Apr 15, 2017, 7:09:59 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- c57d1935
- Parents:
- 308880c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/generic_types/evaluation/cpp-print.hpp
r308880c ra381b46 1 1 #pragma once 2 3 2 #include <iomanip> 4 3 #include <iostream> 5 4 #include <utility> 6 5 7 template<typename T> 8 void print(std::ostream& out, const T& x) { out << x; } 6 template<typename T> void print(std::ostream& out, const T& x) { out << x; } 9 7 10 template<> 11 void print<bool>(std::ostream& out, const bool& x) { out << (x ? "true" : "false"); } 8 template<> void print<bool>(std::ostream& out, const bool& x) { out << (x ? "true" : "false"); } 12 9 13 template<> 14 void print<char>(std::ostream& out, const char& x ) { 10 template<> void print<char>(std::ostream& out, const char& x ) { 15 11 if ( 0x20 <= x && x <= 0x7E ) { out << "'" << x << "'"; } 16 12 else { out << "'\\" << std::hex << (unsigned int)x << std::setbase(0) << "'"; } 17 13 } 18 14 19 template<typename R, typename S> 15 template<typename R, typename S> 20 16 std::ostream& operator<< (std::ostream& out, const std::pair<R, S>& x) { 21 17 out << "["; … … 26 22 } 27 23 28 template<typename T, typename... Args> 24 template<typename T, typename... Args> 29 25 void print(std::ostream& out, const T& arg, const Args&... rest) { 30 26 out << arg;
Note: See TracChangeset
for help on using the changeset viewer.