XOR bitset when 2D bitset is stored as 1D
问题 To answer How to store binary data when you only care about speed?, I am trying to write some to do comparisons, so I want to use std::bitset . However, for fair comparison, I would like a 1D std::bitset to emulate a 2D. So instead of having: bitset<3> b1(string("010")); bitset<3> b2(string("111")); I would like to use: bitset<2 * 3> b1(string("010111")); to optimize data locality. However, now I am having problem with How should I store and compute Hamming distance between binary codes?, as