vendredi 2 septembre 2016

Why does VC++ compile the code while clang doesn't?

I use 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, it's ok. However, if I change 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 surprising, if I comments the first line as follows, clang will also be ok.

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

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

What's the root cause?

Aucun commentaire:

Enregistrer un commentaire