我正在使用 Boost 1.39。我已经使用boost::flyweight<no_locking, hashed_factory<> >
(我的应用程序是单线程的)实现了我的类。我班级的测试程序顺利通过,但是当我在应用程序中使用时,我很恐慌
#9 0x08de7c3e in boost::flyweights::detail::refcounted_value<boost::flyweights::detail::default_value_policy<SharedFileAttr>::rep_type, SharedFileAttr>::release (this=0x0) at /usr/include/boost/flyweight/refcounted.hpp:89
#10 0x08de7517 in boost::flyweights::detail::refcounted_handle<boost::flyweights::detail::refcounted_value<boost::flyweights::detail::default_value_policy<SharedFileAttr>::rep_type, SharedFileAttr> const*, boost::flyweights::detail::flyweight_core_tracking_helper<boost::flyweights::detail::default_value_policy<SharedFileAttr>, mpl_::na, boost::flyweights::refcounted, boost::flyweights::hashed_factory<mpl_::na, mpl_::na, mpl_::na, 0>, boost::flyweights::no_locking, boost::flyweights::static_holder> >::~refcounted_handle (this=0xf32fe61c,
__in_chrg=<value optimized out>) at /usr/include/boost/flyweight/refcounted.hpp:131
#11 0x08e2edfe in boost::flyweights::flyweight<SharedFileAttr, boost::flyweights::no_locking, boost::flyweights::hashed_factory<mpl_::na, mpl_::na, mpl_::na, 0>, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::operator= (this=0xf32fe7e4, x=...)
at /usr/include/boost/flyweight/flyweight.hpp:196
请注意,在第 9 帧中,这是 0x0
我不确定我的代码如何使用 boost::flyweight 导致引用计数问题。毕竟,我的接口只包含添加享元对象和销毁它们的方法。
我不知道如何解决这个问题。有任何想法吗?