Count matching elements after splitting

  Kiến thức lập trình

I want to combine std::views::split or std::views::lazy_split with std::ranges::count but I cannot get it to work.

This is what I currently have:

std::string setting;
std::string extension;

const auto count = std::range::count(setting | std::views::split(' '), extension);

And unfortunately the MSVC error is not really helpful:

error C3889: call to object of class type ‘std::ranges::_Count_fn’: no matching call operator found

How can I count the elements that match extension after splitting (without having to store the parts into a container)?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website