Reformat code with clang-format-18

This commit is contained in:
John Freeman
2024-10-15 18:27:56 -05:00
parent e7cd03325b
commit 552377c76f
82 changed files with 818 additions and 912 deletions

View File

@@ -136,44 +136,49 @@ class [[nodiscard]] Expected
public:
template <typename U>
requires std::convertible_to<U, T> constexpr Expected(U && r)
: Base(T(std::forward<U>(r)))
requires std::convertible_to<U, T>
constexpr Expected(U&& r) : Base(T(std::forward<U>(r)))
{
}
template <typename U>
requires std::convertible_to<U, E> &&
(!std::is_reference_v<U>)constexpr Expected(Unexpected<U> e)
: Base(E(std::move(e.value())))
requires std::convertible_to<U, E> && (!std::is_reference_v<U>)
constexpr Expected(Unexpected<U> e) : Base(E(std::move(e.value())))
{
}
constexpr bool has_value() const
constexpr bool
has_value() const
{
return Base::has_value();
}
constexpr T const& value() const
constexpr T const&
value() const
{
return Base::value();
}
constexpr T& value()
constexpr T&
value()
{
return Base::value();
}
constexpr E const& error() const
constexpr E const&
error() const
{
return Base::error();
}
constexpr E& error()
constexpr E&
error()
{
return Base::error();
}
constexpr explicit operator bool() const
constexpr explicit
operator bool() const
{
return has_value();
}
@@ -181,22 +186,26 @@ public:
// Add operator* and operator-> so the Expected API looks a bit more like
// what std::expected is likely to look like. See:
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0323r10.html
[[nodiscard]] constexpr T& operator*()
[[nodiscard]] constexpr T&
operator*()
{
return this->value();
}
[[nodiscard]] constexpr T const& operator*() const
[[nodiscard]] constexpr T const&
operator*() const
{
return this->value();
}
[[nodiscard]] constexpr T* operator->()
[[nodiscard]] constexpr T*
operator->()
{
return &this->value();
}
[[nodiscard]] constexpr T const* operator->() const
[[nodiscard]] constexpr T const*
operator->() const
{
return &this->value();
}
@@ -218,23 +227,25 @@ public:
}
template <typename U>
requires std::convertible_to<U, E> &&
(!std::is_reference_v<U>)constexpr Expected(Unexpected<U> e)
: Base(E(std::move(e.value())))
requires std::convertible_to<U, E> && (!std::is_reference_v<U>)
constexpr Expected(Unexpected<U> e) : Base(E(std::move(e.value())))
{
}
constexpr E const& error() const
constexpr E const&
error() const
{
return Base::error();
}
constexpr E& error()
constexpr E&
error()
{
return Base::error();
}
constexpr explicit operator bool() const
constexpr explicit
operator bool() const
{
return Base::has_value();
}

View File

