2
0
mirror of https://github.com/boostorg/mysql.git synced 2026-01-21 05:02:13 +00:00
Files
mysql/test/unit/include/test_unit/custom_allocator.hpp
Anarthal (Rubén Pérez) 793b678287 Updated file copyrights to 2025
2025-02-11 20:42:41 +01:00

57 lines
1.3 KiB
C++

//
// Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_MYSQL_TEST_UNIT_INCLUDE_TEST_UNIT_CUSTOM_ALLOCATOR_HPP
#define BOOST_MYSQL_TEST_UNIT_INCLUDE_TEST_UNIT_CUSTOM_ALLOCATOR_HPP
#include <cstddef>
#include <memory>
namespace boost {
namespace mysql {
namespace test {
template <class T>
struct custom_allocator
{
using value_type = T;
custom_allocator() noexcept {}
template <class U>
custom_allocator(const custom_allocator<U>&) noexcept
{
}
T* allocate(std::size_t n) { return std::allocator<T>().allocate(n); }
void deallocate(T* p, std::size_t n) { return std::allocator<T>().deallocate(p, n); }
};
template <class T>
struct custom_allocator_no_defctor : custom_allocator<T>
{
custom_allocator_no_defctor(int) noexcept {}
};
template <class T, class U>
constexpr bool operator==(const custom_allocator<T>&, const custom_allocator<U>&) noexcept
{
return true;
}
template <class T, class U>
constexpr bool operator!=(const custom_allocator<T>&, const custom_allocator<U>&) noexcept
{
return false;
}
} // namespace test
} // namespace mysql
} // namespace boost
#endif