1//
2// Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7
8#ifndef BOOST_MYSQL_TEST_UNIT_INCLUDE_TEST_UNIT_CUSTOM_ALLOCATOR_HPP
9#define BOOST_MYSQL_TEST_UNIT_INCLUDE_TEST_UNIT_CUSTOM_ALLOCATOR_HPP
10
11#include <cstddef>
12#include <memory>
13
14namespace boost {
15namespace mysql {
16namespace test {
17
18template <class T>
19struct custom_allocator
20{
21 using value_type = T;
22
23 custom_allocator() noexcept {}
24
25 template <class U>
26 custom_allocator(const custom_allocator<U>&) noexcept
27 {
28 }
29
30 T* allocate(std::size_t n) { return std::allocator<T>().allocate(n); }
31 void deallocate(T* p, std::size_t n) { return std::allocator<T>().deallocate(p, n); }
32};
33
34template <class T>
35struct custom_allocator_no_defctor : custom_allocator<T>
36{
37 custom_allocator_no_defctor(int) noexcept {}
38};
39
40template <class T, class U>
41constexpr bool operator==(const custom_allocator<T>&, const custom_allocator<U>&) noexcept
42{
43 return true;
44}
45
46template <class T, class U>
47constexpr bool operator!=(const custom_allocator<T>&, const custom_allocator<U>&) noexcept
48{
49 return false;
50}
51
52} // namespace test
53} // namespace mysql
54} // namespace boost
55
56#endif
57

source code of boost/libs/mysql/test/unit/include/test_unit/custom_allocator.hpp