@@ -84,13 +84,13 @@ private:
protected:
template <class Other>
static constexpr bool is_compatible_v =
std::is_arithmetic_v<Other>&& std::is_arithmetic_v<value_type>&&
std::is_convertible_v<Other, value_type>;
std::is_arithmetic_v<Other> && std::is_arithmetic_v<value_type> &&
std::is_convertible_v<Other, value_type>;
template <class OtherFee, class = enable_if_unit_t<OtherFee>>
static constexpr bool is_compatiblefee_v =
is_compatible_v<typename OtherFee::value_type>&&
std::is_same_v<UnitTag, typename OtherFee::unit_type>;
is_compatible_v<typename OtherFee::value_type> &&
std::is_same_v<UnitTag, typename OtherFee::unit_type>;
template <class Other>
using enable_if_compatible_t =
@@ -110,7 +110,8 @@ public:
{
}
constexpr TaggedFee& operator=(beast::Zero)
constexpr TaggedFee&
operator=(beast::Zero)
{
fee_ = 0;
return *this;
@@ -250,7 +251,8 @@ public:
}
/** Returns true if the amount is not zero */
explicit constexpr operator bool() const noexcept
explicit constexpr
operator bool() const noexcept
{
return fee_ != 0;
}
@@ -344,8 +346,8 @@ constexpr bool can_muldiv_source_v =
template <class Dest, class = enable_if_unit_t<Dest>>
constexpr bool can_muldiv_dest_v =
can_muldiv_source_v<Dest>&& // Dest is also a source
std::is_convertible_v<std::uint64_t, typename Dest::value_type> &&
can_muldiv_source_v<Dest> && // Dest is also a source
std::is_convertible_v<std::uint64_t, typename Dest::value_type> &&
sizeof(typename Dest::value_type) >= sizeof(std::uint64_t);
template <
@@ -354,8 +356,8 @@ template <
class = enable_if_unit_t<Source1>,
class = enable_if_unit_t<Source2>>
constexpr bool can_muldiv_sources_v =
can_muldiv_source_v<Source1>&& can_muldiv_source_v<Source2>&& std::
is_same_v<typename Source1::unit_type, typename Source2::unit_type>;
can_muldiv_source_v<Source1> && can_muldiv_source_v<Source2> &&
std::is_same_v<typename Source1::unit_type, typename Source2::unit_type>;
template <
class Source1,
@@ -365,7 +367,7 @@ template <
class = enable_if_unit_t<Source2>,
class = enable_if_unit_t<Dest>>
constexpr bool can_muldiv_v =
can_muldiv_sources_v<Source1, Source2>&& can_muldiv_dest_v<Dest>;
can_muldiv_sources_v<Source1, Source2> && can_muldiv_dest_v<Dest>;
// Source and Dest can be the same by default
template <

View File

@@ -82,7 +82,8 @@ public:
operator<(IOUAmount const& other) const;
/** Returns true if the amount is not zero */
explicit operator bool() const noexcept;
explicit
operator bool() const noexcept;
/** Return the sign of the amount */
int
@@ -109,7 +110,8 @@ inline IOUAmount::IOUAmount(std::int64_t mantissa, int exponent)
normalize();
}
inline IOUAmount& IOUAmount::operator=(beast::Zero)
inline IOUAmount&
IOUAmount::operator=(beast::Zero)
{
// The -100 is used to allow 0 to sort less than small positive values
// which will have a large negative exponent.

View File

@@ -88,8 +88,10 @@ public:
static constexpr Number
lowest() noexcept;
explicit operator XRPAmount() const; // round to nearest, even on tie
explicit operator rep() const; // round to nearest, even on tie
explicit
operator XRPAmount() const; // round to nearest, even on tie
explicit
operator rep() const; // round to nearest, even on tie
friend constexpr bool
operator==(Number const& x, Number const& y) noexcept

View File

@@ -65,7 +65,8 @@ public:
{
}
constexpr XRPAmount& operator=(beast::Zero)
constexpr XRPAmount&
operator=(beast::Zero)
{
drops_ = 0;
return *this;
@@ -155,7 +156,8 @@ public:
}
/** Returns true if the amount is not zero */
explicit constexpr operator bool() const noexcept
explicit constexpr
operator bool() const noexcept
{
return drops_ != 0;
}

View File

@@ -521,7 +521,8 @@ public:
return bytes;
}
base_uint<Bits, Tag>& operator=(beast::Zero)
base_uint<Bits, Tag>&
operator=(beast::Zero)
{
data_.fill(0);
return *this;

View File

@@ -30,8 +30,8 @@ namespace ripple {
template <class Dest, class Src>
static constexpr bool is_safetocasttovalue_v =
(std::is_integral_v<Src> && std::is_integral_v<Dest>)&&(
std::is_signed<Src>::value || std::is_unsigned<Dest>::value) &&
(std::is_integral_v<Src> && std::is_integral_v<Dest>) &&
(std::is_signed<Src>::value || std::is_unsigned<Dest>::value) &&
(std::is_signed<Src>::value != std::is_signed<Dest>::value
? sizeof(Dest) > sizeof(Src)
: sizeof(Dest) >= sizeof(Src));

View File

@@ -187,7 +187,8 @@ public:
return *this;
}
explicit operator Int() const noexcept
explicit
operator Int() const noexcept
{
return m_value;
}