This tutorial walks you from an empty project to using the Utility library. It assumes you have already built the library.
1. Build the library
cmake -S . -B build -DBUILD_TESTING=ON
cmake --build build
ctest --test-dir build --output-on-failure
2. Use a math type
Utility provides vectors, matrices, and quaternions under utility::math:
#include <utility/math/vector.hpp>
auto sum = a + b;
auto dot = utility::math::dot(a, b);
3D vector class inheriting from glm::vec3.
3. Use a cache
utility::Cache provides a thread-safe key-value store:
#include <utility/cache.hpp>
auto value = cache.
get(
"answer");
A thread-safe cache for storing key-value pairs.
std::optional< Entry > get(const Key &key) const
Retrieve the value associated with a specific key.
void put(const Key &key, const Entry &value)
Add or update a key-value pair in the cache.
4. Consume as a dependency
Once installed, link against utility::utility:
find_package(utility CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE utility::utility)
Next steps