Skip to content

dementive/lt

Repository files navigation

lt

Lightweight templates for C++ 23.

Containers

Container Description
array Wrapper around a C array
const_map Const compile time map
fixed_map Fixed size compile time map
fixed_set Fixed size compile time set
fixed_string Fixed size string
fixed_vector Fixed size vector
list Intrusive doubly linked list
pair Basic version of std::pair
span Const view into a contiguous memory space.
tuple Basic version of std::tuple

Types

Type Description
defer Call a callback on scope exit.
either A type that is either one type or another type
option Basic version of std::optional
result Basic version of std::expected

Macros

Macro Description
DebugType Type that is only enabled in debug mode.
debug_func Function that is only enabled in debug mode.
FOR_EACH Recursive macro.
test Simple testing framework using recursive macros.

Features

  • No dynamic memory allocation

  • No exceptions

  • No rtti

  • Almost everything is constexpr

  • The only standard library headers used are: <new>, <stddef.h>, and <initializer_list>.

  • Compiles cleanly with -Wall -Wextra -Wpedantic -Wshadow and all sanitizers.

Extras

In the extras directory there are some other useful utilities that are built using some things from lt.

  • perf.hpp - Uses defer to profile the current scope using linux perf. You can call the perf_scope("name") macro to profile the current scope or just put perf_func at the top of any function to profile it. You can then use get_perf_stats() to get a view into everything you've profiled so far with these macros or use print_perf_stats() to print out all stats rerecorded by perf. Reworked from https://github.com/tezc/sc/tree/master/perf and adapted to C++.

  • log.hpp - https://github.com/tezc/sc/tree/master/logger adapted to C++.

Credits

The tuple and list were adapted from the Tuple and SelfList from Godot.

Perf and logging utilities were adapted from sc

snprintf from stb

About

Lightweight C++ 23 Templates

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published