Given a class that you want to have recursive field in my case:
class SemiVariant {
union {
std::pair<SemiVariant, SemiVariant> pair_value_;
int something_else_;
}
};
Basically this can't be because obviously we have an incomplete type. Using unique_ptr to admin the memory and allow the incomplete type also didn't work. I don't know if there already an existing class that will serve as optional but that can use dynamic memory. unique_ptr are not perfect for my case because they disable the default copy constructor. Which I want to exist.
Aucun commentaire:
Enregistrer un commentaire