Why is this std::bind not converted to std::function?

Posted by dauphic on Stack Overflow See other posts from Stack Overflow or by dauphic
Published on 2012-11-28T22:53:41Z Indexed on 2012/11/28 23:03 UTC
Read the original article Hit count: 224

Filed under:
|
|
|
|

Why is the nested std::bind in the below code not implicitly converted to an std::function<void()> by any of the major compilers (VS2010/2012, gcc, clang)? Is this standard behavior, or a bug?

#include <functional>

void bar(int, std::function<void()>) { }
void foo() { }

int main()
{
    std::function<void(int, std::function<void()>)> func;
    func = std::bind(bar, 5, std::bind(foo));

    std::cin.get();
    return 0;
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about function