Index: /trunk/nv/core/arcball.hh
===================================================================
--- /trunk/nv/core/arcball.hh	(revision 381)
+++ /trunk/nv/core/arcball.hh	(revision 382)
@@ -15,5 +15,5 @@
 
 #include <nv/core/common.hh>
-#include <nv/core/math.hh>
+#include <nv/stl/math.hh>
 
 namespace nv
Index: /trunk/nv/core/common.hh
===================================================================
--- /trunk/nv/core/common.hh	(revision 381)
+++ /trunk/nv/core/common.hh	(revision 382)
@@ -98,6 +98,6 @@
 #endif
 
-#if NV_COMPILER == NV_MSVC && NV_COMP_VER < 1700
-#error "MSVC 2013+ required!"
+#if NV_COMPILER == NV_MSVC && NV_COMP_VER < 1900
+#error "MSVC 2015+ required!"
 #endif
 
@@ -106,11 +106,7 @@
 #endif
 
-#if NV_COMPILER == NV_CLANG && NV_COMP_VER < 320
-#error "clang 3.2+ required!"
-#endif
-
-// Feature incoming - remove and find when constexpr compiler is used
-#define NV_CONSTEXPR 
-#define NV_CONSTEXPR_CONST const
+#if NV_COMPILER == NV_CLANG && NV_COMP_VER < 330
+#error "clang 3.3+ required!"
+#endif
 
 #if NV_COMPILER == NV_MSVC 
@@ -137,12 +133,10 @@
 #define NV_RESTRICT __declspec(restrict)
 #define NV_RESTRICT_VAR __restrict
-#define NV_NOEXCEPT throw()
-#define NV_ALIGN_OF(type) __alignof(type)
 #if NV_ARCHITECTURE == NV_64BIT
 #define NV_OFFSET_OF(obj,m) (nv::size_t)( (nv::ptrdiff_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m)) )
 #else // NV_32BIT
 #define NV_OFFSET_OF(obj,m) (nv::size_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m))
+#define NV_MSVC_SUPRESS( warn_number ) __pragma( warning( suppress : warn_number ) )
 #endif  
-//#define NV_CONSTEXPR 
 #elif NV_COMPILER == NV_GNUC || NV_COMPILER == NV_CLANG
 #define NV_DEPRECATED(func) func __attribute__ ((deprecated))
@@ -151,8 +145,6 @@
 #define NV_RESTRICT __restrict__
 #define NV_RESTRICT_VAR __restrict__
-#define NV_NOEXCEPT noexcept
-#define NV_ALIGN_OF(type) alignof(type)
 #define NV_OFFSET_OF(obj, m) __builtin_offsetof(obj, m)
-//#define NV_CONSTEXPR constexpr 
+#define NV_MSVC_SUPRESS( warn_number ) 
 #else
 #error "Unknown compiler, cannot proceed!"
@@ -184,11 +176,20 @@
 	struct static_assert_fail
 	{
-		static const bool value = false;
+		static constexpr bool value = false;
 	};
 
-	using size_t    = decltype( sizeof(0) );
+#if NV_COMPILER == NV_MSVC 
+	using ::size_t;
+#else
+	using size_t    = decltype( 0 );
+#endif
 	using ptrdiff_t = decltype((int*)0 - (int*)0);
-
 	using nullptr_t = decltype( nullptr );
+	
+#if NV_ARCHITECTURE == NV_64BIT
+	using uintptr_t = unsigned long long;
+#else
+	using uintptr_t = unsigned int;
+#endif
 
 	// Typedefs for fixed size types.
@@ -225,5 +226,5 @@
 	struct four_cc
 	{
-		static const unsigned int value = (((((d << 8) | c) << 8) | b) << 8) | a;
+		static constexpr unsigned int value = (((((d << 8) | c) << 8) | b) << 8) | a;
 	};
 
@@ -231,5 +232,5 @@
 	{
 	protected:
-		NV_CONSTEXPR noncopyable() = default;
+		constexpr noncopyable() = default;
 		~noncopyable() = default;
 		noncopyable( const noncopyable& ) = delete;
@@ -244,5 +245,5 @@
 
 	template <typename T, typename U>
-	T narrow_cast( const U& a )
+	constexpr T narrow_cast( const U& a )
 	{
 		return static_cast<T>( a & T( -1 ) );
Index: /trunk/nv/stl/array.hh
===================================================================
--- /trunk/nv/stl/array.hh	(revision 381)
+++ /trunk/nv/stl/array.hh	(revision 382)
@@ -24,138 +24,16 @@
 namespace nv
 {
-	using std::vector;
+	using ::std::vector;
 
-	template < typename T, typename Storage >
-	class array_base 
-		: public detail::pointer_iterators < array_base< T, Storage >, Storage >
-	{
-	public:
-		typedef T         value_type;
-		typedef size_t    size_type;
-		typedef ptrdiff_t difference_type;
-		typedef T*        pointer;
-		typedef const T*  const_pointer;
-		typedef T*        iterator;
-		typedef const T*  const_iterator;
-		typedef T&        reference;
-		typedef const T&  const_reference;
-		typedef nv::reverse_iterator<iterator>       reverse_iterator;
-		typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
+	template < typename ContainerAllocator >
+	using array_base = detail::add_random_access< detail::add_iterators < ContainerAllocator > >;
 
-		inline const_pointer data() const { return m_storage.data(); }
-		inline pointer data() { return m_storage.data(); }
-		inline size_t size() const { return m_storage.size(); }
-		inline bool empty() const { return m_storage.size() == 0; }
-		inline size_type   raw_size() const { return m_storage.size() * sizeof( value_type ); }
-		inline const char* raw_data() const { return (const char*)m_storage.data(); }
-		inline char*       raw_data() { return (char*)m_storage.data(); }
-
-		inline reference       front() { NV_ASSERT( !empty(), "front() called on empty data!" );  return m_storage.data()[0]; }
-		inline const_reference front() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_storage.data()[0]; }
-		inline reference       back() { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_storage.data()[size() - 1]; }
-		inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_storage.data()[size() - 1]; }
-
-		reference operator[]( size_type i )
-		{
-			NV_ASSERT( i < m_storage.size(), "Out of range" );
-			return m_storage.data()[i];
-		}
-
-		const_reference operator[]( size_type i ) const
-		{
-			NV_ASSERT( i < m_storage.size(), "Out of range" );
-			return m_storage.data()[i];
-		}
-
-		inline void assign( const value_type& value ) { fill( value ); }
-
-		inline void fill( const value_type& value )
-		{
-			fill_n( this->begin(), this->size(), value );
-		}
-
-		inline void clear()
-		{
-			fill_default_n( this->begin(), this->size() );
-		}
-
-	protected:
-		Storage m_storage;
-	};
 
 	template< typename T, size_t N >
-	using array = array_base < T, fixed_container_storage < static_storage< T, N > > >;
+	using array = array_base < fixed_container_allocator < fixed_static_storage< T, N > > >;
 	
+	template< typename T >
+	using dynamic_array = array_base < sized_container_allocator< resizable_dynamic_storage< T > > >;
 
-#if 0
-
-	template< typename T, size_t N >
-	class array : public detail::pointer_iterators < array< T, N >, T, false >
-	{
-	public:
-		typedef T         value_type;
-		typedef size_t    size_type;
-		typedef ptrdiff_t difference_type;
-		typedef T*        pointer;
-		typedef const T*  const_pointer;
-		typedef T*        iterator;
-		typedef const T*  const_iterator;
-		typedef T&        reference;
-		typedef const T&  const_reference;
-		typedef nv::reverse_iterator<iterator>       reverse_iterator;
-		typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
-
-		static const size_type SIZE = N;
-		static const size_type ELEMENT_SIZE = sizeof( value_type );
-
-		inline const_pointer data() const { return m_data; }
-		inline pointer data() { return m_data; }
-		inline size_type size() const { return SIZE; }
-		inline bool empty() const { return false; }
-		inline size_type   raw_size() const { return SIZE * sizeof( T ); }
-		inline const char* raw_data() const { return (const char*)m_data; }
-		inline char*       raw_data() { return (char*)m_data; }
-
-		inline reference       front() { NV_ASSERT( !empty(), "front() called on empty data!" );  return m_data[0]; }
-		inline const_reference front() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[0]; }
-		inline reference       back() { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[SIZE - 1]; }
-		inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[SIZE - 1]; }
-
-		reference operator[]( size_type i ) 
-		{ 
-			NV_ASSERT( i < N, "Out of range" ); 
-			return this->m_data[i];
-		}
-
-		const_reference operator[]( size_type i ) const 
-		{     
-			NV_ASSERT( i < N, "Out of range" ); 
-			return this->m_data[i];
-		}
-
-		reference at( size_type i )
-		{
-			NV_ASSERT( i < N, "Out of range" );
-			return this->m_data[i];
-		}
-
-		const_reference at( size_type i ) const
-		{
-			NV_ASSERT( i < N, "Out of range" );
-			return this->m_data[i];
-		}
-
-		void assign( const value_type& value ) { fill( value ); }
-
-		void fill( const value_type& value )
-		{
-			std::fill_n( this->begin(), this->size(), value );
-		}
-
-	private:
-		value_type m_data[SIZE];
-	};
-
-#endif
 // 	template < typename T, typename ContainerAllocator >
 // 	class vector_base
@@ -211,107 +89,4 @@
 // 	};
 
-	template< typename T >
-	class dynamic_array : public detail::data_base< storage_view< T > >
-	{
-	public:
-		typedef T         value_type;
-		typedef T*        iterator;
-		typedef const T*  const_iterator;
-		typedef T&        reference;
-		typedef const T&  const_reference;
-		typedef size_t    size_type;
-		typedef ptrdiff_t difference_type;
-
-		typedef nv::reverse_iterator<iterator>       reverse_iterator;
-		typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
-
-		dynamic_array() : detail::data_base< storage_view< T > >() {}
-//			: m_data( nullptr ), m_size(0) {}
-		explicit dynamic_array( size_type new_size ) : detail::data_base< storage_view< T > >( new value_type[new_size], new_size ) {}
-//			: m_data( new value_type[ new_size ] ), m_size( new_size ) {}
-		dynamic_array( const value_type& value, size_type size ) : detail::data_base< storage_view< T > >()
-//			: m_data( nullptr ), m_size(0) 
-		{ assign( value, size ); }
-		dynamic_array( const_iterator values, size_type size ) : detail::data_base< storage_view< T > >()
-//			: m_data( nullptr ), m_size(0) 
-		{ assign( values, size ); }
-
-		void resize( size_type new_size )
-		{
-			if ( new_size != this->size() )
-			{
-				value_type* old_data = this->data();
-				value_type* new_data = new_size > 0 ? new value_type[new_size] : nullptr;
-				if ( old_data && this->data() )
-				{
-					std::copy_n( old_data, new_size > this->size() ? this->size() : new_size, new_data );
-				}
-				delete[] old_data;
-				assign( new_data, new_size );
-			}
-		}
-
-// 		iterator        begin()        { return m_data; }
-// 		const_iterator  begin()  const { return m_data; }
-// 		const_iterator  cbegin() const { return m_data; }
-// 
-// 		iterator        end()        { return m_data+m_size; }
-// 		const_iterator  end()  const { return m_data+m_size; }
-// 		const_iterator  cend() const { return m_data+m_size; }
-// 
-// 		reverse_iterator rbegin()              { return reverse_iterator( end() ); }
-// 		const_reverse_iterator rbegin() const  { return const_reverse_iterator( end() ); }
-// 		const_reverse_iterator crbegin() const { return const_reverse_iterator( end() ); }
-// 
-// 		reverse_iterator rend()                { return reverse_iterator( begin() ); }
-// 		const_reverse_iterator rend() const    { return const_reverse_iterator( begin() ); }
-// 		const_reverse_iterator crend() const   { return const_reverse_iterator( begin() ); }
-
-		reference operator[]( size_type i ) 
-		{ 
-			NV_ASSERT( i < this->size(), "Out of range" );
-			return this->data()[i];
-		}
-
-		const_reference operator[]( size_type i ) const 
-		{     
-			NV_ASSERT( i < this->size(), "Out of range" );
-			return this->data()[i];
-		}
-
-// 		reference       front()       { return m_data[0]; }
-// 		const_reference front() const { return m_data[0]; }
-// 		reference       back()        { return m_data[m_size-1]; }
-// 		const_reference back() const  { return m_data[m_size-1]; }
-// 
-// 		size_type        size() const     { return m_size; }
-// 		bool             empty() const    { return m_size == 0; }
-// 		static size_type max_size()       { return numeric_limits< size_type >::max(); }
-// 		const value_type* data() const { return m_data; }
-// 		value_type*       data()       { return m_data; }
-// 
-// 		size_type   raw_size() const { return m_size * ELEMENT_SIZE; }
-// 		const char* raw_data() const { return (const char*)m_data; }
-// 		char*       raw_data()       { return (char*)m_data; }
-
-		void assign( const value_type& value ) { std::fill_n( this->begin(), this->size(), value ); }
-		void assign( const value_type& value, size_type new_size ) 
-		{
-			resize( new_size );
-			std::fill_n( this->begin(), this->size(), value );
-		}
-		void assign( const_iterator values, size_type new_size )
-		{
-			resize( new_size );
-			std::copy_n( values, this->size(), this->data() );
-		}
-
-		~dynamic_array() { delete[] this->data(); }
-
-		static const size_type ELEMENT_SIZE = sizeof(T);
-	};
-
-
-
 }
 
