зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1374629 - Ensure that mozilla::NotNull has zero space overhead. r=njn
MozReview-Commit-ID: 9Bo2qxd3HRv --HG-- extra : rebase_source : e35aec9978f13092d91141955effb0942e84e70c
This commit is contained in:
Родитель
bdc7c83579
Коммит
5480e54c73
|
@ -63,6 +63,7 @@
|
|||
// for the last one, where the handle type is |void|. See below.
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include <stddef.h>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -114,7 +115,12 @@ public:
|
|||
|
||||
// Construct/assign from another NotNull with a compatible base pointer type.
|
||||
template <typename U>
|
||||
MOZ_IMPLICIT NotNull(const NotNull<U>& aOther) : mBasePtr(aOther.get()) {}
|
||||
MOZ_IMPLICIT NotNull(const NotNull<U>& aOther) : mBasePtr(aOther.get()) {
|
||||
static_assert(sizeof(T) == sizeof(NotNull<T>),
|
||||
"NotNull must have zero space overhead.");
|
||||
static_assert(offsetof(NotNull<T>, mBasePtr) == 0,
|
||||
"mBasePtr must have zero offset.");
|
||||
}
|
||||
|
||||
// Default copy/move construction and assignment.
|
||||
NotNull(const NotNull<T>&) = default;
|
||||
|
|
Загрузка…
Ссылка в новой задаче