I checked the gcc code, if anyone wants to try to add this.
latest of cvs as of today

gcc/cp/decl.c : 9141
add a cxx_dialect == cxx0x check so it doesn't error on the static only member init

gcc/cp/init.c perform_member_init
If the member has no initialization, grab the init tree and perform the construction with that. little more complicated....

add parser code.

In the meantime I'll just use this wrapper class:

template <typename TYPE, TYPE value >
class defaulted
{
public:
   defaulted() : _t(value) { }
   operator TYPE & () { return _t; }
   TYPE & operator =(const TYPE & other) { _t = other; }
private:
   TYPE _t;
};

template <typename TYPE>
class defaulted_ptr
{
public:
defaulted_ptr() : _t(0) { } operator TYPE * & () { return _t; }
   TYPE * &  operator =(const TYPE * &other) { _t = other; }
private:
   TYPE * _t;
};


int main()
{
   defaulted<bool, true> a;
   defaulted_ptr<int *> b;
}

Chris

Chris wrote:
Hi,

I noticed N2756 is not on the gcc c++0x status page (probably because it's new). Any ideas if and when this would be implemented? It would be life-changing.

class A {
public:
A() { }
private:
   int x = 5;
   int y = 0;
};








Reply via email to