texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] How to mark/copy objects in C++


From: Gabriel Dos Reis
Subject: Re: [Texmacs-dev] How to mark/copy objects in C++
Date: 24 May 2004 21:11:54 +0200

Joris van der Hoeven <address@hidden> writes:

| A question for Gabriel: would there be an easy way to implement
| type-safe marking/copying routines in C++ for all TeXmacs types.
| Of course, we can manually write such routines for each type,
| but there might be a more automatic way. What do you think?

One more tip.  If you have a polymophic type T, and a pointer "p" of
type *T -- that may actually points to a complete object of type U
derived from T, then 

     dynamic_cast<void*>(p)

gives you a pointer to the start of the storage of the complete
object.  Therefore, you would be able to mark the complete object and
you would need to implement the specific bits of marking/copying only
for the "leaves classes" or "sealed classes", i.e. those from which
you no longer derive from.  That gives you something very general.

-- Gaby




reply via email to

[Prev in Thread] Current Thread [Next in Thread]