gpt4 book ai didi

c++ - 使用 std::deque 时出错

转载 作者:行者123 更新时间:2023-11-30 01:19:17 24 4
gpt4 key购买 nike

当我在我的类中使用 std::deque 作为私有(private)成员时,我会遇到很多错误,比如

/usr/include/c++/v1/deque:907:49: error: implicit instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >'
static const difference_type __block_size = sizeof(value_type) < 256 ? 4096 / sizeof(value_type) : 16;

/usr/include/c++/v1/deque:1181:30: error: '__alloc_traits' is a protected member of 'std::__1::__deque_base<std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >'
typedef typename __base::__alloc_traits __alloc_traits;

等等。

当我使用 vector 时它可以工作,但我想要 pop_front 功能。

有什么想法吗?

编辑:
代码:

#include <deque>
class Example {
public:
Example() {}
~Example() {}
private:
std::deque<std::string> m_deque;
};

最佳答案

您必须包括 #include <string>

关于c++ - 使用 std::deque<std::string> 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21099348/

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