[libcxx-commits] [libcxx] [libc++][type_traits] P2674R1: A trait for implicit lifetime types (PR #106870)
Hristo Hristov via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Aug 31 14:09:06 PDT 2024
Zingam wrote:
> The implementation without the builtin can never be implemented correctly for all structs. You wouldn't be able to check if this class has a trivial default constructor:
>
> ```c++
> struct X {
> X() = default; // Trivial eligible constructor
> X(int = 0); // ... But X is not default constructible
> X(const X&);
> };
>
> static_assert(__builtin_is_implicit_lifetime(X));
> static_assert(!is_implicit_lifetime_v<X>);
> ```
>
> Not sure you should try to provide a fallback in the `!__has_builtin` case.
>
> (But if you do keep it, you don't check if it's a class before you check `trivially_destructible&&(trivially_X_constructible||...)`. This allows extension types like `double _Complex` and `int [[vector_size(4)]]`, but does not deny references like `int&` which are _not_ implicit lifetime)
Thanks for the review. I plan to remove the non-builtin implementation.
https://github.com/llvm/llvm-project/pull/106870
More information about the libcxx-commits
mailing list