The Subspace C++ Library
The Subspace C++ Library provides a concept-centered abstraction on top of the bare-metal C++ standard library. It provides the tools to build stable applications quickly, and to make your application performant through explicitly leveraging compiler optimizations without accidentally tripping over Undefined Behaviour and miscompilation. Stop spending time debugging tricky heisenbugs and start relying on the compiler to produce the program you wrote.
Find Subspace on Github here: https://github.com/chromium/subspace
Prelude
The sus/prelude.h header imports the most commonly used types into the
global namespace. All types in the prelude namespace are
included:
Example
#include "sus/prelude.h"
int main() {
auto v = Vec<i32>(1, 2, 3, 4, 5);
return sus::move(v).into_iter().sum();
}
Namespaces
-
The root namespace of the Subspace C++ library.
-
Checking for (e.g.
sus_check) and handling (e.g.sus_panic,sus_unreachable) unexpected runtime conditions. -
The
Box<T>type for heap allocation and other tools for type-erasure of concepts. -
The
Choicetype. -
Utilities for comparing and ordering values.
-
Collection types.
-
Concepts and functions for constructing and converting between types.
-
Inspection and manipulation of the process's environment.
-
Interfaces for working with Errors.
-
Composable external iteration.
-
Marker types, such as for accessing unsafe APIs, for overload resolution, or type elision.
-
-
-
Commonly used things that can be pulled into the global top level namespace. This is done by default when including the
sus/prelude.hheader. -
Operators
-
For writing
f32literals. -
For writing
f64literals. -
For writing
i16literals. -
For writing
i32literals. -
For writing
i64literals. -
For writing
i8literals. -
For writing
isizeliterals. -
Constructs a
usizerange from a literal. -
Constructs an
isizerange from a literal. -
For writing
u16literals. -
For writing
u32literals. -
For writing
u64literals. -
For writing
u8literals. -
For writing
usizeliterals.
Type Aliases
-
A collection of objects of type
T, with a fixed sizeN. -
The
Optiontype. -
-
A dynamically-sized const view into a contiguous sequence of objects of type
const T. -
A resizeable contiguous buffer of type
T. -
A 32-bit floating point type.
-
A 64-bit floating point type.
-
A 16-bit signed integer.
-
A 32-bit signed integer.
-
A 64-bit signed integer.
-
An 8-bit signed integer.
-
An address-sized signed integer.
-
A 16-bit unsigned integer.
-
A 32-bit unsigned integer.
-
A 64-bit unsigned integer.
-
An 8-bit unsigned integer.
-
A pointer-sized unsigned integer.
-
An address-sized unsigned integer.
Variable Aliases
-
The global
UnsafeFnMarkerwhich can be passed to unsafe functions. See theUnsafeFnMarkertype for an explanation.
Macros
-
A macro that replaces the
INFINITYmacro from the<cmath>header. Consider using f32::INFINITY instead. -
A macro that replaces the
NANmacro from the<cmath>header. Consider using f32::NAN instead. -
Verifies that the input, evaluated to a
bool, is true. Otherwise, it willpanic, printing a message and terminating the program. -
Verifies that the input
cond, evaluated to abool, is true. Otherwise, it willpanic, printing a customized message, and terminating the program. -
Mark a class field as never being a specific value, often a zero, after a constructor has run and before the destructor has completed. This allows querying if a class is constructed in a memory location, since the class is constructed iff the value of the field is not the never-value.
-
Mark a class as unconditionally trivially relocatable while also asserting that all of the types passed as arguments are also marked as such.
-
Mark a class as trivially relocatable based on a compile-time condition.
-
Mark a class as trivially relocatable if the types passed as arguments are all trivially relocatable.
-
Mark a class as unconditionally trivially relocatable, without any additional assertion to help verify correctness.
-
Check a condition in debug builds, causing a
sus_panic()if the condition fails. Nothing is checked in release builds. -
Macro to help implement
DynCfor a conceptC. The macro is placed in the body of theDynCclass. -
Macro to help implement
DynCTypedfor a conceptC. The macro is placed in the body of theDynCTypedclass. -
Terminate the program.
-
Terminate the program, after printing a message.
-
Indicates to the developer that the location should not be reached, and terminates the program with a
panic. -
Indicates to the compiler that the location will never be reached, allowing it to optimize code generation accordingly. If this function is actually reached, Undefined Behaviour will occur.