sparrow 0.3.0
Loading...
Searching...
No Matches
sparrow::buffer< T > Class Template Reference

Object that owns a piece of contiguous memory. More...

#include <buffer.hpp>

Inheritance diagram for sparrow::buffer< T >:
[legend]
Collaboration diagram for sparrow::buffer< T >:
[legend]

Public Types

using allocator_type = typename base_type::allocator_type
 
using value_type = T
 
using reference = value_type&
 
using const_reference = const value_type&
 
using pointer = typename alloc_traits::pointer
 
using const_pointer = typename alloc_traits::const_pointer
 
using size_type = typename alloc_traits::size_type
 
using difference_type = typename alloc_traits::difference_type
 
using iterator = pointer_iterator<pointer>
 
using const_iterator = pointer_iterator<const_pointer>
 
using reverse_iterator = std::reverse_iterator<iterator>
 
using const_reverse_iterator = std::reverse_iterator<const_iterator>
 

Public Member Functions

 buffer ()=default
 
template<class A>
requires (not std::same_as<A, buffer<T>> and allocator<A>)
constexpr buffer (const A &a)
 
template<allocator A = allocator_type>
constexpr buffer (size_type n, const A &a=A())
 
template<allocator A = allocator_type>
constexpr buffer (size_type n, const value_type &v, const A &a=A())
 
template<allocator A = allocator_type>
constexpr buffer (pointer p, size_type n, const A &a=A())
 
template<allocator A = allocator_type>
constexpr buffer (std::initializer_list< value_type > init, const A &a=A())
 
template<class It, allocator A = allocator_type>
constexpr buffer (It first, It last, const A &a=A())
 
template<std::ranges::input_range Range, allocator A = allocator_type>
requires std::same_as<std::ranges::range_value_t<Range>, T>
constexpr buffer (const Range &range, const A &a=A())
 
 ~buffer ()
 
 buffer (const buffer &rhs)
 
template<allocator A>
 buffer (const buffer &rhs, const A &a)
 
 buffer (buffer &&rhs) noexcept=default
 
template<allocator A>
 buffer (buffer &&rhs, const A &a)
 
constexpr bufferoperator= (const buffer &rhs)
 
constexpr bufferoperator= (buffer &&rhs)
 
constexpr bufferoperator= (std::initializer_list< value_type > init)
 
constexpr reference operator[] (size_type i)
 
constexpr const_reference operator[] (size_type i) const
 
constexpr reference front ()
 
constexpr const_reference front () const
 
constexpr reference back ()
 
constexpr const_reference back () const
 
template<class U = T>
constexpr U * data () noexcept
 
template<class U = T>
constexpr const U * data () const noexcept
 
constexpr iterator begin () noexcept
 
constexpr iterator end () noexcept
 
constexpr const_iterator begin () const noexcept
 
constexpr const_iterator end () const noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr const_iterator cend () const noexcept
 
constexpr reverse_iterator rbegin () noexcept
 
constexpr reverse_iterator rend () noexcept
 
constexpr const_reverse_iterator rbegin () const noexcept
 
constexpr const_reverse_iterator rend () const noexcept
 
constexpr const_reverse_iterator crbegin () const noexcept
 
constexpr const_reverse_iterator crend () const noexcept
 
constexpr bool empty () const noexcept
 
constexpr size_type capacity () const noexcept
 
constexpr size_type size () const noexcept
 
constexpr size_type max_size () const noexcept
 
constexpr void reserve (size_type new_cap)
 
constexpr void shrink_to_fit ()
 
constexpr void clear ()
 
constexpr iterator insert (const_iterator pos, const T &value)
 
constexpr iterator insert (const_iterator pos, T &&value)
 
constexpr iterator insert (const_iterator pos, size_type count, const T &value)
 
template<mpl::iterator_of_type< T > InputIt>
constexpr iterator insert (const_iterator pos, InputIt first, InputIt last)
 
template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, T>
constexpr iterator insert (const_iterator pos, R &&range)
 
constexpr iterator insert (const_iterator pos, std::initializer_list< T > ilist)
 
template<class... Args>
constexpr iterator emplace (const_iterator pos, Args &&... args)
 
constexpr iterator erase (const_iterator pos)
 
constexpr iterator erase (const_iterator first, const_iterator last)
 
constexpr void push_back (const T &value)
 
constexpr void push_back (T &&value)
 
constexpr void pop_back ()
 
constexpr void resize (size_type new_size)
 
constexpr void resize (size_type new_size, const value_type &value)
 
constexpr void swap (buffer &rhs) noexcept
 
template<mpl::iterator_of_type< T > InputIt>
constexpr auto insert (const_iterator pos, InputIt first, InputIt last) -> iterator
 
template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, T>
constexpr auto insert (const_iterator pos, R &&range) -> iterator
 
