add stack resize to C++ template