Provided you are sure the vector you are passing actually contains pointer to valid
MyStruct
instances, a
reinterpret_cast[
^] would do the trick. Try, for instance:
#include <iostream>
#include <vector>
using namespace std;
struct Foo
{
string s;
int i;
};
void reportFooVector( vector <Foo*> * pvf )
{
for (auto p : *pvf)
cout << p->s << ", " << p->i << endl;
}
int main()
{
Foo foo{ "foo", 5};
Foo goo{ "goo", 10};
vector <void *> vf { &foo, & goo};
reportFooVector( reinterpret_cast< vector < Foo * > * >(&vf));
}