-
Notifications
You must be signed in to change notification settings - Fork 31
migrate to C++20 #507
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
migrate to C++20 #507
Changes from all commits
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 |
|---|---|---|
|
|
@@ -7,13 +7,10 @@ | |
| #include <cstdint> | ||
| #include <cstring> | ||
| #include <string_view> | ||
| #include <type_traits> | ||
|
|
||
| template<typename T> | ||
| MAYBE_UNUSED NODISCARD static auto numeric_hash(const T val) noexcept | ||
| -> std::enable_if_t<std::is_arithmetic_v<T>, size_t> | ||
| MAYBE_UNUSED NODISCARD static size_t numeric_hash(const std::integral auto val) noexcept | ||
|
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. question (bug_risk): numeric_hash now only accepts integral types, which is a behavior change from the previous arithmetic version Previously, |
||
| { | ||
| static constexpr const size_t size = sizeof(val); | ||
| static constexpr size_t size = sizeof(val); | ||
| char buf[size]; | ||
| std::memcpy(buf, &val, size); | ||
| return std::hash<std::string_view>()({buf, size}); | ||
|
|
||
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.
issue (bug_risk): makeQPointer destroys the newly created QObject before returning, leaving QPointer dangling
This constructs a
std::unique_ptr<T>and returns aQPointer<T>toptr.get(). WhenmakeQPointerreturns,ptris destroyed andTis deleted, so theQPointerimmediately dangles. You need to transfer ownership out of theunique_ptr(e.g.ptr.release()) or construct withnew T(...)so Qt owns the object via the parent hierarchy and it survives the function scope.