template<class It>
constexpr auto allocate_and_copy (size_type n, It first, It last) -> pointer
 
template<class It>
constexpr auto copy_initialize (It first, It last, pointer begin, allocator_type &a) -> pointer
 

Detailed Description

template<class T>
class sparrow::buffer< T >

Object that owns a piece of contiguous memory.

This class provides an API similar to std::vector, with two main differences:

  • it is not templated by the allocator type, but makes use of any_allocator which type-erases it.
  • it can acquire ownership of an already allocated raw buffer.

Definition at line 108 of file buffer.hpp.

Member Typedef Documentation

◆ allocator_type

template<class T>
using sparrow::buffer< T >::allocator_type = typename base_type::allocator_type

Definition at line 120 of file buffer.hpp.

◆ const_iterator

template<class T>
using sparrow::buffer< T >::const_iterator = pointer_iterator<const_pointer>

Definition at line 129 of file buffer.hpp.

◆ const_pointer

template<class T>
using sparrow::buffer< T >::const_pointer = typename alloc_traits::const_pointer

Definition at line 125 of file buffer.hpp.

◆ const_reference

template<class T>
using sparrow::buffer< T >::const_reference = const value_type&

Definition at line 123 of file buffer.hpp.

◆ const_reverse_iterator

template<class T>
using sparrow::buffer< T >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 131 of file buffer.hpp.

◆ difference_type

template<class T>
using sparrow::buffer< T >::difference_type = typename alloc_traits::difference_type

Definition at line 127 of file buffer.hpp.

◆ iterator

template<class T>
using sparrow::buffer< T >::iterator = pointer_iterator<pointer>

Definition at line 128 of file buffer.hpp.

◆ pointer

template<class T>
using sparrow::buffer< T >::pointer = typename alloc_traits::pointer

Definition at line 124 of file buffer.hpp.

◆ reference

template<class T>
using sparrow::buffer< T >::reference = value_type&

Definition at line 122 of file buffer.hpp.

◆ reverse_iterator

template<class T>
using sparrow::buffer< T >::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 130 of file buffer.hpp.

◆ size_type

template<class T>
using sparrow::buffer< T >::size_type = typename alloc_traits::size_type

Definition at line 126 of file buffer.hpp.

◆ value_type

template<class T>
using sparrow::buffer< T >::value_type = T

Definition at line 121 of file buffer.hpp.

Constructor & Destructor Documentation

◆ buffer() [1/12]

template<class T>
sparrow::buffer< T >::buffer ( )
default
Here is the caller graph for this function:

◆ buffer() [2/12]

template<class T>
template<class A>
requires (not std::same_as<A, buffer<T>> and allocator<A>)
sparrow::buffer< T >::buffer ( const A & a)
inlineexplicitconstexpr

Definition at line 137 of file buffer.hpp.

◆ buffer() [3/12]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( size_type n,
const A & a = A() )
explicitconstexpr

Definition at line 420 of file buffer.hpp.

◆ buffer() [4/12]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( size_type n,
const value_type & v,
const A & a = A() )
constexpr

Definition at line 428 of file buffer.hpp.

◆ buffer() [5/12]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( pointer p,
size_type n,
const A & a = A() )
constexpr

Definition at line 436 of file buffer.hpp.

◆ buffer() [6/12]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( std::initializer_list< value_type > init,
const A & a = A() )
constexpr

Definition at line 443 of file buffer.hpp.

Here is the call graph for this function:

◆ buffer() [7/12]

template<class T>
template<class It, allocator A>
sparrow::buffer< T >::buffer ( It first,
It last,
const A & a = A() )
constexpr

Definition at line 451 of file buffer.hpp.

◆ buffer() [8/12]

template<class T>
requires std::same_as<std::ranges::range_value_t<Range>, T>
template<std::ranges::input_range Range, allocator A>
requires std::same_as<std::ranges::range_value_t<Range>, T>
sparrow::buffer< T >::buffer ( const Range & range,
const A & a = A() )
constexpr

Definition at line 460 of file buffer.hpp.

Here is the call graph for this function:

◆ ~buffer()

template<class T>
sparrow::buffer< T >::~buffer ( )

Definition at line 472 of file buffer.hpp.

◆ buffer() [9/12]

template<class T>
sparrow::buffer< T >::buffer ( const buffer< T > & rhs)

Definition at line 478 of file buffer.hpp.

Here is the call graph for this function:

◆ buffer() [10/12]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( const buffer< T > & rhs,
const A & a )

Definition at line 486 of file buffer.hpp.

Here is the call graph for this function:

◆ buffer() [11/12]

template<class T>
sparrow::buffer< T >::buffer ( buffer< T > && rhs)
defaultnoexcept
Here is the call graph for this function:

◆ buffer() [12/12]

