custom allocators: define missing 'rebind' type (#3895)

This commit is contained in:
Sergei Trofimovich authored and GitHub committed 2023-03-08 12:31:56 +01:00
1 parent b504dca35a
commit 6cec5aefc9
2 files changed
+18

No files matched your search

+9
View File
@@ -20,11 +20,20 @@ struct bad_allocator : std::allocator<T>
{ {
using std::allocator<T>::allocator; using std::allocator<T>::allocator;
bad_allocator() = default;
template<class U> bad_allocator(const bad_allocator<U>& /*unused*/) { }
template<class... Args> template<class... Args>
void construct(T* /*unused*/, Args&& ... /*unused*/) void construct(T* /*unused*/, Args&& ... /*unused*/)
{ {
throw std::bad_alloc(); throw std::bad_alloc();
} }
template <class U>
struct rebind
{
using other = bad_allocator<U>;
};
}; };
} // namespace } // namespace
+9
View File
@@ -189,6 +189,15 @@ class my_allocator : public std::allocator<T>
{ {
public: public:
using std::allocator<T>::allocator; using std::allocator<T>::allocator;
my_allocator() = default;
template<class U> my_allocator(const my_allocator<U>& /*unused*/) { }
template <class U>
struct rebind
{
using other = my_allocator<U>;
};
}; };
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////