remove std::cout

This commit is contained in:
Alex Fishgait 2023-10-09 13:29:28 +02:00
parent 4a08806397
commit 8bbece686d

View File

@ -262,9 +262,11 @@ TEST_CASE("bad my_allocator::construct")
} }
} }
namespace{ namespace
{
template <class T> template <class T>
struct NAlloc { struct NAlloc
{
// Aliases and inner types // Aliases and inner types
using value_type = T; using value_type = T;
using size_type = std::size_t; using size_type = std::size_t;
@ -275,37 +277,39 @@ namespace{
using const_pointer = const value_type*; using const_pointer = const value_type*;
template <typename U> template <typename U>
struct rebind { struct rebind
{
using other = NAlloc<U>; using other = NAlloc<U>;
}; };
NAlloc() : NAlloc() :
alloc() { alloc()
{
}; };
virtual ~NAlloc() { } virtual ~NAlloc() { }
pointer allocate(std::size_t n) { pointer allocate(std::size_t n)
#ifdef _DEBUG {
std::cout << "NAlloc allocating " << n << " bytes\n";
#endif
return static_cast<pointer>(alloc.allocate(n)); // get memory from pool return static_cast<pointer>(alloc.allocate(n)); // get memory from pool
} }
void deallocate(pointer p, [[maybe_unused]] std::size_t n) { void deallocate(pointer p, [[maybe_unused]] std::size_t n)
#ifdef _DEBUG {
std::cout << "NAlloc deallocating " << n * sizeof *p << " bytes\n";
#endif
alloc.deallocate(static_cast<pointer>(p), 1); // return memory to pool alloc.deallocate(static_cast<pointer>(p), 1); // return memory to pool
} }
bool operator!=(const NAlloc<T>& other) const { bool operator!=(const NAlloc<T>& other) const
{
return !(*this == other); return !(*this == other);
} }
bool operator==(const NAlloc<T>& other) const { bool operator==(const NAlloc<T>& other) const
{
return alloc == other.alloc; return alloc == other.alloc;
} }