gpt4 book ai didi

c++ - 使用 `A::template B x;` 定义变量是否符合 C++ 标准?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:14:10 26 4
gpt4 key购买 nike

<分区>

gcc、vc++ 和 clang 接受以下代码。

template<class T>
struct A
{
template<class U>
struct B
{};
};

int main()
{
A<int>::B<int> y; // OK as expected
A<int>::template B<int> x; // Also OK! Is this standard-compliant?
};

使用 A<int>::template B<int> x; 定义变量是否符合 C++ 标准? ?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com