Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-07-17 13:35:14


"David B. Held" <dheld_at_[hidden]> wrote in message
news:ah4c01$gcr$1_at_main.gmane.org...
> "Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
> news:ah48ka$62f$1_at_main.gmane.org...
> > [...]
> > Here is another clean example using struct initiliazers which uses 1
> > statement and is more solid at construction time.
>
> I don't see how you have avoided a copy during construction. You are
> calling the generated copy c'tor in the new statement. The only way
> you can avoid a copy and provide a count wrapper like you have done
> is to overload placement new for all possible combinations of arguments
> (which isn't terribly difficult with some template and preprocessor magic,
> probably...but fairly tedious to write). I've thought about this approach
> before, and I'm sure hundreds have thought about it before me. This
> approach is fraught with difficulties for which there appears no easy
> solution.

Well whether the gcc 3.0 is wrong or the syntax allows initialization of
dynamic objects; I haven't checked yet. One thing I know is that ./a.out
outputs:

A::A(int, int, int)
3
A::~A()

The copy constructor is not called.

I've modified get() and operator -> () that now supports null pointers.
'counter_type' is also easier to access.

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*"0ES=')U8W0_at_96QE;65N=%]T>7!E"@D)>PH)"0ES
M=')U8W0_at_8V]U;G1E<E]T>7!E"@D)"7L*"0D)"69R:65N9"!C;&%S<R!S<75A
M9%]P='(["@H)"0D)8V]U;G1E<E]T>7!E*"D_at_.B!M7W9A;'5E*#$I"@D)"0E[
M"@D)"0E]"@H)"0EP<FEV871E._at_H)"0D):6YT(&U?=F%L=64["@D)"7T["@H)
M"0EV86QU95]T>7!E(&U?=F%L=64["@D)"6-O=6YT97)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;W(@+3X@*"D_at_8V]N<W0*"0E["@D)"7)E='5R
M;B!R96EN=&5R<')E=%]C87-T/'9A;'5E7W1Y<&4@*CXH;5]P='(I.PH)"7T*
M"@D)=F%L=65?='EP92 J(&=E="@I(&-O;G-T"@D)>PH)"0ER971U<FX@<F5I
M;G1E<G!R971?8V%S=#QV86QU95]T>7!E("H^*&U?<'1R*3L*"0E]"@H)"65L
M96UE;G1?='EP92 J('-H87)E*"D_at_8V]N<W0*"0E["@D)"6EF("AM7W!T<BD*
M"0D)>PH)"0D)*RL@;5]P='(M/FU?8V]U;G0N;5]V86QU93L*"0D)?0H)"0ER
M971U<FX@;5]P='(["@D)?0H*"0EV;VED(')E<V5T*&5L96UE;G1?='EP92 J
M(&%?<" ](# I"@D)>PH)"0EI9B H;5]P='(@)B8@(2 M+2!M7W!T<BT^;5]C
M;W5N="YM7W9A;'5E*0H)"0E["@D)"0ED96QE=&4@;5]P='(["@D)"7T*"0D)
M;5]P='(@/2!A7W ["@D)?0H*"7!R:79A=&4Z"@D)96QE;65N=%]T>7!E("H@
7;5]P='(["@E].PH*?0H*"B-E;F1I9_at_H`
`
end

begin 666 ice.cpp
M(VEN8VQU9&4@/&EO<W1R96%M/@HC:6YC;'5D92 B<W%U861?<'1R+F_at_B"@IU
M<VEN9R!N86UE<W!A8V4@<W1D.PIU<VEN9R!N86UE<W!A8V4_at_[hidden]*<W1R
M=6-T($$*>PH):6YT(&DL(&HL(&L["@H)02AI;G0_at_82P@:6YT(&(L(&EN="!C
M*2 Z(&DH82DL(&HH8BDL(&LH8RD*"7L*"0EC;W5T(#P\(%]?4%)%5%197T95
M3D-424].7U\@/#P_at_96YD;#L*"7T*"@E!*$$@8V]N<W0@)B!P*2 Z(&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["@H*:6YT(&UA:6XH*0I["@ES
M<75A9%]P='(\03X@<" ](&YE=R!S<75A9%]P='(\03XZ.F5L96UE;G1?='EP
M92_at_H<W%U861?<'1R/$$^.CIE;&5M96YT7W1Y<&4I('M!*#$L(#(L(#,I+"!S
M<75A9%]P='(\03XZ.F-O=6YT97)?='EP92_at_I?2D["@H)8V]U=" \/"!P+3YK
8(#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