[btree] lower bound search should return an empty optional if every entry in the node is higher.

Patch from Ming-Hung Tsai
This commit is contained in:
Joe Thornber 2015-05-26 14:09:29 +01:00
parent 880785a9bf
commit cf903cfea6

View File

@ -458,7 +458,8 @@ namespace persistent_data {
template <typename ValueTraits> template <typename ValueTraits>
struct lower_bound_search { struct lower_bound_search {
static boost::optional<unsigned> search(btree_detail::node_ref<ValueTraits> n, uint64_t key) { static boost::optional<unsigned> search(btree_detail::node_ref<ValueTraits> n, uint64_t key) {
return n.lower_bound(key); int i = n.lower_bound(key);
return (i < 0) ? boost::optional<unsigned>() : boost::optional<unsigned>(i);
} }
}; };