MySQL 9.1.0
Source Code Documentation
mysql::abi_helpers::Array_view< Element_tp > Class Template Reference

Ownership-agnostic array class, which is both trivial and standard-layout. More...

#include <array_view.h>

Inheritance diagram for mysql::abi_helpers::Array_view< Element_tp >:
[legend]

Public Types

using Element_t = Element_tp
 

Public Member Functions

 Array_view ()=default
 
 Array_view (Element_t *array, std::size_t size)
 Construct a view over the given array. More...
 
void assign (Element_t *array, std::size_t size)
 
void allocate (std::size_t size, PSI_memory_key key)
 Create a new array of the given type, replacing the existing one without deallocating it. More...
 
void free ()
 Free the array, assuming it was previously allocated using allocate (or my_malloc). More...
 
void clear ()
 
- Public Member Functions inherited from mysql::abi_helpers::detail::Array_base< Element_tp, Element_tp * >
std::size_t size () const
 
std::ptrdiff_t ssize () const
 
bool empty () const
 
 operator bool () const
 
Element_tp & operator[] (std::size_t index)
 Index operator (non-const). More...
 
const Element_tp & operator[] (std::size_t index) const
 Index operator (const). More...
 
Element_tp * data ()
 
const Element_tp * data () const
 
Element_tp * begin ()
 
const Element_tp * begin () const
 
Element_tp * end ()
 
const Element_tp * end () const
 
const Element_tp * cbegin () const
 
const Element_tp * cend () const
 

Private Types

using Self_t = Array_view< Element_tp >
 
using Base_t = detail::Array_base< Element_tp, Element_tp * >
 

Additional Inherited Members

- Protected Attributes inherited from mysql::abi_helpers::detail::Array_base< Element_tp, Element_tp * >
int32_t m_size
 Number of elements in the array. More...
 
Element_tp * m_data
 Array data. More...
 

Detailed Description

template<class Element_tp>
requires requires
class mysql::abi_helpers::Array_view< Element_tp >

Ownership-agnostic array class, which is both trivial and standard-layout.

This holds a length and a raw pointer to an array. The user has to manage ownership of the memory as needed.

Template Parameters
Element_tpThe type of elements in the array.

Member Typedef Documentation

◆ Base_t

template<class Element_tp >
using mysql::abi_helpers::Array_view< Element_tp >::Base_t = detail::Array_base<Element_tp, Element_tp *>
private

◆ Element_t

template<class Element_tp >
using mysql::abi_helpers::Array_view< Element_tp >::Element_t = Element_tp

◆ Self_t

template<class Element_tp >
using mysql::abi_helpers::Array_view< Element_tp >::Self_t = Array_view<Element_tp>
private

Constructor & Destructor Documentation

◆ Array_view() [1/2]

template<class Element_tp >
mysql::abi_helpers::Array_view< Element_tp >::Array_view ( )
default

◆ Array_view() [2/2]

template<class Element_tp >
mysql::abi_helpers::Array_view< Element_tp >::Array_view ( Element_t array,
std::size_t  size 
)
inline

Construct a view over the given array.

Member Function Documentation

◆ allocate()

template<class Element_tp >
void mysql::abi_helpers::Array_view< Element_tp >::allocate ( std::size_t  size,
PSI_memory_key  key 
)
inline

Create a new array of the given type, replacing the existing one without deallocating it.

Note
This, and free below, are only enabled in the MySQL server. This ensures that a component does not try to free memory allocated by the server or vice versa, which is disallowed on some platforms.
Parameters
sizeThe number of elements.
keyThe instrumentation key to track the allocation.

◆ assign()

template<class Element_tp >
void mysql::abi_helpers::Array_view< Element_tp >::assign ( Element_t array,
std::size_t  size 
)
inline

◆ clear()

template<class Element_tp >
void mysql::abi_helpers::Array_view< Element_tp >::clear ( )
inline

◆ free()

template<class Element_tp >
void mysql::abi_helpers::Array_view< Element_tp >::free ( )
inline

Free the array, assuming it was previously allocated using allocate (or my_malloc).

This, and allocate above, are only enabled in the MySQL server. See above for justification.


The documentation for this class was generated from the following file: