【发布时间】:2021-11-06 01:46:15
【问题描述】:
当我使用 GCC 编译时,它需要设置开关 (A),而 MSVC 和 Clang 找不到 MyType 专业化,反之亦然。谁是对的?
template <std::size_t col_size, auto val>
struct sized_t2 {
// static constexpr std::size_t size = col_size;
// static constexpr auto value = val;
using type = decltype(val);
};
template <typename>
struct MyType;
/* // (A)
#define GCC_CONST const
/*/
#define GCC_CONST
//*/
template <std::size_t col_size, auto val>
struct MyType<GCC_CONST sized_t2<col_size, val>> {
using type = int;
};
template<sized_t2... Cols>
auto Test2()
{
using XXX = std::tuple<typename MyType<decltype(Cols)>::type...>;
(void)XXX{};
return;
}
int main()
{
struct x{};
Test2<sized_t2<42,x{}>{}>();
}
【问题讨论】:
-
@cigien (A) 是关于阻止此代码在主要编译器之一上编译的编译器错误,所以我不能省略它。 (B) 和 (C) 在不同的上下文中是关于同一个主题,问它是同一个问题没有错