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