title: Use of lambda expression in C++ ternary operator : error type mismatch
body: <p>I am just exploring lambda expression and trying to use it to return from a function using C++ ternary operator. However the below code does not work with error!</p>
  <p><strong>this is a simplified version of the program to explain my actual problem so kindly post answer using a lambda only, not just return (x+y+offset).</strong></p>
  <blockquote>
  <p>In member function 'int Calculator::add(int, int)': 12:26: error: no
  match for ternary 'operator?:' (operand types are 'bool', 'int', and
  'Calculator::add(int, int)::&lt;lambda()&gt;') 16:3: warning: control
  reaches end of non-void function [-Wreturn-type]</p>
  </blockquote>
  <pre><code>    #include &lt;iostream&gt;
      #include &lt;string&gt;
      
      class Calculator
      {
        public:
        bool initalized = false;
        int offset = 0;
        
        int add(int x, int y)
        {
            return !initalized ? -1 : [this, x, y]()
            {
                return ((x+y) + offset);
            };
        }
      };
      
      int main()
      {
          Calculator c;
          c.initalized = true;
          c.offset = 1;
      
          printf(&quot;%d&quot;, c.add(2,10));
      }
  
  </code></pre>
  <p>What am I doing wrong here?</p>