Boost logo

Boost :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2006-11-03 03:51:25


Roland Schwarz <roland.schwarz_at_[hidden]> writes:

> Anthony Williams wrote:
>> If the constexpr proposal gets accepted into the C++ Standard, we won't have
>> to worry about this in the future --- constructors that just use constant
>> expressions can be tagged "constexpr", and used for static initialization.
>
> What does this mean, can you please illustrate it with an example?

struct A
{
    constexpr A(int i_):
        i(i_),j(0)
    {}

    int i;
    int j;
};

static A a(6); // static initialization, same as {6,0}, but with a constructor.

Anthony

-- 
Anthony Williams
Software Developer
Just Software Solutions Ltd
http://www.justsoftwaresolutions.co.uk

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