Implement LWG#2436: 'Comparators for associative containers should always be CopyConstructible'
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274235 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user