i != boost::dynamic_bitset<>::npos; 这行代码是什么意思?
void StudyWidgets::GetPrime(int num){
boost::dynamic_bitset<> db(num);//0000000000
db.set();//1111111111
for (auto i = db.find_next(1); i != boost::dynamic_bitset<>::npos; i = db.find_next(i))
{
for (auto j = db.find_next(i); j != boost::dynamic_bitset<>::npos; j = db.find_next(j))
{
if (j%i == 0)
{
db[j] = 0;
}
}
//索引: 9 8 7 6 5 4 3 2 1 0
//i = 2时:1 0 1 0 1 0 1 1 1 1
//i = 3时:0 0 1 0 1 0 1 1 1 1
//i = 5时:0 0 1 0 1 0 1 1 1 1
//i = 7时:0 0 1 0 1 0 1 1 1 1
std::cout << std::endl << "i=" << i << "时:";
for (size_t m = db.size() - 1; m >= 0 && m < db.size(); m--)//注意条件,因为当m=0时,m--后 m=18446744073709551615
{
std::cout << db[m] << " ";
}
}
std::cout << std::endl;
//0010101111
for (auto i = db.find_next(1); i != boost::dynamic_bitset<>::npos; i = db.find_next(i))
{
std::cout << i; //2 3 5 7
}
}