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/copy.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/copy.pass.cpp')
-rw-r--r-- | libcxx/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp b/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp index 89ea345029c..ff37b22c7d2 100644 --- a/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp +++ b/libcxx/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp @@ -19,6 +19,13 @@ using std::experimental::optional; +struct AllowConstAssign { + AllowConstAssign(AllowConstAssign const&) {} + AllowConstAssign const& operator=(AllowConstAssign const&) const { + return *this; + } +}; + struct X { static bool throw_now; @@ -43,6 +50,11 @@ int main() assert(static_cast<bool>(opt) == static_cast<bool>(opt2)); } { + optional<const AllowConstAssign> opt; + optional<const AllowConstAssign> opt2; + opt = opt2; + } + { optional<int> opt; constexpr optional<int> opt2(2); opt = opt2; |