A single-file, header-only library of C++14 standard algorithms adapted to ranges. range.hpp aims to be a thin wrapper around the standard algorithms. If you need a more comprehensive range library, you may want to use range-v3 instead.
Copy range.hpp to the include directory of your project. Change file name and/or namespace as you like.
Include range.hpp and use algorithms in namespace range
:
#include <iostream>
#include <iterator>
#include <vector>
#include <range.hpp>
int main()
{
std::vector<int> numbers {49, 72, 17, 16, 98, 52, 18, 61, 21, 29, 86};
range::sort(numbers);
range::copy(numbers, std::ostream_iterator(std::cout, " "));
std::cout << '\n';
}
Sequence algorithms in algorithm and numeric
headers except for random_shuffle
are provided.
Move to the repository root and type following commands to run tests:
mkdir tests/build
cd tests/build
cmake ..
cmake --build .
./run
Tested compilers are:
- g++ 7
- clang++ 5.0 with libc++
Boost Software License, Version 1.0.
License text is included in the header file. You don't need to copy license file (LICENSE.txt) into your project if you just use the header file.