Make array<const T, 0> non-CopyAssignable and make swap and fill ill-formed.

The standard isn't exactly clear how std::array should handle zero-sized arrays
with const element types. In particular W.R.T. copy assignment, swap, and fill.

This patch takes the position that those operations should be ill-formed,
and makes changes to libc++ to make it so.

This follows up on commit r324182.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324185 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2018-02-04 02:17:02 +00:00
parent f3224ac007
commit 122c064a76
5 changed files with 181 additions and 10 deletions

View File

@@ -36,6 +36,14 @@ int main()
T* p = c.data();
(void)p; // to placate scan-build
}
{
typedef double T;
typedef std::array<const T, 0> C;
C c = {};
const T* p = c.data();
static_assert((std::is_same<decltype(c.data()), const T*>::value), "");
(void)p; // to placate scan-build
}
{
struct NoDefault {
NoDefault(int) {}