为什么VC++编译代码而clang没有?

xml*_*lmx 4 c++ compiler-errors clang visual-c++ c++11

我使用VS 2015(Update 3)编译以下代码:

#include <codecvt>
#include <cctype>
#include <functional>

int main()
{
    std::function<int(int)> fn = std::isspace;
}
Run Code Online (Sandbox Code Playgroud)

如果我使用VC++编译它,那没关系.但是,如果我Visual Studio 2015 - Clang with Microsoft CodeGen (v140_clang_c2)在Visual Studio 中将编译器更改为,则clang会报告错误:

main.cpp(7,26):错误:没有可行的从''转换为'std :: function'

std :: function fn = std :: isspace;

更令人惊讶的是,如果我评论第一行如下,clang也会好的.

//#include <codecvt> // now clang feels happy
#include <cctype>
#include <functional>

int main()
{
    std::function<int(int)> fn = std::isspace;
}
Run Code Online (Sandbox Code Playgroud)

根本原因是什么?

Che*_*Alf 6

std::isspace 在标准库中重载.

由于其标准库头的结构,一个编译器会看到两个不同的名称声明.

然后它的使用没有参数或铸造是不明确的.