Skip to content

Commit

Permalink
Merge branch 'mpt-latest' into mpt-comment
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Oct 25, 2024
2 parents c2a208a + 7a6272e commit c397814
Show file tree
Hide file tree
Showing 150 changed files with 4,139 additions and 4,480 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ IncludeCategories:
IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: false
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
Expand All @@ -73,6 +74,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
RequiresClausePosition: OwnLine
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
Expand Down
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ e2384885f5f630c8f0ffe4bf21a169b433a16858
b9d007813378ad0ff45660dc07285b823c7e9855
fe9a5365b8a52d4acc42eb27369247e6f238a4f9
9a93577314e6a8d4b4a8368cc9d2b15a5d8303e8
552377c76f55b403a1c876df873a23d780fcc81c
10 changes: 5 additions & 5 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on: [push, pull_request]

jobs:
check:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
env:
CLANG_VERSION: 10
CLANG_VERSION: 18
steps:
- uses: actions/checkout@v4
- name: Install clang-format
Expand All @@ -19,8 +19,8 @@ jobs:
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add
sudo apt-get update
sudo apt-get install clang-format-${CLANG_VERSION}
- name: Format sources
run: find include src -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -exec clang-format-${CLANG_VERSION} -i {} +
- name: Format first-party sources
run: find include src -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.ipp' \) -exec clang-format-${CLANG_VERSION} -i {} +
- name: Check for differences
id: assert
run: |
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
To fix it, you can do one of two things:
1. Download and apply the patch generated as an artifact of this
job to your repo, commit, and push.
2. Run 'git-clang-format --extensions c,cpp,h,cxx,ipp develop'
2. Run 'git-clang-format --extensions cpp,h,hpp,ipp develop'
in your repo, commit, and push.
run: |
echo "${PREAMBLE}"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# .pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v10.0.1
rev: v18.1.3
hooks:
- id: clang-format
162 changes: 74 additions & 88 deletions API-CHANGELOG.md

Large diffs are not rendered by default.

53 changes: 32 additions & 21 deletions include/xrpl/basics/Expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,67 +136,76 @@ 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();
}

// 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();
}
Expand All @@ -218,23 +227,25 @@ class [[nodiscard]] Expected<void, E>
}

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();
}
Expand Down
24 changes: 13 additions & 11 deletions include/xrpl/basics/FeeUnits.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ class TaggedFee : private boost::totally_ordered<TaggedFee<UnitTag, T>>,
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 =
Expand All @@ -110,7 +110,8 @@ class TaggedFee : private boost::totally_ordered<TaggedFee<UnitTag, T>>,
{
}

constexpr TaggedFee& operator=(beast::Zero)
constexpr TaggedFee&
operator=(beast::Zero)
{
fee_ = 0;
return *this;
Expand Down Expand Up @@ -250,7 +251,8 @@ class TaggedFee : private boost::totally_ordered<TaggedFee<UnitTag, T>>,
}

/** Returns true if the amount is not zero */
explicit constexpr operator bool() const noexcept
explicit constexpr
operator bool() const noexcept
{
return fee_ != 0;
}
Expand Down Expand Up @@ -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 <
Expand All @@ -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,
Expand All @@ -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 <
Expand Down
6 changes: 4 additions & 2 deletions include/xrpl/basics/IOUAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class IOUAmount : private boost::totally_ordered<IOUAmount>,
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
Expand All @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions include/xrpl/basics/MPTAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class MPTAmount : private boost::totally_ordered<MPTAmount>,
operator<(MPTAmount const& other) const;

/** Returns true if the amount is not zero */
explicit constexpr operator bool() const noexcept;
explicit constexpr
operator bool() const noexcept;

/** Return the sign of the amount */
constexpr int
Expand All @@ -96,7 +97,8 @@ constexpr MPTAmount::MPTAmount(value_type value) : value_(value)
{
}

constexpr MPTAmount& MPTAmount::operator=(beast::Zero)
constexpr MPTAmount&
MPTAmount::operator=(beast::Zero)
{
value_ = 0;
return *this;
Expand Down
9 changes: 6 additions & 3 deletions include/xrpl/basics/Number.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ class Number
* as the preferred type for floating point arithmetic as it makes
* "mixed mode" more convenient, e.g. MPTAmount + Number.
*/
explicit operator XRPAmount() const; // round to nearest, even on tie
explicit operator MPTAmount() 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 MPTAmount() 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
Expand Down
6 changes: 4 additions & 2 deletions include/xrpl/basics/XRPAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class XRPAmount : private boost::totally_ordered<XRPAmount>,
{
}

constexpr XRPAmount& operator=(beast::Zero)
constexpr XRPAmount&
operator=(beast::Zero)
{
drops_ = 0;
return *this;
Expand Down Expand Up @@ -155,7 +156,8 @@ class XRPAmount : private boost::totally_ordered<XRPAmount>,
}

/** Returns true if the amount is not zero */
explicit constexpr operator bool() const noexcept
explicit constexpr
operator bool() const noexcept
{
return drops_ != 0;
}
Expand Down
3 changes: 2 additions & 1 deletion include/xrpl/basics/base_uint.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ class base_uint
return bytes;
}

base_uint<Bits, Tag>& operator=(beast::Zero)
base_uint<Bits, Tag>&
operator=(beast::Zero)
{
data_.fill(0);
return *this;
Expand Down
4 changes: 2 additions & 2 deletions include/xrpl/basics/safe_cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion include/xrpl/basics/tagged_integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ class tagged_integer
return *this;
}

explicit operator Int() const noexcept
explicit
operator Int() const noexcept
{
return m_value;
}
Expand Down
8 changes: 5 additions & 3 deletions include/xrpl/beast/container/detail/aged_ordered_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,9 @@ class aged_ordered_container
// set
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
auto
insert(value_type&& value) -> typename std::
enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type;
insert(value_type&& value) -> typename std::enable_if<
!maybe_multi && !maybe_map,
std::pair<iterator, bool>>::type;

// multiset
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
Expand Down Expand Up @@ -1795,7 +1796,8 @@ template <
template <bool maybe_multi, bool maybe_map>
auto
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::
insert(value_type&& value) -> typename std::
insert(value_type&& value) ->
typename std::
enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type
{
typename cont_type::insert_commit_data d;
Expand Down
Loading

0 comments on commit c397814

Please sign in to comment.