title: In Stroustrup's example, what does the colon mean in "return 1 : 2"?
body: <p>I don't understand one particular use of a colon.</p>
  
  <p>I found it in the book <a href="https://en.wikipedia.org/wiki/The_C%2B%2B_Programming_Language" rel="noreferrer"><em>The C++ Programming Language</em></a> by Bjarne Stroustrup, 4th edition, section 11.4.4 "Call and Return", page 297:</p>
  
  <pre><code>void g(double y)
  {
    [&amp;]{ f(y); }                                               // return type is void
    auto z1 = [=](int x){ return x+y; }                        // return type is double
    auto z2 = [=,y]{ if (y) return 1; else return 2; }         // error: body too complicated
                                                               // for return type deduction
    auto z3 =[y]() { return 1 : 2; }                           // return type is int
    auto z4 = [=,y]()−&gt;int { if (y) return 1; else return 2; } // OK: explicit return type
  }
  </code></pre>
  
  <p>The confusing colon appears on line 7, in the statement <code>return 1 : 2</code>. I have no idea what it could be. It's not a label or ternary operator.</p>
  
  <p>It seems like a conditional ternary operator without the first member (and without the <code>?</code>), but in that case I don't understand how it could work without a condition.</p>