Visual Studio 2015中的编译错误C2228

Compiler Error C2228 in Visual Studio 2015

本文关键字:编译 错误 C2228 Studio 2015 Visual      更新时间:2023-10-16

我正试图在visual studio中编译webrtc代码,并遇到此错误(来自type_traits.h)。代码是:

// Determines if the given class has zero-argument .data() and .size() methods
// whose return values are convertible to T* and size_t, respectively.
template <typename DS, typename T>
class HasDataAndSize {
 private:
     template <
     typename C,
     typename std::enable_if<
     std::is_convertible<decltype(std::declval<C>().data()), T*>::value &&
     std::is_convertible<decltype(std::declval<C>().size()), std::size_t>::value>::type* = nullptr>
  static int Test(int);
  template <typename>
  static char Test(...);
 public:
  static constexpr bool value = std::is_same<decltype(Test<DS>(0)), int>::value;
};

错误是:

错误C2228左'。数据必须有class/struct/union

  • 我如何重写这个模板,使其与visual studio 2015编译器编译?

更新visual studio 2015至更新3已解决此问题。