MySQL 8.4.3
Source Code Documentation
Bounds_checked_array< Element_type > Class Template Reference

A wrapper class which provides array bounds checking. More...

#include <sql_array.h>

Public Types

typedef Element_type value_type
 
typedef Element_type * iterator
 
typedef const Element_type * const_iterator
 

Public Member Functions

 Bounds_checked_array ()
 
 Bounds_checked_array (Element_type *el, size_t size_arg)
 
template<class T , size_t N>
 Bounds_checked_array (std::array< T, N > &arr)
 
Bounds_checked_array Clone (MEM_ROOT *mem_root) const
 Make a copy of '*this'. Allocate memory for m_array on 'mem_root'. More...
 
void reset ()
 
void reset (Element_type *array, size_t size)
 
void resize (size_t new_size)
 Set a new bound on the array. More...
 
Bounds_checked_array prefix (size_t new_size)
 Like resize(), but returns a new view of the array without modifying this one. More...
 
Element_type * data ()
 
const Element_type * data () const
 
Element_type & operator[] (size_t n)
 
const Element_type & operator[] (size_t n) const
 
iterator begin ()
 begin : Returns a pointer to the first element in the array. More...
 
iterator end ()
 end : Returns a pointer to the past-the-end element in the array. More...
 
const_iterator begin () const
 begin : Returns a pointer to the first element in the array. More...
 
const_iterator end () const
 end : Returns a pointer to the past-the-end element in the array. More...
 
const_iterator cbegin () const
 Returns a pointer to the first element in the array. More...
 
const_iterator cend () const
 Returns a pointer to the past-the-end element in the array. More...
 
Bounds_checked_array without_back () const
 
size_t element_size () const
 
size_t size () const
 
bool empty () const
 
bool is_null () const
 
void pop_front ()
 
Element_type * array () const
 
bool operator== (const Bounds_checked_array< Element_type > &rhs) const
 
bool operator!= (const Bounds_checked_array< Element_type > &rhs) const
 

Static Public Member Functions

static Bounds_checked_array Alloc (MEM_ROOT *mem_root, size_t size)
 

Private Attributes

Element_type * m_array
 
size_t m_size
 

Detailed Description

template<typename Element_type>
class Bounds_checked_array< Element_type >

A wrapper class which provides array bounds checking.

We do not own the array, we simply have a pointer to the first element, and a length.

Remarks
We want the compiler-generated versions of:
  • the copy CTOR (memberwise initialization)
  • the assignment operator (memberwise assignment)

This is roughly analogous to C++20's std::span.

Template Parameters
Element_typeThe type of the elements of the container.

Member Typedef Documentation

◆ const_iterator

template<typename Element_type >
typedef const Element_type* Bounds_checked_array< Element_type >::const_iterator

◆ iterator

template<typename Element_type >
typedef Element_type* Bounds_checked_array< Element_type >::iterator

◆ value_type

template<typename Element_type >
typedef Element_type Bounds_checked_array< Element_type >::value_type

Constructor & Destructor Documentation

◆ Bounds_checked_array() [1/3]

template<typename Element_type >
Bounds_checked_array< Element_type >::Bounds_checked_array ( )
inline

◆ Bounds_checked_array() [2/3]

template<typename Element_type >
Bounds_checked_array< Element_type >::Bounds_checked_array ( Element_type *  el,
size_t  size_arg 
)
inline

◆ Bounds_checked_array() [3/3]

template<typename Element_type >
template<class T , size_t N>
Bounds_checked_array< Element_type >::Bounds_checked_array ( std::array< T, N > &  arr)
inlineexplicit

Member Function Documentation

◆ Alloc()

template<typename Element_type >
static Bounds_checked_array Bounds_checked_array< Element_type >::Alloc ( MEM_ROOT mem_root,
size_t  size 
)
inlinestatic

◆ array()

template<typename Element_type >
Element_type * Bounds_checked_array< Element_type >::array ( ) const
inline

