gpt4 book ai didi

c++ - 为什么这个 CRTP 不能编译?

转载 作者:行者123 更新时间:2023-11-28 00:55:31 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
“Inherited” types using CRTP and typedef

template<typename T>
struct A {
typename T::Sub s;
};

struct B : A<B> {
struct Sub {};
};

Clang 报告此错误:

todo.cc:3:15: error: no type named 'Sub' in 'B'
typename T::Sub s;
~~~~~~~~~~~~^~~
todo.cc:6:12: note: in instantiation of template class 'A<B>' requested here
struct B : A<B> {
^

我怎样才能让它工作?

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