C++ reference counter template class