【发布时间】:2015-01-05 07:19:44
【问题描述】:
我有一个 C 风格的数组 unsigned char Temp[SERVER_BUFFER_SIZE],我想将它复制到最后的 std::deque 中(更像是附加它)
std::deque<unsigned char>* buffer = new std::deque<unsigned char>();
std::copy(Temp[0], Temp[SERVER_BUFFER_SIZE], buffer->cend());
我遇到了很多这样的错误:
错误 4 错误 C2825: '_Iter': must be a class or namespace when 后跟 '::' c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility 371 1 a Error 5 error C2039: 'iterator_category' : is not a member of '`global 命名空间'' c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility 371 1 a 错误 9 错误 C2825: '_Iter': 必须是类或命名空间后跟 '::' c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility 372 1 a 错误 12 错误 C2602: 'std::iterator_traits<_init>::value_type' 不是 'std::iterator_traits<_init>' c:\program 基类的成员 文件 (x86)\microsoft visual studio 12.0\vc\include\xutility 372 1 a
【问题讨论】:
-
你为什么使用
new来实例化你的队列? -
这样我就可以将它传递给该函数范围之外的其他地方
-
最好使用
std::unique_ptr<std::deque<unsigned char>>来实现这一点。 -
您可以通过从该函数返回将其传递到该函数范围之外的其他位置。
标签: c++