4#ifndef EXPRESSIONPARSING_POINTERCACHE_H
5#define EXPRESSIONPARSING_POINTERCACHE_H
11 template <
class T, std::memory_order MEMORY_ORDER>
31 operator bool()
const {
32 return m_ptr !=
nullptr;
38 return m_ptr.load(MEMORY_ORDER);
43 while (
m_ptr ==
nullptr) {
44 const T *expected=
nullptr;
45 if (
m_ptr.compare_exchange_weak(expected, ptr, MEMORY_ORDER))
break;
void setIfUnset(const T &obj)
set a pointer without handing over ownership
const T * operator->() const
dereference the pointer
void setIfUnset(std::unique_ptr< T > &&ptr)
set a pointer andhand over ownership
void setPointer(const T *ptr, bool owner)
std::atomic< bool > m_owner
std::atomic< const T * > m_ptr
Namespace holding all the expression evaluation code.