You don't have to you a pimpl idiom right from the book (forwarding
all method calls). Me and many other developers use intermediate
approach - pimp isn't really "private implementation", but "private
data". I mean that is hidden behind the pointer is only data, not
method. In this approach you don't have a cost and the work of
forwarding all method calls, but you have binary compatibility
(because class's size does not change when you add or remove data) and
clear interface, which clean of any implementation details. To make
the cleaning complete you have, of course, to move an internal private
methods to the "private data" (or pimlp) class as well.
And about C++ - you should understand that C++ is very generic
language, and it should not bound itself to specific ideoms and
techniques. What is good for one - bad for other. Thanks to the way
the C++ language is now - you can easily implement pimpl or everything
else you want.
On 4/28/05, Gottlob Frege
I so wish that pimpl was somehow part of the language. ie you don't worry about or see the pointer at all, nor do you have to forward all the function calls. I don't see why the compiler couldn't implement pimpl for me. (Of course, for cases where you want multiple implementations at run time, etc, you still do that yourself, but the typical case the compiler could do).
Maybe:
// h file class Foo interface { void GetX(); };
// cpp file: class Foo continue // some keyword { int x; };
Foo::GetX() { return x; }
And just like implementing the same function twice, the linker could warn about 2 implementations of the same class.
P.S. this could also allow you to keep some members defined in the h file, (and others in the cpp impl) if you wanted the speed of inlines for some variables, or public/protected variables, etc.
Just a thought. Maybe I should complain elsewhere...
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Best regards, Zigmar