Date: Tue, 24 Jan 2023 20:41:05 +0000
The member function:
std::bitset<N>::to_ullong
takes no arguments. I think there should be an overload which takes an
argument to indicate the index of the starting bit. For example I'm
currently writing code for a microcontroller and I need to keep track
of the status of 256 FPGA addresses, and so I have:
std::bitset<256u> my_bitset;
It would be nice to be able get the 8 most significant bits as follows:
my_bitset.ullong(248u);
and perhaps also allow a negative number, such that the following
would be equivalent:
my_bitset.ullong(-8);
Any maybe even allow a range of bits:
my_bitset.ullong(247, 255);
And if the range is known at compile time, we could have a 'subset'
method as follows:
template<size_t N>
class bitset {
template<size_t a, size_t z>
bitset<z + 1u - a> subset(void);
};
int main(void)
{
bitset<256u> my_bitset;
bitset<8u> my_subset = my_bitset.subset<248u,255u>();
}
std::bitset<N>::to_ullong
takes no arguments. I think there should be an overload which takes an
argument to indicate the index of the starting bit. For example I'm
currently writing code for a microcontroller and I need to keep track
of the status of 256 FPGA addresses, and so I have:
std::bitset<256u> my_bitset;
It would be nice to be able get the 8 most significant bits as follows:
my_bitset.ullong(248u);
and perhaps also allow a negative number, such that the following
would be equivalent:
my_bitset.ullong(-8);
Any maybe even allow a range of bits:
my_bitset.ullong(247, 255);
And if the range is known at compile time, we could have a 'subset'
method as follows:
template<size_t N>
class bitset {
template<size_t a, size_t z>
bitset<z + 1u - a> subset(void);
};
int main(void)
{
bitset<256u> my_bitset;
bitset<8u> my_subset = my_bitset.subset<248u,255u>();
}
Received on 2023-01-24 20:41:17