]> git.donarmstrong.com Git - lilypond.git/blob - flower/pcursor.hh
release: 0.0.8
[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     int operator -(PCursor<T> op) const {
21         return Cursor<void*>::operator-(op);
22     }
23     /// make cursor with #no# items further
24     PCursor<T> operator +( int no) const {
25         return PCursor<T> (Cursor<void*>::operator+(no));
26     }
27     PCursor(const PointerList<T> & l) : Cursor<void*> (l) {}
28
29     PCursor( const Cursor<void*>& cursor ) : Cursor<void*>(cursor) { }
30     void* vptr() const { return  * ((Cursor<void*> &) *this); }
31
32     // should return T& ?
33     T ptr() const { return (T) vptr(); }
34     T operator ->() const { return  ptr(); }
35     operator T() { return ptr(); }
36     T operator *() { return ptr(); }
37
38 private:
39 //    Cursor<void*>::operator void*;
40     // sigh
41 };
42 /**
43 don't create PointerList<void*>'s
44  */
45
46
47 template<class T>
48 inline  int pcursor_compare(PCursor<T> a,PCursor<T>b)
49 {
50     return cursor_compare(Cursor<void*>(a),Cursor<void*> (b));
51 }
52
53 #include "compare.hh"
54 template_instantiate_compare(PCursor<T>, pcursor_compare, template<class T>);
55
56 #endif