I have a pointer to a std :: vector * vector. How to get the address of the element i of this vector?

  • one
    p_vector->data() + i - VTT
  • one
    &p_vector->at(i); - Fat-Zer
  • Which way is better? - solo
  • one
    @solo, here's another way: &(*p_vector)[i] - freim
  • @solo, the way with at bit slower, but checks that i is in the allowed range. Ways with [] and data() do not check anything, due to this a little faster. - freim

0