My Project
Public Member Functions
Mem_root_array< Element_type, has_trivial_destructor > Class Template Reference

#include <mem_root_array.h>

List of all members.

Public Member Functions

 Mem_root_array (MEM_ROOT *root)
Element_type & at (size_t n)
const Element_type & at (size_t n) const
Element_type * begin ()
Element_type * end ()
void clear ()
void chop (const size_t pos)
bool reserve (size_t n)
bool push_back (const Element_type &element)
size_t capacity () const
size_t element_size () const
bool empty () const
size_t size () const

Detailed Description

template<typename Element_type, bool has_trivial_destructor>
class Mem_root_array< Element_type, has_trivial_destructor >

A typesafe replacement for DYNAMIC_ARRAY. We use MEM_ROOT for allocating storage, rather than the C++ heap. The interface is chosen to be similar to std::vector.

Remarks:
Unlike DYNAMIC_ARRAY, elements are properly copied (rather than memcpy()d) if the underlying array needs to be expanded.
Depending on has_trivial_destructor, we destroy objects which are removed from the array (including when the array object itself is destroyed).
Note that MEM_ROOT has no facility for reusing free space, so don't use this if multiple re-expansions are likely to happen.
Parameters:
Element_typeThe type of the elements of the container. Elements must be copyable.
has_trivial_destructorIf true, we don't destroy elements. We could have used type traits to determine this. __has_trivial_destructor is supported by some (but not all) compilers we use.

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines