I have a boost::variant: B is an incomplete type so I have two possibilitys to declare my variant
typedef boost::variant<B*, char, int> vari; // this works
typedef boost::variant<B&, char, int> vari; // this works also
But now I have the following function in which I try to assign a value to my variant:
void setVari(vari& v, const int n){
swich(n) {
case 1 :
vari = 100;
break;
case 2 :
vari = 'a'
break;
case 3 : {
B elem;
vari = elem; // or "vari = *elem" if i use the pointer variant
break;
}
case default :
break;
}
}
This function only works if I use the first method to declare my variant.
If I use the reference content, the compiler complains about template argument deduction/substituiion failed
errors.
Is there a possibility to make this function work, when using reference instead of a pointer?