diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2016-06-30 15:11:53 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2016-06-30 15:11:53 +0000 |
commit | 497677449be6f4a19b6b692dccab3b23e7cfd872 (patch) | |
tree | c194cf777fd0b44f992ab9b96d8406aa7f212ef5 /libcxx/test/std/containers | |
parent | 2d1938be0d21f0e4c8b79db722b361969d90538a (diff) | |
download | bcm5719-llvm-497677449be6f4a19b6b692dccab3b23e7cfd872.tar.gz bcm5719-llvm-497677449be6f4a19b6b692dccab3b23e7cfd872.zip |
Implement LWG#2436: 'Comparators for associative containers should always be CopyConstructible'
llvm-svn: 274235
Diffstat (limited to 'libcxx/test/std/containers')
12 files changed, 348 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/associative/map/map.cons/compare_copy_constructible.fail.cpp b/libcxx/test/std/containers/associative/map/map.cons/compare_copy_constructible.fail.cpp new file mode 100644 index 00000000000..81ccba3bbc9 --- /dev/null +++ b/libcxx/test/std/containers/associative/map/map.cons/compare_copy_constructible.fail.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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// Check that std::map fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <map> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs < rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::map<int, int, Comp<int> > m; +} diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/compare_copy_constructible.fail.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/compare_copy_constructible.fail.cpp new file mode 100644 index 00000000000..e6f6c3efee5 --- /dev/null +++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/compare_copy_constructible.fail.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. +// +//===----------------------------------------------------------------------===// + +// <map> + +// Check that std::multimap fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <map> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs < rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::multimap<int, int, Comp<int> > m; +} diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/compare_copy_constructible.fail.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/compare_copy_constructible.fail.cpp new file mode 100644 index 00000000000..2eade5299d6 --- /dev/null +++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/compare_copy_constructible.fail.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> + +// Check that std::multiset fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <set> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs < rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::multiset<int, Comp<int> > m; +} diff --git a/libcxx/test/std/containers/associative/set/set.cons/compare_copy_constructible.fail.cpp b/libcxx/test/std/containers/associative/set/set.cons/compare_copy_constructible.fail.cpp new file mode 100644 index 00000000000..dcf23effc44 --- /dev/null +++ b/libcxx/test/std/containers/associative/set/set.cons/compare_copy_constructible.fail.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> + +// Check that std::set fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <set> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs < rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::set<int, Comp<int> > m; +} diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/compare_copy_constructible.fail.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/compare_copy_constructible.fail.cpp new file mode 100644 index 00000000000..270475702af --- /dev/null +++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/compare_copy_constructible.fail.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. +// +//===----------------------------------------------------------------------===// + +// <unordered_map> + +// Check that std::unordered_map fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <unordered_map> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs == rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::unordered_map<int, int, std::hash<int>, Comp<int> > m; +} diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/hash_copy_constructible.fail.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/hash_copy_constructible.fail.cpp new file mode 100644 index 00000000000..8faebcbf1c9 --- /dev/null +++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/hash_copy_constructible.fail.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. +// +//===----------------------------------------------------------------------===// + +// <unordered_map> + +// Check that std::unordered_map fails to instantiate if the hash function is +// not copy-constructible. This is mentioned in LWG issue 2436 + +#include <unordered_map> + +template <class T> +struct Hash { + std::size_t operator () (const T& lhs) const { return 0; } + + Hash () {} +private: + Hash (const Hash &); // declared but not defined + }; + + +int main() { + std::unordered_map<int, int, Hash<int> > m; +} diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/compare_copy_constructible.fail.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/compare_copy_constructible.fail.cpp new file mode 100644 index 00000000000..ead4fe00ce4 --- /dev/null +++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/compare_copy_constructible.fail.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. +// +//===----------------------------------------------------------------------===// + +// <unordered_map> + +// Check that std::unordered_multimap fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <unordered_map> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs == rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::unordered_multimap<int, int, std::hash<int>, Comp<int> > m; +} diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/hash_copy_constructible.fail.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/hash_copy_constructible.fail.cpp new file mode 100644 index 00000000000..060f96b1fdc --- /dev/null +++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/hash_copy_constructible.fail.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. +// +//===----------------------------------------------------------------------===// + +// <unordered_map> + +// Check that std::unordered_multimap fails to instantiate if the hash function is +// not copy-constructible. This is mentioned in LWG issue 2436 + +#include <unordered_map> + +template <class T> +struct Hash { + std::size_t operator () (const T& lhs) const { return 0; } + + Hash () {} +private: + Hash (const Hash &); // declared but not defined + }; + + +int main() { + std::unordered_multimap<int, int, Hash<int> > m; +} diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/compare_copy_constructible.fail.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/compare_copy_constructible.fail.cpp new file mode 100644 index 00000000000..b38316c3768 --- /dev/null +++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/compare_copy_constructible.fail.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. +// +//===----------------------------------------------------------------------===// + +// <unordered_set> + +// Check that std::unordered_set fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <unordered_set> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs == rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::unordered_multiset<int, std::hash<int>, Comp<int> > m; +} diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/hash_copy_constructible.fail.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/hash_copy_constructible.fail.cpp new file mode 100644 index 00000000000..a43f94ca2af --- /dev/null +++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/hash_copy_constructible.fail.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. +// +//===----------------------------------------------------------------------===// + +// <unordered_set> + +// Check that std::unordered_multiset fails to instantiate if the hash function is +// not copy-constructible. This is mentioned in LWG issue 2436 + +#include <unordered_set> + +template <class T> +struct Hash { + std::size_t operator () (const T& lhs) const { return 0; } + + Hash () {} +private: + Hash (const Hash &); // declared but not defined + }; + + +int main() { + std::unordered_multiset<int, Hash<int> > m; +} diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/compare_copy_constructible.fail.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/compare_copy_constructible.fail.cpp new file mode 100644 index 00000000000..6b675f00f16 --- /dev/null +++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/compare_copy_constructible.fail.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. +// +//===----------------------------------------------------------------------===// + +// <unordered_set> + +// Check that std::unordered_set fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <unordered_set> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs == rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::unordered_set<int, std::hash<int>, Comp<int> > m; +} diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/hash_copy_constructible.fail.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/hash_copy_constructible.fail.cpp new file mode 100644 index 00000000000..066f160a258 --- /dev/null +++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/hash_copy_constructible.fail.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. +// +//===----------------------------------------------------------------------===// + +// <unordered_map> + +// Check that std::unordered_set fails to instantiate if the hash function is +// not copy-constructible. This is mentioned in LWG issue 2436 + +#include <unordered_set> + +template <class T> +struct Hash { + std::size_t operator () (const T& lhs) const { return 0; } + + Hash () {} +private: + Hash (const Hash &); // declared but not defined + }; + + +int main() { + std::unordered_set<int, Hash<int> > m; +} |