cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
indices.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_CONTAINER_INDICES_H
4#define pRC_CORE_CONTAINER_INDICES_H
5
7
8namespace pRC
9{
10 template<class... Is, If<All<IsConvertible<Is, Index>...>> = 0>
11 Indices(Is const...) -> Indices<sizeof...(Is)>;
12
13 template<Size N>
14 class Indices
15 {
16 public:
17 static constexpr auto size()
18 {
19 return N;
20 }
21
22 public:
23 ~Indices() = default;
24 constexpr Indices() = default;
25 constexpr Indices(Indices const &) = default;
26 constexpr Indices(Indices &&) = default;
27 constexpr Indices &operator=(Indices const &) & = default;
28 constexpr Indices &operator=(Indices &&) & = default;
29
30 template<class... Is, If<All<IsConvertible<Is, Index>...>> = 0,
31 If<IsSatisfied<(sizeof...(Is) == N)>> = 0>
32 constexpr Indices(Is const... indices)
33 : mIndices(indices...)
34 {
35 }
36
37 constexpr decltype(auto) operator[](Index const dimension) &&
38 {
39 return move(mIndices)[dimension];
40 }
41
42 constexpr decltype(auto) operator[](Index const dimension) const &&
43 {
44 return move(mIndices)[dimension];
45 }
46
47 constexpr decltype(auto) operator[](Index const dimension) &
48 {
49 return mIndices[dimension];
50 }
51
52 constexpr decltype(auto) operator[](Index const dimension) const &
53 {
54 return mIndices[dimension];
55 }
56
57 private:
58 BEGIN_IGNORE_DIAGNOSTIC_GCC("-Wpedantic")
59 StackArray<Index, N> const mIndices = {};
61 };
62}
63#endif // pRC_CORE_CONTAINER_INDICES_H
Definition type_traits.hpp:49
Definition indices.hpp:15
constexpr Indices & operator=(Indices const &) &=default
static constexpr auto size()
Definition indices.hpp:17
constexpr Indices(Indices &&)=default
constexpr Indices & operator=(Indices &&) &=default
constexpr Indices(Is const ... indices)
Definition indices.hpp:32
constexpr Indices()=default
~Indices()=default
constexpr Indices(Indices const &)=default
Definition cholesky.hpp:18
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
Size Index
Definition type_traits.hpp:21
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
Indices(Is const ...) -> Indices< sizeof...(Is)>
Constant< Bool, B > IsSatisfied
Definition type_traits.hpp:71
#define BEGIN_IGNORE_DIAGNOSTIC_GCC(warning)
Definition pragma.hpp:42
#define END_IGNORE_DIAGNOSTIC_GCC
Definition pragma.hpp:43