Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-08-12 11:08:51


> I'm not sure if this ptr<> type under discussion works this way, but in
> general you can't conformingly use char* arithmetic with offsets to find
> the sub-parts of non-POD types.

The offsets are what static_cast<>s return. I cheat in the syntax when I
say ptr_base<T, __false_type>::m_ptr is of type T *; it's just to make the
code cleaner. It is a pointer to a memory block in fact but I have to
figure out the best way to properly align the allocated block with T, U and
extra integers before going further. I was thinking of this pointee type:

template <typename T>
    struct ptr_block
    {
        int m_counter;
        int m_typeid;

        union
        {
            int;
            T;
        } m_object;
    };

But operator new (size_t, rc_type const &) won't be easy to implement
because size_t is not a compile-time constant.

Philippe A. Bouchard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk