Mozilla Framework Based on Templates (MFBT)
source directory, but headers within it should be included using paths like
"mozilla/StandardInteger.h". It is fairly new, so its functionality is currently sparse. Feel free to file bugs to add new functionality to it, or to move existing functionality into it, as needed.
mfbt code goes to some length to document all its interfaces in comments, including examples when possible. It also attempts to define its functionality in well-named files, such that simply skimming the contents of
will quickly suggest the relevant header to examine. Therefore this document primarily attempts to direct readers to the correct file to read those comments. Feel free to file a documentation bug if you think this approach could be improved, and feel free to make improvements to this document if you see them.
StandardInteger.h implements the
<stdint.h> interface. (The
<stdint.h> standard header is not available on all platforms and so cannot be used directly. This header also provides a useful "hook" for embeddings that must customize the types underlying the fixed-size integer types.)
StandardInteger.h and further provides
CheckedInt.h implements checked integers. They behave like integers, but safely check for integer overflow and divide-by-zero. Useful for input validation.
FloatingPoint.h provides various operations for examining and working upon double-precision floating point values, and for producing various special floating point values.
Types.h further provides macros to define imported and exported C symbols.
Attributes.h implements various function and class attribute macros. The function macros control inlining, note whether a function returns, and enforce various C++-related restrictions on inheritance and use. The class macros permit controlling the inheritability of a class.
MOZ_UNLIKELY macros to annotate conditions with their expected truthiness.
Util.h implements various other bits of useful functionality. (This header will likely be further split up so that its functionality is less grab-bag.)
Assertions.h provides assertion macros in implementing runtime assertions and compile-time assertions.
GuardObjects.h provides macros which can be used to annotate an RAII-style guard class, so that any attempt to create an unnamed temporary for it will assert. (An unnamed temporary lives for a shorter period of time than the scope where it's found, so it usually isn't what was desired.)
RangedPtr, a smart pointer template whose value may be manipulated only within a range specified at construction time, and which may be dereferenced only at valid locations in that range. This pointer is a useful way to expose access to values within an array.
RefPtr.h implements various smart pointer templates to simplify reference counting of values of particular classes.
Scoped.h implements scope-based resource management, to simplify the task of cleaning up resources when leaving a scope.
ThreadLocal.h implements thread-local storage, aka "TLS", also called thread-specific storage. It should be used only for static-storage-duration variables, such as global variables or static class members.