29 #include <initializer_list> 54 explicit SmartPtr(
const std::shared_ptr<T>& sp) :
std::shared_ptr<T>(sp) {}
74 operator T*()
const {
return this->
get(); }
89 using const_iterator =
typename std::vector< SmartPtr<T> >::const_iterator;
90 using size_type =
typename std::vector< std::shared_ptr<T> >::size_type;
91 using base =
typename std::vector< SmartPtr<T> >;
103 for ( T* n : li ) { this->push_back(n); }
144 return this->base::insert(pos, n,
SmartPtr<T>(val));
152 return this->base::insert(position, first, last);
160 return this->base::insert(pos, val);
181 void swap(base&) =
delete;
188 this->base::reserve(this->base::size() + v.size());
189 insert(pos, v.base::begin(), v.base::end());
202 insert((index < 0 ? base::end() : base::begin()) + index, e);
210 this->erase((index < 0 ? base::end() - 1 : base::begin()) + index);
218 const base* base_this =
this;
220 for (
auto n : *base_this ) {
221 if (n.get() == e)
return index;
240 return p.get() == it->get();
250 return p.get() != it->get();
260 return p.get() == it->get();
270 return p.get() != it->get();
void erase_index(int index)
Definition: smart.h:208
iterator insert(const_iterator pos, const SmartPtr< T > val)
Definition: smart.h:158
iterator insert(const_iterator position, iterator first, iterator last)
Definition: smart.h:150
void push_back(T *p)
Definition: smart.h:119
typename std::vector< SmartPtr< Term > >::iterator iterator
Definition: smart.h:88
SmartPtr & operator=(T *p)
Definition: smart.h:59
void merge(SmartVector< T > &v)
Definition: smart.h:196
bool operator==(T *p) const
Definition: smart.h:64
iterator insert(const_iterator pos, T *val)
Definition: smart.h:134
iterator insert(const_iterator pos, size_type n, const T *val)
Definition: smart.h:142
int get_index(T *e) const
Definition: smart.h:216
iterator find(T *e)
Definition: smart.h:230
SmartPtr(const std::shared_ptr< T > &sp)
Definition: smart.h:54
SmartVector()
Definition: smart.h:96
void swap(SmartVector< T > &v)
Definition: smart.h:176
void merge(SmartVector< T > &v, iterator pos)
Definition: smart.h:186
SmartPtr()
Definition: smart.h:44
SmartVector(std::initializer_list< T * > li)
Definition: smart.h:101
bool operator!=(T *p) const
Definition: smart.h:69
SmartVector(std::initializer_list< SmartPtr< T > > li)
Definition: smart.h:114
SmartVector(T *p)
Definition: smart.h:109
void insert_index(int index, T *e)
Definition: smart.h:200
SmartPtr(T *p)
Definition: smart.h:49