Move test into test/std subdirectory.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// void clear();
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef std::set<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);
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<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);
}
#endif
}

View File

@@ -0,0 +1,168 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// size_type count(const key_type& k) const;
#include <set>
#include <cassert>
#include "min_allocator.h"
#include "private_constructor.hpp"
int main()
{
{
typedef int V;
typedef std::set<int> M;
typedef M::size_type R;
V ar[] =
{
5,
6,
7,
8,
9,
10,
11,
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);
}
#if __cplusplus >= 201103L
{
typedef int V;
typedef std::set<int, std::less<int>, min_allocator<int>> M;
typedef M::size_type R;
V ar[] =
{
5,
6,
7,
8,
9,
10,
11,
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);
}
#endif
#if _LIBCPP_STD_VER > 11
{
typedef int V;
typedef std::set<int, std::less<>> M;
typedef M::size_type R;
V ar[] =
{
5,
6,
7,
8,
9,
10,
11,
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);
}
{
typedef PrivateConstructor V;
typedef std::set<V, std::less<>> M;
typedef M::size_type R;
M m;
m.insert ( V::make ( 5 ));
m.insert ( V::make ( 6 ));
m.insert ( V::make ( 7 ));
m.insert ( V::make ( 8 ));
m.insert ( V::make ( 9 ));
m.insert ( V::make ( 10 ));
m.insert ( V::make ( 11 ));
m.insert ( V::make ( 12 ));
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);
}
#endif
}

View File

@@ -0,0 +1,90 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// template <class... Args>
// pair<iterator, bool> emplace(Args&&... args);
#include <set>
#include <cassert>
#include "../../Emplaceable.h"
#include "DefaultOnly.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::set<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() == DefaultOnly());
assert(DefaultOnly::count == 1);
r = m.emplace();
assert(!r.second);
assert(r.first == m.begin());
assert(m.size() == 1);
assert(*m.begin() == DefaultOnly());
assert(DefaultOnly::count == 1);
}
assert(DefaultOnly::count == 0);
{
typedef std::set<Emplaceable> M;
typedef std::pair<M::iterator, bool> R;
M m;
R r = m.emplace();
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 1);
assert(*m.begin() == Emplaceable());
r = m.emplace(2, 3.5);
assert(r.second);
assert(r.first == next(m.begin()));
assert(m.size() == 2);
assert(*r.first == Emplaceable(2, 3.5));
r = m.emplace(2, 3.5);
assert(!r.second);
assert(r.first == next(m.begin()));
assert(m.size() == 2);
assert(*r.first == Emplaceable(2, 3.5));
}
{
typedef std::set<int> M;
typedef std::pair<M::iterator, bool> R;
M m;
R r = m.emplace(M::value_type(2));
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 1);
assert(*r.first == 2);
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> M;
typedef std::pair<M::iterator, bool> R;
M m;
R r = m.emplace(M::value_type(2));
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 1);
assert(*r.first == 2);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// template <class... Args>
// iterator emplace_hint(const_iterator position, Args&&... args);
#include <set>
#include <cassert>
#include "../../Emplaceable.h"
#include "DefaultOnly.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::set<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() == 1);
assert(*m.begin() == DefaultOnly());
assert(DefaultOnly::count == 1);
}
assert(DefaultOnly::count == 0);
{
typedef std::set<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() == 2);
assert(*r == Emplaceable(2, 3.5));
}
{
typedef std::set<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);
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<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
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// bool empty() const;
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef std::set<int> M;
M m;
assert(m.empty());
m.insert(M::value_type(1));
assert(!m.empty());
m.clear();
assert(m.empty());
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> M;
M m;
assert(m.empty());
m.insert(M::value_type(1));
assert(!m.empty());
m.clear();
assert(m.empty());
}
#endif
}

View File

@@ -0,0 +1,370 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// 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>
#include "min_allocator.h"
#include "private_constructor.hpp"
int main()
{
{
typedef int V;
typedef std::set<int> M;
{
typedef std::pair<M::iterator, M::iterator> R;
V ar[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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));
}
}
#if __cplusplus >= 201103L
{
typedef int V;
typedef std::set<int, std::less<int>, min_allocator<int>> M;
typedef std::pair<M::iterator, M::iterator> R;
V ar[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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));
}
#endif
#if _LIBCPP_STD_VER > 11
{
typedef int V;
typedef std::set<V, std::less<>> M;
{
typedef std::pair<M::iterator, M::iterator> R;
V ar[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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 PrivateConstructor V;
typedef std::set<V, std::less<>> M;
typedef std::pair<M::iterator, M::iterator> R;
M m;
m.insert ( V::make ( 5 ));
m.insert ( V::make ( 7 ));
m.insert ( V::make ( 9 ));
m.insert ( V::make ( 11 ));
m.insert ( V::make ( 13 ));
m.insert ( V::make ( 15 ));
m.insert ( V::make ( 17 ));
m.insert ( V::make ( 19 ));
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));
}
#endif
}

