comparing sub-bitsets in C++ -


i have 2 bitsets std::bitset<200> a , std::bitset<200> b , compare bits a[10-60] , b[50-100]. extracting 50 bits in both bitsets 2 bitsets , comparing them following. there better approach?

std::bitset<200> a, b; // , b set std::bitset<50> x, y; for(int i=10; i<=60; i++)   if(a.test(i)) x.set(i); for(int i=50; i<=100; i++)   if(b.test(i)) y.set(i);  if( x == y) .... 

how looping both bitsets, , b, together?

bool same = true; (size_t ai = 10, bi = 50; ai != 60; ++ai, ++bi) {   if (a.test(ai) != b.test(bi) {     same = false;     break;   } } // same denotes if sections of , b equal. 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -