Josh Dybnis on 2 Jul 2003 14:44:01 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[ALACPP] smart pointers in C


I don't think that it is possible to do smart pointers in C. The reason
why, is that there is no way in C to associate a piece of code with a
value, in such a way that the code is automatically executed when the
value is stored into a variable, or conversly when the value is taken
out of a variable (either because the variable goes out of scope or
another value is stored in it). In C++ this can be done with 
constructors, a destrutor, a copy constructor, and an overloaded
assignment operator.

In many cases where you would want to use smart pointers in C, a
garbage collector will work just as well or better. See
http://www.hpl.hp.com/personal/Hans_Boehm/gc/

-Josh Dybnis
_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp