Skip to content

Commit f82f33e

Browse files
committed
Refactor goto_cc_cmdlinet::have_infile_arg using std::any_of
This avoids the need to declare and mutate iterators. Its states what it is doing by means of the name of the algorithm - `std::any_of`, which saves on reading a loop to work it out.
1 parent 098351a commit f82f33e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/goto-cc/goto_cc_cmdline.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ Date: April 2010
1313

1414
#include "goto_cc_cmdline.h"
1515

16-
#include <cstring>
16+
#include <algorithm>
1717
#include <cassert>
18-
#include <iostream>
1918
#include <cstdio>
19+
#include <cstring>
20+
#include <iostream>
2021

2122
#include <util/invariant.h>
2223
#include <util/prefix.h>
@@ -120,10 +121,8 @@ void goto_cc_cmdlinet::add_infile_arg(const std::string &arg)
120121

121122
bool goto_cc_cmdlinet::have_infile_arg() const
122123
{
123-
for(parsed_argvt::const_iterator it = parsed_argv.begin();
124-
it != parsed_argv.end();
125-
it++)
126-
if(it->is_infile_name)
127-
return true;
128-
return false;
124+
return std::any_of(
125+
parsed_argv.cbegin(), parsed_argv.cend(), [](const argt &arg) {
126+
return arg.is_infile_name;
127+
});
129128
}

0 commit comments

Comments
 (0)