Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-07-16 11:43:15


"David B. Held" <dheld_at_[hidden]> wrote in message
news:ah0cl8$tqu$1_at_main.gmane.org...
> "Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
> news:ah005q$b1s$1_at_main.gmane.org...
> > [...]
> > mutable_ptr<>:
>
> Is the LGPL compatible with Boost licensing requirements? I'm not sure.
> Some people say leading underscore names are not recommended,
> because they tend to be close to reserved names.

I'll verify the licensing stuff eventually.

> I'm no expert on smart
> pointers, but it seems that std::auto_ptr could easily have taken this
> route. My question is: why did it not?

Because the mutable modifier shouldn't be used for regular members. It is
reserved for cached, temporary buffers, etc. This is why 'mutable' is part
of the class name: it is not used for cache but for speed optimization.

> > [...]
> > shared_ptr<>:
> > - functionality is similar to boost::shared_ptr<> except:
>
> Actually, it's not remotely like boost::shared_ptr<>. It doesn't support
> custom deleters or void pointers. It doesn't work with weak or intrusive
> pointers. And it doesn't provide operator! or a bool test operator. It
> also doesn't interoperate with std::auto_ptr or boost::scoped_ptr.

I'll adapt it to the Boost library eventually but it was following STL
standards up to now.

> > - reference counters are merged with instanciated objects:
> > - operator new () is called once in the end (like
> > boost::shared_ptr<>);
>
> Except that you call a copy c'tor, which prevents you from using the
> class with non_copyable objects, and imposes a penalty on expensive-
> copy types. And the construction syntax is awkward.

(Too bad the new initializer lists extension is deprecated under gcc).

Important classes like pair<>, list<>, vector<> from STL already use copy
constructor to initialize their members. It is also negligable in time
because the operator new() is already expensive. And I'm curious to know if
the compiler is not creating the object directly instead of creating a
temporary, copying it and destroying it when optimizations are requested.

The speed may be slower when instanciating the object but it is instanciated
only once while boost::shared_ptr<> is slower on other tasks (which are
asked more frequently).

[...]

> > - faster than boost::shared_ptr<>.
>
> But only because it has a small subset of boost::shared_ptr's
functionality
> and flexibility.

Yes but I'm pointing out main advantages only. Other features could
eventually be integrated.

> > I hope someone will share the same vision of efficienty benefits I have.
>
> I think there are certainly cases where efficiency is important. However,
> most people agree that the proliferation of smart pointer types is a
> problem.

We have to keep an objective point of vue.

> Getting people to toss another one in their toolbox might be a challenge.
;)
> Also, you have a name clash. I don't think the current boost::shared_ptr
> is going to get deprecated in favor of your design. ;)

Corrected. fdi::shared_ptr<> is now fdi::squad_ptr<>.

Philippe A. Bouchard

begin 666 squad_ptr.h
M+RH*(" @5&AI<R!F:6QE(&ES('!A<G0@;V8@=&AE($9$22!L:6)R87)I97,*
M(" @0V]P>7)I9VAT("AC*2 R,# R(%!H:6QI<'!E($$N($)O=6-H87)D(#QP
M:&EL:7!P94!F;W)N=7_at_N8V]M/@H*(" @5&AI<R!L:6)R87)Y(&ES(&9R964@
M<V]F='=A<F4[('EO=2!C86X@<F5D:7-T<FEB=71E(&ET(&%N9"]O<@H@("!M
M;V1I9GD@:70@=6YD97(@=&AE('1E<FUS(&]F('1H92!'3E4_at_3&EB<F%R>2!'
M96YE<F%L(%!U8FQI8PH@("!,:6-E;G-E('9E<G-I;VX@,B!A<R!P=6)L:7-H
M960_at_8GD@=&AE($9R964_at_4V]F='=A<F4_at_1F]U;F1A=&EO;BX*"B @(%1H:7,@
M;&EB<F%R>2!I<R!D:7-T<FEB=71E9"!I;B!T:&4@:&]P92!T:&%T(&ET('=I
M;&P_at_8F4@=7-E9G5L+ H@("!B=70_at_5TE42$]55"!!3ED_at_5T%24D%.5%D[('=I
M=&AO=70_at_979E;B!T:&4@:6UP;&EE9"!W87)R86YT>2!O9_at_H@("!-15)#2$%.
M5$%"24Q)5%D@;W(@1DE43D534R!&3U(@02!005)424-53$%2(%!54E!/4T4N
M("!3964@=&AE($=.50H@("!,:6)R87)Y($=E;F5R86P_at_4'5B;&EC($QI8V5N
M<V4_at_9F]R(&UO<F4_at_9&5T86EL<RX*"B @(%EO=2!S:&]U;&0@:&%V92!R96-E
M:79E9"!A(&-O<'D@;V8@=&AE($=.52!,:6)R87)Y($=E;F5R86P_at_4'5B;&EC
M($QI8V5N<V4*(" @86QO;F<@=VET:"!T:&ES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*#$P*2D[#0H)"7-Q=6%D7W!T<CQI
M;G0^('-P-"AS<#,I.PT*#0H)"6-O=70@/#P@(BH@<W S(#T@(B \/" J('-P
M,R \/"!E;F1L.PT*"0EC;W5T(#P\("(J('-P-" ]("(@/#P@*B!S<#0@/#P@
M96YD;#L-"@E]#0H-"@EC;W5T(#P\(&5N9&P@/#P@(C,Z(B \/"!E;F1L.PT*
M"7L-"@D);&ES=#P@;75T86)L95]P='(\03X@/B!L,3L-"@D);#$N<'5S:%]B
M86-K*&YE=R!!*#$P*2D[#0H)"6PQ+G!U<VA?8F%C:RAN97<@02_at_Q,2DI.PT*
M"0EL,2YP=7-H7V)A8VLH;F5W($$H,3(I*3L-"@T*"0EL:7-T/"!M=71A8FQE
M7W!T<CQ!/B ^(&PR*&PQ*3L-"@D)8V]U=" \/" B;#$N8F%C:R_at_I(#T@(B \
M/"!L,2YB86-K*"DN9V5T*"D@/#P_at_96YD;#L-"@D)8V]U=" \/" B;#(N8F%C
L:R_at_I+3YI(#T@(B \/"!L,BYB86-K*"DM/FD@/#P_at_96YD;#L-"@E]#0I]#0H`
`
end


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