70 const T* list_data = std::data(l);
71 for (std::size_t i = 0; i < l.size(); ++i) {
96 std::copy(d.begin(), d.end(),
begin());
107 std::copy(d.begin(), d.end(),
begin());
175 void resize(std::size_t new_size)
noexcept {
190 void resize(std::size_t new_size,
const T& v)
noexcept {
241 [[nodiscard]]
const T&
first() const noexcept {
248 [[nodiscard]] T&
back() noexcept {
255 [[nodiscard]]
const T&
back() const noexcept {
263 void fill(
const T& v)
noexcept {
272 [[nodiscard]] T *
at(std::size_t i)
noexcept {
283 [[nodiscard]] T
const *
at(std::size_t i)
const noexcept {
Main namespace of the library.
Definition: basic_types.hpp:50
Wrapper of a C array for autmatic deallocation of memory.
Definition: data_array.hpp:59
data_array(data_array &&d) noexcept
Move constructor.
Definition: data_array.hpp:113
T * at(std::size_t i) noexcept
Pointer at a specific location of the array.
Definition: data_array.hpp:272
T * m_data
Pointer to the memory allocated by this array.
Definition: data_array.hpp:309
T & first() noexcept
Non-constant reference to the first element in the array.
Definition: data_array.hpp:234
data_array() noexcept=default
Default constructor.
data_array(const std::size_t n) noexcept
Constructor with size.
Definition: data_array.hpp:82
const T & back() const noexcept
Constant reference to the first element in the array.
Definition: data_array.hpp:255
const T & first() const noexcept
Constant reference to the first element in the array.
Definition: data_array.hpp:241
void fill(const T &v) noexcept
Assign the same value to every element in the data.
Definition: data_array.hpp:263
data_array & operator=(const data_array &d) noexcept
Copy assignment operator.
Definition: data_array.hpp:100
data_array(const std::size_t n, const T &v) noexcept
Constructor with size.
Definition: data_array.hpp:90
std::size_t size() const noexcept
Size of the array.
Definition: data_array.hpp:204
T & operator[](const std::size_t i) noexcept
Element at position i.
Definition: data_array.hpp:213
void resize(std::size_t new_size, const T &v) noexcept
Resize-initialize the array.
Definition: data_array.hpp:190
void alloc_data() noexcept
Definition: data_array.hpp:303
T const * at(std::size_t i) const noexcept
Pointer at a specific location of the array.
Definition: data_array.hpp:283
void resize(std::size_t new_size) noexcept
Resize the array.
Definition: data_array.hpp:175
void clear() noexcept
Clear the contents of the array.
Definition: data_array.hpp:162
T & back() noexcept
Non-constant reference to the last element in the array.
Definition: data_array.hpp:248
T * end() noexcept
Non-constant raw pointer to last+1 element.
Definition: data_array.hpp:293
std::size_t m_size
The size of this array in number of elements.
Definition: data_array.hpp:311
T const * begin() const noexcept
Constant raw pointer to first element.
Definition: data_array.hpp:296
data_array(const data_array &d) noexcept
Copy constructor.
Definition: data_array.hpp:94
T * begin() noexcept
Non-constant raw pointer to first element.
Definition: data_array.hpp:291
T const * end() const noexcept
Constant raw pointer to last+1 element.
Definition: data_array.hpp:298
~data_array() noexcept
Destructor.
Definition: data_array.hpp:157