[webkit-dev] Code style: Propose using C++11 uniform initializer syntax in member initializer lists

Daniel Bates dbates at webkit.org
Mon Aug 28 21:24:18 PDT 2017


Hi all,

I am writing to propose using C++11 uniform initializer syntax in member initializer lists. The following:

class A {
public:
    A(B&& b, float i, int j)
    : m_b(WTFMove(b))
    , m_i(i)
    , m_j(j)
    {
    }
...
};

Would become:

class A {
public:
    A(B&& b, float i, int j)
    : m_b { WTFMove(b) }
    , m_i { i }
    , m_j { j }
    {
    }
...
};

Using uniform initializer syntax in member initializer lists would make the syntax we use for member initializer lists consistent with the syntax we use for non-static data member initializers. It would also cause a compile time error if member initialization required a narrowing conversion (e.g. implicit float to int conversion). Another benefit of using this syntax is that it allows initialization of a struct using aggregate initialization.

Dan


More information about the webkit-dev mailing list