|
JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
|
POD-compatible fixed-size array, similar in shape to std::array, but simpler and fully POD.
More...
#include <jh/pods/array.h>
Public Types | |
| using | value_type = T |
| Value type alias. | |
| using | size_type = std::uint16_t |
| Size type alias (16-bit). | |
| using | difference_type = std::ptrdiff_t |
| Difference type alias. | |
| using | reference = value_type & |
| Reference type. | |
| using | const_reference = const value_type & |
| Const reference type. | |
| using | pointer = value_type * |
| Pointer type. | |
| using | const_pointer = const value_type * |
| Const pointer type. | |
Public Member Functions | |
| constexpr reference | operator[] (std::size_t i) noexcept |
| Access element by index (no bounds checking). | |
| constexpr const_reference | operator[] (std::size_t i) const noexcept |
| Access element by index (const, no bounds checking). | |
| constexpr pointer | begin () noexcept |
| Get pointer to beginning of array. | |
| constexpr const_pointer | begin () const noexcept |
| Get const pointer to beginning of array. | |
| constexpr pointer | end () noexcept |
| Get pointer to end of array (one past last element). | |
| constexpr const_pointer | end () const noexcept |
| Get const pointer to end of array (one past last element). | |
| constexpr bool | operator== (const array &) const =default |
| Compare two arrays for equality (element-wise). | |
Static Public Member Functions | |
| static constexpr size_type | size () noexcept |
| Return the number of elements in the array. | |
Public Attributes | |
| T | data [N] |
| Inline contiguous storage for N elements of type T. | |
POD-compatible fixed-size array, similar in shape to std::array, but simpler and fully POD.
| T | Element type. Must satisfy pod_like<T> and must be free of const/volatile qualifiers (i.e. satisfy cv_free_pod_like<T>). Using const T or volatile T would make the array itself non-POD due to loss of trivial assignment and copy semantics. |
| N | Number of elements. Total memory (sizeof(T) * N) must not exceed 16KB. |
This structure is designed for:
jh::runtime_arr, arena) placement-new, mmap, .data segments) T data[N]) operator[], range-based for-loops, == comparison std::array. It has: .at(), .fill(), .swap() helpers