pimpl

Pimpl idiom: What size_type to use if implementation is unknown?

I have a class that holds an array of elements, and I want to give it a GetSize member function. But what return type should I give that function? I'm using the pimpl idiom, and so in the header file it is not known what the implementation will use to store the elements. So I cannot just say std::vector<T>::size_type, for example: cla...

How to return a generic iterator (independent of particular container)?

I'd like to design a class Foo that stores various data of different types and returns iterators over them. It's supposed to be generic, so the user of Foo does not know how the data is stored (Foo could be using std::set or std::vector or whatever). I'm tempted to write an interface like this: class Foo { class FooImpl; FooImpl* i...

Pimpl idiom used with a class member variable

Whats the correct way of implementing this class? //Header #include <boost/shared_ptr.hh> class MyClass { public: static foo() static foobar(); private: class pimpl; static boost::shared_ptr<pimpl> m_handle; static bool initialized; }; //source namespace { bool init() { //... // init() can't access...