Open-Source Wikis

/

Gecko

/

Packages and shared libraries

/

mfbt — Mozilla Framework-Based Templates

mozilla/gecko-dev

mfbt — Mozilla Framework-Based Templates

mfbt/ is Mozilla's in-house C++ utility library: the bits that look like the C++ standard library but predate it (or that the team prefers to control directly). Header-only and used everywhere in the tree.

What's inside

Header What it provides
RefPtr.h Refcounting smart pointer
UniquePtr.h Mozilla's std::unique_ptr
WeakPtr.h Weak references
Maybe.h Optional ("Maybe", Some(...), Nothing())
Result.h mozilla::Result<T, E> and MOZ_TRY
Span.h View over a range
Variant.h Tagged union
Atomics.h Atomic primitives
Logging.h The MOZ_LOG macros
Assertions.h MOZ_ASSERT, MOZ_RELEASE_ASSERT, MOZ_DIAGNOSTIC_ASSERT
EnumSet.h, EnumeratedArray.h Strongly-typed enum collections
Tuple.h, Pair.h Tuple/pair
Range.h, RangedPtr.h Bounds-checked pointer arithmetic
HashFunctions.h Mozilla's hashing
MemoryReporting.h MallocSizeOf + memory accounting
Vector.h Mozilla's std::vector
Buffer.h, BufferList.h Byte buffers
TimeStamp.h, TimeDuration.h Monotonic time
MathAlgorithms.h min/max/clamp/IsPowerOfTwo/RoundUp

Why not std?

mfbt predates many C++17/20 standard-library facilities, and parts deliberately diverge:

  • Stricter assertions and bounds checks.
  • Memory-reporting hooks (so about:memory can size objects).
  • Static-analysis annotations.
  • Refcounting integration with nsISupports.

New code that has the choice is encouraged to use mfbt types where they exist (e.g., mozilla::Maybe over std::optional) for consistency.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

mfbt — Mozilla Framework-Based Templates – Gecko wiki | Factory