I've made a vector with a boost::variant of multiple types like this:
std::vector<boost::variant<type1,type2,type3,...and so on>>
And after that, I've made a typedef to rename this whole type as vecTypesVar and the variant named typesVar
typedef boost::variant<type1,type2,type3,...and so on> typesVar
typedef std::vector<typesVar> vecTypesVar
Now I've made a for-loop on that vector to and using the options .which
I'm trying to make an implementation for each type like this.
vecTypesVar type = getTypesData();
for (auto i = 0; i < type.size(); ++i)
{
switch (type[i].which())
{
case 0:
break;
case 1:
break;
case 2:
break;
default: ;
}
}
So, here it's started the problem, on each case of the switch I'm trying to make a variable the same type as the one that came.
For example:
case 0:
auto data = boost::get<type1>(type[i]);
but I'm getting an error which said:
error C2248: 'type1::type1' : cannot access private member declared in class 'type1'
I've also tried to use visitors like this: template
class port_visitator : public boost::static_visitor<T>
{
T operator()(typesVar type) const
{
return boost::get<T>(type);
}
};
and used that in my switch:
case 0:
auto data = apply_visitor(port_visitator<type1>(), type[i]);
But I'm receiving the same error:
error C2248: 'type1::type1' : cannot access private member declared in class 'type1'
Is anyone of you how knows how can I fix this issue?
Thanks in advance :D
Aucun commentaire:
Enregistrer un commentaire