lilypond-1.4.3
[lilypond.git] / flower / include / pointer.tcc
blobcd4aac565efb9a81e544def397de4d7e00f7305a
1 /*
2   pointer.tcc -- implement P
4   source file of the Flower Library
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
10 #ifndef POINTER_TCC
11 #define POINTER_TCC
13 template<class T>
14 inline
15 T *
16 P<T>::copy_p () const
18   return t_p? new T (*t_p) : 0;
21 template<class T>
22 inline
23 void
24 P<T>::copy (T const *l_C)
26   t_p = l_C ? new T (*l_C) : 0;
29 template<class T>
30 inline
31 void
32 P<T>::junk ()
34   delete t_p;
35   t_p =0;
38 template<class T>
39 inline
40 P<T>::P (P<T> const &s) 
42   t_p = s.copy_p ();
45 template<class T>
46 inline
47 P<T> &
48 P<T>::operator = (P const&s)
50   junk ();
51   copy (s.t_p);
52   return *this;
55 template<class T>
56 inline
57 P<T>::~P () {
58   junk ();
61 template<class T>
62 inline
63 void
64 P<T>::set_p (T * np) 
66   if (np == t_p)
67     return;
68   delete t_p;
69   
70   t_p = np;
74 template<class T>
75 inline
76 void
77 P<T>::set_l (T const * l_C) 
79   if (t_p == l_C)
80     return;
81   
82   junk ();
83   copy (l_C);
88 #endif // POINTER_TCC