
Am Sunday 03 January 2010 18:59:24 schrieb vicente.botet:
it can contain any non pointer type and pointers to transactional objects, but no pointer to non-transactional objects. The pointee transactional objects do not need to be copied since the STM system track any modification to them.
aren't you then really looking for a deep copy, excluding pointers to transactional objects? unfortunately there is no such concept of a "deep copy" in c++ either, so my approach is to use Boost.Serialization for cloning objects (or a user-supplied function). Using serialization you can decide on a case to case basis if the object behind a pointer should be copied. (depending on if the type is transactional, in your case). of course, that'd introduce the Serializable requirement and I don't know how well that fits into your design.
for the latter, you might want to make the decision if memcpy() can be used based on boost::serialization::is_bitwise_serializable.
is_bitwise_serializable don't goes too far. it is equivalent to is_artithmetic. But it can be specialized.
I have find in Boost.TypeTraits this example
I don't think you can use type traits to make sure an object doesn't have pointers (to non-transactional memory). I think you'll have to rely on the user to provide that information.
Of course, this force the user to define specific shallow copy semantics operations, but IMO this will have some advantages. What do you think of this approach?
how do you detect if a type provides this shallow copy constructor? as far as I know there is no way to statically detect that, that's why I went with inline friend functions, that can be found via ADL: https://svn.boost.org/svn/boost/sandbox/persistent/libs/persistent/doc/html/... this may be different in your case though because of the requirement to derive from *_transaction_object, that could be used to detect which types ought to provide a special copy constructor.