-
Notifications
You must be signed in to change notification settings - Fork 118
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
Refactor generic_data_handle
.
#2467
Conversation
The commit changes the `generic_data_handle` as follows: * Common sanitizing logic is consolidated in two methods `assert_*`. * The logic explicitly deals with the 'literal' and 'data_handle' cases separately. * Hides the `type_name` method, by making it private. * Adds assignment from a `data_handle`. * Improves documentation.
This comment has been minimized.
This comment has been minimized.
✔️ 5dfa16c -> Azure artifacts URL |
Codecov Report
@@ Coverage Diff @@
## master #2467 +/- ##
=======================================
Coverage 60.41% 60.41%
=======================================
Files 626 626
Lines 120812 120823 +11
=======================================
+ Hits 72990 73001 +11
Misses 47822 47822
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
✔️ 6025a9b -> Azure artifacts URL |
* * small (`sizeof(T) <= sizeof(void*)`), trivial types such as `int` or `float`, | ||
* * and raw pointers. | ||
* | ||
* In this context raw pointer is a regular C pointer, i.e. just and address. |
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.
* In this context raw pointer is a regular C pointer, i.e. just and address. | |
* In this context raw pointer is a regular C pointer, i.e. just an address. |
template <typename T> | ||
static constexpr bool can_be_stored_literally_v = | ||
std::is_trivial_v<T> && !std::is_pointer_v<T> && sizeof(T) <= sizeof(void*); | ||
(std::is_trivial_v<T> && sizeof(T) <= sizeof(void*)) || std::is_pointer_v<T>; |
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.
Pointer types are trivial, so this is equivalent
(std::is_trivial_v<T> && sizeof(T) <= sizeof(void*)) || std::is_pointer_v<T>; | |
std::is_trivial_v<T> && sizeof(T) <= sizeof(void*); |
but I am not totally convinced by the change to make can_be_stored_literally_v<double*>
be true
.
Storing small, trivial non-pointer values is an unfortunate feature supported by generic_data_handle
that goes beyond it being a type-erased data_handle<T>
. I hope that feature can be removed fairly promptly.
In contrast, storing a raw (in the sense that it is a not a permutation-stable handle to an entry in an soa
container) T*
is something that data_handle<T>
does support, and which will not go away any time soon.
Given this, it seems preferable to keep as much of a distinction as possible between these two cases.
The commit changes the
generic_data_handle
as follows:assert_*
.type_name
method, by making it private.data_handle
.can_be_stored_literally
allows pointers.generic_data_handle
in a type unsafe manner.