I'm compiling a simple (and possibly erroneous) C++ file:
// file test_function.cpp
#include <functional>
void foo()
{
void* (*func)() = nullptr;
std::function<void()> func_(func);
}
I think the type of func_ should be std::function<void*()>
. As expected, clang++ with libc++ gives an error:
$ clang++ -std=c++14 -c -stdlib=libc++ test_function.cpp
test_function.cpp:6:27: error: no matching constructor for initialization of 'std::function<void ()>'
std::function<void()> func_(func);
^ ~~~~
However, g++ and clang++ with libstdc++ gives no errors:
$ clang++ -std=c++14 -c -stdlib=libstdc++ test_function.cpp
$ g++ -std=c++14 -c test_function.cpp
Is the situation normal? Are there descriptions about function type conversion in C++ standards?