compare.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /// \file
  2. // CPP, the Concepts PreProcessor library
  3. //
  4. // Copyright Eric Niebler 2018-present
  5. // Copyright (c) 2020-present, Google LLC.
  6. //
  7. // Use, modification and distribution is subject to the
  8. // Boost Software License, Version 1.0. (See accompanying
  9. // file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. //
  12. // This source code is licensed under the MIT license found in the
  13. // LICENSE file in the root directory of this source tree.
  14. //
  15. // Project home: https://github.com/ericniebler/range-v3
  16. //
  17. #ifndef RANGES_V3_COMPARE_HPP
  18. #define RANGES_V3_COMPARE_HPP
  19. #if __cplusplus > 201703L && __has_include(<compare>) && \
  20. defined(__cpp_concepts) && defined(__cpp_impl_three_way_comparison)
  21. #include <compare>
  22. #include <type_traits>
  23. namespace ranges
  24. {
  25. template<typename... Ts>
  26. struct common_comparison_category
  27. {
  28. using type = void;
  29. };
  30. template<typename... Ts>
  31. requires ((std::is_same_v<Ts, std::partial_ordering> ||
  32. std::is_same_v<Ts, std::weak_ordering> ||
  33. std::is_same_v<Ts, std::strong_ordering>) && ...)
  34. struct common_comparison_category<Ts...> : std::common_type<Ts...>
  35. {};
  36. template<typename... Ts>
  37. using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
  38. } // namespace ranges
  39. #endif // __cplusplus
  40. #endif // RANGES_V3_COMPARE_HPP