================
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+// Scalar types are bitwise clonable.
+static_assert(__is_bitwise_cloneable(int));
+static_assert(__is_bitwise_cloneable(int*));
+// array
+static_assert(__is_bitwise_cloneable(int[10]));
+
+// non-scalar types.
+static_assert(!__is_bitwise_cloneable(int&));
+
+
+struct Forward; // expected-note 2{{forward declaration of 'Forward'}}
+static_assert(!__is_bitwise_cloneable(Forward)); // expected-error 
{{incomplete type 'Forward' used in type trait expression}}
+
+struct Foo { int a; };
+static_assert(__is_bitwise_cloneable(Foo));
+
+struct DynamicClass { virtual int Foo(); };
+static_assert(__is_bitwise_cloneable(DynamicClass));
+
+struct Bar { int& b; }; // trivially copyable
+static_assert(__is_trivially_copyable(Bar));
+static_assert(__is_bitwise_cloneable(Bar));
----------------
ilya-biryukov wrote:

I think it makes a lot of sense to make this a strict superset of trivially 
copyable types.
But why isn't next example bitwise-cloneable then?

```cpp
struct Bar2 { Bar2(const Bar2&); int& b; };
static_assert(!__is_trivially_copyable(Bar2));
static_assert(!__is_bitwise_cloneable(Bar2)); 
```
`Bar2` is not trivially copyable because of the presence of a user-defined 
constructor, we chose to drop that requirement for the new trait. Why isn't the 
type bitwise-cloneable?

https://github.com/llvm/llvm-project/pull/86512
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to