diff options
author | Matthias Braun <matze@braunis.de> | 2015-12-03 22:17:26 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2015-12-03 22:17:26 +0000 |
commit | bb300c512008269c1caabff9613a6dbc49f83fa4 (patch) | |
tree | b62bce071086105f08af76a48dced41551d3a6b4 /lib/Support/raw_ostream.cpp | |
parent | 0956a120f5a443670cf86e59a6ad9dcff7135a9e (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254655 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/raw_ostream.cpp')
-rw-r--r-- | lib/Support/raw_ostream.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 49ef400c5f2..5b1dceca0bf 100644 --- a/lib/Support/raw_ostream.cpp +++ b/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() { |