Bug 1449132 [wpt PR 10194] - [css-grid] Fix resolution of percentage paddings and...
[gecko.git] / mfbt / Opaque.h
blobd7239ee7c23e7ebab92b206bc9115aa70e7f9fa0
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 /* An opaque integral type supporting only comparison operators. */
9 #ifndef mozilla_Opaque_h
10 #define mozilla_Opaque_h
12 #include "mozilla/TypeTraits.h"
14 namespace mozilla {
16 /**
17 * Opaque<T> is a replacement for integral T in cases where only comparisons
18 * must be supported, and it's desirable to prevent accidental dependency on
19 * exact values.
21 template<typename T>
22 class Opaque final
24 static_assert(mozilla::IsIntegral<T>::value,
25 "mozilla::Opaque only supports integral types");
27 T mValue;
29 public:
30 Opaque() {}
31 explicit Opaque(T aValue) : mValue(aValue) {}
33 bool operator==(const Opaque& aOther) const {
34 return mValue == aOther.mValue;
37 bool operator!=(const Opaque& aOther) const {
38 return !(*this == aOther);
42 } // namespace mozilla
44 #endif /* mozilla_Opaque_h */