Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

What's the problem with this?

Language: Layout:
+ ] Compiler args + ] Show input
Compilation time: 0.22 sec, absolute service time: 0,37 sec 
edit mode |  history  | discussion
Error(s):
source_file.cpp:16:14: error: no matching conversion for functional-style cast from 'void (*)(Foo)' to 'std::function<void (Foo)>'
    auto f = std::function<void(Foo)>(&func);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/v1/functional:1448:5: note: candidate constructor not viable: no known conversion from 'void (*)(Foo)' to 'nullptr_t' for 1st argument
    function(nullptr_t) _NOEXCEPT : __f_(0) {}
    ^
/usr/include/c++/v1/functional:1449:5: note: candidate constructor not viable: no known conversion from 'void (*)(Foo)' to 'const std::__1::function<void (Foo)>' for 1st argument
    function(const function&);
    ^
/usr/include/c++/v1/functional:1450:5: note: candidate constructor not viable: no known conversion from 'void (*)(Foo)' to 'std::__1::function<void (Foo)>' for 1st argument
    function(function&&) _NOEXCEPT;
    ^
/usr/include/c++/v1/functional:1454:41: note: candidate template ignored: disabled by 'enable_if' [with _Fp = void (*)(Foo)]
                                        __callable<_Fp>::value &&
                                        ^
/usr/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) {}
      ^
/usr/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) {}
      ^
/usr/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&);
      ^
/usr/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&&);
      ^
/usr/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,
      ^
/usr/include/c++/v1/functional:1446:5: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
    function() _NOEXCEPT : __f_(0) {}
    ^
1 error generated.

        

    
                
λ
.NET NoSQL database for rapid development