Index: /trunk/nv/stl/algorithm.hh
===================================================================
--- /trunk/nv/stl/algorithm.hh	(revision 387)
+++ /trunk/nv/stl/algorithm.hh	(revision 388)
@@ -10,13 +10,14 @@
 * @brief STL algorithm library
 */
-// TODO: implement fill_default!
 
 #ifndef NV_STL_ALGORITHM_HH
 #define NV_STL_ALGORITHM_HH
 
-#include <nv/core/common.hh>
+#include <nv/stl/algorithm/common.hh>
+#include <nv/stl/algorithm/raw.hh>
+#include <nv/stl/algorithm/copy.hh>
+#include <nv/stl/algorithm/fill.hh>
 #include <nv/stl/utility.hh>
 #include <nv/stl/iterator.hh>
-#include <nv/stl/capi.hh>
 
 namespace nv
@@ -186,199 +187,4 @@
 	}
 
-	template< typename T >
-	T* raw_copy( const T* first, const T* last, T* out )
-	{
-		return (T*)nvmemcpy( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
-	}
-
-	template< typename T >
-	T* raw_copy_n( const T* ptr, size_t n, T* out )
-	{
-		return (T*)nvmemcpy( out, ptr, n * sizeof(T) ) + n;
-	}
-
-	template< typename T >
-	T* raw_alias_copy( const T* first, const T* last, T* out )
-	{
-		return (T*)nvmemmove( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
-	}
-
-	template< typename T >
-	T* raw_alias_copy_n( const T* ptr, size_t n, T* out )
-	{
-		return (T*)nvmemmove( out, ptr, n * sizeof( T ) ) + n;
-	}
-
-	template< typename T >
-	T* raw_zero( T* first, T* last )
-	{
-		return (T*)nvmemset( first, 0, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
-	}
-
-	template< typename T >
-	T* raw_zero_n( T* ptr, size_t n )
-	{
-		return (T*)nvmemset( ptr, 0, n * sizeof( T ) ) + n;
-	}
-
-	template< typename T >
-	T* raw_fill( T* first, T* last, unsigned char value )
-	{
-		return (T*)nvmemset( first, value, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
-	}
-
-	template< typename T >
-	T* raw_fill_n( T* ptr, size_t n, unsigned char value )
-	{
-		return (T*)nvmemset( ptr, value, n * sizeof( T ) ) + n;
-	}
-
-	namespace detail
-	{
-		template < typename ForwardIterator, typename T, typename AnyType >
-		void fill_impl( ForwardIterator first, ForwardIterator last, const T& value, AnyType, forward_iterator_tag )
-		{
-			// TODO: version with T temp = value for scalars
-			for (; first != last; ++first )
-				*first = value;
-		}
-
-		template < typename BlockAccessIterator, typename T >
-		void fill_impl( BlockAccessIterator first, BlockAccessIterator last, T value, true_type, block_access_iterator_tag )
-		{
-			raw_fill( first, last, (unsigned char)value );  
-		}
-
-		template < typename ForwardIterator, typename T, typename AnyType >
-		ForwardIterator fill_n_impl( ForwardIterator first, size_t count, const T& value, AnyType, forward_iterator_tag )
-		{
-			// TODO: version with T temp = T() for scalars
-			for ( ; count-- > 0; ++first ) *first = value;
-			return first;
-		}
-
-		template < typename BlockAccessIterator, typename T >
-		BlockAccessIterator fill_n_impl( BlockAccessIterator first, size_t count, T value, true_type, block_access_iterator_tag )
-		{
-			return BlockAccessIterator( raw_fill_n( first, count, (unsigned char)value ) );
-		}
-
-		template < typename ForwardIterator, typename T, typename AnyType >
-		void fill_default_impl( ForwardIterator first, ForwardIterator last, AnyType, forward_iterator_tag )
-		{
-			// TODO: version with T temp = T() for scalars
-			for ( ; first != last; ++first )
-				*first = T();
-		}
-
-		template < typename BlockAccessIterator, typename T >
-		void fill_default_impl( BlockAccessIterator first, BlockAccessIterator last, true_type, block_access_iterator_tag )
-		{
-			raw_zero( first, last );
-		}
-
-		template < typename ForwardIterator, typename T, typename AnyType >
-		ForwardIterator fill_default_n_impl( ForwardIterator first, size_t n, AnyType, forward_iterator_tag )
-		{
-			// TODO: version with T temp = T() for scalars
-			for ( ; n-- > 0; ++first ) *first = value;
-			return first;
-		}
-
-		template < typename BlockAccessIterator, typename T >
-		BlockAccessIterator fill_default_n_impl( BlockAccessIterator first, size_t count, true_type, block_access_iterator_tag )
-		{
-			return BlockAccessIterator( raw_zero_n( first, count, (unsigned char)value ) );
-		}
-	}
-
-	// TODO: fill_default special case!
-	template < typename ForwardIterator, typename T > 
-	inline void fill( ForwardIterator first, ForwardIterator last, const T& value )
-	{
-		typedef typename iterator_traits< ForwardIterator >::value_type        value_type;
-		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
-		detail::fill_impl( first, last, static_cast<value_type>( value ),
-			bool_constant< sizeof( value_type ) == 1 && 
-			has_trivial_assign<value_type>::value >(), iterator_category() );
-	}
-
-	template < typename ForwardIterator, typename T >
-	inline ForwardIterator fill_n( ForwardIterator first, size_t count, const T& value )
-	{
-		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
-		return detail::fill_n_impl( first, count, static_cast<value_type>( value ),
-			bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() );
-	}
-
-	template < typename ForwardIterator >
-	inline void fill_default( ForwardIterator first, ForwardIterator last )
-	{
-		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
-		detail::fill_default_impl( first, last, 
-			bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() );
-	}
-
-	template < typename ForwardIterator >
-	inline ForwardIterator fill_default_n( ForwardIterator first, size_t count )
-	{
-		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
-		return detail::fill_default_n_impl( first, count, 
-			bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() );
-	}
-
-	namespace detail
-	{
-		template< typename InputIterator, typename OutputIterator, typename AnyType >
-		inline OutputIterator copy_impl( InputIterator first, InputIterator last, OutputIterator out, AnyType, input_iterator_tag, forward_iterator_tag )
-		{
-			for ( ; first != last; ++first, ++out )
-				*first = *out;
-			return out;
-		}
-
-		template< typename BlockAccessIterator, typename OutputIterator >
-		inline BlockAccessIterator copy_impl( BlockAccessIterator first, BlockAccessIterator last, OutputIterator out, true_type, block_access_iterator_tag, block_access_iterator_tag )
-		{
-			return raw_alias_copy( first, last, out )
-		}
-
-		template< typename InputIterator, typename OutputIterator, typename AnyType >
-		inline OutputIterator copy_n_impl( InputIterator first, size_t n, OutputIterator out, AnyType, input_iterator_tag, forward_iterator_tag )
-		{
-			for ( ; n-- > 0; ++first, ++out ) *first = *out;
-			return out;
-		}
-
-		template< typename BlockAccessIterator, typename OutputIterator >
-		inline BlockAccessIterator copy_n_impl( BlockAccessIterator first, BlockAccessIterator n, OutputIterator out, true_type, block_access_iterator_tag, block_access_iterator_tag )
-		{
-			return raw_alias_copy_n( first, n, out )
-		}
-	}
-
-	template< class InputIterator, class OutputIterator >
-	inline OutputIterator copy( InputIterator first, InputIterator last, OutputIterator out )
-	{
-		typedef typename iterator_traits< InputIterator >::value_type value_type;
-		typedef typename iterator_traits< InputIterator >::iterator_category input_iterator_category;
-		typedef typename iterator_traits< OutputIterator >::iterator_category output_iterator_category;
-		return detail::copy_impl( first, last, out,
-			has_trivial_copy<value_type>::value, iterator_category(), output_iterator_category() );
-	}
-
-	template< class InputIterator, class OutputIterator >
-	inline OutputIterator copy_n( InputIterator first, size_t n, OutputIterator out )
-	{
-		typedef typename iterator_traits< InputIterator >::value_type value_type;
-		typedef typename iterator_traits< InputIterator >::iterator_category input_iterator_category;
-		typedef typename iterator_traits< OutputIterator >::iterator_category output_iterator_category;
-		return detail::copy_n_impl( first, n, out,
-			has_trivial_copy<value_type>::value, iterator_category(), output_iterator_category() );
-	}
-
 }
 
Index: /trunk/nv/stl/algorithm/common.hh
===================================================================
--- /trunk/nv/stl/algorithm/common.hh	(revision 388)
+++ /trunk/nv/stl/algorithm/common.hh	(revision 388)
@@ -0,0 +1,22 @@
+// Copyright (C) 2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+/**
+* @file common.hh
+* @author Kornel Kisielewicz epyon@chaosforge.org
+* @brief algorithm common
+*/
+
+#ifndef NV_STL_ALGORITHM_COMMON_HH
+#define NV_STL_ALGORITHM_COMMON_HH
+
+#include <nv/core/common.hh>
+
+namespace nv
+{
+}
+
+#endif // NV_STL_ALGORITHM_COMMON_HH
Index: /trunk/nv/stl/algorithm/copy.hh
===================================================================
--- /trunk/nv/stl/algorithm/copy.hh	(revision 388)
+++ /trunk/nv/stl/algorithm/copy.hh	(revision 388)
@@ -0,0 +1,74 @@
+// Copyright (C) 2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+/**
+* @file copy.hh
+* @author Kornel Kisielewicz epyon@chaosforge.org
+* @brief algorithm copy
+*/
+
+#ifndef NV_STL_ALGORITHM_COPY_HH
+#define NV_STL_ALGORITHM_COPY_HH
+
+#include <nv/stl/algorithm/common.hh>
+#include <nv/stl/algorithm/raw.hh>
+
+namespace nv
+{
+
+	namespace detail
+	{
+		template< typename InputIterator, typename OutputIterator, typename AnyType >
+		inline OutputIterator copy_impl( InputIterator first, InputIterator last, OutputIterator out, AnyType, input_iterator_tag, forward_iterator_tag )
+		{
+			for ( ; first != last; ++first, ++out )
+				*first = *out;
+			return out;
+		}
+
+		template< typename BlockAccessIterator, typename OutputIterator >
+		inline BlockAccessIterator copy_impl( BlockAccessIterator first, BlockAccessIterator last, OutputIterator out, true_type, block_access_iterator_tag, block_access_iterator_tag )
+		{
+			return raw_alias_copy( first, last, out )
+		}
+
+		template< typename InputIterator, typename OutputIterator, typename AnyType >
+		inline OutputIterator copy_n_impl( InputIterator first, size_t n, OutputIterator out, AnyType, input_iterator_tag, forward_iterator_tag )
+		{
+			for ( ; n-- > 0; ++first, ++out ) *first = *out;
+			return out;
+		}
+
+		template< typename BlockAccessIterator, typename OutputIterator >
+		inline BlockAccessIterator copy_n_impl( BlockAccessIterator first, BlockAccessIterator n, OutputIterator out, true_type, block_access_iterator_tag, block_access_iterator_tag )
+		{
+			return raw_alias_copy_n( first, n, out )
+		}
+	}
+
+	template< class InputIterator, class OutputIterator >
+	inline OutputIterator copy( InputIterator first, InputIterator last, OutputIterator out )
+	{
+		typedef typename iterator_traits< InputIterator >::value_type value_type;
+		typedef typename iterator_traits< InputIterator >::iterator_category input_iterator_category;
+		typedef typename iterator_traits< OutputIterator >::iterator_category output_iterator_category;
+		return detail::copy_impl( first, last, out,
+			has_trivial_copy<value_type>::value, iterator_category(), output_iterator_category() );
+	}
+
+	template< class InputIterator, class OutputIterator >
+	inline OutputIterator copy_n( InputIterator first, size_t n, OutputIterator out )
+	{
+		typedef typename iterator_traits< InputIterator >::value_type value_type;
+		typedef typename iterator_traits< InputIterator >::iterator_category input_iterator_category;
+		typedef typename iterator_traits< OutputIterator >::iterator_category output_iterator_category;
+		return detail::copy_n_impl( first, n, out,
+			has_trivial_copy<value_type>::value, iterator_category(), output_iterator_category() );
+	}
+
+}
+
+#endif // NV_STL_ALGORITHM_COPY_HH
Index: /trunk/nv/stl/algorithm/fill.hh
===================================================================
--- /trunk/nv/stl/algorithm/fill.hh	(revision 388)
+++ /trunk/nv/stl/algorithm/fill.hh	(revision 388)
@@ -0,0 +1,120 @@
+// Copyright (C) 2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+/**
+* @file fill.hh
+* @author Kornel Kisielewicz epyon@chaosforge.org
+* @brief algorithm fill
+*/
+
+#ifndef NV_STL_ALGORITHM_FILL_HH
+#define NV_STL_ALGORITHM_FILL_HH
+
+#include <nv/stl/algorithm/common.hh>
+#include <nv/stl/algorithm/raw.hh>
+
+namespace nv
+{
+
+	namespace detail
+	{
+		template < typename ForwardIterator, typename T, typename AnyType >
+		void fill_impl( ForwardIterator first, ForwardIterator last, const T& value, AnyType, forward_iterator_tag )
+		{
+			// TODO: version with T temp = value for scalars
+			for ( ; first != last; ++first )
+				*first = value;
+		}
+
+		template < typename BlockAccessIterator, typename T >
+		void fill_impl( BlockAccessIterator first, BlockAccessIterator last, T value, true_type, block_access_iterator_tag )
+		{
+			raw_fill( first, last, (unsigned char)value );
+		}
+
+		template < typename ForwardIterator, typename T, typename AnyType >
+		ForwardIterator fill_n_impl( ForwardIterator first, size_t count, const T& value, AnyType, forward_iterator_tag )
+		{
+			// TODO: version with T temp = T() for scalars
+			for ( ; count-- > 0; ++first ) *first = value;
+			return first;
+		}
+
+		template < typename BlockAccessIterator, typename T >
+		BlockAccessIterator fill_n_impl( BlockAccessIterator first, size_t count, T value, true_type, block_access_iterator_tag )
+		{
+			return BlockAccessIterator( raw_fill_n( first, count, (unsigned char)value ) );
+		}
+
+		template < typename ForwardIterator, typename T, typename AnyType >
+		void fill_default_impl( ForwardIterator first, ForwardIterator last, AnyType, forward_iterator_tag )
+		{
+			// TODO: version with T temp = T() for scalars
+			for ( ; first != last; ++first )
+				*first = T();
+		}
+
+		template < typename BlockAccessIterator, typename T >
+		void fill_default_impl( BlockAccessIterator first, BlockAccessIterator last, true_type, block_access_iterator_tag )
+		{
+			raw_zero( first, last );
+		}
+
+		template < typename ForwardIterator, typename T, typename AnyType >
+		ForwardIterator fill_default_n_impl( ForwardIterator first, size_t n, AnyType, forward_iterator_tag )
+		{
+			// TODO: version with T temp = T() for scalars
+			for ( ; n-- > 0; ++first ) *first = value;
+			return first;
+		}
+
+		template < typename BlockAccessIterator, typename T >
+		BlockAccessIterator fill_default_n_impl( BlockAccessIterator first, size_t count, true_type, block_access_iterator_tag )
+		{
+			return BlockAccessIterator( raw_zero_n( first, count, (unsigned char)value ) );
+		}
+	}
+
+	template < typename ForwardIterator, typename T >
+	inline void fill( ForwardIterator first, ForwardIterator last, const T& value )
+	{
+		typedef typename iterator_traits< ForwardIterator >::value_type        value_type;
+		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
+		detail::fill_impl( first, last, static_cast<value_type>( value ),
+			bool_constant< sizeof( value_type ) == 1 &&
+			has_trivial_assign<value_type>::value >(), iterator_category() );
+	}
+
+	template < typename ForwardIterator, typename T >
+	inline ForwardIterator fill_n( ForwardIterator first, size_t count, const T& value )
+	{
+		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
+		return detail::fill_n_impl( first, count, static_cast<value_type>( value ),
+			bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() );
+	}
+
+	template < typename ForwardIterator >
+	inline void fill_default( ForwardIterator first, ForwardIterator last )
+	{
+		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
+		detail::fill_default_impl( first, last,
+			bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() );
+	}
+
+	template < typename ForwardIterator >
+	inline ForwardIterator fill_default_n( ForwardIterator first, size_t count )
+	{
+		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
+		return detail::fill_default_n_impl( first, count,
+			bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() );
+	}
+
+}
+
+#endif // NV_STL_ALGORITHM_FILL_HH
Index: /trunk/nv/stl/algorithm/raw.hh
===================================================================
--- /trunk/nv/stl/algorithm/raw.hh	(revision 388)
+++ /trunk/nv/stl/algorithm/raw.hh	(revision 388)
@@ -0,0 +1,73 @@
+// Copyright (C) 2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+/**
+* @file raw.hh
+* @author Kornel Kisielewicz epyon@chaosforge.org
+* @brief algorithm raw
+*/
+
+#ifndef NV_STL_ALGORITHM_RAW_HH
+#define NV_STL_ALGORITHM_RAW_HH
+
+#include <nv/stl/algorithm/common.hh>
+#include <nv/stl/capi.hh>
+
+namespace nv
+{
+
+	template< typename T >
+	T* raw_copy( const T* first, const T* last, T* out )
+	{
+		return (T*)nvmemcpy( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
+	}
+
+	template< typename T >
+	T* raw_copy_n( const T* ptr, size_t n, T* out )
+	{
+		return (T*)nvmemcpy( out, ptr, n * sizeof( T ) ) + n;
+	}
+
+	template< typename T >
+	T* raw_alias_copy( const T* first, const T* last, T* out )
+	{
+		return (T*)nvmemmove( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
+	}
+
+	template< typename T >
+	T* raw_alias_copy_n( const T* ptr, size_t n, T* out )
+	{
+		return (T*)nvmemmove( out, ptr, n * sizeof( T ) ) + n;
+	}
+
+	template< typename T >
+	T* raw_zero( T* first, T* last )
+	{
+		return (T*)nvmemset( first, 0, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
+	}
+
+	template< typename T >
+	T* raw_zero_n( T* ptr, size_t n )
+	{
+		return (T*)nvmemset( ptr, 0, n * sizeof( T ) ) + n;
+	}
+
+	template< typename T >
+	T* raw_fill( T* first, T* last, unsigned char value )
+	{
+		return (T*)nvmemset( first, value, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
+	}
+
+	template< typename T >
+	T* raw_fill_n( T* ptr, size_t n, unsigned char value )
+	{
+		return (T*)nvmemset( ptr, value, n * sizeof( T ) ) + n;
+	}
+
+}
+
+#endif // NV_STL_ALGORITHM_RAW_HH
+
