diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-09-07 01:56:07 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-09-07 01:56:07 +0000 |
commit | c1d527d3d832cac86eb9461dcef978011ef8caeb (patch) | |
tree | 8c68a5f8183f4a6af52acbdc1ed67f469e6e9ef7 /libcxx/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp | |
parent | edd0a7023f32a94f211201156fdc8ddf16bd85b2 (diff) | |
download | bcm5719-llvm-c1d527d3d832cac86eb9461dcef978011ef8caeb.tar.gz bcm5719-llvm-c1d527d3d832cac86eb9461dcef978011ef8caeb.zip |
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
Diffstat (limited to 'libcxx/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp')
-rw-r--r-- | libcxx/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp b/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp index fa00f5602c7..1c3b780677e 100644 --- a/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp +++ b/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp @@ -21,6 +21,13 @@ using std::experimental::optional; +struct AllowConstAssign { + AllowConstAssign(AllowConstAssign const&) {} + AllowConstAssign const& operator=(AllowConstAssign const&) const { + return *this; + } +}; + struct X { static bool throw_now; @@ -77,6 +84,11 @@ int main() assert(*opt == *opt2); } { + optional<const AllowConstAssign> opt; + optional<const AllowConstAssign> opt2; + opt = std::move(opt2); + } + { static_assert(!std::is_nothrow_move_assignable<optional<X>>::value, ""); optional<X> opt; optional<X> opt2(X{}); |