File indexing completed on 2025-09-15 08:38:52
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_ITERATOR_MIN_CATEGORY_HPP_INCLUDED_
0008 #define BOOST_ITERATOR_MIN_CATEGORY_HPP_INCLUDED_
0009
0010 #include <type_traits>
0011
0012 namespace boost {
0013 namespace iterators {
0014 namespace detail {
0015
0016 template<
0017 typename T1,
0018 typename T2,
0019 bool GreaterEqual = std::is_convertible< T1, T2 >::value,
0020 bool LessEqual = std::is_convertible< T2, T1 >::value
0021 >
0022 struct min_category_impl
0023 {
0024 static_assert(GreaterEqual || LessEqual, "Iterator category types must be related through convertibility.");
0025 };
0026
0027 template< typename T1, typename T2 >
0028 struct min_category_impl< T1, T2, true, false >
0029 {
0030 using type = T2;
0031 };
0032
0033 template< typename T1, typename T2 >
0034 struct min_category_impl< T1, T2, false, true >
0035 {
0036 using type = T1;
0037 };
0038
0039 template< typename T1, typename T2 >
0040 struct min_category_impl< T1, T2, true, true >
0041 {
0042 static_assert(std::is_same< T1, T2 >::value, "Iterator category types must be the same when they are equivalent.");
0043 using type = T1;
0044 };
0045
0046 }
0047
0048
0049
0050
0051
0052 template< typename... Categories >
0053 struct min_category;
0054
0055 template< typename T >
0056 struct min_category< T >
0057 {
0058 using type = T;
0059 };
0060
0061 template< typename T1, typename T2, typename... Tail >
0062 struct min_category< T1, T2, Tail... >
0063 {
0064 using type = typename min_category<
0065 typename iterators::detail::min_category_impl< T1, T2 >::type,
0066 Tail...
0067 >::type;
0068 };
0069
0070
0071 template< typename T1, typename T2 >
0072 struct min_category< T1, T2 >
0073 {
0074 using type = typename iterators::detail::min_category_impl< T1, T2 >::type;
0075 };
0076
0077 template< typename... Categories >
0078 using min_category_t = typename min_category< Categories... >::type;
0079
0080 }
0081 }
0082
0083 #endif