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