Index: /trunk/nv/stl/capi.hh
===================================================================
--- /trunk/nv/stl/capi.hh	(revision 381)
+++ /trunk/nv/stl/capi.hh	(revision 382)
@@ -42,5 +42,5 @@
 #endif 
 		// TODO: remove when clang 3.5 will be used (with builtins)
-#if NV_COMPILER == NV_CLANG
+#if NV_COMPILER == NV_CLANG || NV_COMPILER == NV_GNUC
 #define NV_CAPI_CALL(name) detail::name
 		extern "C" {
@@ -57,9 +57,5 @@
 			extern int    __cdecl strncmp( const char * , const char * , size_t );
 			extern nv::size_t __cdecl strlen ( const char * );
-	}
-#endif
-
-#if NV_COMPILER == NV_GNUC
-#define NV_CAPI_CALL(name) __builtin_##name
+		}
 #endif
 	}
@@ -68,4 +64,10 @@
 	{
 		return NV_CAPI_CALL(malloc)( size );
+	}
+	inline void* nvrealloc( void* p, size_t size )
+	{
+		if ( size > 0 ) return NV_CAPI_CALL( realloc )( p, size );
+		NV_CAPI_CALL( free )( p );
+		return nullptr;
 	}
 	inline void nvfree( void* p )
Index: /trunk/nv/stl/cstring_store.hh
===================================================================
--- /trunk/nv/stl/cstring_store.hh	(revision 381)
+++ /trunk/nv/stl/cstring_store.hh	(revision 382)
@@ -61,29 +61,4 @@
 	using cstring_unordered_map = std::unordered_map < const char*, T, detail::cstring_hash, detail::cstring_compare > ;
 
-	struct cstring_deleter : public noncopyable
-	{
-	public:
-		cstring_deleter() {}
-
-		char* duplicate( const char* s )
-		{
-			char* result = detail::cstring_duplicate( s );
-			insert( result );
-			return result;
-		}
-
-		void insert( char * s )
-		{
-			m_array.push_back( s );
-		}
-
-		~cstring_deleter()
-		{
-			for ( auto s : m_array ) free( s );
-		}
-	private:
-		std::vector< char* > m_array;
-	};
-
 	class cstring_store : public noncopyable
 	{
Index: /trunk/nv/stl/limits.hh
===================================================================
--- /trunk/nv/stl/limits.hh	(revision 381)
+++ /trunk/nv/stl/limits.hh	(revision 382)
@@ -20,58 +20,58 @@
 	struct limits
 	{
-		static const unsigned char uc_min = 0;
-		static const unsigned char uc_max = 255;
-		static const unsigned char uc_bit = sizeof( unsigned char ) * 8;
-		static const signed char sc_min = -128;
-		static const signed char sc_max = 127;
-		static const signed char sc_bit = sizeof( signed char ) * 8;
-		static const char c_min = ( char( 0 ) < char( -1 ) ? 0 : -128 );
-		static const char c_max = ( char( 0 ) < char( -1 ) ? 255 : 127 );
-		static const char c_bit = sizeof( char ) * 8;
-		static const unsigned short us_min = 0;
-		static const unsigned short us_max = 65535;
-		static const unsigned short us_bit = sizeof( unsigned short ) * 8;
-		static const signed short ss_min = -32768;
-		static const signed short ss_max = 32767;
-		static const signed short ss_bit = sizeof( signed short ) * 8;
-		static const unsigned int ui_min = 0;
-		static const unsigned int ui_max = 4294967295;
-		static const unsigned int ui_bit = sizeof( unsigned int ) * 8;
-		static const signed int si_min = -2147483648;
-		static const signed int si_max = 2147483647;
-		static const signed int si_bit = sizeof( signed int ) * 8;
-		static const unsigned long ul_min = 0;
-		static const unsigned long ul_max = 4294967295;
-		static const unsigned long ul_bit = sizeof( unsigned long ) * 8;
-		static const signed long sl_min = -2147483648;
-		static const signed long sl_max = 2147483647;
-		static const signed long sl_bit = sizeof( signed long ) * 8;
-		static const unsigned long long ull_min = 0;
-		static const unsigned long long ull_max = 18446744073709551615;
-		static const unsigned long long ull_bit = sizeof( unsigned long long ) * 8;
-		static const signed long long sll_min = -9223372036854775808;
-		static const signed long long sll_max = 9223372036854775807;
-		static const signed long long sll_bit = sizeof( signed long long ) * 8;
-
-		static const int f_dig        = 6;
-		static const int f_mant_dig   = 24;
-		static const int f_max_exp    = 128;
-		static const int f_max_10_exp = 38;
-		static const int f_min_exp    = -125;
-		static const int f_min_10_exp = -37;
-
-		static const int d_dig        = 15;
-		static const int d_mant_dig   = 53;
-		static const int d_max_exp    = 1024;
-		static const int d_max_10_exp = 308;
-		static const int d_min_exp    = -1021;
-		static const int d_min_10_exp = -307;
-
-		static const int ld_dig        = d_dig;
-		static const int ld_mant_dig   = d_mant_dig;
-		static const int ld_max_exp    = d_max_exp;
-		static const int ld_max_10_exp = d_max_10_exp;
-		static const int ld_min_exp    = d_min_exp;
-		static const int ld_min_10_exp = d_min_10_exp;
+		static constexpr unsigned char uc_min = 0;
+		static constexpr unsigned char uc_max = 255;
+		static constexpr unsigned char uc_bit = sizeof( unsigned char ) * 8;
+		static constexpr signed char sc_min = -128;
+		static constexpr signed char sc_max = 127;
+		static constexpr signed char sc_bit = sizeof( signed char ) * 8;
+		static constexpr char c_min = ( char( 0 ) < char( -1 ) ? 0 : -128 );
+		static constexpr char c_max = ( char( 0 ) < char( -1 ) ? 255 : 127 );
+		static constexpr char c_bit = sizeof( char ) * 8;
+		static constexpr unsigned short us_min = 0;
+		static constexpr unsigned short us_max = 65535;
+		static constexpr unsigned short us_bit = sizeof( unsigned short ) * 8;
+		static constexpr signed short ss_min = -32768;
+		static constexpr signed short ss_max = 32767;
+		static constexpr signed short ss_bit = sizeof( signed short ) * 8;
+		static constexpr unsigned int ui_min = 0;
+		static constexpr unsigned int ui_max = 4294967295;
+		static constexpr unsigned int ui_bit = sizeof( unsigned int ) * 8;
+		static constexpr signed int si_min = -2147483648;
+		static constexpr signed int si_max = 2147483647;
+		static constexpr signed int si_bit = sizeof( signed int ) * 8;
+		static constexpr unsigned long ul_min = 0;
+		static constexpr unsigned long ul_max = 4294967295;
+		static constexpr unsigned long ul_bit = sizeof( unsigned long ) * 8;
+		static constexpr signed long sl_min = -2147483648;
+		static constexpr signed long sl_max = 2147483647;
+		static constexpr signed long sl_bit = sizeof( signed long ) * 8;
+		static constexpr unsigned long long ull_min = 0;
+		static constexpr unsigned long long ull_max = 18446744073709551615;
+		static constexpr unsigned long long ull_bit = sizeof( unsigned long long ) * 8;
+		static constexpr signed long long sll_min = -9223372036854775808;
+		static constexpr signed long long sll_max = 9223372036854775807;
+		static constexpr signed long long sll_bit = sizeof( signed long long ) * 8;
+
+		static constexpr int f_dig        = 6;
+		static constexpr int f_mant_dig   = 24;
+		static constexpr int f_max_exp    = 128;
+		static constexpr int f_max_10_exp = 38;
+		static constexpr int f_min_exp    = -125;
+		static constexpr int f_min_10_exp = -37;
+
+		static constexpr int d_dig        = 15;
+		static constexpr int d_mant_dig   = 53;
+		static constexpr int d_max_exp    = 1024;
+		static constexpr int d_max_10_exp = 308;
+		static constexpr int d_min_exp    = -1021;
+		static constexpr int d_min_10_exp = -307;
+
+		static constexpr int ld_dig        = d_dig;
+		static constexpr int ld_mant_dig   = d_mant_dig;
+		static constexpr int ld_max_exp    = d_max_exp;
+		static constexpr int ld_max_10_exp = d_max_10_exp;
+		static constexpr int ld_min_exp    = d_min_exp;
+		static constexpr int ld_min_10_exp = d_min_10_exp;
 	};
 
@@ -96,53 +96,53 @@
 		struct numeric_limits_base
 		{
-			static const float_denorm_style has_denorm = denorm_absent;
-			static const bool has_denorm_loss   = false;
-			static const bool has_infinity      = false;
-			static const bool has_quiet_NaN     = false;
-			static const bool has_signaling_NaN = false;
-			static const bool is_bounded        = false;
-			static const bool is_exact          = false;
-			static const bool is_iec559         = false;
-			static const bool is_integer        = false;
-			static const bool is_modulo         = false;
-			static const bool is_signed         = false;
-			static const bool is_specialized    = false;
-			static const bool tinyness_before   = false;
-			static const bool traps             = false;
-			static const float_round_style round_style = round_toward_zero;
-			static const int digits         = 0;
-			static const int digits10       = 0;
-			static const int max_digits10   = 0;
-			static const int max_exponent   = 0;
-			static const int max_exponent10 = 0;
-			static const int min_exponent   = 0;
-			static const int min_exponent10 = 0;
-			static const int radix          = 0;
+			static constexpr float_denorm_style has_denorm = denorm_absent;
+			static constexpr bool has_denorm_loss   = false;
+			static constexpr bool has_infinity      = false;
+			static constexpr bool has_quiet_NaN     = false;
+			static constexpr bool has_signaling_NaN = false;
+			static constexpr bool is_bounded        = false;
+			static constexpr bool is_exact          = false;
+			static constexpr bool is_iec559         = false;
+			static constexpr bool is_integer        = false;
+			static constexpr bool is_modulo         = false;
+			static constexpr bool is_signed         = false;
+			static constexpr bool is_specialized    = false;
+			static constexpr bool tinyness_before   = false;
+			static constexpr bool traps             = false;
+			static constexpr float_round_style round_style = round_toward_zero;
+			static constexpr int digits         = 0;
+			static constexpr int digits10       = 0;
+			static constexpr int max_digits10   = 0;
+			static constexpr int max_exponent   = 0;
+			static constexpr int max_exponent10 = 0;
+			static constexpr int min_exponent   = 0;
+			static constexpr int min_exponent10 = 0;
+			static constexpr int radix          = 0;
 		};
 
 		struct numeric_limits_int_base : public numeric_limits_base
 		{
-			static const bool is_bounded     = true;
-			static const bool is_exact       = true;
-			static const bool is_integer     = true;
-			static const bool is_modulo      = true;
-			static const bool is_specialized = true;
-			static const int radix = 2;
+			static constexpr bool is_bounded     = true;
+			static constexpr bool is_exact       = true;
+			static constexpr bool is_integer     = true;
+			static constexpr bool is_modulo      = true;
+			static constexpr bool is_specialized = true;
+			static constexpr int radix = 2;
 		};
 
 		struct numeric_limits_float_base : public numeric_limits_base
 		{
-			static const float_denorm_style has_denorm = denorm_present;
-			static const bool has_denorm_loss   = true;
-			static const bool has_infinity      = true;
-			static const bool has_quiet_NaN     = true;
-			static const bool has_signaling_NaN = true;
-			static const bool is_bounded        = true;
-			static const bool is_iec559         = true;
-			static const bool is_signed         = true;
-			static const bool is_specialized    = true;
-			static const bool tinyness_before   = true;
-			static const float_round_style round_style = round_to_nearest;
-			static const int radix = 2;
+			static constexpr float_denorm_style has_denorm = denorm_present;
+			static constexpr bool has_denorm_loss   = true;
+			static constexpr bool has_infinity      = true;
+			static constexpr bool has_quiet_NaN     = true;
+			static constexpr bool has_signaling_NaN = true;
+			static constexpr bool is_bounded        = true;
+			static constexpr bool is_iec559         = true;
+			static constexpr bool is_signed         = true;
+			static constexpr bool is_specialized    = true;
+			static constexpr bool tinyness_before   = true;
+			static constexpr float_round_style round_style = round_to_nearest;
+			static constexpr int radix = 2;
 		};
 
@@ -152,9 +152,9 @@
 	struct numeric_limits : detail::numeric_limits_base
 	{
-		static NV_CONSTEXPR T min()           NV_NOEXCEPT { return T( 0 ); }
-		static NV_CONSTEXPR T max()           NV_NOEXCEPT { return T( 0 ); }
-		static NV_CONSTEXPR T lowest()        NV_NOEXCEPT { return T( 0 ); }
-		static NV_CONSTEXPR T epsilon()       NV_NOEXCEPT { return T( 0 ); }
-		static NV_CONSTEXPR T round_error()   NV_NOEXCEPT { return T( 0 ); }
+		static constexpr T min()           noexcept { return T( 0 ); }
+		static constexpr T max()           noexcept { return T( 0 ); }
+		static constexpr T lowest()        noexcept { return T( 0 ); }
+		static constexpr T epsilon()       noexcept { return T( 0 ); }
+		static constexpr T round_error()   noexcept { return T( 0 ); }
 	};
 
@@ -171,14 +171,14 @@
 	struct numeric_limits < bool > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR bool min()           NV_NOEXCEPT { return false; }
-		static NV_CONSTEXPR bool max()           NV_NOEXCEPT { return true; }
-		static NV_CONSTEXPR bool lowest()        NV_NOEXCEPT { return false; }
-		static NV_CONSTEXPR bool epsilon()       NV_NOEXCEPT { return bool( 0 ); }
-		static NV_CONSTEXPR bool round_error()   NV_NOEXCEPT { return bool( 0 ); }
-
-		static const bool is_modulo = false;
-		static const bool is_signed = false;
-		static const int  digits    = 1;
-		static const int  digits10  = 0;
+		static constexpr bool min()           noexcept { return false; }
+		static constexpr bool max()           noexcept { return true; }
+		static constexpr bool lowest()        noexcept { return false; }
+		static constexpr bool epsilon()       noexcept { return bool( 0 ); }
+		static constexpr bool round_error()   noexcept { return bool( 0 ); }
+
+		static constexpr bool is_modulo = false;
+		static constexpr bool is_signed = false;
+		static constexpr int  digits    = 1;
+		static constexpr int  digits10  = 0;
 	};
 
