Subject: [std-proposals] Extending std::bitset
From: ramy koudsi (rkoudsi1_at_[hidden])
Date: 2020-03-12 00:49:42
std::bitset does not have a size limit, however it has an initialization size limit. Bitsets cannot currently be initialized with anything bigger than a long long int.
To remove this limitation I propose adding another constructor that accepts a std::string object.
I see its use like:
The example above uses hex strings, but can easily be changed to accept strings of any base by adding another constructor accepting a string and an argument showing the base.
std::bitset<12> littlebs(âAFDâ, 16);
In addition, a member function to_string(int base) would be nice.
std::string littlestr = littlebs.to_string(16);
// littlestr is âAFDâ
I wanted to hear your thoughts about this. Has anyone thought of this and come up with a better solution?
STD-PROPOSALS list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups