[Patch] [add changelog] reduce template instantiation depth in <variant>

Jonathan Wakely jwakely@redhat.com
Tue Nov 15 12:11:00 GMT 2016


On 12/11/16 12:39 -0800, Tim Shen wrote:
>On Sat, Nov 12, 2016 at 4:28 AM, Daniel Krügler
><daniel.kruegler@gmail.com> wrote:
>> 2016-11-12 10:04 GMT+01:00 Barrett Adair <barrettellisadair@gmail.com>:
>>>>Currently, std::variant exceeds the default ftemplate-depth parameter when instantiated with 297 types. This small patch increases this ceiling to 446 types (from the bottom of the template stack).
>>>
>>> Sorry, first patch - I just read the guidelines. I changed the format
>>> and added a changelog entry. I hope I did it correctly this time.
>>
>> Let me add that this patch suggestion causes a change in semantics in
>> theory, because fold expressions have no short-circuit evaluation,
>
>Is it a compiler QoI problem, or part of the language? I'd be
>surprised if the language somehow prohibits the short circuits from
>happening.

It's a language feature.

In a fold expression every member of the pack expansion gets
instantiated. If one of them produces an invalid instantiation you get
an error.

Using std::conjunction (or our non-standard std::__and_) instantiation
stops as soon as the result is known (i.e. if one of the conditions is
false).



More information about the Libstdc++ mailing list