相关疑难解决方法(0)

在C++ 11中使用decltype()时出错(在gcc 4.7.0中创建不透明的错误消息)

使用以下代码(我的原始代码的简化版本)

#include <iostream>
#include <cmath>

template <typename> class A;                  // edit 1 following Mark & Matthieu
template <typename X> class A {
  X a;
  template <typename> friend class A;         // edit 1 following Mark & Matthieu
public:
  A(X x) : a(x) {}
  X get() const { return a; }                // edit 2 to avoid using A<Y>::a
  template <typename Y>
  auto diff(A<Y> const& y) const
    -> decltype(a - y.a)                       // original code causing error with gcc
    -> typename std::common_type<X, Y>::type  // …
Run Code Online (Sandbox Code Playgroud)

c++ decltype auto c++11

14
推荐指数
2
解决办法
946
查看次数

标签 统计

auto ×1

c++ ×1

c++11 ×1

decltype ×1