Fix PR30260 - optional<const T> not working.

This patch fixes PR30260 by using a (void*) cast on the placement argument
to placement new to casts away the const. See also http://llvm.org/PR30260.

As a drive by change this patch also changes the header guard for
<experimental/optional> to _LIBCPP_EXPERIMENTAL_OPTIONAL from _LIBCPP_OPTIONAL.

llvm-svn: 280775
This commit is contained in:
Eric Fiselier
2016-09-07 01:56:07 +00:00
parent edd0a7023f
commit c1d527d3d8
9 changed files with 113 additions and 14 deletions

View File

@@ -87,6 +87,11 @@ int main()
optional<T> rhs(3);
test(rhs);
}
{
typedef const int T;
optional<T> rhs(3);
test(rhs);
}
{
typedef X T;
optional<T> rhs;
@@ -97,6 +102,11 @@ int main()
optional<T> rhs(X(3));
test(rhs);
}
{
typedef const X T;
optional<T> rhs(X(3));
test(rhs);
}
{
typedef Y T;
optional<T> rhs;