Index: trunk/nv/stl/array.hh
===================================================================
--- trunk/nv/stl/array.hh	(revision 368)
+++ trunk/nv/stl/array.hh	(revision 374)
@@ -16,4 +16,6 @@
 #include <nv/core/common.hh>
 #include <nv/stl/memory.hh>
+#include <nv/stl/iterator.hh>
+#include <nv/stl/utility.hh>
 #include <vector>
 #include <algorithm>
@@ -23,36 +25,36 @@
 {
 	using std::vector;
-	using std::array;
-
-	template< class T, std::size_t N >
-	class static_array : public detail::data_base< T, false, N >
+
+	template< typename T, size_t N >
+	class array : public detail::pointer_iterators < array< T, N >, T, false >
 	{
 	public:
-		typedef T              value_type;
-		typedef T*             iterator;
-		typedef const T*       const_iterator;
-		typedef T&             reference;
-		typedef const T&       const_reference;
-		typedef std::size_t    size_type;
-		typedef std::ptrdiff_t difference_type;
-
-		typedef std::reverse_iterator<iterator>       reverse_iterator;
-		typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-
-// 		iterator        begin()        { return m_data; }
-// 		const_iterator  begin()  const { return m_data; }
-// 		const_iterator  cbegin() const { return m_data; }
-// 
-// 		iterator        end()        { return m_data+N; }
-// 		const_iterator  end()  const { return m_data+N; }
-// 		const_iterator  cend() const { return m_data+N; }
-// 
-// 		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() ); }
+		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 ) 
@@ -68,24 +70,131 @@
 		}
 
-// 		reference       front()       { return m_data[0]; }
-// 		const_reference front() const { return m_data[0]; }
-// 		reference       back()        { return m_data[N-1]; }
-// 		const_reference back() const  { return m_data[N-1]; }
-// 
-// 		static size_type size()     { return N; }
-// 		static bool      empty()    { return false; }
-// 		static size_type max_size() { return N; }
-// 
-// 		const value_type* data() const { return m_data; }
-// 		value_type*       data()       { return m_data; }
-// 
-// 		size_type   raw_size() const { return N * 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 ); }
-
-		static const size_type SIZE = N;
-		static const size_type ELEMENT_SIZE = sizeof(T);
+		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 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 ); }
+
+		void fill( const value_type& value )
+		{
+			std::fill_n( this->begin(), this->size(), value );
+		}
+
+	private:
+		value_type m_data[SIZE];
+	};
+
+	template< typename T, size_t N >
+	inline void swap( array<T, N>& lhs, array<T, N>& rhs )
+	{
+		lhs.swap( rhs );
+	}
+
+// 	template < typename T, typename ContainerAllocator >
+// 	class vector_base
+// 	{
+// 	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;
+// 
+// 	protected:
+// 		ContainerAllocator m_storage;
+// 	};
+
+// 	template< typename T, size_t N >
+// 	class static_vector : public detail::pointer_iterators < static_vector< 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_vector() : m_size(0) {}
+// 
+// 		inline const_pointer data() const { return m_data; }
+// 		inline pointer data() { return m_data; }
+// 		inline size_type size() const { return m_size; }
+// 		inline bool empty() const { return !m_size; }
+// 		inline size_type   raw_size() const { return N * 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[m_size - 1]; }
+// 		inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[m_size - 1]; }
+// 	protected:
+// 		value_type m_data[N];
+// 		size_type  m_size;
+// 	};
+
+	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;
 	};
 
@@ -94,14 +203,14 @@
 	{
 	public:
-		typedef T              value_type;
-		typedef T*             iterator;
-		typedef const T*       const_iterator;
-		typedef T&             reference;
-		typedef const T&       const_reference;
-		typedef std::size_t    size_type;
-		typedef std::ptrdiff_t difference_type;
-
-		typedef std::reverse_iterator<iterator>       reverse_iterator;
-		typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+		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< T, false, 0 >() {}
@@ -166,5 +275,5 @@
 // 		size_type        size() const     { return m_size; }
 // 		bool             empty() const    { return m_size == 0; }
-// 		static size_type max_size()       { return std::numeric_limits< size_type >::max(); }
+// 		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; }
@@ -191,4 +300,6 @@
 	};
 
+
+
 }
 
