i have a type defined as below,
using BookMapT = std::map<long long int, long long int, std::function<bool(long long int,long long int)>>;
BookMapT greater_map(greater<long long int>{});
BookMapT less_map(less<long long int>{});
So if have a number and I want to compare with the beginning of a BookMapT
int compare(BookMapT& book, long long int number_to_compare){
return book.key_comp()(number_to_compare, book.begin()->first);
}
From http://www.cplusplus.com/reference/map/map/key_comp/ I can see key_comp
return a copy
of the comparison object, will this copy
action somehow hamper performance? What confuse me most is how much cost is this copying of std::function
?
Thanks.
Aucun commentaire:
Enregistrer un commentaire