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

Daniel Bates dbates at webkit.org
Tue Aug 29 11:06:09 PDT 2017


Posted patch to update Code Style Guidelines at <
https://bugs.webkit.org/show_bug.cgi?id=176058>.

Dan

On Mon, Aug 28, 2017 at 9:24 PM, Daniel Bates <dbates at webkit.org> wrote:

> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20170829/0b1b57a4/attachment.html>


More information about the webkit-dev mailing list