@@ -186,13 +186,13 @@
 	struct numeric_limits < char > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR char min()           NV_NOEXCEPT { return limits::c_min; }
-		static NV_CONSTEXPR char max()           NV_NOEXCEPT { return limits::c_max; }
-		static NV_CONSTEXPR char lowest()        NV_NOEXCEPT { return limits::c_min; }
-		static NV_CONSTEXPR char epsilon()       NV_NOEXCEPT { return 0; }
-		static NV_CONSTEXPR char round_error()   NV_NOEXCEPT { return 0; }
-
-		static const bool is_signed = (limits::c_min < 0);
-		static const int  digits    = limits::c_bit - ( limits::c_min < 0 ? 1 : 0 );
-		static const int  digits10  = (limits::c_bit - ( limits::c_min < 0 ? 1 : 0 )) * 301 / 1000;
+		static constexpr char min()           noexcept { return limits::c_min; }
+		static constexpr char max()           noexcept { return limits::c_max; }
+		static constexpr char lowest()        noexcept { return limits::c_min; }
+		static constexpr char epsilon()       noexcept { return 0; }
+		static constexpr char round_error()   noexcept { return 0; }
+
+		static constexpr bool is_signed = (limits::c_min < 0);
+		static constexpr int  digits    = limits::c_bit - ( limits::c_min < 0 ? 1 : 0 );
+		static constexpr int  digits10  = (limits::c_bit - ( limits::c_min < 0 ? 1 : 0 )) * 301 / 1000;
 	};
 
@@ -200,13 +200,13 @@
 	struct numeric_limits < unsigned char > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR unsigned char min()           NV_NOEXCEPT { return limits::uc_min; }
-		static NV_CONSTEXPR unsigned char max()           NV_NOEXCEPT { return limits::uc_max; }
-		static NV_CONSTEXPR unsigned char lowest()        NV_NOEXCEPT { return limits::uc_min; }
-		static NV_CONSTEXPR unsigned char epsilon()       NV_NOEXCEPT { return 0; }
-		static NV_CONSTEXPR unsigned char round_error()   NV_NOEXCEPT { return 0; }
-
-		static const bool is_signed = false;
-		static const int  digits    = limits::c_bit;
-		static const int  digits10  = limits::c_bit  * 301 / 1000;
+		static constexpr unsigned char min()           noexcept { return limits::uc_min; }
+		static constexpr unsigned char max()           noexcept { return limits::uc_max; }
+		static constexpr unsigned char lowest()        noexcept { return limits::uc_min; }
+		static constexpr unsigned char epsilon()       noexcept { return 0; }
+		static constexpr unsigned char round_error()   noexcept { return 0; }
+
+		static constexpr bool is_signed = false;
+		static constexpr int  digits    = limits::c_bit;
+		static constexpr int  digits10  = limits::c_bit  * 301 / 1000;
 	};
 
@@ -214,13 +214,13 @@
 	struct numeric_limits < signed char > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR signed char min()           NV_NOEXCEPT { return limits::sc_min; }
-		static NV_CONSTEXPR signed char max()           NV_NOEXCEPT { return limits::sc_max; }
-		static NV_CONSTEXPR signed char lowest()        NV_NOEXCEPT { return limits::sc_min; }
-		static NV_CONSTEXPR signed char epsilon()       NV_NOEXCEPT { return 0; }
-		static NV_CONSTEXPR signed char round_error()   NV_NOEXCEPT { return 0; }
-
-		static const bool is_signed = true;
-		static const int  digits    = limits::c_bit - 1;
-		static const int  digits10  = (limits::c_bit - 1) * 301 / 1000;
+		static constexpr signed char min()           noexcept { return limits::sc_min; }
+		static constexpr signed char max()           noexcept { return limits::sc_max; }
+		static constexpr signed char lowest()        noexcept { return limits::sc_min; }
+		static constexpr signed char epsilon()       noexcept { return 0; }
+		static constexpr signed char round_error()   noexcept { return 0; }
+
+		static constexpr bool is_signed = true;
+		static constexpr int  digits    = limits::c_bit - 1;
+		static constexpr int  digits10  = (limits::c_bit - 1) * 301 / 1000;
 	};
 
@@ -229,13 +229,13 @@
 	struct numeric_limits < unsigned short > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR unsigned short min()           NV_NOEXCEPT { return limits::us_min; }
-		static NV_CONSTEXPR unsigned short max()           NV_NOEXCEPT { return limits::us_max; }
-		static NV_CONSTEXPR unsigned short lowest()        NV_NOEXCEPT { return limits::us_min; }
-		static NV_CONSTEXPR unsigned short epsilon()       NV_NOEXCEPT { return 0; }
-		static NV_CONSTEXPR unsigned short round_error()   NV_NOEXCEPT { return 0; }
-
-		static const bool is_signed = false;
-		static const int  digits    = limits::us_bit;
-		static const int  digits10  = limits::us_bit * 301 / 1000;
+		static constexpr unsigned short min()           noexcept { return limits::us_min; }
+		static constexpr unsigned short max()           noexcept { return limits::us_max; }
+		static constexpr unsigned short lowest()        noexcept { return limits::us_min; }
+		static constexpr unsigned short epsilon()       noexcept { return 0; }
+		static constexpr unsigned short round_error()   noexcept { return 0; }
+
+		static constexpr bool is_signed = false;
+		static constexpr int  digits    = limits::us_bit;
+		static constexpr int  digits10  = limits::us_bit * 301 / 1000;
 	};
 
@@ -243,13 +243,13 @@
 	struct numeric_limits < signed short > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR signed short min()           NV_NOEXCEPT { return limits::ss_min; }
-		static NV_CONSTEXPR signed short max()           NV_NOEXCEPT { return limits::ss_max; }
-		static NV_CONSTEXPR signed short lowest()        NV_NOEXCEPT { return limits::ss_min; }
-		static NV_CONSTEXPR signed short epsilon()       NV_NOEXCEPT { return 0; }
-		static NV_CONSTEXPR signed short round_error()   NV_NOEXCEPT { return 0; }
-
-		static const bool is_signed = true;
-		static const int  digits    = limits::ss_bit - 1;
-		static const int  digits10  = ( limits::ss_bit - 1 ) * 301 / 1000;
+		static constexpr signed short min()           noexcept { return limits::ss_min; }
+		static constexpr signed short max()           noexcept { return limits::ss_max; }
+		static constexpr signed short lowest()        noexcept { return limits::ss_min; }
+		static constexpr signed short epsilon()       noexcept { return 0; }
+		static constexpr signed short round_error()   noexcept { return 0; }
+
+		static constexpr bool is_signed = true;
+		static constexpr int  digits    = limits::ss_bit - 1;
+		static constexpr int  digits10  = ( limits::ss_bit - 1 ) * 301 / 1000;
 	};
 
@@ -257,13 +257,13 @@
 	struct numeric_limits < unsigned int > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR unsigned int min()           NV_NOEXCEPT { return limits::ui_min; }
-		static NV_CONSTEXPR unsigned int max()           NV_NOEXCEPT { return limits::ui_max; }
-		static NV_CONSTEXPR unsigned int lowest()        NV_NOEXCEPT { return limits::ui_min; }
-		static NV_CONSTEXPR unsigned int epsilon()       NV_NOEXCEPT { return 0; }
-		static NV_CONSTEXPR unsigned int round_error()   NV_NOEXCEPT { return 0; }
-
-		static const bool is_signed = false;
-		static const int  digits    = limits::ui_bit;
-		static const int  digits10  = limits::ui_bit * 301 / 1000;
+		static constexpr unsigned int min()           noexcept { return limits::ui_min; }
+		static constexpr unsigned int max()           noexcept { return limits::ui_max; }
+		static constexpr unsigned int lowest()        noexcept { return limits::ui_min; }
+		static constexpr unsigned int epsilon()       noexcept { return 0; }
+		static constexpr unsigned int round_error()   noexcept { return 0; }
+
+		static constexpr bool is_signed = false;
+		static constexpr int  digits    = limits::ui_bit;
+		static constexpr int  digits10  = limits::ui_bit * 301 / 1000;
 	};
 
@@ -271,13 +271,13 @@
 	struct numeric_limits < signed int > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR signed int min()           NV_NOEXCEPT { return limits::si_min; }
