It would be nice if lzz.exe included support for the "pimpl" idiom, in some way. The idea is that the tedious part of implementing the idiom would be taken care of automatically somehow (I haven't thought about the details, to be honest). Maybe you would have to introduce a new keyword ("__hidden"?) that, when used on class member, would force their inclusion in an implementation class.
// Pimpl.lzz
class HasPimpl
{
public:
int f()
{
return _foo;
}
__hidden int _foo;
};
Lzz generates:
// Pimpl.h
class HasPimpl
{
public:
HasPimpl(); // Automatically generated to manage pimpl, otherwise would leverage ctor/dtor
~HasPimpl(); // Might not be necessary if we use smart pointer for pimpl
int f();
class Impl* _pimpl;
};
// Pimpl.cpp
#include "Pimpl.h"
struct HasPimpl::Impl
{
HasPimpl * self; // Not used in this scenario, might be necessary in others to access "non-__hidden" members of HasPiml
int _foo;
int f()
{
return _foo;
}
};
Hi Mike,
It would be nice if lzz.exe included support for the "pimpl" idiom, in some way. The idea is that the tedious part of implementing the idiom would be taken care of automatically somehow (I haven't thought about the details, to be honest). Maybe you would have to introduce a new keyword ("__hidden"?) that, when used on class member, would force their inclusion in an implementation class.
// Pimpl.lzz
class HasPimpl
{
public:
int f()
{
return _foo;
}
__hidden int _foo;
};
Lzz generates:
// Pimpl.h
class HasPimpl
{
public:
HasPimpl(); // Automatically generated to manage pimpl, otherwise would leverage ctor/dtor
~HasPimpl(); // Might not be necessary if we use smart pointer for pimpl
int f();
class Impl* _pimpl;
};
// Pimpl.cpp
#include "Pimpl.h"
struct HasPimpl::Impl
{
HasPimpl * self; // Not used in this scenario, might be necessary in others to access "non-__hidden" members of HasPiml
int _foo;
int f()
{
return _foo;
}
};
HasPimpl::HasPimpl()
{
_pimpl = new Impl;
pimpl->self = this;
}
HasPimpl::~HasPimpl()
{
delete _pimpl;
}
int HasPimpl::f()
{
return _pimpl->f();
}
Regards,
Manuel