Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::RefArray< T, N > Class Template Reference

A template class for a reference array. Behaves as if std::array<T&, N> was possible. More...

#include <ref_array.hpp>

Classes

class  iterator
 Nested iterator class for RefArray, based on indexing into the pointer array. Provides semantics similar to what would be expected if std::array<T&, N> was possible. More...
 

Public Member Functions

 RefArray ()=default
 
 RefArray (const std::array< T *, N > &ptr_array)
 
 RefArray (std::array< T, N > &arr)
 
template<typename... Ts>
 RefArray (T &first, Ts &... refs)
 
T & operator[] (std::size_t idx) const
 
std::array< T, N > get_copy ()
 Get a copy of the underlying data. Use carefully, as it allocates new data for the data pointed to by the elements in the RefArray.
 
constexpr std::size_t size () const
 
iterator begin () const
 Returns an iterator to the beginning of the RefArray.
 
iterator end () const
 Returns an iterator to the end of the RefArray.
 
T ** get_storage ()
 
T *const * get_storage () const
 

Private Attributes

T * storage [N]
 

Detailed Description

template<typename T, std::size_t N>
class bb::RefArray< T, N >

A template class for a reference array. Behaves as if std::array<T&, N> was possible.

This class provides a fixed-size array of pointers to elements of type T, exposed as references. It offers random access to its elements and provides an iterator class for traversal.

Template Parameters
TThe type of elements stored in the array.
NThe size of the array.

Definition at line 22 of file ref_array.hpp.

Constructor & Destructor Documentation

◆ RefArray() [1/4]

template<typename T , std::size_t N>
bb::RefArray< T, N >::RefArray ( )
default

◆ RefArray() [2/4]

template<typename T , std::size_t N>
bb::RefArray< T, N >::RefArray ( const std::array< T *, N > &  ptr_array)
inline

Definition at line 25 of file ref_array.hpp.

◆ RefArray() [3/4]

template<typename T , std::size_t N>
bb::RefArray< T, N >::RefArray ( std::array< T, N > &  arr)
inline

Definition at line 31 of file ref_array.hpp.

◆ RefArray() [4/4]

template<typename T , std::size_t N>
template<typename... Ts>
bb::RefArray< T, N >::RefArray ( T &  first,
Ts &...  refs 
)
inline

Definition at line 38 of file ref_array.hpp.

Member Function Documentation

◆ begin()

template<typename T , std::size_t N>
iterator bb::RefArray< T, N >::begin ( ) const
inline

Returns an iterator to the beginning of the RefArray.

Returns
An iterator to the first element.

Definition at line 123 of file ref_array.hpp.

◆ end()

template<typename T , std::size_t N>
iterator bb::RefArray< T, N >::end ( ) const
inline

Returns an iterator to the end of the RefArray.

Returns
An iterator to the element following the last element.

Definition at line 129 of file ref_array.hpp.

◆ get_copy()

template<typename T , std::size_t N>
std::array< T, N > bb::RefArray< T, N >::get_copy ( )
inline

Get a copy of the underlying data. Use carefully, as it allocates new data for the data pointed to by the elements in the RefArray.

Definition at line 63 of file ref_array.hpp.

◆ get_storage() [1/2]

template<typename T , std::size_t N>
T ** bb::RefArray< T, N >::get_storage ( )
inline

Definition at line 131 of file ref_array.hpp.

◆ get_storage() [2/2]

template<typename T , std::size_t N>
T *const * bb::RefArray< T, N >::get_storage ( ) const
inline

Definition at line 132 of file ref_array.hpp.

◆ operator[]()

template<typename T , std::size_t N>
T & bb::RefArray< T, N >::operator[] ( std::size_t  idx) const
inline

Definition at line 42 of file ref_array.hpp.

◆ size()

template<typename T , std::size_t N>
constexpr std::size_t bb::RefArray< T, N >::size ( ) const
inlineconstexpr

Definition at line 117 of file ref_array.hpp.

Member Data Documentation

◆ storage

template<typename T , std::size_t N>
T* bb::RefArray< T, N >::storage[N]
private

Definition at line 137 of file ref_array.hpp.


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