Debian Codegraph @

src/atlas/array/ArrayLayout.h

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 #pragma once
12
13 #include <cstddef>
14 #include <initializer_list>
15 #include <vector>
16
17 //------------------------------------------------------------------------------------------------------
18
19 namespace atlas {
20 namespace array {
21
22 class ArrayLayout : public std::vector<idx_t> {
23 private:
24 using Base = std::vector<idx_t>;
25
26 public:
27 ArrayLayout() {}
28 ArrayLayout(std::initializer_list<idx_t> list): Base(list) {}
29 ArrayLayout(Base&& base): Base(std::forward<Base>(base)) {}
30 };
31
32 namespace detail {
33
34 inline ArrayLayout make_layout(idx_t size1) {
35 return ArrayLayout{size1};
36 }
37 inline ArrayLayout make_layout(idx_t size1, idx_t size2) {
38 return ArrayLayout{size1, size2};
39 }
40 inline ArrayLayout make_layout(idx_t size1, idx_t size2, idx_t size3) {
41 return ArrayLayout{size1, size2, size3};
42 }
43 inline ArrayLayout make_layout(idx_t size1, idx_t size2, idx_t size3, idx_t size4) {
44 return ArrayLayout{size1, size2, size3, size4};
45 }
46 inline ArrayLayout make_layout(idx_t size1, idx_t size2, idx_t size3, idx_t size4, idx_t size5) {
47 return ArrayLayout{size1, size2, size3, size4, size5};
48 }
49
50 } // namespace detail
51
52 template <typename... idx_t>
53 ArrayLayout make_layout(idx_t... indices) {
54 return detail::make_layout(std::forward<idx_t>(indices)...);
55 }
56
57
58 //------------------------------------------------------------------------------------------------------
59
60 } // namespace array
61 } // namespace atlas