[libcxx-commits] [libcxx] [libc++][type_traits] P2647R1: A trait for implicit lifetime types (PR #106870)
Mital Ashok via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Aug 31 14:06:47 PDT 2024
MitalAshok 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)
https://github.com/llvm/llvm-project/pull/106870
More information about the libcxx-commits
mailing list