aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Bitcode/Serialize.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-12-05 00:13:07 +0000
committerTed Kremenek <kremenek@apple.com>2007-12-05 00:13:07 +0000
commit7b8ad1cfd715f8ae5059a942254682a4b916028f (patch)
tree7ad62c5050ac4dffe1337850f37075772c7660fe /include/llvm/Bitcode/Serialize.h
parent567d358193effac22cbda6144ca5b9b08e524f96 (diff)
downloadexternal_llvm-7b8ad1cfd715f8ae5059a942254682a4b916028f.zip
external_llvm-7b8ad1cfd715f8ae5059a942254682a4b916028f.tar.gz
external_llvm-7b8ad1cfd715f8ae5059a942254682a4b916028f.tar.bz2
Added "Emitter" functor to allow easy emitting of elements of a container
using std::for_each. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44589 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Bitcode/Serialize.h')
-rw-r--r--include/llvm/Bitcode/Serialize.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/llvm/Bitcode/Serialize.h b/include/llvm/Bitcode/Serialize.h
index 7b6d822..b0b39de 100644
--- a/include/llvm/Bitcode/Serialize.h
+++ b/include/llvm/Bitcode/Serialize.h
@@ -37,6 +37,17 @@ public:
template <typename T>
inline void Emit(const T& X) { SerializeTrait<T>::Emit(*this,X); }
+ template <typename T>
+ struct Emitter {
+ Serializer &S;
+
+ Emitter(Serializer& s) : S(s) {}
+ void operator()(const T& x) const { S.Emit(x); }
+ };
+
+ template <typename T>
+ Emitter<T> MakeEmitter() { return Emitter<T>(*this); }
+
void EmitInt(uint64_t X);
void EmitSInt(int64_t X);