Skip to content

Commit

Permalink
experiment with C++20 ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
nunoplopes committed Apr 29, 2024
1 parent a22ae35 commit 777490a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions ir/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "util/hash.h"
#include "util/sort.h"
#include "util/unionfind.h"
#include <algorithm>
#include <fstream>
#include <set>
#include <unordered_set>
Expand Down Expand Up @@ -244,9 +245,9 @@ vector<GlobalVariable *> Function::getGlobalVars() const {

vector<string_view> Function::getGlobalVarNames() const {
vector<string_view> gvnames;
auto gvs = getGlobalVars();
transform(gvs.begin(), gvs.end(), back_inserter(gvnames),
[](auto &itm) { return string_view(itm->getName()).substr(1); });
ranges::transform(
getGlobalVars(), back_inserter(gvnames),
[](auto &itm) { return string_view(itm->getName()).substr(1); });
return gvnames;
}

Expand Down
4 changes: 2 additions & 2 deletions ir/instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "smt/solver.h"
#include "util/compiler.h"
#include "util/config.h"
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
Expand Down Expand Up @@ -2225,8 +2226,7 @@ vector<Value*> FnCall::operands() const {
vector<Value*> output;
if (fnptr)
output.emplace_back(fnptr);
transform(args.begin(), args.end(), back_inserter(output),
[](auto &p){ return p.first; });
ranges::transform(args, back_inserter(output), [](auto &p){ return p.first;});
return output;
}

Expand Down

0 comments on commit 777490a

Please sign in to comment.