Index: trunk/nv/stl/array.hh
===================================================================
--- trunk/nv/stl/array.hh	(revision 374)
+++ trunk/nv/stl/array.hh	(revision 375)
@@ -25,4 +25,73 @@
 {
 	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;
+
+		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;
+	};
+
+	// TODO: using array =
+	template< typename T, size_t N >
+	class array : public array_base< T, 
+		fixed_container_storage< static_storage< T, N > >
+	>
+	{
+
+	};
+
+#if 0
 
 	template< typename T, size_t N >
@@ -82,10 +151,4 @@
 		}
 
-		void swap( array<value_type, N>& y )
-		{
-			for ( size_type i = 0; i < N; ++i )
-				nv::swap( m_data[i], y.m_data[i] );
-		}
-
 		void assign( const value_type& value ) { fill( value ); }
 
@@ -99,10 +162,5 @@
 	};
 
-	template< typename T, size_t N >
-	inline void swap( array<T, N>& lhs, array<T, N>& rhs )
-	{
-		lhs.swap( rhs );
-	}
-
+#endif
 // 	template < typename T, typename ContainerAllocator >
 // 	class vector_base
@@ -158,47 +216,6 @@
 // 	};
 
-	template < typename T, typename ContainerAllocator >
-	class array_base : public detail:: pointer_iterators < array_base< T, ContainerAllocator >, 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;
-
-		inline array_base() : m_storage() {}
-		inline array_base( pointer a_data, size_t a_size )
-		{
-
-		}
-		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 sizeof( T ) * m_storage.size(); }
-		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]; }
-	protected:
-		void push_values( size_type n, const value_type& value )
-		{
-
-		}
-		ContainerAllocator m_storage;
-	};
-
-	template< class T >
-	class dynamic_array : public detail::data_base< T, false, 0 >
+	template< typename T >
+	class dynamic_array : public detail::data_base< storage_view< T > >
 	{
 	public:
@@ -214,12 +231,12 @@
 		typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
 
-		dynamic_array() : detail::data_base< T, false, 0 >() {}
+		dynamic_array() : detail::data_base< storage_view< T > >() {}
 //			: m_data( nullptr ), m_size(0) {}
-		explicit dynamic_array( size_type new_size ) : detail::data_base< T, false, 0 >( new value_type[new_size], new_size ) {}
+		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< T, false, 0 >()
+		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< T, false, 0 >()
+		dynamic_array( const_iterator values, size_type size ) : detail::data_base< storage_view< T > >()
 //			: m_data( nullptr ), m_size(0) 
 		{ assign( values, size ); }
@@ -227,14 +244,14 @@
 		void resize( size_type new_size )
 		{
-			if ( new_size != this->m_size )
+			if ( new_size != this->size() )
 			{
-				value_type* old_data = this->m_data;
-				this->m_data = new_size > 0 ? new value_type[new_size] : nullptr;
-				if ( old_data && this->m_data )
+				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->m_size ? this->m_size : new_size, this->m_data );
+					std::copy_n( old_data, new_size > this->size() ? this->size() : new_size, new_data );
 				}
 				delete[] old_data;
-				this->m_size = new_size;
+				assign( new_data, new_size );
 			}
 		}
@@ -258,12 +275,12 @@
 		reference operator[]( size_type i ) 
 		{ 
-			NV_ASSERT( i < this->m_size, "Out of range" );
-			return this->m_data[i];
+			NV_ASSERT( i < this->size(), "Out of range" );
+			return this->data()[i];
 		}
 
 		const_reference operator[]( size_type i ) const 
 		{     
-			NV_ASSERT( i < this->m_size, "Out of range" );
-			return this->m_data[i];
+			NV_ASSERT( i < this->size(), "Out of range" );
+			return this->data()[i];
 		}
 
