-
Notifications
You must be signed in to change notification settings - Fork 116
Stop using std::is_trivial #2039
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
Conversation
Use reference types with is_trivially_assignable.
The implementation remains semantically correct. Potential optimizations for rvalues "prescribed" in the standard require more code changes.
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.
Looks good to me assuming the clang-format makes things worse and we want to ignore it for this patch
Thanks. |
Since
std::is_trivial
is deprecated in C++ 26, it makes sense to get rid of it in our code in advance. This is requested in the issue #1961.In
type_traits
, we simply inject names into the oneDPL namespace, so the only change there so far is to add a comment.In
glue_memory_impl,h
,is_trivial
is checked to "optimize" the implementation for trivial types (it is worth checking if that really brings any performance improvement, but let's keep that for later). There we have a few cases:uninitialized_copy/move
, the in-place construction is changed to the "copy" brick, which essentially does an assignment like*result = *input
. Therefore, here the check is for the result value type to be trivially default-constructible and trivially assignable from the input reference type.uninitialized_value_construct
, the "optimization" uses the "fill" brick which assigns a given value of the output value type. Therefore the new check is for trivially default-constructible and trivially copyable. The same logic applies touninitialized_fill
, which currently (before the patch) checks forstd::is_arithmetic
:)uninitialized_default_construct
, construction is fully skipped - so the check should be for trivially default-constructible only.Update: In a discussion with @rarutyun we come to the conclusion that the triviality of both expected and actual operations should be checked in the condition. The patch is updated accordingly.