|
Boost Users : |
Subject: Re: [Boost-users] pointer to member function of multi_index
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-03-17 22:57:05
AMDG
Sandeep Gupta wrote:
> I am sure this is due to some trivial mistake; the statement to
> create a pointer member function insert of multi_index container fails
> in the following code:
>
>
> typedef multi_index_container<
> std::pair<int,int>,
> indexed_by<
> ordered_unique<member<pair<int,int>, int, &pair<int, int>::first> >
> >
> > mic;
>
>
> std::pair<mic_index::iterator, bool> (mic_index::*fn)(pair<int,int>) =
> &mic_index::insert; //compile error
>
>
> The error is due to mismatch in signature as given in the error:
> std::pair<boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<std::pair<int,
> int>, ...
> std::pair<boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<typename
> SuperMeta::type::node_type> >, bool>...
>
> If need be I can post full error message. Appreciate any suggestions.
>
The signature is
std::pair<mic_index::iterator, bool> (mic_index::*fn)(const pair<int,int>&);
However, it is not usually a good idea to rely on the exact
signature of library member functions. For instance, the standard
library allows member functions to have extra default arguments.
In the case of multi_index, using a reference to const will not
always work because multi_index uses call_traits.
In Christ,
Steven Watanabe
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