By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,373 Members | 1,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,373 IT Pros & Developers. It's quick & easy.

std::set::upper_bound

P: n/a
Can you create std::set::upper_bound function just using
std::set::lower_bound ?

Apr 12 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
asdf wrote:
Can you create std::set::upper_bound function just using
std::set::lower_bound ?


Yes, but why would you want to?
Apr 12 '06 #2

P: n/a
Andre Kostur wrote:
asdf wrote:
Can you create std::set::upper_bound function just using
std::set::lower_bound ?


Yes, but why would you want to?


On further thought, maybe. Depends on what you mean by "just using
std::set::lower_bound".
Apr 12 '06 #3

P: n/a
asdf wrote:
Can you create std::set::upper_bound function just using
std::set::lower_bound ?


I think this works:

iterator upper_bound(const key_type& k)
{
iterator lb = lower_bound(k);
if (lb != end() && key_comp(*lb,k))
++lb;
return lb;
}

-Mark
Apr 13 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.