
Stefan Strasser-2 wrote:
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?
yes, this could be said this way. Stefan Strasser-2 wrote:
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.
Non , serialization don't fits my requirements as I need to use the object when deferred updating policy is used. Stefan Strasser-2 wrote:
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.
I was talking of has_trivial_copy and has_trivial_assign. Anyway, if the user provides a fusion sequence view of the structure, we can decide if the structure has pointers to non-transactional objects. Stefan Strasser-2 wrote:
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,
I know that this cannot be detected. And the user will need to specialize the trait. Stefan Strasser-2 wrote:
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/...
Do you mean that I can request instead of the shallow copy constructor request a make_shallow_copy? C* make_shallow_copy(C const &); Stefan Strasser-2 wrote:
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.
Sorry, I don't understand how the fact the type must derive from base_transaction_object can help to define the has_shallow_copy_constructor. Could you elaborate? Thanks for your comments, Vicente -- View this message in context: http://old.nabble.com/How-to-create-a-shallow-copy-without-calling-a-constru... Sent from the Boost - Dev mailing list archive at Nabble.com.