Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-07-17 03:58:30


"Ed Brey" <brey_at_[hidden]> wrote in message
news:ah1udl$i4$1_at_main.gmane.org...
>
> "Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
news:ah1i2c$p2g$1_at_main.gmane.org...

[...]

> > 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.
>
> Certainly not in all circumstances. For example, if the constructor reads
configuration data from a file, it will be read twice. And of course, part
of the convenience of shared_ptr is that it often makes it practical for
classes to be noncopyable, which can save development time, depending on the
nature of the class.

Here is a draft version of what could remove copy constructors usages. It
would require proper initialization from the user in this example. Besides
the implicit reinterpret_cast<> in the constructor which shouldn't be there
IMO, any thoughts?

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(&QI8G)A<GD[('-E92!T:&4@
M9FEL92!#3U!924Y'+DQ)0BX@($EF(&YO="P@=W)I=&4@=&\*(" @=&AE($9R
M964_at_4V]F='=A<F4_at_1F]U;F1A=&EO;BP_at_26YC+BP_at_-3D@5&5M<&QE(%!L86-E
M("T_at_4W5I=&4@,S,P+ H@("!";W-T;VXL($U!(# R,3$Q+3$S,#<L(%5302X*
M*B\*"@HC:69N9&5F(%-154%$7U!44E]("B-D969I;F4_at_4U%5041?4%127T@*
M"@HC:6YC;'5D92 \;F5W/@H*"FYA;65S<&%C92!F9&D*>PH*=&5M<&QA=&4@
M/&-L87-S(%]4<#X*"7-T<G5C="!S<75A9%]P='(*"7L*"0ET>7!E9&5F(%]4
M<"!V86QU95]T>7!E.PH)"71Y<&5D968@:6YT(&-O=6YT97)?='EP93L*"@D)
M<W1R=6-T(&5L96UE;G1?='EP90H)"7L*"0D)9G)I96YD(&-L87-S('-Q=6%D
M7W!T<CL*"@D)"65L96UE;G1?='EP92_at_I(#H@;5]C;W5N="@Q*0H)"0E["@D)
M"7T*"@D)"7YE;&5M96YT7W1Y<&4H*0H)"0E["@D)"0ER96EN=&5R<')E=%]C
M87-T/'9A;'5E7W1Y<&4@)CXH;5]B=69F97(I+GYV86QU95]T>7!E*"D["@D)
M"7T*"@D)<')I=F%T93H*"0D)8VAA<B!M7V)U9F9E<EMS:7IE;V8H=F%L=65?
M='EP92E=.PH)"0EC;W5N=&5R7W1Y<&4@;5]C;W5N=#L*"0E].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(&DH<"YI
M*2P@:BAP+FHI+"!K*' N:RD*"7L*"0EC;W5T(#P\(%]?4%)%5%197T953D-4
M24].7U\@/#P_at_96YD;#L*"7T*"@E^02_at_I"@E["@D)8V]U=" \/"!?7U!21514
M65]&54Y#5$E/3E]?(#P\(&5N9&P["@E]"GT["@II;G0@;6%I;B_at_I"GL*"7-Q
M=6%D7W!T<CQ!/B!P(#T@;F5W("AS<75A9%]P='(\03XZ.F%L;&]C*"DI($$H
M,2P@,BP@,RD["@H)8V]U=" \/"!P+3YK(#P\(&5N9&P["@H)<F5T=7)N(# [
#"GT*
`
end


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