18 const void*
ptr =
nullptr;
24 bool is(
const void*
ptr)
const {
25 return this->ptr ==
ptr;
30 bool is(
const T& ref)
const {
31 return is(
static_cast<const void*
>(&ref));
35 template <
typename T,
typename... Ts>
36 bool one_of(
const T& ref,
const Ts&... refs)
const {
45 return is(ref) || one_of(refs...);
49 bool one_of(
const std::vector<const void*>& ptrs)
const {
50 for(
size_t i = 0; i < ptrs.size(); ++i)
51 if(
is(ptrs[i]))
return true;
58 const void* addr_begin =
reinterpret_cast<const void*
>(&ref);
59 const void* addr_end =
reinterpret_cast<const void*
>(
reinterpret_cast<size_t>(addr_begin) +
sizeof(T));
60 return ptr >= addr_begin &&
ptr < addr_end;
bool is(const T &ref) const
Test if the stored pointer points to the given variable/object instance.
const void * ptr
The stored pointer.
pointer_test(const void *ptr)
Instantiate a pointer_test with a const void pointer.
bool one_of(const std::vector< const void * > &ptrs) const
Test if the stored pointer points to one of the given pointer addresses.
bool one_of(const T &ref, const Ts &... refs) const
Test if the stored pointer points to one of the given variable/object instances.
bool member_of(const T &ref) const
Test if the stored pointer points inside the address range of the given object instance.
bool is(const void *ptr) const
Test if the stored pointer points to the given pointer address.