This repository was archived by the owner on Mar 5, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.h
More file actions
44 lines (37 loc) · 1.27 KB
/
array.h
File metadata and controls
44 lines (37 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
#include <array>
#include <cassert>
template <class T, int32_t N>
struct Array : std::array<T, N> {
using reference = typename std::array<T, N>::reference;
using const_reference = typename std::array<T, N>::const_reference;
using size_type = typename std::array<T, N>::size_type;
constexpr int32_t ssize() const;
constexpr reference at(int32_t pos);
constexpr const_reference at(int32_t pos) const;
};
template <class T, int32_t N>
constexpr int32_t Array<T, N>::ssize() const {
auto size = this->size();
assert(size < INT32_MAX);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
return size;
#pragma clang diagnostic pop
}
template <class T, int32_t N>
constexpr typename Array<T, N>::reference Array<T, N>::at(int32_t pos) {
assert(pos >= 0);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
return std::array<T, N>::at(static_cast<size_type>(pos));
#pragma clang diagnostic pop
}
template <class T, int32_t N>
constexpr typename Array<T, N>::const_reference Array<T, N>::at(int32_t pos) const {
assert(pos >= 0);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
return std::array<T, N>::at(static_cast<size_type>(pos));
#pragma clang diagnostic pop
}