Boost logo

Boost :

Subject: Re: [boost] [smart_ptr] shared_ptr template type
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-07-15 08:44:22


Gottlob Frege wrote:
>
> My standard answer has now become:
> 1. use a traits/policy class
> 2. have the default traits/policy call a free functinon
>
> eg:
>
> // default free function
> // or yours will found by ADL if you supply your own
> //
> template<class T> bool is_null_pointer(T p)
> {
> return (p == 0);
> };
>
> // default policy class, calls whatever it finds by ADL
> // feel free to supply your own policy class instead
> //
> template<class T> struct default_smart_pointer_traits
> : public smart_pointer_traits<T>
> {
> static bool is_null(pointer p)
> {
> return is_null_pointer(p);
> }
> };

That's a very nice approach. You seem to lump traits and policy classes together, but they are clearly not equivalent. I think a policy class is superior to a traits class, so your numbered bullets should not contain "traits/".

What about function templates? The above seems to apply to class templates only. Overloading permits one function template to rely on a default functor type while another can take a functor as an argument. (The former can call the latter, of course.) The functor argument can be defaulted, provided the default functor is stateless.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk