[llvm-commits] [llvm] r44589 - /llvm/trunk/include/llvm/Bitcode/Serialize.h
Ted Kremenek
kremenek at apple.com
Tue Dec 4 16:13:07 PST 2007
Author: kremenek
Date: Tue Dec 4 18:13:07 2007
New Revision: 44589
URL: http://llvm.org/viewvc/llvm-project?rev=44589&view=rev
Log:
Added "Emitter" functor to allow easy emitting of elements of a container
using std::for_each.
Modified:
llvm/trunk/include/llvm/Bitcode/Serialize.h
Modified: llvm/trunk/include/llvm/Bitcode/Serialize.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Serialize.h?rev=44589&r1=44588&r2=44589&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/Serialize.h (original)
+++ llvm/trunk/include/llvm/Bitcode/Serialize.h Tue Dec 4 18:13:07 2007
@@ -37,6 +37,17 @@
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);
More information about the llvm-commits
mailing list