Remove is_invocable static assertions in _Rb_tree?

Jonathan Wakely jwakely@redhat.com
Tue May 29 12:40:00 GMT 2018


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?




More information about the Libstdc++ mailing list