MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / operator<

Function operator<

extern/json/json.hpp:2889–2910  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

operator()Method · 0.70

Calls 3

basic_jsonFunction · 0.85
createFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected