From 6c7abfd7f289c8685ea3c8cdc2094d66df8367f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 23 Jun 2007 13:01:38 +0000 Subject: [PATCH] no message [SVN r38075] --- doc/Jamfile.v2 | 2 +- doc/interprocess.qbk | 40 +-- example/Jamfile.v2 | 2 +- example/doc_message_queueB.cpp | 2 +- .../interprocess/allocators/adaptive_pool.hpp | 33 +- .../interprocess/allocators/allocator.hpp | 32 +- .../allocators/cached_adaptive_pool.hpp | 29 +- .../allocators/cached_node_allocator.hpp | 29 +- .../allocators/detail/adaptive_node_pool.hpp | 9 +- .../allocators/detail/node_pool.hpp | 2 +- .../allocators/node_allocator.hpp | 35 +-- .../allocators/private_adaptive_pool.hpp | 20 +- .../allocators/private_node_allocator.hpp | 19 +- .../boost/interprocess/containers/deque.hpp | 39 ++- .../containers/detail/flat_tree.hpp | 9 +- .../interprocess/containers/detail/tree.hpp | 16 +- .../interprocess/containers/flat_map.hpp | 11 +- .../interprocess/containers/flat_set.hpp | 6 +- .../boost/interprocess/containers/list.hpp | 61 ++-- include/boost/interprocess/containers/map.hpp | 5 +- include/boost/interprocess/containers/set.hpp | 4 +- .../boost/interprocess/containers/slist.hpp | 62 ++-- .../boost/interprocess/containers/string.hpp | 51 ++-- .../boost/interprocess/containers/vector.hpp | 53 ++-- .../detail/Attic/basic_segment_manager.hpp | 10 +- .../detail/Attic/creation_tags.hpp | 3 + .../detail/Attic/generic_cast.hpp | 54 ---- .../detail/basic_segment_manager.hpp | 10 +- .../interprocess/detail/config_begin.hpp | 15 +- .../boost/interprocess/detail/config_end.hpp | 7 +- .../interprocess/detail/creation_tags.hpp | 3 + .../interprocess/detail/file_wrapper.hpp | 1 + .../detail/in_place_interface.hpp | 4 +- .../boost/interprocess/detail/iterators.hpp | 281 +++++++++++++++--- .../detail/managed_memory_impl.hpp | 3 +- .../detail/managed_open_or_create_impl.hpp | 20 +- include/boost/interprocess/detail/move.hpp | 5 +- .../interprocess/detail/move_iterator.hpp | 3 +- include/boost/interprocess/detail/mpl.hpp | 49 ++- .../boost/interprocess/detail/named_proxy.hpp | 16 +- .../interprocess/detail/os_file_functions.hpp | 115 +------ .../interprocess/detail/pointer_type.hpp | 3 +- .../detail/posix_time_types_wrk.hpp | 10 + .../boost/interprocess/detail/type_traits.hpp | 168 +++++++++++ .../boost/interprocess/detail/utilities.hpp | 17 +- .../interprocess/detail/version_type.hpp | 59 +--- .../boost/interprocess/detail/win32_api.hpp | 10 + .../boost/interprocess/detail/workaround.hpp | 15 +- .../boost/interprocess/interprocess_fwd.hpp | 7 +- .../boost/interprocess/ipc/message_queue.hpp | 10 +- .../mem_algo/detail/simple_seq_fit_impl.hpp | 5 +- .../interprocess/mem_algo/rbtree_best_fit.hpp | 5 +- include/boost/interprocess/offset_ptr.hpp | 69 ++--- .../boost/interprocess/segment_manager.hpp | 74 ++--- .../interprocess/shared_memory_object.hpp | 5 +- .../interprocess/smart_ptr/intrusive_ptr.hpp | 31 -- .../interprocess/smart_ptr/scoped_ptr.hpp | 2 +- .../interprocess/smart_ptr/shared_ptr.hpp | 71 ++--- .../interprocess/smart_ptr/unique_ptr.hpp | 57 ++-- .../boost/interprocess/smart_ptr/weak_ptr.hpp | 6 +- .../sync/emulation/interprocess_condition.hpp | 5 +- .../sync/emulation/interprocess_mutex.hpp | 5 +- include/boost/interprocess/sync/file_lock.hpp | 113 +++++++ .../boost/interprocess/sync/scoped_lock.hpp | 1 - .../boost/interprocess/sync/sharable_lock.hpp | 2 +- .../interprocess/sync/upgradable_lock.hpp | 1 - .../interprocess/windows_shared_memory.hpp | 2 + proj/vc7ide/flat_tree_test.vcproj | 264 ++++++++-------- proj/vc7ide/interprocesslib.vcproj | 6 +- .../vc7ide/shared_memory_mappable_test.vcproj | 265 +++++++++-------- test/Jamfile.v2 | 2 +- test/allocator_v1.hpp | 31 +- test/condition_test_template.hpp | 2 +- test/deque_test.cpp | 9 +- test/dummy_test_allocator.hpp | 23 +- test/expand_bwd_test_allocator.hpp | 23 +- test/file_mapping_test.cpp | 1 + test/flat_tree_test.cpp | 46 ++- test/message_queue_test.cpp | 10 +- test/user_buffer_test.cpp | 6 +- test/vector_test.cpp | 8 +- 81 files changed, 1444 insertions(+), 1175 deletions(-) delete mode 100644 include/boost/interprocess/detail/Attic/generic_cast.hpp create mode 100644 include/boost/interprocess/detail/type_traits.hpp diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 0d0220b..a0dd004 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -27,9 +27,9 @@ doxygen interprocess_doxygen EXTRACT_ALL=NO HIDE_UNDOC_MEMBERS=YES EXTRACT_PRIVATE=NO + EXPAND_ONLY_PREDEF=YES # ENABLE_PREPROCESSING=NO # MACRO_EXPANSION=YES - EXPAND_ONLY_PREDEF=YES # SEARCH_INCLUDES=YES # INCLUDE_PATH=$(BOOST_ROOT) ; diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk index 1629adc..5528de1 100644 --- a/doc/interprocess.qbk +++ b/doc/interprocess.qbk @@ -1,6 +1,6 @@ -[library Interprocess +[library Boost.Interprocess [quickbook 1.4] - [version 2007-05-03] + [version 2007-06-23] [authors [Gaztañaga, Ion]] [copyright 2005- 2007 Ion Gaztañaga] [purpose Interprocess communication utilities] @@ -2824,7 +2824,7 @@ These classes can be customized with the following template parameters: addresses in each process. If `void_pointer` is `void*` only fixed address mapping could be used. - * See [link interprocess.customizing_boost_interprocess.custom_interprocess_alloc Writing a new memory + * See [link boost_interprocess.customizing_boost_interprocess.custom_interprocess_alloc Writing a new memory allocation algorithm] for more details about memory algorithms. * *IndexType* is the type of index that will be used to store the name-object @@ -3412,7 +3412,7 @@ just must specify [boost::interprocess::map_index map_index] as a template param [*Boost.Interprocess] plans to offer an *unordered_map* based index as soon as this container is included in Boost. If these indexes are not enough for you, you can define your own index type. To know how to do this, go to -[link interprocess.customizing_boost_interprocess.custom_indexes Building custom indexes] section. +[link boost_interprocess.customizing_boost_interprocess.custom_indexes Building custom indexes] section. [endsect] @@ -3695,7 +3695,7 @@ offers 3 allocators based on this segregated storage algorithm: To know the details of the implementation of of the segregated storage pools see the -[link interprocess.architecture_2.implementation_segregated_storage_pools Implementation of [*Boost.Interprocess] segregated storage pools] +[link boost_interprocess.architecture_2.implementation_segregated_storage_pools Implementation of [*Boost.Interprocess] segregated storage pools] section. [section:segregated_allocators_common Additional parameters and functions of segregated storage node allocators] @@ -3704,7 +3704,7 @@ section. [classref boost::interprocess::private_node_allocator private_node_allocator] and [classref boost::interprocess::cached_node_allocator cached_node_allocator] implement the standard allocator interface and the functions explained in the -[link interprocess.allocator_introduction.allocator_properties Properties of Boost.Interprocess allocators]. +[link boost_interprocess.allocator_introduction.allocator_properties Properties of Boost.Interprocess allocators]. All these allocators are templatized by 3 parameters: @@ -3731,7 +3731,7 @@ pool is used for each node size. This is not possible if you try to share a node allocator between processes. To achieve this sharing [classref boost::interprocess::node_allocator node_allocator] uses the segment manager's unique type allocation service -(see [link interprocess.managed_memory_segment_features.unique Unique instance construction] section). +(see [link boost_interprocess.managed_memory_segment_features.unique Unique instance construction] section). In the initialization, a [classref boost::interprocess::node_allocator node_allocator] @@ -3926,7 +3926,7 @@ and performance (aceptable for many applications) with the ability to return fre of nodes to the memory segment, so that they can be used by any other container or managed object construction. To know the details of the implementation of of "adaptive pools" see the -[link interprocess.architecture_2.implementation_adaptive_pools Implementation of [*Boost.Intrusive] adaptive pools] +[link boost_interprocess.architecture_2.implementation_adaptive_pools Implementation of [*Boost.Intrusive] adaptive pools] section. Like with segregated storage based node allocators, Boost.Interprocess offers @@ -3940,7 +3940,7 @@ Like with segregated storage based node allocators, Boost.Interprocess offers [classref boost::interprocess::private_adaptive_pool private_adaptive_pool] and [classref boost::interprocess::cached_adaptive_pool cached_adaptive_pool] implement the standard allocator interface and the functions explained in the -[link interprocess.allocator_introduction.allocator_properties Properties of Boost.Interprocess allocators]. +[link boost_interprocess.allocator_introduction.allocator_properties Properties of Boost.Interprocess allocators]. All these allocators are templatized by 4 parameters: @@ -4238,7 +4238,7 @@ in a generic way, [*Boost.Interprocess] offers the following classes: to be used in managed memory segments like shared memory. It's implemented using a vector-like contiguous storage, so it has fast c string conversion and can be used with the - [link interprocess.streams.vectorstream vectorstream] iostream formatting classes. + [link boost_interprocess.streams.vectorstream vectorstream] iostream formatting classes. To use it include: [c++] @@ -5139,7 +5139,7 @@ pointer. If the [*memory algorithm] will be used just with fixed address mapping `void_pointer` can be defined as `void*`. The rest of the interface of a [*Boost.Interprocess] [*memory algorithm] is described in -[link interprocess.customizing_boost_interprocess.custom_interprocess_alloc Writing a new shared memory allocation algorithm] +[link boost_interprocess.customizing_boost_interprocess.custom_interprocess_alloc Writing a new shared memory allocation algorithm] section. As memory algorithm examples, you can see the implementations [classref boost::interprocess::simple_seq_fit simple_seq_fit] or [classref boost::interprocess::rbtree_best_fit rbtree_best_fit] classes. @@ -5216,7 +5216,7 @@ to be used to identify named objects, we can specify the memory algorithm that w control dynamically the portions of the memory segment, and we can specify also the index type that will store the [name pointer, object information] mapping. We can construct our own index types as explained in -[link interprocess.customizing_boost_interprocess.custom_indexes Building custom indexes] section. +[link boost_interprocess.customizing_boost_interprocess.custom_indexes Building custom indexes] section. [endsect] @@ -5483,7 +5483,7 @@ that boost::interprocess::rbtree_best_fit class offers: * The [*allocate()] function must return 0 if there is no more available memory. The memory returned by [*my_algorithm] must be aligned to the most restrictive memory alignment of the system, for example, - to the value returned by *boost::alignment_of::value*. + to the value returned by *detail::alignment_of::value*. This function should be executed with the synchronization capabilities offered by `typename mutex_family::mutex_type` interprocess_mutex. That means, that if we define `typedef mutex_family mutex_family;` then this function should offer @@ -5757,13 +5757,13 @@ these alternatives: allocators call `allocate()` only when the pool runs out of nodes. This is pretty efficient (much more than the current default general-purpose algorithm) and this can save a lot of memory. See - [link interprocess.stl_allocators_segregated_storage Segregated storage node allocators] and - [link interprocess.stl_allocators_adaptive Adaptive node allocators] for more information. + [link boost_interprocess.stl_allocators_segregated_storage Segregated storage node allocators] and + [link boost_interprocess.stl_allocators_adaptive Adaptive node allocators] for more information. * Write your own memory algorithm. If you have experience with memory allocation algorithms and you think another algorithm is better suited than the default one for your application, you can specify it in all [*Boost.Interprocess] managed memory segments. See the section - [link interprocess.customizing_boost_interprocess.custom_interprocess_alloc Writing a new shared memory allocation algorithm] + [link boost_interprocess.customizing_boost_interprocess.custom_interprocess_alloc Writing a new shared memory allocation algorithm] to know how to do this. If you think its better than the default one for general-purpose applications, be polite and donate it to [*Boost.Interprocess] to make it default! @@ -5842,7 +5842,7 @@ If you see that the performance is not good enough you have these alternatives: * Use another [*Boost.Interprocess] index type if you feel the default one is not fast enough. If you are not still satisfied, write your own index type. See - [link interprocess.customizing_boost_interprocess.custom_indexes Building custom indexes] for this. + [link boost_interprocess.customizing_boost_interprocess.custom_indexes Building custom indexes] for this. * Destruction via pointer is at least as fast as using the name of the object and can be faster (in node containers, for example). So if your problem is that you @@ -6009,14 +6009,14 @@ limitations under the License. [section:changes Changes...] -[section:changes_interprocess_2007_06_11 Changes in Interprocess 2007-06-11...] +[section:changes_interprocess_2007_06_23 Changes in Interprocess 2007-06-23...] * Added iteration of named and unique objects in a segment manager. * Fixed leak in [classref boost::interprocess::vector vector]. * Added support for Solaris. * Optimized [classref boost::interprocess::segment_manager] to avoid code bloat associated with templated instantiations. -* Removed the use of allocator::construct/destroy from containers. +* Removed the use of allocator::construct and allocator::destroy from containers. * Correction of typos and documentation errors. * Fixed bug for UNIX: No slash ('/') was being added as the first character for shared memory names, leading to errors in some UNIX systems. @@ -6185,4 +6185,4 @@ allocators and containers, I've used to design Interprocess. [endsect] -[xinclude interprocess_doxygen.boostbook] +[xinclude interprocess_doxygen.xml] diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index 387f761..09309d4 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -32,4 +32,4 @@ rule test_all return $(all_rules) ; } -test-suite interprocess_example : [ test_all r ] ; \ No newline at end of file +test-suite interprocess_example : [ test_all r ] : multi ; \ No newline at end of file diff --git a/example/doc_message_queueB.cpp b/example/doc_message_queueB.cpp index fdfc633..398f055 100644 --- a/example/doc_message_queueB.cpp +++ b/example/doc_message_queueB.cpp @@ -24,7 +24,7 @@ int main () ); unsigned int priority; - unsigned int recvd_size; + std::size_t recvd_size; //Receive 100 numbers for(int i = 0; i < 100; ++i){ diff --git a/include/boost/interprocess/allocators/adaptive_pool.hpp b/include/boost/interprocess/allocators/adaptive_pool.hpp index 855c29f..5d22fbd 100644 --- a/include/boost/interprocess/allocators/adaptive_pool.hpp +++ b/include/boost/interprocess/allocators/adaptive_pool.hpp @@ -19,12 +19,9 @@ #include #include -#include -#include -#include #include #include -#include +#include #include #include #include @@ -71,10 +68,10 @@ class adaptive_pool typedef typename detail:: pointer_to_other::type const_pointer; typedef T value_type; - typedef typename workaround::random_it - ::reference reference; - typedef typename workaround::random_it - ::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -140,26 +137,26 @@ class adaptive_pool (detail::get_pointer(mp_node_pool)); return node_pool->get_segment_manager(); } - - /*!Return address of mutable value. Never throws*/ +/* + //!Return address of mutable value. Never throws pointer address(reference value) const - { return pointer(boost::addressof(value)); } + { return pointer(addressof(value)); } - /*!Return address of nonmutable value. Never throws*/ + //!Return address of nonmutable value. Never throws const_pointer address(const_reference value) const - { return const_pointer(boost::addressof(value)); } + { return const_pointer(addressof(value)); } - /*!Construct object, calling constructor. - Throws if T(const Convertible &) throws*/ + //!Construct object, calling constructor. + //!Throws if T(const Convertible &) throws template void construct(const pointer &ptr, const Convertible &value) { new(detail::get_pointer(ptr)) value_type(value); } - /*!Destroys object. Throws if object's destructor throws*/ + //!Destroys object. Throws if object's destructor throws void destroy(const pointer &ptr) { BOOST_ASSERT(ptr != 0); (*ptr).~value_type(); } - - /*!Returns the number of elements that could be allocated. Never throws*/ +*/ + //!Returns the number of elements that could be allocated. Never throws size_type max_size() const { return this->get_segment_manager()->get_size()/sizeof(value_type); } diff --git a/include/boost/interprocess/allocators/allocator.hpp b/include/boost/interprocess/allocators/allocator.hpp index b7f95ee..e36fc1a 100644 --- a/include/boost/interprocess/allocators/allocator.hpp +++ b/include/boost/interprocess/allocators/allocator.hpp @@ -20,12 +20,11 @@ #include #include -#include #include #include #include #include -#include +#include #include #include @@ -85,10 +84,10 @@ class allocator ::type pointer; typedef typename detail:: pointer_to_other::type const_pointer; - typedef typename workaround::random_it - ::reference reference; - typedef typename workaround::random_it - ::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -104,15 +103,15 @@ class allocator /*!Returns the segment manager. Never throws*/ segment_manager* get_segment_manager()const { return detail::get_pointer(mp_mngr); } +/* + //!Returns address of mutable object. Never throws + pointer address(reference value) + { return pointer(addressof(value)); } - /*!Returns address of mutable object. Never throws*/ - pointer address(reference value) const - { return pointer(boost::addressof(value)); } - - /*!Returns address of non mutable object. Never throws*/ + //!Returns address of non mutable object. Never throws const_pointer address(const_reference value) const - { return const_pointer(boost::addressof(value)); } - + { return const_pointer(addressof(value)); } +*/ /*!Constructor from the segment manager. Never throws*/ allocator(segment_manager *segment_mngr) : mp_mngr(segment_mngr) { } @@ -176,7 +175,7 @@ class allocator mp_mngr->allocation_command (command, l_size, p_size, r_size, detail::get_pointer(reuse), sizeof(value_type)); received_size = r_size/sizeof(value_type); - BOOST_ASSERT(0 == ((std::size_t)result.first % boost::alignment_of::value)); + BOOST_ASSERT(0 == ((std::size_t)result.first % detail::alignment_of::value)); return std::pair (static_cast(result.first), result.second); } @@ -224,8 +223,9 @@ struct has_trivial_destructor; template struct has_trivial_destructor > - : public ::boost::true_type -{}; +{ + enum { value = true }; +}; /// @endcond } //namespace boost { diff --git a/include/boost/interprocess/allocators/cached_adaptive_pool.hpp b/include/boost/interprocess/allocators/cached_adaptive_pool.hpp index 204d8f2..2ff84dff 100644 --- a/include/boost/interprocess/allocators/cached_adaptive_pool.hpp +++ b/include/boost/interprocess/allocators/cached_adaptive_pool.hpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -72,10 +71,10 @@ class cached_adaptive_pool typedef typename detail:: pointer_to_other::type const_pointer; typedef T value_type; - typedef typename workaround::random_it - ::reference reference; - typedef typename workaround::random_it - ::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -162,25 +161,25 @@ class cached_adaptive_pool /*!Returns the max cached nodes parameter. Never throws*/ std::size_t get_max_cached_nodes() const { return m_max_cached_nodes; } - - /*!Return address of mutable value. Never throws*/ - pointer address(reference value) const - { return pointer(boost::addressof(value)); } +/* + //!Return address of mutable value. Never throws + pointer address(reference value) + { return pointer(addressof(value)); } - /*!Return address of non mutable value. Never throws*/ + //!Return address of non mutable value. Never throws const_pointer address(const_reference value) const - { return const_pointer(boost::addressof(value)); } + { return const_pointer(addressof(value)); } - /*!Construct object, calling constructor. - Throws if T(const Convertible &) throws*/ + //!Construct object, calling constructor. + //!Throws if T(const Convertible &) throws template void construct(const pointer &ptr, const Convertible &value) { new(detail::get_pointer(ptr)) value_type(value); } - /*!Destroys object. Throws if object's destructor throws*/ + //!Destroys object. Throws if object's destructor throws void destroy(const pointer &ptr) { BOOST_ASSERT(ptr != 0); (*ptr).~value_type(); } - +*/ /*!Returns the number of elements that could be allocated. Never throws*/ size_type max_size() const { return this->get_segment_manager()->get_size()/sizeof(value_type); } diff --git a/include/boost/interprocess/allocators/cached_node_allocator.hpp b/include/boost/interprocess/allocators/cached_node_allocator.hpp index 2be6dd8..4a07140 100644 --- a/include/boost/interprocess/allocators/cached_node_allocator.hpp +++ b/include/boost/interprocess/allocators/cached_node_allocator.hpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -70,10 +69,10 @@ class cached_node_allocator typedef typename detail:: pointer_to_other::type const_pointer; typedef T value_type; - typedef typename workaround::random_it - ::reference reference; - typedef typename workaround::random_it - ::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -160,26 +159,26 @@ class cached_node_allocator /*!Returns the max cached nodes parameter. Never throws*/ std::size_t get_max_cached_nodes() const { return m_max_cached_nodes; } - - /*!Return address of mutable value. Never throws*/ +/* + //!Return address of mutable value. Never throws pointer address(reference value) const - { return pointer(boost::addressof(value)); } + { return pointer(addressof(value)); } - /*!Return address of non mutable value. Never throws*/ + //!Return address of non mutable value. Never throws const_pointer address(const_reference value) const - { return const_pointer(boost::addressof(value)); } + { return const_pointer(addressof(value)); } - /*!Construct object, calling constructor. - Throws if T(const Convertible &) throws*/ + //!Construct object, calling constructor. + //!Throws if T(const Convertible &) throws template void construct(const pointer &ptr, const Convertible &value) { new(detail::get_pointer(ptr)) value_type(value); } - /*!Destroys object. Throws if object's destructor throws*/ + //!Destroys object. Throws if object's destructor throws void destroy(const pointer &ptr) { BOOST_ASSERT(ptr != 0); (*ptr).~value_type(); } - - /*!Returns the number of elements that could be allocated. Never throws*/ +*/ + //!Returns the number of elements that could be allocated. Never throws size_type max_size() const { return this->get_segment_manager()->get_size()/sizeof(value_type); } diff --git a/include/boost/interprocess/allocators/detail/adaptive_node_pool.hpp b/include/boost/interprocess/allocators/detail/adaptive_node_pool.hpp index c88b631..1d1671d 100644 --- a/include/boost/interprocess/allocators/detail/adaptive_node_pool.hpp +++ b/include/boost/interprocess/allocators/detail/adaptive_node_pool.hpp @@ -25,8 +25,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -77,7 +76,7 @@ class private_adaptive_node_pool typedef boost::intrusive::list > chunk_list_t; - enum { Alignment = boost::alignment_of::value }; + enum { Alignment = detail::alignment_of::value }; enum { RealNodeSize = boost::math::static_lcm::value }; enum { HeaderSize = ct_min::value @@ -274,7 +273,7 @@ class private_adaptive_node_pool assert(m_allocated==0); priv_invariants(); m_first_free_chunk = m_chunk_list.end(); - m_chunk_list.clear_and_destroy + m_chunk_list.clear_and_dispose (chunk_destroyer(detail::get_pointer(mp_segment_mngr))); m_free_chunks = 0; } @@ -373,7 +372,7 @@ class private_adaptive_node_pool chunk_iterator it(--m_chunk_list.end()); if(it == m_first_free_chunk) ++m_first_free_chunk; //m_first_free_chunk is now equal to end() - m_chunk_list.erase_and_destroy(it, chunk_destroyer(detail::get_pointer(mp_segment_mngr))); + m_chunk_list.erase_and_dispose(it, chunk_destroyer(detail::get_pointer(mp_segment_mngr))); --m_free_chunks; } } diff --git a/include/boost/interprocess/allocators/detail/node_pool.hpp b/include/boost/interprocess/allocators/detail/node_pool.hpp index 3d4c0eb..0da3dae 100644 --- a/include/boost/interprocess/allocators/detail/node_pool.hpp +++ b/include/boost/interprocess/allocators/detail/node_pool.hpp @@ -208,7 +208,7 @@ class private_node_pool const void *addr = get_chunk_from_hook(&*it); //Execute the algorithm and get an iterator to the last value - m_freelist.remove_and_destroy_if + m_freelist.remove_and_dispose_if (is_between(addr, BlockSize), push_in_list(free_nodes, last_it)); //If the number of nodes is equal to nodes_per_chunk diff --git a/include/boost/interprocess/allocators/node_allocator.hpp b/include/boost/interprocess/allocators/node_allocator.hpp index 899096c..15b4e8f 100644 --- a/include/boost/interprocess/allocators/node_allocator.hpp +++ b/include/boost/interprocess/allocators/node_allocator.hpp @@ -19,9 +19,6 @@ #include #include -#include -#include -#include #include #include #include @@ -68,10 +65,10 @@ class node_allocator typedef typename detail:: pointer_to_other::type const_pointer; typedef T value_type; - typedef typename workaround::random_it - ::reference reference; - typedef typename workaround::random_it - ::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -138,31 +135,31 @@ class node_allocator (detail::get_pointer(mp_node_pool)); return node_pool->get_segment_manager(); } - - /*!Return address of mutable value. Never throws*/ +/* + //!Return address of mutable value. Never throws pointer address(reference value) const - { return pointer(boost::addressof(value)); } + { return pointer(addressof(value)); } - /*!Return address of nonmutable value. Never throws*/ + //!Return address of nonmutable value. Never throws const_pointer address(const_reference value) const - { return const_pointer(boost::addressof(value)); } + { return const_pointer(addressof(value)); } - /*!Construct object, calling constructor. - Throws if T(const Convertible &) throws*/ + //!Construct object, calling constructor. + //!Throws if T(const Convertible &) throws template void construct(const pointer &ptr, const Convertible &value) { new(detail::get_pointer(ptr)) value_type(value); } - /*!Destroys object. Throws if object's destructor throws*/ + //!Destroys object. Throws if object's destructor throws void destroy(const pointer &ptr) { BOOST_ASSERT(ptr != 0); (*ptr).~value_type(); } - - /*!Returns the number of elements that could be allocated. Never throws*/ +*/ + //!Returns the number of elements that could be allocated. Never throws size_type max_size() const { return this->get_segment_manager()->get_size()/sizeof(value_type); } - /*!Allocate memory for an array of count elements. - Throws boost::interprocess::bad_alloc if there is no enough memory*/ + //!Allocate memory for an array of count elements. + //!Throws boost::interprocess::bad_alloc if there is no enough memory pointer allocate(size_type count, cvoid_pointer = 0) { if(count > ((size_type)-1)/sizeof(value_type)) diff --git a/include/boost/interprocess/allocators/private_adaptive_pool.hpp b/include/boost/interprocess/allocators/private_adaptive_pool.hpp index 180fd96..20471e1 100644 --- a/include/boost/interprocess/allocators/private_adaptive_pool.hpp +++ b/include/boost/interprocess/allocators/private_adaptive_pool.hpp @@ -19,9 +19,6 @@ #include #include -#include -#include -#include #include #include #include @@ -69,10 +66,10 @@ class private_adaptive_pool typedef typename detail:: pointer_to_other::type const_pointer; typedef T value_type; - typedef typename workaround::random_it - ::reference reference; - typedef typename workaround::random_it - ::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -141,14 +138,14 @@ class private_adaptive_pool //!Returns the segment manager. Never throws segment_manager* get_segment_manager()const { return detail::get_pointer(mp_segment_mngr); } - +/* //!Return address of mutable value. Never throws pointer address(reference value) const - { return pointer(boost::addressof(value)); } + { return pointer(addressof(value)); } //!Return address of non mutable value. Never throws const_pointer address(const_reference value) const - { return const_pointer(boost::addressof(value)); } + { return const_pointer(addressof(value)); } //!Construct object, calling constructor. //!Throws if T(const Convertible &) throws @@ -159,8 +156,7 @@ class private_adaptive_pool //!Destroys object. Throws if object's destructor throws void destroy(const pointer &ptr) { BOOST_ASSERT(ptr != 0); (*ptr).~value_type(); } - - +*/ //!Returns the number of elements that could be allocated. Never throws size_type max_size() const { return mp_segment_mngr->get_size()/sizeof(value_type); } diff --git a/include/boost/interprocess/allocators/private_node_allocator.hpp b/include/boost/interprocess/allocators/private_node_allocator.hpp index fa10359..8aa5f8a 100644 --- a/include/boost/interprocess/allocators/private_node_allocator.hpp +++ b/include/boost/interprocess/allocators/private_node_allocator.hpp @@ -19,9 +19,6 @@ #include #include -#include -#include -#include #include #include #include @@ -70,10 +67,10 @@ class private_node_allocator typedef typename detail:: pointer_to_other::type const_pointer; typedef T value_type; - typedef typename workaround::random_it - ::reference reference; - typedef typename workaround::random_it - ::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -143,14 +140,14 @@ class private_node_allocator //!Returns the segment manager. Never throws segment_manager* get_segment_manager()const { return detail::get_pointer(mp_segment_mngr); } - +/* //!Return address of mutable value. Never throws pointer address(reference value) const - { return pointer(boost::addressof(value)); } + { return pointer(addressof(value)); } //!Return address of non mutable value. Never throws const_pointer address(const_reference value) const - { return const_pointer(boost::addressof(value)); } + { return const_pointer(addressof(value)); } //!Construct object, calling constructor. //!Throws if T(const Convertible &) throws @@ -161,7 +158,7 @@ class private_node_allocator //!Destroys object. Throws if object's destructor throws void destroy(const pointer &ptr) { BOOST_ASSERT(ptr != 0); (*ptr).~value_type(); } - +*/ //!Returns the number of elements that could be allocated. Never throws size_type max_size() const { return mp_segment_mngr->get_size()/sizeof(value_type); } diff --git a/include/boost/interprocess/containers/deque.hpp b/include/boost/interprocess/containers/deque.hpp index 0572c72..b43fbe3 100644 --- a/include/boost/interprocess/containers/deque.hpp +++ b/include/boost/interprocess/containers/deque.hpp @@ -57,8 +57,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -70,7 +69,6 @@ #include namespace boost { - namespace interprocess { /// @cond @@ -154,7 +152,7 @@ class deque_base // A pointer in the range [map, map + map_size) points to an allocated node // if and only if the pointer is in the range [start.node, finish.node]. class const_iterator - : public boost::iterator { @@ -500,8 +498,8 @@ class deque : protected deque_base typedef typename Base::iterator iterator; typedef typename Base::const_iterator const_iterator; - typedef boost::reverse_iterator const_reverse_iterator; - typedef boost::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; /// @cond protected: // Internal typedefs @@ -617,8 +615,8 @@ class deque : protected deque_base const allocator_type& a = allocator_type()) : Base(a) { //Dispatch depending on integer/iterator - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; this->priv_initialize_dispatch(first, last, Result()); } @@ -671,8 +669,8 @@ class deque : protected deque_base template void assign(InpIt first, InpIt last) { //Dispatch depending on integer/iterator - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; this->priv_assign_dispatch(first, last, Result()); } @@ -821,8 +819,8 @@ class deque : protected deque_base void insert(iterator pos, InpIt first, InpIt last) { //Dispatch depending on integer/iterator - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; this->priv_insert_dispatch(pos, first, last, Result()); } @@ -845,11 +843,12 @@ class deque : protected deque_base this->priv_reserve_elements_at_back(new_size); while(n--){ + //T default_constructed = move(T()); T default_constructed; - if(boost::is_scalar::value){ +/* if(boost::is_scalar::value){ //Value initialization new(&default_constructed)T(); - } + }*/ this->push_back(move(default_constructed)); } } @@ -986,14 +985,14 @@ class deque : protected deque_base } template - void priv_initialize_dispatch(Integer n, Integer x, true_) + void priv_initialize_dispatch(Integer n, Integer x, detail::true_) { this->priv_initialize_map(n); this->priv_fill_initialize(x); } template - void priv_initialize_dispatch(InpIt first, InpIt last, false_) + void priv_initialize_dispatch(InpIt first, InpIt last, detail::false_) { typedef typename std::iterator_traits::iterator_category ItCat; this->priv_range_initialize(first, last, ItCat()); @@ -1012,11 +1011,11 @@ class deque : protected deque_base } template - void priv_assign_dispatch(Integer n, Integer val, true_) + void priv_assign_dispatch(Integer n, Integer val, detail::true_) { this->priv_fill_assign((size_type) n, (T) val); } template - void priv_assign_dispatch(InpIt first, InpIt last, false_) + void priv_assign_dispatch(InpIt first, InpIt last, detail::false_) { typedef typename std::iterator_traits::iterator_category ItCat; this->priv_assign_aux(first, last, ItCat()); @@ -1051,7 +1050,7 @@ class deque : protected deque_base template void priv_insert_dispatch(iterator pos, Integer n, Integer x, - true_) + detail::true_) { this->priv_fill_insert(pos, (size_type) n, (value_type) x); } @@ -1059,7 +1058,7 @@ class deque : protected deque_base template void priv_insert_dispatch(iterator pos, InpIt first, InpIt last, - false_) + detail::false_) { typedef typename std::iterator_traits::iterator_category ItCat; this->insert(pos, first, last, ItCat()); diff --git a/include/boost/interprocess/containers/detail/flat_tree.hpp b/include/boost/interprocess/containers/detail/flat_tree.hpp index c3a5477..9cd310c 100644 --- a/include/boost/interprocess/containers/detail/flat_tree.hpp +++ b/include/boost/interprocess/containers/detail/flat_tree.hpp @@ -37,7 +37,6 @@ #include #include -#include #include #include #include @@ -119,8 +118,8 @@ class flat_tree typedef typename allocator_type::difference_type difference_type; typedef typename vector_t::iterator iterator; typedef typename vector_t::const_iterator const_iterator; - typedef boost::reverse_iterator reverse_iterator; - typedef boost::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; // allocation/deallocation @@ -718,8 +717,8 @@ template > { enum { value = - has_trivial_destructor::value && - has_trivial_destructor::value }; + has_trivial_destructor::value && + has_trivial_destructor::value }; }; } //namespace interprocess { diff --git a/include/boost/interprocess/containers/detail/tree.hpp b/include/boost/interprocess/containers/detail/tree.hpp index a3c5cb4..82edead 100644 --- a/include/boost/interprocess/containers/detail/tree.hpp +++ b/include/boost/interprocess/containers/detail/tree.hpp @@ -47,8 +47,6 @@ #include #include -#include -#include #include #include #include @@ -417,7 +415,7 @@ class rbtree public: //rbtree const_iterator class const_iterator - : public boost::iterator + : public std::iterator < std::bidirectional_iterator_tag , value_type , rbtree_difference_type , rbtree_const_pointer , rbtree_const_reference> @@ -507,8 +505,8 @@ class rbtree { iterator tmp = *this; --*this; return tmp; } }; - typedef boost::reverse_iterator reverse_iterator; - typedef boost::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; rbtree(const key_compare& comp = key_compare(), const allocator_type& a = allocator_type()) @@ -837,16 +835,16 @@ class rbtree } iterator erase(const_iterator position) - { return iterator(this->m_irbtree.erase_and_destroy(position.get(), Destroyer(*this))); } + { return iterator(this->m_irbtree.erase_and_dispose(position.get(), Destroyer(*this))); } size_type erase(const key_type& k) - { return this->m_irbtree.erase_and_destroy(k, KeyNodeCompare(value_comp()), Destroyer(*this)); } + { return this->m_irbtree.erase_and_dispose(k, KeyNodeCompare(value_comp()), Destroyer(*this)); } iterator erase(const_iterator first, const_iterator last) - { return iterator(this->m_irbtree.erase_and_destroy(first.get(), last.get(), Destroyer(*this))); } + { return iterator(this->m_irbtree.erase_and_dispose(first.get(), last.get(), Destroyer(*this))); } void clear() - { this->m_irbtree.clear_and_destroy(Destroyer(*this)); } + { this->m_irbtree.clear_and_dispose(Destroyer(*this)); } // set operations: iterator find(const key_type& k) diff --git a/include/boost/interprocess/containers/flat_map.hpp b/include/boost/interprocess/containers/flat_map.hpp index 8d1dac2..2023a7c 100644 --- a/include/boost/interprocess/containers/flat_map.hpp +++ b/include/boost/interprocess/containers/flat_map.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -67,12 +68,12 @@ inline bool operator<(const flat_map& x, template class flat_map { - /// @endcond + /// @cond private: //This is the real tree stored here. It's based on a movable pair typedef detail::flat_tree, - select1st< detail::pair >, + detail::select1st< detail::pair >, Pred, typename Alloc::template rebind >::other> impl_tree_t; @@ -80,7 +81,7 @@ class flat_map //This is the tree that we should store if pair was movable typedef detail::flat_tree, - select1st< std::pair >, + detail::select1st< std::pair >, Pred, Alloc> tree_t; @@ -700,14 +701,14 @@ class flat_multimap //This is the real tree stored here. It's based on a movable pair typedef detail::flat_tree, - select1st< detail::pair >, + detail::select1st< detail::pair >, Pred, typename Alloc::template rebind >::other> impl_tree_t; typedef detail::flat_tree, - select1st< std::pair >, + detail::select1st< std::pair >, Pred, Alloc> tree_t; // tree_t m_flat_tree; // flat tree representing flat_multimap diff --git a/include/boost/interprocess/containers/flat_set.hpp b/include/boost/interprocess/containers/flat_set.hpp index 8a76042..8f1a972 100644 --- a/include/boost/interprocess/containers/flat_set.hpp +++ b/include/boost/interprocess/containers/flat_set.hpp @@ -60,8 +60,7 @@ class flat_set { /// @cond private: - typedef detail::flat_tree, Pred, Alloc> tree_t; + typedef detail::flat_tree, Pred, Alloc> tree_t; tree_t m_flat_tree; // flat tree representing flat_set /// @endcond @@ -577,8 +576,7 @@ class flat_multiset { /// @cond private: - typedef detail::flat_tree, Pred, Alloc> tree_t; + typedef detail::flat_tree, Pred, Alloc> tree_t; tree_t m_flat_tree; // flat tree representing flat_multiset /// @endcond diff --git a/include/boost/interprocess/containers/list.hpp b/include/boost/interprocess/containers/list.hpp index 601d460..683e67b 100644 --- a/include/boost/interprocess/containers/list.hpp +++ b/include/boost/interprocess/containers/list.hpp @@ -52,9 +52,6 @@ #include #include -#include -#include -#include #include #include #include @@ -65,6 +62,7 @@ #include #include #include +#include namespace boost { namespace interprocess { @@ -84,6 +82,10 @@ struct list_node , boost::intrusive::safe_link , VoidPointer> IlistData; + list_node() + : m_data() + {} + #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE template list_node(const Convertible &conv) @@ -161,6 +163,9 @@ struct list_alloc { new(detail::get_pointer(ptr)) Node(forward(value)); } #endif + static void construct(const NodePtr &ptr) + { new(detail::get_pointer(ptr)) Node(); } + static void destroy(const NodePtr &ptr) { detail::get_pointer(ptr)->~Node(); } @@ -186,6 +191,15 @@ struct list_alloc } #endif + NodePtr create_node() + { + NodePtr p = NodeAlloc::allocate(1); + Deallocator node_deallocator(p, *this); + self_t::construct(p); + node_deallocator.release(); + return (p); + } + void destroy_node(NodePtr node) { self_t::destroy(node); @@ -316,7 +330,7 @@ class list public: //! Const iterator used to iterate through a list. class const_iterator - : public boost::iterator { @@ -410,9 +424,9 @@ class list }; //! Iterator used to iterate backwards through a list. - typedef boost::reverse_iterator reverse_iterator; + typedef std::reverse_iterator reverse_iterator; //! Const iterator used to iterate backwards through a list. - typedef boost::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; //! Effects: Constructs a list taking the allocator as parameter. //! @@ -499,7 +513,7 @@ class list //! //! Complexity: Linear to the number of elements in the list. void clear() - { this->m_ilist.clear_and_destroy(Destroyer(*this)); } + { this->m_ilist.clear_and_dispose(Destroyer(*this)); } //! Effects: Returns an iterator to the first element contained in the list. //! @@ -740,13 +754,8 @@ class list } else{ size_type n = new_size - len; - while(n--){ - T default_constructed; - if(boost::is_scalar::value){ - //Value initialization hack. Fix me! - new(&default_constructed)T(); - } - this->push_back(move(default_constructed)); + for (size_type i = 0; i < n; ++i){ + this->m_ilist.push_back(*this->create_node()); } } } @@ -832,8 +841,8 @@ class list template void insert(iterator p, InpIt first, InpIt last) { - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; this->priv_insert_dispatch(p, first, last, Result()); } @@ -879,7 +888,7 @@ class list //! //! Complexity: Amortized constant time. iterator erase(iterator p) - { return iterator(this->m_ilist.erase_and_destroy(p.get(), Destroyer(*this))); } + { return iterator(this->m_ilist.erase_and_dispose(p.get(), Destroyer(*this))); } //! Requires: first and last must be valid iterator to elements in *this. //! @@ -889,7 +898,7 @@ class list //! //! Complexity: Linear to the distance between first and last. iterator erase(iterator first, iterator last) - { return iterator(this->m_ilist.erase_and_destroy(first.get(), last.get(), Destroyer(*this))); } + { return iterator(this->m_ilist.erase_and_dispose(first.get(), last.get(), Destroyer(*this))); } //! Effects: Assigns the n copies of val to *this. //! @@ -908,8 +917,8 @@ class list template void assign(InpIt first, InpIt last) { - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; this->priv_assign_dispatch(first, last, Result()); } @@ -1053,7 +1062,7 @@ class list void remove_if(Pred pred) { typedef ValueCompareToNodeCompare Predicate; - this->m_ilist.remove_and_destroy_if(Predicate(pred), Destroyer(*this)); + this->m_ilist.remove_and_dispose_if(Predicate(pred), Destroyer(*this)); } //! Effects: Removes adjacent duplicate elements or adjacent @@ -1081,7 +1090,7 @@ class list void unique(BinaryPredicate binary_pred) { typedef ValueCompareToNodeCompare Predicate; - this->m_ilist.unique_and_destroy(Predicate(binary_pred), Destroyer(*this)); + this->m_ilist.unique_and_dispose(Predicate(binary_pred), Destroyer(*this)); } //! Requires: The lists x and *this must be distinct. @@ -1197,7 +1206,7 @@ class list template void priv_insert_dispatch(iterator p, InputIter first, InputIter last, - false_) + detail::false_) { for ( ; first != last; ++first){ this->insert(p, *first); @@ -1205,7 +1214,7 @@ class list } template - void priv_insert_dispatch(iterator p, Integer n, Integer x, true_) + void priv_insert_dispatch(iterator p, Integer n, Integer x, detail::true_) { this->priv_fill_insert(p, n, x); } void priv_fill_assign(size_type n, const T& val) @@ -1221,12 +1230,12 @@ class list } template - void priv_assign_dispatch(Integer n, Integer val, true_) + void priv_assign_dispatch(Integer n, Integer val, detail::true_) { this->priv_fill_assign((size_type) n, (T) val); } template void priv_assign_dispatch(InputIter first2, InputIter last2, - false_) + detail::false_) { iterator first1 = this->begin(); iterator last1 = this->end(); diff --git a/include/boost/interprocess/containers/map.hpp b/include/boost/interprocess/containers/map.hpp index a300ceb..3de2bae 100644 --- a/include/boost/interprocess/containers/map.hpp +++ b/include/boost/interprocess/containers/map.hpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -90,7 +91,7 @@ class map private: typedef detail::rbtree, - select1st< std::pair >, + detail::select1st< std::pair >, Pred, Alloc> tree_t; tree_t m_tree; // red-black tree representing map @@ -730,7 +731,7 @@ class multimap private: typedef detail::rbtree, - select1st< std::pair >, + detail::select1st< std::pair >, Pred, Alloc> tree_t; tree_t m_tree; // red-black tree representing map diff --git a/include/boost/interprocess/containers/set.hpp b/include/boost/interprocess/containers/set.hpp index f49d601..899b7a9 100644 --- a/include/boost/interprocess/containers/set.hpp +++ b/include/boost/interprocess/containers/set.hpp @@ -86,7 +86,7 @@ class set /// @cond private: typedef detail::rbtree, Pred, Alloc> tree_t; + detail::identity, Pred, Alloc> tree_t; tree_t m_tree; // red-black tree representing set /// @endcond @@ -566,7 +566,7 @@ class multiset /// @cond private: typedef detail::rbtree, Pred, Alloc> tree_t; + detail::identity, Pred, Alloc> tree_t; tree_t m_tree; // red-black tree representing multiset /// @endcond diff --git a/include/boost/interprocess/containers/slist.hpp b/include/boost/interprocess/containers/slist.hpp index 75157aa..528ba45 100644 --- a/include/boost/interprocess/containers/slist.hpp +++ b/include/boost/interprocess/containers/slist.hpp @@ -51,9 +51,6 @@ #include #include -#include -#include -#include #include #include #include @@ -83,6 +80,9 @@ struct slist_node , boost::intrusive::safe_link , VoidPointer> IslistData; + slist_node() + : m_data() + {} #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE template slist_node(const Convertible &value) @@ -159,6 +159,9 @@ struct slist_alloc { new(detail::get_pointer(ptr)) Node(forward(value)); } #endif + static void construct(const NodePtr &ptr) + { new(detail::get_pointer(ptr)) Node(); } + static void destroy(const NodePtr &ptr) { detail::get_pointer(ptr)->~Node(); } @@ -184,6 +187,15 @@ struct slist_alloc } #endif + NodePtr create_node() + { + NodePtr p = NodeAlloc::allocate(1); + Deallocator node_deallocator(p, *this); + self_t::construct(p); + node_deallocator.release(); + return (p); + } + void destroy_node(NodePtr node) { self_t::destroy(node); @@ -321,7 +333,7 @@ class slist public: //! Const iterator used to iterate through a list. class const_iterator - : public boost::iterator { @@ -545,8 +557,8 @@ class slist template void assign(InpIt first, InpIt last) { - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; this->assign_dispatch(first, last, Result()); } @@ -687,7 +699,7 @@ class slist //! //! Complexity: Amortized constant time. void pop_front() - { this->m_islist.pop_front_and_destroy(Destroyer(*this)); } + { this->m_islist.pop_front_and_dispose(Destroyer(*this)); } //! Returns: The iterator to the element before i in the sequence. //! Returns the end-iterator, if either i is the begin-iterator or the @@ -836,7 +848,7 @@ class slist //! Note: Does not invalidate iterators or references to non erased elements. iterator erase_after(iterator prev_pos) { - return iterator(this->m_islist.erase_after_and_destroy(prev_pos.get(), Destroyer(*this))); + return iterator(this->m_islist.erase_after_and_dispose(prev_pos.get(), Destroyer(*this))); } //! Effects: Erases the range (before_first, last) from @@ -852,7 +864,7 @@ class slist //! Note: Does not invalidate iterators or references to non erased elements. iterator erase_after(iterator before_first, iterator last) { - return iterator(this->m_islist.erase_after_and_destroy(before_first.get(), last.get(), Destroyer(*this))); + return iterator(this->m_islist.erase_after_and_dispose(before_first.get(), last.get(), Destroyer(*this))); } //! Requires: p must be a valid iterator of *this. @@ -916,14 +928,8 @@ class slist } else{ size_type n = newsize - len; - iterator c(cur); - while(n--){ - T default_constructed; - if(boost::is_scalar::value){ - //Value initialization hack. Fix me! - new(&default_constructed)T(); - } - c = this->insert_after(c, move(default_constructed)); + for (size_type i = 0; i < n; ++i){ + cur = this->m_islist.insert_after(cur, *this->create_node()); } } } @@ -934,11 +940,7 @@ class slist //! //! Complexity: Linear to the number of elements in the list. void clear() - { this->m_islist.clear_and_destroy(Destroyer(*this)); } - - // Removes all of the elements from the slist x to *this, inserting - // them immediately after p. x must not be *this. Complexity: - // linear in x.size(). + { this->m_islist.clear_and_dispose(Destroyer(*this)); } //! Requires: p must point to an element contained //! by the list. x != *this @@ -1155,7 +1157,7 @@ class slist void remove_if(Pred pred) { typedef ValueCompareToNodeCompare Predicate; - this->m_islist.remove_and_destroy_if(Predicate(pred), Destroyer(*this)); + this->m_islist.remove_and_dispose_if(Predicate(pred), Destroyer(*this)); } //! Effects: Removes adjacent duplicate elements or adjacent @@ -1183,7 +1185,7 @@ class slist void unique(Pred pred) { typedef ValueCompareToNodeCompare Predicate; - this->m_islist.unique_and_destroy(Predicate(pred), Destroyer(*this)); + this->m_islist.unique_and_dispose(Predicate(pred), Destroyer(*this)); } //! Requires: The lists x and *this must be distinct. @@ -1282,12 +1284,12 @@ class slist } template - void assign_dispatch(Int n, Int val, true_) + void assign_dispatch(Int n, Int val, detail::true_) { this->fill_assign((size_type) n, (T)val); } template void assign_dispatch(InpIt first, InpIt last, - false_) + detail::false_) { iterator end_n(end()); iterator prev(before_begin()); @@ -1316,17 +1318,17 @@ class slist template void insert_after_range(iterator prev_pos, InIter first, InIter last) { - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; this->insert_after_range(prev_pos, first, last, Result()); } template - void insert_after_range(iterator prev_pos, Int n, Int x, true_) + void insert_after_range(iterator prev_pos, Int n, Int x, detail::true_) { this->priv_insert_after_fill(prev_pos, n, x); } template - void insert_after_range(iterator prev_pos, InIter first, InIter last, false_) + void insert_after_range(iterator prev_pos, InIter first, InIter last, detail::false_) { typename Islist::iterator intrusive_it(prev_pos.get()); while (first != last){ diff --git a/include/boost/interprocess/containers/string.hpp b/include/boost/interprocess/containers/string.hpp index 0f6eafa..6852927 100644 --- a/include/boost/interprocess/containers/string.hpp +++ b/include/boost/interprocess/containers/string.hpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -54,8 +53,7 @@ #include #include #include -#include -#include +#include #include #include @@ -154,8 +152,9 @@ class basic_string_base }; //This basic type should have the same alignment as long_t - typedef typename type_with_alignment::value>::type - long_alignment_type; +// typedef typename type_with_alignment::value>::type +// long_alignment_type; + typedef void *long_alignment_type; //This type is the first part of the structure controlling a short string //The "data" member stores @@ -234,9 +233,9 @@ class basic_string_base protected: - typedef boost::integral_constant allocator_v1; - typedef boost::integral_constant allocator_v2; - typedef boost::integral_constant allocator_v1; + typedef detail::integral_constant allocator_v2; + typedef detail::integral_constant::value> alloc_version; std::pair @@ -495,9 +494,9 @@ class basic_string //! Const iterator used to iterate through a string. It's a Random Access Iterator typedef const_pointer const_iterator; //! Iterator used to iterate backwards through a string - typedef boost::reverse_iterator reverse_iterator; + typedef std::reverse_iterator reverse_iterator; //! Const iterator used to iterate backwards through a string - typedef boost::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; //! The largest possible value of type size_type. That is, size_type(-1). static const size_type npos; @@ -591,8 +590,8 @@ class basic_string : base_t(a) { //Dispatch depending on integer/iterator - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; this->priv_initialize_dispatch(f, l, Result()); } @@ -983,8 +982,8 @@ class basic_string basic_string& assign(InputIter first, InputIter last) { //Dispatch depending on integer/iterator - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; return this->priv_assign_dispatch(first, last, Result()); } @@ -1084,8 +1083,8 @@ class basic_string void insert(iterator p, InputIter first, InputIter last) { //Dispatch depending on integer/iterator - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; this->priv_insert_dispatch(p, first, last, Result()); } @@ -1227,8 +1226,8 @@ class basic_string InputIter f, InputIter l) { //Dispatch depending on integer/iterator - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; return this->priv_replace_dispatch(first, last, f, l, Result()); } @@ -1619,7 +1618,7 @@ class basic_string } template - void priv_initialize_dispatch(Integer n, Integer x, true_) + void priv_initialize_dispatch(Integer n, Integer x, detail::true_) { this->allocate_initial_block(max_value(n+1, InternalBufferChars)); priv_uninitialized_fill_n(this->priv_addr(), n, x); @@ -1628,7 +1627,7 @@ class basic_string } template - void priv_initialize_dispatch(InputIter f, InputIter l, false_) + void priv_initialize_dispatch(InputIter f, InputIter l, detail::false_) { this->priv_range_initialize(f, l); } template inline @@ -1678,12 +1677,12 @@ class basic_string } template - basic_string& priv_assign_dispatch(Integer n, Integer x, true_) + basic_string& priv_assign_dispatch(Integer n, Integer x, detail::true_) { return this->assign((size_type) n, (CharT) x); } template basic_string& priv_assign_dispatch(InputIter f, InputIter l, - false_) + detail::false_) { size_type cur = 0; CharT *ptr = detail::get_pointer(this->priv_addr()); @@ -1814,12 +1813,12 @@ class basic_string template void priv_insert_dispatch(iterator p, Integer n, Integer x, - true_) + detail::true_) { insert(p, (size_type) n, (CharT) x); } template void priv_insert_dispatch(iterator p, InputIter first, InputIter last, - false_) + detail::false_) { typedef typename std::iterator_traits::iterator_category Category; priv_insert(p, first, last, Category()); @@ -1838,13 +1837,13 @@ class basic_string template basic_string& priv_replace_dispatch(iterator first, iterator last, Integer n, Integer x, - true_) + detail::true_) { return this->replace(first, last, (size_type) n, (CharT) x); } template basic_string& priv_replace_dispatch(iterator first, iterator last, InputIter f, InputIter l, - false_) + detail::false_) { typedef typename std::iterator_traits::iterator_category Category; return this->priv_replace(first, last, f, l, Category()); diff --git a/include/boost/interprocess/containers/vector.hpp b/include/boost/interprocess/containers/vector.hpp index 2332bfe..80c4dc8 100644 --- a/include/boost/interprocess/containers/vector.hpp +++ b/include/boost/interprocess/containers/vector.hpp @@ -54,11 +54,7 @@ #include #include -#include -#include -#include #include -#include #include #include @@ -114,11 +110,10 @@ struct vector_alloc_holder ~vector_alloc_holder() { this->prot_deallocate(); } - typedef boost::integral_constant allocator_v1; - typedef boost::integral_constant allocator_v2; - typedef boost::integral_constant allocator_v1; + typedef detail::integral_constant allocator_v2; + typedef detail::integral_constant::value> alloc_version; - std::pair allocation_command(allocation_type command, size_type limit_size, @@ -236,7 +231,7 @@ class vector : private detail::vector_alloc_holder //! Const iterator used to iterate through a vector. class const_iterator - : public boost::iterator }; //! Iterator used to iterate backwards through a vector. - typedef boost::reverse_iterator + typedef std::reverse_iterator reverse_iterator; //! Const iterator used to iterate backwards through a vector. - typedef boost::reverse_iterator + typedef std::reverse_iterator const_reverse_iterator; public: @@ -775,8 +770,8 @@ class vector : private detail::vector_alloc_holder void assign(InIt first, InIt last) { //Dispatch depending on integer/iterator - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; this->priv_assign_dispatch(first, last, Result()); } @@ -933,8 +928,8 @@ class vector : private detail::vector_alloc_holder void insert(iterator pos, InIt first, InIt last) { //Dispatch depending on integer/iterator - const bool aux_boolean = boost::is_integral::value; - typedef bool_ Result; + const bool aux_boolean = detail::is_convertible::value; + typedef detail::bool_ Result; this->priv_insert_dispatch(pos, first, last, Result()); } @@ -1038,13 +1033,11 @@ class vector : private detail::vector_alloc_holder else{ size_type n = new_size - this->size(); this->reserve(new_size); + T *ptr = detail::get_pointer(this->m_start + this->m_size); while(n--){ - T default_constructed; - if(boost::is_scalar::value){ - //Value initialization - new(&default_constructed)T(); - } - this->push_back(move(default_constructed)); + //Default construct + new(ptr++)T(); + ++this->m_size; } } } @@ -1195,7 +1188,7 @@ class vector : private detail::vector_alloc_holder (pointer new_start, size_type new_capacity, pointer pos, FwdIt first, FwdIt last, size_type n) { - typedef detail::scoped_destructor_n ValueArrayDestructor; + typedef detail::scoped_destructor_n ValueArrayDestructor; typedef detail::move_iterator move_it; //Backup old data pointer old_start = this->m_start; @@ -1587,7 +1580,7 @@ class vector : private detail::vector_alloc_holder //Backwards expansion //If anything goes wrong, this object will destroy //all old objects - typedef detail::scoped_destructor_n ValueArrayDestructor; + typedef detail::scoped_destructor_n ValueArrayDestructor; pointer old_start = this->m_start; size_type old_size = this->m_size; ValueArrayDestructor old_values_destroyer(old_start, old_size); @@ -1634,12 +1627,11 @@ class vector : private detail::vector_alloc_holder } template - void priv_assign_dispatch(Integer n, Integer val, true_) + void priv_assign_dispatch(Integer n, Integer val, detail::true_) { this->assign((size_type) n, (T) val); } template - void priv_assign_dispatch(InIt first, InIt last, - false_) + void priv_assign_dispatch(InIt first, InIt last, detail::false_) { //Dispatch depending on integer/iterator typedef typename @@ -1648,13 +1640,12 @@ class vector : private detail::vector_alloc_holder } template - void priv_insert_dispatch( iterator pos, Integer n, - Integer val, true_) + void priv_insert_dispatch( iterator pos, Integer n, Integer val, detail::true_) { this->insert(pos, (size_type)n, (T)val); } template void priv_insert_dispatch(iterator pos, InIt first, - InIt last, false_) + InIt last, detail::false_) { //Dispatch depending on integer/iterator typedef typename @@ -1663,7 +1654,7 @@ class vector : private detail::vector_alloc_holder } template - void priv_initialize_aux(Integer n, Integer value, true_) + void priv_initialize_aux(Integer n, Integer value, detail::true_) { this->priv_range_initialize(cvalue_iterator(value, n), cvalue_iterator(), @@ -1672,7 +1663,7 @@ class vector : private detail::vector_alloc_holder template void priv_initialize_aux(InIt first, InIt last, - false_) + detail::false_) { //Dispatch depending on integer/iterator typedef typename diff --git a/include/boost/interprocess/detail/Attic/basic_segment_manager.hpp b/include/boost/interprocess/detail/Attic/basic_segment_manager.hpp index 0405699..1787318 100644 --- a/include/boost/interprocess/detail/Attic/basic_segment_manager.hpp +++ b/include/boost/interprocess/detail/Attic/basic_segment_manager.hpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -105,7 +105,7 @@ struct block_header { return get_rounded_size ( sizeof(Header) - , boost::alignment_of::value) + , detail::alignment_of::value) + total_size(); } @@ -159,7 +159,7 @@ struct block_header template static block_header *block_header_from_value(T *value) - { return block_header_from_value(value, sizeof(T), boost::alignment_of::value); } + { return block_header_from_value(value, sizeof(T), detail::alignment_of::value); } static block_header *block_header_from_value(const void *value, std::size_t sz, std::size_t algn) { @@ -178,7 +178,7 @@ struct block_header { block_header * hdr = reinterpret_cast(detail::char_ptr_cast(header) + - get_rounded_size(sizeof(Header), boost::alignment_of::value)); + get_rounded_size(sizeof(Header), detail::alignment_of::value)); //Some sanity checks return hdr; } @@ -188,7 +188,7 @@ struct block_header { Header * hdr = reinterpret_cast(detail::char_ptr_cast(bheader) - - get_rounded_size(sizeof(Header), boost::alignment_of::value)); + get_rounded_size(sizeof(Header), detail::alignment_of::value)); //Some sanity checks return hdr; } diff --git a/include/boost/interprocess/detail/Attic/creation_tags.hpp b/include/boost/interprocess/detail/Attic/creation_tags.hpp index b3e6382..bc6168c 100644 --- a/include/boost/interprocess/detail/Attic/creation_tags.hpp +++ b/include/boost/interprocess/detail/Attic/creation_tags.hpp @@ -26,6 +26,9 @@ static const detail::create_only_t create_only = detail::create_only_t(); static const detail::open_or_create_t open_or_create = detail::open_or_create_t(); static const detail::open_only_t open_only = detail::open_only_t(); +enum create_enum_t +{ DoCreate, DoOpen, DoCreateOrOpen }; + }} //namespace boost { namespace interprocess { #include diff --git a/include/boost/interprocess/detail/Attic/generic_cast.hpp b/include/boost/interprocess/detail/Attic/generic_cast.hpp deleted file mode 100644 index 5781ffa..0000000 --- a/include/boost/interprocess/detail/Attic/generic_cast.hpp +++ /dev/null @@ -1,54 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2007. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/interprocess for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTERPROCESS_GENERIC_CAST_HPP -#define BOOST_INTERPROCESS_GENERIC_CAST_HPP - -#if (defined _MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif - -#include -#include - -namespace boost{ -namespace interprocess{ - -template -class cast_to; - -template -class cast_to -{ - public: - template - static T* using_static_cast(S *s) - { return static_cast(s); } - - template - static T* using_dynamic_cast(S *s) - { return dynamic_cast(s); } - - template - static T* using_const_cast(S *s) - { return const_cast(s); } - - template - static T* using_reinterpret_cast(S *s) - { return reinterpret_cast(s); } -}; - -} //namespace interprocess{ -} //namespace boost{ - -#include - -#endif //#ifndef BOOST_INTERPROCESS_GENERIC_CAST_HPP - diff --git a/include/boost/interprocess/detail/basic_segment_manager.hpp b/include/boost/interprocess/detail/basic_segment_manager.hpp index 0405699..1787318 100644 --- a/include/boost/interprocess/detail/basic_segment_manager.hpp +++ b/include/boost/interprocess/detail/basic_segment_manager.hpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -105,7 +105,7 @@ struct block_header { return get_rounded_size ( sizeof(Header) - , boost::alignment_of::value) + , detail::alignment_of::value) + total_size(); } @@ -159,7 +159,7 @@ struct block_header template static block_header *block_header_from_value(T *value) - { return block_header_from_value(value, sizeof(T), boost::alignment_of::value); } + { return block_header_from_value(value, sizeof(T), detail::alignment_of::value); } static block_header *block_header_from_value(const void *value, std::size_t sz, std::size_t algn) { @@ -178,7 +178,7 @@ struct block_header { block_header * hdr = reinterpret_cast(detail::char_ptr_cast(header) + - get_rounded_size(sizeof(Header), boost::alignment_of::value)); + get_rounded_size(sizeof(Header), detail::alignment_of::value)); //Some sanity checks return hdr; } @@ -188,7 +188,7 @@ struct block_header { Header * hdr = reinterpret_cast(detail::char_ptr_cast(bheader) - - get_rounded_size(sizeof(Header), boost::alignment_of::value)); + get_rounded_size(sizeof(Header), detail::alignment_of::value)); //Some sanity checks return hdr; } diff --git a/include/boost/interprocess/detail/config_begin.hpp b/include/boost/interprocess/detail/config_begin.hpp index 313d37d..e479c27 100644 --- a/include/boost/interprocess/detail/config_begin.hpp +++ b/include/boost/interprocess/detail/config_begin.hpp @@ -1,11 +1,13 @@ -#ifndef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_DEPRECATE +#ifndef BOOST_INTERPROCESS_CONFIG_INCLUDED +#define BOOST_INTERPROCESS_CONFIG_INCLUDED +#include #endif -#include -#include - -#ifdef _MSC_VER +#ifdef BOOST_MSVC + #ifdef _CRT_SECURE_NO_DEPRECATE + #define BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE + #define _CRT_SECURE_NO_DEPRECATE + #endif #pragma warning (push) // //'function' : resolved overload was found by argument-dependent lookup @@ -30,5 +32,6 @@ #pragma warning (disable : 4521) ////Disable "multiple copy constructors specified" #pragma warning (disable : 4522) #pragma warning (disable : 4146) + #pragma warning (disable : 4503) //Decorated name length exceeded #pragma warning (disable : 4267) //conversion from 'X' to 'Y', possible loss of data #endif diff --git a/include/boost/interprocess/detail/config_end.hpp b/include/boost/interprocess/detail/config_end.hpp index 14eceb1..5c6ad50 100644 --- a/include/boost/interprocess/detail/config_end.hpp +++ b/include/boost/interprocess/detail/config_end.hpp @@ -1,3 +1,8 @@ -#if defined _MSC_VER +#if defined BOOST_MSVC #pragma warning (pop) + #ifdef BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE + #undef BOOST_INTERPROCESS_CRT_SECURE_NO_DEPRECATE + #undef _CRT_SECURE_NO_DEPRECATE + #endif #endif + diff --git a/include/boost/interprocess/detail/creation_tags.hpp b/include/boost/interprocess/detail/creation_tags.hpp index b3e6382..bc6168c 100644 --- a/include/boost/interprocess/detail/creation_tags.hpp +++ b/include/boost/interprocess/detail/creation_tags.hpp @@ -26,6 +26,9 @@ static const detail::create_only_t create_only = detail::create_only_t(); static const detail::open_or_create_t open_or_create = detail::open_or_create_t(); static const detail::open_only_t open_only = detail::open_only_t(); +enum create_enum_t +{ DoCreate, DoOpen, DoCreateOrOpen }; + }} //namespace boost { namespace interprocess { #include diff --git a/include/boost/interprocess/detail/file_wrapper.hpp b/include/boost/interprocess/detail/file_wrapper.hpp index 15d6a4d..a352738 100644 --- a/include/boost/interprocess/detail/file_wrapper.hpp +++ b/include/boost/interprocess/detail/file_wrapper.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include diff --git a/include/boost/interprocess/detail/in_place_interface.hpp b/include/boost/interprocess/detail/in_place_interface.hpp index fc0ee2e..b4829a6 100644 --- a/include/boost/interprocess/detail/in_place_interface.hpp +++ b/include/boost/interprocess/detail/in_place_interface.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include //typeid /*!\file @@ -49,7 +49,7 @@ template struct placement_destroy : public in_place_interface { placement_destroy() - : in_place_interface(boost::alignment_of::value, sizeof(T), typeid(T).name()) + : in_place_interface(detail::alignment_of::value, sizeof(T), typeid(T).name()) {} virtual void destroy(void *mem) diff --git a/include/boost/interprocess/detail/iterators.hpp b/include/boost/interprocess/detail/iterators.hpp index 998d844..491b430 100644 --- a/include/boost/interprocess/detail/iterators.hpp +++ b/include/boost/interprocess/detail/iterators.hpp @@ -22,30 +22,18 @@ #include #include -#include + +#include namespace boost { namespace interprocess { template class constant_iterator - : public boost::iterator_facade - < constant_iterator - , T - , boost::random_access_traversal_tag - , const T & - , Difference> + : public std::iterator + { - typedef boost::iterator_facade - < constant_iterator - , T - , boost::random_access_traversal_tag - , const T & - , Difference> super_t; - typedef constant_iterator this_type; - //Give access to private core functions - friend class boost::iterator_core_access; public: explicit constant_iterator(const T &ref, Difference range_size) @@ -55,8 +43,65 @@ class constant_iterator constant_iterator() : m_ptr(0), m_num(0){} + constant_iterator& operator++() + { increment(); return *this; } + + constant_iterator operator++(int) + { + constant_iterator result (*this); + increment(); + return result; + } + + friend bool operator== (const constant_iterator& i, const constant_iterator& i2) + { return i.equal(i2); } + + friend bool operator!= (const constant_iterator& i, const constant_iterator& i2) + { return !(i == i2); } + + friend bool operator< (const constant_iterator& i, const constant_iterator& i2) + { return i.less(i2); } + + friend bool operator> (const constant_iterator& i, const constant_iterator& i2) + { return i2 < i; } + + friend bool operator<= (const constant_iterator& i, const constant_iterator& i2) + { return !(i > i2); } + + friend bool operator>= (const constant_iterator& i, const constant_iterator& i2) + { return !(i < i2); } + + friend Difference operator- (const constant_iterator& i, const constant_iterator& i2) + { return i2.distance_to(i); } + + //Arithmetic + constant_iterator& operator+=(Difference off) + { this->advance(off); return *this; } + + constant_iterator operator+(Difference off) const + { + constant_iterator other(*this); + other.advance(off); + return other; + } + + friend constant_iterator operator+(Difference off, const constant_iterator& right) + { return right + off; } + + constant_iterator& operator-=(Difference off) + { this->advance(-off); return *this; } + + constant_iterator operator-(Difference off) const + { return *this + (-off); } + + const T& operator*() const + { return dereference(); } + + const T* operator->() const + { return &(dereference()); } + private: - const T * m_ptr; + const T * m_ptr; Difference m_num; void increment() @@ -68,6 +113,9 @@ class constant_iterator bool equal(const this_type &other) const { return m_num == other.m_num; } + bool less(const this_type &other) const + { return other.m_num < m_num; } + const T & dereference() const { return *m_ptr; } @@ -80,24 +128,10 @@ class constant_iterator template class repeat_iterator - : public boost::iterator_facade - < repeat_iterator - , T - , boost::random_access_traversal_tag - , T & - , Difference> + : public std::iterator + { - typedef boost::iterator_facade - < repeat_iterator - , T - , boost::random_access_traversal_tag - , T & - , Difference> super_t; - - typedef repeat_iterator this_type; - //Give access to private core functions - friend class boost::iterator_core_access; - + typedef repeat_iterator this_type; public: explicit repeat_iterator(T &ref, Difference range_size) : m_ptr(&ref), m_num(range_size){} @@ -106,6 +140,63 @@ class repeat_iterator repeat_iterator() : m_ptr(0), m_num(0){} + repeat_iterator& operator++() + { increment(); return *this; } + + repeat_iterator operator++(int) + { + repeat_iterator result (*this); + increment(); + return result; + } + + friend bool operator== (const repeat_iterator& i, const repeat_iterator& i2) + { return i.equal(i2); } + + friend bool operator!= (const repeat_iterator& i, const repeat_iterator& i2) + { return !(i == i2); } + + friend bool operator< (const repeat_iterator& i, const repeat_iterator& i2) + { return i.less(i2); } + + friend bool operator> (const repeat_iterator& i, const repeat_iterator& i2) + { return i2 < i; } + + friend bool operator<= (const repeat_iterator& i, const repeat_iterator& i2) + { return !(i > i2); } + + friend bool operator>= (const repeat_iterator& i, const repeat_iterator& i2) + { return !(i < i2); } + + friend Difference operator- (const repeat_iterator& i, const repeat_iterator& i2) + { return i2.distance_to(i); } + + //Arithmetic + repeat_iterator& operator+=(Difference off) + { this->advance(off); return *this; } + + repeat_iterator operator+(Difference off) const + { + repeat_iterator other(*this); + other.advance(off); + return other; + } + + friend repeat_iterator operator+(Difference off, const repeat_iterator& right) + { return right + off; } + + repeat_iterator& operator-=(Difference off) + { this->advance(-off); return *this; } + + repeat_iterator operator-(Difference off) const + { return *this + (-off); } + + T& operator*() const + { return dereference(); } + + T *operator->() const + { return &(dereference()); } + private: T * m_ptr; Difference m_num; @@ -119,6 +210,9 @@ class repeat_iterator bool equal(const this_type &other) const { return m_num == other.m_num; } + bool less(const this_type &other) const + { return other.m_num < m_num; } + T & dereference() const { return *m_ptr; } @@ -129,6 +223,125 @@ class repeat_iterator { return m_num - other.m_num; } }; +template +struct operator_arrow_proxy +{ + operator_arrow_proxy(const PseudoReference &px) + : m_value(px) + {} + + PseudoReference* operator->() const { return &m_value; } + // This function is needed for MWCW and BCC, which won't call operator-> + // again automatically per 13.3.1.2 para 8 +// operator T*() const { return &m_value; } + mutable PseudoReference m_value; +}; + + +template +class transform_iterator + : public UnaryFunction + , public std::iterator + < typename Iterator::iterator_category + , typename Iterator::value_type + , typename Iterator::difference_type + , typename Iterator::pointer + , typename UnaryFunction::result_type> +{ + public: + explicit transform_iterator(const Iterator &it, const UnaryFunction &f) + : UnaryFunction(f), m_it(it) + {} + + //Constructors + transform_iterator& operator++() + { increment(); return *this; } + + transform_iterator operator++(int) + { + transform_iterator result (*this); + increment(); + return result; + } + + friend bool operator== (const transform_iterator& i, const transform_iterator& i2) + { return i.equal(i2); } + + friend bool operator!= (const transform_iterator& i, const transform_iterator& i2) + { return !(i == i2); } + +/* + friend bool operator> (const transform_iterator& i, const transform_iterator& i2) + { return i2 < i; } + + friend bool operator<= (const transform_iterator& i, const transform_iterator& i2) + { return !(i > i2); } + + friend bool operator>= (const transform_iterator& i, const transform_iterator& i2) + { return !(i < i2); } +*/ + friend typename Iterator::difference_type operator- (const transform_iterator& i, const transform_iterator& i2) + { return i2.distance_to(i); } + + //Arithmetic + transform_iterator& operator+=(typename Iterator::difference_type off) + { this->advance(off); return *this; } + + transform_iterator operator+(typename Iterator::difference_type off) const + { + transform_iterator other(*this); + other.advance(off); + return other; + } + + friend transform_iterator operator+(typename Iterator::difference_type off, const transform_iterator& right) + { return right + off; } + + transform_iterator& operator-=(typename Iterator::difference_type off) + { this->advance(-off); return *this; } + + transform_iterator operator-(typename Iterator::difference_type off) const + { return *this + (-off); } + + typename UnaryFunction::result_type operator*() const + { return dereference(); } + + operator_arrow_proxy + operator->() const + { return operator_arrow_proxy(dereference()); } + + private: + Iterator m_it; + + void increment() + { ++m_it; } + + void decrement() + { --m_it; } + + bool equal(const transform_iterator &other) const + { return m_it == other.m_it; } + + bool less(const transform_iterator &other) const + { return other.m_it < m_it; } + + typename UnaryFunction::result_type dereference() const + { return UnaryFunction::operator()(*m_it); } + + void advance(typename Iterator::difference_type n) + { std::advance(m_it, n); } + + typename Iterator::difference_type distance_to(const transform_iterator &other)const + { return std::distance(other.m_it, m_it); } +}; + +template +transform_iterator +make_transform_iterator(Iterator it, UnaryFunc fun) +{ + return transform_iterator(it, fun); +} + } //namespace interprocess { } //namespace boost { diff --git a/include/boost/interprocess/detail/managed_memory_impl.hpp b/include/boost/interprocess/detail/managed_memory_impl.hpp index 912ac1f..9e977b8 100644 --- a/include/boost/interprocess/detail/managed_memory_impl.hpp +++ b/include/boost/interprocess/detail/managed_memory_impl.hpp @@ -23,13 +23,13 @@ #include #include #include +#include #include #include #include #include #include // -#include #include // #include @@ -624,7 +624,6 @@ template class create_open_func { public: - create_open_func(BasicManagedMemoryImpl * const frontend, create_enum_t type) : m_frontend(frontend), m_type(type){} diff --git a/include/boost/interprocess/detail/managed_open_or_create_impl.hpp b/include/boost/interprocess/detail/managed_open_or_create_impl.hpp index 328cffe..5902e1e 100644 --- a/include/boost/interprocess/detail/managed_open_or_create_impl.hpp +++ b/include/boost/interprocess/detail/managed_open_or_create_impl.hpp @@ -13,10 +13,10 @@ #include #include +#include #include #include -#include -#include +#include #include #include #include @@ -49,7 +49,7 @@ class managed_open_or_create_impl ManagedOpenOrCreateUserOffset = detail::ct_rounded_size < sizeof(boost::uint32_t) - , boost::alignment_of::value>::value + , detail::alignment_of::value>::value }; managed_open_or_create_impl(detail::create_only_t, @@ -200,11 +200,11 @@ class managed_open_or_create_impl //These are templatized to allow explicit instantiations template - static void write_whole_device(DeviceAbstraction &, std::size_t, false_) + static void write_whole_device(DeviceAbstraction &, std::size_t, detail::false_) {} //Empty template - static void write_whole_device(DeviceAbstraction &dev, std::size_t size, true_) + static void write_whole_device(DeviceAbstraction &dev, std::size_t size, detail::true_) { file_handle_t hnd = detail::file_handle_from_mapping_handle(dev.get_mapping_handle()); @@ -234,23 +234,23 @@ class managed_open_or_create_impl //These are templatized to allow explicit instantiations template - static void truncate_device(DeviceAbstraction &, std::size_t, false_) + static void truncate_device(DeviceAbstraction &, std::size_t, detail::false_) {} //Empty template - static void truncate_device(DeviceAbstraction &dev, std::size_t size, true_) + static void truncate_device(DeviceAbstraction &dev, std::size_t size, detail::true_) { dev.truncate(size); } //These are templatized to allow explicit instantiations template - static void create_device(DeviceAbstraction &dev, const char *name, std::size_t size, false_) + static void create_device(DeviceAbstraction &dev, const char *name, std::size_t size, detail::false_) { DeviceAbstraction tmp(create_only, name, read_write, size); tmp.swap(dev); } template - static void create_device(DeviceAbstraction &dev, const char *name, std::size_t, true_) + static void create_device(DeviceAbstraction &dev, const char *name, std::size_t, detail::true_) { DeviceAbstraction tmp(create_only, name, read_write); tmp.swap(dev); @@ -262,7 +262,7 @@ class managed_open_or_create_impl mode_t mode, const void *addr, ConstructFunc construct_func) { - typedef bool_ file_like_t; + typedef detail::bool_ file_like_t; (void)mode; error_info err; bool created = false; diff --git a/include/boost/interprocess/detail/move.hpp b/include/boost/interprocess/detail/move.hpp index 4268821..db0bfa0 100644 --- a/include/boost/interprocess/detail/move.hpp +++ b/include/boost/interprocess/detail/move.hpp @@ -37,6 +37,7 @@ struct is_movable #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE #include +#include namespace boost { namespace interprocess { @@ -116,13 +117,11 @@ typename detail::move_type::type move #else //#ifdef BOOST_INTERPROCESS_RVALUE_REFERENCE -#include - namespace boost { namespace interprocess { template -inline typename boost::remove_reference::type&& +inline typename detail::remove_reference::type&& move(T&& t) { return t; } diff --git a/include/boost/interprocess/detail/move_iterator.hpp b/include/boost/interprocess/detail/move_iterator.hpp index ce5ae71..83af256 100644 --- a/include/boost/interprocess/detail/move_iterator.hpp +++ b/include/boost/interprocess/detail/move_iterator.hpp @@ -13,7 +13,6 @@ #include #include -#include namespace boost{ namespace interprocess{ @@ -23,7 +22,7 @@ template class move_iterator { public: - typedef typename boost::remove_reference::type iterator_type; + typedef It iterator_type; typedef typename std::iterator_traits::value_type value_type; #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE typedef typename move_type::type reference; diff --git a/include/boost/interprocess/detail/mpl.hpp b/include/boost/interprocess/detail/mpl.hpp index 6f05e6c..8ab2600 100644 --- a/include/boost/interprocess/detail/mpl.hpp +++ b/include/boost/interprocess/detail/mpl.hpp @@ -17,13 +17,21 @@ # pragma once #endif -#include +//#include namespace boost { namespace interprocess { +namespace detail { + +template +struct integral_constant +{ + static const T value = val; + typedef integral_constant type; +}; template< bool C_ > -struct bool_ +struct bool_ : integral_constant { static const bool value = C_; }; @@ -31,6 +39,38 @@ struct bool_ typedef bool_ true_; typedef bool_ false_; +typedef true_ true_type; +typedef false_ false_type; + +typedef char yes_type; +struct no_type +{ + char padding[8]; +}; + +template +struct enable_if_c { + typedef T type; +}; + +template +struct enable_if_c {}; + +template +struct enable_if : public enable_if_c {}; + +template +class is_convertible +{ + typedef char true_t; + class false_t { char dummy[2]; }; + static true_t dispatch(U); + static false_t dispatch(...); + static T trigger(); + public: + enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) }; +}; + template< bool C , typename T1 @@ -63,7 +103,7 @@ struct if_ template struct select1st - : public std::unary_function +// : public std::unary_function { const typename Pair::first_type& operator()(const Pair& x) const { return x.first; } @@ -75,12 +115,13 @@ struct select1st // identity is an extension: it is not part of the standard. template struct identity - : public std::unary_function +// : public std::unary_function { const T& operator()(const T& x) const { return x; } }; +} //namespace detail { } //namespace interprocess { } //namespace boost { diff --git a/include/boost/interprocess/detail/named_proxy.hpp b/include/boost/interprocess/detail/named_proxy.hpp index 0797a49..be7aeea 100644 --- a/include/boost/interprocess/detail/named_proxy.hpp +++ b/include/boost/interprocess/detail/named_proxy.hpp @@ -70,14 +70,14 @@ struct Ctor0Arg : public placement_destroy // { // typedef Ctor2Arg self_t; // -// void do_increment(false_) +// void do_increment(detail::false_) // { ++m_p1; ++m_p2; } // -// void do_increment(true_){} +// void do_increment(detail::true_){} // // self_t& operator++() // { -// typedef bool_ Result; +// typedef detail::bool_ Result; // this->do_increment(Result()); // return *this; // } @@ -97,7 +97,7 @@ struct Ctor0Arg : public placement_destroy // T* memory = static_cast(mem); // for(constructed = 0; constructed < num; ++constructed){ // new(memory++)T(m_p1, m_p2); -// typedef bool_ Result; +// typedef detail::bool_ Result; // this->do_increment(Result()); // } // } @@ -140,14 +140,14 @@ struct Ctor0Arg : public placement_destroy typedef BOOST_PP_CAT(BOOST_PP_CAT(Ctor, n), Arg) self_t; \ typedef T target_t; \ \ - void do_increment(false_) \ + void do_increment(detail::false_) \ { BOOST_PP_ENUM(n, BOOST_INTERPROCESS_AUX_PARAM_INC, _); } \ \ - void do_increment(true_){} \ + void do_increment(detail::true_){} \ \ self_t& operator++() \ { \ - typedef bool_ Result; \ + typedef detail::bool_ Result; \ this->do_increment(Result()); \ return *this; \ } \ @@ -168,7 +168,7 @@ struct Ctor0Arg : public placement_destroy T* memory = static_cast(mem); \ for(constructed = 0; constructed < num; ++constructed){ \ new(memory++)T(BOOST_PP_ENUM_PARAMS(n, m_p)); \ - typedef bool_ Result; \ + typedef detail::bool_ Result; \ this->do_increment(Result()); \ } \ } \ diff --git a/include/boost/interprocess/detail/os_file_functions.hpp b/include/boost/interprocess/detail/os_file_functions.hpp index 09c3d6c..1beda3d 100644 --- a/include/boost/interprocess/detail/os_file_functions.hpp +++ b/include/boost/interprocess/detail/os_file_functions.hpp @@ -13,8 +13,7 @@ #include #include -#include -#include +//#include #if (defined BOOST_WINDOWS) && !(defined BOOST_DISABLE_WIN32) # include @@ -126,7 +125,7 @@ inline bool get_file_pointer(file_handle_t hnd, offset_t &off) inline bool write_file(file_handle_t hnd, const void *data, std::size_t numdata) { unsigned long written; - return 0 != WriteFile(hnd, data, (unsigned long)numdata, &written, 0); + return 0 != winapi::write_file(hnd, data, (unsigned long)numdata, &written, 0); } inline file_handle_t invalid_file() @@ -160,34 +159,7 @@ inline bool try_acquire_file_lock(file_handle_t hnd, bool &acquired) return (acquired = true); } -inline bool timed_acquire_file_lock - (file_handle_t hnd, bool &acquired, const boost::posix_time::ptime &abs_time) -{ - //Obtain current count and target time - boost::posix_time::ptime now = - boost::posix_time::microsec_clock::universal_time(); - using namespace boost::detail; - if(now >= abs_time) return false; - - do{ - if(!try_acquire_file_lock(hnd, acquired)) - return false; - - if(acquired) - return true; - else{ - now = boost::posix_time::microsec_clock::universal_time(); - - if(now >= abs_time){ - acquired = false; - return true; - } - // relinquish current time slice - winapi::sched_yield(); - } - }while (true); -} inline bool release_file_lock(file_handle_t hnd) { @@ -218,34 +190,7 @@ inline bool try_acquire_file_lock_sharable(file_handle_t hnd, bool &acquired) return (acquired = true); } -inline bool timed_acquire_file_lock_sharable - (file_handle_t hnd, bool &acquired, const boost::posix_time::ptime &abs_time) -{ - //Obtain current count and target time - boost::posix_time::ptime now = - boost::posix_time::microsec_clock::universal_time(); - using namespace boost::detail; - if(now >= abs_time) return false; - - do{ - if(!try_acquire_file_lock_sharable(hnd, acquired)) - return false; - - if(acquired) - return true; - else{ - now = boost::posix_time::microsec_clock::universal_time(); - - if(now >= abs_time){ - acquired = false; - return true; - } - // relinquish current time slice - winapi::sched_yield(); - } - }while (true); -} inline bool release_file_lock_sharable(file_handle_t hnd) { return release_file_lock(hnd); } @@ -373,35 +318,6 @@ inline bool try_acquire_file_lock(file_handle_t hnd, bool &acquired) return (acquired = true); } -inline bool timed_acquire_file_lock - (file_handle_t hnd, bool &acquired, const boost::posix_time::ptime &abs_time) -{ - //Obtain current count and target time - boost::posix_time::ptime now = - boost::posix_time::microsec_clock::universal_time(); - using namespace boost::detail; - - if(now >= abs_time) return false; - - do{ - if(!try_acquire_file_lock(hnd, acquired)) - return false; - - if(acquired) - return true; - else{ - now = boost::posix_time::microsec_clock::universal_time(); - - if(now >= abs_time){ - acquired = false; - return true; - } - // relinquish current time slice - sleep(0); - } - }while (true); -} - inline bool release_file_lock(file_handle_t hnd) { struct ::flock lock; @@ -437,34 +353,7 @@ inline bool try_acquire_file_lock_sharable(file_handle_t hnd, bool &acquired) return (acquired = true); } -inline bool timed_acquire_file_lock_sharable - (file_handle_t hnd, bool &acquired, const boost::posix_time::ptime &abs_time) -{ - //Obtain current count and target time - boost::posix_time::ptime now = - boost::posix_time::microsec_clock::universal_time(); - using namespace boost::detail; - if(now >= abs_time) return false; - - do{ - if(!try_acquire_file_lock_sharable(hnd, acquired)) - return false; - - if(acquired) - return true; - else{ - now = boost::posix_time::microsec_clock::universal_time(); - - if(now >= abs_time){ - acquired = false; - return true; - } - // relinquish current time slice - ::sleep(0); - } - }while (true); -} inline bool release_file_lock_sharable(file_handle_t hnd) { return release_file_lock(hnd); } diff --git a/include/boost/interprocess/detail/pointer_type.hpp b/include/boost/interprocess/detail/pointer_type.hpp index 68fc434..52a2274 100644 --- a/include/boost/interprocess/detail/pointer_type.hpp +++ b/include/boost/interprocess/detail/pointer_type.hpp @@ -20,6 +20,7 @@ #include #include +#include namespace boost { namespace interprocess { @@ -60,7 +61,7 @@ template struct pointer_type { typedef typename pointer_type_imp::pointer_type::type>::type type; + typename detail::remove_reference::type>::type type; }; } //namespace detail { diff --git a/include/boost/interprocess/detail/posix_time_types_wrk.hpp b/include/boost/interprocess/detail/posix_time_types_wrk.hpp index 4776cd7..ad077c3 100644 --- a/include/boost/interprocess/detail/posix_time_types_wrk.hpp +++ b/include/boost/interprocess/detail/posix_time_types_wrk.hpp @@ -20,8 +20,18 @@ #endif //#ifndef WIN32_LEAN_AND_MEAN #endif //#ifdef _WIN32 +//#include +//#include #include +namespace boost { +namespace interprocess { + +typedef boost::date_time::microsec_clock microsec_clock; + +} +} + #ifdef _WIN32 #ifdef BOOST_INTERPROCESS_WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN diff --git a/include/boost/interprocess/detail/type_traits.hpp b/include/boost/interprocess/detail/type_traits.hpp new file mode 100644 index 0000000..684be75 --- /dev/null +++ b/include/boost/interprocess/detail/type_traits.hpp @@ -0,0 +1,168 @@ +////////////////////////////////////////////////////////////////////////////// +// (C) Copyright John Maddock 2000. +// (C) Copyright Ion Gaztanaga 2005-2007. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/interprocess for documentation. +// +// The alignment_of implementation comes from John Maddock's boost::alignment_of code +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTERPROCESS_DETAIL_TYPE_TRAITS_HPP +#define BOOST_INTERPROCESS_DETAIL_TYPE_TRAITS_HPP + +#if (defined _MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include + +namespace boost { +namespace interprocess { +namespace detail { + +//boost::alignment_of yields to 10K lines of preprocessed code, so we +//need an alternative +template struct alignment_of; + +template +struct alignment_of_hack +{ + char c; + T t; + alignment_of_hack(); +}; + +template +struct alignment_logic +{ + enum{ value = A < S ? A : S }; +}; + +template< typename T > +struct alignment_of +{ + enum{ value = alignment_logic + < sizeof(alignment_of_hack) - sizeof(T) + , sizeof(T)>::value }; +}; + +//This is not standard, but should work with all compilers +union max_align +{ + char char_; + short short_; + int int_; + long long_; + #ifdef BOOST_HAS_LONG_LONG + long long long_long_; + #endif + float float_; + double double_; + long double long_double_; + void * void_ptr_; +}; + +template +struct remove_reference +{ + typedef T type; +}; + +template +struct remove_reference +{ + typedef T type; +}; + +template +struct is_reference +{ + enum { value = false }; +}; + +template +struct is_reference +{ + enum { value = true }; +}; + +template +struct is_pointer +{ + enum { value = false }; +}; + +template +struct is_pointer +{ + enum { value = true }; +}; + +template +struct add_reference +{ + typedef T& type; +}; + +template +struct add_reference +{ + typedef T& type; +}; + +template<> +struct add_reference +{ + typedef int& type; +}; + +template<> +struct add_reference +{ + typedef int& type; +}; +template +struct is_same +{ + typedef char yes_type; + struct no_type + { + char padding[8]; + }; + + template + static yes_type is_same_tester(V*, V*); + static no_type is_same_tester(...); + + static T t; + static U u; + + static const bool value = sizeof(yes_type) == sizeof(is_same_tester(&t,&u)); +}; +/* +template< typename T > +struct is_pointer_impl +{ + static const bool value = + (::boost::type_traits::ice_and< + ::boost::detail::is_pointer_helper::type>::value + , ::boost::type_traits::ice_not< + ::boost::is_member_pointer::value + >::value + >::value) + ); +};*/ + +} // namespace detail +} //namespace interprocess { +} //namespace boost { + +#endif //#ifndef BOOST_INTERPROCESS_DETAIL_TYPE_TRAITS_HPP + +#include + diff --git a/include/boost/interprocess/detail/utilities.hpp b/include/boost/interprocess/detail/utilities.hpp index 6c84dbc..f6be4fd 100644 --- a/include/boost/interprocess/detail/utilities.hpp +++ b/include/boost/interprocess/detail/utilities.hpp @@ -25,9 +25,8 @@ #include #include #include -//#include #include -#include +#include namespace boost { namespace interprocess { @@ -143,10 +142,11 @@ struct scoped_array_deallocator //!A deleter for scoped_ptr that destroys //!an object using a STL allocator. -template +template struct scoped_destructor_n { - typedef Pointer pointer; + typedef typename Allocator::pointer pointer; + typedef typename Allocator::value_type value_type; pointer m_p; std::size_t m_n; @@ -160,7 +160,6 @@ struct scoped_destructor_n ~scoped_destructor_n() { if(!m_p) return; - typedef typename std::iterator_traits::value_type value_type; value_type *raw_ptr = detail::get_pointer(m_p); for(std::size_t i = 0; i < m_n; ++i, ++raw_ptr) raw_ptr->~value_type(); @@ -558,8 +557,12 @@ struct has_trivial_destructor_after_move : public boost::has_trivial_destructor {}; -enum create_enum_t -{ DoCreate, DoOpen, DoCreateOrOpen }; +template T* +addressof(T& v) +{ + return reinterpret_cast( + &const_cast(reinterpret_cast(v))); +} } //namespace interprocess { } //namespace boost { diff --git a/include/boost/interprocess/detail/version_type.hpp b/include/boost/interprocess/detail/version_type.hpp index 1e72143..7b71268 100644 --- a/include/boost/interprocess/detail/version_type.hpp +++ b/include/boost/interprocess/detail/version_type.hpp @@ -15,35 +15,10 @@ #ifndef BOOST_INTERPROCESS_DETAIL_VERSION_TYPE_HPP #define BOOST_INTERPROCESS_DETAIL_VERSION_TYPE_HPP -/* -#include -namespace boost{ -namespace interprocess{ -namespace detail{ +#include +#include -template -struct version_type - : public boost::integral_constant -{ - typedef T type; - - version_type(const version_type&); -}; - -template -struct version - : public boost::integral_constant -{}; - -} //namespace detail{ -} //namespace interprocess{ -} //namespace boost{ -*/ - - -#include -#include namespace boost{ namespace interprocess{ @@ -53,7 +28,7 @@ namespace detail{ template struct version_type - : public boost::integral_constant + : public detail::integral_constant { typedef T type; @@ -63,7 +38,7 @@ struct version_type namespace impl{ template , typename T::version>::value> + bool = detail::is_convertible, typename T::version>::value> struct extract_version { static const unsigned value = 1; @@ -103,7 +78,7 @@ struct version template struct version - : public boost::integral_constant::value> + : public detail::integral_constant::value> { }; @@ -111,28 +86,4 @@ struct version } //namespace interprocess{ } //namespace boost{ - -/* -#include -#include - -struct A -{ - typedef boost::interprocess::detail::version_type version; -}; - -struct B -{ - struct version {static unsigned const value = 3;}; -}; - -int main() -{ - boost::interprocess::detail:: - std::cout << boost::interprocess::detail::version::value << '\n'; - std::cout << boost::interprocess::detail::version::value << '\n'; - std::cout << boost::interprocess::detail::version::value << '\n'; -} -*/ - #endif //#define BOOST_INTERPROCESS_DETAIL_VERSION_TYPE_HPP diff --git a/include/boost/interprocess/detail/win32_api.hpp b/include/boost/interprocess/detail/win32_api.hpp index ee85b88..aeb1060 100644 --- a/include/boost/interprocess/detail/win32_api.hpp +++ b/include/boost/interprocess/detail/win32_api.hpp @@ -190,6 +190,7 @@ extern "C" __declspec(dllimport) int __stdcall DuplicateHandle , unsigned long dwDesiredAccess, int bInheritHandle , unsigned long dwOptions); extern "C" __declspec(dllimport) void __stdcall GetSystemTimeAsFileTime(interprocess_filetime*); +extern "C" __declspec(dllimport) int __stdcall FileTimeToLocalFileTime(const interprocess_filetime *in, const interprocess_filetime *out); extern "C" __declspec(dllimport) void * __stdcall CreateMutexA(interprocess_security_attributes*, int, const char *); extern "C" __declspec(dllimport) void * __stdcall OpenMutexA(unsigned long, int, const char *); extern "C" __declspec(dllimport) unsigned long __stdcall WaitForSingleObject(void *, unsigned long); @@ -221,6 +222,8 @@ extern "C" __declspec(dllimport) int __stdcall LockFile (void *hnd, unsigned lo extern "C" __declspec(dllimport) int __stdcall UnlockFile(void *hnd, unsigned long offset_low, unsigned long offset_high, unsigned long size_low, unsigned long size_high); extern "C" __declspec(dllimport) int __stdcall LockFileEx(void *hnd, unsigned long flags, unsigned long reserved, unsigned long size_low, unsigned long size_high, interprocess_overlapped* overlapped); extern "C" __declspec(dllimport) int __stdcall UnlockFileEx(void *hnd, unsigned long reserved, unsigned long size_low, unsigned long size_high, interprocess_overlapped* overlapped); +extern "C" __declspec(dllimport) int __stdcall WriteFile(void *hnd, const void *buffer, unsigned long bytes_to_write, unsigned long *bytes_written, interprocess_overlapped* overlapped); + /* extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * ); extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * ); @@ -281,6 +284,10 @@ static inline unsigned long get_last_error() static inline void get_system_time_as_file_time(interprocess_filetime *filetime) { GetSystemTimeAsFileTime(filetime); } +static inline bool file_time_to_local_file_time + (const interprocess_filetime *in, const interprocess_filetime *out) +{ return 0 != FileTimeToLocalFileTime(in, out); } + static inline void *create_mutex(const char *name) { return CreateMutexA(0, 0, name); } @@ -347,6 +354,9 @@ static inline bool lock_file_ex(void *hnd, unsigned long flags, unsigned long re static inline bool unlock_file_ex(void *hnd, unsigned long reserved, unsigned long size_low, unsigned long size_high, interprocess_overlapped *overlapped) { return 0 != UnlockFileEx(hnd, reserved, size_low, size_high, overlapped); } +static inline bool write_file(void *hnd, const void *buffer, unsigned long bytes_to_write, unsigned long *bytes_written, interprocess_overlapped* overlapped) +{ return 0 != WriteFile(hnd, buffer, bytes_to_write, bytes_written, overlapped); } + static inline long interlocked_increment(long volatile *addr) { return BOOST_INTERLOCKED_INCREMENT(addr); } diff --git a/include/boost/interprocess/detail/workaround.hpp b/include/boost/interprocess/detail/workaround.hpp index b50d5f9..4fe883a 100644 --- a/include/boost/interprocess/detail/workaround.hpp +++ b/include/boost/interprocess/detail/workaround.hpp @@ -13,11 +13,6 @@ #include -#include -#include -#include -#include - #if !(defined BOOST_WINDOWS) || (defined BOOST_DISABLE_WIN32) #if defined(_POSIX_THREAD_PROCESS_SHARED) && (_POSIX_THREAD_PROCESS_SHARED - 0 > 0) #if !defined(__CYGWIN__) @@ -70,26 +65,26 @@ #if defined(BOOST_INTERPROCESS_RVALUE_REFERENCE) || defined(BOOST_INTERPROCESS_VARIADIC_TEMPLATES) #define BOOST_INTERPROCESS_PERFECT_FORWARDING #endif - +/* namespace boost { namespace interprocess { namespace workaround{ -//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*// +////////////////////////////////////////////////// // // // We want generally const_shm_ptr to inherit// // from iterator class but for void this // // doesn't work, so we must inherit from // // other class. // // // -//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*// +////////////////////////////////////////////////// //Empty class struct empty_type{}; template struct random_it -: public boost::iterator { typedef const T* const_pointer; @@ -143,7 +138,7 @@ template<> struct random_it } //namespace workaround } //namespace interprocess { } //namespace boost { - +*/ #include #endif //#ifndef BOOST_INTERPROCESS_PTR_WRKRND_HPP diff --git a/include/boost/interprocess/interprocess_fwd.hpp b/include/boost/interprocess/interprocess_fwd.hpp index e450560..396094f 100644 --- a/include/boost/interprocess/interprocess_fwd.hpp +++ b/include/boost/interprocess/interprocess_fwd.hpp @@ -15,8 +15,9 @@ # pragma once #endif -#include -#include +//#include +//#include + #include ////////////////////////////////////////////////////////////////////////////// @@ -460,7 +461,7 @@ string; }} //namespace boost { namespace interprocess { -#include +//#include #endif //#ifndef BOOST_INTERPROCESS_FWD_HPP diff --git a/include/boost/interprocess/ipc/message_queue.hpp b/include/boost/interprocess/ipc/message_queue.hpp index 3229ada..b13a0f2 100644 --- a/include/boost/interprocess/ipc/message_queue.hpp +++ b/include/boost/interprocess/ipc/message_queue.hpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include //std::lower_bound #include //std::size_t @@ -273,8 +273,8 @@ class mq_hdr_t (std::size_t max_msg_size, std::size_t max_num_msg) { const std::size_t - msg_hdr_align = boost::alignment_of::value, - index_align = boost::alignment_of::value, + msg_hdr_align = detail::alignment_of::value, + index_align = detail::alignment_of::value, r_hdr_size = detail::ct_rounded_size::value, r_index_size = detail::get_rounded_size(sizeof(msg_hdr_ptr_t)*max_num_msg, msg_hdr_align), r_max_msg_size = detail::get_rounded_size(max_msg_size, msg_hdr_align) + sizeof(detail::msg_hdr_t); @@ -287,8 +287,8 @@ class mq_hdr_t void initialize_memory() { const std::size_t - msg_hdr_align = boost::alignment_of::value, - index_align = boost::alignment_of::value, + msg_hdr_align = detail::alignment_of::value, + index_align = detail::alignment_of::value, r_hdr_size = detail::ct_rounded_size::value, r_index_size = detail::get_rounded_size(sizeof(msg_hdr_ptr_t)*m_max_num_msg, msg_hdr_align), r_max_msg_size = detail::get_rounded_size(m_max_msg_size, msg_hdr_align) + sizeof(detail::msg_hdr_t); diff --git a/include/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp b/include/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp index f43d340..b4e139a 100644 --- a/include/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp +++ b/include/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp @@ -25,8 +25,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -214,7 +213,7 @@ class simple_seq_fit_impl /*!Makes a new memory portion available for allocation*/ void priv_add_segment(void *addr, std::size_t size); - enum { Alignment = boost::alignment_of::value }; + enum { Alignment = detail::alignment_of::value }; enum { BlockCtrlBytes = detail::ct_rounded_size::value }; enum { BlockCtrlSize = BlockCtrlBytes/Alignment }; enum { MinBlockSize = BlockCtrlSize + Alignment }; diff --git a/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp b/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp index e71c4df..6d7c068 100644 --- a/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp +++ b/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp @@ -26,8 +26,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -268,7 +267,7 @@ class rbtree_best_fit //!Makes a new memory portion available for allocation void priv_add_segment(void *addr, std::size_t size); - enum { Alignment = boost::alignment_of::value }; + enum { Alignment = detail::alignment_of::value }; enum { AlignmentMask = (Alignment - 1) }; enum { BlockCtrlBytes = detail::ct_rounded_size::value }; enum { BlockCtrlUnits = BlockCtrlBytes/Alignment }; diff --git a/include/boost/interprocess/offset_ptr.hpp b/include/boost/interprocess/offset_ptr.hpp index d007104..cbef3ef 100644 --- a/include/boost/interprocess/offset_ptr.hpp +++ b/include/boost/interprocess/offset_ptr.hpp @@ -21,8 +21,9 @@ #include #include #include -#include +#include #include +#include /*!\file Describes a smart pointer that stores the offset between this pointer and @@ -49,10 +50,10 @@ template class offset_ptr { /// @cond - typedef boost::interprocess::workaround::random_it random_it_t; - typedef offset_ptr self_t; - typedef typename random_it_t::const_pointer const_pointer_t; - typedef typename random_it_t::const_reference const_reference_t; + typedef offset_ptr self_t; + typedef const PointedType * const_pointer_t; + typedef typename detail::add_reference + ::type const_reference_t; void unspecified_bool_type_func() const {} typedef void (self_t::*unspecified_bool_type)() const; @@ -88,11 +89,12 @@ class offset_ptr /// @endcond public: - typedef typename random_it_t::pointer pointer; - typedef typename random_it_t::reference reference; - typedef typename random_it_t::value_type value_type; - typedef typename random_it_t::difference_type difference_type; - typedef typename random_it_t::iterator_category iterator_category; + typedef PointedType * pointer; + typedef typename detail:: + add_reference::type reference; + typedef PointedType value_type; + typedef std::ptrdiff_t difference_type; + typedef std::random_access_iterator_tag iterator_category; public: //Public Functions @@ -283,7 +285,8 @@ inline void swap (boost::interprocess::offset_ptr &pt, pt2 = ptr; } -/*!Simulation of static_cast between pointers. Never throws.*/ +/* +//!Simulation of static_cast between pointers. Never throws. template inline boost::interprocess::offset_ptr static_pointer_cast(boost::interprocess::offset_ptr const & r) @@ -292,7 +295,7 @@ inline boost::interprocess::offset_ptr (r, boost::interprocess::detail::static_cast_tag()); } -/*!Simulation of const_cast between pointers. Never throws.*/ +//!Simulation of const_cast between pointers. Never throws. template inline boost::interprocess::offset_ptr const_pointer_cast(boost::interprocess::offset_ptr const & r) @@ -301,7 +304,7 @@ inline boost::interprocess::offset_ptr (r, boost::interprocess::detail::const_cast_tag()); } -/*!Simulation of dynamic_cast between pointers. Never throws.*/ +//!Simulation of dynamic_cast between pointers. Never throws. template inline boost::interprocess::offset_ptr dynamic_pointer_cast(boost::interprocess::offset_ptr const & r) @@ -310,7 +313,7 @@ inline boost::interprocess::offset_ptr (r, boost::interprocess::detail::dynamic_cast_tag()); } -/*!Simulation of reinterpret_cast between pointers. Never throws.*/ +//!Simulation of reinterpret_cast between pointers. Never throws. template inline boost::interprocess::offset_ptr reinterpret_pointer_cast(boost::interprocess::offset_ptr const & r) @@ -318,21 +321,23 @@ inline boost::interprocess::offset_ptr return boost::interprocess::offset_ptr (r, boost::interprocess::detail::reinterpret_cast_tag()); } - +*/ } //namespace interprocess { /// @cond //!has_trivial_constructor<> == true_type specialization for optimizations template struct has_trivial_constructor< boost::interprocess::offset_ptr > - : public true_type -{}; +{ + enum { value = true }; +}; ///has_trivial_destructor<> == true_type specialization for optimizations template struct has_trivial_destructor< boost::interprocess::offset_ptr > - : public true_type -{}; +{ + enum { value = true }; +}; //#if !defined(_MSC_VER) || (_MSC_VER >= 1400) namespace interprocess { @@ -350,32 +355,8 @@ inline T * get_pointer(boost::interprocess::offset_ptr const & p) } //namespace boost { /// @cond + namespace boost{ -namespace interprocess{ - -/*!Simulation of cast operators between pointers.*/ -template -class cast_to< offset_ptr > -{ - public: - template - static offset_ptr using_static_cast(const offset_ptr &s) - { return offset_ptr(s, detail::static_cast_tag()); } - - template - static offset_ptr using_reinterpret_cast(const offset_ptr &s) - { return offset_ptr(s, detail::reinterpret_cast_tag()); } - - template - static offset_ptr using_const_cast(const offset_ptr &s) - { return offset_ptr(s, detail::const_cast_tag()); } - - template - static offset_ptr using_dynamic_cast(const offset_ptr &s) - { return offset_ptr(s, detail::dynamic_cast_tag()); } -}; - -} //namespace interprocess{ //This is to support embedding a bit in the pointer //for intrusive containers, saving space diff --git a/include/boost/interprocess/segment_manager.hpp b/include/boost/interprocess/segment_manager.hpp index 89a9a08..5eb5440 100644 --- a/include/boost/interprocess/segment_manager.hpp +++ b/include/boost/interprocess/segment_manager.hpp @@ -19,8 +19,9 @@ #include #include -#include -#include +#include + +#include #include #include @@ -37,14 +38,16 @@ #include #endif -/*!\file - Describes the object placed in a memory segment that provides - named object allocation capabilities for single-segment and - multi-segment allocations. -*/ +//!\file +//!Describes the object placed in a memory segment that provides +//!named object allocation capabilities for single-segment and +//!multi-segment allocations. namespace boost{ namespace interprocess{ + +/// @cond + namespace detail{ //Anti-exception node eraser @@ -115,7 +118,7 @@ struct intrusive_value_type_impl intrusive_value_type_impl(){} - enum { BlockHdrAlignment = boost::alignment_of::value }; + enum { BlockHdrAlignment = detail::alignment_of::value }; block_header *get_block_header() const { @@ -363,8 +366,8 @@ class segment_manager typedef detail::index_config index_config_named; typedef detail::index_config index_config_unique; typedef IndexType index_type; - typedef bool_::value > is_intrusive_t; - typedef bool_::value> is_node_index_t; + typedef detail::bool_::value > is_intrusive_t; + typedef detail::bool_::value> is_node_index_t; public: typedef IndexType named_index_t; @@ -381,19 +384,11 @@ class segment_manager typedef typename Base::mutex_family mutex_family; - - typedef boost::transform_iterator - const_named_iterator; - typedef boost::transform_iterator - const_unique_iterator; -/* - typedef typename - named_index_t::const_iterator const_named_iterator; - typedef typename - unique_index_t::const_iterator const_unique_iterator; -*/ + typedef transform_iterator + const_named_iterator; + typedef transform_iterator + const_unique_iterator; + //!Constructor proxy object definition helper class template struct construct_proxy @@ -669,31 +664,40 @@ class segment_manager void zero_free_memory() { Base::zero_free_memory(); } + //!Returns a constant iterator to the beginning of the information about + //the named allocations performed in this segment manager const_named_iterator named_begin() const { - return boost::make_transform_iterator + return make_transform_iterator (m_header.m_named_index.begin(), named_transform()); } + //!Returns a constant iterator to the end of the information about + //the named allocations performed in this segment manager const_named_iterator named_end() const { - return boost::make_transform_iterator + return make_transform_iterator (m_header.m_named_index.end(), named_transform()); } + //!Returns a constant iterator to the beginning of the information about + //the unique allocations performed in this segment manager const_unique_iterator unique_begin() const { - return boost::make_transform_iterator + return make_transform_iterator (m_header.m_unique_index.begin(), unique_transform()); } + //!Returns a constant iterator to the end of the information about + //the unique allocations performed in this segment manager const_unique_iterator unique_end() const { - return boost::make_transform_iterator + return make_transform_iterator (m_header.m_unique_index.end(), unique_transform()); } /// @cond + //!Generic named/anonymous new function. Offers all the possibilities, //!such as throwing, search before creating, and the constructor is //!encapsulated in an object function. @@ -778,7 +782,7 @@ class segment_manager IndexType > &index, detail::in_place_interface &table, std::size_t &length, - true_ is_intrusive) + detail::true_ is_intrusive) { (void)is_intrusive; typedef IndexType > index_type; @@ -817,7 +821,7 @@ class segment_manager IndexType > &index, detail::in_place_interface &table, std::size_t &length, - false_ is_intrusive) + detail::false_ is_intrusive) { (void)is_intrusive; typedef IndexType > index_type; @@ -854,7 +858,7 @@ class segment_manager (block_header_t *block_header, IndexType > &index, detail::in_place_interface &table, - true_ is_node_index) + detail::true_ is_node_index) { (void)is_node_index; typedef typename IndexType >::iterator index_it; @@ -868,7 +872,7 @@ class segment_manager (block_header_t *block_header, IndexType > &index, detail::in_place_interface &table, - false_ is_node_index) + detail::false_ is_node_index) { (void)is_node_index; CharT *name = static_cast(block_header->template name()); @@ -879,7 +883,7 @@ class segment_manager bool priv_generic_named_destroy(const CharT *name, IndexType > &index, detail::in_place_interface &table, - true_ is_intrusive_index) + detail::true_ is_intrusive_index) { (void)is_intrusive_index; typedef IndexType > index_type; @@ -930,7 +934,7 @@ class segment_manager bool priv_generic_named_destroy(const CharT *name, IndexType > &index, detail::in_place_interface &table, - false_ is_intrusive_index) + detail::false_ is_intrusive_index) { (void)is_intrusive_index; typedef IndexType > index_type; @@ -1010,7 +1014,7 @@ class segment_manager bool dothrow, detail::in_place_interface &table, IndexType > &index, - true_ is_intrusive) + detail::true_ is_intrusive) { (void)is_intrusive; std::size_t namelen = std::char_traits::length(name); @@ -1132,7 +1136,7 @@ class segment_manager bool dothrow, detail::in_place_interface &table, IndexType > &index, - false_ is_intrusive) + detail::false_ is_intrusive) { (void)is_intrusive; std::size_t namelen = std::char_traits::length(name); diff --git a/include/boost/interprocess/shared_memory_object.hpp b/include/boost/interprocess/shared_memory_object.hpp index 25a64ad..25dff13 100644 --- a/include/boost/interprocess/shared_memory_object.hpp +++ b/include/boost/interprocess/shared_memory_object.hpp @@ -15,8 +15,8 @@ #include #include #include -#include -#include +//#include +#include #include #include #include @@ -129,6 +129,7 @@ class shared_memory_object /// @cond private: + //!Closes a previously opened file mapping. Never throws. void priv_close(); diff --git a/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp b/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp index ee32558..4529aa9 100644 --- a/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp +++ b/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp @@ -23,7 +23,6 @@ #include #include -#include #include // for std::less #include // for std::basic_ostream @@ -269,36 +268,6 @@ inline T *get_pointer(boost::interprocess::intrusive_ptr p) } // namespace boost -/// @cond -namespace boost{ -namespace interprocess{ - -/*!Simulation of cast operators between pointers.*/ -template -class cast_to< intrusive_ptr > -{ - public: - template - static intrusive_ptr using_static_cast(const intrusive_ptr &s) - { return intrusive_ptr(s, detail::static_cast_tag()); } - - template - static intrusive_ptr using_reinterpret_cast(const intrusive_ptr &s) - { return intrusive_ptr(s, detail::reinterpret_cast_tag()); } - - template - static intrusive_ptr using_const_cast(const intrusive_ptr &s) - { return intrusive_ptr(s, detail::const_cast_tag()); } - - template - static intrusive_ptr using_dynamic_cast(const intrusive_ptr &s) - { return intrusive_ptr(s, detail::dynamic_cast_tag()); } -}; -/// @endcond - -} //namespace interprocess{ -} //namespace boost{ - #include #endif // #ifndef BOOST_INTERPROCESS_INTRUSIVE_PTR_HPP_INCLUDED diff --git a/include/boost/interprocess/smart_ptr/scoped_ptr.hpp b/include/boost/interprocess/smart_ptr/scoped_ptr.hpp index f80f215..c6495ae 100644 --- a/include/boost/interprocess/smart_ptr/scoped_ptr.hpp +++ b/include/boost/interprocess/smart_ptr/scoped_ptr.hpp @@ -40,7 +40,7 @@ class scoped_ptr scoped_ptr & operator=(scoped_ptr const &); typedef scoped_ptr this_type; - typedef typename workaround::random_it::reference reference; + typedef typename detail::add_reference::type reference; /// @endcond public: diff --git a/include/boost/interprocess/smart_ptr/shared_ptr.hpp b/include/boost/interprocess/smart_ptr/shared_ptr.hpp index 43cf623..cb7ab45 100644 --- a/include/boost/interprocess/smart_ptr/shared_ptr.hpp +++ b/include/boost/interprocess/smart_ptr/shared_ptr.hpp @@ -20,14 +20,13 @@ #include #include -#include #include #include #include #include +#include +#include #include -#include -#include #include // for std::swap #include // for std::less @@ -85,12 +84,14 @@ class shared_ptr typedef typename detail::pointer_to_other ::type pointer; - typedef typename workaround::random_it::reference reference; - typedef typename workaround::random_it::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; typedef typename detail::pointer_to_other - ::type const_deleter_pointer; + ::type const_deleter_pointer; typedef typename detail::pointer_to_other - ::type const_allocator_pointer; + ::type const_allocator_pointer; /*!Constructs an empty shared_ptr. Use_count() == 0 && get() == 0.*/ shared_ptr() @@ -103,12 +104,11 @@ class shared_ptr explicit shared_ptr(const pointer&p, const VA &a = VA(), const D &d = D()) : m_pn(p, a, d) { - typedef pointer Pointer; //Check that the pointer passed is of the same type that //the pointer the allocator defines or it's a raw pointer - typedef typename detail::pointer_to_other::type ParameterPointer; - BOOST_STATIC_ASSERT((boost::is_same::value)|| - (boost::is_pointer::value)); + typedef typename detail::pointer_to_other::type ParameterPointer; + BOOST_STATIC_ASSERT((detail::is_same::value) || + (detail::is_pointer::value)); //detail::sp_enable_shared_from_this( m_pn, p, p ); } @@ -128,23 +128,20 @@ class shared_ptr template shared_ptr(shared_ptr const & r, detail::static_cast_tag) - : m_pn(cast_to::type>:: - using_static_cast(r.m_pn.get_pointer()), - r.m_pn) + : m_pn( pointer(static_cast(detail::get_pointer(r.m_pn.get_pointer()))) + , r.m_pn) {} template shared_ptr(shared_ptr const & r, detail::const_cast_tag) - : m_pn(cast_to::type>:: - using_const_cast(r.m_pn.get_pointer()), - r.m_pn) + : m_pn( pointer(const_cast(detail::get_pointer(r.m_pn.get_pointer()))) + , r.m_pn) {} template shared_ptr(shared_ptr const & r, detail::dynamic_cast_tag) - : m_pn(cast_to::type>:: - using_dynamic_cast(r.m_pn.get_pointer()), - r.m_pn) + : m_pn( pointer(dynamic_cast(detail::get_pointer(r.m_pn.get_pointer()))) + , r.m_pn) { if(!m_pn.get_pointer()){ // need to allocate new counter -- the cast failed m_pn = detail::shared_count(); @@ -170,8 +167,8 @@ class shared_ptr //Check that the pointer passed is of the same type that //the pointer the allocator defines or it's a raw pointer typedef typename detail::pointer_to_other::type ParameterPointer; - BOOST_STATIC_ASSERT((boost::is_same::value)|| - (boost::is_pointer::value)); + BOOST_STATIC_ASSERT((detail::is_same::value) || + (detail::is_pointer::value)); this_type(p, a, d).swap(*this); } @@ -287,36 +284,6 @@ T * get_pointer(boost::interprocess::shared_ptr const & p) } // namespace boost -/// @cond -namespace boost{ -namespace interprocess{ - -/*!Simulation of cast operators between pointers.*/ -template -class cast_to< shared_ptr > -{ - public: - template - static shared_ptr using_static_cast(const shared_ptr &s) - { return shared_ptr(s, detail::static_cast_tag()); } - - template - static shared_ptr using_reinterpret_cast(const shared_ptr &s) - { return shared_ptr(s, detail::reinterpret_cast_tag()); } - - template - static shared_ptr using_const_cast(const shared_ptr &s) - { return shared_ptr(s, detail::const_cast_tag()); } - - template - static shared_ptr using_dynamic_cast(const shared_ptr &s) - { return shared_ptr(s, detail::dynamic_cast_tag()); } -}; -/// @endcond - -} //namespace interprocess{ -} //namespace boost{ - #include #endif // #ifndef BOOST_INTERPROCESS_SHARED_PTR_HPP_INCLUDED diff --git a/include/boost/interprocess/smart_ptr/unique_ptr.hpp b/include/boost/interprocess/smart_ptr/unique_ptr.hpp index 181b6a3..d7e841c 100644 --- a/include/boost/interprocess/smart_ptr/unique_ptr.hpp +++ b/include/boost/interprocess/smart_ptr/unique_ptr.hpp @@ -25,8 +25,9 @@ #include #include #include -#include -#include +#include +//#include +//#include #include namespace boost{ @@ -85,8 +86,8 @@ class unique_ptr { /// @cond struct nat {int for_bool_;}; - typedef typename boost::add_reference::type deleter_reference; - typedef typename boost::add_reference::type deleter_const_reference; + typedef typename detail::add_reference::type deleter_reference; + typedef typename detail::add_reference::type deleter_const_reference; /// @endcond public: @@ -104,9 +105,9 @@ class unique_ptr {} unique_ptr(pointer p - ,typename if_ + ,typename detail::if_ ,D - ,typename boost::add_reference::type>::type d) + ,typename detail::add_reference::type>::type d) : ptr_(p, d) {} /* @@ -127,11 +128,11 @@ class unique_ptr template unique_ptr(const unique_ptr& u, typename boost::enable_if_c< - boost::is_convertible::pointer, pointer>::value && - boost::is_convertible::value && + detail::is_convertible::pointer, pointer>::value && + detail::is_convertible::value && ( - !boost::is_reference::value || - boost::is_same::value + !detail::is_reference::value || + detail::is_same::value ) , nat @@ -142,12 +143,12 @@ class unique_ptr #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE template unique_ptr(const detail::moved_object >& u, - typename boost::enable_if_c< - boost::is_convertible::pointer, pointer>::value && - boost::is_convertible::value && + typename detail::enable_if_c< + detail::is_convertible::pointer, pointer>::value && + detail::is_convertible::value && ( - !boost::is_reference::value || - boost::is_same::value + !detail::is_reference::value || + detail::is_same::value ) , nat @@ -158,11 +159,11 @@ class unique_ptr template unique_ptr(unique_ptr && u, typename boost::enable_if_c< - boost::is_convertible::pointer, pointer>::value && - boost::is_convertible::value && + detail::is_convertible::pointer, pointer>::value && + detail::is_convertible::value && ( - !boost::is_reference::value || - boost::is_same::value + !detail::is_reference::value || + detail::is_same::value ) , nat @@ -200,7 +201,7 @@ class unique_ptr } // observers - typename boost::add_reference::type operator*() const + typename detail::add_reference::type operator*() const { return *ptr_.first(); } pointer operator->() const @@ -266,8 +267,8 @@ template class unique_ptr { struct nat {int for_bool_;}; - typedef typename boost::add_reference::type deleter_reference; - typedef typename boost::add_reference::type deleter_const_reference; + typedef typename detail::add_reference::type deleter_reference; + typedef typename detail::add_reference::type deleter_const_reference; public: typedef T element_type; typedef D deleter_type; @@ -279,7 +280,7 @@ public: unique_ptr(pointer p, typename if_< boost::is_reference, D, - typename boost::add_reference::type>::type d) + typename detail::add_reference::type>::type d) : ptr_(p, d) {} unique_ptr(const unique_ptr& u) : ptr_(const_cast(u).release(), u.get_deleter()) {} @@ -302,7 +303,7 @@ public: } // observers - typename boost::add_reference::type operator[](std::size_t i) const {return ptr_.first()[i];} + typename detail::add_reference::type operator[](std::size_t i) const {return ptr_.first()[i];} pointer get() const {return ptr_.first();} deleter_reference get_deleter() {return ptr_.second();} deleter_const_reference get_deleter() const {return ptr_.second();} @@ -344,8 +345,8 @@ template class unique_ptr { struct nat {int for_bool_;}; - typedef typename boost::add_reference::type deleter_reference; - typedef typename boost::add_reference::type deleter_const_reference; + typedef typename detail::add_reference::type deleter_reference; + typedef typename detail::add_reference::type deleter_const_reference; public: typedef T element_type; typedef D deleter_type; @@ -358,7 +359,7 @@ public: unique_ptr(pointer p, typename if_< boost::is_reference, D, - typename boost::add_reference::type>::type d) + typename detail::add_reference::type>::type d) : ptr_(p, d) {} unique_ptr(const unique_ptr& u) : ptr_(const_cast(u).release(), u.get_deleter()) {} @@ -381,7 +382,7 @@ public: } // observers - typename boost::add_reference::type operator[](std::size_t i) const {return ptr_.first()[i];} + typename detail::add_reference::type operator[](std::size_t i) const {return ptr_.first()[i];} pointer get() const {return ptr_.first();} deleter_reference get_deleter() {return ptr_.second();} deleter_const_reference get_deleter() const {return ptr_.second();} diff --git a/include/boost/interprocess/smart_ptr/weak_ptr.hpp b/include/boost/interprocess/smart_ptr/weak_ptr.hpp index 923e7c3..6a82ba2 100644 --- a/include/boost/interprocess/smart_ptr/weak_ptr.hpp +++ b/include/boost/interprocess/smart_ptr/weak_ptr.hpp @@ -32,8 +32,10 @@ class weak_ptr typedef weak_ptr this_type; typedef typename detail::pointer_to_other ::type pointer; - typedef typename workaround::random_it::reference reference; - typedef typename workaround::random_it::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; /// @endcond public: diff --git a/include/boost/interprocess/sync/emulation/interprocess_condition.hpp b/include/boost/interprocess/sync/emulation/interprocess_condition.hpp index 6b1081f..1be75db 100644 --- a/include/boost/interprocess/sync/emulation/interprocess_condition.hpp +++ b/include/boost/interprocess/sync/emulation/interprocess_condition.hpp @@ -80,8 +80,7 @@ inline bool interprocess_condition::do_timed_wait(bool tout_enabled, const boost::posix_time::ptime &abs_time, interprocess_mutex &mut) { - boost::posix_time::ptime now = - boost::posix_time::microsec_clock::universal_time(); + boost::posix_time::ptime now = microsec_clock::universal_time(); if(tout_enabled){ if(now >= abs_time) return false; @@ -115,7 +114,7 @@ inline bool interprocess_condition::do_timed_wait(bool tout_enabled, //Check for timeout if(tout_enabled){ - now = boost::posix_time::microsec_clock::universal_time(); + now = microsec_clock::universal_time(); if(now >= abs_time){ //If we can lock the interprocess_mutex it means that no notification diff --git a/include/boost/interprocess/sync/emulation/interprocess_mutex.hpp b/include/boost/interprocess/sync/emulation/interprocess_mutex.hpp index b459118..a7693d1 100644 --- a/include/boost/interprocess/sync/emulation/interprocess_mutex.hpp +++ b/include/boost/interprocess/sync/emulation/interprocess_mutex.hpp @@ -49,8 +49,7 @@ inline bool interprocess_mutex::try_lock(void) inline bool interprocess_mutex::timed_lock(const boost::posix_time::ptime &abs_time) { //Obtain current count and target time - boost::posix_time::ptime now = - boost::posix_time::microsec_clock::universal_time(); + boost::posix_time::ptime now = microsec_clock::universal_time(); if(now >= abs_time) return false; @@ -60,7 +59,7 @@ inline bool interprocess_mutex::timed_lock(const boost::posix_time::ptime &abs_t if (m_s == 1 && prev_s == 0){ break; } - now = boost::posix_time::microsec_clock::universal_time(); + now = microsec_clock::universal_time(); if(now >= abs_time){ return false; diff --git a/include/boost/interprocess/sync/file_lock.hpp b/include/boost/interprocess/sync/file_lock.hpp index f9848ff..68ca61a 100644 --- a/include/boost/interprocess/sync/file_lock.hpp +++ b/include/boost/interprocess/sync/file_lock.hpp @@ -20,6 +20,7 @@ #include #include #include +#include /*!\file Describes a class that wraps file locking capabilities. @@ -105,6 +106,118 @@ class file_lock /// @cond private: file_handle_t m_file_hnd; + + bool timed_acquire_file_lock + (file_handle_t hnd, bool &acquired, const boost::posix_time::ptime &abs_time) + { + //Obtain current count and target time + boost::posix_time::ptime now = microsec_clock::universal_time(); + using namespace boost::detail; + + if(now >= abs_time) return false; + + do{ + if(!try_acquire_file_lock(hnd, acquired)) + return false; + + if(acquired) + return true; + else{ + now = microsec_clock::universal_time(); + + if(now >= abs_time){ + acquired = false; + return true; + } + // relinquish current time slice + winapi::sched_yield(); + } + }while (true); + } + + bool timed_acquire_file_lock_sharable + (file_handle_t hnd, bool &acquired, const boost::posix_time::ptime &abs_time) + { + //Obtain current count and target time + boost::posix_time::ptime now = microsec_clock::universal_time(); + using namespace boost::detail; + + if(now >= abs_time) return false; + + do{ + if(!try_acquire_file_lock_sharable(hnd, acquired)) + return false; + + if(acquired) + return true; + else{ + now = microsec_clock::universal_time(); + + if(now >= abs_time){ + acquired = false; + return true; + } + // relinquish current time slice + winapi::sched_yield(); + } + }while (true); + } + + bool timed_acquire_file_lock + (file_handle_t hnd, bool &acquired, const boost::posix_time::ptime &abs_time) + { + //Obtain current count and target time + boost::posix_time::ptime now = microsec_clock::universal_time(); + using namespace boost::detail; + + if(now >= abs_time) return false; + + do{ + if(!try_acquire_file_lock(hnd, acquired)) + return false; + + if(acquired) + return true; + else{ + now = microsec_clock::universal_time(); + + if(now >= abs_time){ + acquired = false; + return true; + } + // relinquish current time slice + sleep(0); + } + }while (true); + } + + bool timed_acquire_file_lock_sharable + (file_handle_t hnd, bool &acquired, const boost::posix_time::ptime &abs_time) + { + //Obtain current count and target time + boost::posix_time::ptime now = microsec_clock::universal_time(); + using namespace boost::detail; + + if(now >= abs_time) return false; + + do{ + if(!try_acquire_file_lock_sharable(hnd, acquired)) + return false; + + if(acquired) + return true; + else{ + now = microsec_clock::universal_time(); + + if(now >= abs_time){ + acquired = false; + return true; + } + // relinquish current time slice + ::sleep(0); + } + }while (true); + } /// @endcond }; diff --git a/include/boost/interprocess/sync/scoped_lock.hpp b/include/boost/interprocess/sync/scoped_lock.hpp index 58062bd..c244bae 100644 --- a/include/boost/interprocess/sync/scoped_lock.hpp +++ b/include/boost/interprocess/sync/scoped_lock.hpp @@ -25,7 +25,6 @@ #include #include #include -#include #include /*!\file diff --git a/include/boost/interprocess/sync/sharable_lock.hpp b/include/boost/interprocess/sync/sharable_lock.hpp index d8f733d..0ec26a8 100644 --- a/include/boost/interprocess/sync/sharable_lock.hpp +++ b/include/boost/interprocess/sync/sharable_lock.hpp @@ -25,7 +25,7 @@ #include #include #include -#include +//Ig#include #include /*!\file diff --git a/include/boost/interprocess/sync/upgradable_lock.hpp b/include/boost/interprocess/sync/upgradable_lock.hpp index d37bbb6..a73e906 100644 --- a/include/boost/interprocess/sync/upgradable_lock.hpp +++ b/include/boost/interprocess/sync/upgradable_lock.hpp @@ -25,7 +25,6 @@ #include #include #include -#include #include /*!\file diff --git a/include/boost/interprocess/windows_shared_memory.hpp b/include/boost/interprocess/windows_shared_memory.hpp index 158eb52..4a781f0 100644 --- a/include/boost/interprocess/windows_shared_memory.hpp +++ b/include/boost/interprocess/windows_shared_memory.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include /*!\file @@ -126,6 +127,7 @@ class windows_shared_memory /// @cond private: + //!Closes a previously opened file mapping. Never throws. void priv_close(); diff --git a/proj/vc7ide/flat_tree_test.vcproj b/proj/vc7ide/flat_tree_test.vcproj index 1a4e520..ac3b715 100644 --- a/proj/vc7ide/flat_tree_test.vcproj +++ b/proj/vc7ide/flat_tree_test.vcproj @@ -1,134 +1,136 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + ProjectType="Visual C++" + Version="7.10" + Name="flat_tree_test" + ProjectGUID="{58CCE183-6092-48FE-A4F7-BA0D3A792637}" + Keyword="Win32Proj"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proj/vc7ide/interprocesslib.vcproj b/proj/vc7ide/interprocesslib.vcproj index ae82f76..58590c7 100644 --- a/proj/vc7ide/interprocesslib.vcproj +++ b/proj/vc7ide/interprocesslib.vcproj @@ -422,9 +422,6 @@ - - @@ -473,6 +470,9 @@ + + diff --git a/proj/vc7ide/shared_memory_mappable_test.vcproj b/proj/vc7ide/shared_memory_mappable_test.vcproj index c807807..c431027 100644 --- a/proj/vc7ide/shared_memory_mappable_test.vcproj +++ b/proj/vc7ide/shared_memory_mappable_test.vcproj @@ -1,135 +1,136 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + ProjectType="Visual C++" + Version="7.10" + Name="shared_memory_mapping_test" + ProjectGUID="{5CE18C83-6025-36FE-A4F7-BA09176D3A11}" + Keyword="Win32Proj"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 685e1a7..ab83520 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -31,4 +31,4 @@ rule test_all return $(all_rules) ; } -test-suite interprocess_test : [ test_all r ] ; +test-suite interprocess_test : [ test_all r ] : multi ; diff --git a/test/allocator_v1.hpp b/test/allocator_v1.hpp index 20523e8..4aa6374 100644 --- a/test/allocator_v1.hpp +++ b/test/allocator_v1.hpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -80,10 +79,10 @@ class allocator_v1 ::type pointer; typedef typename detail:: pointer_to_other::type const_pointer; - typedef typename workaround::random_it - ::reference reference; - typedef typename workaround::random_it - ::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -97,15 +96,15 @@ class allocator_v1 /*!Returns the segment manager. Never throws*/ segment_manager* get_segment_manager()const { return detail::get_pointer(mp_mngr); } - - /*!Returns address of mutable object. Never throws*/ +/* + //!Returns address of mutable object. Never throws pointer address(reference value) const - { return pointer(boost::addressof(value)); } + { return pointer(addressof(value)); } - /*!Returns address of non mutable object. Never throws*/ + //!Returns address of non mutable object. Never throws const_pointer address(const_reference value) const - { return const_pointer(boost::addressof(value)); } - + { return const_pointer(addressof(value)); } +*/ /*!Constructor from the segment manager. Never throws*/ allocator_v1(segment_manager *segment_mngr) : mp_mngr(segment_mngr) { } @@ -127,16 +126,16 @@ class allocator_v1 /*!Deallocates memory previously allocated. Never throws*/ void deallocate(const pointer &ptr, size_type) { mp_mngr->deallocate(detail::get_pointer(ptr)); } - - /*!Construct object, calling constructor. - Throws if T(const T&) throws*/ +/* + //!Construct object, calling constructor. + //!Throws if T(const T&) throws void construct(const pointer &ptr, const_reference value) { new(detail::get_pointer(ptr)) value_type(value); } - /*!Destroys object. Throws if object's destructor throws*/ + //!Destroys object. Throws if object's destructor throws void destroy(const pointer &ptr) { BOOST_ASSERT(ptr != 0); (*ptr).~value_type(); } - +*/ /*!Returns the number of elements that could be allocated. Never throws*/ size_type max_size() const { return mp_mngr->get_size(); } diff --git a/test/condition_test_template.hpp b/test/condition_test_template.hpp index bb34716..4237b4b 100644 --- a/test/condition_test_template.hpp +++ b/test/condition_test_template.hpp @@ -37,7 +37,7 @@ namespace test { boost::posix_time::ptime ptime_delay(int secs) { - return boost::posix_time::microsec_clock::universal_time() + + return microsec_clock::universal_time() + boost::posix_time::time_duration(0, 0, secs); } diff --git a/test/deque_test.cpp b/test/deque_test.cpp index 1418671..bd81b14 100644 --- a/test/deque_test.cpp +++ b/test/deque_test.cpp @@ -27,6 +27,7 @@ #include #include #include +#include //***************************************************************// // // @@ -44,14 +45,14 @@ template class boost::interprocess::deque -bool copyable_only(V1 *, V2 *, boost::false_type) +bool copyable_only(V1 *, V2 *, detail::false_type) { return true; } //Function to check if both sets are equal template -bool copyable_only(V1 *shmdeque, V2 *stddeque, boost::true_type) +bool copyable_only(V1 *shmdeque, V2 *stddeque, detail::true_type) { typedef typename V1::value_type IntType; std::size_t size = shmdeque->size(); @@ -174,8 +175,8 @@ bool do_test() } if(!copyable_only(shmdeque, stddeque - ,boost::integral_constant - ::value>())){ +// ,boost::integral_constant + ,detail::bool_::value>())){ return false; } diff --git a/test/dummy_test_allocator.hpp b/test/dummy_test_allocator.hpp index c056d2b..15c1b05 100644 --- a/test/dummy_test_allocator.hpp +++ b/test/dummy_test_allocator.hpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -59,10 +58,10 @@ class dummy_test_allocator typedef T value_type; typedef T * pointer; typedef const T * const_pointer; - typedef typename workaround::random_it - ::reference reference; - typedef typename workaround::random_it - ::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -84,26 +83,26 @@ class dummy_test_allocator template dummy_test_allocator(const dummy_test_allocator &other) {} - - pointer address(reference value) const - { return pointer(boost::addressof(value)); } +/* + pointer address(reference value) + { return pointer(addressof(value)); } const_pointer address(const_reference value) const - { return const_pointer(boost::addressof(value)); } - + { return const_pointer(addressof(value)); } +*/ pointer allocate(size_type, cvoid_ptr = 0) { return 0; } void deallocate(const pointer &, size_type) { } - +/* template void construct(pointer, const Convertible &) {} void destroy(pointer) {} - +*/ size_type max_size() const { return 0; } diff --git a/test/expand_bwd_test_allocator.hpp b/test/expand_bwd_test_allocator.hpp index 58b61ba..4ef8612 100644 --- a/test/expand_bwd_test_allocator.hpp +++ b/test/expand_bwd_test_allocator.hpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -61,10 +60,10 @@ class expand_bwd_test_allocator typedef T value_type; typedef T * pointer; typedef const T * const_pointer; - typedef typename workaround::random_it - ::reference reference; - typedef typename workaround::random_it - ::const_reference const_reference; + typedef typename detail::add_reference + ::type reference; + typedef typename detail::add_reference + ::type const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -89,26 +88,26 @@ class expand_bwd_test_allocator expand_bwd_test_allocator(const expand_bwd_test_allocator &other) : mp_buffer(other.mp_buffer), m_size(other.m_size) , m_offset(other.m_offset), m_allocations(0){ } - - pointer address(reference value) const - { return pointer(boost::addressof(value)); } +/* + pointer address(reference value) + { return pointer(addressof(value)); } const_pointer address(const_reference value) const - { return const_pointer(boost::addressof(value)); } - + { return const_pointer(addressof(value)); } +*/ pointer allocate(size_type , cvoid_ptr hint = 0) { (void)hint; return 0; } void deallocate(const pointer &, size_type) {} - +/* template void construct(pointer ptr, const Convertible &value) { new((void*)ptr) value_type(value); } void destroy(pointer ptr) { (*ptr).~value_type(); } - +*/ size_type max_size() const { return m_size; } diff --git a/test/file_mapping_test.cpp b/test/file_mapping_test.cpp index d82960b..5eb777a 100644 --- a/test/file_mapping_test.cpp +++ b/test/file_mapping_test.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include using namespace boost::interprocess; diff --git a/test/flat_tree_test.cpp b/test/flat_tree_test.cpp index 2bffd71..f0e8191 100644 --- a/test/flat_tree_test.cpp +++ b/test/flat_tree_test.cpp @@ -21,13 +21,13 @@ #include "set_test.hpp" #include "map_test.hpp" -/*****************************************************************/ -/* */ -/* This example repeats the same operations with std::set and */ -/* shmem_set using the node allocator */ -/* and compares the values of both containers */ -/* */ -/*****************************************************************/ +///////////////////////////////////////////////////////////////// +// +// This example repeats the same operations with std::set and +// shmem_set using the node allocator +// and compares the values of both containers +// +///////////////////////////////////////////////////////////////// using namespace boost::interprocess; @@ -145,15 +145,15 @@ int main() ,MyStdMultiMap>()){ return 1; } -/* - if (0 != map_test()){ - return 1; - } -*/ + +// if (0 != map_test()){ +// return 1; +// } + if (0 != map_test + +/* +//#include +//#include +//#include +*/ +/* +//#define WIN32_LEAN_AND_MEAN +//#define BOOST_USE_WINDOWS_H +#include +#include +//#include +*/ + diff --git a/test/message_queue_test.cpp b/test/message_queue_test.cpp index 6747d72..a10c012 100644 --- a/test/message_queue_test.cpp +++ b/test/message_queue_test.cpp @@ -25,11 +25,11 @@ #undef max #endif -/******************************************************************************/ -/* */ -/* This example tests the process shared message queue. */ -/* */ -/******************************************************************************/ +//////////////////////////////////////////////////////////////////////////////// +// // +// This example tests the process shared message queue. // +// // +//////////////////////////////////////////////////////////////////////////////// using namespace boost::interprocess; diff --git a/test/user_buffer_test.cpp b/test/user_buffer_test.cpp index 35f949f..ce4c45d 100644 --- a/test/user_buffer_test.cpp +++ b/test/user_buffer_test.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include "print_container.hpp" @@ -52,9 +52,9 @@ bool CheckEqual(MyUserList *userlist, MyStdList *stdlist, MyHeapList *heaplist) int main () { //Create the user memory who will store all objects - const int size_aligner = sizeof(boost::detail::max_align); + const int size_aligner = sizeof(detail::max_align); const int memsize = 65536/size_aligner*size_aligner; - static boost::detail::max_align static_buffer[memsize/size_aligner]; + static detail::max_align static_buffer[memsize/size_aligner]; //Named new capable user mem allocator wmanaged_external_buffer user_buffer(create_only, static_buffer, memsize); diff --git a/test/vector_test.cpp b/test/vector_test.cpp index 93d57bb..d9290c0 100644 --- a/test/vector_test.cpp +++ b/test/vector_test.cpp @@ -31,7 +31,6 @@ #include "expand_bwd_test_allocator.hpp" #include "expand_bwd_test_template.hpp" #include "dummy_test_allocator.hpp" -#include using namespace boost::interprocess; @@ -46,14 +45,14 @@ template class boost::interprocess::vector >; template -bool copyable_only(V1 *, V2 *, boost::false_type) +bool copyable_only(V1 *, V2 *, detail::false_type) { return true; } //Function to check if both sets are equal template -bool copyable_only(V1 *shmvector, V2 *stdvector, boost::true_type) +bool copyable_only(V1 *shmvector, V2 *stdvector, detail::true_type) { typedef typename V1::value_type IntType; std::size_t size = shmvector->size(); @@ -200,8 +199,7 @@ bool do_test() if(!test::CheckEqualContainers(shmvector, stdvector)) return false; if(!copyable_only(shmvector, stdvector - ,boost::integral_constant - ::value>())){ + ,detail::bool_::value>())){ return false; }