10.2.3 : Le main.cpp
Voici le main.cpp : On commence par les includes standars :
1 2 3 4 5 6 7 8 |
#include <iostream> #include <ranges> #include <vector> #include <numeric> #include <ranges> #include <execution> #include <algorithm> |
On définit notre fonction principale :
1 |
int main(){ |
On déclare un vecteur :
1 2 |
size_t nbValue(15lu); std::vector<float> vecA(nbValue); |
On l'initialise :
1 |
std::iota(vecA.begin(), vecA.end(), 0); |
On teste chunk :
1 2 3 4 5 6 7 |
std::cout << "Test with chunk :" << std::endl; for (const auto & a : std::views::chunk(vecA, 5)){ //For some reason, the chunk gives vector of vector of elements and not only vector of elements, so we can call .front() std::cout << "a.front() = " << a.front() << std::endl; } return 0; } |
Le fichier main.cpp complet :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include <iostream> #include <ranges> #include <vector> #include <numeric> #include <ranges> #include <execution> #include <algorithm> int main(){ size_t nbValue(15lu); std::vector<float> vecA(nbValue); std::iota(vecA.begin(), vecA.end(), 0); std::cout << "Test with chunk :" << std::endl; for (const auto & a : std::views::chunk(vecA, 5)){ //For some reason, the chunk gives vector of vector of elements and not only vector of elements, so we can call .front() std::cout << "a.front() = " << a.front() << std::endl; } return 0; } |
Le fichier main.cpp est disponible ici.