/* This file is NOT part of the LLVM Project Copyright 2021 Green Hills Software, Inc. This program is the property of Green Hills Software, Inc, its contents are proprietary information and no part of it is to be disclosed to anyone except employees of Green Hills Software, Inc., or as agreed in writing signed by the President of Green Hills Software, Inc. */ /* As of November 2022, libcxx does not have an implementation of std::lexicographical_compare_three_way. This is a GHS implementation. */ #ifndef _LIBCPP_GHS_LEXICOGRAPHICAL_COMPARE_THREE_WAY #define _LIBCPP_GHS_LEXICOGRAPHICAL_COMPARE_THREE_WAY #include <__config> #include <__compare/compare_three_way.h> #include <__compare/three_way_comparable.h> #if defined(__ghs__) #pragma ghs start_cxx_lib_header #pragma ghs startdata #if defined(__ghs_max_pack_value) #pragma pack (push, __ghs_max_pack_value) #endif #endif _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 template constexpr auto lexicographical_compare_three_way(_InputIterator1 __b1, _InputIterator1 __e1, _InputIterator2 __b2, _InputIterator2 __e2, _Compare __comp) -> decltype(__comp(*__b1, *__b2)) { static_assert(__compares_as, "Comparison function must return a comparison category type" " in std::lexicographical_compare_three_way"); for (; __b1 != __e1 && __b2 != __e2; void(++__b1), void(++__b2)) { if (auto cmp = __comp(*__b1, *__b2); cmp != 0) { return cmp; } } return __b1 != __e1 ? strong_ordering::greater : __b2 != __e2 ? strong_ordering::less : strong_ordering::equal; } template constexpr auto lexicographical_compare_three_way(_InputIterator1 __b1, _InputIterator1 __e1, _InputIterator2 __b2, _InputIterator2 __e2) { return std::lexicographical_compare_three_way(__b1, __e1, __b2, __e2, compare_three_way()); } #endif /* _LIBCPP_STD_VER > 17 */ _LIBCPP_END_NAMESPACE_STD #if defined(__ghs__) #if defined(__ghs_max_pack_value) #pragma pack(pop) #endif #pragma ghs enddata #pragma ghs end_cxx_lib_header #endif #endif /* _LIBCPP_GHS_LEXICOGRAPHICAL_COMPARE_THREE_WAY */