Skip to content
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

optref, error, bytes, hex #1

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix namespace
  • Loading branch information
turuslan committed Nov 12, 2023
commit 0568c4cc46bc609ea0771985bfd8ce6488dfe3f6
15 changes: 7 additions & 8 deletions src/qtils/cxx20/lexicographical_compare_three_way.hpp
Original file line number Diff line number Diff line change
@@ -13,17 +13,16 @@
#include <algorithm>
#endif

namespace libp2p::cxx20 {
namespace qtils::cxx20 {
#ifdef __APPLE__
/// https://en.cppreference.com/w/cpp/algorithm/lexicographical_compare_three_way
template <class I1, class I2, class Cmp>
constexpr auto lexicographical_compare_three_way(
I1 f1, I1 l1, I2 f2, I2 l2, Cmp comp) -> decltype(comp(*f1, *f2)) {
using ret_t = decltype(comp(*f1, *f2));
static_assert(
std::disjunction_v<std::is_same<ret_t, std::strong_ordering>,
std::is_same<ret_t, std::weak_ordering>,
std::is_same<ret_t, std::partial_ordering>>,
static_assert(std::disjunction_v<std::is_same<ret_t, std::strong_ordering>,
std::is_same<ret_t, std::weak_ordering>,
std::is_same<ret_t, std::partial_ordering>>,
"The return type must be a comparison category type.");

bool exhaust1 = (f1 == l1);
@@ -36,7 +35,7 @@ namespace libp2p::cxx20 {
}

return !exhaust1 ? std::strong_ordering::greater
: !exhaust2 ? std::strong_ordering::less
: !exhaust2 ? std::strong_ordering::less
: std::strong_ordering::equal;
}

@@ -62,10 +61,10 @@ namespace libp2p::cxx20 {

template <class I1, class I2>
constexpr auto lexicographical_compare_three_way(I1 f1, I1 l1, I2 f2, I2 l2) {
return ::libp2p::cxx20::lexicographical_compare_three_way(
return ::qtils::cxx20::lexicographical_compare_three_way(
f1, l1, f2, l2, compare_three_way{});
}
#else
using std::lexicographical_compare_three_way;
#endif
} // namespace libp2p::cxx20
} // namespace qtils::cxx20