https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109738

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Scott Zhong from comment #0)
> The debugger showed during resolution of spaceship operator, the implicit
> conversion to const char* for StringWrapper is selected instead of
> StringWrapper::operator<() during insertion into std::map with the key of
> std::list<StringWrapper>.

I think this is the correct C++20 behaviour.

The library checks whether lhs <=> rhs is valid, and if so, it uses that.
Otherwise, it synthesizes a three-way comparison using operator<.

Because your type is implicitly convertible to something that is three-way
comparable, the lhs <=> rhs expression is valid, and so that's what gets used.

Reply via email to