-		static NV_CONSTEXPR signed int max()           NV_NOEXCEPT { return limits::si_max; }
-		static NV_CONSTEXPR signed int lowest()        NV_NOEXCEPT { return limits::si_min; }
-		static NV_CONSTEXPR signed int epsilon()       NV_NOEXCEPT { return 0; }
-		static NV_CONSTEXPR signed int round_error()   NV_NOEXCEPT { return 0; }
-
-		static const bool is_signed = true;
-		static const int  digits    = limits::si_bit - 1;
-		static const int  digits10  = ( limits::si_bit - 1 ) * 301 / 1000;
+		static constexpr signed int min()           noexcept { return limits::si_min; }
+		static constexpr signed int max()           noexcept { return limits::si_max; }
+		static constexpr signed int lowest()        noexcept { return limits::si_min; }
+		static constexpr signed int epsilon()       noexcept { return 0; }
+		static constexpr signed int round_error()   noexcept { return 0; }
+
+		static constexpr bool is_signed = true;
+		static constexpr int  digits    = limits::si_bit - 1;
+		static constexpr int  digits10  = ( limits::si_bit - 1 ) * 301 / 1000;
 	};
 
@@ -285,13 +285,13 @@
 	struct numeric_limits < unsigned long > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR unsigned long min()           NV_NOEXCEPT { return limits::ul_min; }
-		static NV_CONSTEXPR unsigned long max()           NV_NOEXCEPT { return limits::ul_max; }
-		static NV_CONSTEXPR unsigned long lowest()        NV_NOEXCEPT { return limits::ul_min; }
-		static NV_CONSTEXPR unsigned long epsilon()       NV_NOEXCEPT { return 0; }
-		static NV_CONSTEXPR unsigned long round_error()   NV_NOEXCEPT { return 0; }
-
-		static const bool is_signed = false;
-		static const int  digits    = limits::ul_bit;
-		static const int  digits10  = limits::ul_bit * 301 / 1000;
+		static constexpr unsigned long min()           noexcept { return limits::ul_min; }
+		static constexpr unsigned long max()           noexcept { return limits::ul_max; }
+		static constexpr unsigned long lowest()        noexcept { return limits::ul_min; }
+		static constexpr unsigned long epsilon()       noexcept { return 0; }
+		static constexpr unsigned long round_error()   noexcept { return 0; }
+
+		static constexpr bool is_signed = false;
+		static constexpr int  digits    = limits::ul_bit;
+		static constexpr int  digits10  = limits::ul_bit * 301 / 1000;
 	};
 
@@ -299,13 +299,13 @@
 	struct numeric_limits < signed long > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR signed long min()           NV_NOEXCEPT { return limits::sl_min; }
-		static NV_CONSTEXPR signed long max()           NV_NOEXCEPT { return limits::sl_max; }
-		static NV_CONSTEXPR signed long lowest()        NV_NOEXCEPT { return limits::sl_min; }
-		static NV_CONSTEXPR signed long epsilon()       NV_NOEXCEPT { return 0; }
-		static NV_CONSTEXPR signed long round_error()   NV_NOEXCEPT { return 0; }
-
-		static const bool is_signed = true;
-		static const int  digits    = limits::sl_bit - 1;
-		static const int  digits10  = ( limits::sl_bit - 1 ) * 301 / 1000;
+		static constexpr signed long min()           noexcept { return limits::sl_min; }
+		static constexpr signed long max()           noexcept { return limits::sl_max; }
+		static constexpr signed long lowest()        noexcept { return limits::sl_min; }
+		static constexpr signed long epsilon()       noexcept { return 0; }
+		static constexpr signed long round_error()   noexcept { return 0; }
+
+		static constexpr bool is_signed = true;
+		static constexpr int  digits    = limits::sl_bit - 1;
+		static constexpr int  digits10  = ( limits::sl_bit - 1 ) * 301 / 1000;
 	};
 
@@ -313,13 +313,13 @@
 	struct numeric_limits < unsigned long long > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR unsigned long long min()           NV_NOEXCEPT { return limits::ull_min; }
-		static NV_CONSTEXPR unsigned long long max()           NV_NOEXCEPT{ return limits::ull_max; }
-		static NV_CONSTEXPR unsigned long long lowest()        NV_NOEXCEPT{ return limits::ull_min; }
-		static NV_CONSTEXPR unsigned long long epsilon()       NV_NOEXCEPT{ return 0; }
-		static NV_CONSTEXPR unsigned long long round_error()   NV_NOEXCEPT{ return 0; }
-
-		static const bool is_signed = false;
-		static const int  digits    = limits::ull_bit;
-		static const int  digits10  = limits::ull_bit * 301 / 1000;
+		static constexpr unsigned long long min()           noexcept { return limits::ull_min; }
+		static constexpr unsigned long long max()           noexcept { return limits::ull_max; }
+		static constexpr unsigned long long lowest()        noexcept { return limits::ull_min; }
+		static constexpr unsigned long long epsilon()       noexcept { return 0; }
+		static constexpr unsigned long long round_error()   noexcept { return 0; }
+
+		static constexpr bool is_signed = false;
+		static constexpr int  digits    = limits::ull_bit;
+		static constexpr int  digits10  = limits::ull_bit * 301 / 1000;
 	};
 
@@ -327,13 +327,13 @@
 	struct numeric_limits < signed long long > : detail::numeric_limits_int_base
 	{
-		static NV_CONSTEXPR signed long long min()           NV_NOEXCEPT{ return limits::sll_min; }
-		static NV_CONSTEXPR signed long long max()           NV_NOEXCEPT{ return limits::sll_max; }
-		static NV_CONSTEXPR signed long long lowest()        NV_NOEXCEPT{ return limits::sll_min; }
-		static NV_CONSTEXPR signed long long epsilon()       NV_NOEXCEPT{ return 0; }
-		static NV_CONSTEXPR signed long long round_error()   NV_NOEXCEPT{ return 0; }
-
-		static const bool is_signed = true;
-		static const int  digits    = limits::sll_bit - 1;
-		static const int  digits10  = ( limits::sll_bit - 1 ) * 301 / 1000;
+		static constexpr signed long long min()           noexcept { return limits::sll_min; }
+		static constexpr signed long long max()           noexcept { return limits::sll_max; }
+		static constexpr signed long long lowest()        noexcept { return limits::sll_min; }
+		static constexpr signed long long epsilon()       noexcept { return 0; }
+		static constexpr signed long long round_error()   noexcept { return 0; }
+
+		static constexpr bool is_signed = true;
+		static constexpr int  digits    = limits::sll_bit - 1;
+		static constexpr int  digits10  = ( limits::sll_bit - 1 ) * 301 / 1000;
 	};
 
@@ -341,17 +341,17 @@
 	struct numeric_limits < float > : detail::numeric_limits_float_base
 	{
-		static NV_CONSTEXPR float min()           NV_NOEXCEPT { return 1.175494351e-38F; }
-		static NV_CONSTEXPR float max()           NV_NOEXCEPT { return 3.402823466e+38F; }
-		static NV_CONSTEXPR float lowest()        NV_NOEXCEPT { return -max(); }
-		static NV_CONSTEXPR float epsilon()       NV_NOEXCEPT { return 1.192092896e-07F; }
-		static NV_CONSTEXPR float round_error()   NV_NOEXCEPT { return 0.5F; }
-
-		static const int digits         = limits::f_mant_dig;
-		static const int digits10       = limits::f_dig;
-		static const int max_digits10   = 2 + limits::f_dig * 301 / 1000;
-		static const int max_exponent   = limits::f_max_exp;
-		static const int max_exponent10 = limits::f_max_10_exp;
-		static const int min_exponent   = limits::f_min_exp;
-		static const int min_exponent10 = limits::f_min_10_exp;
+		static constexpr float min()           noexcept { return 1.175494351e-38F; }
+		static constexpr float max()           noexcept { return 3.402823466e+38F; }
+		static constexpr float lowest()        noexcept { return -max(); }
+		static constexpr float epsilon()       noexcept { return 1.192092896e-07F; }
+		static constexpr float round_error()   noexcept { return 0.5F; }
+
+		static constexpr int digits         = limits::f_mant_dig;
+		static constexpr int digits10       = limits::f_dig;
+		static constexpr int max_digits10   = 2 + limits::f_dig * 301 / 1000;
+		static constexpr int max_exponent   = limits::f_max_exp;
+		static constexpr int max_exponent10 = limits::f_max_10_exp;
+		static constexpr int min_exponent   = limits::f_min_exp;
+		static constexpr int min_exponent10 = limits::f_min_10_exp;
 	};
 
@@ -359,17 +359,17 @@
 	struct numeric_limits < double > : detail::numeric_limits_float_base
 	{
-		static NV_CONSTEXPR double min()           NV_NOEXCEPT { return 2.2250738585072014e-308; }
-		static NV_CONSTEXPR double max()           NV_NOEXCEPT { return 1.7976931348623158e+308; }
-		static NV_CONSTEXPR double lowest()        NV_NOEXCEPT { return -max(); }
-		static NV_CONSTEXPR double epsilon()       NV_NOEXCEPT { return 2.2204460492503131e-016; }
-		static NV_CONSTEXPR double round_error()   NV_NOEXCEPT { return 0.5; }
-
-		static const int digits         = limits::d_mant_dig;
-		static const int digits10       = limits::d_dig;
-		static const int max_digits10   = 2 + limits::d_dig * 301 / 1000;
-		static const int max_exponent   = limits::d_max_exp;
-		static const int max_exponent10 = limits::d_max_10_exp;
-		static const int min_exponent   = limits::d_min_exp;
-		static const int min_exponent10 = limits::d_min_10_exp;
+		static constexpr double min()           noexcept { return 2.2250738585072014e-308; }
+		static constexpr double max()           noexcept { return 1.7976931348623158e+308; }
+		static constexpr double lowest()        noexcept { return -max(); }
+		static constexpr double epsilon()       noexcept { return 2.2204460492503131e-016; }
+		static constexpr double round_error()   noexcept { return 0.5; }
+
+		static constexpr int digits         = limits::d_mant_dig;
+		static constexpr int digits10       = limits::d_dig;
+		static constexpr int max_digits10   = 2 + limits::d_dig * 301 / 1000;
+		static constexpr int max_exponent   = limits::d_max_exp;
+		static constexpr int max_exponent10 = limits::d_max_10_exp;
+		static constexpr int min_exponent   = limits::d_min_exp;
+		static constexpr int min_exponent10 = limits::d_min_10_exp;
 	};
 
@@ -377,17 +377,17 @@
 	struct numeric_limits < long double > : detail::numeric_limits_float_base
 	{
-		static NV_CONSTEXPR long double min()           NV_NOEXCEPT { return 2.2250738585072014e-308; }
-		static NV_CONSTEXPR long double max()           NV_NOEXCEPT { return 1.7976931348623158e+308; }
-		static NV_CONSTEXPR long double lowest()        NV_NOEXCEPT { return -max(); }
-		static NV_CONSTEXPR long double epsilon()       NV_NOEXCEPT { return 2.2204460492503131e-016; }
-		static NV_CONSTEXPR long double round_error()   NV_NOEXCEPT { return 0.5; }
-
-		static const int digits         = limits::ld_mant_dig;
-		static const int digits10       = limits::ld_dig;
-		static const int max_digits10   = 2 + limits::ld_dig * 301 / 1000;
-		static const int max_exponent   = limits::ld_max_exp;
-		static const int max_exponent10 = limits::ld_max_10_exp;
-		static const int min_exponent   = limits::ld_min_exp;
-		static const int min_exponent10 = limits::ld_min_10_exp;
+		static constexpr long double min()           noexcept { return 2.2250738585072014e-308; }
+		static constexpr long double max()           noexcept { return 1.7976931348623158e+308; }
+		static constexpr long double lowest()        noexcept { return -max(); }
+		static constexpr long double epsilon()       noexcept { return 2.2204460492503131e-016; }
+		static constexpr long double round_error()   noexcept { return 0.5; }
+
+		static constexpr int digits         = limits::ld_mant_dig;
+		static constexpr int digits10       = limits::ld_dig;
+		static constexpr int max_digits10   = 2 + limits::ld_dig * 301 / 1000;
+		static constexpr int max_exponent   = limits::ld_max_exp;
+		static constexpr int max_exponent10 = limits::ld_max_10_exp;
+		static constexpr int min_exponent   = limits::ld_min_exp;
+		static constexpr int min_exponent10 = limits::ld_min_10_exp;
 	};
 
