/* * (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 ArrayStrides : public std::vector { private: using Base = std::vector; public: ArrayStrides() {} ArrayStrides(std::initializer_list list): Base(list) {} ArrayStrides(Base&& base): Base(std::forward(base)) {} }; namespace detail { template inline ArrayStrides make_strides(Int size1) { return ArrayStrides{static_cast(size1)}; } template inline ArrayStrides make_strides(Int1 size1, Int2 size2) { return ArrayStrides{static_cast(size1), static_cast(size2)}; } template inline ArrayStrides make_strides(Int1 size1, Int2 size2, Int3 size3) { return ArrayStrides{static_cast(size1), static_cast(size2), static_cast(size3)}; } template inline ArrayStrides make_strides(Int1 size1, Int2 size2, Int3 size3, Int4 size4) { return ArrayStrides{static_cast(size1), static_cast(size2), static_cast(size3), static_cast(size4)}; } template inline ArrayStrides make_strides(Int1 size1, Int2 size2, Int3 size3, Int4 size4, Int5 size5) { return ArrayStrides{static_cast(size1), static_cast(size2), static_cast(size3), static_cast(size4), static_cast(size5)}; } } // namespace detail inline ArrayStrides make_strides(std::initializer_list sizes) { return ArrayStrides(sizes); } template ArrayStrides make_strides(idx_t... indices) { return detail::make_strides(std::forward(indices)...); } //------------------------------------------------------------------------------------------------------ } // namespace array } // namespace atlas