mirror of https://github.com/nlohmann/json.git
custom allocators: define missing 'rebind' type (#3895)
parent
b504dca35a
commit
6cec5aefc9
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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>;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue