Boost logo

Boost :

From: Tal Agmon (tal.boost_at_[hidden])
Date: 2006-05-22 12:11:26


Hi Joaquin,

NodeBase is an interface

struct NodeBase{ virtual group_id memberOf()const=0; ...};

 NodeBase<<interface >> used by NodeCommon and other Nodes uses
NodeCommon in a relationship of is-a

Best Regards,
Tal Agmon

On 5/22/06, Joaquín Mª López Muñoz <joaquin_at_[hidden]> wrote:
> Tal Agmon ha escrito:
>
> > Hello,
> >
> > I use multi_index as follow with success:
> >
> > typedef boost::multi_index::multi_index_container<
> > boost::shared_ptr<NodeBase>,
> > boost::multi_index::indexed_by<
> > boost::multi_index::ordered_unique<
> > BOOST_MULTI_INDEX_CONST_MEM_FUN(NodeBase, handle, getHandle)
> > >,
> > boost::multi_index::ordered_non_unique<
> > BOOST_MULTI_INDEX_CONST_MEM_FUN(NodeBase, group_id, memberOf)
> > >
> > >
> > > NodePtrSet;
> >
> > but I would like NodeBase inherite boost::enable_shared_from_this<NodeBase>
> > I get error C2964: invalid expression as template parameter using msvc 6
> >
> > any idea?
>
> Hello Tal,
>
> Some more context is needed: the following complete snippet compiles and works
> fine in MSVC 6.5, so your problem must depend on some other circumstance that
> you haven't described sufficiently:
>
> ******** BEGIN CODE ********
> #include <boost/multi_index_container.hpp>
> #include <boost/multi_index/ordered_index.hpp>
> #include <boost/multi_index/mem_fun.hpp>
> #include <boost/shared_ptr.hpp>
> #include <boost/enable_shared_from_this.hpp>
>
> typedef int handle;
> typedef int group_id;
>
> struct NodeBase:boost::enable_shared_from_this<NodeBase>
> {
> NodeBase(handle h,group_id gid):h(h),gid(gid){}
>
> group_id memberOf()const{return gid;}
> handle getHandle()const{return h;}
>
> private:
> group_id gid;
> handle h;
> };
>
> typedef boost::multi_index::multi_index_container<
> boost::shared_ptr<NodeBase>,
> boost::multi_index::indexed_by<
> boost::multi_index::ordered_unique<
> BOOST_MULTI_INDEX_CONST_MEM_FUN(NodeBase,handle,getHandle)
> >,
> boost::multi_index::ordered_non_unique<
> BOOST_MULTI_INDEX_CONST_MEM_FUN(NodeBase,group_id,memberOf)
> >
> >
> > NodePtrSet;
>
> int main()
> {
> NodePtrSet ns;
>
> typedef boost::shared_ptr<NodeBase> element_type;
>
> ns.insert(element_type(new NodeBase(0,0)));
> ns.insert(element_type(new NodeBase(1,0)));
> ns.insert(element_type(new NodeBase(2,1)));
>
> return 0;
> }
>
> ******** END CODE ********
>
> Could you maybe come up with a reproducible test case showing the problem?
>
> Best regards,
>
> Joaquín M López Muñoz
> Telefónica, Investigación y Desarrollo
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk