Templated version, to use also standard vectors