From ea6909436378938465daa3f157cba9aff508829b Mon Sep 17 00:00:00 2001 From: coderpankaj Date: Mon, 10 Jul 2023 22:23:10 +0530 Subject: [PATCH] [main] Added example for ranges. Unable to compile due to gcc 10 dependency. Code not tested. Signed-off-by: coderpankaj --- algorithms/CPlusPlus/Ranges/testRanges.cpp | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 algorithms/CPlusPlus/Ranges/testRanges.cpp diff --git a/algorithms/CPlusPlus/Ranges/testRanges.cpp b/algorithms/CPlusPlus/Ranges/testRanges.cpp new file mode 100644 index 00000000..b3b0e29c --- /dev/null +++ b/algorithms/CPlusPlus/Ranges/testRanges.cpp @@ -0,0 +1,36 @@ +// Content: Use of Range algorithms +// Author: Pankaj Patil +// Date: Sat, 10th July 2023 + +/* INCLUES */ +#include +#include +#include +#include +using namespace std; + +/* MAIN FUNCTION */ +int main() +{ + cout << "Hello World" << endl; + + vector v = {1, 2, 3, 3, 5, 6}; + auto it = ranges::adjacent_find(v); + if (it != v.end()) { + std::cout << *it << std::endl; + } + + // std::vector v = {1, 2, 3, 4, 5}; + // int value = 3; + // auto it = std::ranges::binary_search(v, value); + // if (it != v.end()) { + // std::cout << "Found " << value << " at index " << it - v.begin() << std::endl; + // } + + + + return 1; +} + +// Compile this code using : g++ -o tuple.exe testTuple.cpp +// Execute this code using : tuple.exe