Upgrade clang-format to version 15 (#6859)

This commit is contained in:
Dennis Luxen
2024-05-06 09:14:46 +02:00
committed by GitHub
parent b503e96a98
commit 7f9d591ab7
156 changed files with 2357 additions and 1894 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ template <typename From, typename Tag> struct Alias final
static_assert(std::is_arithmetic<From>::value, "Needs to be based on an arithmetic type");
From __value;
friend std::ostream &operator<<<From, Tag>(std::ostream &stream, const Alias &inst);
friend std::ostream &operator<< <From, Tag>(std::ostream &stream, const Alias &inst);
explicit operator From &() { return __value; }
explicit operator From() const { return __value; }
+31 -25
View File
@@ -179,7 +179,8 @@ template <class BinaryOperation, typename iterator_type>
double getLength(iterator_type begin, const iterator_type end, BinaryOperation op)
{
double result = 0;
const auto functor = [&result, op](const Coordinate lhs, const Coordinate rhs) {
const auto functor = [&result, op](const Coordinate lhs, const Coordinate rhs)
{
result += op(lhs, rhs);
return false;
};
@@ -197,8 +198,9 @@ findClosestDistance(const Coordinate coordinate, const iterator_type begin, cons
double current_min = std::numeric_limits<double>::max();
// comparator updating current_min without ever finding an element
const auto compute_minimum_distance = [&current_min, coordinate](const Coordinate lhs,
const Coordinate rhs) {
const auto compute_minimum_distance =
[&current_min, coordinate](const Coordinate lhs, const Coordinate rhs)
{
current_min = std::min(current_min, findClosestDistance(coordinate, lhs, rhs));
return false;
};
@@ -216,8 +218,9 @@ double findClosestDistance(const iterator_type lhs_begin,
{
double current_min = std::numeric_limits<double>::max();
const auto compute_minimum_distance_in_rhs = [&current_min, rhs_begin, rhs_end](
const Coordinate coordinate) {
const auto compute_minimum_distance_in_rhs =
[&current_min, rhs_begin, rhs_end](const Coordinate coordinate)
{
current_min = std::min(current_min, findClosestDistance(coordinate, rhs_begin, rhs_end));
return false;
};
@@ -233,13 +236,11 @@ std::pair<Coordinate, Coordinate> leastSquareRegression(const iterator_type begi
// following the formulas of https://faculty.elgin.edu/dkernler/statistics/ch04/4-2.html
const auto number_of_coordinates = std::distance(begin, end);
BOOST_ASSERT(number_of_coordinates >= 2);
const auto extract_lon = [](const Coordinate coordinate) {
return static_cast<double>(toFloating(coordinate.lon));
};
const auto extract_lon = [](const Coordinate coordinate)
{ return static_cast<double>(toFloating(coordinate.lon)); };
const auto extract_lat = [](const Coordinate coordinate) {
return static_cast<double>(toFloating(coordinate.lat));
};
const auto extract_lat = [](const Coordinate coordinate)
{ return static_cast<double>(toFloating(coordinate.lat)); };
double min_lon = extract_lon(*begin);
double max_lon = extract_lon(*begin);
@@ -262,19 +263,21 @@ std::pair<Coordinate, Coordinate> leastSquareRegression(const iterator_type begi
{
std::vector<util::Coordinate> rotated_coordinates(number_of_coordinates);
// rotate all coordinates to the right
std::transform(begin, end, rotated_coordinates.begin(), [](const auto coordinate) {
return rotateCCWAroundZero(coordinate, detail::degToRad(-90));
});
std::transform(begin,
end,
rotated_coordinates.begin(),
[](const auto coordinate)
{ return rotateCCWAroundZero(coordinate, detail::degToRad(-90)); });
const auto rotated_regression =
leastSquareRegression(rotated_coordinates.begin(), rotated_coordinates.end());
return {rotateCCWAroundZero(rotated_regression.first, detail::degToRad(90)),
rotateCCWAroundZero(rotated_regression.second, detail::degToRad(90))};
}
const auto make_accumulate = [](const auto extraction_function) {
return [extraction_function](const double sum_so_far, const Coordinate coordinate) {
return sum_so_far + extraction_function(coordinate);
};
const auto make_accumulate = [](const auto extraction_function)
{
return [extraction_function](const double sum_so_far, const Coordinate coordinate)
{ return sum_so_far + extraction_function(coordinate); };
};
const auto accumulated_lon = std::accumulate(begin, end, 0., make_accumulate(extract_lon));
@@ -283,8 +286,10 @@ std::pair<Coordinate, Coordinate> leastSquareRegression(const iterator_type begi
const auto mean_lon = accumulated_lon / number_of_coordinates;
const auto mean_lat = accumulated_lat / number_of_coordinates;
const auto make_variance = [](const auto mean, const auto extraction_function) {
return [extraction_function, mean](const double sum_so_far, const Coordinate coordinate) {
const auto make_variance = [](const auto mean, const auto extraction_function)
{
return [extraction_function, mean](const double sum_so_far, const Coordinate coordinate)
{
const auto difference = extraction_function(coordinate) - mean;
return sum_so_far + difference * difference;
};
@@ -312,7 +317,8 @@ std::pair<Coordinate, Coordinate> leastSquareRegression(const iterator_type begi
std::accumulate(begin,
end,
0.,
[&](const auto sum_so_far, const auto current_coordinate) {
[&](const auto sum_so_far, const auto current_coordinate)
{
return sum_so_far + (extract_lon(current_coordinate) - mean_lon) *
(extract_lat(current_coordinate) - mean_lat) /
(sample_variance_lon * sample_variance_lat);
@@ -323,9 +329,8 @@ std::pair<Coordinate, Coordinate> leastSquareRegression(const iterator_type begi
const auto intercept = mean_lat - slope * mean_lon;
const auto GetLatAtLon = [intercept,
slope](const util::FloatLongitude longitude) -> util::FloatLatitude {
return {intercept + slope * static_cast<double>((longitude))};
};
slope](const util::FloatLongitude longitude) -> util::FloatLatitude
{ return {intercept + slope * static_cast<double>((longitude))}; };
const double offset = 0.00001;
const Coordinate regression_first = {
@@ -359,7 +364,8 @@ bool areParallel(const iterator_type lhs_begin,
const auto rotation_angle_radians = detail::degToRad(bearing_lhs - 90);
const auto rotated_difference_rhs = rotateCCWAroundZero(difference_rhs, rotation_angle_radians);
const auto get_slope = [](const Coordinate from, const Coordinate to) {
const auto get_slope = [](const Coordinate from, const Coordinate to)
{
const auto diff_lat = static_cast<int>(from.lat) - static_cast<int>(to.lat);
const auto diff_lon = static_cast<int>(from.lon) - static_cast<int>(to.lon);
if (diff_lon == 0)
+1 -1
View File
@@ -254,7 +254,7 @@ template <typename ElementT> class DeallocatingVector
++current_size;
}
template <typename... Ts> void emplace_back(Ts &&... element)
template <typename... Ts> void emplace_back(Ts &&...element)
{
const std::size_t current_capacity = capacity();
if (current_size == current_capacity)
+22 -19
View File
@@ -68,7 +68,7 @@ template <typename EdgeDataT> class DynamicGraph
}
template <typename... Ts>
InputEdge(NodeIterator source, NodeIterator target, Ts &&... data)
InputEdge(NodeIterator source, NodeIterator target, Ts &&...data)
: source(source), target(target), data(std::forward<Ts>(data)...)
{
}
@@ -189,25 +189,28 @@ template <typename EdgeDataT> class DynamicGraph
other.node_array.resize(node_array.size());
NodeID node_id = 0;
std::transform(
node_array.begin(), node_array.end(), other.node_array.begin(), [&](const Node &node) {
const EdgeIterator first_edge = other.edge_list.size();
std::transform(node_array.begin(),
node_array.end(),
other.node_array.begin(),
[&](const Node &node)
{
const EdgeIterator first_edge = other.edge_list.size();
BOOST_ASSERT(node_id < number_of_nodes);
if (filter(node_id++))
{
std::copy_if(edge_list.begin() + node.first_edge,
edge_list.begin() + node.first_edge + node.edges,
std::back_inserter(other.edge_list),
[&](const auto &edge) { return filter(edge.target); });
const unsigned num_edges = other.edge_list.size() - first_edge;
return Node{first_edge, num_edges};
}
else
{
return Node{first_edge, 0};
}
});
BOOST_ASSERT(node_id < number_of_nodes);
if (filter(node_id++))
{
std::copy_if(edge_list.begin() + node.first_edge,
edge_list.begin() + node.first_edge + node.edges,
std::back_inserter(other.edge_list),
[&](const auto &edge) { return filter(edge.target); });
const unsigned num_edges = other.edge_list.size() - first_edge;
return Node{first_edge, num_edges};
}
else
{
return Node{first_edge, 0};
}
});
return other;
}
+3 -3
View File
@@ -37,9 +37,9 @@ class FilteredGraphImpl<util::StaticGraph<EdgeDataT, Ownership>, Ownership>
unsigned GetOutDegree(const NodeIterator n) const
{
auto range = graph.GetAdjacentEdgeRange(n);
return std::count_if(range.begin(), range.end(), [this](const EdgeIterator edge) {
return edge_filter[edge];
});
return std::count_if(range.begin(),
range.end(),
[this](const EdgeIterator edge) { return edge_filter[edge]; });
}
inline NodeIterator GetTarget(const EdgeIterator e) const
+3 -3
View File
@@ -58,7 +58,7 @@ class GeojsonLogger
}
// writes a single feature into the Geojson file
template <typename... Args> static bool Write(Args &&... args)
template <typename... Args> static bool Write(Args &&...args)
{
// make sure to syncronize logging output, our writing should be sequential
std::lock_guard<std::mutex> guard(lock);
@@ -146,7 +146,7 @@ class ScopedGeojsonLoggerGuard
{
public:
template <typename... Args>
ScopedGeojsonLoggerGuard(const std::string &logfile, Args &&... args)
ScopedGeojsonLoggerGuard(const std::string &logfile, Args &&...args)
: policy(std::forward<Args>(args)...)
{
GeojsonLogger<geojson_conversion_policy, scenario>::Open(logfile);
@@ -159,7 +159,7 @@ class ScopedGeojsonLoggerGuard
GeojsonLogger<geojson_conversion_policy, scenario>::SetPolicy(nullptr);
}
template <typename... Args> static bool Write(Args &&... args)
template <typename... Args> static bool Write(Args &&...args)
{
return GeojsonLogger<geojson_conversion_policy, scenario>::Write(
std::forward<Args>(args)...);
+10 -8
View File
@@ -63,14 +63,16 @@ template <typename StringView> inline auto decompose(const StringView &lhs, cons
auto const lcs = longest_common_substring(lhs, rhs);
// trim spaces, transform to lower
const auto trim = [](StringView view) {
const auto trim = [](StringView view)
{
// we compare suffixes based on this value, it might break UTF chars, but as long as we are
// consistent in handling, we do not create bad results
std::string str;
str.reserve(view.size());
std::transform(view.begin(), view.end(), std::back_inserter(str), [](unsigned char c) {
return std::tolower(c);
});
std::transform(view.begin(),
view.end(),
std::back_inserter(str),
[](unsigned char c) { return std::tolower(c); });
auto front = str.find_first_not_of(' ');
if (front == std::string::npos)
@@ -131,13 +133,13 @@ inline bool requiresNameAnnounced(const StringView &from_name,
const auto checkForPrefixOrSuffixChange = [](const std::string_view first,
const std::string_view second,
const SuffixTable &suffix_table) {
const SuffixTable &suffix_table)
{
std::string first_prefix, first_suffix, second_prefix, second_suffix;
std::tie(first_prefix, first_suffix, second_prefix, second_suffix) =
decompose(first, second);
const auto checkTable = [&](const std::string &str) {
return str.empty() || suffix_table.isSuffix(str);
};
const auto checkTable = [&](const std::string &str)
{ return str.empty() || suffix_table.isSuffix(str); };
return checkTable(first_prefix) && checkTable(first_suffix) && checkTable(second_prefix) &&
checkTable(second_suffix);
+2 -3
View File
@@ -315,9 +315,8 @@ template <typename GroupBlockPolicy, storage::Ownership Ownership> struct Indexe
values_byte_iter = block.WriteBlockPrefix(curr, next, values_byte_iter);
std::advance(next, std::min<diff_type>(1, std::distance(next, sentinel)));
auto to_bytes = [&](const auto &data) {
values_byte_iter = std::copy_n(&data, sizeof(ValueType), values_byte_iter);
};
auto to_bytes = [&](const auto &data)
{ values_byte_iter = std::copy_n(&data, sizeof(ValueType), values_byte_iter); };
std::copy(data + *curr,
data + *next,
boost::make_function_output_iterator(std::cref(to_bytes)));
+4 -5
View File
@@ -43,11 +43,10 @@ class integer_iterator : public boost::iterator_facade<integer_iterator<Integer>
difference_type distance_to(const integer_iterator &other) const
{
return std::is_signed<value_type>::value
? (other.m_value - m_value)
: (other.m_value >= m_value)
? static_cast<difference_type>(other.m_value - m_value)
: -static_cast<difference_type>(m_value - other.m_value);
return std::is_signed<value_type>::value ? (other.m_value - m_value)
: (other.m_value >= m_value)
? static_cast<difference_type>(other.m_value - m_value)
: -static_cast<difference_type>(m_value - other.m_value);
}
friend class ::boost::iterator_core_access;
+2 -1
View File
@@ -79,7 +79,8 @@ NodeBasedDynamicGraphFromEdges(NodeID number_of_nodes,
auto edges_list = directedEdgesFromCompressed<NodeBasedDynamicGraph::InputEdge>(
input_edge_list,
[](NodeBasedDynamicGraph::InputEdge &output_edge,
const extractor::NodeBasedEdge &input_edge) {
const extractor::NodeBasedEdge &input_edge)
{
output_edge.data.weight = input_edge.weight;
output_edge.data.duration = input_edge.duration;
output_edge.data.distance = input_edge.distance;
+6 -9
View File
@@ -193,23 +193,20 @@ struct OpeningHours
&& (times.empty() ||
std::any_of(times.begin(),
times.end(),
[&time, &use_curr_day, &use_next_day](const auto &x) {
return x.IsInRange(time, use_curr_day, use_next_day);
}))
[&time, &use_curr_day, &use_next_day](const auto &x)
{ return x.IsInRange(time, use_curr_day, use_next_day); }))
// .. and if weekdays are not specified or matches weekdays range
&& (weekdays.empty() ||
std::any_of(weekdays.begin(),
weekdays.end(),
[&time, use_curr_day, use_next_day](const auto &x) {
return x.IsInRange(time, use_curr_day, use_next_day);
}))
[&time, use_curr_day, use_next_day](const auto &x)
{ return x.IsInRange(time, use_curr_day, use_next_day); }))
// .. and if month-day ranges are not specified or is in any month-day range
&& (monthdays.empty() ||
std::any_of(monthdays.begin(),
monthdays.end(),
[&time, use_curr_day, use_next_day](const auto &x) {
return x.IsInRange(time, use_curr_day, use_next_day);
}));
[&time, use_curr_day, use_next_day](const auto &x)
{ return x.IsInRange(time, use_curr_day, use_next_day); }));
}
std::vector<TimeSpan> times;
+3 -3
View File
@@ -345,9 +345,9 @@ class QueryHeap
void DeleteAll()
{
auto const none_handle = heap.s_handle_from_iterator(heap.end());
std::for_each(inserted_nodes.begin(), inserted_nodes.end(), [&none_handle](auto &node) {
node.handle = none_handle;
});
std::for_each(inserted_nodes.begin(),
inserted_nodes.end(),
[&none_handle](auto &node) { node.handle = none_handle; });
heap.clear();
}
+2 -1
View File
@@ -64,7 +64,8 @@ template <unsigned BLOCK_SIZE, storage::Ownership Ownership> class RangeTable
// construct table from length vector
template <typename VectorT> explicit RangeTable(const VectorT &lengths)
{
const unsigned number_of_blocks = [&lengths]() {
const unsigned number_of_blocks = [&lengths]()
{
unsigned num = (lengths.size() + 1) / (BLOCK_SIZE + 1);
if ((lengths.size() + 1) % (BLOCK_SIZE + 1) != 0)
{
+9 -5
View File
@@ -94,7 +94,7 @@ template <typename EdgeDataT> struct SortableEdgeWithData : SortableEdgeWithData
SortableEdgeWithData() = default;
template <typename... Ts>
SortableEdgeWithData(NodeIterator source, NodeIterator target, Ts &&... data)
SortableEdgeWithData(NodeIterator source, NodeIterator target, Ts &&...data)
: Base{source, target}, data{std::forward<Ts>(data)...}
{
}
@@ -304,10 +304,14 @@ class StaticGraph
BOOST_ASSERT(node_array.size() == number_of_nodes + 1);
edge_array.resize(number_of_edges);
std::transform(begin, end, edge_array.begin(), [](const auto &from) {
return static_graph_details::edgeToEntry<EdgeArrayEntry>(
from, traits::HasDataMember<EdgeArrayEntry>{});
});
std::transform(begin,
end,
edge_array.begin(),
[](const auto &from)
{
return static_graph_details::edgeToEntry<EdgeArrayEntry>(
from, traits::HasDataMember<EdgeArrayEntry>{});
});
}
protected:
+4 -4
View File
@@ -281,7 +281,8 @@ class StaticRTree
tbb::parallel_for(
tbb::blocked_range<uint64_t>(0, element_count),
[&input_data_vector, &input_wrapper_vector, this](
const tbb::blocked_range<uint64_t> &range) {
const tbb::blocked_range<uint64_t> &range)
{
for (uint64_t element_counter = range.begin(), end = range.end();
element_counter != end;
++element_counter)
@@ -560,9 +561,8 @@ class StaticRTree
return Nearest(
input_coordinate,
[](const CandidateSegment &) { return std::make_pair(true, true); },
[max_results](const std::size_t num_results, const CandidateSegment &) {
return num_results >= max_results;
});
[max_results](const std::size_t num_results, const CandidateSegment &)
{ return num_results >= max_results; });
}
// Return edges in distance order with the coordinate of the closest point on the edge.
+2 -2
View File
@@ -14,13 +14,13 @@ template <typename T> void hash_combine(std::size_t &seed, const T &val)
template <typename T> void hash_val(std::size_t &seed, const T &val) { hash_combine(seed, val); }
template <typename T, typename... Types>
void hash_val(std::size_t &seed, const T &val, const Types &... args)
void hash_val(std::size_t &seed, const T &val, const Types &...args)
{
hash_combine(seed, val);
hash_val(seed, args...);
}
template <typename... Types> std::size_t hash_val(const Types &... args)
template <typename... Types> std::size_t hash_val(const Types &...args)
{
std::size_t seed = 0;
hash_val(seed, args...);
+2 -1
View File
@@ -18,7 +18,8 @@ template <int length, int precision> char *printInt(char *buffer, int value)
static_assert(length > 0, "length must be positive");
static_assert(precision > 0, "precision must be positive");
const bool minus = [&value] {
const bool minus = [&value]
{
if (value >= 0)
{
value = -value;
+13 -9
View File
@@ -51,16 +51,20 @@ template <std::size_t TimeBinSize = 1000, std::size_t IndexBinSize = 1000> class
{
std::stringstream out;
const auto print_bins = [&out](auto frame_index, auto begin, auto end) {
const auto print_bins = [&out](auto frame_index, auto begin, auto end)
{
auto bin_index = 0;
std::for_each(begin, end, [&](const auto count) {
if (count > 0)
{
out << (frame_index * TimeBinSize) << "," << (bin_index * IndexBinSize) << ","
<< count << std::endl;
}
bin_index++;
});
std::for_each(begin,
end,
[&](const auto count)
{
if (count > 0)
{
out << (frame_index * TimeBinSize) << ","
<< (bin_index * IndexBinSize) << "," << count << std::endl;
}
bin_index++;
});
};
if (frame_offsets.size() == 0)