Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-09-13 10:38:42


David Abrahams wrote:
> "Sohail Somani" <s.somani_at_[hidden]> writes:
>
>>> -----Original Message-----
>>> From: boost-users-bounces_at_[hidden]
>>> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of
>>> Roman Neuhauser
>>> if (!initialized_) {
>>> throw new exception("This object is broken.");
>>> }
>>>
>>> That's somewhat like OOP in C, and FMPOV a huge step back.
>>
>> Actually, even in strict C, good programmers tend to do something
>> like:
>>
>> T * make_T(T1 p1, T2 p2);
>> T1 do_op1(T*this__,...)

void destroy_T( T * this_ );

>> And make T opaque, i.e. C++ in C.
>
> Yes. Most of the principles of good C++ design translate back to C
> very well. They just take a lot more work.

The above implementation hiding technique actually didn't translate forward
to C++ particularly well (resulting in far less work). In the pre-shared_ptr
era, I mean. :-)

class T; // opaque
shared_ptr<T> make_T( T1 p1, T2 p2 );
T1 do_op1( shared_ptr<T> this_, ... );
// no destroy_T needed


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net