Index: /trunk/nv/stl/memory.hh
===================================================================
--- /trunk/nv/stl/memory.hh	(revision 381)
+++ /trunk/nv/stl/memory.hh	(revision 382)
@@ -25,4 +25,41 @@
 namespace nv
 {
+	namespace detail
+	{
+		template< typename T >
+		struct addressof_helper
+		{
+			T & value;
+			constexpr addressof_helper( T & v ) : value( v ) {}
+			constexpr operator T& () const { return value; }
+		private:
+			addressof_helper & operator=( const addressof_helper & );
+		};
+
+		template< typename T >
+		struct addressof_impl
+		{
+			static constexpr T * f( T & v, long )
+			{
+				return reinterpret_cast<T*>(
+					&const_cast<char&>( reinterpret_cast<const volatile char &>( v ) ) );
+			}
+			static constexpr T * f( T * v, int ) { return v; }
+		};
+	}
+
+	template< typename T >
+	T * addressof( T & v )
+	{
+		return detail::addressof_impl<T>::f( detail::addressof_helper<T>( v ), 0 );
+	}
+
+	namespace mem_flags
+	{
+		static constexpr uint16 is_const  = 0x0001;
+		static constexpr uint16 is_static = 0x0002;
+		static constexpr uint16 read_only = 0x0004;
+		static constexpr uint16 temporary = 0x0008;
+	}
 
 	template< typename T >
@@ -32,11 +69,12 @@
 		typedef T      value_type;
 		typedef size_t size_type;
-		static const bool is_static = false;
-		static const bool is_fixed  = false;
-		static const bool is_const  = false;
-
-		NV_CONSTEXPR storage_view() 
+		static constexpr bool is_static   = false;
+		static constexpr bool is_fixed    = false;
+		static constexpr bool is_const    = false;
+		static constexpr size_t type_size = sizeof( value_type );
+
+		constexpr storage_view() 
 			: m_data( nullptr ), m_size( 0 ) {}
-		NV_CONSTEXPR storage_view( value_type* a_data, size_type a_size ) 
+		constexpr storage_view( value_type* a_data, size_type a_size )
 			: m_data( a_data ), m_size( a_size ) {}
 
@@ -47,7 +85,11 @@
 		}
 
-		NV_CONSTEXPR size_t size() const { return m_size; }
-		NV_CONSTEXPR value_type* data() { return m_data; }
-		NV_CONSTEXPR const value_type* data() const { return m_data; }
+		constexpr size_t size() const { return m_size; }
+		constexpr bool empty() const { return m_size != 0; }
+		constexpr const value_type* data() const { return m_data; }
+		inline    value_type* data() { return m_data; }
+		constexpr size_type   raw_size() const { return sizeof( value_type ) * m_size; }
+		constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
+		inline    char* raw_data() { return reinterpret_cast<char*>( m_data ); }
 	protected:
 		value_type* m_data;
@@ -59,13 +101,14 @@
 	{
 	public:
-		typedef T      value_type;
-		typedef size_t size_type;
-		static const bool is_static = false;
-		static const bool is_fixed  = false;
-		static const bool is_const  = true;
-
-		NV_CONSTEXPR const_storage_view() 
+		typedef T        value_type;
+		typedef size_t   size_type;
+		static constexpr bool is_static   = false;
+		static constexpr bool is_fixed    = false;
+		static constexpr bool is_const    = true;
+		static constexpr size_t type_size = sizeof( value_type );
+
+		constexpr const_storage_view()
 			: m_data( nullptr ), m_size( 0 ) {}
-		NV_CONSTEXPR const_storage_view( const value_type* a_data, size_type a_size )
+		constexpr const_storage_view( const value_type* a_data, size_type a_size )
 			: m_data( a_data ), m_size( a_size ) {}
 
@@ -76,6 +119,9 @@
 		}
 
-		NV_CONSTEXPR size_t size() const { return m_size; }
-		NV_CONSTEXPR const value_type* data() const { return m_data; }
+		constexpr size_type size() const { return m_size; }
+		constexpr bool empty() const { return m_size != 0; }
+		constexpr const value_type* data() const { return m_data; }
+		constexpr size_type   raw_size() const { return sizeof( value_type ) * m_size; }
+		constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
 	protected:
 		const value_type* m_data;
@@ -84,45 +130,33 @@
 
 
-	template< typename T, size_t N >
-	class static_storage
-	{
-	public:
-		typedef T value_type;
-		static const bool is_static = true;
-		static const bool is_fixed  = true;
-		static const bool is_const  = false;
-
-		NV_CONSTEXPR T* data() { return static_cast<T*>( m_data ); }
-		NV_CONSTEXPR const T* data() const { return static_cast<const T*>( m_data ); }
-		static NV_CONSTEXPR size_t capacity() { return N; }
-	protected:
-		typedef aligned_array_t<T, N, NV_ALIGN_OF( T ) > storage_type;
-		storage_type m_data;
-	};
-
-	template< typename T, size_t N >
-	class fixed_dynamic_storage
-	{
-	public:
-		typedef T value_type;
-		static const bool is_static = false;
-		static const bool is_fixed = true;
-		static const bool is_const = false;
-
-		fixed_dynamic_storage()
-		{
-			m_data = nvmalloc( N * sizeof( value_type ) );
-		}
-		~fixed_dynamic_storage()
-		{
-			nvfree( m_data );
-		}
-		static NV_CONSTEXPR size_t capacity() { return N; }
-		NV_CONSTEXPR T* data() { return static_cast<T*>( m_data ); }
-		NV_CONSTEXPR const T* data() const { return static_cast<const T*>( m_data ); }
-	protected:
-		uint8* m_data;
-	};
-
+	template < typename T >
+	inline void raw_construct_object( void* object )
+	{
+		new ( object )T;
+	}
+
+	template < typename T, typename ...Args >
+	inline void raw_construct_object( void* object, Args&&... params )
+	{
+		new ( object )T( forward<Args>( params )... );
+	}
+
+	template < typename T, typename ...Args >
+	inline void construct_object( T* object, Args&&... params )
+	{
+		new ( object )T( forward<Args>( params )... );
+	}
+
+	template < typename T >
+	inline void destroy_object( T* object )
+	{
+		object->~T();
+	}
+
+	template <typename TYPE>
+	void raw_destroy_object( void* object )
+	{
+		( (TYPE*)object )->TYPE::~TYPE();
+	}
 
 	namespace detail
@@ -220,4 +254,43 @@
 		}
 
+		template < typename InputIterator, typename ForwardIterator >
+		inline ForwardIterator uninitialized_copy_impl( InputIterator first, InputIterator last, ForwardIterator out, false_type )
+		{
+			typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
+			InputIterator src( first );
+			ForwardIterator dest( out );
+			for ( ; first != last; ++src, ++dest )
+			{
+				::new ( static_cast<void*>( addressof( *dest ) ) ) value_type( *src );
+			}
+			return dest;
+		}
+
+		template < typename InputIterator, typename ForwardIterator >
+		inline ForwardIterator uninitialized_copy_impl( InputIterator first, InputIterator last, ForwardIterator out, true_type )
+		{
+			return ForwardIterator( nvmemmove( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) );
+		}
+
+		template < typename InputIterator, typename ForwardIterator >
+		inline ForwardIterator uninitialized_copy_n_impl( InputIterator first, size_t count, ForwardIterator out, false_type )
+		{
+			typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
+			InputIterator src( first );
+			ForwardIterator dest( out );
+			for ( ; count > 0; --count, ++src, ++dest )
+			{
+				::new ( static_cast<void*>( addressof( *dest ) ) ) value_type( *src );
+			}
+			return it;
+		}
+
+		template < typename InputIterator, typename ForwardIterator >
+		inline ForwardIterator uninitialized_copy_n_impl( InputIterator first, size_t count, ForwardIterator out, true_type )
+		{
+			typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
+			return ForwardIterator( nvmemmove( out, first, count * sizeof( value_type ) ) );
+		}
+
 	}
 
@@ -235,35 +308,4 @@
 		return detail::uninitialized_fill_n_impl( first, count, value, has_trivial_assign<value_type>() );
 	}
-
-	template < typename T >
-	inline void raw_construct_object( void* object )
-	{
-		new (object)T;
-	}
-
-	template < typename T, typename ...Args >
-	inline void raw_construct_object( void* object, Args&&... params )
-	{
-		new (object)T( forward<Args>( params )... );
-	}
-
-	template < typename T, typename ...Args >
-	inline void construct_object( T* object, Args&&... params )
-	{
-		new (object)T( forward<Args>( params )... );
-	}
-
-	template < typename T >
-	inline void destroy_object( T* object )
-	{
-		object->~T();
-	}
-
-	template <typename TYPE>
-	void raw_destroy_object( void* object )
-	{
-		( (TYPE*)object )->TYPE::~TYPE();
-	}
-
 
 	template < typename ForwardIterator, typename ...Args >
@@ -304,33 +346,50 @@
 	}
 
