Remove more imports of ranges namespace.

This commit is contained in:
Daniel Kirchner
2021-05-07 15:42:17 +02:00
parent c69add1682
commit 6104ac1cdf
5 changed files with 29 additions and 29 deletions
+14 -10
View File
@@ -47,7 +47,6 @@
#include <vector>
using namespace std;
using namespace ranges;
using namespace solidity::langutil;
using namespace solidity::frontend;
@@ -134,18 +133,18 @@ void checkCallGraphExpectations(
auto notEmpty = [](set<string> const& _set){ return !_set.empty(); };
soltestAssert(
(_expectedCreatedContractSets | views::values | views::remove_if(notEmpty)).empty(),
(_expectedCreatedContractSets | ranges::views::values | ranges::views::remove_if(notEmpty)).empty(),
"Contracts that are not expected to create other contracts should not be included in _expectedCreatedContractSets."
);
soltestAssert(
(_expectedEdges | views::keys | to<set>()) == (_callGraphs | views::keys | to<set>()) &&
(ranges::views::set_difference(_expectedCreatedContractSets | views::keys, _expectedEdges | views::keys)).empty(),
(_expectedEdges | ranges::views::keys | ranges::to<set>()) == (_callGraphs | ranges::views::keys | ranges::to<set>()) &&
(ranges::views::set_difference(_expectedCreatedContractSets | ranges::views::keys, _expectedEdges | ranges::views::keys)).empty(),
"Contracts listed in expectations do not match contracts actually found in the source file or in other expectations."
);
for (string const& contractName: _expectedEdges | views::keys)
for (string const& contractName: _expectedEdges | ranges::views::keys)
{
soltestAssert(
(ranges::views::set_difference(valueOrDefault(_expectedCreatedContractSets, contractName, {}), _expectedEdges | views::keys)).empty(),
(ranges::views::set_difference(valueOrDefault(_expectedCreatedContractSets, contractName, {}), _expectedEdges | ranges::views::keys)).empty(),
"Inconsistent expectations: contract expected to be created but not to be present in the source file."
);
}
@@ -153,16 +152,21 @@ void checkCallGraphExpectations(
map<string, EdgeNames> edges;
map<string, set<string>> createdContractSets;
map<string, set<string>> emittedEventSets;
for (string const& contractName: _expectedEdges | views::keys)
for (string const& contractName: _expectedEdges | ranges::views::keys)
{
soltestAssert(_callGraphs.at(contractName) != nullptr, "");
CallGraph const& callGraph = *_callGraphs.at(contractName);
edges[contractName] = edgeNames(callGraph.edges);
if (!callGraph.bytecodeDependency.empty())
createdContractSets[contractName] = callGraph.bytecodeDependency | views::keys | views::transform(getContractName) | to<set<string>>();
createdContractSets[contractName] = callGraph.bytecodeDependency |
ranges::views::keys |
ranges::views::transform(getContractName) |
ranges::to<set<string>>();
if (!callGraph.emittedEvents.empty())
emittedEventSets[contractName] = callGraph.emittedEvents | views::transform(eventToString) | to<set<string>>();
emittedEventSets[contractName] = callGraph.emittedEvents |
ranges::views::transform(eventToString) |
ranges::to<set<string>>();
}
BOOST_CHECK_EQUAL(edges, _expectedEdges);
@@ -179,7 +183,7 @@ ostream& operator<<(ostream& _out, EdgeNames const& _edgeNames)
ostream& operator<<(ostream& _out, set<string> const& _set)
{
_out << "{" << (_set | views::join(", ") | to<string>()) << "}";
_out << "{" << (_set | ranges::views::join(", ") | ranges::to<string>()) << "}";
return _out;
}
+7 -8
View File
@@ -65,7 +65,6 @@
#include <variant>
using namespace std;
using namespace ranges;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::langutil;
@@ -126,9 +125,9 @@ public:
);
vector<string> overlappingAbbreviations =
ranges::views::set_intersection(_extraOptions | views::keys, _optimizationSteps | views::keys) |
views::transform([](char _abbreviation){ return string(1, _abbreviation); }) |
to<vector>();
ranges::views::set_intersection(_extraOptions | ranges::views::keys, _optimizationSteps | ranges::views::keys) |
ranges::views::transform([](char _abbreviation){ return string(1, _abbreviation); }) |
ranges::to<vector>();
yulAssert(
overlappingAbbreviations.empty(),
@@ -140,9 +139,9 @@ public:
);
vector<tuple<char, string>> sortedOptions =
views::concat(_optimizationSteps, _extraOptions) |
to<vector<tuple<char, string>>>() |
actions::sort([](tuple<char, string> const& _a, tuple<char, string> const& _b) {
ranges::views::concat(_optimizationSteps, _extraOptions) |
ranges::to<vector<tuple<char, string>>>() |
ranges::actions::sort([](tuple<char, string> const& _a, tuple<char, string> const& _b) {
return (
!boost::algorithm::iequals(get<1>(_a), get<1>(_b)) ?
boost::algorithm::lexicographical_compare(get<1>(_a), get<1>(_b), boost::algorithm::is_iless()) :
@@ -154,7 +153,7 @@ public:
size_t rows = (sortedOptions.size() - 1) / _columns + 1;
for (size_t row = 0; row < rows; ++row)
{
for (auto const& [key, name]: sortedOptions | views::drop(row) | views::stride(rows))
for (auto const& [key, name]: sortedOptions | ranges::views::drop(row) | ranges::views::stride(rows))
cout << key << ": " << setw(static_cast<int>(longestDescriptionLength)) << setiosflags(ios::left) << name << " ";
cout << endl;