title: C++: boost fusion fold with c++14 generic lambdas
body: <p>I am trying to pass a generic lambda function to a boost::fusion::fold function so that I can iterate all the elements of a boost::fusion::vector. My goal is to call a non-const member function from each element in the vector. The problem is that even though the vector holds non-const values the type deduced by the generic lambda is a const reference. This results in my gcc-4.9.0 compiler (using CygWin) complaining that I am discarding the const qualifier.</p>
  
  <pre><code>#include &lt;iostream&gt;                                        
  #include &lt;boost/fusion/include/vector.hpp&gt;                             
  #include &lt;boost/fusion/include/fold.hpp&gt;                               
  #include &lt;boost/fusion/include/for_each.hpp&gt;                               
  
  class Silly {                                              
  
  public:                                                
    Silly(int x)                                             
      : x_(x){}                                              
  
    int increment(int i) {                                       
      return x_ += i;                                        
    }                                                                                                                                        
  
  private:                                               
    int x_;                                              
  };                                                 
  
  using my_type = boost::fusion::vector&lt;Silly, Silly&gt;;                           
  
  
  int main() {                                               
    my_type my_vector(1, 2);                                     
    boost::fusion::fold(my_vector, 0, [](int i, auto&amp; x){return x.increment(i);}); //error: passing 'const Silly' as 'this' argument of 'int Silly::increment(int)' discards qualifiers                                      
  }                                                                                              
  </code></pre>
  
  <p>Now, if instead of the lambda I pass the following functor, the program compiles cleanly</p>
  
  <pre><code>struct functor {
  
    template &lt;class X&gt;
    int operator()(int i, X&amp; x) {
    return x.increment(i);
   }
  };
  </code></pre>
  
  <p>Is this a boost::fusion bug or am I missing something? Thanks in advance!</p>