title: Operator-> transistency and shared_ptr
body: <p>I recall reading somewhere, can't recall where though, that operator-> is transient. That it will look through objects with operator-> until it find something that isn't a pointer and then running a normal operator. on that. I have however run into a problem with this,</p>
  
  <p>Consider this code:</p>
  
  <pre><code>#include &lt;boost/shared_ptr.hpp&gt;
  #include &lt;vector&gt;
  #include &lt;iostream&gt;
  
  struct Foo {
      Foo(int val) : i(val) {}
      typedef boost::shared_ptr&lt;Foo&gt; ptr;
      int i;
  };
  
  int main(int argc, char** argv) {
      typedef std::vector&lt;Foo::ptr&gt; FooVec;
      FooVec v;
      for(FooVec::iterator it = v.begin(); it != v.end(); ++it) {
          std::cout &lt;&lt;it-&gt;i &lt;&lt;std::endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>ptr.cpp: In function ‘int main(int, char**)’:
  ptr.cpp:15:19: error: ‘class boost::shared_ptr&lt;Foo&gt;’ has no member named ‘i’
     std::cout &lt;&lt;it-&gt;i &lt;&lt;std::endl;
  </code></pre>
  
  <p>Since a boost::shared_ptr isn't a pointer. I could solve this by instead writing</p>
  
  <pre><code>std::cout &lt;&lt;(*it)-&gt;i &lt;&lt;std::endl
  </code></pre>
  
  <p>But I think that looks a lot worse, I tried std::shared_ptr as well but that got the same problem. Is there a nice way of solving this or am I stuck with <code>(*it)-&gt;i</code>?</p>