@@ -292,8 +309,8 @@
 		{
 			resize( new_size );
-			std::copy_n( values, this->size(), this->m_data );
-		}
-
-		~dynamic_array() { delete[] this->m_data; }
+			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/memory.hh
===================================================================
--- trunk/nv/stl/memory.hh	(revision 374)
+++ trunk/nv/stl/memory.hh	(revision 375)
@@ -25,4 +25,103 @@
 namespace nv
 {
+	template< typename T >
+	class storage_view
+	{
+	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  = false;
+
+		NV_CONSTEXPR storage_view() 
+			: m_data( nullptr ), m_size( 0 ) {}
+		NV_CONSTEXPR storage_view( value_type* a_data, size_type a_size ) 
+			: m_data( a_data ), m_size( a_size ) {}
+
+		void assign( value_type* a_data, size_type a_size )
+		{
+			m_data = a_data;
+			m_size = a_size;
+		}
+
+		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; }
+	protected:
+		value_type* m_data;
+		size_type   m_size;
+	};
+
+	template< typename T >
+	class const_storage_view
+	{
+	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() 
+			: m_data( nullptr ), m_size( 0 ) {}
+		NV_CONSTEXPR const_storage_view( const value_type* a_data, size_type a_size )
+			: m_data( a_data ), m_size( a_size ) {}
+
+		void assign( const value_type* a_data, size_type a_size )
+		{
+			m_data = a_data;
+			m_size = a_size;
+		}
+
+		NV_CONSTEXPR size_t size() const { return m_size; }
+		NV_CONSTEXPR const value_type* data() const { return m_data; }
+	protected:
+		const value_type* m_data;
+		size_type         m_size;
+	};
+
+
+	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 typename aligned_array<T, N, NV_ALIGN_OF( T ) >::type 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 = malloc( N * sizeof( value_type ) );
+		}
+		~fixed_dynamic_storage()
+		{
+			free( 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;
+	};
+
 
 	namespace detail
@@ -126,5 +225,5 @@
 	{
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		uninitialized_fill_impl( first, last, value, has_trivial_assign<value_type>() );
+		detail::uninitialized_fill_impl( first, last, value, has_trivial_assign<value_type>() );
 	}
 
@@ -133,5 +232,5 @@
 	{
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		return uninitialized_fill_n_impl( first, count, value, has_trivial_assign<value_type>() );
+		return detail::uninitialized_fill_n_impl( first, count, value, has_trivial_assign<value_type>() );
 	}
 
@@ -180,5 +279,5 @@
 	{
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		uninitialized_construct_impl( first, last, has_trivial_constructor<value_type>() );
+		detail::uninitialized_construct_impl( first, last, has_trivial_constructor<value_type>() );
 	}
 
@@ -187,5 +286,5 @@
 	{
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		return uninitialized_construct_n_impl( first, count, has_trivial_constructor<value_type>() );
+		return detail::uninitialized_construct_n_impl( first, count, has_trivial_constructor<value_type>() );
 	}
 
@@ -194,5 +293,5 @@
 	{
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		uninitialized_destroy_impl( first, last, has_trivial_destructor<value_type>() );
+		detail::uninitialized_destroy_impl( first, last, has_trivial_destructor<value_type>() );
 	}
 
@@ -201,17 +300,18 @@
 	{
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		return uninitialized_destroy_n_impl( first, count, has_trivial_destructor<value_type>() );
+		return detail::uninitialized_destroy_n_impl( first, count, has_trivial_destructor<value_type>() );
 	}
 
 	namespace detail
 	{
-		template < typename PARENT, typename T, bool CONST, typename BASE = empty_base_class<PARENT> >
+		template < typename PARENT, typename Storage, bool Const = Storage::is_const >
 		class pointer_iterators {};
 
-		template < typename PARENT, typename T, typename BASE >
-		class pointer_iterators< PARENT, T, true, BASE > : public BASE
+		template < typename PARENT, typename Storage >
+		class pointer_iterators< PARENT, Storage, true >
 		{
 		public:
-			typedef const T* const_iterator;
+			typedef typename Storage::value_type         value_type;
+			typedef const value_type*                    const_iterator;
 			typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
 
@@ -227,10 +327,11 @@
 		};
 
-		template < typename PARENT, typename T, typename BASE >
-		class pointer_iterators< PARENT, T, false, BASE > : public BASE
+		template < typename PARENT, typename Storage >
+		class pointer_iterators< PARENT, Storage, false >
 		{
 		public:
-			typedef T*       iterator;
-			typedef const T* const_iterator;
+			typedef typename Storage::value_type         value_type;
+			typedef value_type*                          iterator;
+			typedef const value_type*                    const_iterator;
 			typedef nv::reverse_iterator<iterator>       reverse_iterator;
 			typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
@@ -252,125 +353,79 @@
 		};
 
-		template < typename T, bool CONST, size_t SIZE >
-		class data_base
-		{
+		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 >
+		{
+		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;
 		};
 
-		template < typename T, size_t SIZE >
-		class data_base < T, true, SIZE > 
-			: public pointer_iterators< data_base < T, true, SIZE >, T, true > 
+		template < typename Storage >
+		class data_base < Storage, false >
+			: public pointer_iterators < data_base < Storage, false >, Storage >
 		{
 		public:
-			typedef T                    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 const_pointer data() const { 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 const_reference front() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[0]; }
-			inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[SIZE - 1]; }
+			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:
-			value_type m_data[SIZE];
+			void assign( pointer a_data, size_type a_size )
+			{
+				m_view.assign( a_data, a_size );
+			}
+
+			Storage m_view;
 		};
 
-		template < typename T, size_t SIZE >
-		class data_base < T, false, SIZE >
-			: public pointer_iterators < data_base < T, false, SIZE >, T, false >
-		{
-		public:
-			typedef T                    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 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]; }
-		protected:
-			value_type m_data[SIZE];
-		};
-
-
-		template < typename T >
-		class data_base < T, true, 0 >
-			: public pointer_iterators < data_base < T, true, 0 >, T, true >
-		{
-		public:
-			typedef T                    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() : m_data( nullptr ), m_size( 0 ) {}
-			inline data_base( const_pointer a_data, size_t a_size ) : m_data( a_data ), m_size( a_size ) {}
-			inline const T* data() const { return m_data; }
-			inline size_t size() const { return m_size; }
-			inline bool empty() const { return m_size != 0; }
-			inline size_type   raw_size() const { return sizeof( T ) * m_size; }
-			inline const char* raw_data() const { return (const char*)m_data; }
-
-			inline const_reference front() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[0]; }
-			inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[m_size - 1]; }
-		protected:
-			const_pointer m_data;
-			size_type     m_size;
-		};
-
-		template < typename T >
-		class data_base < T, false, 0 >
-			: public pointer_iterators < data_base < T, false, 0 >, T, false >
-		{
-		public:
-			typedef T                    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() : m_data( nullptr ), m_size( 0 ) {}
-			inline data_base( pointer a_data, size_t a_size ) : m_data( a_data ), m_size( a_size ) {}
-			inline const_pointer data() const { return m_data; }
-			inline pointer data() { return m_data; }
-			inline size_t size() const { return m_size; }
-			inline bool empty() const { return m_size != 0; }
-			inline size_type   raw_size() const { return sizeof( T ) * m_size; }
-			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[m_size - 1]; }
-			inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[m_size - 1]; }
-		protected:
-			pointer   m_data;
-			size_type m_size;
-		};
-
-	}
-
-	class const_mem_ref : public detail::data_base< char, true, 0 >
+	}
+
+	class const_mem_ref : public detail::data_base< const_storage_view< char > >
 	{
 	public:
@@ -384,10 +439,10 @@
 		typedef const_pointer        const_iterator;
 	public:
-		inline const_mem_ref() : detail::data_base< char, true, 0 >() {}
-		inline const_mem_ref( const void* p, size_type n ) : detail::data_base< char, true, 0 >( (const char*)p, n ) {}
-		inline const_mem_ref( const const_mem_ref& l ) : detail::data_base< char, true, 0 >( l.data(), l.size() ) {}
-	};
-
-	class mem_ref : public detail::data_base< char, false, 0 >
+		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 > >
 	{
 	public:
@@ -402,33 +457,68 @@
 		typedef const_pointer        const_iterator;
 	public:
-		inline mem_ref() : detail::data_base< char, false, 0 >() {}
-		inline mem_ref( void* p, size_type n ) : detail::data_base< char, false, 0 >( (char*)p, n ) {}
-		inline mem_ref( const mem_ref& l ) : detail::data_base< char, false, 0 >( const_cast< char* >( l.data() ), l.size() ) {}
-	};
-
-	template < typename T, size_t N >
-	class static_container_allocator
-	{
-	public:
-		typedef T value_type;
-		typedef typename aligned_array<T, N, NV_ALIGN_OF( T ) >::type storage;
-
-		static const bool   is_static  = true;
-		static const size_t type_align = NV_ALIGN_OF( T );
-		static const size_t type_size  = sizeof( T );
-
-		static_container_allocator()
-		{
-		}
-		bool resize( size_t new_size )
-		{
-			return true;
-		}
-		static NV_CONSTEXPR size_t capacity() { return N; }
-		static NV_CONSTEXPR size_t size() { 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 ); }
-
-		storage m_data;
+		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() ) {}
+	};
+
+	struct policy_initialize_always
+	{
+		template < typename ForwardIterator >
+		static void initialize( ForwardIterator first, ForwardIterator last )
+		{
+			uninitialized_construct( first, last );
+		}
+	};
+
+	struct policy_initialize_never
+	{
+		template < typename ForwardIterator >
+		static void initialize( ForwardIterator, ForwardIterator )
+		{
+		}
+	};
+
+	struct policy_initialize_standard
+	{
+		template < typename ForwardIterator >
+		static void initialize( ForwardIterator first, ForwardIterator last )
+		{
+			typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+			if ( !has_trivial_constructor<value_type>() )
+				detail::uninitialized_construct_impl( first, last, false_type() );
+		}
+	};
+
+
+	template <
+		typename Storage,
+		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;
 	};
 