template<class T>
template<allocator A>
sparrow::buffer< T >::buffer ( buffer< T > && rhs,
const A & a )

Definition at line 494 of file buffer.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ allocate_and_copy()

template<class T>
template<class It>
auto sparrow::buffer< T >::allocate_and_copy ( size_type n,
It first,
It last ) -> pointer
constexpr

Definition at line 1008 of file buffer.hpp.

Here is the call graph for this function:

◆ back() [1/2]

template<class T>
auto sparrow::buffer< T >::back ( )
nodiscardconstexpr

Definition at line 579 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ back() [2/2]

template<class T>
auto sparrow::buffer< T >::back ( ) const
nodiscardconstexpr

Definition at line 586 of file buffer.hpp.

Here is the call graph for this function:

◆ begin() [1/2]

template<class T>
auto sparrow::buffer< T >::begin ( ) const
nodiscardconstexprnoexcept

Definition at line 633 of file buffer.hpp.

Here is the call graph for this function:

◆ begin() [2/2]

template<class T>
auto sparrow::buffer< T >::begin ( )
nodiscardconstexprnoexcept

Definition at line 621 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ capacity()

template<class T>
auto sparrow::buffer< T >::capacity ( ) const
nodiscardconstexprnoexcept

Definition at line 699 of file buffer.hpp.

Here is the caller graph for this function:

◆ cbegin()

template<class T>
auto sparrow::buffer< T >::cbegin ( ) const
nodiscardconstexprnoexcept

Definition at line 645 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cend()

template<class T>
auto sparrow::buffer< T >::cend ( ) const
nodiscardconstexprnoexcept

Definition at line 651 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

template<class T>
void sparrow::buffer< T >::clear ( )
constexpr

Definition at line 759 of file buffer.hpp.

Here is the caller graph for this function:

◆ copy_initialize()

template<class T>
template<class It>
auto sparrow::buffer< T >::copy_initialize ( It first,
It last,
pointer begin,
allocator_type & a ) -> pointer
constexpr

Definition at line 1066 of file buffer.hpp.

Here is the call graph for this function:

◆ crbegin()

template<class T>
auto sparrow::buffer< T >::crbegin ( ) const
nodiscardconstexprnoexcept

Definition at line 681 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ crend()

template<class T>
auto sparrow::buffer< T >::crend ( ) const
nodiscardconstexprnoexcept

Definition at line 687 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ data() [1/2]

template<class T>
template<class U>
const U * sparrow::buffer< T >::data ( ) const
nodiscardconstexprnoexcept

Definition at line 608 of file buffer.hpp.

◆ data() [2/2]

template<class T>
template<class U>
U * sparrow::buffer< T >::data ( )
nodiscardconstexprnoexcept

Definition at line 594 of file buffer.hpp.

Here is the caller graph for this function:

◆ emplace()

template<class T>
template<class... Args>
buffer< T >::iterator sparrow::buffer< T >::emplace ( const_iterator pos,
Args &&... args )
constexpr

Definition at line 856 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

template<class T>
bool sparrow::buffer< T >::empty ( ) const
nodiscardconstexprnoexcept

Definition at line 693 of file buffer.hpp.

Here is the caller graph for this function:

◆ end() [1/2]

template<class T>
auto sparrow::buffer< T >::end ( ) const
nodiscardconstexprnoexcept

Definition at line 639 of file buffer.hpp.

Here is the call graph for this function:

◆ end() [2/2]

template<class T>
auto sparrow::buffer< T >::end ( )
nodiscardconstexprnoexcept

Definition at line 627 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erase() [1/2]

template<class T>
auto sparrow::buffer< T >::erase ( const_iterator first,
const_iterator last )
constexpr

Definition at line 886 of file buffer.hpp.

Here is the call graph for this function:

◆ erase() [2/2]

template<class T>
auto sparrow::buffer< T >::erase ( const_iterator pos)
constexpr

Definition at line 878 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ front() [1/2]

template<class T>
auto sparrow::buffer< T >::front ( )
nodiscardconstexpr

Definition at line 565 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ front() [2/2]

template<class T>
auto sparrow::buffer< T >::front ( ) const
nodiscardconstexpr

Definition at line 572 of file buffer.hpp.

Here is the call graph for this function:

◆ insert() [1/8]

template<class T>
auto sparrow::buffer< T >::insert ( const_iterator pos,
const T & value )
constexpr

Definition at line 765 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert() [2/8]

template<class T>
template<mpl::iterator_of_type< T > InputIt>
iterator sparrow::buffer< T >::insert ( const_iterator pos,
InputIt first,
InputIt last )
constexpr
Here is the call graph for this function:

◆ insert() [3/8]

template<class T>
template<mpl::iterator_of_type< T > InputIt>
auto sparrow::buffer< T >::insert ( const_iterator pos,
InputIt first,
InputIt last ) -> iterator
constexpr

