
I've uploaded an updated version ...
Pavel Vozenilek wrote ... I do have a few. /Pavel
________________________________________________ 1. You should not use double underscores (and neither leading single underscore). These are reserved for standard.
It's corrected.
________________________________________________ 2. It is better when member functions are all lowercase (like elsewhere in Boost).
It's corrected.
________________________________________________ 3. pimpl.hpp:
The base::_Get() should have BOOST_ASSERT() before dereferencing.
Possibly this function could be omitted altogether since it is always overriden.
It's corrected.
-----------
_Destructor should be named destroy() to evoke action.
Better yet, move it into real destructor.
It's corrected.
-----------
late_creation policy may nam named "manual_creation" or so.
The Set() should destroy previous instance if non-NULL.
The _Get() should contain BOOST_ASSERT() or throw if NULL.
It's corrected.
---------------
Closing bracket for namespace should nopt have ";" but should have comment like // namespace pimpl_policies
It's corrected.
----------------
operator=() does shallow copy of dynamically allocated value. Is this really what ypu want?
It's corrected.
________________________________________________ 4. Compiling with Intel C++ 7.0 for Windows I get error:
testsuite.cpp C:\work\reviews\pimpl\testsuite.cpp(54): error: no suitable user-defined conversion from "boost::pimpl<CMyValues1,
boost::pimpl_policies::base>" to "const boost::pimpl<CMyValues2, boost::pimpl_policies::late_creation>" exists test.m_ValuesWithLazyCreator2 = test.m_ValuesWithDefaultConstructor;
I've now tested with Intel C++ 9.0 windows and it works fine. How can I get a copy of this old version?
________________________________________________ 5. The pimpl doesn't show how I work with member functions. This is the most important part of the idiom and If there's way to make the tedious work any simpler I am all for it.
You just work with the pimpl's -> operator. That will give you access to the pimpl's member functions. The new 'testsuite.cpp' shows its use. And thanks for your corrections, I highly appreciate them. Regards, Asger Mangaard