Skip to content

[libc++] Use hidden friends to avoid circular dependencies in spaceship constrains #104700

Closed
@mordante

Description

@mordante

This as reported in #82113
Per LWG4139

 Consider

    decltype(std::declval<std::chrono::leap_second&>() <=> std::chrono::system_clock::now())

There is a <=> operator for leap second defined as

    template<class Duration>
      requires three_way_comparable_with<sys_seconds, sys_time<Duration>>
      constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y) noexcept;

In order to resolve this overload, we need to check the constraints. three_way_comparable_with will end up checking
that sys_seconds{} < sys_time<Duration>{} is a valid expression. To do that, we run overload resolution, find a bunch
of operator<=>, including the leap_second overload mentioned above. We check its constraints... and we find
ourselves doing that recursively. 

Metadata

Metadata

Assignees

Labels

chronoIssues related to std::chronolibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions