! @brief comparison operator for JSON types Returns an ordering that is similar to Python: - order: null < boolean < number < object < array < string - furthermore, each type is not smaller than itself - discarded values are not comparable @since version 1.0.0 */
| 2875 | @since version 1.0.0 |
| 2876 | */ |
| 2877 | inline bool operator<(const value_t lhs, const value_t rhs) noexcept |
| 2878 | { |
| 2879 | static constexpr std::array<std::uint8_t, 8> order = {{ |
| 2880 | 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, |
| 2881 | 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */ |
| 2882 | } |
| 2883 | }; |
| 2884 | |
| 2885 | const auto l_index = static_cast<std::size_t>(lhs); |
| 2886 | const auto r_index = static_cast<std::size_t>(rhs); |
| 2887 | return l_index < order.size() and r_index < order.size() and order[l_index] < order[r_index]; |
| 2888 | } |
| 2889 | } // namespace detail |
| 2890 | } // namespace nlohmann |
| 2891 |
no test coverage detected