Boost logo

Boost Users :

From: Nebojsa Simic (nelle_at_[hidden])
Date: 2007-11-16 14:46:13


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_unique<identity<Statistics> >,
      ordered_non_unique< member<Statistics,double,&Statistics::gamma> >
>
> StatisticsMap;

StatisticsMap m_statistic;

indexed by :

typedef StatisticsMap::nth_index<1>::type StatisticsByResponse;

somewhere in code i try to do this :

std::pair<StatisticsMap::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 )
  );

" ...
\boost\boost\bind\mem_fn_template.hpp(260) : error C2440: 'argument' :
cannot convert from 'const
boost::multi_index::detail::index_node_base<Value>::value_type *' to
'Statistics *const '
 with
        [
            Value=Statistics
        ]
        Conversion loses qualifiers
boost\boost\bind.hpp(347) : see reference to function template
instantiation 'R boost::_mfi::mf2<R,T,A1,A2>::operator
()<Statistics>(const U &,A1,A2) const' being compiled
        with
        [
            R=void,
            T=Statistics,
            A1=double,
            A2=int,

U=boost::multi_index::detail::index_node_base<Statistics>::value_type
        ]

....
"

I see the problem is that compiler tries to convert Statistics* into
Statistics* const, but I do not know how to fix it ..

-- 
Nebojsa Simic

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