Aggregate Initialiser Syntax

F

Frederick Gotham

I have set up an online poll:

http://snappoll.com/poll/130337.php

to ask C++ programmers whether they want aggregate initialiser syntax to be
added to the Standard. Here's is how it works:

struct MyAgg { int a; double b; };

class MyClass {
private:

int const arr[3];
MyAgg const agg;

public:

MyClass(int const a,int const b,int const c)
: arr( {a,b,c} ), agg( {b, c * 5.4} )
{
/* Function Body */
}
};

And also:

int *const p = new int[3]({5,4,3});
MyAgg *const p = new MyAgg({3,56.3});

The reason I set up the poll is to possibly demonstrate to the Standards
Committee that programmers feel that this is a fundamental programming
function, and should be provided by the language. (They haven't paid much
attention to the request of late).
 
J

Jerry Coffin

I have set up an online poll:

http://snappoll.com/poll/130337.php

to ask C++ programmers whether they want aggregate initialiser syntax to be
added to the Standard. Here's is how it works:

If you're going to suggest this, wouldn't it make more sense to follow
the same syntax used in C99, as in:

struct { int a[3], b; } w[] =
{ [0].a = {1}, [1].a[0] = 2 };

(from C99, $6.7.8/35).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top