"Johan Nilsson" <[EMAIL PROTECTED]> wrote in message
at52vi$si6$[EMAIL PROTECTED]">news:at52vi$si6$[EMAIL PROTECTED]...
[snip]

> I'd like to be able to store references to objects of arbitrary types in a
> homogenous collection, not requiring them to be derived from a common base
> class. For COM users, that would be something like an "IUnknown in the
> context of standard C++". I suspect that boost::any might be something
> similar to what I need, but I just got that idea using void pointers.
>

What's the point of that? I mean, with no interface to the types, you can't
do anything with these objects you're storing, not even delete them.

You could also do:

struct IHolder {
    virtual ~IHolder () {}
};

template <typename Object>
class holder : public IHolder{
    public:
        holder (Object* const object);
        ~holder ();
};

It's always better to try and look for a real (type safe) solution than
playing around with type casting. It still depends on what you want to _do_
with theses objects behind this common, empty interface. I suspect problems
with your design if you have been led down this path.

[snip]






_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to