commit 3937532d3956500a0af89dc667abab949f8f447f parent f9c8f40201b40b5ebeed551ca5ba744cfaaef9ea Author: Michael Savage <mikejsavage@gmail.com> Date: Mon Feb 6 19:34:57 +0200 Add a constructor for array2d< T > from array< T > Diffstat:
array.h | | | 7 | +++++++ |
diff --git a/array.h b/array.h @@ -101,6 +101,13 @@ public: elems = memory; } + array2d( array< T > a, size_t width, size_t height ) { + ASSERT( width * height <= a.n ); + elems = a.ptr(); + w = width; + h = height; + } + T & operator()( size_t x, size_t y ) { ASSERT( in_range( x, y ) ); return elems[ y * w + x ];