Remove is_invocable static assertions in _Rb_tree?
Thu May 31 10:38:00 GMT 2018
On 31/05/18 13:33 +0300, Ville Voutilainen wrote:
>On 31 May 2018 at 13:31, Jonathan Wakely <firstname.lastname@example.org> wrote:
>> Some people are really bad at reading error messages. If the first
>> line is a static assertion with a message it can tell them what's
>> wrong, so they don't just get confused by the errors. But I think we
>> have to just remove the assertions.
>I agree that it looks like we need to remove the asserts, and maybe
>bring some of them back
>somehow in a more limited fashion if we can figure out how to do that,
>which is a bit unlikely.
libc++ has a nice solution, they have similar checks for the
comparison function being invocable as const (per LWG DR 2542) but
they use the Clang diagnose_if extension to produce a warning, not an
error. That means if the types are incomplete you get a warning, but
the code still compiles. If the types are complete by the time the
comparison function is actually used then everything works fine.
Our approach is a fatal static_assert, not just a warning, so even if
the program is actually OK, it won't compile. If we moved the checks
to the member functions that actually use the comparison function then
we'd delay checking until the invocation must be valid. But that means
adding the checks in lots and lots of places. I think the benefit of
the clearer error messages is outweighed by the annoyance of repeating
the checks everywhere.
More information about the Libstdc++