View File

@@ -0,0 +1,181 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// iterator erase(const_iterator position);
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef std::set<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());
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<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());
}
#endif
}

View File

@@ -0,0 +1,141 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// iterator erase(const_iterator first, const_iterator last);
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef std::set<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());
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<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());
}
#endif
}

View File

@@ -0,0 +1,203 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// size_type erase(const key_type& k);
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef std::set<int> M;
typedef int V;
typedef M::size_type 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(9);
assert(m.size() == 8);
assert(i == 0);
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(4);
assert(m.size() == 7);
assert(i == 1);
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(1);
assert(m.size() == 6);
assert(i == 1);
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(8);
assert(m.size() == 5);
assert(i == 1);
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(3);
assert(m.size() == 4);
assert(i == 1);
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(6);
assert(m.size() == 3);
assert(i == 1);
assert(*next(m.begin(), 0) == 2);
assert(*next(m.begin(), 1) == 5);
assert(*next(m.begin(), 2) == 7);
i = m.erase(7);
assert(m.size() == 2);
assert(i == 1);
assert(*next(m.begin(), 0) == 2);
assert(*next(m.begin(), 1) == 5);
i = m.erase(2);
assert(m.size() == 1);
assert(i == 1);
assert(*next(m.begin(), 0) == 5);
i = m.erase(5);
assert(m.size() == 0);
assert(i == 1);
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> M;
typedef int V;
typedef M::size_type 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(9);
assert(m.size() == 8);
assert(i == 0);
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(4);
assert(m.size() == 7);
assert(i == 1);
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(1);
assert(m.size() == 6);
assert(i == 1);
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(8);
assert(m.size() == 5);
assert(i == 1);
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(3);
assert(m.size() == 4);
assert(i == 1);
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(6);
assert(m.size() == 3);
assert(i == 1);
assert(*next(m.begin(), 0) == 2);
assert(*next(m.begin(), 1) == 5);
assert(*next(m.begin(), 2) == 7);
i = m.erase(7);
assert(m.size() == 2);
assert(i == 1);
assert(*next(m.begin(), 0) == 2);
assert(*next(m.begin(), 1) == 5);
i = m.erase(2);
assert(m.size() == 1);
assert(i == 1);
assert(*next(m.begin(), 0) == 5);
i = m.erase(5);
assert(m.size() == 0);
assert(i == 1);
}
#endif
}

View File

@@ -0,0 +1,240 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// iterator find(const key_type& k);
// const_iterator find(const key_type& k) const;
#include <set>
#include <cassert>
#include "min_allocator.h"
#include "private_constructor.hpp"
int main()
{
{
typedef int V;
typedef std::set<int> M;
{
typedef M::iterator R;
V ar[] =
{
5,
6,
7,
8,
9,
10,
11,
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[] =
{
5,
6,
7,
8,
9,
10,
11,
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));
}
}
#if __cplusplus >= 201103L
{
typedef int V;
typedef std::set<int, std::less<int>, min_allocator<int>> M;
{
typedef M::iterator R;
V ar[] =
{
5,
6,
7,
8,
9,
10,
11,
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[] =
{
5,
6,
7,
8,
9,
10,
11,
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));
}
}
#endif
#if _LIBCPP_STD_VER > 11
{
typedef int V;
typedef std::set<V, std::less<>> M;
typedef M::iterator R;
V ar[] =
{
5,
6,
7,
8,
9,
10,
11,
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 PrivateConstructor V;
typedef std::set<V, std::less<>> M;
typedef M::iterator R;
M m;
m.insert ( V::make ( 5 ));
m.insert ( V::make ( 6 ));
m.insert ( V::make ( 7 ));
m.insert ( V::make ( 8 ));
m.insert ( V::make ( 9 ));
m.insert ( V::make ( 10 ));
m.insert ( V::make ( 11 ));
m.insert ( V::make ( 12 ));
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));
}
#endif
}

View File

