LWG Issue #2210 Part 5 - map/multimap; no, really - the last one was set/multiset. THIS is map/multimap

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@190474 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2013-09-11 01:15:47 +00:00
parent 24a7e331f1
commit 49d596d412
5 changed files with 157 additions and 1 deletions

View File

@@ -69,6 +69,32 @@ int main()
assert(m.key_comp() == C(3));
assert(m.get_allocator() == A());
}
#if _LIBCPP_STD_VER > 11
{
typedef std::pair<const int, double> V;
typedef min_allocator<V> A;
typedef test_compare<std::less<int> > C;
typedef std::map<int, double, C, A> M;
A a;
M m ({ {1, 1},
{1, 1.5},
{1, 2},
{2, 1},
{2, 1.5},
{2, 2},
{3, 1},
{3, 1.5},
{3, 2}
}, a);
assert(m.size() == 3);
assert(distance(m.begin(), m.end()) == 3);
assert(*m.begin() == V(1, 1));
assert(*next(m.begin()) == V(2, 1));
assert(*next(m.begin(), 2) == V(3, 1));
assert(m.get_allocator() == a);
}
#endif
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -75,5 +75,34 @@ int main()
assert(*next(m.begin()) == V(2, 1));
assert(*next(m.begin(), 2) == V(3, 1));
}
#if _LIBCPP_STD_VER > 11
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
};
typedef std::pair<const int, double> V;
typedef min_allocator<V> A;
typedef test_compare<std::less<int> > C;
A a;
std::map<int, double, 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() == V(1, 1));
assert(*next(m.begin()) == V(2, 1));
assert(*next(m.begin(), 2) == V(3, 1));
assert(m.get_allocator() == a);
}
#endif
#endif
}

View File

@@ -92,5 +92,38 @@ int main()
assert(m.key_comp() == Cmp(4));
assert(m.get_allocator() == A());
}
#if _LIBCPP_STD_VER > 11
{
typedef test_compare<std::less<int> > C;
typedef std::pair<const int, double> V;
typedef min_allocator<V> A;
typedef std::multimap<int, double, C, A> M;
A a;
M m ({ {1, 1},
{1, 1.5},
{1, 2},
{2, 1},
{2, 1.5},
{2, 2},
{3, 1},
{3, 1.5},
{3, 2}
}, a);
assert(m.size() == 9);
assert(distance(m.begin(), m.end()) == 9);
M::const_iterator i = m.cbegin();
assert(*i == V(1, 1));
assert(*++i == V(1, 1.5));
assert(*++i == V(1, 2));
assert(*++i == V(2, 1));
assert(*++i == V(2, 1.5));
assert(*++i == V(2, 2));
assert(*++i == V(3, 1));
assert(*++i == V(3, 1.5));
assert(*++i == V(3, 2));
assert(m.get_allocator() == a);
}
#endif
#endif
}

View File

@@ -76,5 +76,37 @@ int main()
assert(*next(m.begin(), 7) == V(3, 1.5));
assert(*next(m.begin(), 8) == V(3, 2));
}
#if _LIBCPP_STD_VER > 11
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
};
typedef min_allocator<std::pair<const int, double>> A;
A a;
std::multimap<int, double, std::less<int>, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
assert(m.size() == 9);
assert(distance(m.begin(), m.end()) == 9);
assert(*m.begin() == V(1, 1));
assert(*next(m.begin()) == V(1, 1.5));
assert(*next(m.begin(), 2) == V(1, 2));
assert(*next(m.begin(), 3) == V(2, 1));
assert(*next(m.begin(), 4) == V(2, 1.5));
assert(*next(m.begin(), 5) == V(2, 2));
assert(*next(m.begin(), 6) == V(3, 1));
assert(*next(m.begin(), 7) == V(3, 1.5));
assert(*next(m.begin(), 8) == V(3, 2));
assert(m.get_allocator() == a);
}
#endif
#endif
}