Philippe A. Bouchard wrote:

[...]

> Example:
> optional<int> i;
>
> new (i) int(17);


Ex. 1:
// Class Widget has a heavy copy constructor
optional<Widget> i;

new (i) Widget(this, ...);


Ex. 2:
// The object A is aligned like a char
struct A
{
    char c_;

    A() : c_('\0') {}
    A(char a_c) : c_(a_c) {}
};

optional<char> array[50];

for (int i = 0; i < 50; ++ i)
{
    new (array[i]) A(' ');
}



Philippe A. Bouchard




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

Reply via email to