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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to