title: c++ syntax to find min in a list
body: <p>I see some complicated discussion on this topic but I'm failing to make what should be a very simple piece of code work.  I've found two ways to make it work but I'm puzzled by the some issues of syntax.  I just want to find the minimum value in a list.  This works:</p>
  
  <pre><code>using namespace std;
  
  #include &lt;iostream&gt;
  #include &lt;list&gt;
  #include &lt;algorithm&gt;
  
  int main(void)
  {
    auto init_list = {10, 20, 30};
    list&lt;int&gt; alist(init_list);
  
    list&lt;int&gt;::iterator minnum = min_element(begin(alist), end(alist));
  
    cout &lt;&lt; "The min in the list is: " &lt;&lt; *minnum &lt;&lt; endl;
    return(1);
  }
  </code></pre>
  
  <p>But there is also the definition of min() which takes an initializer_list as an argument.  I think I am misunderstanding the syntax of it.  Since I've already defined an init_list I can call</p>
  
  <pre><code>int minint = min(init_list);
  </code></pre>
  
  <p>and that works.  But I don't understand why.  The documentation on min says this call should be of form:</p>
  
  <pre><code>template&lt; class T, class Compare &gt;
  T min( std::initializer_list&lt;T&gt; ilist, Compare comp );
  </code></pre>
  
  <p>So shouldn't I have to specify a &lt; comparison operator to be able to use this (apparently not...why?)?  However, I don't know how to pass this operator correctly, and have been unable to come up with a clear explanation.  Each of the following generate a wide variety of syntax errors:</p>
  
  <pre><code>int minint = min(init_list, operator&lt;);
  int minint = min(init_list, int::operator&lt;);
  </code></pre>
  
  <p>How am I supposed to pass the operator?  Clearly it doesn't matter in this case but if my list was not a list of ints but a list of some custom type with overloaded operators then would I need to pass an operator&lt; ?  Or does the syntax simply mean that class T must have a comparison operator defined, but you never have to specify it in the min function call?</p>