cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
array_scalar.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_CONTAINER_ARRAY_SCALAR_H
4#define pRC_CORE_CONTAINER_ARRAY_SCALAR_H
5
10
11namespace pRC
12{
13 template<Allocation A, class T>
14 class CommonArray<A, T>
15 {
16 public:
17 static constexpr auto Allocation = A;
18 using Type = T;
20
21 static constexpr auto Dimension = Sizes::Dimension;
22
23 static constexpr auto size()
24 {
25 return Sizes::size();
26 }
27
28 static constexpr auto size(Index const dimension) = delete;
29
30 static constexpr auto indexToSubscripts(Index const index)
31 {
32 return Subscripts<>(index);
33 }
34
35 static constexpr auto subscriptsToIndex()
36 {
37 return Index(Subscripts<>());
38 }
39
40 static constexpr auto subscriptsToIndex(Subscripts<> const &subscripts)
41 {
42 return Index(subscripts);
43 }
44
45 public:
46 ~CommonArray() = default;
47 constexpr CommonArray() = default;
48
49 constexpr CommonArray(CommonArray const &) = default;
50 constexpr CommonArray(CommonArray &&) = default;
51
52 template<pRC::Allocation B, IsConvertible<T> R>
53 constexpr CommonArray(CommonArray<B, R> const &other)
54 {
55 *this = other;
56 }
57
58 template<class X>
60 constexpr CommonArray(X &&value)
61 : mData(forward<X>(value))
62 {
63 }
64
65 constexpr CommonArray &operator=(CommonArray const &) & = default;
66 constexpr CommonArray &operator=(CommonArray &&) & = default;
67
68 template<pRC::Allocation B, IsConvertible<T> R>
69 constexpr auto &operator=(CommonArray<B, R> const &rhs) &
70 {
71 operator()() = rhs();
72 return *this;
73 }
74
75 template<class X>
77 constexpr auto &operator=(X &&value) &
78 {
79 operator()() = forward<X>(value);
80 return *this;
81 }
82
83 constexpr decltype(auto) operator()() &&
84 {
85 return move(*this)[0];
86 }
87
88 constexpr decltype(auto) operator()() const &&
89 {
90 return move(*this)[0];
91 }
92
93 constexpr decltype(auto) operator()() &
94 {
95 return operator[](0);
96 }
97
98 constexpr decltype(auto) operator()() const &
99 {
100 return operator[](0);
101 }
102
103 constexpr decltype(auto) operator()(Subscripts<> const &) &&
104 {
105 return move(*this)();
106 }
107
108 constexpr decltype(auto) operator()(Subscripts<> const &) const &&
109 {
110 return move(*this)();
111 }
112
113 constexpr decltype(auto) operator()(Subscripts<> const &) &
114 {
115 return operator()();
116 }
117
118 constexpr decltype(auto) operator()(Subscripts<> const &) const &
119 {
120 return operator()();
121 }
122
123 constexpr decltype(auto) operator[](Index const index) &&
124 {
125 return move(mData)[index];
126 }
127
128 constexpr decltype(auto) operator[](Index const index) const &&
129 {
130 return move(mData)[index];
131 }
132
133 constexpr decltype(auto) operator[](Index const index) &
134 {
135 return mData[index];
136 }
137
138 constexpr decltype(auto) operator[](Index const index) const &
139 {
140 return mData[index];
141 }
142
143 constexpr auto data() && = delete;
144 constexpr auto data() const && = delete;
145
146 constexpr auto data() &
147 {
148 return mData.data();
149 }
150
151 constexpr auto data() const &
152 {
153 return mData.data();
154 }
155
156 private:
158 };
159}
160#endif // pRC_CORE_CONTAINER_ARRAY_SCALAR_H
constexpr auto data() const &&=delete
static constexpr auto size()
Definition array_scalar.hpp:23
constexpr auto & operator=(CommonArray< B, R > const &rhs) &
Definition array_scalar.hpp:69
constexpr auto & operator=(X &&value) &
Definition array_scalar.hpp:77
static constexpr auto subscriptsToIndex()
Definition array_scalar.hpp:35
constexpr auto data() &&=delete
static constexpr auto indexToSubscripts(Index const index)
Definition array_scalar.hpp:30
static constexpr auto subscriptsToIndex(Subscripts<> const &subscripts)
Definition array_scalar.hpp:40
constexpr CommonArray & operator=(CommonArray &&) &=default
static constexpr auto size(Index const dimension)=delete
constexpr CommonArray(CommonArray const &)=default
constexpr CommonArray & operator=(CommonArray const &) &=default
constexpr CommonArray(CommonArray &&)=default
constexpr CommonArray()=default
constexpr auto data() const &
Definition array_scalar.hpp:151
constexpr CommonArray(CommonArray< B, R > const &other)
Definition array_scalar.hpp:53
constexpr CommonArray(X &&value)
Definition array_scalar.hpp:60
Definition declarations.hpp:12
Definition value.hpp:12
Definition sequence.hpp:29
static constexpr Size Dimension
Definition sequence.hpp:47
static constexpr auto size()
Definition sequence.hpp:69
Definition subscripts.hpp:21
Definition concepts.hpp:37
pRC::Float<> T
Definition externs_nonTT.hpp:1
int value
Definition gmock-actions_test.cc:1714
Definition cholesky.hpp:10
Size Index
Definition basics.hpp:32
Allocation
Definition allocation.hpp:18