arena allocator + incremental garbage collector
  • C++ 98.4%
  • CMake 1.6%
Find a file
2024-04-23 20:19:45 -04:00
.github/workflows xo-ratio: github: + missing randomgen dep in xo-cpp-builder workflow 2024-04-23 20:19:45 -04:00
cmake xo-ratio: build: ++ GUESSED_CMAKE_CMD message 2024-04-23 15:53:11 -04:00
docs xo-ratio: docs: ++ install links for 3rd-party deps 2024-04-19 07:35:21 -04:00
example xo-ratio: build: drop unused xo-reflect dep 2024-04-18 17:28:18 -04:00
include/xo/ratio xo-ratio: ++ default ctor, .is_zero() .is_unit() methods 2024-04-23 15:53:42 -04:00
utest xo-ratio: rename reduce() -> normalize() 2024-04-19 07:17:36 -04:00
.gitignore xo-ratio: + .gitignore 2024-04-17 21:23:47 -04:00
CMakeLists.txt xo-ratio: bugfix: missing GNUInstallDirs in toplevel CMakeLists.txt 2024-04-23 15:52:45 -04:00
LICENSE xo-ratio: initial commit 2024-04-17 21:23:20 -04:00
README.md xo-ratio: README: + docs link 2024-04-18 18:06:19 -04:00

ratio library

Header-only, constexpr library providing exact representation for rational numbers.

Relative to std::ratio:

  1. Uses constexpr instead of creating new types. This means it can be used seamlessly at runtime.
  2. Supports a few more arithmetic operations, for example exponentiation to integer powers.
  3. Provides constexpr conversion to fixed-capacity strings (using xo-flatstring)
  4. Provides concept support (with c++20)
  5. Requires modern (c++17) support to achieve this

Relative to boost::ratio:

  1. Streamlined, assumes modern compiler support

Documentation

Getting Started

install dependencies

clone xo-ratio

$ cd ~/proj   # for example
$ git clone https://github.com/Rconybea/xo-ratio

build + install

$ cd xo-ratio
$ PREFIX=/usr/local # for example
$ BUILDDIR=.build   # for example
$ make ${BUILDDIR}
$ cmake --build .build
$ cmake --install .build

build with unit test coverage

$ cd xo-ratio
$ mkdir .build-ccov
$ cmake -DCMAKE_BUILD_TYPE=coverage -B .build-ccov
$ cmake --build .build-ccov

run coverage-enabled unit tests

$ cmake --build .build-ccov -- test

generate html+text coverage report

$ cmake --build .build-ccov -- ccov

browse to .build-ccov/ccov/html/index.html

LSP support

$ cd xo-ratio
$ ln -s .build/compile_commands.json