【发布时间】:2015-05-27 16:12:17
【问题描述】:
我想在 std::vector 中存储三个任意整数而不定义结构/类。所以我选择了 std::tuple:
std::vector<std::tuple<unsigned int, unsigned int, unsigned int>
使用MS VS 2013,会导致如下错误:
>c:\program files (x86)\microsoft visual studio 12.0\vc\include\vector(1628): error C2036: 'std::tuple<unsigned int,unsigned int,unsigned int> *' : unknown size
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\vector(1622) : while compiling class template member function 'void std::vector<std::tuple<unsigned int,unsigned int,unsigned int>,std::allocator<_Ty>>::_Tidy(void)'
1> with
1> [
1> _Ty=std::tuple<unsigned int,unsigned int,unsigned int>
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\vector(945) : see reference to function template instantiation 'void std::vector<std::tuple<unsigned int,unsigned int,unsigned int>,std::allocator<_Ty>>::_Tidy(void)' being compiled
1> with
1> [
1> _Ty=std::tuple<unsigned int,unsigned int,unsigned int>
1> ]
1> d:\projects\gl33\src\nvf.cpp(39) : see reference to class template instantiation 'std::vector<std::tuple<unsigned int,unsigned int,unsigned int>,std::allocator<_Ty>>' being compiled
1> with
1> [
1> _Ty=std::tuple<unsigned int,unsigned int,unsigned int>
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =======
这是因为 MSVS2013 编译器的限制吗?还是我做错了什么?
【问题讨论】:
-
我猜你忘了包含
<tuple>标头:#include <tuple>- 当只包含<vector>而不是<tuple>时,我可以重现您的错误消息。 -
该死,你是对的。只是以为已经被收录了。感谢您的评论。你会重新发布一个我可以标记为已解决的答案吗?
标签: c++11 vector visual-studio-2013 tuples