gpt4 book ai didi

c++ - 是否可以模板化 basic_string<>::iterator?

转载 作者:行者123 更新时间:2023-11-30 00:56:46 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Where and why do I have to put the “template” and “typename” keywords?

我使用的是 g++4.6,我尝试根据使用的 char 类型对我的类进行模板化,但我的变量不仅是字符,还有这些字符的字符串。所以我尝试了这样的事情:

template<typename T>
class Node
//...
//constructor
Node(std::basic_string<T> str, std::basic_string<T>::iterator it)
{
}
//usage
Node<char16_t> start;

但是我明白了‘std::basic_string<_CharT, std::char_traits<_CharT>, std::allocator<_Tp1>>::iterator’ 不是类型
当我将构造函数 arg 列表中的第二个 T 替换为 char16_t 时,它会编译。

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