66 const std::type_info *type;
68 void checkType(
const std::type_info& asType)
const;
70 any_ptr() : any_ptr(
nullptr) {}
72 explicit any_ptr(std::nullptr_t) : ptr(
nullptr), type(&
typeid(std::nullptr_t)) {}
75 explicit any_ptr(T *ptr) : ptr(ptr), type(&
typeid(T*)) {}
78 explicit any_ptr(
const T *ptr) : any_ptr(
const_cast<T*
>(ptr)) {}
80 any_ptr(
void *ptr,
const std::type_info& type) : ptr(ptr), type(&type) {}
82 any_ptr(
const any_ptr &other) : ptr(other.ptr), type(other.type) {}
84 const any_ptr& operator=(
const any_ptr& other) {ptr=other.ptr; type=other.type;
return *
this;}
86 bool operator==(
const any_ptr& other)
const {
return ptr==other.ptr && (ptr==
nullptr || type==other.type);}
87 bool operator!=(
const any_ptr& other)
const {
return !operator==(other);}
89 bool operator==(std::nullptr_t)
const {
return ptr==
nullptr;}
90 bool operator!=(std::nullptr_t)
const {
return ptr!=
nullptr;}
93 bool contains()
const {
return typeid(T*) == *type;}
95 void *raw()
const {
return ptr;}
96 const std::type_info& pointerType()
const {
return *type;}
97 const char *pointerTypeName()
const {
return opp_typename(*type);}
98 const char *typeName()
const;
101 T *get() { checkType(
typeid(T*));
return reinterpret_cast<T*
>(ptr); }
104 const T *get()
const { checkType(
typeid(T*));
return reinterpret_cast<const T*
>(ptr);}
106 std::string str()
const;