gecko-dev/mfbt
Nicholas Nethercote b3d842431f Bug 1272203 (part 1) - Add mozilla::NotNull to MFBT. r=froydnj.
This patch implements mozilla::NotNull, which is similar but not identicial to
gsl::not_null.

The current draft(?) implementation of gsl::not_null is at
https://github.com/Microsoft/GSL/blob/master/include/gsl.h.

The main difference is that not_null allows implicit conversion from T to
not_null<T>. In contrast, NotNull only allows explicit conversion from T to
NotNull<T> via WrapNotNull().

The rationale for this is that when converting from a less-constrained type to
a more constrained type, implicit conversion is undesirable. For example, if I
changed a function f from this:

  f(int* aPtr);

to this:

  f(gsl::not_null<int*> aPtr);

no call sites would have to be modified. But if I changed it to this:

  f(mozilla::NotNull<int*> aPtr);

call sites *would* need to be modified. This is a good thing! It forces the
author to audit the call sites for non-nullness, and encourages them to
back-propagate NotNull throughout the code.

The other difference between not_null and NotNull is that not_null disables
pointer arithmetic, which means it cannot be used with array pointers. I have
not implemented this restriction for NotNull because it seems arbitrary and
unnecessary.
2016-05-12 14:21:16 +10:00
..
decimal
double-conversion
staticruntime
tests Bug 1272203 (part 1) - Add mozilla::NotNull to MFBT. r=froydnj. 2016-05-12 14:21:16 +10:00
Alignment.h Bug 1269319 - Make AlignedStorage/AlignedStorage2 non-copyable to fix strict aliasing issues. r=Waldo 2016-05-19 20:57:36 +02:00
AllocPolicy.h Bug 1262671 - Introduce MFBT BufferList class (r=froydnj) 2016-05-27 09:57:40 -07:00
AlreadyAddRefed.h Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj. 2016-04-27 14:16:50 +10:00
Array.h
ArrayUtils.h
Assertions.h Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj. 2016-04-27 14:16:50 +10:00
Atomics.h
Attributes.h Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj. 2016-04-27 14:16:50 +10:00
BinarySearch.h
BloomFilter.h
BufferList.h Bug 1262671 - Introduce MFBT BufferList class (r=froydnj) 2016-05-27 09:57:40 -07:00
Casting.h
ChaosMode.cpp
ChaosMode.h
Char16.h
CheckedInt.h
Compiler.h
Compression.cpp
Compression.h Bug 1268754 - Tweak some MFBT return values. r=Ms2ger. 2016-04-29 13:14:34 +10:00
DebugOnly.h
EndianUtils.h Bug 1275016 - Rename Endian.h to EndianUtils.h to avoid #include confusion with Android's endian.h stdlib header. r=froydnj 2016-05-22 13:31:11 -07:00
EnumeratedArray.h
EnumeratedRange.h
EnumSet.h
FastBernoulliTrial.h
FloatingPoint.cpp
FloatingPoint.h Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj. 2016-04-27 14:16:50 +10:00
Function.h
GuardObjects.h
HashFunctions.cpp
HashFunctions.h Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj. 2016-04-27 14:16:50 +10:00
IndexSequence.h
InitializerList.h
IntegerPrintfMacros.h
IntegerRange.h
IntegerTypeTraits.h
JSONWriter.cpp
JSONWriter.h
Likely.h
LinkedList.h
LinuxSignal.h
lz4.c
lz4.h
MacroArgs.h
MacroForEach.h
MathAlgorithms.h Bug 1271972: wasm: Implement i64.ctz, i64.clz, i64.popcount; r=sunfish 2016-05-11 19:00:53 +02:00
Maybe.h
MaybeOneOf.h
MemoryChecking.h
MemoryReporting.h
Move.h
moz.build Bug 1272203 (part 1) - Add mozilla::NotNull to MFBT. r=froydnj. 2016-05-12 14:21:16 +10:00
NotNull.h Bug 1272203 (part 1) - Add mozilla::NotNull to MFBT. r=froydnj. 2016-05-12 14:21:16 +10:00
NullPtr.h
NumericLimits.h
objs.mozbuild
Opaque.h
Pair.h
PodOperations.h
Poison.cpp
Poison.h Bug 1268246 - Add a simple Poison class lifetime checker. r=froydnj 2016-04-29 13:54:54 -04:00
Range.h
RangedArray.h
RangedPtr.h
ReentrancyGuard.h
RefCounted.h
RefCountType.h
RefPtr.h Bug 1269968 - Remove unnecessary deduction on RefPtr.h. r=froydnj 2016-05-03 20:45:00 +02:00
ReverseIterator.h
RollingMean.h
Saturate.h
Scoped.h
ScopeExit.h
SegmentedVector.h Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj. 2016-04-27 14:16:50 +10:00
SHA1.cpp Bug 1275016 - Rename Endian.h to EndianUtils.h to avoid #include confusion with Android's endian.h stdlib header. r=froydnj 2016-05-22 13:31:11 -07:00
SHA1.h
SizePrintfMacros.h
Snprintf.h
SplayTree.h Bug 1268754 - Tweak some MFBT return values. r=Ms2ger. 2016-04-29 13:14:34 +10:00
STYLE
TaggedAnonymousMemory.cpp
TaggedAnonymousMemory.h
TemplateLib.h
ThreadLocal.h Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj. 2016-04-27 14:16:50 +10:00
ToString.h
Tuple.h
TypedEnumBits.h
Types.h
TypeTraits.h
UniquePtr.h Bug 1267550 (part 2) - Rename MOZ_WARN_UNUSED_RESULT as MOZ_MUST_USE. r=froydnj. 2016-04-27 14:16:50 +10:00
UniquePtrExtensions.h
unused.cpp
unused.h
Variant.h Bug 1209227 - Part 2: Mark mfbt::Variant as MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS, r=froydnj 2016-05-19 09:34:01 -04:00
Vector.h Bug 1271022 - add Vector::podResizeToFit (r=njn) 2016-05-09 08:59:10 -05:00
WeakPtr.h
WindowsVersion.h
XorShift128PlusRNG.h