输入性状以获取操作员的晋升结果

创意帽

C ++运算符中的隐式类型转换规则

列出C ++的隐式类型转换。

因此,问题是,是否存在可以执行该表的类型特征?类似的东西

template <typename T, typename J>
struct promotion_type
{
  typedef decltype(operator+(const T&,const J&)) type;
};

(不是我的问题,但这不能编译:

/home/user/source/testdir/main.cpp:97:51: error: there are no arguments to 'operator+' that depend on a template parameter, so a declaration of 'operator+' must be available [-fpermissive]
   typedef decltype(operator+(const T&,const J&)) type;
                                               ^
/home/user/source/testdir/main.cpp:97:51: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)

克瑞克(Kerrek SB)

怎么decltype(std::declval<T>() + std::declval<J>())

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章