Overview
The types namespace provides convenient type aliases for commonly used types in the Drac++ project. These aliases offer shorthand notations for standard library types and follow Rust-like naming conventions. Namespace:draconis::utils::types
Header: <Drac++/Utils/Types.hpp>
Integer types
Unsigned integers
| Alias | Underlying Type | Description |
|---|---|---|
u8 | std::uint8_t | 8-bit unsigned integer |
u16 | std::uint16_t | 16-bit unsigned integer |
u32 | std::uint32_t | 32-bit unsigned integer |
u64 | std::uint64_t | 64-bit unsigned integer |
usize | std::size_t | Unsigned size type (result of sizeof) |
Signed integers
| Alias | Underlying Type | Description |
|---|---|---|
i8 | std::int8_t | 8-bit signed integer |
i16 | std::int16_t | 16-bit signed integer |
i32 | std::int32_t | 32-bit signed integer |
i64 | std::int64_t | 64-bit signed integer |
isize | std::ptrdiff_t | Signed size type (result of pointer subtraction) |
Floating-point types
| Alias | Underlying Type | Description |
|---|---|---|
f32 | float | 32-bit floating-point number |
f64 | double | 64-bit floating-point number |
String types
| Alias | Underlying Type | Description |
|---|---|---|
String | std::string | Owning, mutable string |
WString | std::wstring | Owning, mutable wide string |
StringView | std::string_view | Non-owning view of a string |
WStringView | std::wstring_view | Non-owning view of a wide string |
CStr | char | Single character type |
PCStr | const char* | Pointer to a null-terminated C-style string |
WCStr | wchar_t | Single wide character type |
PWCStr | const wchar_t* | Pointer to a null-terminated C-style wide string |
Container types
Array
Tp- The element typesz- The size of the array
Vec
Tp- The element type
Span
Tp- The element typesz- (Optional) The size of the span
Map
Key- The key typeVal- The value type
UnorderedMap
Key- The key typeVal- The value type
Tuple types
Pair
T1- The type of the first elementT2- The type of the second element
Tuple
Ts...- The types of the elements
Smart pointers
SharedPointer
Tp- The type of the managed object
UniquePointer
Tp- The type of the managed objectDp- The deleter type (defaults tostd::default_delete<Tp>)
Option type
Tp- The type of the potential value
Helper constants and functions
None
Some
value- The value to wrap in an Option
Example usage
Result type
Tp or an error value of type Er.
Template parameters:
Tp- The type of the success value (defaults toUnit)Er- The type of the error value (defaults toerror::DracError)
Err
Er- The type of the error value (defaults toerror::DracError)
Example usage
Synchronization types
| Alias | Underlying Type | Description |
|---|---|---|
Mutex | std::mutex | Mutex type for synchronization |
LockGuard | std::lock_guard<Mutex> | RAII-style lock guard for mutexes |
Function types
Fn
Tp- The function signature (e.g.,void(),int(String))
Future
Tp- The type of the value
Special types
| Alias | Underlying Type | Description |
|---|---|---|
Unit | void | Represents a unit type |
RawPointer | void* | A type-erased pointer |
Exception | std::exception | Standard exception type |