Differential D3094 Diff 14018 ps/trunk/libraries/source/spidermonkey/include-win32-debug/mozilla/Array.h
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/libraries/source/spidermonkey/include-win32-debug/mozilla/Array.h
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | ||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */ | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ | ||||
/* This Source Code Form is subject to the terms of the Mozilla Public | /* This Source Code Form is subject to the terms of the Mozilla Public | ||||
* License, v. 2.0. If a copy of the MPL was not distributed with this | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||||
/* A compile-time constant-length array with bounds-checking assertions. */ | /* A compile-time constant-length array with bounds-checking assertions. */ | ||||
#ifndef mozilla_Array_h | #ifndef mozilla_Array_h | ||||
#define mozilla_Array_h | #define mozilla_Array_h | ||||
#include "mozilla/Assertions.h" | #include "mozilla/Assertions.h" | ||||
#include "mozilla/Attributes.h" | #include "mozilla/Attributes.h" | ||||
#include "mozilla/Move.h" | |||||
#include "mozilla/ReverseIterator.h" | #include "mozilla/ReverseIterator.h" | ||||
#include <stddef.h> | #include <stddef.h> | ||||
namespace mozilla { | namespace mozilla { | ||||
template<typename T, size_t Length> | template<typename T, size_t Length> | ||||
class Array | class Array | ||||
{ | { | ||||
T mArr[Length]; | T mArr[Length]; | ||||
public: | public: | ||||
Array() {} | |||||
template <typename... Args> | |||||
MOZ_IMPLICIT Array(Args&&... aArgs) | |||||
: mArr{mozilla::Forward<Args>(aArgs)...} | |||||
{ | |||||
static_assert(sizeof...(aArgs) == Length, | |||||
"The number of arguments should be equal to the template parameter Length"); | |||||
} | |||||
T& operator[](size_t aIndex) | T& operator[](size_t aIndex) | ||||
{ | { | ||||
MOZ_ASSERT(aIndex < Length); | MOZ_ASSERT(aIndex < Length); | ||||
return mArr[aIndex]; | return mArr[aIndex]; | ||||
} | } | ||||
const T& operator[](size_t aIndex) const | const T& operator[](size_t aIndex) const | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator