Erase by iterator fails
- Dominant language
- C++
- Stars
- 26
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
There is a compiler error if try to erase by iterator instead key.
The same action on std::map is Ok.
```
template
void use_it(Map& m, std::string key, int data)
{
using value_type = typename Map::value_type;
using const_iterator = typename Map::const_iterator;
m.insert(value_type(key, data));
const_iterator iter = m.find(key);
if (iter != m.end()) {
assert(iter->first == key);
assert(iter->second == data);
std::cout << iter->first << " --> " << iter->second;
}
assert(!m.empty());
//m.erase(key); // it is ok
{
const_iterator iter = m.begin();
m.erase(iter); // erase by iterator fails
}
assert(m.empty());
}
int main()
{
using boost::bimaps::bimap;
using boost::bimaps::set_of;
using bimap_type = bimap, set_of>;
bimap_type bm;
// Standard map
{
typedef std::map map_type;
map_type m;
use_it(m, "one", 1);
}
// Left map view
{
typedef bimap_type::left_map map_type;
map_type& m = bm.left;
use_it(m, "one", 1);
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the supplied use_it reproducer and compare the std::map and Boost.Bimap left_map iterator erase calls. Check the relevant bimap view and iterator interfaces, then compile and run the example; done means erasing through the iterator succeeds and the container is empty.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100