title: Error Taking the Address of a Temporary Array (array of lambdas)
body: <p>So, I have a class that takes an integer, a vector of integers, and an array of lambda functions for its constructor, like so:</p>
  
  <pre><code>class Cell {
  private:
      short m_State;
      std::function&lt; bool(const char) &gt; m_func;
  
  public:
      Cell(short state, std::function&lt; bool(const char) &gt; func) { m_State = state; m_func = func; };
      Cell() { m_State = 0; m_func = [] (char) -&gt; bool { return false; }; };
      bool operator() (const char input) { return m_func(input); };
      short State() { return m_State; };
  };
  
  
  class Row {
  private:
      Cell * m_Cells;
      short m_States;
  
  public:
      Row( short num_states, std::vector&lt;short&gt; states, std::function&lt; bool(char) &gt; * funcs ) {
          m_States = num_states;
          m_Cells = new Cell[num_states];
          for (short i = 0; i &lt; m_States; i++) {
              m_Cells[i] = Cell( states[i], funcs[i] );
          }
      };
  
      ~Row() {
          delete[] m_Cells;
          m_Cells = NULL;
          m_States = 0;
      };
  
      short operator[] (const char input) const {
          for (short i = 0; i &lt; m_States; i++)
              if (m_Cells[i](input))
                  return m_Cells[i].State();
          return -1;
      };
  };
  </code></pre>
  
  <p>Now, suppose I have some lambdas:</p>
  
  <pre><code>auto kIS_BETWEEN = [](char s, char e) { return [s, e](char x) -&gt; bool { return (x &gt;= s &amp;&amp; x &lt;= e); }; };
  auto kIS_NOT_0_DIGIT_FUNC = kIS_BETWEEN('1', '9')
  </code></pre>
  
  <p>Further suppose that I have a preprocessor definition like so:</p>
  
  <pre><code>#define FUNC_TYPE(x) const std::function&lt; bool(const char) &gt;[x]
  </code></pre>
  
  <p>Now, when I try and define a <code>Row</code> variable:</p>
  
  <pre><code>Row x = Row( 1, {1}, (FUNC_TYPE(1)){kIS_NOT_0_DIGIT_FUNC} );
  </code></pre>
  
  <p>I get a "taking address of temporary array" error. What am I doing wrong and how can I fix it?</p>