… | |
… | |
18 | |
18 | |
19 | #include <shstr.h> |
19 | #include <shstr.h> |
20 | #include <traits.h> |
20 | #include <traits.h> |
21 | |
21 | |
22 | // use a gcc extension for auto declarations until ISO C++ sanctifies them |
22 | // use a gcc extension for auto declarations until ISO C++ sanctifies them |
23 | #define AUTODECL(var,expr) typeof(expr) var = (expr) |
23 | #define auto(var,expr) typeof(expr) var = (expr) |
24 | |
24 | |
25 | // very ugly macro that basicaly declares and initialises a variable |
25 | // very ugly macro that basicaly declares and initialises a variable |
26 | // that is in scope for the next statement only |
26 | // that is in scope for the next statement only |
27 | // works only for stuff that can be assigned 0 and converts to false |
27 | // works only for stuff that can be assigned 0 and converts to false |
28 | // (note: works great for pointers) |
28 | // (note: works great for pointers) |
… | |
… | |
399 | } |
399 | } |
400 | |
400 | |
401 | void erase (T *obj) |
401 | void erase (T *obj) |
402 | { |
402 | { |
403 | assert (obj->*index); |
403 | assert (obj->*index); |
404 | int pos = obj->*index; |
404 | unsigned int pos = obj->*index; |
405 | obj->*index = 0; |
405 | obj->*index = 0; |
406 | |
406 | |
407 | if (pos < this->size ()) |
407 | if (pos < this->size ()) |
408 | { |
408 | { |
409 | (*this)[pos - 1] = (*this)[this->size () - 1]; |
409 | (*this)[pos - 1] = (*this)[this->size () - 1]; |