9 #ifndef CReferencedMemBlock_H
10 #define CReferencedMemBlock_H
16 #include <mrpt/otherlibs/stlplus/smart_ptr.hpp>
37 void resize(
size_t mem_block_size );
41 if (!m_data.present())
throw std::runtime_error(
"Trying to access to an uninitialized memory block");
42 if (m_data->empty())
throw std::runtime_error(
"Trying to access to a memory block of size 0");
43 return reinterpret_cast<T*
>(&((*m_data)[0]));
47 if (!m_data.present())
throw std::runtime_error(
"Trying to access to an uninitialized memory block");
48 if (m_data->empty())
throw std::runtime_error(
"Trying to access to a memory block of size 0");
49 return reinterpret_cast<const T*
>(&((*m_data)[0]));
52 template <
class T> T&
getAs() {
return *getAsPtr<T>(); }
53 template <
class T>
const T&
getAs()
const {
return *getAsPtr<T>(); }
55 unsigned int alias_count()
const;
59 stlplus::smart_ptr< std::vector<char> >
m_data;
Represents a memory block (via "void*") that can be shared between several objects through copy opera...
stlplus::smart_ptr< std::vector< char > > m_data
const T * getAsPtr() const
void clear()
Clear the contents of this container.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.