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

@ -66,6 +66,11 @@ public:
set(initializer_list<value_type> il, const value_compare& comp = value_compare());
set(initializer_list<value_type> il, const value_compare& comp,
const allocator_type& a);
template <class InputIterator>
set(InputIterator first, InputIterator last, const allocator_type& a)
: set(first, last, Compare(), a) {} // C++14
set(initializer_list<value_type> il, const allocator_type& a)
: set(il, Compare(), a) {} // C++14
~set();
set& operator=(const set& s);
@ -242,6 +247,11 @@ public:
multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());
multiset(initializer_list<value_type> il, const value_compare& comp,
const allocator_type& a);
template <class InputIterator>
multiset(InputIterator first, InputIterator last, const allocator_type& a)
: set(first, last, Compare(), a) {} // C++14
multiset(initializer_list<value_type> il, const allocator_type& a)
: set(il, Compare(), a) {} // C++14
~multiset();
multiset& operator=(const multiset& s);
@ -442,6 +452,13 @@ public:
insert(__f, __l);
}
#if _LIBCPP_STD_VER > 11
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
: set(__f, __l, key_compare(), __a) {}
#endif
_LIBCPP_INLINE_VISIBILITY
set(const set& __s)
: __tree_(__s.__tree_)
@ -494,6 +511,12 @@ public:
insert(__il.begin(), __il.end());
}
#if _LIBCPP_STD_VER > 11
_LIBCPP_INLINE_VISIBILITY
set(initializer_list<value_type> __il, const allocator_type& __a)
: set(__il, key_compare(), __a) {}
#endif
_LIBCPP_INLINE_VISIBILITY
set& operator=(initializer_list<value_type> __il)
{
@ -817,6 +840,13 @@ public:
insert(__f, __l);
}
#if _LIBCPP_STD_VER > 11
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
: multiset(__f, __l, key_compare(), __a) {}
#endif
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
multiset(_InputIterator __f, _InputIterator __l,
@ -876,6 +906,12 @@ public:
insert(__il.begin(), __il.end());
}
#if _LIBCPP_STD_VER > 11
_LIBCPP_INLINE_VISIBILITY
multiset(initializer_list<value_type> __il, const allocator_type& __a)
: multiset(__il, key_compare(), __a) {}
#endif
_LIBCPP_INLINE_VISIBILITY
multiset& operator=(initializer_list<value_type> __il)
{

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
}