[Boost-users] multi_index with base class member

9 views
Skip to first unread message

david joeyoung

unread,
Nov 5, 2009, 3:28:16 AM11/5/09
to boost...@lists.boost.org
please give me some advices.

I get a compile error,when to index on base class member.

the codes are listed below:

struct Foo 
int a; 
}; 
 
struct Bar : public Foo 
int b;
}; 

struct idx0 {};

typedef multi_index_container<
Bar,
indexed_by<
 ordered_unique<
tag < idx0 > ,member < Bar,int,&Bar::a> 
 >
>
> test_type;

Error 1 error C2440: 'specialization' : cannot convert from 'int Foo::* ' to 'int Bar::* '
and the codes are compiled in boost 1.40, vs 2008 sp1



Steven Watanabe

unread,
Nov 5, 2009, 12:29:27 PM11/5/09
to boost...@lists.boost.org
AMDG

david joeyoung wrote:
> please give me some advices.
>
> I get a compile error,when to index on base class member.
>
> the codes are listed below:
>
> struct Foo
> {
> int a;
> };
>
> struct Bar : public Foo
> {
> int b;
> };

> <snip>
> member < Bar,int,&Bar::a>
> <snip>


>
> Error 1 error C2440: 'specialization' : cannot convert from 'int Foo::* ' to
> 'int Bar::* '
> and the codes are compiled in boost 1.40, vs 2008 sp1
>

You can use the base class in member:

member<Foo, int, &Bar::a>

In Christ,
Steven Watanabe

_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Reply all
Reply to author
Forward
0 new messages