17 #ifndef ASTRA_ARRAY_HPP
18 #define ASTRA_ARRAY_HPP
34 inline Array() : ptr_(nullptr), size_(0) {}
36 inline Array(decltype(
nullptr)) : ptr_(nullptr), size_(0) {}
43 inline size_t size()
const {
return size_; }
45 inline bool empty()
const {
return size_ == 0; }
48 inline T*
data() {
return ptr_; }
50 inline const T*
data()
const {
return ptr_; }
53 inline T*
begin() {
return ptr_; }
55 inline const T*
begin()
const {
return ptr_; }
57 inline T*
end() {
return ptr_ + size_; }
59 inline const T*
end()
const {
return ptr_ + size_; }
62 inline T&
front() {
return *ptr_; }
64 inline const T&
front()
const {
return *ptr_; }
66 inline T&
back() {
return ptr_[size_ - 1]; }
68 inline const T&
back()
const {
return ptr_[size_ - 1]; }
112 if (
this == &other) {
return true; }
113 return this->ptr_ == other.ptr_;
Simple wrapper around primitive arrays
Definition: Array.hpp:31
Array(T *ptr, size_t size)
Constructs array from pointer and size
Definition: Array.hpp:38
const T & back() const
Gets immutable reference to last array element
Definition: Array.hpp:68
T * end()
Gets mutable iterator pointing to one past the end of array
Definition: Array.hpp:57
T * begin()
Gets mutable iterator pointing to beginning of array
Definition: Array.hpp:53
Array(T *begin, T *end)
Constructs array from begin and end iterators
Definition: Array.hpp:40
Array< T > slice(size_t start, size_t end)
Creates a mutable sub-array of the same type based on a start and end index
Definition: Array.hpp:93
const T * begin() const
Gets immutable iterator pointing to beginning of array
Definition: Array.hpp:55
Array< const T > slice(size_t start, size_t end) const
Creates an immutable sub-array of the same type based on a start and end index
Definition: Array.hpp:104
Array(decltype(nullptr))
Implicit conversion constructor from nullptr to a zero-length array
Definition: Array.hpp:36
bool operator!=(const Array &other) const
Identity based inequality operator
Definition: Array.hpp:117
const T & front() const
Gets immutable reference to first array element
Definition: Array.hpp:64
size_t size() const
Gets size of array
Definition: Array.hpp:43
const T * data() const
Gets immutable raw pointer to array data
Definition: Array.hpp:50
T * data()
Gets mutable raw pointer to array data
Definition: Array.hpp:48
T & back()
Gets mutable reference to last array element
Definition: Array.hpp:66
bool operator==(const Array &other) const
Identity based equality operator
Definition: Array.hpp:110
bool empty() const
Returns true if array is zero length
Definition: Array.hpp:45
const T & operator[](size_t index) const
Immutable index operator into array
Definition: Array.hpp:83
T & front()
Gets mutable reference to first array element
Definition: Array.hpp:62
Array()
Default constructs zero-length array
Definition: Array.hpp:34
const T * end() const
Gets iterator pointing to one past the end of array
Definition: Array.hpp:59
T & operator[](size_t index)
Mutable index operator into array
Definition: Array.hpp:74
Array< T > make_array(T *ptr, std::size_t size)
Simplifies Array construction by leveraging function template type deduction
Definition: Array.hpp:132