From 69910ca06c4ddeed23bdcdcaa1c7743c66a7f421 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Fri, 21 Sep 2012 20:07:31 +0900 Subject: [PATCH] bug fix --- libs/algorithm/test/generate.cpp | 2 +- libs/algorithm/test/generate_n.cpp | 2 +- sprout/iterator/filter_iterator.hpp | 8 ++++---- sprout/range/adaptor/replaced.hpp | 2 +- sprout/range/adaptor/replaced_if.hpp | 4 ++-- testspr/tools.hpp | 12 ++++++++++++ 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/libs/algorithm/test/generate.cpp b/libs/algorithm/test/generate.cpp index 9ecbd2ca..3a816f74 100644 --- a/libs/algorithm/test/generate.cpp +++ b/libs/algorithm/test/generate.cpp @@ -11,7 +11,7 @@ namespace testspr { static void algorithm_generate_test() { using namespace sprout; { - SPROUT_STATIC_CONSTEXPR auto arr1 = array{{0}}; + SPROUT_STATIC_CONSTEXPR auto arr1 = array{{}}; // { diff --git a/libs/algorithm/test/generate_n.cpp b/libs/algorithm/test/generate_n.cpp index 9d8af43a..158136fb 100644 --- a/libs/algorithm/test/generate_n.cpp +++ b/libs/algorithm/test/generate_n.cpp @@ -11,7 +11,7 @@ namespace testspr { static void algorithm_generate_n_test() { using namespace sprout; { - SPROUT_STATIC_CONSTEXPR auto arr1 = array{{0}}; + SPROUT_STATIC_CONSTEXPR auto arr1 = array{{}}; // { diff --git a/sprout/iterator/filter_iterator.hpp b/sprout/iterator/filter_iterator.hpp index b801261f..321f8fb7 100644 --- a/sprout/iterator/filter_iterator.hpp +++ b/sprout/iterator/filter_iterator.hpp @@ -55,13 +55,13 @@ namespace sprout { iterator_type last; predicate_type pred; private: - iterator_type satisfy_predicate() { - while (current != last && !pred(current)) { + void satisfy_predicate() { + while (current != last && !pred(*current)) { ++current; } } - iterator_type satisfy_predicate_backward() { - while (!pred(current)) { + void satisfy_predicate_backward() { + while (!pred(*current)) { --current; } } diff --git a/sprout/range/adaptor/replaced.hpp b/sprout/range/adaptor/replaced.hpp index 4faca60b..e847c3bb 100644 --- a/sprout/range/adaptor/replaced.hpp +++ b/sprout/range/adaptor/replaced.hpp @@ -29,7 +29,7 @@ namespace sprout { : old_(old_value) , new_(new_value) {} - T const& operator()(T const& value) const { + SPROUT_CONSTEXPR T const& operator()(T const& value) const { return (value == old_) ? new_ : value; } }; diff --git a/sprout/range/adaptor/replaced_if.hpp b/sprout/range/adaptor/replaced_if.hpp index 1ae8ac95..38901f6a 100644 --- a/sprout/range/adaptor/replaced_if.hpp +++ b/sprout/range/adaptor/replaced_if.hpp @@ -30,8 +30,8 @@ namespace sprout { : pred_(pred) , new_(new_value) {} - T const& operator()(T const& value) const { - return pred(value) ? new_ : value; + SPROUT_CONSTEXPR T const& operator()(T const& value) const { + return pred_(value) ? new_ : value; } }; } // namespace detail diff --git a/testspr/tools.hpp b/testspr/tools.hpp index 6e073351..d75a01f3 100644 --- a/testspr/tools.hpp +++ b/testspr/tools.hpp @@ -67,6 +67,18 @@ namespace testspr { public: SPROUT_CONSTEXPR bool operator()(T const& t) const { return t % 2 != 0; } }; + // + // is_multiple_of + // + template + struct is_multiple_of { + public: + typedef T first_argument_type; + typedef U second_argument_type; + typedef bool result_type; + public: + SPROUT_CONSTEXPR bool operator()(T const& t, U const& u) const { return t % u == 0; } + }; // // less