Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / js / src / frontend / TypedIndex.h
blobc75d59ae3db8804eebc0a7a4cef2b973be092847
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef frontend_TypedIndex_h
8 #define frontend_TypedIndex_h
10 #include <cstdint>
11 #include <stddef.h>
13 namespace js {
14 namespace frontend {
16 // TypedIndex allows discrimination in variants between different
17 // index types. Used as a typesafe index for various stencil arrays.
18 template <typename Tag>
19 struct TypedIndex {
20 TypedIndex() = default;
21 constexpr explicit TypedIndex(uint32_t index) : index(index){};
23 uint32_t index = 0;
25 // For Vector::operator[]
26 operator size_t() const { return index; }
28 TypedIndex& operator=(size_t idx) {
29 index = idx;
30 return *this;
33 bool operator<(TypedIndex other) const { return index < other.index; }
34 bool operator<=(TypedIndex other) const { return index <= other.index; }
35 bool operator>(TypedIndex other) const { return index > other.index; }
36 bool operator>=(TypedIndex other) const { return index >= other.index; }
39 } // namespace frontend
40 } // namespace js
42 #endif