This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82758] New: Allocators declared `final` are not acceptible by containers
- From: "wmx16835 at 126 dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 28 Oct 2017 11:10:24 +0000
- Subject: [Bug c++/82758] New: Allocators declared `final` are not acceptible by containers
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82758
Bug ID: 82758
Summary: Allocators declared `final` are not acceptible by
containers
Product: gcc
Version: 7.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: wmx16835 at 126 dot com
Target Milestone: ---
I found that any allocator type declared `final` are not acceptable by the
implementation of the containers that require allocators, including `vector`,
`deque`, `list`, `forward_list`, `set`, `map`, `multiset`, `multimap`,
`unordered_set`, `unordered_map`, `unordered_multiset`, `unordered_multimap`.
For example, providing there is a user-defined allocator type:
template <class T>
class MyAllocator final : public std::allocator<T> {
public:
template <class U>
struct rebind { using other = MyAllocator<U>; };
};
Each line of the following expressions shall be well-formed. However, they do
not compile.
std::vector<int, MyAllocator<int>> v{};
std::deque<int, MyAllocator<int>> d{};
std::list<int, MyAllocator<int>> l{};
std::forward_list<int, MyAllocator<int>> f_l{};
std::set<int, std::less<int>, MyAllocator<int>> s{};
std::map<int, int, std::less<int>, MyAllocator<std::pair<int, int>>> mp{};
std::multiset<int, std::less<int>, MyAllocator<int>> m_s{};
std::multimap<int, int, std::less<int>, MyAllocator<std::pair<int, int>>>
m_mp{};
std::unordered_set<int, std::hash<int>, std::equal_to<int>, MyAllocator<int>>
u_s{};
std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
MyAllocator<std::pair<const int, int>>> u_mp{};
std::unordered_multiset<int, std::hash<int>, std::equal_to<int>,
MyAllocator<int>> u_m_s {};
std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>,
MyAllocator<std::pair<const int, int>>> u_m_mp{};