title: use of boost::ref for passing reference to functions that take values
body: <p>I am confused about the use of boost::ref. I dont understand why any one would want to do the following  -</p>
  
  <pre><code>void f(int x)
  {
      cout &lt;&lt; x&lt;&lt;endl;
      x++;
  }
  
  int main(int argc, char *argv[])
  {
      int aaa=2;
      f(boost::ref(aaa));
      cout &lt;&lt; aaa&lt;&lt;endl;
      exit(0);
  }
  </code></pre>
  
  <p>What is the use of passing a ref to a function. I can always pass by value instead. Also it not that the ref is actually passed. In the above the value of aaa in main remains 2 only.</p>
  
  <p>Where exactly is boost ref useful?</p>
  
  <p>Is it possible to use boost::ref in this scenario.
  I want to pass iterator refernce to std::sort function. normally the sort works on iterator copies - will boost::ref make it work for references also? (without any changes to std::sort)</p>