Copying Boost.Array initialization code

I am looking for the code that enables me to do the following with Boost.Array:
boost::array

On 23/12/10 17:28, Torri, Stephen CIV NSWCDD, W15 wrote:
I am looking for the code that enables me to do the following with Boost.Array:
boost::array
tmp = { { 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1 } }; I would like to learn how to do this. I have need to easily initialize a 4x4 grid with data.
boost array does nothign special. Any class which is defined as a POD type (Plain Old Data) supports aggregate construction. To make a POD class, all memeber should be POD and public, dont inherit from anything and dont provide constructor.

2010/12/23 Joel Falcou
On 23/12/10 17:28, Torri, Stephen CIV NSWCDD, W15 wrote:
I am looking for the code that enables me to do the following with Boost.Array:
boost::array
tmp = { { 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1 } }; I would like to learn how to do this. I have need to easily initialize a 4x4 grid with data.
boost array does nothign special. Any class which is defined as a POD type (Plain Old Data) supports aggregate construction. To make a POD class, all memeber should be POD and public, dont inherit from anything and dont provide constructor.
POD != aggregate. An aggregate class is a class with no user-declared constructors, no private or protected non-static data members, no base classes, and no virtual functions. The following type is an aggregate but isn't a POD. struct a { std::string s; }; Also, all arrays are aggregates. Roman Perepelitsa.

On 24/12/10 10:36, Roman Perepelitsa wrote:
POD != aggregate. An aggregate class is a class with no user-declared constructors, no private or protected non-static data members, no base classes, and no virtual functions.
The following type is an aggregate but isn't a POD.
struct a { std::string s; }; I think my POD definition is the same as yours. I think I misused the term "aggregate construction" used for the {} construction. What's the correct for this then ?

2010/12/24 Joel Falcou
On 24/12/10 10:36, Roman Perepelitsa wrote:
POD != aggregate. An aggregate class is a class with no user-declared constructors, no private or protected non-static data members, no base classes, and no virtual functions.
The following type is an aggregate but isn't a POD.
struct a { std::string s; };
I think my POD definition is the same as yours.
Not exactly. Aggregate does not have a recursive requirement (members of aggregate class does not have to be aggregates).
I think I misused the term "aggregate construction" used for the {} construction. What's the correct for this then ?
It's called aggregate. Roman Perepelitsa.
participants (3)
-
Joel Falcou
-
Roman Perepelitsa
-
Torri, Stephen CIV NSWCDD, W15