Boost logo

Boost Users :

From: Martin Eigel (martin_eigel_at_[hidden])
Date: 2006-02-15 15:37:22


Hi list,

I am encountering a problem with MultiIndex which can
be resolved by disabling SAFE_MODE. As I actually do
not get the problem in the code attached below I'd
like to ask for an explanation. The marked line of
code (i.e. the second iterator assignment) seems to be
responsible for blocking MultiIndex's dtor in

safe_mode.hpp:
void detach_all_iterators()
{
    for(safe_iterator_base*
it=header.next;it;it=it->next)it->cont=0;
}

Why is this and how can it correctly be avoided?

Cheers,
Martin

(boost 1.33.1, gcc 3.4.5)

#define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING
#define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE

#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>

using boost::multi_index_container;
using namespace boost::multi_index;

struct T1{};
struct T2{};

typedef int T;
typedef std::pair<T,T> value_type;

typedef multi_index_container<
  value_type,
  indexed_by<
  ordered_unique<
  tag<T1>, member<value_type,T,&value_type::first> >,
  ordered_unique<
  tag<T2>, member<value_type,T,&value_type::second> >
> > miT;

int main(){
  miT::const_iterator it;
  miT map;
  it = map.get<T1>().end();
  map.clear();
  it = map.get<T1>().end(); // *** this hangs dtor!
  return 0;
}

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


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