Boost logo

Boost Users :

From: Marshall Clow (marshall_at_[hidden])
Date: 2008-05-16 16:56:52


At 2:37 PM -0500 5/16/08, Nevin \":-]\" Liber wrote:
>2008/5/16 Kevin Martin <kev82_at_[hidden]>:
>> My problem is module interfaces. I have a module (set of classes) that
>> solve a problem, and they require data. They don't care whether that
>> data is on the heap, the stack, or the moon. They just want a pointer
>> to it. In this case it is arguable that the pointers passed shouldn't
>> be smart pointers at all, just normal pointers.
>
>My general rule of thumb is that if mucking with ownership or
>lifetime, pass a smart pointer. If not, pass a raw pointer.

A brief addenda (from my rules of thumb) for non-ownership cases:
        * If the parameter is optional, pass a raw pointer, and the
callee should
expect a NULL pointer.
        * If the parameter is not optional, pass a reference.

-- 
-- Marshall
Marshall Clow     Idio Software   <mailto:marshall_at_[hidden]>
It is by caffeine alone I set my mind in motion.
It is by the beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.

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