[cpp] Split vector creation from setting the size