Perform a find into a boost::variant vector
I have this situation:
1 2 3
|
typedef variant<myObj<int>, myObj<float>, myObj<double>, myObj<string> > var_t;
vector<var_t> vec;
vector<var_t>::iterator it;
|
With a proper method I fill this heterogeneous vector without problems.
The problem is that I want to obtain the position of an object in some way.
I tried
1 2 3 4 5 6 7 8
|
f(var_t x)
{
for (it = cmdLineVec.begin(), i=0; it != cmdLineVec.end(); it++, i++)
{
if( (*it) == x )
cout << "Position " << i <<" !" << endl;
}
}
|
and
f(var_t x){ it = find(vec.begin(), vec.end(), x) }
without success.
Have you got any idea?
Excuse me but I'm asking for an implementation, not for a editor to adopt...
One way to do it is to count the number of times operator() is called on your static visitor object.
Topic archived. No new replies allowed.