作者:無名--小貞貞貞貞貞貞貞貞_微博_ | 来源:互联网 | 2022-12-06 18:24
当使用模板别名作为声明部分特化的模板类的参数时,我面临着某种意外的结果.在某些情况下,我甚至观察到GCC 8.2和Clang 6.0.0不同意结果.可以在下面找到说明我的案例的代码.
// A template struct named Foo.
template
struct Foo {};
// A template alias for type Foo.
template
using AliasFoo = Foo;
// A variadic template alias for type Foo.
template
using VariadicAliasFoo = Foo;
// A template struct named Bar.
template class TEMPLATE, typename TYPE>
struct Bar
{
static constexpr bool value = false;
};
// Partial specialization of template struct Bar.
template class TEMPLATE, typename... ARGS>
struct Bar >
{
static constexpr bool value = true;
};
// The main function.
int main()
{
// These compile time assertions are satisfied (as expected).
static_assert(Bar >::value, "");
static_assert(Bar >::value, "");
static_assert(Bar >::value, "");
// These compile time assertions fails with Clang 6.0.0 but succeed with GCC 8.2
static_assert(Bar >::value, "");
static_assert(Bar >::value, "");
static_assert(Bar >::value, "");
// These compile time assertions fails with Clang 6.0.0 and GCC 8.2.
static_assert(Bar >::value, "");
static_assert(Bar >::value, "");
static_assert(Bar >::value, "");
// Always return zero.
return 0;
}
我的问题是,根据标准(c ++ 17),上面代码中最后六个编译时断言的结果应该是什么?