Boost logo

Boost Users :

Subject: [Boost-users] [bind] [multi-index] Create type of pointer to overloaded erase method
From: Peter Barker (newbarker_at_[hidden])
Date: 2008-09-10 06:07:57


Hello all,

I have a container of the following type:

struct RecsByID {};
struct RecsBySizeAndFit {};
typedef boost::multi_index_container<
 boost::shared_ptr<LastSizeFitRecord>,
 bmi::indexed_by<
   bmi::ordered_unique<bmi::tag<RecsByID>,bmi::const_mem_fun<RecordBase,unsigned
int,&RecordBase::getRecID> >,
   bmi::ordered_unique<bmi::tag<RecsBySizeAndFit>,bmi::const_mem_fun<LastSizeFitRecord,const
SizeAndFit&,&LastSizeFitRecord::getSizeAndFit> >
>
> RecordsContainer;

The main thing to note above is that the first index is of type
"unsigned int" - the record ID.

I have a container of unsigned ints which represent the records to be
deleted so naturally wanted to do a std::for_each() with a binder and
passing in _1 to RecordsContainer::erase. Not that simple because
Records::Container::erase has three overloads so I'm trying to come up
with a type that will represent the overload I want.

I've tried this:

RecordsContainer::size_type (RecordsContainer::*erase)(unsigned int) =
&RecordsContainer::erase;

but it failed to compile. Visual Studio 2003 gives me the following
error on the above line:

error C2440: 'initializing' : cannot convert from
'overloaded-function' to '<Unknown>'

I've decided this particular pointer to member would not be intuitive
to use in production code, but I thought I'd try to get it working and
failed and would like to know what I'm doing wrong!

Regards,

Pete


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net