Core: BREAK_WHEN_PICKED

git-svn-id: svn://ultimatepp.org/upp/trunk@1930 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2010-01-24 13:21:33 +00:00
parent 03de5f35f6
commit 316f8b6164
3 changed files with 34 additions and 0 deletions

View file

@ -164,6 +164,7 @@ public:
V PickKeys() pick_ { return key; }
const V& GetKeys() const { return key; }
bool IsPicked(void) const { return key.IsPicked(); }
// Pick assignment & copy. Picked source can only Clear(), ~AIndex(), operator=, operator<<=

View file

@ -8,6 +8,23 @@ struct Vector_ {
int alloc;
};
#ifdef _DEBUG
void *break_when_picked;
void BreakWhenPicked(void *ptr)
{
if(ptr == break_when_picked)
__BREAK__;
}
void BREAK_WHEN_PICKED__(void *ptr)
{
break_when_picked = ptr;
}
#endif
void VectorReAlloc_(void *v_, int newalloc, int sizeofT)
{
Vector_ *v = (Vector_*)v_;

View file

@ -1,3 +1,14 @@
#ifdef _DEBUG
void BreakWhenPicked(void *ptr);
void BREAK_WHEN_PICKED__(void *ptr);
template <class T>
void BREAK_WHEN_PICKED(T& x)
{
BREAK_WHEN_PICKED__(&x);
}
#endif
template <class T>
class Vector : public MoveableAndDeepCopyOption< Vector<T> > {
T *vector;
@ -6,7 +17,12 @@ class Vector : public MoveableAndDeepCopyOption< Vector<T> > {
static void RawFree(T *ptr) { if(ptr) MemoryFree(ptr); }
static T *RawAlloc(int& n);
#ifdef _DEBUG
static Vector& SetPicked(pick_ Vector& v) { BreakWhenPicked(&v); Vector& p = (Vector&)(v); p.items = -1; p.vector = NULL; return p; }
#else
static Vector& SetPicked(pick_ Vector& v) { Vector& p = (Vector&)(v); p.items = -1; p.vector = NULL; return p; }
#endif
void Pick(pick_ Vector<T>& v);