-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup clang tidy #882
base: main
Are you sure you want to change the base?
Cleanup clang tidy #882
Changes from all commits
133e334
0f8a9d5
3909008
862dffd
af6a46e
a9799ff
ff5638c
762160d
cca35b0
9c136ad
75b8802
8d594ce
a9a560a
0ed9ac1
10937a8
423ff5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -281,7 +281,7 @@ inline void add_diag(Eigen::ArrayBase<DerivedA>& x, Eigen::ArrayBase<DerivedB> c | |
} | ||
template <rk2_tensor DerivedA, column_vector DerivedB> | ||
inline void add_diag(Eigen::ArrayBase<DerivedA>&& x, Eigen::ArrayBase<DerivedB> const& y) { | ||
x.matrix().diagonal() += y.matrix(); | ||
std::move(x).matrix().diagonal() += y.matrix(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is very strange There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not a perfect forwarding because it contains Alternatively, we can decide to not capture by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now this (and other places) is indeed a nasty one. For this function, we have a add_diag(real(complex_tensor), diag_value); Where We can silence the warning locally. We can also choose to define a named variable in all the caller side, so auto& real_value_proxy = real(complex_tensor);
add_diag(real_value_proxy , diag_value); Then we just need the |
||
} | ||
|
||
// zero tensor | ||
|
@@ -351,13 +351,14 @@ template <symmetry_tag sym, class Proxy> | |
inline void update_real_value(RealValue<sym> const& new_value, Proxy&& current_value, double scalar) { | ||
if constexpr (is_symmetric_v<sym>) { | ||
if (!is_nan(new_value)) { | ||
current_value = scalar * new_value; | ||
std::forward<Proxy>(current_value) = scalar * new_value; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also this seems to be very strange. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is how a perfectly forwarded proxy works: the std::forward<Proxy>.operator=(scalar * new_value); which can be rewritten as This deliberately consumes the If we do not want to do perfect forwarding, can you please explain why we went for this solution in the first place here? I do understand that this implementation creates a modifiable view of the 3-phase tensor by value, while taking mutable reference for other objects, but it this really the way that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #882 (comment) |
||
} | ||
} else { | ||
for (size_t i = 0; i != 3; ++i) { | ||
if (!is_nan(new_value(i))) { | ||
current_value(i) = scalar * new_value(i); | ||
current_value(i) = scalar * new_value(i); // can't forward due to runtime element access | ||
} | ||
(void)std::forward<Proxy>(current_value); | ||
Comment on lines
+359
to
+361
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. runtime access; can't move in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #882 (comment) |
||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ inline void iterate_component_sequence(Func&& func, ForwardIterator begin, Forwa | |
// get component directly using sequence id | ||
func(*it, sequence_idx[seq]); | ||
} | ||
(void)std::forward<Func>(func); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function captures There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here for #882 (comment).
|
||
} | ||
|
||
template <typename T> bool check_id_na(T const& obj) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and below: the capture is correct: this should work on any type and zero-copy, regardless of whether it is a value, an lvalue or a prvalue. However, there is nothing to forward to, so it must be a
(void)
sinkThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing this instead of the original? Have a unnamed argument will not trigger an unused argument warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After re-thinking about it, the original implementation is not correct. We do not do anything with the argument so it does not make sense to make it universal reference. Just define as unnamed const lvalue reference and throw them away.