vendredi 2 juin 2017

Pass std::vector as const float *? [duplicate]

This question already has an answer here:

My function is:

void function(const float *, int sizeOfArray){...}

My vector is:

std::vector<float> myVector(size, val);

I read in the docs you can use myVector[0] as standard c++ static arrays operations.

How can I pass that vector to that function without having to copy the values to a new dynamic array? (I want to avoid using new / delete just for this).

Is it something like...?

function(myVector[0], size);

I'm using C++11 by the way.

Aucun commentaire:

Enregistrer un commentaire