Clingo
|
An immutable array with efficient copying. More...
#include <immutable_array.hh>
Public Member Functions | |
constexpr | immutable_array () noexcept=default |
Construct an empty array. | |
immutable_array (immutable_array const &other) noexcept=default | |
Copy construct the array. | |
immutable_array (immutable_array &&other) noexcept=default | |
Move construct the array. | |
auto | operator= (immutable_array const &other) noexcept -> immutable_array &=default |
Copy assign the array. | |
auto | operator= (immutable_array &&other) noexcept -> immutable_array &=default |
Move assign the array. | |
immutable_array (std::span< T > span) | |
Construct array copying values from the given span. | |
immutable_array (std::span< T const > span) | |
Construct array copying values from the given span. | |
immutable_array (std::vector< T > &&vec) | |
Construct array taking ownership of the given vector. | |
immutable_array (std::vector< T > const &vec) | |
Construct array copying from the given vector. | |
immutable_array (std::initializer_list< T > init) | |
Construct array coping from the given initializer list. | |
template<class It > | |
immutable_array (It first, It last) | |
Construct array coping from the given iterator range. | |
template<class It , class Pred > | |
immutable_array (It first, It last, Pred conv) | |
Construct array coping from the given iterator range. | |
auto | at (size_type pos) const -> const_reference |
Get the element at the given index. | |
auto | operator[] (size_type pos) const -> const_reference |
Get the element at the given index. | |
auto | front () const -> const_reference |
Get a reference to the first element. | |
auto | back () const -> const_reference |
Get a reference to the last element. | |
auto | data () const -> T const * |
Get a pointer to the undelying data. | |
auto | begin () const noexcept -> const_iterator |
Get an iterator pointing to the beginning of the array. | |
auto | end () const noexcept -> const_iterator |
Get an iterator pointing to the end of the array. | |
auto | empty () const noexcept -> bool |
Check if the array is empty. | |
auto | size () const noexcept -> size_type |
Get the size of the array. | |
void | swap (immutable_array &other) noexcept |
Swap two immutable arrays. | |
Friends | |
auto | operator== (immutable_array const &lhs, immutable_array const &rhs) -> bool |
Compare two vectors. | |
auto | operator<=> (immutable_array const &lhs, immutable_array const &rhs) |
Compare two vectors lexicographically. | |
An immutable array with efficient copying.
Note that this can be implemented more efficiently avoiding the double indirection.
|
inline |
Construct array taking ownership of the given vector.
Note that this might change in case the data type is implemented differently.
|
inline |
Get the element at the given index.
Throws in case the index is to large.