]> git.donarmstrong.com Git - lilypond.git/blob - flower/pcursor.hh
6cc3433e25a2d191eedcc3f38af54ff0607d1a58
[lilypond.git] / flower / pcursor.hh
1
2 /*
3   pcursor.hh -- part of flowerlib
4
5   (c) 1996 Han-Wen Nienhuys&Jan Nieuwenhuizen
6 */
7
8 #ifndef PCURSOR_HH
9 #define PCURSOR_HH
10
11
12 /// cursor to go with PointerList
13 template<class T>
14 struct PCursor : public Cursor<void *> {
15
16     /// make cursor with #no# items back
17     PCursor<T> operator -( int no) const {
18         return PCursor<T> (Cursor<void*>::operator-(no));
19     }
20
21     /// make cursor with #no# items further
22     PCursor<T> operator +( int no) const {
23         return PCursor<T> (Cursor<void*>::operator+(no));
24     }
25     PCursor(const PointerList<T> & l) : Cursor<void*> (l) {}
26
27     PCursor( const Cursor<void*>& cursor ) : Cursor<void*>(cursor) { }
28     void* vptr() const { return  * ((Cursor<void*> &) *this); }
29
30     // should return T& ?
31     T ptr() const { return (T) vptr(); }
32     T operator ->() const { return  ptr(); }
33     operator T() { return ptr(); }
34     T operator *() { return ptr(); }
35
36 private:
37 //    Cursor<void*>::operator void*;
38     // sigh
39 };
40 /**
41 don't create PointerList<void*>'s
42  */
43
44
45 template<class T>
46 inline  int pcursor_compare(PCursor<T> a,PCursor<T>b)
47 {
48     return cursor_compare(Cursor<void*>(b),Cursor<void*> (a));
49 }
50
51 #include "compare.hh"
52 template_instantiate_compare(PCursor<T>, pcursor_compare, template<class T>);
53
54 #endif