lundi 27 avril 2015

Construct bitset from array of integers

It's easy to construct a bitset<64> from a uint64_t:

uint64_t flags = ...;
std::bitset<64> bs{flags};

But is there a good way to construct a bitset<64 * N> from a uint64_t[N]?

uint64_t flags[3];
// ... some assignments
std::bitset<192> bs{flags};  // this very unhelpfully compiles
                             // yet is totally invalid

Or am I stuck having to call set() in a loop?

Aucun commentaire:

Enregistrer un commentaire