Quantcast
Channel: User HolyBlackCat - Stack Overflow
Viewing all articles
Browse latest Browse all 1287

Answer by HolyBlackCat for How to use std::lower_bound when the key is part of the data and i want to search for the key?

$
0
0

While (as the other answer says) you can give std::lower_bound a comparator with two different parameter types (as value is always the second parameter), in those cases I find it less confusing to use std::partition_point.

std::partition_point does the same thing, but uses an unary predicate and doesn't have a value parameter:

chunk_id id = ...;auto iter = std::partition_point(a, b, [&](const chunk_offset &o){return o.chunk_id < id;});

Viewing all articles
Browse latest Browse all 1287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>