LWG Issue #2210 Part 4 - map/multimap

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@190454 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2013-09-11 00:06:45 +00:00
parent e00f53bcfb
commit 24a7e331f1
5 changed files with 142 additions and 0 deletions

View File

@@ -51,5 +51,23 @@ int main()
assert(*++i == V(5));
assert(*++i == V(6));
}
#if _LIBCPP_STD_VER > 11
{
typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
typedef C::value_type V;
min_allocator<int> a;
C m ({1, 2, 3, 4, 5, 6}, a);
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);
}
#endif
#endif
}

View File

@@ -55,4 +55,38 @@ int main()
assert(*next(m.begin(), 6) == 3);
assert(*next(m.begin(), 7) == 3);
assert(*next(m.begin(), 8) == 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;
std::multiset<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
assert(m.size() == 9);
assert(distance(m.begin(), m.end()) == 9);
assert(*next(m.begin(), 0) == 1);
assert(*next(m.begin(), 1) == 1);
assert(*next(m.begin(), 2) == 1);
assert(*next(m.begin(), 3) == 2);
assert(*next(m.begin(), 4) == 2);
assert(*next(m.begin(), 5) == 2);
assert(*next(m.begin(), 6) == 3);
assert(*next(m.begin(), 7) == 3);
assert(*next(m.begin(), 8) == 3);
assert(m.get_allocator() == a);
}
#endif
}

View File

@@ -12,6 +12,7 @@
// 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>
@@ -21,6 +22,7 @@
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;
@@ -37,5 +39,25 @@ int main()
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

@@ -14,6 +14,10 @@
// 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>
@@ -49,4 +53,32 @@ int main()
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
}