emlabcpp
modern opinionated embedded C++ library
aliases.h
Go to the documentation of this file.
1 
24 #pragma once
25 
26 #include "./allocator.h"
27 
28 #include <deque>
29 #include <list>
30 #include <map>
31 #include <memory>
32 #include <set>
33 #include <vector>
34 
35 namespace emlabcpp::pmr
36 {
37 
38 struct deleter
39 {
40  std::reference_wrapper< pmr::memory_resource > res;
41 
42  template < typename T >
43  void operator()( T* item ) const
44  {
45  std::destroy_at( item );
46  res.get().deallocate( item, sizeof( T ), alignof( T ) );
47  }
48 };
49 
50 template < typename T >
51 using unique_ptr = std::unique_ptr< T, deleter >;
52 
53 template < typename T >
54 using vector = std::vector< T, allocator< T > >;
55 template < typename T >
56 using list = std::list< T, allocator< T > >;
57 template < typename T >
58 using set = std::set< T, allocator< T > >;
59 template < typename T >
60 using deque = std::deque< T, allocator< T > >;
61 template < typename Key, typename T >
62 using map = std::map< Key, T, std::less< Key >, allocator< std::pair< Key const, T > > >;
63 
64 } // namespace emlabcpp::pmr
Definition: allocator.h:36
MIT License.
Definition: aliases.h:36
std::map< Key, T, std::less< Key >, allocator< std::pair< Key const, T > > > map
Definition: aliases.h:62
std::vector< T, allocator< T > > vector
Definition: aliases.h:54
std::unique_ptr< T, deleter > unique_ptr
Definition: aliases.h:51
std::list< T, allocator< T > > list
Definition: aliases.h:56
std::set< T, allocator< T > > set
Definition: aliases.h:58
std::deque< T, allocator< T > > deque
Definition: aliases.h:60
Definition: aliases.h:39
std::reference_wrapper< pmr::memory_resource > res
Definition: aliases.h:40
void operator()(T *item) const
Definition: aliases.h:43