MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / operator<

Function operator<

Source/Utils/json.hpp:3404–3416  ·  view source on GitHub ↗

! @brief comparison operator for JSON types Returns an ordering that is similar to Python: - order: null < boolean < number < object < array < string < binary - furthermore, each type is not smaller than itself - discarded values are not comparable - binary is represented as a b"" string in python and directly comparable to a string; howev

Source from the content-addressed store, hash-verified

3402 @since version 1.0.0
3403 */
3404 inline bool operator<(const value_t lhs, const value_t rhs) noexcept
3405 {
3406 static constexpr std::array<std::uint8_t, 9> order = { {
3407 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
3408 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */,
3409 6 /* binary */
3410 }
3411 };
3412
3413 const auto l_index = static_cast<std::size_t>(lhs);
3414 const auto r_index = static_cast<std::size_t>(rhs);
3415 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
3416 }
3417 } // namespace detail
3418} // namespace nlohmann
3419

Callers 1

operator()Method · 0.85

Calls 3

typeMethod · 0.80
basic_jsonFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected