| 2884 | inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD* |
| 2885 | #else |
| 2886 | inline bool operator<(const value_t lhs, const value_t rhs) noexcept |
| 2887 | #endif |
| 2888 | { |
| 2889 | static constexpr std::array<std::uint8_t, 9> order = {{ |
| 2890 | 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, |
| 2891 | 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, |
| 2892 | 6 /* binary */ |
| 2893 | } |
| 2894 | }; |
| 2895 | |
| 2896 | const auto l_index = static_cast<std::size_t>(lhs); |
| 2897 | const auto r_index = static_cast<std::size_t>(rhs); |
| 2898 | #if JSON_HAS_THREE_WAY_COMPARISON |
| 2899 | if (l_index < order.size() && r_index < order.size()) |
| 2900 | { |
| 2901 | return order[l_index] <=> order[r_index]; // *NOPAD* |
| 2902 | } |
| 2903 | return std::partial_ordering::unordered; |
| 2904 | #else |
| 2905 | return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; |
| 2906 | #endif |
| 2907 | } |
| 2908 | |
| 2909 | // GCC selects the built-in operator< over an operator rewritten from |
| 2910 | // a user-defined spaceship operator |
no test coverage detected