This repository provides the constrained and range-based version of the algorithms from the STL numerics libarary that did not make it into C++20.
The library is header only and has no dependencies, except a C++20 compatible compiler with concept and
ranges support. It can be consumed via cmake by adding it as a subdirectory, in which case the target
nrng::nrng
will be available, or by copying the files under include
to a place where they are found.
Installing the library is currently not supported.
-
A C++ compiler that supports C++20. See cppreference.com to see which features are supported by each compiler.
-
Install Command
-
Debian/Ubuntu:
sudo apt-get install cmake
-
Windows:
choco install cmake -y
-
MacOS:
brew install cmake
-
-
Install Command
-
Debian/Ubuntu:
sudo apt-get install doxygen sudo apt-get install graphviz
-
Windows:
choco install doxygen.install -y choco install graphviz -y
-
MacOS:
brew install doxygen brew install graphviz
-
-
Install Command
-
Debian/Ubuntu:
sudo apt-get install ccache
-
Windows:
choco install ccache -y
-
MacOS:
brew install ccache
-
-
Install Command
Follow instructions here: https://github.com/include-what-you-use/include-what-you-use#how-to-install
Instruction for building the tests.
Make a build directory:
mkdir build
By default (if you don't set environment variables CC
and CXX
), the system default compiler will be used.
Conan and CMake use the environment variables CC and CXX to decide which compiler to use. So to avoid the conflict issues only specify the compilers using these variables.
CMake will detect which compiler was used to build each of the Conan targets. If you build all of your Conan targets with one compiler, and then build your CMake targets with a different compiler, the project may fail to build.
Commands for setting the compilers
-
Debian/Ubuntu/MacOS:
Set your desired compiler (
clang
,gcc
, etc):-
Temporarily (only for the current shell)
Run one of the followings in the terminal:
-
clang
CC=clang CXX=clang++
-
gcc
CC=gcc CXX=g++
-
-
Permanent:
Open
~/.bashrc
using your text editor:gedit ~/.bashrc
Add
CC
andCXX
to point to the compilers:export CC=clang export CXX=clang++
Save and close the file.
-
-
Windows:
-
Permanent:
Run one of the followings in PowerShell:
-
Visual Studio generator and compiler (cl)
[Environment]::SetEnvironmentVariable("CC", "cl.exe", "User") [Environment]::SetEnvironmentVariable("CXX", "cl.exe", "User") refreshenv
Set the architecture using vsvarsall:
vsvarsall.bat x64
-
clang
[Environment]::SetEnvironmentVariable("CC", "clang.exe", "User") [Environment]::SetEnvironmentVariable("CXX", "clang++.exe", "User") refreshenv
-
gcc
[Environment]::SetEnvironmentVariable("CC", "gcc.exe", "User") [Environment]::SetEnvironmentVariable("CXX", "g++.exe", "User") refreshenv
-
-
Temporarily (only for the current shell):
$Env:CC="clang.exe" $Env:CXX="clang++.exe"
-
To configure the project and write makefiles, you could use cmake
with a bunch of command line options.
The easier option is to run cmake interactively:
with the Cmake Curses Dialog Command Line tool:
ccmake -S . -B ./build
Once ccmake
has finished setting up, press 'c' to configure the project,
press 'g' to generate, and 'q' to quit.
Once you have selected all the options you would like to use, you can build the project (all targets):
cmake --build ./build
For Visual Studio, give the build configuration (Release, RelWithDeb, Debug, etc) like the following:
cmake --build ./build -- /p:configuration=Release