Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <array>
- #include <algorithm>
- #include <sprout/algorithm/sort.hpp>
- template <class Container>
- constexpr auto compute_length(Container &&container)
- {
- auto itr1 = container.cbegin();
- auto itr2 = itr1 + 1;
- auto itr3 = itr2 + 1;
- while(itr3 != container.cend())
- {
- if (*itr1 < *itr2 + *itr3)
- return *itr1 + *itr2 + *itr3;
- ++itr1;
- ++itr2;
- ++itr3;
- }
- return 0;
- }
- int main()
- {
- constexpr std::array a = {2, 3, 4, 5, 10};
- // constexpr std::array a = {4, 5, 10, 20};
- constexpr auto b = sprout::sort(a, [](auto i, auto j){return i > j;});
- constexpr auto ans = compute_length(std::move(b));
- static_assert(ans == 12);
- // static_assert(ans == 0);
- return 0;
- }
Add Comment
Please, Sign In to add comment