1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <vector>
// template <class T, class Alloc>
// void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <vector>
#include <cassert>
#include "min_allocator.h"
int main()
{
#if _LIBCPP_DEBUG >= 1
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
std::vector<int>::iterator i1 = c1.begin();
std::vector<int>::iterator i2 = c2.begin();
swap(c1, c2);
c1.erase(i2);
c2.erase(i1);
c1.erase(i1);
assert(false);
}
#if __cplusplus >= 201103L
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
std::vector<int, min_allocator<int>>::iterator i1 = c1.begin();
std::vector<int, min_allocator<int>>::iterator i2 = c2.begin();
swap(c1, c2);
c1.erase(i2);
c2.erase(i1);
c1.erase(i1);
assert(false);
}
#endif
#endif
}
|