Greeting,

    I would like to propose partial<> when you wish to postpone an object's
construction:
http://groups.yahoo.com/group/boost/files/shifted_ptr/partial.hpp

    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:
1
2
4
4
1


On an Intel platform.



Philippe A. Bouchard




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

Reply via email to