Skip to content

Commit

Permalink
Clean up docs on friend overloads for numerics
Browse files Browse the repository at this point in the history
  • Loading branch information
danakj committed Sep 11, 2023
1 parent 295944f commit 843340d
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 80 deletions.
10 changes: 5 additions & 5 deletions sus/num/__private/float_methods.inc
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ sus_pure constexpr inline _self operator-() const {
return _self(-primitive_value);
}

/// Satisfies the [`Add<@doc.self>`]($sus::num::Add) concept.
/// Satisfies the [`Add`]($sus::num::Add) concept for floating point values.
/// #[doc.overloads=float.+]
[[nodiscard]] sus_pure friend constexpr inline _self operator+(
_self l, _self r) noexcept {
Expand Down Expand Up @@ -345,7 +345,7 @@ friend constexpr inline _self operator+(_self l, U r) noexcept = delete;
template <PrimitiveFloat U>
requires(!std::convertible_to<U, _self>)
friend constexpr inline _self operator+(U l, _self r) noexcept = delete;
/// Satisfies the [`Sub<@doc.self>`]($sus::num::Sub) concept.
/// Satisfies the [`Sub`]($sus::num::Sub) concept for floating point values.
/// #[doc.overloads=float.-]
[[nodiscard]] sus_pure friend constexpr inline _self operator-(
_self l, _self r) noexcept {
Expand Down Expand Up @@ -373,7 +373,7 @@ friend constexpr inline _self operator-(_self l, U r) noexcept = delete;
template <PrimitiveFloat U>
requires(!std::convertible_to<U, _self>)
friend constexpr inline _self operator-(U l, _self r) noexcept = delete;
/// Satisfies the [`Mul<@doc.self>`]($sus::num::Mul) concept.
/// Satisfies the [`Mul`]($sus::num::Mul) concept for floating point values.
/// #[doc.overloads=float.*]
[[nodiscard]] sus_pure friend constexpr inline _self operator*(
_self l, _self r) noexcept {
Expand Down Expand Up @@ -401,7 +401,7 @@ friend constexpr inline _self operator*(_self l, U r) noexcept = delete;
template <PrimitiveFloat U>
requires(!std::convertible_to<U, _self>)
friend constexpr inline _self operator*(U l, _self r) noexcept = delete;
/// Satisfies the [`Div<@doc.self>`]($sus::num::Div) concept.
/// Satisfies the [`Div`]($sus::num::Div) concept for floating point values.
/// #[doc.overloads=float./]
[[nodiscard]] sus_pure friend constexpr inline _self operator/(
_self l, _self r) noexcept {
Expand Down Expand Up @@ -429,7 +429,7 @@ friend constexpr inline _self operator/(_self l, U r) noexcept = delete;
template <PrimitiveFloat U>
requires(!std::convertible_to<U, _self>)
friend constexpr inline _self operator/(U l, _self r) noexcept = delete;
/// Satisfies the [`Rem<@doc.self>`]($sus::num::Rem) concept.
/// Satisfies the [`Rem`]($sus::num::Rem) concept for floating point values.
///
/// The remainder from the division of two floats.
///
Expand Down
84 changes: 47 additions & 37 deletions sus/num/__private/signed_integer_methods.inc
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,12 @@ sus_pure constexpr inline _self operator~() const& noexcept {
__private::unchecked_not(__private::into_unsigned(primitive_value)));
}

/// Satisfies the [`Add<@doc.self>`]($sus::num::Add) concept.
/// Satisfies the [`Add`]($sus::num::Add) concept for signed integers.
///
/// This operation supports working with primitive signed or unsigned integers
/// that convert to `@doc.self`, as well as enums. However enum class is
/// excluded as they require an explicit conversion to a `@doc.self`.
/// This operation supports shifting with primitive signed or unsigned integers
/// that convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=signedint.+]
[[nodiscard]] sus_pure_const friend constexpr inline _self operator+(
Expand Down Expand Up @@ -600,11 +601,12 @@ template <class U>
requires((PrimitiveInteger<U> || PrimitiveEnum<U>) &&
!std::convertible_to<U, _self>)
friend constexpr inline _self operator+(U l, _self r) noexcept = delete;
/// Satisfies the [`Sub<@doc.self>`]($sus::num::Sub) concept.
/// Satisfies the [`Sub`]($sus::num::Sub) concept for signed integers.
///
/// This operation supports working with primitive signed or unsigned integers
/// that convert to `@doc.self`, as well as enums. However enum class is
/// excluded as they require an explicit conversion to a `@doc.self`.
/// This operation supports shifting with primitive signed or unsigned integers
/// that convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=signedint.-]
[[nodiscard]] sus_pure friend constexpr inline _self operator-(
Expand Down Expand Up @@ -639,11 +641,12 @@ template <class U>
requires((PrimitiveInteger<U> || PrimitiveEnum<U>) &&
!std::convertible_to<U, _self>)
friend constexpr inline _self operator-(U l, _self r) noexcept = delete;
/// Satisfies the [`Mul<@doc.self>`]($sus::num::Mul) concept.
/// Satisfies the [`Mul`]($sus::num::Mul) concept for signed integers.
///
/// This operation supports working with primitive signed or unsigned integers
/// that convert to `@doc.self`, as well as enums. However enum class is
/// excluded as they require an explicit conversion to a `@doc.self`.
/// This operation supports shifting with primitive signed or unsigned integers
/// that convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=signedint.*]
[[nodiscard]] sus_pure friend constexpr inline _self operator*(
Expand Down Expand Up @@ -678,11 +681,12 @@ template <class U>
requires((PrimitiveInteger<U> || PrimitiveEnum<U>) &&
!std::convertible_to<U, _self>)
friend constexpr inline _self operator*(U l, _self r) noexcept = delete;
/// Satisfies the [`Div<@doc.self>`]($sus::num::Div) concept.
/// Satisfies the [`Div`]($sus::num::Div) concept for signed integers.
///
/// This operation supports working with primitive signed or unsigned integers
/// that convert to `@doc.self`, as well as enums. However enum class is
/// excluded as they require an explicit conversion to a `@doc.self`.
/// This operation supports shifting with primitive signed or unsigned integers
/// that convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=signedint./]
[[nodiscard]] sus_pure friend constexpr inline _self operator/(
Expand Down Expand Up @@ -717,11 +721,12 @@ template <class U>
requires((PrimitiveInteger<U> || PrimitiveEnum<U>) &&
!std::convertible_to<U, _self>)
friend constexpr inline _self operator/(U l, _self r) noexcept = delete;
/// Satisfies the [`Rem<@doc.self>`]($sus::num::Rem) concept.
/// Satisfies the [`Rem`]($sus::num::Rem) concept for signed integers.
///
/// This operation supports working with primitive signed or unsigned integers
/// that convert to `@doc.self`, as well as enums. However enum class is
/// excluded as they require an explicit conversion to a `@doc.self`.
/// This operation supports shifting with primitive signed or unsigned integers
/// that convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=signedint.%]
[[nodiscard]] sus_pure friend constexpr inline _self operator%(
Expand Down Expand Up @@ -757,11 +762,12 @@ template <class U>
!std::convertible_to<U, _self>)
friend constexpr inline _self operator%(U l, _self r) noexcept = delete;

/// Satisfies the [`BitAnd<@doc.self>`]($sus::num::BitAnd) concept.
/// Satisfies the [`BitAnd`]($sus::num::BitAnd) concept for signed integers.
///
/// This operation supports working with primitive signed or unsigned integers
/// that convert to `@doc.self`, as well as enums. However enum class is
/// excluded as they require an explicit conversion to a `@doc.self`.
/// This operation supports shifting with primitive signed or unsigned integers
/// that convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=signedint.&]
[[nodiscard]] sus_pure friend constexpr inline _self operator&(
Expand Down Expand Up @@ -792,11 +798,12 @@ template <class U>
requires((PrimitiveInteger<U> || PrimitiveEnum<U>) &&
!std::convertible_to<U, _self>)
friend constexpr inline _self operator&(U l, _self r) noexcept = delete;
/// Satisfies the [`BitOr<@doc.self>`]($sus::num::BitOr) concept.
/// Satisfies the [`BitOr`]($sus::num::BitOr) concept for signed integers.
///
/// This operation supports working with primitive signed or unsigned integers
/// that convert to `@doc.self`, as well as enums. However enum class is
/// excluded as they require an explicit conversion to a `@doc.self`.
/// This operation supports shifting with primitive signed or unsigned integers
/// that convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=signedint.|]
[[nodiscard]] sus_pure friend constexpr inline _self operator|(
Expand Down Expand Up @@ -827,11 +834,12 @@ template <class U>
requires((PrimitiveInteger<U> || PrimitiveEnum<U>) &&
!std::convertible_to<U, _self>)
friend constexpr inline _self operator|(U l, _self r) noexcept = delete;
/// Satisfies the [`BitXor<@doc.self>`]($sus::num::BitXor) concept.
/// Satisfies the [`BitXor`]($sus::num::BitXor) concept for signed integers.
///
/// This operation supports working with primitive signed or unsigned integers
/// that convert to `@doc.self`, as well as enums. However enum class is
/// excluded as they require an explicit conversion to a `@doc.self`.
/// This operation supports shifting with primitive signed or unsigned integers
/// that convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=signedint.^]
[[nodiscard]] sus_pure friend constexpr inline _self operator^(
Expand Down Expand Up @@ -862,12 +870,14 @@ template <class U>
requires((PrimitiveInteger<U> || PrimitiveEnum<U>) &&
!std::convertible_to<U, _self>)
friend constexpr inline _self operator^(U l, _self r) noexcept = delete;
/// Satisfies the [`Shl<@doc.self>`]($sus::num::Shl) concept.
/// Satisfies the [`Shl`]($sus::num::Shl) concept for signed integers.
///
/// This operation supports shifting with primitive signed or unsigned integers
/// that convert to `u32`, as well as enums. However enum class is excluded
/// as they require an explicit conversion to a `u32`. Thus the bound is
/// `std::convertible_to` (implicit conversion) instead of
/// that convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// Thus the bound is `std::convertible_to` (implicit conversion) instead of
/// `sus::construct::From` (explicit conversion).
///
/// #[doc.overloads=signedint.<<]
Expand All @@ -884,7 +894,7 @@ template <class U>
requires(!std::convertible_to<U, u32>)
[[nodiscard]] sus_pure friend constexpr inline _self operator<<(
_self l, U r) noexcept = delete;
/// Satisfies the [`Shr<@doc.self>`]($sus::num::Shr) concept.
/// Satisfies the [`Shr`]($sus::num::Shr) concept for signed integers.
///
/// #[doc.overloads=signedint.>>]
[[nodiscard]] sus_pure friend constexpr inline _self operator>>(
Expand Down
60 changes: 34 additions & 26 deletions sus/num/__private/unsigned_integer_methods.inc
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,12 @@ sus_pure constexpr inline _self operator~() const& noexcept {
return _self(__private::unchecked_not(primitive_value));
}

/// Satisfies the [`Add<@doc.self>`]($sus::num::Add) concept.
/// Satisfies the [`Add`]($sus::num::Add) concept for unsigned integers.
///
/// This operation supports working with primitive unsigned integers that
/// convert to @doc.self, as well as enums. However enum class is excluded as
/// they require an explicit conversion to a @doc.self.
/// convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=unsignedint.+]
[[nodiscard]] sus_pure friend constexpr inline _self operator+(
Expand Down Expand Up @@ -639,11 +640,12 @@ template <class U>
!((UnsignedPrimitiveInteger<U> || UnsignedPrimitiveEnum<U>) && //
::sus::mem::size_of<U>() <= ::sus::mem::size_of<_primitive>()))
friend constexpr inline _self operator+(U l, _self r) noexcept = delete;
/// Satisfies the [`Sub<@doc.self>`]($sus::num::Sub) concept.
/// Satisfies the [`Sub`]($sus::num::Sub) concept for unsigned integers.
///
/// This operation supports working with primitive unsigned integers that
/// convert to @doc.self, as well as enums. However enum class is excluded as
/// they require an explicit conversion to a @doc.self.
/// convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=unsignedint.-]
[[nodiscard]] sus_pure friend constexpr inline _self operator-(
Expand Down Expand Up @@ -684,11 +686,12 @@ template <class U>
!((UnsignedPrimitiveInteger<U> || UnsignedPrimitiveEnum<U>) && //
::sus::mem::size_of<U>() <= ::sus::mem::size_of<_primitive>()))
friend constexpr inline _self operator-(U l, _self r) noexcept = delete;
/// Satisfies the [`Mul<@doc.self>`]($sus::num::Mul) concept.
/// Satisfies the [`Mul`]($sus::num::Mul) concept for unsigned integers.
///
/// This operation supports working with primitive unsigned integers that
/// convert to @doc.self, as well as enums. However enum class is excluded as
/// they require an explicit conversion to a @doc.self.
/// convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=unsignedint.*]
[[nodiscard]] sus_pure friend constexpr inline _self operator*(
Expand Down Expand Up @@ -729,11 +732,12 @@ template <class U>
!((UnsignedPrimitiveInteger<U> || UnsignedPrimitiveEnum<U>) && //
::sus::mem::size_of<U>() <= ::sus::mem::size_of<_primitive>()))
friend constexpr inline _self operator*(U l, _self r) noexcept = delete;
/// Satisfies the [`Div<@doc.self>`]($sus::num::Div) concept.
/// Satisfies the [`Div`]($sus::num::Div) concept for unsigned integers.
///
/// This operation supports working with primitive unsigned integers that
/// convert to @doc.self, as well as enums. However enum class is excluded as
/// they require an explicit conversion to a @doc.self.
/// convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=unsignedint./]
[[nodiscard]] sus_pure friend constexpr inline _self operator/(
Expand Down Expand Up @@ -772,11 +776,12 @@ template <class U>
!((UnsignedPrimitiveInteger<U> || UnsignedPrimitiveEnum<U>) && //
::sus::mem::size_of<U>() <= ::sus::mem::size_of<_primitive>()))
friend constexpr inline _self operator/(U l, _self r) noexcept = delete;
/// Satisfies the [`Rem<@doc.self>`]($sus::num::Rem) concept.
/// Satisfies the [`Rem`]($sus::num::Rem) concept for unsigned integers.
///
/// This operation supports working with primitive unsigned integers that
/// convert to @doc.self, as well as enums. However enum class is excluded as
/// they require an explicit conversion to a @doc.self.
/// convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=unsignedint.%]
[[nodiscard]] sus_pure friend constexpr inline _self operator%(
Expand Down Expand Up @@ -816,11 +821,12 @@ template <class U>
::sus::mem::size_of<U>() <= ::sus::mem::size_of<_primitive>()))
friend constexpr inline _self operator%(U l, _self r) noexcept = delete;

/// Satisfies the [`BitAnd<@doc.self>`]($sus::num::BitAnd) concept.
/// Satisfies the [`BitAnd`]($sus::num::BitAnd) concept for unsigned integers.
///
/// This operation supports working with primitive unsigned integers that
/// convert to @doc.self, as well as enums. However enum class is excluded as
/// they require an explicit conversion to a @doc.self.
/// convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=unsignedint.&]
[[nodiscard]] sus_pure friend constexpr inline _self operator&(
Expand Down Expand Up @@ -857,11 +863,12 @@ template <class U>
!((UnsignedPrimitiveInteger<U> || UnsignedPrimitiveEnum<U>) && //
::sus::mem::size_of<U>() <= ::sus::mem::size_of<_primitive>()))
friend constexpr inline _self operator&(U l, _self r) noexcept = delete;
/// Satisfies the [`BitOr<@doc.self>`]($sus::num::BitOr) concept.
/// Satisfies the [`BitOr`]($sus::num::BitOr) concept for unsigned integers.
///
/// This operation supports working with primitive unsigned integers that
/// convert to @doc.self, as well as enums. However enum class is excluded as
/// they require an explicit conversion to a @doc.self.
/// convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=unsignedint.|]
[[nodiscard]] sus_pure friend constexpr inline _self operator|(
Expand Down Expand Up @@ -898,11 +905,12 @@ template <class U>
!((UnsignedPrimitiveInteger<U> || UnsignedPrimitiveEnum<U>) && //
::sus::mem::size_of<U>() <= ::sus::mem::size_of<_primitive>()))
friend constexpr inline _self operator|(U l, _self r) noexcept = delete;
/// Satisfies the [`BitXor<@doc.self>`]($sus::num::BitXor) concept.
/// Satisfies the [`BitXor`]($sus::num::BitXor) concept for unsigned integers.
///
/// This operation supports working with primitive unsigned integers that
/// convert to @doc.self, as well as enums. However enum class is excluded as
/// they require an explicit conversion to a @doc.self.
/// convert to the safe numeric, as well as enums.
/// However enum class is excluded as they require an explicit conversion to an
/// integer.
///
/// #[doc.overloads=unsignedint.^]
[[nodiscard]] sus_pure friend constexpr inline _self operator^(
Expand Down Expand Up @@ -939,7 +947,7 @@ template <class U>
!((UnsignedPrimitiveInteger<U> || UnsignedPrimitiveEnum<U>) && //
::sus::mem::size_of<U>() <= ::sus::mem::size_of<_primitive>()))
friend constexpr inline _self operator^(U l, _self r) noexcept = delete;
/// Satisfies the [`Shl<@doc.self>`]($sus::num::Shl) concept.
/// Satisfies the [`Shl`]($sus::num::Shl) concept for unsigned integers.
///
/// #[doc.overloads=unsignedint.<<]
[[nodiscard]] sus_pure friend constexpr inline _self operator<<(
Expand All @@ -954,7 +962,7 @@ template <class U>
requires(!std::convertible_to<U, u32>)
[[nodiscard]] sus_pure friend constexpr inline _self operator<<(
_self l, U r) noexcept = delete;
/// Satisfies the [`Shr<@doc.self>`]($sus::num::Shr) concept.
/// Satisfies the [`Shr`]($sus::num::Shr) concept for unsigned integers.
///
/// #[doc.overloads=unsignedint.>>]
[[nodiscard]] sus_pure friend constexpr inline _self operator>>(
Expand Down
Loading

0 comments on commit 843340d

Please sign in to comment.