File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
include/cslib/algorithm/sort Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -37,11 +37,18 @@ namespace algorithm
3737 *
3838 * Interesting fact:
3939 * If CompareT::operator() does strong check (i.e. < OR >), this algorithm is stable. Overwise it's not.
40- *
41- * TODO: iterator must be RandomAccessIterator, add this check
4240 */
4341
44- template < typename IteratorT, typename CompareT = std::less<typename std::iterator_traits<IteratorT>::value_type> >
42+ template <
43+ typename IteratorT,
44+ typename CompareT = std::less<typename std::iterator_traits<IteratorT>::value_type> >,
45+ typename = typename std::enable_if<
46+ std::is_convertible<
47+ typename std::iterator_traits<IteratorT>::iterator_category,
48+ typename std::random_access_iterator_tag
49+ >::value
50+ >::type
51+ >
4552 void bubble_sort (IteratorT first, IteratorT last, CompareT compare = CompareT())
4653 {
4754 for (IteratorT iIter = first; iIter != last; ++iIter)
You can’t perform that action at this time.
0 commit comments