+	template < typename InputIterator, typename ForwardIterator >
+	inline ForwardIterator uninitialized_copy( InputIterator first, InputIterator last, ForwardIterator out )
+	{
+		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+		return detail::uninitialized_copy_impl( first, last, out, has_trivial_copy<value_type>() );
+	}
+
+	template < typename InputIterator, typename ForwardIterator >
+	inline ForwardIterator uninitialized_copy_n( InputIterator first, size_t count, ForwardIterator out )
+	{
+		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+		return detail::uninitialized_copy_n_impl( first, count, out, has_trivial_copy<value_type>() );
+	}
+
 	namespace detail
 	{
-		template < typename PARENT, typename Storage, bool Const = Storage::is_const >
-		class pointer_iterators {};
-
-		template < typename PARENT, typename Storage >
-		class pointer_iterators< PARENT, Storage, true >
+
+		template < typename Super, bool Const = Super::is_const >
+		class add_iterators {};
+
+		template < typename Super >
+		class add_iterators < Super, true > : public Super
 		{
 		public:
-			typedef typename Storage::value_type         value_type;
+			typedef typename Super::value_type           value_type;
 			typedef const value_type*                    const_iterator;
 			typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
 
-			inline const_iterator begin() const { return const_iterator( static_cast<const PARENT&>( *this ).data() ); }
-			inline const_iterator end() const { return const_iterator( static_cast<const PARENT&>( *this ).data() + static_cast<const PARENT&>( *this ).size() ); }
-			inline const_iterator cbegin() const { return const_iterator( static_cast<const PARENT&>( *this ).data() ); }
-			inline const_iterator cend() const { return const_iterator( static_cast<const PARENT&>( *this ).data() + static_cast<const PARENT&>( *this ).size() ); }
+			using Super::Super;
+
+			inline const_iterator begin() const { return const_iterator( Super::data() ); }
+			inline const_iterator end() const { return const_iterator( Super::data() + Super::size() ); }
+			inline const_iterator cbegin() const { return const_iterator( Super::data() ); }
+			inline const_iterator cend() const { return const_iterator( Super::data() + Super::size() ); }
 			inline const_reverse_iterator rbegin() const { return const_reverse_iterator( end() ); }
 			inline const_reverse_iterator crbegin() const { return const_reverse_iterator( end() ); }
 			inline const_reverse_iterator rend() const { return const_reverse_iterator( begin() ); }
 			inline const_reverse_iterator crend() const { return const_reverse_iterator( begin() ); }
-			inline const_iterator iat( size_t i ) const { NV_ASSERT( i <= static_cast<const PARENT&>( *this ).size(), "Index out of range" ); return begin() + i; }
+			inline const_iterator iat( size_t i ) const { NV_ASSERT( i <= Super::size(), "Index out of range" ); return begin() + i; }
 		};
 
-		template < typename PARENT, typename Storage >
-		class pointer_iterators< PARENT, Storage, false >
+		template < typename Super >
+		class add_iterators < Super, false > : public Super
 		{
 		public:
-			typedef typename Storage::value_type         value_type;
+			typedef typename Super::value_type           value_type;
 			typedef value_type*                          iterator;
 			typedef const value_type*                    const_iterator;
@@ -338,10 +397,12 @@
 			typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
 
-			inline const_iterator begin() const { return const_iterator( static_cast<const PARENT&>( *this ).data() ); }
-			inline const_iterator end() const { return const_iterator( static_cast<const PARENT&>( *this ).data() + static_cast<const PARENT&>( *this ).size() ); }
-			inline iterator begin() { return iterator( static_cast<PARENT&>( *this ).data() ); }
-			inline iterator end() { return iterator( static_cast<PARENT&>( *this ).data() + static_cast<const PARENT&>( *this ).size() ); }
-			inline const_iterator cbegin() const { return const_iterator( static_cast<const PARENT&>( *this ).data() ); }
-			inline const_iterator cend() const { return const_iterator( static_cast<const PARENT&>( *this ).data() + static_cast<const PARENT&>( *this ).size() ); }
+			using Super::Super;
+
+			inline const_iterator begin() const { return const_iterator( Super::data() ); }
+			inline const_iterator end() const { return const_iterator( Super::data() + Super::size() ); }
+			inline iterator begin() { return iterator( Super::data() ); }
+			inline iterator end() { return iterator( Super::data() + Super::size() ); }
+			inline const_iterator cbegin() const { return const_iterator( Super::data() ); }
+			inline const_iterator cend() const { return const_iterator( Super::data() + Super::size() ); }
 			inline reverse_iterator rbegin() { return reverse_iterator( end() ); }
 			inline const_reverse_iterator rbegin() const { return const_reverse_iterator( end() ); }
@@ -350,84 +411,71 @@
 			inline const_reverse_iterator rend() const { return const_reverse_iterator( begin() ); }
 			inline const_reverse_iterator crend() const { return const_reverse_iterator( begin() ); }
-			inline const_iterator iat( size_t i ) const { NV_ASSERT( i <= static_cast<const PARENT&>( *this ).size(), "Index out of range" ); return begin() + i; }
-			inline iterator       iat( size_t i ) { NV_ASSERT( i <= static_cast<const PARENT&>( *this ).size(), "Index out of range" ); return begin() + i; }
+			inline const_iterator iat( size_t i ) const { NV_ASSERT( i <= Super::size(), "Index out of range" ); return begin() + i; }
+			inline iterator       iat( size_t i ) { NV_ASSERT( i <= Super::size(), "Index out of range" ); return begin() + i; }
 		};
 
-		template < typename Storage, bool Const = Storage::is_const >
-		class data_base;
-
-
-		template < typename Storage >
-		class data_base < Storage, true >
-			: public pointer_iterators < data_base < Storage, true >, Storage >
+		template < typename Super, bool Const = Super::is_const >
+		class add_random_access {};
+
+		template < typename Super >
+		class add_random_access < Super, true > : public Super
 		{
 		public:
-			typedef typename Storage::value_type value_type;
-			typedef const value_type*            const_pointer;
-			typedef size_t	                     size_type;
-			typedef const_pointer                const_iterator;
-			typedef const value_type&            const_reference;
-
-			inline data_base() {}
-			inline data_base( const_pointer a_data, size_t a_size )
-				: m_view( a_data, a_size ) {}
-			inline const_pointer data() const { return m_view.data(); }
-			inline size_t size() const { return m_view.size(); }
-			inline bool empty() const { return size() != 0; }
-			inline size_type   raw_size() const { return sizeof( value_type ) * size(); }
-			inline const char* raw_data() const { return (const char*)data(); }
-
-			inline const_reference front() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return data()[0]; }
-			inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return data()[size() - 1]; }
-		protected:
-			void assign( const_pointer a_data, size_type a_size )
-			{
-				m_view.assign( a_data, a_size );
-			}
-
-			Storage m_view;
+			typedef typename Super::value_type           value_type;
+			typedef typename Super::size_type            size_type;
+			typedef const value_type*                    const_iterator;
+			typedef value_type&                          reference;
+			typedef const value_type&                    const_reference;
+
+			inline const_reference front() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[0]; }
+			inline const_reference back() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[Super::size() - 1]; }
+
+			const_reference operator[]( size_type i ) const
+			{
+				NV_ASSERT( i < Super::size(), "Out of range" );
+				return Super::data()[i];
+			}
 		};
 
-		template < typename Storage >
-		class data_base < Storage, false >
-			: public pointer_iterators < data_base < Storage, false >, Storage >
+		template < typename Super >
+		class add_random_access < Super, false > : public Super
 		{
 		public:
-			typedef typename Storage::value_type value_type;
-			typedef value_type*                  pointer;
-			typedef const value_type*            const_pointer;
-			typedef size_t	                     size_type;
-			typedef pointer                      iterator;
-			typedef const_pointer                const_iterator;
-			typedef value_type&		             reference;
-			typedef const value_type&            const_reference;
-
-			inline data_base() {}
-			inline data_base( pointer a_data, size_t a_size ) : m_view( a_data, a_size ) {}
-			inline const_pointer data() const { return m_view.data(); }
-			inline pointer data() { return m_view.data(); }
-			inline size_t size() const { return m_view.size(); }
-			inline bool empty() const { return size() != 0; }
-			inline size_type   raw_size() const { return sizeof( value_type ) * size(); }
-			inline const char* raw_data() const { return (const char*)data(); }
-			inline char*       raw_data() { return (char*)data(); }
-
-			inline reference       front() { NV_ASSERT( !empty(), "front() called on empty data!" );  return data()[0]; }
-			inline const_reference front() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return data()[0]; }
-			inline reference       back() { NV_ASSERT( !empty(), "front() called on empty data!" ); return data()[size() - 1]; }
-			inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return data()[size() - 1]; }
-		protected:
-			void assign( pointer a_data, size_type a_size )
-			{
-				m_view.assign( a_data, a_size );
-			}
-
-			Storage m_view;
+			typedef typename Super::value_type           value_type;
+			typedef typename Super::size_type            size_type;
+			typedef value_type*                          iterator;
+			typedef const value_type*                    const_iterator;
+			typedef value_type&                          reference;
+			typedef const value_type&                    const_reference;
+
+			inline reference       front() { NV_ASSERT( !Super::empty(), "front() called on empty data!" );  return Super::data()[0]; }
+			inline const_reference front() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[0]; }
+			inline reference       back() { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[Super::size() - 1]; }
+			inline const_reference back() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[Super::size() - 1]; }
+
+			reference operator[]( size_type i )
+			{
+				NV_ASSERT( i < Super::size(), "Out of range" );
+				return Super::data()[i];
+			}
+
+			const_reference operator[]( size_type i ) const
+			{
+				NV_ASSERT( i < Super::size(), "Out of range" );
+				return Super::data()[i];
+			}
+
+			inline void fill( const value_type& value )
+			{
+				fill_n( iterator( Super::data() ), iterator( Super::data() + this->size() ), value );
+			}
+
 		};
 
 	}
 
-	class const_mem_ref : public detail::data_base< const_storage_view< char > >
-	{
+	class const_mem_ref : public detail::add_iterators< const_storage_view< char > >
+	{
+		typedef detail::add_iterators< const_storage_view< char > > inherited;
 	public:
 		typedef char                 value_type;
@@ -440,11 +488,12 @@
 		typedef const_pointer        const_iterator;
 	public:
-		inline const_mem_ref() : detail::data_base< const_storage_view< char > >() {}
-		inline const_mem_ref( const void* p, size_type n ) : detail::data_base< const_storage_view< char > >( (const char*)p, n ) {}
-		inline const_mem_ref( const const_mem_ref& l ) : detail::data_base< const_storage_view< char > >( l.data(), l.size() ) {}
-	};
-
-	class mem_ref : public detail::data_base< storage_view< char > >
-	{
+		inline const_mem_ref() : inherited() {}
+		inline const_mem_ref( const void* p, size_type n ) : inherited( (const char*)p, n ) {}
+		inline const_mem_ref( const const_mem_ref& l ) : inherited( l.data(), l.size() ) {}
+	};
+
+	class mem_ref : public detail::add_iterators< storage_view< char > >
+	{
+		typedef detail::add_iterators< storage_view< char > > inherited;
 	public:
 		typedef char                 value_type;
@@ -458,7 +507,17 @@
 		typedef const_pointer        const_iterator;
 	public:
-		inline mem_ref() : detail::data_base< storage_view< char > >() {}
-		inline mem_ref( void* p, size_type n ) : detail::data_base< storage_view< char > >( (char*)p, n ) {}
-		inline mem_ref( const mem_ref& l ) : detail::data_base< storage_view< char > >( const_cast< char* >( l.data() ), l.size() ) {}
+		inline mem_ref() : inherited() {}
+		inline mem_ref( void* p, size_type n ) : inherited( (char*)p, n ) {}
+		inline mem_ref( const mem_ref& l ) : inherited( const_cast< char* >( l.data() ), l.size() ) {}
+	};
+
+	template< typename SizeType >
+	struct default_next_capacity
+	{
+		static SizeType get( SizeType requested, SizeType capacity )
+		{
+			SizeType additional = nv::max( requested, capacity );
+			return capacity + additional;
+		}
 	};
 
@@ -468,5 +527,16 @@
 		static void initialize( ForwardIterator first, ForwardIterator last )
 		{
-			uninitialized_construct( first, last );
+			typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+			uninitialized_construct( first, last, value_type() );
+		}
+		template < typename InputIterator, typename ForwardIterator >
+		static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
+		{
+			return uninitialized_copy( first, last, out );
+		}
+		template < typename ForwardIterator >
+		static void destroy( ForwardIterator first, ForwardIterator last )
+		{
+			uninitialized_destroy( first, last );
 		}
 	};
@@ -476,4 +546,13 @@
 		template < typename ForwardIterator >
 		static void initialize( ForwardIterator, ForwardIterator )
+		{
+		}
+		template < typename InputIterator, typename ForwardIterator >
+		static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
+		{
+			return detail::uninitialized_copy( first, last, out, true_type );
+		}
+		template < typename ForwardIterator >
+		static void destroy( ForwardIterator, ForwardIterator )
 		{
 		}
@@ -489,6 +568,137 @@
 				detail::uninitialized_construct_impl( first, last, false_type() );
 		}
