Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-07-25 16:46:32


Hi again,

    I would like to see one that could find a solid counter-example on this
suggestion. It consists of different way an object can be instanciated by
overloading operator new (size_t, T const &) with different allocator
techniques. The one that I'm trying to pinpoint is referenced count targets
for now but can easily be extended to garbage collection also. The costs /
benefits ratio is reasonnable in this situation because efficienty is at its
highest level and the syntax is really really simple. The only drawback is
that the compiler doesn't know if the object was properly instanced and will
result in a segmentation fault when altering the reference count... but the
pointer contructor need to be explicit in order to assert you know what you
are doing, and dynamic_cast<>() is cheating with compiler subroutines to do
the same thing with virtual table assertion anyways. The extensibility is
profitable also.

    I am not familiar with debuggers (I usually use couts) but is it
possible to easily debug the program with the static member pointer defined
in prebuild<> using expressions evaluations? I am not familiar with your
policies either... can someone help me getting started? Thank you.

Philippe A. Bouchard

begin 666 squad_ptr.h
M+RH-"B @(%1H:7,@9FEL92!I<R!P87)T(&]F('1H92!&1$D@;&EB<F%R:65S
M#0H@("!#;W!Y<FEG:'0@*&,I(#(P,#(@4&AI;&EP<&4_at_02X@0F]U8VAA<F0@
M/'!H:6QI<'!E0&9O<FYU>"YC;VT^#0H-"B @(%1H:7,@;&EB<F%R>2!I<R!F
M<F5E('-O9G1W87)E.R!Y;W4_at_8V%N(')E9&ES=')I8G5T92!I="!A;F0O;W(-
M"B @(&UO9&EF>2!I="!U;F1E<B!T:&4@=&5R;7,@;V8@=&AE($=.52!,:6)R
M87)Y($=E;F5R86P_at_4'5B;&EC#0H@("!,:6-E;G-E('9E<G-I;VX@,B!A<R!P
M=6)L:7-H960_at_8GD@=&AE($9R964_at_4V]F='=A<F4_at_1F]U;F1A=&EO;BX-"@T*
M(" @5&AI<R!L:6)R87)Y(&ES(&1I<W1R:6)U=&5D(&EN('1H92!H;W!E('1H
M870@:70@=VEL;"!B92!U<V5F=6PL#0H@("!B=70_at_5TE42$]55"!!3ED_at_5T%2
M4D%.5%D[('=I=&AO=70_at_979E;B!T:&4@:6UP;&EE9"!W87)R86YT>2!O9_at_T*
M(" @34520TA!3E1!0DE,2519(&]R($9)5$Y%4U,@1D]2($$@4$%25$E#54Q!
M4B!055)03U-%+B @4V5E('1H92!'3E4-"B @($QI8G)A<GD_at_1V5N97)A;"!0
M=6)L:6,@3&EC96YS92!F;W(@;6]R92!D971A:6QS+@T*#0H@("!9;W4@<VAO
M=6QD(&AA=F4@<F5C96EV960_at_82!C;W!Y(&]F('1H92!'3E4_at_3&EB<F%R>2!'
M96YE<F%L(%!U8FQI8R!,:6-E;G-E#0H@("!A;&]N9R!W:71H('1H:7,@;&EB
M<F%R>3L@<V5E('1H92!F:6QE($-/4%E)3D<N3$E"+B @268@;F]T+"!W<FET
M92!T;PT*(" @=&AE($9R964_at_4V]F='=A<F4_at_1F]U;F1A=&EO;BP_at_26YC+BP@
M-3D_at_5&5M<&QE(%!L86-E("T_at_4W5I=&4@,S,P+ T*(" @0F]S=&]N+"!-02 P
M,C$Q,2TQ,S W+"!54T$N#0HJ+PT*#0H-"B-I9FYD968_at_4U%5041?4%127T_at_-
M"B-D969I;F4_at_4U%5041?4%127T_at_-"@T*#0HC:6YC;'5D92 B<')E8G5I;&0N
M:"(-"@T*#0IN86UE<W!A8V4_at_9F1I#0I[#0H-"@T*<W1R=6-T(&UT.PT*<W1R
M=6-T(&=C.PT*<W1R=6-T(')E9CL-"@T*#0IT96UP;&%T92 \='EP96YA;64@
M7U0^#0H)<W1R=6-T('-Q=6%D7W!T<CL-"@T*#0HO*BH-"@E/8FIE8W0@<&]I
M;G1E9"!T;R!B>2!S<75A9%]P='(\/BX-"@T*"4AA<R!T;R!B92!I;G-T86YC
M:6%T960@=7-I;F<@=6YC;VUM;VX_at_97AP<F5S<VEO;G,N("!3964_at_8F5L;W<N
M#0HJ+PT*#0IT96UP;&%T92 \='EP96YA;64_at_7U0^#0H)8VQA<W,@<W%U861?
M=&%R9V5T#0H)>PT*"0ET>7!E9&5F(%]4('9A;'5E7W1Y<&4[#0H-"@D)9G)I
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F5C="D[#0I]#0H-"@T*?0T*#0H-"B-E;F1I9_at_T*
`
end

begin 666 testptr1.cpp
M(VEN8VQU9&4@/&EO<W1R96%M/@T*(VEN8VQU9&4@(G-Q=6%D7W!T<BYH(@T*
M#0IU<VEN9R!N86UE<W!A8V4@<W1D.PT*=7-I;F<@;F%M97-P86-E(&9D:3L-
M"@T*<W1R=6-T('!A<F5N= T*>PT*"6-H87(@*B!F.PT*#0H)<&%R96YT*"D-
M"@E[#0H)"6-O=70@/#P_at_7U]04D545%E?1E5.0U1)3TY?7R \/"!E;F1L.PT*
M"7T-"@T*"79I<G1U86P@?G!A<F5N="@I#0H)>PT*"0EC;W5T(#P\(%]?4%)%
M5%197T953D-424].7U\@/#P_at_96YD;#L-"@E]#0I].PT*#0IS=')U8W0_at_8VAI
M;&0_at_.B!P87)E;G0-"GL-"@EC:&EL9"AC:&%R("H_at_85]P+" N+BXI#0H)>PT*
M"0EF(#T_at_85]P.PT*"0EC;W5T(#P\(%]?4%)%5%197T953D-424].7U\@/#P@
M96YD;#L-"@E]#0H-"@EV:7)T=6%L('YC:&EL9"@I#0H)>PT*"0EC;W5T(#P\
M(%]?4%)%5%197T953D-424].7U\@/#P_at_96YD;#L-"@E]#0I].PT*#0II;G0@
M;6%I;B_at_I#0I[#0H)<W%U861?<'1R/'!A<F5N=#X@<"AN97<@*')E9BD_at_8VAI
M;&0H(DIO:&XB+" B36-);FYI<R(I*3L-"@T*"6-O=70@/#P@<"T^9B \/"!E
7;F1L.PT*#0H)<F5T=7)N(# [#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