New paper: N3526, Uniform initialization for arrays and class aggregate types -- Michael Price

A new WG21 paper is available:

Document number: N3526

Date: 2013-01-21

Uniform initialization for arrays and class aggregate types

 

by Michael Price

An excerpt:

This document proposes a slight relaxation of the rules for eliding braces from aggregate initialization in order to make initialization of arrays and class aggregates more uniform. This change is required in order to support class aggregate types with a single member subaggregate that behave similarly to their array counterparts (i.e. std::array).

[...]

However, when we begin to mix the aggregate types, uniform initialization begins to break down.

  struct aggr_t {
      int a;
      int b;
  }  array_of_aggr[2] = {{1, 2}, {3, 4}};

  struct aggr_ex_t {
      int x[2][2];
  };

  aggr_ex_t bad  = {{1, 2}, {3, 4}};      // Error: Too many initializers, see below for details
  aggr_ex_t good = {{{1, 2}, {3, 4}}};

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.