[llvm-bugs] [Bug 30260] New: optional<const T> not working
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Sep 2 11:16:30 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=30260
Bug ID: 30260
Summary: optional<const T> not working
Product: libc++
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: howard.hinnant at gmail.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
Classification: Unclassified
I expect this to compile and work:
#include <experimental/optional>
struct Foo {};
std::experimental::optional<const Foo>
someFunc();
int
main()
{
std::experimental::optional<const Foo> j;
j.emplace(*someFunc());
}
Instead I get compile-time errors such as:
In file included from test.cpp:22:
../libcxx/include/experimental/optional:274:17: error: no matching function for
call to 'operator new'
::new(_VSTD::addressof(__val_))
value_type(_VSTD::move(__x.__val_));
^~
I believe all that is needed (untested suggestion) is a const_cast of the
result of addressof on the way to new (several places).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160902/0cb8d822/attachment.html>
More information about the llvm-bugs
mailing list