1d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry#ifndef _DEARRAYUTIL_HPP 2d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry#define _DEARRAYUTIL_HPP 3d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry/*------------------------------------------------------------------------- 4d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * drawElements C++ Base Library 5d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * ----------------------------- 6d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * 7d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * Copyright 2015 The Android Open Source Project 8d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * 9d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * Licensed under the Apache License, Version 2.0 (the "License"); 10d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * you may not use this file except in compliance with the License. 11d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * You may obtain a copy of the License at 12d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * 13d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * http://www.apache.org/licenses/LICENSE-2.0 14d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * 15d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * Unless required by applicable law or agreed to in writing, software 16d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * distributed under the License is distributed on an "AS IS" BASIS, 17d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * See the License for the specific language governing permissions and 19d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * limitations under the License. 20d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * 21d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry *//*! 22d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * \file 23d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry * \brief Array utils 24d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry *//*--------------------------------------------------------------------*/ 25d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry 26d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry#include "deDefs.hpp" 276b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyry#include "deMeta.hpp" 28d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry 29d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyrynamespace de 30d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry{ 31d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry 32d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry//! Get an element of an array with a specified size. 33d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyrytemplate <int LastElementIndex, int Size, typename Elem> 346b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyryconst Elem& getSizedArrayElement (const Elem (&array)[Size], typename de::meta::EnableIf<int, LastElementIndex==Size>::Type offset) 35d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry{ 36d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry DE_ASSERT(inBounds(offset, 0, Size)); 37d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry return array[offset]; 38d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry} 39d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry 40d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry//! Get an element of an array with a compile-time constant size. 41d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyrytemplate <int Size, typename Elem> 42d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyryconst Elem& getArrayElement (const Elem (&array)[Size], int offset) 43d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry{ 44d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry DE_ASSERT(inBounds(offset, 0, Size)); 45d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry return array[offset]; 46d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry} 47d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry 48d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry} // de 49d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry 50d6148171f88da1301f053e2e0236afc69416137cJarkko Pöyry#endif // _DEARRAYUTIL_HPP 51