I want to extract a subset from a given bitset, where:
both G(given bitset size) and S(subset size) are known at compile-time
G
>
sizeof(unsigned long long) * 8
S
<=
sizeof(int) * 8
The subset may start anywhere in the given bitset
The resulting subset should be a bitset of the correct size, S
I can isolate the subset using bitwise math but then bitset.to_ullong
does not work because of overflow error.
I know I can use bitset.to_string
and do string manipulations/conversion. What I'm currently doing is extracting bits one-by-one manually (this is enough for my use case).
I'm just interested to know if there are other ways of doing this.