28 #ifndef SMART_POINTER_HPP 29 #define SMART_POINTER_HPP 31 #include "../my_config.h" 50 smart_node(T *arg): ptr(arg), count_ref(0) {
if(arg ==
nullptr)
throw SRC_BUG; };
55 ~
smart_node() noexcept(
false) {
if(ptr !=
nullptr)
delete ptr;
if(!count_ref.
is_zero())
throw SRC_BUG; };
57 void add_ref() { ++count_ref; };
58 void del_ref() {
if(count_ref.
is_zero())
throw SRC_BUG; --count_ref;
if(count_ref.
is_zero())
delete this; };
59 T & get_val() {
return *ptr; };
96 throw Ememory(
"smart_pointer::smart_pointer");
117 if(ref.ptr !=
nullptr)
159 T & operator *()
const {
if(ptr ==
nullptr)
throw SRC_BUG;
return ptr->get_val(); };
162 T* operator ->()
const {
if(ptr ==
nullptr)
throw SRC_BUG;
return &(ptr->get_val()); };
165 bool is_null()
const {
return ptr ==
nullptr; };
smart_pointer(const smart_pointer &ref)
copy constructor
smart_pointer(smart_pointer &&ref) noexcept
move constructor
class which holds the address of the allocated memory for many smart_pointers
smart_pointer()
creates a smart_pointer equivalent to a pointer to NULL
exception used when memory has been exhausted
contains all the excetion class thrown by libdar
switch module to limitint (32 ou 64 bits integers) or infinint
bool is_null() const
return whether the smart_pointer is pointing to nullptr
smart pointer class to be used to automagically manage multiple time pointed to address ...
const smart_pointer & assign(T *arg)
assignment operator from a base type pointer (not from a smart_pointer)
~smart_pointer()
destructor
the arbitrary large positive integer class
smart_pointer(T *arg)
creates a smart_pointer pointing to an allocated memory
libdar namespace encapsulate all libdar symbols