Why is VC ++ compiling code, but clang not?

I am using VS 2015 (update 3) to compile the following code:

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

int main()
{
    std::function<int(int)> fn = std::isspace;
}

If I use VC ++ to compile it, that's fine. However, if I changed the compiler to Visual Studio 2015 - Clang with Microsoft CodeGen (v140_clang_c2)in Visual Studio, clang reports an error:

main.cpp (7,26): error: no viable conversion from '' to 'std :: function'

std :: function fn = std :: isspace;

More surprisingly, if I comment on the first line as follows, clang will also be fine.

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

int main()
{
    std::function<int(int)> fn = std::isspace;
}

What is the reason?

+4
source share
2 answers

std::isspace overloaded in the standard library.

- .

.

+6

std::isspace , , <cctype>, C, , <locale>.

std::function<int(int)> fn = static_cast<int(*)(int)>(std::isspace);

, std::, C .

Clang GCC <codecvt> <locale>, , ; VS .

+4

Source: https://habr.com/ru/post/1653499/


All Articles