Skip to content

Stop using std::is_trivial (deprecated in C++26) #1961

Closed
@dangelog

Description

@dangelog

Hello,

The std::is_trivial type trait has been deprecated in C++26 by https://isocpp.org/files/papers/P3247R2.html ; some code in oneDPL is still using it, and needs to be ported away.

https://github.com/search?q=repo%3Auxlfoundation%2FoneDPL%20std::is_trivial&type=code

Note that I'm talking specifically about is_trivial and is_trivial_v, the other type traits are OK.

The direct (= semantically equivalent) non-deprecated replacement of is_trivial_v<T> would be to check for std::is_trivially_default_constructible_v<T> && std::is_trivially_copyable_v<T>.

However the ideal replacement is to reason about what exact type properties are needed, and test for those using specific type traits; for instance, check for trivial copy assignment, trivial destruction, and so on.

(The problem is that the definitions of trivial/trivially copyable encompass too much, and are inaccurate.)

Please also see the remarks to this mailing list thread for libstdc++: https://gcc.gnu.org/pipermail/libstdc++/2024-December/060119.html

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions