Skip to content

makes most operators hidden friends #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

cjdb
Copy link
Contributor

@cjdb cjdb commented Apr 30, 2025

This ensures that they're not placed in their function names' respective overload sets, which has a considerable impact on build times and on compiler diagnostics (as they're not listed as failed candidates when overload resolution fails).

cjdb added 5 commits April 30, 2025 19:58
This ensures that they're not placed in their function names' respecitve
overload sets, which has a considerable impact on build times and on
compiler diagnostics (as they're not listed as failed candidates when
overload resolution fails).
Running an include tracer indicated that placing `size_hint_impl.h` in
this header should prevent link-time errors when attempting to
incidentally format `SizeHint`.
@cjdb cjdb force-pushed the hidden-friend-operators branch from c8fe86b to 438c023 Compare May 1, 2025 23:25
@@ -910,6 +910,9 @@ class Choice<__private::TypeList<Ts...>, Tags...> final {
const Choice<__private::TypeList<RhsTs...>, RhsTag, RhsTags...>& r) =
delete;

// Stream support
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Stream support
// Stream support.

Comment on lines 64 to +66
} // namespace __private

namespace __private {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can avoid closing and opening the namespace here

/// #[doc.overloads=array.cmp.array]
template <class U>
requires(::sus::cmp::ExclusiveStrongOrd<T, U>)
constexpr friend std::strong_ordering operator<=>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we write friend constexpr as the order for these keywords consistently (the one above is in that order)?

std::make_index_sequence<N>());
}

// Stream support
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Stream support
// Stream support.

@@ -36,7 +36,8 @@ struct VarError {
Reason reason;

/// Satisfies the [`Eq`]($sus::cmp::Eq) concept.
constexpr bool operator==(const VarError& rhs) const noexcept = default;
constexpr friend bool operator==(const VarError& lhs,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constexpr friend bool operator==(const VarError& lhs,
friend constexpr bool operator==(const VarError& lhs,

} // namespace sus

// fmt support.
template <class Char>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question - can this go to the bottom?

@@ -748,6 +748,47 @@ _sus_pure constexpr _self _self::from_ne_bytes(
return _self(val);
}

_sus_pure constexpr u32 _self::count_ones() const& noexcept {
return __private::count_ones(primitive_value);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did these bodies need to move?

@@ -0,0 +1,56 @@
// Copyright 2023 Google LLC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright 2023 Google LLC
// Copyright 2025 Google LLC

@@ -60,3 +60,5 @@
#define _pointer 1
#define _primitive ::sus::num::__private::ptr_type<::sus::mem::size_of<uintptr_t>()>::unsigned_type
#include "sus/num/__private/unsigned_integer_methods_impl.inc"
// Comment to prevent clang-format from deleting this line and sorting includes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Comment to prevent clang-format from deleting this line and sorting includes
// This must come last, after the types are fully defined.

@@ -775,6 +775,7 @@ class [[nodiscard]] Result final {
{
return eq(l, r);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants