mfbt/Array.h
author Gaia Pushbot <release+gaiajson@mozilla.com>
Mon, 06 Jan 2014 18:55:25 -0800
changeset 179251 3a37244033093d342ff83a7cdc1e85b8b732eff3
parent 152848 f55906cadf07a9ef44cc4ce2574fe35f3dc85672
child 202609 e69f4a011613aac0afae6ec1eeb64f3528caf4a6
permissions -rw-r--r--
Bumping gaia.json for 4 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/2860f076e014 Author: John Hu <johu@mozilla.com> Desc: Merge pull request #15054 from huchengtw-moz/video/Bug_915039-no-string-change Bug 915039 - [Video] There is no easy way to navigate back to the activi...,r=djf ======== https://hg.mozilla.org/integration/gaia-central/rev/4657e4f9e26f Author: John Hu <johu@mozilla.com> Desc: Bug 915039 - [Video] There is no easy way to navigate back to the activity caller if the library is empty ======== https://hg.mozilla.org/integration/gaia-central/rev/9ef07f058573 Author: John Hu <johu@mozilla.com> Desc: Merge pull request #15053 from huchengtw-moz/video/Bug_915039_revert Revert "Merge pull request #14745 from huchengtw-moz/video/Bug_915039_ad... ======== https://hg.mozilla.org/integration/gaia-central/rev/0cbfbd2b1343 Author: John Hu <johu@mozilla.com> Desc: Revert "Merge pull request #14745 from huchengtw-moz/video/Bug_915039_add_cancel_button" This reverts commit a523c1ee4130a7883981924f8e68fb94be02428a, reversing changes made to 83688a4f70774f1f96f4621f781024fcc925bce9.

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* A compile-time constant-length array with bounds-checking assertions. */

#ifndef mozilla_Array_h
#define mozilla_Array_h

#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"

#include <stddef.h>

namespace mozilla {

template<typename T, size_t Length>
class Array
{
    T arr[Length];

  public:
    T& operator[](size_t i) {
      MOZ_ASSERT(i < Length);
      return arr[i];
    }

    const T& operator[](size_t i) const {
      MOZ_ASSERT(i < Length);
      return arr[i];
    }
};

template<typename T>
class Array<T, 0>
{
  public:
    T& operator[](size_t i) {
      MOZ_ASSUME_UNREACHABLE("indexing into zero-length array");
    }

    const T& operator[](size_t i) const {
      MOZ_ASSUME_UNREACHABLE("indexing into zero-length array");
    }
};

}  /* namespace mozilla */

#endif /* mozilla_Array_h */