-	};
-
+		template < typename InputIterator, typename ForwardIterator >
+		static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
+		{
+			return uninitialized_copy( first, last, out );
+		}
+		template < typename ForwardIterator >
+		static void destroy( ForwardIterator first, ForwardIterator last )
+		{
+			typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+			if ( !has_trivial_destructor<value_type>() )
+				detail::uninitialized_destroy_impl( first, last, false_type() );
+		}
+	};
+
+	template< typename T >
+	class dynamic_storage
+	{
+	public:
+		typedef T      value_type;
+
+		static constexpr bool is_static   = false;
+		static constexpr bool is_const    = false;
+		static constexpr size_t type_size = sizeof( value_type );
+
+		constexpr dynamic_storage() : m_data( nullptr ) {}
+
+		constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); }
+		inline    value_type* data() { return reinterpret_cast<T*>( m_data ); }
+		constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
+		inline    char* raw_data() { return reinterpret_cast<char*>( m_data ); }
+	protected:
+		bool reallocate( size_t new_size )
+		{
+			if ( m_data != 0 || new_size != 0 )
+				m_data = (uint8*)nvrealloc( m_data, new_size * sizeof( value_type ) );
+			return true; // TODO : alloc check?
+		}
+	protected:
+		uint8* m_data;
+	};
+
+	template< typename T, size_t N >
+	class static_storage
+	{
+	public:
+		typedef T      value_type;
+
+		static constexpr bool is_static   = true;
+		static constexpr bool is_const    = false;
+		static constexpr size_t type_size = sizeof( value_type );
+
+		constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); }
+		inline    value_type* data() { return reinterpret_cast<T*>( m_data ); }
+		constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
+		inline    char* raw_data() { return reinterpret_cast<char*>( m_data ); }
+	protected:
+		static constexpr bool reallocate( size_t new_size ) { return new_size <= N; }
+	protected:
+		typedef aligned_array_t<T, N, alignof( T ) > storage_type;
+		storage_type m_data;
+	};
+
+	template< typename Storage, size_t N >
+	class fixed_storage : public Storage
+	{
+	public:
+		typedef size_t size_type;
+
+		static constexpr bool is_fixed = true;
+
+		fixed_storage()
+		{
+			Storage::reallocate( N );
+		}
+		~fixed_storage()
+		{
+			Storage::reallocate( 0 );
+		}
+		static constexpr size_t capacity() { return N; }
+		static constexpr size_t size() { return N; }
+		static constexpr bool empty() { return N != 0; }
+		static constexpr size_t raw_size() { return sizeof( T ) * N; }
+	};
+
+	template< typename Storage >
+	class resizable_storage : public Storage
+	{
+	public:
+		typedef size_t size_type;
+
+		static constexpr bool is_fixed = false;
+
+		~resizable_storage()
+		{
+			if ( m_size > 0 ) reallocate( 0 );
+		}
+		constexpr size_t capacity() { return m_size; }
+		constexpr size_t size() const { return m_size; }
+		constexpr bool empty() const { return m_size != 0; }
+		constexpr size_t raw_size() const { return sizeof( value_type ) * m_size; }
+	protected:
+		constexpr resizable_storage() : m_size( 0 ) {}
+		// TODO: return type error checking
+		bool resize( size_t new_size )
+		{
+			if ( new_size != m_size )
+			{
+				m_size = new_size;
+				return reallocate( m_size );
+			}
+			return true;
+		}
+	protected:
+		size_type m_size;
+	};
+
+
+	template< typename T, size_t N >
+	using fixed_static_storage  = fixed_storage< static_storage< T, N >, N >;
+
+	template< typename T, size_t N >
+	using fixed_dynamic_storage = fixed_storage< dynamic_storage< T >, N >;
+
+	template< typename T >
+	using resizable_dynamic_storage = resizable_storage< dynamic_storage< T > >;
+
+// TODO:
+//	template< typename T, size_t N >
+//	using resizable_static_storage  = resizable_storage< static_storage< T, N > >;
+
+// TODO:
+//	template< typename Storage, typename NextCapacity = default_next_capacity >
+//	class growable_storage : Storage;
 
 	template <
@@ -496,58 +706,80 @@
 		typename InitializePolicy = policy_initialize_standard
 	>
-	class fixed_container_storage
-	{
-	public:
-		typedef typename Storage::value_type   value_type;
-
-		static const bool   is_static  = Storage::is_static;
-		static const bool   is_fixed   = Storage::is_fixed;
-		static const bool   is_const   = Storage::is_const;
-		static const size_t type_size  = sizeof( value_type );
-
-		fixed_container_storage()
-		{
-			InitializePolicy::initialize( data(), data() + m_data.capacity() );
-		}
-
-		~fixed_container_storage()
-		{
-			uninitialized_destroy( data(), data() + m_data.capacity() );
-		}
-
-		static NV_CONSTEXPR size_t capacity() { return Storage::capacity(); }
-		static NV_CONSTEXPR size_t size() { return Storage::capacity(); }
-		NV_CONSTEXPR value_type* data() { return m_data.data(); }
-		NV_CONSTEXPR const value_type* data() const { return m_data.data(); }
-	protected:
-		Storage m_data;
-	};
-
-	template < typename T >
-	class dynamic_container_allocator
-	{
-	public:
-		static const bool   is_static = false;
-		static const bool   is_fixed  = true;
-		static const size_t type_size = sizeof( T );
-
-		dynamic_container_allocator()
-			: m_data(nullptr), m_size(0)
-		{
-		
-		}
-
-		static NV_CONSTEXPR size_t capacity() { return 0x80000000; }
-		size_t size() const { return m_size; }
-		T* data() { return static_cast<T*>( m_data ); }
-		const T* data() const { return static_cast<const T*>( m_data ); }
-
-		~dynamic_container_allocator()
-		{
-			delete m_data;
-		}
-
-		uint8* m_data;
-		size_t m_size;
+	class fixed_container_allocator : public Storage
+	{
+	public:
+		typedef typename Storage::value_type value_type;
+		typedef typename Storage::size_type  size_type;
+
+		fixed_container_allocator()
+		{
+			InitializePolicy::initialize( data(), data() + Storage::capacity() );
+		}
+
+		~fixed_container_allocator()
+		{
+			InitializePolicy::destroy( data(), data() + Storage::capacity() );
+		}
+	};
+
+	template <
+		typename Storage,
+		typename InitializePolicy = policy_initialize_standard
+	>
+	class sized_container_allocator : public Storage
+	{
+	public:
+		typedef typename Storage::value_type value_type;
+		typedef typename Storage::size_type  size_type;
+
+		sized_container_allocator() {}
+		explicit sized_container_allocator( size_type new_size ) { resize( new_size ); }
+
+		void resize( size_type new_size )
+		{
+			size_type old_size = Storage::size();
+			if ( new_size != old_size )
+			{
+				if ( new_size < old_size )
+				{
+					InitializePolicy::destroy( Storage::data() + new_size, Storage::data() + old_size );
+				}
+				Storage::resize( new_size );
+				if ( new_size > old_size )
+				{
+					InitializePolicy::initialize( Storage::data() + old_size, Storage::data() + new_size );
+				}
+			}
+		}
+
+		void assign( const value_type* ptr, size_type sz )
+		{
+			if ( Storage::size() > 0 ) InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() );
+			if ( ptr != nullptr && sz > 0 )
+			{
+				if ( sz != Storage::size() )
+				{
+					Storage::resize( 0 );
+					Storage::resize( sz );
+				}
+				InitializePolicy::copy( ptr, ptr + sz, Storage::data() );
+			}
+			else Storage::resize( 0 );
+		}
+
+		void clear()
+		{
+			if ( Storage::size() > 0 )
+			{
+				InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() );
+				Storage::resize( 0 );
+			}
+		}
+
+		~sized_container_allocator()
+		{
+			if ( Storage::size() > 0 ) clear();
+		}
+
 	};
 
