gpt4 book ai didi

c++ - dynamic_bitset,让我的程序崩溃

转载 作者:搜寻专家 更新时间:2023-10-31 01:18:33 25 4
gpt4 key购买 nike

我是 boost 的新手。我有一个使用 dynamic_bitset 的程序在 lambda 函数中。在我尝试运行该程序后,我收到了这条消息。即使没有初始化 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>]: Assertion 'm_check_invariants()' failed. Aborted

代码是这样的
对该函数的主要调用:

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::function property, std::function action);

最奇怪的是,即使我删除了该函数的所有内容,它仍然给我错误消息

最佳答案

可能您在 lambda 中引用的 dynamic_bitset 变量已经超出范围并且已经被销毁,或者类似的东西。 (没有源码很难说得更具体)

关于c++ - dynamic_bitset,让我的程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7026347/

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