21#ifndef mia_core_vector_hh
22#define mia_core_vector_hh
42struct array_destructor {
44 virtual void operator () (T *p)
57struct array_void_destructor {
59 virtual void operator () (T *)
83 typedef const T& const_reference;
85 typedef const T *const_iterator;
86 typedef size_t size_type;
98 m_data(new T[n], array_destructor<T>()),
102 memset(m_data.get(), 0, m_size *
sizeof(T));
110 m_size(other.m_size),
111 m_data(other.m_data),
112 m_cdata(other.m_cdata)
119 m_size = other.m_size;
120 m_data = other.m_data;
121 m_cdata = other.m_cdata;
133 m_data(init, array_void_destructor<T>()),
158 "TCArrayWrapper::operator[]: No writeable data available or not unique,"
159 " call TCArrayWrapper::make_unique() first or enforce the use of "
160 "'TCArrayWrapper::operator[](...) const'");
161 return m_data.get()[i];
179 "TCArrayWrapper::begin(): No writeable data available or not unique, "
180 "call TCArrayWrapper::make_unique() first or enforce the use of "
181 "'TCArrayWrapper::begin() const'");
191 "TCArrayWrapper::begin(): No writeable data available or not unique, "
192 "call TCArrayWrapper::make_unique() first or enforce the use of "
193 "'TCArrayWrapper::end() const'");
194 return m_data.get() + m_size;
209 const_iterator
end()
const
211 return m_cdata + m_size;
231 if (m_data && m_data.unique())
236 m_data.reset(
new T[m_size], array_destructor<T>());
237 std::copy(m_cdata, m_cdata + m_size, m_data.get());
238 m_cdata = m_data.get();
243 std::shared_ptr<T> m_data;
A wrapper around the c-array to provide an STL like interface for iterators.
reference operator[](size_t i)
TCArrayWrapper(const TCArrayWrapper< T > &other)
TCArrayWrapper(size_t n, const T *init)
const_iterator end() const
TCArrayWrapper(size_t n, bool clean=true)
*/
TCArrayWrapper< T > & operator=(const TCArrayWrapper< T > &other)
assignment operator
const_iterator begin() const
TCArrayWrapper(size_t n, T *init)
std::ostream & operator<<(std::ostream &os, const TCArrayWrapper< T > &v)
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
#define NS_MIA_END
conveniance define to end the mia namespace
#define DEBUG_ASSERT_RELEASE_THROW(cond, msg...)
TCArrayWrapper< double > CDoubleVector