aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-12-03 22:17:26 +0000
committerMatthias Braun <matze@braunis.de>2015-12-03 22:17:26 +0000
commite957a9bb1bbff982e2d17debf2f574f593017f5b (patch)
treebbf4653050a6e791d83e211e89feae65bb2e1890 /llvm/lib/Support/raw_ostream.cpp
parentbb599e3a4d105f1f2561a80d56e3d1ffb46cddb4 (diff)
downloadllvm-e957a9bb1bbff982e2d17debf2f574f593017f5b.zip
llvm-e957a9bb1bbff982e2d17debf2f574f593017f5b.tar.gz
llvm-e957a9bb1bbff982e2d17debf2f574f593017f5b.tar.bz2
raw_ostream: << operator for callables with raw_stream argument
This allows easier construction of print helpers. Example: Printable PrintLaneMask(unsigned LaneMask) { return Printable([LaneMask](raw_ostream &OS) { OS << format("%08X", LaneMask); }); } // Usage: OS << PrintLaneMask(Mask); Differential Revision: http://reviews.llvm.org/D14348 llvm-svn: 254655
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 49ef400..5b1dcec 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -264,6 +264,10 @@ raw_ostream &raw_ostream::operator<<(double N) {
return this->operator<<(format("%e", N));
}
+raw_ostream &raw_ostream::operator<<(Printable P) {
+ P(*this);
+ return *this;
+}
void raw_ostream::flush_nonempty() {