<html>
<head>
<base href="http://llvm.org/bugs/" />
</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::function<void()> does not accept non-void-returning functions"
href="http://llvm.org/bugs/show_bug.cgi?id=22468">22468</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>std::function<void()> does not accept non-void-returning functions
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>eugeni.stepanov@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>#include <functional>
int f() { return 42; }
std::function<void()> g(&f);
The above code work with libstdc++, but not with libc++.
It is supposed to work per <a href="http://cplusplus.github.io/LWG/lwg-active.html#2420">http://cplusplus.github.io/LWG/lwg-active.html#2420</a>
It fails with the following error:
error: no matching constructor for initialization of 'std::function<void ()>'
std::function<void()> g(&f);
^ ~~
/code/llvm/build/bin/../include/c++/v1/functional:1448:5: note: candidate
constructor not viable: no known conversion from 'int (*)()' to 'nullptr_t' for
1st argument
function(nullptr_t) _NOEXCEPT : __f_(0) {}
^
/code/llvm/build/bin/../include/c++/v1/functional:1449:5: note: candidate
constructor not viable: no known conversion from 'int (*)()' to 'const
std::__1::function<void ()>' for 1st argument
function(const function&);
^
/code/llvm/build/bin/../include/c++/v1/functional:1450:5: note: candidate
constructor not viable: no known conversion from 'int (*)()' to
'std::__1::function<void ()>' for 1st argument
function(function&&) _NOEXCEPT;
^
/code/llvm/build/bin/../include/c++/v1/functional:1454:41: note: candidate
template ignored: disabled by 'enable_if' [with _Fp = int (*)()]
__callable<_Fp>::value &&
^
/code/llvm/build/bin/../include/c++/v1/functional:1460:7: note: candidate
constructor template not viable: requires 2 arguments, but 1 was provided
function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
^
/code/llvm/build/bin/../include/c++/v1/functional:1463:7: note: candidate
constructor template not viable: requires 3 arguments, but 1 was provided
function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0)
{}
^
/code/llvm/build/bin/../include/c++/v1/functional:1465:7: note: candidate
constructor template not viable: requires 3 arguments, but 1 was provided
function(allocator_arg_t, const _Alloc&, const function&);
^
/code/llvm/build/bin/../include/c++/v1/functional:1467:7: note: candidate
constructor template not viable: requires 3 arguments, but 1 was provided
function(allocator_arg_t, const _Alloc&, function&&);
^
/code/llvm/build/bin/../include/c++/v1/functional:1469:7: note: candidate
constructor template not viable: requires at least 3 arguments, but 1 was
provided
function(allocator_arg_t, const _Alloc& __a, _Fp __f,
^
/code/llvm/build/bin/../include/c++/v1/functional:1446:5: note: candidate
constructor not viable: requires 0 arguments, but 1 was provided
function() _NOEXCEPT : __f_(0) {}</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>