MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / operator<

Function operator<

include/behaviortree_cpp/contrib/json.hpp:2902–2923  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2900 inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD*
2901#else
2902 inline bool operator<(const value_t lhs, const value_t rhs) noexcept
2903#endif
2904{
2905 static constexpr std::array<std::uint8_t, 9> order = {{
2906 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
2907 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */,
2908 6 /* binary */
2909 }
2910 };
2911
2912 const auto l_index = static_cast<std::size_t>(lhs);
2913 const auto r_index = static_cast<std::size_t>(rhs);
2914#if JSON_HAS_THREE_WAY_COMPARISON
2915 if (l_index < order.size() && r_index < order.size())
2916 {
2917 return order[l_index] <=> order[r_index]; // *NOPAD*
2918 }
2919 return std::partial_ordering::unordered;
2920#else
2921 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2922#endif
2923}
2924
2925// GCC selects the built-in operator< over an operator rewritten from
2926// a user-defined spaceship operator

Callers 1

operator()Method · 0.70

Calls 3

createFunction · 0.85
basic_jsonFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected