I'm reading through the rapidjson library at the moment, and found this piece of code in stringbuffer.h
:
void Put(Ch c) { *stack_.template Push<Ch>() = c; }
where stack_
is defined as
mutable internal::Stack<Allocator> stack_;
and the function Push()
is implemented as
template<typename T>
RAPIDJSON_FORCEINLINE T* Push(size_t count = 1) {
Reserve<T>(count);
return PushUnsafe<T>(count);
}
My question is about the Push(Ch c)
function defined at the top. Why is there a template
command issued when accessing the Push()
member function? Does it serve any purpose besides delivering clarity that Push()
is a templated function?
Further, is this some kind of best practice / would you recommend it?