title: Accessing class members using reference_wrapper instead of standard pointers in C++11
body: <p>I am trying to build an <code>unordered_map</code> to <code>vector</code> variables which are members of my class. I can do this using standard pointers <code>*</code> but this requires the use of <code>(*x)</code> to access the vector. I wondered if <code>std::reference_wrapper</code> would be cleaner, but can't get it to work.</p>
  
  <pre><code>#include &lt;unordered_map&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;functional&gt;
  
  class model_class {
  
  private:
  
    static constexpr auto MaxHerds = 1 ;
    static constexpr int MaxInitValues = 5 ;
    static constexpr int MaxAnimals = 2 ;
  
    std::vector&lt; double &gt; MamCellsF ;
    std::vector&lt; std::vector&lt; double &gt; &gt; InitCond ;
  
  public:
  
    std::unordered_map&lt; std::string , std::reference_wrapper&lt; std::vector&lt; double &gt; &gt; &gt; vector;
    std::unordered_map&lt; std::string , std::vector&lt; std::vector&lt; double &gt; &gt;* &gt; array;
  
    model_class ( ) :
      // initialise vectors
      MamCellsF( MaxHerds , 0.07 ) ,
      InitCond( MaxAnimals , std::vector&lt; double &gt; ( MaxInitValues , 0.7 ) )
    {
       // point to variables from model
       vector.insert({"MamCellsF", std::ref(MamCellsF)});
       array["InitCond"] = &amp;InitCond;
  
       // assign to vectors
       MamCellsF = { 0.001 , 0.002 }  ; // warning: automatic resizing
       InitCond = { { 1.0 , 550 , 3.5 , 1 , 4 } ,
       { 2.0 , 625 , 3.5 , 5 , 4 } } ;
    }
  
    void print_values(){
  
      // access the vectors
      double a = vector["MamCellsF"].get()[1]; // error: "no matching function call to `std::reference_wrapper&lt;std::vector&lt;double&gt;&gt;::reference_wrapper()"
      double b = (*array["InitCond"])[0][1];
      std::cout &lt;&lt; a &lt;&lt; std::endl;
      std::cout &lt;&lt; b &lt;&lt; std::endl;
  
    }
  
  };
  
  void test()
  {
  
    model_class model;
    model.print_values();
  
  }
  </code></pre>