我是新的提升。我有一個在lambda函數中使用dynamic_bitset
的程序。在我嘗試運行該程序後,我收到了此消息。即使沒有初始化bitset
及其處理函數的函數,也會顯示此消息。dynamic_bitset,崩潰我的程序
有人知道這個信息的含義是什麼,可能是什麼問題?
消息:
/usr/include/boost/dynamic_bitset/dynamic_bitset.hpp:616:
boost::dynamic_bitset<Block, Allocator>::~dynamic_bitset() [with Block = long unsigned int, Allocator = std::allocator<long unsigned int>]
:斷言'm_check_invariants()'
失敗。 中止
良好的代碼是一樣的東西給這個函數這個
主要電話:
int Molecule::initSimilarity(int depth){
cout << "_size is: " << _size << "\t depth is: " << depth << endl; //TODO delete
AtomSet viewing(_size);
int m = 0;
{
// break into initial groups by symbol and valancy
for(int i=0 ; i<_size ; i++)
{
if(viewing[i]) continue;
AtomSet mask = getSetMask(//AtomSet is typedef for dynamic_bitset
[&](const Atom& b)->bool
{
return (!viewing[b._index] && b._valence == _atoms[i]->_valence && strcmp(b._symbol, _atoms[i]->_symbol) == 0);
},
[&](Atom &b)
{
b._class = m; //set the equivalence class of atom 'b' to 'm'
}
);
m++;
viewing |= mask; //viewing now contains a set of atoms and for each atom it's equivalence class
}
cout << "number of equivalence class: " << m << endl; //TODO DELETE!
}
for (int j = 0; j < depth ; j++){
AtomSet viewed(_size);
int before = m;
// iteratively refine the breakdown into groups
for (int i = 0 ; i < _size ; i++) //for any atom A
{
if (viewed[i]) continue;
viewed.flip(i);
AtomSet mask = getSetMask(//put all atoms which are equivalnt but not similar to A in
//their own equivalence class
[&](const Atom& b)->bool
{
if (viewed[b._index])
return false; //if b is in viewed return false;
if (_atoms[i]->_class == b._class) //if in the same class add b to viewed
{
viewed.flip(b._index);
bool similar = !isSimilar(*_atoms[i],b);
return similar;
}
return false;
},
[&m](Atom& b)
{
b._class = m;
}
);
if (!mask.none()) m++;
}
if (before == m){
std::cout << "Finished early after just " << j << " iterations" << std::endl;
return m;
}
}
return m;
}
getSetMask的簽名是: AtomSet getSetMask(STD ::功能特性,標準::功能行動);
,而最古怪的事情,即使我刪除該功能的所有內容仍然給我的錯誤信息
如果您希望人們發現錯誤,您應該發佈產生錯誤的代碼。 – sth
如果在沒有該功能的情況下錯誤仍然存在,那麼問題的根源可能不在該功能中。此外,代碼沒有提及任何'dynamic_bitset'。另外:getSetMask()用這些lambda函數做什麼?它是否存儲在某個地方? – sth
對不起,你是對的。 AtomSet是dynamic_bitset的typedef。我會eddit –