Boost logo

Boost :

From: Dirk Griffioen (d.griffioen_at_[hidden])
Date: 2004-07-12 09:14:09


Hi,

I encountered the following little problem:

I would like to use the following datastructures with boost::serialize:

struct Match {};
typedef std::string Key;
typedef tst< Match, Key > TernarySearchTree; //this one has a shared_ptr

typedef std::vector< TernarySearchTree > Trees;
typedef std::map< std::string, Trees > Symbols;

I have defined some serialize overloads so saving goes fine, but when
loading I get a "memory acces violation" inside the following code:

{
   boost::archive::text_iarchive ia(ifs);
   ia >> symbols_;
}

More specific, inside <boost/serializiton/shared_count.hpp>

    void add_ref_copy()
    {
#if defined(BOOST_HAS_THREADS)
        mutex_type::scoped_lock lock(mtx_);
#endif
       ++use_count_;
    }

Which constructs a scoped_lock, and there, the "explicit
scoped_lock(lightweight_mutex & m): m_(m)" seems to go wrong.

What could be the reason? The more since all worked fine (saving and
loading) when I used a simple vector of tst's.

 Is it not possible to use a map of string/vector (the error seems to
suggest the library failing when copying vector to map - eg ++use_count
of the shared_ptr inside the TST).

Thanks in advance,

Dirk


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk