medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit f9c8f40201b40b5ebeed551ca5ba744cfaaef9ea
parent a13557c8b7c04be29b8471300e9930609105fedf
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Mon Feb  6 19:34:26 +0200

Add array::cast< S >

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