[LLVMbugs] [Bug 22468] New: std::function<void()> does not accept non-void-returning functions
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Feb 4 15:54:53 PST 2015
http://llvm.org/bugs/show_bug.cgi?id=22468
Bug ID: 22468
Summary: std::function<void()> does not accept
non-void-returning functions
Product: libc++
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: eugeni.stepanov at gmail.com
CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
Classification: Unclassified
#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 http://cplusplus.github.io/LWG/lwg-active.html#2420
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) {}
--
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/20150204/556ea9ff/attachment.html>
More information about the llvm-bugs
mailing list