Date: Thu, 12 Mar 2020 11:07:17 +0100
On Thu, Mar 12, 2020 at 01:49:42AM -0400, ramy koudsi via Std-Proposals wrote:
> Hi,
>
> 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.
std::bitset already (since c++11) have a constructor accepting a
std::basic_string.
/MF
> I see its use like:
> std::bitset<80> bigbs(“FFFF95D3FFFFAC27FFFF”);
>
> 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?
>
> Thank you
>
> Ramy
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> Hi,
>
> 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.
std::bitset already (since c++11) have a constructor accepting a
std::basic_string.
/MF
> I see its use like:
> std::bitset<80> bigbs(“FFFF95D3FFFFAC27FFFF”);
>
> 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?
>
> Thank you
>
> Ramy
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2020-03-12 05:10:08