2 pointer.hh -- declare P
4 source file of the Flower Library
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
15 /** P<T> is a handy template to use iso T*. It inits to 0, deletes on
16 destruction, deep copies upon copying
18 It is probably not feasible to use P<T> as template argument, since
19 a lot of auto conversion wouldn't work. new T would be called too
22 Sorry for the silly naming */
26 Set contents to a copy of #t_l#
28 void copy (T const*t_l);
32 junk contents and set to 0
39 Remove the pointer, and return it.
42 T *get_p () { T*p = t_p; t_p=0; return p; }
46 T *get_l () { return t_p; }
48 T const *get_C () const { return t_p; }
50 copy the contents of pointer, and return it
54 swallow new_p, and set contents t new_p
56 void set_p (T *new_p);
58 junk contents, and copy contents of t_l
60 void set_l (T const *t_C);
62 P &operator = (P const &);
65 //P (T *p) { t_p = p; }
67 T *operator -> () { return t_p; }
68 operator T * () { return t_p; }
69 const T *operator -> () const { return t_p ; }
70 T &operator * () { return *t_p; }
71 T const &operator * () const { return *t_p; }
72 operator const T * () const { return t_p; }