I want to upgrade my custom container to compatible with std::ranges algorithms such as find_if and others, like bellow
auto is_satisfy = [](CustomContainer::value_type x) { ... };
std::ranges::find_if(custom_container, is_satisfy);
// instead of std::find_if(custom_container.begin(), custom_container.end(), is_satisfy);
Signature of std::ranges::find_if like as
struct find_if_fn {
template< ranges::input_range R,
class Proj = std::identity,
std::indirect_unary_predicate<std::projected<ranges::iterator_t<R>,
Proj>> Pred >
constexpr ranges::borrowed_iterator_t<R>
operator()( R&& r, Pred pred = {}, Proj proj = {} ) const
{
return (*this)(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj));
}
};
What is the input_range concept and how this feature is supported by my own custom container?