fix recursion depth O(logN): some algorithms

This commit is contained in:
bolero-MURAKAMI 2013-01-03 17:01:50 +09:00
parent 28697ee7a8
commit 5019f6aa96
162 changed files with 3600 additions and 1659 deletions

View file

@ -38,12 +38,80 @@ namespace testspr {
}
{
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
sprout::begin(arr1),
sprout::begin(arr1) + 5,
testspr::reduct_input(sprout::begin(arr1)),
testspr::reduct_input(sprout::begin(arr1) + 5),
testspr::less_than<int>(8)
);
TESTSPR_BOTH_ASSERT(result == 5);
}
{
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
testspr::reduct_input(sprout::begin(arr1)),
testspr::reduct_input(sprout::end(arr1)),
testspr::is_odd<int>()
);
TESTSPR_BOTH_ASSERT(result == 5);
}
{
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
testspr::reduct_input(sprout::begin(arr1)),
testspr::reduct_input(sprout::end(arr1)),
testspr::less_than<int>(8)
);
TESTSPR_BOTH_ASSERT(result == 7);
}
{
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
testspr::reduct_input(sprout::begin(arr1)),
testspr::reduct_input(sprout::begin(arr1) + 5),
testspr::is_odd<int>()
);
TESTSPR_BOTH_ASSERT(result == 3);
}
{
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
testspr::reduct_input(sprout::begin(arr1)),
testspr::reduct_input(sprout::begin(arr1) + 5),
testspr::less_than<int>(8)
);
TESTSPR_BOTH_ASSERT(result == 5);
}
#if defined(__clang__)
{
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
testspr::reduct_random_access(sprout::begin(arr1)),
testspr::reduct_random_access(sprout::end(arr1)),
testspr::is_odd<int>()
);
TESTSPR_BOTH_ASSERT(result == 5);
}
{
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
testspr::reduct_random_access(sprout::begin(arr1)),
testspr::reduct_random_access(sprout::end(arr1)),
testspr::less_than<int>(8)
);
TESTSPR_BOTH_ASSERT(result == 7);
}
{
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
testspr::reduct_random_access(sprout::begin(arr1)),
testspr::reduct_random_access(sprout::begin(arr1) + 5),
testspr::is_odd<int>()
);
TESTSPR_BOTH_ASSERT(result == 3);
}
{
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
testspr::reduct_random_access(sprout::begin(arr1)),
testspr::reduct_random_access(sprout::begin(arr1) + 5),
testspr::less_than<int>(8)
);
TESTSPR_BOTH_ASSERT(result == 5);
}
#endif
}
}
} // namespace testspr