@@ -438,6 +528,6 @@
 	public:
 		static const bool   is_static = false;
+		static const bool   is_fixed  = true;
 		static const size_t type_size = sizeof( T );
-		static const size_t type_align = NV_ALIGN_OF( T );
 
 		dynamic_container_allocator()
Index: trunk/nv/stl/string.hh
===================================================================
--- trunk/nv/stl/string.hh	(revision 374)
+++ trunk/nv/stl/string.hh	(revision 375)
@@ -337,5 +337,5 @@
 
 	// string base class - will become a base for a string class later
-	class string_base : public detail::data_base< char, true, 0 >
+	class string_base : public detail::data_base< const_storage_view< char > >
 	{
 	public:
@@ -354,39 +354,40 @@
  		inline std::string to_string() const
  		{
- 			return std::string( m_data, m_size );
+ 			return std::string( data(), size() );
  		}
 
-		inline NV_CONSTEXPR size_type length()   const { return m_size; }
+		inline NV_CONSTEXPR size_type length()   const { return size(); }
 
 		// access
-		inline NV_CONSTEXPR char operator[]( size_type i ) const { return m_data[i]; }
-		inline char at( size_t i ) const
+		inline NV_CONSTEXPR char operator[]( size_type i ) const { return data()[i]; }
+		inline char at( size_type i ) const
 		{
 			//	if ( i >= m_data ) NV_THROW( std::out_of_range( "string_ref::at" ) );
-			return m_data[i];
-		}
-
-		inline NV_CONSTEXPR char front()        const { return m_data[0]; }
-		inline NV_CONSTEXPR char back()         const { return m_data[m_size - 1]; }
+			return data()[i];
+		}
+
+		inline NV_CONSTEXPR char front()        const { return data()[0]; }
+		inline NV_CONSTEXPR char back()         const { return data()[size() - 1]; }
 
 		// string operations
 		int compare( const string_base& rhs ) const
 		{
-			int cmp = std::memcmp( m_data, rhs.m_data, ( nv::min )( m_size, rhs.m_size ) );
-			return cmp != 0 ? cmp : ( m_size == rhs.m_size ? 0 : m_size < rhs.m_size ? -1 : 1 );
+			size_type this_size = size();
+			int cmp = std::memcmp( data(), rhs.data(), ( nv::min )( this_size, rhs.size() ) );
+			return cmp != 0 ? cmp : ( this_size == rhs.size() ? 0 : this_size < rhs.size() ? -1 : 1 );
 		}
 		bool starts_with( char c ) const { return !empty() && c == front(); }
 		bool starts_with( const string_base& s ) const
 		{
-			return m_size >= s.m_size && std::memcmp( m_data, s.m_data, s.m_size ) == 0;
+			return size() >= s.size() && std::memcmp( data(), s.data(), s.size() ) == 0;
 		}
 		bool ends_with( char c ) const { return !empty() && c == back(); }
 		bool ends_with( const string_base& s ) const
 		{
-			return m_size >= s.m_size && std::memcmp( m_data + m_size - s.m_size, s.m_data, s.m_size ) == 0;
+			return size() >= s.size() && std::memcmp( data() + size() - s.size(), s.data(), s.size() ) == 0;
 		}
 		size_type find( const string_base& s, size_type pos = 0 ) const
 		{
-			if ( pos >= m_size ) return npos;
+			if ( pos >= size() ) return npos;
 			const_iterator it = search( this->cbegin() + ( difference_type ) pos, this->cend(), s.cbegin(), s.cend() );
 			return it == this->cend() ? npos : ( size_type )distance( this->cbegin(), it );
@@ -394,19 +395,19 @@
 		size_type find( char c, size_type pos = 0 ) const
 		{
-			if ( pos >= m_size ) return npos;
-			const_iterator it = find_if( this->cbegin() + ( difference_type ) pos, this->cend(), [=] ( char val ) { return val == c; } );
+			if ( pos >= size() ) return npos;
+			const_iterator it = find_if( this->cbegin() + (difference_type)pos, this->cend(), [=] ( char val ) { return val == c; } );
 			return it == this->cend() ? npos : ( size_type )distance( this->cbegin(), it );
 		}
 		size_type rfind( const string_base& s, size_type pos = 0 ) const
 		{
-			if ( pos >= m_size ) return npos;
-			const_reverse_iterator it = search( this->crbegin() + ( difference_type ) pos, this->crend(), s.crbegin(), s.crend() );
-			return it == this->crend() ? npos : m_size - 1 - ( size_type )distance( this->crbegin(), it );
+			if ( pos >= size() ) return npos;
+			const_reverse_iterator it = search( this->crbegin() + (difference_type)pos, this->crend(), s.crbegin(), s.crend() );
+			return it == this->crend() ? npos : size() - 1 - ( size_type )distance( this->crbegin(), it );
 		}
 		size_type rfind( char c, size_type pos = 0 ) const
 		{
-			if ( pos >= m_size ) return npos;
-			const_reverse_iterator it = find_if( this->crbegin() + ( difference_type ) pos, this->crend(), [=] ( char val ) { return val == c; } );
-			return it == this->crend() ? npos : m_size - 1 - ( size_type )distance( this->crbegin(), it );
+			if ( pos >= size() ) return npos;
+			const_reverse_iterator it = find_if( this->crbegin() + (difference_type)pos, this->crend(), [=] ( char val ) { return val == c; } );
+			return it == this->crend() ? npos : size() - 1 - ( size_type )distance( this->crbegin(), it );
 		}
 		size_type find_first_of( char c ) const { return find( c ); }
@@ -420,10 +421,10 @@
 		{
 			const_reverse_iterator it = nv::find_first_of( this->crbegin(), this->crend(), s.cbegin(), s.cend() );
-			return it == this->crend() ? npos : m_size - 1 - ( size_type )distance( this->crbegin(), it );
+			return it == this->crend() ? npos : size() - 1 - ( size_type )distance( this->crbegin(), it );
 		}
 		size_type find_first_not_of( const string_base& s ) const
 		{
 			for ( const_iterator it = this->cbegin(); it != this->cend(); ++it )
-				if ( 0 == std::memchr( s.m_data, *it, s.m_size ) )
+				if ( 0 == std::memchr( s.data(), *it, s.size() ) )
 					return ( size_type )distance( this->cbegin(), it );
 			return npos;
@@ -439,6 +440,6 @@
 		{
 			for ( const_reverse_iterator it = this->crbegin(); it != this->crend(); ++it )
-				if ( 0 == std::memchr( s.m_data, *it, s.m_size ) )
-					return m_size - 1 - ( size_type )distance( this->crbegin(), it );;
+				if ( 0 == std::memchr( s.data(), *it, s.size() ) )
+					return size() - 1 - (size_type)distance( this->crbegin(), it );
 			return npos;
 		}
@@ -447,5 +448,5 @@
 			for ( const_reverse_iterator it = this->crbegin(); it != this->crend(); ++it )
 				if ( c != *it )
-					return m_size - 1 - ( size_type )distance( this->crbegin(), it );
+					return size() - 1 - ( size_type )distance( this->crbegin(), it );
 			return npos;
 		}
@@ -456,6 +457,6 @@
 		inline size_t hash() const
 		{
-			const char* str = m_data;
-			size_type   sz  = m_size;
+			const char* str = data();
+			size_type   sz  = size();
 			int seed = 131;
 			int result = 0;
@@ -470,7 +471,7 @@
 
 	protected:
-		inline NV_CONSTEXPR string_base() : detail::data_base< char, true, 0 >() {}
+		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< char, true, 0 >( a_data, a_lenght ) {}
+			: detail::data_base< const_storage_view< char > >( a_data, a_lenght ) {}
 	};
 
@@ -480,5 +481,5 @@
 		inline NV_CONSTEXPR string_ref() {}
 		inline NV_CONSTEXPR string_ref( const string_ref& rhs )
-			: string_base( rhs.m_data, rhs.m_size )
+			: string_base( rhs.data(), rhs.size() )
 		{
 		}
@@ -514,6 +515,5 @@
 		inline string_ref& operator=( const string_ref &rhs )
 		{
-			m_data = rhs.m_data;
-			m_size = rhs.m_size;
+			assign( rhs.data(), rhs.size() );
 			return *this;
 		}
@@ -522,17 +522,17 @@
 		inline void clear()
 		{
-			m_size = 0;
-			m_data = nullptr;
+			assign( nullptr, 0 );
 		}
 		inline void remove_prefix( size_type n )
 		{
-			if ( n > m_size )	n = m_size;
-			m_data += n;
-			m_size -= n;
+			size_type s = size();
+			if ( n > s ) n = s;
+			assign( data() + n, s - n );
 		}
 		inline void remove_suffix( size_type n )
 		{
-			if ( n > m_size ) n = m_size;
-			m_size -= n;
+			size_type s = size();
+			if ( n > s ) n = s;
+			assign( data(), s - n );
 		}
 
@@ -555,18 +555,22 @@
 		~const_string()
 		{
-			if ( m_data ) delete m_data;
+			if ( data() )
+			{
+				delete data();
+			}
 		}
 
 		inline const_string( const_string&& other )
 		{
-			m_data = other.m_data;
-			other.m_data = nullptr;
+			assign( other.data(), other.size() );
+			other.assign( nullptr, 0 );
 		}
 
 		inline const_string& operator=( const_string&& other )
 		{
-			pointer temp = m_data;
-			m_data = other.m_data;
-			other.m_data = temp;
+			pointer   old_data = data();
+			size_type old_size = size();
+			assign( other.data(), other.size() );
+			other.assign( old_data , old_size );
 			return *this;
 		}
@@ -584,5 +588,5 @@
 			std::memcpy( data, p, s );
 			data[s] = 0;
-			m_data = data;
+			assign( data, s );
 		}
 	};
