Fixes to make safe_ptr work outside of kakoune.

This commit is contained in:
King_DuckZ 2017-03-12 15:12:44 +00:00
parent 23d7121e76
commit 8a65faf45c

View file

@ -3,7 +3,11 @@
// #define SAFE_PTR_TRACK_CALLSTACKS
#include "assert.hh"
//King_DuckZ:
#include <cassert>
#define kak_assert(a) assert(a)
//#include "assert.hh"
#include "ref_ptr.hh"
#include <type_traits>
@ -57,6 +61,8 @@ struct SafeCountablePolicy
++sc->m_count;
#ifdef SAFE_PTR_TRACK_CALLSTACKS
sc->m_callstacks.emplace_back(ptr);
#else
static_cast<void>(ptr);
#endif
}
@ -69,6 +75,8 @@ struct SafeCountablePolicy
[=](const SafeCountable::Callstack& cs) { return cs.ptr == ptr; });
kak_assert(it != sc->m_callstacks.end());
sc->m_callstacks.erase(it);
#else
static_cast<void>(ptr);
#endif
}
@ -79,6 +87,10 @@ struct SafeCountablePolicy
[=](const SafeCountable::Callstack& cs) { return cs.ptr == from; });
kak_assert(it != sc->m_callstacks.end());
it->ptr = to;
#else
static_cast<void>(sc);
static_cast<void>(from);
static_cast<void>(to);
#endif
}
#else