PR libstdc++/90945 Patch to have pretty printer for std::vector<bool> return bool intead of int for elements

Jonathan Wakely jwakely@redhat.com
Wed Jun 19 22:59:00 GMT 2019


On 19/06/19 21:58 +0200, Michael Weghorn wrote:
>On 19/06/2019 21.54, Jonathan Wakely wrote:
>>>> +  std::vector<bool> vb;
>>>> +  vb.reserve(100);
>>>> +  vb.push_back(true);
>>>> +  vb.push_back(true);
>>>> +  vb.push_back(false);
>>>> +  vb.push_back(false);
>>>> +  vb.push_back(true);
>>>> +  vb.erase(vb.begin());
>>>> +// { dg-final { regexp-test vb {std::(__debug::)?vector of length 4,
>>>> capacity 100 = \\{true, false, false, true\\}} } }
>>>> +
>>>
>>> This inserts 5 elements, so I'd expect that either "vector of length 5"
>>> and an additional "true" element at the beginning need to be added for
>>> the expected result or one of the two first 'vb.push_back(true)' needs
>>> to be removed.
>>
>> It inserts five then erases one, the test is right.
>>
>> Except that it should be capacity=128, because the capacity increases
>> in units of 64 bits. of course.
>
>Yes, of course. Sorry, I was missing that.

Here's the patch that I've committed to trunk, after testing.

This is probably OK to backport to the release branches as well, so
I'll add that to my TODO list.

Thanks again for the patch!


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 4579 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190619/dd980d2e/attachment.bin>


More information about the Libstdc++ mailing list