C++ template for run-length encoding compression