[ create a new paste ] login | about

Link: http://codepad.org/csde4mwT    [ raw code | fork ]

manuelj_pg - C++, pasted on Feb 27:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <boost/optional.hpp>
#include <boost/utility.hpp>

struct Foo : boost::noncopyable
{
    Foo(int i)
    {
    }
};


#define CONSTRUCT_OPTIONAL(dest, ctor_expr) \
    new ((dest).get_ptr()) ctor_expr;

int main()
{
    typedef boost::optional<Foo> OptFoo;
    OptFoo foos[100];
    
    CONSTRUCT_OPTIONAL(foos[3], Foo(2));
}


Output:
No errors or program output.


Create a new paste based on this one


Comments: