Subject: Re: [Boost-bugs] [Boost C++ Libraries] #4044: reset_object_address with library-created objects
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-03-26 23:10:03
#4044: reset_object_address with library-created objects
-------------------------------------------------+--------------------------
Reporter: Richard Hazlewood | Owner: ramey
Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: serialization
Version: Boost 1.42.0 | Severity: Problem
Keywords: reset_object_address heap allocated |
-------------------------------------------------+--------------------------
Comment(by Richard Hazlewood):
Okay, I was trying to generalize/test-case. Here's something closer to
what I'm really doing (I'm away from the real code, so this is from memory
;-) ):
{{{
class Whatever
{
typedef boost::function<Signature> Func;
Func m_func;
///
template <typename A>
void serialize(A &a, const unsigned)
{
if (A::is_saving::value)
{
FunctionObject *p = m_func.target<FunctionObject>();
// Let's serialize the function object via pointer
a & p;
}
else
{
FunctionObject *p = 0;
a & p;
m_func = *p; // Hand function object to boost::function
FunctionObject *realp = m_func.target<FunctionObject>();
a.reset_object_address(realp, p); // Does not work
delete p; // Hence this will ultimately mess things up
// (subsequent serialization may land in same address)
}
}
};
}}}
Also, I can't do:
{{{
{
a & *m_func.target<FunctionObject>();
}
else
{
m_func = FunctionObject(); // Initialize boost::function with empty
object
FunctionObject *realp = m_func.target<FunctionObject>();
a & *realp; // Deserialize right in
}
}}}
Because the {{{FunctionObject}}} has a private default ctor. This is why
I was trying to route it through the serialization library's pointer
creation ({{{FunctionObject}}} has ''access'' friendship).
Further, this is a simplification. In the real code {{{FunctionObject}}}
is a template argument, but it ''is'' serializable.
Hope this is clearer.
Best...
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4044#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC