| 385 | template<class A, class B> |
| 386 | constexpr bool cmp_less(A a, B b) noexcept |
| 387 | { |
| 388 | static_assert(std::is_integral_v<A>); |
| 389 | static_assert(std::is_integral_v<B>); |
| 390 | if constexpr (std::is_signed_v<A> == std::is_signed_v<B>) { |
| 391 | return a < b; |
| 392 | } |
| 393 | else if constexpr (std::is_signed_v<A>) { |
| 394 | if (a < 0) { |
| 395 | return true; |
| 396 | } |
| 397 | else { |
| 398 | return std::make_unsigned_t<A>(a) < b; |
| 399 | } |
| 400 | } |
| 401 | else { |
| 402 | if (b < 0) { |
| 403 | return false; |
| 404 | } |
| 405 | else { |
| 406 | return a < std::make_unsigned_t<B>(b); |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | |
450 | | |
451 | | template<class A, class B> |
452 | | constexpr bool cmp_less(A a, B b) noexcept |
453 | | { |
454 | | static_assert(std::is_integral_v<A>); |
455 | | static_assert(std::is_integral_v<B>); |
456 | | if constexpr (std::is_signed_v<A> == std::is_signed_v<B>) { |
457 | | return a < b; |
458 | | } |
459 | | else if constexpr (std::is_signed_v<A>) { |
460 | | if (a < 0) { |
461 | | return true; |
462 | | } |
463 | | else { |
464 | | return std::make_unsigned_t<A>(a) < b; |
465 | | } |
466 | | } |
467 | | else { |
468 | | if (b < 0) { |
469 | | return false; |
470 | | } |
471 | | else { |
472 | | return a < std::make_unsigned_t<B>(b); |
473 | | } |
474 | | } |
475 | | } |