2010-05-11 21:42:16 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-05-11 23:36:01 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <set>
|
|
|
|
|
|
|
|
// class multiset
|
|
|
|
|
|
|
|
// void swap(multiset& m);
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
typedef int V;
|
|
|
|
typedef std::multiset<int> 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[] =
|
|
|
|
{
|
|
|
|
5,
|
|
|
|
6,
|
|
|
|
7,
|
|
|
|
8,
|
|
|
|
9,
|
|
|
|
10,
|
|
|
|
11,
|
|
|
|
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[] =
|
|
|
|
{
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
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[] =
|
|
|
|
{
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
4
|
|
|
|
};
|
|
|
|
V ar2[] =
|
|
|
|
{
|
|
|
|
5,
|
|
|
|
6,
|
|
|
|
7,
|
|
|
|
8,
|
|
|
|
9,
|
|
|
|
10,
|
|
|
|
11,
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|