diff options
author | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
commit | a90c6dd46005b2b14de3bb889a8d03bb34bd3256 (patch) | |
tree | 81065ae44967d68964de1f2fdfa107623e58e8a4 /test/std/containers/associative/multiset/multiset.cons | |
parent | 669a8a5a1929e881258bfed10d7461ca42ea0a9e (diff) | |
download | external_libcxx-a90c6dd46005b2b14de3bb889a8d03bb34bd3256.tar.gz external_libcxx-a90c6dd46005b2b14de3bb889a8d03bb34bd3256.tar.bz2 external_libcxx-a90c6dd46005b2b14de3bb889a8d03bb34bd3256.zip |
Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/std/containers/associative/multiset/multiset.cons')
21 files changed, 1543 insertions, 0 deletions
diff --git a/test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp new file mode 100644 index 000000000..0a7572275 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp @@ -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 multiset + +// multiset(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::multiset<int, C, A> m(A(5)); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.get_allocator() == A(5)); +} diff --git a/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp new file mode 100644 index 000000000..7d76581d6 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp @@ -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 multiset + +// multiset& operator=(initializer_list<value_type> il); + +#include <set> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + typedef std::multiset<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 // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if __cplusplus >= 201103L + { + typedef std::multiset<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 +} diff --git a/test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp new file mode 100644 index 000000000..84038ca1e --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp @@ -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 multiset + +// explicit multiset(const value_compare& comp); + +#include <set> +#include <cassert> + +#include "../../../test_compare.h" + +int main() +{ + typedef test_compare<std::less<int> > C; + std::multiset<int, C> m(C(3)); + assert(m.empty()); + assert(m.begin() == m.end()); + assert(m.key_comp() == C(3)); +} diff --git a/test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp new file mode 100644 index 000000000..76c9f8b2a --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp @@ -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 multiset + +// multiset(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::multiset<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)); +} diff --git a/test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp new file mode 100644 index 000000000..dde362872 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp @@ -0,0 +1,118 @@ +//===----------------------------------------------------------------------===// +// +// 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 multiset + +// multiset(const multiset& 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::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multiset<int, C, A> m = mo; + assert(m.get_allocator() == A(7)); + assert(m.key_comp() == C(5)); + 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(mo.get_allocator() == A(7)); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 9); + assert(distance(mo.begin(), mo.end()) == 9); + assert(*next(mo.begin(), 0) == 1); + assert(*next(mo.begin(), 1) == 1); + assert(*next(mo.begin(), 2) == 1); + assert(*next(mo.begin(), 3) == 2); + assert(*next(mo.begin(), 4) == 2); + assert(*next(mo.begin(), 5) == 2); + assert(*next(mo.begin(), 6) == 3); + assert(*next(mo.begin(), 7) == 3); + assert(*next(mo.begin(), 8) == 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::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multiset<int, C, A> m = mo; + assert(m.get_allocator() == A(-2)); + assert(m.key_comp() == C(5)); + 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(mo.get_allocator() == A(7)); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 9); + assert(distance(mo.begin(), mo.end()) == 9); + assert(*next(mo.begin(), 0) == 1); + assert(*next(mo.begin(), 1) == 1); + assert(*next(mo.begin(), 2) == 1); + assert(*next(mo.begin(), 3) == 2); + assert(*next(mo.begin(), 4) == 2); + assert(*next(mo.begin(), 5) == 2); + assert(*next(mo.begin(), 6) == 3); + assert(*next(mo.begin(), 7) == 3); + assert(*next(mo.begin(), 8) == 3); + } +#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +} diff --git a/test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp new file mode 100644 index 000000000..04a769e73 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// 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 multiset + +// multiset(const multiset& 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::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multiset<int, C, A> m(mo, A(3)); + assert(m.get_allocator() == A(3)); + assert(m.key_comp() == C(5)); + 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(mo.get_allocator() == A(7)); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 9); + assert(distance(mo.begin(), mo.end()) == 9); + assert(*next(mo.begin(), 0) == 1); + assert(*next(mo.begin(), 1) == 1); + assert(*next(mo.begin(), 2) == 1); + assert(*next(mo.begin(), 3) == 2); + assert(*next(mo.begin(), 4) == 2); + assert(*next(mo.begin(), 5) == 2); + assert(*next(mo.begin(), 6) == 3); + assert(*next(mo.begin(), 7) == 3); + assert(*next(mo.begin(), 8) == 3); +} diff --git a/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp new file mode 100644 index 000000000..cca636325 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp @@ -0,0 +1,138 @@ +//===----------------------------------------------------------------------===// +// +// 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 multiset + +// multiset& operator=(const multiset& 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::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2)); + std::multiset<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() == 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(mo.get_allocator() == A(2)); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 9); + assert(distance(mo.begin(), mo.end()) == 9); + assert(*next(mo.begin(), 0) == 1); + assert(*next(mo.begin(), 1) == 1); + assert(*next(mo.begin(), 2) == 1); + assert(*next(mo.begin(), 3) == 2); + assert(*next(mo.begin(), 4) == 2); + assert(*next(mo.begin(), 5) == 2); + assert(*next(mo.begin(), 6) == 3); + assert(*next(mo.begin(), 7) == 3); + assert(*next(mo.begin(), 8) == 3); + } + { + typedef int V; + const V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + std::multiset<int> *p = &m; + m = *p; + assert(m.size() == 9); + 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::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2)); + std::multiset<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() == 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(mo.get_allocator() == A(2)); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 9); + assert(distance(mo.begin(), mo.end()) == 9); + assert(*next(mo.begin(), 0) == 1); + assert(*next(mo.begin(), 1) == 1); + assert(*next(mo.begin(), 2) == 1); + assert(*next(mo.begin(), 3) == 2); + assert(*next(mo.begin(), 4) == 2); + assert(*next(mo.begin(), 5) == 2); + assert(*next(mo.begin(), 6) == 3); + assert(*next(mo.begin(), 7) == 3); + assert(*next(mo.begin(), 8) == 3); + } +} diff --git a/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp new file mode 100644 index 000000000..5bb0312f0 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp @@ -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 multiset + +// multiset(); + +#include <set> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + { + std::multiset<int> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#if __cplusplus >= 201103L + { + std::multiset<int, std::less<int>, min_allocator<int>> m; + assert(m.empty()); + assert(m.begin() == m.end()); + } + { + std::multiset<int> m = {}; + assert(m.empty()); + assert(m.begin() == m.end()); + } +#endif +} diff --git a/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp new file mode 100644 index 000000000..a0bdb0786 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp @@ -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> + +// multiset() +// 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::multiset<MoveOnly> C; + static_assert(std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(!std::is_nothrow_default_constructible<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_default_constructible<C>::value, ""); + } +#endif +} diff --git a/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp new file mode 100644 index 000000000..658af1a89 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp @@ -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> + +// ~multiset() // 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::multiset<MoveOnly> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_destructible<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_destructible<C>::value, ""); + } +#endif +} diff --git a/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp new file mode 100644 index 000000000..dadafec7c --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp @@ -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 multiset + +// multiset(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::multiset<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 // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if __cplusplus >= 201103L + { + typedef std::multiset<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)); + } +#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 +} diff --git a/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp new file mode 100644 index 000000000..c67657aff --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp @@ -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 multiset + +// multiset(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::multiset<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 +} diff --git a/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp new file mode 100644 index 000000000..83114893a --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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 multiset + +// multiset(initializer_list<value_type> il, const key_compare& comp, 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::multiset<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)); +#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +} diff --git a/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp new file mode 100644 index 000000000..f6c1fd76d --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp @@ -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 multiset + +// template <class InputIterator> +// multiset(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::multiset<V> m(input_iterator<const int*>(ar), + input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0]))); + 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); + } +#if __cplusplus >= 201103L + { + typedef int V; + V ar[] = + { + 1, + 1, + 1, + 2, + 2, + 2, + 3, + 3, + 3 + }; + std::multiset<V, std::less<V>, min_allocator<V>> m(input_iterator<const int*>(ar), + input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0]))); + 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); + } +#endif +} diff --git a/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp new file mode 100644 index 000000000..4ed00c712 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// 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 multiset + +// template <class InputIterator> +// multiset(InputIterator first, InputIterator last, +// const value_compare& comp, 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::multiset<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() == 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); +#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 +} diff --git a/test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp new file mode 100644 index 000000000..0bbaaf12e --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp @@ -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> + +// class multiset + +// template <class InputIterator> +// multiset(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::multiset<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() == 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); +} diff --git a/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp new file mode 100644 index 000000000..40321cd24 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp @@ -0,0 +1,119 @@ +//===----------------------------------------------------------------------===// +// +// 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 multiset + +// multiset(multiset&& 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::multiset<int, C, A> mo(C(5), A(7)); + std::multiset<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::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); + std::multiset<int, C, A> m = std::move(mo); + assert(m.get_allocator() == A(7)); + assert(m.key_comp() == C(5)); + 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(mo.get_allocator() == A(7)); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 0); + assert(distance(mo.begin(), mo.end()) == 0); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#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::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A()); + std::multiset<int, C, A> m = std::move(mo); + assert(m.get_allocator() == A()); + assert(m.key_comp() == C(5)); + 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(mo.get_allocator() == A()); + assert(mo.key_comp() == C(5)); + assert(mo.size() == 0); + assert(distance(mo.begin(), mo.end()) == 0); + } +#endif +} diff --git a/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp new file mode 100644 index 000000000..1a0b065f8 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp @@ -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 multiset + +// multiset(multiset&& 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::multiset<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::multiset<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::multiset<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 +} diff --git a/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp new file mode 100644 index 000000000..0b0ce44cb --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp @@ -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 multiset + +// multiset& operator=(multiset&& 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::multiset<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::multiset<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::multiset<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()); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if __cplusplus >= 201103L + { + typedef MoveOnly V; + typedef test_compare<std::less<MoveOnly> > C; + typedef min_allocator<V> A; + typedef std::multiset<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 +} diff --git a/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp new file mode 100644 index 000000000..cef3f2024 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp @@ -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> + +// multiset& operator=(multiset&& 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::multiset<MoveOnly> C; + static_assert(std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_assignable<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); + } +#endif +} diff --git a/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp new file mode 100644 index 000000000..e18f3f5f1 --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp @@ -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> + +// multiset(multiset&&) +// 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::multiset<MoveOnly> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; + static_assert(std::is_nothrow_move_constructible<C>::value, ""); + } + { + typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; + static_assert(!std::is_nothrow_move_constructible<C>::value, ""); + } +#endif +} |