◆ begin() [1/2]

template<typename Element_type >
iterator Bounds_checked_array< Element_type >::begin ( void  )
inline

begin : Returns a pointer to the first element in the array.

◆ begin() [2/2]

template<typename Element_type >
const_iterator Bounds_checked_array< Element_type >::begin ( void  ) const
inline

begin : Returns a pointer to the first element in the array.

◆ cbegin()

template<typename Element_type >
const_iterator Bounds_checked_array< Element_type >::cbegin ( ) const
inline

Returns a pointer to the first element in the array.

◆ cend()

template<typename Element_type >
const_iterator Bounds_checked_array< Element_type >::cend ( ) const
inline

Returns a pointer to the past-the-end element in the array.

◆ Clone()

template<typename Element_type >
Bounds_checked_array Bounds_checked_array< Element_type >::Clone ( MEM_ROOT mem_root) const
inline

Make a copy of '*this'. Allocate memory for m_array on 'mem_root'.

◆ data() [1/2]

template<typename Element_type >
Element_type * Bounds_checked_array< Element_type >::data ( )
inline

◆ data() [2/2]

template<typename Element_type >
const Element_type * Bounds_checked_array< Element_type >::data ( ) const
inline

◆ element_size()

template<typename Element_type >
size_t Bounds_checked_array< Element_type >::element_size ( ) const
inline

◆ empty()

template<typename Element_type >
bool Bounds_checked_array< Element_type >::empty ( ) const
inline

◆ end() [1/2]

template<typename Element_type >
iterator Bounds_checked_array< Element_type >::end ( void  )
inline

end : Returns a pointer to the past-the-end element in the array.

◆ end() [2/2]

template<typename Element_type >
const_iterator Bounds_checked_array< Element_type >::end ( void  ) const
inline

end : Returns a pointer to the past-the-end element in the array.

◆ is_null()

template<typename Element_type >
bool Bounds_checked_array< Element_type >::is_null ( ) const
inline

◆ operator!=()

template<typename Element_type >
bool Bounds_checked_array< Element_type >::operator!= ( const Bounds_checked_array< Element_type > &  rhs) const
inline

◆ operator==()

template<typename Element_type >
bool Bounds_checked_array< Element_type >::operator== ( const Bounds_checked_array< Element_type > &  rhs) const
inline

◆ operator[]() [1/2]

template<typename Element_type >
Element_type & Bounds_checked_array< Element_type >::operator[] ( size_t  n)
inline

◆ operator[]() [2/2]

template<typename Element_type >
const Element_type & Bounds_checked_array< Element_type >::operator[] ( size_t  n) const
inline

◆ pop_front()

template<typename Element_type >
void Bounds_checked_array< Element_type >::pop_front ( )
inline

◆ prefix()

template<typename Element_type >
Bounds_checked_array Bounds_checked_array< Element_type >::prefix ( size_t  new_size)
inline

Like resize(), but returns a new view of the array without modifying this one.

◆ reset() [1/2]

template<typename Element_type >
void Bounds_checked_array< Element_type >::reset ( void  )
inline

◆ reset() [2/2]

template<typename Element_type >
void Bounds_checked_array< Element_type >::reset ( Element_type *  array,
size_t  size 
)
inline

◆ resize()

template<typename Element_type >
void Bounds_checked_array< Element_type >::resize ( size_t  new_size)
inline

Set a new bound on the array.

Does not resize the underlying array, so the new size must be smaller than or equal to the current size.

◆ size()

template<typename Element_type >
size_t Bounds_checked_array< Element_type >::size ( ) const
inline

◆ without_back()

template<typename Element_type >
Bounds_checked_array Bounds_checked_array< Element_type >::without_back ( ) const
inline

Member Data Documentation

◆ m_array

template<typename Element_type >
Element_type* Bounds_checked_array< Element_type >::m_array
private

◆ m_size

template<typename Element_type >
size_t Bounds_checked_array< Element_type >::m_size
private

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