Is it possible to project on a std::map? I tried to use std::ranges::min with a projection, but it seems to throw errors that I can't interpret why its not liking things.
#include <set>
#include <iostream>
#include <ranges>
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>
int main()
{
std::map<int, int> usage_table;
auto lowest = std::ranges::min( std::move(usage_table),
{},
&std::map<int,int>::value_type::second );
}
I could work around it, but it would be nice if this one liner worked.
Best
Instead of
std::ranges::min
you can usestd::ranges::min_element
like this:Also, it's unclear why you are
move
ing themap
, it doesn't seem to do anything useful.