Skip to content

Commit f0b4f89

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 1fc57a6 commit f0b4f89

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>
@@ -137,10 +138,8 @@ void goto_cc_cmdlinet::add_infile_arg(const std::string &arg)
137138

138139
bool goto_cc_cmdlinet::have_infile_arg() const
139140
{
140-
for(parsed_argvt::const_iterator it = parsed_argv.begin();
141-
it != parsed_argv.end();
142-
it++)
143-
if(it->is_infile_name)
144-
return true;
145-
return false;
141+
return std::any_of(
142+
parsed_argv.cbegin(), parsed_argv.cend(), [](const argt &arg) {
143+
return arg.is_infile_name;
144+
});
146145
}

0 commit comments

Comments
 (0)