1 /* ///////////////////////////////////////////////////////////////////////
2 * File: allocator_selector.h
7 * Brief: Memory allocator selector
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
13 #ifndef EXTL_MEMORY_ALLOCATOR_SELECTOR_H
14 #define EXTL_MEMORY_ALLOCATOR_SELECTOR_H
16 /*!\file allocator_selector.h
17 * \brief Memory allocator selector
20 # error allocator_selector.h need be supported by c++.
23 /* ///////////////////////////////////////////////////////////////////////
26 #include "basic_allocator_selector.h"
27 #include "basic_pool_allocator.h"
29 /* ///////////////////////////////////////////////////////////////////////
34 /*!\brief allocator_selector class
36 * \param T The allocator type
44 * basic_pool_allocator<T, A, L, MAX_FREE_INDEX>
46 * \ingroup extl_group_memory
48 template < typename_param_k T
>
49 struct allocator_selector
53 #if defined(EXTL_MEMORY_ALLOCATOR_SELECT_NULL_ALLOCATOR)
54 typedef null_allocator
<T
> allocator_type
;
55 #elif defined(EXTL_MEMORY_ALLOCATOR_SELECT_NEW_ALLOCATOR)
56 typedef new_allocator
<T
> allocator_type
;
57 #elif defined(EXTL_MEMORY_ALLOCATOR_SELECT_MALLOC_ALLOCATOR)
58 typedef malloc_allocator
<T
> allocator_type
;
59 #elif defined(EXTL_MEMORY_ALLOCATOR_SELECT_BASIC_POOL_ALLOCATOR)
60 # ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
61 typedef basic_pool_allocator
<T
> allocator_type
;
63 typedef basic_pool_allocator
< T
64 , typename_type_k
synch_traits_selector::synch_traits_type
65 , default_basic_pool_allocator_tag
67 # endif /* EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT */
68 #elif defined(EXTL_MEMORY_ALLOCATOR_SELECT_STD_ALLOCATOR)
69 # if !defined(EXTL_NO_STL)
70 typedef EXTL_NS_STD(allocator
)<T
> allocator_type
;
72 # ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
73 typedef basic_pool_allocator
<T
> allocator_type
;
75 typedef basic_pool_allocator
< T
76 , typename_type_k
synch_traits_selector::synch_traits_type
77 , default_basic_pool_allocator_tag
79 # endif /* EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT */
80 # endif /* EXTL_NO_STL */
82 # error Unknown allocator.
88 /* ///////////////////////////////////////////////////////////////////////
93 /* //////////////////////////////////////////////////////////////////// */
94 #endif /* EXTL_MEMORY_ALLOCATOR_SELECTOR_H */
95 /* //////////////////////////////////////////////////////////////////// */