libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
9
test/containers/Copyable.h
Normal file
9
test/containers/Copyable.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef COPYABLE_H
|
||||
#define COPYABLE_H
|
||||
|
||||
class Copyable
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
#endif
|
26
test/containers/DefaultOnly.h
Normal file
26
test/containers/DefaultOnly.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef DEFAULTONLY_H
|
||||
#define DEFAULTONLY_H
|
||||
|
||||
#include <cassert>
|
||||
|
||||
class DefaultOnly
|
||||
{
|
||||
int data_;
|
||||
|
||||
DefaultOnly(const DefaultOnly&);
|
||||
DefaultOnly& operator=(const DefaultOnly&);
|
||||
public:
|
||||
static int count;
|
||||
|
||||
DefaultOnly() : data_(-1) {++count;}
|
||||
~DefaultOnly() {data_ = 0; --count;}
|
||||
|
||||
friend bool operator==(const DefaultOnly& x, const DefaultOnly& y)
|
||||
{return x.data_ == y.data_;}
|
||||
friend bool operator< (const DefaultOnly& x, const DefaultOnly& y)
|
||||
{return x.data_ < y.data_;}
|
||||
};
|
||||
|
||||
int DefaultOnly::count = 0;
|
||||
|
||||
#endif
|
45
test/containers/Emplaceable.h
Normal file
45
test/containers/Emplaceable.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef EMPLACEABLE_H
|
||||
#define EMPLACEABLE_H
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
class Emplaceable
|
||||
{
|
||||
Emplaceable(const Emplaceable&);
|
||||
Emplaceable& operator=(const Emplaceable&);
|
||||
|
||||
int int_;
|
||||
double double_;
|
||||
public:
|
||||
Emplaceable() : int_(0), double_(0) {}
|
||||
Emplaceable(int i, double d) : int_(i), double_(d) {}
|
||||
Emplaceable(Emplaceable&& x)
|
||||
: int_(x.int_), double_(x.double_)
|
||||
{x.int_ = 0; x.double_ = 0;}
|
||||
Emplaceable& operator=(Emplaceable&& x)
|
||||
{int_ = x.int_; x.int_ = 0;
|
||||
double_ = x.double_; x.double_ = 0;
|
||||
return *this;}
|
||||
|
||||
bool operator==(const Emplaceable& x) const
|
||||
{return int_ == x.int_ && double_ == x.double_;}
|
||||
bool operator<(const Emplaceable& x) const
|
||||
{return int_ < x.int_ || int_ == x.int_ && double_ < x.double_;}
|
||||
|
||||
int get() const {return int_;}
|
||||
};
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
struct hash<Emplaceable>
|
||||
: public std::unary_function<Emplaceable, std::size_t>
|
||||
{
|
||||
std::size_t operator()(const Emplaceable& x) const {return x.get();}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
41
test/containers/MoveOnly.h
Normal file
41
test/containers/MoveOnly.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef MOVEONLY_H
|
||||
#define MOVEONLY_H
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
||||
class MoveOnly
|
||||
{
|
||||
MoveOnly(const MoveOnly&);
|
||||
MoveOnly& operator=(const MoveOnly&);
|
||||
|
||||
int data_;
|
||||
public:
|
||||
MoveOnly(int data = 1) : data_(data) {}
|
||||
MoveOnly(MoveOnly&& x)
|
||||
: data_(x.data_) {x.data_ = 0;}
|
||||
MoveOnly& operator=(MoveOnly&& x)
|
||||
{data_ = x.data_; x.data_ = 0; return *this;}
|
||||
|
||||
int get() const {return data_;}
|
||||
|
||||
bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
|
||||
bool operator< (const MoveOnly& x) const {return data_ < x.data_;}
|
||||
};
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
struct hash<MoveOnly>
|
||||
: public std::unary_function<MoveOnly, std::size_t>
|
||||
{
|
||||
std::size_t operator()(const MoveOnly& x) const {return x.get();}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
30
test/containers/NotConstructible.h
Normal file
30
test/containers/NotConstructible.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef NOTCONSTRUCTIBLE_H
|
||||
#define NOTCONSTRUCTIBLE_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
class NotConstructible
|
||||
{
|
||||
NotConstructible(const NotConstructible&);
|
||||
NotConstructible& operator=(const NotConstructible&);
|
||||
public:
|
||||
};
|
||||
|
||||
inline
|
||||
bool
|
||||
operator==(const NotConstructible&, const NotConstructible&)
|
||||
{return true;}
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <>
|
||||
struct hash<NotConstructible>
|
||||
: public std::unary_function<NotConstructible, std::size_t>
|
||||
{
|
||||
std::size_t operator()(const NotConstructible&) const {return 0;}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
86
test/containers/associative/map/map.access/at.pass.cpp
Normal file
86
test/containers/associative/map/map.access/at.pass.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// mapped_type& at(const key_type& k);
|
||||
// const mapped_type& at(const key_type& k) const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1.5),
|
||||
V(2, 2.5),
|
||||
V(3, 3.5),
|
||||
V(4, 4.5),
|
||||
V(5, 5.5),
|
||||
V(7, 7.5),
|
||||
V(8, 8.5),
|
||||
};
|
||||
std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 7);
|
||||
assert(m.at(1) == 1.5);
|
||||
m.at(1) = -1.5;
|
||||
assert(m.at(1) == -1.5);
|
||||
assert(m.at(2) == 2.5);
|
||||
assert(m.at(3) == 3.5);
|
||||
assert(m.at(4) == 4.5);
|
||||
assert(m.at(5) == 5.5);
|
||||
try
|
||||
{
|
||||
m.at(6);
|
||||
assert(false);
|
||||
}
|
||||
catch (std::out_of_range&)
|
||||
{
|
||||
}
|
||||
assert(m.at(7) == 7.5);
|
||||
assert(m.at(8) == 8.5);
|
||||
assert(m.size() == 7);
|
||||
}
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1.5),
|
||||
V(2, 2.5),
|
||||
V(3, 3.5),
|
||||
V(4, 4.5),
|
||||
V(5, 5.5),
|
||||
V(7, 7.5),
|
||||
V(8, 8.5),
|
||||
};
|
||||
const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 7);
|
||||
assert(m.at(1) == 1.5);
|
||||
assert(m.at(2) == 2.5);
|
||||
assert(m.at(3) == 3.5);
|
||||
assert(m.at(4) == 4.5);
|
||||
assert(m.at(5) == 5.5);
|
||||
try
|
||||
{
|
||||
m.at(6);
|
||||
assert(false);
|
||||
}
|
||||
catch (std::out_of_range&)
|
||||
{
|
||||
}
|
||||
assert(m.at(7) == 7.5);
|
||||
assert(m.at(8) == 8.5);
|
||||
assert(m.size() == 7);
|
||||
}
|
||||
}
|
28
test/containers/associative/map/map.access/empty.pass.cpp
Normal file
28
test/containers/associative/map/map.access/empty.pass.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// bool empty() const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
M m;
|
||||
assert(m.empty());
|
||||
m.insert(M::value_type(1, 1.5));
|
||||
assert(!m.empty());
|
||||
m.clear();
|
||||
assert(m.empty());
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// mapped_type& operator[](const key_type& k);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1.5),
|
||||
V(2, 2.5),
|
||||
V(3, 3.5),
|
||||
V(4, 4.5),
|
||||
V(5, 5.5),
|
||||
V(7, 7.5),
|
||||
V(8, 8.5),
|
||||
};
|
||||
std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 7);
|
||||
assert(m[1] == 1.5);
|
||||
assert(m.size() == 7);
|
||||
m[1] = -1.5;
|
||||
assert(m[1] == -1.5);
|
||||
assert(m.size() == 7);
|
||||
assert(m[6] == 0);
|
||||
assert(m.size() == 8);
|
||||
m[6] = 6.5;
|
||||
assert(m[6] == 6.5);
|
||||
assert(m.size() == 8);
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// mapped_type& operator[](key_type&& k);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef std::pair<MoveOnly, double> V;
|
||||
std::map<MoveOnly, double> m;
|
||||
assert(m.size() == 0);
|
||||
assert(m[1] == 0.0);
|
||||
assert(m.size() == 1);
|
||||
m[1] = -1.5;
|
||||
assert(m[1] == -1.5);
|
||||
assert(m.size() == 1);
|
||||
assert(m[6] == 0);
|
||||
assert(m.size() == 2);
|
||||
m[6] = 6.5;
|
||||
assert(m[6] == 6.5);
|
||||
assert(m.size() == 2);
|
||||
#endif
|
||||
}
|
118
test/containers/associative/map/map.access/iterator.pass.cpp
Normal file
118
test/containers/associative/map/map.access/iterator.pass.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// iterator begin();
|
||||
// const_iterator begin() const;
|
||||
// iterator end();
|
||||
// const_iterator end() const;
|
||||
//
|
||||
// reverse_iterator rbegin();
|
||||
// const_reverse_iterator rbegin() const;
|
||||
// reverse_iterator rend();
|
||||
// const_reverse_iterator rend() const;
|
||||
//
|
||||
// const_iterator cbegin() const;
|
||||
// const_iterator cend() const;
|
||||
// const_reverse_iterator crbegin() const;
|
||||
// const_reverse_iterator crend() const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
V(4, 1),
|
||||
V(4, 1.5),
|
||||
V(4, 2),
|
||||
V(5, 1),
|
||||
V(5, 1.5),
|
||||
V(5, 2),
|
||||
V(6, 1),
|
||||
V(6, 1.5),
|
||||
V(6, 2),
|
||||
V(7, 1),
|
||||
V(7, 1.5),
|
||||
V(7, 2),
|
||||
V(8, 1),
|
||||
V(8, 1.5),
|
||||
V(8, 2)
|
||||
};
|
||||
std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
assert(std::distance(m.begin(), m.end()) == m.size());
|
||||
assert(std::distance(m.rbegin(), m.rend()) == m.size());
|
||||
std::map<int, double>::iterator i = m.begin();
|
||||
std::map<int, double>::const_iterator k = i;
|
||||
assert(i == k);
|
||||
for (int j = 1; j <= m.size(); ++j, ++i)
|
||||
{
|
||||
assert(i->first == j);
|
||||
assert(i->second == 1);
|
||||
i->second = 2.5;
|
||||
assert(i->second == 2.5);
|
||||
}
|
||||
}
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
V(4, 1),
|
||||
V(4, 1.5),
|
||||
V(4, 2),
|
||||
V(5, 1),
|
||||
V(5, 1.5),
|
||||
V(5, 2),
|
||||
V(6, 1),
|
||||
V(6, 1.5),
|
||||
V(6, 2),
|
||||
V(7, 1),
|
||||
V(7, 1.5),
|
||||
V(7, 2),
|
||||
V(8, 1),
|
||||
V(8, 1.5),
|
||||
V(8, 2)
|
||||
};
|
||||
const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
assert(std::distance(m.begin(), m.end()) == m.size());
|
||||
assert(std::distance(m.cbegin(), m.cend()) == m.size());
|
||||
assert(std::distance(m.rbegin(), m.rend()) == m.size());
|
||||
assert(std::distance(m.crbegin(), m.crend()) == m.size());
|
||||
std::map<int, double>::const_iterator i = m.begin();
|
||||
for (int j = 1; j <= m.size(); ++j, ++i)
|
||||
{
|
||||
assert(i->first == j);
|
||||
assert(i->second == 1);
|
||||
}
|
||||
}
|
||||
}
|
24
test/containers/associative/map/map.access/max_size.pass.cpp
Normal file
24
test/containers/associative/map/map.access/max_size.pass.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// size_type max_size() const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
M m;
|
||||
assert(m.max_size() != 0);
|
||||
}
|
36
test/containers/associative/map/map.access/size.pass.cpp
Normal file
36
test/containers/associative/map/map.access/size.pass.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// size_type size() const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
M m;
|
||||
assert(m.size() == 0);
|
||||
m.insert(M::value_type(2, 1.5));
|
||||
assert(m.size() == 1);
|
||||
m.insert(M::value_type(1, 1.5));
|
||||
assert(m.size() == 2);
|
||||
m.insert(M::value_type(3, 1.5));
|
||||
assert(m.size() == 3);
|
||||
m.erase(m.begin());
|
||||
assert(m.size() == 2);
|
||||
m.erase(m.begin());
|
||||
assert(m.size() == 1);
|
||||
m.erase(m.begin());
|
||||
assert(m.size() == 0);
|
||||
}
|
29
test/containers/associative/map/map.cons/alloc.pass.cpp
Normal file
29
test/containers/associative/map/map.cons/alloc.pass.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// explicit map(const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::less<int> C;
|
||||
typedef test_allocator<std::pair<const int, double> > A;
|
||||
std::map<int, double, C, A> m(A(5));
|
||||
assert(m.empty());
|
||||
assert(m.begin() == m.end());
|
||||
assert(m.get_allocator() == A(5));
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map& operator=(initializer_list<value_type> il);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef std::pair<const int, double> V;
|
||||
std::map<int, double> m =
|
||||
{
|
||||
{20, 1},
|
||||
};
|
||||
m =
|
||||
{
|
||||
{1, 1},
|
||||
{1, 1.5},
|
||||
{1, 2},
|
||||
{2, 1},
|
||||
{2, 1.5},
|
||||
{2, 2},
|
||||
{3, 1},
|
||||
{3, 1.5},
|
||||
{3, 2}
|
||||
};
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
#endif
|
||||
}
|
28
test/containers/associative/map/map.cons/compare.pass.cpp
Normal file
28
test/containers/associative/map/map.cons/compare.pass.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// explicit map(const key_compare& comp);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef test_compare<std::less<int> > C;
|
||||
std::map<int, double, C> m(C(3));
|
||||
assert(m.empty());
|
||||
assert(m.begin() == m.end());
|
||||
assert(m.key_comp() == C(3));
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map(const key_compare& comp, const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<std::pair<const int, double> > A;
|
||||
std::map<int, double, C, A> m(C(4), A(5));
|
||||
assert(m.empty());
|
||||
assert(m.begin() == m.end());
|
||||
assert(m.key_comp() == C(4));
|
||||
assert(m.get_allocator() == A(5));
|
||||
}
|
94
test/containers/associative/map/map.cons/copy.pass.cpp
Normal file
94
test/containers/associative/map/map.cons/copy.pass.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map(const map& m);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
|
||||
std::map<int, double, C, A> m = mo;
|
||||
assert(m.get_allocator() == A(7));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
|
||||
assert(mo.get_allocator() == A(7));
|
||||
assert(mo.key_comp() == C(5));
|
||||
assert(mo.size() == 3);
|
||||
assert(distance(mo.begin(), mo.end()) == 3);
|
||||
assert(*mo.begin() == V(1, 1));
|
||||
assert(*next(mo.begin()) == V(2, 1));
|
||||
assert(*next(mo.begin(), 2) == V(3, 1));
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef other_allocator<V> A;
|
||||
std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
|
||||
std::map<int, double, C, A> m = mo;
|
||||
assert(m.get_allocator() == A(-2));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
|
||||
assert(mo.get_allocator() == A(7));
|
||||
assert(mo.key_comp() == C(5));
|
||||
assert(mo.size() == 3);
|
||||
assert(distance(mo.begin(), mo.end()) == 3);
|
||||
assert(*mo.begin() == V(1, 1));
|
||||
assert(*next(mo.begin()) == V(2, 1));
|
||||
assert(*next(mo.begin(), 2) == V(3, 1));
|
||||
}
|
||||
#endif
|
||||
}
|
56
test/containers/associative/map/map.cons/copy_alloc.pass.cpp
Normal file
56
test/containers/associative/map/map.cons/copy_alloc.pass.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map(const map& m, const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
|
||||
std::map<int, double, C, A> m(mo, A(3));
|
||||
assert(m.get_allocator() == A(3));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
|
||||
assert(mo.get_allocator() == A(7));
|
||||
assert(mo.key_comp() == C(5));
|
||||
assert(mo.size() == 3);
|
||||
assert(distance(mo.begin(), mo.end()) == 3);
|
||||
assert(*mo.begin() == V(1, 1));
|
||||
assert(*next(mo.begin()) == V(2, 1));
|
||||
assert(*next(mo.begin(), 2) == V(3, 1));
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map& operator=(const map& m);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2)
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
|
||||
std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
|
||||
m = mo;
|
||||
assert(m.get_allocator() == A(7));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
|
||||
assert(mo.get_allocator() == A(2));
|
||||
assert(mo.key_comp() == C(5));
|
||||
assert(mo.size() == 3);
|
||||
assert(distance(mo.begin(), mo.end()) == 3);
|
||||
assert(*mo.begin() == V(1, 1));
|
||||
assert(*next(mo.begin()) == V(2, 1));
|
||||
assert(*next(mo.begin(), 2) == V(3, 1));
|
||||
}
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2)
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef other_allocator<V> A;
|
||||
std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
|
||||
std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
|
||||
m = mo;
|
||||
assert(m.get_allocator() == A(2));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
|
||||
assert(mo.get_allocator() == A(2));
|
||||
assert(mo.key_comp() == C(5));
|
||||
assert(mo.size() == 3);
|
||||
assert(distance(mo.begin(), mo.end()) == 3);
|
||||
assert(*mo.begin() == V(1, 1));
|
||||
assert(*next(mo.begin()) == V(2, 1));
|
||||
assert(*next(mo.begin(), 2) == V(3, 1));
|
||||
}
|
||||
}
|
24
test/containers/associative/map/map.cons/default.pass.cpp
Normal file
24
test/containers/associative/map/map.cons/default.pass.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map();
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::map<int, double> m;
|
||||
assert(m.empty());
|
||||
assert(m.begin() == m.end());
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map(initializer_list<value_type> il);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef std::pair<const int, double> V;
|
||||
std::map<int, double> m =
|
||||
{
|
||||
{1, 1},
|
||||
{1, 1.5},
|
||||
{1, 2},
|
||||
{2, 1},
|
||||
{2, 1.5},
|
||||
{2, 2},
|
||||
{3, 1},
|
||||
{3, 1.5},
|
||||
{3, 2}
|
||||
};
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map(initializer_list<value_type> il, const key_compare& comp);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
#include "../../../test_compare.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef test_compare<std::less<int> > C;
|
||||
std::map<int, double, C> m({
|
||||
{1, 1},
|
||||
{1, 1.5},
|
||||
{1, 2},
|
||||
{2, 1},
|
||||
{2, 1.5},
|
||||
{2, 2},
|
||||
{3, 1},
|
||||
{3, 1.5},
|
||||
{3, 2}
|
||||
}, C(3));
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
assert(m.key_comp() == C(3));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<std::pair<const int, double> > A;
|
||||
std::map<int, double, C, A> m({
|
||||
{1, 1},
|
||||
{1, 1.5},
|
||||
{1, 2},
|
||||
{2, 1},
|
||||
{2, 1.5},
|
||||
{2, 2},
|
||||
{3, 1},
|
||||
{3, 1.5},
|
||||
{3, 2}
|
||||
}, C(3), A(6));
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
assert(m.key_comp() == C(3));
|
||||
assert(m.get_allocator() == A(6));
|
||||
#endif
|
||||
}
|
41
test/containers/associative/map/map.cons/iter_iter.pass.cpp
Normal file
41
test/containers/associative/map/map.cons/iter_iter.pass.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// template <class InputIterator>
|
||||
// map(InputIterator first, InputIterator last);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// template <class InputIterator>
|
||||
// map(InputIterator first, InputIterator last, const key_compare& comp);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
std::map<int, double, C> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// template <class InputIterator>
|
||||
// map(InputIterator first, InputIterator last,
|
||||
// const key_compare& comp, const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
|
||||
assert(m.get_allocator() == A(7));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
}
|
72
test/containers/associative/map/map.cons/move.pass.cpp
Normal file
72
test/containers/associative/map/map.cons/move.pass.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map(map&& m);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef std::pair<const int, double> V;
|
||||
{
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::map<int, double, C, A> mo(C(5), A(7));
|
||||
std::map<int, double, C, A> m = std::move(mo);
|
||||
assert(m.get_allocator() == A(7));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 0);
|
||||
assert(distance(m.begin(), m.end()) == 0);
|
||||
|
||||
assert(mo.get_allocator() == A(7));
|
||||
assert(mo.key_comp() == C(5));
|
||||
assert(mo.size() == 0);
|
||||
assert(distance(mo.begin(), mo.end()) == 0);
|
||||
}
|
||||
{
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
|
||||
std::map<int, double, C, A> m = std::move(mo);
|
||||
assert(m.get_allocator() == A(7));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
|
||||
assert(mo.get_allocator() == A(7));
|
||||
assert(mo.key_comp() == C(5));
|
||||
assert(mo.size() == 0);
|
||||
assert(distance(mo.begin(), mo.end()) == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
144
test/containers/associative/map/map.cons/move_alloc.pass.cpp
Normal file
144
test/containers/associative/map/map.cons/move_alloc.pass.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map(map&& m, const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef test_allocator<VC> A;
|
||||
typedef std::map<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(std::move(m1), A(7));
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(7));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef test_allocator<VC> A;
|
||||
typedef std::map<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(std::move(m1), A(5));
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(5));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef other_allocator<VC> A;
|
||||
typedef std::map<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(std::move(m1), A(5));
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(5));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
#endif
|
||||
}
|
147
test/containers/associative/map/map.cons/move_assign.pass.cpp
Normal file
147
test/containers/associative/map/map.cons/move_assign.pass.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// map& operator=(map&& m);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef test_allocator<VC> A;
|
||||
typedef std::map<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(C(3), A(7));
|
||||
m3 = std::move(m1);
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(7));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef test_allocator<VC> A;
|
||||
typedef std::map<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(C(3), A(5));
|
||||
m3 = std::move(m1);
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(5));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef other_allocator<VC> A;
|
||||
typedef std::map<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(C(3), A(5));
|
||||
m3 = std::move(m1);
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(7));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
#endif
|
||||
}
|
40
test/containers/associative/map/map.modifiers/clear.pass.cpp
Normal file
40
test/containers/associative/map/map.modifiers/clear.pass.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// void clear();
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1.5),
|
||||
P(2, 2.5),
|
||||
P(3, 3.5),
|
||||
P(4, 4.5),
|
||||
P(5, 5.5),
|
||||
P(6, 6.5),
|
||||
P(7, 7.5),
|
||||
P(8, 8.5),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
m.clear();
|
||||
assert(m.size() == 0);
|
||||
}
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// template <class... Args>
|
||||
// pair<iterator, bool> emplace(Args&&... args);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../Emplaceable.h"
|
||||
#include "../../../DefaultOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::map<int, DefaultOnly> M;
|
||||
typedef std::pair<M::iterator, bool> R;
|
||||
M m;
|
||||
assert(DefaultOnly::count == 0);
|
||||
R r = m.emplace();
|
||||
assert(r.second);
|
||||
assert(r.first == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 0);
|
||||
assert(m.begin()->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 1);
|
||||
r = m.emplace(1);
|
||||
assert(r.second);
|
||||
assert(r.first == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
r = m.emplace(1);
|
||||
assert(!r.second);
|
||||
assert(r.first == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
}
|
||||
assert(DefaultOnly::count == 0);
|
||||
{
|
||||
typedef std::map<int, Emplaceable> M;
|
||||
typedef std::pair<M::iterator, bool> R;
|
||||
M m;
|
||||
R r = m.emplace(2);
|
||||
assert(r.second);
|
||||
assert(r.first == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == Emplaceable());
|
||||
r = m.emplace(1, 2, 3.5);
|
||||
assert(r.second);
|
||||
assert(r.first == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == Emplaceable(2, 3.5));
|
||||
r = m.emplace(1, 2, 3.5);
|
||||
assert(!r.second);
|
||||
assert(r.first == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == Emplaceable(2, 3.5));
|
||||
}
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
typedef std::pair<M::iterator, bool> R;
|
||||
M m;
|
||||
R r = m.emplace(M::value_type(2, 3.5));
|
||||
assert(r.second);
|
||||
assert(r.first == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 3.5);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// template <class... Args>
|
||||
// iterator emplace_hint(const_iterator position, Args&&... args);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../Emplaceable.h"
|
||||
#include "../../../DefaultOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::map<int, DefaultOnly> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
assert(DefaultOnly::count == 0);
|
||||
R r = m.emplace_hint(m.end());
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 0);
|
||||
assert(m.begin()->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 1);
|
||||
r = m.emplace_hint(m.end(), 1);
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
r = m.emplace_hint(m.end(), 1);
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
}
|
||||
assert(DefaultOnly::count == 0);
|
||||
{
|
||||
typedef std::map<int, Emplaceable> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace_hint(m.end(), 2);
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == Emplaceable());
|
||||
r = m.emplace_hint(m.end(), 1, 2, 3.5);
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == Emplaceable(2, 3.5));
|
||||
r = m.emplace_hint(m.end(), 1, 2, 3.5);
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == Emplaceable(2, 3.5));
|
||||
}
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace_hint(m.end(), M::value_type(2, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 3.5);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,127 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// iterator erase(const_iterator position);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::iterator I;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1.5),
|
||||
P(2, 2.5),
|
||||
P(3, 3.5),
|
||||
P(4, 4.5),
|
||||
P(5, 5.5),
|
||||
P(6, 6.5),
|
||||
P(7, 7.5),
|
||||
P(8, 8.5),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
I i = m.erase(next(m.cbegin(), 3));
|
||||
assert(m.size() == 7);
|
||||
assert(i == next(m.begin(), 3));
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1.5);
|
||||
assert(next(m.begin())->first == 2);
|
||||
assert(next(m.begin())->second == 2.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 3.5);
|
||||
assert(next(m.begin(), 3)->first == 5);
|
||||
assert(next(m.begin(), 3)->second == 5.5);
|
||||
assert(next(m.begin(), 4)->first == 6);
|
||||
assert(next(m.begin(), 4)->second == 6.5);
|
||||
assert(next(m.begin(), 5)->first == 7);
|
||||
assert(next(m.begin(), 5)->second == 7.5);
|
||||
assert(next(m.begin(), 6)->first == 8);
|
||||
assert(next(m.begin(), 6)->second == 8.5);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 0));
|
||||
assert(m.size() == 6);
|
||||
assert(i == m.begin());
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 2.5);
|
||||
assert(next(m.begin())->first == 3);
|
||||
assert(next(m.begin())->second == 3.5);
|
||||
assert(next(m.begin(), 2)->first == 5);
|
||||
assert(next(m.begin(), 2)->second == 5.5);
|
||||
assert(next(m.begin(), 3)->first == 6);
|
||||
assert(next(m.begin(), 3)->second == 6.5);
|
||||
assert(next(m.begin(), 4)->first == 7);
|
||||
assert(next(m.begin(), 4)->second == 7.5);
|
||||
assert(next(m.begin(), 5)->first == 8);
|
||||
assert(next(m.begin(), 5)->second == 8.5);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 5));
|
||||
assert(m.size() == 5);
|
||||
assert(i == m.end());
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 2.5);
|
||||
assert(next(m.begin())->first == 3);
|
||||
assert(next(m.begin())->second == 3.5);
|
||||
assert(next(m.begin(), 2)->first == 5);
|
||||
assert(next(m.begin(), 2)->second == 5.5);
|
||||
assert(next(m.begin(), 3)->first == 6);
|
||||
assert(next(m.begin(), 3)->second == 6.5);
|
||||
assert(next(m.begin(), 4)->first == 7);
|
||||
assert(next(m.begin(), 4)->second == 7.5);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 1));
|
||||
assert(m.size() == 4);
|
||||
assert(i == next(m.begin()));
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 2.5);
|
||||
assert(next(m.begin())->first == 5);
|
||||
assert(next(m.begin())->second == 5.5);
|
||||
assert(next(m.begin(), 2)->first == 6);
|
||||
assert(next(m.begin(), 2)->second == 6.5);
|
||||
assert(next(m.begin(), 3)->first == 7);
|
||||
assert(next(m.begin(), 3)->second == 7.5);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 2.5);
|
||||
assert(next(m.begin())->first == 5);
|
||||
assert(next(m.begin())->second == 5.5);
|
||||
assert(next(m.begin(), 2)->first == 7);
|
||||
assert(next(m.begin(), 2)->second == 7.5);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2));
|
||||
assert(m.size() == 2);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 2.5);
|
||||
assert(next(m.begin())->first == 5);
|
||||
assert(next(m.begin())->second == 5.5);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 0));
|
||||
assert(m.size() == 1);
|
||||
assert(i == next(m.begin(), 0));
|
||||
assert(m.begin()->first == 5);
|
||||
assert(m.begin()->second == 5.5);
|
||||
|
||||
i = m.erase(m.cbegin());
|
||||
assert(m.size() == 0);
|
||||
assert(i == m.begin());
|
||||
assert(i == m.end());
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// iterator erase(const_iterator first, const_iterator last);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::iterator I;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1.5),
|
||||
P(2, 2.5),
|
||||
P(3, 3.5),
|
||||
P(4, 4.5),
|
||||
P(5, 5.5),
|
||||
P(6, 6.5),
|
||||
P(7, 7.5),
|
||||
P(8, 8.5),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
I i = m.erase(m.cbegin(), m.cbegin());
|
||||
assert(m.size() == 8);
|
||||
assert(i == m.begin());
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1.5);
|
||||
assert(next(m.begin())->first == 2);
|
||||
assert(next(m.begin())->second == 2.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 3.5);
|
||||
assert(next(m.begin(), 3)->first == 4);
|
||||
assert(next(m.begin(), 3)->second == 4.5);
|
||||
assert(next(m.begin(), 4)->first == 5);
|
||||
assert(next(m.begin(), 4)->second == 5.5);
|
||||
assert(next(m.begin(), 5)->first == 6);
|
||||
assert(next(m.begin(), 5)->second == 6.5);
|
||||
assert(next(m.begin(), 6)->first == 7);
|
||||
assert(next(m.begin(), 6)->second == 7.5);
|
||||
assert(next(m.begin(), 7)->first == 8);
|
||||
assert(next(m.begin(), 7)->second == 8.5);
|
||||
|
||||
i = m.erase(m.cbegin(), next(m.cbegin(), 2));
|
||||
assert(m.size() == 6);
|
||||
assert(i == m.begin());
|
||||
assert(next(m.begin(), 0)->first == 3);
|
||||
assert(next(m.begin(), 0)->second == 3.5);
|
||||
assert(next(m.begin(), 1)->first == 4);
|
||||
assert(next(m.begin(), 1)->second == 4.5);
|
||||
assert(next(m.begin(), 2)->first == 5);
|
||||
assert(next(m.begin(), 2)->second == 5.5);
|
||||
assert(next(m.begin(), 3)->first == 6);
|
||||
assert(next(m.begin(), 3)->second == 6.5);
|
||||
assert(next(m.begin(), 4)->first == 7);
|
||||
assert(next(m.begin(), 4)->second == 7.5);
|
||||
assert(next(m.begin(), 5)->first == 8);
|
||||
assert(next(m.begin(), 5)->second == 8.5);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
|
||||
assert(m.size() == 2);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(next(m.begin(), 0)->first == 3);
|
||||
assert(next(m.begin(), 0)->second == 3.5);
|
||||
assert(next(m.begin(), 1)->first == 4);
|
||||
assert(next(m.begin(), 1)->second == 4.5);
|
||||
|
||||
i = m.erase(m.cbegin(), m.cend());
|
||||
assert(m.size() == 0);
|
||||
assert(i == m.begin());
|
||||
assert(i == m.end());
|
||||
}
|
||||
}
|
146
test/containers/associative/map/map.modifiers/erase_key.pass.cpp
Normal file
146
test/containers/associative/map/map.modifiers/erase_key.pass.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// size_type erase(const key_type& k);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::size_type R;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1.5),
|
||||
P(2, 2.5),
|
||||
P(3, 3.5),
|
||||
P(4, 4.5),
|
||||
P(5, 5.5),
|
||||
P(6, 6.5),
|
||||
P(7, 7.5),
|
||||
P(8, 8.5),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
R s = m.erase(9);
|
||||
assert(s == 0);
|
||||
assert(m.size() == 8);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1.5);
|
||||
assert(next(m.begin())->first == 2);
|
||||
assert(next(m.begin())->second == 2.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 3.5);
|
||||
assert(next(m.begin(), 3)->first == 4);
|
||||
assert(next(m.begin(), 3)->second == 4.5);
|
||||
assert(next(m.begin(), 4)->first == 5);
|
||||
assert(next(m.begin(), 4)->second == 5.5);
|
||||
assert(next(m.begin(), 5)->first == 6);
|
||||
assert(next(m.begin(), 5)->second == 6.5);
|
||||
assert(next(m.begin(), 6)->first == 7);
|
||||
assert(next(m.begin(), 6)->second == 7.5);
|
||||
assert(next(m.begin(), 7)->first == 8);
|
||||
assert(next(m.begin(), 7)->second == 8.5);
|
||||
|
||||
s = m.erase(4);
|
||||
assert(m.size() == 7);
|
||||
assert(s == 1);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1.5);
|
||||
assert(next(m.begin())->first == 2);
|
||||
assert(next(m.begin())->second == 2.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 3.5);
|
||||
assert(next(m.begin(), 3)->first == 5);
|
||||
assert(next(m.begin(), 3)->second == 5.5);
|
||||
assert(next(m.begin(), 4)->first == 6);
|
||||
assert(next(m.begin(), 4)->second == 6.5);
|
||||
assert(next(m.begin(), 5)->first == 7);
|
||||
assert(next(m.begin(), 5)->second == 7.5);
|
||||
assert(next(m.begin(), 6)->first == 8);
|
||||
assert(next(m.begin(), 6)->second == 8.5);
|
||||
|
||||
s = m.erase(1);
|
||||
assert(m.size() == 6);
|
||||
assert(s == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 2.5);
|
||||
assert(next(m.begin())->first == 3);
|
||||
assert(next(m.begin())->second == 3.5);
|
||||
assert(next(m.begin(), 2)->first == 5);
|
||||
assert(next(m.begin(), 2)->second == 5.5);
|
||||
assert(next(m.begin(), 3)->first == 6);
|
||||
assert(next(m.begin(), 3)->second == 6.5);
|
||||
assert(next(m.begin(), 4)->first == 7);
|
||||
assert(next(m.begin(), 4)->second == 7.5);
|
||||
assert(next(m.begin(), 5)->first == 8);
|
||||
assert(next(m.begin(), 5)->second == 8.5);
|
||||
|
||||
s = m.erase(8);
|
||||
assert(m.size() == 5);
|
||||
assert(s == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 2.5);
|
||||
assert(next(m.begin())->first == 3);
|
||||
assert(next(m.begin())->second == 3.5);
|
||||
assert(next(m.begin(), 2)->first == 5);
|
||||
assert(next(m.begin(), 2)->second == 5.5);
|
||||
assert(next(m.begin(), 3)->first == 6);
|
||||
assert(next(m.begin(), 3)->second == 6.5);
|
||||
assert(next(m.begin(), 4)->first == 7);
|
||||
assert(next(m.begin(), 4)->second == 7.5);
|
||||
|
||||
s = m.erase(3);
|
||||
assert(m.size() == 4);
|
||||
assert(s == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 2.5);
|
||||
assert(next(m.begin())->first == 5);
|
||||
assert(next(m.begin())->second == 5.5);
|
||||
assert(next(m.begin(), 2)->first == 6);
|
||||
assert(next(m.begin(), 2)->second == 6.5);
|
||||
assert(next(m.begin(), 3)->first == 7);
|
||||
assert(next(m.begin(), 3)->second == 7.5);
|
||||
|
||||
s = m.erase(6);
|
||||
assert(m.size() == 3);
|
||||
assert(s == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 2.5);
|
||||
assert(next(m.begin())->first == 5);
|
||||
assert(next(m.begin())->second == 5.5);
|
||||
assert(next(m.begin(), 2)->first == 7);
|
||||
assert(next(m.begin(), 2)->second == 7.5);
|
||||
|
||||
s = m.erase(7);
|
||||
assert(m.size() == 2);
|
||||
assert(s == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 2.5);
|
||||
assert(next(m.begin())->first == 5);
|
||||
assert(next(m.begin())->second == 5.5);
|
||||
|
||||
s = m.erase(2);
|
||||
assert(m.size() == 1);
|
||||
assert(s == 1);
|
||||
assert(m.begin()->first == 5);
|
||||
assert(m.begin()->second == 5.5);
|
||||
|
||||
s = m.erase(5);
|
||||
assert(m.size() == 0);
|
||||
assert(s == 1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// pair<iterator, bool> insert(const value_type& v);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
typedef std::pair<M::iterator, bool> R;
|
||||
M m;
|
||||
R r = m.insert(M::value_type(2, 2.5));
|
||||
assert(r.second);
|
||||
assert(r.first == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r.first->first == 2);
|
||||
assert(r.first->second == 2.5);
|
||||
|
||||
r = m.insert(M::value_type(1, 1.5));
|
||||
assert(r.second);
|
||||
assert(r.first == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r.first->first == 1);
|
||||
assert(r.first->second == 1.5);
|
||||
|
||||
r = m.insert(M::value_type(3, 3.5));
|
||||
assert(r.second);
|
||||
assert(r.first == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r.first->first == 3);
|
||||
assert(r.first->second == 3.5);
|
||||
|
||||
r = m.insert(M::value_type(3, 3.5));
|
||||
assert(!r.second);
|
||||
assert(r.first == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r.first->first == 3);
|
||||
assert(r.first->second == 3.5);
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// void insert(initializer_list<value_type> il);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef std::pair<const int, double> V;
|
||||
std::map<int, double> m =
|
||||
{
|
||||
{1, 1},
|
||||
{1, 1.5},
|
||||
{1, 2},
|
||||
{3, 1},
|
||||
{3, 1.5},
|
||||
{3, 2}
|
||||
};
|
||||
m.insert({
|
||||
{2, 1},
|
||||
{2, 1.5},
|
||||
{2, 2},
|
||||
});
|
||||
assert(m.size() == 3);
|
||||
assert(distance(m.begin(), m.end()) == 3);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(2, 1));
|
||||
assert(*next(m.begin(), 2) == V(3, 1));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// iterator insert(const_iterator position, const value_type& v);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(m.end(), M::value_type(2, 2.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2.5);
|
||||
|
||||
r = m.insert(m.end(), M::value_type(1, 1.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1.5);
|
||||
|
||||
r = m.insert(m.end(), M::value_type(3, 3.5));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3.5);
|
||||
|
||||
r = m.insert(m.end(), M::value_type(3, 3.5));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3.5);
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// template <class InputIterator>
|
||||
// void insert(InputIterator first, InputIterator last);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::map<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1),
|
||||
P(1, 1.5),
|
||||
P(1, 2),
|
||||
P(2, 1),
|
||||
P(2, 1.5),
|
||||
P(2, 2),
|
||||
P(3, 1),
|
||||
P(3, 1.5),
|
||||
P(3, 2),
|
||||
};
|
||||
M m;
|
||||
m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
|
||||
assert(m.size() == 3);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1);
|
||||
assert(next(m.begin())->first == 2);
|
||||
assert(next(m.begin())->second == 1);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// template <class P>
|
||||
// iterator insert(const_iterator position, P&& p);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::map<int, MoveOnly> M;
|
||||
typedef std::pair<int, MoveOnly> P;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(m.end(), P(2, 2));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2);
|
||||
|
||||
r = m.insert(m.end(), P(1, 1));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1);
|
||||
|
||||
r = m.insert(m.end(), P(3, 3));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3);
|
||||
|
||||
r = m.insert(m.end(), P(3, 3));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// template <class P>
|
||||
// pair<iterator, bool> insert(P&& p);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::map<int, MoveOnly> M;
|
||||
typedef std::pair<M::iterator, bool> R;
|
||||
M m;
|
||||
R r = m.insert(M::value_type(2, 2));
|
||||
assert(r.second);
|
||||
assert(r.first == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r.first->first == 2);
|
||||
assert(r.first->second == 2);
|
||||
|
||||
r = m.insert(M::value_type(1, 1));
|
||||
assert(r.second);
|
||||
assert(r.first == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r.first->first == 1);
|
||||
assert(r.first->second == 1);
|
||||
|
||||
r = m.insert(M::value_type(3, 3));
|
||||
assert(r.second);
|
||||
assert(r.first == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r.first->first == 3);
|
||||
assert(r.first->second == 3);
|
||||
|
||||
r = m.insert(M::value_type(3, 3));
|
||||
assert(!r.second);
|
||||
assert(r.first == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r.first->first == 3);
|
||||
assert(r.first->second == 3);
|
||||
}
|
||||
#endif
|
||||
}
|
56
test/containers/associative/map/map.ops/count.pass.cpp
Normal file
56
test/containers/associative/map/map.ops/count.pass.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// size_type count(const key_type& k) const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::map<int, double> M;
|
||||
{
|
||||
typedef M::size_type R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.count(5);
|
||||
assert(r == 1);
|
||||
r = m.count(6);
|
||||
assert(r == 1);
|
||||
r = m.count(7);
|
||||
assert(r == 1);
|
||||
r = m.count(8);
|
||||
assert(r == 1);
|
||||
r = m.count(9);
|
||||
assert(r == 1);
|
||||
r = m.count(10);
|
||||
assert(r == 1);
|
||||
r = m.count(11);
|
||||
assert(r == 1);
|
||||
r = m.count(12);
|
||||
assert(r == 1);
|
||||
r = m.count(4);
|
||||
assert(r == 0);
|
||||
}
|
||||
}
|
156
test/containers/associative/map/map.ops/equal_range.pass.cpp
Normal file
156
test/containers/associative/map/map.ops/equal_range.pass.cpp
Normal file
@@ -0,0 +1,156 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// pair<iterator,iterator> equal_range(const key_type& k);
|
||||
// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::map<int, double> M;
|
||||
{
|
||||
typedef std::pair<M::iterator, M::iterator> R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(7, 6),
|
||||
V(9, 7),
|
||||
V(11, 8),
|
||||
V(13, 9),
|
||||
V(15, 10),
|
||||
V(17, 11),
|
||||
V(19, 12)
|
||||
};
|
||||
M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.equal_range(5);
|
||||
assert(r.first == next(m.begin(), 0));
|
||||
assert(r.second == next(m.begin(), 1));
|
||||
r = m.equal_range(7);
|
||||
assert(r.first == next(m.begin(), 1));
|
||||
assert(r.second == next(m.begin(), 2));
|
||||
r = m.equal_range(9);
|
||||
assert(r.first == next(m.begin(), 2));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(11);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 4));
|
||||
r = m.equal_range(13);
|
||||
assert(r.first == next(m.begin(), 4));
|
||||
assert(r.second == next(m.begin(), 5));
|
||||
r = m.equal_range(15);
|
||||
assert(r.first == next(m.begin(), 5));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(17);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 7));
|
||||
r = m.equal_range(19);
|
||||
assert(r.first == next(m.begin(), 7));
|
||||
assert(r.second == next(m.begin(), 8));
|
||||
r = m.equal_range(4);
|
||||
assert(r.first == next(m.begin(), 0));
|
||||
assert(r.second == next(m.begin(), 0));
|
||||
r = m.equal_range(6);
|
||||
assert(r.first == next(m.begin(), 1));
|
||||
assert(r.second == next(m.begin(), 1));
|
||||
r = m.equal_range(8);
|
||||
assert(r.first == next(m.begin(), 2));
|
||||
assert(r.second == next(m.begin(), 2));
|
||||
r = m.equal_range(10);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(12);
|
||||
assert(r.first == next(m.begin(), 4));
|
||||
assert(r.second == next(m.begin(), 4));
|
||||
r = m.equal_range(14);
|
||||
assert(r.first == next(m.begin(), 5));
|
||||
assert(r.second == next(m.begin(), 5));
|
||||
r = m.equal_range(16);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(18);
|
||||
assert(r.first == next(m.begin(), 7));
|
||||
assert(r.second == next(m.begin(), 7));
|
||||
r = m.equal_range(20);
|
||||
assert(r.first == next(m.begin(), 8));
|
||||
assert(r.second == next(m.begin(), 8));
|
||||
}
|
||||
{
|
||||
typedef std::pair<M::const_iterator, M::const_iterator> R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(7, 6),
|
||||
V(9, 7),
|
||||
V(11, 8),
|
||||
V(13, 9),
|
||||
V(15, 10),
|
||||
V(17, 11),
|
||||
V(19, 12)
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.equal_range(5);
|
||||
assert(r.first == next(m.begin(), 0));
|
||||
assert(r.second == next(m.begin(), 1));
|
||||
r = m.equal_range(7);
|
||||
assert(r.first == next(m.begin(), 1));
|
||||
assert(r.second == next(m.begin(), 2));
|
||||
r = m.equal_range(9);
|
||||
assert(r.first == next(m.begin(), 2));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(11);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 4));
|
||||
r = m.equal_range(13);
|
||||
assert(r.first == next(m.begin(), 4));
|
||||
assert(r.second == next(m.begin(), 5));
|
||||
r = m.equal_range(15);
|
||||
assert(r.first == next(m.begin(), 5));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(17);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 7));
|
||||
r = m.equal_range(19);
|
||||
assert(r.first == next(m.begin(), 7));
|
||||
assert(r.second == next(m.begin(), 8));
|
||||
r = m.equal_range(4);
|
||||
assert(r.first == next(m.begin(), 0));
|
||||
assert(r.second == next(m.begin(), 0));
|
||||
r = m.equal_range(6);
|
||||
assert(r.first == next(m.begin(), 1));
|
||||
assert(r.second == next(m.begin(), 1));
|
||||
r = m.equal_range(8);
|
||||
assert(r.first == next(m.begin(), 2));
|
||||
assert(r.second == next(m.begin(), 2));
|
||||
r = m.equal_range(10);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(12);
|
||||
assert(r.first == next(m.begin(), 4));
|
||||
assert(r.second == next(m.begin(), 4));
|
||||
r = m.equal_range(14);
|
||||
assert(r.first == next(m.begin(), 5));
|
||||
assert(r.second == next(m.begin(), 5));
|
||||
r = m.equal_range(16);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(18);
|
||||
assert(r.first == next(m.begin(), 7));
|
||||
assert(r.second == next(m.begin(), 7));
|
||||
r = m.equal_range(20);
|
||||
assert(r.first == next(m.begin(), 8));
|
||||
assert(r.second == next(m.begin(), 8));
|
||||
}
|
||||
}
|
90
test/containers/associative/map/map.ops/find.pass.cpp
Normal file
90
test/containers/associative/map/map.ops/find.pass.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// iterator find(const key_type& k);
|
||||
// const_iterator find(const key_type& k) const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::map<int, double> M;
|
||||
{
|
||||
typedef M::iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.find(5);
|
||||
assert(r == m.begin());
|
||||
r = m.find(6);
|
||||
assert(r == next(m.begin()));
|
||||
r = m.find(7);
|
||||
assert(r == next(m.begin(), 2));
|
||||
r = m.find(8);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.find(9);
|
||||
assert(r == next(m.begin(), 4));
|
||||
r = m.find(10);
|
||||
assert(r == next(m.begin(), 5));
|
||||
r = m.find(11);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.find(12);
|
||||
assert(r == next(m.begin(), 7));
|
||||
r = m.find(4);
|
||||
assert(r == next(m.begin(), 8));
|
||||
}
|
||||
{
|
||||
typedef M::const_iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.find(5);
|
||||
assert(r == m.begin());
|
||||
r = m.find(6);
|
||||
assert(r == next(m.begin()));
|
||||
r = m.find(7);
|
||||
assert(r == next(m.begin(), 2));
|
||||
r = m.find(8);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.find(9);
|
||||
assert(r == next(m.begin(), 4));
|
||||
r = m.find(10);
|
||||
assert(r == next(m.begin(), 5));
|
||||
r = m.find(11);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.find(12);
|
||||
assert(r == next(m.begin(), 7));
|
||||
r = m.find(4);
|
||||
assert(r == next(m.begin(), 8));
|
||||
}
|
||||
}
|
122
test/containers/associative/map/map.ops/lower_bound.pass.cpp
Normal file
122
test/containers/associative/map/map.ops/lower_bound.pass.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// iterator lower_bound(const key_type& k);
|
||||
// const_iterator lower_bound(const key_type& k) const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::map<int, double> M;
|
||||
{
|
||||
typedef M::iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(7, 6),
|
||||
V(9, 7),
|
||||
V(11, 8),
|
||||
V(13, 9),
|
||||
V(15, 10),
|
||||
V(17, 11),
|
||||
V(19, 12)
|
||||
};
|
||||
M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.lower_bound(5);
|
||||
assert(r == m.begin());
|
||||
r = m.lower_bound(7);
|
||||
assert(r == next(m.begin()));
|
||||
r = m.lower_bound(9);
|
||||
assert(r == next(m.begin(), 2));
|
||||
r = m.lower_bound(11);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.lower_bound(13);
|
||||
assert(r == next(m.begin(), 4));
|
||||
r = m.lower_bound(15);
|
||||
assert(r == next(m.begin(), 5));
|
||||
r = m.lower_bound(17);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.lower_bound(19);
|
||||
assert(r == next(m.begin(), 7));
|
||||
r = m.lower_bound(4);
|
||||
assert(r == next(m.begin(), 0));
|
||||
r = m.lower_bound(6);
|
||||
assert(r == next(m.begin(), 1));
|
||||
r = m.lower_bound(8);
|
||||
assert(r == next(m.begin(), 2));
|
||||
r = m.lower_bound(10);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.lower_bound(12);
|
||||
assert(r == next(m.begin(), 4));
|
||||
r = m.lower_bound(14);
|
||||
assert(r == next(m.begin(), 5));
|
||||
r = m.lower_bound(16);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.lower_bound(18);
|
||||
assert(r == next(m.begin(), 7));
|
||||
r = m.lower_bound(20);
|
||||
assert(r == next(m.begin(), 8));
|
||||
}
|
||||
{
|
||||
typedef M::const_iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(7, 6),
|
||||
V(9, 7),
|
||||
V(11, 8),
|
||||
V(13, 9),
|
||||
V(15, 10),
|
||||
V(17, 11),
|
||||
V(19, 12)
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.lower_bound(5);
|
||||
assert(r == m.begin());
|
||||
r = m.lower_bound(7);
|
||||
assert(r == next(m.begin()));
|
||||
r = m.lower_bound(9);
|
||||
assert(r == next(m.begin(), 2));
|
||||
r = m.lower_bound(11);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.lower_bound(13);
|
||||
assert(r == next(m.begin(), 4));
|
||||
r = m.lower_bound(15);
|
||||
assert(r == next(m.begin(), 5));
|
||||
r = m.lower_bound(17);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.lower_bound(19);
|
||||
assert(r == next(m.begin(), 7));
|
||||
r = m.lower_bound(4);
|
||||
assert(r == next(m.begin(), 0));
|
||||
r = m.lower_bound(6);
|
||||
assert(r == next(m.begin(), 1));
|
||||
r = m.lower_bound(8);
|
||||
assert(r == next(m.begin(), 2));
|
||||
r = m.lower_bound(10);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.lower_bound(12);
|
||||
assert(r == next(m.begin(), 4));
|
||||
r = m.lower_bound(14);
|
||||
assert(r == next(m.begin(), 5));
|
||||
r = m.lower_bound(16);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.lower_bound(18);
|
||||
assert(r == next(m.begin(), 7));
|
||||
r = m.lower_bound(20);
|
||||
assert(r == next(m.begin(), 8));
|
||||
}
|
||||
}
|
122
test/containers/associative/map/map.ops/upper_bound.pass.cpp
Normal file
122
test/containers/associative/map/map.ops/upper_bound.pass.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// iterator upper_bound(const key_type& k);
|
||||
// const_iterator upper_bound(const key_type& k) const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::map<int, double> M;
|
||||
{
|
||||
typedef M::iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(7, 6),
|
||||
V(9, 7),
|
||||
V(11, 8),
|
||||
V(13, 9),
|
||||
V(15, 10),
|
||||
V(17, 11),
|
||||
V(19, 12)
|
||||
};
|
||||
M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.upper_bound(5);
|
||||
assert(r == next(m.begin(), 1));
|
||||
r = m.upper_bound(7);
|
||||
assert(r == next(m.begin(), 2));
|
||||
r = m.upper_bound(9);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.upper_bound(11);
|
||||
assert(r == next(m.begin(), 4));
|
||||
r = m.upper_bound(13);
|
||||
assert(r == next(m.begin(), 5));
|
||||
r = m.upper_bound(15);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.upper_bound(17);
|
||||
assert(r == next(m.begin(), 7));
|
||||
r = m.upper_bound(19);
|
||||
assert(r == next(m.begin(), 8));
|
||||
r = m.upper_bound(4);
|
||||
assert(r == next(m.begin(), 0));
|
||||
r = m.upper_bound(6);
|
||||
assert(r == next(m.begin(), 1));
|
||||
r = m.upper_bound(8);
|
||||
assert(r == next(m.begin(), 2));
|
||||
r = m.upper_bound(10);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.upper_bound(12);
|
||||
assert(r == next(m.begin(), 4));
|
||||
r = m.upper_bound(14);
|
||||
assert(r == next(m.begin(), 5));
|
||||
r = m.upper_bound(16);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.upper_bound(18);
|
||||
assert(r == next(m.begin(), 7));
|
||||
r = m.upper_bound(20);
|
||||
assert(r == next(m.begin(), 8));
|
||||
}
|
||||
{
|
||||
typedef M::const_iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(7, 6),
|
||||
V(9, 7),
|
||||
V(11, 8),
|
||||
V(13, 9),
|
||||
V(15, 10),
|
||||
V(17, 11),
|
||||
V(19, 12)
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.upper_bound(5);
|
||||
assert(r == next(m.begin(), 1));
|
||||
r = m.upper_bound(7);
|
||||
assert(r == next(m.begin(), 2));
|
||||
r = m.upper_bound(9);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.upper_bound(11);
|
||||
assert(r == next(m.begin(), 4));
|
||||
r = m.upper_bound(13);
|
||||
assert(r == next(m.begin(), 5));
|
||||
r = m.upper_bound(15);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.upper_bound(17);
|
||||
assert(r == next(m.begin(), 7));
|
||||
r = m.upper_bound(19);
|
||||
assert(r == next(m.begin(), 8));
|
||||
r = m.upper_bound(4);
|
||||
assert(r == next(m.begin(), 0));
|
||||
r = m.upper_bound(6);
|
||||
assert(r == next(m.begin(), 1));
|
||||
r = m.upper_bound(8);
|
||||
assert(r == next(m.begin(), 2));
|
||||
r = m.upper_bound(10);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.upper_bound(12);
|
||||
assert(r == next(m.begin(), 4));
|
||||
r = m.upper_bound(14);
|
||||
assert(r == next(m.begin(), 5));
|
||||
r = m.upper_bound(16);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.upper_bound(18);
|
||||
assert(r == next(m.begin(), 7));
|
||||
r = m.upper_bound(20);
|
||||
assert(r == next(m.begin(), 8));
|
||||
}
|
||||
}
|
107
test/containers/associative/map/map.special/member_swap.pass.cpp
Normal file
107
test/containers/associative/map/map.special/member_swap.pass.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// void swap(map& m);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::map<int, double> M;
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
m1.swap(m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
m1.swap(m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
m1.swap(m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
m1.swap(m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
}
|
@@ -0,0 +1,179 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// template <class Key, class T, class Compare, class Allocator>
|
||||
// void
|
||||
// swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
#include "../../../test_allocator.h"
|
||||
#include "../../../test_compare.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::map<int, double> M;
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
typedef test_allocator<V> A;
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef std::map<int, double, C, A> M;
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
assert(m1.key_comp() == C(2));
|
||||
assert(m1.get_allocator() == A(1));
|
||||
assert(m2.key_comp() == C(1));
|
||||
assert(m2.get_allocator() == A(2));
|
||||
}
|
||||
{
|
||||
typedef other_allocator<V> A;
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef std::map<int, double, C, A> M;
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
assert(m1.key_comp() == C(2));
|
||||
assert(m1.get_allocator() == A(2));
|
||||
assert(m2.key_comp() == C(1));
|
||||
assert(m2.get_allocator() == A(1));
|
||||
}
|
||||
}
|
48
test/containers/associative/map/types.pass.cpp
Normal file
48
test/containers/associative/map/types.pass.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// template <class Key, class T, class Compare = less<Key>,
|
||||
// class Allocator = allocator<pair<const Key, T>>>
|
||||
// class map
|
||||
// {
|
||||
// public:
|
||||
// // types:
|
||||
// typedef Key key_type;
|
||||
// typedef T mapped_type;
|
||||
// typedef pair<const key_type, mapped_type> value_type;
|
||||
// typedef Compare key_compare;
|
||||
// typedef Allocator allocator_type;
|
||||
// typedef typename allocator_type::reference reference;
|
||||
// typedef typename allocator_type::const_reference const_reference;
|
||||
// typedef typename allocator_type::pointer pointer;
|
||||
// typedef typename allocator_type::const_pointer const_pointer;
|
||||
// typedef typename allocator_type::size_type size_type;
|
||||
// typedef typename allocator_type::difference_type difference_type;
|
||||
// ...
|
||||
// };
|
||||
|
||||
#include <map>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_same<std::map<int, double>::key_type, int>::value), "");
|
||||
static_assert((std::is_same<std::map<int, double>::mapped_type, double>::value), "");
|
||||
static_assert((std::is_same<std::map<int, double>::value_type, std::pair<const int, double> >::value), "");
|
||||
static_assert((std::is_same<std::map<int, double>::key_compare, std::less<int> >::value), "");
|
||||
static_assert((std::is_same<std::map<int, double>::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
|
||||
static_assert((std::is_same<std::map<int, double>::reference, std::pair<const int, double>&>::value), "");
|
||||
static_assert((std::is_same<std::map<int, double>::const_reference, const std::pair<const int, double>&>::value), "");
|
||||
static_assert((std::is_same<std::map<int, double>::pointer, std::pair<const int, double>*>::value), "");
|
||||
static_assert((std::is_same<std::map<int, double>::const_pointer, const std::pair<const int, double>*>::value), "");
|
||||
static_assert((std::is_same<std::map<int, double>::size_type, std::size_t>::value), "");
|
||||
static_assert((std::is_same<std::map<int, double>::difference_type, std::ptrdiff_t>::value), "");
|
||||
}
|
20
test/containers/associative/map/version.pass.cpp
Normal file
20
test/containers/associative/map/version.pass.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
#include <map>
|
||||
|
||||
#ifndef _LIBCPP_VERSION
|
||||
#error _LIBCPP_VERSION not defined
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
28
test/containers/associative/multimap/empty.pass.cpp
Normal file
28
test/containers/associative/multimap/empty.pass.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// bool empty() const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
M m;
|
||||
assert(m.empty());
|
||||
m.insert(M::value_type(1, 1.5));
|
||||
assert(!m.empty());
|
||||
m.clear();
|
||||
assert(m.empty());
|
||||
}
|
120
test/containers/associative/multimap/iterator.pass.cpp
Normal file
120
test/containers/associative/multimap/iterator.pass.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator begin();
|
||||
// const_iterator begin() const;
|
||||
// iterator end();
|
||||
// const_iterator end() const;
|
||||
//
|
||||
// reverse_iterator rbegin();
|
||||
// const_reverse_iterator rbegin() const;
|
||||
// reverse_iterator rend();
|
||||
// const_reverse_iterator rend() const;
|
||||
//
|
||||
// const_iterator cbegin() const;
|
||||
// const_iterator cend() const;
|
||||
// const_reverse_iterator crbegin() const;
|
||||
// const_reverse_iterator crend() const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
V(4, 1),
|
||||
V(4, 1.5),
|
||||
V(4, 2),
|
||||
V(5, 1),
|
||||
V(5, 1.5),
|
||||
V(5, 2),
|
||||
V(6, 1),
|
||||
V(6, 1.5),
|
||||
V(6, 2),
|
||||
V(7, 1),
|
||||
V(7, 1.5),
|
||||
V(7, 2),
|
||||
V(8, 1),
|
||||
V(8, 1.5),
|
||||
V(8, 2)
|
||||
};
|
||||
std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
assert(std::distance(m.begin(), m.end()) == m.size());
|
||||
assert(std::distance(m.rbegin(), m.rend()) == m.size());
|
||||
std::multimap<int, double>::iterator i = m.begin();
|
||||
std::multimap<int, double>::const_iterator k = i;
|
||||
assert(i == k);
|
||||
for (int j = 1; j <= 8; ++j)
|
||||
for (double d = 1; d <= 2; d += .5, ++i)
|
||||
{
|
||||
assert(i->first == j);
|
||||
assert(i->second == d);
|
||||
i->second = 2.5;
|
||||
assert(i->second == 2.5);
|
||||
}
|
||||
}
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
V(4, 1),
|
||||
V(4, 1.5),
|
||||
V(4, 2),
|
||||
V(5, 1),
|
||||
V(5, 1.5),
|
||||
V(5, 2),
|
||||
V(6, 1),
|
||||
V(6, 1.5),
|
||||
V(6, 2),
|
||||
V(7, 1),
|
||||
V(7, 1.5),
|
||||
V(7, 2),
|
||||
V(8, 1),
|
||||
V(8, 1.5),
|
||||
V(8, 2)
|
||||
};
|
||||
const std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
assert(std::distance(m.begin(), m.end()) == m.size());
|
||||
assert(std::distance(m.cbegin(), m.cend()) == m.size());
|
||||
assert(std::distance(m.rbegin(), m.rend()) == m.size());
|
||||
assert(std::distance(m.crbegin(), m.crend()) == m.size());
|
||||
std::multimap<int, double>::const_iterator i = m.begin();
|
||||
for (int j = 1; j <= 8; ++j)
|
||||
for (double d = 1; d <= 2; d += .5, ++i)
|
||||
{
|
||||
assert(i->first == j);
|
||||
assert(i->second == d);
|
||||
}
|
||||
}
|
||||
}
|
24
test/containers/associative/multimap/max_size.pass.cpp
Normal file
24
test/containers/associative/multimap/max_size.pass.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// size_type max_size() const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
M m;
|
||||
assert(m.max_size() != 0);
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// explicit multimap(const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::less<int> C;
|
||||
typedef test_allocator<std::pair<const int, double> > A;
|
||||
std::multimap<int, double, C, A> m(A(5));
|
||||
assert(m.empty());
|
||||
assert(m.begin() == m.end());
|
||||
assert(m.get_allocator() == A(5));
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap& operator=(initializer_list<value_type> il);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef std::multimap<int, double> C;
|
||||
typedef C::value_type V;
|
||||
C m = {{20, 1}};
|
||||
m =
|
||||
{
|
||||
{1, 1},
|
||||
{1, 1.5},
|
||||
{1, 2},
|
||||
{2, 1},
|
||||
{2, 1.5},
|
||||
{2, 2},
|
||||
{3, 1},
|
||||
{3, 1.5},
|
||||
{3, 2}
|
||||
};
|
||||
assert(m.size() == 9);
|
||||
assert(distance(m.begin(), m.end()) == 9);
|
||||
C::const_iterator i = m.cbegin();
|
||||
assert(*i == V(1, 1));
|
||||
assert(*++i == V(1, 1.5));
|
||||
assert(*++i == V(1, 2));
|
||||
assert(*++i == V(2, 1));
|
||||
assert(*++i == V(2, 1.5));
|
||||
assert(*++i == V(2, 2));
|
||||
assert(*++i == V(3, 1));
|
||||
assert(*++i == V(3, 1.5));
|
||||
assert(*++i == V(3, 2));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// explicit multimap(const key_compare& comp);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef test_compare<std::less<int> > C;
|
||||
std::multimap<int, double, C> m(C(3));
|
||||
assert(m.empty());
|
||||
assert(m.begin() == m.end());
|
||||
assert(m.key_comp() == C(3));
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap(const key_compare& comp, const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<std::pair<const int, double> > A;
|
||||
std::multimap<int, double, C, A> m(C(4), A(5));
|
||||
assert(m.empty());
|
||||
assert(m.begin() == m.end());
|
||||
assert(m.key_comp() == C(4));
|
||||
assert(m.get_allocator() == A(5));
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap(const multimap& m);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
|
||||
std::multimap<int, double, C, A> m = mo;
|
||||
assert(m == mo);
|
||||
assert(m.get_allocator() == A(7));
|
||||
assert(m.key_comp() == C(5));
|
||||
|
||||
assert(mo.get_allocator() == A(7));
|
||||
assert(mo.key_comp() == C(5));
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef other_allocator<V> A;
|
||||
std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
|
||||
std::multimap<int, double, C, A> m = mo;
|
||||
assert(m == mo);
|
||||
assert(m.get_allocator() == A(-2));
|
||||
assert(m.key_comp() == C(5));
|
||||
|
||||
assert(mo.get_allocator() == A(7));
|
||||
assert(mo.key_comp() == C(5));
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap(const multimap& m, const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
|
||||
std::multimap<int, double, C, A> m(mo, A(3));
|
||||
assert(m == mo);
|
||||
assert(m.get_allocator() == A(3));
|
||||
assert(m.key_comp() == C(5));
|
||||
|
||||
assert(mo.get_allocator() == A(7));
|
||||
assert(mo.key_comp() == C(5));
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap& operator=(const multimap& m);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
|
||||
std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
|
||||
m = mo;
|
||||
assert(m == mo);
|
||||
assert(m.get_allocator() == A(7));
|
||||
assert(m.key_comp() == C(5));
|
||||
|
||||
assert(mo.get_allocator() == A(2));
|
||||
assert(mo.key_comp() == C(5));
|
||||
}
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef other_allocator<V> A;
|
||||
std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
|
||||
std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
|
||||
m = mo;
|
||||
assert(m == mo);
|
||||
assert(m.get_allocator() == A(2));
|
||||
assert(m.key_comp() == C(5));
|
||||
|
||||
assert(mo.get_allocator() == A(2));
|
||||
assert(mo.key_comp() == C(5));
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap();
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::multimap<int, double> m;
|
||||
assert(m.empty());
|
||||
assert(m.begin() == m.end());
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef std::multimap<int, double> C;
|
||||
typedef C::value_type V;
|
||||
C m =
|
||||
{
|
||||
{1, 1},
|
||||
{1, 1.5},
|
||||
{1, 2},
|
||||
{2, 1},
|
||||
{2, 1.5},
|
||||
{2, 2},
|
||||
{3, 1},
|
||||
{3, 1.5},
|
||||
{3, 2}
|
||||
};
|
||||
assert(m.size() == 9);
|
||||
assert(distance(m.begin(), m.end()) == 9);
|
||||
C::const_iterator i = m.cbegin();
|
||||
assert(*i == V(1, 1));
|
||||
assert(*++i == V(1, 1.5));
|
||||
assert(*++i == V(1, 2));
|
||||
assert(*++i == V(2, 1));
|
||||
assert(*++i == V(2, 1.5));
|
||||
assert(*++i == V(2, 2));
|
||||
assert(*++i == V(3, 1));
|
||||
assert(*++i == V(3, 1.5));
|
||||
assert(*++i == V(3, 2));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
#include "../../../test_compare.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef test_compare<std::less<int> > Cmp;
|
||||
typedef std::multimap<int, double, Cmp> C;
|
||||
typedef C::value_type V;
|
||||
C m(
|
||||
{
|
||||
{1, 1},
|
||||
{1, 1.5},
|
||||
{1, 2},
|
||||
{2, 1},
|
||||
{2, 1.5},
|
||||
{2, 2},
|
||||
{3, 1},
|
||||
{3, 1.5},
|
||||
{3, 2}
|
||||
},
|
||||
Cmp(4)
|
||||
);
|
||||
assert(m.size() == 9);
|
||||
assert(distance(m.begin(), m.end()) == 9);
|
||||
C::const_iterator i = m.cbegin();
|
||||
assert(*i == V(1, 1));
|
||||
assert(*++i == V(1, 1.5));
|
||||
assert(*++i == V(1, 2));
|
||||
assert(*++i == V(2, 1));
|
||||
assert(*++i == V(2, 1.5));
|
||||
assert(*++i == V(2, 2));
|
||||
assert(*++i == V(3, 1));
|
||||
assert(*++i == V(3, 1.5));
|
||||
assert(*++i == V(3, 2));
|
||||
assert(m.key_comp() == Cmp(4));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef test_compare<std::less<int> > Cmp;
|
||||
typedef test_allocator<std::pair<const int, double> > A;
|
||||
typedef std::multimap<int, double, Cmp, A> C;
|
||||
typedef C::value_type V;
|
||||
C m(
|
||||
{
|
||||
{1, 1},
|
||||
{1, 1.5},
|
||||
{1, 2},
|
||||
{2, 1},
|
||||
{2, 1.5},
|
||||
{2, 2},
|
||||
{3, 1},
|
||||
{3, 1.5},
|
||||
{3, 2}
|
||||
},
|
||||
Cmp(4), A(5)
|
||||
);
|
||||
assert(m.size() == 9);
|
||||
assert(distance(m.begin(), m.end()) == 9);
|
||||
C::const_iterator i = m.cbegin();
|
||||
assert(*i == V(1, 1));
|
||||
assert(*++i == V(1, 1.5));
|
||||
assert(*++i == V(1, 2));
|
||||
assert(*++i == V(2, 1));
|
||||
assert(*++i == V(2, 1.5));
|
||||
assert(*++i == V(2, 2));
|
||||
assert(*++i == V(3, 1));
|
||||
assert(*++i == V(3, 1.5));
|
||||
assert(*++i == V(3, 2));
|
||||
assert(m.key_comp() == Cmp(4));
|
||||
assert(m.get_allocator() == A(5));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class InputIterator>
|
||||
// multimap(InputIterator first, InputIterator last);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 9);
|
||||
assert(distance(m.begin(), m.end()) == 9);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(1, 1.5));
|
||||
assert(*next(m.begin(), 2) == V(1, 2));
|
||||
assert(*next(m.begin(), 3) == V(2, 1));
|
||||
assert(*next(m.begin(), 4) == V(2, 1.5));
|
||||
assert(*next(m.begin(), 5) == V(2, 2));
|
||||
assert(*next(m.begin(), 6) == V(3, 1));
|
||||
assert(*next(m.begin(), 7) == V(3, 1.5));
|
||||
assert(*next(m.begin(), 8) == V(3, 2));
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class InputIterator>
|
||||
// multimap(InputIterator first, InputIterator last,
|
||||
// const key_compare& comp);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
std::multimap<int, double, C> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 9);
|
||||
assert(distance(m.begin(), m.end()) == 9);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(1, 1.5));
|
||||
assert(*next(m.begin(), 2) == V(1, 2));
|
||||
assert(*next(m.begin(), 3) == V(2, 1));
|
||||
assert(*next(m.begin(), 4) == V(2, 1.5));
|
||||
assert(*next(m.begin(), 5) == V(2, 2));
|
||||
assert(*next(m.begin(), 6) == V(3, 1));
|
||||
assert(*next(m.begin(), 7) == V(3, 1.5));
|
||||
assert(*next(m.begin(), 8) == V(3, 2));
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class InputIterator>
|
||||
// multimap(InputIterator first, InputIterator last,
|
||||
// const key_compare& comp, const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
|
||||
assert(m.get_allocator() == A(7));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 9);
|
||||
assert(distance(m.begin(), m.end()) == 9);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(1, 1.5));
|
||||
assert(*next(m.begin(), 2) == V(1, 2));
|
||||
assert(*next(m.begin(), 3) == V(2, 1));
|
||||
assert(*next(m.begin(), 4) == V(2, 1.5));
|
||||
assert(*next(m.begin(), 5) == V(2, 2));
|
||||
assert(*next(m.begin(), 6) == V(3, 1));
|
||||
assert(*next(m.begin(), 7) == V(3, 1.5));
|
||||
assert(*next(m.begin(), 8) == V(3, 2));
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap(multimap&& m);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef std::pair<const int, double> V;
|
||||
{
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::multimap<int, double, C, A> mo(C(5), A(7));
|
||||
std::multimap<int, double, C, A> m = std::move(mo);
|
||||
assert(m.get_allocator() == A(7));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 0);
|
||||
assert(distance(m.begin(), m.end()) == 0);
|
||||
|
||||
assert(mo.get_allocator() == A(7));
|
||||
assert(mo.key_comp() == C(5));
|
||||
assert(mo.size() == 0);
|
||||
assert(distance(mo.begin(), mo.end()) == 0);
|
||||
}
|
||||
{
|
||||
V ar[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 1.5),
|
||||
V(1, 2),
|
||||
V(2, 1),
|
||||
V(2, 1.5),
|
||||
V(2, 2),
|
||||
V(3, 1),
|
||||
V(3, 1.5),
|
||||
V(3, 2),
|
||||
};
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef test_allocator<V> A;
|
||||
std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
|
||||
std::multimap<int, double, C, A> m = std::move(mo);
|
||||
assert(m.get_allocator() == A(7));
|
||||
assert(m.key_comp() == C(5));
|
||||
assert(m.size() == 9);
|
||||
assert(distance(m.begin(), m.end()) == 9);
|
||||
assert(*m.begin() == V(1, 1));
|
||||
assert(*next(m.begin()) == V(1, 1.5));
|
||||
assert(*next(m.begin(), 2) == V(1, 2));
|
||||
assert(*next(m.begin(), 3) == V(2, 1));
|
||||
assert(*next(m.begin(), 4) == V(2, 1.5));
|
||||
assert(*next(m.begin(), 5) == V(2, 2));
|
||||
assert(*next(m.begin(), 6) == V(3, 1));
|
||||
assert(*next(m.begin(), 7) == V(3, 1.5));
|
||||
assert(*next(m.begin(), 8) == V(3, 2));
|
||||
|
||||
assert(mo.get_allocator() == A(7));
|
||||
assert(mo.key_comp() == C(5));
|
||||
assert(mo.size() == 0);
|
||||
assert(distance(mo.begin(), mo.end()) == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap(multimap&& m, const allocator_type& a);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef test_allocator<VC> A;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(std::move(m1), A(7));
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(7));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef test_allocator<VC> A;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(std::move(m1), A(5));
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(5));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef other_allocator<VC> A;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(std::move(m1), A(5));
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(5));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,147 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// multimap& operator=(multimap&& m);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "../../../test_compare.h"
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef test_allocator<VC> A;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(C(3), A(7));
|
||||
m3 = std::move(m1);
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(7));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef test_allocator<VC> A;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(C(3), A(5));
|
||||
m3 = std::move(m1);
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(5));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
{
|
||||
typedef std::pair<MoveOnly, MoveOnly> V;
|
||||
typedef std::pair<const MoveOnly, MoveOnly> VC;
|
||||
typedef test_compare<std::less<MoveOnly> > C;
|
||||
typedef other_allocator<VC> A;
|
||||
typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
|
||||
typedef std::move_iterator<V*> I;
|
||||
V a1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
|
||||
V a2[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(1, 2),
|
||||
V(1, 3),
|
||||
V(2, 1),
|
||||
V(2, 2),
|
||||
V(2, 3),
|
||||
V(3, 1),
|
||||
V(3, 2),
|
||||
V(3, 3)
|
||||
};
|
||||
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
|
||||
M m3(C(3), A(5));
|
||||
m3 = std::move(m1);
|
||||
assert(m3 == m2);
|
||||
assert(m3.get_allocator() == A(7));
|
||||
assert(m3.key_comp() == C(5));
|
||||
assert(m1.empty());
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// void clear();
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1.5),
|
||||
P(2, 2.5),
|
||||
P(3, 3.5),
|
||||
P(4, 4.5),
|
||||
P(5, 5.5),
|
||||
P(6, 6.5),
|
||||
P(7, 7.5),
|
||||
P(8, 8.5),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
m.clear();
|
||||
assert(m.size() == 0);
|
||||
}
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class... Args>
|
||||
// iterator emplace(Args&&... args);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../Emplaceable.h"
|
||||
#include "../../../DefaultOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::multimap<int, DefaultOnly> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
assert(DefaultOnly::count == 0);
|
||||
R r = m.emplace();
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 0);
|
||||
assert(m.begin()->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 1);
|
||||
r = m.emplace(1);
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
r = m.emplace(1);
|
||||
assert(r == next(m.begin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 3);
|
||||
}
|
||||
assert(DefaultOnly::count == 0);
|
||||
{
|
||||
typedef std::multimap<int, Emplaceable> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace(2);
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == Emplaceable());
|
||||
r = m.emplace(1, 2, 3.5);
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == Emplaceable(2, 3.5));
|
||||
r = m.emplace(1, 3, 3.5);
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == Emplaceable(3, 3.5));
|
||||
}
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace(M::value_type(2, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 3.5);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class... Args>
|
||||
// iterator emplace_hint(const_iterator position, Args&&... args);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../Emplaceable.h"
|
||||
#include "../../../DefaultOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::multimap<int, DefaultOnly> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
assert(DefaultOnly::count == 0);
|
||||
R r = m.emplace_hint(m.cend());
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 0);
|
||||
assert(m.begin()->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 1);
|
||||
r = m.emplace_hint(m.cend(), 1);
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
r = m.emplace_hint(m.cend(), 1);
|
||||
assert(r == next(m.begin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == DefaultOnly());
|
||||
assert(DefaultOnly::count == 3);
|
||||
}
|
||||
assert(DefaultOnly::count == 0);
|
||||
{
|
||||
typedef std::multimap<int, Emplaceable> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace_hint(m.cend(), 2);
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == Emplaceable());
|
||||
r = m.emplace_hint(m.cbegin(), 1, 2, 3.5);
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == Emplaceable(2, 3.5));
|
||||
r = m.emplace_hint(m.cbegin(), 1, 3, 3.5);
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == Emplaceable(3, 3.5));
|
||||
}
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace_hint(m.cend(), M::value_type(2, 3.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(m.begin()->first == 2);
|
||||
assert(m.begin()->second == 3.5);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,148 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator erase(const_iterator position);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::iterator I;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1),
|
||||
P(1, 1.5),
|
||||
P(1, 2),
|
||||
P(2, 1),
|
||||
P(2, 1.5),
|
||||
P(2, 2),
|
||||
P(3, 1),
|
||||
P(3, 1.5),
|
||||
P(3, 2),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 9);
|
||||
I i = m.erase(next(m.cbegin(), 3));
|
||||
assert(m.size() == 8);
|
||||
assert(i == next(m.begin(), 3));
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 1.5);
|
||||
assert(next(m.begin(), 4)->first == 2);
|
||||
assert(next(m.begin(), 4)->second == 2);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 1);
|
||||
assert(next(m.begin(), 6)->first == 3);
|
||||
assert(next(m.begin(), 6)->second == 1.5);
|
||||
assert(next(m.begin(), 7)->first == 3);
|
||||
assert(next(m.begin(), 7)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 0));
|
||||
assert(m.size() == 7);
|
||||
assert(i == m.begin());
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 2);
|
||||
assert(next(m.begin(), 2)->first == 2);
|
||||
assert(next(m.begin(), 2)->second == 1.5);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 2);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 1.5);
|
||||
assert(next(m.begin(), 6)->first == 3);
|
||||
assert(next(m.begin(), 6)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 5));
|
||||
assert(m.size() == 6);
|
||||
assert(i == prev(m.end()));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 2);
|
||||
assert(next(m.begin(), 2)->first == 2);
|
||||
assert(next(m.begin(), 2)->second == 1.5);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 2);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 1));
|
||||
assert(m.size() == 5);
|
||||
assert(i == next(m.begin()));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 2);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 2);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2));
|
||||
assert(m.size() == 4);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 2);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 1);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 2);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 0));
|
||||
assert(m.size() == 2);
|
||||
assert(i == next(m.begin(), 0));
|
||||
assert(next(m.begin(), 0)->first == 2);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
assert(next(m.begin(), 1)->first == 3);
|
||||
assert(next(m.begin(), 1)->second == 2);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 1));
|
||||
assert(m.size() == 1);
|
||||
assert(i == m.end());
|
||||
assert(next(m.begin(), 0)->first == 2);
|
||||
assert(next(m.begin(), 0)->second == 1.5);
|
||||
|
||||
i = m.erase(m.cbegin());
|
||||
assert(m.size() == 0);
|
||||
assert(i == m.begin());
|
||||
assert(i == m.end());
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator erase(const_iterator first, const_iterator last);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::iterator I;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1.5),
|
||||
P(2, 2.5),
|
||||
P(3, 3.5),
|
||||
P(4, 4.5),
|
||||
P(5, 5.5),
|
||||
P(6, 6.5),
|
||||
P(7, 7.5),
|
||||
P(8, 8.5),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
I i = m.erase(m.cbegin(), m.cbegin());
|
||||
assert(m.size() == 8);
|
||||
assert(i == m.begin());
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1.5);
|
||||
assert(next(m.begin())->first == 2);
|
||||
assert(next(m.begin())->second == 2.5);
|
||||
assert(next(m.begin(), 2)->first == 3);
|
||||
assert(next(m.begin(), 2)->second == 3.5);
|
||||
assert(next(m.begin(), 3)->first == 4);
|
||||
assert(next(m.begin(), 3)->second == 4.5);
|
||||
assert(next(m.begin(), 4)->first == 5);
|
||||
assert(next(m.begin(), 4)->second == 5.5);
|
||||
assert(next(m.begin(), 5)->first == 6);
|
||||
assert(next(m.begin(), 5)->second == 6.5);
|
||||
assert(next(m.begin(), 6)->first == 7);
|
||||
assert(next(m.begin(), 6)->second == 7.5);
|
||||
assert(next(m.begin(), 7)->first == 8);
|
||||
assert(next(m.begin(), 7)->second == 8.5);
|
||||
|
||||
i = m.erase(m.cbegin(), next(m.cbegin(), 2));
|
||||
assert(m.size() == 6);
|
||||
assert(i == m.begin());
|
||||
assert(next(m.begin(), 0)->first == 3);
|
||||
assert(next(m.begin(), 0)->second == 3.5);
|
||||
assert(next(m.begin(), 1)->first == 4);
|
||||
assert(next(m.begin(), 1)->second == 4.5);
|
||||
assert(next(m.begin(), 2)->first == 5);
|
||||
assert(next(m.begin(), 2)->second == 5.5);
|
||||
assert(next(m.begin(), 3)->first == 6);
|
||||
assert(next(m.begin(), 3)->second == 6.5);
|
||||
assert(next(m.begin(), 4)->first == 7);
|
||||
assert(next(m.begin(), 4)->second == 7.5);
|
||||
assert(next(m.begin(), 5)->first == 8);
|
||||
assert(next(m.begin(), 5)->second == 8.5);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
|
||||
assert(m.size() == 2);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(next(m.begin(), 0)->first == 3);
|
||||
assert(next(m.begin(), 0)->second == 3.5);
|
||||
assert(next(m.begin(), 1)->first == 4);
|
||||
assert(next(m.begin(), 1)->second == 4.5);
|
||||
|
||||
i = m.erase(m.cbegin(), m.cend());
|
||||
assert(m.size() == 0);
|
||||
assert(i == m.begin());
|
||||
assert(i == m.end());
|
||||
}
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// size_type erase(const key_type& k);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
typedef M::size_type I;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1),
|
||||
P(1, 1.5),
|
||||
P(1, 2),
|
||||
P(2, 1),
|
||||
P(2, 1.5),
|
||||
P(2, 2),
|
||||
P(3, 1),
|
||||
P(3, 1.5),
|
||||
P(3, 2),
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 9);
|
||||
I i = m.erase(2);
|
||||
assert(m.size() == 6);
|
||||
assert(i == 3);
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1.5);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
|
||||
i = m.erase(2);
|
||||
assert(m.size() == 6);
|
||||
assert(i == 0);
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 3);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 3);
|
||||
assert(next(m.begin(), 4)->second == 1.5);
|
||||
assert(next(m.begin(), 5)->first == 3);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
|
||||
i = m.erase(3);
|
||||
assert(m.size() == 3);
|
||||
assert(next(m.begin(), 0)->first == 1);
|
||||
assert(next(m.begin(), 0)->second == 1);
|
||||
assert(next(m.begin(), 1)->first == 1);
|
||||
assert(next(m.begin(), 1)->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
|
||||
i = m.erase(1);
|
||||
assert(m.size() == 0);
|
||||
assert(i == 3);
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator insert(const value_type& v);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(M::value_type(2, 2.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2.5);
|
||||
|
||||
r = m.insert(M::value_type(1, 1.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1.5);
|
||||
|
||||
r = m.insert(M::value_type(3, 3.5));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3.5);
|
||||
|
||||
r = m.insert(M::value_type(3, 3.5));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3.5);
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// void insert(initializer_list<value_type> il);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
typedef std::multimap<int, double> C;
|
||||
typedef C::value_type V;
|
||||
C m =
|
||||
{
|
||||
{1, 1},
|
||||
{1, 2},
|
||||
{2, 1},
|
||||
{2, 2},
|
||||
{3, 1},
|
||||
{3, 2}
|
||||
};
|
||||
m.insert(
|
||||
{
|
||||
{1, 1.5},
|
||||
{2, 1.5},
|
||||
{3, 1.5},
|
||||
}
|
||||
);
|
||||
assert(m.size() == 9);
|
||||
assert(distance(m.begin(), m.end()) == 9);
|
||||
C::const_iterator i = m.cbegin();
|
||||
assert(*i == V(1, 1));
|
||||
assert(*++i == V(1, 2));
|
||||
assert(*++i == V(1, 1.5));
|
||||
assert(*++i == V(2, 1));
|
||||
assert(*++i == V(2, 2));
|
||||
assert(*++i == V(2, 1.5));
|
||||
assert(*++i == V(3, 1));
|
||||
assert(*++i == V(3, 2));
|
||||
assert(*++i == V(3, 1.5));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator insert(const_iterator position, const value_type& v);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(m.end(), M::value_type(2, 2.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2.5);
|
||||
|
||||
r = m.insert(m.end(), M::value_type(1, 1.5));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1.5);
|
||||
|
||||
r = m.insert(m.end(), M::value_type(3, 3.5));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3.5);
|
||||
|
||||
r = m.insert(prev(m.end()), M::value_type(3, 4.5));
|
||||
assert(r == prev(m.end(), 2));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 4.5);
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class InputIterator>
|
||||
// void insert(InputIterator first, InputIterator last);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
typedef std::pair<int, double> P;
|
||||
P ar[] =
|
||||
{
|
||||
P(1, 1),
|
||||
P(1, 1.5),
|
||||
P(1, 2),
|
||||
P(2, 1),
|
||||
P(2, 1.5),
|
||||
P(2, 2),
|
||||
P(3, 1),
|
||||
P(3, 1.5),
|
||||
P(3, 2),
|
||||
};
|
||||
M m;
|
||||
m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
|
||||
assert(m.size() == 9);
|
||||
assert(m.begin()->first == 1);
|
||||
assert(m.begin()->second == 1);
|
||||
assert(next(m.begin())->first == 1);
|
||||
assert(next(m.begin())->second == 1.5);
|
||||
assert(next(m.begin(), 2)->first == 1);
|
||||
assert(next(m.begin(), 2)->second == 2);
|
||||
assert(next(m.begin(), 3)->first == 2);
|
||||
assert(next(m.begin(), 3)->second == 1);
|
||||
assert(next(m.begin(), 4)->first == 2);
|
||||
assert(next(m.begin(), 4)->second == 1.5);
|
||||
assert(next(m.begin(), 5)->first == 2);
|
||||
assert(next(m.begin(), 5)->second == 2);
|
||||
assert(next(m.begin(), 6)->first == 3);
|
||||
assert(next(m.begin(), 6)->second == 1);
|
||||
assert(next(m.begin(), 7)->first == 3);
|
||||
assert(next(m.begin(), 7)->second == 1.5);
|
||||
assert(next(m.begin(), 8)->first == 3);
|
||||
assert(next(m.begin(), 8)->second == 2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class P>
|
||||
// iterator insert(const_iterator position, P&& p);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::multimap<int, MoveOnly> M;
|
||||
typedef std::pair<int, MoveOnly> P;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(m.cend(), P(2, 2));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2);
|
||||
|
||||
r = m.insert(m.cend(), P(1, 1));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1);
|
||||
|
||||
r = m.insert(m.cend(), P(3, 3));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3);
|
||||
|
||||
r = m.insert(m.cend(), P(3, 2));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 2);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class P>
|
||||
// iterator insert(P&& p);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../MoveOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::multimap<int, MoveOnly> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.insert(M::value_type(2, 2));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(r->first == 2);
|
||||
assert(r->second == 2);
|
||||
|
||||
r = m.insert(M::value_type(1, 1));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(r->first == 1);
|
||||
assert(r->second == 1);
|
||||
|
||||
r = m.insert(M::value_type(3, 3));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 3);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3);
|
||||
|
||||
r = m.insert(M::value_type(3, 3));
|
||||
assert(r == prev(m.end()));
|
||||
assert(m.size() == 4);
|
||||
assert(r->first == 3);
|
||||
assert(r->second == 3);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// size_type count(const key_type& k) const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::multimap<int, double> M;
|
||||
{
|
||||
typedef M::size_type R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 1),
|
||||
V(5, 2),
|
||||
V(5, 3),
|
||||
V(7, 1),
|
||||
V(7, 2),
|
||||
V(7, 3),
|
||||
V(9, 1),
|
||||
V(9, 2),
|
||||
V(9, 3)
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.count(4);
|
||||
assert(r == 0);
|
||||
r = m.count(5);
|
||||
assert(r == 3);
|
||||
r = m.count(6);
|
||||
assert(r == 0);
|
||||
r = m.count(7);
|
||||
assert(r == 3);
|
||||
r = m.count(8);
|
||||
assert(r == 0);
|
||||
r = m.count(9);
|
||||
assert(r == 3);
|
||||
r = m.count(10);
|
||||
assert(r == 0);
|
||||
}
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// pair<iterator, iterator> equal_range(const key_type& k);
|
||||
// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::multimap<int, double> M;
|
||||
{
|
||||
typedef std::pair<M::iterator, M::iterator> R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 1),
|
||||
V(5, 2),
|
||||
V(5, 3),
|
||||
V(7, 1),
|
||||
V(7, 2),
|
||||
V(7, 3),
|
||||
V(9, 1),
|
||||
V(9, 2),
|
||||
V(9, 3)
|
||||
};
|
||||
M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.equal_range(4);
|
||||
assert(r.first == m.begin());
|
||||
assert(r.second == m.begin());
|
||||
r = m.equal_range(5);
|
||||
assert(r.first == m.begin());
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(6);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(7);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(8);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(9);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 9));
|
||||
r = m.equal_range(10);
|
||||
assert(r.first == m.end());
|
||||
assert(r.second == m.end());
|
||||
}
|
||||
{
|
||||
typedef std::pair<M::const_iterator, M::const_iterator> R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 1),
|
||||
V(5, 2),
|
||||
V(5, 3),
|
||||
V(7, 1),
|
||||
V(7, 2),
|
||||
V(7, 3),
|
||||
V(9, 1),
|
||||
V(9, 2),
|
||||
V(9, 3)
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.equal_range(4);
|
||||
assert(r.first == m.begin());
|
||||
assert(r.second == m.begin());
|
||||
r = m.equal_range(5);
|
||||
assert(r.first == m.begin());
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(6);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(7);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(8);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(9);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 9));
|
||||
r = m.equal_range(10);
|
||||
assert(r.first == m.end());
|
||||
assert(r.second == m.end());
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator find(const key_type& k);
|
||||
// const_iterator find(const key_type& k) const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::multimap<int, double> M;
|
||||
{
|
||||
typedef M::iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 1),
|
||||
V(5, 2),
|
||||
V(5, 3),
|
||||
V(7, 1),
|
||||
V(7, 2),
|
||||
V(7, 3),
|
||||
V(9, 1),
|
||||
V(9, 2),
|
||||
V(9, 3)
|
||||
};
|
||||
M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.find(5);
|
||||
assert(r == m.begin());
|
||||
r = m.find(6);
|
||||
assert(r == m.end());
|
||||
r = m.find(7);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.find(8);
|
||||
assert(r == m.end());
|
||||
r = m.find(9);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.find(10);
|
||||
assert(r == m.end());
|
||||
}
|
||||
{
|
||||
typedef M::const_iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 1),
|
||||
V(5, 2),
|
||||
V(5, 3),
|
||||
V(7, 1),
|
||||
V(7, 2),
|
||||
V(7, 3),
|
||||
V(9, 1),
|
||||
V(9, 2),
|
||||
V(9, 3)
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.find(5);
|
||||
assert(r == m.begin());
|
||||
r = m.find(6);
|
||||
assert(r == m.end());
|
||||
r = m.find(7);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.find(8);
|
||||
assert(r == m.end());
|
||||
r = m.find(9);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.find(10);
|
||||
assert(r == m.end());
|
||||
}
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator lower_bound(const key_type& k);
|
||||
// const_iterator lower_bound(const key_type& k) const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::multimap<int, double> M;
|
||||
{
|
||||
typedef M::iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 1),
|
||||
V(5, 2),
|
||||
V(5, 3),
|
||||
V(7, 1),
|
||||
V(7, 2),
|
||||
V(7, 3),
|
||||
V(9, 1),
|
||||
V(9, 2),
|
||||
V(9, 3)
|
||||
};
|
||||
M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.lower_bound(4);
|
||||
assert(r == m.begin());
|
||||
r = m.lower_bound(5);
|
||||
assert(r == m.begin());
|
||||
r = m.lower_bound(6);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.lower_bound(7);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.lower_bound(8);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.lower_bound(9);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.lower_bound(10);
|
||||
assert(r == m.end());
|
||||
}
|
||||
{
|
||||
typedef M::const_iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 1),
|
||||
V(5, 2),
|
||||
V(5, 3),
|
||||
V(7, 1),
|
||||
V(7, 2),
|
||||
V(7, 3),
|
||||
V(9, 1),
|
||||
V(9, 2),
|
||||
V(9, 3)
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.lower_bound(4);
|
||||
assert(r == m.begin());
|
||||
r = m.lower_bound(5);
|
||||
assert(r == m.begin());
|
||||
r = m.lower_bound(6);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.lower_bound(7);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.lower_bound(8);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.lower_bound(9);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.lower_bound(10);
|
||||
assert(r == m.end());
|
||||
}
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// iterator upper_bound(const key_type& k);
|
||||
// const_iterator upper_bound(const key_type& k) const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::multimap<int, double> M;
|
||||
{
|
||||
typedef M::iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 1),
|
||||
V(5, 2),
|
||||
V(5, 3),
|
||||
V(7, 1),
|
||||
V(7, 2),
|
||||
V(7, 3),
|
||||
V(9, 1),
|
||||
V(9, 2),
|
||||
V(9, 3)
|
||||
};
|
||||
M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.upper_bound(4);
|
||||
assert(r == m.begin());
|
||||
r = m.upper_bound(5);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.upper_bound(6);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.upper_bound(7);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.upper_bound(8);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.upper_bound(9);
|
||||
assert(r == next(m.begin(), 9));
|
||||
r = m.upper_bound(10);
|
||||
assert(r == m.end());
|
||||
}
|
||||
{
|
||||
typedef M::const_iterator R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 1),
|
||||
V(5, 2),
|
||||
V(5, 3),
|
||||
V(7, 1),
|
||||
V(7, 2),
|
||||
V(7, 3),
|
||||
V(9, 1),
|
||||
V(9, 2),
|
||||
V(9, 3)
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.upper_bound(4);
|
||||
assert(r == m.begin());
|
||||
r = m.upper_bound(5);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.upper_bound(6);
|
||||
assert(r == next(m.begin(), 3));
|
||||
r = m.upper_bound(7);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.upper_bound(8);
|
||||
assert(r == next(m.begin(), 6));
|
||||
r = m.upper_bound(9);
|
||||
assert(r == next(m.begin(), 9));
|
||||
r = m.upper_bound(10);
|
||||
assert(r == m.end());
|
||||
}
|
||||
}
|
@@ -0,0 +1,107 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// void swap(multimap& m);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::multimap<int, double> M;
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
m1.swap(m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
m1.swap(m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
m1.swap(m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
m1.swap(m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
}
|
@@ -0,0 +1,179 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// template <class Key, class T, class Compare, class Allocator>
|
||||
// void
|
||||
// swap(multimap<Key, T, Compare, Allocator>& x, multimap<Key, T, Compare, Allocator>& y);
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
#include "../../../test_allocator.h"
|
||||
#include "../../../test_compare.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
typedef std::multimap<int, double> M;
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
}
|
||||
{
|
||||
typedef test_allocator<V> A;
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef std::multimap<int, double, C, A> M;
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
assert(m1.key_comp() == C(2));
|
||||
assert(m1.get_allocator() == A(1));
|
||||
assert(m2.key_comp() == C(1));
|
||||
assert(m2.get_allocator() == A(2));
|
||||
}
|
||||
{
|
||||
typedef other_allocator<V> A;
|
||||
typedef test_compare<std::less<int> > C;
|
||||
typedef std::multimap<int, double, C, A> M;
|
||||
V ar1[] =
|
||||
{
|
||||
V(1, 1),
|
||||
V(2, 2),
|
||||
V(3, 3),
|
||||
V(4, 4)
|
||||
};
|
||||
V ar2[] =
|
||||
{
|
||||
V(5, 5),
|
||||
V(6, 6),
|
||||
V(7, 7),
|
||||
V(8, 8),
|
||||
V(9, 9),
|
||||
V(10, 10),
|
||||
V(11, 11),
|
||||
V(12, 12)
|
||||
};
|
||||
M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
|
||||
M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
|
||||
M m1_save = m1;
|
||||
M m2_save = m2;
|
||||
swap(m1, m2);
|
||||
assert(m1 == m2_save);
|
||||
assert(m2 == m1_save);
|
||||
assert(m1.key_comp() == C(2));
|
||||
assert(m1.get_allocator() == A(2));
|
||||
assert(m2.key_comp() == C(1));
|
||||
assert(m2.get_allocator() == A(1));
|
||||
}
|
||||
}
|
36
test/containers/associative/multimap/size.pass.cpp
Normal file
36
test/containers/associative/multimap/size.pass.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// size_type size() const;
|
||||
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
M m;
|
||||
assert(m.size() == 0);
|
||||
m.insert(M::value_type(2, 1.5));
|
||||
assert(m.size() == 1);
|
||||
m.insert(M::value_type(1, 1.5));
|
||||
assert(m.size() == 2);
|
||||
m.insert(M::value_type(3, 1.5));
|
||||
assert(m.size() == 3);
|
||||
m.erase(m.begin());
|
||||
assert(m.size() == 2);
|
||||
m.erase(m.begin());
|
||||
assert(m.size() == 1);
|
||||
m.erase(m.begin());
|
||||
assert(m.size() == 0);
|
||||
}
|
48
test/containers/associative/multimap/types.pass.cpp
Normal file
48
test/containers/associative/multimap/types.pass.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// template <class Key, class T, class Compare = less<Key>,
|
||||
// class Allocator = allocator<pair<const Key, T>>>
|
||||
// class multimap
|
||||
// {
|
||||
// public:
|
||||
// // types:
|
||||
// typedef Key key_type;
|
||||
// typedef T mapped_type;
|
||||
// typedef pair<const key_type, mapped_type> value_type;
|
||||
// typedef Compare key_compare;
|
||||
// typedef Allocator allocator_type;
|
||||
// typedef typename allocator_type::reference reference;
|
||||
// typedef typename allocator_type::const_reference const_reference;
|
||||
// typedef typename allocator_type::pointer pointer;
|
||||
// typedef typename allocator_type::const_pointer const_pointer;
|
||||
// typedef typename allocator_type::size_type size_type;
|
||||
// typedef typename allocator_type::difference_type difference_type;
|
||||
// ...
|
||||
// };
|
||||
|
||||
#include <map>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_same<std::multimap<int, double>::key_type, int>::value), "");
|
||||
static_assert((std::is_same<std::multimap<int, double>::mapped_type, double>::value), "");
|
||||
static_assert((std::is_same<std::multimap<int, double>::value_type, std::pair<const int, double> >::value), "");
|
||||
static_assert((std::is_same<std::multimap<int, double>::key_compare, std::less<int> >::value), "");
|
||||
static_assert((std::is_same<std::multimap<int, double>::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
|
||||
static_assert((std::is_same<std::multimap<int, double>::reference, std::pair<const int, double>&>::value), "");
|
||||
static_assert((std::is_same<std::multimap<int, double>::const_reference, const std::pair<const int, double>&>::value), "");
|
||||
static_assert((std::is_same<std::multimap<int, double>::pointer, std::pair<const int, double>*>::value), "");
|
||||
static_assert((std::is_same<std::multimap<int, double>::const_pointer, const std::pair<const int, double>*>::value), "");
|
||||
static_assert((std::is_same<std::multimap<int, double>::size_type, std::size_t>::value), "");
|
||||
static_assert((std::is_same<std::multimap<int, double>::difference_type, std::ptrdiff_t>::value), "");
|
||||
}
|
40
test/containers/associative/multiset/clear.pass.cpp
Normal file
40
test/containers/associative/multiset/clear.pass.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class multiset
|
||||
|
||||
// void clear();
|
||||
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multiset<int> M;
|
||||
typedef int V;
|
||||
V ar[] =
|
||||
{
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
m.clear();
|
||||
assert(m.size() == 0);
|
||||
}
|
||||
}
|
53
test/containers/associative/multiset/count.pass.cpp
Normal file
53
test/containers/associative/multiset/count.pass.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class multiset
|
||||
|
||||
// size_type count(const key_type& k) const;
|
||||
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef int V;
|
||||
typedef std::multiset<int> M;
|
||||
{
|
||||
typedef M::size_type R;
|
||||
V ar[] =
|
||||
{
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
9,
|
||||
9
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.count(4);
|
||||
assert(r == 0);
|
||||
r = m.count(5);
|
||||
assert(r == 4);
|
||||
r = m.count(6);
|
||||
assert(r == 0);
|
||||
r = m.count(7);
|
||||
assert(r == 3);
|
||||
r = m.count(8);
|
||||
assert(r == 0);
|
||||
r = m.count(9);
|
||||
assert(r == 2);
|
||||
r = m.count(10);
|
||||
assert(r == 0);
|
||||
}
|
||||
}
|
71
test/containers/associative/multiset/emplace.pass.cpp
Normal file
71
test/containers/associative/multiset/emplace.pass.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class multiset
|
||||
|
||||
// template <class... Args>
|
||||
// iterator emplace(Args&&... args);
|
||||
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../Emplaceable.h"
|
||||
#include "../../DefaultOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::multiset<DefaultOnly> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
assert(DefaultOnly::count == 0);
|
||||
R r = m.emplace();
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(*m.begin() == DefaultOnly());
|
||||
assert(DefaultOnly::count == 1);
|
||||
|
||||
r = m.emplace();
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(*m.begin() == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
}
|
||||
assert(DefaultOnly::count == 0);
|
||||
{
|
||||
typedef std::multiset<Emplaceable> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace();
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(*m.begin() == Emplaceable());
|
||||
r = m.emplace(2, 3.5);
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(*r == Emplaceable(2, 3.5));
|
||||
r = m.emplace(2, 3.5);
|
||||
assert(r == next(m.begin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(*r == Emplaceable(2, 3.5));
|
||||
}
|
||||
{
|
||||
typedef std::multiset<int> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace(M::value_type(2));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(*r == 2);
|
||||
}
|
||||
#endif
|
||||
}
|
71
test/containers/associative/multiset/emplace_hint.pass.cpp
Normal file
71
test/containers/associative/multiset/emplace_hint.pass.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class multiset
|
||||
|
||||
// template <class... Args>
|
||||
// iterator emplace_hint(const_iterator position, Args&&... args);
|
||||
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../Emplaceable.h"
|
||||
#include "../../DefaultOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
{
|
||||
typedef std::multiset<DefaultOnly> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
assert(DefaultOnly::count == 0);
|
||||
R r = m.emplace_hint(m.cend());
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(*m.begin() == DefaultOnly());
|
||||
assert(DefaultOnly::count == 1);
|
||||
|
||||
r = m.emplace_hint(m.cbegin());
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 2);
|
||||
assert(*m.begin() == DefaultOnly());
|
||||
assert(DefaultOnly::count == 2);
|
||||
}
|
||||
assert(DefaultOnly::count == 0);
|
||||
{
|
||||
typedef std::multiset<Emplaceable> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace_hint(m.cend());
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(*m.begin() == Emplaceable());
|
||||
r = m.emplace_hint(m.cend(), 2, 3.5);
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 2);
|
||||
assert(*r == Emplaceable(2, 3.5));
|
||||
r = m.emplace_hint(m.cbegin(), 2, 3.5);
|
||||
assert(r == next(m.begin()));
|
||||
assert(m.size() == 3);
|
||||
assert(*r == Emplaceable(2, 3.5));
|
||||
}
|
||||
{
|
||||
typedef std::multiset<int> M;
|
||||
typedef M::iterator R;
|
||||
M m;
|
||||
R r = m.emplace_hint(m.cend(), M::value_type(2));
|
||||
assert(r == m.begin());
|
||||
assert(m.size() == 1);
|
||||
assert(*r == 2);
|
||||
}
|
||||
#endif
|
||||
}
|
28
test/containers/associative/multiset/empty.pass.cpp
Normal file
28
test/containers/associative/multiset/empty.pass.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class multiset
|
||||
|
||||
// bool empty() const;
|
||||
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::multiset<int> M;
|
||||
M m;
|
||||
assert(m.empty());
|
||||
m.insert(M::value_type(1));
|
||||
assert(!m.empty());
|
||||
m.clear();
|
||||
assert(m.empty());
|
||||
}
|
98
test/containers/associative/multiset/equal_range.pass.cpp
Normal file
98
test/containers/associative/multiset/equal_range.pass.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class multiset
|
||||
|
||||
// pair<iterator,iterator> equal_range(const key_type& k);
|
||||
// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
|
||||
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef int V;
|
||||
typedef std::multiset<int> M;
|
||||
{
|
||||
typedef std::pair<M::iterator, M::iterator> R;
|
||||
V ar[] =
|
||||
{
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
9,
|
||||
9,
|
||||
9
|
||||
};
|
||||
M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.equal_range(4);
|
||||
assert(r.first == next(m.begin(), 0));
|
||||
assert(r.second == next(m.begin(), 0));
|
||||
r = m.equal_range(5);
|
||||
assert(r.first == next(m.begin(), 0));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(6);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(7);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(8);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(9);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 9));
|
||||
r = m.equal_range(10);
|
||||
assert(r.first == next(m.begin(), 9));
|
||||
assert(r.second == next(m.begin(), 9));
|
||||
}
|
||||
{
|
||||
typedef std::pair<M::const_iterator, M::const_iterator> R;
|
||||
V ar[] =
|
||||
{
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
9,
|
||||
9,
|
||||
9
|
||||
};
|
||||
M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.equal_range(4);
|
||||
assert(r.first == next(m.begin(), 0));
|
||||
assert(r.second == next(m.begin(), 0));
|
||||
r = m.equal_range(5);
|
||||
assert(r.first == next(m.begin(), 0));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(6);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(7);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(8);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(9);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 9));
|
||||
r = m.equal_range(10);
|
||||
assert(r.first == next(m.begin(), 9));
|
||||
assert(r.second == next(m.begin(), 9));
|
||||
}
|
||||
}
|
99
test/containers/associative/multiset/erase_iter.pass.cpp
Normal file
99
test/containers/associative/multiset/erase_iter.pass.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class multiset
|
||||
|
||||
// iterator erase(const_iterator position);
|
||||
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multiset<int> M;
|
||||
typedef int V;
|
||||
typedef M::iterator I;
|
||||
V ar[] =
|
||||
{
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
I i = m.erase(next(m.cbegin(), 3));
|
||||
assert(m.size() == 7);
|
||||
assert(i == next(m.begin(), 3));
|
||||
assert(*next(m.begin(), 0) == 1);
|
||||
assert(*next(m.begin(), 1) == 2);
|
||||
assert(*next(m.begin(), 2) == 3);
|
||||
assert(*next(m.begin(), 3) == 5);
|
||||
assert(*next(m.begin(), 4) == 6);
|
||||
assert(*next(m.begin(), 5) == 7);
|
||||
assert(*next(m.begin(), 6) == 8);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 0));
|
||||
assert(m.size() == 6);
|
||||
assert(i == m.begin());
|
||||
assert(*next(m.begin(), 0) == 2);
|
||||
assert(*next(m.begin(), 1) == 3);
|
||||
assert(*next(m.begin(), 2) == 5);
|
||||
assert(*next(m.begin(), 3) == 6);
|
||||
assert(*next(m.begin(), 4) == 7);
|
||||
assert(*next(m.begin(), 5) == 8);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 5));
|
||||
assert(m.size() == 5);
|
||||
assert(i == m.end());
|
||||
assert(*next(m.begin(), 0) == 2);
|
||||
assert(*next(m.begin(), 1) == 3);
|
||||
assert(*next(m.begin(), 2) == 5);
|
||||
assert(*next(m.begin(), 3) == 6);
|
||||
assert(*next(m.begin(), 4) == 7);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 1));
|
||||
assert(m.size() == 4);
|
||||
assert(i == next(m.begin()));
|
||||
assert(*next(m.begin(), 0) == 2);
|
||||
assert(*next(m.begin(), 1) == 5);
|
||||
assert(*next(m.begin(), 2) == 6);
|
||||
assert(*next(m.begin(), 3) == 7);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2));
|
||||
assert(m.size() == 3);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(*next(m.begin(), 0) == 2);
|
||||
assert(*next(m.begin(), 1) == 5);
|
||||
assert(*next(m.begin(), 2) == 7);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2));
|
||||
assert(m.size() == 2);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(*next(m.begin(), 0) == 2);
|
||||
assert(*next(m.begin(), 1) == 5);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 0));
|
||||
assert(m.size() == 1);
|
||||
assert(i == next(m.begin(), 0));
|
||||
assert(*next(m.begin(), 0) == 5);
|
||||
|
||||
i = m.erase(m.cbegin());
|
||||
assert(m.size() == 0);
|
||||
assert(i == m.begin());
|
||||
assert(i == m.end());
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class multiset
|
||||
|
||||
// iterator erase(const_iterator first, const_iterator last);
|
||||
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multiset<int> M;
|
||||
typedef int V;
|
||||
typedef M::iterator I;
|
||||
V ar[] =
|
||||
{
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 8);
|
||||
I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
|
||||
assert(m.size() == 8);
|
||||
assert(i == next(m.begin(), 5));
|
||||
assert(*next(m.begin(), 0) == 1);
|
||||
assert(*next(m.begin(), 1) == 2);
|
||||
assert(*next(m.begin(), 2) == 3);
|
||||
assert(*next(m.begin(), 3) == 4);
|
||||
assert(*next(m.begin(), 4) == 5);
|
||||
assert(*next(m.begin(), 5) == 6);
|
||||
assert(*next(m.begin(), 6) == 7);
|
||||
assert(*next(m.begin(), 7) == 8);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
|
||||
assert(m.size() == 7);
|
||||
assert(i == next(m.begin(), 3));
|
||||
assert(*next(m.begin(), 0) == 1);
|
||||
assert(*next(m.begin(), 1) == 2);
|
||||
assert(*next(m.begin(), 2) == 3);
|
||||
assert(*next(m.begin(), 3) == 5);
|
||||
assert(*next(m.begin(), 4) == 6);
|
||||
assert(*next(m.begin(), 5) == 7);
|
||||
assert(*next(m.begin(), 6) == 8);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
|
||||
assert(m.size() == 4);
|
||||
assert(i == next(m.begin(), 2));
|
||||
assert(*next(m.begin(), 0) == 1);
|
||||
assert(*next(m.begin(), 1) == 2);
|
||||
assert(*next(m.begin(), 2) == 7);
|
||||
assert(*next(m.begin(), 3) == 8);
|
||||
|
||||
i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
|
||||
assert(m.size() == 2);
|
||||
assert(i == next(m.begin(), 0));
|
||||
assert(*next(m.begin(), 0) == 7);
|
||||
assert(*next(m.begin(), 1) == 8);
|
||||
|
||||
i = m.erase(m.cbegin(), m.cend());
|
||||
assert(m.size() == 0);
|
||||
assert(i == m.end());
|
||||
}
|
||||
}
|
73
test/containers/associative/multiset/erase_key.pass.cpp
Normal file
73
test/containers/associative/multiset/erase_key.pass.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class multiset
|
||||
|
||||
// size_type erase(const key_type& k);
|
||||
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::multiset<int> M;
|
||||
typedef int V;
|
||||
typedef M::size_type I;
|
||||
V ar[] =
|
||||
{
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
7,
|
||||
7,
|
||||
7
|
||||
};
|
||||
M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
|
||||
assert(m.size() == 9);
|
||||
I i = m.erase(6);
|
||||
assert(m.size() == 9);
|
||||
assert(i == 0);
|
||||
assert(*next(m.begin(), 0) == 3);
|
||||
assert(*next(m.begin(), 1) == 3);
|
||||
assert(*next(m.begin(), 2) == 3);
|
||||
assert(*next(m.begin(), 3) == 5);
|
||||
assert(*next(m.begin(), 4) == 5);
|
||||
assert(*next(m.begin(), 5) == 5);
|
||||
assert(*next(m.begin(), 6) == 7);
|
||||
assert(*next(m.begin(), 7) == 7);
|
||||
assert(*next(m.begin(), 8) == 7);
|
||||
|
||||
i = m.erase(5);
|
||||
assert(m.size() == 6);
|
||||
assert(i == 3);
|
||||
assert(*next(m.begin(), 0) == 3);
|
||||
assert(*next(m.begin(), 1) == 3);
|
||||
assert(*next(m.begin(), 2) == 3);
|
||||
assert(*next(m.begin(), 3) == 7);
|
||||
assert(*next(m.begin(), 4) == 7);
|
||||
assert(*next(m.begin(), 5) == 7);
|
||||
|
||||
i = m.erase(3);
|
||||
assert(m.size() == 3);
|
||||
assert(i == 3);
|
||||
assert(*next(m.begin(), 0) == 7);
|
||||
assert(*next(m.begin(), 1) == 7);
|
||||
assert(*next(m.begin(), 2) == 7);
|
||||
|
||||
i = m.erase(7);
|
||||
assert(m.size() == 0);
|
||||
assert(i == 3);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user