title: Advantages of calling named lambda in class constructor vs calling an actual private function
body: <p>I was designing an <code>RGBA</code> class, where four parameters needed to be passed to the class's constructor, to instantiate the class. The constructor looks like the one below:</p>
  
  <pre><code>RGBA(int red = 0, int green = 0, int blue = 0, int alpha = 255)
  {
      auto valid_color = [](int param) {return (param &gt;= 0 &amp;&amp; param &lt;= 255) ? param : 0; };
      m_red = valid_color(red);
      m_green = valid_color(green);
      m_blue = valid_color(blue);
      m_alpha = valid_color(alpha);
  }
  </code></pre>
  
  <p>As you can see above, I have used a lambda for each parameter to verify the passed paramater. This lead me to wonder, what advantages could such a lambda have over a function, such as this (declared <code>private</code> in the the interface):</p>
  
  <pre><code>int valid_color(int param)
  {
      return (param &gt;= 0 &amp;&amp; param &lt;= 255) ? param : 0;
  }
  </code></pre>
  
  <p>So my options are this:</p>
  
  <ol>
  <li>Keep using the lambda, and let the code be.</li>
  <li>Instead of a lambda, declare an actual function, like the one above, and use that.</li>
  <li>Just write it out completely for everything. (Slightly tedious and definitelt error-prone).</li>
  </ol>
  
  <p>Which option seems the best, and why?</p>