Boost logo

Boost :

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


"Ed Brey" <brey_at_[hidden]> wrote in message
news:ah3q5c$or7$1_at_main.gmane.org...
> "Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
news:ah3b6t$nah$1_at_main.gmane.org...

[...]

> > 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?
>
> Looking at the code, I don't follow how it is supposed to work. For
example, consider the code:
>
> squad_ptr<char> p(new char);
>
> In this case, squad_ptr puts its use count in memory immediately following
what was allocated for the character. This amounts to a buffer overrun,
blowing past the block that the heap manager gave your program.

This was a too much optimized example and turned corrupted, but element_type
could also be constructed then retouched with new (element_type().m_buffer)
value_type(...) in 2 statements instead of one.

Here is another clean example using struct initiliazers which uses 1
statement and is more solid at construction time.

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)?='EP92!M7V-O=6YT
M.PH)"7T["@H)"7-Q=6%D7W!T<BAE;&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(#(L(#,I+"!S
M<75A9%]P='(\03XZ.F5L96UE;G1?='EP93HZ8V]U;G1E<E]T>7!E*"E]*3L*
F"@EC;W5T(#P\(' M/FL@/#P_at_96YD;#L*"@ER971U<FX@,#L*?0H`
`
end


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