preliminary

Pointer Types

template<typename Underlying_T>
class not_null

Makes your code crash when using nullptrs on the bind-point instead of the dereference point.

Which should make debugging easier in case of a logical error.

Removes the is this a nullptr? checks as it is now implied through construction.

Has zero-size-overhead over Underlying_T.

The constructor is explicit so that when T* changes to not_null<T*>, the call-sites that used the old T* form stop compiling and require explicitly specifying that they indeed understand the passed pointer should not be null.

  • ALLOWS construction from Underlying_T (which MUST be nullptr_t assignable)

  • ALLOWS implicit conversion to Underlying_T

  • DISALLOWS default construction

  • DISALLOWS construction from nullptr_t

  • DISALLOWS pointer arithmetics

  • FORCES explicit construction when passing pointers around

  • THROWS when constructing an Underlying_T with a null value

Template Parameters:

Underlying_T – The underlying pointer type

template<typename Underlying_T, Underlying_T null_value = nullptr>
class null_on_move

Holds an Underlying_T, assigns it to null_value when this object is moved.

Note

For avoiding the need to explicitly implement the move constructor for objects that hold non-raii-handles (eg. Vulkan, Wayland).

template<typename T>
using ref = std::shared_ptr<T>

Wrapper around std::shared_ptr.

Note

Currently just an alias, might turn into an implementation later. https://en.cppreference.com/w/cpp/memory/shared_ptr.html

template<typename Underlying_T, typename ...Args>
constexpr ref<Underlying_T> create_ref(Args&&... args)

Allocates memory for an Underlying_T and directly constructs it there.

Returns:

A ref<Underlying_T> to the constructed object.

template<typename Underlying_T>
constexpr ref<Underlying_T> make_ref(Underlying_T *raw_pointer)

Converts c-style pointer of type Underlying_T to a ref<Underlying_T>.

template<typename t>
using scope = std::unique_ptr<t>

Wrapper around std::unique_ptr.

Note

Currently just an alias, might turn into an implementation later. https://en.cppreference.com/w/cpp/memory/unique_ptr.html

template<typename Underlying_T, typename ...Args>
constexpr scope<Underlying_T> create_scope(Args&&... args)

Allocates memory for an Underlying_T and directly constructs it there.

Returns:

A scope<Underlying_T> to the constructed object.

template<typename Underlying_T>
constexpr scope<Underlying_T> make_scope(Underlying_T *raw_pointer)

Converts c-style pointer of type Underlying_T to a scope<Underlying_T>.

Build Constants

enum class build_constants::Platform : u8

Values:

enumerator gnu_linux

The GNU/Linux platform.

Tested on the following distros: arch-x86_64

Note

: Named like so because linux is a built-in identifier, not because of the memes.

enumerator windows

The Microsoft Windows(tm) platform.

Currently not supported.

enumerator mac

The apple’s macOS platform.

Currently not supported.

enum class build_constants::Compiler : u8

The compiler that was used for compiling the project.

Currently ONLY clang is supported.

Values:

enumerator clang
enumerator gcc
enumerator msvc
enumerator apple_clang
enum class build_constants::BuildType : u8

For what purpose we are building for.

Todo:

: Implement distribution build type.

Values:

enumerator debug
enumerator release
enumerator distribution

Convenient Aliases

using u8 = ::std::uint8_t
using u16 = ::std::uint16_t
using u32 = ::std::uint32_t
using u64 = ::std::uint64_t
using i8 = ::std::int8_t
using i16 = ::std::int16_t
using i32 = ::std::int32_t
using i64 = ::std::int64_t
using f32 = float
using f64 = double
using size_t = ::std::size_t