lower and upper_bound on sorted vector of struct
<p>Say for example I have:</p>

<pre><code> struct my_stuff{
     long my_value;

     struct less_than{
           bool operator()(const my_stuff &amp;a, const my_stuff &amp;b){
                   return a.my_value &lt; b.my_value;
     };
 };
</code></pre>

<p>In my code I have:</p>

<pre><code>  vector&lt;my_stuff&gt; my_vec;
</code></pre>

<p>This vector already contains all the objects that I'm interested in. I then sorted my vector based on the my_value member variable</p>

<pre><code>  sort(my_vec.begin(), my_vec.end(), my_stuff::less_than());
</code></pre>

<p>Everything is fine so far. Now my vector of objects with the member variable "my_value" is now sorted based on the value of "my_value".</p>

<p><strong>My question/problem is: How do I get the lower_bound and upper_bound of this vector based on "my_value". For example, if I was given that I want all the objects in the range [low, high] of my_value, I would want my lower_bound to point to the lowest object in that bound(low) and my upper_bound to point to my high.</strong></p>

<p>What I've tried so far is...</p>

<pre><code> auto low = lower_bound(myvec.begin()-&gt;my_value, my_vec.end()-&gt;my_value, val);
</code></pre>

<p>And same thing for upper bound except with "upper_bound" instead of "lower_bound". How do I syntatically achieve this? What I'm trying to do after I have sorted my vector of objects is to be able to find all the objects within a certain range. I believe lower_bound and upper_bound is the correct way to go about this, but I'm stumped on writing it. Thank you for any help or guidance!</p>