experimental: use clang-format for buffer and graph#1400
experimental: use clang-format for buffer and graph#1400barendgehrels wants to merge 5 commits intoboostorg:developfrom
Conversation
| namespace boost { namespace geometry | ||
| namespace boost | ||
| { | ||
| namespace geometry |
There was a problem hiding this comment.
I cannot find a rule which doesn't affect this style for namespace.
Maybe we can live with this change.
There was a problem hiding this comment.
With the more detailled Brace rules as in #1400 (comment) , I can get namespace boost { namespace geometry {
There was a problem hiding this comment.
Yes, better for sure! Thanks! Applied!
| using turn_vector_type = std::vector<buffer_turn_info_type>; | ||
|
|
||
| using piece_border_type = piece_border<Ring, point_type> ; | ||
| using piece_border_type = piece_border<Ring, point_type>; |
There was a problem hiding this comment.
It nicely catches these kind of small errors.
include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp
Outdated
Show resolved
Hide resolved
| typename Turns, | ||
| typename Pieces, | ||
| typename DistanceStrategy, | ||
| typename UmbrellaStrategy |
There was a problem hiding this comment.
This is also different than what we had. But it is (as far as I can see) the variant closest possible.
| auto const source_turn_indices | ||
| = get_turn_indices_by_node_id(turns, clusters, source_node_id, allow_closed); | ||
| auto const target_turn_indices | ||
| = get_turn_indices_by_node_id(turns, clusters, target_node_id, allow_closed); |
There was a problem hiding this comment.
Nice catches of wrong const placements, from me recently...
| << std::endl; | ||
| std::cout << "quadratic: " << source_node_id << " -> " << target_node_id << " sizes " | ||
| << source_turn_indices.size() << " x " << target_turn_indices.size() << " = " | ||
| << result.size() << std::endl; |
There was a problem hiding this comment.
This is not ideal IMO but I don't think we can get this completely satisfactory
| struct is_better_collinear_target {}; | ||
| struct is_better_collinear_target | ||
| { | ||
| }; |
There was a problem hiding this comment.
This is somehow split (though I have AllowShortBlocksOnASingleLine)
There was a problem hiding this comment.
With the more detailled Brace rules as in #1400 (comment) , I can get
template <operation_type Operation>
struct is_better_collinear_target
{};
include/boost/geometry/algorithms/detail/overlay/graph/select_edge.hpp
Outdated
Show resolved
Hide resolved
| bool const better = is_better_collinear_for_union( | ||
| op0, op1, edges.front().toi, edges.back().toi); | ||
| bool const better | ||
| = is_better_collinear_for_union(op0, op1, edges.front().toi, edges.back().toi); |
There was a problem hiding this comment.
This is nicer IMO
| return side == -1 ? geometry::strategy::buffer::join_convex | ||
| : side == 1 ? geometry::strategy::buffer::join_concave | ||
| : same_direction(p0, p1, p2) ? geometry::strategy::buffer::join_continue | ||
| : geometry::strategy::buffer::join_spike; |
There was a problem hiding this comment.
This is not too bad, actually better than I've ever seen from clang-format
| first_p1, | ||
| first_p2, | ||
| last_p1, | ||
| last_p2); |
There was a problem hiding this comment.
not really nice... but still acceptable probably
|
This looks very convenient and I think having a style that can be programmatically enforced but is slightly different from before is better than having a style that is more difficult to ensure consistency for, I'm definitely in favour of this change. The behaviour for namespaces and empty structs can maybe be made closer to the original by breaking up the Allman style into custom rules to partially address #1400 (comment) and #1400 (comment) like this: -BreakBeforeBraces: Allman
+BreakBeforeBraces: Custom
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: false
+ AfterStruct: true
+ AfterUnion: true
+ AfterExternBlock: true
+ BeforeCatch: true
+ BeforeElse: true
+ BeforeLambdaBody: true
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
+ IndentBraces: falseThe following may also be of interest, if this is to be mass-applied, to somewhat preserve the ability to use git blame to understand why some particular line was changed, it requires logging the commit in a file called .git-blame-ignore-revs at root. |
|
hi @vissarion , I'll not merge it - but just to gauge your opinion, do you like it and the proposed styling? |
Very interesting, thanks! So we should use that indeed. |
I definitely like it and I am in favor of using |
Applied on two folders only!
This is experimental and verifies how
clang-formatcould be used for our code base,using a style that is most close to what we (in general) use.
I used
clang-format-15.Other Boost libraries
clang-formatis used by a few other boost libraries. I tried some of these configurations, but it was not satisfactory to my taste.Here an indication (on a branch of somewhere last year), with sizes in bytes: