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
14
namespace
open_cpp_utils
15
{
16
17
// =====================================================================================================================
18
// Forward Definitions
19
// =====================================================================================================================
20
template
<
typename
T,
size_t
N>
struct
fixed_array
;
21
template
<
typename
T,
size_t
N>
class
dyn_array
;
22
template
<
typename
T,
size_t
N>
using
array
=
fixed_array<T, N>
;
23
24
25
// =====================================================================================================================
26
// Fixed Array
27
// =====================================================================================================================
28
34
template
<
typename
T,
size_t
N>
35
struct
fixed_array
<T, N>
36
{
37
// Typedefs ============================================================================================================
38
39
public
:
40
using
value_type = T;
41
using
array_type = value_type[N];
42
using
size_type = size_t;
43
44
// Functions ===========================================================================================================
45
46
public
:
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
59
private
:
60
array_type data_;
61
62
};
63
64
}
65
66
67
#endif
//ARRAY_H
open_cpp_utils::dyn_array
Definition
array.h:21
open_cpp_utils::fixed_array< T, N >
Wrapper for array of type T with fixed length N.
Definition
array.h:36
open_cpp_utils::fixed_array
Definition
array.h:20
template_utils.h
Provides compile time evaluation utilities for templates and template packs.
Generated by
1.10.0