@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// pair<iterator, bool> insert(const value_type& v);
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef std::set<int> M;
typedef std::pair<M::iterator, bool> R;
M m;
R r = m.insert(M::value_type(2));
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 1);
assert(*r.first == 2);
r = m.insert(M::value_type(1));
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 2);
assert(*r.first == 1);
r = m.insert(M::value_type(3));
assert(r.second);
assert(r.first == prev(m.end()));
assert(m.size() == 3);
assert(*r.first == 3);
r = m.insert(M::value_type(3));
assert(!r.second);
assert(r.first == prev(m.end()));
assert(m.size() == 3);
assert(*r.first == 3);
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> M;
typedef std::pair<M::iterator, bool> R;
M m;
R r = m.insert(M::value_type(2));
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 1);
assert(*r.first == 2);
r = m.insert(M::value_type(1));
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 2);
assert(*r.first == 1);
r = m.insert(M::value_type(3));
assert(r.second);
assert(r.first == prev(m.end()));
assert(m.size() == 3);
assert(*r.first == 3);
r = m.insert(M::value_type(3));
assert(!r.second);
assert(r.first == prev(m.end()));
assert(m.size() == 3);
assert(*r.first == 3);
}
#endif
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// void insert(initializer_list<value_type> il);
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
typedef std::set<int> C;
typedef C::value_type V;
C m = {10, 8};
m.insert({1, 2, 3, 4, 5, 6});
assert(m.size() == 8);
assert(distance(m.begin(), m.end()) == m.size());
C::const_iterator i = m.cbegin();
assert(*i == V(1));
assert(*++i == V(2));
assert(*++i == V(3));
assert(*++i == V(4));
assert(*++i == V(5));
assert(*++i == V(6));
assert(*++i == V(8));
assert(*++i == V(10));
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> C;
typedef C::value_type V;
C m = {10, 8};
m.insert({1, 2, 3, 4, 5, 6});
assert(m.size() == 8);
assert(distance(m.begin(), m.end()) == m.size());
C::const_iterator i = m.cbegin();
assert(*i == V(1));
assert(*++i == V(2));
assert(*++i == V(3));
assert(*++i == V(4));
assert(*++i == V(5));
assert(*++i == V(6));
assert(*++i == V(8));
assert(*++i == V(10));
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,73 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// iterator insert(const_iterator position, const value_type& v);
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef std::set<int> M;
typedef M::iterator R;
M m;
R r = m.insert(m.cend(), M::value_type(2));
assert(r == m.begin());
assert(m.size() == 1);
assert(*r == 2);
r = m.insert(m.cend(), M::value_type(1));
assert(r == m.begin());
assert(m.size() == 2);
assert(*r == 1);
r = m.insert(m.cend(), M::value_type(3));
assert(r == prev(m.end()));
assert(m.size() == 3);
assert(*r == 3);
r = m.insert(m.cend(), M::value_type(3));
assert(r == prev(m.end()));
assert(m.size() == 3);
assert(*r == 3);
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> M;
typedef M::iterator R;
M m;
R r = m.insert(m.cend(), M::value_type(2));
assert(r == m.begin());
assert(m.size() == 1);
assert(*r == 2);
r = m.insert(m.cend(), M::value_type(1));
assert(r == m.begin());
assert(m.size() == 2);
assert(*r == 1);
r = m.insert(m.cend(), M::value_type(3));
assert(r == prev(m.end()));
assert(m.size() == 3);
assert(*r == 3);
r = m.insert(m.cend(), M::value_type(3));
assert(r == prev(m.end()));
assert(m.size() == 3);
assert(*r == 3);
}
#endif
}

View File

