Skip to main content

qtty-cpp

Active

Header-only C++17 library for unit-safe physical quantities, backed by qtty through C FFI.

2 stars
0 forks
C++
BSD-3-Clause
Updated 1 weeks ago

Why it exists

qtty-cpp gives C++ projects typed units, literals, and conversions without hiding what is happening underneath. It uses the same conversion engine as qtty, so the rules stay consistent across languages.

Key Features

  • Strong types per unit to prevent dimension mixing
  • Unit conversion via Quantity::to<T>()
  • User-defined literals (10.0_km, 5.0_s)
  • Generated headers from qtty-ffi definitions
  • CMake target for easy integration

Getting Started

// CMakeLists.txt
add_subdirectory(path/to/qtty-cpp)
target_link_libraries(myapp PRIVATE qtty_cpp)

// main.cpp
#include "qtty/qtty.hpp"
using namespace qtty;

auto distance = 100.0_km;
auto time = 2.0_h;
auto speed = distance / time;
Meter m = distance.to<Meter>();

Contributing

We welcome contributions! Here's how you can help:

  • 1 Fork the repository and create your branch from main
  • 2 Make your changes and add tests if applicable
  • 3 Ensure all tests pass with cargo test
  • 4 Submit a pull request with a clear description

License

This project is licensed under the BSD-3-Clause license. See the LICENSE file for details.

Latest Release

v0.4.5 Jun 4, 2026
View release notes

Tags

cpp c++17 units physics bindings