Hey i want to create a class with a Pimpl (Private implemenation) and normal you would so:
class A
{
private:
class B;
B* _pimpl = nullptr;
}
and the i would define it in the cpp file. But i have to use dynamic allocation. Would it be possible to use a rvalue reference:
class A
{
public:
A(); //Constructor to init rvalue reference
private:
class B;
B&& _pimpl;
}
And then in cpp file:
class A::B
{
public:
int C = 3u;
}
//and then the constructor of A:
A::A() : _pimpl(B()) { } //now we should have a fresh b pimpl?
Im currenty on holidays and i only have my c++ book and when i read about rvalue&&s i tought it might work? What do you guys think?
Aucun commentaire:
Enregistrer un commentaire