Re: could not deduce template argument for 'double [m][n]' from
'double [2][3]'
Am 05.02.2012 09:30, schrieb Helmut Zeisel:
On 1 Feb., 19:29, Helmut Jarausch<jarau...@igpm.rwth-aachen.de>
wrote:
I'd use the new std::array.
How can I initialize 2-dim std::array?
std::array<std::array<double,2>,2> a={{1,2},{3,4}};
Unfortunately you need one further pair of braces for each array level,
ending in
std::array<std::array<double,2>,2> a={{ {{1,2}}, {{3,4}} }};
This is so, because the simple initialization of std::array with a
single pair of braces relies on one very special rule of aggregate
initialization that allows elision of braces under a very restricted set
of circumstances. Technically you could satisfy this condition by
rewriting above to
std::array<std::array<double,2>,2> a={ std::array<double,2>{{1,2}},
std::array<double,2>{{3,4}} };
but this is obviously worse compared to the alternative mentioned above.
HTH & Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]