Boost logo

Boost Users :

Subject: [Boost-users] boost 1.43 bimap updating question
From: Damian (dfermin_at_[hidden])
Date: 2011-11-08 11:57:22


Hello.

I'm trying to update the data of a left bimap and I keep getting this
error message:
error: assignment of read-only data-member
‘boost::bimaps::relation::detail::normal_storage<boost::bimaps::tags::tagged<const
int, boost::bimaps::relation::member_at::left>,
boost::bimaps::tags::tagged<const double,
boost::bimaps::relation::member_at::right> >::second’

Here is what I'm doing:

int idx = 0;
double score = 0.0;

typedef boost::bimap<int, double> bm_type; // define the bimap type we
will use
bm_type bm;
bm_type::right_iterator r_iter;
bm_type::left_iterator l_iter;

bm.insert( bm_type::value_type( 1, 93.9) );
bm.insert( bm_type::value_type( 2, 18.3) );
bm.insert( bm_type::value_type( 3, 4.54) );
bm.insert( bm_type::value_type( 4, 0.343) );

score = 60000.0343;
idx = 3;

l_iter = bm.left.find(idx);
if(l_iter == bm.left.end()) { // this is a new entry so add it
bm.insert( bm_type::value_type( idx, score) );
}
else { // we have this idx value in the bimap

// update the bimap score value only if the current value
// of score is greater than what is currently in the bimap
// for the same index (idx) value.
if( l_iter->second < score ) {
l_iter->second = score;
}
}

Can someone tell me what I'm doing wrong?
The double value in the map is the only part that needs to be updated
and only if a new (higher) score is observed.

Thanks,
Damian

-- 
------------------------------------------------------------------------------
Damian Fermin, Ph.D.
Pathology Department
University of Michigan
4237 Medical Science I
1301 Catherine
Ann Arbor, MI 48109-0602
734.615.0302
"There is No Gene for the Human Spirit"
	-- GATTACA
------------------------------------------------------------------------------

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