Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2003-02-24 12:05:53


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk