Are there any interest in a pimpl library?

More precisely one cpp and one hpp file that implements the pimpl idiom? Regards, Asger Mangaard

Could you be more specific as to what functionality such a library would supply? If you already have an implementation then an example of it's use would be interesting. It is my understanding that the pimpl idiom is fairly simple yet also class specific. I currently implement it like this: In the .hpp class foo { .... private: class pimpl_t; pimpl_t* pimpl; }; in the .cpp #incldue "foo.hpp" class foo::pimpl_t { public: //private data }; I don't readily see how this could be abstracted, so an example would help me to see what you are proposing more clearly. _________________________________________________________________ MSN Messenger 7.5 is now out. Download it for FREE here. http://messenger.msn.co.uk

Could you be more specific as to what functionality such a library would supply? If you already have an implementation then an example of it's use would be interesting.
It is my understanding that the pimpl idiom is fairly simple yet also class specific. I currently implement it like this:
In the .hpp class foo { .... private: class pimpl_t; pimpl_t* pimpl; };
in the .cpp
#incldue "foo.hpp" class foo::pimpl_t { public: //private data };
I don't readily see how this could be abstracted, so an example would help me to see what you are proposing more clearly.
The implementation is simple indeed. However, I find myself using it all the time. The only thing my library does is to initialize the forward declared class, using heap or static memory through policies. Also, provides an easy way of accessing the data. Eg. .hpp boost::pimpl<struct CMyData> m_MyData; .cpp struct CMyData { CMyData() : m_Integer(0) { } int m_Integer; }; /// Data access m_MyData->m_Integer = 2341; The CMyData will be initialized the first time its data members are accessed. Regards, Asger Mangaard
participants (2)
-
Asger Mangaard
-
Joseph Gauterin