IntelC++15.0(Linux上)与typedefs和SFINAE的奇怪行为

IntelC++15.0(Linux上)与typedefs和SFINAE的奇怪行为,c++,linux,typedef,sfinae,icc,C++,Linux,Typedef,Sfinae,Icc,最近,我想从g++转换到IntelC++编译器,希望获得更好的性能,但是我却遇到了各种各样的编译器错误。我深入研究了一下,注意到IntelC++编译器的这种奇怪行为 #include <iostream> using namespace std; struct B {}; template<typename T> struct A { operator std::string() const { return "testing"; } }; ty

最近,我想从g++转换到IntelC++编译器,希望获得更好的性能,但是我却遇到了各种各样的编译器错误。我深入研究了一下,注意到IntelC++编译器的这种奇怪行为

#include <iostream>
using namespace std;

struct B {};

template<typename T>
struct A
{
  operator std::string() const
  {
    return "testing";
  }
};

typedef A<B> C;

template<typename T>
struct SupportsStringOperator
{
  typedef char Yes;
  typedef Yes No[2];

  template <typename U, U> struct has;

  template <typename Fun>
  static Yes& fun_test(has<std::string (Fun::*)() const, &Fun::operator std::string>*);

  template <typename Fun>
  static Yes& fun_test(has<std::string (Fun::*)(), &Fun::operator std::string>*);

  template<typename>
  static No& fun_test(...);

  static const bool value = (sizeof(fun_test<T>(0)) == sizeof(Yes));
};

int main()
{
  A<B> a;
  cout << std::is_same<C, A<B>>::value << endl;
  cout << SupportsStringOperator<C>::value << endl;
  cout << SupportsStringOperator<A<B>>::value << endl;
}
仅当您将主功能更改为-

int main()
{
  A<B> a;
  cout << std::is_same<C, A<B>>::value << endl;
  cout << SupportsStringOperator<A<B>>::value << endl;
  cout << SupportsStringOperator<A<B>>::value << endl;
}

这种行为背后有理性吗?g++和clang++为这两个代码生成第二个输出

有点离题我从哪里可以得到编译器?它是免费试用的,这样我也可以重现那个问题。仅仅使用is_convertive有什么错?@AbhinavGauniyal如果你是学生或开源的话,你可以从那里免费得到编译器contributor@T.C.我不明白。为什么我需要是可兑换的?A和C是相同的类型。可以用std::看到的是相同的。因此,这两个代码是相同的。或者我认为它们是相同的,我的意思是使用“可转换”而不是你的自定义文字特征。
int main()
{
  A<B> a;
  cout << std::is_same<C, A<B>>::value << endl;
  cout << SupportsStringOperator<A<B>>::value << endl;
  cout << SupportsStringOperator<A<B>>::value << endl;
}
1
1
1