The Compositional Numeric Library (CNL) is a C++ library of fixed-precision numeric classes which enhance integers to deliver safer, simpler, cheaper arithmetic types. Documentation can be found here.
The latest version of CNL requires a C++20-compatible tool chain. (Version 1.x supports C++11.) CNL is tested on the following systems:
Tested:
- GCC 5 - 10 / Clang 5 - 11
- CMake 3.5.1
Tested:
- GCC 10
- CMake 3.5.1
Tested:
- Visual Studio 2019 Version 16.7
- CMake 3.8.0
The library is hosted on GitHub:
git clone https://github.com/johnmcfarlane/cnl.git
cd cnl
The CNL library is comprised of headers found in the src directory. CMake scripts are provided.
To build and install CNL on your system:
mkdir build && cd build
cmake ..
cmake --build . --target install
The test suite uses CMake and depends on Google Test and Google Benchmark. Optional integration tests use Boost.Multiprecision and Boost.SIMD.
-
Conan can be used to pull in essential dependencies:
conan profile new --detect --force default conan profile update settings.compiler.libcxx=libstdc++11 default conan install --build=missing ..
-
Configure the project for development
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_cnl_INCLUDE:FILEPATH="$(pwd)"/conan_paths.cmake ..
-
Build tests:
cmake --build . --target test-all
-
Run tests:
ctest -R test-unit
-
Run benchmarks:
ctest -R test-benchmark
-
To describe CNL build options:
cmake -LH ..
-
Then to apply an option, e.g. to disabled exceptions:
cmake -DCNL_EXCEPTIONS=OFF ..
The API is exposed through headers in the include directory. Add this to your system header list and include, e.g.:
// to use a specific type:
#include <cnl/scaled_integer.h>
// or to include all CNL types:
#include <cnl/all.h>
Examples of projects using CNL:
- CDSP - Compositional DSP Library for C++;
- BrewBlox firmware - firmware for a brewery controller
- cnl_example - minimal CMake-based project which uses CNL as a dependency.
- CNL documentation
- CppCon 2017 presentation
- Embedded Artistry article
- ISO C++ papers:
All feedback greatly appreciated.