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
This commit is contained in:
Ted Kremenek 2007-12-05 00:13:07 +00:00
parent dd86ce3d57
commit 7da75c5a40

View File

@ -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);