@@ -78,8 +78,9 @@ namespace gfx {
7878
7979namespace detail {
8080
81- template <typename Iterator> struct run {
82- typedef typename std::iterator_traits<Iterator>::difference_type diff_t ;
81+ template <typename Iterator>
82+ struct run {
83+ using diff_t = typename std::iterator_traits<Iterator>::difference_type;
8384
8485 Iterator base;
8586 diff_t len;
@@ -88,22 +89,24 @@ template <typename Iterator> struct run {
8889 }
8990};
9091
91- template <typename RandomAccessIterator, typename Compare, typename Projection> class TimSort {
92- typedef RandomAccessIterator iter_t ;
93- typedef typename std::iterator_traits<iter_t >::value_type value_t ;
94- typedef typename std::iterator_traits<iter_t >::difference_type diff_t ;
92+ template <typename RandomAccessIterator, typename Compare, typename Projection>
93+ class TimSort {
94+ using iter_t = RandomAccessIterator;
95+ using value_t = typename std::iterator_traits<iter_t >::value_type;
96+ using diff_t = typename std::iterator_traits<iter_t >::difference_type;
9597
96- static const int MIN_MERGE = 32 ;
97- static const int MIN_GALLOP = 7 ;
98+ static constexpr int MIN_MERGE = 32 ;
99+ static constexpr int MIN_GALLOP = 7 ;
98100
99101 int minGallop_; // default to MIN_GALLOP
100102
101103 std::vector<value_t > tmp_; // temp storage for merges
102- typedef typename std::vector<value_t >::iterator tmp_iter_t ;
104+ using tmp_iter_t = typename std::vector<value_t >::iterator;
103105
104106 std::vector<run<RandomAccessIterator> > pending_;
105107
106- static void binarySort (iter_t const lo, iter_t const hi, iter_t start, Compare comp, Projection proj) {
108+ static void binarySort (iter_t const lo, iter_t const hi, iter_t start,
109+ Compare comp, Projection proj) {
107110 GFX_TIMSORT_ASSERT (lo <= start);
108111 GFX_TIMSORT_ASSERT (start <= hi);
109112 if (start == lo) {
@@ -113,7 +116,7 @@ template <typename RandomAccessIterator, typename Compare, typename Projection>
113116 GFX_TIMSORT_ASSERT (lo <= start);
114117 value_t pivot = std::move (*start);
115118
116- iter_t const pos = std::ranges::upper_bound (lo, start, std::invoke (proj, pivot), comp, proj);
119+ auto pos = std::ranges::upper_bound (lo, start, std::invoke (proj, pivot), comp, proj);
117120 for (iter_t p = start; p > pos; --p) {
118121 *p = std::move (*(p - 1 ));
119122 }
@@ -351,22 +354,19 @@ template <typename RandomAccessIterator, typename Compare, typename Projection>
351354 return std::ranges::upper_bound (base + (lastOfs + 1 ), base + ofs, key, comp, proj) - base;
352355 }
353356
354- static void rotateLeft (iter_t first, iter_t last)
355- {
357+ static void rotateLeft (iter_t first, iter_t last) {
356358 value_t tmp = std::move (*first);
357359 iter_t last_1 = std::move (first + 1 , last, first);
358360 *last_1 = std::move (tmp);
359361 }
360362
361- static void rotateRight (iter_t first, iter_t last)
362- {
363+ static void rotateRight (iter_t first, iter_t last) {
363364 iter_t last_1 = last - 1 ;
364365 value_t tmp = std::move (*last_1);
365366 std::move_backward (first, last_1, last);
366367 *first = std::move (tmp);
367368 }
368369
369-
370370 void mergeLo (iter_t const base1, diff_t len1, iter_t const base2, diff_t len2,
371371 Compare comp, Projection proj) {
372372 GFX_TIMSORT_ASSERT (len1 > 0 );
0 commit comments