--- rxvt-unicode/src/rxvtutil.h 2012/05/24 15:03:47 1.53 +++ rxvt-unicode/src/rxvtutil.h 2014/11/10 12:14:48 1.61 @@ -1,11 +1,14 @@ #ifndef RXVT_UTIL_H #define RXVT_UTIL_H +#include #include #include #include "ecb.h" #include "estl.h" +#include "emman.h" + // increases code size unless -fno-enforce-eh-specs #if __GNUC__ # define NOTHROW @@ -26,8 +29,8 @@ // linear interpolation template -static inline -T lerp (T a, U b, P p) +static inline T +lerp (T a, U b, P p) { return (long(a) * long(100 - p) + long(b) * long(p) + 50) / 100; } @@ -60,6 +63,10 @@ void operator delete (void *p, size_t s); }; +// alas new/delete cannot be specified as inline in C++11 (see 17.6.4.6) +void *operator new (size_t s) throw (std::bad_alloc); +void operator delete (void *p) throw (); + struct stringvec : simplevec { ~stringvec () @@ -86,66 +93,7 @@ }; #endif -template -struct auto_ptr -{ - T *p; - - auto_ptr () : p (0) { } - auto_ptr (T *a) : p (a) { } - - auto_ptr (auto_ptr &a) - { - p = a.p; - a.p = 0; - } - - template - auto_ptr (auto_ptr &a) - { - p = a.p; - a.p = 0; - } - - ~auto_ptr () - { - free (p); - } - - // void because it makes sense in our context - void operator = (T *a) - { - free (p); - p = a; - } - - void operator = (auto_ptr &a) - { - *this = a.p; - a.p = 0; - } - - template - void operator = (auto_ptr &a) - { - *this = a.p; - a.p = 0; - } - - operator T * () const { return p; } - - T *operator -> () const { return p; } - T &operator * () const { return *p; } - - T *get () - { - T *r = p; - p = 0; - return r; - } -}; - -typedef auto_ptr auto_str; +typedef estl::scoped_array auto_str; #endif