/* * (C) Copyright 2013 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation * nor does it submit to any jurisdiction. */ #pragma once #include #include #include #include "atlas/library/config.h" //------------------------------------------------------------------------------------------------------ namespace atlas { namespace array { class ArrayAlignment { public: ArrayAlignment(): alignment_(1) {} ArrayAlignment(int alignment): alignment_(alignment) {} operator int() const { return alignment_; } private: int alignment_; }; class ArrayShape : public std::vector { private: using Base = std::vector; public: ArrayShape() {} ArrayShape(Base&& base): Base(std::forward(base)) {} ArrayShape(std::initializer_list list): Base(list) {} template ArrayShape(idx_t data[], size_t size): Base(data, data + size) {} template ArrayShape(const std::array& list): Base(list.begin(), list.end()) {} template ArrayShape(const std::vector& list): Base(list.begin(), list.end()) {} }; namespace detail { template inline ArrayShape make_shape(Int size1) { return ArrayShape{static_cast(size1)}; } template inline ArrayShape make_shape(Int1 size1, Int2 size2) { return ArrayShape{static_cast(size1), static_cast(size2)}; } template inline ArrayShape make_shape(Int1 size1, Int2 size2, Int3 size3) { return ArrayShape{static_cast(size1), static_cast(size2), static_cast(size3)}; } template inline ArrayShape make_shape(Int1 size1, Int2 size2, Int3 size3, Int4 size4) { return ArrayShape{static_cast(size1), static_cast(size2), static_cast(size3), static_cast(size4)}; } template inline ArrayShape make_shape(Int1 size1, Int2 size2, Int3 size3, Int4 size4, Int5 size5) { return ArrayShape{static_cast(size1), static_cast(size2), static_cast(size3), static_cast(size4), static_cast(size5)}; } } // namespace detail inline ArrayShape make_shape(std::initializer_list sizes) { return ArrayShape(sizes); } template ArrayShape make_shape(idx_t... indices) { return detail::make_shape(std::forward(indices)...); } //------------------------------------------------------------------------------------------------------ } // namespace array } // namespace atlas