@@ -0,0 +1,73 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// template <class InputIterator>
// void insert(InputIterator first, InputIterator last);
#include <set>
#include <cassert>
#include "test_iterators.h"
#include "min_allocator.h"
int main()
{
{
typedef std::set<int> M;
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
M m;
m.insert(input_iterator<const V*>(ar),
input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
assert(m.size() == 3);
assert(*m.begin() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> M;
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
M m;
m.insert(input_iterator<const V*>(ar),
input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
assert(m.size() == 3);
assert(*m.begin() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
}
#endif
}

View File

@@ -0,0 +1,76 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// iterator insert(const_iterator position, value_type&& v);
#include <set>
#include <cassert>
#include "../../MoveOnly.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::set<MoveOnly> M;
typedef M::iterator R;
M m;
R r = m.insert(m.cend(), M::value_type(2));
assert(r == m.begin());
assert(m.size() == 1);
assert(*r == 2);
r = m.insert(m.cend(), M::value_type(1));
assert(r == m.begin());
assert(m.size() == 2);
assert(*r == 1);
r = m.insert(m.cend(), M::value_type(3));
assert(r == prev(m.end()));
assert(m.size() == 3);
assert(*r == 3);
r = m.insert(m.cend(), M::value_type(3));
assert(r == prev(m.end()));
assert(m.size() == 3);
assert(*r == 3);
}
#if __cplusplus >= 201103L
{
typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
typedef M::iterator R;
M m;
R r = m.insert(m.cend(), M::value_type(2));
assert(r == m.begin());
assert(m.size() == 1);
assert(*r == 2);
r = m.insert(m.cend(), M::value_type(1));
assert(r == m.begin());
assert(m.size() == 2);
assert(*r == 1);
r = m.insert(m.cend(), M::value_type(3));
assert(r == prev(m.end()));
assert(m.size() == 3);
assert(*r == 3);
r = m.insert(m.cend(), M::value_type(3));
assert(r == prev(m.end()));
assert(m.size() == 3);
assert(*r == 3);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,84 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// pair<iterator, bool> insert(value_type&& v);
#include <set>
#include <cassert>
#include "../../MoveOnly.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::set<MoveOnly> M;
typedef std::pair<M::iterator, bool> R;
M m;
R r = m.insert(M::value_type(2));
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 1);
assert(*r.first == 2);
r = m.insert(M::value_type(1));
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 2);
assert(*r.first == 1);
r = m.insert(M::value_type(3));
assert(r.second);
assert(r.first == prev(m.end()));
assert(m.size() == 3);
assert(*r.first == 3);
r = m.insert(M::value_type(3));
assert(!r.second);
assert(r.first == prev(m.end()));
assert(m.size() == 3);
assert(*r.first == 3);
}
#if __cplusplus >= 201103L
{
typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
typedef std::pair<M::iterator, bool> R;
M m;
R r = m.insert(M::value_type(2));
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 1);
assert(*r.first == 2);
r = m.insert(M::value_type(1));
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 2);
assert(*r.first == 1);
r = m.insert(M::value_type(3));
assert(r.second);
assert(r.first == prev(m.end()));
assert(m.size() == 3);
assert(*r.first == 3);
r = m.insert(M::value_type(3));
assert(!r.second);
assert(r.first == prev(m.end()));
assert(m.size() == 3);
assert(*r.first == 3);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,211 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// 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 <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3,
4,
4,
4,
5,
5,
5,
6,
6,
6,
7,
7,
7,
8,
8,
8
};
std::set<int> 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::set<int>::iterator i;
i = m.begin();
std::set<int>::const_iterator k = i;
assert(i == k);
for (int j = 1; j <= m.size(); ++j, ++i)
assert(*i == j);
}
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3,
4,
4,
4,
5,
5,
5,
6,
6,
6,
7,
7,
7,
8,
8,
8
};
const std::set<int> 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::set<int>::const_iterator i;
i = m.begin();
for (int j = 1; j <= m.size(); ++j, ++i)
assert(*i == j);
}
#if __cplusplus >= 201103L
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3,
4,
4,
4,
5,
5,
5,
6,
6,
6,
7,
7,
7,
8,
8,
8
};
std::set<int, std::less<int>, min_allocator<int>> 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::set<int, std::less<int>, min_allocator<int>>::iterator i;
i = m.begin();
std::set<int, std::less<int>, min_allocator<int>>::const_iterator k = i;
assert(i == k);
for (int j = 1; j <= m.size(); ++j, ++i)
assert(*i == j);
}
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3,
4,
4,
4,
5,
5,
5,
6,
6,
6,
7,
7,
7,
8,
8,
8
};
const std::set<int, std::less<int>, min_allocator<int>> 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::set<int, std::less<int>, min_allocator<int>>::const_iterator i;
i = m.begin();
for (int j = 1; j <= m.size(); ++j, ++i)
assert(*i == j);
}
#endif
#if _LIBCPP_STD_VER > 11
{ // N3644 testing
typedef std::set<int> C;
C::iterator ii1{}, ii2{};
C::iterator ii4 = ii1;
C::const_iterator cii{};
assert ( ii1 == ii2 );
assert ( ii1 == ii4 );
assert (!(ii1 != ii2 ));
assert ( (ii1 == cii ));
assert ( (cii == ii1 ));
assert (!(ii1 != cii ));
assert (!(cii != ii1 ));
}
#endif
}

View File

@@ -0,0 +1,337 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// iterator lower_bound(const key_type& k);
// const_iterator lower_bound(const key_type& k) const;
#include <set>
#include <cassert>
#include "min_allocator.h"
#include "private_constructor.hpp"
int main()
{
{
typedef int V;
typedef std::set<int> M;
{
typedef M::iterator R;
V ar[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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));
}
}
#if __cplusplus >= 201103L
{
typedef int V;
typedef std::set<int, std::less<int>, min_allocator<int>> M;
{
typedef M::iterator R;
V ar[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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));
}
}
#endif
#if _LIBCPP_STD_VER > 11
{
typedef int V;
typedef std::set<V, std::less<>> M;
typedef M::iterator R;
V ar[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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 PrivateConstructor V;
typedef std::set<V, std::less<>> M;
typedef M::iterator R;
M m;
m.insert ( V::make ( 5 ));
m.insert ( V::make ( 7 ));
m.insert ( V::make ( 9 ));
m.insert ( V::make ( 11 ));
m.insert ( V::make ( 13 ));
m.insert ( V::make ( 15 ));
m.insert ( V::make ( 17 ));
m.insert ( V::make ( 19 ));
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));
}
#endif
}

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// size_type max_size() const;
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef std::set<int> M;
M m;
assert(m.max_size() != 0);
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> M;
M m;
assert(m.max_size() != 0);
}
#endif
}

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set(const allocator_type& a);
#include <set>
#include <cassert>
#include "test_allocator.h"
int main()
{
typedef std::less<int> C;
typedef test_allocator<int> A;
std::set<int, C, A> m(A(5));
assert(m.empty());
assert(m.begin() == m.end());
assert(m.get_allocator() == A(5));
}

