Add an overload of print that accepts std::ostream.

This commit is contained in:
Victor Zverovich
2014-07-09 06:56:36 -07:00
parent ed421848b3
commit e3a44c11f6
3 changed files with 28 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
/*
Formatting library for C++
Copyright (c) 2012, Victor Zverovich
Copyright (c) 2012 - 2014, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -1122,6 +1122,12 @@ void fmt::print(std::FILE *f, StringRef format, const ArgList &args) {
std::fwrite(w.data(), 1, w.size(), f);
}
void fmt::print(std::ostream &os, StringRef format, const ArgList &args) {
Writer w;
w.write(format, args);
os.write(w.data(), w.size());
}
void fmt::print_colored(Color c, StringRef format, const ArgList &args) {
char escape[] = "\x1b[30m";
escape[3] = '0' + static_cast<char>(c);