Re: Misuses of RTTI
In article
<b2c74cac-f79b-4fb0-8a90-5971448b513c@z72g2000hsb.googlegroups.com>,
galathaea <galathaea@gmail.com> wrote:
unfortunately
the things being serialised are not always pure data objects
so boost's tuples are not a replacement for this generic need
pure data what else is there? If you mean POD then boost::fusion can
extend this, not sure about details of handling class that inherit
classes with private data and polymorphism but if I recall template
type deduction does not convert to base class or backward then it
seems do able. I shall assume that all classes in the hierarchy are
modifiable in at least providing friendship to a struct with a single
static function.
template <class T>
struct actual_write
{
static void exec(std::ostream &os, const T &x)
{ x.save(os);}
};
specialize for types that do not have a void save(std::ostream &);
method, such as built in types, std classes etc. Only problem remains
if we have
class cast_in_stone
{
int x;
int y;
public:
cast_in_stone(int,int);
// member functions
};
we have a problem. If cast_in_stone can provide friendship to
actual_write<cast_in_stone> then it is possible I think. since
we can use create a specialization that accesses the private data
of its argument.
At least its food for thought and can traverse data. plain or not.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]