Nebojsa Simic wrote:
Hello all,
First of all, thanks for a wonderful library, it is a pleasure to work with...
However I ran into some problems and I can not find the answers either on the Internet nor on this mailing list. The problem at hand concerns the multiindex container and bind.
I have a class with the following member:
class Statistics { public: void addStats ( double val, int tick ); }
and a container:
typedef multi_index_container< Statistics, indexed_by
, ordered_non_unique< member > > StatisticsMap;
StatisticsMap m_statistic;
indexed by :
typedef StatisticsMap::nth_index<1>::type StatisticsByResponse;
somewhere in code i try to do this :
std::pairStatisticsMap::iterator,bool result = m_statistic.insert( Statistics( response, value, tick ) );
StatisticsByResponse& idxResponse = m_statistic.get<1>(); StatisticsByResponse::iterator it = m_statistic.project<1>(result.first );
the problem comes when I try to update the statistics by using :
for_each( it , idxResponse.end() , boost::bind( &Statistics::addStats, ::_1, val, tick ) );
Ok, the elements in the container are constant and may not be changed
through iterators. For multiindex container the modify method must be
used to change them.
So I changed the last line to :
boost::function