title: Constant reference_wrapper
body: <p>In the following code, the aim is to have a <code>reference_wrapper&lt;int&gt; b</code> such that when <code>a</code> changes, <code>b</code> also changes however, the opposite should not be allowed that is, <code>a</code> should not change when <code>b</code> changes. I tried two ways: Lines 7 and 8. Line 7 caused compiler to complain that it cannot convert from <code>int</code> to <code>const int</code> while line 8 compiled without problem but the result was not what I wanted (<code>a</code> changed when <code>b</code> changed). Any idea?</p>
  
  <pre><code>1.  #include &lt;iostream&gt;
  2.  #include &lt;functional&gt;
  3.  using namespace std;
  4.  
  5.  int main() {
  6.      int a = 1;
  7.      //reference_wrapper&lt;const int&gt; b = ref(a);
  8.      //const reference_wrapper&lt;int&gt; b = ref(a);
  9.  return 0;
  10. }
  </code></pre>