我试图使用一个使用深度为3的嵌套向量的类成员:
vector <vector <vector>> classVariable_;
但是,当我尝试执行像classVariable_.clear()这样简单的操作时,我会在整个代码中收到编译器警告:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_vector.h:在成员函数`std :: vector <_Tp,_Alloc>&std :: vector <_Tp,_Alloc> :: operator =(const std :: vector <_Tp,_Alloc>&)[with _Tp = std :: vector>,_ Alloc = std :: allocator >>]':/ usr / lib / gcc / i686-pc-cygwin /3.4.4/include/c++/bits/stl_vector.h:715:警告:'__result'可能在此函数中未初始化使用/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/ bits / stl_uninitialized.h:82:警告:'__cur'可能在此函数中未初始化使用/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82:警告:'__cur'可能在此函数中未初始化使用
奇怪的是,这适用于深度为2的嵌套向量,但深度为3或更高。 这与stl库中缺少默认运算符/构造函数有关吗?
有谁知道围绕这个干净的解决方案? 我正在使用cygwin编译它,但这不会对此产生影响。
谢谢。
I am trying to use a class member that uses nested vectors of depth 3:
vector< vector< vector > > classVariable_;
However, I then get compiler warnings throughout my code when I try do something as simple as classVariable_.clear():
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_vector.h: In member function `std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector >, _Alloc = std::allocator > >]': /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_vector.h:715: warning: '__result' might be used uninitialized in this function /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82: warning: '__cur' might be used uninitialized in this function /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82: warning: '__cur' might be used uninitialized in this function
The strange thing is that this works with nested vectors of depth 2, but not of depth 3 or more. Is this something to do with missing default operators/constructors in the stl libraries?
Does anyone know a clean solution around this? I am compiling this using cygwin but that should not have an effect on this.
Thank you.
最满意答案
如果你实际上是指vector< vector< vector< int> > > classVariable_ ,那么classVariable_.clear()不应该产生任何警告。 可能是这个bug 。
手动禁用警告,或避免深度为3的嵌套向量,这可能不是一个好主意。
If you actually mean vector< vector< vector< int> > > classVariable_, then classVariable_.clear() shouldn't produce any warning. Might be this bug.
Disable the warning manually, or avoid nested vectors of depth 3, which might not be a good idea anyway.
更多推荐
发布评论