sparrow 0.9.0
|
Class which has internally a reference to a contiguous container of a certain type and provides an API to access it as if it was a buffer<T>. More...
#include <buffer_adaptor.hpp>
Public Types | |
using | value_type = To |
using | reference = value_type& |
using | const_reference = const value_type& |
using | pointer = value_type* |
using | const_pointer = const value_type* |
using | buffer_reference_value_type = std::remove_cvref_t<FromBufferRef>::value_type |
using | buffer_reference = std::conditional_t<is_const, const FromBufferRef, FromBufferRef> |
using | size_type = std::remove_cvref_t<buffer_reference>::size_type |
using | difference_type = std::remove_cvref_t<buffer_reference>::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 | |
constexpr | buffer_adaptor (FromBufferRef buf) |
Constructs a buffer adaptor with a non-const buffer reference. | |
constexpr | buffer_adaptor (const FromBufferRef buf) |
Constructs a buffer adaptor with a const buffer reference. | |
constexpr pointer | data () noexcept |
Returns a pointer to the underlying data. | |
constexpr const_pointer | data () const noexcept |
Returns a constant pointer to the underlying data. | |
constexpr reference | operator[] (size_type idx) |
Returns a reference to the element at the specified index. | |
constexpr const_reference | operator[] (size_type idx) const |
Returns a constant reference to the element at the specified index. | |
constexpr reference | front () |
Returns a reference to the first element. | |
constexpr const_reference | front () const |
Returns a constant reference to the first element. | |
constexpr reference | back () |
Returns a reference to the last element. | |
constexpr const_reference | back () const |
Returns a constant reference to the last element. | |
constexpr iterator | begin () noexcept |
Returns an iterator to the beginning. | |
constexpr iterator | end () noexcept |
Returns an iterator to the end. | |
constexpr const_iterator | begin () const noexcept |
Returns a constant iterator to the beginning. | |
constexpr const_iterator | end () const noexcept |
Returns a constant iterator to the end. | |
constexpr const_iterator | cbegin () const noexcept |
Returns a constant iterator to the beginning. | |
constexpr const_iterator | cend () const noexcept |
Returns a constant iterator to the end. | |
constexpr reverse_iterator | rbegin () noexcept |
Returns a reverse iterator to the beginning. | |
constexpr reverse_iterator | rend () noexcept |
Returns a reverse iterator to the end. | |
constexpr const_reverse_iterator | rbegin () const noexcept |
Returns a constant reverse iterator to the beginning. | |
constexpr const_reverse_iterator | rend () const noexcept |
Returns a constant reverse iterator to the end. | |
constexpr const_reverse_iterator | crbegin () const noexcept |
Returns a constant reverse iterator to the beginning. | |
constexpr const_reverse_iterator | crend () const noexcept |
Returns a constant reverse iterator to the end. | |
constexpr size_type | size () const noexcept(!SPARROW_CONTRACTS_THROW_ON_FAILURE) |
Returns the number of elements that can be held in currently allocated storage. | |
constexpr size_type | max_size () const noexcept |
Returns the maximum possible number of elements. | |
constexpr size_type | capacity () const noexcept |
Returns the number of elements that can be held in currently allocated storage. | |
constexpr bool | empty () const noexcept |
Checks whether the container is empty. | |
constexpr void | reserve (size_type new_cap) |
Reserves storage for at least the specified number of elements. | |
constexpr void | shrink_to_fit () |
Requests the removal of unused capacity. | |
constexpr void | clear () noexcept |
Clears the contents. | |
constexpr iterator | insert (const_iterator pos, const value_type &value) |
Inserts an element at the specified position. | |
constexpr iterator | insert (const_iterator pos, size_type count, const value_type &value) |
Inserts multiple copies of an element at the specified position. | |
template<class InputIt> requires std::input_iterator<InputIt> (not is_const) | |
constexpr iterator | insert (const_iterator pos, InputIt first, InputIt last) |
Inserts elements from a range at the specified position. | |
constexpr iterator | insert (const_iterator pos, std::initializer_list< value_type > ilist) |
Inserts elements from an initializer list at the specified position. | |
template<class... Args> requires (not is_const) | |
constexpr iterator | emplace (const_iterator pos, Args &&... args) |
Constructs an element in-place at the specified position. | |
constexpr iterator | erase (const_iterator pos) |
Erases an element at the specified position. | |
constexpr iterator | erase (const_iterator first, const_iterator last) |
Erases elements in the specified range. | |
constexpr void | push_back (const value_type &value) |
Adds an element to the end. | |
constexpr void | pop_back () |
Removes the last element. | |
constexpr void | resize (size_type new_size) |
Changes the number of elements stored. | |
constexpr void | resize (size_type new_size, const value_type &value) |
Changes the number of elements stored, filling new elements with the specified value. | |
Static Public Attributes | |
static constexpr bool | is_const = std::is_const_v<To> |
Class which has internally a reference to a contiguous container of a certain type and provides an API to access it as if it was a buffer<T>.
To | The type to which the buffer will be adapted. The size of the type To must be equal or bigger than the element type of the container. |
FromBufferRef | The type of the container to adapt. If it's a const reference, all non-const methods are disabled. |
Definition at line 57 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::buffer_reference = std::conditional_t<is_const, const FromBufferRef, FromBufferRef> |
Definition at line 69 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::buffer_reference_value_type = std::remove_cvref_t<FromBufferRef>::value_type |
Definition at line 68 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::const_iterator = pointer_iterator<const_pointer> |
Definition at line 74 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::const_pointer = const value_type* |
Definition at line 65 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::const_reference = const value_type& |
Definition at line 63 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Definition at line 76 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::difference_type = std::remove_cvref_t<buffer_reference>::difference_type |
Definition at line 72 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::iterator = pointer_iterator<pointer> |
Definition at line 73 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::pointer = value_type* |
Definition at line 64 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::reference = value_type& |
Definition at line 62 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::reverse_iterator = std::reverse_iterator<iterator> |
Definition at line 75 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::size_type = std::remove_cvref_t<buffer_reference>::size_type |
Definition at line 71 of file buffer_adaptor.hpp.
using sparrow::buffer_adaptor< To, FromBufferRef >::value_type = To |
Definition at line 61 of file buffer_adaptor.hpp.
|
explicitconstexpr |
Constructs a buffer adaptor with a non-const buffer reference.
buf | The buffer reference to adapt. |
Definition at line 461 of file buffer_adaptor.hpp.
|
explicitconstexpr |
Constructs a buffer adaptor with a const buffer reference.
buf | The const buffer reference to adapt. |
|
nodiscardconstexpr |
Returns a reference to the last element.
Definition at line 532 of file buffer_adaptor.hpp.
|
nodiscardconstexpr |
Returns a constant reference to the last element.
Definition at line 542 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a constant iterator to the beginning.
Definition at line 569 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns an iterator to the beginning.
Definition at line 551 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns the number of elements that can be held in currently allocated storage.
Definition at line 674 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a constant iterator to the beginning.
Definition at line 585 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a constant iterator to the end.
Definition at line 593 of file buffer_adaptor.hpp.
|
constexprnoexcept |
Clears the contents.
Definition at line 706 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a constant reverse iterator to the beginning.
Definition at line 635 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a constant reverse iterator to the end.
Definition at line 643 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a constant pointer to the underlying data.
Definition at line 488 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a pointer to the underlying data.
Definition at line 479 of file buffer_adaptor.hpp.
|
constexpr |
Constructs an element in-place at the specified position.
Args | The argument types. |
pos | The position to emplace at. |
args | Arguments to forward to the constructor. |
Definition at line 776 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Checks whether the container is empty.
Definition at line 681 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a constant iterator to the end.
Definition at line 577 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns an iterator to the end.
Definition at line 560 of file buffer_adaptor.hpp.
|
constexpr |
Erases elements in the specified range.
first | The beginning of the range to erase. |
last | The end of the range to erase. |
Definition at line 814 of file buffer_adaptor.hpp.
|
constexpr |
Erases an element at the specified position.
pos | The position of the element to erase. |
Definition at line 791 of file buffer_adaptor.hpp.
|
nodiscardconstexpr |
Returns a reference to the first element.
Definition at line 514 of file buffer_adaptor.hpp.
|
nodiscardconstexpr |
Returns a constant reference to the first element.
Definition at line 524 of file buffer_adaptor.hpp.
|
constexpr |
Inserts an element at the specified position.
pos | The position to insert at. |
value | The value to insert. |
Definition at line 715 of file buffer_adaptor.hpp.
|
constexpr |
Inserts elements from a range at the specified position.
InputIt | The iterator type. |
pos | The position to insert at. |
first | The beginning of the range to insert. |
last | The end of the range to insert. |
Definition at line 750 of file buffer_adaptor.hpp.
|
constexpr |
Inserts multiple copies of an element at the specified position.
pos | The position to insert at. |
count | The number of elements to insert. |
value | The value to insert. |
Definition at line 730 of file buffer_adaptor.hpp.
|
constexpr |
Inserts elements from an initializer list at the specified position.
pos | The position to insert at. |
ilist | The initializer list to insert. |
Definition at line 766 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns the maximum possible number of elements.
Definition at line 666 of file buffer_adaptor.hpp.
|
nodiscardconstexpr |
Returns a reference to the element at the specified index.
idx | The index of the element. |
Definition at line 496 of file buffer_adaptor.hpp.
|
nodiscardconstexpr |
Returns a constant reference to the element at the specified index.
idx | The index of the element. |
Definition at line 506 of file buffer_adaptor.hpp.
|
constexpr |
Removes the last element.
Definition at line 846 of file buffer_adaptor.hpp.
|
constexpr |
Adds an element to the end.
value | The value to add. |
Definition at line 838 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a constant reverse iterator to the beginning.
Definition at line 619 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a reverse iterator to the beginning.
Definition at line 601 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a constant reverse iterator to the end.
Definition at line 627 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns a reverse iterator to the end.
Definition at line 610 of file buffer_adaptor.hpp.
|
constexpr |
Reserves storage for at least the specified number of elements.
new_cap | The new capacity. |
Definition at line 688 of file buffer_adaptor.hpp.
|
constexpr |
Changes the number of elements stored.
new_size | The new size. |
Definition at line 854 of file buffer_adaptor.hpp.
|
constexpr |
Changes the number of elements stored, filling new elements with the specified value.
new_size | The new size. |
value | The value to fill new elements with. |
Definition at line 865 of file buffer_adaptor.hpp.
|
constexpr |
Requests the removal of unused capacity.
Definition at line 696 of file buffer_adaptor.hpp.
|
nodiscardconstexprnoexcept |
Returns the number of elements that can be held in currently allocated storage.
Definition at line 653 of file buffer_adaptor.hpp.
|
staticconstexpr |
Definition at line 66 of file buffer_adaptor.hpp.