Index: /trunk/nv/stl/rtti_support.hh
===================================================================
--- /trunk/nv/stl/rtti_support.hh	(revision 381)
+++ /trunk/nv/stl/rtti_support.hh	(revision 382)
@@ -22,5 +22,6 @@
 	static const char* name() { return #T; } \
 	static nv::uint64 hash() { \
-		static const nv::uint64 value = nv::rtti_hash(#T); \
+NV_MSVC_SUPRESS( 4307 )\
+		static const nv::uint64 value = nv::rtti_const_hash(#T); \
 		return value; \
 	} \
@@ -32,5 +33,6 @@
 	static const char* name() { return NAME; } \
 	static nv::uint64 hash() { \
-		static const nv::uint64 value = nv::rtti_hash(#T); \
+NV_MSVC_SUPRESS( 4307 )\
+		static const nv::uint64 value = nv::rtti_const_hash(#T); \
 		return value; \
 				} \
@@ -42,22 +44,20 @@
 	namespace detail
 	{
-//		static NV_CONSTEXPR unsigned long long rtti_hash_basis = 14695981039346656037ULL;
-//		static NV_CONSTEXPR unsigned long long rtti_hash_prime = 1099511628211ULL;
-		static unsigned long long rtti_hash_basis = 14695981039346656037ULL;
-		static unsigned long long rtti_hash_prime = 1099511628211ULL;
+		static constexpr unsigned long long rtti_hash_basis = 14695981039346656037ULL;
+		static constexpr unsigned long long rtti_hash_prime = 1099511628211ULL;
 
-// 		constexpr uint64 rtti_hash_impl( char c, const char* remain, uint64 value )
-// 		{
-// 			return c == 0 ? value : rtti_hash_impl( remain[0], remain + 1, ( value ^ (uint64)c ) * rtti_hash_prime );
-// 		}
+ 		constexpr uint64 rtti_hash_impl( char c, const char* remain, uint64 value )
+ 		{
+ 			return c == 0 ? value : rtti_hash_impl( remain[0], remain + 1, (uint64)(uint64)( value ^ (uint64)c ) * rtti_hash_prime );
+ 		}
 
 		template < typename T >	struct rtti_type_fail { static const bool value = false; };
 	}
 
-// 	// compile-time hash
-// 	constexpr uint64 rtti_const_hash( const char* str )
-// 	{
-// 		return detail::hash_impl( str[0], str + 1, detail::hash_basis );
-// 	}
+ 	// compile-time hash
+ 	constexpr uint64 rtti_const_hash( const char* str )
+ 	{
+ 		return detail::rtti_hash_impl( str[0], str + 1, detail::rtti_hash_basis );
+ 	}
 
 	// run-time hash
Index: /trunk/nv/stl/string.hh
===================================================================
--- /trunk/nv/stl/string.hh	(revision 381)
+++ /trunk/nv/stl/string.hh	(revision 382)
@@ -59,6 +59,7 @@
 
 	// string base class - will become a base for a string class later
-	class string_base : public detail::data_base< const_storage_view< char > >
-	{
+	class string_base : public detail::add_iterators< const_storage_view< char > >
+	{
+		typedef detail::add_iterators< const_storage_view< char > > inherited;
 	public:
 		typedef char           value_type;
@@ -71,5 +72,5 @@
 		typedef ptrdiff_t      difference_type;
 
-		static NV_CONSTEXPR_CONST size_type npos = size_type( -1 );
+		static constexpr size_type npos = size_type( -1 );
 
 		// conversion to std::string
@@ -79,8 +80,8 @@
  		}
 
-		inline NV_CONSTEXPR size_type length()   const { return size(); }
+		inline size_type length()   const { return size(); }
 
 		// access
-		inline NV_CONSTEXPR char operator[]( size_type i ) const { return data()[i]; }
+		inline char operator[]( size_type i ) const { return data()[i]; }
 		inline char at( size_type i ) const
 		{
@@ -89,6 +90,6 @@
 		}
 
-		inline NV_CONSTEXPR char front()        const { return data()[0]; }
-		inline NV_CONSTEXPR char back()         const { return data()[size() - 1]; }
+		inline char front()        const { return data()[0]; }
+		inline char back()         const { return data()[size() - 1]; }
 
 		// string operations
@@ -194,12 +195,11 @@
 		// Literal constructors
 		template< size_t N >
-		inline string_base( char( &s )[N] ) : detail::data_base< const_storage_view< char > >( s, N - 1 ) {}
+		inline string_base( char( &s )[N] ) : inherited( s, N - 1 ) {}
 		template< size_t N >
-		inline string_base( const char( &s )[N] ) : detail::data_base< const_storage_view< char > >( s, N - 1 ) {}
+		inline string_base( const char( &s )[N] ) : inherited( s, N - 1 ) {}
 
 	protected:
-		inline NV_CONSTEXPR string_base() : detail::data_base< const_storage_view< char > >() {}
-		inline NV_CONSTEXPR string_base( pointer a_data, size_type a_lenght )
-			: detail::data_base< const_storage_view< char > >( a_data, a_lenght ) {}
+		inline string_base() {}
+		inline string_base( pointer a_data, size_type a_lenght ) : inherited( a_data, a_lenght ) {}
 
 		template < typename ReverseIterator >
@@ -213,10 +213,10 @@
 	{
 	public:
-		inline NV_CONSTEXPR string_ref() {}
-		inline NV_CONSTEXPR string_ref( const string_ref& rhs )
+		inline string_ref() {}
+		inline string_ref( const string_ref& rhs )
 			: string_base( rhs.data(), rhs.size() )
 		{
 		}
-		inline NV_CONSTEXPR string_ref( const string_base& rhs )
+		inline string_ref( const string_base& rhs )
 			: string_base( rhs.data(), rhs.size() )
 		{
@@ -228,5 +228,5 @@
 		}
 
-		inline NV_CONSTEXPR string_ref( const char* str, size_type len )
+		inline string_ref( const char* str, size_type len )
 			: string_base( str, len )
 		{
@@ -277,10 +277,10 @@
 	{
 	public:
-		NV_CONSTEXPR const_string() {}
-		const_string( const char* str, size_type len )
+		inline const_string() {}
+		inline const_string( const char* str, size_type len )
 		{
 			initialize( str, len );
 		}
-		explicit const_string( const char* str )
+		inline explicit const_string( const char* str )
 		{
 			initialize( str, nvstrlen( str ) );
Index: /trunk/nv/stl/traits/alignment.hh
===================================================================
--- /trunk/nv/stl/traits/alignment.hh	(revision 381)
+++ /trunk/nv/stl/traits/alignment.hh	(revision 382)
@@ -86,5 +86,5 @@
 	using aligned_array_t = typename aligned_array< T, Size, Align >::type;
 
-	template< size_t Size, size_t Align = NV_ALIGN_OF( max_align_t ) >
+	template< size_t Size, size_t Align = alignof( max_align_t ) >
 	struct aligned_storage
 	{
@@ -95,5 +95,5 @@
 	};
 
-	template< size_t Size, size_t Align = NV_ALIGN_OF( max_align_t ) >
+	template< size_t Size, size_t Align = alignof( max_align_t ) >
 	using aligned_storage_t = typename aligned_storage<Size, Align>::type;
 
@@ -106,5 +106,5 @@
 		struct size_max < >
 		{
-			static const size_t value = 0;
+			static constexpr size_t value = 0;
 		};
 
@@ -112,5 +112,5 @@
 		struct size_max < Size >
 		{
-			static const size_t value = Size;
+			static constexpr size_t value = Size;
 		};
 
@@ -122,6 +122,6 @@
 	struct aligned_union
 	{
-		static const size_t max_length = detail::size_max < Size, sizeof( Types )... >::value;
-		static const size_t alignment_value = detail::size_max < alignment_of< Types >::value... >::value;
+		static constexpr size_t max_length = detail::size_max < Size, sizeof( Types )... >::value;
+		static constexpr size_t alignment_value = detail::size_max < alignment_of< Types >::value... >::value;
 		struct type
 		{
Index: /trunk/nv/stl/traits/common.hh
===================================================================
--- /trunk/nv/stl/traits/common.hh	(revision 381)
+++ /trunk/nv/stl/traits/common.hh	(revision 382)
@@ -21,9 +21,9 @@
 	struct integral_constant
 	{
-		static const T value = VALUE;
+		static constexpr T value = VALUE;
 		typedef T value_type;
 		typedef integral_constant<T, VALUE> type;
-		NV_CONSTEXPR operator value_type() const NV_NOEXCEPT{ return ( value ); }
-		NV_CONSTEXPR value_type operator()() const NV_NOEXCEPT{ return value; }
+		constexpr operator value_type() const noexcept { return value; }
+		constexpr value_type operator()() const noexcept { return value; }
 	};
 
@@ -169,5 +169,5 @@
 
 	template< typename T >
-	inline typename remove_reference<T>::type&& move( T&& arg ) NV_NOEXCEPT
+	constexpr typename remove_reference<T>::type&& move( T&& arg ) noexcept
 	{
 		return ( ( typename remove_reference<T>::type&& )arg );
@@ -175,11 +175,11 @@
 
 	template < typename T >
-	inline T&& forward( typename remove_reference<T>::type& t )
+	constexpr T&& forward( typename remove_reference<T>::type& t )
 	{
 		return static_cast<T&&>( t );
 	}
 
-		template < typename T >
-	inline T&& forward( typename remove_reference<T>::type&& t ) NV_NOEXCEPT
+	template < typename T >
+	constexpr T&& forward( typename remove_reference<T>::type&& t ) noexcept
 	{
 		static_assert( !is_lvalue_reference<T>::value, "Can not forward an rvalue as an lvalue." );
Index: /trunk/nv/stl/traits/function.hh
===================================================================
--- /trunk/nv/stl/traits/function.hh	(revision 381)
+++ /trunk/nv/stl/traits/function.hh	(revision 382)
@@ -35,5 +35,5 @@
 			typedef R        return_type;
 			typedef void     class_type;
-			static const int arg_count = 0;
+			static constexpr int arg_count = 0;
 		};
 
@@ -44,5 +44,5 @@
 			typedef R        return_type;
 			typedef void     class_type;
-			static const int arg_count = sizeof...( Args );
+			static constexpr int arg_count = sizeof...( Args );
 		};
 
@@ -53,5 +53,5 @@
 			typedef R       return_type;
 			typedef C       class_type;
-			static const int arg_count = 0;
+			static constexpr int arg_count = 0;
 		};
 
@@ -62,5 +62,5 @@
 			typedef R        return_type;
 			typedef C        class_type;
-			static const int arg_count = sizeof...( Args );
+			static constexpr int arg_count = sizeof...( Args );
 		};
 
Index: /trunk/nv/stl/traits/properties.hh
===================================================================
--- /trunk/nv/stl/traits/properties.hh	(revision 381)
+++ /trunk/nv/stl/traits/properties.hh	(revision 382)
@@ -260,5 +260,5 @@
 
 	template< typename T >
-	struct alignment_of	: integral_constant < size_t, NV_ALIGN_OF( typename remove_reference< T >::type ) > {};
+	struct alignment_of	: integral_constant < size_t, alignof( typename remove_reference< T >::type ) > {};
 
 	template < typename T >
Index: /trunk/nv/stl/traits/transforms.hh
===================================================================
--- /trunk/nv/stl/traits/transforms.hh	(revision 381)
+++ /trunk/nv/stl/traits/transforms.hh	(revision 382)
@@ -88,7 +88,7 @@
 		{
 		private:
-			static const bool size1test = sizeof( T ) <= sizeof( signed char );
-			static const bool size2test = sizeof( T ) <= sizeof( signed short );
-			static const bool size4test = sizeof( T ) <= sizeof( signed int );
+			static constexpr bool size1test = sizeof( T ) <= sizeof( signed char );
+			static constexpr bool size2test = sizeof( T ) <= sizeof( signed short );
+			static constexpr bool size4test = sizeof( T ) <= sizeof( signed int );
 			typedef conditional_t<size4test, signed int, signed long> test4type;
 			typedef conditional_t<size2test, signed short, test4type> test2type;
@@ -113,7 +113,7 @@
 		{
 		private:
-			static const bool size1test = sizeof( T ) <= sizeof( unsigned char );
-			static const bool size2test = sizeof( T ) <= sizeof( unsigned short );
-			static const bool size4test = sizeof( T ) <= sizeof( unsigned int );
+			static constexpr bool size1test = sizeof( T ) <= sizeof( unsigned char );
+			static constexpr bool size2test = sizeof( T ) <= sizeof( unsigned short );
+			static constexpr bool size4test = sizeof( T ) <= sizeof( unsigned int );
 			typedef conditional_t<size4test, unsigned int, unsigned long> test4type;
 			typedef conditional_t<size2test, unsigned short, test4type> test2type;
Index: /trunk/nv/stl/utility.hh
===================================================================
--- /trunk/nv/stl/utility.hh	(revision 381)
+++ /trunk/nv/stl/utility.hh	(revision 382)
@@ -20,7 +20,7 @@
 {
 
-	// TODO: change to swap once you get rid of STL
-	template< typename T >
-	void swap( T& x, T& y )
+	// TODO: change to swap<T> once you get rid of STL
+	template< typename T, typename U >
+	void swap( T& x, U& y )
 	{
 		T t = move( x );
Index: /trunk/src/engine/particle_engine.cc
===================================================================
--- /trunk/src/engine/particle_engine.cc	(revision 381)
+++ /trunk/src/engine/particle_engine.cc	(revision 382)
@@ -368,5 +368,5 @@
 				{
 					edata.emmiter_func = nv_particle_emmiter_point;
-					NV_LOG_WARNING( "Unknown emmiter type in particle system! (", sub_type, ")" );
+					NV_LOG_WARNING( "Unknown emmiter type in particle system! (", sub_type.c_str(), ")" );
 				}
 
Index: /trunk/src/engine/program_manager.cc
===================================================================
--- /trunk/src/engine/program_manager.cc	(revision 381)
+++ /trunk/src/engine/program_manager.cc	(revision 382)
@@ -37,5 +37,5 @@
 	}
 
-	nv::program program = m_context->get_device()->create_program( vsource, fsource );
+	nv::program program = m_context->get_device()->create_program( string_ref( vsource ), string_ref( fsource ) );
 	return add( program );
 }
Index: /trunk/src/engine/resource_system.cc
===================================================================
--- /trunk/src/engine/resource_system.cc	(revision 381)
+++ /trunk/src/engine/resource_system.cc	(revision 382)
@@ -12,5 +12,5 @@
 {
 	m_lua = a_lua_state;
-	lua::register_storage( m_lua, get_storage_name(), "register_" + get_resource_name().to_string() );
+	lua::register_storage( m_lua, get_storage_name(), string_ref( "register_" + get_resource_name().to_string() ) );
 }
 
Index: /trunk/src/formats/assimp_loader.cc
===================================================================
--- /trunk/src/formats/assimp_loader.cc	(revision 381)
+++ /trunk/src/formats/assimp_loader.cc	(revision 382)
@@ -238,5 +238,5 @@
 			aiMesh* mesh = scene->mMeshes[mc];
 
-			NV_LOG_NOTICE( "Mesh #", mc, "   - ", std::string( mesh->mName.data ) );
+			NV_LOG_NOTICE( "Mesh #", mc, "   - ", string_ref( (char*)mesh->mName.data ) );
 			NV_LOG_NOTICE( "  bones   - ", mesh->mNumBones );
 			NV_LOG_NOTICE( "  uvs     - ", mesh->mNumUVComponents[0] );
Index: /trunk/src/formats/obj_loader.cc
===================================================================
--- /trunk/src/formats/obj_loader.cc	(revision 381)
+++ /trunk/src/formats/obj_loader.cc	(revision 382)
@@ -280,10 +280,10 @@
 		for ( nv::size_t a = 0; a < count; ++a )
 		{
-			const vec3& n = m_data[a].normal;
-			const vec3& t = tan1[a];
-			if ( ! (t.x == 0.0f && t.y == 0.0f && t.z == 0.0f) )
+			const vec3& nv = m_data[a].normal;
+			const vec3& tv = tan1[a];
+			if ( ! (tv.x == 0.0f && tv.y == 0.0f && tv.z == 0.0f) )
 			{
-				m_data[a].tangent    = vec4( glm::normalize(t - n * glm::dot( n, t )), 0.0f ); 
-				m_data[a].tangent[3] = (glm::dot(glm::cross(n, t), tan2[a]) < 0.0f) ? -1.0f : 1.0f;
+				m_data[a].tangent    = vec4( glm::normalize(tv - nv * glm::dot( nv, tv )), 0.0f ); 
+				m_data[a].tangent[3] = (glm::dot(glm::cross(nv, tv), tan2[a]) < 0.0f) ? -1.0f : 1.0f;
 			}
 		}
Index: /trunk/src/stl/string.cc
===================================================================
--- /trunk/src/stl/string.cc	(revision 381)
+++ /trunk/src/stl/string.cc	(revision 382)
@@ -50,5 +50,5 @@
 	*s = '\0';
 	string_reverse( str, s - 1 );
-	return (size_t)( s - str );
+	return (nv::size_t)( s - str );
 }
 
@@ -65,5 +65,5 @@
 	*s = '\0';
 	string_reverse( str, s - 1 );
-	return (size_t)( s - str );
+	return (nv::size_t)( s - str );
 }
 
@@ -78,5 +78,5 @@
 	*s = '\0';
 	string_reverse( str, s - 1 );
-	return (size_t)( s - str );
+	return (nv::size_t)( s - str );
 }
 
