A multidimensional array of numbers that cannot be written through.
More...
#include <vitrio/array/const_array.hpp>
A multidimensional array of numbers that cannot be written through.
It is an array whose elements can only be read: it keeps its memory alive in the same way, and it cannot be copied either. The memory may be read-only, or it may be the memory of an array that is still written through elsewhere.
- See also
- array
-
const_array_ref
◆ const_array() [1/2]
| vitrio::const_array::const_array |
( |
| ) |
|
|
noexcept |
Construct an array that holds nothing.
Its descriptor is not initialized and it has no memory.
◆ const_array() [2/2]
| vitrio::const_array::const_array |
( |
span< const byte > | memory, |
|
|
std::shared_ptr< const void > | owner, |
|
|
array_descriptor | descriptor ) |
Construct an array over memory allocated elsewhere.
The array keeps owner for as long as it or any array sharing its memory lives. Whatever releasing owner does is how the memory is released, so the memory may come from anywhere.
- Parameters
-
| memory | The memory holding the elements. |
| owner | What keeps memory alive. Must not be null. |
| descriptor | How memory is read as an array. |
- Exceptions
-
| std::invalid_argument | If owner is null, if descriptor is not initialized, or if memory is not aligned to the elements. |
| std::out_of_range | If an element descriptor addresses lies outside memory. |
◆ get_data()
| const byte * vitrio::const_array::get_data |
( |
| ) |
const |
|
noexcept |
Get the memory holding the elements.
- Returns
- const byte* The first byte of the memory. The element at the origin is at the offset the descriptor states. Null when the array holds nothing.
◆ get_descriptor()
Get how the memory is read as an array.
- Returns
- const array_descriptor& The descriptor. Not initialized when the array holds nothing.
◆ share()
Make another read-only array over the same memory.
- Returns
- const_array An array with the same descriptor and the same elements.
The documentation for this class was generated from the following file: