ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtvec.h
(Generate patch)

Comparing rxvt-unicode/src/rxvtvec.h (file contents):
Revision 1.1 by pcg, Mon Nov 24 17:28:08 2003 UTC vs.
Revision 1.4 by pcg, Thu Nov 27 10:12:10 2003 UTC

4template<typename T> static inline T min (T a, long b) { return a < b ? a : b; } 4template<typename T> static inline T min (T a, long b) { return a < b ? a : b; }
5template<typename T> static inline T max (T a, long b) { return a > b ? a : b; } 5template<typename T> static inline T max (T a, long b) { return a > b ? a : b; }
6 6
7#include <cstring> 7#include <cstring>
8#include "simplevec.h" 8#include "simplevec.h"
9
10#include <cstdio>
9 11
10#if 0 12#if 0
11template<typename T> 13template<typename T>
12struct rxvt_vec : simplevec<void *> { 14struct rxvt_vec : simplevec<void *> {
13 typedef T *iterator; 15 typedef T *iterator;
30 ++first; 32 ++first;
31 33
32 return first; 34 return first;
33} 35}
34 36
37template<typename T>
38struct auto_ptr {
39 T *p;
40
41 auto_ptr() : p(0) { }
42 auto_ptr(T *a) : p(a) { }
43
44 auto_ptr(auto_ptr<T> &a)
45 {
46 p = a.p;
47 a.p = 0;
48 }
49
50 template<typename A>
51 auto_ptr(auto_ptr<A> &a)
52 {
53 p = a.p;
54 a.p = 0;
55 }
56
57 ~auto_ptr()
58 {
59 delete p;
60 }
61
62 // void because it makes sense in our context
63 void operator =(T *a)
64 {
65 delete p;
66 p = a;
67 }
68
69 void operator =(auto_ptr &a)
70 {
71 *this = a.p;
72 a.p = 0;
73 }
74
75 template<typename A>
76 void operator =(auto_ptr<A> &a)
77 {
78 *this = a.p;
79 a.p = 0;
80 }
81
82 operator T *() const { return p; }
83
84 T *operator ->() const { return p; }
85 T &operator *() const { return *p; }
86
87 T *get ()
88 {
89 T *r = p;
90 p = 0;
91 return r;
92 }
93};
94
95typedef auto_ptr<char> auto_str;
96
97struct stringvec : simplevec<char *>
98{
99 ~stringvec ()
100 {
101 for (char **c = begin(); c != end(); c++)
102 delete [] *c;
103 }
104};
105
35#endif 106#endif
107

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines