Skip to content

Numeric

DryPerspective edited this page Sep 19, 2023 · 1 revision

Recreation of the contents of the <numeric> standard library header which were added from C++11, and up. Note that it does not contain algorithms added for parallelisation of the standard library, as C++98 has no concurrency primitives.

Functions

iota Fills a range with successive increments of the starting value
gcd Gets the greatest common divisor of two integers
lcm Gets the lowest common multiple of two integers
midpoint Gets the midpoint between two values or pointers

Sample Code

#include "cpp98/numeric.h"

int main(){
    std::vector<int> vec(5); //Create a vector containing 5 default values
    dp::iota(vec.begin(), vec.end(), 1); //Vector now contains {1,2,3,4,5}
}

Clone this wiki locally