【问题标题】:Compiler Error C2228 in Visual Studio 2015Visual Studio 2015 中的编译器错误 C2228
【发布时间】:2016-11-03 11:17:39
【问题描述】:

我正在尝试在 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;
};

错误是:

'.data' 左侧的错误 C2228 必须具有类/结构/联合

  • 如何重新编写此模板以使其与 Visual Studio 2015 编译器一起编译?

【问题讨论】:

    标签: c++ visual-studio visual-studio-2015 webrtc


    【解决方案1】:

    将 Visual Studio 2015 更新为更新 3 解决了此问题。

    【讨论】:

      猜你喜欢
      • 2016-08-30
      • 1970-01-01
      • 2017-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多