decltype(1,t)应该是左值参考吗? (编译器不同意)

问题描述 投票:2回答:1

最小代码:

int t;
static_assert(is_same_v<decltype(1, t), int&>);

以上代码在g ++和clang ++中进行编译,但在MSVC中失败。 MSVC似乎认为:

int t;
static_assert(is_same_v<decltype(1, t), int>);

该标准指定了哪一个?对于SFINAE,我相当依赖此模式。

c++ templates c++17 sfinae decltype
1个回答
0
投票

Gcc和Clang是正确的。 1, tcomma expression

逗号表达式结果的类型,值和值类别恰好是第二个操作数E2的类型,值和值类别。

© www.soinside.com 2019 - 2024. All rights reserved.