changeset 3229:4885e0722884

* include/*: * src/*: * tests/*: * HISTORY: * LICENSE: Updated to uSTL 1.6 sources.
author sergeig
date Wed, 04 Apr 2012 18:51:57 +0000
parents e1cec8d66444
children bf98691daa6d
files packages/language/cxx/ustl/current/ChangeLog packages/language/cxx/ustl/current/HISTORY packages/language/cxx/ustl/current/LICENSE packages/language/cxx/ustl/current/include/ustl.h packages/language/cxx/ustl/current/include/ustl/bktrace.h packages/language/cxx/ustl/current/include/ustl/cmemlink.h packages/language/cxx/ustl/current/include/ustl/fstream.h packages/language/cxx/ustl/current/include/ustl/memblock.h packages/language/cxx/ustl/current/include/ustl/memlink.h packages/language/cxx/ustl/current/include/ustl/metamac.h packages/language/cxx/ustl/current/include/ustl/mistream.h packages/language/cxx/ustl/current/include/ustl/mostream.h packages/language/cxx/ustl/current/include/ustl/ofstream.h packages/language/cxx/ustl/current/include/ustl/simd.h packages/language/cxx/ustl/current/include/ustl/sistream.h packages/language/cxx/ustl/current/include/ustl/sostream.h packages/language/cxx/ustl/current/include/ustl/strmsize.h packages/language/cxx/ustl/current/include/ustl/traits.h packages/language/cxx/ustl/current/include/ustl/typeinfo.h packages/language/cxx/ustl/current/include/ustl/typelist.h packages/language/cxx/ustl/current/include/ustl/typet.h packages/language/cxx/ustl/current/include/ustl/ualgo.h packages/language/cxx/ustl/current/include/ustl/ualgobase.h packages/language/cxx/ustl/current/include/ustl/ubitset.h packages/language/cxx/ustl/current/include/ustl/uctralgo.h packages/language/cxx/ustl/current/include/ustl/uctrstrm.h packages/language/cxx/ustl/current/include/ustl/uexception.h packages/language/cxx/ustl/current/include/ustl/ufunction.h packages/language/cxx/ustl/current/include/ustl/uheap.h packages/language/cxx/ustl/current/include/ustl/uios.h packages/language/cxx/ustl/current/include/ustl/uiosfunc.h packages/language/cxx/ustl/current/include/ustl/uiterator.h packages/language/cxx/ustl/current/include/ustl/ulaalgo.h packages/language/cxx/ustl/current/include/ustl/ulimits.h packages/language/cxx/ustl/current/include/ustl/ulist.h packages/language/cxx/ustl/current/include/ustl/umap.h packages/language/cxx/ustl/current/include/ustl/umatrix.h packages/language/cxx/ustl/current/include/ustl/umemory.h packages/language/cxx/ustl/current/include/ustl/umultimap.h packages/language/cxx/ustl/current/include/ustl/umultiset.h packages/language/cxx/ustl/current/include/ustl/unew.h packages/language/cxx/ustl/current/include/ustl/unumeric.h packages/language/cxx/ustl/current/include/ustl/upair.h packages/language/cxx/ustl/current/include/ustl/upredalgo.h packages/language/cxx/ustl/current/include/ustl/uqueue.h packages/language/cxx/ustl/current/include/ustl/uset.h packages/language/cxx/ustl/current/include/ustl/uspecial.h packages/language/cxx/ustl/current/include/ustl/ustack.h packages/language/cxx/ustl/current/include/ustl/ustdxept.h packages/language/cxx/ustl/current/include/ustl/ustring.h packages/language/cxx/ustl/current/include/ustl/utf8.h packages/language/cxx/ustl/current/include/ustl/utuple.h packages/language/cxx/ustl/current/include/ustl/utypes.h packages/language/cxx/ustl/current/include/ustl/uutility.h packages/language/cxx/ustl/current/include/ustl/uvector.h packages/language/cxx/ustl/current/src/bktrace.cpp packages/language/cxx/ustl/current/src/cmemlink.cpp packages/language/cxx/ustl/current/src/fstream.cpp packages/language/cxx/ustl/current/src/memblock.cpp packages/language/cxx/ustl/current/src/memlink.cpp packages/language/cxx/ustl/current/src/mistream.cpp packages/language/cxx/ustl/current/src/ofstream.cpp packages/language/cxx/ustl/current/src/sistream.cpp packages/language/cxx/ustl/current/src/sostream.cpp packages/language/cxx/ustl/current/src/ualgobase.cpp packages/language/cxx/ustl/current/src/ubitset.cpp packages/language/cxx/ustl/current/src/uexception.cpp packages/language/cxx/ustl/current/src/unew.cpp packages/language/cxx/ustl/current/src/ustdxept.cpp packages/language/cxx/ustl/current/src/ustring.cpp packages/language/cxx/ustl/current/tests/bvt00.cpp packages/language/cxx/ustl/current/tests/bvt01.cpp packages/language/cxx/ustl/current/tests/bvt02.cpp packages/language/cxx/ustl/current/tests/bvt03.cpp packages/language/cxx/ustl/current/tests/bvt04.cpp packages/language/cxx/ustl/current/tests/bvt05.cpp packages/language/cxx/ustl/current/tests/bvt06.cpp packages/language/cxx/ustl/current/tests/bvt07.cpp packages/language/cxx/ustl/current/tests/bvt08.cpp packages/language/cxx/ustl/current/tests/bvt09.cpp packages/language/cxx/ustl/current/tests/bvt10.cpp packages/language/cxx/ustl/current/tests/bvt11.cpp packages/language/cxx/ustl/current/tests/bvt12.cpp packages/language/cxx/ustl/current/tests/bvt13.cpp packages/language/cxx/ustl/current/tests/bvt14.cpp packages/language/cxx/ustl/current/tests/bvt15.cpp packages/language/cxx/ustl/current/tests/bvt15.std packages/language/cxx/ustl/current/tests/bvt16.cpp packages/language/cxx/ustl/current/tests/bvt17.cpp packages/language/cxx/ustl/current/tests/bvt18.cpp packages/language/cxx/ustl/current/tests/bvt19.cpp packages/language/cxx/ustl/current/tests/bvt20.cpp packages/language/cxx/ustl/current/tests/bvt21.cpp packages/language/cxx/ustl/current/tests/bvt22.cpp packages/language/cxx/ustl/current/tests/bvt23.cpp packages/language/cxx/ustl/current/tests/bvt24.cpp packages/language/cxx/ustl/current/tests/bvt25.cpp packages/language/cxx/ustl/current/tests/bvt26.cpp packages/language/cxx/ustl/current/tests/bvt27.cpp
diffstat 99 files changed, 454 insertions(+), 351 deletions(-) [+]
line wrap: on
line diff
--- a/packages/language/cxx/ustl/current/ChangeLog
+++ b/packages/language/cxx/ustl/current/ChangeLog
@@ -1,3 +1,11 @@
+2012-03-24  Sergei Gavrikov  <sergei.gavrikov@gmail.com>
+
+	* include/*:
+	* src/*:
+	* tests/*:
+	* HISTORY:
+	* LICENSE: Updated to uSTL 1.6 sources.
+
 2011-11-21  John Dallaway  <john@dallaway.org.uk>
 
 	* include/ustl/ustring.h: Fix incorrect behaviour of iat when passed
--- a/packages/language/cxx/ustl/current/HISTORY
+++ b/packages/language/cxx/ustl/current/HISTORY
@@ -1,3 +1,24 @@
+2012-02-18 Release 1.6
+	* Fixed compilation with c++0x
+	alignof is a keyword in c++0x, so the stream version usually not needed now.
+	On the other hand, alignof can not be overloaded, so stream_align_of is the
+	new name for the old alignof. Most code should not require changes due to this.
+	* Fix iat in string, which did not handle npos argument correctly, sometimes
+	resulting in failures of other functions using it, like substr.
+
+2011-03-16 Release 1.5
+	* Updated set, map, and multimap with full set of insert, erase, and search overloads
+	* Added public lower_bound, upper_bound, and equal_range to map, as per standard
+	* Added comparator parameter to set, multiset, map, and multimap.
+	* Implemented FirstBit, Rol, Ror, and a generic NextPow2
+	* Remove memlink copy because it conflicts with string copy
+	* Operators returning a new value should be const
+	* Added char* + string operator, and a noarg erase
+	* Added --force-inline configure option
+	* Removed all references to stdc++ headers when not using libstdc++
+	* Fixed minor glitches compiling with clang++
+	* Other small fixes
+
 2010-03-21 Release 1.4
 	* Fixed crash in destructor of empty vector, introduced by 1.3
 	* Fixed list merge, which previously did not compile
--- a/packages/language/cxx/ustl/current/LICENSE
+++ b/packages/language/cxx/ustl/current/LICENSE
@@ -1,7 +1,7 @@
 
 			The MIT License
 
-Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the "Software"),
--- a/packages/language/cxx/ustl/current/include/ustl.h
+++ b/packages/language/cxx/ustl/current/include/ustl.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef USTL_H_6A5A10410D2CD7FC2D78FE470F045EB7
--- a/packages/language/cxx/ustl/current/include/ustl/bktrace.h
+++ b/packages/language/cxx/ustl/current/include/ustl/bktrace.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2006-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2006 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef BKTRACE_H_63ABB1E4388CEDD975DBE58B57DE474F
@@ -47,6 +47,4 @@ private:
 
 } // namespace ustl
 
-ALIGNOF(ustl::CBacktrace, sizeof(void*))
-
 #endif
--- a/packages/language/cxx/ustl/current/include/ustl/cmemlink.h
+++ b/packages/language/cxx/ustl/current/include/ustl/cmemlink.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef CMEMLINK_H_7CFAB32C5C6732ED29B34EF00EA40A12
--- a/packages/language/cxx/ustl/current/include/ustl/fstream.h
+++ b/packages/language/cxx/ustl/current/include/ustl/fstream.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef FSTREAM_H_056E10F70EAD416443E3B36A2D6B5FA3
--- a/packages/language/cxx/ustl/current/include/ustl/memblock.h
+++ b/packages/language/cxx/ustl/current/include/ustl/memblock.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef MEMBLOCK_H_7ED63A891164CC43578E63664D52A196
--- a/packages/language/cxx/ustl/current/include/ustl/memlink.h
+++ b/packages/language/cxx/ustl/current/include/ustl/memlink.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef MEMLINK_H_798D25827C8E322D2D7E734B169FF5FC
@@ -64,9 +64,6 @@ public:
     inline void		link (void* first, void* last)		{ link (first, distance (first, last)); }
     inline void		relink (const void* p, size_type n)	{ cmemlink::relink (p, n); }
     inline void		relink (void* p, size_type n)		{ cmemlink::relink (p, n); }
-    inline void		copy (const cmemlink& l)		{ copy (begin(), l.cdata(), l.size()); }
-    inline void		copy (const void* p, size_type n)	{ copy (begin(), p, n); }
-    void		copy (iterator offset, const void* p, size_type n);
     inline void		swap (memlink& l)			{ cmemlink::swap (l); }
     void		fill (iterator start, const void* p, size_type elsize, size_type elCount = 1);
     inline void		insert (iterator start, size_type size);
--- a/packages/language/cxx/ustl/current/include/ustl/metamac.h
+++ b/packages/language/cxx/ustl/current/include/ustl/metamac.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 //
 /// \file metamac.h
--- a/packages/language/cxx/ustl/current/include/ustl/mistream.h
+++ b/packages/language/cxx/ustl/current/include/ustl/mistream.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef MISTREAM_H_103AEF1F266C04AA1A817D38705983DA
@@ -13,7 +13,7 @@
 #include "uios.h"
 #include "config.h"
 #if WANT_STREAM_BOUNDS_CHECKING
-    #include <typeinfo>
+    #include "typeinfo.h"
 #endif
 
 namespace ustl {
@@ -257,7 +257,7 @@ inline void istream::align (streamsize g
 template <typename T>
 inline void istream::iread (T& v)
 {
-    assert (aligned (alignof (v)));
+    assert (aligned (stream_align_of (v)));
 #if WANT_STREAM_BOUNDS_CHECKING
     if (!verify_remaining ("read", USTL_TYPENAME(v), sizeof(T)))
 	return;
--- a/packages/language/cxx/ustl/current/include/ustl/mostream.h
+++ b/packages/language/cxx/ustl/current/include/ustl/mostream.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef MOSTREAM_H_24A8C5397E0848216573E5670930FC9A
@@ -12,7 +12,7 @@
 #include "uios.h"
 #include "config.h"
 #if WANT_STREAM_BOUNDS_CHECKING
-    #include <typeinfo>
+    #include "typeinfo.h"
 #endif
 
 namespace ustl {
@@ -28,7 +28,7 @@ class string;
 /// This class contains a set of functions to write integral types into an
 /// unstructured memory block. Packing binary file data can be done this
 /// way, for instance. aligning the data is your responsibility, and can
-/// be accomplished by proper ordering of writes and by calling \ref ostream::align.
+/// be accomplished by proper ordering of writes and by calling align.
 /// Unaligned access is usually slower by orders of magnitude and,
 /// on some architectures, such as PowerPC, can cause your program to crash.
 /// Therefore, all write functions have asserts to check alignment.
@@ -253,7 +253,7 @@ inline void ostream::write (const cmemli
 template <typename T>
 inline void ostream::iwrite (const T& v)
 {
-    assert (aligned (alignof (v)));
+    assert (aligned (stream_align_of (v)));
 #if WANT_STREAM_BOUNDS_CHECKING
     if (!verify_remaining ("write", USTL_TYPENAME(v), sizeof(T)))
 	return;
--- a/packages/language/cxx/ustl/current/include/ustl/ofstream.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ofstream.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef FDOSTREAM_H_5E27FC3D530BF3CA04D6C73F5700EECC
--- a/packages/language/cxx/ustl/current/include/ustl/simd.h
+++ b/packages/language/cxx/ustl/current/include/ustl/simd.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 //
 /// \file simd.h
@@ -54,7 +54,7 @@ inline void packop (const Ctr& op1, cons
 {
     assert (op1.size() <= op2.size() && op1.size() <= result.size());
     passign (op1, result);
-    packop (op2, result);
+    op (op2, result);
 }
 
 /// Copies \p op1 into \p result.
--- a/packages/language/cxx/ustl/current/include/ustl/sistream.h
+++ b/packages/language/cxx/ustl/current/include/ustl/sistream.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef SISTREAM_H_0CCA102229A49F5D65EE852E62B27CE2
--- a/packages/language/cxx/ustl/current/include/ustl/sostream.h
+++ b/packages/language/cxx/ustl/current/include/ustl/sostream.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef SOSTREAM_H_5323DC8C26E181D43278F2F53FDCF19F
--- a/packages/language/cxx/ustl/current/include/ustl/strmsize.h
+++ b/packages/language/cxx/ustl/current/include/ustl/strmsize.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 //
 /// \file strmsize.h
@@ -28,6 +28,20 @@ inline streamsize stream_size_of (const 
     return (stream_sizer_t()(v));
 }
 
+/// \brief Returns the recommended stream alignment for type \p T. Override with ALIGNOF.
+/// Because this is occasionally called with a null value, do not access the argument!
+template <typename T>
+inline size_t stream_align_of (const T&)
+{
+    if (numeric_limits<T>::is_integral)
+	return (__alignof__(T));
+    return (4);
+}
+
+#define ALIGNOF(type,grain)	\
+namespace ustl {		\
+    template <> inline size_t stream_align_of (const type&) { return (grain); } }
+
 } // namespace ustl
 
 //
--- a/packages/language/cxx/ustl/current/include/ustl/traits.h
+++ b/packages/language/cxx/ustl/current/include/ustl/traits.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2007-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2007 by Mike Sharov <msharov@users.sourceforge.net>
 //
 // This implementation is adapted from the Loki library, distributed under
 // the MIT license with Copyright (c) 2001 by Andrei Alexandrescu.
new file mode 100644
--- /dev/null
+++ b/packages/language/cxx/ustl/current/include/ustl/typeinfo.h
@@ -0,0 +1,40 @@
+// This file is part of the uSTL library, an STL implementation.
+//
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
+// This file is free software, distributed under the MIT License.
+//
+#ifndef TYPEINFO_H_E67A267F0BBB5005
+#define TYPEINFO_H_E67A267F0BBB5005
+
+#ifndef WITHOUT_LIBSTDCPP
+    #include <typeinfo>
+#else
+
+#include "uexception.h"
+
+namespace __cxxabiv1 { class __class_type_info; }
+
+namespace std {
+class type_info {
+public:
+    inline virtual	~type_info (void)			{ }
+    inline const char*	name (void) const			{ return (__name[0] == '*' ? __name + 1 : __name); }
+    inline bool		before (const type_info& v) const	{ return (__name < v.__name); }
+    inline bool		operator==(const type_info& v) const	{ return (__name == v.__name); }
+    inline bool		operator!=(const type_info& v) const	{ return (!operator==(v)); }
+    virtual bool	__is_pointer_p (void) const;
+    virtual bool	__is_function_p (void) const;
+    virtual bool	__do_catch (const type_info* __thr_type, void** __thr_obj, unsigned __outer) const;
+    virtual bool	__do_upcast (const __cxxabiv1::__class_type_info* __target, void** __obj_ptr) const;
+    explicit inline	type_info (const char* newname)		: __name(newname) { }
+private:
+    inline void		operator= (const type_info&)		{ }
+    inline		type_info (const type_info&)		{ }
+protected:
+    const char*		__name;
+};
+
+} // namespace std
+
+#endif
+#endif
--- a/packages/language/cxx/ustl/current/include/ustl/typelist.h
+++ b/packages/language/cxx/ustl/current/include/ustl/typelist.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2007-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2007 by Mike Sharov <msharov@users.sourceforge.net>
 //
 // This implementation is adapted from the Loki library, distributed under
 // the MIT license with Copyright (c) 2001 by Andrei Alexandrescu.
--- a/packages/language/cxx/ustl/current/include/ustl/typet.h
+++ b/packages/language/cxx/ustl/current/include/ustl/typet.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2007-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2007 by Mike Sharov <msharov@users.sourceforge.net>
 //
 // This implementation is adapted from the Loki library, distributed under
 // the MIT license with Copyright (c) 2001 by Andrei Alexandrescu.
@@ -38,7 +38,8 @@ struct IsSameType<T,T> { enum { value = 
 /// Conversion<T,U>::exists2Way is true if U is also convertible to T
 /// Conversion<T,U>::sameType is true if U is T
 template <typename T, typename U>
-class Conversion {
+struct Conversion {
+private:
     typedef char UT;
     typedef short TT;
     static UT Test (U);
--- a/packages/language/cxx/ustl/current/include/ustl/ualgo.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ualgo.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UALGO_H_711AB4214D417A51166694D47A662D6E
@@ -9,7 +9,6 @@
 #include "upair.h"
 #include "ualgobase.h"
 #include "ufunction.h"
-#include "upredalgo.h"
 #include "umemory.h"
 #include <stdlib.h>	// for rand()
 
--- a/packages/language/cxx/ustl/current/include/ustl/ualgobase.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ualgobase.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UALGOBASE_H_683A0BE77546133C4CE0E3622CFAA2EB
@@ -258,7 +258,7 @@ COPY_BACKWARD_ALIAS_FUNC(const void, voi
 #undef COPY_BACKWARD_ALIAS_FUNC
 #define FILL_ALIAS_FUNC(type, alias_type, v_type)				\
 template <> inline void fill (type* first, type* last, const v_type& value)	\
-{ fill ((alias_type*) first, (alias_type*) last, (const alias_type&) value); }
+{ fill ((alias_type*) first, (alias_type*) last, (const alias_type) value); }
 FILL_ALIAS_FUNC(void, uint8_t, char)
 FILL_ALIAS_FUNC(void, uint8_t, uint8_t)
 #if WANT_UNROLLED_COPY
@@ -298,7 +298,7 @@ COPY_N_ALIAS_FUNC(const int32_t, int32_t
 #undef COPY_N_ALIAS_FUNC
 #define FILL_N_ALIAS_FUNC(type, alias_type, v_type)				\
 template <> inline type* fill_n (type* first, size_t n, const v_type& value)	\
-{ return ((type*) fill_n ((alias_type*) first, n, (const alias_type&) value)); }
+{ return ((type*) fill_n ((alias_type*) first, n, (const alias_type) value)); }
 FILL_N_ALIAS_FUNC(void, uint8_t, char)
 FILL_N_ALIAS_FUNC(void, uint8_t, uint8_t)
 #if WANT_UNROLLED_COPY
--- a/packages/language/cxx/ustl/current/include/ustl/ubitset.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ubitset.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UBITSET_H_7B6450EC1400CBA45DCE0127739F82EE
@@ -38,6 +38,7 @@ public:
     typedef const_pointer	const_iterator;
     typedef size_t		difference_type;
     typedef size_t		size_type;
+    typedef const bitset<Size>&	rcself_t;
 private:
     static const size_t s_WordBits	= BitsInType (value_type);
     static const size_t	s_nWords	= Size / s_WordBits + ((Size % s_WordBits) != 0);
@@ -102,19 +103,19 @@ public:
     inline bool		any (void) const	{ value_type sum = 0; foreach (const_iterator, i, *this) sum |= *i; return (sum); }
     inline bool		none (void) const	{ return (!any()); }
     inline size_t	count (void) const	{ size_t sum = 0; foreach (const_iterator, i, *this) sum += popcount(*i); return (sum); }
-    inline bool		operator== (const bitset<Size>& v) const
+    inline bool		operator== (rcself_t v) const
 			    { return (s_nWords == 1 ? (m_Bits[0] == v.m_Bits[0]) : equal (begin(), end(), v.begin())); }
-    inline const bitset	operator& (const bitset<Size>& v)
+    inline bitset	operator& (rcself_t v) const
 			    { bitset<Size> result; transform (begin(), end(), v.begin(), result.begin(), bitwise_and<value_type>()); return (result); }
-    inline const bitset	operator| (const bitset<Size>& v)
+    inline bitset	operator| (rcself_t v) const
 			    { bitset<Size> result; transform (begin(), end(), v.begin(), result.begin(), bitwise_or<value_type>()); return (result); }
-    inline const bitset	operator^ (const bitset<Size>& v)
+    inline bitset	operator^ (rcself_t v) const
 			    { bitset<Size> result; transform (begin(), end(), v.begin(), result.begin(), bitwise_xor<value_type>()); return (result); }
-   inline const bitset&	operator&= (const bitset<Size>& v)
+    inline rcself_t	operator&= (rcself_t v)
 			    { transform (begin(), end(), v.begin(), begin(), bitwise_and<value_type>()); return (*this); }
-   inline const bitset&	operator|= (const bitset<Size>& v)
+    inline rcself_t	operator|= (rcself_t v)
 			    { transform (begin(), end(), v.begin(), begin(), bitwise_or<value_type>()); return (*this); }
-   inline const bitset&	operator^= (const bitset<Size>& v)
+    inline rcself_t	operator^= (rcself_t v)
 			    { transform (begin(), end(), v.begin(), begin(), bitwise_xor<value_type>()); return (*this); }
     inline void		read (istream& is)			{ nr_container_read (is, *this); }
     inline void		write (ostream& os) const		{ nr_container_write (os, *this); }
--- a/packages/language/cxx/ustl/current/include/ustl/uctralgo.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uctralgo.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UCTRALGO_H_0D1AEDFA74B09791489FE25B1EC644B0
--- a/packages/language/cxx/ustl/current/include/ustl/uctrstrm.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uctrstrm.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 //
 /// \file uctrstrm.h
@@ -16,7 +16,7 @@
 #include "mistream.h"
 #include "sostream.h"
 #include "uiosfunc.h"
-#include <typeinfo>
+#include "typeinfo.h"
 
 namespace ustl {
 
@@ -119,7 +119,7 @@ istream& container_read (istream& is, Co
     const size_t expectedSize = n * stream_size_of(value_type());
     if (!is.verify_remaining ("read", USTL_TYPENAME(v), expectedSize))
 	return (is);
-    if (alignof(NullValue<value_type>()) > alignof(n))
+    if (stream_align_of(NullValue<value_type>()) > stream_align_of(n))
 	is >> ios::talign<value_type>();
     v.resize (n);
     nr_container_read (is, v);
@@ -135,7 +135,7 @@ ostream& container_write (ostream& os, c
     typedef typename Container::written_size_type written_size_type;
     const written_size_type sz (v.size());
     os << sz;
-    if (alignof(NullValue<value_type>()) > alignof(sz))
+    if (stream_align_of(NullValue<value_type>()) > stream_align_of(sz))
 	os << ios::talign<value_type>();
     nr_container_write (os, v);
     os << ios::talign<written_size_type>();
@@ -150,9 +150,9 @@ size_t container_stream_size (const Cont
     typedef typename Container::written_size_type written_size_type;
     const written_size_type sz (v.size());
     size_t sizeSize = stream_size_of (sz);
-    if (alignof(NullValue<value_type>()) > alignof(sz))
-	sizeSize = Align (sizeSize, alignof(NullValue<value_type>()));
-    return (Align (sizeSize + nr_container_stream_size (v), alignof(sz)));
+    if (stream_align_of(NullValue<value_type>()) > stream_align_of(sz))
+	sizeSize = Align (sizeSize, stream_align_of(NullValue<value_type>()));
+    return (Align (sizeSize + nr_container_stream_size (v), stream_align_of(sz)));
 }
 
 /// \brief Writes element \p v into stream \p os as text.
--- a/packages/language/cxx/ustl/current/include/ustl/uexception.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uexception.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UEXCEPTION_H_18DE3EF55C4F00673268F0D66546AF5D
@@ -23,7 +23,7 @@ typedef void (*unexpected_handler) (void
 terminate_handler set_terminate (terminate_handler pHandler) throw();
 /// The runtime will call this function if exception handling must be
 /// abandoned for any reason.  It can also be called by the user.
-void terminate (void) __attribute__ ((__noreturn__));
+void terminate (void) throw() __attribute__ ((__noreturn__));
 /// Takes a new handler function as an argument, returns the old function.
 unexpected_handler set_unexpected (unexpected_handler pHandler) throw();
 /// The runtime will call this function if an exception is thrown which
@@ -88,8 +88,14 @@ private:
 ///
 class bad_cast : public exception {
 public:
-    inline explicit		bad_cast (void) throw() : exception() {}
-    inline virtual const char*	what (void) const throw() { return ("bad cast"); }
+    inline 			bad_cast (void) throw()		: exception() {}
+    inline virtual const char*	what (void) const throw()	{ return ("bad cast"); }
+};
+
+class bad_typeid : public exception {
+public:
+    inline			bad_typeid (void) throw()	{ }
+    inline virtual const char*	what (void) const throw()	{ return ("bad typeid"); }
 };
 
 //----------------------------------------------------------------------
--- a/packages/language/cxx/ustl/current/include/ustl/ufunction.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ufunction.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UFUNCTION_H_221ABA8551801799263C927234C085F3
--- a/packages/language/cxx/ustl/current/include/ustl/uheap.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uheap.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UHEAP_H_574B9EAF271A1C107190B4D575A356C5
--- a/packages/language/cxx/ustl/current/include/ustl/uios.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uios.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UIOS_H_630C16E316F7650E3A02E1C6611B789A
@@ -85,7 +85,7 @@ public:
     inline bool		fail (void) const		{ return (rdstate() & (badbit | failbit)); }
     inline bool		eof (void) const		{ return (rdstate() & eofbit); }
     inline bool		operator! (void) const		{ return (fail()); }
-    inline		operator void* (void) const	{ return (reinterpret_cast<void*>(!fail())); }
+    inline		operator void* (void) const	{ return ((void*)(!fail())); }
     inline void		clear (iostate v = goodbit)	{ m_State = v; }
     inline void		setstate (iostate v)		{ m_State |= v; }
     inline iostate	exceptions (void) const		{ return (m_Exceptions); }
--- a/packages/language/cxx/ustl/current/include/ustl/uiosfunc.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uiosfunc.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UIOSFUNC_H_730C16E316F7650E3A02E1C6611B789A
@@ -36,7 +36,7 @@ public:
     template <typename T>
     class talign : public align {
     public:
-	inline explicit		talign (void) : align (alignof (NullValue<T>())) {}
+	inline explicit		talign (void) : align (stream_align_of (NullValue<T>())) {}
     };
 
     /// \class skip uiosfunc.h ustl.h
--- a/packages/language/cxx/ustl/current/include/ustl/uiterator.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uiterator.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 //
 /// \file uiterator.h
@@ -125,7 +125,7 @@ public:
     				    { m_ip = m_rCtr.insert (m_ip, v); return (*this); }
     inline insert_iterator&	operator* (void)  { return (*this); }
     inline insert_iterator&	operator++ (void) { ++ m_ip; return (*this); }
-    inline insert_iterator	operator++ (int)  { insert_iterator prev (*this); ++ m_ip; return (*this); }
+    inline insert_iterator	operator++ (int)  { insert_iterator prev (*this); ++m_ip; return (prev); }
 protected:
     Container&			m_rCtr;
     iterator			m_ip;
--- a/packages/language/cxx/ustl/current/include/ustl/ulaalgo.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ulaalgo.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef ULAALGO_H_2E403D182E83FB596AFB800E68B255A1
@@ -204,8 +204,7 @@ static tuple<4,float> operator* (const t
 #else	// If no processor extensions, just unroll the multiplication
 
 /// Specialization for 4-component vector transform, the slow part of 3D graphics.
-template <>
-static tuple<4,float> operator* (const tuple<4,float>& t, const matrix<4,4,float>& m)
+template <> inline tuple<4,float> operator* (const tuple<4,float>& t, const matrix<4,4,float>& m)
 {
     tuple<4,float> tr;
     for (uoff_t i = 0; i < 4; ++ i)
--- a/packages/language/cxx/ustl/current/include/ustl/ulimits.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ulimits.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef ULIMITS_H_1C2192EA3821E0811BBAF86B0F048364
@@ -85,20 +85,6 @@ struct numeric_limits<type> {					\
 #define NUMERIC_LIMITS(type, minVal, maxVal, bSigned, bInteger, bIntegral)	\
 namespace ustl { _NUMERIC_LIMITS (type, minVal, maxVal, bSigned, bInteger, bIntegral); }
 
-/// \brief Returns the recommended stream alignment for type \p T. Override with ALIGNOF.
-/// Because this is occasionally called with a null value, do not access the argument!
-template <typename T>
-inline size_t alignof (const T&)
-{
-    if (numeric_limits<T>::is_integral)
-	return (__alignof__(T));
-    return (4);
-}
-
-#define ALIGNOF(type,grain)	\
-namespace ustl {		\
-    template <> inline size_t alignof (const type&) { return (grain); } }
-
 } // namespace ustl
 
 #endif
--- a/packages/language/cxx/ustl/current/include/ustl/ulist.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ulist.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef ULIST_H_54E3B510498982C87A0A1E1932E6729D
--- a/packages/language/cxx/ustl/current/include/ustl/umap.h
+++ b/packages/language/cxx/ustl/current/include/ustl/umap.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UMAP_H_45643F516E02A87A3DCEA5024052A6F5
@@ -16,14 +16,14 @@ namespace ustl {
 ///
 /// \brief A sorted associative container of pair<K,V>
 ///
-template <typename K, typename V>
+template <typename K, typename V, typename Comp = less<K> >
 class map : public vector<pair<K,V> > {
 public:
     typedef K						key_type;
     typedef V						data_type;
     typedef const K&					const_key_ref;
     typedef const V&					const_data_ref;
-    typedef const map<K,V>&				rcself_t;
+    typedef const map<K,V,Comp>&			rcself_t;
     typedef vector<pair<K,V> >				base_class;
     typedef typename base_class::value_type		value_type;
     typedef typename base_class::size_type		size_type;
@@ -39,10 +39,10 @@ public:
     typedef pair<iterator,iterator>			range_t;
     typedef pair<iterator,bool>				insertrv_t;
 public:
-    inline			map (void)			: vector<pair<K,V> > () {}
-    explicit inline		map (size_type n)		: vector<pair<K,V> > (n) {}
-    inline			map (rcself_t v)		: vector<pair<K,V> > (v) {}
-    inline			map (const_iterator i1, const_iterator i2) : vector<pair<K,V> >() { insert (i1, i2); }
+    inline			map (void)			: base_class() {}
+    explicit inline		map (size_type n)		: base_class (n) {}
+    inline			map (rcself_t v)		: base_class (v) {}
+    inline			map (const_iterator i1, const_iterator i2) : base_class() { insert (i1, i2); }
     inline rcself_t		operator= (rcself_t v)		{ base_class::operator= (v); return (*this); }
     inline const_data_ref	operator[] (const_key_ref i) const;
     data_type&			operator[] (const_key_ref i);
@@ -56,25 +56,29 @@ public:
     inline const_iterator	find (const_key_ref k) const;
     inline iterator		find (const_key_ref k)	{ return (const_cast<iterator> (const_cast<rcself_t>(*this).find (k))); }
     inline const_iterator	find_data (const_data_ref v, const_iterator first = NULL, const_iterator last = NULL) const;
-    inline iterator		find_data (const_data_ref v, iterator first = NULL, iterator last = NULL);
+    inline iterator		find_data (const_data_ref v, iterator first = NULL, iterator last = NULL)	{ return (const_cast<iterator> (find_data (v, const_cast<const_iterator>(first), const_cast<const_iterator>(last)))); }
     insertrv_t			insert (const_reference v);
+    inline iterator		insert (iterator, const_reference v)	{ return (insert(v).first); }
     void			insert (const_iterator i1, const_iterator i2);
     inline void			erase (const_key_ref k);
     inline iterator		erase (iterator ep)	{ return (base_class::erase (ep)); }
     inline iterator		erase (iterator ep1, iterator ep2) { return (base_class::erase (ep1, ep2)); }
     inline void			clear (void)		{ base_class::clear(); }
-private:
     const_iterator		lower_bound (const_key_ref k) const;
     inline iterator		lower_bound (const_key_ref k) { return (const_cast<iterator>(const_cast<rcself_t>(*this).lower_bound (k))); }
+    const_iterator		upper_bound (const_key_ref k) const;
+    inline iterator		upper_bound (const_key_ref k) { return (const_cast<iterator>(const_cast<rcself_t>(*this).upper_bound (k))); }
+    const_range_t		equal_range (const_key_ref k) const;
+    inline range_t		equal_range (const_key_ref k) { return (const_cast<const_range_t>(const_cast<rcself_t>(*this).equal_range (k))); }
 };
 
-template <typename K, typename V>
-typename map<K,V>::const_iterator map<K,V>::lower_bound (const_key_ref k) const
+template <typename K, typename V, typename Comp>
+typename map<K,V,Comp>::const_iterator map<K,V,Comp>::lower_bound (const_key_ref k) const
 {
     const_iterator first (begin()), last (end());
     while (first != last) {
 	const_iterator mid = advance (first, distance (first,last) / 2);
-	if (mid->first < k)
+	if (Comp()(mid->first, k))
 	    first = advance (mid, 1);
 	else
 	    last = mid;
@@ -82,17 +86,41 @@ typename map<K,V>::const_iterator map<K,
     return (first);
 }
 
+template <typename K, typename V, typename Comp>
+typename map<K,V,Comp>::const_iterator map<K,V,Comp>::upper_bound (const_key_ref k) const
+{
+    const_iterator first (begin()), last (end());
+    while (first != last) {
+	const_iterator mid = advance (first, distance (first,last) / 2);
+	if (Comp()(k, mid->first))
+	    last = mid;
+	else
+	    first = mid + 1;
+    }
+    return (last);
+}
+
+template <typename K, typename V, typename Comp>
+typename map<K,V,Comp>::const_range_t map<K,V,Comp>::equal_range (const_key_ref k) const
+{
+    const_range_t rv;
+    rv.second = rv.first = lower_bound (k);
+    while (rv.second != end() && !Comp()(k, rv.second->first))
+	++rv.second;
+    return (rv);
+}
+
 /// Returns the pair<K,V> where K = \p k.
-template <typename K, typename V>
-inline typename map<K,V>::const_iterator map<K,V>::find (const_key_ref k) const
+template <typename K, typename V, typename Comp>
+inline typename map<K,V,Comp>::const_iterator map<K,V,Comp>::find (const_key_ref k) const
 {
     const_iterator i = lower_bound (k);
-    return ((i < end() && k < i->first) ? end() : i);
+    return ((i < end() && Comp()(k,i->first)) ? end() : i);
 }
 
 /// Returns the pair<K,V> where V = \p v, occuring in range [first,last).
-template <typename K, typename V>
-inline typename map<K,V>::const_iterator map<K,V>::find_data (const_data_ref v, const_iterator first, const_iterator last) const
+template <typename K, typename V, typename Comp>
+inline typename map<K,V,Comp>::const_iterator map<K,V,Comp>::find_data (const_data_ref v, const_iterator first, const_iterator last) const
 {
     if (!first) first = begin();
     if (!last) last = end();
@@ -100,55 +128,48 @@ inline typename map<K,V>::const_iterator
     return (first);
 }
 
-/// Returns the pair<K,V> where V = \p v, occuring in range [first,last).
-template <typename K, typename V>
-inline typename map<K,V>::iterator map<K,V>::find_data (const_data_ref v, iterator first, iterator last)
-{
-    return (const_cast<iterator> (find_data (v, const_cast<const_iterator>(first), const_cast<const_iterator>(last))));
-}
-
 /// Returns data associated with key \p k.
-template <typename K, typename V>
-inline const typename map<K,V>::data_type& map<K,V>::operator[] (const_key_ref k) const
+template <typename K, typename V, typename Comp>
+inline const typename map<K,V,Comp>::data_type& map<K,V,Comp>::operator[] (const_key_ref k) const
 {
     assert (find(k) != end() && "operator[] const can not insert non-existent keys");
     return (find(k)->second);
 }
 
 /// Returns data associated with key \p k.
-template <typename K, typename V>
-typename map<K,V>::data_type& map<K,V>::operator[] (const_key_ref k)
+template <typename K, typename V, typename Comp>
+typename map<K,V,Comp>::data_type& map<K,V,Comp>::operator[] (const_key_ref k)
 {
     iterator ip = lower_bound (k);
-    if (ip == end() || k < ip->first)
+    if (ip == end() || Comp()(k,ip->first))
 	ip = base_class::insert (ip, make_pair (k, V()));
     return (ip->second);
 }
 
 /// Inserts the pair into the container.
-template <typename K, typename V>
-typename map<K,V>::insertrv_t map<K,V>::insert (const_reference v)
+template <typename K, typename V, typename Comp>
+typename map<K,V,Comp>::insertrv_t map<K,V,Comp>::insert (const_reference v)
 {
     iterator ip = lower_bound (v.first);
-    bool bInserted = ip == end() || v.first < ip->first;
+    bool bInserted = ip == end() || Comp()(v.first, ip->first);
     if (bInserted)
 	ip = base_class::insert (ip, v);
     return (make_pair (ip, bInserted));
 }
 
 /// Inserts elements from range [i1,i2) into the container.
-template <typename K, typename V>
-void map<K,V>::insert (const_iterator i1, const_iterator i2)
+template <typename K, typename V, typename Comp>
+void map<K,V,Comp>::insert (const_iterator i1, const_iterator i2)
 {
     assert (i1 <= i2);
-    reserve (size() + distance (i1, i2));
+    base_class::reserve (size() + distance (i1, i2));
     for (; i1 != i2; ++i1)
 	insert (*i1);
 }
 
 /// Erases the element with key value \p k.
-template <typename K, typename V>
-inline void map<K,V>::erase (const_key_ref k)
+template <typename K, typename V, typename Comp>
+inline void map<K,V,Comp>::erase (const_key_ref k)
 {
     iterator ip = find (k);
     if (ip != end())
--- a/packages/language/cxx/ustl/current/include/ustl/umatrix.h
+++ b/packages/language/cxx/ustl/current/include/ustl/umatrix.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UMATRIX_H_740EBFEF554E833645E0FD72419A8185
--- a/packages/language/cxx/ustl/current/include/ustl/umemory.h
+++ b/packages/language/cxx/ustl/current/include/ustl/umemory.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UMEMORY_H_4AB5B0DB5BF09140541409CC47BCD17A
--- a/packages/language/cxx/ustl/current/include/ustl/umultimap.h
+++ b/packages/language/cxx/ustl/current/include/ustl/umultimap.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UMULTIMAP_H_45743F516E02A87A3FCEA5024052A6F5
@@ -16,20 +16,20 @@ namespace ustl {
 ///
 /// \brief A sorted associative container that may container multiple entries for each key.
 ///
-template <typename K, typename V>
+template <typename K, typename V, typename Comp = less<K> >
 class multimap : public vector<pair<K,V> > {
 public:
     typedef K						key_type;
     typedef V						data_type;
     typedef const K&					const_key_ref;
     typedef const V&					const_data_ref;
-    typedef const multimap<K,V>&			rcself_t;
+    typedef const multimap<K,V,Comp>&			rcself_t;
     typedef vector<pair<K,V> >				base_class;
-    typedef typename base_class::value_type	value_type;
-    typedef typename base_class::size_type	size_type;
-    typedef typename base_class::pointer	pointer;
-    typedef typename base_class::const_pointer	const_pointer;
-    typedef typename base_class::reference	reference;
+    typedef typename base_class::value_type		value_type;
+    typedef typename base_class::size_type		size_type;
+    typedef typename base_class::pointer		pointer;
+    typedef typename base_class::const_pointer		const_pointer;
+    typedef typename base_class::reference		reference;
     typedef typename base_class::const_reference	const_reference;
     typedef typename base_class::const_iterator		const_iterator;
     typedef typename base_class::iterator		iterator;
@@ -38,10 +38,10 @@ public:
     typedef pair<const_iterator,const_iterator>		const_range_t;
     typedef pair<iterator,iterator>			range_t;
 public:
-    inline			multimap (void)		: vector<pair<K,V> > () {} 
-    explicit inline		multimap (size_type n)	: vector<pair<K,V> > (n) {} 
-    inline			multimap (rcself_t v)	: vector<pair<K,V> > (v) {} 
-    inline			multimap (const_iterator i1, const_iterator i2)	: vector<pair<K,V> > () { insert (i1, i2); } 
+    inline			multimap (void)		: base_class() {}
+    explicit inline		multimap (size_type n)	: base_class (n) {}
+    inline			multimap (rcself_t v)	: base_class (v) {}
+    inline			multimap (const_iterator i1, const_iterator i2)	: base_class() { insert (i1, i2); }
     inline rcself_t		operator= (rcself_t v)	{ base_class::operator= (v); return (*this); }
     inline size_type		size (void) const	{ return (base_class::size()); }
     inline iterator		begin (void)		{ return (base_class::begin()); }
@@ -51,11 +51,15 @@ public:
     inline void			assign (const_iterator i1, const_iterator i2) { clear(); insert (i1, i2); }
     inline size_type		count (const_key_ref k) const		{ return (upper_bound(k) - lower_bound(k)); }
     inline void			push_back (const_reference v)		{ insert (v); }
+    inline const_iterator	find (const_key_ref k) const;
+    inline iterator		find (const_key_ref k)			{ return (const_cast<iterator> (const_cast<rcself_t>(*this).find (k))); }
     inline const_range_t	equal_range (const_key_ref k) const	{ return (make_pair (lower_bound(k), upper_bound(k))); }
     inline range_t		equal_range (const_key_ref k)		{ return (make_pair (const_cast<iterator>(lower_bound(k)), const_cast<iterator>(upper_bound(k)))); }
     const_iterator		lower_bound (const_key_ref k) const;
+    inline iterator		lower_bound (const_key_ref k)		{ return (const_cast<iterator> (const_cast<rcself_t>(*this).lower_bound (k))); }
     const_iterator		upper_bound (const_key_ref k) const;
-    inline iterator		insert (const_reference v);
+    inline iterator		upper_bound (const_key_ref k)		{ return (const_cast<iterator> (const_cast<rcself_t>(*this).upper_bound (k))); }
+    inline iterator		insert (const_reference v)		{ return (base_class::insert (upper_bound (v.first), v)); }
     void			insert (const_iterator i1, const_iterator i2);
     inline void			erase (const_key_ref k)			{ erase (const_cast<iterator>(lower_bound(k)), const_cast<iterator>(upper_bound(k))); }
     inline iterator		erase (iterator ep)			{ return (base_class::erase (ep)); } 
@@ -64,13 +68,13 @@ public:
 };
 
 /// Returns an iterator to the first element with key value \p k.
-template <typename K, typename V>
-typename multimap<K,V>::const_iterator multimap<K,V>::lower_bound (const_key_ref k) const
+template <typename K, typename V, typename Comp>
+typename multimap<K,V,Comp>::const_iterator multimap<K,V,Comp>::lower_bound (const_key_ref k) const
 {
     const_iterator first (begin()), last (end());
     while (first != last) {
 	const_iterator mid = advance (first, distance (first,last) / 2);
-	if (mid->first < k)
+	if (Comp()(mid->first, k))
 	    first = advance (mid, 1);
 	else
 	    last = mid;
@@ -79,13 +83,13 @@ typename multimap<K,V>::const_iterator m
 }
 
 /// Returns an iterator to the first element with key value \p k.
-template <typename K, typename V>
-typename multimap<K,V>::const_iterator multimap<K,V>::upper_bound (const_key_ref k) const
+template <typename K, typename V, typename Comp>
+typename multimap<K,V,Comp>::const_iterator multimap<K,V,Comp>::upper_bound (const_key_ref k) const
 {
     const_iterator first (begin()), last (end());
     while (first != last) {
 	const_iterator mid = advance (first, distance (first,last) / 2);
-	if (k < mid->first)
+	if (Comp()(k, mid->first))
 	    last = mid;
 	else
 	    first = advance (mid, 1);
@@ -93,20 +97,20 @@ typename multimap<K,V>::const_iterator m
     return (last);
 }
 
-/// Inserts the pair into the container.
-template <typename K, typename V>
-inline typename multimap<K,V>::iterator multimap<K,V>::insert (const_reference v)
+/// Returns the pair<K,V> where K = \p k.
+template <typename K, typename V, typename Comp>
+inline typename multimap<K,V,Comp>::const_iterator multimap<K,V,Comp>::find (const_key_ref k) const
 {
-    iterator ip = const_cast<iterator> (upper_bound (v.first));
-    return (base_class::insert (ip, v));
+    const_iterator i = lower_bound (k);
+    return ((i < end() && Comp()(k, i->first)) ? end() : i);
 }
 
 /// Inserts elements from range [i1,i2) into the container.
-template <typename K, typename V>
-void multimap<K,V>::insert (const_iterator i1, const_iterator i2)
+template <typename K, typename V, typename Comp>
+void multimap<K,V,Comp>::insert (const_iterator i1, const_iterator i2)
 {
     assert (i1 <= i2);
-    reserve (size() + distance (i1, i2));
+    base_class::reserve (size() + distance (i1, i2));
     for (; i1 != i2; ++i1)
 	insert (*i1);
 }
--- a/packages/language/cxx/ustl/current/include/ustl/umultiset.h
+++ b/packages/language/cxx/ustl/current/include/ustl/umultiset.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UMULTISET_H_446AEDBB7F61C6994DC228C25D5FA3A1
@@ -17,10 +17,10 @@ namespace ustl {
 /// \brief Multiple sorted container.
 /// Unlike set, it may contain multiple copies of each element.
 ///
-template <typename T>
+template <typename T, typename Comp = less<T> >
 class multiset : public vector<T> {
 public:
-    typedef const multiset<T>&				rcself_t;
+    typedef const multiset<T,Comp>&			rcself_t;
     typedef vector<T>					base_class;
     typedef typename base_class::value_type		value_type;
     typedef typename base_class::size_type		size_type;
@@ -33,17 +33,17 @@ public:
     typedef typename base_class::reverse_iterator	reverse_iterator;
     typedef typename base_class::const_reverse_iterator	const_reverse_iterator;
 public:
-    inline			multiset (void)		: vector<T> () {}
-    explicit inline		multiset (size_type n)	: vector<T> (n) {}
-    inline			multiset (rcself_t v)	: vector<T> (v) {} 
-    inline			multiset (const_iterator i1, const_iterator i2) : vector<T> () { insert (i1, i2); }
+    inline			multiset (void)		: base_class() {}
+    explicit inline		multiset (size_type n)	: base_class (n) {}
+    inline			multiset (rcself_t v)	: base_class (v) {}
+    inline			multiset (const_iterator i1, const_iterator i2) : base_class() { insert (i1, i2); }
     inline rcself_t		operator= (rcself_t v)	{ base_class::operator= (v); return (*this); }
     inline size_type		size (void) const	{ return (base_class::size()); }
     inline iterator		begin (void)		{ return (base_class::begin()); }
     inline const_iterator	begin (void) const	{ return (base_class::begin()); }
     inline iterator		end (void)		{ return (base_class::end()); }
     inline const_iterator	end (void) const	{ return (base_class::end()); }
-    inline void			assign (const_iterator i1, const_iterator i2);
+    inline void			assign (const_iterator i1, const_iterator i2)	{ clear(); insert (i1, i2); }
     size_type			count (const_reference v) const;
     inline void			push_back (const_reference v)	{ insert (v); }
     inline iterator		insert (const_reference v);
@@ -54,45 +54,37 @@ public:
     inline void			clear (void)		{ base_class::clear(); }
 };
 
-/// Copies contents of range [i1,i2)
-template <typename T>
-inline void multiset<T>::assign (const_iterator i1, const_iterator i2)
+/// Returns the number of elements of value \p v.
+template <typename T, typename Comp>
+typename multiset<T,Comp>::size_type multiset<T,Comp>::count (const_reference v) const
 {
-    base_class::clear();
-    insert (i1, i2);
-}
-
-/// Returns the number of elements of value \p v.
-template <typename T>
-typename multiset<T>::size_type multiset<T>::count (const_reference v) const
-{
-    const pair<const_iterator,const_iterator> fr = equal_range (begin(), end(), v);
+    const pair<const_iterator,const_iterator> fr = equal_range (begin(), end(), v, Comp());
     return (distance (fr.first, fr.second));
 }
 
 /// Inserts \p v.
-template <typename T>
-inline typename multiset<T>::iterator multiset<T>::insert (const_reference v)
+template <typename T, typename Comp>
+inline typename multiset<T,Comp>::iterator multiset<T,Comp>::insert (const_reference v)
 {
-    iterator ip = upper_bound (begin(), end(), v);
+    iterator ip = upper_bound (begin(), end(), v, Comp());
     return (base_class::insert (ip, v));
 }
 
 /// Inserts all elements from range [i1,i2).
-template <typename T>
-void multiset<T>::insert (const_iterator i1, const_iterator i2)
+template <typename T, typename Comp>
+void multiset<T,Comp>::insert (const_iterator i1, const_iterator i2)
 {
     assert (i1 <= i2);
-    reserve (size() + distance (i1, i2));
+    base_class::reserve (size() + distance (i1, i2));
     for (; i1 < i2; ++i1)
 	push_back (*i1);
 }
 
 /// Erases all elements with value \p v.
-template <typename T>
-void multiset<T>::erase (const_reference v)
+template <typename T, typename Comp>
+void multiset<T,Comp>::erase (const_reference v)
 {
-    pair<iterator,iterator> epr = equal_range (begin(), end(), v);
+    pair<iterator,iterator> epr = equal_range (begin(), end(), v, Comp());
     erase (epr.first, epr.second);
 }
 
--- a/packages/language/cxx/ustl/current/include/ustl/unew.h
+++ b/packages/language/cxx/ustl/current/include/ustl/unew.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UNEW_H_11D237512B324C9C05A55DAF1BF086F1
--- a/packages/language/cxx/ustl/current/include/ustl/unumeric.h
+++ b/packages/language/cxx/ustl/current/include/ustl/unumeric.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UNUMERIC_H_6C99D6F6363832C644A6FFF336E84E18
--- a/packages/language/cxx/ustl/current/include/ustl/upair.h
+++ b/packages/language/cxx/ustl/current/include/ustl/upair.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UPAIR_H_7DC08F1B7FECF8AE6856D84C3B617A75
--- a/packages/language/cxx/ustl/current/include/ustl/upredalgo.h
+++ b/packages/language/cxx/ustl/current/include/ustl/upredalgo.h
@@ -1,11 +1,13 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UPREDALGO_H_2CB058AE0807A01A2F6A51BA5D5820A5
 #define UPREDALGO_H_2CB058AE0807A01A2F6A51BA5D5820A5
 
+#include "ualgo.h"
+
 namespace ustl {
 
 /// Copy_if copies elements from the range [first, last) to the range
--- a/packages/language/cxx/ustl/current/include/ustl/uqueue.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uqueue.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UQUEUE_H_27F01FDB0D59B75277E0E5C41ABC6B5B
--- a/packages/language/cxx/ustl/current/include/ustl/uset.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uset.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef USET_H_45543F516E02A87A3FCEA5024052A6F5
@@ -15,29 +15,29 @@ namespace ustl {
 ///
 /// \brief Unique sorted container. Sorted vector with all values unique.
 ///
-template <typename T>
+template <typename T, typename Comp = less<T> >
 class set : public vector<T> {
 public:
-    typedef const set<T>&			rcself_t;
-    typedef vector<T>				base_class;
+    typedef const set<T,Comp>&				rcself_t;
+    typedef vector<T>					base_class;
     typedef typename base_class::value_type		key_type;
     typedef typename base_class::value_type		data_type;
     typedef typename base_class::value_type		value_type;
     typedef typename base_class::size_type		size_type;
-    typedef typename base_class::pointer			pointer;
+    typedef typename base_class::pointer		pointer;
     typedef typename base_class::const_pointer		const_pointer;
     typedef typename base_class::reference		reference;
-    typedef typename base_class::const_reference		const_reference;
+    typedef typename base_class::const_reference	const_reference;
     typedef typename base_class::const_iterator		const_iterator;
     typedef typename base_class::iterator		iterator;
     typedef typename base_class::reverse_iterator	reverse_iterator;
     typedef typename base_class::const_reverse_iterator	const_reverse_iterator;
     typedef pair<iterator,bool>				insertrv_t;
 public:
-    inline			set (void)		: vector<T> () { }
-    explicit inline		set (size_type n)	: vector<T> (n) { }
-    inline			set (rcself_t v)	: vector<T> (v) { } 
-    inline			set (const_iterator i1, const_iterator i2) : vector<T> () { insert (i1, i2); }
+    inline			set (void)		: base_class() { }
+    explicit inline		set (size_type n)	: base_class (n) { }
+    inline			set (rcself_t v)	: base_class (v) { }
+    inline			set (const_iterator i1, const_iterator i2) : base_class() { insert (i1, i2); }
     inline rcself_t		operator= (rcself_t v)	{ base_class::operator= (v); return (*this); }
     inline size_type		size (void) const	{ return (base_class::size()); }
     inline iterator		begin (void)		{ return (base_class::begin()); }
@@ -46,46 +46,39 @@ public:
     inline const_iterator	end (void) const	{ return (base_class::end()); }
     inline void			assign (const_iterator i1, const_iterator i2)	{ clear(); insert (i1, i2); }
     inline void			push_back (const_reference v)	{ insert (v); }
-    inline const_iterator	find (const_reference v) const	{ const_iterator i = lower_bound (begin(), end(), v); return ((i != end() && *i == v) ? i : end()); }
+    inline const_iterator	find (const_reference v) const	{ const_iterator i = lower_bound (begin(), end(), v, Comp()); return ((i != end() && *i == v) ? i : end()); }
     inline iterator		find (const_reference v)	{ return (const_cast<iterator>(const_cast<rcself_t>(*this).find (v))); }
     insertrv_t			insert (const_reference v);
+    inline iterator		insert (iterator, const_reference v)	{ return (insert(v).first); }
     inline void			insert (const_iterator i1, const_iterator i2);
-    inline void			erase (const_reference v);
-    inline iterator		erase (iterator ep)	{ return (base_class::erase (ep)); }
+    inline void			erase (const_reference v)	{ iterator ip = find (v); if (ip != end()) erase (ip); }
+    inline iterator		erase (iterator ep)		{ return (base_class::erase (ep)); }
     inline iterator		erase (iterator ep1, iterator ep2) { return (base_class::erase (ep1, ep2)); }
-    inline void			clear (void)		{ base_class::clear(); }
+    inline void			clear (void)			{ base_class::clear(); }
 };
 
 /// Inserts \p v into the container, maintaining the sort order.
-template <typename T>
-typename set<T>::insertrv_t set<T>::insert (const_reference v)
+template <typename T, typename Comp>
+typename set<T,Comp>::insertrv_t set<T,Comp>::insert (const_reference v)
 {
-    iterator ip = lower_bound (begin(), end(), v);
-    bool bInserted = (ip == end() || v < *ip);
+    Comp f;
+    iterator ip = lower_bound (begin(), end(), v, f);
+    bool bInserted = (ip == end() || f(v,*ip));
     if (bInserted)
 	ip = base_class::insert (ip, v);
     return (make_pair (ip, bInserted));
 }
 
 /// Inserts the contents of range [i1,i2)
-template <typename T>
-void set<T>::insert (const_iterator i1, const_iterator i2)
+template <typename T, typename Comp>
+void set<T,Comp>::insert (const_iterator i1, const_iterator i2)
 {
     assert (i1 <= i2);
-    reserve (size() + distance (i1, i2));
+    base_class::reserve (size() + distance (i1, i2));
     for (; i1 < i2; ++i1)
 	push_back (*i1);
 }
 
-/// Erases the element with value \p v.
-template <typename T>
-inline void set<T>::erase (const_reference v)
-{
-    iterator ip = find (v);
-    if (ip != end())
-	erase (ip);
-}
-
 } // namespace ustl
 
 #endif
--- a/packages/language/cxx/ustl/current/include/ustl/uspecial.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uspecial.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef USPECIAL_H_947ADYOU0ARE3YOU2REALLY8ARE44CE0
@@ -46,9 +46,9 @@ template <typename T1, typename T2>
 istream& operator>> (istream& is, pair<T1,T2>& p)
 {
     is >> p.first;
-    is.align (alignof(p.second));
+    is.align (stream_align_of(p.second));
     is >> p.second;
-    is.align (alignof(p.first));
+    is.align (stream_align_of(p.first));
     return (is);
 }
 
@@ -57,9 +57,9 @@ template <typename T1, typename T2>
 ostream& operator<< (ostream& os, const pair<T1,T2>& p)
 {
     os << p.first;
-    os.align (alignof(p.second));
+    os.align (stream_align_of(p.second));
     os << p.second;
-    os.align (alignof(p.first));
+    os.align (stream_align_of(p.first));
     return (os);
 }
 
@@ -76,8 +76,8 @@ template <typename T1, typename T2>
 struct object_stream_size<pair<T1,T2> > {
     inline size_t operator()(const pair<T1,T2>& v) const
     {
-	return (Align (stream_size_of(v.first), alignof(v.second)) +
-		Align (stream_size_of(v.second), alignof(v.first)));
+	return (Align (stream_size_of(v.first), stream_align_of(v.second)) +
+		Align (stream_size_of(v.second), stream_align_of(v.first)));
     }
 };
 
@@ -111,10 +111,10 @@ unconst (const pair<typename Container::
 //----{ vector }--------------------------------------------------------
 
 template <typename T>
-inline size_t alignof (const vector<T>&)
+inline size_t stream_align_of (const vector<T>&)
 {
     typedef typename vector<T>::written_size_type written_size_type;
-    return (alignof (written_size_type()));
+    return (stream_align_of (written_size_type()));
 }
 
 //----{ bitset }--------------------------------------------------------
@@ -152,7 +152,7 @@ struct numeric_limits<tuple<N,T> > {
 };
 
 template <size_t N, typename T>
-inline size_t alignof (const tuple<N,T>&) { return (alignof (NullValue<T>())); }
+inline size_t stream_align_of (const tuple<N,T>&) { return (stream_align_of (NullValue<T>())); }
 
 template <typename T, typename IntT>
 inline ostringstream& chartype_text_write (ostringstream& os, const T& v)
@@ -257,4 +257,7 @@ CAST_STREAMABLE(bool, uint8_t)
 ALIGNOF (_long4grain, 4)
 #endif
 
+ALIGNOF(ustl::CBacktrace, sizeof(void*))
+ALIGNOF (ustl::string, stream_align_of (string::value_type()))
+
 #endif
--- a/packages/language/cxx/ustl/current/include/ustl/ustack.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ustack.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef USTACK_H_5242F5635322B2EC44A9AEE73022C6E9
--- a/packages/language/cxx/ustl/current/include/ustl/ustdxept.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ustdxept.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef USTDXEPT_H_46F7AE967738B588038F95E41158D7FF
--- a/packages/language/cxx/ustl/current/include/ustl/ustring.h
+++ b/packages/language/cxx/ustl/current/include/ustl/ustring.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef USTRING_H_1249CB7A098A9010763AAC6D37B133CF
@@ -142,7 +142,7 @@ public:
     inline void			insert (uoff_t ip, size_type n, value_type c)			{ insert (iat(ip), c, n); }
     inline void			insert (uoff_t ip, const string& s, uoff_t sp, size_type slen)	{ insert (iat(ip), s.iat(sp), s.iat(sp + slen)); }
     iterator			erase (iterator epo, size_type n = 1);
-    void			erase (uoff_t epo, size_type n = 1);
+    void			erase (uoff_t epo = 0, size_type n = 1);
     inline iterator		erase (iterator first, const_iterator last)	{ return (erase (first, size_type(distance(first,last)))); }
     inline void			eraser (uoff_t first, uoff_t last)		{ erase (iat(first), iat(last)); }
     inline void			push_back (const_reference c)	{ append (1, c); }
@@ -251,6 +251,8 @@ PTR_STRING_CMP (operator>,  (s2 <  s1))
 PTR_STRING_CMP (operator>=, (s2 <= s1))
 #undef PTR_STRING_CMP
 
+inline string operator+ (const char* cs, const string& ss) { string r; r.reserve (strlen(cs)+ss.size()); r += cs; r += ss; return (r); }
+
 //----------------------------------------------------------------------
 
 inline hashvalue_t hash_value (const char* first, const char* last)
@@ -262,7 +264,4 @@ inline hashvalue_t hash_value (const cha
 
 } // namespace ustl
 
-// Specialization for stream alignment
-ALIGNOF (ustl::string, alignof (string::value_type()))
-
 #endif
--- a/packages/language/cxx/ustl/current/include/ustl/utf8.h
+++ b/packages/language/cxx/ustl/current/include/ustl/utf8.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 //
 // This file contains stream iterators that read and write UTF-8 encoded
--- a/packages/language/cxx/ustl/current/include/ustl/utuple.h
+++ b/packages/language/cxx/ustl/current/include/ustl/utuple.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UTUPLE_H_7324ADEC49B397CA74A56F6050FD5A6B
--- a/packages/language/cxx/ustl/current/include/ustl/utypes.h
+++ b/packages/language/cxx/ustl/current/include/ustl/utypes.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UTYPES_H_118BBB3B50B7DBF22F5460C52E515C83
--- a/packages/language/cxx/ustl/current/include/ustl/uutility.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uutility.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 //
 /// \file uutility.h
@@ -96,7 +96,7 @@ inline T* NullPointer (void)
     { return ((T*) NULL); }
 
 /// \brief Returns a non-dereferentiable value reference.
-/// This is useful for passing to alignof or the like which need a value but
+/// This is useful for passing to stream_align_of or the like which need a value but
 /// don't need to actually use it.
 template <typename T>
 inline T& NullValue (void)
@@ -310,9 +310,6 @@ inline T1 DivRU (T1 n1, T2 n2)
     return ((n1 + adj) / n2);
 }
 
-#if __GNUC__ >= 3
-inline bool TestAndSet (int* pm) INLINE;
-#endif
 /// Sets the contents of \p pm to 1 and returns true if the previous value was 0.
 inline bool TestAndSet (int* pm)
 {
@@ -341,24 +338,67 @@ inline bool TestAndSet (int* pm)
 #endif
 }
 
+/// Returns the index of the first set bit in \p v or \p nbv if none.
+inline uoff_t FirstBit (uint32_t v, uoff_t nbv)
+{
+    uoff_t n = nbv;
+#if __i386__ || __x86_64__
+    if (!__builtin_constant_p(v)) asm ("bsr\t%1, %k0":"+r,r"(n):"r,m"(v)); else
+#endif
+#if __GNUC__
+    if (v) n = 31 - __builtin_clz(v);
+#else
+    if (v) for (uint32_t m = uint32_t(1)<<(n=31); !(v & m); m >>= 1) --n;
+#endif
+    return (n);
+}
+/// Returns the index of the first set bit in \p v or \p nbv if none.
+inline uoff_t FirstBit (uint64_t v, uoff_t nbv)
+{
+    uoff_t n = nbv;
+#if __x86_64__
+    if (!__builtin_constant_p(v)) asm ("bsr\t%1, %0":"+r,r"(n):"r,m"(v)); else
+#endif
+#if __GNUC__
+    if (v) n = 63 - __builtin_clzl(v);
+#else
+    if (v) for (uint64_t m = uint64_t(1)<<(n=63); !(v & m); m >>= 1) --n;
+#endif
+    return (n);
+}
+
+/// Returns the next power of 2 >= \p v.
+/// Values larger than UINT32_MAX/2 will return 2^0
 inline uint32_t NextPow2 (uint32_t v)
 {
+    uint32_t r = v-1;
+#if __i386__ || __x86_64__
+    if (!__builtin_constant_p(r)) asm("bsr\t%0, %0":"+r"(r)); else
+#endif
+    { r = FirstBit(r,r); if (r >= BitsInType(r)-1) r = uint32_t(-1); }
+    return (1<<(1+r));
+}
+
+/// Bitwise rotate value left
+template <typename T>
+inline T Rol (T v, size_t n)
+{
 #if __i386__ || __x86_64__
-	asm("dec\t%1\n\t"
-	"mov\t$1,%0\n\t"
-	"bsr\t%1,%1\n\t"
-	"inc\t%1\n\t"
-	"rol\t%b1,%0":"=&r"(v):"c"(v));
+    if (!(__builtin_constant_p(v) && __builtin_constant_p(n))) asm("rol\t%b1, %0":"+r,r"(v):"i,c"(n)); else
+#endif
+    v = (v << n) | (v >> (BitsInType(T)-n));
     return (v);
-#else
-    // The following code is sub-optimal but mimics the x86 implementation
-    int i = 31;
-    v--;
-    while (!(v & (1 << i)) && i > 0) i--;
-    if (i == 31)
-    	return 1;
-    return (1 << (i + 1));
+}
+
+/// Bitwise rotate value right
+template <typename T>
+inline T Ror (T v, size_t n)
+{
+#if __i386__ || __x86_64__
+    if (!(__builtin_constant_p(v) && __builtin_constant_p(n))) asm("ror\t%b1, %0":"+r,r"(v):"i,c"(n)); else
 #endif
+    v = (v >> n) | (v << (BitsInType(T)-n));
+    return (v);
 }
 
 /// \brief This template is to be used for dereferencing a type-punned pointer without a warning.
@@ -390,7 +430,6 @@ inline DEST noalias_cast (SRC s)
 
 namespace simd {
     /// Call after you are done using SIMD algorithms for 64 bit tuples.
-    inline void reset_mmx (void) INLINE;
     #define ALL_MMX_REGS_CHANGELIST "mm0","mm1","mm2","mm3","mm4","mm5","mm6","mm7","st","st(1)","st(2)","st(3)","st(4)","st(5)","st(6)","st(7)"
 #if CPU_HAS_3DNOW
     inline void reset_mmx (void) { asm ("femms":::ALL_MMX_REGS_CHANGELIST); }
--- a/packages/language/cxx/ustl/current/include/ustl/uvector.h
+++ b/packages/language/cxx/ustl/current/include/ustl/uvector.h
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef UVECTOR_H_00BB13AF082BEB7829C031B265518169
@@ -8,6 +8,7 @@
 
 #include "memblock.h"
 #include "umemory.h"
+#include "upredalgo.h"
 
 namespace ustl {
 
--- a/packages/language/cxx/ustl/current/src/bktrace.cpp
+++ b/packages/language/cxx/ustl/current/src/bktrace.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2006-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2006 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "bktrace.h"
@@ -109,7 +109,7 @@ void CBacktrace::text_write (ostringstre
 /// Reads the object from stream \p is.
 void CBacktrace::read (istream& is)
 {
-    assert (is.aligned (alignof (m_Addresses[0])) && "Backtrace object contains pointers and must be void* aligned");
+    assert (is.aligned (stream_align_of (m_Addresses[0])) && "Backtrace object contains pointers and must be void* aligned");
     is >> m_nFrames >> m_SymbolsSize;
     nfree (m_Symbols);
     m_Symbols = (char*) malloc (m_SymbolsSize + 1);
@@ -122,7 +122,7 @@ void CBacktrace::read (istream& is)
 /// Writes the object to stream \p os.
 void CBacktrace::write (ostream& os) const
 {
-    assert (os.aligned (alignof (m_Addresses[0])) && "Backtrace object contains pointers and must be void* aligned");
+    assert (os.aligned (stream_align_of (m_Addresses[0])) && "Backtrace object contains pointers and must be void* aligned");
     os << m_nFrames << m_SymbolsSize;
     os.write (m_Symbols, m_SymbolsSize);
     os.align();
--- a/packages/language/cxx/ustl/current/src/cmemlink.cpp
+++ b/packages/language/cxx/ustl/current/src/cmemlink.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "cmemlink.h"
@@ -40,7 +40,7 @@ void cmemlink::write (ostream& os) const
     assert (sz == size() && "No support for writing memblocks larger than 4G");
     os << sz;
     os.write (cdata(), sz);
-    os.align (alignof (sz));
+    os.align (stream_align_of (sz));
 }
 
 /// Writes the object to stream \p os
@@ -53,7 +53,7 @@ void cmemlink::text_write (ostringstream
 cmemlink::size_type cmemlink::stream_size (void) const
 {
     const written_size_type sz (size());
-    return (Align (stream_size_of (sz) + sz, alignof(sz)));
+    return (Align (stream_size_of (sz) + sz, stream_align_of(sz)));
 }
 
 #ifdef CYGCLS_USTL_FSTREAMS
--- a/packages/language/cxx/ustl/current/src/fstream.cpp
+++ b/packages/language/cxx/ustl/current/src/fstream.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "fstream.h"
--- a/packages/language/cxx/ustl/current/src/memblock.cpp
+++ b/packages/language/cxx/ustl/current/src/memblock.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "mistream.h"
@@ -73,7 +73,7 @@ void memblock::assign (const void* p, si
 {
     assert ((p != (const void*) cdata() || size() == n) && "Self-assignment can not resize");
     resize (n);
-    copy (p, n);
+    copy_n (pointer(p), n, begin());
 }
 
 /// \brief Reallocates internal block to hold at least \p newSize bytes.
@@ -132,7 +132,7 @@ void memblock::read (istream& is)
 	return;
     resize (n);
     is.read (data(), writable_size());
-    is.align (alignof (n));
+    is.align (stream_align_of (n));
 }
 
 #ifdef CYGCLS_USTL_FSTREAMS
--- a/packages/language/cxx/ustl/current/src/memlink.cpp
+++ b/packages/language/cxx/ustl/current/src/memlink.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "mistream.h"
@@ -19,17 +19,7 @@ void memlink::read (istream& is)
 	USTL_THROW(length_error ("memlink can not increase the size of the linked storage for reading"));
     resize (n);
     is.read (data(), n);
-    is.align (alignof (n));
-}
-
-/// Copies data from \p p, \p n to the linked block starting at \p start.
-void memlink::copy (iterator start, const void* p, size_type n)
-{
-    assert (data() || !n);
-    assert (p || !n);
-    assert (start >= begin() && start + n <= end());
-    if (p)
-	copy_n (const_iterator(p), n, start);
+    is.align (stream_align_of (n));
 }
 
 /// Fills the linked block with the given pattern.
--- a/packages/language/cxx/ustl/current/src/mistream.cpp
+++ b/packages/language/cxx/ustl/current/src/mistream.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "mistream.h"
--- a/packages/language/cxx/ustl/current/src/ofstream.cpp
+++ b/packages/language/cxx/ustl/current/src/ofstream.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "ofstream.h"
--- a/packages/language/cxx/ustl/current/src/sistream.cpp
+++ b/packages/language/cxx/ustl/current/src/sistream.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "sistream.h"
--- a/packages/language/cxx/ustl/current/src/sostream.cpp
+++ b/packages/language/cxx/ustl/current/src/sostream.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "mistream.h"	// for istream_iterator, referenced in utf8.h
--- a/packages/language/cxx/ustl/current/src/ualgobase.cpp
+++ b/packages/language/cxx/ustl/current/src/ualgobase.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #ifndef NDEBUG	// Optimized code here. asserts slow it down, and are checked elsewhere.
@@ -21,13 +21,6 @@ template <typename T> static inline void
 // Copy functions
 //----------------------------------------------------------------------
 
-#if __GNUC__ >= 3
-static inline void movsb_dir_up (void) INLINE;
-static inline void movsb_dir_down (void) INLINE;
-static inline void movsb (const void*& src, size_t nBytes, void*& dest) INLINE;
-static inline void movsd (const void*& src, size_t nWords, void*& dest) INLINE;
-#endif
-
 static inline void movsb_dir_up (void) { asm volatile ("cld"); }
 static inline void movsb_dir_down (void) { asm volatile ("std"); }
 
@@ -58,10 +51,6 @@ template <> inline void stosv (uint32_t*
 #define MMX_ALIGN	16U	// Data must be aligned on this grain
 #define MMX_BS		32U	// Assembly routines copy data this many bytes at a time.
 
-static inline void simd_block_copy (const void* src, void* dest) INLINE;
-static inline void simd_block_store (uint8_t* dest) INLINE;
-static inline void simd_block_cleanup (void) INLINE;
-
 static inline void simd_block_copy (const void* src, void* dest)
 {
     const char* csrc ((const char*) src);
--- a/packages/language/cxx/ustl/current/src/ubitset.cpp
+++ b/packages/language/cxx/ustl/current/src/ubitset.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "ubitset.h"
--- a/packages/language/cxx/ustl/current/src/uexception.cpp
+++ b/packages/language/cxx/ustl/current/src/uexception.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "uexception.h"
@@ -10,8 +10,9 @@
 #include "strmsize.h"
 #include "uspecial.h"
 #include <errno.h>
+
 #if HAVE_CXXABI_H && WANT_NAME_DEMANGLING
-    #include <cxxabi.h>
+extern "C" char* __cxa_demangle (const char* mangled_name, char* output_buffer, size_t* length, int* status);
 #endif
 
 namespace ustl {
@@ -212,7 +213,7 @@ const char* demangle_type_name (char* bu
     char dmname [256];
     size_t sz = VectorSize(dmname);
     int bFailed;
-    abi::__cxa_demangle (buf, dmname, &sz, &bFailed);
+    __cxa_demangle (buf, dmname, &sz, &bFailed);
     if (!bFailed) {
 	bl = min (strlen (dmname), bufSize - 1);
 	memcpy (buf, dmname, bl);
--- a/packages/language/cxx/ustl/current/src/unew.cpp
+++ b/packages/language/cxx/ustl/current/src/unew.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "unew.h"
--- a/packages/language/cxx/ustl/current/src/ustdxept.cpp
+++ b/packages/language/cxx/ustl/current/src/ustdxept.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "ustdxept.h"
--- a/packages/language/cxx/ustl/current/src/ustring.cpp
+++ b/packages/language/cxx/ustl/current/src/ustring.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "ustring.h"
@@ -68,7 +68,7 @@ void string::assign (const_pointer s, si
     while (len && s[len - 1] == 0)
 	-- len;
     resize (len);
-    copy (s, len);
+    copy_n (s, len, begin());
 }
 
 /// Appends to itself the value of string \p s of length \p len.
@@ -235,7 +235,7 @@ void string::replace (iterator first, it
 uoff_t string::find (const_reference c, uoff_t pos) const
 {
     const_iterator found = ::ustl::find (iat(pos), end(), c);
-    return (found < end() ? distance(begin(),found) : npos);
+    return (found < end() ? (uoff_t) distance(begin(),found) : npos);
 }
 
 /// Returns the offset of the first occurence of substring \p s of length \p n after \p pos.
@@ -274,7 +274,7 @@ uoff_t string::rfind (const string& s, u
 	for (i = 0; size_type(i) < s.size(); ++ i)
 	    if (m[-i] != d[-i])
 		break;
-    return (d > sp ? distance (begin(), d + 2 - s.size()) : npos);
+    return (d > sp ? (uoff_t) distance (begin(), d + 2 - s.size()) : npos);
 }
 
 /// Returns the offset of the first occurence of one of characters in \p s of size \p n after \p pos.
--- a/packages/language/cxx/ustl/current/tests/bvt00.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt00.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt01.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt01.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
@@ -53,7 +53,7 @@ void TestML (void)
     WriteCML (a);
     a.fill (a.begin() + 5, "TEST", 4, 3); 
     WriteCML (a);
-    a.copy (cstr, VectorSize(str) - 1);
+    copy_n (cstr, VectorSize(str) - 1, a.begin());
     WriteCML (a);
 }
 
--- a/packages/language/cxx/ustl/current/tests/bvt02.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt02.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
@@ -49,8 +49,7 @@ void TestMB (void)
     if (a.begin() == b.begin())
 	cout << "Assignment does not copy a link\n";
     a.deallocate();
-    a.resize (strTestLen);
-    a.copy (strTest, strTestLen);
+    a.assign (strTest, strTestLen);
     WriteCML (a);
     a.insert (a.begin() + 5, 9);
     a.fill (a.begin() + 5, "-", 1, 9);
--- a/packages/language/cxx/ustl/current/tests/bvt03.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt03.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
@@ -29,17 +29,17 @@ void TestStreams (void)
 
     size_t totalSize = stream_size_of(c);
     totalSize += stream_size_of(uc);
-    totalSize = Align (totalSize, alignof(bv));
+    totalSize = Align (totalSize, stream_align_of(bv));
     totalSize += stream_size_of(bv);
-    totalSize = Align (totalSize, alignof(i));
+    totalSize = Align (totalSize, stream_align_of(i));
     totalSize += stream_size_of(i);
     totalSize += stream_size_of(ui);
     totalSize = Align (totalSize);
     totalSize += stream_size_of(li);
     totalSize += stream_size_of(uli);
-    totalSize = Align (totalSize, alignof(f));
+    totalSize = Align (totalSize, stream_align_of(f));
     totalSize += stream_size_of(f);
-    totalSize = Align (totalSize, alignof(d));
+    totalSize = Align (totalSize, stream_align_of(d));
     totalSize += stream_size_of(d);
     totalSize += stream_size_of(si);
     totalSize += stream_size_of(usi);
--- a/packages/language/cxx/ustl/current/tests/bvt04.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt04.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt05.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt05.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
@@ -377,22 +377,22 @@ static void TestAlgorithms (void)
     v.resize (4);
     setEnd = set_difference (VectorRange(c_Set1), VectorRange(c_Set2), v.begin());
     PrintVector (v);
-    assert (setEnd == v.end());
+    if (setEnd != v.end()) cout << "incorrect range\n";
     cout << "set_symmetric_difference\n";
     v.resize (7);
     setEnd = set_symmetric_difference (VectorRange(c_Set1), VectorRange(c_Set2), v.begin());
     PrintVector (v);
-    assert (setEnd == v.end());
+    if (setEnd != v.end()) cout << "incorrect range\n";
     cout << "set_intersection\n";
     v.resize (2);
     setEnd = set_intersection (VectorRange(c_Set1), VectorRange(c_Set2), v.begin());
     PrintVector (v);
-    assert (setEnd == v.end());
+    if (setEnd != v.end()) cout << "incorrect range\n";
     cout << "set_union\n";
     v.resize (9);
     setEnd = set_union (VectorRange(c_Set1), VectorRange(c_Set2), v.begin());
     PrintVector (v);
-    assert (setEnd == v.end());
+    if (setEnd != v.end()) cout << "incorrect range\n";
     v.assign (first, last);
 }
 
--- a/packages/language/cxx/ustl/current/tests/bvt06.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt06.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt07.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt07.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
@@ -45,10 +45,7 @@ void TestString (void)
     s2 = "World";
     s3 = s1 + s2;
     cout << s3 << endl;
-    s3 = "Concatenated ";
-    s3 += s1.c_str();
-    s3 += s2;
-    s3 += " string.";
+    s3 = "Concatenated " + s1 + s2 + " string.";
     cout << s3 << endl;
 
     if (s1 < s2)
--- a/packages/language/cxx/ustl/current/tests/bvt08.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt08.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt09.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt09.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
@@ -72,8 +72,8 @@ void TestStringStreams (void)
     cout.format ("u_long:  %ld\n", uli);
     cout.format ("float:   %.2f\n", f);
     cout.format ("double:  %.2f\n", d);
-    cout.format ("short:   %hd\n", static_cast<int>(si));
-    cout.format ("u_short: %hd\n", static_cast<int>(usi));
+    cout.format ("short:   %d\n", static_cast<int>(si));
+    cout.format ("u_short: %d\n", static_cast<int>(usi));
     cout << endl;
 
     cout << "Dump:" << endl;
--- a/packages/language/cxx/ustl/current/tests/bvt10.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt10.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt11.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt11.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt12.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt12.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt13.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt13.cpp
@@ -3,7 +3,7 @@
 //
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt14.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt14.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
@@ -49,7 +49,7 @@ void TestMap (void)
     cout << endl;
 
     mcopy = months;
-    monthmap_t::iterator frob = mcopy.insert (make_pair (string("frobuary"), 42)).first;
+    monthmap_t::iterator frob = mcopy.insert (mcopy.begin(), make_pair (string("frobuary"), 42));
     cout << "After inserting " << frob->first << "," << frob->second << ":" << endl;
     for (i = mcopy.begin(); i < mcopy.end(); ++ i)
 	cout << i->first << " ";
--- a/packages/language/cxx/ustl/current/tests/bvt15.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt15.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
@@ -27,10 +27,10 @@ void TestMultiMap (void)
     employees.insert (make_pair (47000, string("Barbara"))); 
     employees.insert (make_pair (47000, string("Mary"))); 
 
-    cout << "As-inserted listing:" << endl;
+    cout << "As-inserted listing:\n";
     PrintEntries (employees);
 
-    cout << "Alphabetical listing:" << endl;
+    cout << "Alphabetical listing:\n";
     sort (employees);
     PrintEntries (employees);
 
@@ -41,13 +41,15 @@ void TestMultiMap (void)
 	cout << " " << i->second;
     cout << endl;
 
-    cout << "There are " << employees.count (27000) << " low-paid employees" << endl;
+    cout << employees.find(27000)->second << " makes $27000\n";
 
-    cout << "Firing all low-paid employees:" << endl;
+    cout << "There are " << employees.count (27000) << " low-paid employees\n";
+
+    cout << "Firing all low-paid employees:\n";
     employees.erase (27000);
     PrintEntries (employees);
 
-    cout << "Firing dumb employees:" << endl;
+    cout << "Firing dumb employees:\n";
     employees.erase (employees.begin(), employees.begin() + 1);
     PrintEntries (employees);
 }
--- a/packages/language/cxx/ustl/current/tests/bvt15.std
+++ b/packages/language/cxx/ustl/current/tests/bvt15.std
@@ -15,6 +15,7 @@ Gail	- $47000
 Mary	- $47000
 BigBoss	- $99000
 Employees making $47000: Barbara Gail Mary
+Dave makes $27000
 There are 2 low-paid employees
 Firing all low-paid employees:
 Dumb	- $15000
--- a/packages/language/cxx/ustl/current/tests/bvt16.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt16.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt17.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt17.cpp
@@ -1,7 +1,7 @@
 // 011010011001011001011000100100
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt18.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt18.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt19.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt19.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt20.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt20.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt21.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt21.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt22.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt22.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt23.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt23.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt24.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt24.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt25.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt25.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt26.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt26.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"
--- a/packages/language/cxx/ustl/current/tests/bvt27.cpp
+++ b/packages/language/cxx/ustl/current/tests/bvt27.cpp
@@ -1,6 +1,6 @@
 // This file is part of the uSTL library, an STL implementation.
 //
-// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
+// Copyright (c) 2005 by Mike Sharov <msharov@users.sourceforge.net>
 // This file is free software, distributed under the MIT License.
 
 #include "stdtest.h"