12 #ifndef ROC_CORE_OPTIONAL_H_
13 #define ROC_CORE_OPTIONAL_H_
44 if (ptr && (
void*)ptr != storage_.memory()) {
45 roc_panic(
"optional: attempt to set incorrect object");
58 roc_panic(
"optional: attempt to dereference uninitialized object");
66 roc_panic(
"optional: attempt to dereference uninitialized object");
72 operator const struct unspecified_bool *()
const {
73 return (
const unspecified_bool*)ptr_;
81 roc_panic(
"optional: attempt to get memory after the object was created");
83 return storage_.memory();
97 template <
class T,
size_t Size>
100 return opt.unallocated_memory();
106 template <
class T,
size_t Size>
Fixed-size maximum-aligned storage.
Base class for non-copyable objects.
Optionally constructed object.
T * operator->() const
Get underlying object.
void * unallocated_memory()
Get object memory.
T & operator*() const
Get underlying reference.
void reset(T *ptr=NULL)
Set pointer to the newly created object, destroy old pointed object if set.
T * get() const
Get underlying object.
#define roc_panic_if_not(x)
Panic if condition is false.
#define roc_panic(...)
Print error message and terminate program gracefully.
Commonly used types and functions.