<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - std::invoke of std::optional::has_value pointer-to-member-function fails, due to its class type being a private base."
href="https://bugs.llvm.org/show_bug.cgi?id=36469">36469</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>std::invoke of std::optional::has_value pointer-to-member-function fails, due to its class type being a private base.
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>4.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>FreeBSD
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ariane@stack.nl
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>The following code snippet:
#include <functional>
#include <optional>
bool testfn(std::optional<int> opt_int) {
return std::invoke(&std::optional<int>::has_value, opt_int);
}
Compiler output (c++ -std=c++1z -c -o test.o test.cc):
test.cc:5:10: error: no matching function for call to 'invoke'
return std::invoke(&std::optional<int>::has_value, opt_int);
^~~~~~~~~~~
/usr/include/c++/v1/functional:2589:1: note: candidate template ignored:
substitution failure [with _Fn = bool
(std::__1::__optional_storage_base<int, false>::*)() const noexcept,
_Args = <std::__1::optional<int> &>]: no type named 'type' in
'std::__1::result_of<bool (std::__1::__optional_storage_base<int,
false>::*&&(std::__1::optional<int> &))() const noexcept>'
invoke(_Fn&& __f, _Args&&... __args)
^
1 error generated.
(I have a hard time reading the error message, but it looks to me like
std::result_of template argument is a zero-argument function that returns a
function.)
Compiler version:
FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM
4.0.0)
Target: x86_64-unknown-freebsd11.1
Thread model: posix
InstalledDir: /usr/bin
Additionally, the following snippet does not compile, while to me seems valid:
std::optional<int> opt_int;
auto fn_ptr = &std::optional<int>::has_value;
bool manual_invocation = (opt_int.*fn_ptr)();</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>