title: C++ stl pointer based containers wrapper
body: <p>I'm writing a program in which I manage tree and nodes (DAG).</p>
  
  <p>Nodes are represented with a <code>class MCModule</code>.</p>
  
  <pre><code>class MCModule
  {
  ...
  };
  
  typedef boost::shared_ptr&lt;MCModule&gt; MCModule_sp;
  typedef MCModule * MCModule_p;
  </code></pre>
  
  <p>I have different kind of containers.</p>
  
  <p>For example, in my class Node, the child nodes are managed with shared pointers.</p>
  
  <pre><code>std::list&lt;shared_ptr&lt;Node&gt;&gt; childs;
  </code></pre>
  
  <p>The parent nodes are manages within raw pointers:</p>
  
  <pre><code>std::list&lt;Node *&gt; parents;
  </code></pre>
  
  <p>I may also have a vector of nodes pointer in another class though.</p>
  
  <p>All those containers store "pointers" of the class Module within shared_ptr or raw pointers.</p>
  
  <p>Whatever the type of container, I need to perform some identical tasks: searching nodes based on its name, based on its id, based on </p>
  
  <p>I started to write the follwing template class:</p>
  
  <pre><code>template&lt;typename _ListT, typename _ElemT&gt;
  class ModuleListWrapper
  {
  public:
      explicit ModuleListWrapper(_ListT&amp; lst) 
          : m_lst(lst){}
  
      /*! Indicates whether the \a module was found in the list or not
       *  \return true if the \a module was found, otherwise return false
       */
      inline bool find(const MCModule_sp&amp; module) {
           return (std::find_if(m_lst.begin(), 
                                m_lst.end(),  
                                compare_with(module-&gt;getName()) ) != m_lst.end() );
      }
  
      inline _ElemT find(const std::string&amp; name) {
          _ListT::iterator it = std::find_if(m_lst.begin(), m_lst.end(),  compare_with(name));
          return ( it != m_lst.end() ) ? (*it) : NullPtrT;
      }
  
  // ... much more accessors ...
  
  
      /*! Overloads the -&gt; operator to facilitate the access to the inner class.
          \return a pointer to the inner \a _ListT object
       */
      inline _ListT * operator-&gt;() const { return &amp;m_lst; }
  
      /*! Gets a reference to the inner \a _ListT object
       */
      inline _ListT&amp; get() const { return m_lst; }
  
  private:
      _ListT&amp; m_lst;
  };
  
  typedef ModuleListWrapper&lt;ModuleList_shareptr, Module_shareptr&gt; ModuleListWrapper_shareptr;
  typedef ModuleListWrapper&lt;ModuleList_rawptr, Module_p&gt; ModuleListWrapper_rawptr;
  typedef ModuleListWrapper&lt;ModuleVector_rawptr, Module_p&gt; ModuleListWrapper_rawptr;
  </code></pre>
  
  <p>The purpose of this class is to provide an interface to perform actions whatever the underlying container. 
  Of course the container must "contain" pointer of the exepected type.</p>
  
  <p>Do you think it is an acceptable solution or is it totally useless ?
  Sure it is not perfect, but maybe better than inheriting from a std::list or std::vector... ?</p>
  
  <p>Any critic, opinion and suggestion is welcome.</p>