View File

@@ -0,0 +1,57 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set& operator=(initializer_list<value_type> il);
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
typedef std::set<int> C;
typedef C::value_type V;
C m = {10, 8};
m = {1, 2, 3, 4, 5, 6};
assert(m.size() == 6);
assert(distance(m.begin(), m.end()) == 6);
C::const_iterator i = m.cbegin();
assert(*i == V(1));
assert(*++i == V(2));
assert(*++i == V(3));
assert(*++i == V(4));
assert(*++i == V(5));
assert(*++i == V(6));
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> C;
typedef C::value_type V;
C m = {10, 8};
m = {1, 2, 3, 4, 5, 6};
assert(m.size() == 6);
assert(distance(m.begin(), m.end()) == 6);
C::const_iterator i = m.cbegin();
assert(*i == V(1));
assert(*++i == V(2));
assert(*++i == V(3));
assert(*++i == V(4));
assert(*++i == V(5));
assert(*++i == V(6));
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// explicit set(const value_compare& comp);
#include <set>
#include <cassert>
#include "../../../test_compare.h"
int main()
{
typedef test_compare<std::less<int> > C;
std::set<int, C> m(C(3));
assert(m.empty());
assert(m.begin() == m.end());
assert(m.key_comp() == C(3));
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set(const value_compare& comp, const allocator_type& a);
#include <set>
#include <cassert>
#include "../../../test_compare.h"
#include "test_allocator.h"
int main()
{
typedef test_compare<std::less<int> > C;
typedef test_allocator<int> A;
std::set<int, 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));
}

View File

@@ -0,0 +1,94 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set(const set& m);
#include <set>
#include <cassert>
#include "../../../test_compare.h"
#include "test_allocator.h"
int main()
{
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
typedef test_compare<std::less<int> > C;
typedef test_allocator<V> A;
std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
std::set<int, 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() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
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() == 1);
assert(*next(mo.begin()) == 2);
assert(*next(mo.begin(), 2) == 3);
}
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
typedef test_compare<std::less<int> > C;
typedef other_allocator<V> A;
std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
std::set<int, 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() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
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() == 1);
assert(*next(mo.begin()) == 2);
assert(*next(mo.begin(), 2) == 3);
}
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
}

View File

@@ -0,0 +1,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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set(const set& m, const allocator_type& a);
#include <set>
#include <cassert>
#include "../../../test_compare.h"
#include "test_allocator.h"
int main()
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
typedef test_compare<std::less<int> > C;
typedef test_allocator<V> A;
std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
std::set<int, 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() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
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() == 1);
assert(*next(mo.begin()) == 2);
assert(*next(mo.begin(), 2) == 3);
}

View File

@@ -0,0 +1,109 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set& operator=(const set& s);
#include <set>
#include <cassert>
#include "../../../test_compare.h"
#include "test_allocator.h"
int main()
{
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
typedef test_compare<std::less<int> > C;
typedef test_allocator<V> A;
std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
std::set<int, 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() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
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() == 1);
assert(*next(mo.begin()) == 2);
assert(*next(mo.begin(), 2) == 3);
}
{
typedef int V;
const V ar[] =
{
1,
2,
3
};
std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
std::set<int> *p = &m;
m = *p;
assert(m.size() == 3);
assert(std::equal(m.begin(), m.end(), ar));
}
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
typedef test_compare<std::less<int> > C;
typedef other_allocator<V> A;
std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
std::set<int, 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() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
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() == 1);
assert(*next(mo.begin()) == 2);
assert(*next(mo.begin(), 2) == 3);
}
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set();
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
std::set<int> m;
assert(m.empty());
assert(m.begin() == m.end());
}
#if __cplusplus >= 201103L
{
std::set<int, std::less<int>, min_allocator<int>> m;
assert(m.empty());
assert(m.begin() == m.end());
}
{
std::set<int> m = {};
assert(m.empty());
assert(m.begin() == m.end());
}
#endif
}

View File

