summaryrefslogtreecommitdiff
path: root/flower/pcursor.hh
blob: 6cc3433e25a2d191eedcc3f38af54ff0607d1a58 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
  pcursor.hh -- part of flowerlib

  (c) 1996 Han-Wen Nienhuys&Jan Nieuwenhuizen
*/

#ifndef PCURSOR_HH
#define PCURSOR_HH


/// cursor to go with PointerList
template<class T>
struct PCursor : public Cursor<void *> {

    /// make cursor with #no# items back
    PCursor<T> operator -( int no) const {
	return PCursor<T> (Cursor<void*>::operator-(no));
    }

    /// make cursor with #no# items further
    PCursor<T> operator +( int no) const {
	return PCursor<T> (Cursor<void*>::operator+(no));
    }
    PCursor(const PointerList<T> & l) : Cursor<void*> (l) {}

    PCursor( const Cursor<void*>& cursor ) : Cursor<void*>(cursor) { }
    void* vptr() const { return  * ((Cursor<void*> &) *this); }

    // should return T& ?
    T ptr() const { return (T) vptr(); }
    T operator ->() const { return  ptr(); }
    operator T() { return ptr(); }
    T operator *() { return ptr(); }

private:
//    Cursor<void*>::operator void*;
    // sigh
};
/**
don't create PointerList<void*>'s
 */


template<class T>
inline  int pcursor_compare(PCursor<T> a,PCursor<T>b)
{
    return cursor_compare(Cursor<void*>(b),Cursor<void*> (a));
}

#include "compare.hh"
template_instantiate_compare(PCursor<T>, pcursor_compare, template<class T>);

#endif