C++ Template Question

Mosfet daniel.duley at verizon.net
Mon Aug 20 23:12:18 BST 2007

<Hans wrote>
> The only question I have about it is if it is possible to use this to
> create a multidimensional array and if so what is the proper way?

You mean sth. like this?

typedef QVarLengthArray<int, 50> Row;
QVarLengthArray<Row, 50> image(height);
for(uint y=0; y<height; ++y)


I was thinking more about if you can create a multidimensional array using 
just one QVarLengthArray in a nice way. I think with the above code you might 
as well just use a QList of QVarLengthArrays, which is not what I want.
Not a big problem - I can convert to offsets - just curious since I am no 
template guru.

<Hans also wrote>
..or you could use a "view"-like 2D adapter with a 1D QVarLengthArray.
(Our VIGRA library has such a thing:

Bookmarked and I will look at this more. Template image algorithm 
implementations seem to be getting quite popular.

On a side note, I first interpreted this project's name as "Viagra", which at 
least in the US has a totally different meaning but would also be good for a 
fast imaging library >:)

More information about the kde-core-devel mailing list