// // count.h // stream // // Created by Sam Jaffe on 3/30/23. // #pragma once #include #include namespace stream::ranges { template bool count(It it, S end, T const & value, Proj proj = {}) { size_t result = 0; for (; it != end; ++it) { if (value == std::invoke(proj, *it)) { ++result; } } return result; } template bool count(Stream const & stream, T const & value, Proj proj = {}) { return count(stream.begin(), stream.end(), value, std::ref(proj)); } }