From ad74de2e1a7c440e639d95f8c6aa734bf03fe188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Thu, 7 Oct 2021 15:20:36 +0200 Subject: [PATCH] Use Algorithm to Locate '--version' Option --- opm/simulators/flow/Main.hpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index 523a7c6f3..a5df2e4a2 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -509,13 +509,17 @@ namespace Opm // // the call is intercepted by this function which will print "flow $version" // on stdout and exit(0). - void handleVersionCmdLine_(int argc, char** argv) { - for ( int i = 1; i < argc; ++i ) + void handleVersionCmdLine_(int argc, char** argv) + { + auto pos = std::find_if(argv, argv + argc, + [](const char* arg) { - if (std::strcmp(argv[i], "--version") == 0) { - std::cout << "flow " << moduleVersionName() << std::endl; - std::exit(EXIT_SUCCESS); - } + return std::strcmp(arg, "--version") == 0; + }); + + if (pos != argv + argc) { + std::cout << "flow " << moduleVersionName() << std::endl; + std::exit(EXIT_SUCCESS); } }