From 99860f4bc7746261a156e9355c9dea7b4fc9c81f Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Tue, 29 Mar 2016 18:13:09 +0900 Subject: [PATCH] fix bogo/bozo_sort implementation --- sprout/algorithm/cxx14/bogo_sort.hpp | 5 +++-- sprout/algorithm/cxx14/bozo_sort.hpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sprout/algorithm/cxx14/bogo_sort.hpp b/sprout/algorithm/cxx14/bogo_sort.hpp index 5e0242b6..77509267 100644 --- a/sprout/algorithm/cxx14/bogo_sort.hpp +++ b/sprout/algorithm/cxx14/bogo_sort.hpp @@ -9,6 +9,7 @@ #define SPROUT_ALGORITHM_CXX14_BOGO_SORT_HPP #include +#include #include #include @@ -20,14 +21,14 @@ namespace sprout { inline SPROUT_CXX14_CONSTEXPR void bogo_sort(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g) { while (!sprout::is_sorted(first, last)) { - sprout::shuffle(first, last, g); + sprout::shuffle(first, last, SPROUT_FORWARD(UniformRandomNumberGenerator, g)); } } template inline SPROUT_CXX14_CONSTEXPR void bogo_sort(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g, Compare comp) { while (!sprout::is_sorted(first, last, comp)) { - sprout::shuffle(first, last, g); + sprout::shuffle(first, last, SPROUT_FORWARD(UniformRandomNumberGenerator, g)); } } } // namespace sprout diff --git a/sprout/algorithm/cxx14/bozo_sort.hpp b/sprout/algorithm/cxx14/bozo_sort.hpp index 7d16ed11..fedc7c9e 100644 --- a/sprout/algorithm/cxx14/bozo_sort.hpp +++ b/sprout/algorithm/cxx14/bozo_sort.hpp @@ -9,6 +9,7 @@ #define SPROUT_ALGORITHM_CXX14_BOZO_SORT_HPP #include +#include #include #include @@ -20,14 +21,14 @@ namespace sprout { inline SPROUT_CXX14_CONSTEXPR void bozo_sort(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g) { while (!sprout::is_sorted(first, last)) { - sprout::random_swap(first, last, g); + sprout::random_swap(first, last, SPROUT_FORWARD(UniformRandomNumberGenerator, g)); } } template inline SPROUT_CXX14_CONSTEXPR void bozo_sort(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g, Compare comp) { while (!sprout::is_sorted(first, last, comp)) { - sprout::random_swap(first, last, g); + sprout::random_swap(first, last, SPROUT_FORWARD(UniformRandomNumberGenerator, g)); } } } // namespace sprout