Re: Another question about multidimensional vectors
On Oct 29, 1:21 am, "BobR" <removeBadB...@worldnet.att.net> wrote:
Juha Nieminen wrote in message...
Markus Pitha wrote:
[...]
I don't really understand what is it that you tried to accomplish
with that. If what you want is to create an x*y double-vector, you can
do it like this:
std::vector<std::vector<int> > values(xSize, std::vector<int>(ySize));
For that, all you need is:
size_t xSize( 20 ), ySize( 30 );
std::vector<std::vector<int> > values( xSize, ySize ); // 20x30
Are you sure? The actual wording in the standard says that this
should work, but the fact that it works is generally considered
to be an accidental side effect of the way the paragraph was
formulated, and is the subject of DR 438. The current status of
DR 438 is still DR, which means that it is still under
discussion, but according to the documentation of the issue,
there seems to be a consensus that this shouldn't work, and that
the only reason the issue is still open is that there are
problems finding the exact words to replace those in the
standard.
In the meantime, the code will compile with some library
implementations, and not with others. (It compiles with 2 out
of 4 that I have access to.) Given that its status is unsure,
however, I'd avoid it; once the wording is finalized, it's quite
possible (even probable) that it will cease working in later
versions of the compilers which currently support it.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34