Struct NativeBool
- Namespace
- Box3D.Native
- Assembly
- Box3D.NET.Native.dll
A one-byte boolean matching the C bool from <stdbool.h>.
public readonly struct NativeBool : IEquatable<NativeBool>Implements
Inherited Members
Examples
b3BodyDef def = B3.b3DefaultBodyDef();
def.isBullet = true; // implicit conversion from bool
if (def.enableSleep) { /* ... */ } // implicit conversion to bool
Remarks
This type exists so that structures containing booleans stay blittable.
A System.Boolean field marshals as a four-byte Win32 BOOL by default,
which both corrupts the layout of every Box3D definition struct and forces the
runtime to copy the structure field by field on each call.
Annotating each field with [MarshalAs(UnmanagedType.U1)] would fix the
width but the structure would still be classified as non-blittable, so it could
not be passed by in reference without a hidden copy. A one-byte value type
keeps the structures copy-free and lets them be pinned and passed directly.
Constructors
- NativeBool(bool)
-
Initializes a new instance with the given value.
Properties
Methods
- Equals(NativeBool)
-
Indicates whether the current object is equal to another object of the same type.
- Equals(object?)
-
Indicates whether this instance and a specified object are equal.
- GetHashCode()
-
Returns the hash code for this instance.
- ToString()
-
Returns the fully qualified type name of this instance.
Operators
- operator ==(NativeBool, NativeBool)
-
Determines whether two values are equal.
- implicit operator NativeBool(bool)
-
Converts a managed boolean to its one-byte native form.
- implicit operator bool(NativeBool)
-
Converts a one-byte native boolean to its managed form.
- operator !=(NativeBool, NativeBool)
-
Determines whether two values are unequal.