-
Notifications
You must be signed in to change notification settings - Fork 2.2k
maint(Clang-Tidy): readability-const-return #3254
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
Changes from all commits
b542f27
de74809
63bf253
8fef23c
3a9516f
3940960
2874d74
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 |
---|---|---|
|
@@ -178,6 +178,7 @@ TEST_SUBMODULE(eigen, m) { | |
ReturnTester() { print_created(this); } | ||
~ReturnTester() { print_destroyed(this); } | ||
static Eigen::MatrixXd create() { return Eigen::MatrixXd::Ones(10, 10); } | ||
// NOLINTNEXTLINE(readability-const-return-type) | ||
static const Eigen::MatrixXd createConst() { return Eigen::MatrixXd::Ones(10, 10); } | ||
Eigen::MatrixXd &get() { return mat; } | ||
Eigen::MatrixXd *getPtr() { return &mat; } | ||
|
@@ -244,6 +245,9 @@ TEST_SUBMODULE(eigen, m) { | |
|
||
// test_fixed, and various other tests | ||
m.def("fixed_r", [mat]() -> FixedMatrixR { return FixedMatrixR(mat); }); | ||
// Our Eigen does a hack which respects constness through the numpy writeable flag. | ||
// Therefore, the const return actually affects this type despite being an rvalue. | ||
// NOLINTNEXTLINE(readability-const-return-type) | ||
m.def("fixed_r_const", [mat]() -> const FixedMatrixR { return FixedMatrixR(mat); }); | ||
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 used to return a non-writable numpy array, now it returns a writable one. 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. Unchanged files with check annotations (Beta) - very nice to see! 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. How annoyingly offspec, Fixing 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. It's a kind-of-handy and "cute" trick, but not at all "normal" C++! 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. Is that trick explained somewhere? (I still don't know what it is.) A one-line comment here with a hint would be nice. |
||
m.def("fixed_c", [mat]() -> FixedMatrixC { return FixedMatrixC(mat); }); | ||
m.def("fixed_copy_r", [](const FixedMatrixR &m) -> FixedMatrixR { return m; }); | ||
|
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.
Intentional?
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.
Clang-Format. I can revert.