[llvm] [ADT] Add detection utility for incomplete types (PR #65495)

Markus Böck via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 6 09:17:47 PDT 2023


================
@@ -2476,6 +2476,16 @@ bool hasNItemsOrLess(ContainerTy &&C, unsigned N) {
 template <class Ptr> auto to_address(const Ptr &P) { return P.operator->(); }
 template <class T> constexpr T *to_address(T *P) { return P; }
 
+// Detect incomplete types, relying on the fact that their size is unknown.
+namespace detail {
+template <typename T> using has_sizeof = decltype(sizeof(T));
+} // namespace detail
+
+/// Detects when type `T` is incomplete. This is true for forward declarations
+/// and types with a full definition.
----------------
zero9178 wrote:

```suggestion
/// but not types with a full definition.
```
Typo?

https://github.com/llvm/llvm-project/pull/65495


More information about the llvm-commits mailing list