Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2003-02-06 10:44:32


Hi,

    I have a question about smart pointer policies. I feel this is some
missing link in shifted_ptr.

Definitions:
1)
struct shifted_header
{
    union
    {
        int m_count;
        void * m_owner;
    };

    ...
};

2)
template <typename T>
    struct shifted_object
    {
        shifted_header m_header;
        T m_object;
    };

3)
void * operator new (size_t, shifted_type const &) returns a pointer of type
T, sizeof(shifted_object), member of shifted_object<T>.

$100 Question:
When I am looking at the "Storage Policy", p. 189, Modern C++ Design; the
class must be initialized by a StoredType object while in my situation the
StoredType is a shifted_object<T> and 'new (so) T' returns a pointer to T
(member of shifted_boject<T>). What am I supposed to do if I want to keep
it optimized and simple?

Thanks,

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