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:
parent
3c3d49ff1a
commit
a86d7d51f3
1 changed files with 14 additions and 3 deletions
|
@ -33,6 +33,9 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <iterator>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
namespace Loki
|
namespace Loki
|
||||||
{
|
{
|
||||||
|
@ -144,10 +147,18 @@ namespace Loki
|
||||||
AssocVector(InputIterator first, InputIterator last,
|
AssocVector(InputIterator first, InputIterator last,
|
||||||
const key_compare& comp = key_compare(),
|
const key_compare& comp = key_compare(),
|
||||||
const A& alloc = A())
|
const A& alloc = A())
|
||||||
: Base(first, last, alloc), MyCompare(comp)
|
: Base( alloc ), MyCompare( comp )
|
||||||
{
|
{
|
||||||
MyCompare& me = *this;
|
typedef ::std::vector< ::std::pair< K, V >, A > BaseType;
|
||||||
std::sort(begin(), end(), me);
|
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)
|
AssocVector& operator=(const AssocVector& rhs)
|
||||||
|
|
Loading…
Add table
Reference in a new issue