Hi again,

    I am doing some helper class that will pad the space after a given type
until it reaches a machine word boundary.  This word boundary would be the
maximum of (alignment_of<T>::value - sizeof(char)) where T is any
'typename', 'typename' is one of {is_class<U>::value == false} and U is any
type.

    I would like some help to isolate the most effective way to define
BOOST_DATA_ALIGNMENT in the following example (defined by default to 8 --
based on std headers).

    I would like to propose padding_of<> at the same time.

template <typename T>
    struct padding_of
    {
        size_t const BOOST_DATA_ALIGNMENT = 8;

        size_t const value = (BOOST_DATA_ALIGNMENT - sizeof(T) %
BOOST_DATA_ALIGNMENT) % BOOST_DATA_ALIGNMENT;
    };


template <typename T>
    struct padded
    {
        T type;
        char padding[padding_of<T>::value];  // can be of size 0!
    };

template <typename T>
    struct shifted_object : padded<counted_base>
    {
        T value;
    };



Thanks,

Philippe A. Bouchard




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

Reply via email to