Definition at line 813 of file buffer.hpp.

Here is the call graph for this function:

◆ insert() [4/8]

template<class T>
template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, T>
iterator sparrow::buffer< T >::insert ( const_iterator pos,
R && range )
constexpr
Here is the call graph for this function:

◆ insert() [5/8]

template<class T>
template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, T>
auto sparrow::buffer< T >::insert ( const_iterator pos,
R && range ) -> iterator
constexpr

Definition at line 839 of file buffer.hpp.

Here is the call graph for this function:

◆ insert() [6/8]

template<class T>
auto sparrow::buffer< T >::insert ( const_iterator pos,
size_type count,
const T & value )
constexpr

Definition at line 781 of file buffer.hpp.

Here is the call graph for this function:

◆ insert() [7/8]

template<class T>
auto sparrow::buffer< T >::insert ( const_iterator pos,
std::initializer_list< T > ilist )
constexpr

Definition at line 847 of file buffer.hpp.

Here is the call graph for this function:

◆ insert() [8/8]

template<class T>
auto sparrow::buffer< T >::insert ( const_iterator pos,
T && value )
constexpr

Definition at line 773 of file buffer.hpp.

Here is the call graph for this function:

◆ max_size()

template<class T>
auto sparrow::buffer< T >::max_size ( ) const
nodiscardconstexprnoexcept

Definition at line 711 of file buffer.hpp.

Here is the caller graph for this function:

◆ operator=() [1/3]

template<class T>
buffer< T > & sparrow::buffer< T >::operator= ( buffer< T > && rhs)
constexpr

Definition at line 521 of file buffer.hpp.

Here is the call graph for this function:

◆ operator=() [2/3]

template<class T>
buffer< T > & sparrow::buffer< T >::operator= ( const buffer< T > & rhs)
constexpr

Definition at line 510 of file buffer.hpp.

Here is the call graph for this function:

◆ operator=() [3/3]

template<class T>
buffer< T > & sparrow::buffer< T >::operator= ( std::initializer_list< value_type > init)
constexpr

Definition at line 540 of file buffer.hpp.

Here is the call graph for this function:

◆ operator[]() [1/2]

template<class T>
auto sparrow::buffer< T >::operator[] ( size_type i)
nodiscardconstexpr

Definition at line 551 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator[]() [2/2]

template<class T>
auto sparrow::buffer< T >::operator[] ( size_type i) const
nodiscardconstexpr

Definition at line 558 of file buffer.hpp.

Here is the call graph for this function:

◆ pop_back()

template<class T>
void sparrow::buffer< T >::pop_back ( )
constexpr

Definition at line 911 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_back() [1/2]

template<class T>
void sparrow::buffer< T >::push_back ( const T & value)
constexpr

Definition at line 899 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_back() [2/2]

template<class T>
void sparrow::buffer< T >::push_back ( T && value)
constexpr

Definition at line 905 of file buffer.hpp.

Here is the call graph for this function:

◆ rbegin() [1/2]

template<class T>
auto sparrow::buffer< T >::rbegin ( ) const
nodiscardconstexprnoexcept

Definition at line 669 of file buffer.hpp.

Here is the call graph for this function:

◆ rbegin() [2/2]

template<class T>
auto sparrow::buffer< T >::rbegin ( )
nodiscardconstexprnoexcept

Definition at line 657 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rend() [1/2]

template<class T>
auto sparrow::buffer< T >::rend ( ) const
nodiscardconstexprnoexcept

Definition at line 675 of file buffer.hpp.

Here is the call graph for this function:

◆ rend() [2/2]

template<class T>
auto sparrow::buffer< T >::rend ( )
nodiscardconstexprnoexcept

Definition at line 663 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reserve()

template<class T>
void sparrow::buffer< T >::reserve ( size_type new_cap)
constexpr

Definition at line 717 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize() [1/2]

template<class T>
void sparrow::buffer< T >::resize ( size_type new_size)
constexpr

Definition at line 919 of file buffer.hpp.

Here is the caller graph for this function:

◆ resize() [2/2]

template<class T>
void sparrow::buffer< T >::resize ( size_type new_size,
const value_type & value )
constexpr

Definition at line 931 of file buffer.hpp.

◆ shrink_to_fit()

template<class T>
void sparrow::buffer< T >::shrink_to_fit ( )
constexpr

Definition at line 750 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

template<class T>
auto sparrow::buffer< T >::size ( ) const
nodiscardconstexprnoexcept

Definition at line 705 of file buffer.hpp.

Here is the caller graph for this function:

◆ swap()

template<class T>
void sparrow::buffer< T >::swap ( buffer< T > & rhs)
constexprnoexcept

Definition at line 943 of file buffer.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

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