title: Extrange error when passing a variable as reference to a thread in C++
body: <p>I'm trying to make a few threads to calculate average, minimum, maximun and standard deviation at the same time.</p>
  
  <p>Like this (T is a 100 size double array):</p>
  
  <pre><code>P[0] = thread(&amp;average, T, ref(average));
  P[0].join();
  P[1] = thread(&amp;maxmin, T, ref(max), ref(min)),
  P[2] = thread(&amp;standardDev, T, ref(stdDev),ref(average));
  
  P[1].join();
  P[2].join();
  </code></pre>
  
  <p>And in the method:</p>
  
  <pre><code>void average(double* T, double &amp;average) {
  double sum=0.0;
  for(int i=0;i&lt;100;i++){
      sum +=T[i];
  }
  average = sum/100;  
  }
  </code></pre>
  
  <p>Then I compile it with:</p>
  
  <pre><code>g++ -pthread -std=c++11 (filename) -o (name)
  </code></pre>
  
  <p>But it fails and shows this error:</p>
  
  <pre><code>In file included from /usr/include/c++/4.8/thread:39:0,
               from ejercicio_4.cpp:2:
  /usr/include/c++/4.8/functional: In instantiation of ‘struct std::_Bind_simple&lt;double*(double*, std::reference_wrapper&lt;double&gt;)&gt;’:
  /usr/include/c++/4.8/thread:137:47:   required from ‘std::thread::thread(_Callable&amp;&amp;, _Args&amp;&amp; ...) [with _Callable = double*; _Args = {double (&amp;)[100], std::reference_wrapper&lt;double&gt;}]’
  ejercicio_4.cpp:89:40:   required from here
  /usr/include/c++/4.8/functional:1697:61: error: no type named ‘type’ in ‘class std::result_of&lt;double*(double*, std::reference_wrapper&lt;double&gt;)&gt;’
         typedef typename result_of&lt;_Callable(_Args...)&gt;::type result_type;
                                                               ^
  /usr/include/c++/4.8/functional:1727:9: error: no type named ‘type’ in ‘class std::result_of&lt;double*(double*, std::reference_wrapper&lt;double&gt;)&gt;’
           _M_invoke(_Index_tuple&lt;_Indices...&gt;)
           ^
  </code></pre>
  
  <p>I have g++ 4.8, so it should work with threads, I don't know what's causing this error.</p>
  
  <p>Thanks in advance.</p>