`decltype`含有多个参数的含义 [英] Meaning of `decltype` with more than one argument

查看:170
本文介绍了`decltype`含有多个参数的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了一个 decltype 相关问题及其答案其中
OP和回答者似乎假定
decltype(t,u)是取决于 t u

I have found a decltype-related question and its answers in which both the OP and the answerers seem to assume that decltype(t,u) is something that depends on the types of both t and u.

链接问题中的 decltype(t,u)
是与
兼容的最小类型 t u ,在某种意义上最小兼容
如果它的含义类似于§5(9)中的常见类型或者 std :: common_type c>从§20.9.7.6(3),那么意思是
decltype(true?t:u)

I suppose that the intended meaning of the decltype(t,u) in the linked question is that of a minimal type compatible with both t and u, in some sense of minimal and compatible. If it is meant like a common type as in §5(9) or in the definition of std::common_type from §20.9.7.6(3), then the intended meaning would be decltype(true ? t : u).

但是,似乎C ++ 11只定义了一个参数 decltype
也就是说,解析器指定接受 decltype( 表达式
其中 可以是以逗号分隔的 assignment-expression 列表。
从§7.1.6.2(4)重新读取 decltype 的规范,
我必须解释 decltype ,u) decltype((u))

However, it seems that C++11 defines only a one-argument decltype. That said, the parser is specified to accept decltype( expression ) where expression can be a comma-separated list of assignment-expression. Re-reading the specification of decltype from §7.1.6.2(4), I have to interpret decltype(t,u) as decltype((u)).

decltype(t,u)实际上?我缺少一些东西?

Question: So what is decltype(t,u) actually? Am I missing something?

编辑:作为答案收敛于这是逗号运算符,我仍然想看到
你的判断, decltype((u))(声明类型的引用)或 decltype(u)

As answers converge on "this is the comma operator", I'd still like to see your judgement on whether it's decltype((u)) (a reference to the declared type) or decltype(u) (the declared type). I suspect the former.

推荐答案

这里的逗号是运算符,不是参数分隔符

Comma here is the operator, not argument separator

这篇关于`decltype`含有多个参数的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