This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Remove is_invocable static assertions in _Rb_tree?
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Tue, 29 May 2018 13:40:08 +0100
- Subject: Remove is_invocable static assertions in _Rb_tree?
I added these to _Rb_tree to try and help users who don't understand
why they get errors for invalid comparison functions:
#if __cplusplus >= 201103L
static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{},
"comparison object must be invocable with two arguments of key type");
# if __cplusplus >= 201703L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2542. Missing const requirements for associative containers
static_assert(is_invocable_v<const _Compare&, const _Key&, const _Key&>,
"comparison object must be invocable as const");
# endif // C++17
#endif // C++11
But the assertions fail for code that isn't obviously ill-formed e.g.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85965
We could move the assertions later, so they only happen when the
comparison function is actually invoked. That might still give better
diagnostics than the ill-formed call to the function. But it would
mean duplicating them in lots of places (or at least putting them in
some new function and calling that function from lots of places).
Or we could just remove those assertions.
Any other ideas?