@@ -0,0 +1,53 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// set()
// noexcept(
// is_nothrow_default_constructible<allocator_type>::value &&
// is_nothrow_default_constructible<key_compare>::value &&
// is_nothrow_copy_constructible<key_compare>::value);
// This tests a conforming extension
#include <set>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp();
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::set<MoveOnly> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
{
typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// ~set() // implied noexcept;
#include <set>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
#if __has_feature(cxx_noexcept)
template <class T>
struct some_comp
{
typedef T value_type;
~some_comp() noexcept(false);
};
#endif
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::set<MoveOnly> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
}
{
typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_destructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
typedef std::set<int> C;
typedef C::value_type V;
C m = {1, 2, 3, 4, 5, 6};
assert(m.size() == 6);
assert(distance(m.begin(), m.end()) == 6);
C::const_iterator i = m.cbegin();
assert(*i == V(1));
assert(*++i == V(2));
assert(*++i == V(3));
assert(*++i == V(4));
assert(*++i == V(5));
assert(*++i == V(6));
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> C;
typedef C::value_type V;
C m = {1, 2, 3, 4, 5, 6};
assert(m.size() == 6);
assert(distance(m.begin(), m.end()) == 6);
C::const_iterator i = m.cbegin();
assert(*i == V(1));
assert(*++i == V(2));
assert(*++i == V(3));
assert(*++i == V(4));
assert(*++i == V(5));
assert(*++i == V(6));
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
#include <set>
#include <cassert>
#include "../../../test_compare.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
typedef test_compare<std::less<int> > Cmp;
typedef std::set<int, Cmp> C;
typedef C::value_type V;
C m({1, 2, 3, 4, 5, 6}, Cmp(10));
assert(m.size() == 6);
assert(distance(m.begin(), m.end()) == 6);
C::const_iterator i = m.cbegin();
assert(*i == V(1));
assert(*++i == V(2));
assert(*++i == V(3));
assert(*++i == V(4));
assert(*++i == V(5));
assert(*++i == V(6));
assert(m.key_comp() == Cmp(10));
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
// set(initializer_list<value_type> il, const allocator_type& a);
#include <set>
#include <cassert>
#include "../../../test_compare.h"
#include "test_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
typedef test_compare<std::less<int> > Cmp;
typedef test_allocator<int> A;
typedef std::set<int, Cmp, A> C;
typedef C::value_type V;
C m({1, 2, 3, 4, 5, 6}, Cmp(10), A(4));
assert(m.size() == 6);
assert(distance(m.begin(), m.end()) == 6);
C::const_iterator i = m.cbegin();
assert(*i == V(1));
assert(*++i == V(2));
assert(*++i == V(3));
assert(*++i == V(4));
assert(*++i == V(5));
assert(*++i == V(6));
assert(m.key_comp() == Cmp(10));
assert(m.get_allocator() == A(4));
}
#if _LIBCPP_STD_VER > 11
{
typedef test_compare<std::less<int> > Cmp;
typedef test_allocator<int> A;
typedef std::set<int, Cmp, A> C;
typedef C::value_type V;
C m({1, 2, 3, 4, 5, 6}, A(4));
assert(m.size() == 6);
assert(distance(m.begin(), m.end()) == 6);
C::const_iterator i = m.cbegin();
assert(*i == V(1));
assert(*++i == V(2));
assert(*++i == V(3));
assert(*++i == V(4));
assert(*++i == V(5));
assert(*++i == V(6));
assert(m.get_allocator() == A(4));
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// template <class InputIterator>
// set(InputIterator first, InputIterator last);
#include <set>
#include <cassert>
#include "test_iterators.h"
#include "min_allocator.h"
int main()
{
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
std::set<V> m(input_iterator<const int*>(ar),
input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
assert(m.size() == 3);
assert(distance(m.begin(), m.end()) == 3);
assert(*m.begin() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
}
#if __cplusplus >= 201103L
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
std::set<V, std::less<int>, min_allocator<int>> m(input_iterator<const int*>(ar),
input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
assert(m.size() == 3);
assert(distance(m.begin(), m.end()) == 3);
assert(*m.begin() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
}
#endif
}

View File

@@ -0,0 +1,84 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// template <class InputIterator>
// set(InputIterator first, InputIterator last,
// const value_compare& comp, const allocator_type& a);
//
// template <class InputIterator>
// set(InputIterator first, InputIterator last,
// const allocator_type& a);
#include <set>
#include <cassert>
#include "test_iterators.h"
#include "../../../test_compare.h"
#include "test_allocator.h"
int main()
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
typedef test_compare<std::less<V> > C;
typedef test_allocator<V> A;
std::set<V, C, A> m(input_iterator<const V*>(ar),
input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
C(5), A(7));
assert(m.value_comp() == C(5));
assert(m.get_allocator() == A(7));
assert(m.size() == 3);
assert(distance(m.begin(), m.end()) == 3);
assert(*m.begin() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
#if _LIBCPP_STD_VER > 11
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
typedef test_allocator<V> A;
typedef test_compare<std::less<int> > C;
A a(7);
std::set<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
assert(m.size() == 3);
assert(distance(m.begin(), m.end()) == 3);
assert(*m.begin() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
assert(m.get_allocator() == a);
}
#endif
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// template <class InputIterator>
// set(InputIterator first, InputIterator last, const value_compare& comp);
#include <set>
#include <cassert>
#include "test_iterators.h"
#include "../../../test_compare.h"
int main()
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
typedef test_compare<std::less<V> > C;
std::set<V, C> m(input_iterator<const V*>(ar),
input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])), C(5));
assert(m.value_comp() == C(5));
assert(m.size() == 3);
assert(distance(m.begin(), m.end()) == 3);
assert(*m.begin() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
}

View File

@@ -0,0 +1,107 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set(set&& s);
#include <set>
#include <cassert>
#include "../../../test_compare.h"
#include "test_allocator.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef int V;
typedef test_compare<std::less<int> > C;
typedef test_allocator<V> A;
std::set<int, C, A> mo(C(5), A(7));
std::set<int, 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);
}
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
typedef test_compare<std::less<int> > C;
typedef test_allocator<V> A;
std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
std::set<int, 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() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
assert(mo.get_allocator() == A(7));
assert(mo.key_comp() == C(5));
assert(mo.size() == 0);
assert(distance(mo.begin(), mo.end()) == 0);
}
#if __cplusplus >= 201103L
{
typedef int V;
V ar[] =
{
1,
1,
1,
2,
2,
2,
3,
3,
3
};
typedef test_compare<std::less<int> > C;
typedef min_allocator<V> A;
std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
std::set<int, C, A> m = std::move(mo);
assert(m.get_allocator() == A());
assert(m.key_comp() == C(5));
assert(m.size() == 3);
assert(distance(m.begin(), m.end()) == 3);
assert(*m.begin() == 1);
assert(*next(m.begin()) == 2);
assert(*next(m.begin(), 2) == 3);
assert(mo.get_allocator() == A());
assert(mo.key_comp() == C(5));
assert(mo.size() == 0);
assert(distance(mo.begin(), mo.end()) == 0);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,141 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set(set&& s, const allocator_type& a);
#include <set>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_compare.h"
#include "test_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef MoveOnly V;
typedef test_compare<std::less<MoveOnly> > C;
typedef test_allocator<V> A;
typedef std::set<MoveOnly, C, A> M;
typedef std::move_iterator<V*> I;
V a1[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(3)
};
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
V a2[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(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 MoveOnly V;
typedef test_compare<std::less<MoveOnly> > C;
typedef test_allocator<V> A;
typedef std::set<MoveOnly, C, A> M;
typedef std::move_iterator<V*> I;
V a1[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(3)
};
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
V a2[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(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 MoveOnly V;
typedef test_compare<std::less<MoveOnly> > C;
typedef other_allocator<V> A;
typedef std::set<MoveOnly, C, A> M;
typedef std::move_iterator<V*> I;
V a1[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(3)
};
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
V a2[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,186 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// set& operator=(set&& s);
#include <set>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_compare.h"
#include "test_allocator.h"
#include "min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef MoveOnly V;
typedef test_compare<std::less<MoveOnly> > C;
typedef test_allocator<V> A;
typedef std::set<MoveOnly, C, A> M;
typedef std::move_iterator<V*> I;
V a1[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(3)
};
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
V a2[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(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 MoveOnly V;
typedef test_compare<std::less<MoveOnly> > C;
typedef test_allocator<V> A;
typedef std::set<MoveOnly, C, A> M;
typedef std::move_iterator<V*> I;
V a1[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(3)
};
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
V a2[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(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 MoveOnly V;
typedef test_compare<std::less<MoveOnly> > C;
typedef other_allocator<V> A;
typedef std::set<MoveOnly, C, A> M;
typedef std::move_iterator<V*> I;
V a1[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(3)
};
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
V a2[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(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());
}
#if __cplusplus >= 201103L
{
typedef MoveOnly V;
typedef test_compare<std::less<MoveOnly> > C;
typedef min_allocator<V> A;
typedef std::set<MoveOnly, C, A> M;
typedef std::move_iterator<V*> I;
V a1[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(3)
};
M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
V a2[] =
{
V(1),
V(1),
V(1),
V(2),
V(2),
V(2),
V(3),
V(3),
V(3)
};
M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
M m3(C(3), A());
m3 = std::move(m1);
assert(m3 == m2);
assert(m3.get_allocator() == A());
assert(m3.key_comp() == C(5));
assert(m1.empty());
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,53 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// set& operator=(set&& c)
// noexcept(
// allocator_type::propagate_on_container_move_assignment::value &&
// is_nothrow_move_assignable<allocator_type>::value &&
// is_nothrow_move_assignable<key_compare>::value);
// This tests a conforming extension
#include <set>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp& operator=(const some_comp&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::set<MoveOnly> C;
static_assert(std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_assignable<C>::value, "");
}
{
typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// set(set&&)
// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
// is_nothrow_move_constructible<key_compare>::value);
// This tests a conforming extension
#include <set>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp(const some_comp&);
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::set<MoveOnly> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
static_assert(std::is_nothrow_move_constructible<C>::value, "");
}
{
typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
static_assert(!std::is_nothrow_move_constructible<C>::value, "");
}
#endif
}

View File

@@ -0,0 +1,201 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// void swap(set& m);
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef int V;
typedef std::set<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);
}
}
#if __cplusplus >= 201103L
{
typedef int V;
typedef std::set<int, std::less<int>, min_allocator<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);
}
}
#endif
}

View File

@@ -0,0 +1,177 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// void swap(set& m);
#include <set>
#include <cassert>
#include "test_allocator.h"
#include "../../../test_compare.h"
int main()
{
typedef int V;
typedef std::set<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;
swap(m1, 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;
swap(m1, 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;
swap(m1, 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;
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::set<int, C, A> M;
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]), 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::set<int, C, A> M;
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]), 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));
}
}

