open-cpp-utils 0.0.1
Loading...
Searching...
No Matches
array.h
1//
2// Created by Maddie on 7/25/2024.
3//
4
5#ifndef ARRAY_H
6#define ARRAY_H
7
8#include "template_utils.h"
9
10#include <stdint.h>
11
12#include <array>
13
14namespace open_cpp_utils
15{
16
17// =====================================================================================================================
18// Forward Definitions
19// =====================================================================================================================
20template<typename T, size_t N> struct fixed_array;
21template<typename T, size_t N> class dyn_array;
22template<typename T, size_t N> using array = fixed_array<T, N>;
23
24
25// =====================================================================================================================
26// Fixed Array
27// =====================================================================================================================
28
34template<typename T, size_t N>
35struct fixed_array<T, N>
36{
37// Typedefs ============================================================================================================
38
39public:
40 using value_type = T;
41 using array_type = value_type[N];
42 using size_type = size_t;
43
44// Functions ===========================================================================================================
45
46public:
47
48// Constructors & Destructor -------------------------------------------------------------------------------------------
49
50 constexpr fixed_array() : data_{ T() } {}
51 constexpr fixed_array(const fixed_array& array) : data_{ array.data_ } {}
52 constexpr fixed_array(const array_type& data) : data_{ data } {}
53
54 constexpr size_type size() { return N; }
55
56
57// Variables ===========================================================================================================
58
59private:
60 array_type data_;
61
62};
63
64}
65
66
67#endif //ARRAY_H
Definition array.h:21
Wrapper for array of type T with fixed length N.
Definition array.h:36
Definition array.h:20
Provides compile time evaluation utilities for templates and template packs.