diff options
Diffstat (limited to 'test/std/containers/associative/multimap/multimap.ops')
25 files changed, 1905 insertions, 0 deletions
diff --git a/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp new file mode 100644 index 0000000000000..c666c295f3a07 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp @@ -0,0 +1,175 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// size_type count(const key_type& k) const; + +#include <map> +#include <cassert> + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + typedef std::pair<const int, double> V; + { + typedef std::multimap<int, double> M; + { + typedef M::size_type R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.count(4); + assert(r == 0); + r = m.count(5); + assert(r == 3); + r = m.count(6); + assert(r == 0); + r = m.count(7); + assert(r == 3); + r = m.count(8); + assert(r == 0); + r = m.count(9); + assert(r == 3); + r = m.count(10); + assert(r == 0); + } + } +#if __cplusplus >= 201103L + { + typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; + { + typedef M::size_type R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.count(4); + assert(r == 0); + r = m.count(5); + assert(r == 3); + r = m.count(6); + assert(r == 0); + r = m.count(7); + assert(r == 3); + r = m.count(8); + assert(r == 0); + r = m.count(9); + assert(r == 3); + r = m.count(10); + assert(r == 0); + } + } +#endif + +#if _LIBCPP_STD_VER > 11 + { + typedef std::multimap<int, double, std::less<>> M; + typedef M::size_type R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.count(4); + assert(r == 0); + r = m.count(5); + assert(r == 3); + r = m.count(6); + assert(r == 0); + r = m.count(7); + assert(r == 3); + r = m.count(8); + assert(r == 0); + r = m.count(9); + assert(r == 3); + r = m.count(10); + assert(r == 0); + + r = m.count(C2Int(4)); + assert(r == 0); + r = m.count(C2Int(5)); + assert(r == 3); + r = m.count(C2Int(6)); + assert(r == 0); + r = m.count(C2Int(7)); + assert(r == 3); + r = m.count(C2Int(8)); + assert(r == 0); + r = m.count(C2Int(9)); + assert(r == 3); + r = m.count(C2Int(10)); + assert(r == 0); + } + + { + typedef PrivateConstructor PC; + typedef std::multimap<PC, double, std::less<>> M; + typedef M::size_type R; + + M m; + m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 )); + + R r = m.count(4); + assert(r == 0); + r = m.count(5); + assert(r == 3); + r = m.count(6); + assert(r == 0); + r = m.count(7); + assert(r == 3); + r = m.count(8); + assert(r == 0); + r = m.count(9); + assert(r == 3); + r = m.count(10); + assert(r == 0); + } +#endif +} diff --git a/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp new file mode 100644 index 0000000000000..7da13bb0d66dc --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: c++03, c++11 + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +int main() +{ + typedef std::multimap<int, double, transparent_less> M; + + M().count(C2Int{5}); +} diff --git a/test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp new file mode 100644 index 0000000000000..f30d1bfd88d62 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + typedef std::multimap<int, double, transparent_less_no_type> M; + + M().count(C2Int{5}); +} +#endif
\ No newline at end of file diff --git a/test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp new file mode 100644 index 0000000000000..ffb7eb6a559a6 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + typedef std::multimap<int, double, transparent_less_private> M; + + M().count(C2Int{5}); +} +#endif
\ No newline at end of file diff --git a/test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp new file mode 100644 index 0000000000000..4bb9d14634f31 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + typedef std::multimap<int, double, transparent_less_not_a_type> M; + + M().count(C2Int{5}); +} +#endif
\ No newline at end of file diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp new file mode 100644 index 0000000000000..5a071042461a7 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp @@ -0,0 +1,287 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <multimap> + +// class multimap + +// pair<iterator, iterator> equal_range(const key_type& k); +// pair<const_iterator, const_iterator> equal_range(const key_type& k) const; + +#include <map> +#include <cassert> + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + typedef std::pair<const int, double> V; + { + typedef std::multimap<int, double> M; + { + typedef std::pair<M::iterator, M::iterator> R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(4); + assert(r.first == m.begin()); + assert(r.second == m.begin()); + r = m.equal_range(5); + assert(r.first == m.begin()); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 9)); + r = m.equal_range(10); + assert(r.first == m.end()); + assert(r.second == m.end()); + } + { + typedef std::pair<M::const_iterator, M::const_iterator> R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(4); + assert(r.first == m.begin()); + assert(r.second == m.begin()); + r = m.equal_range(5); + assert(r.first == m.begin()); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 9)); + r = m.equal_range(10); + assert(r.first == m.end()); + assert(r.second == m.end()); + } + } +#if __cplusplus >= 201103L + { + typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; + { + typedef std::pair<M::iterator, M::iterator> R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(4); + assert(r.first == m.begin()); + assert(r.second == m.begin()); + r = m.equal_range(5); + assert(r.first == m.begin()); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 9)); + r = m.equal_range(10); + assert(r.first == m.end()); + assert(r.second == m.end()); + } + { + typedef std::pair<M::const_iterator, M::const_iterator> R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(4); + assert(r.first == m.begin()); + assert(r.second == m.begin()); + r = m.equal_range(5); + assert(r.first == m.begin()); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 9)); + r = m.equal_range(10); + assert(r.first == m.end()); + assert(r.second == m.end()); + } + } +#endif +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair<const int, double> V; + typedef std::multimap<int, double, std::less<>> M; + + typedef std::pair<M::iterator, M::iterator> R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.equal_range(4); + assert(r.first == m.begin()); + assert(r.second == m.begin()); + r = m.equal_range(5); + assert(r.first == m.begin()); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 9)); + r = m.equal_range(10); + assert(r.first == m.end()); + assert(r.second == m.end()); + + r = m.equal_range(C2Int(4)); + assert(r.first == m.begin()); + assert(r.second == m.begin()); + r = m.equal_range(C2Int(5)); + assert(r.first == m.begin()); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(C2Int(6)); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(C2Int(7)); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(C2Int(8)); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(C2Int(9)); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 9)); + r = m.equal_range(C2Int(10)); + assert(r.first == m.end()); + assert(r.second == m.end()); + } + + { + typedef PrivateConstructor PC; + typedef std::multimap<PC, double, std::less<>> M; + typedef std::pair<M::iterator, M::iterator> R; + + M m; + m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 )); + +// assert(m.size() == 9); + R r = m.equal_range(4); + assert(r.first == m.begin()); + assert(r.second == m.begin()); + r = m.equal_range(5); + assert(r.first == m.begin()); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(6); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 3)); + r = m.equal_range(7); + assert(r.first == next(m.begin(), 3)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(8); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 6)); + r = m.equal_range(9); + assert(r.first == next(m.begin(), 6)); + assert(r.second == next(m.begin(), 9)); + r = m.equal_range(10); + assert(r.first == m.end()); + assert(r.second == m.end()); + } +#endif +} diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp new file mode 100644 index 0000000000000..c0f07468ec5ed --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: c++03, c++11 + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +int main() +{ + typedef std::multimap<int, double, transparent_less> M; + + M().equal_range(C2Int{5}); +} diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp new file mode 100644 index 0000000000000..f022e94324fd9 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + typedef std::multimap<int, double, transparent_less_no_type> M; + + M().equal_range(C2Int{5}); +} +#endif
\ No newline at end of file diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp new file mode 100644 index 0000000000000..695e71703e3b9 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap<int, double, transparent_less_private> M; + + M().equal_range(C2Int{5}); + } +} +#endif
\ No newline at end of file diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp new file mode 100644 index 0000000000000..59c2855e8f695 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap<int, double, transparent_less_not_a_type> M; + + M().equal_range(C2Int{5}); + } +} +#endif
\ No newline at end of file diff --git a/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp new file mode 100644 index 0000000000000..a60e42cf8592d --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp @@ -0,0 +1,223 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; + +#include <map> +#include <cassert> + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + typedef std::pair<const int, double> V; + { + typedef std::multimap<int, double> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == m.end()); + r = m.find(7); + assert(r == next(m.begin(), 3)); + r = m.find(8); + assert(r == m.end()); + r = m.find(9); + assert(r == next(m.begin(), 6)); + r = m.find(10); + assert(r == m.end()); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + 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 == m.end()); + r = m.find(7); + assert(r == next(m.begin(), 3)); + r = m.find(8); + assert(r == m.end()); + r = m.find(9); + assert(r == next(m.begin(), 6)); + r = m.find(10); + assert(r == m.end()); + } + } +#if __cplusplus >= 201103L + { + typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == m.end()); + r = m.find(7); + assert(r == next(m.begin(), 3)); + r = m.find(8); + assert(r == m.end()); + r = m.find(9); + assert(r == next(m.begin(), 6)); + r = m.find(10); + assert(r == m.end()); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + 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 == m.end()); + r = m.find(7); + assert(r == next(m.begin(), 3)); + r = m.find(8); + assert(r == m.end()); + r = m.find(9); + assert(r == next(m.begin(), 6)); + r = m.find(10); + assert(r == m.end()); + } + } +#endif +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair<const int, double> V; + typedef std::multimap<int, double, std::less<>> M; + typedef M::iterator R; + + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == m.end()); + r = m.find(7); + assert(r == next(m.begin(), 3)); + r = m.find(8); + assert(r == m.end()); + r = m.find(9); + assert(r == next(m.begin(), 6)); + r = m.find(10); + assert(r == m.end()); + + r = m.find(C2Int(5)); + assert(r == m.begin()); + r = m.find(C2Int(6)); + assert(r == m.end()); + r = m.find(C2Int(7)); + assert(r == next(m.begin(), 3)); + r = m.find(C2Int(8)); + assert(r == m.end()); + r = m.find(C2Int(9)); + assert(r == next(m.begin(), 6)); + r = m.find(C2Int(10)); + assert(r == m.end()); + } + + { + typedef PrivateConstructor PC; + typedef std::multimap<PC, double, std::less<>> M; + typedef M::iterator R; + + M m; + m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 )); + + R r = m.find(5); + assert(r == m.begin()); + r = m.find(6); + assert(r == m.end()); + r = m.find(7); + assert(r == next(m.begin(), 3)); + r = m.find(8); + assert(r == m.end()); + r = m.find(9); + assert(r == next(m.begin(), 6)); + r = m.find(10); + assert(r == m.end()); + } +#endif +} diff --git a/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp new file mode 100644 index 0000000000000..4f3369870c8f2 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: c++03, c++11 + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +int main() +{ + typedef std::multimap<int, double, transparent_less> M; + + M().find(C2Int{5}); +} diff --git a/test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp new file mode 100644 index 0000000000000..e1eef034064d0 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap<int, double, transparent_less_no_type> M; + + M().find(C2Int{5}); + } +} +#endif
\ No newline at end of file diff --git a/test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp new file mode 100644 index 0000000000000..4c03f583fa1c0 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class map + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap<int, double, transparent_less_private> M; + + M().find(C2Int{5}); + } +} +#endif
\ No newline at end of file diff --git a/test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp new file mode 100644 index 0000000000000..f10bc60aa8641 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator find(const key_type& k); +// const_iterator find(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap<int, double, transparent_less_not_a_type> M; + + M().find(C2Int{5}); + } +} +#endif
\ No newline at end of file diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp new file mode 100644 index 0000000000000..38b931802f8e4 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp @@ -0,0 +1,237 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator lower_bound(const key_type& k); +// const_iterator lower_bound(const key_type& k) const; + +#include <map> +#include <cassert> + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + typedef std::pair<const int, double> V; + { + typedef std::multimap<int, double> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(4); + assert(r == m.begin()); + r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(10); + assert(r == m.end()); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(4); + assert(r == m.begin()); + r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(10); + assert(r == m.end()); + } + } +#if __cplusplus >= 201103L + { + typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(4); + assert(r == m.begin()); + r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(10); + assert(r == m.end()); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(4); + assert(r == m.begin()); + r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(10); + assert(r == m.end()); + } + } +#endif +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair<const int, double> V; + typedef std::multimap<int, double, std::less<>> M; + typedef M::iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.lower_bound(4); + assert(r == m.begin()); + r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(10); + assert(r == m.end()); + + r = m.lower_bound(C2Int(4)); + assert(r == m.begin()); + r = m.lower_bound(C2Int(5)); + assert(r == m.begin()); + r = m.lower_bound(C2Int(6)); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(C2Int(7)); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(C2Int(8)); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(C2Int(9)); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(C2Int(10)); + assert(r == m.end()); + } + + { + typedef PrivateConstructor PC; + typedef std::multimap<PC, double, std::less<>> M; + typedef M::iterator R; + + M m; + m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 )); + + R r = m.lower_bound(4); + assert(r == m.begin()); + r = m.lower_bound(5); + assert(r == m.begin()); + r = m.lower_bound(6); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(7); + assert(r == next(m.begin(), 3)); + r = m.lower_bound(8); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(9); + assert(r == next(m.begin(), 6)); + r = m.lower_bound(10); + assert(r == m.end()); + } + +#endif +} diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp new file mode 100644 index 0000000000000..c5271f65d7e51 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: c++03, c++11 + +// <map> + +// class multimap + +// iterator lower_bound(const key_type& k); +// const_iterator lower_bound(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +int main() +{ + typedef std::multimap<int, double, transparent_less> M; + + M().lower_bound(C2Int{5}); +} diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp new file mode 100644 index 0000000000000..b452be864e2bc --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator lower_bound(const key_type& k); +// const_iterator lower_bound(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap<int, double, transparent_less_no_type> M; + + M().lower_bound(C2Int{5}); + } +} +#endif diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp new file mode 100644 index 0000000000000..a2ba30236a40d --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator lower_bound(const key_type& k); +// const_iterator lower_bound(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap<int, double, transparent_less_private> M; + + M().lower_bound(C2Int{5}); + } +} +#endif diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp new file mode 100644 index 0000000000000..50d9fca91ad90 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator lower_bound(const key_type& k); +// const_iterator lower_bound(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap<int, double, transparent_less_not_a_type> M; + + M().lower_bound(C2Int{5}); + } +} +#endif diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp new file mode 100644 index 0000000000000..7c647a9426cbe --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp @@ -0,0 +1,236 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator upper_bound(const key_type& k); +// const_iterator upper_bound(const key_type& k) const; + +#include <map> +#include <cassert> + +#include "min_allocator.h" +#include "private_constructor.hpp" +#include "is_transparent.h" + +int main() +{ + typedef std::pair<const int, double> V; + { + typedef std::multimap<int, double> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(4); + assert(r == m.begin()); + r = m.upper_bound(5); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 9)); + r = m.upper_bound(10); + assert(r == m.end()); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(4); + assert(r == m.begin()); + r = m.upper_bound(5); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 9)); + r = m.upper_bound(10); + assert(r == m.end()); + } + } +#if __cplusplus >= 201103L + { + typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; + { + typedef M::iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(4); + assert(r == m.begin()); + r = m.upper_bound(5); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 9)); + r = m.upper_bound(10); + assert(r == m.end()); + } + { + typedef M::const_iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(4); + assert(r == m.begin()); + r = m.upper_bound(5); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 9)); + r = m.upper_bound(10); + assert(r == m.end()); + } + } +#endif +#if _LIBCPP_STD_VER > 11 + { + typedef std::pair<const int, double> V; + typedef std::multimap<int, double, std::less<>> M; + typedef M::iterator R; + V ar[] = + { + V(5, 1), + V(5, 2), + V(5, 3), + V(7, 1), + V(7, 2), + V(7, 3), + V(9, 1), + V(9, 2), + V(9, 3) + }; + M m(ar, ar+sizeof(ar)/sizeof(ar[0])); + R r = m.upper_bound(4); + assert(r == m.begin()); + r = m.upper_bound(5); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 9)); + r = m.upper_bound(10); + assert(r == m.end()); + + r = m.upper_bound(C2Int(4)); + assert(r == m.begin()); + r = m.upper_bound(C2Int(5)); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(C2Int(6)); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(C2Int(7)); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(C2Int(8)); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(C2Int(9)); + assert(r == next(m.begin(), 9)); + r = m.upper_bound(C2Int(10)); + } + + { + typedef PrivateConstructor PC; + typedef std::multimap<PC, double, std::less<>> M; + typedef M::iterator R; + + M m; + m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 )); + m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 )); + + R r = m.upper_bound(4); + assert(r == m.begin()); + r = m.upper_bound(5); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(6); + assert(r == next(m.begin(), 3)); + r = m.upper_bound(7); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(8); + assert(r == next(m.begin(), 6)); + r = m.upper_bound(9); + assert(r == next(m.begin(), 9)); + r = m.upper_bound(10); + assert(r == m.end()); + } + +#endif +} diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp new file mode 100644 index 0000000000000..322c6f55130c8 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: c++03, c++11 + +// <map> + +// class multimap + +// iterator upper_bound(const key_type& k); +// const_iterator upper_bound(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +int main() +{ + typedef std::multimap<int, double, transparent_less> M; + + M().upper_bound(C2Int{5}); +} diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp new file mode 100644 index 0000000000000..bb78ad6981601 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator upper_bound(const key_type& k); +// const_iterator upper_bound(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap<int, double, transparent_less_no_type> M; + + M().upper_bound(C2Int{5}); + } +} +#endif diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp new file mode 100644 index 0000000000000..a79d5938e56e4 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator upper_bound(const key_type& k); +// const_iterator upper_bound(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap<int, double, transparent_less_private> M; + + M().upper_bound(C2Int{5}); + } +} +#endif diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp new file mode 100644 index 0000000000000..1c1dc74b72c79 --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator upper_bound(const key_type& k); +// const_iterator upper_bound(const key_type& k) const; +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the +// qualified-id Compare::is_transparent is valid and denotes a type + + +#include <map> +#include <cassert> + +#include "is_transparent.h" + +#if _LIBCPP_STD_VER <= 11 +#error "This test requires is C++14 (or later)" +#else + +int main() +{ + { + typedef std::multimap<int, double, transparent_less_not_a_type> M; + + M().upper_bound(C2Int{5}); + } +} +#endif |