471,078 Members | 822 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,078 software developers and data experts.

std::set::upper_bound

Can you create std::set::upper_bound function just using
std::set::lower_bound ?

Apr 12 '06 #1
3 2633
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
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
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.

Similar topics

26 posts views Thread by Michael Klatt | last post: by
4 posts views Thread by Marcelo Pinto | last post: by
2 posts views Thread by jesper | last post: by
reply views Thread by asdf | last post: by
5 posts views Thread by Fred Zwarts | last post: by
4 posts views Thread by temper3243 | last post: by
5 posts views Thread by jpalecek | last post: by
7 posts views Thread by Adrian | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.