Simple tail implementation written in C++