insert somehow not working correctly.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MCT |
Invalid
|
Undecided
|
Unassigned |
Bug Description
The following code gives a problem when an item DOES NOT exist in the map already:
ConfigStore:
{
boost:
ConfigMap:
if(i != _configMap.end())
{
return i->second;
}
else
{
ConfigStore:
newVal.
dirty(true);
return newVal;
}
}
Then externally I call :
ConfigStore:
What happens is that value is valid after the call, but later becomes invalid. This would suggest that what insert returns is somehow not a reference to the actual stored internal value, but rather of another or copy of the internal value.
I've tried it with:
typedef std::map<key_type, mapped_type> ConfigMap;
typedef boost::
And it works perfectly, just not with:
typedef mct::closed_
mapped_type is a class (not pointer) and key_type is unimportant.
If I understand correctly, you keep a reference to an element or part of it. This is expected to break with MCT; from documentation:
Disadvantages:
* can move data in memory, i.e. invalidate pointers and references;
References/pointers are invalidated exactly when iterators are invalidated (since the latter are just glorified pointers). In other words, during _any_ insert or rehash operation.