123456789101112131415161718192021 |
- #include <cxxomfort/cxxomfort.hpp>
- #include <cxxomfort/algorithm.hpp> // hash
- #include <cxxomfort/iterator.hpp>
- #include <cxxomfort/array.hpp>
- #include <iostream>
- constexpr cxxomfort::array<int,8> nums = { {4, -7, 1, 8, -2, -3, 6, 2} };
- constexpr bool is_pos (int x) noexcept { return x > 0; }
- int main () {
- using namespace std;
- using cxxomfort::constexpr_tag;
- constexpr unsigned positives = cxxomfort::fix::count_if( constexpr_tag
- , nums.cbegin(), nums.cend(), is_pos);
- static_assert( positives == 5, "positives");
- constexpr int const * pf = cxxomfort::fix::find( constexpr_tag
- , nums.cbegin(), nums.cend(), 8 );
- static_assert( pf == nums.cbegin()+3, "find");
-
- }
|