This documentation is automatically generated by competitive-verifier/competitive-verifier
// competitive-verifier: STANDALONE
#include <iostream>
#include "tools/cmp_equal.hpp"
int main() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
static_assert(!tools::cmp_equal(-1, 0U));
static_assert(tools::cmp_equal(0U, 0U));
static_assert(!tools::cmp_equal(0U, -1));
return 0;
}
#line 1 "tests/cmp_equal.test.cpp"
// competitive-verifier: STANDALONE
#include <iostream>
#line 1 "tools/cmp_equal.hpp"
#line 1 "tools/integral.hpp"
#line 1 "tools/is_integral.hpp"
#include <type_traits>
namespace tools {
template <typename T>
struct is_integral : std::is_integral<T> {};
template <typename T>
inline constexpr bool is_integral_v = tools::is_integral<T>::value;
}
#line 5 "tools/integral.hpp"
namespace tools {
template <typename T>
concept integral = tools::is_integral_v<T>;
}
#line 1 "tools/is_signed.hpp"
#line 5 "tools/is_signed.hpp"
namespace tools {
template <typename T>
struct is_signed : std::is_signed<T> {};
template <typename T>
inline constexpr bool is_signed_v = tools::is_signed<T>::value;
}
#line 1 "tools/make_unsigned.hpp"
#line 5 "tools/make_unsigned.hpp"
namespace tools {
template <typename T>
struct make_unsigned : std::make_unsigned<T> {};
template <typename T>
using make_unsigned_t = typename tools::make_unsigned<T>::type;
}
#line 7 "tools/cmp_equal.hpp"
namespace tools {
template <tools::integral T, tools::integral U>
constexpr bool cmp_equal(const T t, const U u) noexcept {
using UT = tools::make_unsigned_t<T>;
using UU = tools::make_unsigned_t<U>;
if constexpr (tools::is_signed_v<T> == tools::is_signed_v<U>) {
return t == u;
} else if constexpr (tools::is_signed_v<T>) {
return t < 0 ? false : static_cast<UT>(t) == u;
} else {
return u < 0 ? false : t == static_cast<UU>(u);
}
}
}
#line 5 "tests/cmp_equal.test.cpp"
int main() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
static_assert(!tools::cmp_equal(-1, 0U));
static_assert(tools::cmp_equal(0U, 0U));
static_assert(!tools::cmp_equal(0U, -1));
return 0;
}