Fixed bug 3388381 by changing ctor body.

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@1127 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
rich_sposato 2011-09-30 23:16:08 +00:00
parent 3c3d49ff1a
commit a86d7d51f3

View file

@ -33,6 +33,9 @@
#include <functional>
#include <vector>
#include <utility>
#include <iterator>
#include <map>
namespace Loki
{
@ -144,10 +147,18 @@ namespace Loki
AssocVector(InputIterator first, InputIterator last,
const key_compare& comp = key_compare(),
const A& alloc = A())
: Base(first, last, alloc), MyCompare(comp)
: Base( alloc ), MyCompare( comp )
{
MyCompare& me = *this;
std::sort(begin(), end(), me);
typedef ::std::vector< ::std::pair< K, V >, A > BaseType;
typedef ::std::map< K, V, C, A > TempMap;
typedef ::std::back_insert_iterator< Base > MyInserter;
MyCompare & me = *this;
// Make a temporary map similar to this type to prevent any duplicates elements.
TempMap temp( first, last, me, alloc );
Base::reserve( temp.size() );
BaseType & target = static_cast< BaseType & >( *this );
MyInserter myInserter = ::std::back_inserter( target );
::std::copy( temp.begin(), temp.end(), myInserter );
}
AssocVector& operator=(const AssocVector& rhs)