Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2003-02-24 04:42:48


    I would like to propose partial<> when you wish to postpone an object's

    The partial<T> object is aligned like an object of type T and reserves
enough memory space to hold it, of course. partial<> uses a helper
partial_type<> which is similar to Andrei Alexandrescu's typelists. It is
highly simplified and it does not cover member pointers up to now. Given
the fact I do not know Boost macros at 100%, I have left the code in pure
C++ syntax.

The following executable:
#include <iostream>
#include "partial.hpp"

using namespace std;
using namespace boost;

struct A
 A(int) {}

int main()
 cout << alignment_of< partial<char> >::value << endl;
 cout << alignment_of< partial<short> >::value << endl;
 cout << alignment_of< partial<int> >::value << endl;
 cout << alignment_of< partial<long long> >::value << endl;
 cout << alignment_of< partial<A> >::value << endl;

 partial<A> t;

 new (t) A(9);

Will ouput:

On an Intel platform.

Philippe A. Bouchard

Boost list run by bdawes at, gregod at, cpdaniel at, john at