ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Pmr.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------------- File Pmr.h -------------------------------*/
3/*--------------------------------------------------------------------------*/
25/*--------------------------------------------------------------------------*/
26/*----------------------------- DEFINITIONS --------------------------------*/
27/*--------------------------------------------------------------------------*/
28
29#ifndef __ADS_interop_std_Pmr
30 #define __ADS_interop_std_Pmr
31/* self-identification: #endif constant */
32
33/*--------------------------------------------------------------------------*/
34/*------------------------------ INCLUDES ----------------------------------*/
35/*--------------------------------------------------------------------------*/
36
38
39#include <cstddef>
40#include <memory_resource>
41
42/*--------------------------------------------------------------------------*/
43/*--------------------------- NAMESPACE ------------------------------------*/
44/*--------------------------------------------------------------------------*/
45
46namespace ADS
47{
48
49/*--------------------------------------------------------------------------*/
50/*--------------------------- CLASS PmrResource ----------------------------*/
51/*--------------------------------------------------------------------------*/
52
54template< class R = PoolResource<> >
55class PmrResource : public std::pmr::memory_resource
56{
57
58 public:
60 explicit PmrResource( R & r ) : f_r( &r ) { }
61
63 [[nodiscard]] R & resource( void ) const { return( *f_r ); }
64
65 private:
67 void * do_allocate( std::size_t b , std::size_t a ) override {
68 return( f_r->allocate( b , a ) );
69 }
70
72 void do_deallocate( void * p , std::size_t b , std::size_t a ) override {
73 f_r->deallocate( p , b , a );
74 }
75
77 bool do_is_equal(
78 const std::pmr::memory_resource & o ) const noexcept override {
79 const auto * q = dynamic_cast< const PmrResource * >( &o );
80 return( ( q != nullptr ) && ( q->f_r == f_r ) );
81 }
82
83 R * f_r;
84
85 }; // end( class PmrResource )
86
87/*--------------------------------------------------------------------------*/
88
89} // end( namespace ADS )
90
91/*--------------------------------------------------------------------------*/
92
93#endif /* Pmr.h included */
94
95/*--------------------------------------------------------------------------*/
96/*------------------------------ End File Pmr.h ----------------------------*/
97/*--------------------------------------------------------------------------*/
A standard allocator over pools of size classes, beyond the book, so that the containers of the stand...
PmrResource(R &r)
the adapter of , which must outlive it and the memory it gives
Definition Pmr.h:60
R & resource(void) const
the resource of ADS
Definition Pmr.h:63
Definition ADT.h:96