C++ template capture buffer