作者:我活该难受G | 来源:互联网 | 2022-12-02 17:25
GCC和clang对此代码持不同意见.
#include
template typename Tpl>
struct storage {
using type_t = T;
template
using storage_tpl = Tpl;
};
template typename>
struct F{
constexpr static int x = 1;
};
template
struct F{
constexpr static int x = 2;
};
int f() {
using S = storage;
static_assert(F().x == 2);
return F().x;
}
根据铿锵S::storage_tpl
不是std::void_t
; 结果,它选择主模板F而不是部分特化,从而选择断言.
乍一看,它看起来像GCC是正确的,因为它知道该嵌套模板仅仅是一个别名std::void_t
,但也许是太聪明,该标准要求S::storage_tpl
和std::void_t
必须是两个不同的模板.
谁是对的?