medfall

A super great game engine
Log | Files | Refs

commit 311d02b1b11913a438f7ded4a2a2c51f3c44074f
parent 5acf102f12482750a3f33ae42cde5deca3af36a5
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Jul  2 13:01:44 +0300

array2d.cast

Diffstat:
array.h | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/array.h b/array.h @@ -156,6 +156,18 @@ public: return sizeof( T ) * w * h; } + template< typename S > + array2d< S > cast() { + ASSERT( sizeof( S ) == sizeof( T ) ); + return array2d< S >( ( S * ) ptr(), w, h ); + } + + template< typename S > + const array2d< S > cast() const { + ASSERT( sizeof( S ) == sizeof( T ) ); + return array2d< S >( ( S * ) ptr(), w, h ); + } + size_t w, h; private: