title: How to use `std::lower_bound` with `std::map`?
body: <p>I have this question:</p>
  
  <p>I have a <code>std::map</code> of strings to integers representing list of fruits:</p>
  
  <pre><code>map&lt;string, int&gt; fruits{
      {"Apple", 5}, {"Grapefruit", 7}, {"Cherry", 10}, {"Grapes", 16}
  };
  
  
  for (const auto&amp; p : fruits)
      cout &lt;&lt; p.first &lt;&lt; " " &lt;&lt; p.second &lt;&lt; endl;
  cout &lt;&lt; endl &lt;&lt; endl;
  
  
  auto it = fruits.begin();
  ++++it;
  
  using type = std::pair&lt;class std::basic_string&lt;char, struct std::char_traits&lt;char&gt;, class std::allocator&lt;char&gt; &gt; const, int&gt;;
  
  auto it2 = std::lower_bound(fruits.cbegin(), fruits.cend(), type{"Cherry", 10});
  //  auto it3 = std::lower_bound(fruits.cbegin(), fruits.cend(), pair&lt;string, int&gt;{ "Cherry", 10 });
  auto it4 = std::lower_bound(fruits.cbegin(), fruits.cend(), pair&lt;const string, int&gt;{ "Cherry", 10 });
  
  for (auto beg = fruits.cbegin(); beg != it2; ++beg)
      cout &lt;&lt; beg-&gt;first &lt;&lt; " " &lt;&lt; beg-&gt;second &lt;&lt; endl;
  
  cout &lt;&lt; typeid(*it).name() &lt;&lt; endl;
  </code></pre>
  
  <p>So my problem was How to pass the third parameter to <code>std::lower_bound</code> explicitly? </p>
  
  <ul>
  <li><p>Because after getting help from <code>typeid</code> I've noticed that the pair's <code>first</code> is <code>const</code> is this because the keys are <code>constants</code>?</p></li>
  <li><p>Also what happen if I pass the value for a given key that is not matching the key in the container. e.g: the element with key <code>"Cherry"</code> has a value <code>10</code> so why <code>lower_bound</code> works correctly if I pass to it invalid <code>value</code> with the key like <code>pair{"Cherry", 345}</code>? </p></li>
  <li><p>Is the value of the pair passed to <code>lower_bound</code> arbitrary?</p></li>
  </ul>