diff --git a/libraries/chainbase/include/chainbase/allocators.hpp b/libraries/chainbase/include/chainbase/allocators.hpp index 6b2299487e..0f04d5db39 100644 --- a/libraries/chainbase/include/chainbase/allocators.hpp +++ b/libraries/chainbase/include/chainbase/allocators.hpp @@ -33,19 +33,20 @@ namespace chainbase { #endif typedef boost::unique_lock< read_write_mutex > write_lock; - // template< typename T > - // using allocator = typename std::conditional< ENABLE_STD_ALLOCATOR, - // std::allocator< T >, - // bip::allocator - // >::type; - using shared_string = std::conditional< ENABLE_STD_ALLOCATOR, + #ifdef ENABLE_STD_ALLOCATOR + #define _ENABLE_STD_ALLOCATOR 1 + #else + #define _ENABLE_STD_ALLOCATOR 0 + #endif + + using shared_string = std::conditional< _ENABLE_STD_ALLOCATOR, std::string, bip::basic_string< char, std::char_traits< char >, allocator< char > > >::type; template - using t_vector = typename std::conditional< ENABLE_STD_ALLOCATOR, + using t_vector = typename std::conditional< _ENABLE_STD_ALLOCATOR, std::vector >, bip::vector > >::type; @@ -58,25 +59,25 @@ namespace chainbase { using t_allocator_pair = allocator< t_pair< const FIRST_TYPE, SECOND_TYPE > >; template< typename KEY_TYPE, typename VALUE_TYPE, typename LESS_FUNC = std::less> - using t_flat_map = typename std::conditional< ENABLE_STD_ALLOCATOR, + using t_flat_map = typename std::conditional< _ENABLE_STD_ALLOCATOR, boost::container::flat_map< KEY_TYPE, VALUE_TYPE, LESS_FUNC, allocator< t_pair< KEY_TYPE, VALUE_TYPE > > >, bip::flat_map< KEY_TYPE, VALUE_TYPE, LESS_FUNC, allocator< t_pair< KEY_TYPE, VALUE_TYPE > > > >::type; template< typename KEY_TYPE, typename VALUE_TYPE, typename LESS_FUNC = std::less> - using t_map = typename std::conditional< ENABLE_STD_ALLOCATOR, + using t_map = typename std::conditional< _ENABLE_STD_ALLOCATOR, std::map< KEY_TYPE, VALUE_TYPE, LESS_FUNC, t_allocator_pair< KEY_TYPE, VALUE_TYPE > >, bip::map< KEY_TYPE, VALUE_TYPE, LESS_FUNC, t_allocator_pair< KEY_TYPE, VALUE_TYPE > > >::type; template< typename T > - using t_deque = typename std::conditional< ENABLE_STD_ALLOCATOR, + using t_deque = typename std::conditional< _ENABLE_STD_ALLOCATOR, std::deque< T, allocator< T > >, bip::deque< T, allocator< T > > >::type; template< typename T, typename LESS_FUNC > - using t_set = typename std::conditional< ENABLE_STD_ALLOCATOR, + using t_set = typename std::conditional< _ENABLE_STD_ALLOCATOR, std::set< T, LESS_FUNC, allocator< T > >, bip::set< T, LESS_FUNC, allocator< T > > >::type; diff --git a/programs/util/test_shared_mem.cpp b/programs/util/test_shared_mem.cpp index 97b11fc0c0..9265bcf9b0 100644 --- a/programs/util/test_shared_mem.cpp +++ b/programs/util/test_shared_mem.cpp @@ -179,7 +179,7 @@ int main(int argc, char** argv, char** envp) pbc->emplace( [&]( book& b ) { b.name = "emplace name"; b.pages = pbc->size(); - }, book::allocator_type( seg.get_segment_manager() ) ); + }, allocator( seg.get_segment_manager() ) ); #else pbc->emplace( [&]( book& b ) { b.name = "emplace name"; @@ -187,7 +187,7 @@ int main(int argc, char** argv, char** envp) }, allocator() ); #endif -#if ENABLE_STD_ALLOCATOR == 0 +#ifndef ENABLE_STD_ALLOCATOR t_deque< book > * deq = seg.find_or_construct>("book deque")(allocator(seg.get_segment_manager())); #else t_deque< book > * deq = new chainbase::t_deque( allocator() );