[bind] [multi-index] Create type of pointer to overloaded erase method
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
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
AMDG Peter Barker wrote:
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: <snip>
The following compiles for me with msvc 9.0
#include
RecordsContainer;
int main() { RecordsContainer::size_type (RecordsContainer::*erase)(unsigned int) = &RecordsContainer::erase; } The parameter type is determined using call_traits, so you can see what this is for unsigned int. In Christ, Steven Watanabe
On Wed, Sep 10, 2008 at 5:54 PM, Steven Watanabe
AMDG
Peter Barker wrote:
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: <snip>
The following compiles for me with msvc 9.0
That fails with the same error here so at least I know that's consistent. Thanks, Pete
participants (2)
-
Peter Barker
-
Steven Watanabe