View File

@@ -0,0 +1,60 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// void swap(set& c)
// noexcept(!allocator_type::propagate_on_container_swap::value ||
// __is_nothrow_swappable<allocator_type>::value);
// This tests a conforming extension
#include <set>
#include <cassert>
#include "../../../MoveOnly.h"
#include "test_allocator.h"
template <class T>
struct some_comp
{
typedef T value_type;
some_comp() {}
some_comp(const some_comp&) {}
void deallocate(void*, unsigned) {}
typedef std::true_type propagate_on_container_swap;
};
int main()
{
#if __has_feature(cxx_noexcept)
{
typedef std::set<MoveOnly> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
C c1, c2;
static_assert(noexcept(swap(c1, c2)), "");
}
{
typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
C c1, c2;
static_assert(!noexcept(swap(c1, c2)), "");
}
#endif
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// size_type size() const;
#include <set>
#include <cassert>
#include "min_allocator.h"
int main()
{
{
typedef std::set<int> M;
M m;
assert(m.size() == 0);
m.insert(M::value_type(2));
assert(m.size() == 1);
m.insert(M::value_type(1));
assert(m.size() == 2);
m.insert(M::value_type(3));
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);
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> M;
M m;
assert(m.size() == 0);
m.insert(M::value_type(2));
assert(m.size() == 1);
m.insert(M::value_type(1));
assert(m.size() == 2);
m.insert(M::value_type(3));
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);
}
#endif
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// template <class Key, class Compare = less<Key>,
// class Allocator = allocator<Key>>
// class set
// {
// public:
// // types:
// typedef Key key_type;
// typedef key_type value_type;
// typedef Compare key_compare;
// typedef key_compare value_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 <set>
#include <type_traits>
#include "min_allocator.h"
int main()
{
{
typedef std::set<int> C;
static_assert((std::is_same<C::key_type, int>::value), "");
static_assert((std::is_same<C::value_type, int>::value), "");
static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), "");
static_assert((std::is_same<C::reference, int&>::value), "");
static_assert((std::is_same<C::const_reference, const int&>::value), "");
static_assert((std::is_same<C::pointer, int*>::value), "");
static_assert((std::is_same<C::const_pointer, const int*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#if __cplusplus >= 201103L
{
typedef std::set<int, std::less<int>, min_allocator<int>> C;
static_assert((std::is_same<C::key_type, int>::value), "");
static_assert((std::is_same<C::value_type, int>::value), "");
static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
static_assert((std::is_same<C::allocator_type, min_allocator<int> >::value), "");
static_assert((std::is_same<C::reference, int&>::value), "");
static_assert((std::is_same<C::const_reference, const int&>::value), "");
static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
// min_allocator doesn't have a size_type, so one gets synthesized
static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
}
#endif
}

View File

@@ -0,0 +1,336 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
// class set
// iterator upper_bound(const key_type& k);
// const_iterator upper_bound(const key_type& k) const;
#include <set>
#include <cassert>
#include "min_allocator.h"
#include "private_constructor.hpp"
int main()
{
{
typedef int V;
typedef std::set<int> M;
{
typedef M::iterator R;
V ar[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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));
}
}
#if __cplusplus >= 201103L
{
typedef int V;
typedef std::set<int, std::less<int>, min_allocator<int>> M;
{
typedef M::iterator R;
V ar[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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));
}
}
#endif
#if _LIBCPP_STD_VER > 11
{
typedef int V;
typedef std::set<V, std::less<>> M;
typedef M::iterator R;
V ar[] =
{
5,
7,
9,
11,
13,
15,
17,
19
};
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 PrivateConstructor V;
typedef std::set<V, std::less<>> M;
typedef M::iterator R;
M m;
m.insert ( V::make ( 5 ));
m.insert ( V::make ( 7 ));
m.insert ( V::make ( 9 ));
m.insert ( V::make ( 11 ));
m.insert ( V::make ( 13 ));
m.insert ( V::make ( 15 ));
m.insert ( V::make ( 17 ));
m.insert ( V::make ( 19 ));
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));
}
#endif
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <set>
#include <set>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}