Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80689 - in branches/release: boost/container boost/container/detail boost/interprocess boost/interprocess/allocators boost/interprocess/allocators/detail boost/interprocess/containers boost/interprocess/detail boost/interprocess/indexes boost/interprocess/ipc boost/interprocess/mem_algo boost/interprocess/mem_algo/detail boost/interprocess/smart_ptr boost/interprocess/smart_ptr/detail boost/interprocess/streams boost/interprocess/sync boost/interprocess/sync/detail boost/interprocess/sync/posix boost/interprocess/sync/shm boost/interprocess/sync/spin boost/interprocess/sync/windows boost/interprocess/sync/xsi boost/intrusive boost/intrusive/detail boost/move libs/container libs/container/doc libs/container/proj libs/container/proj/vc7ide libs/container/test libs/interprocess libs/interprocess/doc libs/interprocess/example libs/interprocess/proj libs/interprocess/proj/vc7ide libs/interprocess/test libs/intrusive libs/move
From: igaztanaga_at_[hidden]
Date: 2012-09-24 08:18:40


Author: igaztanaga
Date: 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
New Revision: 80689
URL: http://svn.boost.org/trac/boost/changeset/80689

Log:
Merge from trunk
Added:
   branches/release/boost/interprocess/sync/detail/condition_any_algorithm.hpp
      - copied unchanged from r80549, /trunk/boost/interprocess/sync/detail/condition_any_algorithm.hpp
   branches/release/boost/interprocess/sync/detail/locks.hpp
      - copied unchanged from r80549, /trunk/boost/interprocess/sync/detail/locks.hpp
   branches/release/boost/interprocess/sync/interprocess_condition_any.hpp
      - copied unchanged from r80549, /trunk/boost/interprocess/sync/interprocess_condition_any.hpp
   branches/release/boost/interprocess/sync/interprocess_sharable_mutex.hpp
      - copied unchanged from r80549, /trunk/boost/interprocess/sync/interprocess_sharable_mutex.hpp
   branches/release/boost/interprocess/sync/named_condition_any.hpp
      - copied unchanged from r80549, /trunk/boost/interprocess/sync/named_condition_any.hpp
   branches/release/boost/interprocess/sync/named_sharable_mutex.hpp
      - copied unchanged from r80549, /trunk/boost/interprocess/sync/named_sharable_mutex.hpp
   branches/release/boost/interprocess/sync/shm/named_condition_any.hpp
      - copied unchanged from r80549, /trunk/boost/interprocess/sync/shm/named_condition_any.hpp
   branches/release/boost/interprocess/sync/windows/named_condition_any.hpp
      - copied unchanged from r80549, /trunk/boost/interprocess/sync/windows/named_condition_any.hpp
   branches/release/libs/container/test/input_from_forward_iterator.hpp
      - copied unchanged from r80549, /trunk/libs/container/test/input_from_forward_iterator.hpp
   branches/release/libs/interprocess/proj/vc7ide/condition_any_test.vcproj
      - copied unchanged from r80549, /trunk/libs/interprocess/proj/vc7ide/condition_any_test.vcproj
   branches/release/libs/interprocess/proj/vc7ide/named_condition_any_test.vcproj
      - copied unchanged from r80549, /trunk/libs/interprocess/proj/vc7ide/named_condition_any_test.vcproj
   branches/release/libs/interprocess/proj/vc7ide/named_sharable_mutex.vcproj
      - copied unchanged from r80549, /trunk/libs/interprocess/proj/vc7ide/named_sharable_mutex.vcproj
   branches/release/libs/interprocess/proj/vc7ide/sharable_mutex.vcproj
      - copied unchanged from r80549, /trunk/libs/interprocess/proj/vc7ide/sharable_mutex.vcproj
   branches/release/libs/interprocess/test/condition_any_test.cpp
      - copied unchanged from r80549, /trunk/libs/interprocess/test/condition_any_test.cpp
   branches/release/libs/interprocess/test/named_condition_any_test.cpp
      - copied unchanged from r80549, /trunk/libs/interprocess/test/named_condition_any_test.cpp
   branches/release/libs/interprocess/test/named_sharable_mutex_test.cpp
      - copied unchanged from r80549, /trunk/libs/interprocess/test/named_sharable_mutex_test.cpp
   branches/release/libs/interprocess/test/sharable_mutex_test.cpp
      - copied unchanged from r80549, /trunk/libs/interprocess/test/sharable_mutex_test.cpp
Removed:
   branches/release/boost/container/detail/stored_ref.hpp
Properties modified:
   branches/release/boost/container/ (props changed)
   branches/release/boost/interprocess/ (props changed)
   branches/release/boost/intrusive/ (props changed)
   branches/release/boost/move/ (props changed)
   branches/release/libs/container/ (props changed)
   branches/release/libs/interprocess/ (props changed)
   branches/release/libs/intrusive/ (props changed)
   branches/release/libs/move/ (props changed)
Text files modified:
   branches/release/boost/container/allocator_traits.hpp | 24
   branches/release/boost/container/deque.hpp | 1306 ++++++++++++++---------------
   branches/release/boost/container/detail/adaptive_node_pool_impl.hpp | 3
   branches/release/boost/container/detail/advanced_insert_int.hpp | 15
   branches/release/boost/container/detail/algorithms.hpp | 24
   branches/release/boost/container/detail/destroyers.hpp | 111 ++
   branches/release/boost/container/detail/flat_tree.hpp | 312 ++++--
   branches/release/boost/container/detail/iterators.hpp | 103 +
   branches/release/boost/container/detail/multiallocation_chain.hpp | 78 +
   branches/release/boost/container/detail/node_alloc_holder.hpp | 96 --
   branches/release/boost/container/detail/preprocessor.hpp | 79 +
   branches/release/boost/container/detail/tree.hpp | 165 +--
   branches/release/boost/container/detail/workaround.hpp | 4
   branches/release/boost/container/flat_map.hpp | 20
   branches/release/boost/container/flat_set.hpp | 8
   branches/release/boost/container/list.hpp | 1118 ++++++++++++++-----------
   branches/release/boost/container/map.hpp | 8
   branches/release/boost/container/set.hpp | 4
   branches/release/boost/container/slist.hpp | 1356 +++++++++++++++++-------------
   branches/release/boost/container/stable_vector.hpp | 1748 +++++++++++++++++++++------------------
   branches/release/boost/container/string.hpp | 846 +++++++++---------
   branches/release/boost/container/vector.hpp | 976 +++++++++------------
   branches/release/boost/interprocess/allocators/adaptive_pool.hpp | 14
   branches/release/boost/interprocess/allocators/allocator.hpp | 14
   branches/release/boost/interprocess/allocators/cached_adaptive_pool.hpp | 8
   branches/release/boost/interprocess/allocators/cached_node_allocator.hpp | 8
   branches/release/boost/interprocess/allocators/detail/adaptive_node_pool.hpp | 4
   branches/release/boost/interprocess/allocators/detail/allocator_common.hpp | 45
   branches/release/boost/interprocess/allocators/detail/node_pool.hpp | 8
   branches/release/boost/interprocess/allocators/detail/node_tools.hpp | 2
   branches/release/boost/interprocess/allocators/node_allocator.hpp | 14
   branches/release/boost/interprocess/allocators/private_adaptive_pool.hpp | 10
   branches/release/boost/interprocess/allocators/private_node_allocator.hpp | 10
   branches/release/boost/interprocess/anonymous_shared_memory.hpp | 6
   branches/release/boost/interprocess/containers/allocation_type.hpp | 2
   branches/release/boost/interprocess/containers/containers_fwd.hpp | 2
   branches/release/boost/interprocess/containers/deque.hpp | 2
   branches/release/boost/interprocess/containers/flat_map.hpp | 2
   branches/release/boost/interprocess/containers/flat_set.hpp | 2
   branches/release/boost/interprocess/containers/list.hpp | 2
   branches/release/boost/interprocess/containers/map.hpp | 2
   branches/release/boost/interprocess/containers/pair.hpp | 2
   branches/release/boost/interprocess/containers/set.hpp | 2
   branches/release/boost/interprocess/containers/slist.hpp | 2
   branches/release/boost/interprocess/containers/stable_vector.hpp | 2
   branches/release/boost/interprocess/containers/string.hpp | 2
   branches/release/boost/interprocess/containers/vector.hpp | 2
   branches/release/boost/interprocess/containers/version_type.hpp | 2
   branches/release/boost/interprocess/creation_tags.hpp | 2
   branches/release/boost/interprocess/detail/atomic.hpp | 182 ++--
   branches/release/boost/interprocess/detail/cast_tags.hpp | 2
   branches/release/boost/interprocess/detail/config_begin.hpp | 2
   branches/release/boost/interprocess/detail/config_end.hpp | 2
   branches/release/boost/interprocess/detail/file_wrapper.hpp | 12
   branches/release/boost/interprocess/detail/in_place_interface.hpp | 2
   branches/release/boost/interprocess/detail/intermodule_singleton.hpp | 2
   branches/release/boost/interprocess/detail/intermodule_singleton_common.hpp | 10
   branches/release/boost/interprocess/detail/interprocess_tester.hpp | 2
   branches/release/boost/interprocess/detail/intersegment_ptr.hpp | 46
   branches/release/boost/interprocess/detail/managed_memory_impl.hpp | 16
   branches/release/boost/interprocess/detail/managed_multi_shared_memory.hpp | 22
   branches/release/boost/interprocess/detail/managed_open_or_create_impl.hpp | 18
   branches/release/boost/interprocess/detail/math_functions.hpp | 4
   branches/release/boost/interprocess/detail/min_max.hpp | 2
   branches/release/boost/interprocess/detail/move.hpp | 2
   branches/release/boost/interprocess/detail/mpl.hpp | 2
   branches/release/boost/interprocess/detail/multi_segment_services.hpp | 2
   branches/release/boost/interprocess/detail/named_proxy.hpp | 10
   branches/release/boost/interprocess/detail/os_file_functions.hpp | 52
   branches/release/boost/interprocess/detail/os_thread_functions.hpp | 4
   branches/release/boost/interprocess/detail/pointer_type.hpp | 2
   branches/release/boost/interprocess/detail/portable_intermodule_singleton.hpp | 6
   branches/release/boost/interprocess/detail/posix_time_types_wrk.hpp | 2
   branches/release/boost/interprocess/detail/preprocessor.hpp | 146 ++
   branches/release/boost/interprocess/detail/ptime_wrk.hpp | 2
   branches/release/boost/interprocess/detail/robust_emulation.hpp | 6
   branches/release/boost/interprocess/detail/segment_manager_helper.hpp | 12
   branches/release/boost/interprocess/detail/tmp_dir_helpers.hpp | 2
   branches/release/boost/interprocess/detail/transform_iterator.hpp | 2
   branches/release/boost/interprocess/detail/type_traits.hpp | 15
   branches/release/boost/interprocess/detail/utilities.hpp | 64 +
   branches/release/boost/interprocess/detail/variadic_templates_tools.hpp | 2
   branches/release/boost/interprocess/detail/win32_api.hpp | 44
   branches/release/boost/interprocess/detail/windows_intermodule_singleton.hpp | 8
   branches/release/boost/interprocess/detail/workaround.hpp | 31
   branches/release/boost/interprocess/detail/xsi_shared_memory_device.hpp | 8
   branches/release/boost/interprocess/detail/xsi_shared_memory_file_wrapper.hpp | 8
   branches/release/boost/interprocess/errors.hpp | 4
   branches/release/boost/interprocess/exceptions.hpp | 2
   branches/release/boost/interprocess/file_mapping.hpp | 8
   branches/release/boost/interprocess/indexes/flat_map_index.hpp | 2
   branches/release/boost/interprocess/indexes/iset_index.hpp | 6
   branches/release/boost/interprocess/indexes/iunordered_set_index.hpp | 14
   branches/release/boost/interprocess/indexes/map_index.hpp | 2
   branches/release/boost/interprocess/indexes/null_index.hpp | 2
   branches/release/boost/interprocess/indexes/unordered_map_index.hpp | 2
   branches/release/boost/interprocess/interprocess_fwd.hpp | 2
   branches/release/boost/interprocess/ipc/message_queue.hpp | 338 ++++++-
   branches/release/boost/interprocess/managed_external_buffer.hpp | 6
   branches/release/boost/interprocess/managed_heap_memory.hpp | 8
   branches/release/boost/interprocess/managed_mapped_file.hpp | 6
   branches/release/boost/interprocess/managed_shared_memory.hpp | 4
   branches/release/boost/interprocess/managed_windows_shared_memory.hpp | 4
   branches/release/boost/interprocess/managed_xsi_shared_memory.hpp | 4
   branches/release/boost/interprocess/mapped_region.hpp | 232 +++++
   branches/release/boost/interprocess/mem_algo/detail/mem_algo_common.hpp | 215 ++--
   branches/release/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp | 32
   branches/release/boost/interprocess/mem_algo/rbtree_best_fit.hpp | 27
   branches/release/boost/interprocess/mem_algo/simple_seq_fit.hpp | 2
   branches/release/boost/interprocess/offset_ptr.hpp | 434 +++++++--
   branches/release/boost/interprocess/permissions.hpp | 2
   branches/release/boost/interprocess/segment_manager.hpp | 58
   branches/release/boost/interprocess/shared_memory_object.hpp | 12
   branches/release/boost/interprocess/smart_ptr/deleter.hpp | 2
   branches/release/boost/interprocess/smart_ptr/detail/shared_count.hpp | 4
   branches/release/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp | 2
   branches/release/boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp | 2
   branches/release/boost/interprocess/smart_ptr/enable_shared_from_this.hpp | 2
   branches/release/boost/interprocess/smart_ptr/intrusive_ptr.hpp | 8
   branches/release/boost/interprocess/smart_ptr/scoped_ptr.hpp | 2
   branches/release/boost/interprocess/smart_ptr/shared_ptr.hpp | 14
   branches/release/boost/interprocess/smart_ptr/unique_ptr.hpp | 6
   branches/release/boost/interprocess/smart_ptr/weak_ptr.hpp | 10
   branches/release/boost/interprocess/streams/bufferstream.hpp | 8
   branches/release/boost/interprocess/streams/vectorstream.hpp | 10
   branches/release/boost/interprocess/sync/detail/condition_algorithm_8a.hpp | 132 ++
   branches/release/boost/interprocess/sync/file_lock.hpp | 10
   branches/release/boost/interprocess/sync/interprocess_condition.hpp | 58
   branches/release/boost/interprocess/sync/interprocess_mutex.hpp | 58
   branches/release/boost/interprocess/sync/interprocess_recursive_mutex.hpp | 2
   branches/release/boost/interprocess/sync/interprocess_semaphore.hpp | 2
   branches/release/boost/interprocess/sync/interprocess_upgradable_mutex.hpp | 54
   branches/release/boost/interprocess/sync/lock_options.hpp | 2
   branches/release/boost/interprocess/sync/mutex_family.hpp | 2
   branches/release/boost/interprocess/sync/named_condition.hpp | 27
   branches/release/boost/interprocess/sync/named_mutex.hpp | 21
   branches/release/boost/interprocess/sync/named_recursive_mutex.hpp | 2
   branches/release/boost/interprocess/sync/named_semaphore.hpp | 2
   branches/release/boost/interprocess/sync/named_upgradable_mutex.hpp | 34
   branches/release/boost/interprocess/sync/null_mutex.hpp | 2
   branches/release/boost/interprocess/sync/posix/condition.hpp | 12
   branches/release/boost/interprocess/sync/posix/mutex.hpp | 5
   branches/release/boost/interprocess/sync/posix/named_mutex.hpp | 2
   branches/release/boost/interprocess/sync/posix/named_semaphore.hpp | 2
   branches/release/boost/interprocess/sync/posix/pthread_helpers.hpp | 12
   branches/release/boost/interprocess/sync/posix/ptime_to_timespec.hpp | 2
   branches/release/boost/interprocess/sync/posix/recursive_mutex.hpp | 6
   branches/release/boost/interprocess/sync/posix/semaphore.hpp | 2
   branches/release/boost/interprocess/sync/posix/semaphore_wrapper.hpp | 6
   branches/release/boost/interprocess/sync/scoped_lock.hpp | 6
   branches/release/boost/interprocess/sync/sharable_lock.hpp | 10
   branches/release/boost/interprocess/sync/shm/named_condition.hpp | 187 ---
   branches/release/boost/interprocess/sync/shm/named_creation_functor.hpp | 4
   branches/release/boost/interprocess/sync/shm/named_mutex.hpp | 15
   branches/release/boost/interprocess/sync/shm/named_recursive_mutex.hpp | 2
   branches/release/boost/interprocess/sync/shm/named_semaphore.hpp | 2
   branches/release/boost/interprocess/sync/shm/named_upgradable_mutex.hpp | 2
   branches/release/boost/interprocess/sync/spin/condition.hpp | 10
   branches/release/boost/interprocess/sync/spin/mutex.hpp | 4
   branches/release/boost/interprocess/sync/spin/recursive_mutex.hpp | 2
   branches/release/boost/interprocess/sync/spin/semaphore.hpp | 2
   branches/release/boost/interprocess/sync/upgradable_lock.hpp | 8
   branches/release/boost/interprocess/sync/windows/condition.hpp | 87 -
   branches/release/boost/interprocess/sync/windows/mutex.hpp | 2
   branches/release/boost/interprocess/sync/windows/named_condition.hpp | 304 ------
   branches/release/boost/interprocess/sync/windows/recursive_mutex.hpp | 2
   branches/release/boost/interprocess/sync/windows/semaphore.hpp | 2
   branches/release/boost/interprocess/sync/windows/sync_utils.hpp | 2
   branches/release/boost/interprocess/sync/xsi/simple_xsi_semaphore.hpp | 2
   branches/release/boost/interprocess/sync/xsi/xsi_named_mutex.hpp | 8
   branches/release/boost/interprocess/windows_shared_memory.hpp | 10
   branches/release/boost/interprocess/xsi_shared_memory.hpp | 6
   branches/release/boost/intrusive/avltree.hpp | 2
   branches/release/boost/intrusive/circular_slist_algorithms.hpp | 9
   branches/release/boost/intrusive/detail/avltree_node.hpp | 22
   branches/release/boost/intrusive/detail/common_slist_algorithms.hpp | 3
   branches/release/boost/intrusive/detail/list_node.hpp | 10
   branches/release/boost/intrusive/detail/rbtree_node.hpp | 34
   branches/release/boost/intrusive/detail/slist_node.hpp | 5
   branches/release/boost/intrusive/detail/tree_algorithms.hpp | 35
   branches/release/boost/intrusive/detail/tree_node.hpp | 15
   branches/release/boost/intrusive/detail/utilities.hpp | 83 -
   branches/release/boost/intrusive/hashtable.hpp | 498 ++++------
   branches/release/boost/intrusive/list.hpp | 2
   branches/release/boost/intrusive/options.hpp | 6
   branches/release/boost/intrusive/pointer_traits.hpp | 2
   branches/release/boost/intrusive/rbtree.hpp | 2
   branches/release/boost/intrusive/rbtree_algorithms.hpp | 21
   branches/release/boost/intrusive/sgtree.hpp | 2
   branches/release/boost/intrusive/slist.hpp | 2
   branches/release/boost/intrusive/splaytree.hpp | 2
   branches/release/boost/intrusive/treap.hpp | 2
   branches/release/libs/container/doc/Jamfile.v2 | 2
   branches/release/libs/container/doc/container.qbk | 21
   branches/release/libs/container/proj/to-do.txt | 120 ++
   branches/release/libs/container/proj/vc7ide/allocator_traits_test.vcproj | 3
   branches/release/libs/container/proj/vc7ide/container.sln | 8
   branches/release/libs/container/proj/vc7ide/container.vcproj | 5
   branches/release/libs/container/test/check_equal_containers.hpp | 24
   branches/release/libs/container/test/deque_test.cpp | 2
   branches/release/libs/container/test/dummy_test_allocator.hpp | 2
   branches/release/libs/container/test/expand_bwd_test_allocator.hpp | 2
   branches/release/libs/container/test/list_test.hpp | 44
   branches/release/libs/container/test/movable_int.hpp | 25
   branches/release/libs/container/test/scoped_allocator_usage_test.cpp | 6
   branches/release/libs/container/test/set_test.hpp | 16
   branches/release/libs/container/test/stable_vector_test.cpp | 6
   branches/release/libs/container/test/vector_test.hpp | 73 +
   branches/release/libs/interprocess/doc/interprocess.qbk | 202 +++-
   branches/release/libs/interprocess/example/Jamfile.v2 | 2
   branches/release/libs/interprocess/example/comp_doc_anonymous_conditionA.cpp | 2
   branches/release/libs/interprocess/example/comp_doc_anonymous_conditionB.cpp | 2
   branches/release/libs/interprocess/example/comp_doc_anonymous_mutexA.cpp | 2
   branches/release/libs/interprocess/example/comp_doc_anonymous_mutexB.cpp | 2
   branches/release/libs/interprocess/example/comp_doc_anonymous_semaphoreA.cpp | 2
   branches/release/libs/interprocess/example/comp_doc_anonymous_semaphoreB.cpp | 2
   branches/release/libs/interprocess/example/comp_doc_anonymous_upgradable_mutexA.cpp | 2
   branches/release/libs/interprocess/example/comp_doc_anonymous_upgradable_mutexB.cpp | 2
   branches/release/libs/interprocess/example/comp_doc_message_queueA.cpp | 2
   branches/release/libs/interprocess/example/comp_doc_message_queueB.cpp | 2
   branches/release/libs/interprocess/example/doc_adaptive_pool.cpp | 2
   branches/release/libs/interprocess/example/doc_allocator.cpp | 2
   branches/release/libs/interprocess/example/doc_anonymous_condition_shared_data.hpp | 2
   branches/release/libs/interprocess/example/doc_anonymous_mutex_shared_data.hpp | 2
   branches/release/libs/interprocess/example/doc_anonymous_semaphore_shared_data.hpp | 2
   branches/release/libs/interprocess/example/doc_anonymous_shared_memory.cpp | 4
   branches/release/libs/interprocess/example/doc_bufferstream.cpp | 4
   branches/release/libs/interprocess/example/doc_cached_adaptive_pool.cpp | 2
   branches/release/libs/interprocess/example/doc_cached_node_allocator.cpp | 2
   branches/release/libs/interprocess/example/doc_complex_map.cpp | 2
   branches/release/libs/interprocess/example/doc_cont.cpp | 2
   branches/release/libs/interprocess/example/doc_file_mapping.cpp | 2
   branches/release/libs/interprocess/example/doc_intrusive.cpp | 2
   branches/release/libs/interprocess/example/doc_ipc_message.cpp | 2
   branches/release/libs/interprocess/example/doc_managed_aligned_allocation.cpp | 4
   branches/release/libs/interprocess/example/doc_managed_allocation_command.cpp | 2
   branches/release/libs/interprocess/example/doc_managed_construction_info.cpp | 2
   branches/release/libs/interprocess/example/doc_managed_copy_on_write.cpp | 4
   branches/release/libs/interprocess/example/doc_managed_external_buffer.cpp | 4
   branches/release/libs/interprocess/example/doc_managed_grow.cpp | 2
   branches/release/libs/interprocess/example/doc_managed_heap_memory.cpp | 6
   branches/release/libs/interprocess/example/doc_managed_mapped_file.cpp | 8
   branches/release/libs/interprocess/example/doc_managed_multiple_allocation.cpp | 5
   branches/release/libs/interprocess/example/doc_managed_raw_allocation.cpp | 2
   branches/release/libs/interprocess/example/doc_map.cpp | 2
   branches/release/libs/interprocess/example/doc_move_containers.cpp | 6
   branches/release/libs/interprocess/example/doc_multi_index.cpp | 2
   branches/release/libs/interprocess/example/doc_named_alloc.cpp | 6
   branches/release/libs/interprocess/example/doc_named_condition_shared_data.hpp | 2
   branches/release/libs/interprocess/example/doc_named_mutex.cpp | 4
   branches/release/libs/interprocess/example/doc_node_allocator.cpp | 2
   branches/release/libs/interprocess/example/doc_offset_ptr.cpp | 2
   branches/release/libs/interprocess/example/doc_private_adaptive_pool.cpp | 4
   branches/release/libs/interprocess/example/doc_private_node_allocator.cpp | 4
   branches/release/libs/interprocess/example/doc_scoped_ptr.cpp | 4
   branches/release/libs/interprocess/example/doc_shared_memory.cpp | 2
   branches/release/libs/interprocess/example/doc_shared_ptr.cpp | 6
   branches/release/libs/interprocess/example/doc_shared_ptr_explicit.cpp | 4
   branches/release/libs/interprocess/example/doc_spawn_vector.cpp | 2
   branches/release/libs/interprocess/example/doc_unique_ptr.cpp | 8
   branches/release/libs/interprocess/example/doc_unordered_map.cpp | 2
   branches/release/libs/interprocess/example/doc_upgradable_mutex_shared_data.hpp | 2
   branches/release/libs/interprocess/example/doc_vectorstream.cpp | 2
   branches/release/libs/interprocess/example/doc_where_allocate.cpp | 4
   branches/release/libs/interprocess/example/doc_windows_shared_memory.cpp | 2
   branches/release/libs/interprocess/example/doc_xsi_shared_memory.cpp | 2
   branches/release/libs/interprocess/proj/to-do.txt | 14
   branches/release/libs/interprocess/proj/vc7ide/Interprocess.sln | 32
   branches/release/libs/interprocess/proj/vc7ide/condition_test.vcproj | 10
   branches/release/libs/interprocess/proj/vc7ide/interprocesslib.vcproj | 27
   branches/release/libs/interprocess/proj/vc7ide/message_queue.vcproj | 8
   branches/release/libs/interprocess/test/adaptive_node_pool_test.cpp | 2
   branches/release/libs/interprocess/test/adaptive_pool_test.cpp | 2
   branches/release/libs/interprocess/test/allocator_v1.hpp | 12
   branches/release/libs/interprocess/test/allocexcept_test.cpp | 6
   branches/release/libs/interprocess/test/anonymous_shared_memory_test.cpp | 2
   branches/release/libs/interprocess/test/boost_interprocess_check.hpp | 2
   branches/release/libs/interprocess/test/bufferstream_test.cpp | 8
   branches/release/libs/interprocess/test/cached_adaptive_pool_test.cpp | 2
   branches/release/libs/interprocess/test/cached_node_allocator_test.cpp | 2
   branches/release/libs/interprocess/test/check_equal_containers.hpp | 26
   branches/release/libs/interprocess/test/condition_test.cpp | 2
   branches/release/libs/interprocess/test/condition_test_template.hpp | 28
   branches/release/libs/interprocess/test/data_test.cpp | 2
   branches/release/libs/interprocess/test/deque_test.cpp | 10
   branches/release/libs/interprocess/test/dummy_test_allocator.hpp | 2
   branches/release/libs/interprocess/test/emplace_test.hpp | 2
   branches/release/libs/interprocess/test/enable_shared_from_this_test.cpp | 2
   branches/release/libs/interprocess/test/expand_bwd_test_allocator.hpp | 6
   branches/release/libs/interprocess/test/expand_bwd_test_template.hpp | 2
   branches/release/libs/interprocess/test/file_lock_test.cpp | 2
   branches/release/libs/interprocess/test/file_mapping_test.cpp | 6
   branches/release/libs/interprocess/test/flat_map_index_allocation_test.cpp | 2
   branches/release/libs/interprocess/test/flat_tree_test.cpp | 12
   branches/release/libs/interprocess/test/get_process_id_name.hpp | 2
   branches/release/libs/interprocess/test/heap_allocator_v1.hpp | 4
   branches/release/libs/interprocess/test/intermodule_singleton_test.cpp | 6
   branches/release/libs/interprocess/test/intersegment_ptr_test.cpp | 8
   branches/release/libs/interprocess/test/intrusive_ptr_test.cpp | 2
   branches/release/libs/interprocess/test/iset_index_allocation_test.cpp | 2
   branches/release/libs/interprocess/test/iunordered_set_index_allocation_test.cpp | 2
   branches/release/libs/interprocess/test/list_test.cpp | 2
   branches/release/libs/interprocess/test/list_test.hpp | 4
   branches/release/libs/interprocess/test/managed_mapped_file_test.cpp | 4
   branches/release/libs/interprocess/test/managed_shared_memory_test.cpp | 2
   branches/release/libs/interprocess/test/managed_windows_shared_memory_test.cpp | 4
   branches/release/libs/interprocess/test/managed_xsi_shared_memory_test.cpp | 2
   branches/release/libs/interprocess/test/map_index_allocation_test.cpp | 2
   branches/release/libs/interprocess/test/map_test.hpp | 6
   branches/release/libs/interprocess/test/mapped_file_test.cpp | 6
   branches/release/libs/interprocess/test/memory_algorithm_test.cpp | 2
   branches/release/libs/interprocess/test/memory_algorithm_test_template.hpp | 24
   branches/release/libs/interprocess/test/message_queue_test.cpp | 37
   branches/release/libs/interprocess/test/movable_int.hpp | 87 +
   branches/release/libs/interprocess/test/multi_index_test.cpp | 2
   branches/release/libs/interprocess/test/mutex_test.cpp | 2
   branches/release/libs/interprocess/test/mutex_test_template.hpp | 6
   branches/release/libs/interprocess/test/mutex_timeout_test.cpp | 2
   branches/release/libs/interprocess/test/named_allocation_test_template.hpp | 2
   branches/release/libs/interprocess/test/named_condition_test.cpp | 72 -
   branches/release/libs/interprocess/test/named_construct_test.cpp | 2
   branches/release/libs/interprocess/test/named_creation_template.hpp | 8
   branches/release/libs/interprocess/test/named_mutex_test.cpp | 2
   branches/release/libs/interprocess/test/named_recursive_mutex_test.cpp | 2
   branches/release/libs/interprocess/test/named_semaphore_test.cpp | 2
   branches/release/libs/interprocess/test/named_upgradable_mutex_test.cpp | 2
   branches/release/libs/interprocess/test/node_allocator_test.cpp | 2
   branches/release/libs/interprocess/test/node_pool_test.cpp | 2
   branches/release/libs/interprocess/test/node_pool_test.hpp | 10
   branches/release/libs/interprocess/test/null_index_test.cpp | 2
   branches/release/libs/interprocess/test/offset_ptr_test.cpp | 6
   branches/release/libs/interprocess/test/print_container.hpp | 4
   branches/release/libs/interprocess/test/private_adaptive_pool_test.cpp | 2
   branches/release/libs/interprocess/test/private_node_allocator_test.cpp | 2
   branches/release/libs/interprocess/test/recursive_mutex_test.cpp | 2
   branches/release/libs/interprocess/test/robust_emulation_test.cpp | 2
   branches/release/libs/interprocess/test/robust_mutex_test.hpp | 4
   branches/release/libs/interprocess/test/robust_recursive_emulation_test.cpp | 2
   branches/release/libs/interprocess/test/semaphore_test.cpp | 2
   branches/release/libs/interprocess/test/set_test.hpp | 6
   branches/release/libs/interprocess/test/sharable_mutex_test_template.hpp | 2
   branches/release/libs/interprocess/test/shared_memory_mapping_test.cpp | 52 +
   branches/release/libs/interprocess/test/shared_memory_test.cpp | 4
   branches/release/libs/interprocess/test/shared_ptr_test.cpp | 6
   branches/release/libs/interprocess/test/slist_test.cpp | 2
   branches/release/libs/interprocess/test/stable_vector_test.cpp | 2
   branches/release/libs/interprocess/test/string_test.cpp | 20
   branches/release/libs/interprocess/test/tree_test.cpp | 16
   branches/release/libs/interprocess/test/unique_ptr_test.cpp | 6
   branches/release/libs/interprocess/test/unordered_test.cpp | 2
   branches/release/libs/interprocess/test/upgradable_mutex_test.cpp | 2
   branches/release/libs/interprocess/test/user_buffer_test.cpp | 8
   branches/release/libs/interprocess/test/util.hpp | 2
   branches/release/libs/interprocess/test/vector_test.cpp | 2
   branches/release/libs/interprocess/test/vector_test.hpp | 8
   branches/release/libs/interprocess/test/vectorstream_test.cpp | 20
   branches/release/libs/interprocess/test/windows_shared_memory_mapping_test.cpp | 4
   branches/release/libs/interprocess/test/windows_shared_memory_test.cpp | 2
   branches/release/libs/interprocess/test/xsi_shared_memory_mapping_test.cpp | 4
   359 files changed, 7816 insertions(+), 6393 deletions(-)

Modified: branches/release/boost/container/allocator_traits.hpp
==============================================================================
--- branches/release/boost/container/allocator_traits.hpp (original)
+++ branches/release/boost/container/allocator_traits.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -70,41 +70,41 @@
       typedef unspecified pointer;
       //! Alloc::const_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<const
       //!
- typedef unspecified const_pointer;
+ typedef see_documentation const_pointer;
       //! Non-standard extension
       //! Alloc::reference if such a type exists; otherwise, value_type&
- typedef unspecified reference;
+ typedef see_documentation reference;
       //! Non-standard extension
       //! Alloc::const_reference if such a type exists ; otherwise, const value_type&
- typedef unspecified const_reference;
+ typedef see_documentation const_reference;
       //! Alloc::void_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<void>.
       //!
- typedef unspecified void_pointer;
+ typedef see_documentation void_pointer;
       //! Alloc::const_void_pointer if such a type exists ; otherwis e, pointer_traits<pointer>::rebind<const
       //!
- typedef unspecified const_void_pointer;
+ typedef see_documentation const_void_pointer;
       //! Alloc::difference_type if such a type exists ; otherwise, pointer_traits<pointer>::difference_type.
       //!
- typedef unspecified difference_type;
+ typedef see_documentation difference_type;
       //! Alloc::size_type if such a type exists ; otherwise, make_unsigned<difference_type>::type
       //!
- typedef unspecified size_type;
+ typedef see_documentation size_type;
       //! Alloc::propagate_on_container_copy_assignment if such a type exists, otherwise an integral_constant
       //! type with internal constant static member `value` == false.
- typedef unspecified propagate_on_container_copy_assignment;
+ typedef see_documentation propagate_on_container_copy_assignment;
       //! Alloc::propagate_on_container_move_assignment if such a type exists, otherwise an integral_constant
       //! type with internal constant static member `value` == false.
- typedef unspecified propagate_on_container_move_assignment;
+ typedef see_documentation propagate_on_container_move_assignment;
       //! Alloc::propagate_on_container_swap if such a type exists, otherwise an integral_constant
       //! type with internal constant static member `value` == false.
- typedef unspecified propagate_on_container_swap;
+ typedef see_documentation propagate_on_container_swap;
       //! Defines an allocator: Alloc::rebind<T>::other if such a type exists; otherwise, Alloc<T, Args>
       //! if Alloc is a class template instantiation of the form Alloc<U, Args>, where Args is zero or
       //! more type arguments ; otherwise, the instantiation of rebind_alloc is ill-formed.
       //!
       //! In C++03 compilers `rebind_alloc` is a struct derived from an allocator
       //! deduced by previously detailed rules.
- template <class T> using rebind_alloc = unspecified;
+ template <class T> using rebind_alloc = see_documentation;
 
       //! In C++03 compilers `rebind_traits` is a struct derived from
       //! `allocator_traits<OtherAlloc>`, where `OtherAlloc` is
@@ -115,7 +115,7 @@
       //! `type` is an allocator related to Alloc deduced deduced by rules explained in `rebind_alloc`.
       template <class T>
       struct portable_rebind_alloc
- { typedef unspecified_type type; };
+ { typedef see_documentation type; };
    #else
       //pointer
       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc,

Modified: branches/release/boost/container/deque.hpp
==============================================================================
--- branches/release/boost/container/deque.hpp (original)
+++ branches/release/boost/container/deque.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -101,17 +101,17 @@
 {
    BOOST_COPYABLE_AND_MOVABLE(deque_base)
    public:
- typedef allocator_traits<A> val_alloc_traits_type;
- typedef typename val_alloc_traits_type::value_type val_alloc_val;
- typedef typename val_alloc_traits_type::pointer val_alloc_ptr;
- typedef typename val_alloc_traits_type::const_pointer val_alloc_cptr;
- typedef typename val_alloc_traits_type::reference val_alloc_ref;
- typedef typename val_alloc_traits_type::const_reference val_alloc_cref;
- typedef typename val_alloc_traits_type::difference_type val_alloc_diff;
- typedef typename val_alloc_traits_type::size_type val_alloc_size;
+ typedef allocator_traits<A> val_alloc_traits_type;
+ typedef typename val_alloc_traits_type::value_type val_alloc_val;
+ typedef typename val_alloc_traits_type::pointer val_alloc_ptr;
+ typedef typename val_alloc_traits_type::const_pointer val_alloc_cptr;
+ typedef typename val_alloc_traits_type::reference val_alloc_ref;
+ typedef typename val_alloc_traits_type::const_reference val_alloc_cref;
+ typedef typename val_alloc_traits_type::difference_type val_alloc_diff;
+ typedef typename val_alloc_traits_type::size_type val_alloc_size;
    typedef typename val_alloc_traits_type::template
- portable_rebind_alloc<val_alloc_ptr>::type ptr_alloc_t;
- typedef allocator_traits<ptr_alloc_t> ptr_alloc_traits_type;
+ portable_rebind_alloc<val_alloc_ptr>::type ptr_alloc_t;
+ typedef allocator_traits<ptr_alloc_t> ptr_alloc_traits_type;
    typedef typename ptr_alloc_traits_type::value_type ptr_alloc_val;
    typedef typename ptr_alloc_traits_type::pointer ptr_alloc_ptr;
    typedef typename ptr_alloc_traits_type::const_pointer ptr_alloc_cptr;
@@ -534,46 +534,35 @@
    /// @cond
    private:
    typedef deque_base<T, A> Base;
- typedef typename Base::val_alloc_val val_alloc_val;
- typedef typename Base::val_alloc_ptr val_alloc_ptr;
- typedef typename Base::val_alloc_cptr val_alloc_cptr;
- typedef typename Base::val_alloc_ref val_alloc_ref;
- typedef typename Base::val_alloc_cref val_alloc_cref;
- typedef typename Base::val_alloc_size val_alloc_size;
- typedef typename Base::val_alloc_diff val_alloc_diff;
-
- typedef typename Base::ptr_alloc_t ptr_alloc_t;
- typedef typename Base::ptr_alloc_val ptr_alloc_val;
- typedef typename Base::ptr_alloc_ptr ptr_alloc_ptr;
- typedef typename Base::ptr_alloc_cptr ptr_alloc_cptr;
- typedef typename Base::ptr_alloc_ref ptr_alloc_ref;
- typedef typename Base::ptr_alloc_cref ptr_alloc_cref;
    /// @endcond
 
- public: // Basic types
- typedef T value_type;
- typedef val_alloc_ptr pointer;
- typedef val_alloc_cptr const_pointer;
- typedef val_alloc_ref reference;
- typedef val_alloc_cref const_reference;
- typedef val_alloc_size size_type;
- typedef val_alloc_diff difference_type;
- typedef typename Base::allocator_type allocator_type;
-
- public: // Iterators
- typedef typename Base::iterator iterator;
- typedef typename Base::const_iterator const_iterator;
-
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef std::reverse_iterator<iterator> reverse_iterator;
+ public:
 
- typedef allocator_type stored_allocator_type;
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+
+ typedef T value_type;
+ typedef typename ::boost::container::allocator_traits<A>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<A>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<A>::reference reference;
+ typedef typename ::boost::container::allocator_traits<A>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<A>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<A>::difference_type difference_type;
+ typedef A allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(allocator_type) stored_allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(typename Base::iterator) iterator;
+ typedef BOOST_CONTAINER_IMPDEF(typename Base::const_iterator) const_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
 
    /// @cond
 
    private: // Internal typedefs
    BOOST_COPYABLE_AND_MOVABLE(deque)
- typedef ptr_alloc_ptr index_pointer;
+ typedef typename Base::ptr_alloc_ptr index_pointer;
    static size_type s_buffer_size()
       { return Base::s_buffer_size(); }
    typedef container_detail::advanced_insert_aux_int<iterator> advanced_insert_aux_int_t;
@@ -584,6 +573,273 @@
    /// @endcond
 
    public:
+ //////////////////////////////////////////////
+ //
+ // construct/copy/destroy
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Effects</b>: Default constructors a deque.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant.
+ deque()
+ : Base()
+ {}
+
+ //! <b>Effects</b>: Constructs a deque taking the allocator as parameter.
+ //!
+ //! <b>Throws</b>: If allocator_type's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant.
+ explicit deque(const allocator_type& a)
+ : Base(a)
+ {}
+
+ //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
+ //! and inserts n default contructed values.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor or copy constructor
+ //! throws or T's default or copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ explicit deque(size_type n)
+ : Base(n, allocator_type())
+ {
+ container_detail::default_construct_aux_proxy<A, iterator> proxy(this->alloc(), n);
+ proxy.uninitialized_copy_remaining_to(this->begin());
+ //deque_base will deallocate in case of exception...
+ }
+
+ //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
+ //! and inserts n copies of value.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor or copy constructor
+ //! throws or T's default or copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ deque(size_type n, const value_type& value,
+ const allocator_type& a = allocator_type())
+ : Base(n, a)
+ { this->priv_fill_initialize(value); }
+
+ //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
+ //! and inserts a copy of the range [first, last) in the deque.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor or copy constructor
+ //! throws or T's constructor taking an dereferenced InIt throws.
+ //!
+ //! <b>Complexity</b>: Linear to the range [first, last).
+ template <class InIt>
+ deque(InIt first, InIt last, const allocator_type& a = allocator_type()
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InIt, size_type>::value
+ >::type * = 0
+ #endif
+ )
+ : Base(a)
+ {
+ typedef typename std::iterator_traits<InIt>::iterator_category ItCat;
+ this->priv_range_initialize(first, last, ItCat());
+ }
+
+ //! <b>Effects</b>: Copy constructs a deque.
+ //!
+ //! <b>Postcondition</b>: x == *this.
+ //!
+ //! <b>Complexity</b>: Linear to the elements x contains.
+ deque(const deque& x)
+ : Base(allocator_traits_type::select_on_container_copy_construction(x.alloc()))
+ {
+ if(x.size()){
+ this->priv_initialize_map(x.size());
+ boost::container::uninitialized_copy_alloc
+ (this->alloc(), x.begin(), x.end(), this->members_.m_start);
+ }
+ }
+
+ //! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
+ //!
+ //! <b>Throws</b>: If allocator_type's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant.
+ deque(BOOST_RV_REF(deque) x)
+ : Base(boost::move(static_cast<Base&>(x)))
+ { this->swap_members(x); }
+
+ //! <b>Effects</b>: Copy constructs a vector using the specified allocator.
+ //!
+ //! <b>Postcondition</b>: x == *this.
+ //!
+ //! <b>Throws</b>: If allocation
+ //! throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to the elements x contains.
+ deque(const deque& x, const allocator_type &a)
+ : Base(a)
+ {
+ if(x.size()){
+ this->priv_initialize_map(x.size());
+ boost::container::uninitialized_copy_alloc
+ (this->alloc(), x.begin(), x.end(), this->members_.m_start);
+ }
+ }
+
+ //! <b>Effects</b>: Move constructor using the specified allocator.
+ //! Moves mx's resources to *this if a == allocator_type().
+ //! Otherwise copies values from x to *this.
+ //!
+ //! <b>Throws</b>: If allocation or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant if a == mx.get_allocator(), linear otherwise.
+ deque(BOOST_RV_REF(deque) mx, const allocator_type &a)
+ : Base(a)
+ {
+ if(mx.alloc() == a){
+ this->swap_members(mx);
+ }
+ else{
+ if(mx.size()){
+ this->priv_initialize_map(mx.size());
+ boost::container::uninitialized_copy_alloc
+ (this->alloc(), mx.begin(), mx.end(), this->members_.m_start);
+ }
+ }
+ }
+
+ //! <b>Effects</b>: Destroys the deque. All stored values are destroyed
+ //! and used memory is deallocated.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements.
+ ~deque() BOOST_CONTAINER_NOEXCEPT
+ {
+ priv_destroy_range(this->members_.m_start, this->members_.m_finish);
+ }
+
+ //! <b>Effects</b>: Makes *this contain the same elements as x.
+ //!
+ //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
+ //! of each of x's elements.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements in x.
+ deque& operator= (BOOST_COPY_ASSIGN_REF(deque) x)
+ {
+ if (&x != this){
+ allocator_type &this_alloc = this->alloc();
+ const allocator_type &x_alloc = x.alloc();
+ container_detail::bool_<allocator_traits_type::
+ propagate_on_container_copy_assignment::value> flag;
+ if(flag && this_alloc != x_alloc){
+ this->clear();
+ this->shrink_to_fit();
+ }
+ container_detail::assign_alloc(this->alloc(), x.alloc(), flag);
+ container_detail::assign_alloc(this->ptr_alloc(), x.ptr_alloc(), flag);
+ this->assign(x.cbegin(), x.cend());
+ }
+ return *this;
+ }
+
+ //! <b>Effects</b>: Move assignment. All mx's values are transferred to *this.
+ //!
+ //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had
+ //! before the function.
+ //!
+ //! <b>Throws</b>: If allocator_type's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear.
+ deque& operator= (BOOST_RV_REF(deque) x)
+ {
+ if (&x != this){
+ allocator_type &this_alloc = this->alloc();
+ allocator_type &x_alloc = x.alloc();
+ //If allocators are equal we can just swap pointers
+ if(this_alloc == x_alloc){
+ //Destroy objects but retain memory in case x reuses it in the future
+ this->clear();
+ this->swap_members(x);
+ //Move allocator if needed
+ container_detail::bool_<allocator_traits_type::
+ propagate_on_container_move_assignment::value> flag;
+ container_detail::move_alloc(this_alloc, x_alloc, flag);
+ container_detail::move_alloc(this->ptr_alloc(), x.ptr_alloc(), flag);
+ }
+ //If unequal allocators, then do a one by one move
+ else{
+ typedef typename std::iterator_traits<iterator>::iterator_category ItCat;
+ this->assign( boost::make_move_iterator(x.begin())
+ , boost::make_move_iterator(x.end()));
+ }
+ }
+ return *this;
+ }
+
+ //! <b>Effects</b>: Assigns the n copies of val to *this.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ void assign(size_type n, const T& val)
+ {
+ typedef constant_iterator<value_type, difference_type> c_it;
+ this->assign(c_it(val, n), c_it());
+ }
+
+ //! <b>Effects</b>: Assigns the the range [first, last) to *this.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's constructor from dereferencing InIt throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ template <class InIt>
+ void assign(InIt first, InIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InIt, size_type>::value
+ && container_detail::is_input_iterator<InIt>::value
+ >::type * = 0
+ #endif
+ )
+ {
+ iterator cur = this->begin();
+ for ( ; first != last && cur != end(); ++cur, ++first){
+ *cur = *first;
+ }
+ if (first == last){
+ this->erase(cur, this->cend());
+ }
+ else{
+ this->insert(this->cend(), first, last);
+ }
+ }
+
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ template <class FwdIt>
+ void assign(FwdIt first, FwdIt last
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<FwdIt, size_type>::value
+ && !container_detail::is_input_iterator<FwdIt>::value
+ >::type * = 0
+ )
+ {
+ const size_type len = std::distance(first, last);
+ if (len > size()) {
+ FwdIt mid = first;
+ std::advance(mid, this->size());
+ boost::copy_or_move(first, mid, begin());
+ this->insert(this->cend(), mid, last);
+ }
+ else{
+ this->erase(boost::copy_or_move(first, last, this->begin()), cend());
+ }
+ }
+ #endif
 
    //! <b>Effects</b>: Returns a copy of the internal allocator.
    //!
@@ -603,6 +859,12 @@
    const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
    { return Base::alloc(); }
 
+ //////////////////////////////////////////////
+ //
+ // iterators
+ //
+ //////////////////////////////////////////////
+
    //! <b>Effects</b>: Returns a reference to the internal allocator.
    //!
    //! <b>Throws</b>: Nothing
@@ -621,21 +883,21 @@
    iterator begin() BOOST_CONTAINER_NOEXCEPT
       { return this->members_.m_start; }
 
- //! <b>Effects</b>: Returns an iterator to the end of the deque.
+ //! <b>Effects</b>: Returns a const_iterator to the first element contained in the deque.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- iterator end() BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_finish; }
+ const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
+ { return this->members_.m_start; }
 
- //! <b>Effects</b>: Returns a const_iterator to the first element contained in the deque.
+ //! <b>Effects</b>: Returns an iterator to the end of the deque.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_start; }
+ iterator end() BOOST_CONTAINER_NOEXCEPT
+ { return this->members_.m_finish; }
 
    //! <b>Effects</b>: Returns a const_iterator to the end of the deque.
    //!
@@ -654,23 +916,23 @@
    reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
       { return reverse_iterator(this->members_.m_finish); }
 
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed deque.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
- { return reverse_iterator(this->members_.m_start); }
+ const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
+ { return const_reverse_iterator(this->members_.m_finish); }
 
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
    //! of the reversed deque.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
- { return const_reverse_iterator(this->members_.m_finish); }
+ reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
+ { return reverse_iterator(this->members_.m_start); }
 
    //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
    //! of the reversed deque.
@@ -715,49 +977,91 @@
    const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
       { return const_reverse_iterator(this->members_.m_start); }
 
- //! <b>Requires</b>: size() > n.
- //!
- //! <b>Effects</b>: Returns a reference to the nth element
- //! from the beginning of the container.
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Effects</b>: Returns true if the deque contains no elements.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_start[difference_type(n)]; }
+ bool empty() const BOOST_CONTAINER_NOEXCEPT
+ { return this->members_.m_finish == this->members_.m_start; }
 
- //! <b>Requires</b>: size() > n.
- //!
- //! <b>Effects</b>: Returns a const reference to the nth element
- //! from the beginning of the container.
+ //! <b>Effects</b>: Returns the number of the elements contained in the deque.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_start[difference_type(n)]; }
+ size_type size() const BOOST_CONTAINER_NOEXCEPT
+ { return this->members_.m_finish - this->members_.m_start; }
 
- //! <b>Requires</b>: size() > n.
- //!
- //! <b>Effects</b>: Returns a reference to the nth element
- //! from the beginning of the container.
+ //! <b>Effects</b>: Returns the largest possible size of the deque.
    //!
- //! <b>Throws</b>: std::range_error if n >= size()
+ //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- reference at(size_type n)
- { this->priv_range_check(n); return (*this)[n]; }
+ size_type max_size() const BOOST_CONTAINER_NOEXCEPT
+ { return allocator_traits_type::max_size(this->alloc()); }
 
- //! <b>Requires</b>: size() > n.
+ //! <b>Effects</b>: Inserts or erases elements at the end such that
+ //! the size becomes n. New elements are default constructed.
    //!
- //! <b>Effects</b>: Returns a const reference to the nth element
- //! from the beginning of the container.
+ //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
    //!
- //! <b>Throws</b>: std::range_error if n >= size()
+ //! <b>Complexity</b>: Linear to the difference between size() and new_size.
+ void resize(size_type new_size)
+ {
+ const size_type len = size();
+ if (new_size < len)
+ this->priv_erase_last_n(len - new_size);
+ else{
+ const size_type n = new_size - this->size();
+ container_detail::default_construct_aux_proxy<A, iterator> proxy(this->alloc(), n);
+ priv_insert_back_aux_impl(n, proxy);
+ }
+ }
+
+ //! <b>Effects</b>: Inserts or erases elements at the end such that
+ //! the size becomes n. New elements are copy constructed from x.
+ //!
+ //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to the difference between size() and new_size.
+ void resize(size_type new_size, const value_type& x)
+ {
+ const size_type len = size();
+ if (new_size < len)
+ this->erase(this->members_.m_start + new_size, this->members_.m_finish);
+ else
+ this->insert(this->members_.m_finish, new_size - len, x);
+ }
+
+ //! <b>Effects</b>: Tries to deallocate the excess of memory created
+ //! with previous allocations. The size of the deque is unchanged
+ //!
+ //! <b>Throws</b>: If memory allocation throws.
    //!
    //! <b>Complexity</b>: Constant.
- const_reference at(size_type n) const
- { this->priv_range_check(n); return (*this)[n]; }
+ void shrink_to_fit()
+ {
+ //This deque implementation already
+ //deallocates excess nodes when erasing
+ //so there is nothing to do except for
+ //empty deque
+ if(this->empty()){
+ this->priv_clear_map();
+ }
+ }
+
+ //////////////////////////////////////////////
+ //
+ // element access
+ //
+ //////////////////////////////////////////////
 
    //! <b>Requires</b>: !empty()
    //!
@@ -803,436 +1107,101 @@
    const_reference back() const BOOST_CONTAINER_NOEXCEPT
       { return *(cend()-1); }
 
- //! <b>Effects</b>: Returns the number of the elements contained in the deque.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- size_type size() const BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_finish - this->members_.m_start; }
-
- //! <b>Effects</b>: Returns the largest possible size of the deque.
- //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Requires</b>: size() > n.
    //!
- //! <b>Complexity</b>: Constant.
- size_type max_size() const BOOST_CONTAINER_NOEXCEPT
- { return allocator_traits_type::max_size(this->alloc()); }
-
- //! <b>Effects</b>: Returns true if the deque contains no elements.
+ //! <b>Effects</b>: Returns a reference to the nth element
+ //! from the beginning of the container.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- bool empty() const BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_finish == this->members_.m_start; }
+ reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
+ { return this->members_.m_start[difference_type(n)]; }
 
- //! <b>Effects</b>: Default constructors a deque.
- //!
- //! <b>Throws</b>: If allocator_type's default constructor throws.
+ //! <b>Requires</b>: size() > n.
    //!
- //! <b>Complexity</b>: Constant.
- deque()
- : Base()
- {}
-
- //! <b>Effects</b>: Constructs a deque taking the allocator as parameter.
+ //! <b>Effects</b>: Returns a const reference to the nth element
+ //! from the beginning of the container.
    //!
- //! <b>Throws</b>: If allocator_type's copy constructor throws.
+ //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- explicit deque(const allocator_type& a)
- : Base(a)
- {}
-
- //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
- //! and inserts n default contructed values.
- //!
- //! <b>Throws</b>: If allocator_type's default constructor or copy constructor
- //! throws or T's default or copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to n.
- explicit deque(size_type n)
- : Base(n, allocator_type())
- {
- container_detail::default_construct_aux_proxy<A, iterator> proxy(this->alloc(), n);
- proxy.uninitialized_copy_remaining_to(this->begin());
- //deque_base will deallocate in case of exception...
- }
-
- //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
- //! and inserts n copies of value.
- //!
- //! <b>Throws</b>: If allocator_type's default constructor or copy constructor
- //! throws or T's default or copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to n.
- deque(size_type n, const value_type& value,
- const allocator_type& a = allocator_type())
- : Base(n, a)
- { this->priv_fill_initialize(value); }
+ const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
+ { return this->members_.m_start[difference_type(n)]; }
 
- //! <b>Effects</b>: Copy constructs a deque.
- //!
- //! <b>Postcondition</b>: x == *this.
+ //! <b>Requires</b>: size() > n.
    //!
- //! <b>Complexity</b>: Linear to the elements x contains.
- deque(const deque& x)
- : Base(allocator_traits_type::select_on_container_copy_construction(x.alloc()))
- {
- if(x.size()){
- this->priv_initialize_map(x.size());
- boost::container::uninitialized_copy_alloc
- (this->alloc(), x.begin(), x.end(), this->members_.m_start);
- }
- }
-
- //! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
+ //! <b>Effects</b>: Returns a reference to the nth element
+ //! from the beginning of the container.
    //!
- //! <b>Throws</b>: If allocator_type's copy constructor throws.
+ //! <b>Throws</b>: std::range_error if n >= size()
    //!
    //! <b>Complexity</b>: Constant.
- deque(BOOST_RV_REF(deque) x)
- : Base(boost::move(static_cast<Base&>(x)))
- { this->swap_members(x); }
-
- //! <b>Effects</b>: Copy constructs a vector using the specified allocator.
- //!
- //! <b>Postcondition</b>: x == *this.
- //!
- //! <b>Throws</b>: If allocation
- //! throws or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to the elements x contains.
- deque(const deque& x, const allocator_type &a)
- : Base(a)
- {
- if(x.size()){
- this->priv_initialize_map(x.size());
- boost::container::uninitialized_copy_alloc
- (this->alloc(), x.begin(), x.end(), this->members_.m_start);
- }
- }
-
- //! <b>Effects</b>: Move constructor using the specified allocator.
- //! Moves mx's resources to *this if a == allocator_type().
- //! Otherwise copies values from x to *this.
- //!
- //! <b>Throws</b>: If allocation or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Constant if a == mx.get_allocator(), linear otherwise.
- deque(BOOST_RV_REF(deque) mx, const allocator_type &a)
- : Base(a)
- {
- if(mx.alloc() == a){
- this->swap_members(mx);
- }
- else{
- if(mx.size()){
- this->priv_initialize_map(mx.size());
- boost::container::uninitialized_copy_alloc
- (this->alloc(), mx.begin(), mx.end(), this->members_.m_start);
- }
- }
- }
-
- //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
- //! and inserts a copy of the range [first, last) in the deque.
- //!
- //! <b>Throws</b>: If allocator_type's default constructor or copy constructor
- //! throws or T's constructor taking an dereferenced InIt throws.
- //!
- //! <b>Complexity</b>: Linear to the range [first, last).
- template <class InpIt>
- deque(InpIt first, InpIt last, const allocator_type& a = allocator_type())
- : Base(a)
- {
- //Dispatch depending on integer/iterator
- const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- this->priv_initialize_dispatch(first, last, Result());
- }
-
- //! <b>Effects</b>: Destroys the deque. All stored values are destroyed
- //! and used memory is deallocated.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Linear to the number of elements.
- ~deque() BOOST_CONTAINER_NOEXCEPT
- {
- priv_destroy_range(this->members_.m_start, this->members_.m_finish);
- }
-
- //! <b>Effects</b>: Makes *this contain the same elements as x.
- //!
- //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
- //! of each of x's elements.
- //!
- //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to the number of elements in x.
- deque& operator= (BOOST_COPY_ASSIGN_REF(deque) x)
- {
- if (&x != this){
- allocator_type &this_alloc = this->alloc();
- const allocator_type &x_alloc = x.alloc();
- container_detail::bool_<allocator_traits_type::
- propagate_on_container_copy_assignment::value> flag;
- if(flag && this_alloc != x_alloc){
- this->clear();
- this->shrink_to_fit();
- }
- container_detail::assign_alloc(this->alloc(), x.alloc(), flag);
- container_detail::assign_alloc(this->ptr_alloc(), x.ptr_alloc(), flag);
- this->assign(x.cbegin(), x.cend());
- }
- return *this;
- }
+ reference at(size_type n)
+ { this->priv_range_check(n); return (*this)[n]; }
 
- //! <b>Effects</b>: Move assignment. All mx's values are transferred to *this.
- //!
- //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had
- //! before the function.
- //!
- //! <b>Throws</b>: If allocator_type's copy constructor throws.
+ //! <b>Requires</b>: size() > n.
    //!
- //! <b>Complexity</b>: Linear.
- deque& operator= (BOOST_RV_REF(deque) x)
- {
- if (&x != this){
- allocator_type &this_alloc = this->alloc();
- allocator_type &x_alloc = x.alloc();
- //If allocators are equal we can just swap pointers
- if(this_alloc == x_alloc){
- //Destroy objects but retain memory in case x reuses it in the future
- this->clear();
- this->swap_members(x);
- //Move allocator if needed
- container_detail::bool_<allocator_traits_type::
- propagate_on_container_move_assignment::value> flag;
- container_detail::move_alloc(this_alloc, x_alloc, flag);
- container_detail::move_alloc(this->ptr_alloc(), x.ptr_alloc(), flag);
- }
- //If unequal allocators, then do a one by one move
- else{
- typedef typename std::iterator_traits<iterator>::iterator_category ItCat;
- this->assign( boost::make_move_iterator(x.begin())
- , boost::make_move_iterator(x.end()));
- }
- }
- return *this;
- }
-
- //! <b>Effects</b>: Swaps the contents of *this and x.
+ //! <b>Effects</b>: Returns a const reference to the nth element
+ //! from the beginning of the container.
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: std::range_error if n >= size()
    //!
    //! <b>Complexity</b>: Constant.
- void swap(deque &x)
- {
- this->swap_members(x);
- container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag;
- container_detail::swap_alloc(this->alloc(), x.alloc(), flag);
- container_detail::swap_alloc(this->ptr_alloc(), x.ptr_alloc(), flag);
- }
-
- //! <b>Effects</b>: Assigns the n copies of val to *this.
- //!
- //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to n.
- void assign(size_type n, const T& val)
- { this->priv_fill_assign(n, val); }
-
- //! <b>Effects</b>: Assigns the the range [first, last) to *this.
- //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's constructor from dereferencing InpIt throws.
- //!
- //! <b>Complexity</b>: Linear to n.
- template <class InpIt>
- void assign(InpIt first, InpIt last)
- {
- //Dispatch depending on integer/iterator
- const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- this->priv_assign_dispatch(first, last, Result());
- }
-
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- //! <b>Effects</b>: Inserts a copy of x at the end of the deque.
- //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_back(const T &x);
-
- //! <b>Effects</b>: Constructs a new element in the end of the deque
- //! and moves the resources of mx to this new element.
- //!
- //! <b>Throws</b>: If memory allocation throws.
- //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_back(T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
- #endif
-
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- //! <b>Effects</b>: Inserts a copy of x at the front of the deque.
- //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_front(const T &x);
-
- //! <b>Effects</b>: Constructs a new element in the front of the deque
- //! and moves the resources of mx to this new element.
- //!
- //! <b>Throws</b>: If memory allocation throws.
- //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_front(T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
- #endif
-
- //! <b>Effects</b>: Removes the last element from the deque.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant time.
- void pop_back() BOOST_CONTAINER_NOEXCEPT
- {
- if (this->members_.m_finish.m_cur != this->members_.m_finish.m_first) {
- --this->members_.m_finish.m_cur;
- allocator_traits_type::destroy
- ( this->alloc()
- , container_detail::to_raw_pointer(this->members_.m_finish.m_cur)
- );
- }
- else
- this->priv_pop_back_aux();
- }
-
- //! <b>Effects</b>: Removes the first element from the deque.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant time.
- void pop_front() BOOST_CONTAINER_NOEXCEPT
- {
- if (this->members_.m_start.m_cur != this->members_.m_start.m_last - 1) {
- allocator_traits_type::destroy
- ( this->alloc()
- , container_detail::to_raw_pointer(this->members_.m_start.m_cur)
- );
- ++this->members_.m_start.m_cur;
- }
- else
- this->priv_pop_front_aux();
- }
-
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- //! <b>Requires</b>: position must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Insert a copy of x before position.
- //!
- //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws.
- //!
- //! <b>Complexity</b>: If position is end(), amortized constant time
- //! Linear time otherwise.
- iterator insert(const_iterator position, const T &x);
-
- //! <b>Requires</b>: position must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Insert a new element before position with mx's resources.
- //!
- //! <b>Throws</b>: If memory allocation throws.
- //!
- //! <b>Complexity</b>: If position is end(), amortized constant time
- //! Linear time otherwise.
- iterator insert(const_iterator position, T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
- #endif
-
- //! <b>Requires</b>: pos must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Insert n copies of x before pos.
- //!
- //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to n.
- void insert(const_iterator pos, size_type n, const value_type& x)
- { this->priv_fill_insert(pos, n, x); }
+ const_reference at(size_type n) const
+ { this->priv_range_check(n); return (*this)[n]; }
 
- //! <b>Requires</b>: pos must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Insert a copy of the [first, last) range before pos.
- //!
- //! <b>Throws</b>: If memory allocation throws, T's constructor from a
- //! dereferenced InpIt throws or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to std::distance [first, last).
- template <class InpIt>
- void insert(const_iterator pos, InpIt first, InpIt last)
- {
- //Dispatch depending on integer/iterator
- const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- this->priv_insert_dispatch(pos, first, last, Result());
- }
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
    //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... in the end of the deque.
+ //! std::forward<Args>(args)... in the beginning of the deque.
    //!
    //! <b>Throws</b>: If memory allocation throws or the in-place constructor throws.
    //!
    //! <b>Complexity</b>: Amortized constant time
    template <class... Args>
- void emplace_back(Args&&... args)
+ void emplace_front(Args&&... args)
    {
- if(this->priv_push_back_simple_available()){
+ if(this->priv_push_front_simple_available()){
          allocator_traits_type::construct
             ( this->alloc()
- , this->priv_push_back_simple_pos()
+ , this->priv_push_front_simple_pos()
             , boost::forward<Args>(args)...);
- this->priv_push_back_simple_commit();
+ this->priv_push_front_simple_commit();
       }
       else{
          typedef container_detail::advanced_insert_aux_non_movable_emplace<A, iterator, Args...> type;
          type &&proxy = type(this->alloc(), boost::forward<Args>(args)...);
- this->priv_insert_back_aux_impl(1, proxy);
+ this->priv_insert_front_aux_impl(1, proxy);
       }
    }
 
    //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... in the beginning of the deque.
+ //! std::forward<Args>(args)... in the end of the deque.
    //!
    //! <b>Throws</b>: If memory allocation throws or the in-place constructor throws.
    //!
    //! <b>Complexity</b>: Amortized constant time
    template <class... Args>
- void emplace_front(Args&&... args)
+ void emplace_back(Args&&... args)
    {
- if(this->priv_push_front_simple_available()){
+ if(this->priv_push_back_simple_available()){
          allocator_traits_type::construct
             ( this->alloc()
- , this->priv_push_front_simple_pos()
+ , this->priv_push_back_simple_pos()
             , boost::forward<Args>(args)...);
- this->priv_push_front_simple_commit();
+ this->priv_push_back_simple_commit();
       }
       else{
          typedef container_detail::advanced_insert_aux_non_movable_emplace<A, iterator, Args...> type;
          type &&proxy = type(this->alloc(), boost::forward<Args>(args)...);
- this->priv_insert_front_aux_impl(1, proxy);
+ this->priv_insert_back_aux_impl(1, proxy);
       }
    }
 
@@ -1257,11 +1226,9 @@
          return (this->end()-1);
       }
       else{
- size_type n = p - this->cbegin();
          typedef container_detail::advanced_insert_aux_emplace<A, iterator, Args...> type;
          type &&proxy = type(this->alloc(), boost::forward<Args>(args)...);
- this->priv_insert_aux_impl(p, 1, proxy);
- return iterator(this->begin() + n);
+ return this->priv_insert_aux_impl(p, 1, proxy);
       }
    }
 
@@ -1269,41 +1236,41 @@
 
    //advanced_insert_int.hpp includes all necessary preprocessor machinery...
    #define BOOST_PP_LOCAL_MACRO(n) \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, > ) \
+ void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
    { \
- if(priv_push_back_simple_available()){ \
+ if(priv_push_front_simple_available()){ \
          allocator_traits_type::construct \
             ( this->alloc() \
- , this->priv_push_back_simple_pos() \
+ , this->priv_push_front_simple_pos() \
               BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- priv_push_back_simple_commit(); \
+ priv_push_front_simple_commit(); \
       } \
       else{ \
- container_detail::BOOST_PP_CAT(BOOST_PP_CAT( \
- advanced_insert_aux_non_movable_emplace, n), arg) \
+ container_detail::BOOST_PP_CAT(BOOST_PP_CAT \
+ (advanced_insert_aux_non_movable_emplace, n), arg) \
                <A, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- priv_insert_back_aux_impl(1, proxy); \
+ priv_insert_front_aux_impl(1, proxy); \
       } \
    } \
                                                                                              \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, > ) \
- void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
+ void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
    { \
- if(priv_push_front_simple_available()){ \
+ if(priv_push_back_simple_available()){ \
          allocator_traits_type::construct \
             ( this->alloc() \
- , this->priv_push_front_simple_pos() \
+ , this->priv_push_back_simple_pos() \
               BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- priv_push_front_simple_commit(); \
+ priv_push_back_simple_commit(); \
       } \
       else{ \
- container_detail::BOOST_PP_CAT(BOOST_PP_CAT \
- (advanced_insert_aux_non_movable_emplace, n), arg) \
+ container_detail::BOOST_PP_CAT(BOOST_PP_CAT( \
+ advanced_insert_aux_non_movable_emplace, n), arg) \
                <A, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- priv_insert_front_aux_impl(1, proxy); \
+ priv_insert_back_aux_impl(1, proxy); \
       } \
    } \
                                                                                              \
@@ -1320,12 +1287,10 @@
          return (this->end()-1); \
       } \
       else{ \
- size_type pos_num = p - this->cbegin(); \
          container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \
             <A, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- this->priv_insert_aux_impl(p, 1, proxy); \
- return iterator(this->begin() + pos_num); \
+ return this->priv_insert_aux_impl(p, 1, proxy); \
       } \
    } \
    //!
@@ -1334,37 +1299,170 @@
 
    #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
- //! <b>Effects</b>: Inserts or erases elements at the end such that
- //! the size becomes n. New elements are copy constructed from x.
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: Inserts a copy of x at the front of the deque.
    //!
- //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's copy constructor throws.
    //!
- //! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size, const value_type& x)
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_front(const T &x);
+
+ //! <b>Effects</b>: Constructs a new element in the front of the deque
+ //! and moves the resources of mx to this new element.
+ //!
+ //! <b>Throws</b>: If memory allocation throws.
+ //!
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_front(T &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
+ #endif
+
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: Inserts a copy of x at the end of the deque.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_back(const T &x);
+
+ //! <b>Effects</b>: Constructs a new element in the end of the deque
+ //! and moves the resources of mx to this new element.
+ //!
+ //! <b>Throws</b>: If memory allocation throws.
+ //!
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_back(T &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
+ #endif
+
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //! <b>Requires</b>: position must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert a copy of x before position.
+ //!
+ //! <b>Returns</b>: an iterator to the inserted element.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: If position is end(), amortized constant time
+ //! Linear time otherwise.
+ iterator insert(const_iterator position, const T &x);
+
+ //! <b>Requires</b>: position must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert a new element before position with mx's resources.
+ //!
+ //! <b>Returns</b>: an iterator to the inserted element.
+ //!
+ //! <b>Throws</b>: If memory allocation throws.
+ //!
+ //! <b>Complexity</b>: If position is end(), amortized constant time
+ //! Linear time otherwise.
+ iterator insert(const_iterator position, T &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
+ #endif
+
+ //! <b>Requires</b>: pos must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert n copies of x before pos.
+ //!
+ //! <b>Returns</b>: an iterator to the first inserted element or pos if n is 0.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ iterator insert(const_iterator pos, size_type n, const value_type& x)
    {
- const size_type len = size();
- if (new_size < len)
- this->erase(this->members_.m_start + new_size, this->members_.m_finish);
+ typedef constant_iterator<value_type, difference_type> c_it;
+ return this->insert(pos, c_it(x, n), c_it());
+ }
+
+ //! <b>Requires</b>: pos must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert a copy of the [first, last) range before pos.
+ //!
+ //! <b>Returns</b>: an iterator to the first inserted element or pos if first == last.
+ //!
+ //! <b>Throws</b>: If memory allocation throws, T's constructor from a
+ //! dereferenced InIt throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to std::distance [first, last).
+ template <class InIt>
+ iterator insert(const_iterator pos, InIt first, InIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InIt, size_type>::value
+ && container_detail::is_input_iterator<InIt>::value
+ >::type * = 0
+ #endif
+ )
+ {
+ size_type n = 0;
+ iterator it(pos);
+ for(;first != last; ++first, ++n){
+ it = this->emplace(it, *first);
+ ++it;
+ }
+ it -= n;
+ return it;
+ }
+
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ template <class FwdIt>
+ iterator insert(const_iterator p, FwdIt first, FwdIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<FwdIt, size_type>::value
+ && !container_detail::is_input_iterator<FwdIt>::value
+ >::type * = 0
+ #endif
+ )
+ {
+ container_detail::advanced_insert_aux_proxy<A, FwdIt, iterator> proxy(this->alloc(), first, last);
+ return priv_insert_aux_impl(p, (size_type)std::distance(first, last), proxy);
+ }
+ #endif
+
+ //! <b>Effects</b>: Removes the first element from the deque.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ void pop_front() BOOST_CONTAINER_NOEXCEPT
+ {
+ if (this->members_.m_start.m_cur != this->members_.m_start.m_last - 1) {
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , container_detail::to_raw_pointer(this->members_.m_start.m_cur)
+ );
+ ++this->members_.m_start.m_cur;
+ }
       else
- this->insert(this->members_.m_finish, new_size - len, x);
+ this->priv_pop_front_aux();
    }
 
- //! <b>Effects</b>: Inserts or erases elements at the end such that
- //! the size becomes n. New elements are default constructed.
+ //! <b>Effects</b>: Removes the last element from the deque.
    //!
- //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
+ //! <b>Throws</b>: Nothing.
    //!
- //! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size)
+ //! <b>Complexity</b>: Constant time.
+ void pop_back() BOOST_CONTAINER_NOEXCEPT
    {
- const size_type len = size();
- if (new_size < len)
- this->priv_erase_last_n(len - new_size);
- else{
- size_type n = new_size - this->size();
- container_detail::default_construct_aux_proxy<A, iterator> proxy(this->alloc(), n);
- priv_insert_back_aux_impl(n, proxy);
+ if (this->members_.m_finish.m_cur != this->members_.m_finish.m_first) {
+ --this->members_.m_finish.m_cur;
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , container_detail::to_raw_pointer(this->members_.m_finish.m_cur)
+ );
       }
+ else
+ this->priv_pop_back_aux();
    }
 
    //! <b>Effects</b>: Erases the element at position pos.
@@ -1428,18 +1526,17 @@
       }
    }
 
- void priv_erase_last_n(size_type n)
+ //! <b>Effects</b>: Swaps the contents of *this and x.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ void swap(deque &x)
    {
- if(n == this->size()) {
- this->clear();
- }
- else {
- iterator new_finish = this->members_.m_finish - n;
- if(!Base::traits_t::trivial_dctr_after_move)
- this->priv_destroy_range(new_finish, this->members_.m_finish);
- this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1);
- this->members_.m_finish = new_finish;
- }
+ this->swap_members(x);
+ container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag;
+ container_detail::swap_alloc(this->alloc(), x.alloc(), flag);
+ container_detail::swap_alloc(this->ptr_alloc(), x.ptr_alloc(), flag);
    }
 
    //! <b>Effects</b>: Erases all the elements of the deque.
@@ -1467,25 +1564,23 @@
       this->members_.m_finish = this->members_.m_start;
    }
 
- //! <b>Effects</b>: Tries to deallocate the excess of memory created
- //! with previous allocations. The size of the deque is unchanged
- //!
- //! <b>Throws</b>: If memory allocation throws.
- //!
- //! <b>Complexity</b>: Constant.
- void shrink_to_fit()
+ /// @cond
+ private:
+
+ void priv_erase_last_n(size_type n)
    {
- //This deque implementation already
- //deallocates excess nodes when erasing
- //so there is nothing to do except for
- //empty deque
- if(this->empty()){
- this->priv_clear_map();
+ if(n == this->size()) {
+ this->clear();
+ }
+ else {
+ iterator new_finish = this->members_.m_finish - n;
+ if(!Base::traits_t::trivial_dctr_after_move)
+ this->priv_destroy_range(new_finish, this->members_.m_finish);
+ this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1);
+ this->members_.m_finish = new_finish;
       }
    }
 
- /// @cond
- private:
    void priv_range_check(size_type n) const
       { if (n >= this->size()) BOOST_RETHROW std::out_of_range("deque"); }
 
@@ -1500,9 +1595,7 @@
          return (end()-1);
       }
       else {
- size_type n = position - cbegin();
- this->priv_insert_aux(position, size_type(1), x);
- return iterator(this->begin() + n);
+ return this->insert(position, size_type(1), x);
       }
    }
 
@@ -1517,10 +1610,7 @@
          return(end()-1);
       }
       else {
- //Just call more general insert(pos, size, value) and return iterator
- size_type n = position - begin();
- this->priv_insert_aux(position, move_it(r_iterator(mx, 1)), move_it(r_iterator()));
- return iterator(this->begin() + n);
+ return this->insert(position, move_it(r_iterator(mx, 1)), move_it(r_iterator()));
       }
    }
 
@@ -1532,7 +1622,7 @@
          this->priv_push_front_simple_commit();
       }
       else{
- this->priv_insert_aux(cbegin(), size_type(1), t);
+ this->insert(cbegin(), size_type(1), t);
       }
    }
 
@@ -1544,7 +1634,7 @@
          this->priv_push_front_simple_commit();
       }
       else{
- this->priv_insert_aux(cbegin(), move_it(r_iterator(t, 1)), move_it(r_iterator()));
+ this->insert(cbegin(), move_it(r_iterator(t, 1)), move_it(r_iterator()));
       }
    }
 
@@ -1556,7 +1646,7 @@
          this->priv_push_back_simple_commit();
       }
       else{
- this->priv_insert_aux(cend(), size_type(1), t);
+ this->insert(cend(), size_type(1), t);
       }
    }
 
@@ -1568,7 +1658,7 @@
          this->priv_push_back_simple_commit();
       }
       else{
- this->priv_insert_aux(cend(), move_it(r_iterator(t, 1)), move_it(r_iterator()));
+ this->insert(cend(), move_it(r_iterator(t, 1)), move_it(r_iterator()));
       }
    }
 
@@ -1600,48 +1690,6 @@
    void priv_push_front_simple_commit()
    { --this->members_.m_start.m_cur; }
 
- template <class InpIt>
- void priv_insert_aux(const_iterator pos, InpIt first, InpIt last, std::input_iterator_tag)
- {
- for(;first != last; ++first){
- this->insert(pos, boost::move(value_type(*first)));
- }
- }
-
- template <class FwdIt>
- void priv_insert_aux(const_iterator pos, FwdIt first, FwdIt last, std::forward_iterator_tag)
- { this->priv_insert_aux(pos, first, last); }
-
- // assign(), a generalized assignment member function. Two
- // versions: one that takes a count, and one that takes a range.
- // The range version is a member template, so we dispatch on whether
- // or not the type is an integer.
- void priv_fill_assign(size_type n, const T& val)
- {
- if (n > size()) {
- std::fill(begin(), end(), val);
- this->insert(cend(), n - size(), val);
- }
- else {
- this->erase(cbegin() + n, cend());
- std::fill(begin(), end(), val);
- }
- }
-
- template <class Integer>
- void priv_initialize_dispatch(Integer n, Integer x, container_detail::true_)
- {
- this->priv_initialize_map(n);
- this->priv_fill_initialize(x);
- }
-
- template <class InpIt>
- void priv_initialize_dispatch(InpIt first, InpIt last, container_detail::false_)
- {
- typedef typename std::iterator_traits<InpIt>::iterator_category ItCat;
- this->priv_range_initialize(first, last, ItCat());
- }
-
    void priv_destroy_range(iterator p, iterator p2)
    {
       for(;p != p2; ++p){
@@ -1662,71 +1710,10 @@
       }
    }
 
- template <class Integer>
- void priv_assign_dispatch(Integer n, Integer val, container_detail::true_)
- { this->priv_fill_assign((size_type) n, (value_type)val); }
-
- template <class InpIt>
- void priv_assign_dispatch(InpIt first, InpIt last, container_detail::false_)
- {
- typedef typename std::iterator_traits<InpIt>::iterator_category ItCat;
- this->priv_assign_aux(first, last, ItCat());
- }
-
- template <class InpIt>
- void priv_assign_aux(InpIt first, InpIt last, std::input_iterator_tag)
- {
- iterator cur = begin();
- for ( ; first != last && cur != end(); ++cur, ++first)
- *cur = *first;
- if (first == last)
- this->erase(cur, cend());
- else
- this->insert(cend(), first, last);
- }
-
- template <class FwdIt>
- void priv_assign_aux(FwdIt first, FwdIt last, std::forward_iterator_tag)
- {
- size_type len = std::distance(first, last);
- if (len > size()) {
- FwdIt mid = first;
- std::advance(mid, size());
- boost::copy_or_move(first, mid, begin());
- this->insert(cend(), mid, last);
- }
- else
- this->erase(boost::copy_or_move(first, last, begin()), cend());
- }
-
- template <class Integer>
- void priv_insert_dispatch(const_iterator pos, Integer n, Integer x, container_detail::true_)
- { this->priv_fill_insert(pos, (size_type) n, (value_type)x); }
-
- template <class InpIt>
- void priv_insert_dispatch(const_iterator pos,InpIt first, InpIt last, container_detail::false_)
- {
- typedef typename std::iterator_traits<InpIt>::iterator_category ItCat;
- this->priv_insert_aux(pos, first, last, ItCat());
- }
-
- void priv_insert_aux(const_iterator pos, size_type n, const value_type& x)
- {
- typedef constant_iterator<value_type, difference_type> c_it;
- this->priv_insert_aux(pos, c_it(x, n), c_it());
- }
-
- //Just forward all operations to priv_insert_aux_impl
- template <class FwdIt>
- void priv_insert_aux(const_iterator p, FwdIt first, FwdIt last)
- {
- container_detail::advanced_insert_aux_proxy<A, FwdIt, iterator> proxy(this->alloc(), first, last);
- priv_insert_aux_impl(p, (size_type)std::distance(first, last), proxy);
- }
-
- void priv_insert_aux_impl(const_iterator p, size_type n, advanced_insert_aux_int_t &interf)
+ iterator priv_insert_aux_impl(const_iterator p, size_type n, advanced_insert_aux_int_t &interf)
    {
       iterator pos(p);
+ const size_type pos_n = p - this->cbegin();
       if(!this->members_.m_map){
          this->priv_initialize_map(0);
          pos = this->begin();
@@ -1780,9 +1767,10 @@
             interf.copy_remaining_to(pos);
          }
       }
+ return this->begin() + pos_n;
    }
 
- void priv_insert_back_aux_impl(size_type n, advanced_insert_aux_int_t &interf)
+ iterator priv_insert_back_aux_impl(size_type n, advanced_insert_aux_int_t &interf)
    {
       if(!this->members_.m_map){
          this->priv_initialize_map(0);
@@ -1792,9 +1780,10 @@
       iterator old_finish = this->members_.m_finish;
       interf.uninitialized_copy_some_and_update(old_finish, n, true);
       this->members_.m_finish = new_finish;
+ return iterator(this->members_.m_finish - n);
    }
 
- void priv_insert_front_aux_impl(size_type n, advanced_insert_aux_int_t &interf)
+ iterator priv_insert_front_aux_impl(size_type n, advanced_insert_aux_int_t &interf)
    {
       if(!this->members_.m_map){
          this->priv_initialize_map(0);
@@ -1803,13 +1792,13 @@
       iterator new_start = this->priv_reserve_elements_at_front(n);
       interf.uninitialized_copy_some_and_update(new_start, difference_type(n), true);
       this->members_.m_start = new_start;
+ return new_start;
    }
 
-
- void priv_fill_insert(const_iterator pos, size_type n, const value_type& x)
+ iterator priv_fill_insert(const_iterator pos, size_type n, const value_type& x)
    {
       typedef constant_iterator<value_type, difference_type> c_it;
- this->insert(pos, c_it(x, n), c_it());
+ return this->insert(pos, c_it(x, n), c_it());
    }
 
    // Precondition: this->members_.m_start and this->members_.m_finish have already been initialized,
@@ -1832,13 +1821,13 @@
       BOOST_CATCH_END
    }
 
- template <class InpIt>
- void priv_range_initialize(InpIt first, InpIt last, std::input_iterator_tag)
+ template <class InIt>
+ void priv_range_initialize(InIt first, InIt last, std::input_iterator_tag)
    {
       this->priv_initialize_map(0);
       BOOST_TRY {
          for ( ; first != last; ++first)
- this->push_back(*first);
+ this->emplace_back(*first);
       }
       BOOST_CATCH(...){
          this->clear();
@@ -1990,39 +1979,32 @@
 
 // Nonmember functions.
 template <class T, class A>
-inline bool operator==(const deque<T, A>& x,
- const deque<T, A>& y)
+inline bool operator==(const deque<T, A>& x, const deque<T, A>& y)
 {
    return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
 }
 
 template <class T, class A>
-inline bool operator<(const deque<T, A>& x,
- const deque<T, A>& y)
+inline bool operator<(const deque<T, A>& x, const deque<T, A>& y)
 {
    return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
 }
 
 template <class T, class A>
-inline bool operator!=(const deque<T, A>& x,
- const deque<T, A>& y)
+inline bool operator!=(const deque<T, A>& x, const deque<T, A>& y)
    { return !(x == y); }
 
 template <class T, class A>
-inline bool operator>(const deque<T, A>& x,
- const deque<T, A>& y)
+inline bool operator>(const deque<T, A>& x, const deque<T, A>& y)
    { return y < x; }
 
 template <class T, class A>
-inline bool operator<=(const deque<T, A>& x,
- const deque<T, A>& y)
- { return !(y < x); }
-
-template <class T, class A>
-inline bool operator>=(const deque<T, A>& x,
- const deque<T, A>& y)
+inline bool operator>=(const deque<T, A>& x, const deque<T, A>& y)
    { return !(x < y); }
 
+template <class T, class A>
+inline bool operator<=(const deque<T, A>& x, const deque<T, A>& y)
+ { return !(y < x); }
 
 template <class T, class A>
 inline void swap(deque<T, A>& x, deque<T, A>& y)

Modified: branches/release/boost/container/detail/adaptive_node_pool_impl.hpp
==============================================================================
--- branches/release/boost/container/detail/adaptive_node_pool_impl.hpp (original)
+++ branches/release/boost/container/detail/adaptive_node_pool_impl.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -348,8 +348,7 @@
    {
       block_iterator block_it(m_block_multiset.end());
       while(n--){
- void *pElem = container_detail::to_raw_pointer(chain.front());
- chain.pop_front();
+ void *pElem = container_detail::to_raw_pointer(chain.pop_front());
          priv_invariants();
          block_info_t *block_info = this->priv_block_from_node(pElem);
          BOOST_ASSERT(block_info->free_nodes.size() < m_real_num_node);

Modified: branches/release/boost/container/detail/advanced_insert_int.hpp
==============================================================================
--- branches/release/boost/container/detail/advanced_insert_int.hpp (original)
+++ branches/release/boost/container/detail/advanced_insert_int.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -173,7 +173,6 @@
 #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
 #include <boost/container/detail/variadic_templates_tools.hpp>
-#include <boost/container/detail/stored_ref.hpp>
 #include <boost/move/move.hpp>
 #include <typeinfo>
 //#include <iostream> //For debugging purposes
@@ -227,8 +226,7 @@
          if(!this->used_){
             alloc_traits::construct( this->a_
                                    , container_detail::to_raw_pointer(&*p)
- , ::boost::container::container_detail::
- stored_ref<Args>::forward(get<IdxPack>(this->args_))...
+ , ::boost::forward<Args>(get<IdxPack>(this->args_))...
                                    );
             this->used_ = true;
          }
@@ -241,8 +239,7 @@
       if(!this->used_){
          alloc_traits::construct( this->a_
                                 , container_detail::to_raw_pointer(&*p)
- , ::boost::container::container_detail::
- stored_ref<Args>::forward(get<IdxPack>(this->args_))...
+ , ::boost::forward<Args>(get<IdxPack>(this->args_))...
                                 );
          this->used_ = true;
       }
@@ -288,7 +285,7 @@
          aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v;
          value_type *vp = static_cast<value_type *>(static_cast<void *>(&v));
          alloc_traits::construct(this->a_, vp,
- ::boost::container::container_detail::stored_ref<Args>::forward(get<IdxPack>(this->args_))...);
+ ::boost::forward<Args>(get<IdxPack>(this->args_))...);
          scoped_destructor<A> d(this->a_, vp);
          *p = ::boost::move(*vp);
          d.release();
@@ -305,7 +302,7 @@
             aligned_storage<sizeof(value_type), alignment_of<value_type>::value> v;
             value_type *vp = static_cast<value_type *>(static_cast<void *>(&v));
             alloc_traits::construct(this->a_, vp,
- ::boost::container::container_detail::stored_ref<Args>::forward(get<IdxPack>(this->args_))...);
+ ::boost::forward<Args>(get<IdxPack>(this->args_))...);
             try {
                *p = ::boost::move(*vp);
             } catch (...) {
@@ -413,7 +410,7 @@
          alloc_traits::construct(this->a_, vp \
             BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)); \
          scoped_destructor<A> d(this->a_, vp); \
- *p = ::boost::move(*vp); \
+ *p = ::boost::move(*vp); \
          d.release(); \
          this->used_ = true; \
       } \
@@ -430,7 +427,7 @@
             alloc_traits::construct(this->a_, vp \
                BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)); \
             scoped_destructor<A> d(this->a_, vp); \
- *p = ::boost::move(*vp); \
+ *p = ::boost::move(*vp); \
             d.release(); \
             this->used_ = true; \
          } \

Modified: branches/release/boost/container/detail/algorithms.hpp
==============================================================================
--- branches/release/boost/container/detail/algorithms.hpp (original)
+++ branches/release/boost/container/detail/algorithms.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -34,6 +34,30 @@
 namespace boost {
 namespace container {
 
+template<class It>
+struct is_default_construct_iterator
+{
+ static const bool value = false;
+};
+
+template<class U, class D>
+struct is_default_construct_iterator<default_construct_iterator<U, D> >
+{
+ static const bool value = true;
+};
+
+template<class It>
+struct is_emplace_iterator
+{
+ static const bool value = false;
+};
+
+template<class U, class EF, class D>
+struct is_emplace_iterator<emplace_iterator<U, EF, D> >
+{
+ static const bool value = true;
+};
+
 template<class A, class T, class InpIt>
 inline void construct_in_place(A &a, T* dest, InpIt source)
 { boost::container::allocator_traits<A>::construct(a, dest, *source); }

Modified: branches/release/boost/container/detail/destroyers.hpp
==============================================================================
--- branches/release/boost/container/detail/destroyers.hpp (original)
+++ branches/release/boost/container/detail/destroyers.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -28,6 +28,68 @@
 namespace container_detail {
 
 //!A deleter for scoped_ptr that deallocates the memory
+//!allocated for an object using a STL allocator.
+template <class A>
+struct scoped_deallocator
+{
+ typedef allocator_traits<A> allocator_traits_type;
+ typedef typename allocator_traits_type::pointer pointer;
+ typedef container_detail::integral_constant<unsigned,
+ boost::container::container_detail::
+ version<A>::value> alloc_version;
+ typedef container_detail::integral_constant<unsigned, 1> allocator_v1;
+ typedef container_detail::integral_constant<unsigned, 2> allocator_v2;
+
+ private:
+ void priv_deallocate(allocator_v1)
+ { m_alloc.deallocate(m_ptr, 1); }
+
+ void priv_deallocate(allocator_v2)
+ { m_alloc.deallocate_one(m_ptr); }
+
+ BOOST_MOVABLE_BUT_NOT_COPYABLE(scoped_deallocator)
+
+ public:
+
+ pointer m_ptr;
+ A& m_alloc;
+
+ scoped_deallocator(pointer p, A& a)
+ : m_ptr(p), m_alloc(a)
+ {}
+
+ ~scoped_deallocator()
+ { if (m_ptr)priv_deallocate(alloc_version()); }
+
+ scoped_deallocator(BOOST_RV_REF(scoped_deallocator) o)
+ : m_ptr(o.m_ptr), m_alloc(o.m_alloc)
+ { o.release(); }
+
+ pointer get() const
+ { return m_ptr; }
+
+ void release()
+ { m_ptr = 0; }
+};
+
+template <class Allocator>
+struct null_scoped_deallocator
+{
+ typedef boost::container::allocator_traits<Allocator> AllocTraits;
+ typedef typename AllocTraits::pointer pointer;
+ typedef typename AllocTraits::size_type size_type;
+
+ null_scoped_deallocator(pointer, Allocator&, size_type)
+ {}
+
+ void release()
+ {}
+
+ pointer get() const
+ { return pointer(); }
+};
+
+//!A deleter for scoped_ptr that deallocates the memory
 //!allocated for an array of objects using a STL allocator.
 template <class Allocator>
 struct scoped_array_deallocator
@@ -239,10 +301,57 @@
    void operator()(const pointer &p)
    {
       AllocTraits::destroy(a_, container_detail::to_raw_pointer(p));
- priv_deallocate(p, alloc_version());
+ this->priv_deallocate(p, alloc_version());
    }
 };
 
+template <class A>
+class allocator_destroyer_and_chain_builder
+{
+ typedef allocator_traits<A> allocator_traits_type;
+ typedef typename allocator_traits_type::value_type value_type;
+ typedef typename A::multiallocation_chain multiallocation_chain;
+
+ A & a_;
+ multiallocation_chain &c_;
+
+ public:
+ allocator_destroyer_and_chain_builder(A &a, multiallocation_chain &c)
+ : a_(a), c_(c)
+ {}
+
+ void operator()(const typename A::pointer &p)
+ {
+ allocator_traits<A>::destroy(a_, container_detail::to_raw_pointer(p));
+ c_.push_front(p);
+ }
+};
+
+template <class A>
+class allocator_multialloc_chain_node_deallocator
+{
+ typedef allocator_traits<A> allocator_traits_type;
+ typedef typename allocator_traits_type::value_type value_type;
+ typedef typename A::multiallocation_chain multiallocation_chain;
+ typedef allocator_destroyer_and_chain_builder<A> chain_builder;
+
+ A & a_;
+ multiallocation_chain c_;
+
+ public:
+ allocator_multialloc_chain_node_deallocator(A &a)
+ : a_(a), c_()
+ {}
+
+ chain_builder get_chain_builder()
+ { return chain_builder(a_, c_); }
+
+ ~allocator_multialloc_chain_node_deallocator()
+ {
+ if(!c_.empty())
+ a_.deallocate_individual(boost::move(c_));
+ }
+};
 
 } //namespace container_detail {
 } //namespace container {

Modified: branches/release/boost/container/detail/flat_tree.hpp
==============================================================================
--- branches/release/boost/container/detail/flat_tree.hpp (original)
+++ branches/release/boost/container/detail/flat_tree.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -214,6 +214,21 @@
       : m_data(comp, a)
    { this->m_data.m_vect.insert(this->m_data.m_vect.end(), first, last); }
 
+ template <class InputIterator>
+ flat_tree( bool unique_insertion
+ , InputIterator first, InputIterator last
+ , const Compare& comp = Compare()
+ , const allocator_type& a = allocator_type())
+ : m_data(comp, a)
+ {
+ if(unique_insertion){
+ this->insert_unique(first, last);
+ }
+ else{
+ this->insert_equal(first, last);
+ }
+ }
+
    ~flat_tree()
    { }
 
@@ -290,9 +305,9 @@
    std::pair<iterator,bool> insert_unique(const value_type& val)
    {
       insert_commit_data data;
- std::pair<iterator,bool> ret = priv_insert_unique_prepare(val, data);
+ std::pair<iterator,bool> ret = this->priv_insert_unique_prepare(val, data);
       if(ret.second){
- ret.first = priv_insert_commit(data, val);
+ ret.first = this->priv_insert_commit(data, val);
       }
       return ret;
    }
@@ -300,9 +315,9 @@
    std::pair<iterator,bool> insert_unique(BOOST_RV_REF(value_type) val)
    {
       insert_commit_data data;
- std::pair<iterator,bool> ret = priv_insert_unique_prepare(val, data);
+ std::pair<iterator,bool> ret = this->priv_insert_unique_prepare(val, data);
       if(ret.second){
- ret.first = priv_insert_commit(data, boost::move(val));
+ ret.first = this->priv_insert_commit(data, boost::move(val));
       }
       return ret;
    }
@@ -324,9 +339,9 @@
    iterator insert_unique(const_iterator pos, const value_type& val)
    {
       insert_commit_data data;
- std::pair<iterator,bool> ret = priv_insert_unique_prepare(pos, val, data);
+ std::pair<iterator,bool> ret = this->priv_insert_unique_prepare(pos, val, data);
       if(ret.second){
- ret.first = priv_insert_commit(data, val);
+ ret.first = this->priv_insert_commit(data, val);
       }
       return ret.first;
    }
@@ -334,9 +349,9 @@
    iterator insert_unique(const_iterator pos, BOOST_RV_REF(value_type) mval)
    {
       insert_commit_data data;
- std::pair<iterator,bool> ret = priv_insert_unique_prepare(pos, mval, data);
+ std::pair<iterator,bool> ret = this->priv_insert_unique_prepare(pos, mval, data);
       if(ret.second){
- ret.first = priv_insert_commit(data, boost::move(mval));
+ ret.first = this->priv_insert_commit(data, boost::move(mval));
       }
       return ret.first;
    }
@@ -345,45 +360,164 @@
    {
       insert_commit_data data;
       this->priv_insert_equal_prepare(pos, val, data);
- return priv_insert_commit(data, val);
+ return this->priv_insert_commit(data, val);
    }
 
    iterator insert_equal(const_iterator pos, BOOST_RV_REF(value_type) mval)
    {
       insert_commit_data data;
       this->priv_insert_equal_prepare(pos, mval, data);
- return priv_insert_commit(data, boost::move(mval));
+ return this->priv_insert_commit(data, boost::move(mval));
    }
 
    template <class InIt>
    void insert_unique(InIt first, InIt last)
+ { this->priv_insert_unique_loop(first, last); }
+
+ template <class InIt>
+ void insert_equal(InIt first, InIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < container_detail::is_input_iterator<InIt>::value
+ >::type * = 0
+ #endif
+ )
+ { this->priv_insert_equal_loop(first, last); }
+
+ template <class InIt>
+ void insert_equal(InIt first, InIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_input_iterator<InIt>::value
+ >::type * = 0
+ #endif
+ )
    {
- for ( ; first != last; ++first)
- this->insert_unique(*first);
+ const size_type len = static_cast<size_type>(std::distance(first, last));
+ this->reserve(this->size()+len);
+ this->priv_insert_equal_loop(first, last);
    }
 
+ //Ordered
+
    template <class InIt>
- void insert_equal(InIt first, InIt last)
+ void insert_equal(ordered_range_t, InIt first, InIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < container_detail::is_input_iterator<InIt>::value
+ >::type * = 0
+ #endif
+ )
+ { this->priv_insert_equal_loop_ordered(first, last); }
+
+ template <class FwdIt>
+ void insert_equal(ordered_range_t, FwdIt first, FwdIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < container_detail::is_forward_iterator<FwdIt>::value
+ >::type * = 0
+ #endif
+ )
    {
- typedef typename
- std::iterator_traits<InIt>::iterator_category ItCat;
- this->priv_insert_equal(first, last, ItCat());
+ const size_type len = static_cast<size_type>(std::distance(first, last));
+ this->reserve(this->size()+len);
+ this->priv_insert_equal_loop_ordered(first, last);
    }
 
- template <class InIt>
- void insert_equal(ordered_range_t, InIt first, InIt last)
+ template <class BidirIt>
+ void insert_equal(ordered_range_t, BidirIt first, BidirIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_input_iterator<BidirIt>::value &&
+ !container_detail::is_forward_iterator<BidirIt>::value
+ >::type * = 0
+ #endif
+ )
    {
- typedef typename
- std::iterator_traits<InIt>::iterator_category ItCat;
- this->priv_insert_equal(ordered_range_t(), first, last, ItCat());
+ size_type len = static_cast<size_type>(std::distance(first, last));
+ const size_type BurstSize = 16;
+ size_type positions[BurstSize];
+
+ //Prereserve all memory so that iterators are not invalidated
+ this->reserve(this->size()+len);
+ const const_iterator beg(this->cbegin());
+ const_iterator pos(beg);
+ //Loop in burst sizes
+ while(len){
+ const size_type burst = len < BurstSize ? len : BurstSize;
+ const const_iterator cend(this->cend());
+ len -= burst;
+ for(size_type i = 0; i != burst; ++i){
+ //Get the insertion position for each key
+ pos = const_cast<const flat_tree&>(*this).priv_upper_bound(pos, cend, KeyOfValue()(*first));
+ positions[i] = static_cast<size_type>(pos - beg);
+ ++first;
+ }
+ //Insert all in a single step in the precalculated positions
+ this->m_data.m_vect.insert_ordered_at(burst, positions + burst, first);
+ //Next search position updated
+ pos += burst;
+ }
    }
 
    template <class InIt>
- void insert_unique(ordered_unique_range_t, InIt first, InIt last)
+ void insert_unique(ordered_unique_range_t, InIt first, InIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < container_detail::is_input_iterator<InIt>::value ||
+ container_detail::is_forward_iterator<InIt>::value
+ >::type * = 0
+ #endif
+ )
+ { this->priv_insert_unique_loop_hint(first, last); }
+
+ template <class BidirIt>
+ void insert_unique(ordered_unique_range_t, BidirIt first, BidirIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !(container_detail::is_input_iterator<BidirIt>::value ||
+ container_detail::is_forward_iterator<BidirIt>::value)
+ >::type * = 0
+ #endif
+ )
    {
- typedef typename
- std::iterator_traits<InIt>::iterator_category ItCat;
- this->priv_insert_unique(ordered_unique_range_t(), first, last, ItCat());
+ size_type len = static_cast<size_type>(std::distance(first, last));
+ const size_type BurstSize = 16;
+ size_type positions[BurstSize];
+ size_type skips[BurstSize];
+
+ //Prereserve all memory so that iterators are not invalidated
+ this->reserve(this->size()+len);
+ const const_iterator beg(this->cbegin());
+ const_iterator pos(beg);
+ const value_compare &value_comp = this->m_data;
+ //Loop in burst sizes
+ while(len){
+ skips[0u] = 0u;
+ const size_type burst = len < BurstSize ? len : BurstSize;
+ size_type unique_burst = 0u;
+ const const_iterator cend(this->cend());
+ while(unique_burst < burst && len > 0){
+ //Get the insertion position for each key
+ const value_type & val = *first++;
+ --len;
+ pos = const_cast<const flat_tree&>(*this).priv_lower_bound(pos, cend, KeyOfValue()(val));
+ //Check if already present
+ if(pos != cend && !value_comp(*pos, val)){
+ ++skips[unique_burst];
+ continue;
+ }
+
+ //If not present, calculate position
+ positions[unique_burst] = static_cast<size_type>(pos - beg);
+ if(++unique_burst < burst)
+ skips[unique_burst] = 0u;
+ }
+ //Insert all in a single step in the precalculated positions
+ this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
+ //Next search position updated
+ pos += unique_burst;
+ }
    }
 
    #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
@@ -398,9 +532,9 @@
       value_destructor<stored_allocator_type> d(a, val);
       insert_commit_data data;
       std::pair<iterator,bool> ret =
- priv_insert_unique_prepare(val, data);
+ this->priv_insert_unique_prepare(val, data);
       if(ret.second){
- ret.first = priv_insert_commit(data, boost::move(val));
+ ret.first = this->priv_insert_commit(data, boost::move(val));
       }
       return ret;
    }
@@ -414,9 +548,9 @@
       stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
       value_destructor<stored_allocator_type> d(a, val);
       insert_commit_data data;
- std::pair<iterator,bool> ret = priv_insert_unique_prepare(hint, val, data);
+ std::pair<iterator,bool> ret = this->priv_insert_unique_prepare(hint, val, data);
       if(ret.second){
- ret.first = priv_insert_commit(data, boost::move(val));
+ ret.first = this->priv_insert_commit(data, boost::move(val));
       }
       return ret.first;
    }
@@ -444,7 +578,7 @@
       value_destructor<stored_allocator_type> d(a, val);
       insert_commit_data data;
       this->priv_insert_equal_prepare(hint, val, data);
- iterator i = priv_insert_commit(data, boost::move(val));
+ iterator i = this->priv_insert_commit(data, boost::move(val));
       return i;
    }
 
@@ -462,9 +596,9 @@
          BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \
       value_destructor<stored_allocator_type> d(a, val); \
       insert_commit_data data; \
- std::pair<iterator,bool> ret = priv_insert_unique_prepare(val, data); \
+ std::pair<iterator,bool> ret = this->priv_insert_unique_prepare(val, data); \
       if(ret.second){ \
- ret.first = priv_insert_commit(data, boost::move(val)); \
+ ret.first = this->priv_insert_commit(data, boost::move(val)); \
       } \
       return ret; \
    } \
@@ -480,9 +614,9 @@
          BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \
       value_destructor<stored_allocator_type> d(a, val); \
       insert_commit_data data; \
- std::pair<iterator,bool> ret = priv_insert_unique_prepare(hint, val, data); \
+ std::pair<iterator,bool> ret = this->priv_insert_unique_prepare(hint, val, data); \
       if(ret.second){ \
- ret.first = priv_insert_commit(data, boost::move(val)); \
+ ret.first = this->priv_insert_commit(data, boost::move(val)); \
       } \
       return ret.first; \
    } \
@@ -513,7 +647,7 @@
       value_destructor<stored_allocator_type> d(a, val); \
       insert_commit_data data; \
       this->priv_insert_equal_prepare(hint, val, data); \
- iterator i = priv_insert_commit(data, boost::move(val)); \
+ iterator i = this->priv_insert_commit(data, boost::move(val)); \
       return i; \
    } \
 
@@ -653,7 +787,7 @@
 
    std::pair<iterator,bool> priv_insert_unique_prepare
       (const value_type& val, insert_commit_data &commit_data)
- { return priv_insert_unique_prepare(this->begin(), this->end(), val, commit_data); }
+ { return this->priv_insert_unique_prepare(this->begin(), this->end(), val, commit_data); }
 
    std::pair<iterator,bool> priv_insert_unique_prepare
       (const_iterator pos, const value_type& val, insert_commit_data &commit_data)
@@ -794,102 +928,38 @@
       return std::pair<RanIt, RanIt>(first, first);
    }
 
- template <class BidirIt>
- void priv_insert_equal(ordered_range_t, BidirIt first, BidirIt last, std::bidirectional_iterator_tag)
+ template<class InIt>
+ void priv_insert_equal_loop(InIt first, InIt last)
    {
- size_type len = static_cast<size_type>(std::distance(first, last));
- const size_type BurstSize = 16;
- size_type positions[BurstSize];
-
- //Prereserve all memory so that iterators are not invalidated
- this->reserve(this->size()+len);
- const const_iterator beg(this->cbegin());
- const_iterator pos(beg);
- //Loop in burst sizes
- while(len){
- const size_type burst = len < BurstSize ? len : BurstSize;
- const const_iterator cend(this->cend());
- len -= burst;
- for(size_type i = 0; i != burst; ++i){
- //Get the insertion position for each key
- pos = const_cast<const flat_tree&>(*this).priv_upper_bound(pos, cend, KeyOfValue()(*first));
- positions[i] = static_cast<size_type>(pos - beg);
- ++first;
- }
- //Insert all in a single step in the precalculated positions
- this->m_data.m_vect.insert_ordered_at(burst, positions + burst, first);
- //Next search position updated
- pos += burst;
+ for ( ; first != last; ++first){
+ this->insert_equal(*first);
       }
    }
 
- template <class BidirIt>
- void priv_insert_unique(ordered_unique_range_t, BidirIt first, BidirIt last, std::bidirectional_iterator_tag)
+ template<class InIt>
+ void priv_insert_equal_loop_ordered(InIt first, InIt last)
    {
- size_type len = static_cast<size_type>(std::distance(first, last));
- const size_type BurstSize = 16;
- size_type positions[BurstSize];
- size_type skips[BurstSize];
-
- //Prereserve all memory so that iterators are not invalidated
- this->reserve(this->size()+len);
- const const_iterator beg(this->cbegin());
- const_iterator pos(beg);
- const value_compare &value_comp = this->m_data;
- //Loop in burst sizes
- while(len){
- skips[0u] = 0u;
- const size_type burst = len < BurstSize ? len : BurstSize;
- size_type unique_burst = 0u;
- const const_iterator cend(this->cend());
- while(unique_burst < burst && len > 0){
- //Get the insertion position for each key
- const value_type & val = *first++;
- --len;
- pos = const_cast<const flat_tree&>(*this).priv_lower_bound(pos, cend, KeyOfValue()(val));
- //Check if already present
- if(pos != cend && !value_comp(*pos, val)){
- ++skips[unique_burst];
- continue;
- }
-
- //If not present, calculate position
- positions[unique_burst] = static_cast<size_type>(pos - beg);
- if(++unique_burst < burst)
- skips[unique_burst] = 0u;
- }
- //Insert all in a single step in the precalculated positions
- this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
- //Next search position updated
- pos += unique_burst;
+ const_iterator pos(this->cend());
+ for ( ; first != last; ++first){
+ pos = this->insert_equal(pos, *first);
       }
    }
-/*
- template <class FwdIt>
- void priv_insert_equal_forward(ordered_range_t, FwdIt first, FwdIt last, std::forward_iterator_tag)
- { this->priv_insert_equal(first, last, std::forward_iterator_tag()); }
-*/
- template <class InIt>
- void priv_insert_equal(ordered_range_t, InIt first, InIt last, std::input_iterator_tag)
- { this->priv_insert_equal(first, last, std::input_iterator_tag()); }
 
- template <class InIt>
- void priv_insert_unique(ordered_unique_range_t, InIt first, InIt last, std::input_iterator_tag)
- { this->priv_insert_unique(first, last, std::input_iterator_tag()); }
-/*
- template <class FwdIt>
- void priv_insert_equal_forward(FwdIt first, FwdIt last, std::forward_iterator_tag)
+ template<class InIt>
+ void priv_insert_unique_loop(InIt first, InIt last)
    {
- const size_type len = static_cast<size_type>(std::distance(first, last));
- this->reserve(this->size()+len);
- this->priv_insert_equal(first, last, std::input_iterator_tag());
+ for ( ; first != last; ++first){
+ this->insert_unique(*first);
+ }
    }
-*/
- template <class InIt>
- void priv_insert_equal(InIt first, InIt last, std::input_iterator_tag)
+
+ template<class InIt>
+ void priv_insert_unique_loop_ordered(InIt first, InIt last)
    {
- for ( ; first != last; ++first)
- this->insert_equal(*first);
+ const_iterator pos(this->cend());
+ for ( ; first != last; ++first){
+ pos = this->insert_unique(pos, *first);
+ }
    }
 };
 

Modified: branches/release/boost/container/detail/iterators.hpp
==============================================================================
--- branches/release/boost/container/detail/iterators.hpp (original)
+++ branches/release/boost/container/detail/iterators.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -22,10 +22,10 @@
 #include <boost/container/detail/workaround.hpp>
 #include <boost/move/move.hpp>
 #include <boost/container/allocator_traits.hpp>
+#include <boost/container/detail/type_traits.hpp>
 
 #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 #include <boost/container/detail/variadic_templates_tools.hpp>
-#include <boost/container/detail/stored_ref.hpp>
 #else
 #include <boost/container/detail/preprocessor.hpp>
 #endif
@@ -222,14 +222,12 @@
    default_construct_iterator operator-(Difference off) const
    { return *this + (-off); }
 
- const T& operator*() const
- { return dereference(); }
-
- const T* operator->() const
- { return &(dereference()); }
-
- const T& operator[] (Difference n) const
- { return dereference(); }
+ //This pseudo-iterator's dereference operations have no sense since value is not
+ //constructed until ::boost::container::construct_in_place is called.
+ //So comment them to catch bad uses
+ //const T& operator*() const;
+ //const T& operator[](difference_type) const;
+ //const T* operator->() const;
 
    private:
    Difference m_num;
@@ -445,14 +443,12 @@
    this_type operator-(difference_type off) const
    { return *this + (-off); }
 
- const T& operator*() const
- { return dereference(); }
-
- const T& operator[](difference_type) const
- { return dereference(); }
-
- const T* operator->() const
- { return &(dereference()); }
+ //This pseudo-iterator's dereference operations have no sense since value is not
+ //constructed until ::boost::container::construct_in_place is called.
+ //So comment them to catch bad uses
+ //const T& operator*() const;
+ //const T& operator[](difference_type) const;
+ //const T* operator->() const;
 
    template<class A>
    void construct_in_place(A &a, T* ptr)
@@ -506,8 +502,7 @@
    void inplace_impl(A &a, T* ptr, const container_detail::index_tuple<IdxPack...>&)
    {
       allocator_traits<A>::construct
- (a, ptr, container_detail::stored_ref<Args>::forward
- (container_detail::get<IdxPack>(args_))...);
+ (a, ptr, ::boost::forward<Args>(container_detail::get<IdxPack>(args_))...);
    }
 
    container_detail::tuple<Args&...> args_;
@@ -539,10 +534,78 @@
 
 #endif
 
+namespace container_detail {
+
+template<class T>
+struct has_iterator_category
+{
+ template <typename X>
+ static char test(int, typename X::iterator_category*);
+
+ template <typename X>
+ static int test(int, ...);
+
+ static const bool value = (1 == sizeof(test<T>(0, 0)));
+};
+
+
+template<class T, bool = has_iterator_category<T>::value >
+struct is_input_iterator
+{
+ static const bool value = is_same<typename T::iterator_category, std::input_iterator_tag>::value;
+};
+
+template<class T>
+struct is_input_iterator<T, false>
+{
+ static const bool value = false;
+};
+
+template<class T, bool = has_iterator_category<T>::value >
+struct is_forward_iterator
+{
+ static const bool value = is_same<typename T::iterator_category, std::forward_iterator_tag>::value;
+};
+
+template<class T>
+struct is_forward_iterator<T, false>
+{
+ static const bool value = false;
+};
+
+template<class T, bool = has_iterator_category<T>::value >
+struct is_bidirectional_iterator
+{
+ static const bool value = is_same<typename T::iterator_category, std::bidirectional_iterator_tag>::value;
+};
+
+template<class T>
+struct is_bidirectional_iterator<T, false>
+{
+ static const bool value = false;
+};
+
+template<class T, class IIterator>
+struct iiterator_types
+{
+ typedef typename std::iterator_traits<IIterator>::pointer it_pointer;
+ typedef typename std::iterator_traits<IIterator>::difference_type difference_type;
+ typedef typename ::boost::intrusive::pointer_traits<it_pointer>::
+ template rebind_pointer<T>::type pointer;
+ typedef typename ::boost::intrusive::pointer_traits<it_pointer>::
+ template rebind_pointer<const T>::type const_pointer;
+ typedef typename ::boost::intrusive::
+ pointer_traits<pointer>::reference reference;
+ typedef typename ::boost::intrusive::
+ pointer_traits<const_pointer>::reference const_reference;
+};
+
+
+} //namespace container_detail {
+
 } //namespace container {
 } //namespace boost {
 
 #include <boost/container/detail/config_end.hpp>
 
 #endif //#ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP
-

Modified: branches/release/boost/container/detail/multiallocation_chain.hpp
==============================================================================
--- branches/release/boost/container/detail/multiallocation_chain.hpp (original)
+++ branches/release/boost/container/detail/multiallocation_chain.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -45,14 +45,30 @@
> slist_impl_t;
    slist_impl_t slist_impl_;
 
- static node & to_node(VoidPointer p)
- { return *static_cast<node*>(static_cast<void*>(container_detail::to_raw_pointer(p))); }
+ typedef typename boost::intrusive::pointer_traits
+ <VoidPointer>::template rebind_pointer<node>::type node_ptr;
+ typedef typename boost::intrusive::
+ pointer_traits<node_ptr> node_ptr_traits;
+
+ static node & build_node(const VoidPointer &p)
+ {
+ return *::new (static_cast<node*>(static_cast<void*>(container_detail::to_raw_pointer(p)))) node;
+ }
+
+ static VoidPointer destroy_node(node &n)
+ {
+ VoidPointer retptr = node_ptr_traits::pointer_to(n);
+ n.~node();
+ return retptr;
+ }
+
+ static node_ptr to_node_ptr(VoidPointer p)
+ { return node_ptr_traits::static_cast_from(p); }
 
    BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_multiallocation_chain)
 
    public:
 
-
    typedef VoidPointer void_pointer;
    typedef typename slist_impl_t::iterator iterator;
    typedef typename slist_impl_t::size_type size_type;
@@ -94,19 +110,21 @@
    { slist_impl_.clear(); }
 
    iterator insert_after(iterator it, void_pointer m)
- { return slist_impl_.insert_after(it, to_node(m)); }
+ { return slist_impl_.insert_after(it, build_node(m)); }
 
    void push_front(void_pointer m)
- { return slist_impl_.push_front(to_node(m)); }
+ { return slist_impl_.push_front(build_node(m)); }
 
    void push_back(void_pointer m)
- { return slist_impl_.push_back(to_node(m)); }
+ { return slist_impl_.push_back(build_node(m)); }
 
- void pop_front()
- { return slist_impl_.pop_front(); }
-
- void *front()
- { return &*slist_impl_.begin(); }
+ void_pointer pop_front()
+ {
+ node & n = slist_impl_.front();
+ void_pointer ret = destroy_node(n);
+ slist_impl_.pop_front();
+ return ret;
+ }
 
    void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_begin, iterator before_end)
    { slist_impl_.splice_after(after_this, x.slist_impl_, before_begin, before_end); }
@@ -118,10 +136,12 @@
    { slist_impl_.splice_after(after_this, x.slist_impl_); }
 
    void incorporate_after(iterator after_this, void_pointer begin , iterator before_end)
- { slist_impl_.incorporate_after(after_this, &to_node(begin), &to_node(before_end)); }
+ {
+ slist_impl_.incorporate_after(after_this, to_node_ptr(begin), to_node_ptr(before_end));
+ }
 
    void incorporate_after(iterator after_this, void_pointer begin, void_pointer before_end, size_type n)
- { slist_impl_.incorporate_after(after_this, &to_node(begin), &to_node(before_end), n); }
+ { slist_impl_.incorporate_after(after_this, to_node_ptr(begin), to_node_ptr(before_end), n); }
 
    void swap(basic_multiallocation_chain &x)
    { slist_impl_.swap(x.slist_impl_); }
@@ -157,18 +177,20 @@
    MultiallocationChain holder_;
    typedef typename MultiallocationChain::void_pointer void_pointer;
    typedef typename boost::intrusive::pointer_traits
- <void_pointer>::template rebind_pointer<T>::type pointer;
+ <void_pointer> void_pointer_traits;
+ typedef typename void_pointer_traits::template
+ rebind_pointer<T>::type pointer;
+ typedef typename boost::intrusive::pointer_traits
+ <pointer> pointer_traits;
 
- static pointer cast(void_pointer p)
- {
- return pointer(static_cast<T*>(container_detail::to_raw_pointer(p)));
- }
+ static pointer cast(const void_pointer &p)
+ { return pointer_traits::static_cast_from(p); }
 
    public:
    typedef transform_iterator
       < typename MultiallocationChain::iterator
- , container_detail::cast_functor <T> > iterator;
- typedef typename MultiallocationChain::size_type size_type;
+ , container_detail::cast_functor <T> > iterator;
+ typedef typename MultiallocationChain::size_type size_type;
 
    transform_multiallocation_chain()
       : holder_()
@@ -198,14 +220,11 @@
    void splice_after(iterator after_this, transform_multiallocation_chain &x, iterator before_begin, iterator before_end, size_type n)
    { holder_.splice_after(after_this.base(), x.holder_, before_begin.base(), before_end.base(), n); }
 
- void incorporate_after(iterator after_this, void_pointer begin, void_pointer before_end, size_type n)
+ void incorporate_after(iterator after_this, pointer begin, pointer before_end, size_type n)
    { holder_.incorporate_after(after_this.base(), begin, before_end, n); }
 
- void pop_front()
- { holder_.pop_front(); }
-
- pointer front()
- { return cast(holder_.front()); }
+ pointer pop_front()
+ { return cast(holder_.pop_front()); }
 
    bool empty() const
    { return holder_.empty(); }
@@ -234,8 +253,11 @@
    static iterator iterator_to(pointer p)
    { return iterator(MultiallocationChain::iterator_to(p)); }
 
- std::pair<void_pointer, void_pointer> extract_data()
- { return holder_.extract_data(); }
+ std::pair<pointer, pointer> extract_data()
+ {
+ std::pair<void_pointer, void_pointer> data(holder_.extract_data());
+ return std::pair<pointer, pointer>(cast(data.first), cast(data.second));
+ }
 
    MultiallocationChain extract_multiallocation_chain()
    {

Modified: branches/release/boost/container/detail/node_alloc_holder.hpp
==============================================================================
--- branches/release/boost/container/detail/node_alloc_holder.hpp (original)
+++ branches/release/boost/container/detail/node_alloc_holder.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -43,99 +43,6 @@
 namespace container {
 namespace container_detail {
 
-//!A deleter for scoped_ptr that deallocates the memory
-//!allocated for an object using a STL allocator.
-template <class A>
-struct scoped_deallocator
-{
- typedef allocator_traits<A> allocator_traits_type;
- typedef typename allocator_traits_type::pointer pointer;
- typedef container_detail::integral_constant<unsigned,
- boost::container::container_detail::
- version<A>::value> alloc_version;
- typedef container_detail::integral_constant<unsigned, 1> allocator_v1;
- typedef container_detail::integral_constant<unsigned, 2> allocator_v2;
-
- private:
- void priv_deallocate(allocator_v1)
- { m_alloc.deallocate(m_ptr, 1); }
-
- void priv_deallocate(allocator_v2)
- { m_alloc.deallocate_one(m_ptr); }
-
- BOOST_MOVABLE_BUT_NOT_COPYABLE(scoped_deallocator)
-
- public:
-
- pointer m_ptr;
- A& m_alloc;
-
- scoped_deallocator(pointer p, A& a)
- : m_ptr(p), m_alloc(a)
- {}
-
- ~scoped_deallocator()
- { if (m_ptr)priv_deallocate(alloc_version()); }
-
- scoped_deallocator(BOOST_RV_REF(scoped_deallocator) o)
- : m_ptr(o.m_ptr), m_alloc(o.m_alloc)
- { o.release(); }
-
- pointer get() const
- { return m_ptr; }
-
- void release()
- { m_ptr = 0; }
-};
-
-template <class A>
-class allocator_destroyer_and_chain_builder
-{
- typedef allocator_traits<A> allocator_traits_type;
- typedef typename allocator_traits_type::value_type value_type;
- typedef typename A::multiallocation_chain multiallocation_chain;
-
- A & a_;
- multiallocation_chain &c_;
-
- public:
- allocator_destroyer_and_chain_builder(A &a, multiallocation_chain &c)
- : a_(a), c_(c)
- {}
-
- void operator()(const typename A::pointer &p)
- {
- allocator_traits<A>::destroy(a_, container_detail::to_raw_pointer(p));
- c_.push_front(p);
- }
-};
-
-template <class A>
-class allocator_multialloc_chain_node_deallocator
-{
- typedef allocator_traits<A> allocator_traits_type;
- typedef typename allocator_traits_type::value_type value_type;
- typedef typename A::multiallocation_chain multiallocation_chain;
- typedef allocator_destroyer_and_chain_builder<A> chain_builder;
-
- A & a_;
- multiallocation_chain c_;
-
- public:
- allocator_multialloc_chain_node_deallocator(A &a)
- : a_(a), c_()
- {}
-
- chain_builder get_chain_builder()
- { return chain_builder(a_, c_); }
-
- ~allocator_multialloc_chain_node_deallocator()
- {
- if(!c_.empty())
- a_.deallocate_individual(boost::move(c_));
- }
-};
-
 template<class ValueCompare, class Node>
 struct node_compare
    : private ValueCompare
@@ -340,8 +247,7 @@
          Node *p = 0;
          BOOST_TRY{
                for(difference_type i = 0; i < n; ++i, ++beg, --constructed){
- p = container_detail::to_raw_pointer(mem.front());
- mem.pop_front();
+ p = container_detail::to_raw_pointer(mem.pop_front());
                //This can throw
                constructed = 0;
                boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), beg);

Modified: branches/release/boost/container/detail/preprocessor.hpp
==============================================================================
--- branches/release/boost/container/detail/preprocessor.hpp (original)
+++ branches/release/boost/container/detail/preprocessor.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -16,11 +16,6 @@
 #endif
 
 #include <boost/container/detail/config_begin.hpp>
-
-#ifndef BOOST_NO_RVALUE_REFERENCES
-#include <boost/container/detail/stored_ref.hpp>
-#endif //#ifndef BOOST_NO_RVALUE_REFERENCES
-
 #include <boost/container/detail/workaround.hpp>
 
 #ifdef BOOST_CONTAINER_PERFECT_FORWARDING
@@ -78,19 +73,10 @@
 
 #ifndef BOOST_NO_RVALUE_REFERENCES
 
- #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
-
- #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
- BOOST_PP_CAT(m_p, n) (static_cast<BOOST_PP_CAT(P, n)>( BOOST_PP_CAT(p, n) )) \
-
- #else //#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
-
    #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
    BOOST_PP_CAT(m_p, n) (::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) )) \
    //!
 
- #endif //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
-
 #else //BOOST_NO_RVALUE_REFERENCES
 
    #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
@@ -102,8 +88,68 @@
 
    #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
+ namespace boost {
+ namespace container {
+ namespace container_detail {
+ template<class T>
+ struct ref_holder;
+
+ template<class T>
+ struct ref_holder<T &>
+ {
+ ref_holder(T &t)
+ : t_(t)
+ {}
+ T &t_;
+ T & get() { return t_; }
+ };
+
+ template<class T>
+ struct ref_holder<const T>
+ {
+ ref_holder(const T &t)
+ : t_(t)
+ {}
+ const T &t_;
+ const T & get() { return t_; }
+ };
+
+ template<class T>
+ struct ref_holder<const T &&>
+ {
+ ref_holder(const T &t)
+ : t_(t)
+ {}
+ const T &t_;
+ const T & get() { return t_; }
+ };
+
+ template<class T>
+ struct ref_holder
+ {
+ ref_holder(T &&t)
+ : t_(t)
+ {}
+ T &t_;
+ T && get() { return ::boost::move(t_); }
+ };
+
+ template<class T>
+ struct ref_holder<T &&>
+ {
+ ref_holder(T &&t)
+ : t(t)
+ {}
+ T &t;
+ T && get() { return ::boost::move(t_); }
+ };
+
+ } //namespace container_detail {
+ } //namespace container {
+ } //namespace boost {
+
       #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data) \
- BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \
+ ::boost::container::container_detail::ref_holder<BOOST_PP_CAT(P, n)> BOOST_PP_CAT(m_p, n); \
       //!
 
    #else //BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG
@@ -123,8 +169,7 @@
 
 #if !defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
- #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) \
- ::boost::container::container_detail::stored_ref< BOOST_PP_CAT(P, n) >::forward( BOOST_PP_CAT(this->m_p, n) ) \
+ #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) BOOST_PP_CAT(this->m_p, n).get() \
    //!
 
 #else //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)

Deleted: branches/release/boost/container/detail/stored_ref.hpp
==============================================================================
--- branches/release/boost/container/detail/stored_ref.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
+++ (empty file)
@@ -1,92 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Ion Gaztanaga 2008-2012. 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/container for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef BOOST_CONTAINER_DETAIL_STORED_REF_HPP
-#define BOOST_CONTAINER_DETAIL_STORED_REF_HPP
-
-#include "config_begin.hpp"
-#include <boost/container/detail/workaround.hpp>
-
-#ifndef BOOST_NO_RVALUE_REFERENCES
-
-namespace boost{
-namespace container{
-namespace container_detail{
-
-template<class T>
-struct stored_ref
-{
-
- static T && forward(T &t)
- #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
- { return t; }
- #else
- { return boost::move(t); }
- #endif
-};
-
-template<class T>
-struct stored_ref<const T>
-{
- static const T && forward(const T &t)
- #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
- { return t; }
- #else
- { return static_cast<const T&&>(t); }
- #endif
-};
-
-template<class T>
-struct stored_ref<T&&>
-{
- static T && forward(T &t)
- #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
- { return t; }
- #else
- { return boost::move(t); }
- #endif
-};
-
-template<class T>
-struct stored_ref<const T&&>
-{
- static const T && forward(const T &t)
- #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
- { return t; }
- #else
- { return static_cast<const T &&>(t); }
- #endif
-};
-
-template<class T>
-struct stored_ref<const T&>
-{
- static const T & forward(const T &t)
- { return t; }
-};
-
-template<class T>
-struct stored_ref<T&>
-{
- static T & forward(T &t)
- { return t; }
-};
-
-} //namespace container_detail{
-} //namespace container{
-} //namespace boost{
-
-#else
-#error "This header can be included only for compiler with rvalue references"
-#endif //BOOST_NO_RVALUE_REFERENCES
-
-#include <boost/container/detail/config_end.hpp>
-
-#endif //BOOST_CONTAINER_DETAIL_STORED_REF_HPP

Modified: branches/release/boost/container/detail/tree.hpp
==============================================================================
--- branches/release/boost/container/detail/tree.hpp (original)
+++ branches/release/boost/container/detail/tree.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -476,21 +476,77 @@
    {}
 
    template <class InputIterator>
- rbtree(InputIterator first, InputIterator last, const key_compare& comp,
- const allocator_type& a, bool unique_insertion)
+ rbtree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp,
+ const allocator_type& a
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < container_detail::is_input_iterator<InputIterator>::value
+ || container_detail::is_same<alloc_version, allocator_v1>::value
+ >::type * = 0
+ #endif
+ )
       : AllocHolder(a, comp)
    {
- typedef typename std::iterator_traits<InputIterator>::iterator_category ItCat;
- priv_create_and_insert_nodes(first, last, unique_insertion, alloc_version(), ItCat());
+ if(unique_insertion){
+ this->insert_unique(first, last);
+ }
+ else{
+ this->insert_equal(first, last);
+ }
+ }
+
+ template <class InputIterator>
+ rbtree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp,
+ const allocator_type& a
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !(container_detail::is_input_iterator<InputIterator>::value
+ || container_detail::is_same<alloc_version, allocator_v1>::value)
+ >::type * = 0
+ #endif
+ )
+ : AllocHolder(a, comp)
+ {
+ if(unique_insertion){
+ this->insert_unique(first, last);
+ }
+ else{
+ //Optimized allocation and construction
+ this->allocate_many_and_construct
+ (first, std::distance(first, last), insert_equal_end_hint_functor(this->icont()));
+ }
    }
 
    template <class InputIterator>
    rbtree( ordered_range_t, InputIterator first, InputIterator last
- , const key_compare& comp = key_compare(), const allocator_type& a = allocator_type())
+ , const key_compare& comp = key_compare(), const allocator_type& a = allocator_type()
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < container_detail::is_input_iterator<InputIterator>::value
+ || container_detail::is_same<alloc_version, allocator_v1>::value
+ >::type * = 0
+ #endif
+ )
       : AllocHolder(a, comp)
    {
- typedef typename std::iterator_traits<InputIterator>::iterator_category ItCat;
- priv_create_and_insert_ordered_nodes(first, last, alloc_version(), ItCat());
+ this->insert_equal(first, last);
+ }
+
+ template <class InputIterator>
+ rbtree( ordered_range_t, InputIterator first, InputIterator last
+ , const key_compare& comp = key_compare(), const allocator_type& a = allocator_type()
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !(container_detail::is_input_iterator<InputIterator>::value
+ || container_detail::is_same<alloc_version, allocator_v1>::value)
+ >::type * = 0
+ #endif
+ )
+ : AllocHolder(a, comp)
+ {
+ //Optimized allocation and construction
+ this->allocate_many_and_construct
+ (first, std::distance(first, last), push_back_functor(this->icont()));
    }
 
    rbtree(const rbtree& x)
@@ -943,14 +999,14 @@
    { return const_iterator(this->non_const_icont().upper_bound(k, KeyNodeCompare(value_comp()))); }
 
    std::pair<iterator,iterator> equal_range(const key_type& k)
- {
+ {
       std::pair<iiterator, iiterator> ret =
          this->icont().equal_range(k, KeyNodeCompare(value_comp()));
       return std::pair<iterator,iterator>(iterator(ret.first), iterator(ret.second));
    }
 
    std::pair<const_iterator, const_iterator> equal_range(const key_type& k) const
- {
+ {
       std::pair<iiterator, iiterator> ret =
          this->non_const_icont().equal_range(k, KeyNodeCompare(value_comp()));
       return std::pair<const_iterator,const_iterator>
@@ -958,108 +1014,39 @@
    }
 
    private:
- //Iterator range version
- template<class InpIterator>
- void priv_create_and_insert_nodes
- (InpIterator beg, InpIterator end, bool unique, allocator_v1, std::input_iterator_tag)
- {
- if(unique){
- for (; beg != end; ++beg){
- this->insert_unique(*beg);
- }
- }
- else{
- for (; beg != end; ++beg){
- this->insert_equal(*beg);
- }
- }
- }
-
- template<class InpIterator>
- void priv_create_and_insert_nodes
- (InpIterator beg, InpIterator end, bool unique, allocator_v2, std::input_iterator_tag)
- { //Just forward to the default one
- priv_create_and_insert_nodes(beg, end, unique, allocator_v1(), std::input_iterator_tag());
- }
 
- class insertion_functor;
- friend class insertion_functor;
+ class insert_equal_end_hint_functor;
+ friend class insert_equal_end_hint_functor;
 
- class insertion_functor
+ class insert_equal_end_hint_functor
    {
       Icont &icont_;
+ const iconst_iterator cend_;
 
       public:
- insertion_functor(Icont &icont)
- : icont_(icont)
+ insert_equal_end_hint_functor(Icont &icont)
+ : icont_(icont), cend_(this->icont_.cend())
       {}
 
       void operator()(Node &n)
- { this->icont_.insert_equal(this->icont_.cend(), n); }
+ { this->icont_.insert_equal(cend_, n); }
    };
 
+ class push_back_functor;
+ friend class push_back_functor;
 
- template<class FwdIterator>
- void priv_create_and_insert_nodes
- (FwdIterator beg, FwdIterator end, bool unique, allocator_v2, std::forward_iterator_tag)
- {
- if(beg != end){
- if(unique){
- priv_create_and_insert_nodes(beg, end, unique, allocator_v2(), std::input_iterator_tag());
- }
- else{
- //Optimized allocation and construction
- this->allocate_many_and_construct
- (beg, std::distance(beg, end), insertion_functor(this->icont()));
- }
- }
- }
-
- //Iterator range version
- template<class InpIterator>
- void priv_create_and_insert_ordered_nodes
- (InpIterator beg, InpIterator end, allocator_v1, std::input_iterator_tag)
- {
- const_iterator cend_n(this->cend());
- for (; beg != end; ++beg){
- this->insert_before(cend_n, *beg);
- }
- }
-
- template<class InpIterator>
- void priv_create_and_insert_ordered_nodes
- (InpIterator beg, InpIterator end, allocator_v2, std::input_iterator_tag)
- { //Just forward to the default one
- priv_create_and_insert_ordered_nodes(beg, end, allocator_v1(), std::input_iterator_tag());
- }
-
- class back_insertion_functor;
- friend class back_insertion_functor;
-
- class back_insertion_functor
+ class push_back_functor
    {
       Icont &icont_;
 
       public:
- back_insertion_functor(Icont &icont)
+ push_back_functor(Icont &icont)
          : icont_(icont)
       {}
 
       void operator()(Node &n)
       { this->icont_.push_back(n); }
    };
-
-
- template<class FwdIterator>
- void priv_create_and_insert_ordered_nodes
- (FwdIterator beg, FwdIterator end, allocator_v2, std::forward_iterator_tag)
- {
- if(beg != end){
- //Optimized allocation and construction
- this->allocate_many_and_construct
- (beg, std::distance(beg, end), back_insertion_functor(this->icont()));
- }
- }
 };
 
 template <class Key, class Value, class KeyOfValue,

Modified: branches/release/boost/container/detail/workaround.hpp
==============================================================================
--- branches/release/boost/container/detail/workaround.hpp (original)
+++ branches/release/boost/container/detail/workaround.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -31,6 +31,10 @@
    #define BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST
 #endif
 
+//Macros for documentation purposes. For code, expands to the argument
+#define BOOST_CONTAINER_IMPDEF(TYPE) TYPE
+#define BOOST_CONTAINER_SEEDOC(TYPE) TYPE
+
 #include <boost/container/detail/config_end.hpp>
 
 #endif //#ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP

Modified: branches/release/boost/container/flat_map.hpp
==============================================================================
--- branches/release/boost/container/flat_map.hpp (original)
+++ branches/release/boost/container/flat_map.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -39,11 +39,7 @@
 
 /// @cond
 // Forward declarations of operators == and <, needed for friend declarations.
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class Key, class T, class Pred = std::less< std::pair< Key, T> >, class A = std::allocator<T> >
-#else
 template <class Key, class T, class Pred, class A>
-#endif
 class flat_map;
 
 template <class Key, class T, class Pred, class A>
@@ -94,7 +90,7 @@
 //! Erasing an element of a flat_map invalidates iterators and references
 //! pointing to elements that come after (their keys are bigger) the erased element.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class Key, class T, class Pred = std::less< std::pair< Key, T> >, class A = std::allocator<T> >
+template <class Key, class T, class Pred = std::less<Key>, class A = std::allocator< std::pair< Key, T> > >
 #else
 template <class Key, class T, class Pred, class A>
 #endif
@@ -194,8 +190,8 @@
    template <class InputIterator>
    flat_map(InputIterator first, InputIterator last, const Pred& comp = Pred(),
          const allocator_type& a = allocator_type())
- : m_flat_tree(comp, container_detail::force<impl_allocator_type>(a))
- { m_flat_tree.insert_unique(first, last); }
+ : m_flat_tree(true, first, last, comp, container_detail::force<impl_allocator_type>(a))
+ {}
 
    //! <b>Effects</b>: Constructs an empty flat_map using the specified comparison object and
    //! allocator, and inserts elements from the ordered unique range [first ,last). This function
@@ -870,11 +866,7 @@
 namespace container {
 
 // Forward declaration of operators < and ==, needed for friend declaration.
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class Key, class T, class Pred = std::less< std::pair< Key, T> >, class A = std::allocator<T> >
-#else
 template <class Key, class T, class Pred, class A>
-#endif
 class flat_multimap;
 
 template <class Key, class T, class Pred, class A>
@@ -901,7 +893,7 @@
 //! A is the allocator to allocate the value_types
 //! (e.g. <i>allocator< std::pair<Key, T> ></i>).
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class Key, class T, class Pred = std::less< std::pair< Key, T> >, class A = std::allocator<T> >
+template <class Key, class T, class Pred = std::less<Key>, class A = std::allocator< std::pair< Key, T> > >
 #else
 template <class Key, class T, class Pred, class A>
 #endif
@@ -996,8 +988,8 @@
    flat_multimap(InputIterator first, InputIterator last,
             const Pred& comp = Pred(),
             const allocator_type& a = allocator_type())
- : m_flat_tree(comp, container_detail::force<impl_allocator_type>(a))
- { m_flat_tree.insert_equal(first, last); }
+ : m_flat_tree(false, first, last, comp, container_detail::force<impl_allocator_type>(a))
+ {}
 
    //! <b>Effects</b>: Constructs an empty flat_multimap using the specified comparison object and
    //! allocator, and inserts elements from the ordered range [first ,last). This function

Modified: branches/release/boost/container/flat_set.hpp
==============================================================================
--- branches/release/boost/container/flat_set.hpp (original)
+++ branches/release/boost/container/flat_set.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -125,8 +125,8 @@
    flat_set(InputIterator first, InputIterator last,
             const Pred& comp = Pred(),
             const allocator_type& a = allocator_type())
- : m_flat_tree(comp, a)
- { m_flat_tree.insert_unique(first, last); }
+ : m_flat_tree(true, first, last, comp, a)
+ {}
 
    //! <b>Effects</b>: Constructs an empty flat_set using the specified comparison object and
    //! allocator, and inserts elements from the ordered unique range [first ,last). This function
@@ -777,8 +777,8 @@
    flat_multiset(InputIterator first, InputIterator last,
                  const Pred& comp = Pred(),
                  const allocator_type& a = allocator_type())
- : m_flat_tree(comp, a)
- { m_flat_tree.insert_equal(first, last); }
+ : m_flat_tree(false, first, last, comp, a)
+ {}
 
    //! <b>Effects</b>: Constructs an empty flat_multiset using the specified comparison object and
    //! allocator, and inserts elements from the ordered range [first ,last ). This function

Modified: branches/release/boost/container/list.hpp
==============================================================================
--- branches/release/boost/container/list.hpp (original)
+++ branches/release/boost/container/list.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -94,6 +94,111 @@
    typedef container_type type ;
 };
 
+template<class T, class IIterator>
+class list_const_iterator
+ : public std::iterator< std::bidirectional_iterator_tag, T
+ , typename iiterator_types<T, IIterator>::difference_type
+ , typename iiterator_types<T, IIterator>::const_pointer
+ , typename iiterator_types<T, IIterator>::const_reference>
+{
+ protected:
+
+ IIterator m_it;
+
+ public:
+ typedef typename iiterator_types<T, IIterator>::const_pointer const_pointer;
+ typedef typename iiterator_types<T, IIterator>::const_reference const_reference;
+
+ //Constructors
+ list_const_iterator()
+ : m_it()
+ {}
+
+ explicit list_const_iterator(const IIterator &it)
+ : m_it(it)
+ {}
+
+ //Pointer like operators
+ const_reference operator*() const
+ { return this->m_it->m_data; }
+
+ const_pointer operator->() const
+ { return ::boost::intrusive::pointer_traits<const_pointer>::to_pointer(this->m_it->m_data); }
+
+ //Increment / Decrement
+ list_const_iterator& operator++()
+ { ++this->m_it; return *this; }
+
+ list_const_iterator operator++(int)
+ { IIterator tmp = this->m_it; ++*this; return list_const_iterator(tmp); }
+
+ list_const_iterator& operator--()
+ { --this->m_it; return *this; }
+
+ list_const_iterator operator--(int)
+ { IIterator tmp = this->m_it; --*this; return list_const_iterator(tmp); }
+
+ //Comparison operators
+ friend bool operator== (const list_const_iterator& l, const list_const_iterator& r)
+ { return l.m_it == r.m_it; }
+
+ friend bool operator!= (const list_const_iterator& l, const list_const_iterator& r)
+ { return l.m_it != r.m_it; }
+
+ IIterator &get()
+ { return this->m_it; }
+
+ const IIterator &get() const
+ { return this->m_it; }
+};
+
+template<class T, class IIterator>
+class list_iterator
+ : public list_const_iterator<T, IIterator>
+{
+ private:
+ typedef list_const_iterator<T, IIterator> const_iterator;
+
+ public:
+ typedef typename iiterator_types<T, IIterator>::pointer pointer;
+ typedef typename iiterator_types<T, IIterator>::reference reference;
+
+ //Constructors
+ list_iterator()
+ : const_iterator()
+ {}
+
+ explicit list_iterator(const IIterator &it)
+ : const_iterator(it)
+ {}
+
+ //Pointer like operators
+ reference operator*() const
+ { return this->m_it->m_data; }
+
+ pointer operator->() const
+ { return ::boost::intrusive::pointer_traits<pointer>::pointer_to(this->m_it->m_data); }
+
+ //Increment / Decrement
+ list_iterator& operator++()
+ { ++this->m_it; return *this; }
+
+ list_iterator operator++(int)
+ { IIterator tmp = this->m_it; ++*this; return list_iterator(tmp); }
+
+ list_iterator& operator--()
+ { --this->m_it; return *this; }
+
+ list_iterator operator--(int)
+ { IIterator tmp = this->m_it; --*this; return list_iterator(tmp); }
+
+ IIterator &get()
+ { return this->m_it; }
+
+ const IIterator &get() const
+ { return this->m_it; }
+};
+
 } //namespace container_detail {
 /// @endcond
 
@@ -119,7 +224,6 @@
    /// @cond
    typedef typename
       container_detail::intrusive_list_type<A>::type Icont;
- typedef list <T, A> ThisType;
    typedef container_detail::node_alloc_holder<A, Icont> AllocHolder;
    typedef typename AllocHolder::NodePtr NodePtr;
    typedef typename AllocHolder::NodeAlloc NodeAlloc;
@@ -159,141 +263,39 @@
       bool operator()(const Node &a) const
       { return static_cast<const Pred&>(*this)(a.m_data); }
    };
- /// @endcond
-
- public:
- //! The type of object, T, stored in the list
- typedef T value_type;
- //! Pointer to T
- typedef typename allocator_traits_type::pointer pointer;
- //! Const pointer to T
- typedef typename allocator_traits_type::const_pointer const_pointer;
- //! Reference to T
- typedef typename allocator_traits_type::reference reference;
- //! Const reference to T
- typedef typename allocator_traits_type::const_reference const_reference;
- //! An unsigned integral type
- typedef typename allocator_traits_type::size_type size_type;
- //! A signed integral type
- typedef typename allocator_traits_type::difference_type difference_type;
- //! The allocator type
- typedef A allocator_type;
- //! Non-standard extension: the stored allocator type
- typedef NodeAlloc stored_allocator_type;
 
- /// @cond
- private:
    BOOST_COPYABLE_AND_MOVABLE(list)
- typedef difference_type list_difference_type;
- typedef pointer list_pointer;
- typedef const_pointer list_const_pointer;
- typedef reference list_reference;
- typedef const_reference list_const_reference;
- /// @endcond
-
- public:
- //! Const iterator used to iterate through a list.
- class const_iterator
- /// @cond
- : public std::iterator<std::bidirectional_iterator_tag,
- value_type, list_difference_type,
- list_const_pointer, list_const_reference>
- {
-
- protected:
- typename Icont::iterator m_it;
- explicit const_iterator(typename Icont::iterator it) : m_it(it){}
- void prot_incr() { ++m_it; }
- void prot_decr() { --m_it; }
-
- private:
- typename Icont::iterator get()
- { return this->m_it; }
-
- public:
- friend class list<T, A>;
- typedef list_difference_type difference_type;
-
- //Constructors
- const_iterator()
- : m_it()
- {}
-
- //Pointer like operators
- const_reference operator*() const
- { return m_it->m_data; }
-
- const_pointer operator->() const
- { return const_pointer(&m_it->m_data); }
-
- //Increment / Decrement
- const_iterator& operator++()
- { prot_incr(); return *this; }
-
- const_iterator operator++(int)
- { typename Icont::iterator tmp = m_it; ++*this; return const_iterator(tmp); }
-
- const_iterator& operator--()
- { prot_decr(); return *this; }
-
- const_iterator operator--(int)
- { typename Icont::iterator tmp = m_it; --*this; return const_iterator(tmp); }
-
- //Comparison operators
- bool operator== (const const_iterator& r) const
- { return m_it == r.m_it; }
-
- bool operator!= (const const_iterator& r) const
- { return m_it != r.m_it; }
- }
- /// @endcond
- ;
-
- //! Iterator used to iterate through a list
- class iterator
- /// @cond
- : public const_iterator
- {
-
- private:
- explicit iterator(typename Icont::iterator it)
- : const_iterator(it)
- {}
-
- typename Icont::iterator get()
- { return this->m_it; }
-
- public:
- friend class list<T, A>;
- typedef list_pointer pointer;
- typedef list_reference reference;
-
- //Constructors
- iterator(){}
-
- //Pointer like operators
- reference operator*() const { return this->m_it->m_data; }
- pointer operator->() const { return pointer(&this->m_it->m_data); }
-
- //Increment / Decrement
- iterator& operator++()
- { this->prot_incr(); return *this; }
-
- iterator operator++(int)
- { typename Icont::iterator tmp = this->m_it; ++*this; return iterator(tmp); }
-
- iterator& operator--()
- { this->prot_decr(); return *this; }
 
- iterator operator--(int)
- { iterator tmp = *this; --*this; return tmp; }
- };
+ typedef container_detail::list_iterator<T, typename Icont::iterator> iterator_impl;
+ typedef container_detail::list_const_iterator<T, typename Icont::iterator>const_iterator_impl;
    /// @endcond
 
- //! Iterator used to iterate backwards through a list.
- typedef std::reverse_iterator<iterator> reverse_iterator;
- //! Const iterator used to iterate backwards through a list.
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ public:
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+
+ typedef T value_type;
+ typedef typename ::boost::container::allocator_traits<A>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<A>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<A>::reference reference;
+ typedef typename ::boost::container::allocator_traits<A>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<A>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<A>::difference_type difference_type;
+ typedef A allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(NodeAlloc) stored_allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
+ typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
+
+ //////////////////////////////////////////////
+ //
+ // construct/copy/destroy
+ //
+ //////////////////////////////////////////////
 
    //! <b>Effects</b>: Default constructs a list.
    //!
@@ -404,6 +406,98 @@
    ~list()
    {} //AllocHolder clears the list
 
+ //! <b>Effects</b>: Makes *this contain the same elements as x.
+ //!
+ //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
+ //! of each of x's elements.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements in x.
+ list& operator=(BOOST_COPY_ASSIGN_REF(list) x)
+ {
+ if (&x != this){
+ NodeAlloc &this_alloc = this->node_alloc();
+ const NodeAlloc &x_alloc = x.node_alloc();
+ container_detail::bool_<allocator_traits_type::
+ propagate_on_container_copy_assignment::value> flag;
+ if(flag && this_alloc != x_alloc){
+ this->clear();
+ }
+ this->AllocHolder::copy_assign_alloc(x);
+ this->assign(x.begin(), x.end());
+ }
+ return *this;
+ }
+
+ //! <b>Effects</b>: Move assignment. All mx's values are transferred to *this.
+ //!
+ //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had
+ //! before the function.
+ //!
+ //! <b>Throws</b>: If allocator_type's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant.
+ list& operator=(BOOST_RV_REF(list) x)
+ {
+ if (&x != this){
+ NodeAlloc &this_alloc = this->node_alloc();
+ NodeAlloc &x_alloc = x.node_alloc();
+ //If allocators are equal we can just swap pointers
+ if(this_alloc == x_alloc){
+ //Destroy and swap pointers
+ this->clear();
+ this->icont() = boost::move(x.icont());
+ //Move allocator if needed
+ this->AllocHolder::move_assign_alloc(x);
+ }
+ //If unequal allocators, then do a one by one move
+ else{
+ typedef typename std::iterator_traits<iterator>::iterator_category ItCat;
+ this->assign( boost::make_move_iterator(x.begin())
+ , boost::make_move_iterator(x.end()));
+ }
+ }
+ return *this;
+ }
+
+ //! <b>Effects</b>: Assigns the n copies of val to *this.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ void assign(size_type n, const T& val)
+ {
+ typedef constant_iterator<value_type, difference_type> cvalue_iterator;
+ return this->assign(cvalue_iterator(val, n), cvalue_iterator());
+ }
+
+ //! <b>Effects</b>: Assigns the the range [first, last) to *this.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's constructor from dereferencing InpIt throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ template <class InpIt>
+ void assign(InpIt first, InpIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InpIt, size_type>::value
+ >::type * = 0
+ #endif
+ )
+ {
+ iterator first1 = this->begin();
+ const iterator last1 = this->end();
+ for ( ; first1 != last1 && first != last; ++first1, ++first)
+ *first1 = *first;
+ if (first == last)
+ this->erase(first1, last1);
+ else{
+ this->insert(last1, first, last);
+ }
+ }
+
    //! <b>Effects</b>: Returns a copy of the internal allocator.
    //!
    //! <b>Throws</b>: If allocator's copy constructor throws.
@@ -412,19 +506,27 @@
    allocator_type get_allocator() const
    { return allocator_type(this->node_alloc()); }
 
+ //! <b>Effects</b>: Returns a copy of the internal allocator.
+ //!
+ //! <b>Throws</b>: If allocator's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant.
    const stored_allocator_type &get_stored_allocator() const
    { return this->node_alloc(); }
 
+ //! <b>Effects</b>: Returns a copy of the internal allocator.
+ //!
+ //! <b>Throws</b>: If allocator's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant.
    stored_allocator_type &get_stored_allocator()
    { return this->node_alloc(); }
 
- //! <b>Effects</b>: Erases all the elements of the list.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Linear to the number of elements in the list.
- void clear()
- { AllocHolder::clear(alloc_version()); }
+ //////////////////////////////////////////////
+ //
+ // iterators
+ //
+ //////////////////////////////////////////////
 
    //! <b>Effects</b>: Returns an iterator to the first element contained in the list.
    //!
@@ -528,6 +630,12 @@
    const_reverse_iterator crend() const
    { return const_reverse_iterator(this->cbegin()); }
 
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
+
    //! <b>Effects</b>: Returns true if the list contains no elements.
    //!
    //! <b>Throws</b>: Nothing.
@@ -552,61 +660,38 @@
    size_type max_size() const
    { return AllocHolder::max_size(); }
 
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- //! <b>Effects</b>: Inserts a copy of x at the beginning of the list.
- //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_front(const T &x);
-
- //! <b>Effects</b>: Constructs a new element in the beginning of the list
- //! and moves the resources of mx to this new element.
- //!
- //! <b>Throws</b>: If memory allocation throws.
- //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_front(T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
- #endif
-
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- //! <b>Effects</b>: Inserts a copy of x at the end of the list.
- //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_back(const T &x);
-
- //! <b>Effects</b>: Constructs a new element in the end of the list
- //! and moves the resources of mx to this new element.
+ //! <b>Effects</b>: Inserts or erases elements at the end such that
+ //! the size becomes n. New elements are default constructed.
    //!
- //! <b>Throws</b>: If memory allocation throws.
+ //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
    //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_back(T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
- #endif
+ //! <b>Complexity</b>: Linear to the difference between size() and new_size.
+ void resize(size_type new_size)
+ {
+ if(!priv_try_shrink(new_size)){
+ typedef default_construct_iterator<value_type, difference_type> default_iterator;
+ this->insert(this->cend(), default_iterator(new_size - this->size()), default_iterator());
+ }
+ }
 
- //! <b>Effects</b>: Removes the first element from the list.
+ //! <b>Effects</b>: Inserts or erases elements at the end such that
+ //! the size becomes n. New elements are copy constructed from x.
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
    //!
- //! <b>Complexity</b>: Amortized constant time.
- void pop_front()
- { this->erase(this->cbegin()); }
+ //! <b>Complexity</b>: Linear to the difference between size() and new_size.
+ void resize(size_type new_size, const T& x)
+ {
+ if(!priv_try_shrink(new_size)){
+ this->insert(this->cend(), new_size - this->size(), x);
+ }
+ }
 
- //! <b>Effects</b>: Removes the last element from the list.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Amortized constant time.
- void pop_back()
- { const_iterator tmp = this->cend(); this->erase(--tmp); }
+ //////////////////////////////////////////////
+ //
+ // element access
+ //
+ //////////////////////////////////////////////
 
    //! <b>Requires</b>: !empty()
    //!
@@ -652,157 +737,128 @@
    const_reference back() const
    { return *(--this->end()); }
 
- //! <b>Effects</b>: Inserts or erases elements at the end such that
- //! the size becomes n. New elements are copy constructed from x.
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
+
+ #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //! <b>Effects</b>: Inserts an object of type T constructed with
+ //! std::forward<Args>(args)... in the end of the list.
    //!
- //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's in-place constructor throws.
    //!
- //! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size, const T& x)
- {
- const_iterator iend = this->cend();
- size_type len = this->size();
-
- if(len > new_size){
- size_type to_erase = len - new_size;
- while(to_erase--){
- --iend;
- }
- this->erase(iend, this->cend());
- }
- else{
- this->priv_create_and_insert_nodes(iend, new_size - len, x);
- }
- }
+ //! <b>Complexity</b>: Constant
+ template <class... Args>
+ void emplace_back(Args&&... args)
+ { this->emplace(this->cend(), boost::forward<Args>(args)...); }
 
- //! <b>Effects</b>: Inserts or erases elements at the end such that
- //! the size becomes n. New elements are default constructed.
- //!
- //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
+ //! <b>Effects</b>: Inserts an object of type T constructed with
+ //! std::forward<Args>(args)... in the beginning of the list.
    //!
- //! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size)
- {
- const_iterator iend = this->end();
- size_type len = this->size();
-
- if(len > new_size){
- size_type to_erase = len - new_size;
- const_iterator ifirst;
- if(to_erase < len/2u){
- ifirst = iend;
- while(to_erase--){
- --ifirst;
- }
- }
- else{
- ifirst = this->begin();
- size_type to_skip = len - to_erase;
- while(to_skip--){
- ++ifirst;
- }
- }
- this->erase(ifirst, iend);
- }
- else{
- this->priv_create_and_insert_nodes(this->cend(), new_size - len);
- }
- }
-
- //! <b>Effects</b>: Swaps the contents of *this and x.
- //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's in-place constructor throws.
    //!
- //! <b>Complexity</b>: Constant.
- void swap(ThisType& x)
- { AllocHolder::swap(x); }
+ //! <b>Complexity</b>: Constant
+ template <class... Args>
+ void emplace_front(Args&&... args)
+ { this->emplace(this->cbegin(), boost::forward<Args>(args)...); }
 
- //! <b>Effects</b>: Makes *this contain the same elements as x.
- //!
- //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
- //! of each of x's elements.
+ //! <b>Effects</b>: Inserts an object of type T constructed with
+ //! std::forward<Args>(args)... before p.
    //!
- //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's in-place constructor throws.
    //!
- //! <b>Complexity</b>: Linear to the number of elements in x.
- ThisType& operator=(BOOST_COPY_ASSIGN_REF(ThisType) x)
+ //! <b>Complexity</b>: Constant
+ template <class... Args>
+ iterator emplace(const_iterator p, Args&&... args)
    {
- if (&x != this){
- NodeAlloc &this_alloc = this->node_alloc();
- const NodeAlloc &x_alloc = x.node_alloc();
- container_detail::bool_<allocator_traits_type::
- propagate_on_container_copy_assignment::value> flag;
- if(flag && this_alloc != x_alloc){
- this->clear();
- }
- this->AllocHolder::copy_assign_alloc(x);
- this->assign(x.begin(), x.end());
- }
- return *this;
+ NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...));
+ return iterator(this->icont().insert(p.get(), *pnode));
    }
 
- //! <b>Effects</b>: Move assignment. All mx's values are transferred to *this.
+ #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+
+ #define BOOST_PP_LOCAL_MACRO(n) \
+ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
+ void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { \
+ this->emplace(this->cend() \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
+ } \
+ \
+ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
+ void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { \
+ this->emplace(this->cbegin() \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
+ } \
+ \
+ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
+ iterator emplace(const_iterator p \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { \
+ NodePtr pnode (AllocHolder::create_node \
+ (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \
+ return iterator(this->icont().insert(p.get(), *pnode)); \
+ } \
    //!
- //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had
- //! before the function.
+ #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+ #include BOOST_PP_LOCAL_ITERATE()
+
+ #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: Inserts a copy of x at the beginning of the list.
    //!
- //! <b>Throws</b>: If allocator_type's copy constructor throws.
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's copy constructor throws.
    //!
- //! <b>Complexity</b>: Constant.
- ThisType& operator=(BOOST_RV_REF(ThisType) x)
- {
- if (&x != this){
- NodeAlloc &this_alloc = this->node_alloc();
- NodeAlloc &x_alloc = x.node_alloc();
- //If allocators are equal we can just swap pointers
- if(this_alloc == x_alloc){
- //Destroy and swap pointers
- this->clear();
- this->icont() = boost::move(x.icont());
- //Move allocator if needed
- this->AllocHolder::move_assign_alloc(x);
- }
- //If unequal allocators, then do a one by one move
- else{
- typedef typename std::iterator_traits<iterator>::iterator_category ItCat;
- this->assign( boost::make_move_iterator(x.begin())
- , boost::make_move_iterator(x.end()));
- }
- }
- return *this;
- }
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_front(const T &x);
 
- //! <b>Requires</b>: p must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Inserts n copies of x before p.
+ //! <b>Effects</b>: Constructs a new element in the beginning of the list
+ //! and moves the resources of mx to this new element.
    //!
- //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //! <b>Throws</b>: If memory allocation throws.
    //!
- //! <b>Complexity</b>: Linear to n.
- void insert(const_iterator p, size_type n, const T& x)
- { this->priv_create_and_insert_nodes(p, n, x); }
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_front(T &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
+ #endif
 
- //! <b>Requires</b>: p must be a valid iterator of *this.
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: Inserts a copy of x at the end of the list.
    //!
- //! <b>Effects</b>: Insert a copy of the [first, last) range before p.
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's copy constructor throws.
    //!
- //! <b>Throws</b>: If memory allocation throws, T's constructor from a
- //! dereferenced InpIt throws.
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_back(const T &x);
+
+ //! <b>Effects</b>: Constructs a new element in the end of the list
+ //! and moves the resources of mx to this new element.
    //!
- //! <b>Complexity</b>: Linear to std::distance [first, last).
- template <class InpIt>
- void insert(const_iterator p, InpIt first, InpIt last)
- {
- const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- this->priv_insert_dispatch(p, first, last, Result());
- }
+ //! <b>Throws</b>: If memory allocation throws.
+ //!
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_back(T &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
+ #endif
 
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! <b>Requires</b>: position must be a valid iterator of *this.
    //!
    //! <b>Effects</b>: Insert a copy of x before position.
    //!
+ //! <b>Returns</b>: an iterator to the inserted element.
+ //!
    //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws.
    //!
    //! <b>Complexity</b>: Amortized constant time.
@@ -812,6 +868,8 @@
    //!
    //! <b>Effects</b>: Insert a new element before position with mx's resources.
    //!
+ //! <b>Returns</b>: an iterator to the inserted element.
+ //!
    //! <b>Throws</b>: If memory allocation throws.
    //!
    //! <b>Complexity</b>: Amortized constant time.
@@ -820,78 +878,88 @@
    BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
    #endif
 
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... in the end of the list.
+ //! <b>Requires</b>: p must be a valid iterator of *this.
    //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's in-place constructor throws.
+ //! <b>Effects</b>: Inserts n copies of x before p.
    //!
- //! <b>Complexity</b>: Constant
- template <class... Args>
- void emplace_back(Args&&... args)
- {
- this->emplace(this->cend(), boost::forward<Args>(args)...);
- }
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... in the beginning of the list.
+ //! <b>Returns</b>: an iterator to the first inserted element or p if n is 0.
    //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's in-place constructor throws.
+ //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
    //!
- //! <b>Complexity</b>: Constant
- template <class... Args>
- void emplace_front(Args&&... args)
+ //! <b>Complexity</b>: Linear to n.
+ iterator insert(const_iterator p, size_type n, const T& x)
    {
- this->emplace(this->cbegin(), boost::forward<Args>(args)...);
+ typedef constant_iterator<value_type, difference_type> cvalue_iterator;
+ return this->insert(p, cvalue_iterator(x, n), cvalue_iterator());
    }
 
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... before p.
+ //! <b>Requires</b>: p must be a valid iterator of *this.
    //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's in-place constructor throws.
+ //! <b>Effects</b>: Insert a copy of the [first, last) range before p.
    //!
- //! <b>Complexity</b>: Constant
- template <class... Args>
- iterator emplace(const_iterator p, Args&&... args)
- {
- NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...));
- return iterator(this->icont().insert(p.get(), *pnode));
+ //! <b>Returns</b>: an iterator to the first inserted element or p if first == last.
+ //!
+ //! <b>Throws</b>: If memory allocation throws, T's constructor from a
+ //! dereferenced InpIt throws.
+ //!
+ //! <b>Complexity</b>: Linear to std::distance [first, last).
+ template <class InpIt>
+ iterator insert(const_iterator p, InpIt first, InpIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InpIt, size_type>::value
+ && (container_detail::is_input_iterator<InpIt>::value
+ || container_detail::is_same<alloc_version, allocator_v1>::value
+ )
+ >::type * = 0
+ #endif
+ )
+ {
+ const typename Icont::iterator ipos(p.get());
+ iterator ret_it(ipos);
+ if(first != last){
+ ret_it = iterator(this->icont().insert(ipos, *this->create_node_from_it(first)));
+ ++first;
+ }
+ for (; first != last; ++first){
+ this->icont().insert(ipos, *this->create_node_from_it(first));
+ }
+ return ret_it;
    }
 
- #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ template <class FwdIt>
+ iterator insert(const_iterator p, FwdIt first, FwdIt last
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<FwdIt, size_type>::value
+ && !(container_detail::is_input_iterator<FwdIt>::value
+ || container_detail::is_same<alloc_version, allocator_v1>::value
+ )
+ >::type * = 0
+ )
+ {
+ //Optimized allocation and construction
+ insertion_functor func(this->icont(), p.get());
+ this->allocate_many_and_construct(first, std::distance(first, last), func);
+ return iterator(func.inserted_first());
+ }
+ #endif
 
- #define BOOST_PP_LOCAL_MACRO(n) \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- this->emplace(this->cend() \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- } \
- \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- this->emplace(this->cbegin() \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- } \
- \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- iterator emplace(const_iterator p \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- NodePtr pnode (AllocHolder::create_node \
- (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \
- return iterator(this->icont().insert(p.get(), *pnode)); \
- } \
+ //! <b>Effects</b>: Removes the first element from the list.
    //!
- #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Amortized constant time.
+ void pop_front()
+ { this->erase(this->cbegin()); }
 
- #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+ //! <b>Effects</b>: Removes the last element from the list.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Amortized constant time.
+ void pop_back()
+ { const_iterator tmp = this->cend(); this->erase(--tmp); }
 
    //! <b>Requires</b>: p must be a valid iterator of *this.
    //!
@@ -913,27 +981,27 @@
    iterator erase(const_iterator first, const_iterator last)
    { return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); }
 
- //! <b>Effects</b>: Assigns the n copies of val to *this.
+ //! <b>Effects</b>: Swaps the contents of *this and x.
    //!
- //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //! <b>Throws</b>: Nothing.
    //!
- //! <b>Complexity</b>: Linear to n.
- void assign(size_type n, const T& val)
- { this->priv_fill_assign(n, val); }
+ //! <b>Complexity</b>: Constant.
+ void swap(list& x)
+ { AllocHolder::swap(x); }
 
- //! <b>Effects</b>: Assigns the the range [first, last) to *this.
+ //! <b>Effects</b>: Erases all the elements of the list.
    //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's constructor from dereferencing InpIt throws.
+ //! <b>Throws</b>: Nothing.
    //!
- //! <b>Complexity</b>: Linear to n.
- template <class InpIt>
- void assign(InpIt first, InpIt last)
- {
- const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- this->priv_assign_dispatch(first, last, Result());
- }
+ //! <b>Complexity</b>: Linear to the number of elements in the list.
+ void clear()
+ { AllocHolder::clear(alloc_version()); }
+
+ //////////////////////////////////////////////
+ //
+ // slist operations
+ //
+ //////////////////////////////////////////////
 
    //! <b>Requires</b>: p must point to an element contained
    //! by the list. x != *this
@@ -948,13 +1016,30 @@
    //!
    //! <b>Note</b>: Iterators of values obtained from list x now point to elements of
    //! this list. Iterators of this list and all the references are not invalidated.
- void splice(const_iterator p, ThisType& x) BOOST_CONTAINER_NOEXCEPT
+ void splice(const_iterator p, list& x) BOOST_CONTAINER_NOEXCEPT
    {
- BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x);
+ BOOST_ASSERT(*this != x);
+ BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice(p.get(), x.icont());
    }
 
    //! <b>Requires</b>: p must point to an element contained
+ //! by the list. x != *this
+ //!
+ //! <b>Effects</b>: Transfers all the elements of list x to this list, before the
+ //! the element pointed by p. No destructors or copy constructors are called.
+ //!
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of
+ //! this list. Iterators of this list and all the references are not invalidated.
+ void splice(const_iterator p, BOOST_RV_REF(list) x) BOOST_CONTAINER_NOEXCEPT
+ { this->splice(p, static_cast<list&>(x)); }
+
+ //! <b>Requires</b>: p must point to an element contained
    //! by this list. i must point to an element contained in list x.
    //!
    //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
@@ -968,13 +1053,31 @@
    //!
    //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
    //! list. Iterators of this list and all the references are not invalidated.
- void splice(const_iterator p, ThisType &x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
+ void splice(const_iterator p, list &x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
    {
- BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x);
+ BOOST_ASSERT(*this != x);
+ BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice(p.get(), x.icont(), i.get());
    }
 
    //! <b>Requires</b>: p must point to an element contained
+ //! by this list. i must point to an element contained in list x.
+ //!
+ //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
+ //! before the the element pointed by p. No destructors or copy constructors are called.
+ //! If p == i or p == ++i, this function is a null operation.
+ //!
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
+ //! list. Iterators of this list and all the references are not invalidated.
+ void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator i) BOOST_CONTAINER_NOEXCEPT
+ { this->splice(p, static_cast<list&>(x), i); }
+
+ //! <b>Requires</b>: p must point to an element contained
    //! by this list. first and last must point to elements contained in list x.
    //!
    //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
@@ -987,14 +1090,31 @@
    //!
    //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
    //! list. Iterators of this list and all the references are not invalidated.
- void splice(const_iterator p, ThisType &x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
+ void splice(const_iterator p, list &x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
    {
- BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x);
+ BOOST_ASSERT(*this != x);
+ BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice(p.get(), x.icont(), first.get(), last.get());
    }
 
    //! <b>Requires</b>: p must point to an element contained
    //! by this list. first and last must point to elements contained in list x.
+ //!
+ //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
+ //! before the the element pointed by p. No destructors or copy constructors are called.
+ //!
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements transferred.
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
+ //! list. Iterators of this list and all the references are not invalidated.
+ void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
+ { this->splice(p, static_cast<list&>(x), first, last); }
+
+ //! <b>Requires</b>: p must point to an element contained
+ //! by this list. first and last must point to elements contained in list x.
    //! n == std::distance(first, last)
    //!
    //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
@@ -1007,21 +1127,33 @@
    //!
    //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
    //! list. Iterators of this list and all the references are not invalidated.
- void splice(const_iterator p, ThisType &x, const_iterator first, const_iterator last, size_type n) BOOST_CONTAINER_NOEXCEPT
+ //!
+ //! <b>Note</b>: Non-standard extension
+ void splice(const_iterator p, list &x, const_iterator first, const_iterator last, size_type n) BOOST_CONTAINER_NOEXCEPT
    {
- BOOST_ASSERT((NodeAlloc&)*this == (NodeAlloc&)x);
+ BOOST_ASSERT(*this != x);
+ BOOST_ASSERT(this->node_alloc() == x.node_alloc());
       this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n);
    }
 
- //! <b>Effects</b>: Reverses the order of elements in the list.
+ //! <b>Requires</b>: p must point to an element contained
+ //! by this list. first and last must point to elements contained in list x.
+ //! n == std::distance(first, last)
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
+ //! before the the element pointed by p. No destructors or copy constructors are called.
    //!
- //! <b>Complexity</b>: This function is linear time.
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
    //!
- //! <b>Note</b>: Iterators and references are not invalidated
- void reverse()
- { this->icont().reverse(); }
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
+ //! list. Iterators of this list and all the references are not invalidated.
+ //!
+ //! <b>Note</b>: Non-standard extension
+ void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last, size_type n) BOOST_CONTAINER_NOEXCEPT
+ { this->splice(p, static_cast<list&>(x), first, last, n); }
 
    //! <b>Effects</b>: Removes all the elements that compare equal to value.
    //!
@@ -1032,7 +1164,7 @@
    //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
    //! and iterators to elements that are not removed remain valid.
    void remove(const T& value)
- { remove_if(equal_to_value(value)); }
+ { this->remove_if(equal_to_value(value)); }
 
    //! <b>Effects</b>: Removes all the elements for which a specified
    //! predicate is satisfied.
@@ -1089,9 +1221,23 @@
    //!
    //! <b>Complexity</b>: This function is linear time: it performs at most
    //! size() + x.size() - 1 comparisons.
- void merge(list<T, A>& x)
+ void merge(list &x)
    { this->merge(x, value_less()); }
 
+ //! <b>Requires</b>: The lists x and *this must be distinct.
+ //!
+ //! <b>Effects</b>: This function removes all of x's elements and inserts them
+ //! in order into *this according to std::less<value_type>. The merge is stable;
+ //! that is, if an element from *this is equivalent to one from x, then the element
+ //! from *this will precede the one from x.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: This function is linear time: it performs at most
+ //! size() + x.size() - 1 comparisons.
+ void merge(BOOST_RV_REF(list) x)
+ { this->merge(static_cast<list&>(x)); }
+
    //! <b>Requires</b>: p must be a comparison function that induces a strict weak
    //! ordering and both *this and x must be sorted according to that ordering
    //! The lists x and *this must be distinct.
@@ -1118,6 +1264,24 @@
       }
    }
 
+ //! <b>Requires</b>: p must be a comparison function that induces a strict weak
+ //! ordering and both *this and x must be sorted according to that ordering
+ //! The lists x and *this must be distinct.
+ //!
+ //! <b>Effects</b>: This function removes all of x's elements and inserts them
+ //! in order into *this. The merge is stable; that is, if an element from *this is
+ //! equivalent to one from x, then the element from *this will precede the one from x.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: This function is linear time: it performs at most
+ //! size() + x.size() - 1 comparisons.
+ //!
+ //! <b>Note</b>: Iterators and references to *this are not invalidated.
+ template <class StrictWeakOrdering>
+ void merge(BOOST_RV_REF(list) x, StrictWeakOrdering comp)
+ { this->merge(static_cast<list&>(x), comp); }
+
    //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
    //! The sort is stable, that is, the relative order of equivalent elements is preserved.
    //!
@@ -1148,9 +1312,47 @@
       this->icont().sort(ValueCompareToNodeCompare<StrictWeakOrdering>(comp));
    }
 
+ //! <b>Effects</b>: Reverses the order of elements in the list.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: This function is linear time.
+ //!
+ //! <b>Note</b>: Iterators and references are not invalidated
+ void reverse()
+ { this->icont().reverse(); }
+
    /// @cond
    private:
 
+ bool priv_try_shrink(size_type new_size)
+ {
+ const size_type len = this->size();
+ if(len > new_size){
+ const const_iterator iend = this->cend();
+ size_type to_erase = len - new_size;
+ const_iterator ifirst;
+ if(to_erase < len/2u){
+ ifirst = iend;
+ while(to_erase--){
+ --ifirst;
+ }
+ }
+ else{
+ ifirst = this->cbegin();
+ size_type to_skip = len - to_erase;
+ while(to_skip--){
+ ++ifirst;
+ }
+ }
+ this->erase(ifirst, iend);
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
    iterator priv_insert(const_iterator p, const T &x)
    {
       NodePtr tmp = AllocHolder::create_node(x);
@@ -1175,116 +1377,38 @@
    void priv_push_front (BOOST_RV_REF(T) x)
    { this->insert(this->cbegin(), boost::move(x)); }
 
- //Iterator range version
- template<class InpIterator>
- void priv_create_and_insert_nodes
- (const_iterator pos, InpIterator beg, InpIterator end)
- {
- typedef typename std::iterator_traits<InpIterator>::iterator_category ItCat;
- priv_create_and_insert_nodes(pos, beg, end, alloc_version(), ItCat());
- }
-
- template<class InpIterator>
- void priv_create_and_insert_nodes
- (const_iterator pos, InpIterator beg, InpIterator end, allocator_v1, std::input_iterator_tag)
- {
- for (; beg != end; ++beg){
- this->icont().insert(pos.get(), *this->create_node_from_it(beg));
- }
- }
-
- template<class InpIterator>
- void priv_create_and_insert_nodes
- (const_iterator pos, InpIterator beg, InpIterator end, allocator_v2, std::input_iterator_tag)
- { //Just forward to the default one
- priv_create_and_insert_nodes(pos, beg, end, allocator_v1(), std::input_iterator_tag());
- }
-
    class insertion_functor;
    friend class insertion_functor;
 
    class insertion_functor
    {
       Icont &icont_;
- typename Icont::const_iterator pos_;
+ typedef typename Icont::iterator iiterator;
+ typedef typename Icont::const_iterator iconst_iterator;
+
+ const iconst_iterator pos_;
+ iiterator ret_;
+ bool first_;
 
       public:
       insertion_functor(Icont &icont, typename Icont::const_iterator pos)
- : icont_(icont), pos_(pos)
+ : icont_(icont), pos_(pos), ret_(pos.unconst()), first_(true)
       {}
 
       void operator()(Node &n)
- { this->icont_.insert(pos_, n); }
- };
-
-
- template<class FwdIterator>
- void priv_create_and_insert_nodes
- (const_iterator pos, FwdIterator beg, FwdIterator end, allocator_v2, std::forward_iterator_tag)
- {
- if(beg != end){
- //Optimized allocation and construction
- this->allocate_many_and_construct
- (beg, std::distance(beg, end), insertion_functor(this->icont(), pos.get()));
- }
- }
-
- //Default constructed version
- void priv_create_and_insert_nodes(const_iterator pos, size_type n)
- {
- typedef default_construct_iterator<value_type, difference_type> default_iterator;
- this->priv_create_and_insert_nodes(pos, default_iterator(n), default_iterator());
- }
-
- //Copy constructed version
- void priv_create_and_insert_nodes(const_iterator pos, size_type n, const T& x)
- {
- typedef constant_iterator<value_type, difference_type> cvalue_iterator;
- this->priv_create_and_insert_nodes(pos, cvalue_iterator(x, n), cvalue_iterator());
- }
-
- //Dispatch to detect iterator range or integer overloads
- template <class InputIter>
- void priv_insert_dispatch(const_iterator p,
- InputIter first, InputIter last,
- container_detail::false_)
- { this->priv_create_and_insert_nodes(p, first, last); }
-
- template<class Integer>
- void priv_insert_dispatch(const_iterator p, Integer n, Integer x, container_detail::true_)
- { this->insert(p, (size_type)n, x); }
-
- void priv_fill_assign(size_type n, const T& val)
- {
- iterator i = this->begin(), iend = this->end();
-
- for ( ; i != iend && n > 0; ++i, --n)
- *i = val;
- if (n > 0){
- this->priv_create_and_insert_nodes(this->cend(), n, val);
- }
- else{
- this->erase(i, cend());
+ {
+ if(first_){
+ ret_ = this->icont_.insert(pos_, n);
+ first_ = false;
+ }
+ else{
+ this->icont_.insert(pos_, n);
+ }
       }
- }
 
- template <class Integer>
- void priv_assign_dispatch(Integer n, Integer val, container_detail::true_)
- { this->priv_fill_assign((size_type) n, (T) val); }
-
- template <class InputIter>
- void priv_assign_dispatch(InputIter first2, InputIter last2, container_detail::false_)
- {
- iterator first1 = this->begin();
- iterator last1 = this->end();
- for ( ; first1 != last1 && first2 != last2; ++first1, ++first2)
- *first1 = *first2;
- if (first2 == last2)
- this->erase(first1, last1);
- else{
- this->priv_create_and_insert_nodes(last1, first2, last2);
- }
- }
+ iiterator inserted_first() const
+ { return ret_; }
+ };
 
    //Functors for member algorithm defaults
    struct value_less

Modified: branches/release/boost/container/map.hpp
==============================================================================
--- branches/release/boost/container/map.hpp (original)
+++ branches/release/boost/container/map.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -68,7 +68,7 @@
 //! A is the allocator to allocate the value_types
 //! (e.g. <i>allocator< std::pair<const Key, T> > </i>).
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class Key, class T, class Pred = std::less< std::pair< const Key, T> >, class A = std::allocator<T> >
+template <class Key, class T, class Pred = std::less<Key>, class A = std::allocator< std::pair< const Key, T> > >
 #else
 template <class Key, class T, class Pred, class A>
 #endif
@@ -155,7 +155,7 @@
    template <class InputIterator>
    map(InputIterator first, InputIterator last, const Pred& comp = Pred(),
          const allocator_type& a = allocator_type())
- : m_tree(first, last, comp, a, true)
+ : m_tree(true, first, last, comp, a)
    {
       //Allocator type must be std::pair<CONST Key, T>
       BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));
@@ -814,7 +814,7 @@
 //! A is the allocator to allocate the value_types
 //!(e.g. <i>allocator< std::pair<<b>const</b> Key, T> ></i>).
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
-template <class Key, class T, class Pred = std::less< std::pair< const Key, T> >, class A = std::allocator<T> >
+template <class Key, class T, class Pred = std::less<Key>, class A = std::allocator< std::pair< const Key, T> > >
 #else
 template <class Key, class T, class Pred, class A>
 #endif
@@ -902,7 +902,7 @@
    multimap(InputIterator first, InputIterator last,
             const Pred& comp = Pred(),
             const allocator_type& a = allocator_type())
- : m_tree(first, last, comp, a, false)
+ : m_tree(false, first, last, comp, a)
    {
       //Allocator type must be std::pair<CONST Key, T>
       BOOST_STATIC_ASSERT((container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value));

Modified: branches/release/boost/container/set.hpp
==============================================================================
--- branches/release/boost/container/set.hpp (original)
+++ branches/release/boost/container/set.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -118,7 +118,7 @@
    template <class InputIterator>
    set(InputIterator first, InputIterator last, const Pred& comp = Pred(),
          const allocator_type& a = allocator_type())
- : m_tree(first, last, comp, a, true)
+ : m_tree(true, first, last, comp, a)
    {}
 
    //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
@@ -705,7 +705,7 @@
    multiset(InputIterator first, InputIterator last,
             const Pred& comp = Pred(),
             const allocator_type& a = allocator_type())
- : m_tree(first, last, comp, a, false)
+ : m_tree(false, first, last, comp, a)
    {}
 
    //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and

Modified: branches/release/boost/container/slist.hpp
==============================================================================
--- branches/release/boost/container/slist.hpp (original)
+++ branches/release/boost/container/slist.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -20,9 +20,11 @@
 
 #include <boost/container/container_fwd.hpp>
 #include <boost/move/move.hpp>
+#include <boost/move/move_helpers.hpp>
 #include <boost/intrusive/pointer_traits.hpp>
 #include <boost/container/detail/utilities.hpp>
 #include <boost/container/detail/mpl.hpp>
+#include <boost/container/detail/type_traits.hpp>
 #include <boost/type_traits/has_trivial_destructor.hpp>
 #include <boost/detail/no_exceptions_support.hpp>
 #include <boost/container/detail/node_alloc_holder.hpp>
@@ -52,6 +54,9 @@
 
 /// @cond
 
+template <class T, class A>
+class slist;
+
 namespace container_detail {
 
 template<class VoidPointer>
@@ -95,6 +100,99 @@
    typedef container_type type ;
 };
 
+template<class T, class IIterator>
+class slist_const_iterator
+ : public std::iterator< std::forward_iterator_tag, T
+ , typename iiterator_types<T, IIterator>::difference_type
+ , typename iiterator_types<T, IIterator>::const_pointer
+ , typename iiterator_types<T, IIterator>::const_reference>
+{
+ protected:
+
+ IIterator m_it;
+
+ public:
+ typedef typename iiterator_types<T, IIterator>::const_pointer const_pointer;
+ typedef typename iiterator_types<T, IIterator>::const_reference const_reference;
+
+ //Constructors
+ slist_const_iterator()
+ : m_it()
+ {}
+
+ explicit slist_const_iterator(const IIterator &it)
+ : m_it(it)
+ {}
+
+ //Pointer like operators
+ const_reference operator*() const
+ { return this->m_it->m_data; }
+
+ const_pointer operator->() const
+ { return ::boost::intrusive::pointer_traits<const_pointer>::pointer_to(this->m_it->m_data); }
+
+ //Increment / Decrement
+ slist_const_iterator& operator++()
+ { ++this->m_it; return *this; }
+
+ slist_const_iterator operator++(int)
+ { IIterator tmp = this->m_it; ++*this; return slist_const_iterator(tmp); }
+
+ //Comparison operators
+ friend bool operator== (const slist_const_iterator& l, const slist_const_iterator& r)
+ { return l.m_it == r.m_it; }
+
+ friend bool operator!= (const slist_const_iterator& l, const slist_const_iterator& r)
+ { return l.m_it != r.m_it; }
+
+ IIterator &get()
+ { return this->m_it; }
+
+ const IIterator &get() const
+ { return this->m_it; }
+};
+
+template<class T, class IIterator>
+class slist_iterator
+ : public slist_const_iterator<T, IIterator>
+{
+ private:
+ typedef slist_const_iterator<T, IIterator> const_iterator;
+
+ public:
+ typedef typename iiterator_types<T, IIterator>::pointer pointer;
+ typedef typename iiterator_types<T, IIterator>::reference reference;
+
+ //Constructors
+ slist_iterator()
+ : const_iterator()
+ {}
+
+ explicit slist_iterator(const IIterator &it)
+ : const_iterator(it)
+ {}
+
+ //Pointer like operators
+ reference operator*() const
+ { return this->m_it->m_data; }
+
+ pointer operator->() const
+ { return ::boost::intrusive::pointer_traits<pointer>::to_pointer(this->m_it->m_data); }
+
+ //Increment / Decrement
+ slist_iterator& operator++()
+ { ++this->m_it; return *this; }
+
+ slist_iterator operator++(int)
+ { IIterator tmp = this->m_it; ++*this; return slist_iterator(tmp); }
+
+ IIterator &get()
+ { return this->m_it; }
+
+ const IIterator &get() const
+ { return this->m_it; }
+};
+
 } //namespace container_detail {
 
 /// @endcond
@@ -141,13 +239,10 @@
       <A, typename container_detail::intrusive_slist_type<A>::type>
 {
    /// @cond
- typedef typename container_detail::
- move_const_ref_type<T>::type insert_const_ref_type;
    typedef typename
       container_detail::intrusive_slist_type<A>::type Icont;
    typedef container_detail::node_alloc_holder<A, Icont> AllocHolder;
    typedef typename AllocHolder::NodePtr NodePtr;
- typedef slist <T, A> ThisType;
    typedef typename AllocHolder::NodeAlloc NodeAlloc;
    typedef typename AllocHolder::ValAlloc ValAlloc;
    typedef typename AllocHolder::Node Node;
@@ -185,126 +280,39 @@
       bool operator()(const Node &a) const
       { return static_cast<const Pred&>(*this)(a.m_data); }
    };
- /// @endcond
- public:
- //! The type of object, T, stored in the list
- typedef T value_type;
- //! Pointer to T
- typedef typename allocator_traits_type::pointer pointer;
- //! Const pointer to T
- typedef typename allocator_traits_type::const_pointer const_pointer;
- //! Reference to T
- typedef typename allocator_traits_type::reference reference;
- //! Const reference to T
- typedef typename allocator_traits_type::const_reference const_reference;
- //! An unsigned integral type
- typedef typename allocator_traits_type::size_type size_type;
- //! A signed integral type
- typedef typename allocator_traits_type::difference_type difference_type;
- //! The allocator type
- typedef A allocator_type;
- //! Non-standard extension: the stored allocator type
- typedef NodeAlloc stored_allocator_type;
 
- /// @cond
- private:
    BOOST_COPYABLE_AND_MOVABLE(slist)
- typedef difference_type list_difference_type;
- typedef pointer list_pointer;
- typedef const_pointer list_const_pointer;
- typedef reference list_reference;
- typedef const_reference list_const_reference;
+ typedef container_detail::slist_iterator<T, typename Icont::iterator> iterator_impl;
+ typedef container_detail::slist_const_iterator<T, typename Icont::iterator>const_iterator_impl;
    /// @endcond
 
    public:
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+
+ typedef T value_type;
+ typedef typename ::boost::container::allocator_traits<A>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<A>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<A>::reference reference;
+ typedef typename ::boost::container::allocator_traits<A>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<A>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<A>::difference_type difference_type;
+ typedef A allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(NodeAlloc) stored_allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
+ typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
 
- //! Const iterator used to iterate through a list.
- class const_iterator
- /// @cond
- : public std::iterator<std::forward_iterator_tag,
- value_type, list_difference_type,
- list_const_pointer, list_const_reference>
- {
-
- protected:
- typename Icont::iterator m_it;
- explicit const_iterator(typename Icont::iterator it) : m_it(it){}
- void prot_incr(){ ++m_it; }
-
- private:
- typename Icont::iterator get()
- { return this->m_it; }
-
- public:
- friend class slist<T, A>;
- typedef list_difference_type difference_type;
-
- //Constructors
- const_iterator()
- : m_it()
- {}
-
- //Pointer like operators
- const_reference operator*() const
- { return m_it->m_data; }
-
- const_pointer operator->() const
- { return const_pointer(&m_it->m_data); }
-
- //Increment / Decrement
- const_iterator& operator++()
- { prot_incr(); return *this; }
-
- const_iterator operator++(int)
- { typename Icont::iterator tmp = m_it; ++*this; return const_iterator(tmp); }
-
- //Comparison operators
- bool operator== (const const_iterator& r) const
- { return m_it == r.m_it; }
-
- bool operator!= (const const_iterator& r) const
- { return m_it != r.m_it; }
- }
- /// @endcond
- ;
-
- //! Iterator used to iterate through a list
- class iterator
- /// @cond
- : public const_iterator
- {
-
- private:
- explicit iterator(typename Icont::iterator it)
- : const_iterator(it)
- {}
-
- typename Icont::iterator get()
- { return this->m_it; }
-
- public:
- friend class slist<T, A>;
- typedef list_pointer pointer;
- typedef list_reference reference;
-
- //Constructors
- iterator(){}
-
- //Pointer like operators
- reference operator*() const { return this->m_it->m_data; }
- pointer operator->() const { return pointer(&this->m_it->m_data); }
-
- //Increment / Decrement
- iterator& operator++()
- { this->prot_incr(); return *this; }
+ public:
 
- iterator operator++(int)
- { typename Icont::iterator tmp = this->m_it; ++*this; return iterator(tmp); }
- }
- /// @endcond
- ;
+ //////////////////////////////////////////////
+ //
+ // construct/copy/destroy
+ //
+ //////////////////////////////////////////////
 
- public:
    //! <b>Effects</b>: Constructs a list taking the allocator as parameter.
    //!
    //! <b>Throws</b>: If allocator_type's copy constructor throws.
@@ -336,7 +344,7 @@
    //! <b>Complexity</b>: Linear to n.
    explicit slist(size_type n, const value_type& x, const allocator_type& a = allocator_type())
       : AllocHolder(a)
- { this->priv_create_and_insert_nodes(this->before_begin(), n, x); }
+ { this->insert_after(this->cbefore_begin(), n, x); }
 
    //! <b>Effects</b>: Constructs a list that will use a copy of allocator a
    //! and inserts a copy of the range [first, last) in the list.
@@ -346,10 +354,9 @@
    //!
    //! <b>Complexity</b>: Linear to the range [first, last).
    template <class InpIt>
- slist(InpIt first, InpIt last,
- const allocator_type& a = allocator_type())
+ slist(InpIt first, InpIt last, const allocator_type& a = allocator_type())
       : AllocHolder(a)
- { this->insert_after(this->before_begin(), first, last); }
+ { this->insert_after(this->cbefore_begin(), first, last); }
 
    //! <b>Effects</b>: Copy constructs a list.
    //!
@@ -360,7 +367,7 @@
    //! <b>Complexity</b>: Linear to the elements x contains.
    slist(const slist& x)
       : AllocHolder(x)
- { this->insert_after(this->before_begin(), x.begin(), x.end()); }
+ { this->insert_after(this->cbefore_begin(), x.begin(), x.end()); }
 
    //! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
    //!
@@ -380,7 +387,7 @@
    //! <b>Complexity</b>: Linear to the elements x contains.
    slist(const slist& x, const allocator_type &a)
       : AllocHolder(a)
- { this->insert_after(this->before_begin(), x.begin(), x.end()); }
+ { this->insert_after(this->cbefore_begin(), x.begin(), x.end()); }
 
    //! <b>Effects</b>: Move constructor using the specified allocator.
    //! Moves x's resources to *this.
@@ -399,6 +406,15 @@
       }
    }
 
+ //! <b>Effects</b>: Destroys the list. All stored values are destroyed
+ //! and used memory is deallocated.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements.
+ ~slist()
+ {} //AllocHolder clears the slist
+
    //! <b>Effects</b>: Makes *this contain the same elements as x.
    //!
    //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
@@ -454,14 +470,46 @@
       return *this;
    }
 
- //! <b>Effects</b>: Destroys the list. All stored values are destroyed
- //! and used memory is deallocated.
+ //! <b>Effects</b>: Assigns the n copies of val to *this.
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
    //!
- //! <b>Complexity</b>: Linear to the number of elements.
- ~slist()
- {} //AllocHolder clears the slist
+ //! <b>Complexity</b>: Linear to n.
+ void assign(size_type n, const T& val)
+ {
+ typedef constant_iterator<value_type, difference_type> cvalue_iterator;
+ return this->assign(cvalue_iterator(val, n), cvalue_iterator());
+ }
+
+ //! <b>Effects</b>: Assigns the range [first, last) to *this.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's constructor from dereferencing InpIt throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ template <class InpIt>
+ void assign(InpIt first, InpIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InpIt, size_type>::value
+ >::type * = 0
+ #endif
+ )
+ {
+ iterator end_n(this->end());
+ iterator prev(this->before_begin());
+ iterator node(this->begin());
+ while (node != end_n && first != last){
+ *node = *first;
+ prev = node;
+ ++node;
+ ++first;
+ }
+ if (first != last)
+ this->insert_after(prev, first, last);
+ else
+ this->erase_after(prev, end_n);
+ }
 
    //! <b>Effects</b>: Returns a copy of the internal allocator.
    //!
@@ -471,35 +519,49 @@
    allocator_type get_allocator() const
    { return allocator_type(this->node_alloc()); }
 
+ //! <b>Effects</b>: Returns a copy of the internal allocator.
+ //!
+ //! <b>Throws</b>: If allocator's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant.
    const stored_allocator_type &get_stored_allocator() const
    { return this->node_alloc(); }
 
+ //! <b>Effects</b>: Returns a reference to the internal allocator.
+ //!
+ //! <b>Throws</b>: Nothing
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Note</b>: Non-standard extension.
    stored_allocator_type &get_stored_allocator()
    { return this->node_alloc(); }
 
- public:
+ //////////////////////////////////////////////
+ //
+ // iterators
+ //
+ //////////////////////////////////////////////
 
- //! <b>Effects</b>: Assigns the n copies of val to *this.
+ //! <b>Effects</b>: Returns a non-dereferenceable iterator that,
+ //! when incremented, yields begin(). This iterator may be used
+ //! as the argument to insert_after, erase_after, etc.
    //!
- //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //! <b>Throws</b>: Nothing.
    //!
- //! <b>Complexity</b>: Linear to n.
- void assign(size_type n, const T& val)
- { this->priv_fill_assign(n, val); }
+ //! <b>Complexity</b>: Constant.
+ iterator before_begin()
+ { return iterator(end()); }
 
- //! <b>Effects</b>: Assigns the range [first, last) to *this.
+ //! <b>Effects</b>: Returns a non-dereferenceable const_iterator
+ //! that, when incremented, yields begin(). This iterator may be used
+ //! as the argument to insert_after, erase_after, etc.
    //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's constructor from dereferencing InpIt throws.
+ //! <b>Throws</b>: Nothing.
    //!
- //! <b>Complexity</b>: Linear to n.
- template <class InpIt>
- void assign(InpIt first, InpIt last)
- {
- const bool aux_boolean = container_detail::is_convertible<InpIt, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- this->priv_assign_dispatch(first, last, Result());
- }
+ //! <b>Complexity</b>: Constant.
+ const_iterator before_begin() const
+ { return this->cbefore_begin(); }
 
    //! <b>Effects</b>: Returns an iterator to the first element contained in the list.
    //!
@@ -533,25 +595,15 @@
    const_iterator end() const
    { return this->cend(); }
 
- //! <b>Effects</b>: Returns a non-dereferenceable iterator that,
- //! when incremented, yields begin(). This iterator may be used
- //! as the argument toinsert_after, erase_after, etc.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- iterator before_begin()
- { return iterator(end()); }
-
    //! <b>Effects</b>: Returns a non-dereferenceable const_iterator
    //! that, when incremented, yields begin(). This iterator may be used
- //! as the argument toinsert_after, erase_after, etc.
+ //! as the argument to insert_after, erase_after, etc.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_iterator before_begin() const
- { return this->cbefore_begin(); }
+ const_iterator cbefore_begin() const
+ { return const_iterator(end()); }
 
    //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
    //!
@@ -569,15 +621,43 @@
    const_iterator cend() const
    { return const_iterator(this->non_const_icont().end()); }
 
- //! <b>Effects</b>: Returns a non-dereferenceable const_iterator
- //! that, when incremented, yields begin(). This iterator may be used
- //! as the argument toinsert_after, erase_after, etc.
+ //! <b>Returns</b>: The iterator to the element before i in the sequence.
+ //! Returns the end-iterator, if either i is the begin-iterator or the
+ //! sequence is empty.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements before i.
+ //!
+ //! <b>Note</b>: Non-standard extension.
+ iterator previous(iterator p)
+ { return iterator(this->icont().previous(p.get())); }
+
+ //! <b>Returns</b>: The const_iterator to the element before i in the sequence.
+ //! Returns the end-const_iterator, if either i is the begin-const_iterator or
+ //! the sequence is empty.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements before i.
+ //!
+ //! <b>Note</b>: Non-standard extension.
+ const_iterator previous(const_iterator p)
+ { return const_iterator(this->icont().previous(p.get())); }
+
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Effects</b>: Returns true if the list contains no elements.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_iterator cbefore_begin() const
- { return const_iterator(end()); }
+ bool empty() const
+ { return !this->size(); }
 
    //! <b>Effects</b>: Returns the number of the elements contained in the list.
    //!
@@ -595,21 +675,40 @@
    size_type max_size() const
    { return AllocHolder::max_size(); }
 
- //! <b>Effects</b>: Returns true if the list contains no elements.
+ //! <b>Effects</b>: Inserts or erases elements at the end such that
+ //! the size becomes n. New elements are default constructed.
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
    //!
- //! <b>Complexity</b>: Constant.
- bool empty() const
- { return !this->size(); }
+ //! <b>Complexity</b>: Linear to the difference between size() and new_size.
+ void resize(size_type new_size)
+ {
+ const_iterator last_pos;
+ if(!priv_try_shrink(new_size, last_pos)){
+ typedef default_construct_iterator<value_type, difference_type> default_iterator;
+ this->insert_after(last_pos, default_iterator(new_size - this->size()), default_iterator());
+ }
+ }
 
- //! <b>Effects</b>: Swaps the contents of *this and x.
+ //! <b>Effects</b>: Inserts or erases elements at the end such that
+ //! the size becomes n. New elements are copy constructed from x.
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
    //!
- //! <b>Complexity</b>: Linear to the number of elements on *this and x.
- void swap(slist& x)
- { AllocHolder::swap(x); }
+ //! <b>Complexity</b>: Linear to the difference between size() and new_size.
+ void resize(size_type new_size, const T& x)
+ {
+ const_iterator last_pos;
+ if(!priv_try_shrink(new_size, last_pos)){
+ this->insert_after(last_pos, new_size, x);
+ }
+ }
+
+ //////////////////////////////////////////////
+ //
+ // element access
+ //
+ //////////////////////////////////////////////
 
    //! <b>Requires</b>: !empty()
    //!
@@ -633,64 +732,88 @@
    const_reference front() const
    { return *this->begin(); }
 
- //! <b>Effects</b>: Inserts a copy of t in the beginning of the list.
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
+
+ #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+
+ //! <b>Effects</b>: Inserts an object of type T constructed with
+ //! std::forward<Args>(args)... in the front of the list
    //!
    //! <b>Throws</b>: If memory allocation throws or
    //! T's copy constructor throws.
    //!
    //! <b>Complexity</b>: Amortized constant time.
- void push_front(insert_const_ref_type x)
- { return priv_push_front(x); }
+ template <class... Args>
+ void emplace_front(Args&&... args)
+ { this->emplace_after(this->cbefore_begin(), boost::forward<Args>(args)...); }
 
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- void push_front(T &x) { push_front(const_cast<const T &>(x)); }
+ //! <b>Effects</b>: Inserts an object of type T constructed with
+ //! std::forward<Args>(args)... after prev
+ //!
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's in-place constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant
+ template <class... Args>
+ iterator emplace_after(const_iterator prev, Args&&... args)
+ {
+ NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...));
+ return iterator(this->icont().insert_after(prev.get(), *pnode));
+ }
 
- template<class U>
- void push_front(const U &u
- , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return priv_push_front(u); }
- #endif
+ #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
- //! <b>Effects</b>: Constructs a new element in the beginning of the list
- //! and moves the resources of t to this new element.
- //!
- //! <b>Throws</b>: If memory allocation throws.
+ #define BOOST_PP_LOCAL_MACRO(n) \
+ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
+ void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { \
+ this->emplace(this->cbegin() \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
+ } \
+ \
+ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
+ iterator emplace_after(const_iterator prev \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { \
+ NodePtr pnode (AllocHolder::create_node \
+ (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \
+ return iterator(this->icont().insert_after(prev.get(), *pnode)); \
+ } \
    //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_front(BOOST_RV_REF(T) x)
- { this->icont().push_front(*this->create_node(boost::move(x))); }
+ #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+ #include BOOST_PP_LOCAL_ITERATE()
 
- //! <b>Effects</b>: Removes the first element from the list.
+ #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: Inserts a copy of x at the beginning of the list.
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's copy constructor throws.
    //!
    //! <b>Complexity</b>: Amortized constant time.
- void pop_front()
- { this->icont().pop_front_and_dispose(Destroyer(this->node_alloc())); }
+ void push_front(const T &x);
 
- //! <b>Returns</b>: The iterator to the element before i in the sequence.
- //! Returns the end-iterator, if either i is the begin-iterator or the
- //! sequence is empty.
+ //! <b>Effects</b>: Constructs a new element in the beginning of the list
+ //! and moves the resources of mx to this new element.
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: If memory allocation throws.
    //!
- //! <b>Complexity</b>: Linear to the number of elements before i.
- iterator previous(iterator p)
- { return iterator(this->icont().previous(p.get())); }
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_front(T &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
+ #endif
 
- //! <b>Returns</b>: The const_iterator to the element before i in the sequence.
- //! Returns the end-const_iterator, if either i is the begin-const_iterator or
- //! the sequence is empty.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Linear to the number of elements before i.
- const_iterator previous(const_iterator p)
- { return const_iterator(this->icont().previous(p.get())); }
 
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! <b>Requires</b>: p must be a valid iterator of *this.
    //!
- //! <b>Effects</b>: Inserts a copy of the value after the p pointed
+ //! <b>Effects</b>: Inserts a copy of the value after the position pointed
    //! by prev_p.
    //!
    //! <b>Returns</b>: An iterator to the inserted element.
@@ -701,18 +824,7 @@
    //!
    //! <b>Note</b>: Does not affect the validity of iterators and references of
    //! previous values.
- iterator insert_after(const_iterator prev_pos, insert_const_ref_type x)
- { return this->priv_insert_after(prev_pos, x); }
-
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- iterator insert_after(const_iterator position, T &x)
- { return this->insert_after(position, const_cast<const T &>(x)); }
-
- template<class U>
- iterator insert_after( const_iterator position, const U &u
- , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return this->priv_insert_after(position, u); }
- #endif
+ iterator insert_after(const_iterator prev_pos, const T &x);
 
    //! <b>Requires</b>: prev_pos must be a valid iterator of *this.
    //!
@@ -727,26 +839,36 @@
    //!
    //! <b>Note</b>: Does not affect the validity of iterators and references of
    //! previous values.
- iterator insert_after(const_iterator prev_pos, BOOST_RV_REF(value_type) x)
- { return iterator(this->icont().insert_after(prev_pos.get(), *this->create_node(boost::move(x)))); }
+ iterator insert_after(const_iterator prev_pos, T &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert_after, T, iterator, priv_insert_after, const_iterator)
+ #endif
 
    //! <b>Requires</b>: prev_pos must be a valid iterator of *this.
    //!
    //! <b>Effects</b>: Inserts n copies of x after prev_pos.
    //!
+ //! <b>Returns</b>: an iterator to the last inserted element or prev_pos if n is 0.
+ //!
    //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
    //!
+ //!
    //! <b>Complexity</b>: Linear to n.
    //!
    //! <b>Note</b>: Does not affect the validity of iterators and references of
    //! previous values.
- void insert_after(const_iterator prev_pos, size_type n, const value_type& x)
- { this->priv_create_and_insert_nodes(prev_pos, n, x); }
+ iterator insert_after(const_iterator prev_pos, size_type n, const value_type& x)
+ {
+ typedef constant_iterator<value_type, difference_type> cvalue_iterator;
+ return this->insert_after(prev_pos, cvalue_iterator(x, n), cvalue_iterator());
+ }
 
    //! <b>Requires</b>: prev_pos must be a valid iterator of *this.
    //!
    //! <b>Effects</b>: Inserts the range pointed by [first, last)
- //! after the p prev_pos.
+ //! after the position prev_pos.
+ //!
+ //! <b>Returns</b>: an iterator to the last inserted element or prev_pos if first == last.
    //!
    //! <b>Throws</b>: If memory allocation throws, T's constructor from a
    //! dereferenced InpIt throws.
@@ -755,137 +877,50 @@
    //!
    //! <b>Note</b>: Does not affect the validity of iterators and references of
    //! previous values.
- template <class InIter>
- void insert_after(const_iterator prev_pos, InIter first, InIter last)
+ template <class InpIt>
+ iterator insert_after(const_iterator prev_pos, InpIt first, InpIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InpIt, size_type>::value
+ && (container_detail::is_input_iterator<InpIt>::value
+ || container_detail::is_same<alloc_version, allocator_v1>::value
+ )
+ >::type * = 0
+ #endif
+ )
+ {
+ iterator ret_it(prev_pos.get());
+ for (; first != last; ++first){
+ ret_it = iterator(this->icont().insert_after(ret_it.get(), *this->create_node_from_it(first)));
+ }
+ return ret_it;
+ }
+
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ template <class FwdIt>
+ iterator insert_after(const_iterator prev, FwdIt first, FwdIt last
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<FwdIt, size_type>::value
+ && !(container_detail::is_input_iterator<FwdIt>::value
+ || container_detail::is_same<alloc_version, allocator_v1>::value
+ )
+ >::type * = 0
+ )
    {
- const bool aux_boolean = container_detail::is_convertible<InIter, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- this->priv_insert_after_range_dispatch(prev_pos, first, last, Result());
+ //Optimized allocation and construction
+ insertion_functor func(this->icont(), prev.get());
+ this->allocate_many_and_construct(first, std::distance(first, last), func);
+ return iterator(func.inserted_first());
    }
-
- //! <b>Requires</b>: p must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Insert a copy of x before p.
- //!
- //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to the elements before p.
- iterator insert(const_iterator position, insert_const_ref_type x)
- { return this->priv_insert(position, x); }
-
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- iterator insert(const_iterator position, T &x)
- { return this->insert(position, const_cast<const T &>(x)); }
-
- template<class U>
- iterator insert( const_iterator position, const U &u
- , typename container_detail::enable_if_c<container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return this->priv_insert(position, u); }
    #endif
 
- //! <b>Requires</b>: p must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Insert a new element before p with mx's resources.
- //!
- //! <b>Throws</b>: If memory allocation throws.
- //!
- //! <b>Complexity</b>: Linear to the elements before p.
- iterator insert(const_iterator p, BOOST_RV_REF(value_type) x)
- { return this->insert_after(previous(p), boost::move(x)); }
-
- //! <b>Requires</b>: p must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Inserts n copies of x before p.
- //!
- //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to n plus linear to the elements before p.
- void insert(const_iterator p, size_type n, const value_type& x)
- { return this->insert_after(previous(p), n, x); }
-
- //! <b>Requires</b>: p must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Insert a copy of the [first, last) range before p.
- //!
- //! <b>Throws</b>: If memory allocation throws, T's constructor from a
- //! dereferenced InpIt throws.
- //!
- //! <b>Complexity</b>: Linear to std::distance [first, last) plus
- //! linear to the elements before p.
- template <class InIter>
- void insert(const_iterator p, InIter first, InIter last)
- { return this->insert_after(previous(p), first, last); }
-
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... in the front of the list
+ //! <b>Effects</b>: Removes the first element from the list.
    //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's copy constructor throws.
+ //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Amortized constant time.
- template <class... Args>
- void emplace_front(Args&&... args)
- { this->emplace_after(this->cbefore_begin(), boost::forward<Args>(args)...); }
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... before p
- //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's in-place constructor throws.
- //!
- //! <b>Complexity</b>: Linear to the elements before p
- template <class... Args>
- iterator emplace(const_iterator p, Args&&... args)
- { return this->emplace_after(this->previous(p), boost::forward<Args>(args)...); }
-
- //! <b>Effects</b>: Inserts an object of type T constructed with
- //! std::forward<Args>(args)... after prev
- //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's in-place constructor throws.
- //!
- //! <b>Complexity</b>: Constant
- template <class... Args>
- iterator emplace_after(const_iterator prev, Args&&... args)
- {
- NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...));
- return iterator(this->icont().insert_after(prev.get(), *pnode));
- }
-
- #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
- #define BOOST_PP_LOCAL_MACRO(n) \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- this->emplace(this->cbegin() \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- } \
- \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- iterator emplace (const_iterator p \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- return this->emplace_after \
- (this->previous(p) \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- } \
- \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- iterator emplace_after(const_iterator prev \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- NodePtr pnode (AllocHolder::create_node \
- (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \
- return iterator(this->icont().insert_after(prev.get(), *pnode)); \
- } \
- //!
- #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+ void pop_front()
+ { this->icont().pop_front_and_dispose(Destroyer(this->node_alloc())); }
 
    //! <b>Effects</b>: Erases the element after the element pointed by prev_pos
    //! of the list.
@@ -919,69 +954,13 @@
       return iterator(this->icont().erase_after_and_dispose(before_first.get(), last.get(), Destroyer(this->node_alloc())));
    }
 
- //! <b>Requires</b>: p must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Erases the element at p p.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Linear to the number of elements before p.
- iterator erase(const_iterator p)
- { return iterator(this->erase_after(previous(p))); }
-
- //! <b>Requires</b>: first and last must be valid iterator to elements in *this.
- //!
- //! <b>Effects</b>: Erases the elements pointed by [first, last).
+ //! <b>Effects</b>: Swaps the contents of *this and x.
    //!
    //! <b>Throws</b>: Nothing.
    //!
- //! <b>Complexity</b>: Linear to the distance between first and last plus
- //! linear to the elements before first.
- iterator erase(const_iterator first, const_iterator last)
- { return iterator(this->erase_after(previous(first), last)); }
-
- //! <b>Effects</b>: Inserts or erases elements at the end such that
- //! the size becomes n. New elements are copy constructed from x.
- //!
- //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size, const T& x)
- {
- typename Icont::iterator end_n(this->icont().end()), cur(this->icont().before_begin()), cur_next;
- while (++(cur_next = cur) != end_n && new_size > 0){
- --new_size;
- cur = cur_next;
- }
- if (cur_next != end_n)
- this->erase_after(const_iterator(cur), const_iterator(end_n));
- else
- this->insert_after(const_iterator(cur), new_size, x);
- }
-
- //! <b>Effects</b>: Inserts or erases elements at the end such that
- //! the size becomes n. New elements are default constructed.
- //!
- //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size)
- {
- typename Icont::iterator end_n(this->icont().end()), cur(this->icont().before_begin()), cur_next;
- size_type len = this->size();
- size_type left = new_size;
-
- while (++(cur_next = cur) != end_n && left > 0){
- --left;
- cur = cur_next;
- }
- if (cur_next != end_n){
- this->erase_after(const_iterator(cur), const_iterator(end_n));
- }
- else{
- this->priv_create_and_insert_nodes(const_iterator(cur), new_size - len);
- }
- }
+ //! <b>Complexity</b>: Linear to the number of elements on *this and x.
+ void swap(slist& x)
+ { AllocHolder::swap(x); }
 
    //! <b>Effects</b>: Erases all the elements of the list.
    //!
@@ -991,6 +970,12 @@
    void clear()
    { this->icont().clear_and_dispose(Destroyer(this->node_alloc())); }
 
+ //////////////////////////////////////////////
+ //
+ // slist operations
+ //
+ //////////////////////////////////////////////
+
    //! <b>Requires</b>: p must point to an element contained
    //! by the list. x != *this
    //!
@@ -1006,14 +991,27 @@
    //! this list. Iterators of this list and all the references are not invalidated.
    void splice_after(const_iterator prev_pos, slist& x)
    {
- if((NodeAlloc&)*this == (NodeAlloc&)x){
- this->icont().splice_after(prev_pos.get(), x.icont());
- }
- else{
- throw std::runtime_error("slist::splice called with unequal allocators");
- }
+ BOOST_ASSERT(*this != x);
+ BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+ this->icont().splice_after(prev_pos.get(), x.icont());
    }
 
+ //! <b>Requires</b>: p must point to an element contained
+ //! by the list. x != *this
+ //!
+ //! <b>Effects</b>: Transfers all the elements of list x to this list, after the
+ //! the element pointed by p. No destructors or copy constructors are called.
+ //!
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
+ //!
+ //! <b>Complexity</b>: Linear to the elements in x.
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of
+ //! this list. Iterators of this list and all the references are not invalidated.
+ void splice_after(const_iterator prev_pos, BOOST_RV_REF(slist) x)
+ { this->splice_after(prev_pos, static_cast<slist&>(x)); }
+
    //! <b>Requires</b>: prev_pos must be a valid iterator of this.
    //! i must point to an element contained in list x.
    //!
@@ -1030,15 +1028,29 @@
    //! list. Iterators of this list and all the references are not invalidated.
    void splice_after(const_iterator prev_pos, slist& x, const_iterator prev)
    {
- if((NodeAlloc&)*this == (NodeAlloc&)x){
- this->icont().splice_after(prev_pos.get(), x.icont(), prev.get());
- }
- else{
- throw std::runtime_error("slist::splice called with unequal allocators");
- }
+ BOOST_ASSERT(*this != x);
+ BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+ this->icont().splice_after(prev_pos.get(), x.icont(), prev.get());
    }
 
    //! <b>Requires</b>: prev_pos must be a valid iterator of this.
+ //! i must point to an element contained in list x.
+ //!
+ //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
+ //! after the element pointed by prev_pos.
+ //! If prev_pos == prev or prev_pos == ++prev, this function is a null operation.
+ //!
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
+ //! list. Iterators of this list and all the references are not invalidated.
+ void splice_after(const_iterator prev_pos, BOOST_RV_REF(slist) x, const_iterator prev)
+ { this->splice_after(prev_pos, static_cast<slist&>(x), prev); }
+
+ //! <b>Requires</b>: prev_pos must be a valid iterator of this.
    //! before_first and before_last must be valid iterators of x.
    //! prev_pos must not be contained in [before_first, before_last) range.
    //!
@@ -1055,19 +1067,15 @@
    void splice_after(const_iterator prev_pos, slist& x,
       const_iterator before_first, const_iterator before_last)
    {
- if((NodeAlloc&)*this == (NodeAlloc&)x){
- this->icont().splice_after
- (prev_pos.get(), x.icont(), before_first.get(), before_last.get());
- }
- else{
- throw std::runtime_error("slist::splice called with unequal allocators");
- }
+ BOOST_ASSERT(*this != x);
+ BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+ this->icont().splice_after
+ (prev_pos.get(), x.icont(), before_first.get(), before_last.get());
    }
 
    //! <b>Requires</b>: prev_pos must be a valid iterator of this.
    //! before_first and before_last must be valid iterators of x.
    //! prev_pos must not be contained in [before_first, before_last) range.
- //! n == std::distance(before_first, before_last)
    //!
    //! <b>Effects</b>: Transfers the range [before_first + 1, before_last + 1)
    //! from list x to this list, after the element pointed by prev_pos.
@@ -1075,82 +1083,58 @@
    //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
    //! are not equal.
    //!
- //! <b>Complexity</b>: Constant.
+ //! <b>Complexity</b>: Linear to the number of transferred elements.
    //!
    //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
    //! list. Iterators of this list and all the references are not invalidated.
- void splice_after(const_iterator prev_pos, slist& x,
- const_iterator before_first, const_iterator before_last,
- size_type n)
- {
- if((NodeAlloc&)*this == (NodeAlloc&)x){
- this->icont().splice_after
- (prev_pos.get(), x.icont(), before_first.get(), before_last.get(), n);
- }
- else{
- throw std::runtime_error("slist::splice called with unequal allocators");
- }
- }
-
- //! <b>Requires</b>: p must point to an element contained
- //! by the list. x != *this
- //!
- //! <b>Effects</b>: Transfers all the elements of list x to this list, before the
- //! the element pointed by p. No destructors or copy constructors are called.
- //!
- //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
- //! are not equal.
- //!
- //! <b>Complexity</b>: Linear in distance(begin(), p), and linear in x.size().
- //!
- //! <b>Note</b>: Iterators of values obtained from list x now point to elements of
- //! this list. Iterators of this list and all the references are not invalidated.
- void splice(const_iterator p, ThisType& x)
- { this->splice_after(this->previous(p), x); }
+ void splice_after(const_iterator prev_pos, BOOST_RV_REF(slist) x,
+ const_iterator before_first, const_iterator before_last)
+ { this->splice_after(prev_pos, static_cast<slist&>(x), before_first, before_last); }
 
- //! <b>Requires</b>: p must point to an element contained
- //! by this list. i must point to an element contained in list x.
+ //! <b>Requires</b>: prev_pos must be a valid iterator of this.
+ //! before_first and before_last must be valid iterators of x.
+ //! prev_pos must not be contained in [before_first, before_last) range.
+ //! n == std::distance(before_first, before_last)
    //!
- //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
- //! before the the element pointed by p. No destructors or copy constructors are called.
- //! If p == i or p == ++i, this function is a null operation.
+ //! <b>Effects</b>: Transfers the range [before_first + 1, before_last + 1)
+ //! from list x to this list, after the element pointed by prev_pos.
    //!
    //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
    //! are not equal.
    //!
- //! <b>Complexity</b>: Linear in distance(begin(), p), and in distance(x.begin(), i).
+ //! <b>Complexity</b>: Constant.
    //!
    //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
    //! list. Iterators of this list and all the references are not invalidated.
- void splice(const_iterator p, slist& x, const_iterator i)
- { this->splice_after(previous(p), x, i); }
+ void splice_after(const_iterator prev_pos, slist& x,
+ const_iterator before_first, const_iterator before_last,
+ size_type n)
+ {
+ BOOST_ASSERT(*this != x);
+ BOOST_ASSERT(this->node_alloc() == x.node_alloc());
+ this->icont().splice_after
+ (prev_pos.get(), x.icont(), before_first.get(), before_last.get(), n);
+ }
 
- //! <b>Requires</b>: p must point to an element contained
- //! by this list. first and last must point to elements contained in list x.
+ //! <b>Requires</b>: prev_pos must be a valid iterator of this.
+ //! before_first and before_last must be valid iterators of x.
+ //! prev_pos must not be contained in [before_first, before_last) range.
+ //! n == std::distance(before_first, before_last)
    //!
- //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
- //! before the the element pointed by p. No destructors or copy constructors are called.
+ //! <b>Effects</b>: Transfers the range [before_first + 1, before_last + 1)
+ //! from list x to this list, after the element pointed by prev_pos.
    //!
    //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
    //! are not equal.
    //!
- //! <b>Complexity</b>: Linear in distance(begin(), p), in distance(x.begin(), first),
- //! and in distance(first, last).
+ //! <b>Complexity</b>: Constant.
    //!
    //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
    //! list. Iterators of this list and all the references are not invalidated.
- void splice(const_iterator p, slist& x, const_iterator first, const_iterator last)
- { this->splice_after(previous(p), x, previous(first), previous(last)); }
-
- //! <b>Effects</b>: Reverses the order of elements in the list.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: This function is linear time.
- //!
- //! <b>Note</b>: Iterators and references are not invalidated
- void reverse()
- { this->icont().reverse(); }
+ void splice_after(const_iterator prev_pos, BOOST_RV_REF(slist) x,
+ const_iterator before_first, const_iterator before_last,
+ size_type n)
+ { this->splice_after(prev_pos, static_cast<slist&>(x), before_first, before_last, n); }
 
    //! <b>Effects</b>: Removes all the elements that compare equal to value.
    //!
@@ -1161,7 +1145,7 @@
    //! <b>Note</b>: The relative order of elements that are not removed is unchanged,
    //! and iterators to elements that are not removed remain valid.
    void remove(const T& value)
- { remove_if(equal_to_value(value)); }
+ { this->remove_if(equal_to_value(value)); }
 
    //! <b>Effects</b>: Removes all the elements for which a specified
    //! predicate is satisfied.
@@ -1221,6 +1205,20 @@
    void merge(slist & x)
    { this->merge(x, value_less()); }
 
+ //! <b>Requires</b>: The lists x and *this must be distinct.
+ //!
+ //! <b>Effects</b>: This function removes all of x's elements and inserts them
+ //! in order into *this according to std::less<value_type>. The merge is stable;
+ //! that is, if an element from *this is equivalent to one from x, then the element
+ //! from *this will precede the one from x.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: This function is linear time: it performs at most
+ //! size() + x.size() - 1 comparisons.
+ void merge(BOOST_RV_REF(slist) x)
+ { this->merge(static_cast<slist&>(x)); }
+
    //! <b>Requires</b>: p must be a comparison function that induces a strict weak
    //! ordering and both *this and x must be sorted according to that ordering
    //! The lists x and *this must be distinct.
@@ -1247,6 +1245,24 @@
       }
    }
 
+ //! <b>Requires</b>: p must be a comparison function that induces a strict weak
+ //! ordering and both *this and x must be sorted according to that ordering
+ //! The lists x and *this must be distinct.
+ //!
+ //! <b>Effects</b>: This function removes all of x's elements and inserts them
+ //! in order into *this. The merge is stable; that is, if an element from *this is
+ //! equivalent to one from x, then the element from *this will precede the one from x.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: This function is linear time: it performs at most
+ //! size() + x.size() - 1 comparisons.
+ //!
+ //! <b>Note</b>: Iterators and references to *this are not invalidated.
+ template <class StrictWeakOrdering>
+ void merge(BOOST_RV_REF(slist) x, StrictWeakOrdering comp)
+ { this->merge(static_cast<slist&>(x), comp); }
+
    //! <b>Effects</b>: This function sorts the list *this according to std::less<value_type>.
    //! The sort is stable, that is, the relative order of equivalent elements is preserved.
    //!
@@ -1277,139 +1293,291 @@
       this->icont().sort(ValueCompareToNodeCompare<StrictWeakOrdering>(comp));
    }
 
- /// @cond
- private:
- iterator priv_insert(const_iterator p, const value_type& x)
- { return this->insert_after(previous(p), x); }
+ //! <b>Effects</b>: Reverses the order of elements in the list.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: This function is linear time.
+ //!
+ //! <b>Note</b>: Iterators and references are not invalidated
+ void reverse()
+ { this->icont().reverse(); }
+
+ //////////////////////////////////////////////
+ //
+ // list compatibility interface
+ //
+ //////////////////////////////////////////////
 
- iterator priv_insert_after(const_iterator prev_pos, const value_type& x)
- { return iterator(this->icont().insert_after(prev_pos.get(), *this->create_node(x))); }
+ #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
- void priv_push_front(const value_type &x)
- { this->icont().push_front(*this->create_node(x)); }
+ //! <b>Effects</b>: Inserts an object of type T constructed with
+ //! std::forward<Args>(args)... before p
+ //!
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's in-place constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to the elements before p
+ template <class... Args>
+ iterator emplace(const_iterator p, Args&&... args)
+ { return this->emplace_after(this->previous(p), boost::forward<Args>(args)...); }
+
+ #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+
+ #define BOOST_PP_LOCAL_MACRO(n) \
+ BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
+ iterator emplace (const_iterator p \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
+ { \
+ return this->emplace_after \
+ (this->previous(p) \
+ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
+ } \
+ //!
+ #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
+ #include BOOST_PP_LOCAL_ITERATE()
+ #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
- //Iterator range version
- template<class InpIterator>
- void priv_create_and_insert_nodes
- (const_iterator prev, InpIterator beg, InpIterator end)
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Requires</b>: p must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert a copy of x before p.
+ //!
+ //! <b>Returns</b>: an iterator to the inserted element.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to the elements before p.
+ iterator insert(const_iterator position, const T &x);
+
+ //! <b>Requires</b>: p must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert a new element before p with mx's resources.
+ //!
+ //! <b>Returns</b>: an iterator to the inserted element.
+ //!
+ //! <b>Throws</b>: If memory allocation throws.
+ //!
+ //! <b>Complexity</b>: Linear to the elements before p.
+ iterator insert(const_iterator prev_pos, T &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
+ #endif
+
+ //! <b>Requires</b>: p must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Inserts n copies of x before p.
+ //!
+ //! <b>Returns</b>: an iterator to the first inserted element or p if n == 0.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to n plus linear to the elements before p.
+ iterator insert(const_iterator p, size_type n, const value_type& x)
    {
- typedef typename std::iterator_traits<InpIterator>::iterator_category ItCat;
- priv_create_and_insert_nodes(prev, beg, end, alloc_version(), ItCat());
+ const_iterator prev(this->previous(p));
+ this->insert_after(prev, n, x);
+ return ++iterator(prev.get());
    }
-
- template<class InpIterator>
- void priv_create_and_insert_nodes
- (const_iterator prev, InpIterator beg, InpIterator end, allocator_v1, std::input_iterator_tag)
+
+ //! <b>Requires</b>: p must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert a copy of the [first, last) range before p.
+ //!
+ //! <b>Returns</b>: an iterator to the first inserted element or p if first == last.
+ //!
+ //! <b>Throws</b>: If memory allocation throws, T's constructor from a
+ //! dereferenced InpIt throws.
+ //!
+ //! <b>Complexity</b>: Linear to std::distance [first, last) plus
+ //! linear to the elements before p.
+ template <class InIter>
+ iterator insert(const_iterator p, InIter first, InIter last)
    {
- for (; beg != end; ++beg){
- this->icont().insert_after(prev.get(), *this->create_node_from_it(beg));
- ++prev;
- }
+ const_iterator prev(this->previous(p));
+ this->insert_after(prev, first, last);
+ return ++iterator(prev.get());
    }
 
- template<class InpIterator>
- void priv_create_and_insert_nodes
- (const_iterator prev, InpIterator beg, InpIterator end, allocator_v2, std::input_iterator_tag)
- { //Just forward to the default one
- priv_create_and_insert_nodes(prev, beg, end, allocator_v1(), std::input_iterator_tag());
- }
+ //! <b>Requires</b>: p must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Erases the element at p p.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements before p.
+ iterator erase(const_iterator p)
+ { return iterator(this->erase_after(previous(p))); }
 
- class insertion_functor;
- friend class insertion_functor;
+ //! <b>Requires</b>: first and last must be valid iterator to elements in *this.
+ //!
+ //! <b>Effects</b>: Erases the elements pointed by [first, last).
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear to the distance between first and last plus
+ //! linear to the elements before first.
+ iterator erase(const_iterator first, const_iterator last)
+ { return iterator(this->erase_after(previous(first), last)); }
 
- class insertion_functor
- {
- Icont &icont_;
- typename Icont::const_iterator prev_;
+ //! <b>Requires</b>: p must point to an element contained
+ //! by the list. x != *this
+ //!
+ //! <b>Effects</b>: Transfers all the elements of list x to this list, before the
+ //! the element pointed by p. No destructors or copy constructors are called.
+ //!
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
+ //!
+ //! <b>Complexity</b>: Linear in distance(begin(), p), and linear in x.size().
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of
+ //! this list. Iterators of this list and all the references are not invalidated.
+ void splice(const_iterator p, slist& x)
+ { this->splice_after(this->previous(p), x); }
 
- public:
- insertion_functor(Icont &icont, typename Icont::const_iterator prev)
- : icont_(icont), prev_(prev)
- {}
+ //! <b>Requires</b>: p must point to an element contained
+ //! by the list. x != *this
+ //!
+ //! <b>Effects</b>: Transfers all the elements of list x to this list, before the
+ //! the element pointed by p. No destructors or copy constructors are called.
+ //!
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
+ //!
+ //! <b>Complexity</b>: Linear in distance(begin(), p), and linear in x.size().
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of
+ //! this list. Iterators of this list and all the references are not invalidated.
+ void splice(const_iterator p, BOOST_RV_REF(slist) x)
+ { this->splice(p, static_cast<slist&>(x)); }
 
- void operator()(Node &n)
- { prev_ = this->icont_.insert_after(prev_, n); }
- };
+ //! <b>Requires</b>: p must point to an element contained
+ //! by this list. i must point to an element contained in list x.
+ //!
+ //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
+ //! before the the element pointed by p. No destructors or copy constructors are called.
+ //! If p == i or p == ++i, this function is a null operation.
+ //!
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
+ //!
+ //! <b>Complexity</b>: Linear in distance(begin(), p), and in distance(x.begin(), i).
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
+ //! list. Iterators of this list and all the references are not invalidated.
+ void splice(const_iterator p, slist& x, const_iterator i)
+ { this->splice_after(this->previous(p), x, this->previous(i)); }
 
- template<class FwdIterator>
- void priv_create_and_insert_nodes
- (const_iterator prev, FwdIterator beg, FwdIterator end, allocator_v2, std::forward_iterator_tag)
- {
- //Optimized allocation and construction
- this->allocate_many_and_construct
- (beg, std::distance(beg, end), insertion_functor(this->icont(), prev.get()));
- }
+ //! <b>Requires</b>: p must point to an element contained
+ //! by this list. i must point to an element contained in list x.
+ //!
+ //! <b>Effects</b>: Transfers the value pointed by i, from list x to this list,
+ //! before the the element pointed by p. No destructors or copy constructors are called.
+ //! If p == i or p == ++i, this function is a null operation.
+ //!
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
+ //!
+ //! <b>Complexity</b>: Linear in distance(begin(), p), and in distance(x.begin(), i).
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
+ //! list. Iterators of this list and all the references are not invalidated.
+ void splice(const_iterator p, BOOST_RV_REF(slist) x, const_iterator i)
+ { this->splice(p, static_cast<slist&>(x), i); }
 
- //Default constructed version
- void priv_create_and_insert_nodes(const_iterator prev, size_type n)
- {
- typedef default_construct_iterator<value_type, difference_type> default_iterator;
- this->priv_create_and_insert_nodes(prev, default_iterator(n), default_iterator());
- }
+ //! <b>Requires</b>: p must point to an element contained
+ //! by this list. first and last must point to elements contained in list x.
+ //!
+ //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
+ //! before the the element pointed by p. No destructors or copy constructors are called.
+ //!
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
+ //!
+ //! <b>Complexity</b>: Linear in distance(begin(), p), in distance(x.begin(), first),
+ //! and in distance(first, last).
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
+ //! list. Iterators of this list and all the references are not invalidated.
+ void splice(const_iterator p, slist& x, const_iterator first, const_iterator last)
+ { this->splice_after(this->previous(p), x, this->previous(first), this->previous(last)); }
 
- //Copy constructed version
- void priv_create_and_insert_nodes(const_iterator prev, size_type n, const T& x)
- {
- typedef constant_iterator<value_type, difference_type> cvalue_iterator;
- this->priv_create_and_insert_nodes(prev, cvalue_iterator(x, n), cvalue_iterator());
- }
+ //! <b>Requires</b>: p must point to an element contained
+ //! by this list. first and last must point to elements contained in list x.
+ //!
+ //! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
+ //! before the the element pointed by p. No destructors or copy constructors are called.
+ //!
+ //! <b>Throws</b>: std::runtime_error if this' allocator and x's allocator
+ //! are not equal.
+ //!
+ //! <b>Complexity</b>: Linear in distance(begin(), p), in distance(x.begin(), first),
+ //! and in distance(first, last).
+ //!
+ //! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
+ //! list. Iterators of this list and all the references are not invalidated.
+ void splice(const_iterator p, BOOST_RV_REF(slist) x, const_iterator first, const_iterator last)
+ { this->splice(p, static_cast<slist&>(x), first, last); }
+
+ /// @cond
+ private:
 
- //Dispatch to detect iterator range or integer overloads
- template <class InputIter>
- void priv_insert_dispatch(const_iterator prev,
- InputIter first, InputIter last,
- container_detail::false_)
- { this->priv_create_and_insert_nodes(prev, first, last); }
+ void priv_push_front (const T &x)
+ { this->insert(this->cbegin(), x); }
 
- template<class Integer>
- void priv_insert_dispatch(const_iterator prev, Integer n, Integer x, container_detail::true_)
- { this->priv_create_and_insert_nodes(prev, (size_type)n, x); }
+ void priv_push_front (BOOST_RV_REF(T) x)
+ { this->insert(this->cbegin(), ::boost::move(x)); }
 
- void priv_fill_assign(size_type n, const T& val)
+ bool priv_try_shrink(size_type new_size, const_iterator &last_pos)
    {
- iterator end_n(this->end());
- iterator prev(this->before_begin());
- iterator node(this->begin());
- for ( ; node != end_n && n > 0 ; --n){
- *node = val;
- prev = node;
- ++node;
+ typename Icont::iterator end_n(this->icont().end()), cur(this->icont().before_begin()), cur_next;
+ while (++(cur_next = cur) != end_n && new_size > 0){
+ --new_size;
+ cur = cur_next;
+ }
+ last_pos = const_iterator(cur);
+ if (cur_next != end_n){
+ this->erase_after(last_pos, const_iterator(end_n));
+ return true;
+ }
+ else{
+ return false;
       }
- if (n > 0)
- this->priv_create_and_insert_nodes(prev, n, val);
- else
- this->erase_after(prev, end_n);
    }
 
- template <class Int>
- void priv_assign_dispatch(Int n, Int val, container_detail::true_)
- { this->priv_fill_assign((size_type) n, (T)val); }
+ template<class U>
+ iterator priv_insert(const_iterator p, BOOST_FWD_REF(U) x)
+ { return this->insert_after(previous(p), ::boost::forward<U>(x)); }
 
- template <class InpIt>
- void priv_assign_dispatch(InpIt first, InpIt last, container_detail::false_)
+ template<class U>
+ iterator priv_insert_after(const_iterator prev_pos, BOOST_FWD_REF(U) x)
+ { return iterator(this->icont().insert_after(prev_pos.get(), *this->create_node(::boost::forward<U>(x)))); }
+
+ class insertion_functor;
+ friend class insertion_functor;
+
+ class insertion_functor
    {
- iterator end_n(this->end());
- iterator prev(this->before_begin());
- iterator node(this->begin());
- while (node != end_n && first != last){
- *node = *first;
- prev = node;
- ++node;
- ++first;
- }
- if (first != last)
- this->priv_create_and_insert_nodes(prev, first, last);
- else
- this->erase_after(prev, end_n);
- }
+ Icont &icont_;
+ typedef typename Icont::iterator iiterator;
+ typedef typename Icont::const_iterator iconst_iterator;
+ const iconst_iterator prev_;
+ iiterator ret_;
+
+ public:
+ insertion_functor(Icont &icont, typename Icont::const_iterator prev)
+ : icont_(icont), prev_(prev), ret_(prev.unconst())
+ {}
 
- template <class Int>
- void priv_insert_after_range_dispatch(const_iterator prev_pos, Int n, Int x, container_detail::true_)
- { this->priv_create_and_insert_nodes(prev_pos, (size_type)n, x); }
+ void operator()(Node &n)
+ {
+ ret_ = this->icont_.insert_after(prev_, n);
+ }
 
- template <class InIter>
- void priv_insert_after_range_dispatch(const_iterator prev_pos, InIter first, InIter last, container_detail::false_)
- { this->priv_create_and_insert_nodes(prev_pos, first, last); }
+ iiterator inserted_first() const
+ { return ret_; }
+ };
 
    //Functors for member algorithm defaults
    struct value_less

Modified: branches/release/boost/container/stable_vector.hpp
==============================================================================
--- branches/release/boost/container/stable_vector.hpp (original)
+++ branches/release/boost/container/stable_vector.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -28,6 +28,7 @@
 #include <boost/container/container_fwd.hpp>
 #include <boost/mpl/bool.hpp>
 #include <boost/mpl/not.hpp>
+#include <boost/assert.hpp>
 #include <boost/type_traits/is_integral.hpp>
 #include <boost/container/detail/version_type.hpp>
 #include <boost/container/detail/multiallocation_chain.hpp>
@@ -36,10 +37,11 @@
 #include <boost/container/detail/algorithms.hpp>
 #include <boost/container/allocator_traits.hpp>
 #include <boost/intrusive/pointer_traits.hpp>
-
-#include <algorithm>
+#include <boost/aligned_storage.hpp>
+#include <algorithm> //max
 #include <stdexcept>
 #include <memory>
+#include <new> //placement new
 
 ///@cond
 
@@ -47,10 +49,6 @@
 
 //#define STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
 
-#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
-#include <boost/assert.hpp>
-#endif
-
 ///@endcond
 
 namespace boost {
@@ -60,24 +58,6 @@
 
 namespace stable_vector_detail{
 
-template<class SmartPtr>
-struct smart_ptr_type
-{
- typedef typename SmartPtr::value_type value_type;
- typedef value_type *pointer;
- static pointer get (const SmartPtr &smartptr)
- { return smartptr.get();}
-};
-
-template<class T>
-struct smart_ptr_type<T*>
-{
- typedef T value_type;
- typedef value_type *pointer;
- static pointer get (pointer ptr)
- { return ptr;}
-};
-
 template <class C>
 class clear_on_destroy
 {
@@ -93,7 +73,7 @@
    {
       if(do_clear_){
          c_.clear();
- c_.clear_pool();
+ c_.priv_clear_pool();
       }
    }
 
@@ -104,23 +84,40 @@
    bool do_clear_;
 };
 
+template<typename VoidPointer, typename T>
+struct node;
+
 template<class VoidPtr>
-struct node_type_base
+struct node_base
 {
- node_type_base()
+ private:
+ typedef typename boost::intrusive::
+ pointer_traits<VoidPtr> void_ptr_traits;
+ typedef typename void_ptr_traits::
+ template rebind_pointer
+ <node_base>::type node_base_ptr;
+ typedef typename void_ptr_traits::
+ template rebind_pointer
+ <node_base_ptr>::type node_base_ptr_ptr;
+
+ public:
+ node_base(const node_base_ptr_ptr &n)
+ : up(n)
+ {}
+
+ node_base()
+ : up()
    {}
- void set_pointer(const VoidPtr &p)
- { up = p; }
 
- VoidPtr up;
+ node_base_ptr_ptr up;
 };
 
 template<typename VoidPointer, typename T>
-struct node_type
- : public node_type_base<VoidPointer>
+struct node
+ : public node_base<VoidPointer>
 {
    private:
- node_type();
+ node();
 
    public:
    T value;
@@ -135,87 +132,78 @@
                          , Pointer
                          , Reference>
 {
- typedef typename boost::intrusive::
- pointer_traits<Pointer>::template
- rebind_pointer<void>::type void_ptr;
- typedef typename boost::intrusive::
- pointer_traits<Pointer>::template
- rebind_pointer<const void>::type const_void_ptr;
- typedef node_type<void_ptr, T> node_type_t;
- typedef typename boost::intrusive::
- pointer_traits<Pointer>::template
- rebind_pointer<node_type_t>::type node_type_ptr_t;
- typedef typename boost::intrusive::
- pointer_traits<Pointer>::template
- rebind_pointer<const node_type_t>::type const_node_type_ptr_t;
- typedef typename boost::intrusive::
- pointer_traits<Pointer>::template
- rebind_pointer<void_ptr>::type void_ptr_ptr;
+ typedef boost::intrusive::
+ pointer_traits<Pointer> ptr_traits;
+ typedef typename ptr_traits::template
+ rebind_pointer<void>::type void_ptr;
+ typedef node<void_ptr, T> node_type;
+ typedef node_base<void_ptr> node_base_type;
+ typedef typename ptr_traits::template
+ rebind_pointer<node_type>::type node_ptr;
+ typedef boost::intrusive::
+ pointer_traits<node_ptr> node_ptr_traits;
+ typedef typename ptr_traits::template
+ rebind_pointer<node_base_type>::type node_base_ptr;
+ typedef typename ptr_traits::template
+ rebind_pointer<node_base_ptr>::type node_base_ptr_ptr;
+ typedef typename ptr_traits::template
+ rebind_pointer<T>::type friend_iterator_pointer;
 
- friend class iterator<T, const T, typename boost::intrusive::pointer_traits<Pointer>::template rebind_pointer<T>::type>;
+ friend class iterator<T, const T, friend_iterator_pointer>;
 
    public:
    typedef std::random_access_iterator_tag iterator_category;
    typedef T value_type;
- typedef typename boost::intrusive::
- pointer_traits<Pointer>::difference_type difference_type;
+ typedef typename ptr_traits::difference_type difference_type;
    typedef Pointer pointer;
    typedef Reference reference;
 
    iterator()
    {}
 
- explicit iterator(node_type_ptr_t pn)
- : pn(pn)
+ explicit iterator(node_ptr p)
+ : pn(p)
    {}
 
- iterator(const iterator<T, T&, typename boost::intrusive::pointer_traits<Pointer>::template rebind_pointer<T>::type>& x)
+ iterator(const iterator<T, T&, friend_iterator_pointer>& x)
       : pn(x.pn)
    {}
-
- private:
- static node_type_ptr_t node_ptr_cast(const void_ptr &p)
- {
- return node_type_ptr_t(static_cast<node_type_t*>(container_detail::to_raw_pointer(p)));
- }
 
- static const_node_type_ptr_t node_ptr_cast(const const_void_ptr &p)
- {
- return const_node_type_ptr_t(static_cast<const node_type_t*>(container_detail::to_raw_pointer(p)));
- }
-
- static void_ptr_ptr void_ptr_ptr_cast(const void_ptr &p)
- {
- return void_ptr_ptr(static_cast<void_ptr*>(container_detail::to_raw_pointer(p)));
- }
+ node_ptr &node_pointer()
+ { return pn; }
 
- reference dereference() const
- { return pn->value; }
- bool equal(const iterator& x) const
- { return pn==x.pn; }
- void increment()
- { pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)+1)); }
- void decrement()
- { pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)-1)); }
- void advance(difference_type n)
- { pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)+n)); }
- difference_type distance_to(const iterator& x)const
- { return void_ptr_ptr_cast(x.pn->up) - void_ptr_ptr_cast(pn->up); }
+ const node_ptr &node_pointer() const
+ { return pn; }
 
    public:
    //Pointer like operators
- reference operator*() const { return this->dereference(); }
- pointer operator->() const { return pointer(&this->dereference()); }
+ reference operator*() const
+ { return pn->value; }
+
+ pointer operator->() const
+ { return ptr_traits::pointer_to(this->operator*()); }
 
    //Increment / Decrement
- iterator& operator++()
- { this->increment(); return *this; }
+ iterator& operator++()
+ {
+ if(node_base_ptr_ptr p = this->pn->up){
+ ++p;
+ this->pn = node_ptr_traits::static_cast_from(*p);
+ }
+ return *this;
+ }
 
    iterator operator++(int)
    { iterator tmp(*this); ++*this; return iterator(tmp); }
 
    iterator& operator--()
- { this->decrement(); return *this; }
+ {
+ if(node_base_ptr_ptr p = this->pn->up){
+ --p;
+ this->pn = node_ptr_traits::static_cast_from(*p);
+ }
+ return *this;
+ }
 
    iterator operator--(int)
    { iterator tmp(*this); --*this; return iterator(tmp); }
@@ -229,7 +217,10 @@
 
    iterator& operator+=(difference_type off)
    {
- pn = node_ptr_cast(*(void_ptr_ptr_cast(pn->up)+off));
+ if(node_base_ptr_ptr p = this->pn->up){
+ p += off;
+ this->pn = node_ptr_traits::static_cast_from(*p);
+ }
       return *this;
    }
 
@@ -259,7 +250,7 @@
 
    friend difference_type operator-(const iterator& left, const iterator& right)
    {
- return void_ptr_ptr_cast(left.pn->up) - void_ptr_ptr_cast(right.pn->up);
+ return left.pn->up - right.pn->up;
    }
 
    //Comparison operators
@@ -270,18 +261,18 @@
    { return l.pn != r.pn; }
 
    friend bool operator< (const iterator& l, const iterator& r)
- { return void_ptr_ptr_cast(l.pn->up) < void_ptr_ptr_cast(r.pn->up); }
+ { return l.pn->up < r.pn->up; }
 
    friend bool operator<= (const iterator& l, const iterator& r)
- { return void_ptr_ptr_cast(l.pn->up) <= void_ptr_ptr_cast(r.pn->up); }
+ { return l.pn->up <= r.pn->up; }
 
    friend bool operator> (const iterator& l, const iterator& r)
- { return void_ptr_ptr_cast(l.pn->up) > void_ptr_ptr_cast(r.pn->up); }
+ { return l.pn->up > r.pn->up; }
 
    friend bool operator>= (const iterator& l, const iterator& r)
- { return void_ptr_ptr_cast(l.pn->up) >= void_ptr_ptr_cast(r.pn->up); }
+ { return l.pn->up >= r.pn->up; }
 
- node_type_ptr_t pn;
+ node_ptr pn;
 };
 
 template<class A, unsigned int Version>
@@ -304,39 +295,131 @@
          , typename allocator_traits<A>::value_type> type;
 };
 
+template<class VoidPtr, class VoidAllocator>
+struct index_traits
+{
+ typedef boost::intrusive::
+ pointer_traits
+ <VoidPtr> void_ptr_traits;
+ typedef stable_vector_detail::
+ node_base<VoidPtr> node_base_type;
+ typedef typename void_ptr_traits::template
+ rebind_pointer<node_base_type>::type node_base_ptr;
+ typedef typename void_ptr_traits::template
+ rebind_pointer<node_base_ptr>::type node_base_ptr_ptr;
+ typedef boost::intrusive::
+ pointer_traits<node_base_ptr> node_base_ptr_traits;
+ typedef boost::intrusive::
+ pointer_traits<node_base_ptr_ptr> node_base_ptr_ptr_traits;
+ typedef typename allocator_traits<VoidAllocator>::
+ template portable_rebind_alloc
+ <node_base_ptr>::type node_base_ptr_allocator;
+ typedef ::boost::container::vector
+ <node_base_ptr, node_base_ptr_allocator> index_type;
+ typedef typename index_type::iterator index_iterator;
+ typedef typename index_type::const_iterator const_index_iterator;
+ typedef typename index_type::size_type size_type;
+
+ static const size_type ExtraPointers = 3;
+ //Stable vector stores metadata at the end of the index (node_base_ptr vector) with additional 3 pointers:
+ // back() is this->index.back() - ExtraPointers;
+ // end node index is *(this->index.end() -3)
+ // Node cache first is *(this->index.end() - 2);
+ // Node cache last is this->index.back();
+
+ static node_base_ptr_ptr ptr_to_node_base_ptr(node_base_ptr &n)
+ { return node_base_ptr_ptr_traits::pointer_to(n); }
+
+ static void fix_up_pointers(index_iterator first, index_iterator last)
+ {
+ while(first != last){
+ typedef typename index_type::reference node_base_ptr_ref;
+ node_base_ptr_ref nbp = *first;
+ nbp->up = index_traits::ptr_to_node_base_ptr(nbp);
+ ++first;
+ }
+ }
+
+ static index_iterator get_fix_up_end(index_type &index)
+ { return index.end() - (ExtraPointers - 1); }
+
+ static void fix_up_pointers_from(index_type & index, index_iterator first)
+ { index_traits::fix_up_pointers(first, index_traits::get_fix_up_end(index)); }
+
+ static void readjust_end_node(index_type &index, node_base_type &end_node)
+ {
+ if(!index.empty()){
+ node_base_ptr &end_node_idx_ref = *(--index_traits::get_fix_up_end(index));
+ end_node_idx_ref = node_base_ptr_traits::pointer_to(end_node);
+ end_node.up = node_base_ptr_ptr_traits::pointer_to(end_node_idx_ref);
+ }
+ else{
+ end_node.up = node_base_ptr_ptr();
+ }
+ }
+
+ static void initialize_end_node(index_type &index, node_base_type &end_node, const size_type index_capacity_if_empty)
+ {
+ if(index.empty()){
+ index.reserve(index_capacity_if_empty + ExtraPointers);
+ index.resize(ExtraPointers);
+ node_base_ptr &end_node_ref = *index.data();
+ end_node_ref = node_base_ptr_traits::pointer_to(end_node);
+ end_node.up = index_traits::ptr_to_node_base_ptr(end_node_ref);
+ }
+ }
+
+
+ #ifdef STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
+ static bool invariants(index_type &index)
+ {
+ for( index_iterator it = index.begin()
+ , it_end = index_traits::get_fix_up_end(index)
+ ; it != it_end
+ ; ++it){
+ if((*it)->up != index_traits::ptr_to_node_base_ptr(*it)){
+ return false;
+ }
+ }
+ return true;
+ }
+ #endif //STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
+};
+
 } //namespace stable_vector_detail
 
 #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
-#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
+ #if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
+
+ #define STABLE_VECTOR_CHECK_INVARIANT \
+ invariant_checker BOOST_JOIN(check_invariant_,__LINE__)(*this); \
+ BOOST_JOIN(check_invariant_,__LINE__).touch();
 
-#define STABLE_VECTOR_CHECK_INVARIANT \
-invariant_checker BOOST_JOIN(check_invariant_,__LINE__)(*this); \
-BOOST_JOIN(check_invariant_,__LINE__).touch();
-#else
+ #else //STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
 
-#define STABLE_VECTOR_CHECK_INVARIANT
+ #define STABLE_VECTOR_CHECK_INVARIANT
 
-#endif //#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
+ #endif //#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
 
 #endif //#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
 /// @endcond
 
-//! Originally developed by Joaquin M. Lopez Munoz, stable_vector is std::vector
+//! Originally developed by Joaquin M. Lopez Munoz, stable_vector is a std::vector
 //! drop-in replacement implemented as a node container, offering iterator and reference
 //! stability.
 //!
-//! More details taken the author's blog:
+//! Here are the details taken from the author's blog
 //! (<a href="http://bannalia.blogspot.com/2008/09/introducing-stablevector.html" >
-//! Introducing stable_vector</a>)
+//! Introducing stable_vector</a>):
 //!
 //! We present stable_vector, a fully STL-compliant stable container that provides
 //! most of the features of std::vector except element contiguity.
 //!
 //! General properties: stable_vector satisfies all the requirements of a container,
 //! a reversible container and a sequence and provides all the optional operations
-//! present in std::vector. Like std::vector, iterators are random access.
+//! present in std::vector. Like std::vector, iterators are random access.
 //! stable_vector does not provide element contiguity; in exchange for this absence,
 //! the container is stable, i.e. references and iterators to an element of a stable_vector
 //! remain valid as long as the element is not erased, and an iterator that has been
@@ -353,7 +436,7 @@
 //! additional allocation per element.
 //!
 //! Exception safety: As stable_vector does not internally copy elements around, some
-//! operations provide stronger exception safety guarantees than in std::vector:
+//! operations provide stronger exception safety guarantees than in std::vector.
 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 template <class T, class A = std::allocator<T> >
 #else
@@ -363,36 +446,40 @@
 {
    ///@cond
    typedef allocator_traits<A> allocator_traits_type;
- typedef typename container_detail::
- move_const_ref_type<T>::type insert_const_ref_type;
    typedef typename boost::intrusive::pointer_traits
       <typename allocator_traits_type::pointer>::
          template rebind_pointer<void>::type void_ptr;
- typedef typename boost::intrusive::pointer_traits
- <void_ptr>::template
- rebind_pointer<const void>::type const_void_ptr;
- typedef typename boost::intrusive::pointer_traits
- <void_ptr>::template
- rebind_pointer<void_ptr>::type void_ptr_ptr;
- typedef typename boost::intrusive::pointer_traits
- <void_ptr>::template
- rebind_pointer<const void_ptr>::type const_void_ptr_ptr;
- typedef stable_vector_detail::node_type
- <void_ptr, T> node_type_t;
- typedef typename boost::intrusive::pointer_traits
- <void_ptr>::template
- rebind_pointer<node_type_t>::type node_type_ptr_t;
- typedef stable_vector_detail::node_type_base
- <void_ptr> node_type_base_t;
- typedef typename boost::intrusive::pointer_traits
- <void_ptr>::template
- rebind_pointer<node_type_base_t>::type node_type_base_ptr_t;
- typedef ::boost::container::vector<void_ptr,
- typename allocator_traits_type::
- template portable_rebind_alloc
- <void_ptr>::type> impl_type;
- typedef typename impl_type::iterator impl_iterator;
- typedef typename impl_type::const_iterator const_impl_iterator;
+ typedef typename allocator_traits_type::
+ template portable_rebind_alloc
+ <void>::type void_allocator_type;
+ typedef stable_vector_detail::index_traits
+ <void_ptr, void_allocator_type> index_traits_type;
+ typedef typename index_traits_type::node_base_type node_base_type;
+ typedef typename index_traits_type::node_base_ptr node_base_ptr;
+ typedef typename index_traits_type::
+ node_base_ptr_ptr node_base_ptr_ptr;
+ typedef typename index_traits_type::
+ node_base_ptr_traits node_base_ptr_traits;
+ typedef typename index_traits_type::
+ node_base_ptr_ptr_traits node_base_ptr_ptr_traits;
+ typedef typename index_traits_type::index_type index_type;
+ typedef typename index_traits_type::index_iterator index_iterator;
+ typedef typename index_traits_type::
+ const_index_iterator const_index_iterator;
+ typedef boost::intrusive::
+ pointer_traits
+ <typename allocator_traits_type::pointer> ptr_traits;
+ typedef stable_vector_detail::node<void_ptr, T> node_type;
+ typedef typename ptr_traits::template
+ rebind_pointer<node_type>::type node_ptr;
+ typedef boost::intrusive::
+ pointer_traits<node_ptr> node_ptr_traits;
+ typedef typename ptr_traits::template
+ rebind_pointer<const node_type>::type const_node_ptr;
+ typedef boost::intrusive::
+ pointer_traits<const_node_ptr> const_node_ptr_traits;
+ typedef typename node_ptr_traits::reference node_reference;
+ typedef typename const_node_ptr_traits::reference const_node_reference;
 
    typedef ::boost::container::container_detail::
       integral_constant<unsigned, 1> allocator_v1;
@@ -403,82 +490,162 @@
       version<A>::value> alloc_version;
    typedef typename allocator_traits_type::
       template portable_rebind_alloc
- <node_type_t>::type node_allocator_type;
+ <node_type>::type node_allocator_type;
+ typedef typename stable_vector_detail::
+ select_multiallocation_chain
+ < node_allocator_type
+ , alloc_version::value
+ >::type multiallocation_chain;
 
- node_type_ptr_t allocate_one()
+ node_ptr allocate_one()
    { return this->allocate_one(alloc_version()); }
 
    template<class AllocatorVersion>
- node_type_ptr_t allocate_one(AllocatorVersion,
+ node_ptr allocate_one(AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
             ::value>::type * = 0)
- { return node_alloc().allocate(1); }
+ { return this->priv_node_alloc().allocate(1); }
 
    template<class AllocatorVersion>
- node_type_ptr_t allocate_one(AllocatorVersion,
+ node_ptr allocate_one(AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
             ::value>::type * = 0)
- { return node_alloc().allocate_one(); }
+ { return this->priv_node_alloc().allocate_one(); }
 
- void deallocate_one(node_type_ptr_t p)
+ void deallocate_one(node_ptr p)
    { return this->deallocate_one(p, alloc_version()); }
 
    template<class AllocatorVersion>
- void deallocate_one(node_type_ptr_t p, AllocatorVersion,
+ void deallocate_one(node_ptr p, AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
             ::value>::type * = 0)
- { node_alloc().deallocate(p, 1); }
+ { this->priv_node_alloc().deallocate(p, 1); }
 
    template<class AllocatorVersion>
- void deallocate_one(node_type_ptr_t p, AllocatorVersion,
+ void deallocate_one(node_ptr p, AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
          <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
             ::value>::type * = 0)
- { node_alloc().deallocate_one(p); }
+ { this->priv_node_alloc().deallocate_one(p); }
 
- friend class stable_vector_detail::clear_on_destroy<stable_vector>;
- ///@endcond
- public:
+ multiallocation_chain allocate_individual(typename allocator_traits_type::size_type n)
+ { return this->allocate_individual(n, alloc_version()); }
+
+ struct allocate_individual_rollback
+ {
+ allocate_individual_rollback(stable_vector &sv, multiallocation_chain &chain)
+ : mr_sv(sv), mr_chain(chain)
+ {}
+
+ ~allocate_individual_rollback()
+ {
+ if(!mr_chain.empty()){
+ mr_sv.deallocate_individual(mr_chain);
+ }
+ }
+
+ stable_vector &mr_sv;
+ multiallocation_chain &mr_chain;
+ };
+
+ template<class AllocatorVersion>
+ multiallocation_chain allocate_individual
+ (typename allocator_traits_type::size_type n, AllocatorVersion,
+ typename boost::container::container_detail::enable_if_c
+ <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
+ ::value>::type * = 0)
+ {
+ multiallocation_chain m;
+ multiallocation_chain m_ret;
+ allocate_individual_rollback rollback(*this, m);
+ while(n--){
+ m.push_front(this->allocate_one());
+ }
+ m.swap(m_ret);
+ return ::boost::move(m_ret);
+ }
+
+ template<class AllocatorVersion>
+ multiallocation_chain allocate_individual
+ (typename allocator_traits_type::size_type n, AllocatorVersion,
+ typename boost::container::container_detail::enable_if_c
+ <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
+ ::value>::type * = 0)
+ { return this->priv_node_alloc().allocate_individual(n); }
 
+ void deallocate_individual(multiallocation_chain &holder)
+ { this->deallocate_individual(holder, alloc_version()); }
 
- // types:
+ template<class AllocatorVersion>
+ void deallocate_individual(multiallocation_chain & holder, AllocatorVersion,
+ typename boost::container::container_detail::enable_if_c
+ <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
+ ::value>::type * = 0)
+ {
+ while(!holder.empty()){
+ this->deallocate_one(holder.pop_front());
+ }
+ }
+
+ template<class AllocatorVersion>
+ void deallocate_individual(multiallocation_chain & holder, AllocatorVersion,
+ typename boost::container::container_detail::enable_if_c
+ <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
+ ::value>::type * = 0)
+ { this->priv_node_alloc().deallocate_individual(boost::move(holder)); }
 
- typedef typename allocator_traits_type::reference reference;
- typedef typename allocator_traits_type::const_reference const_reference;
- typedef typename allocator_traits_type::pointer pointer;
- typedef typename allocator_traits_type::const_pointer const_pointer;
+ friend class stable_vector_detail::clear_on_destroy<stable_vector>;
    typedef stable_vector_detail::iterator
- <T,T&, pointer> iterator;
+ < T
+ , typename allocator_traits<A>::reference
+ , typename allocator_traits<A>::pointer> iterator_impl;
    typedef stable_vector_detail::iterator
- <T,const T&, const_pointer> const_iterator;
- typedef typename impl_type::size_type size_type;
- typedef typename iterator::difference_type difference_type;
- typedef T value_type;
- typedef A allocator_type;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef node_allocator_type stored_allocator_type;
+ < T
+ , typename allocator_traits<A>::const_reference
+ , typename allocator_traits<A>::const_pointer> const_iterator_impl;
+ ///@endcond
+ public:
+
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+ typedef T value_type;
+ typedef typename ::boost::container::allocator_traits<A>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<A>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<A>::reference reference;
+ typedef typename ::boost::container::allocator_traits<A>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<A>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<A>::difference_type difference_type;
+ typedef A allocator_type;
+ typedef node_allocator_type stored_allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
+ typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
 
    ///@cond
    private:
    BOOST_COPYABLE_AND_MOVABLE(stable_vector)
- static const size_type ExtraPointers = 3;
- //This container stores metadata at the end of the void_ptr vector with additional 3 pointers:
- // back() is impl.back() - ExtraPointers;
- // end node index is impl.end()[-3]
- // Node cache first is impl.end()[-2];
- // Node cache last is *impl.back();
+ static const size_type ExtraPointers = index_traits_type::ExtraPointers;
 
- typedef typename stable_vector_detail::
- select_multiallocation_chain
- < node_allocator_type
- , alloc_version::value
- >::type multiallocation_chain;
+ class insert_rollback;
+ friend class insert_rollback;
+
+ class push_back_rollback;
+ friend class push_back_rollback;
    ///@endcond
+
    public:
+ //////////////////////////////////////////////
+ //
+ // construct/copy/destroy
+ //
+ //////////////////////////////////////////////
 
    //! <b>Effects</b>: Default constructs a stable_vector.
    //!
@@ -486,7 +653,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    stable_vector()
- : internal_data(), impl()
+ : internal_data(), index()
    {
       STABLE_VECTOR_CHECK_INVARIANT;
    }
@@ -497,7 +664,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    explicit stable_vector(const allocator_type& al)
- : internal_data(al),impl(al)
+ : internal_data(al), index(al)
    {
       STABLE_VECTOR_CHECK_INVARIANT;
    }
@@ -510,7 +677,7 @@
    //!
    //! <b>Complexity</b>: Linear to n.
    explicit stable_vector(size_type n)
- : internal_data(),impl()
+ : internal_data(), index()
    {
       stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
       this->resize(n);
@@ -526,10 +693,10 @@
    //!
    //! <b>Complexity</b>: Linear to n.
    stable_vector(size_type n, const T& t, const allocator_type& al = allocator_type())
- : internal_data(al),impl(al)
+ : internal_data(al), index(al)
    {
       stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
- this->insert(this->cbegin(), n, t);
+ this->insert(this->cend(), n, t);
       STABLE_VECTOR_CHECK_INVARIANT;
       cod.release();
    }
@@ -543,10 +710,10 @@
    //! <b>Complexity</b>: Linear to the range [first, last).
    template <class InputIterator>
    stable_vector(InputIterator first,InputIterator last, const allocator_type& al = allocator_type())
- : internal_data(al),impl(al)
+ : internal_data(al), index(al)
    {
       stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
- this->insert(this->cbegin(), first, last);
+ this->insert(this->cend(), first, last);
       STABLE_VECTOR_CHECK_INVARIANT;
       cod.release();
    }
@@ -558,12 +725,12 @@
    //! <b>Complexity</b>: Linear to the elements x contains.
    stable_vector(const stable_vector& x)
       : internal_data(allocator_traits<node_allocator_type>::
- select_on_container_copy_construction(x.node_alloc()))
- , impl(allocator_traits<allocator_type>::
- select_on_container_copy_construction(x.impl.get_stored_allocator()))
+ select_on_container_copy_construction(x.priv_node_alloc()))
+ , index(allocator_traits<allocator_type>::
+ select_on_container_copy_construction(x.index.get_stored_allocator()))
    {
       stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
- this->insert(this->cbegin(), x.begin(), x.end());
+ this->insert(this->cend(), x.begin(), x.end());
       STABLE_VECTOR_CHECK_INVARIANT;
       cod.release();
    }
@@ -574,7 +741,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    stable_vector(BOOST_RV_REF(stable_vector) x)
- : internal_data(boost::move(x.node_alloc())), impl(boost::move(x.impl))
+ : internal_data(boost::move(x.priv_node_alloc())), index(boost::move(x.index))
    {
       this->priv_swap_members(x);
    }
@@ -585,10 +752,10 @@
    //!
    //! <b>Complexity</b>: Linear to the elements x contains.
    stable_vector(const stable_vector& x, const allocator_type &a)
- : internal_data(a), impl(a)
+ : internal_data(a), index(a)
    {
       stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
- this->insert(this->cbegin(), x.begin(), x.end());
+ this->insert(this->cend(), x.begin(), x.end());
       STABLE_VECTOR_CHECK_INVARIANT;
       cod.release();
    }
@@ -600,14 +767,14 @@
    //!
    //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise
    stable_vector(BOOST_RV_REF(stable_vector) x, const allocator_type &a)
- : internal_data(a), impl(a)
+ : internal_data(a), index(a)
    {
- if(this->node_alloc() == x.node_alloc()){
+ if(this->priv_node_alloc() == x.priv_node_alloc()){
          this->priv_swap_members(x);
       }
       else{
          stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
- this->insert(this->cbegin(), x.begin(), x.end());
+ this->insert(this->cend(), x.begin(), x.end());
          STABLE_VECTOR_CHECK_INVARIANT;
          cod.release();
       }
@@ -622,7 +789,7 @@
    ~stable_vector()
    {
       this->clear();
- clear_pool();
+ this->priv_clear_pool();
    }
 
    //! <b>Effects</b>: Makes *this contain the same elements as x.
@@ -637,16 +804,16 @@
    {
       STABLE_VECTOR_CHECK_INVARIANT;
       if (&x != this){
- node_allocator_type &this_alloc = this->node_alloc();
- const node_allocator_type &x_alloc = x.node_alloc();
+ node_allocator_type &this_alloc = this->priv_node_alloc();
+ const node_allocator_type &x_alloc = x.priv_node_alloc();
          container_detail::bool_<allocator_traits_type::
             propagate_on_container_copy_assignment::value> flag;
          if(flag && this_alloc != x_alloc){
             this->clear();
             this->shrink_to_fit();
          }
- container_detail::assign_alloc(this->node_alloc(), x.node_alloc(), flag);
- container_detail::assign_alloc(this->impl.get_stored_allocator(), x.impl.get_stored_allocator(), flag);
+ container_detail::assign_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag);
+ container_detail::assign_alloc(this->index.get_stored_allocator(), x.index.get_stored_allocator(), flag);
          this->assign(x.begin(), x.end());
       }
       return *this;
@@ -663,22 +830,21 @@
    stable_vector& operator=(BOOST_RV_REF(stable_vector) x)
    {
       if (&x != this){
- node_allocator_type &this_alloc = this->node_alloc();
- node_allocator_type &x_alloc = x.node_alloc();
+ node_allocator_type &this_alloc = this->priv_node_alloc();
+ node_allocator_type &x_alloc = x.priv_node_alloc();
          //If allocators are equal we can just swap pointers
          if(this_alloc == x_alloc){
             //Destroy objects but retain memory
             this->clear();
- this->impl = boost::move(x.impl);
+ this->index = boost::move(x.index);
             this->priv_swap_members(x);
             //Move allocator if needed
             container_detail::bool_<allocator_traits_type::
                propagate_on_container_move_assignment::value> flag;
- container_detail::move_alloc(this->node_alloc(), x.node_alloc(), flag);
+ container_detail::move_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag);
          }
          //If unequal allocators, then do a one by one move
          else{
- typedef typename std::iterator_traits<iterator>::iterator_category ItCat;
             this->assign( boost::make_move_iterator(x.begin())
                         , boost::make_move_iterator(x.end()));
          }
@@ -686,28 +852,44 @@
       return *this;
    }
 
- //! <b>Effects</b>: Assigns the the range [first, last) to *this.
+
+ //! <b>Effects</b>: Assigns the n copies of val to *this.
    //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's constructor from dereferencing InpIt throws.
+ //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
    //!
    //! <b>Complexity</b>: Linear to n.
- template<typename InputIterator>
- void assign(InputIterator first,InputIterator last)
+ void assign(size_type n, const T& t)
    {
- assign_dispatch(first, last, boost::is_integral<InputIterator>());
+ typedef constant_iterator<value_type, difference_type> cvalue_iterator;
+ this->assign(cvalue_iterator(t, n), cvalue_iterator());
    }
 
-
- //! <b>Effects</b>: Assigns the n copies of val to *this.
+ //! <b>Effects</b>: Assigns the the range [first, last) to *this.
    //!
- //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's constructor from dereferencing InpIt throws.
    //!
    //! <b>Complexity</b>: Linear to n.
- void assign(size_type n,const T& t)
+ template<typename InputIterator>
+ void assign(InputIterator first,InputIterator last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InputIterator, size_type>::value
+ >::type * = 0
+ #endif
+ )
    {
- typedef constant_iterator<value_type, difference_type> cvalue_iterator;
- return assign_dispatch(cvalue_iterator(t, n), cvalue_iterator(), boost::mpl::false_());
+ STABLE_VECTOR_CHECK_INVARIANT;
+ iterator first1 = this->begin();
+ iterator last1 = this->end();
+ for ( ; first1 != last1 && first != last; ++first1, ++first)
+ *first1 = *first;
+ if (first == last){
+ this->erase(first1, last1);
+ }
+ else{
+ this->insert(last1, first, last);
+ }
    }
 
    //! <b>Effects</b>: Returns a copy of the internal allocator.
@@ -715,7 +897,8 @@
    //! <b>Throws</b>: If allocator's copy constructor throws.
    //!
    //! <b>Complexity</b>: Constant.
- allocator_type get_allocator()const {return this->node_alloc();}
+ allocator_type get_allocator() const
+ { return this->priv_node_alloc(); }
 
    //! <b>Effects</b>: Returns a reference to the internal allocator.
    //!
@@ -725,7 +908,7 @@
    //!
    //! <b>Note</b>: Non-standard extension.
    const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
- { return node_alloc(); }
+ { return this->priv_node_alloc(); }
 
    //! <b>Effects</b>: Returns a reference to the internal allocator.
    //!
@@ -735,8 +918,13 @@
    //!
    //! <b>Note</b>: Non-standard extension.
    stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
- { return node_alloc(); }
+ { return this->priv_node_alloc(); }
 
+ //////////////////////////////////////////////
+ //
+ // iterators
+ //
+ //////////////////////////////////////////////
 
    //! <b>Effects</b>: Returns an iterator to the first element contained in the stable_vector.
    //!
@@ -744,7 +932,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    iterator begin()
- { return (impl.empty()) ? end(): iterator(node_ptr_cast(impl.front())) ; }
+ { return (this->index.empty()) ? this->end(): iterator(node_ptr_traits::static_cast_from(this->index.front())); }
 
    //! <b>Effects</b>: Returns a const_iterator to the first element contained in the stable_vector.
    //!
@@ -752,21 +940,23 @@
    //!
    //! <b>Complexity</b>: Constant.
    const_iterator begin()const
- { return (impl.empty()) ? cend() : const_iterator(node_ptr_cast(impl.front())) ; }
+ { return (this->index.empty()) ? this->cend() : const_iterator(node_ptr_traits::static_cast_from(this->index.front())) ; }
 
    //! <b>Effects</b>: Returns an iterator to the end of the stable_vector.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- iterator end() {return iterator(get_end_node());}
+ iterator end()
+ { return iterator(this->priv_get_end_node()); }
 
    //! <b>Effects</b>: Returns a const_iterator to the end of the stable_vector.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_iterator end()const {return const_iterator(get_end_node());}
+ const_iterator end() const
+ { return const_iterator(this->priv_get_end_node()); }
 
    //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
    //! of the reversed stable_vector.
@@ -774,7 +964,8 @@
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- reverse_iterator rbegin() {return reverse_iterator(this->end());}
+ reverse_iterator rbegin()
+ { return reverse_iterator(this->end()); }
 
    //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed stable_vector.
@@ -782,7 +973,8 @@
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_reverse_iterator rbegin()const {return const_reverse_iterator(this->end());}
+ const_reverse_iterator rbegin() const
+ { return const_reverse_iterator(this->end()); }
 
    //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
    //! of the reversed stable_vector.
@@ -790,7 +982,8 @@
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- reverse_iterator rend() {return reverse_iterator(this->begin());}
+ reverse_iterator rend()
+ { return reverse_iterator(this->begin()); }
 
    //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
    //! of the reversed stable_vector.
@@ -798,21 +991,24 @@
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_reverse_iterator rend()const {return const_reverse_iterator(this->begin());}
+ const_reverse_iterator rend()const
+ { return const_reverse_iterator(this->begin()); }
 
    //! <b>Effects</b>: Returns a const_iterator to the first element contained in the stable_vector.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_iterator cbegin()const {return this->begin();}
+ const_iterator cbegin() const
+ { return this->begin(); }
 
    //! <b>Effects</b>: Returns a const_iterator to the end of the stable_vector.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_iterator cend()const {return this->end();}
+ const_iterator cend()const
+ { return this->end(); }
 
    //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed stable_vector.
@@ -820,7 +1016,8 @@
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_reverse_iterator crbegin()const{return this->rbegin();}
+ const_reverse_iterator crbegin() const
+ { return this->rbegin(); }
 
    //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
    //! of the reversed stable_vector.
@@ -828,81 +1025,90 @@
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_reverse_iterator crend()const {return this->rend();}
+ const_reverse_iterator crend()const
+ { return this->rend(); }
 
- //! <b>Effects</b>: Returns the number of the elements contained in the stable_vector.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- size_type size() const
- { return impl.empty() ? 0 : (impl.size() - ExtraPointers); }
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
 
- //! <b>Effects</b>: Returns the largest possible size of the stable_vector.
+ //! <b>Effects</b>: Returns true if the stable_vector contains no elements.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- size_type max_size() const
- { return impl.max_size() - ExtraPointers; }
+ bool empty() const
+ { return this->index.size() <= ExtraPointers; }
 
- //! <b>Effects</b>: Number of elements for which memory has been allocated.
- //! capacity() is always greater than or equal to size().
+ //! <b>Effects</b>: Returns the number of the elements contained in the stable_vector.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- size_type capacity() const
+ size_type size() const
    {
- if(!impl.capacity()){
- return 0;
- }
- else{
- const size_type num_nodes = this->impl.size() + this->internal_data.pool_size;
- const size_type num_buck = this->impl.capacity();
- return (num_nodes < num_buck) ? num_nodes : num_buck;
- }
+ const size_type index_size = this->index.size();
+ return index_size ? (index_size - ExtraPointers) : 0;
    }
 
- //! <b>Effects</b>: Returns true if the stable_vector contains no elements.
+ //! <b>Effects</b>: Returns the largest possible size of the stable_vector.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- bool empty() const
- { return impl.empty() || impl.size() == ExtraPointers; }
+ size_type max_size() const
+ { return this->index.max_size() - ExtraPointers; }
 
    //! <b>Effects</b>: Inserts or erases elements at the end such that
- //! the size becomes n. New elements are copy constructed from x.
+ //! the size becomes n. New elements are default constructed.
    //!
    //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
    //!
    //! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type n, const T& t)
+ void resize(size_type n)
    {
+ typedef default_construct_iterator<value_type, difference_type> default_iterator;
       STABLE_VECTOR_CHECK_INVARIANT;
- if(n > size())
- this->insert(this->cend(), n - this->size(), t);
+ if(n > this->size())
+ this->insert(this->cend(), default_iterator(n - this->size()), default_iterator());
       else if(n < this->size())
          this->erase(this->cbegin() + n, this->cend());
    }
 
    //! <b>Effects</b>: Inserts or erases elements at the end such that
- //! the size becomes n. New elements are default constructed.
+ //! the size becomes n. New elements are copy constructed from x.
    //!
    //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
    //!
    //! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type n)
+ void resize(size_type n, const T& t)
    {
- typedef default_construct_iterator<value_type, difference_type> default_iterator;
       STABLE_VECTOR_CHECK_INVARIANT;
- if(n > size())
- this->insert(this->cend(), default_iterator(n - this->size()), default_iterator());
+ if(n > this->size())
+ this->insert(this->cend(), n - this->size(), t);
       else if(n < this->size())
          this->erase(this->cbegin() + n, this->cend());
    }
 
+ //! <b>Effects</b>: Number of elements for which memory has been allocated.
+ //! capacity() is always greater than or equal to size().
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ size_type capacity() const
+ {
+ const size_type index_size = this->index.size();
+ BOOST_ASSERT(!index_size || index_size >= ExtraPointers);
+ const size_type bucket_extra_capacity = this->index.capacity()- index_size;
+ const size_type node_extra_capacity = this->internal_data.pool_size;
+ const size_type extra_capacity = (bucket_extra_capacity < node_extra_capacity)
+ ? bucket_extra_capacity : node_extra_capacity;
+ return (index_size ? (index_size - ExtraPointers + extra_capacity) : index_size);
+ }
+
    //! <b>Effects</b>: If n is less than or equal to capacity(), this call has no
    //! effect. Otherwise, it is a request for allocation of additional memory.
    //! If the request is successful, then capacity() is greater than or equal to
@@ -915,221 +1121,161 @@
       if(n > this->max_size())
          throw std::bad_alloc();
 
- size_type size = this->size();
+ size_type size = this->size();
       size_type old_capacity = this->capacity();
       if(n > old_capacity){
- this->initialize_end_node(n);
- const void * old_ptr = &impl[0];
- impl.reserve(n + ExtraPointers);
- bool realloced = &impl[0] != old_ptr;
+ index_traits_type::initialize_end_node(this->index, this->internal_data.end_node, n);
+ const void * old_ptr = &index[0];
+ this->index.reserve(n + ExtraPointers);
+ bool realloced = &index[0] != old_ptr;
          //Fix the pointers for the newly allocated buffer
          if(realloced){
- this->align_nodes(impl.begin(), impl.begin()+size+1);
+ index_traits_type::fix_up_pointers_from(this->index, this->index.begin());
          }
          //Now fill pool if data is not enough
          if((n - size) > this->internal_data.pool_size){
- this->add_to_pool((n - size) - this->internal_data.pool_size);
+ this->priv_increase_pool((n - size) - this->internal_data.pool_size);
          }
       }
    }
 
- //! <b>Requires</b>: size() > n.
+ //! <b>Effects</b>: Tries to deallocate the excess of memory created
+ //! with previous allocations. The size of the stable_vector is unchanged
    //!
- //! <b>Effects</b>: Returns a reference to the nth element
- //! from the beginning of the container.
+ //! <b>Throws</b>: If memory allocation throws.
+ //!
+ //! <b>Complexity</b>: Linear to size().
+ void shrink_to_fit()
+ {
+ if(this->capacity()){
+ //First empty allocated node pool
+ this->priv_clear_pool();
+ //If empty completely destroy the index, let's recover default-constructed state
+ if(this->empty()){
+ this->index.clear();
+ this->index.shrink_to_fit();
+ this->internal_data.end_node.up = node_base_ptr_ptr();
+ }
+ //Otherwise, try to shrink-to-fit the index and readjust pointers if necessary
+ else{
+ const void* old_ptr = &index[0];
+ this->index.shrink_to_fit();
+ bool realloced = &index[0] != old_ptr;
+ //Fix the pointers for the newly allocated buffer
+ if(realloced){
+ index_traits_type::fix_up_pointers_from(this->index, this->index.begin());
+ }
+ }
+ }
+ }
+
+ //////////////////////////////////////////////
+ //
+ // element access
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Requires</b>: !empty()
+ //!
+ //! <b>Effects</b>: Returns a reference to the first
+ //! element of the container.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- reference operator[](size_type n){return value(impl[n]);}
+ reference front()
+ { return static_cast<node_reference>(*this->index.front()).value; }
 
- //! <b>Requires</b>: size() > n.
+ //! <b>Requires</b>: !empty()
    //!
- //! <b>Effects</b>: Returns a const reference to the nth element
- //! from the beginning of the container.
+ //! <b>Effects</b>: Returns a const reference to the first
+ //! element of the container.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_reference operator[](size_type n)const{return value(impl[n]);}
+ const_reference front() const
+ { return static_cast<const_node_reference>(*this->index.front()).value; }
 
- //! <b>Requires</b>: size() > n.
+ //! <b>Requires</b>: !empty()
    //!
- //! <b>Effects</b>: Returns a reference to the nth element
- //! from the beginning of the container.
+ //! <b>Effects</b>: Returns a reference to the last
+ //! element of the container.
    //!
- //! <b>Throws</b>: std::range_error if n >= size()
+ //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- reference at(size_type n)
- {
- if(n>=size())
- throw std::out_of_range("invalid subscript at stable_vector::at");
- return operator[](n);
- }
-
- //! <b>Requires</b>: size() > n.
- //!
- //! <b>Effects</b>: Returns a const reference to the nth element
- //! from the beginning of the container.
- //!
- //! <b>Throws</b>: std::range_error if n >= size()
- //!
- //! <b>Complexity</b>: Constant.
- const_reference at(size_type n)const
- {
- if(n>=size())
- throw std::out_of_range("invalid subscript at stable_vector::at");
- return operator[](n);
- }
+ reference back()
+ { return static_cast<node_reference>(*this->index[this->size() - ExtraPointers]).value; }
 
    //! <b>Requires</b>: !empty()
    //!
- //! <b>Effects</b>: Returns a reference to the first
+ //! <b>Effects</b>: Returns a const reference to the last
    //! element of the container.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- reference front()
- { return value(impl.front()); }
+ const_reference back()const
+ { return static_cast<const_node_reference>(*this->index[this->size() - ExtraPointers]).value; }
 
- //! <b>Requires</b>: !empty()
+ //! <b>Requires</b>: size() > n.
    //!
- //! <b>Effects</b>: Returns a const reference to the first
- //! element of the container.
+ //! <b>Effects</b>: Returns a reference to the nth element
+ //! from the beginning of the container.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_reference front()const
- { return value(impl.front()); }
+ reference operator[](size_type n)
+ { return static_cast<node_reference>(*this->index[n]).value; }
 
- //! <b>Requires</b>: !empty()
+ //! <b>Requires</b>: size() > n.
    //!
- //! <b>Effects</b>: Returns a reference to the last
- //! element of the container.
+ //! <b>Effects</b>: Returns a const reference to the nth element
+ //! from the beginning of the container.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- reference back()
- { return value(*(&impl.back() - ExtraPointers)); }
+ const_reference operator[](size_type n)const
+ { return static_cast<const_node_reference>(*this->index[n]).value; }
 
- //! <b>Requires</b>: !empty()
+ //! <b>Requires</b>: size() > n.
    //!
- //! <b>Effects</b>: Returns a const reference to the last
- //! element of the container.
+ //! <b>Effects</b>: Returns a reference to the nth element
+ //! from the beginning of the container.
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: std::range_error if n >= size()
    //!
    //! <b>Complexity</b>: Constant.
- const_reference back()const
- { return value(*(&impl.back() - ExtraPointers)); }
-
- //! <b>Effects</b>: Inserts a copy of x at the end of the stable_vector.
- //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_back(insert_const_ref_type x)
- { return priv_push_back(x); }
-
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- void push_back(T &x) { push_back(const_cast<const T &>(x)); }
-
- template<class U>
- void push_back(const U &u, typename container_detail::enable_if_c
- <container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return priv_push_back(u); }
- #endif
-
- //! <b>Effects</b>: Constructs a new element in the end of the stable_vector
- //! and moves the resources of mx to this new element.
- //!
- //! <b>Throws</b>: If memory allocation throws.
- //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_back(BOOST_RV_REF(T) t)
- { this->insert(end(), boost::move(t)); }
-
- //! <b>Effects</b>: Removes the last element from the stable_vector.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant time.
- void pop_back()
- { this->erase(this->end()-1); }
-
- //! <b>Requires</b>: position must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Insert a copy of x before position.
- //!
- //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws.
- //!
- //! <b>Complexity</b>: If position is end(), amortized constant time
- //! Linear time otherwise.
- iterator insert(const_iterator position, insert_const_ref_type x)
- { return this->priv_insert(position, x); }
-
- #if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- iterator insert(const_iterator position, T &x) { return this->insert(position, const_cast<const T &>(x)); }
-
- template<class U>
- iterator insert(const_iterator position, const U &u, typename container_detail::enable_if_c
- <container_detail::is_same<T, U>::value && !::boost::has_move_emulation_enabled<U>::value >::type* =0)
- { return this->priv_insert(position, u); }
- #endif
-
- //! <b>Requires</b>: position must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Insert a new element before position with mx's resources.
- //!
- //! <b>Throws</b>: If memory allocation throws.
- //!
- //! <b>Complexity</b>: If position is end(), amortized constant time
- //! Linear time otherwise.
- iterator insert(const_iterator position, BOOST_RV_REF(T) x)
+ reference at(size_type n)
    {
- typedef repeat_iterator<T, difference_type> repeat_it;
- typedef boost::move_iterator<repeat_it> repeat_move_it;
- //Just call more general insert(pos, size, value) and return iterator
- size_type pos_n = position - cbegin();
- this->insert(position
- ,repeat_move_it(repeat_it(x, 1))
- ,repeat_move_it(repeat_it()));
- return iterator(this->begin() + pos_n);
+ if(n>=this->size())
+ throw std::out_of_range("invalid subscript at stable_vector::at");
+ return operator[](n);
    }
 
- //! <b>Requires</b>: pos must be a valid iterator of *this.
+ //! <b>Requires</b>: size() > n.
    //!
- //! <b>Effects</b>: Insert n copies of x before pos.
+ //! <b>Effects</b>: Returns a const reference to the nth element
+ //! from the beginning of the container.
    //!
- //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //! <b>Throws</b>: std::range_error if n >= size()
    //!
- //! <b>Complexity</b>: Linear to n.
- void insert(const_iterator position, size_type n, const T& t)
+ //! <b>Complexity</b>: Constant.
+ const_reference at(size_type n)const
    {
- STABLE_VECTOR_CHECK_INVARIANT;
- this->insert_not_iter(position, n, t);
+ if(n>=this->size())
+ throw std::out_of_range("invalid subscript at stable_vector::at");
+ return operator[](n);
    }
 
- //! <b>Requires</b>: pos must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Insert a copy of the [first, last) range before pos.
- //!
- //! <b>Throws</b>: If memory allocation throws, T's constructor from a
- //! dereferenced InpIt throws or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to std::distance [first, last).
- template <class InputIterator>
- void insert(const_iterator position,InputIterator first, InputIterator last)
- {
- STABLE_VECTOR_CHECK_INVARIANT;
- this->insert_iter(position,first,last,
- boost::mpl::not_<boost::is_integral<InputIterator> >());
- }
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
 
@@ -1206,6 +1352,147 @@
 
    #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
 
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: Inserts a copy of x at the end of the stable_vector.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_back(const T &x);
+
+ //! <b>Effects</b>: Constructs a new element in the end of the stable_vector
+ //! and moves the resources of mx to this new element.
+ //!
+ //! <b>Throws</b>: If memory allocation throws.
+ //!
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_back(T &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
+ #endif
+
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Requires</b>: position must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert a copy of x before position.
+ //!
+ //! <b>Returns</b>: An iterator to the inserted element.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or x's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: If position is end(), amortized constant time
+ //! Linear time otherwise.
+ iterator insert(const_iterator position, const T &x);
+
+ //! <b>Requires</b>: position must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert a new element before position with mx's resources.
+ //!
+ //! <b>Returns</b>: an iterator to the inserted element.
+ //!
+ //! <b>Throws</b>: If memory allocation throws.
+ //!
+ //! <b>Complexity</b>: If position is end(), amortized constant time
+ //! Linear time otherwise.
+ iterator insert(const_iterator position, T &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
+ #endif
+
+ //! <b>Requires</b>: pos must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert n copies of x before position.
+ //!
+ //! <b>Returns</b>: an iterator to the first inserted element or position if n is 0.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ iterator insert(const_iterator position, size_type n, const T& t)
+ {
+ STABLE_VECTOR_CHECK_INVARIANT;
+ typedef constant_iterator<value_type, difference_type> cvalue_iterator;
+ return this->insert(position, cvalue_iterator(t, n), cvalue_iterator());
+ }
+
+ //! <b>Requires</b>: pos must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert a copy of the [first, last) range before pos.
+ //!
+ //! <b>Returns</b>: an iterator to the first inserted element or position if first == last.
+ //!
+ //! <b>Throws</b>: If memory allocation throws, T's constructor from a
+ //! dereferenced InpIt throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to std::distance [first, last).
+ template <class InputIterator>
+ iterator insert(const_iterator position,InputIterator first, InputIterator last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InputIterator, size_type>::value
+ && container_detail::is_input_iterator<InputIterator>::value
+ >::type * = 0
+ #endif
+ )
+ {
+ STABLE_VECTOR_CHECK_INVARIANT;
+ const size_type pos_n = position - this->cbegin();
+ for(; first != last; ++first){
+ this->emplace(position, *first);
+ }
+ return this->begin() + pos_n;
+ }
+
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ template <class FwdIt>
+ iterator insert(const_iterator position, FwdIt first, FwdIt last
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<FwdIt, size_type>::value
+ && !container_detail::is_input_iterator<FwdIt>::value
+ >::type * = 0
+ )
+ {
+ const size_type num_new = (size_type)std::distance(first,last);
+ const size_type pos = static_cast<size_type>(position - this->cbegin());
+ if(num_new){
+ //Fills the node pool and inserts num_new null pointers in pos.
+ //If a new buffer was needed fixes up pointers up to pos so
+ //past-new nodes are not aligned until the end of this function
+ //or in a rollback in case of exception
+ index_iterator it_past_newly_constructed(this->priv_insert_forward_non_templated(pos, num_new));
+ const index_iterator it_past_new(it_past_newly_constructed + num_new);
+ {
+ //Prepare rollback
+ insert_rollback rollback(*this, it_past_newly_constructed, it_past_new);
+ while(first != last){
+ const node_ptr p = this->priv_get_from_pool();
+ BOOST_ASSERT(!!p);
+ //Put it in the index so rollback can return it in pool if construct_in_place throws
+ *it_past_newly_constructed = p;
+ //Constructs and fixes up pointers This can throw
+ this->priv_build_node_from_it(p, it_past_newly_constructed, first);
+ ++first;
+ ++it_past_newly_constructed;
+ }
+ //rollback.~insert_rollback() called in case of exception
+ }
+ //Fix up pointers for past-new nodes (new nodes were fixed during construction) and
+ //nodes before insertion position in priv_insert_forward_non_templated(...)
+ index_traits_type::fix_up_pointers_from(this->index, it_past_newly_constructed);
+ }
+ return this->begin() + pos;
+ }
+ #endif
+
+ //! <b>Effects</b>: Removes the last element from the stable_vector.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ void pop_back()
+ { this->erase(--this->cend()); }
+
    //! <b>Effects</b>: Erases the element at position pos.
    //!
    //! <b>Throws</b>: Nothing.
@@ -1216,10 +1503,10 @@
    {
       STABLE_VECTOR_CHECK_INVARIANT;
       difference_type d = position - this->cbegin();
- impl_iterator it = impl.begin() + d;
- this->delete_node(*it);
- it = impl.erase(it);
- this->align_nodes(it, get_last_align());
+ index_iterator it = this->index.begin() + d;
+ this->priv_delete_node(position.node_pointer());
+ it = this->index.erase(it);
+ index_traits_type::fix_up_pointers_from(this->index, it);
       return this->begin()+d;
    }
 
@@ -1230,7 +1517,19 @@
    //! <b>Complexity</b>: Linear to the distance between first and last
    //! plus linear to the elements between pos and the last element.
    iterator erase(const_iterator first, const_iterator last)
- { return priv_erase(first, last, alloc_version()); }
+ {
+ STABLE_VECTOR_CHECK_INVARIANT;
+ difference_type d1 = first - this->cbegin(), d2 = last - this->cbegin();
+ if(d1 != d2){
+ index_iterator it1(this->index.begin() + d1), it2(it1 + (d2 - d1));
+ for(index_iterator it = it1; it != it2; ++it){
+ this->priv_delete_node(node_ptr_traits::static_cast_from(*it));
+ }
+ const index_iterator e = this->index.erase(it1, it2);
+ index_traits_type::fix_up_pointers_from(this->index, e);
+ }
+ return iterator(this->begin() + d1);
+ }
 
    //! <b>Effects</b>: Swaps the contents of *this and x.
    //!
@@ -1241,9 +1540,9 @@
    {
       STABLE_VECTOR_CHECK_INVARIANT;
       container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag;
- container_detail::swap_alloc(this->node_alloc(), x.node_alloc(), flag);
+ container_detail::swap_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag);
       //vector's allocator is swapped here
- this->impl.swap(x.impl);
+ this->index.swap(x.index);
       this->priv_swap_members(x);
    }
 
@@ -1255,456 +1554,269 @@
    void clear()
    { this->erase(this->cbegin(),this->cend()); }
 
- //! <b>Effects</b>: Tries to deallocate the excess of memory created
- //! with previous allocations. The size of the stable_vector is unchanged
- //!
- //! <b>Throws</b>: If memory allocation throws.
- //!
- //! <b>Complexity</b>: Linear to size().
- void shrink_to_fit()
- {
- if(this->capacity()){
- //First empty allocated node pool
- this->clear_pool();
- //If empty completely destroy the index, let's recover default-constructed state
- if(this->empty()){
- this->impl.clear();
- this->impl.shrink_to_fit();
- this->internal_data.set_end_pointer_to_default_constructed();
- }
- //Otherwise, try to shrink-to-fit the index and readjust pointers if necessary
- else{
- const size_type size = this->size();
- const void* old_ptr = &impl[0];
- this->impl.shrink_to_fit();
- bool realloced = &impl[0] != old_ptr;
- //Fix the pointers for the newly allocated buffer
- if(realloced){
- this->align_nodes(impl.begin(), impl.begin()+size+1);
- }
- }
- }
- }
-
    /// @cond
 
- iterator priv_insert(const_iterator position, const value_type &t)
- {
- typedef constant_iterator<value_type, difference_type> cvalue_iterator;
- return this->insert_iter(position, cvalue_iterator(t, 1), cvalue_iterator(), std::forward_iterator_tag());
- }
-
- void priv_push_back(const value_type &t)
- { this->insert(end(), t); }
+ private:
 
- template<class AllocatorVersion>
- void clear_pool(AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
+ class insert_rollback
    {
- if(!impl.empty() && impl.back()){
- void_ptr &pool_first_ref = impl.end()[-2];
- void_ptr &pool_last_ref = impl.back();
+ public:
 
- multiallocation_chain holder;
- holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, this->internal_data.pool_size);
- while(!holder.empty()){
- node_type_ptr_t n = holder.front();
- holder.pop_front();
- this->deallocate_one(n);
- }
- pool_first_ref = pool_last_ref = 0;
- this->internal_data.pool_size = 0;
- }
- }
+ insert_rollback(stable_vector &sv, index_iterator &it_past_constructed, const index_iterator &it_past_new)
+ : m_sv(sv), m_it_past_constructed(it_past_constructed), m_it_past_new(it_past_new)
+ {}
 
- template<class AllocatorVersion>
- void clear_pool(AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- {
- if(!impl.empty() && impl.back()){
- void_ptr &pool_first_ref = impl.end()[-2];
- void_ptr &pool_last_ref = impl.back();
- multiallocation_chain holder;
- holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
- node_alloc().deallocate_individual(boost::move(holder));
- pool_first_ref = pool_last_ref = 0;
- this->internal_data.pool_size = 0;
+ ~insert_rollback()
+ {
+ if(m_it_past_constructed != m_it_past_new){
+ m_sv.priv_put_in_pool(node_ptr_traits::static_cast_from(*m_it_past_constructed));
+ index_iterator e = m_sv.index.erase(m_it_past_constructed, m_it_past_new);
+ index_traits_type::fix_up_pointers_from(m_sv.index, e);
+ }
       }
- }
 
- void clear_pool()
- {
- this->clear_pool(alloc_version());
- }
+ private:
+ stable_vector &m_sv;
+ index_iterator &m_it_past_constructed;
+ const index_iterator &m_it_past_new;
+ };
 
- void add_to_pool(size_type n)
+ class push_back_rollback
    {
- this->add_to_pool(n, alloc_version());
- }
+ public:
+ push_back_rollback(stable_vector &sv, const node_ptr &p)
+ : m_sv(sv), m_p(p)
+ {}
 
- template<class AllocatorVersion>
- void add_to_pool(size_type n, AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- {
- size_type remaining = n;
- while(remaining--){
- this->put_in_pool(this->allocate_one());
+ ~push_back_rollback()
+ {
+ if(m_p){
+ m_sv.priv_put_in_pool(m_p);
+ }
       }
- }
 
- template<class AllocatorVersion>
- void add_to_pool(size_type n, AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- {
- void_ptr &pool_first_ref = impl.end()[-2];
- void_ptr &pool_last_ref = impl.back();
- multiallocation_chain holder;
- holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
- //BOOST_STATIC_ASSERT((::boost::has_move_emulation_enabled<multiallocation_chain>::value == true));
- multiallocation_chain m (node_alloc().allocate_individual(n));
- holder.splice_after(holder.before_begin(), m, m.before_begin(), m.last(), n);
- this->internal_data.pool_size += n;
- std::pair<void_ptr, void_ptr> data(holder.extract_data());
- pool_first_ref = data.first;
- pool_last_ref = data.second;
- }
+ void release()
+ { m_p = node_ptr(); }
 
- void put_in_pool(node_type_ptr_t p)
- {
- void_ptr &pool_first_ref = impl.end()[-2];
- void_ptr &pool_last_ref = impl.back();
- multiallocation_chain holder;
- holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
- holder.push_front(p);
- ++this->internal_data.pool_size;
- std::pair<void_ptr, void_ptr> ret(holder.extract_data());
- pool_first_ref = ret.first;
- pool_last_ref = ret.second;
- }
+ private:
+ stable_vector &m_sv;
+ node_ptr m_p;
+ };
 
- node_type_ptr_t get_from_pool()
+ index_iterator priv_insert_forward_non_templated(size_type pos, size_type num_new)
    {
- if(!impl.back()){
- return node_type_ptr_t(0);
+ index_traits_type::initialize_end_node(this->index, this->internal_data.end_node, num_new);
+
+ //Now try to fill the pool with new data
+ if(this->internal_data.pool_size < num_new){
+ this->priv_increase_pool(num_new - this->internal_data.pool_size);
       }
- else{
- void_ptr &pool_first_ref = impl.end()[-2];
- void_ptr &pool_last_ref = impl.back();
- multiallocation_chain holder;
- holder.incorporate_after(holder.before_begin(), pool_first_ref, pool_last_ref, internal_data.pool_size);
- node_type_ptr_t ret = holder.front();
- holder.pop_front();
- --this->internal_data.pool_size;
- if(!internal_data.pool_size){
- pool_first_ref = pool_last_ref = void_ptr(0);
- }
- else{
- std::pair<void_ptr, void_ptr> data(holder.extract_data());
- pool_first_ref = data.first;
- pool_last_ref = data.second;
- }
- return ret;
+
+ //Now try to make room in the vector
+ const node_base_ptr_ptr old_buffer = this->index.data();
+ this->index.insert(this->index.begin() + pos, num_new, node_ptr());
+ bool new_buffer = this->index.data() != old_buffer;
+
+ //Fix the pointers for the newly allocated buffer
+ const index_iterator index_beg = this->index.begin();
+ if(new_buffer){
+ index_traits_type::fix_up_pointers(index_beg, index_beg + pos);
       }
+ return index_beg + pos;
    }
 
- void insert_iter_prolog(size_type n, difference_type d)
+ bool priv_capacity_bigger_than_size() const
    {
- initialize_end_node(n);
- const void* old_ptr = &impl[0];
- //size_type old_capacity = capacity();
- //size_type old_size = size();
- impl.insert(impl.begin()+d, n, 0);
- bool realloced = &impl[0] != old_ptr;
- //Fix the pointers for the newly allocated buffer
- if(realloced){
- align_nodes(impl.begin(), impl.begin()+d);
- }
+ return this->index.capacity() > this->index.size() &&
+ this->internal_data.pool_size > 0;
    }
 
- template<typename InputIterator>
- void assign_dispatch(InputIterator first, InputIterator last, boost::mpl::false_)
+ template <class U>
+ void priv_push_back(BOOST_MOVE_CATCH_FWD(U) x)
    {
- STABLE_VECTOR_CHECK_INVARIANT;
- iterator first1 = this->begin();
- iterator last1 = this->end();
- for ( ; first1 != last1 && first != last; ++first1, ++first)
- *first1 = *first;
- if (first == last){
- this->erase(first1, last1);
+ if(this->priv_capacity_bigger_than_size()){
+ //Enough memory in the pool and in the index
+ const node_ptr p = this->priv_get_from_pool();
+ BOOST_ASSERT(!!p);
+ {
+ push_back_rollback rollback(*this, p);
+ //This might throw
+ this->priv_build_node_from_convertible(p, ::boost::forward<U>(x));
+ rollback.release();
+ }
+ //This can't throw as there is room for a new elements in the index
+ index_iterator new_index = this->index.insert(this->index.end() - ExtraPointers, p);
+ index_traits_type::fix_up_pointers_from(this->index, new_index);
       }
       else{
- this->insert(last1, first, last);
+ this->insert(this->cend(), ::boost::forward<U>(x));
       }
    }
 
- template<typename Integer>
- void assign_dispatch(Integer n, Integer t, boost::mpl::true_)
+ iterator priv_insert(const_iterator position, const value_type &t)
    {
       typedef constant_iterator<value_type, difference_type> cvalue_iterator;
- this->assign_dispatch(cvalue_iterator(t, n), cvalue_iterator(), boost::mpl::false_());
+ return this->insert(position, cvalue_iterator(t, 1), cvalue_iterator());
    }
 
- iterator priv_erase(const_iterator first, const_iterator last, allocator_v1)
+ iterator priv_insert(const_iterator position, BOOST_RV_REF(T) x)
    {
- STABLE_VECTOR_CHECK_INVARIANT;
- difference_type d1 = first - this->cbegin(), d2 = last - this->cbegin();
- if(d1 != d2){
- impl_iterator it1(impl.begin() + d1), it2(impl.begin() + d2);
- for(impl_iterator it = it1; it != it2; ++it)
- this->delete_node(*it);
- impl_iterator e = impl.erase(it1, it2);
- this->align_nodes(e, get_last_align());
- }
- return iterator(this->begin() + d1);
- }
-
- impl_iterator get_last_align()
- {
- return impl.end() - (ExtraPointers - 1);
- }
-
- const_impl_iterator get_last_align() const
- {
- return impl.cend() - (ExtraPointers - 1);
- }
-
- template<class AllocatorVersion>
- iterator priv_erase(const_iterator first, const_iterator last, AllocatorVersion,
- typename boost::container::container_detail::enable_if_c
- <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
- ::value>::type * = 0)
- {
- STABLE_VECTOR_CHECK_INVARIANT;
- return priv_erase(first, last, allocator_v1());
+ typedef repeat_iterator<T, difference_type> repeat_it;
+ typedef boost::move_iterator<repeat_it> repeat_move_it;
+ //Just call more general insert(pos, size, value) and return iterator
+ return this->insert(position, repeat_move_it(repeat_it(x, 1)), repeat_move_it(repeat_it()));
    }
 
- static node_type_ptr_t node_ptr_cast(const void_ptr &p)
+ void priv_clear_pool()
    {
- return node_type_ptr_t(static_cast<node_type_t*>(container_detail::to_raw_pointer(p)));
- }
+ if(!this->index.empty() && this->index.back()){
+ node_base_ptr &pool_first_ref = *(this->index.end() - 2);
+ node_base_ptr &pool_last_ref = this->index.back();
 
- static node_type_base_ptr_t node_base_ptr_cast(const void_ptr &p)
- {
- return node_type_base_ptr_t(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p)));
+ multiallocation_chain holder;
+ holder.incorporate_after( holder.before_begin()
+ , node_ptr_traits::static_cast_from(pool_first_ref)
+ , node_ptr_traits::static_cast_from(pool_last_ref)
+ , internal_data.pool_size);
+ this->deallocate_individual(holder);
+ pool_first_ref = pool_last_ref = 0;
+ this->internal_data.pool_size = 0;
+ }
    }
 
- static value_type& value(const void_ptr &p)
+ void priv_increase_pool(size_type n)
    {
- return node_ptr_cast(p)->value;
+ node_base_ptr &pool_first_ref = *(this->index.end() - 2);
+ node_base_ptr &pool_last_ref = this->index.back();
+ multiallocation_chain holder;
+ holder.incorporate_after( holder.before_begin()
+ , node_ptr_traits::static_cast_from(pool_first_ref)
+ , node_ptr_traits::static_cast_from(pool_last_ref)
+ , internal_data.pool_size);
+ multiallocation_chain m (this->allocate_individual(n));
+ holder.splice_after(holder.before_begin(), m, m.before_begin(), m.last(), n);
+ this->internal_data.pool_size += n;
+ std::pair<node_ptr, node_ptr> data(holder.extract_data());
+ pool_first_ref = data.first;
+ pool_last_ref = data.second;
    }
 
- void initialize_end_node(size_type impl_capacity = 0)
+ void priv_put_in_pool(const node_ptr &p)
    {
- if(impl.empty()){
- impl.reserve(impl_capacity + ExtraPointers);
- impl.resize (ExtraPointers, void_ptr(0));
- impl[0] = &this->internal_data.end_node;
- this->internal_data.end_node.up = &impl[0];
- }
+ node_base_ptr &pool_first_ref = *(this->index.end()-2);
+ node_base_ptr &pool_last_ref = this->index.back();
+ multiallocation_chain holder;
+ holder.incorporate_after( holder.before_begin()
+ , node_ptr_traits::static_cast_from(pool_first_ref)
+ , node_ptr_traits::static_cast_from(pool_last_ref)
+ , internal_data.pool_size);
+ holder.push_front(p);
+ ++this->internal_data.pool_size;
+ std::pair<node_ptr, node_ptr> ret(holder.extract_data());
+ pool_first_ref = ret.first;
+ pool_last_ref = ret.second;
    }
 
- void readjust_end_node()
+ node_ptr priv_get_from_pool()
    {
- if(!this->impl.empty()){
- void_ptr &end_node_ref = *(this->get_last_align()-1);
- end_node_ref = this->get_end_node();
- this->internal_data.end_node.up = &end_node_ref;
+ //Precondition: index is not empty
+ BOOST_ASSERT(!this->index.empty());
+ node_base_ptr &pool_first_ref = *(this->index.end() - 2);
+ node_base_ptr &pool_last_ref = this->index.back();
+ multiallocation_chain holder;
+ holder.incorporate_after( holder.before_begin()
+ , node_ptr_traits::static_cast_from(pool_first_ref)
+ , node_ptr_traits::static_cast_from(pool_last_ref)
+ , internal_data.pool_size);
+ node_ptr ret = holder.pop_front();
+ --this->internal_data.pool_size;
+ if(!internal_data.pool_size){
+ pool_first_ref = pool_last_ref = node_ptr();
       }
       else{
- this->internal_data.end_node.up = void_ptr(&this->internal_data.end_node.up);
+ std::pair<node_ptr, node_ptr> data(holder.extract_data());
+ pool_first_ref = data.first;
+ pool_last_ref = data.second;
       }
+ return ret;
    }
 
- node_type_ptr_t get_end_node() const
+ node_ptr priv_get_end_node() const
    {
- const node_type_base_t* cp = &this->internal_data.end_node;
- node_type_base_t* p = const_cast<node_type_base_t*>(cp);
- return node_ptr_cast(p);
+ return node_ptr_traits::pointer_to
+ (static_cast<node_type&>(const_cast<node_base_type&>(this->internal_data.end_node)));
    }
 
- template<class Iter>
- void_ptr new_node(const void_ptr &up, Iter it)
+ void priv_delete_node(const node_ptr &n)
    {
- node_type_ptr_t p = this->allocate_one();
- try{
- boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), it);
- //This does not throw
- ::new(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p))) node_type_base_t;
- p->set_pointer(up);
- }
- catch(...){
- this->deallocate_one(p);
- throw;
- }
- return p;
- }
-
- void delete_node(const void_ptr &p)
- {
- node_type_ptr_t n(node_ptr_cast(p));
       allocator_traits<node_allocator_type>::
- destroy(this->node_alloc(), container_detail::to_raw_pointer(n));
- this->put_in_pool(n);
- }
-
- static void align_nodes(impl_iterator first, impl_iterator last)
- {
- while(first!=last){
- node_ptr_cast(*first)->up = void_ptr(&*first);
- ++first;
- }
+ destroy(this->priv_node_alloc(), container_detail::addressof(n->value));
+ static_cast<node_base_type*>(container_detail::to_raw_pointer(n))->~node_base_type();
+ this->priv_put_in_pool(n);
+ }
+
+ template<class Iterator>
+ void priv_build_node_from_it(const node_ptr &p, const index_iterator &up_index, const Iterator &it)
+ {
+ //This can throw
+ boost::container::construct_in_place
+ ( this->priv_node_alloc()
+ , container_detail::addressof(p->value)
+ , it);
+ //This does not throw
+ ::new(static_cast<node_base_type*>(container_detail::to_raw_pointer(p)))
+ node_base_type(index_traits_type::ptr_to_node_base_ptr(*up_index));
+ }
+
+ template<class ValueConvertible>
+ void priv_build_node_from_convertible(const node_ptr &p, BOOST_FWD_REF(ValueConvertible) value_convertible)
+ {
+ //This can throw
+ boost::container::allocator_traits<node_allocator_type>::construct
+ ( this->priv_node_alloc()
+ , container_detail::addressof(p->value)
+ , ::boost::forward<ValueConvertible>(value_convertible));
+ //This does not throw
+ ::new(static_cast<node_base_type*>(container_detail::to_raw_pointer(p))) node_base_type;
    }
 
- void insert_not_iter(const_iterator position, size_type n, const T& t)
- {
- typedef constant_iterator<value_type, difference_type> cvalue_iterator;
- this->insert_iter(position, cvalue_iterator(t, n), cvalue_iterator(), std::forward_iterator_tag());
- }
-
- template <class InputIterator>
- void insert_iter(const_iterator position,InputIterator first,InputIterator last, boost::mpl::true_)
- {
- typedef typename std::iterator_traits<InputIterator>::iterator_category category;
- this->insert_iter(position, first, last, category());
- }
-
- template <class InputIterator>
- void insert_iter(const_iterator position,InputIterator first,InputIterator last,std::input_iterator_tag)
- {
- for(; first!=last; ++first){
- this->insert(position, *first);
- }
- }
-
- template <class InputIterator>
- iterator insert_iter(const_iterator position, InputIterator first, InputIterator last, std::forward_iterator_tag)
+ void priv_swap_members(stable_vector &x)
    {
- size_type n = (size_type)std::distance(first,last);
- difference_type d = position-this->cbegin();
- if(n){
- this->insert_iter_prolog(n, d);
- const impl_iterator it(impl.begin() + d);
- this->insert_iter_fwd(it, first, last, n);
- //Fix the pointers for the newly allocated buffer
- this->align_nodes(it + n, get_last_align());
- }
- return this->begin() + d;
+ container_detail::do_swap(this->internal_data.pool_size, x.internal_data.pool_size);
+ index_traits_type::readjust_end_node(this->index, this->internal_data.end_node);
+ index_traits_type::readjust_end_node(x.index, x.internal_data.end_node);
    }
 
- template <class FwdIterator>
- void insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v1)
+ #if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
+ bool priv_invariant()const
    {
- size_type i=0;
- try{
- while(first!=last){
- it[i] = this->new_node(void_ptr_ptr(&it[i]), first);
- ++first;
- ++i;
- }
- }
- catch(...){
- impl_iterator e = impl.erase(it + i, it + n);
- this->align_nodes(e, get_last_align());
- throw;
- }
- }
+ index_type & index_ref = const_cast<index_type&>(this->index);
 
- template <class FwdIterator>
- void insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v2)
- {
- multiallocation_chain mem(node_alloc().allocate_individual(n));
-
- size_type i = 0;
- node_type_ptr_t p = 0;
- try{
- while(first != last){
- p = mem.front();
- mem.pop_front();
- //This can throw
- boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), first);
- //This does not throw
- ::new(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p))) node_type_base_t;
- p->set_pointer(void_ptr_ptr(&it[i]));
- ++first;
- it[i] = p;
- ++i;
- }
- }
- catch(...){
- node_alloc().deallocate_one(p);
- node_alloc().deallocate_many(boost::move(mem));
- impl_iterator e = impl.erase(it+i, it+n);
- this->align_nodes(e, get_last_align());
- throw;
- }
- }
-
- template <class FwdIterator>
- void insert_iter_fwd(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n)
- {
- size_type i = 0;
- node_type_ptr_t p = 0;
- try{
- while(first != last){
- p = this->get_from_pool();
- if(!p){
- insert_iter_fwd_alloc(it+i, first, last, n-i, alloc_version());
- break;
- }
- //This can throw
- boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), first);
- //This does not throw
- ::new(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p))) node_type_base_t;
- p->set_pointer(void_ptr_ptr(&it[i]));
- ++first;
- it[i]=p;
- ++i;
- }
- }
- catch(...){
- put_in_pool(p);
- impl_iterator e = impl.erase(it+i, it+n);
- this->align_nodes(e, get_last_align());
- throw;
+ if(index.empty())
+ return !this->capacity() && !this->size();
+ if(this->priv_get_end_node() != *(index.end() - ExtraPointers)){
+ return false;
       }
- }
 
- template <class InputIterator>
- void insert_iter(const_iterator position, InputIterator first, InputIterator last, boost::mpl::false_)
- {
- this->insert_not_iter(position, first, last);
- }
-
- #if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING)
- bool invariant()const
- {
- if(impl.empty())
- return !capacity() && !size();
- if(get_end_node() != *(impl.end() - ExtraPointers)){
+ if(!index_traits_type::invariants(index_ref)){
          return false;
       }
- for(const_impl_iterator it = impl.begin(), it_end = get_last_align(); it != it_end; ++it){
- if(const_void_ptr(node_ptr_cast(*it)->up) !=
- const_void_ptr(const_void_ptr_ptr(&*it)))
- return false;
- }
- size_type n = capacity()-size();
- const void_ptr &pool_head = impl.back();
+
+ size_type n = this->capacity() - this->size();
+ node_base_ptr &pool_first_ref = *(index_ref.end() - 2);
+ node_base_ptr &pool_last_ref = index_ref.back();
+ multiallocation_chain holder;
+ holder.incorporate_after( holder.before_begin()
+ , node_ptr_traits::static_cast_from(pool_first_ref)
+ , node_ptr_traits::static_cast_from(pool_last_ref)
+ , internal_data.pool_size);
+ typename multiallocation_chain::iterator beg(holder.begin()), end(holder.end());
       size_type num_pool = 0;
- node_type_ptr_t p = node_ptr_cast(pool_head);
- while(p){
+ while(beg != end){
          ++num_pool;
- p = node_ptr_cast(p->up);
+ ++beg;
       }
- return n >= num_pool;
+ return n >= num_pool && num_pool == internal_data.pool_size;
    }
 
    class invariant_checker
@@ -1715,7 +1827,7 @@
 
       public:
       invariant_checker(const stable_vector& v):p(&v){}
- ~invariant_checker(){BOOST_ASSERT(p->invariant());}
+ ~invariant_checker(){BOOST_ASSERT(p->priv_invariant());}
       void touch(){}
    };
    #endif
@@ -1725,51 +1837,29 @@
    {
       private:
       BOOST_MOVABLE_BUT_NOT_COPYABLE(ebo_holder)
+
       public:
-/*
- explicit ebo_holder(BOOST_RV_REF(ebo_holder) x)
- : node_allocator_type(boost::move(static_cast<node_allocator_type&>(x)))
- , pool_size(0)
- , end_node()
- {}
-*/
       template<class AllocatorRLValue>
       explicit ebo_holder(BOOST_FWD_REF(AllocatorRLValue) a)
          : node_allocator_type(boost::forward<AllocatorRLValue>(a))
          , pool_size(0)
          , end_node()
- {
- this->set_end_pointer_to_default_constructed();
- }
+ {}
 
       ebo_holder()
          : node_allocator_type()
          , pool_size(0)
          , end_node()
- {
- this->set_end_pointer_to_default_constructed();
- }
-
- void set_end_pointer_to_default_constructed()
- {
- end_node.set_pointer(void_ptr(&end_node.up));
- }
+ {}
 
       size_type pool_size;
- node_type_base_t end_node;
+ node_base_type end_node;
    } internal_data;
 
- void priv_swap_members(stable_vector &x)
- {
- container_detail::do_swap(this->internal_data.pool_size, x.internal_data.pool_size);
- this->readjust_end_node();
- x.readjust_end_node();
- }
-
- node_allocator_type &node_alloc() { return internal_data; }
- const node_allocator_type &node_alloc() const { return internal_data; }
+ node_allocator_type &priv_node_alloc() { return internal_data; }
+ const node_allocator_type &priv_node_alloc() const { return internal_data; }
 
- impl_type impl;
+ index_type index;
    /// @endcond
 };
 

Modified: branches/release/boost/container/string.hpp
==============================================================================
--- branches/release/boost/container/string.hpp (original)
+++ branches/release/boost/container/string.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -48,6 +48,7 @@
 #include <boost/move/move.hpp>
 #include <boost/static_assert.hpp>
 #include <boost/functional/hash.hpp>
+#include <boost/intrusive/pointer_traits.hpp>
 
 #include <functional>
 #include <string>
@@ -68,13 +69,8 @@
 #include <boost/type_traits/has_trivial_destructor.hpp>
 #include <boost/aligned_storage.hpp>
 
-#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
 namespace boost {
 namespace container {
-#else
-namespace boost {
-namespace container {
-#endif
 
 /// @cond
 namespace container_detail {
@@ -97,10 +93,11 @@
  public:
    typedef A allocator_type;
    //! The stored allocator type
- typedef allocator_type stored_allocator_type;
+ typedef allocator_type stored_allocator_type;
    typedef typename allocator_traits_type::pointer pointer;
    typedef typename allocator_traits_type::value_type value_type;
    typedef typename allocator_traits_type::size_type size_type;
+ typedef ::boost::intrusive::pointer_traits<pointer> pointer_traits;
 
    basic_string_base()
       : members_()
@@ -128,10 +125,7 @@
    {
       if(!this->is_short()){
          this->deallocate_block();
- allocator_traits_type::destroy
- ( this->alloc()
- , static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r))
- );
+ this->is_short(true);
       }
    }
 
@@ -203,11 +197,17 @@
       long_raw_t r;
       short_t s;
 
- short_t &short_repr() const
- { return *const_cast<short_t *>(&s); }
+ const short_t &short_repr() const
+ { return s; }
 
- long_t &long_repr() const
- { return *const_cast<long_t*>(reinterpret_cast<const long_t*>(&r)); }
+ const long_t &long_repr() const
+ { return *static_cast<const long_t*>(static_cast<const void*>(&r)); }
+
+ short_t &short_repr()
+ { return s; }
+
+ long_t &long_repr()
+ { return *static_cast<long_t*>(static_cast<void*>(&r)); }
    };
 
    struct members_holder
@@ -242,20 +242,22 @@
    { return static_cast<bool>(this->members_.m_repr.s.h.is_short != 0); }
 
    void is_short(bool yes)
- {
- if(yes && !this->is_short()){
+ {
+ const bool was_short = this->is_short();
+ if(yes && !was_short){
          allocator_traits_type::destroy
             ( this->alloc()
             , static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r))
             );
+ this->members_.m_repr.s.h.is_short = true;
       }
- else{
+ else if(!yes && was_short){
          allocator_traits_type::construct
             ( this->alloc()
             , static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r))
             );
+ this->members_.m_repr.s.h.is_short = false;
       }
- this->members_.m_repr.s.h.is_short = yes;
    }
 
    private:
@@ -279,7 +281,7 @@
                          size_type &received_size, pointer reuse = 0)
    {
       if(this->is_short() && (command & (expand_fwd | expand_bwd)) ){
- reuse = pointer(0);
+ reuse = pointer();
          command &= ~(expand_fwd | expand_bwd);
       }
       return this->allocation_command
@@ -297,7 +299,7 @@
       (void)limit_size;
       (void)reuse;
       if(!(command & allocate_new))
- return std::pair<pointer, bool>(pointer(0), false);
+ return std::pair<pointer, bool>(pointer(), false);
       received_size = preferred_size;
       return std::make_pair(this->alloc().allocate(received_size), false);
    }
@@ -358,7 +360,7 @@
             pointer p = this->allocation_command(allocate_new, n, new_cap, new_cap).first;
             this->is_short(false);
             this->priv_long_addr(p);
- this->priv_size(0);
+ this->priv_long_size(0);
             this->priv_storage(new_cap);
          }
       }
@@ -384,13 +386,26 @@
    { return this->priv_storage() - 1; }
 
    pointer priv_short_addr() const
- { return pointer(&this->members_.m_repr.short_repr().data[0]); }
+ { return pointer_traits::pointer_to(const_cast<value_type&>(this->members_.m_repr.short_repr().data[0])); }
 
    pointer priv_long_addr() const
    { return this->members_.m_repr.long_repr().start; }
 
    pointer priv_addr() const
- { return this->is_short() ? pointer(&this->members_.m_repr.short_repr().data[0]) : this->members_.m_repr.long_repr().start; }
+ {
+ return this->is_short()
+ ? priv_short_addr()
+ : priv_long_addr()
+ ;
+ }
+
+ pointer priv_end_addr() const
+ {
+ return this->is_short()
+ ? this->priv_short_addr() + this->priv_short_size()
+ : this->priv_long_addr() + this->priv_long_size()
+ ;
+ }
 
    void priv_long_addr(pointer addr)
    { this->members_.m_repr.long_repr().start = addr; }
@@ -416,7 +431,7 @@
    }
 
    size_type priv_size() const
- { return this->is_short() ? priv_short_size() : priv_long_size(); }
+ { return this->is_short() ? this->priv_short_size() : this->priv_long_size(); }
 
    size_type priv_short_size() const
    { return this->members_.m_repr.short_repr().h.length; }
@@ -439,7 +454,7 @@
 
    void priv_long_size(size_type sz)
    {
- this->members_.m_repr.long_repr().length = static_cast<typename allocator_traits_type::size_type>(sz);
+ this->members_.m_repr.long_repr().length = sz;
    }
 
    void swap_data(basic_string_base& other)
@@ -449,16 +464,22 @@
             container_detail::do_swap(this->members_.m_repr, other.members_.m_repr);
          }
          else{
- repr_t copied(this->members_.m_repr);
- this->members_.m_repr.long_repr() = other.members_.m_repr.long_repr();
- other.members_.m_repr = copied;
+ short_t short_backup(this->members_.m_repr.short_repr());
+ long_t long_backup (other.members_.m_repr.long_repr());
+ other.members_.m_repr.long_repr().~long_t();
+ ::new(&this->members_.m_repr.long_repr()) long_t;
+ this->members_.m_repr.long_repr() = long_backup;
+ other.members_.m_repr.short_repr() = short_backup;
          }
       }
       else{
          if(other.is_short()){
- repr_t copied(other.members_.m_repr);
- other.members_.m_repr.long_repr() = this->members_.m_repr.long_repr();
- this->members_.m_repr = copied;
+ short_t short_backup(other.members_.m_repr.short_repr());
+ long_t long_backup (this->members_.m_repr.long_repr());
+ this->members_.m_repr.long_repr().~long_t();
+ ::new(&other.members_.m_repr.long_repr()) long_t;
+ other.members_.m_repr.long_repr() = long_backup;
+ this->members_.m_repr.short_repr() = short_backup;
          }
          else{
             container_detail::do_swap(this->members_.m_repr.long_repr(), other.members_.m_repr.long_repr());
@@ -586,6 +607,7 @@
    typedef typename base_t::allocator_v1 allocator_v1;
    typedef typename base_t::allocator_v2 allocator_v2;
    typedef typename base_t::alloc_version alloc_version;
+ typedef ::boost::intrusive::pointer_traits<pointer> pointer_traits;
    /// @endcond
 
    public: // Constructor, destructor, assignment.
@@ -624,7 +646,10 @@
    //! <b>Throws</b>: If allocator_type's default constructor throws.
    basic_string(const basic_string& s)
       : base_t(allocator_traits_type::select_on_container_copy_construction(s.alloc()))
- { this->priv_range_initialize(s.begin(), s.end()); }
+ {
+ this->priv_terminate_string();
+ this->assign(s.begin(), s.end());
+ }
 
    //! <b>Effects</b>: Move constructor. Moves s's resources to *this.
    //!
@@ -642,7 +667,10 @@
    //! <b>Throws</b>: If allocation throws.
    basic_string(const basic_string& s, const allocator_type &a)
       : base_t(a)
- { this->priv_range_initialize(s.begin(), s.end()); }
+ {
+ this->priv_terminate_string();
+ this->assign(s.begin(), s.end());
+ }
 
    //! <b>Effects</b>: Move constructor using the specified allocator.
    //! Moves s's resources to *this.
@@ -653,11 +681,12 @@
    basic_string(BOOST_RV_REF(basic_string) s, const allocator_type &a)
       : base_t(a)
    {
+ this->priv_terminate_string();
       if(a == this->alloc()){
          this->swap_data(s);
       }
       else{
- this->priv_range_initialize(s.begin(), s.end());
+ this->assign(s.begin(), s.end());
       }
    }
 
@@ -667,10 +696,11 @@
                const allocator_type& a = allocator_type())
       : base_t(a)
    {
+ this->priv_terminate_string();
       if (pos > s.size())
          this->throw_out_of_range();
       else
- this->priv_range_initialize
+ this->assign
             (s.begin() + pos, s.begin() + pos + container_detail::min_value(n, s.size() - pos));
    }
 
@@ -679,23 +709,29 @@
    basic_string(const CharT* s, size_type n,
                const allocator_type& a = allocator_type())
       : base_t(a)
- { this->priv_range_initialize(s, s + n); }
+ {
+ this->priv_terminate_string();
+ this->assign(s, s + n);
+ }
 
    //! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter,
    //! and is initialized by the null-terminated s c-string.
    basic_string(const CharT* s,
                 const allocator_type& a = allocator_type())
       : base_t(a)
- { this->priv_range_initialize(s, s + Traits::length(s)); }
+ {
+ this->priv_terminate_string();
+ this->assign(s, s + Traits::length(s));
+ }
 
    //! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter,
    //! and is initialized by n copies of c.
    basic_string(size_type n, CharT c,
                 const allocator_type& a = allocator_type())
       : base_t(a)
- {
- this->priv_range_initialize(cvalue_iterator(c, n),
- cvalue_iterator());
+ {
+ this->priv_terminate_string();
+ this->assign(n, c);
    }
 
    //! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter,
@@ -705,10 +741,8 @@
                const allocator_type& a = allocator_type())
       : base_t(a)
    {
- //Dispatch depending on integer/iterator
- const bool aux_boolean = container_detail::is_convertible<InputIterator, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- this->priv_initialize_dispatch(f, l, Result());
+ this->priv_terminate_string();
+ this->assign(f, l);
    }
 
    //! <b>Effects</b>: Destroys the basic_string. All used memory is deallocated.
@@ -735,8 +769,8 @@
             if(!this->is_short()){
                this->deallocate_block();
                this->is_short(true);
- Traits::assign(*this->priv_addr(), this->priv_null());
- this->priv_size(0);
+ Traits::assign(*this->priv_addr(), CharT(0));
+ this->priv_short_size(0);
             }
          }
          container_detail::assign_alloc(this->alloc(), x.alloc(), flag);
@@ -811,7 +845,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    iterator end()
- { return this->priv_addr() + this->priv_size(); }
+ { return this->priv_end_addr(); }
 
    //! <b>Effects</b>: Returns a const_iterator to the end of the vector.
    //!
@@ -819,7 +853,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    const_iterator end() const
- { return this->priv_addr() + this->priv_size(); }
+ { return this->priv_end_addr(); }
 
    //! <b>Effects</b>: Returns a const_iterator to the end of the vector.
    //!
@@ -827,7 +861,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    const_iterator cend() const
- { return this->priv_addr() + this->priv_size(); }
+ { return this->priv_end_addr(); }
 
    //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
    //! of the reversed vector.
@@ -836,7 +870,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    reverse_iterator rbegin()
- { return reverse_iterator(this->priv_addr() + this->priv_size()); }
+ { return reverse_iterator(this->priv_end_addr()); }
 
    //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
    //! of the reversed vector.
@@ -854,7 +888,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    const_reverse_iterator crbegin() const
- { return const_reverse_iterator(this->priv_addr() + this->priv_size()); }
+ { return const_reverse_iterator(this->priv_end_addr()); }
 
    //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
    //! of the reversed vector.
@@ -943,7 +977,7 @@
    //! <b>Complexity</b>: Linear to the difference between size() and new_size.
    void resize(size_type n, CharT c)
    {
- if (n <= size())
+ if (n <= this->size())
          this->erase(this->begin() + n, this->end());
       else
          this->append(n - this->size(), c);
@@ -956,7 +990,7 @@
    //!
    //! <b>Complexity</b>: Linear to the difference between size() and new_size.
    void resize(size_type n)
- { resize(n, this->priv_null()); }
+ { resize(n, CharT(0)); }
 
    //! <b>Effects</b>: If n is less than or equal to capacity(), this call has no
    //! effect. Otherwise, it is a request for allocation of additional memory.
@@ -966,8 +1000,9 @@
    //! <b>Throws</b>: If memory allocation allocation throws
    void reserve(size_type res_arg)
    {
- if (res_arg > this->max_size())
+ if (res_arg > this->max_size()){
          this->throw_length_error();
+ }
 
       if (this->capacity() < res_arg){
          size_type n = container_detail::max_value(res_arg, this->size()) + 1;
@@ -976,13 +1011,14 @@
             (allocate_new, n, new_cap, new_cap).first;
          size_type new_length = 0;
 
+ const pointer addr = this->priv_addr();
          new_length += priv_uninitialized_copy
- (this->priv_addr(), this->priv_addr() + this->priv_size(), new_start);
+ (addr, addr + this->priv_size(), new_start);
          this->priv_construct_null(new_start + new_length);
          this->deallocate_block();
          this->is_short(false);
          this->priv_long_addr(new_start);
- this->priv_size(new_length);
+ this->priv_long_size(new_length);
          this->priv_storage(new_cap);
       }
    }
@@ -1003,8 +1039,8 @@
    //! <b>Complexity</b>: Linear to the number of elements in the vector.
    void clear()
    {
- if (!empty()) {
- Traits::assign(*this->priv_addr(), this->priv_null());
+ if (!this->empty()) {
+ Traits::assign(*this->priv_addr(), CharT(0));
          this->priv_size(0);
       }
    }
@@ -1021,7 +1057,7 @@
       if(this->priv_storage() > InternalBufferChars){
          //Check if we should pass from dynamically allocated buffer
          //to the internal storage
- if(this->priv_size() < (InternalBufferChars)){
+ if(this->priv_size() < InternalBufferChars){
             //Dynamically allocated buffer attributes
             pointer long_addr = this->priv_long_addr();
             size_type long_storage = this->priv_long_storage();
@@ -1078,9 +1114,10 @@
    //! <b>Throws</b>: std::range_error if n >= size()
    //!
    //! <b>Complexity</b>: Constant.
- reference at(size_type n) {
- if (n >= size())
- this->throw_out_of_range();
+ reference at(size_type n)
+ {
+ if (n >= this->size())
+ this->throw_out_of_range();
       return *(this->priv_addr() + n);
    }
 
@@ -1093,7 +1130,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    const_reference at(size_type n) const {
- if (n >= size())
+ if (n >= this->size())
          this->throw_out_of_range();
       return *(this->priv_addr() + n);
    }
@@ -1177,14 +1214,16 @@
    //! <b>Effects</b>: Equivalent to append(static_cast<size_type>(1), c).
    void push_back(CharT c)
    {
- if (this->priv_size() < this->capacity()){
- this->priv_construct_null(this->priv_addr() + (this->priv_size() + 1));
- Traits::assign(this->priv_addr()[this->priv_size()], c);
- this->priv_size(this->priv_size()+1);
+ const size_type old_size = this->priv_size();
+ if (old_size < this->capacity()){
+ const pointer addr = this->priv_addr();
+ this->priv_construct_null(addr + old_size + 1);
+ Traits::assign(addr[old_size], c);
+ this->priv_size(old_size+1);
       }
       else{
          //No enough memory, insert a new object at the end
- this->append((size_type)1, c);
+ this->append(size_type(1), c);
       }
    }
 
@@ -1212,8 +1251,8 @@
    //! <b>Throws</b>: If memory allocation throws or out_of_range if pos > str.size().
    //!
    //! <b>Returns</b>: *this
- basic_string& assign(const basic_string& s,
- size_type pos, size_type n) {
+ basic_string& assign(const basic_string& s, size_type pos, size_type n)
+ {
       if (pos > s.size())
       this->throw_out_of_range();
       return this->assign(s.begin() + pos,
@@ -1249,12 +1288,29 @@
    //!
    //! <b>Returns</b>: *this
    template <class InputIter>
- basic_string& assign(InputIter first, InputIter last)
+ basic_string& assign(InputIter first, InputIter last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InputIter, size_type>::value
+ >::type * = 0
+ #endif
+ )
    {
- //Dispatch depending on integer/iterator
- const bool aux_boolean = container_detail::is_convertible<InputIter, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- return this->priv_assign_dispatch(first, last, Result());
+ size_type cur = 0;
+ const pointer addr = this->priv_addr();
+ CharT *ptr = container_detail::to_raw_pointer(addr);
+ const size_type old_size = this->priv_size();
+ while (first != last && cur != old_size) {
+ Traits::assign(*ptr, *first);
+ ++first;
+ ++cur;
+ ++ptr;
+ }
+ if (first == last)
+ this->erase(addr + cur, addr + old_size);
+ else
+ this->append(first, last);
+ return *this;
    }
 
    //! <b>Requires</b>: pos <= size().
@@ -1266,9 +1322,10 @@
    //! <b>Returns</b>: *this
    basic_string& insert(size_type pos, const basic_string& s)
    {
- if (pos > size())
+ const size_type size = this->size();
+ if (pos > size)
          this->throw_out_of_range();
- if (this->size() > this->max_size() - s.size())
+ if (size > this->max_size() - s.size())
          this->throw_length_error();
       this->insert(this->priv_addr() + pos, s.begin(), s.end());
       return *this;
@@ -1282,13 +1339,14 @@
    //! <b>Throws</b>: If memory allocation throws or out_of_range if pos1 > size() or pos2 > str.size().
    //!
    //! <b>Returns</b>: *this
- basic_string& insert(size_type pos1, const basic_string& s,
- size_type pos2, size_type n)
+ basic_string& insert(size_type pos1, const basic_string& s, size_type pos2, size_type n)
    {
- if (pos1 > this->size() || pos2 > s.size())
+ const size_type size = this->size();
+ const size_type str_size = s.size();
+ if (pos1 > size || pos2 > str_size)
          this->throw_out_of_range();
- size_type len = container_detail::min_value(n, s.size() - pos2);
- if (this->size() > this->max_size() - len)
+ size_type len = container_detail::min_value(n, str_size - pos2);
+ if (size > this->max_size() - len)
          this->throw_length_error();
       const CharT *beg_ptr = container_detail::to_raw_pointer(s.begin()) + pos2;
       const CharT *end_ptr = beg_ptr + len;
@@ -1327,7 +1385,7 @@
    //! <b>Returns</b>: *this
    basic_string& insert(size_type pos, const CharT* s)
    {
- if (pos > size())
+ if (pos > this->size())
          this->throw_out_of_range();
       size_type len = Traits::length(s);
       if (this->size() > this->max_size() - len)
@@ -1359,7 +1417,7 @@
    //! <b>Returns</b>: An iterator which refers to the copy of the inserted character.
    iterator insert(const_iterator p, CharT c)
    {
- size_type new_offset = p - this->priv_addr() + 1;
+ size_type new_offset = p - this->priv_addr();
       this->insert(p, cvalue_iterator(c, 1), cvalue_iterator());
       return this->priv_addr() + new_offset;
    }
@@ -1369,28 +1427,144 @@
    //!
    //! <b>Effects</b>: Inserts n copies of c before the character referred to by p.
    //!
- //! <b>Returns</b>: An iterator which refers to the copy of the first
- //! inserted character, or p if n == 0.
- void insert(const_iterator p, size_type n, CharT c)
- {
- this->insert(p, cvalue_iterator(c, n), cvalue_iterator());
- }
+ //! <b>Returns</b>: an iterator to the first inserted element or p if n is 0.
+ iterator insert(const_iterator p, size_type n, CharT c)
+ { return this->insert(p, cvalue_iterator(c, n), cvalue_iterator()); }
 
    //! <b>Requires</b>: p is a valid iterator on *this. [first,last) is a valid range.
    //!
    //! <b>Effects</b>: Equivalent to insert(p - begin(), basic_string(first, last)).
    //!
- //! <b>Returns</b>: An iterator which refers to the copy of the first
- //! inserted character, or p if first == last.
+ //! <b>Returns</b>: an iterator to the first inserted element or p if first == last.
    template <class InputIter>
- void insert(const_iterator p, InputIter first, InputIter last)
+ iterator insert(const_iterator p, InputIter first, InputIter last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InputIter, size_type>::value
+ && container_detail::is_input_iterator<InputIter>::value
+ >::type * = 0
+ #endif
+ )
    {
- //Dispatch depending on integer/iterator
- const bool aux_boolean = container_detail::is_convertible<InputIter, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- this->priv_insert_dispatch(p, first, last, Result());
+ const size_type n_pos = p - this->cbegin();
+ for ( ; first != last; ++first, ++p) {
+ p = this->insert(p, *first);
+ }
+ return this->begin() + n_pos;
    }
 
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ template <class ForwardIter>
+ iterator insert(const_iterator p, ForwardIter first, ForwardIter last
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<ForwardIter, size_type>::value
+ && !container_detail::is_input_iterator<ForwardIter>::value
+ >::type * = 0
+ )
+ {
+ const size_type n_pos = p - this->cbegin();
+ if (first != last) {
+ const size_type n = std::distance(first, last);
+ const size_type old_size = this->priv_size();
+ const size_type remaining = this->capacity() - old_size;
+ const pointer old_start = this->priv_addr();
+ bool enough_capacity = false;
+ std::pair<pointer, bool> allocation_ret;
+ size_type new_cap = 0;
+
+ //Check if we have enough capacity
+ if (remaining >= n){
+ enough_capacity = true;
+ }
+ else {
+ //Otherwise expand current buffer or allocate new storage
+ new_cap = this->next_capacity(n);
+ allocation_ret = this->allocation_command
+ (allocate_new | expand_fwd | expand_bwd, old_size + n + 1,
+ new_cap, new_cap, old_start);
+
+ //Check forward expansion
+ if(old_start == allocation_ret.first){
+ enough_capacity = true;
+ this->priv_storage(new_cap);
+ }
+ }
+
+ //Reuse same buffer
+ if(enough_capacity){
+ const size_type elems_after = old_size - (p - old_start);
+ const size_type old_length = old_size;
+ if (elems_after >= n) {
+ const pointer pointer_past_last = old_start + old_size + 1;
+ priv_uninitialized_copy(old_start + (old_size - n + 1),
+ pointer_past_last, pointer_past_last);
+
+ this->priv_size(old_size+n);
+ Traits::move(const_cast<CharT*>(container_detail::to_raw_pointer(p + n)),
+ container_detail::to_raw_pointer(p),
+ (elems_after - n) + 1);
+ this->priv_copy(first, last, const_cast<CharT*>(container_detail::to_raw_pointer(p)));
+ }
+ else {
+ ForwardIter mid = first;
+ std::advance(mid, elems_after + 1);
+
+ priv_uninitialized_copy(mid, last, old_start + old_size + 1);
+ const size_type newer_size = old_size + (n - elems_after);
+ this->priv_size(newer_size);
+ priv_uninitialized_copy
+ (p, const_iterator(old_start + old_length + 1),
+ old_start + newer_size);
+ this->priv_size(newer_size + elems_after);
+ this->priv_copy(first, mid, const_cast<CharT*>(container_detail::to_raw_pointer(p)));
+ }
+ }
+ else{
+ pointer new_start = allocation_ret.first;
+ if(!allocation_ret.second){
+ //Copy data to new buffer
+ size_type new_length = 0;
+ //This can't throw, since characters are POD
+ new_length += priv_uninitialized_copy
+ (const_iterator(old_start), p, new_start);
+ new_length += priv_uninitialized_copy
+ (first, last, new_start + new_length);
+ new_length += priv_uninitialized_copy
+ (p, const_iterator(old_start + old_size),
+ new_start + new_length);
+ this->priv_construct_null(new_start + new_length);
+
+ this->deallocate_block();
+ this->is_short(false);
+ this->priv_long_addr(new_start);
+ this->priv_long_size(new_length);
+ this->priv_long_storage(new_cap);
+ }
+ else{
+ //value_type is POD, so backwards expansion is much easier
+ //than with vector<T>
+ value_type * const oldbuf = container_detail::to_raw_pointer(old_start);
+ value_type * const newbuf = container_detail::to_raw_pointer(new_start);
+ const value_type *const pos = container_detail::to_raw_pointer(p);
+ const size_type before = pos - oldbuf;
+
+ //First move old data
+ Traits::move(newbuf, oldbuf, before);
+ Traits::move(newbuf + before + n, pos, old_size - before);
+ //Now initialize the new data
+ priv_uninitialized_copy(first, last, new_start + before);
+ this->priv_construct_null(new_start + (old_size + n));
+ this->is_short(false);
+ this->priv_long_addr(new_start);
+ this->priv_long_size(old_size + n);
+ this->priv_long_storage(new_cap);
+ }
+ }
+ }
+ return this->begin() + n_pos;
+ }
+ #endif
+
    //! <b>Requires</b>: pos <= size()
    //!
    //! <b>Effects</b>: Determines the effective length xlen of the string to be removed as the smaller of n and size() - pos.
@@ -1404,9 +1578,10 @@
    //! <b>Returns</b>: *this
    basic_string& erase(size_type pos = 0, size_type n = npos)
    {
- if (pos > size())
+ if (pos > this->size())
          this->throw_out_of_range();
- erase(this->priv_addr() + pos, this->priv_addr() + pos + container_detail::min_value(n, size() - pos));
+ const pointer addr = this->priv_addr();
+ erase(addr + pos, addr + pos + container_detail::min_value(n, this->size() - pos));
       return *this;
    }
 
@@ -1419,11 +1594,12 @@
    iterator erase(const_iterator p)
    {
       // The move includes the terminating null.
- CharT *ptr = const_cast<CharT*>(container_detail::to_raw_pointer(p));
+ CharT * const ptr = const_cast<CharT*>(container_detail::to_raw_pointer(p));
+ const size_type old_size = this->priv_size();
       Traits::move(ptr,
                    container_detail::to_raw_pointer(p + 1),
- this->priv_size() - (p - this->priv_addr()));
- this->priv_size(this->priv_size()-1);
+ old_size - (p - this->priv_addr()));
+ this->priv_size(old_size-1);
       return iterator(ptr);
    }
 
@@ -1439,11 +1615,12 @@
    {
       CharT * f = const_cast<CharT*>(container_detail::to_raw_pointer(first));
       if (first != last) { // The move includes the terminating null.
- size_type num_erased = last - first;
+ const size_type num_erased = last - first;
+ const size_type old_size = this->priv_size();
          Traits::move(f,
                       container_detail::to_raw_pointer(last),
- (this->priv_size() + 1)-(last - this->priv_addr()));
- size_type new_length = this->priv_size() - num_erased;
+ (old_size + 1)-(last - this->priv_addr()));
+ const size_type new_length = old_size - num_erased;
          this->priv_size(new_length);
       }
       return iterator(f);
@@ -1456,8 +1633,9 @@
    //! <b>Effects</b>: Equivalent to erase(size() - 1, 1).
    void pop_back()
    {
- Traits::assign(this->priv_addr()[this->priv_size()-1], this->priv_null());
- this->priv_size(this->priv_size()-1);;
+ const size_type old_size = this->priv_size();
+ Traits::assign(this->priv_addr()[old_size-1], CharT(0));
+ this->priv_size(old_size-1);;
    }
 
    //! <b>Requires</b>: pos1 <= size().
@@ -1469,13 +1647,15 @@
    //! <b>Returns</b>: *this
    basic_string& replace(size_type pos1, size_type n1, const basic_string& str)
    {
- if (pos1 > size())
+ if (pos1 > this->size())
          this->throw_out_of_range();
- const size_type len = container_detail::min_value(n1, size() - pos1);
+ const size_type len = container_detail::min_value(n1, this->size() - pos1);
       if (this->size() - len >= this->max_size() - str.size())
          this->throw_length_error();
- return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len,
- str.begin(), str.end());
+ const pointer addr = this->priv_addr();
+ return this->replace( const_iterator(addr + pos1)
+ , const_iterator(addr + pos1 + len)
+ , str.begin(), str.end());
    }
 
    //! <b>Requires</b>: pos1 <= size() and pos2 <= str.size().
@@ -1490,14 +1670,16 @@
    basic_string& replace(size_type pos1, size_type n1,
                          const basic_string& str, size_type pos2, size_type n2)
    {
- if (pos1 > size() || pos2 > str.size())
+ if (pos1 > this->size() || pos2 > str.size())
          this->throw_out_of_range();
- const size_type len1 = container_detail::min_value(n1, size() - pos1);
+ const size_type len1 = container_detail::min_value(n1, this->size() - pos1);
       const size_type len2 = container_detail::min_value(n2, str.size() - pos2);
       if (this->size() - len1 >= this->max_size() - len2)
          this->throw_length_error();
- return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len1,
- str.priv_addr() + pos2, str.priv_addr() + pos2 + len2);
+ const pointer addr = this->priv_addr();
+ const pointer straddr = str.priv_addr();
+ return this->replace(addr + pos1, addr + pos1 + len1,
+ straddr + pos2, straddr + pos2 + len2);
    }
 
    //! <b>Requires</b>: pos1 <= size() and s points to an array of at least n2 elements of CharT.
@@ -1514,16 +1696,15 @@
    //! if the length of the resulting string would exceed max_size()
    //!
    //! <b>Returns</b>: *this
- basic_string& replace(size_type pos1, size_type n1,
- const CharT* s, size_type n2)
+ basic_string& replace(size_type pos1, size_type n1, const CharT* s, size_type n2)
    {
- if (pos1 > size())
+ if (pos1 > this->size())
          this->throw_out_of_range();
- const size_type len = container_detail::min_value(n1, size() - pos1);
+ const size_type len = container_detail::min_value(n1, this->size() - pos1);
       if (n2 > this->max_size() || size() - len >= this->max_size() - n2)
          this->throw_length_error();
- return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len,
- s, s + n2);
+ const pointer addr = this->priv_addr();
+ return this->replace(addr + pos1, addr + pos1 + len, s, s + n2);
    }
 
    //! <b>Requires</b>: pos1 <= size() and s points to an array of at least n2 elements of CharT.
@@ -1542,13 +1723,14 @@
    //! <b>Returns</b>: *this
    basic_string& replace(size_type pos, size_type n1, const CharT* s)
    {
- if (pos > size())
+ if (pos > this->size())
          this->throw_out_of_range();
- const size_type len = container_detail::min_value(n1, size() - pos);
+ const size_type len = container_detail::min_value(n1, this->size() - pos);
       const size_type n2 = Traits::length(s);
- if (n2 > this->max_size() || size() - len >= this->max_size() - n2)
+ if (n2 > this->max_size() || this->size() - len >= this->max_size() - n2)
          this->throw_length_error();
- return this->replace(this->priv_addr() + pos, this->priv_addr() + pos + len,
+ const pointer addr = this->priv_addr();
+ return this->replace(addr + pos, addr + pos + len,
                      s, s + Traits::length(s));
    }
 
@@ -1562,12 +1744,13 @@
    //! <b>Returns</b>: *this
    basic_string& replace(size_type pos1, size_type n1, size_type n2, CharT c)
    {
- if (pos1 > size())
+ if (pos1 > this->size())
          this->throw_out_of_range();
- const size_type len = container_detail::min_value(n1, size() - pos1);
- if (n2 > this->max_size() || size() - len >= this->max_size() - n2)
+ const size_type len = container_detail::min_value(n1, this->size() - pos1);
+ if (n2 > this->max_size() || this->size() - len >= this->max_size() - n2)
          this->throw_length_error();
- return this->replace(this->priv_addr() + pos1, this->priv_addr() + pos1 + len, n2, c);
+ const pointer addr = this->priv_addr();
+ return this->replace(addr + pos1, addr + pos1 + len, n2, c);
    }
 
    //! <b>Requires</b>: [begin(),i1) and [i1,i2) are valid ranges.
@@ -1631,14 +1814,51 @@
    //!
    //! <b>Returns</b>: *this
    template <class InputIter>
- basic_string& replace(const_iterator i1, const_iterator i2, InputIter j1, InputIter j2)
+ basic_string& replace(const_iterator i1, const_iterator i2, InputIter j1, InputIter j2
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InputIter, size_type>::value
+ && container_detail::is_input_iterator<InputIter>::value
+ >::type * = 0
+ #endif
+ )
    {
- //Dispatch depending on integer/iterator
- const bool aux_boolean = container_detail::is_convertible<InputIter, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- return this->priv_replace_dispatch(i1, i2, j1, j2, Result());
+ for ( ; i1 != i2 && j1 != j2; ++i1, ++j1){
+ Traits::assign(*const_cast<CharT*>(container_detail::to_raw_pointer(i1)), *j1);
+ }
+
+ if (j1 == j2)
+ this->erase(i1, i2);
+ else
+ this->insert(i2, j1, j2);
+ return *this;
    }
 
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ template <class ForwardIter>
+ basic_string& replace(const_iterator i1, const_iterator i2, ForwardIter j1, ForwardIter j2
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<ForwardIter, size_type>::value
+ && !container_detail::is_input_iterator<ForwardIter>::value
+ >::type * = 0
+ )
+ {
+ difference_type n = std::distance(j1, j2);
+ const difference_type len = i2 - i1;
+ if (len >= n) {
+ this->priv_copy(j1, j2, const_cast<CharT*>(container_detail::to_raw_pointer(i1)));
+ this->erase(i1 + n, i2);
+ }
+ else {
+ ForwardIter m = j1;
+ std::advance(m, len);
+ this->priv_copy(j1, m, const_cast<CharT*>(container_detail::to_raw_pointer(i1)));
+ this->insert(i2, m, j2);
+ }
+ return *this;
+ }
+ #endif
+
    //! <b>Requires</b>: pos <= size()
    //!
    //! <b>Effects</b>: Determines the effective length rlen of the string to copy as the
@@ -1652,9 +1872,9 @@
    //! <b>Returns</b>: rlen
    size_type copy(CharT* s, size_type n, size_type pos = 0) const
    {
- if (pos > size())
+ if (pos > this->size())
          this->throw_out_of_range();
- const size_type len = container_detail::min_value(n, size() - pos);
+ const size_type len = container_detail::min_value(n, this->size() - pos);
       Traits::copy(s, container_detail::to_raw_pointer(this->priv_addr() + pos), len);
       return len;
    }
@@ -1703,12 +1923,13 @@
    //! <b>Returns</b>: find(basic_string<CharT,traits,Allocator>(s,n),pos).
    size_type find(const CharT* s, size_type pos, size_type n) const
    {
- if (pos + n > size())
+ if (pos + n > this->size())
          return npos;
       else {
- pointer finish = this->priv_addr() + this->priv_size();
+ const pointer addr = this->priv_addr();
+ pointer finish = addr + this->priv_size();
          const const_iterator result =
- std::search(container_detail::to_raw_pointer(this->priv_addr() + pos),
+ std::search(container_detail::to_raw_pointer(addr + pos),
                    container_detail::to_raw_pointer(finish),
                    s, s + n, Eq_traits<Traits>());
          return result != finish ? result - begin() : npos;
@@ -1721,19 +1942,21 @@
    //!
    //! <b>Returns</b>: find(basic_string(s), pos).
    size_type find(const CharT* s, size_type pos = 0) const
- { return find(s, pos, Traits::length(s)); }
+ { return this->find(s, pos, Traits::length(s)); }
 
    //! <b>Throws</b>: Nothing
    //!
    //! <b>Returns</b>: find(basic_string<CharT,traits,Allocator>(1,c), pos).
    size_type find(CharT c, size_type pos = 0) const
    {
- if (pos >= size())
+ const size_type size = this->size();
+ if (pos >= size)
          return npos;
       else {
- pointer finish = this->priv_addr() + this->priv_size();
+ const pointer addr = this->priv_addr();
+ pointer finish = addr + size;
          const const_iterator result =
- std::find_if(this->priv_addr() + pos, finish,
+ std::find_if(addr + pos, finish,
                   std::bind2nd(Eq_traits<Traits>(), c));
          return result != finish ? result - begin() : npos;
       }
@@ -1757,7 +1980,7 @@
    //! <b>Returns</b>: rfind(basic_string(s, n), pos).
    size_type rfind(const CharT* s, size_type pos, size_type n) const
    {
- const size_type len = size();
+ const size_type len = this->size();
 
       if (n > len)
          return npos;
@@ -1786,7 +2009,7 @@
    //! <b>Returns</b>: rfind(basic_string<CharT,traits,Allocator>(1,c),pos).
    size_type rfind(CharT c, size_type pos = npos) const
    {
- const size_type len = size();
+ const size_type len = this->size();
 
       if (len < 1)
          return npos;
@@ -1816,14 +2039,15 @@
    //! <b>Returns</b>: find_first_of(basic_string(s, n), pos).
    size_type find_first_of(const CharT* s, size_type pos, size_type n) const
    {
- if (pos >= size())
+ const size_type size = this->size();
+ if (pos >= size)
          return npos;
       else {
- pointer finish = this->priv_addr() + this->priv_size();
- const_iterator result = std::find_first_of(this->priv_addr() + pos, finish,
- s, s + n,
- Eq_traits<Traits>());
- return result != finish ? result - begin() : npos;
+ const pointer addr = this->priv_addr();
+ pointer finish = addr + size;
+ const_iterator result = std::find_first_of
+ (addr + pos, finish, s, s + n, Eq_traits<Traits>());
+ return result != finish ? result - this->begin() : npos;
       }
    }
 
@@ -1860,17 +2084,17 @@
    //! <b>Returns</b>: find_last_of(basic_string(s, n), pos).
    size_type find_last_of(const CharT* s, size_type pos, size_type n) const
    {
- const size_type len = size();
+ const size_type len = this->size();
 
       if (len < 1)
          return npos;
       else {
- const const_iterator last = this->priv_addr() + container_detail::min_value(len - 1, pos) + 1;
+ const pointer addr = this->priv_addr();
+ const const_iterator last = addr + container_detail::min_value(len - 1, pos) + 1;
          const const_reverse_iterator rresult =
             std::find_first_of(const_reverse_iterator(last), rend(),
- s, s + n,
- Eq_traits<Traits>());
- return rresult != rend() ? (rresult.base() - 1) - this->priv_addr() : npos;
+ s, s + n, Eq_traits<Traits>());
+ return rresult != rend() ? (rresult.base() - 1) - addr : npos;
       }
    }
 
@@ -1906,13 +2130,14 @@
    //! <b>Returns</b>: find_first_not_of(basic_string(s, n), pos).
    size_type find_first_not_of(const CharT* s, size_type pos, size_type n) const
    {
- if (pos > size())
+ if (pos > this->size())
          return npos;
       else {
- pointer finish = this->priv_addr() + this->priv_size();
- const_iterator result = std::find_if(this->priv_addr() + pos, finish,
- Not_within_traits<Traits>(s, s + n));
- return result != finish ? result - this->priv_addr() : npos;
+ const pointer addr = this->priv_addr();
+ const pointer finish = addr + this->priv_size();
+ const const_iterator result = std::find_if
+ (addr + pos, finish, Not_within_traits<Traits>(s, s + n));
+ return result != finish ? result - addr : npos;
       }
    }
 
@@ -1929,12 +2154,13 @@
    //! <b>Returns</b>: find_first_not_of(basic_string(1, c), pos).
    size_type find_first_not_of(CharT c, size_type pos = 0) const
    {
- if (pos > size())
+ if (pos > this->size())
          return npos;
       else {
- pointer finish = this->priv_addr() + this->priv_size();
- const_iterator result
- = std::find_if(this->priv_addr() + pos, finish,
+ const pointer addr = this->priv_addr();
+ const pointer finish = addr + this->priv_size();
+ const const_iterator result
+ = std::find_if(addr + pos, finish,
                      std::not1(std::bind2nd(Eq_traits<Traits>(), c)));
          return result != finish ? result - begin() : npos;
       }
@@ -1957,7 +2183,7 @@
    //! <b>Returns</b>: find_last_not_of(basic_string(s, n), pos).
    size_type find_last_not_of(const CharT* s, size_type pos, size_type n) const
    {
- const size_type len = size();
+ const size_type len = this->size();
 
       if (len < 1)
          return npos;
@@ -1983,13 +2209,13 @@
    //! <b>Returns</b>: find_last_not_of(basic_string(1, c), pos).
    size_type find_last_not_of(CharT c, size_type pos = npos) const
    {
- const size_type len = size();
+ const size_type len = this->size();
 
       if (len < 1)
          return npos;
       else {
          const const_iterator last = begin() + container_detail::min_value(len - 1, pos) + 1;
- const_reverse_iterator rresult =
+ const const_reverse_iterator rresult =
             std::find_if(const_reverse_iterator(last), rend(),
                   std::not1(std::bind2nd(Eq_traits<Traits>(), c)));
          return rresult != rend() ? (rresult.base() - 1) - begin() : npos;
@@ -2006,10 +2232,11 @@
    //! <b>Returns</b>: basic_string<CharT,traits,Allocator>(data()+pos,rlen).
    basic_string substr(size_type pos = 0, size_type n = npos) const
    {
- if (pos > size())
+ if (pos > this->size())
          this->throw_out_of_range();
- return basic_string(this->priv_addr() + pos,
- this->priv_addr() + pos + container_detail::min_value(n, size() - pos), this->alloc());
+ const pointer addr = this->priv_addr();
+ return basic_string(addr + pos,
+ addr + pos + container_detail::min_value(n, size() - pos), this->alloc());
    }
 
    //! <b>Effects</b>: Determines the effective length rlen of the string to copy as
@@ -2022,7 +2249,11 @@
    //! Otherwise, returns a value < 0 if size() < str.size(), a 0 value if size() == str.size(),
    //! and value > 0 if size() > str.size()
    int compare(const basic_string& str) const
- { return s_compare(this->priv_addr(), this->priv_addr() + this->priv_size(), str.priv_addr(), str.priv_addr() + str.priv_size()); }
+ {
+ const pointer addr = this->priv_addr();
+ const pointer str_addr = str.priv_addr();
+ return s_compare(addr, addr + this->priv_size(), str_addr, str_addr + str.priv_size());
+ }
 
    //! <b>Requires</b>: pos1 <= size()
    //!
@@ -2034,11 +2265,13 @@
    //! <b>Returns</b>:basic_string(*this,pos1,n1).compare(str).
    int compare(size_type pos1, size_type n1, const basic_string& str) const
    {
- if (pos1 > size())
+ if (pos1 > this->size())
          this->throw_out_of_range();
- return s_compare(this->priv_addr() + pos1,
- this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
- str.priv_addr(), str.priv_addr() + str.priv_size());
+ const pointer addr = this->priv_addr();
+ const pointer str_addr = str.priv_addr();
+ return s_compare(addr + pos1,
+ addr + pos1 + container_detail::min_value(n1, this->size() - pos1),
+ str_addr, str_addr + str.priv_size());
    }
 
    //! <b>Requires</b>: pos1 <= size() and pos2 <= str.size()
@@ -2051,19 +2284,24 @@
    //! <b>Returns</b>: basic_string(*this, pos1, n1).compare(basic_string(str, pos2, n2)).
    int compare(size_type pos1, size_type n1,
                const basic_string& str, size_type pos2, size_type n2) const {
- if (pos1 > size() || pos2 > str.size())
+ if (pos1 > this->size() || pos2 > str.size())
          this->throw_out_of_range();
- return s_compare(this->priv_addr() + pos1,
- this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
- str.priv_addr() + pos2,
- str.priv_addr() + pos2 + container_detail::min_value(n2, size() - pos2));
+ const pointer addr = this->priv_addr();
+ const pointer str_addr = str.priv_addr();
+ return s_compare(addr + pos1,
+ addr + pos1 + container_detail::min_value(n1, this->size() - pos1),
+ str_addr + pos2,
+ str_addr + pos2 + container_detail::min_value(n2, str.size() - pos2));
    }
 
    //! <b>Throws</b>: Nothing
    //!
    //! <b>Returns</b>: compare(basic_string(s)).
    int compare(const CharT* s) const
- { return s_compare(this->priv_addr(), this->priv_addr() + this->priv_size(), s, s + Traits::length(s)); }
+ {
+ const pointer addr = this->priv_addr();
+ return s_compare(addr, addr + this->priv_size(), s, s + Traits::length(s));
+ }
 
 
    //! <b>Requires</b>: pos1 > size() and s points to an array of at least n2 elements of CharT.
@@ -2074,10 +2312,11 @@
    int compare(size_type pos1, size_type n1,
                const CharT* s, size_type n2) const
    {
- if (pos1 > size())
+ if (pos1 > this->size())
          this->throw_out_of_range();
- return s_compare(this->priv_addr() + pos1,
- this->priv_addr() + pos1 + container_detail::min_value(n1, size() - pos1),
+ const pointer addr = this->priv_addr();
+ return s_compare( addr + pos1,
+ addr + pos1 + container_detail::min_value(n1, this->size() - pos1),
                         s, s + n2);
    }
 
@@ -2109,12 +2348,12 @@
    {
       //Allocate a new buffer.
       size_type real_cap = 0;
- pointer long_addr = this->priv_long_addr();
- size_type long_size = this->priv_long_size();
- size_type long_storage = this->priv_long_storage();
+ const pointer long_addr = this->priv_long_addr();
+ const size_type long_size = this->priv_long_size();
+ const size_type long_storage = this->priv_long_storage();
       //We can make this nothrow as chars are always NoThrowCopyables
       try{
- std::pair<pointer, bool> ret = this->allocation_command
+ const std::pair<pointer, bool> ret = this->allocation_command
                (allocate_new, long_size+1, long_size+1, real_cap, long_addr);
          //Copy and update
          Traits::copy( container_detail::to_raw_pointer(ret.first)
@@ -2145,55 +2384,12 @@
    }
 
    void priv_construct_null(pointer p)
- { this->construct(p, 0); }
-
- static CharT priv_null()
- { return (CharT) 0; }
+ { this->construct(p, CharT(0)); }
 
    // Helper functions used by constructors. It is a severe error for
    // any of them to be called anywhere except from within constructors.
    void priv_terminate_string()
- { this->priv_construct_null(this->priv_addr() + this->priv_size()); }
-
- template <class InputIter>
- void priv_range_initialize(InputIter f, InputIter l,
- std::input_iterator_tag)
- {
- this->allocate_initial_block(InternalBufferChars);
- this->priv_construct_null(this->priv_addr() + this->priv_size());
- this->append(f, l);
- }
-
- template <class ForwardIter>
- void priv_range_initialize(ForwardIter f, ForwardIter l,
- std::forward_iterator_tag)
- {
- difference_type n = std::distance(f, l);
- this->allocate_initial_block(container_detail::max_value<difference_type>(n+1, InternalBufferChars));
- priv_uninitialized_copy(f, l, this->priv_addr());
- this->priv_size(n);
- this->priv_terminate_string();
- }
-
- template <class InputIter>
- void priv_range_initialize(InputIter f, InputIter l)
- {
- typedef typename std::iterator_traits<InputIter>::iterator_category Category;
- this->priv_range_initialize(f, l, Category());
- }
-
- template <class Integer>
- void priv_initialize_dispatch(Integer n, Integer x, container_detail::true_)
- {
- this->allocate_initial_block(container_detail::max_value<difference_type>(n+1, InternalBufferChars));
- priv_uninitialized_fill_n(this->priv_addr(), n, x);
- this->priv_size(n);
- this->priv_terminate_string();
- }
-
- template <class InputIter>
- void priv_initialize_dispatch(InputIter f, InputIter l, container_detail::false_)
- { this->priv_range_initialize(f, l); }
+ { this->priv_construct_null(this->priv_end_addr()); }
 
    template<class FwdIt, class Count> inline
    void priv_uninitialized_fill_n(FwdIt first, Count count, const CharT val)
@@ -2241,154 +2437,6 @@
       return (constructed);
    }
 
- template <class Integer>
- basic_string& priv_assign_dispatch(Integer n, Integer x, container_detail::true_)
- { return this->assign((size_type) n, (CharT) x); }
-
- template <class InputIter>
- basic_string& priv_assign_dispatch(InputIter f, InputIter l,
- container_detail::false_)
- {
- size_type cur = 0;
- CharT *ptr = container_detail::to_raw_pointer(this->priv_addr());
- while (f != l && cur != this->priv_size()) {
- Traits::assign(*ptr, *f);
- ++f;
- ++cur;
- ++ptr;
- }
- if (f == l)
- this->erase(this->priv_addr() + cur, this->priv_addr() + this->priv_size());
- else
- this->append(f, l);
- return *this;
- }
-
- template <class InputIter>
- void priv_insert(const_iterator p, InputIter first, InputIter last, std::input_iterator_tag)
- {
- for ( ; first != last; ++first, ++p) {
- p = this->insert(p, *first);
- }
- }
-
- template <class ForwardIter>
- void priv_insert(const_iterator position, ForwardIter first,
- ForwardIter last, std::forward_iterator_tag)
- {
- if (first != last) {
- size_type n = std::distance(first, last);
- size_type remaining = this->capacity() - this->priv_size();
- const size_type old_size = this->size();
- pointer old_start = this->priv_addr();
- bool enough_capacity = false;
- std::pair<pointer, bool> allocation_ret;
- size_type new_cap = 0;
-
- //Check if we have enough capacity
- if (remaining >= n){
- enough_capacity = true;
- }
- else {
- //Otherwise expand current buffer or allocate new storage
- new_cap = this->next_capacity(n);
- allocation_ret = this->allocation_command
- (allocate_new | expand_fwd | expand_bwd, old_size + n + 1,
- new_cap, new_cap, old_start);
-
- //Check forward expansion
- if(old_start == allocation_ret.first){
- enough_capacity = true;
- this->priv_storage(new_cap);
- }
- }
-
- //Reuse same buffer
- if(enough_capacity){
- const size_type elems_after =
- this->priv_size() - (position - this->priv_addr());
- size_type old_length = this->priv_size();
- if (elems_after >= n) {
- pointer pointer_past_last = this->priv_addr() + this->priv_size() + 1;
- priv_uninitialized_copy(this->priv_addr() + (this->priv_size() - n + 1),
- pointer_past_last, pointer_past_last);
-
- this->priv_size(this->priv_size()+n);
- Traits::move(const_cast<CharT*>(container_detail::to_raw_pointer(position + n)),
- container_detail::to_raw_pointer(position),
- (elems_after - n) + 1);
- this->priv_copy(first, last, const_cast<CharT*>(container_detail::to_raw_pointer(position)));
- }
- else {
- ForwardIter mid = first;
- std::advance(mid, elems_after + 1);
-
- priv_uninitialized_copy(mid, last, this->priv_addr() + this->priv_size() + 1);
- this->priv_size(this->priv_size() + (n - elems_after));
- priv_uninitialized_copy
- (position, const_iterator(this->priv_addr() + old_length + 1),
- this->priv_addr() + this->priv_size());
- this->priv_size(this->priv_size() + elems_after);
- this->priv_copy(first, mid, const_cast<CharT*>(container_detail::to_raw_pointer(position)));
- }
- }
- else{
- pointer new_start = allocation_ret.first;
- if(!allocation_ret.second){
- //Copy data to new buffer
- size_type new_length = 0;
- //This can't throw, since characters are POD
- new_length += priv_uninitialized_copy
- (const_iterator(this->priv_addr()), position, new_start);
- new_length += priv_uninitialized_copy
- (first, last, new_start + new_length);
- new_length += priv_uninitialized_copy
- (position, const_iterator(this->priv_addr() + this->priv_size()),
- new_start + new_length);
- this->priv_construct_null(new_start + new_length);
-
- this->deallocate_block();
- this->is_short(false);
- this->priv_long_addr(new_start);
- this->priv_long_size(new_length);
- this->priv_long_storage(new_cap);
- }
- else{
- //value_type is POD, so backwards expansion is much easier
- //than with vector<T>
- value_type *oldbuf = container_detail::to_raw_pointer(old_start);
- value_type *newbuf = container_detail::to_raw_pointer(new_start);
- const value_type *pos = container_detail::to_raw_pointer(position);
- size_type before = pos - oldbuf;
-
- //First move old data
- Traits::move(newbuf, oldbuf, before);
- Traits::move(newbuf + before + n, pos, old_size - before);
- //Now initialize the new data
- priv_uninitialized_copy(first, last, new_start + before);
- this->priv_construct_null(new_start + (old_size + n));
- this->is_short(false);
- this->priv_long_addr(new_start);
- this->priv_long_size(old_size + n);
- this->priv_long_storage(new_cap);
- }
- }
- }
- }
-
- template <class Integer>
- void priv_insert_dispatch(const_iterator p, Integer n, Integer x,
- container_detail::true_)
- { insert(p, (size_type) n, (CharT) x); }
-
- template <class InputIter>
- void priv_insert_dispatch(const_iterator p, InputIter first, InputIter last,
- container_detail::false_)
- {
- typedef typename std::iterator_traits<InputIter>::iterator_category Category;
- priv_insert(p, first, last, Category());
- }
-
    template <class InputIterator, class OutIterator>
    void priv_copy(InputIterator first, InputIterator last, OutIterator result)
    {
@@ -2414,40 +2462,6 @@
       return this->priv_replace(first, last, f, l, Category());
    }
 
-
- template <class InputIter>
- basic_string& priv_replace(const_iterator first, const_iterator last,
- InputIter f, InputIter l, std::input_iterator_tag)
- {
- for ( ; first != last && f != l; ++first, ++f)
- Traits::assign(*first, *f);
-
- if (f == l)
- this->erase(first, last);
- else
- this->insert(last, f, l);
- return *this;
- }
-
- template <class ForwardIter>
- basic_string& priv_replace(const_iterator first, const_iterator last,
- ForwardIter f, ForwardIter l,
- std::forward_iterator_tag)
- {
- difference_type n = std::distance(f, l);
- const difference_type len = last - first;
- if (len >= n) {
- this->priv_copy(f, l, const_cast<CharT*>(container_detail::to_raw_pointer(first)));
- this->erase(first + n, last);
- }
- else {
- ForwardIter m = f;
- std::advance(m, len);
- this->priv_copy(f, m, const_cast<CharT*>(container_detail::to_raw_pointer(first)));
- this->insert(last, m, l);
- }
- return *this;
- }
    /// @endcond
 };
 

Modified: branches/release/boost/container/vector.hpp
==============================================================================
--- branches/release/boost/container/vector.hpp (original)
+++ branches/release/boost/container/vector.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -86,7 +86,7 @@
    { return *m_ptr; }
 
    const value_type * operator->() const
- { return container_detail::to_raw_pointer(m_ptr); }
+ { return container_detail::to_raw_pointer(m_ptr); }
 
    reference operator[](difference_type off) const
    { return m_ptr[off]; }
@@ -408,40 +408,29 @@
 class vector : private container_detail::vector_alloc_holder<A>
 {
    /// @cond
- typedef vector<T, A> self_t;
    typedef container_detail::vector_alloc_holder<A> base_t;
    typedef allocator_traits<A> allocator_traits_type;
    /// @endcond
    public:
- //! The type of object, T, stored in the vector
- typedef T value_type;
- //! Pointer to T
- typedef typename allocator_traits_type::pointer pointer;
- //! Const pointer to T
- typedef typename allocator_traits_type::const_pointer const_pointer;
- //! Reference to T
- typedef typename allocator_traits_type::reference reference;
- //! Const reference to T
- typedef typename allocator_traits_type::const_reference const_reference;
- //! An unsigned integral type
- typedef typename allocator_traits_type::size_type size_type;
- //! A signed integral type
- typedef typename allocator_traits_type::difference_type difference_type;
- //! The allocator type
- typedef A allocator_type;
- //! The random access iterator
- typedef container_detail::vector_iterator<pointer> iterator;
- //! The random access const_iterator
- typedef container_detail::vector_const_iterator<pointer> const_iterator;
-
- //! Iterator used to iterate backwards through a vector.
- typedef std::reverse_iterator<iterator>
- reverse_iterator;
- //! Const iterator used to iterate backwards through a vector.
- typedef std::reverse_iterator<const_iterator>
- const_reverse_iterator;
- //! The stored allocator type
- typedef allocator_type stored_allocator_type;
+ //////////////////////////////////////////////
+ //
+ // types
+ //
+ //////////////////////////////////////////////
+
+ typedef T value_type;
+ typedef typename ::boost::container::allocator_traits<A>::pointer pointer;
+ typedef typename ::boost::container::allocator_traits<A>::const_pointer const_pointer;
+ typedef typename ::boost::container::allocator_traits<A>::reference reference;
+ typedef typename ::boost::container::allocator_traits<A>::const_reference const_reference;
+ typedef typename ::boost::container::allocator_traits<A>::size_type size_type;
+ typedef typename ::boost::container::allocator_traits<A>::difference_type difference_type;
+ typedef A allocator_type;
+ typedef allocator_type stored_allocator_type;
+ typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_iterator<pointer>) iterator;
+ typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_const_iterator<pointer>) const_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
 
    /// @cond
    private:
@@ -459,6 +448,11 @@
    /// @endcond
 
    public:
+ //////////////////////////////////////////////
+ //
+ // construct/copy/destroy
+ //
+ //////////////////////////////////////////////
 
    //! <b>Effects</b>: Constructs a vector taking the allocator as parameter.
    //!
@@ -488,23 +482,7 @@
    //! <b>Complexity</b>: Linear to n.
    explicit vector(size_type n)
       : base_t()
- {
- //Allocate
- size_type real_cap;
- std::pair<pointer, bool> ret =
- this->allocation_command(allocate_new, n, n, real_cap, this->members_.m_start);
- T *new_mem = container_detail::to_raw_pointer(ret.first);
- //Anti-exception rollback
- typename value_traits::ArrayDeallocator scoped_alloc(new_mem, this->alloc(), real_cap);
- //Default constructor
- container_detail::default_construct_aux_proxy<A, T*> proxy(this->alloc(), n);
- proxy.uninitialized_copy_remaining_to(new_mem);
- //All ok, commit
- this->members_.m_start = ret.first;
- this->members_.m_size = n;
- this->members_.m_capacity = real_cap;
- scoped_alloc.release();
- }
+ { this->resize(n); }
 
    //! <b>Effects</b>: Constructs a vector that will use a copy of allocator a
    //! and inserts n copies of value.
@@ -515,7 +493,19 @@
    //! <b>Complexity</b>: Linear to n.
    vector(size_type n, const T& value, const allocator_type& a = allocator_type())
       : base_t(a)
- { this->insert(this->cend(), n, value); }
+ { this->resize(n, value); }
+
+ //! <b>Effects</b>: Constructs a vector that will use a copy of allocator a
+ //! and inserts a copy of the range [first, last) in the vector.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor or allocation
+ //! throws or T's constructor taking an dereferenced InIt throws.
+ //!
+ //! <b>Complexity</b>: Linear to the range [first, last).
+ template <class InIt>
+ vector(InIt first, InIt last, const allocator_type& a = allocator_type())
+ : base_t(a)
+ { this->assign(first, last); }
 
    //! <b>Effects</b>: Copy constructs a vector.
    //!
@@ -571,22 +561,10 @@
       }
       else{
          this->assign( container_detail::to_raw_pointer(mx.members_.m_start)
- , container_detail::to_raw_pointer(mx.members_.m_start + mx.members_.m_size));
+ , container_detail::to_raw_pointer(mx.members_.m_start) + mx.members_.m_size);
       }
    }
 
- //! <b>Effects</b>: Constructs a vector that will use a copy of allocator a
- //! and inserts a copy of the range [first, last) in the vector.
- //!
- //! <b>Throws</b>: If allocator_type's default constructor or allocation
- //! throws or T's constructor taking an dereferenced InIt throws.
- //!
- //! <b>Complexity</b>: Linear to the range [first, last).
- template <class InIt>
- vector(InIt first, InIt last, const allocator_type& a = allocator_type())
- : base_t(a)
- { this->assign(first, last); }
-
    //! <b>Effects</b>: Destroys the vector. All stored values are destroyed
    //! and used memory is deallocated.
    //!
@@ -596,6 +574,141 @@
    ~vector() BOOST_CONTAINER_NOEXCEPT
    {} //vector_alloc_holder clears the data
 
+ //! <b>Effects</b>: Makes *this contain the same elements as x.
+ //!
+ //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
+ //! of each of x's elements.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or T's copy/move constructor/assignment throws.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements in x.
+ vector& operator=(BOOST_COPY_ASSIGN_REF(vector) x)
+ {
+ if (&x != this){
+ allocator_type &this_alloc = this->alloc();
+ const allocator_type &x_alloc = x.alloc();
+ container_detail::bool_<allocator_traits_type::
+ propagate_on_container_copy_assignment::value> flag;
+ if(flag && this_alloc != x_alloc){
+ this->clear();
+ this->shrink_to_fit();
+ }
+ container_detail::assign_alloc(this_alloc, x_alloc, flag);
+ this->assign( container_detail::to_raw_pointer(x.members_.m_start)
+ , container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size));
+ }
+ return *this;
+ }
+
+ //! <b>Effects</b>: Move assignment. All mx's values are transferred to *this.
+ //!
+ //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had
+ //! before the function.
+ //!
+ //! <b>Throws</b>: Nothing
+ //!
+ //! <b>Complexity</b>: Linear.
+ vector& operator=(BOOST_RV_REF(vector) x)
+ //iG BOOST_CONTAINER_NOEXCEPT_IF(!allocator_type::propagate_on_container_move_assignment::value || is_nothrow_move_assignable<allocator_type>::value);)
+ BOOST_CONTAINER_NOEXCEPT
+ {
+ if (&x != this){
+ allocator_type &this_alloc = this->alloc();
+ allocator_type &x_alloc = x.alloc();
+ //If allocators are equal we can just swap pointers
+ if(this_alloc == x_alloc){
+ //Destroy objects but retain memory in case x reuses it in the future
+ this->clear();
+ this->swap_members(x);
+ //Move allocator if needed
+ container_detail::bool_<allocator_traits_type::
+ propagate_on_container_move_assignment::value> flag;
+ container_detail::move_alloc(this_alloc, x_alloc, flag);
+ }
+ //If unequal allocators, then do a one by one move
+ else{
+ this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start))
+ , boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size)));
+ }
+ }
+ return *this;
+ }
+
+ //! <b>Effects</b>: Assigns the the range [first, last) to *this.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or T's copy/move constructor/assignment or
+ //! T's constructor/assignment from dereferencing InpIt throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ template <class InIt>
+ void assign(InIt first, InIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InIt, size_type>::value
+ //&& container_detail::is_input_iterator<InIt>::value
+ >::type * = 0
+ #endif
+ )
+ {
+ //Overwrite all elements we can from [first, last)
+ iterator cur = this->begin();
+ for ( ; first != last && cur != end(); ++cur, ++first){
+ *cur = *first;
+ }
+
+ if (first == last){
+ //There are no more elements in the sequence, erase remaining
+ this->erase(cur, this->cend());
+ }
+ else{
+ //There are more elements in the range, insert the remaining ones
+ this->insert(this->cend(), first, last);
+ }
+ }
+
+ //! <b>Effects</b>: Assigns the n copies of val to *this.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's copy/move constructor/assignment throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ void assign(size_type n, const value_type& val)
+ { this->assign(cvalue_iterator(val, n), cvalue_iterator()); }
+
+ //! <b>Effects</b>: Returns a copy of the internal allocator.
+ //!
+ //! <b>Throws</b>: If allocator's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant.
+ allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
+ { return this->alloc(); }
+
+ //! <b>Effects</b>: Returns a reference to the internal allocator.
+ //!
+ //! <b>Throws</b>: Nothing
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Note</b>: Non-standard extension.
+ const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
+ { return this->alloc(); }
+
+ //! <b>Effects</b>: Returns a reference to the internal allocator.
+ //!
+ //! <b>Throws</b>: Nothing
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Note</b>: Non-standard extension.
+ stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
+ { return this->alloc(); }
+
+ //////////////////////////////////////////////
+ //
+ // iterators
+ //
+ //////////////////////////////////////////////
+
    //! <b>Effects</b>: Returns an iterator to the first element contained in the vector.
    //!
    //! <b>Throws</b>: Nothing.
@@ -698,67 +811,19 @@
    const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
    { return const_reverse_iterator(this->begin()); }
 
- //! <b>Requires</b>: !empty()
- //!
- //! <b>Effects</b>: Returns a reference to the first
- //! element of the container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- reference front() BOOST_CONTAINER_NOEXCEPT
- { return *this->members_.m_start; }
-
- //! <b>Requires</b>: !empty()
- //!
- //! <b>Effects</b>: Returns a const reference to the first
- //! element of the container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- const_reference front() const BOOST_CONTAINER_NOEXCEPT
- { return *this->members_.m_start; }
-
- //! <b>Requires</b>: !empty()
- //!
- //! <b>Effects</b>: Returns a reference to the last
- //! element of the container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- reference back() BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_start[this->members_.m_size - 1]; }
-
- //! <b>Requires</b>: !empty()
- //!
- //! <b>Effects</b>: Returns a const reference to the last
- //! element of the container.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- const_reference back() const BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_start[this->members_.m_size - 1]; }
-
- //! <b>Returns</b>: A pointer such that [data(),data() + size()) is a valid range.
- //! For a non-empty vector, data() == &front().
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- pointer data() BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_start; }
+ //////////////////////////////////////////////
+ //
+ // capacity
+ //
+ //////////////////////////////////////////////
 
- //! <b>Returns</b>: A pointer such that [data(),data() + size()) is a valid range.
- //! For a non-empty vector, data() == &front().
+ //! <b>Effects</b>: Returns true if the vector contains no elements.
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_pointer data() const BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_start; }
+ bool empty() const BOOST_CONTAINER_NOEXCEPT
+ { return !this->members_.m_size; }
 
    //! <b>Effects</b>: Returns the number of the elements contained in the vector.
    //!
@@ -776,94 +841,53 @@
    size_type max_size() const BOOST_CONTAINER_NOEXCEPT
    { return allocator_traits_type::max_size(this->alloc()); }
 
- //! <b>Effects</b>: Number of elements for which memory has been allocated.
- //! capacity() is always greater than or equal to size().
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- size_type capacity() const BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_capacity; }
-
- //! <b>Effects</b>: Returns true if the vector contains no elements.
+ //! <b>Effects</b>: Inserts or erases elements at the end such that
+ //! the size becomes n. New elements are default constructed.
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
    //!
- //! <b>Complexity</b>: Constant.
- bool empty() const BOOST_CONTAINER_NOEXCEPT
- { return !this->members_.m_size; }
+ //! <b>Complexity</b>: Linear to the difference between size() and new_size.
+ void resize(size_type new_size)
+ {
+ if (new_size < this->size()){
+ //Destroy last elements
+ this->erase(const_iterator(this->members_.m_start + new_size), this->end());
+ }
+ else{
+ const size_type n = new_size - this->size();
+ this->reserve(new_size);
+ container_detail::default_construct_aux_proxy<A, T*> proxy(this->alloc(), n);
+ this->priv_forward_range_insert(this->cend().get_ptr(), n, proxy);
+ }
+ }
 
- //! <b>Requires</b>: size() > n.
- //!
- //! <b>Effects</b>: Returns a reference to the nth element
- //! from the beginning of the container.
+ //! <b>Effects</b>: Inserts or erases elements at the end such that
+ //! the size becomes n. New elements are copy constructed from x.
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
    //!
- //! <b>Complexity</b>: Constant.
- reference operator[](size_type n)
- { return this->members_.m_start[n]; }
+ //! <b>Complexity</b>: Linear to the difference between size() and new_size.
+ void resize(size_type new_size, const T& x)
+ {
+ pointer finish = this->members_.m_start + this->members_.m_size;
+ if (new_size < size()){
+ //Destroy last elements
+ this->erase(const_iterator(this->members_.m_start + new_size), this->end());
+ }
+ else{
+ //Insert new elements at the end
+ this->insert(const_iterator(finish), new_size - this->size(), x);
+ }
+ }
 
- //! <b>Requires</b>: size() > n.
- //!
- //! <b>Effects</b>: Returns a const reference to the nth element
- //! from the beginning of the container.
+ //! <b>Effects</b>: Number of elements for which memory has been allocated.
+ //! capacity() is always greater than or equal to size().
    //!
    //! <b>Throws</b>: Nothing.
    //!
    //! <b>Complexity</b>: Constant.
- const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
- { return this->members_.m_start[n]; }
-
- //! <b>Requires</b>: size() > n.
- //!
- //! <b>Effects</b>: Returns a reference to the nth element
- //! from the beginning of the container.
- //!
- //! <b>Throws</b>: std::range_error if n >= size()
- //!
- //! <b>Complexity</b>: Constant.
- reference at(size_type n)
- { this->priv_check_range(n); return this->members_.m_start[n]; }
-
- //! <b>Requires</b>: size() > n.
- //!
- //! <b>Effects</b>: Returns a const reference to the nth element
- //! from the beginning of the container.
- //!
- //! <b>Throws</b>: std::range_error if n >= size()
- //!
- //! <b>Complexity</b>: Constant.
- const_reference at(size_type n) const
- { this->priv_check_range(n); return this->members_.m_start[n]; }
-
- //! <b>Effects</b>: Returns a copy of the internal allocator.
- //!
- //! <b>Throws</b>: If allocator's copy constructor throws.
- //!
- //! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
- { return this->alloc(); }
-
- //! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
- //! <b>Throws</b>: Nothing
- //!
- //! <b>Complexity</b>: Constant.
- //!
- //! <b>Note</b>: Non-standard extension.
- const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
- { return this->alloc(); }
-
- //! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
- //! <b>Throws</b>: Nothing
- //!
- //! <b>Complexity</b>: Constant.
- //!
- //! <b>Note</b>: Non-standard extension.
- stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
- { return this->alloc(); }
+ size_type capacity() const BOOST_CONTAINER_NOEXCEPT
+ { return this->members_.m_capacity; }
 
    //! <b>Effects</b>: If n is less than or equal to capacity(), this call has no
    //! effect. Otherwise, it is a request for allocation of additional memory.
@@ -926,110 +950,138 @@
       }
    }
 
- //! <b>Effects</b>: Makes *this contain the same elements as x.
+ //! <b>Effects</b>: Tries to deallocate the excess of memory created
+ //! with previous allocations. The size of the vector is unchanged
    //!
- //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
- //! of each of x's elements.
+ //! <b>Throws</b>: If memory allocation throws, or T's copy/move constructor throws.
    //!
- //! <b>Throws</b>: If memory allocation throws or T's copy/move constructor/assignment throws.
+ //! <b>Complexity</b>: Linear to size().
+ void shrink_to_fit()
+ { priv_shrink_to_fit(alloc_version()); }
+
+ //////////////////////////////////////////////
+ //
+ // element access
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Requires</b>: !empty()
    //!
- //! <b>Complexity</b>: Linear to the number of elements in x.
- vector& operator=(BOOST_COPY_ASSIGN_REF(vector) x)
- {
- if (&x != this){
- allocator_type &this_alloc = this->alloc();
- const allocator_type &x_alloc = x.alloc();
- container_detail::bool_<allocator_traits_type::
- propagate_on_container_copy_assignment::value> flag;
- if(flag && this_alloc != x_alloc){
- this->clear();
- this->shrink_to_fit();
- }
- container_detail::assign_alloc(this_alloc, x_alloc, flag);
- this->assign( container_detail::to_raw_pointer(x.members_.m_start)
- , container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size));
- }
- return *this;
- }
+ //! <b>Effects</b>: Returns a reference to the first
+ //! element of the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ reference front() BOOST_CONTAINER_NOEXCEPT
+ { return *this->members_.m_start; }
 
- //! <b>Effects</b>: Move assignment. All mx's values are transferred to *this.
+ //! <b>Requires</b>: !empty()
    //!
- //! <b>Postcondition</b>: x.empty(). *this contains a the elements x had
- //! before the function.
+ //! <b>Effects</b>: Returns a const reference to the first
+ //! element of the container.
    //!
- //! <b>Throws</b>: Nothing
+ //! <b>Throws</b>: Nothing.
    //!
- //! <b>Complexity</b>: Linear.
- vector& operator=(BOOST_RV_REF(vector) x)
- //iG BOOST_CONTAINER_NOEXCEPT_IF(!allocator_type::propagate_on_container_move_assignment::value || is_nothrow_move_assignable<allocator_type>::value);)
- BOOST_CONTAINER_NOEXCEPT
- {
- if (&x != this){
- allocator_type &this_alloc = this->alloc();
- allocator_type &x_alloc = x.alloc();
- //If allocators are equal we can just swap pointers
- if(this_alloc == x_alloc){
- //Destroy objects but retain memory in case x reuses it in the future
- this->clear();
- this->swap_members(x);
- //Move allocator if needed
- container_detail::bool_<allocator_traits_type::
- propagate_on_container_move_assignment::value> flag;
- container_detail::move_alloc(this_alloc, x_alloc, flag);
- }
- //If unequal allocators, then do a one by one move
- else{
- this->assign( boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start))
- , boost::make_move_iterator(container_detail::to_raw_pointer(x.members_.m_start + x.members_.m_size)));
- }
- }
- return *this;
- }
+ //! <b>Complexity</b>: Constant.
+ const_reference front() const BOOST_CONTAINER_NOEXCEPT
+ { return *this->members_.m_start; }
+
+ //! <b>Requires</b>: !empty()
+ //!
+ //! <b>Effects</b>: Returns a reference to the last
+ //! element of the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ reference back() BOOST_CONTAINER_NOEXCEPT
+ { return this->members_.m_start[this->members_.m_size - 1]; }
+
+ //! <b>Requires</b>: !empty()
+ //!
+ //! <b>Effects</b>: Returns a const reference to the last
+ //! element of the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_reference back() const BOOST_CONTAINER_NOEXCEPT
+ { return this->members_.m_start[this->members_.m_size - 1]; }
+
+ //! <b>Requires</b>: size() > n.
+ //!
+ //! <b>Effects</b>: Returns a reference to the nth element
+ //! from the beginning of the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ reference operator[](size_type n)
+ { return this->members_.m_start[n]; }
 
- //! <b>Effects</b>: Assigns the n copies of val to *this.
+ //! <b>Requires</b>: size() > n.
    //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's copy/move constructor/assignment throws.
+ //! <b>Effects</b>: Returns a const reference to the nth element
+ //! from the beginning of the container.
    //!
- //! <b>Complexity</b>: Linear to n.
- void assign(size_type n, const value_type& val)
- { this->assign(cvalue_iterator(val, n), cvalue_iterator()); }
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
+ { return this->members_.m_start[n]; }
 
- //! <b>Effects</b>: Assigns the the range [first, last) to *this.
+ //! <b>Requires</b>: size() > n.
    //!
- //! <b>Throws</b>: If memory allocation throws or T's copy/move constructor/assignment or
- //! T's constructor/assignment from dereferencing InpIt throws.
+ //! <b>Effects</b>: Returns a reference to the nth element
+ //! from the beginning of the container.
    //!
- //! <b>Complexity</b>: Linear to n.
- template <class InIt>
- void assign(InIt first, InIt last)
- {
- //Dispatch depending on integer/iterator
- const bool aux_boolean = container_detail::is_convertible<InIt, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- this->priv_assign_dispatch(first, last, Result());
- }
+ //! <b>Throws</b>: std::range_error if n >= size()
+ //!
+ //! <b>Complexity</b>: Constant.
+ reference at(size_type n)
+ { this->priv_check_range(n); return this->members_.m_start[n]; }
 
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- //! <b>Effects</b>: Inserts a copy of x at the end of the vector.
+ //! <b>Requires</b>: size() > n.
    //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's copy/move constructor throws.
+ //! <b>Effects</b>: Returns a const reference to the nth element
+ //! from the beginning of the container.
    //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_back(const T &x);
+ //! <b>Throws</b>: std::range_error if n >= size()
+ //!
+ //! <b>Complexity</b>: Constant.
+ const_reference at(size_type n) const
+ { this->priv_check_range(n); return this->members_.m_start[n]; }
 
- //! <b>Effects</b>: Constructs a new element in the end of the vector
- //! and moves the resources of mx to this new element.
+ //////////////////////////////////////////////
+ //
+ // data access
+ //
+ //////////////////////////////////////////////
+
+ //! <b>Returns</b>: A pointer such that [data(),data() + size()) is a valid range.
+ //! For a non-empty vector, data() == &front().
    //!
- //! <b>Throws</b>: If memory allocation throws or
- //! T's move constructor throws.
+ //! <b>Throws</b>: Nothing.
    //!
- //! <b>Complexity</b>: Amortized constant time.
- void push_back(T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
- #endif
+ //! <b>Complexity</b>: Constant.
+ T* data() BOOST_CONTAINER_NOEXCEPT
+ { return container_detail::to_raw_pointer(this->members_.m_start); }
+
+ //! <b>Returns</b>: A pointer such that [data(),data() + size()) is a valid range.
+ //! For a non-empty vector, data() == &front().
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ const T * data() const BOOST_CONTAINER_NOEXCEPT
+ { return container_detail::to_raw_pointer(this->members_.m_start); }
+
+ //////////////////////////////////////////////
+ //
+ // modifiers
+ //
+ //////////////////////////////////////////////
 
    #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! <b>Effects</b>: Inserts an object of type T constructed with
@@ -1051,7 +1103,7 @@
       else{
          typedef container_detail::advanced_insert_aux_emplace<A, T*, Args...> type;
          type &&proxy = type(this->alloc(), ::boost::forward<Args>(args)...);
- priv_range_insert(back_pos, 1, proxy);
+ this->priv_forward_range_insert(back_pos, 1, proxy);
       }
    }
 
@@ -1072,7 +1124,7 @@
       size_type pos_n = position - cbegin();
       typedef container_detail::advanced_insert_aux_emplace<A, T*, Args...> type;
       type &&proxy = type(this->alloc(), ::boost::forward<Args>(args)...);
- priv_range_insert(position.get_ptr(), 1, proxy);
+ this->priv_forward_range_insert(position.get_ptr(), 1, proxy);
       return iterator(this->members_.m_start + pos_n);
    }
 
@@ -1093,7 +1145,7 @@
          container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \
             <A, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- priv_range_insert(back_pos, 1, proxy); \
+ this->priv_forward_range_insert(back_pos, 1, proxy); \
       } \
    } \
                                                                                                 \
@@ -1105,7 +1157,7 @@
          container_detail::BOOST_PP_CAT(BOOST_PP_CAT(advanced_insert_aux_emplace, n), arg) \
             <A, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
             (this->alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- priv_range_insert(container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy); \
+ this->priv_forward_range_insert(container_detail::to_raw_pointer(pos.get_ptr()), 1,proxy);\
       return iterator(this->members_.m_start + pos_n); \
    } \
    //!
@@ -1113,21 +1165,28 @@
    #include BOOST_PP_LOCAL_ITERATE()
 
    #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
- //! <b>Effects</b>: Swaps the contents of *this and x.
+
+ #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: Inserts a copy of x at the end of the vector.
    //!
- //! <b>Throws</b>: Nothing.
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's copy/move constructor throws.
    //!
- //! <b>Complexity</b>: Constant.
- void swap(vector& x)
- {
- //Just swap internals
- this->swap_members(x);
- //And now the allocator
- container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag;
- container_detail::swap_alloc(this->alloc(), x.alloc(), flag);
- }
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_back(const T &x);
 
+ //! <b>Effects</b>: Constructs a new element in the end of the vector
+ //! and moves the resources of mx to this new element.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or
+ //! T's move constructor throws.
+ //!
+ //! <b>Complexity</b>: Amortized constant time.
+ void push_back(T &&x);
+ #else
+ BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
+ #endif
+
    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
    //! <b>Requires</b>: position must be a valid iterator of *this.
    //!
@@ -1152,32 +1211,63 @@
    BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator)
    #endif
 
- //! <b>Requires</b>: pos must be a valid iterator of *this.
+ //! <b>Requires</b>: p must be a valid iterator of *this.
+ //!
+ //! <b>Effects</b>: Insert n copies of x before pos.
+ //!
+ //! <b>Returns</b>: an iterator to the first inserted element or p if n is 0.
+ //!
+ //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ iterator insert(const_iterator p, size_type n, const T& x)
+ { return this->insert(p, cvalue_iterator(x, n), cvalue_iterator()); }
+
+ //! <b>Requires</b>: p must be a valid iterator of *this.
    //!
    //! <b>Effects</b>: Insert a copy of the [first, last) range before pos.
    //!
+ //! <b>Returns</b>: an iterator to the first inserted element or pos if first == last.
+ //!
    //! <b>Throws</b>: If memory allocation throws, T's constructor from a
    //! dereferenced InpIt throws or T's copy/move constructor/assignment throws.
    //!
    //! <b>Complexity</b>: Linear to std::distance [first, last).
    template <class InIt>
- void insert(const_iterator pos, InIt first, InIt last)
+ iterator insert(const_iterator pos, InIt first, InIt last
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<InIt, size_type>::value
+ && container_detail::is_input_iterator<InIt>::value
+ >::type * = 0
+ #endif
+ )
    {
- //Dispatch depending on integer/iterator
- const bool aux_boolean = container_detail::is_convertible<InIt, size_type>::value;
- typedef container_detail::bool_<aux_boolean> Result;
- this->priv_insert_dispatch(pos, first, last, Result());
+ const size_type n_pos = pos - this->cbegin();
+ iterator it(pos.get_ptr());
+ for(;first != last; ++first){
+ it = this->emplace(it, *first);
+ ++it;
+ }
+ return this->begin() + n_pos;
    }
 
- //! <b>Requires</b>: pos must be a valid iterator of *this.
- //!
- //! <b>Effects</b>: Insert n copies of x before pos.
- //!
- //! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to n.
- void insert(const_iterator p, size_type n, const T& x)
- { this->insert(p, cvalue_iterator(x, n), cvalue_iterator()); }
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ template <class FwdIt>
+ iterator insert(const_iterator pos, FwdIt first, FwdIt last
+ , typename container_detail::enable_if_c
+ < !container_detail::is_convertible<FwdIt, size_type>::value
+ && !container_detail::is_input_iterator<FwdIt>::value
+ >::type * = 0
+ )
+ {
+ const size_type n_pos = pos - this->cbegin();
+ const size_type n = std::distance(first, last);
+ container_detail::advanced_insert_aux_proxy<A, FwdIt, T*> proxy(this->alloc(), first, last);
+ this->priv_forward_range_insert(pos.get_ptr(), n, proxy);
+ return this->begin() + n_pos;
+ }
+ #endif
 
    //! <b>Effects</b>: Removes the last element from the vector.
    //!
@@ -1230,43 +1320,18 @@
       return iterator(first.get_ptr());
    }
 
- //! <b>Effects</b>: Inserts or erases elements at the end such that
- //! the size becomes n. New elements are copy constructed from x.
- //!
- //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
- //!
- //! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size, const T& x)
- {
- pointer finish = this->members_.m_start + this->members_.m_size;
- if (new_size < size()){
- //Destroy last elements
- this->erase(const_iterator(this->members_.m_start + new_size), this->end());
- }
- else{
- //Insert new elements at the end
- this->insert(const_iterator(finish), new_size - this->size(), x);
- }
- }
-
- //! <b>Effects</b>: Inserts or erases elements at the end such that
- //! the size becomes n. New elements are default constructed.
+ //! <b>Effects</b>: Swaps the contents of *this and x.
    //!
- //! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
+ //! <b>Throws</b>: Nothing.
    //!
- //! <b>Complexity</b>: Linear to the difference between size() and new_size.
- void resize(size_type new_size)
+ //! <b>Complexity</b>: Constant.
+ void swap(vector& x)
    {
- if (new_size < this->size()){
- //Destroy last elements
- this->erase(const_iterator(this->members_.m_start + new_size), this->end());
- }
- else{
- size_type n = new_size - this->size();
- this->reserve(new_size);
- container_detail::default_construct_aux_proxy<A, T*> proxy(this->alloc(), n);
- priv_range_insert(this->cend().get_ptr(), n, proxy);
- }
+ //Just swap internals
+ this->swap_members(x);
+ //And now the allocator
+ container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag;
+ container_detail::swap_alloc(this->alloc(), x.alloc(), flag);
    }
 
    //! <b>Effects</b>: Erases all the elements of the vector.
@@ -1277,15 +1342,6 @@
    void clear() BOOST_CONTAINER_NOEXCEPT
    { this->prot_destroy_all(); }
 
- //! <b>Effects</b>: Tries to deallocate the excess of memory created
- //! with previous allocations. The size of the vector is unchanged
- //!
- //! <b>Throws</b>: If memory allocation throws, or T's copy/move constructor throws.
- //!
- //! <b>Complexity</b>: Linear to size().
- void shrink_to_fit()
- { priv_shrink_to_fit(alloc_version()); }
-
    /// @cond
 
    //Absolutely experimental. This function might change, disappear or simply crash!
@@ -1344,7 +1400,7 @@
                               container_detail::is_same<AllocVersion, allocator_v1>::value >::type * = 0)
    {
       if(this->members_.m_capacity){
- if(!size()){
+ if(!this->size()){
             this->prot_deallocate();
          }
          else{
@@ -1399,25 +1455,7 @@
       }
    }
 
- template <class FwdIt>
- void priv_range_insert(const_iterator pos, FwdIt first, FwdIt last, std::forward_iterator_tag)
- {
- if(first != last){
- const size_type n = std::distance(first, last);
- container_detail::advanced_insert_aux_proxy<A, FwdIt, T*> proxy(this->alloc(), first, last);
- priv_range_insert(pos.get_ptr(), n, proxy);
- }
- }
-
- template <class InIt>
- void priv_range_insert(const_iterator pos, InIt first, InIt last, std::input_iterator_tag)
- {
- for(;first != last; ++first){
- this->emplace(pos, *first);
- }
- }
-
- void priv_range_insert(pointer pos, const size_type n, advanced_insert_aux_int_t &interf)
+ void priv_forward_range_insert(pointer pos, const size_type n, advanced_insert_aux_int_t &interf)
    {
       //Check if we have enough memory or try to expand current memory
       size_type remaining = this->members_.m_capacity - this->members_.m_size;
@@ -1564,7 +1602,7 @@
    //New situation in Case A (hole_size == 0):
    // range is moved through move assignments
    //
- // first_pos last_pos old_limit
+ // first_pos last_pos limit_pos
    // | | |
    // ____________V_______V__________________V_____________
    //| prefix' | | | range |suffix'|raw_mem ~
@@ -1573,10 +1611,10 @@
    // |_>_>_>_>_>^
    //
    //
- //New situation in Case B (hole_size >= 0):
+ //New situation in Case B (hole_size > 0):
    // range is moved through uninitialized moves
    //
- // first_pos last_pos old_limit
+ // first_pos last_pos limit_pos
    // | | |
    // ____________V_______V__________________V________________
    //| prefix' | | | [hole] | range |
@@ -1587,31 +1625,33 @@
    //New situation in Case C (hole_size == 0):
    // range is moved through move assignments and uninitialized moves
    //
- // first_pos last_pos old_limit
+ // first_pos last_pos limit_pos
    // | | |
    // ____________V_______V__________________V___
    //| prefix' | | | range |
    //|___________________________________|___^___|
    // | |
    // |_>_>_>_>_>_>_>_>_>_>_>^
- size_type priv_insert_ordered_at_shift_range(size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
+ size_type priv_insert_ordered_at_shift_range
+ (size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
    {
       BOOST_ASSERT(first_pos <= last_pos);
       BOOST_ASSERT(last_pos <= limit_pos);
       //
       T* const begin_ptr = container_detail::to_raw_pointer(this->members_.m_start);
+ T* const first_ptr = begin_ptr + first_pos;
+ T* const last_ptr = begin_ptr + last_pos;
 
       size_type hole_size = 0;
       //Case A:
       if((last_pos + shift_count) <= limit_pos){
          //All move assigned
- boost::move_backward(begin_ptr + first_pos, begin_ptr + last_pos, begin_ptr + last_pos + shift_count);
+ boost::move_backward(first_ptr, last_ptr, last_ptr + shift_count);
       }
       //Case B:
       else if((first_pos + shift_count) >= limit_pos){
          //All uninitialized_moved
- ::boost::container::uninitialized_move_alloc
- (this->alloc(), begin_ptr + first_pos, begin_ptr + last_pos, begin_ptr + first_pos + shift_count);
+ ::boost::container::uninitialized_move_alloc(this->alloc(), first_ptr, last_ptr, first_ptr + shift_count);
          hole_size = last_pos + shift_count - limit_pos;
       }
       //Case C:
@@ -1619,10 +1659,9 @@
          //Some uninitialized_moved
          T* const limit_ptr = begin_ptr + limit_pos;
          T* const boundary_ptr = limit_ptr - shift_count;
- ::boost::container::uninitialized_move_alloc
- (this->alloc(), boundary_ptr, begin_ptr + last_pos, limit_ptr);
+ ::boost::container::uninitialized_move_alloc(this->alloc(), boundary_ptr, last_ptr, limit_ptr);
          //The rest is move assigned
- boost::move_backward(begin_ptr + first_pos, boundary_ptr, limit_ptr);
+ boost::move_backward(first_ptr, boundary_ptr, limit_ptr);
       }
       return hole_size;
    }
@@ -1999,173 +2038,10 @@
       }
    }
 
- template <class InIt>
- void priv_assign_aux(InIt first, InIt last, std::input_iterator_tag)
- {
- //Overwrite all elements we can from [first, last)
- iterator cur = begin();
- for ( ; first != last && cur != end(); ++cur, ++first){
- *cur = *first;
- }
-
- if (first == last){
- //There are no more elements in the sequence, erase remaining
- this->erase(cur, cend());
- }
- else{
- //There are more elements in the range, insert the remaining ones
- this->insert(this->cend(), first, last);
- }
- }
-
- template <class FwdIt>
- void priv_assign_aux(FwdIt first, FwdIt last, std::forward_iterator_tag)
- {
- size_type n = std::distance(first, last);
- if(!n){
- this->prot_destroy_all();
- return;
- }
- //Check if we have enough memory or try to expand current memory
- size_type remaining = this->members_.m_capacity - this->members_.m_size;
- bool same_buffer_start;
- std::pair<pointer, bool> ret;
- size_type real_cap = this->members_.m_capacity;
-
- if (n <= remaining){
- same_buffer_start = true;
- }
- else{
- //There is not enough memory, allocate a new buffer
- size_type new_cap = this->next_capacity(n);
- ret = this->allocation_command
- (allocate_new | expand_fwd | expand_bwd,
- this->size() + n, new_cap, real_cap, this->members_.m_start);
- same_buffer_start = ret.second && this->members_.m_start == ret.first;
- if(same_buffer_start){
- this->members_.m_capacity = real_cap;
- }
- }
-
- if(same_buffer_start){
- T *start = container_detail::to_raw_pointer(this->members_.m_start);
- if (this->size() >= n){
- //There is memory, but there are more old elements than new ones
- //Overwrite old elements with new ones
- std::copy(first, last, start);
- //Destroy remaining old elements
- this->destroy_n(start + n, this->members_.m_size - n);
- this->members_.m_size = n;
- }
- else{
- //There is memory, but there are less old elements than new ones
- //First overwrite some old elements with new ones
- FwdIt mid = first;
- std::advance(mid, this->size());
- // iG T *end = std::copy(first, mid, start);
- T *end = std::copy(first, mid, start);
- //Initialize the remaining new elements in the uninitialized memory
- ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), mid, last, end);
- this->members_.m_size = n;
- }
- }
- else if(!ret.second){
- typename value_traits::ArrayDeallocator scoped_alloc(ret.first, this->alloc(), real_cap);
- ::boost::container::uninitialized_copy_or_move_alloc(this->alloc(), first, last, container_detail::to_raw_pointer(ret.first));
- scoped_alloc.release();
- //Destroy and deallocate old buffer
- if(this->members_.m_start != 0){
- this->destroy_n(container_detail::to_raw_pointer(this->members_.m_start), this->members_.m_size);
- this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
- }
- this->members_.m_start = ret.first;
- this->members_.m_size = n;
- this->members_.m_capacity = real_cap;
- }
- else{
- //Backwards expansion
- //If anything goes wrong, this object will destroy old objects
- T *old_start = container_detail::to_raw_pointer(this->members_.m_start);
- size_type old_size = this->members_.m_size;
- typename value_traits::OldArrayDestructor old_values_destroyer(old_start, this->alloc(), old_size);
- //If something goes wrong size will be 0
- //but holding the whole buffer
- this->members_.m_size = 0;
- this->members_.m_start = ret.first;
- this->members_.m_capacity = real_cap;
-
- //Backup old buffer data
- size_type old_offset = old_start - container_detail::to_raw_pointer(ret.first);
- size_type first_count = container_detail::min_value(n, old_offset);
-
- FwdIt mid = first;
- std::advance(mid, first_count);
- ::boost::container::uninitialized_copy_or_move_alloc
- (this->alloc(), first, mid, container_detail::to_raw_pointer(ret.first));
-
- if(old_offset > n){
- //All old elements will be destroyed by "old_values_destroyer"
- this->members_.m_size = n;
- }
- else{
- //We have constructed objects from the new begin until
- //the old end so release the rollback destruction
- old_values_destroyer.release();
- this->members_.m_start = ret.first;
- this->members_.m_size = first_count + old_size;
- //Now overwrite the old values
- size_type second_count = container_detail::min_value(old_size, n - first_count);
- FwdIt mid2 = mid;
- std::advance(mid2, second_count);
- // iG std::copy(mid, mid2, old_start);
- std::copy(mid, mid2, old_start);
-
- //Check if we still have to append elements in the
- //uninitialized end
- if(second_count == old_size){
- // iG std::copy(mid2, last, old_start + old_size);
- std::copy(mid2, last, old_start + old_size);
- }
- else{
- //We have to destroy some old values
- this->destroy_n
- (old_start + second_count, old_size - second_count);
- this->members_.m_size = n;
- }
- this->members_.m_size = n;
- }
- }
- }
-
- template <class Integer>
- void priv_assign_dispatch(Integer n, Integer val, container_detail::true_)
- { this->assign((size_type) n, (value_type)val); }
-
- template <class InIt>
- void priv_assign_dispatch(InIt first, InIt last, container_detail::false_)
- {
- //Dispatch depending on integer/iterator
- typedef typename std::iterator_traits<InIt>::iterator_category ItCat;
- this->priv_assign_aux(first, last, ItCat());
- }
-
- template <class Integer>
- void priv_insert_dispatch(const_iterator pos, Integer n, Integer val, container_detail::true_)
- { this->insert(pos, (size_type)n, (T)val); }
-
- template <class InIt>
- void priv_insert_dispatch(const_iterator pos, InIt first,
- InIt last, container_detail::false_)
- {
- //Dispatch depending on integer/iterator
- typedef typename std::iterator_traits<InIt>::iterator_category ItCat;
- this->priv_range_insert(pos, first, last, ItCat());
- }
-
    void priv_check_range(size_type n) const
    {
       //If n is out of range, throw an out_of_range exception
- if (n >= size())
+ if (n >= this->size())
          throw std::out_of_range("vector::at");
    }
 

Modified: branches/release/boost/interprocess/allocators/adaptive_pool.hpp
==============================================================================
--- branches/release/boost/interprocess/allocators/adaptive_pool.hpp (original)
+++ branches/release/boost/interprocess/allocators/adaptive_pool.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -105,7 +105,7 @@
    //!adaptive_pool_base
    template<class T2>
    struct rebind
- {
+ {
       typedef adaptive_pool_base<Version, T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
    };
 
@@ -129,8 +129,8 @@
    //!count of the associated node pool. Never throws
    adaptive_pool_base(const adaptive_pool_base &other)
       : mp_node_pool(other.get_node_pool())
- {
- node_pool<0>::get(ipcdetail::to_raw_pointer(mp_node_pool))->inc_ref_count();
+ {
+ node_pool<0>::get(ipcdetail::to_raw_pointer(mp_node_pool))->inc_ref_count();
    }
 
    //!Assignment from other adaptive_pool_base
@@ -211,7 +211,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef adaptive_pool_v1<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
    };
 
@@ -271,7 +271,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef adaptive_pool<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
    };
 
@@ -303,7 +303,7 @@
    //!adaptive_pool
    template<class T2>
    struct rebind
- {
+ {
       typedef adaptive_pool<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
    };
 

Modified: branches/release/boost/interprocess/allocators/allocator.hpp
==============================================================================
--- branches/release/boost/interprocess/allocators/allocator.hpp (original)
+++ branches/release/boost/interprocess/allocators/allocator.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -115,7 +115,7 @@
    //!objects of type T2
    template<class T2>
    struct rebind
- {
+ {
       typedef allocator<T2, SegmentManager> other;
    };
 
@@ -145,8 +145,9 @@
    pointer allocate(size_type count, cvoid_ptr hint = 0)
    {
       (void)hint;
- if(count > this->max_size())
+ if(size_overflows<sizeof(T)>(count)){
          throw bad_alloc();
+ }
       return pointer(static_cast<value_type*>(mp_mngr->allocate(count*sizeof(T))));
    }
 
@@ -169,7 +170,7 @@
    //!pointed by p can hold. This size only works for memory allocated with
    //!allocate, allocation_command and allocate_many.
    size_type size(const pointer &p) const
- {
+ {
       return (size_type)mp_mngr->size(ipcdetail::to_raw_pointer(p))/sizeof(T);
    }
 
@@ -192,7 +193,10 @@
    multiallocation_chain allocate_many
       (size_type elem_size, size_type num_elements)
    {
- return multiallocation_chain(mp_mngr->allocate_many(sizeof(T)*elem_size, num_elements));
+ if(size_overflows<sizeof(T)>(elem_size)){
+ throw bad_alloc();
+ }
+ return multiallocation_chain(mp_mngr->allocate_many(elem_size*sizeof(T), num_elements));
    }
 
    //!Allocates n_elements elements, each one of size elem_sizes[i]in a

Modified: branches/release/boost/interprocess/allocators/cached_adaptive_pool.hpp
==============================================================================
--- branches/release/boost/interprocess/allocators/cached_adaptive_pool.hpp (original)
+++ branches/release/boost/interprocess/allocators/cached_adaptive_pool.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -69,7 +69,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef cached_adaptive_pool_v1
          <T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
    };
@@ -149,7 +149,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef cached_adaptive_pool
          <T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
    };
@@ -183,7 +183,7 @@
    //!cached_adaptive_pool
    template<class T2>
    struct rebind
- {
+ {
       typedef cached_adaptive_pool<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
    };
 

Modified: branches/release/boost/interprocess/allocators/cached_node_allocator.hpp
==============================================================================
--- branches/release/boost/interprocess/allocators/cached_node_allocator.hpp (original)
+++ branches/release/boost/interprocess/allocators/cached_node_allocator.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -64,7 +64,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef cached_node_allocator_v1
          <T2, SegmentManager, NodesPerBlock> other;
    };
@@ -122,7 +122,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef cached_node_allocator<T2, SegmentManager, NodesPerBlock> other;
    };
 
@@ -155,7 +155,7 @@
    //!cached_node_allocator
    template<class T2>
    struct rebind
- {
+ {
       typedef cached_node_allocator<T2, SegmentManager> other;
    };
 

Modified: branches/release/boost/interprocess/allocators/detail/adaptive_node_pool.hpp
==============================================================================
--- branches/release/boost/interprocess/allocators/detail/adaptive_node_pool.hpp (original)
+++ branches/release/boost/interprocess/allocators/detail/adaptive_node_pool.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -74,7 +74,7 @@
 };
 
 //!Pooled shared memory allocator using adaptive pool. Includes
-//!a reference count but the class does not delete itself, this is
+//!a reference count but the class does not delete itself, this is
 //!responsibility of user classes. Node size (NodeSize) and the number of
 //!nodes allocated per block (NodesPerBlock) are known at compile time
 template< class SegmentManager

Modified: branches/release/boost/interprocess/allocators/detail/allocator_common.hpp
==============================================================================
--- branches/release/boost/interprocess/allocators/detail/allocator_common.hpp (original)
+++ branches/release/boost/interprocess/allocators/detail/allocator_common.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //
@@ -73,7 +73,7 @@
 template<class NodePool>
 struct get_or_create_node_pool_func
 {
-
+
    //!This connects or constructs the unique instance of node_pool_t
    //!Can throw boost::interprocess::bad_alloc
    void operator()()
@@ -90,7 +90,7 @@
    //!object parameters
    get_or_create_node_pool_func(typename NodePool::segment_manager *mngr)
       : mp_segment_manager(mngr){}
-
+
    NodePool *mp_node_pool;
    typename NodePool::segment_manager *mp_segment_manager;
 };
@@ -118,7 +118,7 @@
 
       //Last link, let's destroy the segment_manager
       mp_node_pool->get_segment_manager()->template destroy<NodePool>(boost::interprocess::unique_instance);
- }
+ }
 
    //!Constructor. Initializes function
    //!object parameters
@@ -173,7 +173,7 @@
    ~cache_impl()
    {
       this->deallocate_all_cached_nodes();
- ipcdetail::destroy_node_pool_if_last_link(ipcdetail::to_raw_pointer(mp_node_pool));
+ ipcdetail::destroy_node_pool_if_last_link(ipcdetail::to_raw_pointer(mp_node_pool));
    }
 
    NodePool *get_node_pool() const
@@ -191,8 +191,7 @@
       if(m_cached_nodes.empty()){
          m_cached_nodes = mp_node_pool->allocate_nodes(m_max_cached_nodes/2);
       }
- void *ret = ipcdetail::to_raw_pointer(m_cached_nodes.front());
- m_cached_nodes.pop_front();
+ void *ret = ipcdetail::to_raw_pointer(m_cached_nodes.pop_front());
       return ret;
    }
 
@@ -203,8 +202,7 @@
       BOOST_TRY{
          //If don't have any cached node, we have to get a new list of free nodes from the pool
          while(!m_cached_nodes.empty() && count--){
- void *ret = ipcdetail::to_raw_pointer(m_cached_nodes.front());
- m_cached_nodes.pop_front();
+ void *ret = ipcdetail::to_raw_pointer(m_cached_nodes.pop_front());
             chain.push_back(ret);
             ++allocated;
          }
@@ -335,7 +333,7 @@
    //!pointed by p can hold. This size only works for memory allocated with
    //!allocate, allocation_command and allocate_many.
    size_type size(const pointer &p) const
- {
+ {
       return (size_type)this->derived()->get_segment_manager()->size(ipcdetail::to_raw_pointer(p))/sizeof(T);
    }
 
@@ -357,7 +355,10 @@
    //!with deallocate(...)
    multiallocation_chain allocate_many(size_type elem_size, size_type num_elements)
    {
- return this->derived()->get_segment_manager()->allocate_many(sizeof(T)*elem_size, num_elements);
+ if(size_overflows<sizeof(T)>(elem_size)){
+ throw bad_alloc();
+ }
+ return this->derived()->get_segment_manager()->allocate_many(elem_size*sizeof(T), num_elements);
    }
 
    //!Allocates n_elements elements, each one of size elem_sizes[i]in a
@@ -457,14 +458,17 @@
       (void)hint;
       typedef typename node_pool<0>::type node_pool_t;
       node_pool_t *pool = node_pool<0>::get(this->derived()->get_node_pool());
- if(count > this->max_size())
+ if(size_overflows<sizeof(T)>(count)){
          throw bad_alloc();
- else if(Version == 1 && count == 1)
+ }
+ else if(Version == 1 && count == 1){
          return pointer(static_cast<value_type*>
          (pool->allocate_node()));
- else
+ }
+ else{
          return pointer(static_cast<value_type*>
- (pool->get_segment_manager()->allocate(sizeof(T)*count)));
+ (pool->get_segment_manager()->allocate(count*sizeof(T))));
+ }
    }
 
    //!Deallocate allocated memory. Never throws
@@ -605,14 +609,15 @@
    {
       (void)hint;
       void * ret;
- if(count > this->max_size())
+ if(size_overflows<sizeof(T)>(count)){
          throw bad_alloc();
+ }
       else if(Version == 1 && count == 1){
          ret = m_cache.cached_allocation();
       }
       else{
- ret = this->get_segment_manager()->allocate(sizeof(T)*count);
- }
+ ret = this->get_segment_manager()->allocate(count*sizeof(T));
+ }
       return pointer(static_cast<T*>(ret));
    }
 
@@ -699,7 +704,7 @@
 
 
 //!Pooled shared memory allocator using adaptive pool. Includes
-//!a reference count but the class does not delete itself, this is
+//!a reference count but the class does not delete itself, this is
 //!responsibility of user classes. Node size (NodeSize) and the number of
 //!nodes allocated per block (NodesPerBlock) are known at compile time
 template<class private_node_allocator_t>
@@ -736,7 +741,7 @@
       //-----------------------
       return private_node_allocator_t::allocate_node();
    }
-
+
    //!Deallocates an array pointed by ptr. Never throws
    void deallocate_node(void *ptr)
    {

Modified: branches/release/boost/interprocess/allocators/detail/node_pool.hpp
==============================================================================
--- branches/release/boost/interprocess/allocators/detail/node_pool.hpp (original)
+++ branches/release/boost/interprocess/allocators/detail/node_pool.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -37,7 +37,7 @@
 
 
 //!Pooled shared memory allocator using single segregated storage. Includes
-//!a reference count but the class does not delete itself, this is
+//!a reference count but the class does not delete itself, this is
 //!responsibility of user classes. Node size (NodeSize) and the number of
 //!nodes allocated per block (NodesPerBlock) are known at compile time
 template< class SegmentManager, std::size_t NodeSize, std::size_t NodesPerBlock >
@@ -73,11 +73,11 @@
 
 
 //!Pooled shared memory allocator using single segregated storage. Includes
-//!a reference count but the class does not delete itself, this is
+//!a reference count but the class does not delete itself, this is
 //!responsibility of user classes. Node size (NodeSize) and the number of
 //!nodes allocated per block (NodesPerBlock) are known at compile time
 //!Pooled shared memory allocator using adaptive pool. Includes
-//!a reference count but the class does not delete itself, this is
+//!a reference count but the class does not delete itself, this is
 //!responsibility of user classes. Node size (NodeSize) and the number of
 //!nodes allocated per block (NodesPerBlock) are known at compile time
 template< class SegmentManager

Modified: branches/release/boost/interprocess/allocators/detail/node_tools.hpp
==============================================================================
--- branches/release/boost/interprocess/allocators/detail/node_tools.hpp (original)
+++ branches/release/boost/interprocess/allocators/detail/node_tools.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2007-2012. 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)
 //

Modified: branches/release/boost/interprocess/allocators/node_allocator.hpp
==============================================================================
--- branches/release/boost/interprocess/allocators/node_allocator.hpp (original)
+++ branches/release/boost/interprocess/allocators/node_allocator.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -102,7 +102,7 @@
    //!node_allocator_base
    template<class T2>
    struct rebind
- {
+ {
       typedef node_allocator_base<Version, T2, SegmentManager, NodesPerBlock> other;
    };
 
@@ -128,8 +128,8 @@
    //!count of the associated node pool. Never throws
    node_allocator_base(const node_allocator_base &other)
       : mp_node_pool(other.get_node_pool())
- {
- node_pool<0>::get(ipcdetail::to_raw_pointer(mp_node_pool))->inc_ref_count();
+ {
+ node_pool<0>::get(ipcdetail::to_raw_pointer(mp_node_pool))->inc_ref_count();
    }
 
    //!Copy constructor from related node_allocator_base. If not present, constructs
@@ -206,7 +206,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef node_allocator_v1<T2, SegmentManager, NodesPerBlock> other;
    };
 
@@ -256,7 +256,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef node_allocator<T2, SegmentManager, NodesPerBlock> other;
    };
 
@@ -288,7 +288,7 @@
    //!node_allocator
    template<class T2>
    struct rebind
- {
+ {
       typedef node_allocator<T2, SegmentManager, NodesPerBlock> other;
    };
 

Modified: branches/release/boost/interprocess/allocators/private_adaptive_pool.hpp
==============================================================================
--- branches/release/boost/interprocess/allocators/private_adaptive_pool.hpp (original)
+++ branches/release/boost/interprocess/allocators/private_adaptive_pool.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -102,7 +102,7 @@
    //!Obtains node_allocator from other node_allocator
    template<class T2>
    struct rebind
- {
+ {
       typedef private_adaptive_pool_base
          <Version, T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
    };
@@ -210,7 +210,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef private_adaptive_pool_v1<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
    };
 
@@ -269,7 +269,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef private_adaptive_pool
          <T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
    };
@@ -302,7 +302,7 @@
    //!private_adaptive_pool
    template<class T2>
    struct rebind
- {
+ {
       typedef private_adaptive_pool
          <T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
    };

Modified: branches/release/boost/interprocess/allocators/private_node_allocator.hpp
==============================================================================
--- branches/release/boost/interprocess/allocators/private_node_allocator.hpp (original)
+++ branches/release/boost/interprocess/allocators/private_node_allocator.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -97,7 +97,7 @@
    //!Obtains node_allocator from other node_allocator
    template<class T2>
    struct rebind
- {
+ {
       typedef private_node_allocator_base
          <Version, T2, SegmentManager, NodesPerBlock> other;
    };
@@ -198,7 +198,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef private_node_allocator_v1<T2, SegmentManager, NodesPerBlock> other;
    };
 
@@ -246,7 +246,7 @@
 
    template<class T2>
    struct rebind
- {
+ {
       typedef private_node_allocator
          <T2, SegmentManager, NodesPerBlock> other;
    };
@@ -279,7 +279,7 @@
    //!private_node_allocator
    template<class T2>
    struct rebind
- {
+ {
       typedef private_node_allocator
          <T2, SegmentManager, NodesPerBlock> other;
    };

Modified: branches/release/boost/interprocess/anonymous_shared_memory.hpp
==============================================================================
--- branches/release/boost/interprocess/anonymous_shared_memory.hpp (original)
+++ branches/release/boost/interprocess/anonymous_shared_memory.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -90,13 +90,13 @@
                   , 0);
 
    if(address == MAP_FAILED){
- if(fd != -1)
+ if(fd != -1)
          close(fd);
       error_info err = system_error_code();
       throw interprocess_exception(err);
    }
 
- if(fd != -1)
+ if(fd != -1)
       close(fd);
 
    return ipcdetail::raw_mapped_region_creator::create_posix_mapped_region(address, size);

Modified: branches/release/boost/interprocess/containers/allocation_type.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/allocation_type.hpp (original)
+++ branches/release/boost/interprocess/containers/allocation_type.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/containers_fwd.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/containers_fwd.hpp (original)
+++ branches/release/boost/interprocess/containers/containers_fwd.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/deque.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/deque.hpp (original)
+++ branches/release/boost/interprocess/containers/deque.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/flat_map.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/flat_map.hpp (original)
+++ branches/release/boost/interprocess/containers/flat_map.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/flat_set.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/flat_set.hpp (original)
+++ branches/release/boost/interprocess/containers/flat_set.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/list.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/list.hpp (original)
+++ branches/release/boost/interprocess/containers/list.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/map.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/map.hpp (original)
+++ branches/release/boost/interprocess/containers/map.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/pair.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/pair.hpp (original)
+++ branches/release/boost/interprocess/containers/pair.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/set.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/set.hpp (original)
+++ branches/release/boost/interprocess/containers/set.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/slist.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/slist.hpp (original)
+++ branches/release/boost/interprocess/containers/slist.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/stable_vector.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/stable_vector.hpp (original)
+++ branches/release/boost/interprocess/containers/stable_vector.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/string.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/string.hpp (original)
+++ branches/release/boost/interprocess/containers/string.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/vector.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/vector.hpp (original)
+++ branches/release/boost/interprocess/containers/vector.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/containers/version_type.hpp
==============================================================================
--- branches/release/boost/interprocess/containers/version_type.hpp (original)
+++ branches/release/boost/interprocess/containers/version_type.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/creation_tags.hpp
==============================================================================
--- branches/release/boost/interprocess/creation_tags.hpp (original)
+++ branches/release/boost/interprocess/creation_tags.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/atomic.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/atomic.hpp (original)
+++ branches/release/boost/interprocess/detail/atomic.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011
+// (C) Copyright Ion Gaztanaga 2006-2012
 // (C) Copyright Markus Schoepflin 2007
 // (C) Copyright Bryce Lelbach 2010
 //
@@ -390,96 +390,96 @@
 } //namespace interprocess{
 } //namespace boost{
 
-#elif defined(__IBMCPP__) && (__IBMCPP__ >= 800) && defined(_AIX)
+#elif defined(__IBMCPP__) && (__IBMCPP__ >= 800) && defined(_AIX)
 
-#include <builtins.h>
+#include <builtins.h>
 
-namespace boost {
-namespace interprocess {
-namespace ipcdetail{
-
-//first define boost::uint32_t versions of __lwarx and __stwcx to avoid poluting
-//all the functions with casts
-
-//! From XLC documenation :
-//! This function can be used with a subsequent stwcxu call to implement a
-//! read-modify-write on a specified memory location. The two functions work
-//! together to ensure that if the store is successfully performed, no other
-//! processor or mechanism can modify the target doubleword between the time
-//! lwarxu function is executed and the time the stwcxu functio ncompletes.
-//! "mem" : pointer to the object
-//! Returns the value at pointed to by mem
-inline boost::uint32_t lwarxu(volatile boost::uint32_t *mem)
-{
- return static_cast<boost::uint32_t>(__lwarx(reinterpret_cast<volatile int*>(mem)));
-}
-
-//! "mem" : pointer to the object
-//! "val" : the value to store
-//! Returns true if the update of mem is successful and false if it is
-//!unsuccessful
-inline bool stwcxu(volatile boost::uint32_t* mem, boost::uint32_t val)
-{
- return (__stwcx(reinterpret_cast<volatile int*>(mem), static_cast<int>(val)) != 0);
-}
-
-//! "mem": pointer to the object
-//! "val": amount to add
-//! Returns the old value pointed to by mem
-inline boost::uint32_t atomic_add32
- (volatile boost::uint32_t *mem, boost::uint32_t val)
-{
- boost::uint32_t oldValue;
- do
- {
- oldValue = lwarxu(mem);
- }while (!stwcxu(mem, oldValue+val));
- return oldValue;
-}
-
-//! Atomically increment an apr_uint32_t by 1
-//! "mem": pointer to the object
-//! Returns the old value pointed to by mem
-inline boost::uint32_t atomic_inc32(volatile boost::uint32_t *mem)
-{ return atomic_add32(mem, 1); }
-
-//! Atomically decrement an boost::uint32_t by 1
-//! "mem": pointer to the atomic value
-//! Returns the old value pointed to by mem
-inline boost::uint32_t atomic_dec32(volatile boost::uint32_t *mem)
-{ return atomic_add32(mem, (boost::uint32_t)-1); }
-
-//! Atomically read an boost::uint32_t from memory
-inline boost::uint32_t atomic_read32(volatile boost::uint32_t *mem)
-{ return *mem; }
-
-//! Compare an boost::uint32_t's value with "cmp".
-//! If they are the same swap the value with "with"
-//! "mem": pointer to the value
-//! "with" what to swap it with
-//! "cmp": the value to compare it to
-//! Returns the old value of *mem
-inline boost::uint32_t atomic_cas32
- (volatile boost::uint32_t *mem, boost::uint32_t with, boost::uint32_t cmp)
-{
- boost::uint32_t oldValue;
- boost::uint32_t valueToStore;
- do
- {
- oldValue = lwarxu(mem);
- } while (!stwcxu(mem, (oldValue == with) ? cmp : oldValue));
-
- return oldValue;
-}
-
-//! Atomically set an boost::uint32_t in memory
-//! "mem": pointer to the object
-//! "param": val value that the object will assume
-inline void atomic_write32(volatile boost::uint32_t *mem, boost::uint32_t val)
-{ *mem = val; }
+namespace boost {
+namespace interprocess {
+namespace ipcdetail{
+
+//first define boost::uint32_t versions of __lwarx and __stwcx to avoid poluting
+//all the functions with casts
+
+//! From XLC documenation :
+//! This function can be used with a subsequent stwcxu call to implement a
+//! read-modify-write on a specified memory location. The two functions work
+//! together to ensure that if the store is successfully performed, no other
+//! processor or mechanism can modify the target doubleword between the time
+//! lwarxu function is executed and the time the stwcxu functio ncompletes.
+//! "mem" : pointer to the object
+//! Returns the value at pointed to by mem
+inline boost::uint32_t lwarxu(volatile boost::uint32_t *mem)
+{
+ return static_cast<boost::uint32_t>(__lwarx(reinterpret_cast<volatile int*>(mem)));
+}
 
-} //namespace ipcdetail
-} //namespace interprocess
+//! "mem" : pointer to the object
+//! "val" : the value to store
+//! Returns true if the update of mem is successful and false if it is
+//!unsuccessful
+inline bool stwcxu(volatile boost::uint32_t* mem, boost::uint32_t val)
+{
+ return (__stwcx(reinterpret_cast<volatile int*>(mem), static_cast<int>(val)) != 0);
+}
+
+//! "mem": pointer to the object
+//! "val": amount to add
+//! Returns the old value pointed to by mem
+inline boost::uint32_t atomic_add32
+ (volatile boost::uint32_t *mem, boost::uint32_t val)
+{
+ boost::uint32_t oldValue;
+ do
+ {
+ oldValue = lwarxu(mem);
+ }while (!stwcxu(mem, oldValue+val));
+ return oldValue;
+}
+
+//! Atomically increment an apr_uint32_t by 1
+//! "mem": pointer to the object
+//! Returns the old value pointed to by mem
+inline boost::uint32_t atomic_inc32(volatile boost::uint32_t *mem)
+{ return atomic_add32(mem, 1); }
+
+//! Atomically decrement an boost::uint32_t by 1
+//! "mem": pointer to the atomic value
+//! Returns the old value pointed to by mem
+inline boost::uint32_t atomic_dec32(volatile boost::uint32_t *mem)
+{ return atomic_add32(mem, (boost::uint32_t)-1); }
+
+//! Atomically read an boost::uint32_t from memory
+inline boost::uint32_t atomic_read32(volatile boost::uint32_t *mem)
+{ return *mem; }
+
+//! Compare an boost::uint32_t's value with "cmp".
+//! If they are the same swap the value with "with"
+//! "mem": pointer to the value
+//! "with" what to swap it with
+//! "cmp": the value to compare it to
+//! Returns the old value of *mem
+inline boost::uint32_t atomic_cas32
+ (volatile boost::uint32_t *mem, boost::uint32_t with, boost::uint32_t cmp)
+{
+ boost::uint32_t oldValue;
+ boost::uint32_t valueToStore;
+ do
+ {
+ oldValue = lwarxu(mem);
+ } while (!stwcxu(mem, (oldValue == with) ? cmp : oldValue));
+
+ return oldValue;
+}
+
+//! Atomically set an boost::uint32_t in memory
+//! "mem": pointer to the object
+//! "param": val value that the object will assume
+inline void atomic_write32(volatile boost::uint32_t *mem, boost::uint32_t val)
+{ *mem = val; }
+
+} //namespace ipcdetail
+} //namespace interprocess
 } //namespace boost
 
 #elif defined(__GNUC__) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 )
@@ -552,9 +552,9 @@
    return c != unless_this;
 }
 
-} //namespace ipcdetail
-} //namespace interprocess
-} //namespace boost
+} //namespace ipcdetail
+} //namespace interprocess
+} //namespace boost
 
 
 #include <boost/interprocess/detail/config_end.hpp>

Modified: branches/release/boost/interprocess/detail/cast_tags.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/cast_tags.hpp (original)
+++ branches/release/boost/interprocess/detail/cast_tags.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/config_begin.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/config_begin.hpp (original)
+++ branches/release/boost/interprocess/detail/config_begin.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/config_end.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/config_end.hpp (original)
+++ branches/release/boost/interprocess/detail/config_end.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/file_wrapper.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/file_wrapper.hpp (original)
+++ branches/release/boost/interprocess/detail/file_wrapper.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -60,10 +60,10 @@
    //!After the call, "moved" does not represent any file.
    //!Does not throw
    file_wrapper &operator=(BOOST_RV_REF(file_wrapper) moved)
- {
+ {
       file_wrapper tmp(boost::move(moved));
       this->swap(tmp);
- return *this;
+ return *this;
    }
 
    //!Swaps to file_wrappers.
@@ -73,7 +73,7 @@
    //!Erases a file from the system.
    //!Returns false on error. Never throws
    static bool remove(const char *name);
-
+
    //!Sets the size of the file
    void truncate(offset_t length);
 
@@ -122,10 +122,10 @@
 { return get_file_size((file_handle_t)m_handle, size); }
 
 inline void file_wrapper::swap(file_wrapper &other)
-{
+{
    std::swap(m_handle, other.m_handle);
    std::swap(m_mode, other.m_mode);
- m_filename.swap(other.m_filename);
+ m_filename.swap(other.m_filename);
 }
 
 inline mapping_handle_t file_wrapper::get_mapping_handle() const

Modified: branches/release/boost/interprocess/detail/in_place_interface.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/in_place_interface.hpp (original)
+++ branches/release/boost/interprocess/detail/in_place_interface.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/intermodule_singleton.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/intermodule_singleton.hpp (original)
+++ branches/release/boost/interprocess/detail/intermodule_singleton.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/intermodule_singleton_common.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/intermodule_singleton_common.hpp (original)
+++ branches/release/boost/interprocess/detail/intermodule_singleton_common.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-2012. 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)
 //
@@ -199,7 +199,7 @@
    private:
    static ThreadSafeGlobalMap &get_map()
    {
- return *static_cast<ThreadSafeGlobalMap *>(static_cast<void *>(&mem_holder.map_mem));
+ return *static_cast<ThreadSafeGlobalMap *>(static_cast<void *>(&mem_holder.map_mem[0]));
    }
 
    static void initialize_global_map_handle()
@@ -274,7 +274,7 @@
    //Values: Uninitialized, Initializing, Initialized, Broken
    static volatile boost::uint32_t this_module_map_initialized;
 
- //Raw memory to construct the global map manager
+ //Raw memory to construct the global map manager
    static struct mem_holder_t
    {
       ::boost::detail::max_align aligner;
@@ -411,7 +411,7 @@
          atomic_inc32(&rcount->singleton_ref_count);
          ret_ptr = rcount->ptr;
       }
- void *data() const
+ void *data() const
          { return ret_ptr; }
 
       private:
@@ -448,7 +448,7 @@
       }
       void *data() const
          { return ret_ptr; }
-
+
       private:
       ThreadSafeGlobalMap &m_map;
       void *ret_ptr;

Modified: branches/release/boost/interprocess/detail/interprocess_tester.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/interprocess_tester.hpp (original)
+++ branches/release/boost/interprocess/detail/interprocess_tester.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2007-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/intersegment_ptr.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/intersegment_ptr.hpp (original)
+++ branches/release/boost/interprocess/detail/intersegment_ptr.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -177,7 +177,7 @@
 
    void set_mode(std::size_t mode)
    {
- BOOST_ASSERT(mode < is_max_mode);
+ BOOST_ASSERT(mode < is_max_mode);
       members.direct.ctrl = mode;
    }
 
@@ -309,13 +309,13 @@
       void *ptr_base;
       void *this_base;
       get_segment_info_and_offset(this, this_info, this_offset, this_base);
-
+
       if(!this_info.group){
          this->set_mode(is_in_stack);
          this->members.direct.addr = const_cast<void*>(ptr);
       }
       else{
- get_segment_info_and_offset(ptr, ptr_info, ptr_offset, ptr_base);
+ get_segment_info_and_offset(ptr, ptr_info, ptr_offset, ptr_base);
 
          if(ptr_info.group != this_info.group){
             this->set_mode(is_pointee_outside);
@@ -383,7 +383,7 @@
       };
       vector<segment_data> m_segments;
       multi_segment_services &m_ms_services;
-
+
       public:
       segment_group_t(multi_segment_services &ms_services)
          : m_ms_services(ms_services)
@@ -445,7 +445,7 @@
       typedef Mutex mutex_type;
       //!Maps base addresses and segment information
       //!(size and segment group and id)*
-
+
       ptr_to_segment_info_t m_ptr_to_segment_info;
 
       ~mappings_t()
@@ -486,7 +486,7 @@
       --it;
       char * segment_base = const_cast<char*>(reinterpret_cast<const char*>(it->first));
       std::size_t segment_size = it->second.size;
-
+
       if(segment_base <= reinterpret_cast<const char*>(ptr) &&
          (segment_base + segment_size) >= reinterpret_cast<const char*>(ptr)){
          segment = it->second;
@@ -552,7 +552,7 @@
             s_groups.insert(segment_group_t(*services));
          BOOST_ASSERT(ret.second);
          return &*ret.first;
- }
+ }
    }
 
    static bool delete_group(segment_group_id id)
@@ -574,7 +574,7 @@
             }
          }
          return success;
- }
+ }
    }
 };
 
@@ -663,17 +663,17 @@
 
    //!Pointer-like -> operator. It can return 0 pointer.
    //!Never throws.
- pointer operator->() const
+ pointer operator->() const
    { return self_t::get(); }
 
    //!Dereferencing operator, if it is a null intersegment_ptr behavior
    //!is undefined. Never throws.
- reference operator* () const
+ reference operator* () const
    { return *(self_t::get()); }
 
    //!Indexing operator.
    //!Never throws.
- reference operator[](std::ptrdiff_t idx) const
+ reference operator[](std::ptrdiff_t idx) const
    { return self_t::get()[idx]; }
 
    //!Assignment from pointer (saves extra conversion).
@@ -690,15 +690,15 @@
    //!are assignable, intersegment_ptrs will be assignable. Never throws.
    template <class T2>
    intersegment_ptr& operator= (const intersegment_ptr<T2> & ptr)
- {
+ {
       pointer p(ptr.get()); (void)p;
- base_t::set_from_other(ptr); return *this;
+ base_t::set_from_other(ptr); return *this;
    }
 
    //!intersegment_ptr + std::ptrdiff_t.
    //!Never throws.
- intersegment_ptr operator+ (std::ptrdiff_t idx) const
- {
+ intersegment_ptr operator+ (std::ptrdiff_t idx) const
+ {
       intersegment_ptr result (*this);
       result.inc_offset(idx*sizeof(T));
       return result;
@@ -706,8 +706,8 @@
 
    //!intersegment_ptr - std::ptrdiff_t.
    //!Never throws.
- intersegment_ptr operator- (std::ptrdiff_t idx) const
- {
+ intersegment_ptr operator- (std::ptrdiff_t idx) const
+ {
       intersegment_ptr result (*this);
       result.dec_offset(idx*sizeof(T));
       return result;
@@ -745,7 +745,7 @@
 
    //!Safe bool conversion operator.
    //!Never throws.
- operator unspecified_bool_type() const
+ operator unspecified_bool_type() const
    { return base_t::is_null()? 0 : &self_t::unspecified_bool_type_func; }
 
    //!Not operator. Not needed in theory, but improves portability.
@@ -784,12 +784,12 @@
 template <class T1, class T2> inline
 bool operator ==(const intersegment_ptr<T1> &left,
                  const intersegment_ptr<T2> &right)
-{
+{
    //Make sure both pointers can be compared
    bool e = typename intersegment_ptr<T1>::pointer(0) ==
             typename intersegment_ptr<T2>::pointer(0);
    (void)e;
- return left._equal(right);
+ return left._equal(right);
 }
 
 //!Returns true if *this is less than other.
@@ -798,12 +798,12 @@
 template <class T1, class T2> inline
 bool operator <(const intersegment_ptr<T1> &left,
                 const intersegment_ptr<T2> &right)
-{
+{
    //Make sure both pointers can be compared
    bool e = typename intersegment_ptr<T1>::pointer(0) <
             typename intersegment_ptr<T2>::pointer(0);
    (void)e;
- return left._less(right);
+ return left._less(right);
 }
 
 template<class T1, class T2> inline

Modified: branches/release/boost/interprocess/detail/managed_memory_impl.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/managed_memory_impl.hpp (original)
+++ branches/release/boost/interprocess/detail/managed_memory_impl.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -172,14 +172,14 @@
       //This function should not throw. The index construction can
       //throw if constructor allocates memory. So we must catch it.
       BOOST_TRY{
- //Let's construct the allocator in memory
+ //Let's construct the allocator in memory
          mp_header = new(addr) segment_manager(size);
       }
       BOOST_CATCH(...){
          return false;
       }
       BOOST_CATCH_END
- return true;
+ return true;
    }
 
    //!Connects to a segment manager in the reserved buffer. Never throws.
@@ -192,7 +192,7 @@
 
    //!Frees resources. Never throws.
    bool close_impl()
- {
+ {
       bool ret = mp_header != 0;
       mp_header = 0;
       return ret;
@@ -254,12 +254,12 @@
    handle_t get_handle_from_address (const void *ptr) const
    {
       return (handle_t)(reinterpret_cast<const char*>(ptr) -
- reinterpret_cast<const char*>(this->get_address()));
+ reinterpret_cast<const char*>(this->get_address()));
    }
 
    //!Returns true if the address belongs to the managed memory segment
    bool belongs_to_segment (const void *ptr) const
- {
+ {
       return ptr >= this->get_address() &&
              ptr < (reinterpret_cast<const char*>(this->get_address()) + this->get_size());
    }
@@ -292,7 +292,7 @@
       allocation_command (boost::interprocess::allocation_type command, size_type limit_size,
                            size_type preferred_size,size_type &received_size,
                            T *reuse_ptr = 0)
- {
+ {
       return mp_header->allocation_command
          (command, limit_size, preferred_size, received_size, reuse_ptr);
    }
@@ -724,7 +724,7 @@
       : m_frontend(frontend), m_type(type){}
 
    bool operator()(void *addr, typename BasicManagedMemoryImpl::size_type size, bool created) const
- {
+ {
       if(((m_type == DoOpen) && created) ||
          ((m_type == DoCreate) && !created))
          return false;

Modified: branches/release/boost/interprocess/detail/managed_multi_shared_memory.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/managed_multi_shared_memory.hpp (original)
+++ branches/release/boost/interprocess/detail/managed_multi_shared_memory.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -36,7 +36,7 @@
 #include <boost/assert.hpp>
 //These includes needed to fulfill default template parameters of
 //predeclarations in interprocess_fwd.hpp
-#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
+#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
 #include <boost/interprocess/sync/mutex_family.hpp>
 
 //!\file
@@ -69,7 +69,7 @@
                <CharType, MemoryAlgorithm, IndexType> self_t;
    typedef ipcdetail::basic_managed_memory_impl
       <CharType, MemoryAlgorithm, IndexType> base_t;
-
+
    typedef typename MemoryAlgorithm::void_pointer void_pointer;
    typedef typename ipcdetail::
       managed_open_or_create_impl<shared_memory_object, MemoryAlgorithm::Alignment> managed_impl;
@@ -100,7 +100,7 @@
 // if(!m_shmem.create(m_mem_name, size, m_addr))
 // return 0;
 // return m_shmem.get_address();
-// }
+// }
 // private:
 // shared_memory &m_shmem;
 // const char *m_mem_name;
@@ -134,7 +134,7 @@
             typename shmem_list_t::value_type &m_impl = *mp_frontend->m_shmem_list.rbegin();
             return result_type(m_impl.get_real_address(), m_impl.get_real_size()-1);
          }*/
- return result_type(static_cast<void *>(0), 0);
+ return result_type(static_cast<void *>(0), 0);
       }
 
       virtual bool update_segments ()
@@ -174,7 +174,7 @@
          : mp_frontend(frontend), m_type(type), m_segment_number(segment_number){}
 
       bool operator()(void *addr, size_type size, bool created) const
- {
+ {
          if(((m_type == DoOpen) && created) ||
             ((m_type == DoCreate) && !created))
             return false;
@@ -226,7 +226,7 @@
          : mp_frontend(frontend){}
 
       void operator()(const mapped_region &region, bool last) const
- {
+ {
          if(last) mp_frontend->destroy_impl();
          else mp_frontend->close_impl();
       }
@@ -251,7 +251,7 @@
                                      const permissions &perm = permissions())
       : m_group_services(get_this_pointer())
    {
- priv_open_or_create(create_open_func::DoCreate,name, size, perm);
+ priv_open_or_create(create_open_func::DoCreate,name, size, perm);
    }
 
    basic_managed_multi_shared_memory(open_or_create_t,
@@ -301,7 +301,7 @@
       if(group){
          void_pointer::delete_group(group);
       }
- return false;
+ return false;
    }
 
    bool priv_new_segment(typename create_open_func::type_t type,
@@ -368,7 +368,7 @@
 
    //!Frees resources. Never throws.
    void priv_close()
- {
+ {
       if(!m_shmem_list.empty()){
          bool ret;
          //Obtain group identifier
@@ -385,7 +385,7 @@
          m_shmem_list.clear();
       }
    }
-
+
    private:
    shmem_list_t m_shmem_list;
    group_services m_group_services;

Modified: branches/release/boost/interprocess/detail/managed_open_or_create_impl.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/managed_open_or_create_impl.hpp (original)
+++ branches/release/boost/interprocess/detail/managed_open_or_create_impl.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -48,12 +48,12 @@
 
 template<>
 struct managed_open_or_create_impl_device_id_t<xsi_shared_memory_file_wrapper>
-{
+{
    typedef xsi_key type;
 };
 
 #endif //BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS
-
+
 /// @endcond
 
 namespace ipcdetail {
@@ -79,7 +79,7 @@
 
    const DeviceAbstraction &get_device() const
    { return dev; }
-
+
    private:
    DeviceAbstraction dev;
 };
@@ -94,9 +94,9 @@
    typedef typename managed_open_or_create_impl_device_id_t<DeviceAbstraction>::type device_id_t;
    typedef managed_open_or_create_impl_device_holder<StoreDevice, DeviceAbstraction> DevHolder;
    enum
- {
- UninitializedSegment,
- InitializingSegment,
+ {
+ UninitializedSegment,
+ InitializingSegment,
       InitializedSegment,
       CorruptedSegment
    };
@@ -222,10 +222,10 @@
    { this->swap(moved); }
 
    managed_open_or_create_impl &operator=(BOOST_RV_REF(managed_open_or_create_impl) moved)
- {
+ {
       managed_open_or_create_impl tmp(boost::move(moved));
       this->swap(tmp);
- return *this;
+ return *this;
    }
 
    ~managed_open_or_create_impl()

Modified: branches/release/boost/interprocess/detail/math_functions.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/math_functions.hpp (original)
+++ branches/release/boost/interprocess/detail/math_functions.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,7 +1,7 @@
 //////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Stephen Cleary 2000.
-// (C) Copyright Ion Gaztanaga 2007-2011.
+// (C) Copyright Ion Gaztanaga 2007-2012.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -93,7 +93,7 @@
 
    std::size_t n = x;
    std::size_t log2 = 0;
-
+
    for(std::size_t shift = Bits >> 1; shift; shift >>= 1){
       std::size_t tmp = n >> shift;
       if (tmp)

Modified: branches/release/boost/interprocess/detail/min_max.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/min_max.hpp (original)
+++ branches/release/boost/interprocess/detail/min_max.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/interprocess/detail/move.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/move.hpp (original)
+++ branches/release/boost/interprocess/detail/move.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2010-2011.
+// (C) Copyright Ion Gaztanaga 2010-2012.
 // 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)

Modified: branches/release/boost/interprocess/detail/mpl.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/mpl.hpp (original)
+++ branches/release/boost/interprocess/detail/mpl.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/interprocess/detail/multi_segment_services.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/multi_segment_services.hpp (original)
+++ branches/release/boost/interprocess/detail/multi_segment_services.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/named_proxy.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/named_proxy.hpp (original)
+++ branches/release/boost/interprocess/detail/named_proxy.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -93,7 +93,7 @@
    {}
 
    tuple<Args&...> args_;
-};
+};
 
 //!Describes a proxy class that implements named
 //!allocation syntax.
@@ -119,7 +119,7 @@
 
    template<class ...Args>
    T *operator()(Args &&...args) const
- {
+ {
       CtorNArg<T, is_iterator, Args...> &&ctor_obj = CtorNArg<T, is_iterator, Args...>
          (boost::forward<Args>(args)...);
       return mp_mngr->template
@@ -199,7 +199,7 @@
 // private:
 // void construct(void *mem, true_)
 // { new((void*)mem)T(*m_p1, *m_p2); }
-//
+//
 // void construct(void *mem, false_)
 // { new((void*)mem)T(m_p1, m_p2); }
 //
@@ -293,7 +293,7 @@
    //!makes a named allocation and calls the
    //!default constructor
    T *operator()() const
- {
+ {
       Ctor0Arg<T> ctor_obj;
       return mp_mngr->template
          generic_construct<T>(mp_name, m_num, m_find, m_dothrow, ctor_obj);

Modified: branches/release/boost/interprocess/detail/os_file_functions.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/os_file_functions.hpp (original)
+++ branches/release/boost/interprocess/detail/os_file_functions.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -96,28 +96,28 @@
 
 inline file_handle_t create_new_file
    (const char *name, mode_t mode, const permissions & perm = permissions(), bool temporary = false)
-{
+{
    unsigned long attr = temporary ? winapi::file_attribute_temporary : 0;
    return winapi::create_file
       ( name, (unsigned int)mode, winapi::create_new, attr
- , (winapi::interprocess_security_attributes*)perm.get_permissions());
+ , (winapi::interprocess_security_attributes*)perm.get_permissions());
 }
 
 inline file_handle_t create_or_open_file
    (const char *name, mode_t mode, const permissions & perm = permissions(), bool temporary = false)
-{
+{
    unsigned long attr = temporary ? winapi::file_attribute_temporary : 0;
    return winapi::create_file
       ( name, (unsigned int)mode, winapi::open_always, attr
- , (winapi::interprocess_security_attributes*)perm.get_permissions());
+ , (winapi::interprocess_security_attributes*)perm.get_permissions());
 }
 
 inline file_handle_t open_existing_file
    (const char *name, mode_t mode, bool temporary = false)
-{
+{
    unsigned long attr = temporary ? winapi::file_attribute_temporary : 0;
    return winapi::create_file
- (name, (unsigned int)mode, winapi::open_existing, attr, 0);
+ (name, (unsigned int)mode, winapi::open_existing, attr, 0);
 }
 
 inline bool delete_file(const char *name)
@@ -177,7 +177,7 @@
 { return winapi::set_file_pointer_ex(hnd, 0, &off, winapi::file_current); }
 
 inline bool write_file(file_handle_t hnd, const void *data, std::size_t numdata)
-{
+{
    unsigned long written;
    return 0 != winapi::write_file(hnd, data, (unsigned long)numdata, &written, 0);
 }
@@ -189,9 +189,9 @@
 { return 0 != winapi::close_handle(hnd); }
 
 inline bool acquire_file_lock(file_handle_t hnd)
-{
+{
    static winapi::interprocess_overlapped overlapped;
- const unsigned long len = ~((unsigned long)(0u));
+ const unsigned long len = ((unsigned long)-1);
 // winapi::interprocess_overlapped overlapped;
 // std::memset(&overlapped, 0, sizeof(overlapped));
    return winapi::lock_file_ex
@@ -199,8 +199,8 @@
 }
 
 inline bool try_acquire_file_lock(file_handle_t hnd, bool &acquired)
-{
- const unsigned long len = ~((unsigned long)(0u));
+{
+ const unsigned long len = ((unsigned long)-1);
    winapi::interprocess_overlapped overlapped;
    std::memset(&overlapped, 0, sizeof(overlapped));
    if(!winapi::lock_file_ex
@@ -208,30 +208,30 @@
        0, len, len, &overlapped)){
       return winapi::get_last_error() == winapi::error_lock_violation ?
                acquired = false, true : false;
-
+
    }
    return (acquired = true);
 }
 
 inline bool release_file_lock(file_handle_t hnd)
-{
- const unsigned long len = ~((unsigned long)(0u));
+{
+ const unsigned long len = ((unsigned long)-1);
    winapi::interprocess_overlapped overlapped;
    std::memset(&overlapped, 0, sizeof(overlapped));
    return winapi::unlock_file_ex(hnd, 0, len, len, &overlapped);
 }
 
 inline bool acquire_file_lock_sharable(file_handle_t hnd)
-{
- const unsigned long len = ~((unsigned long)(0u));
+{
+ const unsigned long len = ((unsigned long)-1);
    winapi::interprocess_overlapped overlapped;
    std::memset(&overlapped, 0, sizeof(overlapped));
    return winapi::lock_file_ex(hnd, 0, 0, len, len, &overlapped);
 }
 
 inline bool try_acquire_file_lock_sharable(file_handle_t hnd, bool &acquired)
-{
- const unsigned long len = ~((unsigned long)(0u));
+{
+ const unsigned long len = ((unsigned long)-1);
    winapi::interprocess_overlapped overlapped;
    std::memset(&overlapped, 0, sizeof(overlapped));
    if(!winapi::lock_file_ex
@@ -406,7 +406,7 @@
 
 inline file_handle_t create_new_file
    (const char *name, mode_t mode, const permissions & perm = permissions(), bool temporary = false)
-{
+{
    (void)temporary;
    int ret = ::open(name, ((int)mode) | O_EXCL | O_CREAT, perm.get_permissions());
    if(ret >= 0){
@@ -439,7 +439,7 @@
 
 inline file_handle_t open_existing_file
    (const char *name, mode_t mode, bool temporary = false)
-{
+{
    (void)temporary;
    return ::open(name, (int)mode);
 }
@@ -459,7 +459,7 @@
 }
 
 inline bool get_file_size(file_handle_t hnd, offset_t &size)
-{
+{
    struct stat data;
    bool ret = 0 == ::fstat(hnd, &data);
    if(ret){
@@ -472,7 +472,7 @@
 { return ((off_t)(-1)) != ::lseek(hnd, off, (int)pos); }
 
 inline bool get_file_pointer(file_handle_t hnd, offset_t &off)
-{
+{
    off = ::lseek(hnd, 0, SEEK_CUR);
    return off != ((off_t)-1);
 }
@@ -522,7 +522,7 @@
 }
 
 inline bool acquire_file_lock_sharable(file_handle_t hnd)
-{
+{
    struct ::flock lock;
    lock.l_type = F_RDLCK;
    lock.l_whence = SEEK_SET;
@@ -532,7 +532,7 @@
 }
 
 inline bool try_acquire_file_lock_sharable(file_handle_t hnd, bool &acquired)
-{
+{
    struct flock lock;
    lock.l_type = F_RDLCK;
    lock.l_whence = SEEK_SET;
@@ -601,7 +601,7 @@
             || (de->d_name[1] == '.' && de->d_name[2] == '\0' )) ){
          continue;
       }
- if(dont_delete_this && std::strcmp(dont_delete_this, de->d_name) == 0){
+ if(dont_delete_this && std::strcmp(dont_delete_this, de->d_name) == 0){
          continue;
       }
       fn = refcstrRootDirectory;

Modified: branches/release/boost/interprocess/detail/os_thread_functions.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/os_thread_functions.hpp (original)
+++ branches/release/boost/interprocess/detail/os_thread_functions.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -104,7 +104,7 @@
 typedef pid_t OS_process_id_t;
 
 struct OS_systemwide_thread_id_t
-{
+{
    OS_systemwide_thread_id_t()
       : pid(), tid()
    {}

Modified: branches/release/boost/interprocess/detail/pointer_type.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/pointer_type.hpp (original)
+++ branches/release/boost/interprocess/detail/pointer_type.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
 // (C) Copyright Gennaro Prota 2003 - 2004.
 //
 // Distributed under the Boost Software License, Version 1.0.

Modified: branches/release/boost/interprocess/detail/portable_intermodule_singleton.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/portable_intermodule_singleton.hpp (original)
+++ branches/release/boost/interprocess/detail/portable_intermodule_singleton.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-2012. 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)
 //
@@ -54,7 +54,7 @@
    s += "/";
    s += file_prefix;
    if(creation_time){
- std::string sstamp;
+ std::string sstamp;
       get_pid_creation_time_str(sstamp);
       s += sstamp;
    }
@@ -137,7 +137,7 @@
          delete_file(singleton_lock_file_path_);
          shared_memory_object::remove(shm_name_);
       }
-
+
       const char * const shm_name_;
       const char * const singleton_lock_file_path_;
       managed_global_memory & shm_;

Modified: branches/release/boost/interprocess/detail/posix_time_types_wrk.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/posix_time_types_wrk.hpp (original)
+++ branches/release/boost/interprocess/detail/posix_time_types_wrk.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/preprocessor.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/preprocessor.hpp (original)
+++ branches/release/boost/interprocess/detail/preprocessor.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //
@@ -57,21 +57,10 @@
 
 #ifndef BOOST_NO_RVALUE_REFERENCES
 
- #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
-
- #define BOOST_INTERPROCESS_PP_PARAM_INIT(z, n, data) \
- BOOST_PP_CAT(m_p, n) (BOOST_PP_CAT(p, n)) \
- //!
-
-
- #else //#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
-
    #define BOOST_INTERPROCESS_PP_PARAM_INIT(z, n, data) \
      BOOST_PP_CAT(m_p, n) (::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) )) \
    //!
 
- #endif //#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
-
 #else //#ifndef BOOST_NO_RVALUE_REFERENCES
 
    #define BOOST_INTERPROCESS_PP_PARAM_INIT(z, n, data) \
@@ -79,31 +68,104 @@
    //!
 #endif
 
-#define BOOST_INTERPROCESS_PP_PARAM_INC(z, n, data) \
- BOOST_PP_CAT(++m_p, n) \
-//!
-
 #ifndef BOOST_NO_RVALUE_REFERENCES
 
-#if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
+ #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
-#define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data) \
- BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \
-//!
+ namespace boost {
+ namespace interprocess {
+ namespace ipcdetail {
+ template<class T>
+ struct ref_holder;
+
+ template<class T>
+ struct ref_holder<T &>
+ {
+ ref_holder(T &t)
+ : t_(t)
+ {}
+ T &t_;
+ T & get() { return t_; }
+ T & get_lvalue() { return t_; }
+ };
+
+ template<class T>
+ struct ref_holder<const T>
+ {
+ ref_holder(const T &t)
+ : t_(t)
+ {}
+ const T &t_;
+ const T & get() { return t_; }
+ const T & get_lvalue() { return t_; }
+ };
+
+ template<class T>
+ struct ref_holder<const T &&>
+ {
+ ref_holder(const T &t)
+ : t_(t)
+ {}
+ const T &t_;
+ const T & get() { return t_; }
+ const T & get_lvalue() { return t_; }
+ };
+
+ template<class T>
+ struct ref_holder
+ {
+ ref_holder(T &&t)
+ : t_(t)
+ {}
+ T &t_;
+ T && get() { return ::boost::move(t_); }
+ T & get_lvalue() { return t_; }
+ };
+
+ template<class T>
+ struct ref_holder<T &&>
+ {
+ ref_holder(T &&t)
+ : t(t)
+ {}
+ T &t;
+ T && get() { return ::boost::move(t_); }
+ T & get_lvalue() { return t_; }
+ };
+
+ } //namespace ipcdetail {
+ } //namespace interprocess {
+ } //namespace boost {
+
+ #define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data) \
+ ::boost::interprocess::ipcdetail::ref_holder<BOOST_PP_CAT(P, n)> BOOST_PP_CAT(m_p, n); \
+ //!
+
+ #define BOOST_INTERPROCESS_PP_PARAM_INC(z, n, data) \
+ BOOST_PP_CAT(++m_p, n).get_lvalue() \
+ //!
+
+ #else //BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG
+
+ #define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data)\
+ BOOST_PP_CAT(P, n) && BOOST_PP_CAT(m_p, n); \
+ //!
+
+ #define BOOST_INTERPROCESS_PP_PARAM_INC(z, n, data) \
+ BOOST_PP_CAT(++m_p, n) \
+ //!
+
+ #endif //defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
 #else
+ #define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data) \
+ BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \
+ //!
 
-#define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data) \
- BOOST_PP_CAT(P, n) && BOOST_PP_CAT(m_p, n); \
-//!
-
-#endif //defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
-
+ #define BOOST_INTERPROCESS_PP_PARAM_INC(z, n, data) \
+ BOOST_PP_CAT(++m_p, n) \
+ //!
 
-#else
-#define BOOST_INTERPROCESS_PP_PARAM_DEFINE(z, n, data) \
- BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \
-//!
 #endif
 
 #define BOOST_INTERPROCESS_PP_PARAM_FORWARD(z, n, data) \
@@ -112,23 +174,25 @@
 
 #if !defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
-#include <boost/container/detail/stored_ref.hpp>
+ #define BOOST_INTERPROCESS_PP_MEMBER_FORWARD(z, n, data) BOOST_PP_CAT(this->m_p, n).get() \
+ //!
 
-#define BOOST_INTERPROCESS_PP_MEMBER_FORWARD(z, n, data) \
-::boost::container::container_detail::stored_ref< BOOST_PP_CAT(P, n) >::forward( BOOST_PP_CAT(m_p, n) ) \
-//!
+ #define BOOST_INTERPROCESS_PP_MEMBER_IT_FORWARD(z, n, data) \
+ BOOST_PP_CAT(*m_p, n).get_lvalue() \
+ //!
 
 #else
 
-#define BOOST_INTERPROCESS_PP_MEMBER_FORWARD(z, n, data) \
-::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(m_p, n) ) \
-//!
+ #define BOOST_INTERPROCESS_PP_MEMBER_FORWARD(z, n, data) \
+ ::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(m_p, n) ) \
+ //!
 
-#endif //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
+ #define BOOST_INTERPROCESS_PP_MEMBER_IT_FORWARD(z, n, data) \
+ BOOST_PP_CAT(*m_p, n) \
+ //!
 
-#define BOOST_INTERPROCESS_PP_MEMBER_IT_FORWARD(z, n, data) \
-BOOST_PP_CAT(*m_p, n) \
-//!
+
+#endif //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
 
 #include <boost/interprocess/detail/config_end.hpp>
 

Modified: branches/release/boost/interprocess/detail/ptime_wrk.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/ptime_wrk.hpp (original)
+++ branches/release/boost/interprocess/detail/ptime_wrk.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/robust_emulation.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/robust_emulation.hpp (original)
+++ branches/release/boost/interprocess/detail/robust_emulation.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2010-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2010-2012. 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)
 //
@@ -132,7 +132,7 @@
             throw interprocess_exception(other_error, "Robust emulation robust_mutex_lock_file constructor failed: create_file filed with unexpected error");
          }
       }
- }
+ }
 
    ~robust_mutex_lock_file()
    {
@@ -324,7 +324,7 @@
       return false;
    }
    atomic_write32(&this->state, fixing_state);
- return true;
+ return true;
 }
 
 template<class Mutex>

Modified: branches/release/boost/interprocess/detail/segment_manager_helper.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/segment_manager_helper.hpp (original)
+++ branches/release/boost/interprocess/detail/segment_manager_helper.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -130,7 +130,7 @@
 
    template<class CharType>
    CharType *name() const
- {
+ {
       return const_cast<CharType*>(reinterpret_cast<const CharType*>
          (reinterpret_cast<const char*>(this) + name_offset()));
    }
@@ -175,7 +175,7 @@
    { return block_header_from_value(value, sizeof(T), ::boost::alignment_of<T>::value); }
 
    static block_header<size_type> *block_header_from_value(const void *value, std::size_t sz, std::size_t algn)
- {
+ {
       block_header * hdr =
          const_cast<block_header*>
             (reinterpret_cast<const block_header*>(reinterpret_cast<const char*>(value) -
@@ -189,7 +189,7 @@
 
    template<class Header>
    static block_header<size_type> *from_first_header(Header *header)
- {
+ {
       block_header<size_type> * hdr =
          reinterpret_cast<block_header<size_type>*>(reinterpret_cast<char*>(header) +
                  get_rounded_size(size_type(sizeof(Header)), size_type(::boost::alignment_of<block_header<size_type> >::value)));
@@ -199,7 +199,7 @@
 
    template<class Header>
    static Header *to_first_header(block_header<size_type> *bheader)
- {
+ {
       Header * hdr =
          reinterpret_cast<Header*>(reinterpret_cast<char*>(bheader) -
                  get_rounded_size(size_type(sizeof(Header)), size_type(::boost::alignment_of<block_header<size_type> >::value)));
@@ -478,7 +478,7 @@
                          , segment_manager_iterator_value_adaptor<Iterator, intrusive> >
 {
    typedef segment_manager_iterator_value_adaptor<Iterator, intrusive> result_type;
-
+
    result_type operator()(const typename Iterator::value_type &arg) const
    { return result_type(arg); }
 };

Modified: branches/release/boost/interprocess/detail/tmp_dir_helpers.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/tmp_dir_helpers.hpp (original)
+++ branches/release/boost/interprocess/detail/tmp_dir_helpers.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2007-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/transform_iterator.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/transform_iterator.hpp (original)
+++ branches/release/boost/interprocess/detail/transform_iterator.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
 // (C) Copyright Gennaro Prota 2003 - 2004.
 //
 // Distributed under the Boost Software License, Version 1.0.

Modified: branches/release/boost/interprocess/detail/type_traits.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/type_traits.hpp (original)
+++ branches/release/boost/interprocess/detail/type_traits.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 // (C) Copyright John Maddock 2000.
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -117,6 +117,12 @@
    typedef T type;
 };
 
+template<class T>
+struct remove_const_volatile
+{
+ typedef typename remove_const<typename remove_volatile<T>::type>::type type;
+};
+
 template <typename T, typename U>
 struct is_same
 {
@@ -136,6 +142,13 @@
    static const bool value = sizeof(yes_type) == sizeof(is_same_tester(t,u));
 };
 
+template<class T, class U>
+struct is_cv_same
+{
+ static const bool value = is_same< typename remove_const_volatile<T>::type
+ , typename remove_const_volatile<U>::type >::value;
+};
+
 } // namespace ipcdetail
 } //namespace interprocess {
 } //namespace boost {

Modified: branches/release/boost/interprocess/detail/utilities.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/utilities.hpp (original)
+++ branches/release/boost/interprocess/detail/utilities.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011.
+// (C) Copyright Ion Gaztanaga 2005-2012.
 // (C) Copyright Gennaro Prota 2003 - 2004.
 //
 // Distributed under the Boost Software License, Version 1.0.
@@ -31,8 +31,10 @@
 #include <boost/interprocess/containers/version_type.hpp>
 #include <boost/intrusive/pointer_traits.hpp>
 #include <boost/move/move.hpp>
+#include <boost/static_assert.hpp>
 #include <utility>
 #include <algorithm>
+#include <climits>
 
 namespace boost {
 namespace interprocess {
@@ -86,7 +88,10 @@
 template <std::size_t OrigSize, std::size_t RoundTo>
 struct ct_rounded_size
 {
- static const std::size_t value = ((OrigSize-1)/RoundTo+1)*RoundTo;
+ BOOST_STATIC_ASSERT((RoundTo != 0));
+ static const std::size_t intermediate_value = (OrigSize-1)/RoundTo+1;
+ BOOST_STATIC_ASSERT(intermediate_value <= std::size_t(-1)/RoundTo);
+ static const std::size_t value = intermediate_value*RoundTo;
 };
 
 // Gennaro Prota wrote this. Thanks!
@@ -133,6 +138,59 @@
        &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
 }
 
+template<class SizeType>
+struct sqrt_size_type_max
+{
+ static const SizeType value = (SizeType(1) << (sizeof(SizeType)*(CHAR_BIT/2)))-1;
+};
+
+template<class SizeType>
+inline bool multiplication_overflows(SizeType a, SizeType b)
+{
+ const SizeType sqrt_size_max = sqrt_size_type_max<SizeType>::value;
+ return //Fast runtime check
+ ( (a | b) > sqrt_size_max &&
+ //Slow division check
+ b && a > SizeType(-1)/b
+ );
+}
+
+template<std::size_t SztSizeOfType, class SizeType>
+inline bool size_overflows(SizeType count)
+{
+ //Compile time-check
+ BOOST_STATIC_ASSERT(SztSizeOfType <= SizeType(-1));
+ //Runtime check
+ return multiplication_overflows(SizeType(SztSizeOfType), count);
+}
+
+template<class RawPointer>
+class pointer_size_t_caster
+{
+ public:
+ explicit pointer_size_t_caster(std::size_t sz)
+ : m_ptr(reinterpret_cast<RawPointer>(sz))
+ {}
+
+ explicit pointer_size_t_caster(RawPointer p)
+ : m_ptr(p)
+ {}
+
+ std::size_t size() const
+ { return reinterpret_cast<std::size_t>(m_ptr); }
+
+ RawPointer pointer() const
+ { return m_ptr; }
+
+ private:
+ RawPointer m_ptr;
+};
+
+
+template<class SizeType>
+inline bool sum_overflows(SizeType a, SizeType b)
+{ return SizeType(-1) - a < b; }
+
 //Anti-exception node eraser
 template<class Cont>
 class value_eraser
@@ -140,7 +198,7 @@
    public:
    value_eraser(Cont & cont, typename Cont::iterator it)
       : m_cont(cont), m_index_it(it), m_erase(true){}
- ~value_eraser()
+ ~value_eraser()
    { if(m_erase) m_cont.erase(m_index_it); }
 
    void release() { m_erase = false; }

Modified: branches/release/boost/interprocess/detail/variadic_templates_tools.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/variadic_templates_tools.hpp (original)
+++ branches/release/boost/interprocess/detail/variadic_templates_tools.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/boost/interprocess/detail/win32_api.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/win32_api.hpp (original)
+++ branches/release/boost/interprocess/detail/win32_api.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -50,6 +50,7 @@
 static const unsigned long error_sharing_violation = 32L;
 static const unsigned long error_file_not_found = 2u;
 static const unsigned long error_no_more_files = 18u;
+static const unsigned long error_not_locked = 158L;
 //Retries in CreateFile, see http://support.microsoft.com/kb/316609
 static const unsigned int error_sharing_violation_tries = 3u;
 static const unsigned int error_sharing_violation_sleep_ms = 250u;
@@ -61,6 +62,7 @@
 static const unsigned long page_readonly = 0x02;
 static const unsigned long page_readwrite = 0x04;
 static const unsigned long page_writecopy = 0x08;
+static const unsigned long page_noaccess = 0x01;
 
 static const unsigned long standard_rights_required = 0x000F0000L;
 static const unsigned long section_query = 0x0001;
@@ -239,17 +241,16 @@
    } value;
 };
 
- struct IUnknown_BIPC
- {
- public:
- virtual long __stdcall QueryInterface(
- /* [in] */ const GUID_BIPC &riid,
- /* [iid_is][out] */ void **ppvObject) = 0;
-
- virtual unsigned long __stdcall AddRef( void) = 0;
+struct IUnknown_BIPC
+{
+ public:
+ virtual long __stdcall QueryInterface(
+ const GUID_BIPC &riid, // [in]
+ void **ppvObject) = 0; // [iid_is][out]
 
- virtual unsigned long __stdcall Release( void) = 0;
- };
+ virtual unsigned long __stdcall AddRef (void) = 0;
+ virtual unsigned long __stdcall Release(void) = 0;
+};
 
 struct IWbemClassObject_BIPC : public IUnknown_BIPC
 {
@@ -357,7 +358,6 @@
 
 };
 
-
 struct IWbemContext_BIPC : public IUnknown_BIPC
 {
 public:
@@ -585,8 +585,6 @@
 
 };
 
-
-
 struct interprocess_overlapped
 {
    unsigned long *internal;
@@ -661,7 +659,7 @@
     unsigned short wProcessorRevision;
 };
 
-typedef struct _interprocess_memory_basic_information
+struct interprocess_memory_basic_information
 {
    void * BaseAddress;
    void * AllocationBase;
@@ -670,16 +668,16 @@
    unsigned long State;
    unsigned long Protect;
    unsigned long Type;
-} interprocess_memory_basic_information;
+};
 
-typedef struct _interprocess_acl
+struct interprocess_acl
 {
    unsigned char AclRevision;
    unsigned char Sbz1;
    unsigned short AclSize;
    unsigned short AceCount;
    unsigned short Sbz2;
-} interprocess_acl;
+};
 
 typedef struct _interprocess_security_descriptor
 {
@@ -876,6 +874,8 @@
 extern "C" __declspec(dllimport) int __stdcall MoveFileExA (const char *, const char *, unsigned long);
 extern "C" __declspec(dllimport) void __stdcall GetSystemInfo (struct system_info *);
 extern "C" __declspec(dllimport) int __stdcall FlushViewOfFile (void *, std::size_t);
+extern "C" __declspec(dllimport) int __stdcall VirtualUnlock (void *, std::size_t);
+extern "C" __declspec(dllimport) int __stdcall VirtualProtect (void *, std::size_t, unsigned long, unsigned long *);
 extern "C" __declspec(dllimport) int __stdcall FlushFileBuffers (void *);
 extern "C" __declspec(dllimport) int __stdcall GetFileSizeEx (void *, __int64 *size);
 extern "C" __declspec(dllimport) unsigned long __stdcall FormatMessageA
@@ -1033,7 +1033,7 @@
       , duplicate_same_access);
 }
 
-inline long get_file_type(void *hFile)
+inline unsigned long get_file_type(void *hFile)
 {
    return GetFileType(hFile);
 }
@@ -1137,6 +1137,12 @@
 inline bool flush_view_of_file(void *base_addr, std::size_t numbytes)
 { return 0 != FlushViewOfFile(base_addr, numbytes); }
 
+inline bool virtual_unlock(void *base_addr, std::size_t numbytes)
+{ return 0 != VirtualUnlock(base_addr, numbytes); }
+
+inline bool virtual_protect(void *base_addr, std::size_t numbytes, unsigned long flNewProtect, unsigned long &lpflOldProtect)
+{ return 0 != VirtualProtect(base_addr, numbytes, flNewProtect, &lpflOldProtect); }
+
 inline bool flush_file_buffers(void *handle)
 { return 0 != FlushFileBuffers(handle); }
 

Modified: branches/release/boost/interprocess/detail/windows_intermodule_singleton.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/windows_intermodule_singleton.hpp (original)
+++ branches/release/boost/interprocess/detail/windows_intermodule_singleton.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-2012. 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)
 //
@@ -68,8 +68,8 @@
       //in max_count and initial count parameters.
       //Also, max count must be bigger than 0 and bigger or equal than initial count.
       if(sizeof(void*) == sizeof(boost::uint32_t)){
- //This means that for 32 bit processes, a semaphore count (31 usable bits) is
- //enough to store 4 byte aligned memory (4GB -> 32 bits - 2 bits = 30 bits).
+ //This means that for 32 bit processes, a semaphore count (31 usable bits) is
+ //enough to store 4 byte aligned memory (4GB -> 32 bits - 2 bits = 30 bits).
          //The max count will hold the pointer value and current semaphore count
          //will be zero.
          //
@@ -224,7 +224,7 @@
       m_sem_count.close();
       //Once scoped_lock unlocks the mutex, the destructor will close the handle...
    }
-
+
    private:
    winapi_mutex_wrapper m_mtx_lock;
    winapi_semaphore_wrapper m_sem_map;

Modified: branches/release/boost/interprocess/detail/workaround.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/workaround.hpp (original)
+++ branches/release/boost/interprocess/detail/workaround.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -27,7 +27,7 @@
          #define BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
       #endif
    #endif
-
+
    #if defined(_POSIX_BARRIERS) && ((_POSIX_BARRIERS - 0) > 0)
       #define BOOST_INTERPROCESS_POSIX_BARRIERS
    #endif
@@ -39,7 +39,7 @@
       #endif
    //Some platforms have a limited (name length) named semaphore support
    #elif (defined(__FreeBSD__) && (__FreeBSD__ >= 4)) || defined(__APPLE__)
- #define BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES
+ #define BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES
    #endif
 
    #if ((defined _V6_ILP32_OFFBIG) &&(_V6_ILP32_OFFBIG - 0 > 0)) ||\
@@ -90,6 +90,8 @@
       // hp-ux tru64 vms freebsd
       #if defined(__hpux) || defined(__osf__) || defined(__vms) || (defined(__FreeBSD__) && (__FreeBSD__ < 7))
          #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
+ //Some systems have "jailed" environments where shm usage is restricted at runtime
+ //and temporary file file based shm is possible in those executions.
       #elif defined(__FreeBSD__)
          #define BOOST_INTERPROCESS_RUNTIME_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
       #endif
@@ -130,6 +132,29 @@
    #define BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS 10000
 #endif
 
+//Other switches
+//BOOST_INTERPROCESS_MSG_QUEUE_USES_CIRC_INDEX
+//message queue uses a circular queue as index instead of an array (better performance)
+//Boost version < 1.52 uses an array, so undef this if you want to communicate
+//with processes compiled with those versions.
+#define BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX
+
+//Inline attributes
+#if defined(_MSC_VER)
+ #define BOOST_INTERPROCESS_ALWAYS_INLINE __forceinline
+#elif defined (__GNUC__)
+ #define BOOST_INTERPROCESS_ALWAYS_INLINE __attribute__((__always_inline__))
+#else
+ #define BOOST_INTERPROCESS_ALWAYS_INLINE inline
+#endif
+
+#if defined(_MSC_VER)
+ #define BOOST_INTERPROCESS_NEVER_INLINE __declspec(noinline)
+#elif defined (__GNUC__)
+ #define BOOST_INTERPROCESS_NEVER_INLINE __attribute__((__noinline__))
+#endif
+
+
 #include <boost/interprocess/detail/config_end.hpp>
 
 #endif //#ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP

Modified: branches/release/boost/interprocess/detail/xsi_shared_memory_device.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/xsi_shared_memory_device.hpp (original)
+++ branches/release/boost/interprocess/detail/xsi_shared_memory_device.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-2012. 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)
 //
@@ -74,10 +74,10 @@
    { this->swap(moved); }
 
    xsi_shared_memory_device &operator=(BOOST_RV_REF(xsi_shared_memory_device) moved)
- {
+ {
       xsi_shared_memory_device tmp(boost::move(moved));
       this->swap(tmp);
- return *this;
+ return *this;
    }
 
    //!Swaps two xsi_shared_memory_device. Does not throw
@@ -178,7 +178,7 @@
 {
    m_shm.swap(other.m_shm);
    std::swap(m_mode, other.m_mode);
- m_name.swap(other.m_name);
+ m_name.swap(other.m_name);
 }
 
 inline mapping_handle_t xsi_shared_memory_device::get_mapping_handle() const

Modified: branches/release/boost/interprocess/detail/xsi_shared_memory_file_wrapper.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/xsi_shared_memory_file_wrapper.hpp (original)
+++ branches/release/boost/interprocess/detail/xsi_shared_memory_file_wrapper.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-2012. 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)
 //
@@ -40,7 +40,7 @@
 {
    /// @cond
    BOOST_MOVABLE_BUT_NOT_COPYABLE(xsi_shared_memory_file_wrapper)
- /// @endcond
+ /// @endcond
    public:
 
    xsi_shared_memory_file_wrapper() : xsi_shared_memory() {}
@@ -61,10 +61,10 @@
    { this->swap(moved); }
 
    xsi_shared_memory_file_wrapper &operator=(BOOST_RV_REF(xsi_shared_memory_file_wrapper) moved)
- {
+ {
       xsi_shared_memory_file_wrapper tmp(boost::move(moved));
       this->swap(tmp);
- return *this;
+ return *this;
    }
 
    //!Swaps two xsi_shared_memory_file_wrapper. Does not throw

Modified: branches/release/boost/interprocess/errors.hpp
==============================================================================
--- branches/release/boost/interprocess/errors.hpp (original)
+++ branches/release/boost/interprocess/errors.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -183,7 +183,7 @@
 };
 
 inline error_code_t lookup_error(native_error_t err)
-{
+{
    const ec_xlate *cur = &ec_table[0],
                   *end = cur + sizeof(ec_table)/sizeof(ec_xlate);
    for (;cur != end; ++cur ){

Modified: branches/release/boost/interprocess/exceptions.hpp
==============================================================================
--- branches/release/boost/interprocess/exceptions.hpp (original)
+++ branches/release/boost/interprocess/exceptions.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/file_mapping.hpp
==============================================================================
--- branches/release/boost/interprocess/file_mapping.hpp (original)
+++ branches/release/boost/interprocess/file_mapping.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -61,7 +61,7 @@
    {
       file_mapping tmp(boost::move(moved));
       this->swap(tmp);
- return *this;
+ return *this;
    }
 
    //!Swaps to file_mappings.
@@ -111,10 +111,10 @@
 { return m_filename.c_str(); }
 
 inline void file_mapping::swap(file_mapping &other)
-{
+{
    std::swap(m_handle, other.m_handle);
    std::swap(m_mode, other.m_mode);
- m_filename.swap(other.m_filename);
+ m_filename.swap(other.m_filename);
 }
 
 inline mapping_handle_t file_mapping::get_mapping_handle() const

Modified: branches/release/boost/interprocess/indexes/flat_map_index.hpp
==============================================================================
--- branches/release/boost/interprocess/indexes/flat_map_index.hpp (original)
+++ branches/release/boost/interprocess/indexes/flat_map_index.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/indexes/iset_index.hpp
==============================================================================
--- branches/release/boost/interprocess/indexes/iset_index.hpp (original)
+++ branches/release/boost/interprocess/indexes/iset_index.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -82,7 +82,7 @@
    struct intrusive_key_value_less
    {
       bool operator()(const intrusive_compare_key_type &i, const value_type &b) const
- {
+ {
          std::size_t blen = b.name_length();
          return (i.m_len < blen) ||
                   (i.m_len == blen &&
@@ -91,7 +91,7 @@
       }
 
       bool operator()(const value_type &b, const intrusive_compare_key_type &i) const
- {
+ {
          std::size_t blen = b.name_length();
          return (blen < i.m_len) ||
                   (blen == i.m_len &&

Modified: branches/release/boost/interprocess/indexes/iunordered_set_index.hpp
==============================================================================
--- branches/release/boost/interprocess/indexes/iunordered_set_index.hpp (original)
+++ branches/release/boost/interprocess/indexes/iunordered_set_index.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -58,21 +58,21 @@
    struct equal_function
    {
       bool operator()(const intrusive_compare_key_type &i, const value_type &b) const
- {
+ {
          return (i.m_len == b.name_length()) &&
                   (std::char_traits<char_type>::compare
                      (i.mp_str, b.name(), i.m_len) == 0);
       }
 
       bool operator()(const value_type &b, const intrusive_compare_key_type &i) const
- {
+ {
          return (i.m_len == b.name_length()) &&
                   (std::char_traits<char_type>::compare
                      (i.mp_str, b.name(), i.m_len) == 0);
       }
 
       bool operator()(const value_type &b1, const value_type &b2) const
- {
+ {
          return (b1.name_length() == b2.name_length()) &&
                   (std::char_traits<char_type>::compare
                      (b1.name(), b2.name(), b1.name_length()) == 0);
@@ -190,7 +190,7 @@
 
       bucket_ptr shunk_p = alloc.allocation_command
          (boost::interprocess::shrink_in_place | boost::interprocess::nothrow_allocation, received_size, received_size, received_size, buckets).first;
- BOOST_ASSERT(buckets == shunk_p);
+ BOOST_ASSERT(buckets == shunk_p); (void)shunk_p;
 
       bucket_ptr buckets_init = buckets + received_size;
       for(size_type i = 0; i < (old_size - received_size); ++i){
@@ -290,7 +290,7 @@
       size_type cur_size = this->size();
       size_type cur_count = this->bucket_count();
       bucket_ptr old_p = this->bucket_pointer();
-
+
       if(!this->size() && old_p != bucket_ptr(&this->init_bucket)){
          this->rehash(bucket_traits(bucket_ptr(&this->init_bucket), 1));
          destroy_buckets(this->alloc, old_p, cur_count);
@@ -337,7 +337,7 @@
             //Strong guarantee: if something goes wrong
             //we should remove the insertion.
             //
- //We can use the iterator because the hash function
+ //We can use the iterator because the hash function
             //can't throw and this means that "reserve" will
             //throw only because of the memory allocation:
             //the iterator has not been invalidated.

Modified: branches/release/boost/interprocess/indexes/map_index.hpp
==============================================================================
--- branches/release/boost/interprocess/indexes/map_index.hpp (original)
+++ branches/release/boost/interprocess/indexes/map_index.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/indexes/null_index.hpp
==============================================================================
--- branches/release/boost/interprocess/indexes/null_index.hpp (original)
+++ branches/release/boost/interprocess/indexes/null_index.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/indexes/unordered_map_index.hpp
==============================================================================
--- branches/release/boost/interprocess/indexes/unordered_map_index.hpp (original)
+++ branches/release/boost/interprocess/indexes/unordered_map_index.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/interprocess_fwd.hpp
==============================================================================
--- branches/release/boost/interprocess/interprocess_fwd.hpp (original)
+++ branches/release/boost/interprocess/interprocess_fwd.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/ipc/message_queue.hpp
==============================================================================
--- branches/release/boost/interprocess/ipc/message_queue.hpp (original)
+++ branches/release/boost/interprocess/ipc/message_queue.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -99,7 +99,7 @@
 
    //!Sends a message stored in buffer "buffer" with size "buffer_size" in the
    //!message queue with priority "priority". If the message queue is full
- //!the sender is blocked. Throws interprocess_error on error.*/
+ //!the sender is blocked. Throws interprocess_error on error.
    void send (const void *buffer, size_type buffer_size,
               unsigned int priority);
 
@@ -161,7 +161,7 @@
    //!Returns false on error. Never throws
    static bool remove(const char *name);
 
- /// @cond
+ /// @cond
    private:
    typedef boost::posix_time::ptime ptime;
    bool do_receive(block_t block,
@@ -227,9 +227,27 @@
 //!
 //!-> offset_ptr<msg_hdr_t> index [max_num_msg]
 //! An array of pointers with size "max_num_msg" called index. Each pointer
-//! points to a preallocated message. The elements of this array are
+//! points to a preallocated message. Elements of this array are
 //! reordered in runtime in the following way:
 //!
+//! IF BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX is defined:
+//!
+//! When the current number of messages is "cur_num_msg", the array
+//! is treated like a circular buffer. Starting from position "cur_first_msg"
+//! "cur_num_msg" in a circular way, pointers point to inserted messages and the rest
+//! point to free messages. Those "cur_num_msg" pointers are
+//! ordered by the priority of the pointed message and by insertion order
+//! if two messages have the same priority. So the next message to be
+//! used in a "receive" is pointed by index [(cur_first_msg + cur_num_msg-1)%max_num_msg]
+//! and the first free message ready to be used in a "send" operation is
+//! [cur_first_msg] if circular buffer is extended from front,
+//! [(cur_first_msg + cur_num_msg)%max_num_msg] otherwise.
+//!
+//! This transforms the index in a circular buffer with an embedded free
+//! message queue.
+//!
+//! ELSE (BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX is NOT defined):
+//!
 //! When the current number of messages is "cur_num_msg", the first
 //! "cur_num_msg" pointers point to inserted messages and the rest
 //! point to free messages. The first "cur_num_msg" pointers are
@@ -237,11 +255,12 @@
 //! if two messages have the same priority. So the next message to be
 //! used in a "receive" is pointed by index [cur_num_msg-1] and the first free
 //! message ready to be used in a "send" operation is index [cur_num_msg].
-//! This transforms index in a fixed size priority queue with an embedded free
+//!
+//! This transforms the index in a fixed size priority queue with an embedded free
 //! message queue.
 //!
 //!-> struct message_t
-//! {
+//! {
 //! msg_hdr_t header;
 //! char[max_msg_size] data;
 //! } messages [max_num_msg];
@@ -252,7 +271,7 @@
 template<class VoidPointer>
 class mq_hdr_t
    : public ipcdetail::priority_functor<VoidPointer>
-{
+{
    typedef VoidPointer void_pointer;
    typedef msg_hdr_t<void_pointer> msg_header;
    typedef typename boost::intrusive::
@@ -269,17 +288,16 @@
    //!Constructor. This object must be constructed in the beginning of the
    //!shared memory of the size returned by the function "get_mem_size".
    //!This constructor initializes the needed resources and creates
- //!the internal structures like the priority index. This can throw.*/
+ //!the internal structures like the priority index. This can throw.
    mq_hdr_t(size_type max_num_msg, size_type max_msg_size)
       : m_max_num_msg(max_num_msg),
          m_max_msg_size(max_msg_size),
          m_cur_num_msg(0)
+ #if defined(BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX)
+ ,m_cur_first_msg(0u)
+ #endif
       { this->initialize_memory(); }
 
- //!Returns the inserted message with top priority
- msg_header * top_msg()
- { return mp_index[m_cur_num_msg-1].get(); }
-
    //!Returns true if the message queue is full
    bool is_full() const
       { return m_cur_num_msg == m_max_num_msg; }
@@ -292,24 +310,196 @@
    void free_top_msg()
       { --m_cur_num_msg; }
 
- //!Returns the first free msg of the free message queue
- msg_header * free_msg()
- { return mp_index[m_cur_num_msg].get(); }
+ #if defined(BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX)
+
+ typedef msg_hdr_ptr_t *iterator;
+
+ size_type end_pos() const
+ {
+ const size_type space_until_bufend = m_max_num_msg - m_cur_first_msg;
+ return space_until_bufend > m_cur_num_msg
+ ? m_cur_first_msg + m_cur_num_msg : m_cur_num_msg - space_until_bufend;
+ }
+
+ //!Returns the inserted message with top priority
+ msg_header &top_msg()
+ {
+ size_type pos = this->end_pos();
+ return *mp_index[pos ? --pos : m_max_num_msg - 1];
+ }
+
+ //!Returns the inserted message with bottom priority
+ msg_header &bottom_msg()
+ { return *mp_index[m_cur_first_msg]; }
+
+ iterator inserted_ptr_begin() const
+ { return &mp_index[m_cur_first_msg]; }
+
+ iterator inserted_ptr_end() const
+ { return &mp_index[this->end_pos()]; }
+
+ iterator lower_bound(const msg_hdr_ptr_t & value, priority_functor<VoidPointer> func)
+ {
+ iterator begin(this->inserted_ptr_begin()), end(this->inserted_ptr_end());
+ if(end < begin){
+ iterator idx_end = &mp_index[m_max_num_msg];
+ iterator ret = std::lower_bound(begin, idx_end, value, func);
+ if(idx_end == ret){
+ iterator idx_beg = &mp_index[0];
+ ret = std::lower_bound(idx_beg, end, value, func);
+ //sanity check, these cases should not call lower_bound (optimized out)
+ assert(ret != end);
+ assert(ret != begin);
+ return ret;
+ }
+ else{
+ return ret;
+ }
+ }
+ else{
+ return std::lower_bound(begin, end, value, func);
+ }
+ }
+
+ msg_header & insert_at(iterator where)
+ {
+ iterator inserted_ptr_end = this->inserted_ptr_end();
+ iterator inserted_ptr_beg = this->inserted_ptr_begin();
+ if(where == inserted_ptr_end){
+ ++m_cur_num_msg;
+ return **inserted_ptr_end;
+ }
+ else if(where == inserted_ptr_beg){
+ //unsigned integer guarantees underflow
+ m_cur_first_msg = m_cur_first_msg ? m_cur_first_msg : m_max_num_msg;
+ --m_cur_first_msg;
+ ++m_cur_num_msg;
+ return *mp_index[m_cur_first_msg];
+ }
+ else{
+ size_type pos = where - &mp_index[0];
+ size_type circ_pos = pos >= m_cur_first_msg ? pos - m_cur_first_msg : pos + (m_max_num_msg - m_cur_first_msg);
+ //Check if it's more efficient to move back or move front
+ if(circ_pos < m_cur_num_msg/2){
+ //The queue can't be full so m_cur_num_msg == 0 or m_cur_num_msg <= pos
+ //indicates two step insertion
+ if(!pos){
+ pos = m_max_num_msg;
+ where = &mp_index[m_max_num_msg-1];
+ }
+ else{
+ --where;
+ }
+ const bool unique_segment = m_cur_first_msg && m_cur_first_msg <= pos;
+ size_type first_segment_beg = unique_segment ? m_cur_first_msg : 1u;
+ size_type first_segment_end = pos;
+ size_type second_segment_beg = unique_segment || !m_cur_first_msg ? m_max_num_msg : m_cur_first_msg;
+ size_type second_segment_end = m_max_num_msg;
+ const msg_hdr_ptr_t backup = *(&mp_index[0] + (unique_segment ? first_segment_beg : second_segment_beg) - 1);
+
+ //First segment
+ if(!unique_segment){
+ std::copy( &mp_index[0] + second_segment_beg
+ , &mp_index[0] + second_segment_end
+ , &mp_index[0] + second_segment_beg - 1);
+ mp_index[m_max_num_msg-1] = mp_index[0];
+ }
+ std::copy( &mp_index[0] + first_segment_beg
+ , &mp_index[0] + first_segment_end
+ , &mp_index[0] + first_segment_beg - 1);
+ *where = backup;
+ m_cur_first_msg = m_cur_first_msg ? m_cur_first_msg : m_max_num_msg;
+ --m_cur_first_msg;
+ ++m_cur_num_msg;
+ return **where;
+ }
+ else{
+ //The queue can't be full so end_pos < m_cur_first_msg
+ //indicates two step insertion
+ const size_type end_pos = this->end_pos();
+ const bool unique_segment = pos < end_pos;
+ size_type first_segment_beg = pos;
+ size_type first_segment_end = unique_segment ? end_pos : m_max_num_msg-1;
+ size_type second_segment_beg = 0u;
+ size_type second_segment_end = unique_segment ? 0u : end_pos;
+ const msg_hdr_ptr_t backup = *inserted_ptr_end;
+
+ //First segment
+ if(!unique_segment){
+ std::copy_backward( &mp_index[0] + second_segment_beg
+ , &mp_index[0] + second_segment_end
+ , &mp_index[0] + second_segment_end + 1);
+ mp_index[0] = mp_index[m_max_num_msg-1];
+ }
+ std::copy_backward( &mp_index[0] + first_segment_beg
+ , &mp_index[0] + first_segment_end
+ , &mp_index[0] + first_segment_end + 1);
+ *where = backup;
+ ++m_cur_num_msg;
+ return **where;
+ }
+ }
+ }
+
+ #else
+
+ typedef msg_hdr_ptr_t *iterator;
+
+ //!Returns the inserted message with top priority
+ msg_header &top_msg()
+ { return *mp_index[m_cur_num_msg-1]; }
+
+ //!Returns the inserted message with bottom priority
+ msg_header &bottom_msg()
+ { return *mp_index[0]; }
+
+ iterator inserted_ptr_begin() const
+ { return &mp_index[0]; }
+
+ iterator inserted_ptr_end() const
+ { return &mp_index[m_cur_num_msg]; }
+
+ iterator lower_bound(const msg_hdr_ptr_t & value, priority_functor<VoidPointer> func)
+ { return std::lower_bound(this->inserted_ptr_begin(), this->inserted_ptr_end(), value, func); }
+
+ msg_header & insert_at(iterator pos)
+ {
+ const msg_hdr_ptr_t backup = *inserted_ptr_end();
+ std::copy_backward(pos, inserted_ptr_end(), inserted_ptr_end()+1);
+ *pos = backup;
+ ++m_cur_num_msg;
+ return **pos;
+ }
+
+ #endif
 
    //!Inserts the first free message in the priority queue
- void queue_free_msg()
- {
- //Get free msg
- msg_hdr_ptr_t free = mp_index[m_cur_num_msg];
+ msg_header & queue_free_msg(unsigned int priority)
+ {
       //Get priority queue's range
- msg_hdr_ptr_t *it = &mp_index[0], *it_end = &mp_index[m_cur_num_msg];
- //Check where the free message should be placed
- it = std::lower_bound(it, it_end, free, static_cast<priority_functor<VoidPointer>&>(*this));
- //Make room in that position
- std::copy_backward(it, it_end, it_end+1);
+ iterator it (inserted_ptr_begin()), it_end(inserted_ptr_end());
+ //Optimize for non-priority usage
+ if(m_cur_num_msg && priority > this->bottom_msg().priority){
+ //Check for higher priority than all stored messages
+ if(priority > this->top_msg().priority){
+ it = it_end;
+ }
+ else{
+ //Since we don't now which free message we will pick
+ //build a dummy header for searches
+ msg_header dummy_hdr;
+ dummy_hdr.priority = priority;
+
+ //Get free msg
+ msg_hdr_ptr_t dummy_ptr(&dummy_hdr);
+
+ //Check where the free message should be placed
+ it = this->lower_bound(dummy_ptr, static_cast<priority_functor<VoidPointer>&>(*this));
+ }
+
+ }
       //Insert the free message in the correct position
- *it = free;
- ++m_cur_num_msg;
+ return this->insert_at(it);
    }
 
    //!Returns the number of bytes needed to construct a message queue with
@@ -322,7 +512,7 @@
                  msg_hdr_align = ::boost::alignment_of<msg_header>::value,
                  index_align = ::boost::alignment_of<msg_hdr_ptr_t>::value,
          r_hdr_size = ipcdetail::ct_rounded_size<sizeof(mq_hdr_t), index_align>::value,
- r_index_size = ipcdetail::get_rounded_size(sizeof(msg_hdr_ptr_t)*max_num_msg, msg_hdr_align),
+ r_index_size = ipcdetail::get_rounded_size(max_num_msg*sizeof(msg_hdr_ptr_t), msg_hdr_align),
          r_max_msg_size = ipcdetail::get_rounded_size(max_msg_size, msg_hdr_align) + sizeof(msg_header);
       return r_hdr_size + r_index_size + (max_num_msg*r_max_msg_size) +
          ipcdetail::managed_open_or_create_impl<shared_memory_object>::ManagedOpenOrCreateUserOffset;
@@ -336,7 +526,7 @@
                   msg_hdr_align = ::boost::alignment_of<msg_header>::value,
                   index_align = ::boost::alignment_of<msg_hdr_ptr_t>::value,
          r_hdr_size = ipcdetail::ct_rounded_size<sizeof(mq_hdr_t), index_align>::value,
- r_index_size = ipcdetail::get_rounded_size(sizeof(msg_hdr_ptr_t)*m_max_num_msg, msg_hdr_align),
+ r_index_size = ipcdetail::get_rounded_size(m_max_num_msg*sizeof(msg_hdr_ptr_t), msg_hdr_align),
          r_max_msg_size = ipcdetail::get_rounded_size(m_max_msg_size, msg_hdr_align) + sizeof(msg_header);
 
       //Pointer to the index
@@ -345,7 +535,7 @@
 
       //Pointer to the first message header
       msg_header *msg_hdr = reinterpret_cast<msg_header*>
- (reinterpret_cast<char*>(this)+r_hdr_size+r_index_size);
+ (reinterpret_cast<char*>(this)+r_hdr_size+r_index_size);
 
       //Initialize the pointer to the index
       mp_index = index;
@@ -373,6 +563,10 @@
    interprocess_condition m_cond_recv;
    //Condition block senders when the queue is full
    interprocess_condition m_cond_send;
+ #if defined(BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX)
+ //Current start offset in the circular index
+ size_type m_cur_first_msg;
+ #endif
 };
 
 
@@ -403,7 +597,7 @@
             new (mptr) mq_hdr_t<VoidPointer>(m_maxmsg, m_maxmsgsize);
          }
          BOOST_CATCH(...){
- return false;
+ return false;
          }
          BOOST_CATCH_END
       }
@@ -433,7 +627,7 @@
       //Create shared memory and execute functor atomically
    : m_shmem(create_only,
               name,
- get_mem_size(max_msg_size, max_num_msg),
+ get_mem_size(max_msg_size, max_num_msg),
               read_write,
               static_cast<void*>(0),
               //Prepare initialization functor
@@ -503,13 +697,13 @@
       throw interprocess_exception(size_error);
    }
 
+ bool was_empty = false;
    //---------------------------------------------
    scoped_lock<interprocess_mutex> lock(p_hdr->m_mutex);
    //---------------------------------------------
    {
       //If the queue is full execute blocking logic
       if (p_hdr->is_full()) {
-
          switch(block){
             case non_blocking :
                return false;
@@ -536,30 +730,30 @@
             break;
          }
       }
-
- //Get the first free message from free message queue
- ipcdetail::msg_hdr_t<VoidPointer> *free_msg = p_hdr->free_msg();
- if (free_msg == 0) {
- throw interprocess_exception("boost::interprocess::message_queue corrupted");
- }
+
+ was_empty = p_hdr->is_empty();
+ //Insert the first free message in the priority queue
+ ipcdetail::msg_hdr_t<VoidPointer> &free_msg_hdr = p_hdr->queue_free_msg(priority);
+
+ //Sanity check, free msgs are always cleaned when received
+ assert(free_msg_hdr.priority == 0);
+ assert(free_msg_hdr.len == 0);
 
       //Copy control data to the free message
- free_msg->priority = priority;
- free_msg->len = buffer_size;
+ free_msg_hdr.priority = priority;
+ free_msg_hdr.len = buffer_size;
 
       //Copy user buffer to the message
- std::memcpy(free_msg->data(), buffer, buffer_size);
-
-// bool was_empty = p_hdr->is_empty();
- //Insert the first free message in the priority queue
- p_hdr->queue_free_msg();
-
- //If this message changes the queue empty state, notify it to receivers
-// if (was_empty){
- p_hdr->m_cond_recv.notify_one();
-// }
+ std::memcpy(free_msg_hdr.data(), buffer, buffer_size);
    } // Lock end
 
+ //Notify outside lock to avoid contention. This might produce some
+ //spurious wakeups, but it's usually far better than notifying inside.
+ //If this message changes the queue empty state, notify it to receivers
+ if (was_empty){
+ p_hdr->m_cond_recv.notify_one();
+ }
+
    return true;
 }
 
@@ -600,6 +794,7 @@
       throw interprocess_exception(size_error);
    }
 
+ bool was_full = false;
    //---------------------------------------------
    scoped_lock<interprocess_mutex> lock(p_hdr->m_mutex);
    //---------------------------------------------
@@ -635,51 +830,52 @@
          }
       }
 
- //Thre is at least message ready to pick, get the top one
- ipcdetail::msg_hdr_t<VoidPointer> *top_msg = p_hdr->top_msg();
-
- //Paranoia check
- if (top_msg == 0) {
- throw interprocess_exception("boost::interprocess::message_queue corrupted");
- }
+ //There is at least one message ready to pick, get the top one
+ ipcdetail::msg_hdr_t<VoidPointer> &top_msg = p_hdr->top_msg();
 
       //Get data from the message
- recvd_size = top_msg->len;
- priority = top_msg->priority;
+ recvd_size = top_msg.len;
+ priority = top_msg.priority;
+
+ //Some cleanup to ease debugging
+ top_msg.len = 0;
+ top_msg.priority = 0;
 
       //Copy data to receiver's bufers
- std::memcpy(buffer, top_msg->data(), recvd_size);
+ std::memcpy(buffer, top_msg.data(), recvd_size);
 
-// bool was_full = p_hdr->is_full();
+ was_full = p_hdr->is_full();
 
       //Free top message and put it in the free message list
       p_hdr->free_top_msg();
-
- //If this reception changes the queue full state, notify senders
-// if (was_full){
- p_hdr->m_cond_send.notify_one();
-// }
    } //Lock end
 
+ //Notify outside lock to avoid contention. This might produce some
+ //spurious wakeups, but it's usually far better than notifying inside.
+ //If this reception changes the queue full state, notify senders
+ if (was_full){
+ p_hdr->m_cond_send.notify_one();
+ }
+
    return true;
 }
 
 template<class VoidPointer>
 inline typename message_queue_t<VoidPointer>::size_type message_queue_t<VoidPointer>::get_max_msg() const
-{
+{
    ipcdetail::mq_hdr_t<VoidPointer> *p_hdr = static_cast<ipcdetail::mq_hdr_t<VoidPointer>*>(m_shmem.get_user_address());
    return p_hdr ? p_hdr->m_max_num_msg : 0; }
 
 template<class VoidPointer>
 inline typename message_queue_t<VoidPointer>::size_type message_queue_t<VoidPointer>::get_max_msg_size() const
-{
+{
    ipcdetail::mq_hdr_t<VoidPointer> *p_hdr = static_cast<ipcdetail::mq_hdr_t<VoidPointer>*>(m_shmem.get_user_address());
- return p_hdr ? p_hdr->m_max_msg_size : 0;
+ return p_hdr ? p_hdr->m_max_msg_size : 0;
 }
 
 template<class VoidPointer>
 inline typename message_queue_t<VoidPointer>::size_type message_queue_t<VoidPointer>::get_num_msg()
-{
+{
    ipcdetail::mq_hdr_t<VoidPointer> *p_hdr = static_cast<ipcdetail::mq_hdr_t<VoidPointer>*>(m_shmem.get_user_address());
    if(p_hdr){
       //---------------------------------------------
@@ -688,7 +884,7 @@
       return p_hdr->m_cur_num_msg;
    }
 
- return 0;
+ return 0;
 }
 
 template<class VoidPointer>

Modified: branches/release/boost/interprocess/managed_external_buffer.hpp
==============================================================================
--- branches/release/boost/interprocess/managed_external_buffer.hpp (original)
+++ branches/release/boost/interprocess/managed_external_buffer.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -23,7 +23,7 @@
 #include <boost/assert.hpp>
 //These includes needed to fulfill default template parameters of
 //predeclarations in interprocess_fwd.hpp
-#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
+#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
 #include <boost/interprocess/sync/mutex_family.hpp>
 #include <boost/interprocess/indexes/iset_index.hpp>
 
@@ -50,7 +50,7 @@
       <CharType, AllocationAlgorithm, IndexType> base_t;
    BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_managed_external_buffer)
    /// @endcond
-
+
    public:
    typedef typename base_t::size_type size_type;
 

Modified: branches/release/boost/interprocess/managed_heap_memory.hpp
==============================================================================
--- branches/release/boost/interprocess/managed_heap_memory.hpp (original)
+++ branches/release/boost/interprocess/managed_heap_memory.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -24,7 +24,7 @@
 #include <boost/detail/no_exceptions_support.hpp>
 //These includes needed to fulfill default template parameters of
 //predeclarations in interprocess_fwd.hpp
-#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
+#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
 #include <boost/interprocess/sync/mutex_family.hpp>
 #include <boost/interprocess/indexes/iset_index.hpp>
 
@@ -99,7 +99,7 @@
    //!have some extra bytes to allocate new objects. If returns
    //!false, the heap allocation has failed.
    bool grow(size_type extra_bytes)
- {
+ {
       //If memory is reallocated, data will
       //be automatically copied
       BOOST_TRY{
@@ -129,7 +129,7 @@
    private:
    //!Frees resources. Never throws.
    void priv_close()
- {
+ {
       base_t::destroy_impl();
       std::vector<char>().swap(m_heapmem);
    }

Modified: branches/release/boost/interprocess/managed_mapped_file.hpp
==============================================================================
--- branches/release/boost/interprocess/managed_mapped_file.hpp (original)
+++ branches/release/boost/interprocess/managed_mapped_file.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -26,7 +26,7 @@
 #include <boost/interprocess/permissions.hpp>
 //These includes needed to fulfill default template parameters of
 //predeclarations in interprocess_fwd.hpp
-#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
+#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
 #include <boost/interprocess/sync/mutex_family.hpp>
 #include <boost/interprocess/indexes/iset_index.hpp>
 
@@ -61,7 +61,7 @@
 
    private:
 
- typedef ipcdetail::create_open_func<base_t> create_open_func_t;
+ typedef ipcdetail::create_open_func<base_t> create_open_func_t;
    typedef ipcdetail::managed_open_or_create_impl< ipcdetail::file_wrapper
                                                  , AllocationAlgorithm::Alignment> managed_open_or_create_type;
 

Modified: branches/release/boost/interprocess/managed_shared_memory.hpp
==============================================================================
--- branches/release/boost/interprocess/managed_shared_memory.hpp (original)
+++ branches/release/boost/interprocess/managed_shared_memory.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -25,7 +25,7 @@
 #include <boost/interprocess/permissions.hpp>
 //These includes needed to fulfill default template parameters of
 //predeclarations in interprocess_fwd.hpp
-#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
+#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
 #include <boost/interprocess/sync/mutex_family.hpp>
 
 namespace boost {

Modified: branches/release/boost/interprocess/managed_windows_shared_memory.hpp
==============================================================================
--- branches/release/boost/interprocess/managed_windows_shared_memory.hpp (original)
+++ branches/release/boost/interprocess/managed_windows_shared_memory.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -25,7 +25,7 @@
 #include <boost/move/move.hpp>
 //These includes needed to fulfill default template parameters of
 //predeclarations in interprocess_fwd.hpp
-#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
+#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
 #include <boost/interprocess/sync/mutex_family.hpp>
 #include <boost/interprocess/indexes/iset_index.hpp>
 

Modified: branches/release/boost/interprocess/managed_xsi_shared_memory.hpp
==============================================================================
--- branches/release/boost/interprocess/managed_xsi_shared_memory.hpp (original)
+++ branches/release/boost/interprocess/managed_xsi_shared_memory.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //
@@ -28,7 +28,7 @@
 #include <boost/interprocess/creation_tags.hpp>
 //These includes needed to fulfill default template parameters of
 //predeclarations in interprocess_fwd.hpp
-#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
+#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
 #include <boost/interprocess/sync/mutex_family.hpp>
 #include <boost/interprocess/indexes/iset_index.hpp>
 

Modified: branches/release/boost/interprocess/mapped_region.hpp
==============================================================================
--- branches/release/boost/interprocess/mapped_region.hpp (original)
+++ branches/release/boost/interprocess/mapped_region.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -21,6 +21,18 @@
 #include <boost/interprocess/detail/os_file_functions.hpp>
 #include <string>
 #include <boost/cstdint.hpp>
+//Some Unixes use caddr_t instead of void * in madvise
+// SunOS Tru64 HP-UX AIX
+#if defined(sun) || defined(__sun) || defined(__osf__) || defined(__osf) || defined(_hpux) || defined(hpux) || defined(_AIX)
+#define BOOST_INTERPROCESS_MADVISE_USES_CADDR_T
+#include <sys/types.h>
+#endif
+
+//A lot of UNIXes have destructive semantics for MADV_DONTNEED, so
+//we need to be careful to allow it.
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
+#define BOOST_INTERPROCESS_MADV_DONTNEED_HAS_NONDESTRUCTIVE_SEMANTICS
+#endif
 
 #if defined (BOOST_INTERPROCESS_WINDOWS)
 # include <boost/interprocess/detail/win32_api.hpp>
@@ -49,6 +61,13 @@
 namespace interprocess {
 
 /// @cond
+
+//Solaris declares madvise only in some configurations but defines MADV_XXX, a bit confusing.
+//Predeclare it here to avoid any compilation error
+#if (defined(sun) || defined(__sun)) && defined(MADV_NORMAL)
+extern "C" int madvise(caddr_t, size_t, int);
+#endif
+
 namespace ipcdetail{ class interprocess_tester; }
 namespace ipcdetail{ class raw_mapped_region_creator; }
 
@@ -117,6 +136,10 @@
       return *this;
    }
 
+ //!Swaps the mapped_region with another
+ //!mapped region
+ void swap(mapped_region &other);
+
    //!Returns the size of the mapping. Never throws.
    std::size_t get_size() const;
 
@@ -135,9 +158,41 @@
    //!Never throws. Returns false if operation could not be performed.
    bool flush(std::size_t mapping_offset = 0, std::size_t numbytes = 0, bool async = true);
 
- //!Swaps the mapped_region with another
- //!mapped region
- void swap(mapped_region &other);
+ //!Shrinks current mapped region. If after shrinking there is no longer need for a previously
+ //!mapped memory page, accessing that page can trigger a segmentation fault.
+ //!Depending on the OS, this operation might fail (XSI shared memory), it can decommit storage
+ //!and free a portion of the virtual address space (e.g.POSIX) or this
+ //!function can release some physical memory wihout freeing any virtual address space(Windows).
+ //!Returns true on success. Never throws.
+ bool shrink_by(std::size_t bytes, bool from_back = true);
+
+ //!This enum specifies region usage behaviors that an application can specify
+ //!to the mapped region implementation.
+ enum advice_types{
+ //!Specifies that the application has no advice to give on its behavior with respect to
+ //!the region. It is the default characteristic if no advice is given for a range of memory.
+ advice_normal,
+ //!Specifies that the application expects to access the region sequentially from
+ //!lower addresses to higher addresses. The implementation can lower the priority of
+ //!preceding pages within the region once a page have been accessed.
+ advice_sequential,
+ //!Specifies that the application expects to access the region in a random order,
+ //!and prefetching is likely not advantageous.
+ advice_random,
+ //!Specifies that the application expects to access the region in the near future.
+ //!The implementation can prefetch pages of the region.
+ advice_willneed,
+ //!Specifies that the application expects that it will not access the region in the near future.
+ //!The implementation can unload pages within the range to save system resources.
+ advice_dontneed
+ };
+
+ //!Advises the implementation on the expected behavior of the application with respect to the data
+ //!in the region. The implementation may use this information to optimize handling of the region data.
+ //!This function has no effect on the semantics of access to memory in the region, although it may affect
+ //!the performance of access.
+ //!If the advise type is not known to the implementation, the function returns false. True otherwise.
+ bool advise(advice_types advise);
 
    //!Returns the size of the page. This size is the minimum memory that
    //!will be used by the system when mapping a memory mappable source and
@@ -152,6 +207,7 @@
    void* priv_map_address() const;
    std::size_t priv_map_size() const;
    bool priv_flush_param_check(std::size_t mapping_offset, void *&addr, std::size_t &numbytes) const;
+ bool priv_shrink_param_check(std::size_t bytes, bool from_back, void *&shrink_page_start, std::size_t &shrink_page_bytes);
    static void priv_size_from_mapping_size
       (offset_t mapping_size, offset_t offset, offset_t page_offset, std::size_t &size);
    static offset_t priv_page_offset_addr_fixup(offset_t page_offset, const void *&addr);
@@ -226,6 +282,38 @@
    return true;
 }
 
+inline bool mapped_region::priv_shrink_param_check
+ (std::size_t bytes, bool from_back, void *&shrink_page_start, std::size_t &shrink_page_bytes)
+{
+ //Check some errors
+ if(m_base == 0 || bytes > m_size){
+ return false;
+ }
+ else if(bytes == m_size){
+ this->priv_close();
+ return true;
+ }
+ else{
+ const std::size_t page_size = mapped_region::get_page_size();
+ if(from_back){
+ const std::size_t new_pages = (m_size + m_page_offset - bytes - 1)/page_size + 1;
+ shrink_page_start = static_cast<char*>(this->priv_map_address()) + new_pages*page_size;
+ shrink_page_bytes = m_page_offset + m_size - new_pages*page_size;
+ m_size -= bytes;
+ }
+ else{
+ shrink_page_start = this->priv_map_address();
+ m_page_offset += bytes;
+ shrink_page_bytes = (m_page_offset/page_size)*page_size;
+ m_page_offset = m_page_offset % page_size;
+ m_size -= bytes;
+ m_base = static_cast<char *>(m_base) + bytes;
+ assert(shrink_page_bytes%page_size == 0);
+ }
+ return true;
+ }
+}
+
 inline void mapped_region::priv_size_from_mapping_size
    (offset_t mapping_size, offset_t offset, offset_t page_offset, std::size_t &size)
 {
@@ -405,6 +493,37 @@
    return true;
 }
 
+inline bool mapped_region::shrink_by(std::size_t bytes, bool from_back)
+{
+ void *shrink_page_start;
+ std::size_t shrink_page_bytes;
+ if(!this->priv_shrink_param_check(bytes, from_back, shrink_page_start, shrink_page_bytes)){
+ return false;
+ }
+ else if(shrink_page_bytes){
+ //In Windows, we can't decommit the storage or release the virtual address space,
+ //the best we can do is try to remove some memory from the process working set.
+ //With a bit of luck we can free some physical memory.
+ unsigned long old_protect_ignored;
+ bool b_ret = winapi::virtual_unlock(shrink_page_start, shrink_page_bytes)
+ || (winapi::get_last_error() == winapi::error_not_locked);
+ (void)old_protect_ignored;
+ //Change page protection to forbid any further access
+ b_ret = b_ret && winapi::virtual_protect
+ (shrink_page_start, shrink_page_bytes, winapi::page_noaccess, old_protect_ignored);
+ return b_ret;
+ }
+ else{
+ return true;
+ }
+}
+
+inline bool mapped_region::advise(advice_types)
+{
+ //Windows has no madvise/posix_madvise equivalent
+ return false;
+}
+
 inline void mapped_region::priv_close()
 {
    if(m_base){
@@ -503,7 +622,13 @@
 
    //Create new mapping
    int prot = 0;
- int flags = 0;
+ int flags =
+ #ifdef MAP_NOSYNC
+ //Avoid excessive syncing in BSD systems
+ MAP_NOSYNC;
+ #else
+ 0;
+ #endif
 
    switch(mode)
    {
@@ -562,14 +687,107 @@
    }
 }
 
+inline bool mapped_region::shrink_by(std::size_t bytes, bool from_back)
+{
+ void *shrink_page_start = 0;
+ std::size_t shrink_page_bytes = 0;
+ if(m_is_xsi || !this->priv_shrink_param_check(bytes, from_back, shrink_page_start, shrink_page_bytes)){
+ return false;
+ }
+ else if(shrink_page_bytes){
+ //In UNIX we can decommit and free virtual address space.
+ return 0 == munmap(shrink_page_start, shrink_page_bytes);
+ }
+ else{
+ return true;
+ }
+}
+
 inline bool mapped_region::flush(std::size_t mapping_offset, std::size_t numbytes, bool async)
 {
    void *addr;
- if(!this->priv_flush_param_check(mapping_offset, addr, numbytes)){
+ if(m_is_xsi || !this->priv_flush_param_check(mapping_offset, addr, numbytes)){
       return false;
    }
    //Flush it all
- return msync( addr, numbytes, async ? MS_ASYNC : MS_SYNC) == 0;
+ return msync(addr, numbytes, async ? MS_ASYNC : MS_SYNC) == 0;
+}
+
+inline bool mapped_region::advise(advice_types advice)
+{
+ int unix_advice = 0;
+ //Modes; 0: none, 2: posix, 1: madvise
+ const unsigned int mode_none = 0;
+ const unsigned int mode_padv = 1;
+ const unsigned int mode_madv = 2;
+ unsigned int mode = mode_none;
+ //Choose advice either from POSIX (preferred) or native Unix
+ switch(advice){
+ case advice_normal:
+ #if defined(POSIX_MADV_NORMAL)
+ unix_advice = POSIX_MADV_NORMAL;
+ mode = mode_padv;
+ #elif defined(MADV_NORMAL)
+ unix_advice = MADV_NORMAL;
+ mode = mode_madv;
+ #endif
+ break;
+ case advice_sequential:
+ #if defined(POSIX_MADV_SEQUENTIAL)
+ unix_advice = POSIX_MADV_SEQUENTIAL;
+ mode = mode_padv;
+ #elif defined(MADV_SEQUENTIAL)
+ unix_advice = MADV_SEQUENTIAL;
+ mode = mode_madv;
+ #endif
+ break;
+ case advice_random:
+ #if defined(POSIX_MADV_RANDOM)
+ unix_advice = POSIX_MADV_RANDOM;
+ mode = mode_padv;
+ #elif defined(MADV_RANDOM)
+ unix_advice = MADV_RANDOM;
+ mode = mode_madv;
+ #endif
+ break;
+ case advice_willneed:
+ #if defined(POSIX_MADV_WILLNEED)
+ unix_advice = POSIX_MADV_WILLNEED;
+ mode = mode_padv;
+ #elif defined(MADV_WILLNEED)
+ unix_advice = MADV_WILLNEED;
+ mode = mode_madv;
+ #endif
+ break;
+ case advice_dontneed:
+ #if defined(POSIX_MADV_DONTNEED)
+ unix_advice = POSIX_MADV_DONTNEED;
+ mode = mode_padv;
+ #elif defined(MADV_DONTNEED) && defined(BOOST_INTERPROCESS_MADV_DONTNEED_HAS_NONDESTRUCTIVE_SEMANTICS)
+ unix_advice = MADV_DONTNEED;
+ mode = mode_madv;
+ #endif
+ break;
+ default:
+ return false;
+ }
+ switch(mode){
+ #if defined(POSIX_MADV_NORMAL)
+ case mode_padv:
+ return 0 == posix_madvise(this->priv_map_address(), this->priv_map_size(), unix_advice);
+ #endif
+ #if defined(MADV_NORMAL)
+ case mode_madv:
+ return 0 == madvise(
+ #if defined(BOOST_INTERPROCESS_MADVISE_USES_CADDR_T)
+ (caddr_t)
+ #endif
+ this->priv_map_address(), this->priv_map_size(), unix_advice);
+ #endif
+ default:
+ return false;
+
+ }
 }
 
 inline void mapped_region::priv_close()

Modified: branches/release/boost/interprocess/mem_algo/detail/mem_algo_common.hpp
==============================================================================
--- branches/release/boost/interprocess/mem_algo/detail/mem_algo_common.hpp (original)
+++ branches/release/boost/interprocess/mem_algo/detail/mem_algo_common.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -26,6 +26,7 @@
 #include <boost/interprocess/detail/utilities.hpp>
 #include <boost/move/move.hpp>
 #include <boost/interprocess/detail/min_max.hpp>
+#include <boost/container/detail/multiallocation_chain.hpp>
 #include <boost/assert.hpp>
 #include <boost/static_assert.hpp>
 #include <algorithm>
@@ -40,6 +41,37 @@
 namespace interprocess {
 namespace ipcdetail {
 
+template<class VoidPointer>
+class basic_multiallocation_chain
+ : public boost::container::container_detail::
+ basic_multiallocation_chain<VoidPointer>
+{
+ BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_multiallocation_chain)
+ typedef boost::container::container_detail::
+ basic_multiallocation_chain<VoidPointer> base_t;
+ public:
+
+ basic_multiallocation_chain()
+ : base_t()
+ {}
+
+ basic_multiallocation_chain(BOOST_RV_REF(basic_multiallocation_chain) other)
+ : base_t(::boost::move(static_cast<base_t&>(other)))
+ {}
+
+ basic_multiallocation_chain& operator=(BOOST_RV_REF(basic_multiallocation_chain) other)
+ {
+ this->base_t::operator=(::boost::move(static_cast<base_t&>(other)));
+ return *this;
+ }
+
+ void *pop_front()
+ {
+ return boost::interprocess::ipcdetail::to_raw_pointer(this->base_t::pop_front());
+ }
+};
+
+
 //!This class implements several allocation functions shared by different algorithms
 //!(aligned allocation, multiple allocation...).
 template<class MemoryAlgorithm>
@@ -199,7 +231,7 @@
    static void* allocate_aligned
       (MemoryAlgorithm *memory_algo, size_type nbytes, size_type alignment)
    {
-
+
       //Ensure power of 2
       if ((alignment & (alignment - size_type(1u))) != 0){
          //Alignment is not power of two
@@ -215,7 +247,7 @@
 
       if(nbytes > UsableByPreviousChunk)
          nbytes -= UsableByPreviousChunk;
-
+
       //We can find a aligned portion if we allocate a block that has alignment
       //nbytes + alignment bytes or more.
       size_type minimum_allocation = max_value
@@ -436,101 +468,108 @@
       }
       else{
          for(size_type i = 0; i < n_elements; ++i){
+ if(multiplication_overflows(elem_sizes[i], sizeof_element)){
+ total_request_units = 0;
+ break;
+ }
             elem_units = memory_algo->priv_get_total_units(elem_sizes[i]*sizeof_element);
             elem_units = ptr_size_units > elem_units ? ptr_size_units : elem_units;
+ if(sum_overflows(total_request_units, elem_units)){
+ total_request_units = 0;
+ break;
+ }
             total_request_units += elem_units;
          }
       }
 
       multiallocation_chain chain;
-
- size_type low_idx = 0;
- while(low_idx < n_elements){
- size_type total_bytes = total_request_units*Alignment - AllocatedCtrlBytes + UsableByPreviousChunk;
- size_type min_allocation = (!sizeof_element)
- ? elem_units
- : memory_algo->priv_get_total_units(elem_sizes[low_idx]*sizeof_element);
- min_allocation = min_allocation*Alignment - AllocatedCtrlBytes + UsableByPreviousChunk;
-
- size_type received_size;
- std::pair<void *, bool> ret = memory_algo->priv_allocate
- (boost::interprocess::allocate_new, min_allocation, total_bytes, received_size, 0);
- if(!ret.first){
- break;
- }
-
- block_ctrl *block = memory_algo->priv_get_block(ret.first);
- size_type received_units = (size_type)block->m_size;
- char *block_address = reinterpret_cast<char*>(block);
-
- size_type total_used_units = 0;
-// block_ctrl *prev_block = 0;
- while(total_used_units < received_units){
- if(sizeof_element){
- elem_units = memory_algo->priv_get_total_units(elem_sizes[low_idx]*sizeof_element);
- elem_units = ptr_size_units > elem_units ? ptr_size_units : elem_units;
- }
- if(total_used_units + elem_units > received_units)
+ if(total_request_units && !multiplication_overflows(total_request_units, Alignment)){
+ size_type low_idx = 0;
+ while(low_idx < n_elements){
+ size_type total_bytes = total_request_units*Alignment - AllocatedCtrlBytes + UsableByPreviousChunk;
+ size_type min_allocation = (!sizeof_element)
+ ? elem_units
+ : memory_algo->priv_get_total_units(elem_sizes[low_idx]*sizeof_element);
+ min_allocation = min_allocation*Alignment - AllocatedCtrlBytes + UsableByPreviousChunk;
+
+ size_type received_size;
+ std::pair<void *, bool> ret = memory_algo->priv_allocate
+ (boost::interprocess::allocate_new, min_allocation, total_bytes, received_size, 0);
+ if(!ret.first){
                break;
- total_request_units -= elem_units;
- //This is the position where the new block must be created
- block_ctrl *new_block = reinterpret_cast<block_ctrl *>(block_address);
- assert_alignment(new_block);
-
- //The last block should take all the remaining space
- if((low_idx + 1) == n_elements ||
- (total_used_units + elem_units +
- ((!sizeof_element)
- ? elem_units
- : std::max(memory_algo->priv_get_total_units(elem_sizes[low_idx+1]*sizeof_element), ptr_size_units))
- ) > received_units){
- //By default, the new block will use the rest of the buffer
- new_block->m_size = received_units - total_used_units;
- memory_algo->priv_mark_new_allocated_block(new_block);
-
- //If the remaining units are bigger than needed and we can
- //split it obtaining a new free memory block do it.
- if((received_units - total_used_units) >= (elem_units + MemoryAlgorithm::BlockCtrlUnits)){
- size_type shrunk_received;
- size_type shrunk_request = elem_units*Alignment - AllocatedCtrlBytes + UsableByPreviousChunk;
- bool shrink_ok = shrink
- (memory_algo
- ,memory_algo->priv_get_user_buffer(new_block)
- ,shrunk_request
- ,shrunk_request
- ,shrunk_received);
- (void)shrink_ok;
- //Shrink must always succeed with passed parameters
- BOOST_ASSERT(shrink_ok);
- //Some sanity checks
- BOOST_ASSERT(shrunk_request == shrunk_received);
- BOOST_ASSERT(elem_units == ((shrunk_request-UsableByPreviousChunk)/Alignment + AllocatedCtrlUnits));
- //"new_block->m_size" must have been reduced to elem_units by "shrink"
- BOOST_ASSERT(new_block->m_size == elem_units);
- //Now update the total received units with the reduction
- received_units = elem_units + total_used_units;
- }
             }
- else{
- new_block->m_size = elem_units;
- memory_algo->priv_mark_new_allocated_block(new_block);
+
+ block_ctrl *block = memory_algo->priv_get_block(ret.first);
+ size_type received_units = (size_type)block->m_size;
+ char *block_address = reinterpret_cast<char*>(block);
+
+ size_type total_used_units = 0;
+ while(total_used_units < received_units){
+ if(sizeof_element){
+ elem_units = memory_algo->priv_get_total_units(elem_sizes[low_idx]*sizeof_element);
+ elem_units = ptr_size_units > elem_units ? ptr_size_units : elem_units;
+ }
+ if(total_used_units + elem_units > received_units)
+ break;
+ total_request_units -= elem_units;
+ //This is the position where the new block must be created
+ block_ctrl *new_block = reinterpret_cast<block_ctrl *>(block_address);
+ assert_alignment(new_block);
+
+ //The last block should take all the remaining space
+ if((low_idx + 1) == n_elements ||
+ (total_used_units + elem_units +
+ ((!sizeof_element)
+ ? elem_units
+ : std::max(memory_algo->priv_get_total_units(elem_sizes[low_idx+1]*sizeof_element), ptr_size_units))
+ ) > received_units){
+ //By default, the new block will use the rest of the buffer
+ new_block->m_size = received_units - total_used_units;
+ memory_algo->priv_mark_new_allocated_block(new_block);
+
+ //If the remaining units are bigger than needed and we can
+ //split it obtaining a new free memory block do it.
+ if((received_units - total_used_units) >= (elem_units + MemoryAlgorithm::BlockCtrlUnits)){
+ size_type shrunk_received;
+ size_type shrunk_request = elem_units*Alignment - AllocatedCtrlBytes + UsableByPreviousChunk;
+ bool shrink_ok = shrink
+ (memory_algo
+ ,memory_algo->priv_get_user_buffer(new_block)
+ ,shrunk_request
+ ,shrunk_request
+ ,shrunk_received);
+ (void)shrink_ok;
+ //Shrink must always succeed with passed parameters
+ BOOST_ASSERT(shrink_ok);
+ //Some sanity checks
+ BOOST_ASSERT(shrunk_request == shrunk_received);
+ BOOST_ASSERT(elem_units == ((shrunk_request-UsableByPreviousChunk)/Alignment + AllocatedCtrlUnits));
+ //"new_block->m_size" must have been reduced to elem_units by "shrink"
+ BOOST_ASSERT(new_block->m_size == elem_units);
+ //Now update the total received units with the reduction
+ received_units = elem_units + total_used_units;
+ }
+ }
+ else{
+ new_block->m_size = elem_units;
+ memory_algo->priv_mark_new_allocated_block(new_block);
+ }
+
+ block_address += new_block->m_size*Alignment;
+ total_used_units += (size_type)new_block->m_size;
+ //Check we have enough room to overwrite the intrusive pointer
+ BOOST_ASSERT((new_block->m_size*Alignment - AllocatedCtrlUnits) >= sizeof(void_pointer));
+ void_pointer p = new(memory_algo->priv_get_user_buffer(new_block))void_pointer(0);
+ chain.push_back(p);
+ ++low_idx;
             }
+ //Sanity check
+ BOOST_ASSERT(total_used_units == received_units);
+ }
 
- block_address += new_block->m_size*Alignment;
- total_used_units += (size_type)new_block->m_size;
- //Check we have enough room to overwrite the intrusive pointer
- BOOST_ASSERT((new_block->m_size*Alignment - AllocatedCtrlUnits) >= sizeof(void_pointer));
- void_pointer p = new(memory_algo->priv_get_user_buffer(new_block))void_pointer(0);
- chain.push_back(p);
- ++low_idx;
- //prev_block = new_block;
+ if(low_idx != n_elements){
+ priv_deallocate_many(memory_algo, boost::move(chain));
          }
- //Sanity check
- BOOST_ASSERT(total_used_units == received_units);
- }
-
- if(low_idx != n_elements){
- priv_deallocate_many(memory_algo, boost::move(chain));
       }
       return boost::move(chain);
    }
@@ -538,9 +577,7 @@
    static void priv_deallocate_many(MemoryAlgorithm *memory_algo, multiallocation_chain chain)
    {
       while(!chain.empty()){
- void *addr = to_raw_pointer(chain.front());
- chain.pop_front();
- memory_algo->priv_deallocate(addr);
+ memory_algo->priv_deallocate(to_raw_pointer(chain.pop_front()));
       }
    }
 };

Modified: branches/release/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp
==============================================================================
--- branches/release/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp (original)
+++ branches/release/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -60,7 +60,7 @@
    simple_seq_fit_impl();
    simple_seq_fit_impl(const simple_seq_fit_impl &);
    simple_seq_fit_impl &operator=(const simple_seq_fit_impl &);
-
+
    typedef typename boost::intrusive::
       pointer_traits<VoidPointer>::template
          rebind_pointer<char>::type char_ptr;
@@ -96,7 +96,7 @@
       //!This block's memory size (including block_ctrl
       //!header) in BasicSize units
       size_type m_size;
-
+
       size_type get_user_bytes() const
       { return this->m_size*Alignment - BlockCtrlBytes; }
 
@@ -426,7 +426,7 @@
    (void)addr;
    BOOST_ASSERT(addr);
    BOOST_ASSERT(received_size == last_units*Alignment - AllocatedCtrlBytes);
-
+
    //Shrink it
    m_header.m_size /= Alignment;
    m_header.m_size -= last->m_size;
@@ -463,7 +463,7 @@
 
 template<class MutexFamily, class VoidPointer>
 inline void simple_seq_fit_impl<MutexFamily, VoidPointer>::priv_add_segment(void *addr, size_type size)
-{
+{
    algo_impl_t::assert_alignment(addr);
    //Check size
    BOOST_ASSERT(!(size < MinBlockSize));
@@ -523,7 +523,7 @@
 
    //Iterate through all free portions
    do{
- //Just clear user the memory part reserved for the user
+ //Just clear user the memory part reserved for the user
       std::memset( priv_get_user_buffer(block)
                  , 0
              , block->get_user_bytes());
@@ -583,7 +583,7 @@
 template<class MutexFamily, class VoidPointer>
 inline void* simple_seq_fit_impl<MutexFamily, VoidPointer>::
    allocate_aligned(size_type nbytes, size_type alignment)
-{
+{
    //-----------------------
    boost::interprocess::scoped_lock<interprocess_mutex> guard(m_header);
    //-----------------------
@@ -698,7 +698,7 @@
 
       size_type needs_backwards =
          ipcdetail::get_rounded_size(preferred_size - extra_forward, Alignment);
-
+
       if(!only_preferred_backwards){
             max_value(ipcdetail::get_rounded_size(min_size - extra_forward, Alignment)
                      ,min_value(prev->get_user_bytes(), needs_backwards));
@@ -710,7 +710,7 @@
          if(!priv_expand(reuse_ptr, received_size, received_size, received_size)){
             BOOST_ASSERT(0);
          }
-
+
          //We need a minimum size to split the previous one
          if((prev->get_user_bytes() - needs_backwards) > 2*BlockCtrlBytes){
              block_ctrl *new_block = reinterpret_cast<block_ctrl*>
@@ -750,9 +750,7 @@
    boost::interprocess::scoped_lock<interprocess_mutex> guard(m_header);
    //-----------------------
    while(!chain.empty()){
- void *addr = chain.front();
- chain.pop_front();
- this->priv_deallocate(addr);
+ this->priv_deallocate(to_raw_pointer(chain.pop_front()));
    }
 }
 
@@ -969,7 +967,7 @@
    //We can fill expand. Merge both blocks,
    block->m_next = next_block->m_next;
    block->m_size = merged_size;
-
+
    //Find the previous free block of next_block
    block_ctrl *prev = &m_header.m_root;
    while(ipcdetail::to_raw_pointer(prev->m_next) != next_block){
@@ -978,7 +976,7 @@
 
    //Now insert merged block in the free list
    //This allows reusing allocation logic in this function
- m_header.m_allocated -= old_block_size*Alignment;
+ m_header.m_allocated -= old_block_size*Alignment;
    prev->m_next = block;
 
    //Now use check and allocate to do the allocation logic
@@ -992,7 +990,7 @@
       BOOST_ASSERT(0);
       return false;
    }
- return true;
+ return true;
 }
 
 template<class MutexFamily, class VoidPointer> inline
@@ -1071,9 +1069,9 @@
 
    size_type total_size = Alignment*block->m_size;
    BOOST_ASSERT(m_header.m_allocated >= total_size);
-
+
    //Update used memory count
- m_header.m_allocated -= total_size;
+ m_header.m_allocated -= total_size;
 
    //Let's find the previous and the next block of the block to deallocate
    //This ordering comparison must be done with original pointers

Modified: branches/release/boost/interprocess/mem_algo/rbtree_best_fit.hpp
==============================================================================
--- branches/release/boost/interprocess/mem_algo/rbtree_best_fit.hpp (original)
+++ branches/release/boost/interprocess/mem_algo/rbtree_best_fit.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -88,8 +88,7 @@
    typedef MutexFamily mutex_family;
    //!Pointer type to be used with the rest of the Interprocess framework
    typedef VoidPointer void_pointer;
- typedef boost::container::container_detail::
- basic_multiallocation_chain<VoidPointer> multiallocation_chain;
+ typedef ipcdetail::basic_multiallocation_chain<VoidPointer> multiallocation_chain;
 
    typedef typename boost::intrusive::pointer_traits<char_ptr>::difference_type difference_type;
    typedef typename boost::make_unsigned<difference_type>::type size_type;
@@ -132,7 +131,7 @@
       { return size < block.m_size; }
 
       bool operator()(const block_ctrl &block, size_type size) const
- { return block.m_size < size; }
+ { return block.m_size < size; }
    };
 
    //!Shared mutex to protect memory allocate/deallocate
@@ -157,7 +156,7 @@
    } m_header;
 
    friend class ipcdetail::memory_algorithm_common<rbtree_best_fit>;
-
+
    typedef ipcdetail::memory_algorithm_common<rbtree_best_fit> algo_impl_t;
 
    public:
@@ -339,7 +338,7 @@
    void priv_add_segment(void *addr, size_type size);
 
    public:
-
+
    static const size_type Alignment = !MemAlignment
       ? size_type(::boost::alignment_of< ::boost::detail::max_align>::value)
       : size_type(MemAlignment)
@@ -386,7 +385,7 @@
 template<class MutexFamily, class VoidPointer, std::size_t MemAlignment>
 void rbtree_best_fit<MutexFamily, VoidPointer, MemAlignment>::
    priv_add_segment(void *addr, size_type size)
-{
+{
    //Check alignment
    algo_impl_t::check_alignment(addr);
    //Check size
@@ -570,7 +569,7 @@
 
    size_type shrunk_border_offset = (size_type)(reinterpret_cast<char*>(last_block) -
                                        reinterpret_cast<char*>(this)) + EndCtrlBlockBytes;
-
+
    block_ctrl *new_end_block = last_block;
    algo_impl_t::assert_alignment(new_end_block);
 
@@ -672,7 +671,7 @@
 template<class MutexFamily, class VoidPointer, std::size_t MemAlignment>
 inline void* rbtree_best_fit<MutexFamily, VoidPointer, MemAlignment>::
    allocate(size_type nbytes)
-{
+{
    //-----------------------
    boost::interprocess::scoped_lock<mutex_type> guard(m_header);
    //-----------------------
@@ -884,7 +883,7 @@
 
             received_size = needs_backwards_aligned + received_size;
             m_header.m_allocated += needs_backwards_aligned;
-
+
             //Check alignment
             algo_impl_t::assert_alignment(new_block);
 
@@ -1044,7 +1043,7 @@
    //The block must be marked as allocated and the sizes must be equal
    BOOST_ASSERT(priv_is_allocated_block(block));
    //BOOST_ASSERT(old_block_units == priv_tail_size(block));
-
+
    //Put this to a safe value
    received_size = (old_block_units - AllocatedCtrlUnits)*Alignment + UsableByPreviousChunk;
    if(received_size >= preferred_size || received_size >= min_size)
@@ -1298,7 +1297,7 @@
          m_header.m_imultiset.erase(it_old);
          m_header.m_imultiset.insert(m_header.m_imultiset.begin(), *rem_block);
       }
-
+
    }
    else if (block->m_size >= nunits){
       m_header.m_imultiset.erase(it_old);
@@ -1318,7 +1317,7 @@
    //Clear the memory occupied by the tree hook, since this won't be
    //cleared with zero_free_memory
    TreeHook *t = static_cast<TreeHook*>(block);
- //Just clear the memory part reserved for the user
+ //Just clear the memory part reserved for the user
    std::size_t tree_hook_offset_in_block = (char*)t - (char*)block;
    //volatile char *ptr =
    char *ptr = reinterpret_cast<char*>(block)+tree_hook_offset_in_block;
@@ -1344,7 +1343,7 @@
    if(!addr) return;
 
    block_ctrl *block = priv_get_block(addr);
-
+
    //The blocks must be marked as allocated and the sizes must be equal
    BOOST_ASSERT(priv_is_allocated_block(block));
 // BOOST_ASSERT(block->m_size == priv_tail_size(block));

Modified: branches/release/boost/interprocess/mem_algo/simple_seq_fit.hpp
==============================================================================
--- branches/release/boost/interprocess/mem_algo/simple_seq_fit.hpp (original)
+++ branches/release/boost/interprocess/mem_algo/simple_seq_fit.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/offset_ptr.hpp
==============================================================================
--- branches/release/boost/interprocess/offset_ptr.hpp (original)
+++ branches/release/boost/interprocess/offset_ptr.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -44,6 +44,175 @@
 
 namespace interprocess {
 
+/// @cond
+namespace ipcdetail {
+
+ template<class OffsetType, std::size_t OffsetAlignment>
+ union offset_ptr_internal
+ {
+ explicit offset_ptr_internal(OffsetType off)
+ : m_offset(off)
+ {}
+ OffsetType m_offset; //Distance between this object and pointee address
+ typename ::boost::aligned_storage
+ < sizeof(OffsetType)
+ , (OffsetAlignment == offset_type_alignment) ?
+ ::boost::alignment_of<OffsetType>::value : OffsetAlignment
+ >::type alignment_helper;
+ };
+
+ //Note: using the address of a local variable to point to another address
+ //is not standard conforming and this can be optimized-away by the compiler.
+ //Non-inlining is a method to remain illegal but correct
+
+ //Undef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_XXX if your compiler can inline
+ //this code without breaking the library
+
+ ////////////////////////////////////////////////////////////////////////
+ //
+ // offset_ptr_to_raw_pointer
+ //
+ ////////////////////////////////////////////////////////////////////////
+ #define BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR
+ #define BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR
+
+ template<int Dummy>
+ #ifndef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR
+ BOOST_INTERPROCESS_NEVER_INLINE
+ #elif defined(NDEBUG)
+ inline
+ #endif
+ void * offset_ptr_to_raw_pointer(const volatile void *this_ptr, std::size_t offset)
+ {
+ typedef pointer_size_t_caster<void*> caster_t;
+ #ifndef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR
+ if(offset == 1){
+ return 0;
+ }
+ else{
+ caster_t caster((void*)this_ptr);
+ return caster_t(caster.size() + offset).pointer();
+ }
+ #else
+ caster_t caster((void*)this_ptr);
+ return caster_t((caster.size() + offset) & -std::size_t(offset != 1)).pointer();
+ #endif
+ }
+
+ #ifdef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR
+ #undef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR
+ #endif
+ #ifdef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR
+ #undef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR
+ #endif
+
+ ////////////////////////////////////////////////////////////////////////
+ //
+ // offset_ptr_to_offset
+ //
+ ////////////////////////////////////////////////////////////////////////
+ #define BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF
+ //Branchless seems slower in x86
+ //#define BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF
+
+ template<int Dummy>
+ #ifndef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF
+ BOOST_INTERPROCESS_NEVER_INLINE
+ #elif defined(NDEBUG)
+ inline
+ #endif
+ std::size_t offset_ptr_to_offset(const volatile void *ptr, const volatile void *this_ptr)
+ {
+ typedef pointer_size_t_caster<void*> caster_t;
+ #ifndef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF
+ //offset == 1 && ptr != 0 is not legal for this pointer
+ if(!ptr){
+ return 1;
+ }
+ else{
+ caster_t this_caster((void*)this_ptr);
+ caster_t ptr_caster((void*)ptr);
+ std::size_t offset = ptr_caster.size() - this_caster.size();
+ BOOST_ASSERT(offset != 1);
+ return offset;
+ }
+ #else
+ caster_t this_caster((void*)this_ptr);
+ caster_t ptr_caster((void*)ptr);
+ std::size_t offset = (ptr_caster.size() - this_caster.size() - 1) & -std::size_t(ptr != 0);
+ ++offset;
+ return offset;
+ #endif
+ }
+
+ #ifdef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF
+ #undef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF
+ #endif
+ #ifdef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF
+ #undef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF
+ #endif
+
+ ////////////////////////////////////////////////////////////////////////
+ //
+ // offset_ptr_to_offset_from_other
+ //
+ ////////////////////////////////////////////////////////////////////////
+ #define BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER
+ //Branchless seems slower in x86
+ //#define BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF_FROM_OTHER
+
+ template<int Dummy>
+ #ifndef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER
+ BOOST_INTERPROCESS_NEVER_INLINE
+ #elif defined(NDEBUG)
+ inline
+ #endif
+ std::size_t offset_ptr_to_offset_from_other
+ (const volatile void *this_ptr, const volatile void *other_ptr, std::size_t other_offset)
+ {
+ typedef pointer_size_t_caster<void*> caster_t;
+ #ifndef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF_FROM_OTHER
+ if(other_offset == 1){
+ return 1;
+ }
+ else{
+ caster_t this_caster((void*)this_ptr);
+ caster_t other_caster((void*)other_ptr);
+ std::size_t offset = other_caster.size() - this_caster.size() + other_offset;
+ BOOST_ASSERT(offset != 1);
+ return offset;
+ }
+ #else
+ caster_t this_caster((void*)this_ptr);
+ caster_t other_caster((void*)other_ptr);
+ std::size_t offset = (other_caster.size() - this_caster.size()) & -std::size_t(other_offset != 1);
+ offset += other_offset;
+ return offset;
+ #endif
+ }
+
+ #ifdef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER
+ #undef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER
+ #endif
+ #ifdef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF_FROM_OTHER
+ #undef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF_FROM_OTHER
+ #endif
+
+ ////////////////////////////////////////////////////////////////////////
+ //
+ // Let's assume cast to void and cv cast don't change any target address
+ //
+ ////////////////////////////////////////////////////////////////////////
+ template<class From, class To>
+ struct offset_ptr_maintains_address
+ {
+ static const bool value = ipcdetail::is_cv_same<From, To>::value
+ || ipcdetail::is_cv_same<void, To>::value;
+ };
+
+} //namespace ipcdetail {
+/// @endcond
+
 //!A smart pointer that stores the offset between between the pointer and the
 //!the object it points. This allows offset allows special properties, since
 //!the pointer is independent from the address address of the pointee, if the
@@ -74,69 +243,111 @@
 
    public: //Public Functions
 
+ //!Default constructor (null pointer).
+ //!Never throws.
+ offset_ptr()
+ : internal(1)
+ {}
+
    //!Constructor from raw pointer (allows "0" pointer conversion).
    //!Never throws.
- offset_ptr(pointer ptr = 0) { this->set_offset(ptr); }
+ offset_ptr(pointer ptr)
+ : internal(static_cast<OffsetType>(ipcdetail::offset_ptr_to_offset<0>(ptr, this)))
+ {}
 
    //!Constructor from other pointer.
    //!Never throws.
    template <class T>
    offset_ptr( T *ptr
              , typename ipcdetail::enable_if< ipcdetail::is_convertible<T*, PointedType*> >::type * = 0)
- { this->set_offset(static_cast<PointedType*>(ptr)); }
+ : internal(static_cast<OffsetType>
+ (ipcdetail::offset_ptr_to_offset<0>(static_cast<PointedType*>(ptr), this)))
+ {}
 
    //!Constructor from other offset_ptr
    //!Never throws.
    offset_ptr(const offset_ptr& ptr)
- { this->set_offset(ptr.get()); }
+ : internal(static_cast<OffsetType>
+ (ipcdetail::offset_ptr_to_offset_from_other<0>(this, &ptr, ptr.internal.m_offset)))
+ {}
 
    //!Constructor from other offset_ptr. If pointers of pointee types are
    //!convertible, offset_ptrs will be convertibles. Never throws.
- template<class T2, class P2, class O2, std::size_t A2>
- offset_ptr( const offset_ptr<T2, P2, O2, A2> &ptr
- , typename ipcdetail::enable_if< ipcdetail::is_convertible<T2*, PointedType*> >::type * = 0)
- { this->set_offset(static_cast<PointedType*>(ptr.get())); }
+ template<class T2>
+ offset_ptr( const offset_ptr<T2, DifferenceType, OffsetType, OffsetAlignment> &ptr
+ #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
+ , typename ipcdetail::enable_if_c< ipcdetail::is_convertible<T2*, PointedType*>::value
+ && ipcdetail::offset_ptr_maintains_address<T2, PointedType>::value
+ >::type * = 0
+ #endif
+ )
+ : internal(static_cast<OffsetType>
+ (ipcdetail::offset_ptr_to_offset_from_other<0>(this, &ptr, ptr.get_offset())))
+ {}
+
+ #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
+
+ //!Constructor from other offset_ptr. If pointers of pointee types are
+ //!convertible, offset_ptrs will be convertibles. Never throws.
+ template<class T2>
+ offset_ptr( const offset_ptr<T2, DifferenceType, OffsetType, OffsetAlignment> &ptr
+ , typename ipcdetail::enable_if_c< ipcdetail::is_convertible<T2*, PointedType*>::value
+ && !ipcdetail::offset_ptr_maintains_address<T2, PointedType>::value
+ >::type * = 0)
+ : internal(static_cast<OffsetType>
+ (ipcdetail::offset_ptr_to_offset<0>(static_cast<PointedType*>(ptr.get()), this)))
+ {}
+
+ #endif
 
    //!Emulates static_cast operator.
    //!Never throws.
    template<class T2, class P2, class O2, std::size_t A2>
    offset_ptr(const offset_ptr<T2, P2, O2, A2> & r, ipcdetail::static_cast_tag)
- { this->set_offset(static_cast<PointedType*>(r.get())); }
+ : internal(static_cast<OffsetType>
+ (ipcdetail::offset_ptr_to_offset<0>(static_cast<PointedType*>(r.get()), this)))
+ {}
 
    //!Emulates const_cast operator.
    //!Never throws.
    template<class T2, class P2, class O2, std::size_t A2>
    offset_ptr(const offset_ptr<T2, P2, O2, A2> & r, ipcdetail::const_cast_tag)
- { this->set_offset(const_cast<PointedType*>(r.get())); }
+ : internal(static_cast<OffsetType>
+ (ipcdetail::offset_ptr_to_offset<0>(const_cast<PointedType*>(r.get()), this)))
+ {}
 
    //!Emulates dynamic_cast operator.
    //!Never throws.
    template<class T2, class P2, class O2, std::size_t A2>
    offset_ptr(const offset_ptr<T2, P2, O2, A2> & r, ipcdetail::dynamic_cast_tag)
- { this->set_offset(dynamic_cast<PointedType*>(r.get())); }
+ : internal(static_cast<OffsetType>
+ (ipcdetail::offset_ptr_to_offset<0>(dynamic_cast<PointedType*>(r.get()), this)))
+ {}
 
    //!Emulates reinterpret_cast operator.
    //!Never throws.
    template<class T2, class P2, class O2, std::size_t A2>
    offset_ptr(const offset_ptr<T2, P2, O2, A2> & r, ipcdetail::reinterpret_cast_tag)
- { this->set_offset(reinterpret_cast<PointedType*>(r.get())); }
+ : internal(static_cast<OffsetType>
+ (ipcdetail::offset_ptr_to_offset<0>(reinterpret_cast<PointedType*>(r.get()), this)))
+ {}
 
    //!Obtains raw pointer from offset.
    //!Never throws.
- pointer get()const
- { return this->to_raw_pointer(); }
+ pointer get() const
+ { return (pointer)ipcdetail::offset_ptr_to_raw_pointer<0>(this, this->internal.m_offset); }
 
    offset_type get_offset() const
- { return internal.m_offset; }
+ { return this->internal.m_offset; }
 
    //!Pointer-like -> operator. It can return 0 pointer.
    //!Never throws.
- pointer operator->() const
+ pointer operator->() const
    { return this->get(); }
 
    //!Dereferencing operator, if it is a null offset_ptr behavior
    //! is undefined. Never throws.
- reference operator* () const
+ reference operator* () const
    {
       pointer p = this->get();
       reference r = *p;
@@ -145,26 +356,56 @@
 
    //!Indexing operator.
    //!Never throws.
- template<class T>
- reference operator[](T idx) const
+ reference operator[](difference_type idx) const
    { return this->get()[idx]; }
 
    //!Assignment from pointer (saves extra conversion).
    //!Never throws.
    offset_ptr& operator= (pointer from)
- { this->set_offset(from); return *this; }
+ {
+ this->internal.m_offset =
+ static_cast<OffsetType>(ipcdetail::offset_ptr_to_offset<0>(from, this));
+ return *this;
+ }
 
    //!Assignment from other offset_ptr.
    //!Never throws.
- offset_ptr& operator= (const offset_ptr & pt)
- { pointer p(pt.get()); (void)p; this->set_offset(p); return *this; }
+ offset_ptr& operator= (const offset_ptr & ptr)
+ {
+ this->internal.m_offset =
+ static_cast<OffsetType>(ipcdetail::offset_ptr_to_offset_from_other<0>(this, &ptr, ptr.internal.m_offset));
+ return *this;
+ }
 
    //!Assignment from related offset_ptr. If pointers of pointee types
    //! are assignable, offset_ptrs will be assignable. Never throws.
- template<class T2, class P2, class O2, std::size_t A2>
- typename ipcdetail::enable_if<ipcdetail::is_convertible<T2*, PointedType*>, offset_ptr&>::type
- operator= (const offset_ptr<T2, P2, O2, A2> & ptr)
- { this->set_offset(static_cast<PointedType*>(ptr.get())); return *this; }
+ template<class T2>
+ #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
+ typename ipcdetail::enable_if_c< ipcdetail::is_convertible<T2*, PointedType*>::value
+ && ipcdetail::offset_ptr_maintains_address<T2, PointedType>::value
+ , offset_ptr&>::type
+ #else
+ offset_ptr&
+ #endif
+ operator= (const offset_ptr<T2, DifferenceType, OffsetType, OffsetAlignment> &ptr)
+ {
+ this->internal.m_offset =
+ static_cast<OffsetType>(ipcdetail::offset_ptr_to_offset_from_other<0>(this, &ptr, ptr.get_offset()));
+ return *this;
+ }
+
+ #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
+ template<class T2>
+ typename ipcdetail::enable_if_c<ipcdetail::is_convertible<T2*, PointedType*>::value
+ && !ipcdetail::offset_ptr_maintains_address<T2, PointedType>::value
+ , offset_ptr&>::type
+ operator= (const offset_ptr<T2, DifferenceType, OffsetType, OffsetAlignment> &ptr)
+ {
+ this->internal.m_offset =
+ static_cast<OffsetType>(ipcdetail::offset_ptr_to_offset<0>(static_cast<PointedType*>(ptr.get()), this));
+ return *this;
+ }
+ #endif
 
    //!offset_ptr += difference_type.
    //!Never throws.
@@ -173,8 +414,7 @@
 
    //!offset_ptr -= difference_type.
    //!Never throws.
- template<class T>
- offset_ptr &operator-= (T offset)
+ offset_ptr &operator-= (difference_type offset)
    { this->dec_offset(offset * sizeof (PointedType)); return *this; }
 
    //!++offset_ptr.
@@ -185,7 +425,11 @@
    //!offset_ptr++.
    //!Never throws.
    offset_ptr operator++ (int)
- { offset_ptr temp(*this); ++*this; return temp; }
+ {
+ offset_ptr tmp(*this);
+ this->inc_offset(sizeof (PointedType));
+ return tmp;
+ }
 
    //!--offset_ptr.
    //!Never throws.
@@ -195,17 +439,21 @@
    //!offset_ptr--.
    //!Never throws.
    offset_ptr operator-- (int)
- { offset_ptr temp(*this); --*this; return temp; }
+ {
+ offset_ptr tmp(*this);
+ this->dec_offset(sizeof (PointedType));
+ return tmp;
+ }
 
    //!safe bool conversion operator.
    //!Never throws.
- operator unspecified_bool_type() const
- { return this->get()? &self_t::unspecified_bool_type_func : 0; }
+ operator unspecified_bool_type() const
+ { return this->internal.m_offset != 1? &self_t::unspecified_bool_type_func : 0; }
 
    //!Not operator. Not needed in theory, but improves portability.
    //!Never throws
    bool operator! () const
- { return this->get() == 0; }
+ { return this->internal.m_offset == 1; }
 
    //!Compatibility with pointer_traits
    //!
@@ -220,23 +468,23 @@
 
    //!difference_type + offset_ptr
    //!operation
- friend offset_ptr operator+(difference_type diff, const offset_ptr& right)
- { offset_ptr tmp(right); tmp += diff; return tmp; }
+ friend offset_ptr operator+(difference_type diff, offset_ptr right)
+ { right += diff; return right; }
 
    //!offset_ptr + difference_type
    //!operation
- friend offset_ptr operator+(const offset_ptr& left, difference_type diff)
- { offset_ptr tmp(left); tmp += diff; return tmp; }
+ friend offset_ptr operator+(offset_ptr left, difference_type diff)
+ { left += diff; return left; }
 
    //!offset_ptr - diff
    //!operation
- friend offset_ptr operator-(const offset_ptr &left, difference_type diff)
- { offset_ptr tmp(left); tmp -= diff; return tmp; }
+ friend offset_ptr operator-(offset_ptr left, difference_type diff)
+ { left -= diff; return left; }
 
    //!offset_ptr - diff
    //!operation
- friend offset_ptr operator-(difference_type diff, const offset_ptr &right)
- { offset_ptr tmp(right); tmp -= diff; return tmp; }
+ friend offset_ptr operator-(difference_type diff, offset_ptr right)
+ { right -= diff; return right; }
 
    //!offset_ptr - offset_ptr
    //!operation
@@ -309,63 +557,13 @@
 
    private:
    /// @cond
-
- //Note: using the address of a local variable to point to another address
- //is not standard conforming and this can be optimized-away by the compiler.
- //Non-inlining is a method to remain illegal and correct
- #if defined(_MSC_VER)
- __declspec(noinline) //this workaround is needed for MSVC compilers
- #elif defined (__GNUC__)//this workaround is needed for GCC
- __attribute__((__noinline__))
- #endif
- void set_offset(const PointedType *ptr)
- {
- #if defined (__GNUC__)
- //asm(""); //Prevents the function to be optimized-away (provokes an special "side-effect")
- #endif
- //offset == 1 && ptr != 0 is not legal for this pointer
- if(!ptr){
- internal.m_offset = 1;
- }
- else{
- internal.m_offset = (OffsetType)((const char*)ptr - (const char*)(this));
- BOOST_ASSERT(internal.m_offset != 1);
- }
- }
-
- #if defined(_MSC_VER) && (_MSC_VER >= 1400)
- __declspec(noinline)
- #elif defined (__GNUC__)
- __attribute__((__noinline__))
- #endif
- PointedType * to_raw_pointer() const
- {
- #if defined (__GNUC__)
- //asm(""); //Prevents the function to be optimized-away (provokes an special "side-effect")
- #endif
- return static_cast<PointedType *>(
- static_cast<void*>(
- (internal.m_offset == 1) ?
- 0 :
- (const_cast<char*>(reinterpret_cast<const char*>(this)) + internal.m_offset)
- )
- );
- }
-
    void inc_offset(DifferenceType bytes)
    { internal.m_offset += bytes; }
 
    void dec_offset(DifferenceType bytes)
    { internal.m_offset -= bytes; }
 
- union internal_type{
- OffsetType m_offset; //Distance between this object and pointee address
- typename ::boost::aligned_storage
- < sizeof(OffsetType)
- , (OffsetAlignment == offset_type_alignment) ?
- ::boost::alignment_of<OffsetType>::value : OffsetAlignment
- >::type alignment_helper;
- } internal;
+ ipcdetail::offset_ptr_internal<OffsetType, OffsetAlignment> internal;
    /// @endcond
 };
 
@@ -387,36 +585,36 @@
 template<class T1, class P1, class O1, std::size_t A1, class T2, class P2, class O2, std::size_t A2>
 inline boost::interprocess::offset_ptr<T1, P1, O1, A1>
    static_pointer_cast(const boost::interprocess::offset_ptr<T2, P2, O2, A2> & r)
-{
+{
    return boost::interprocess::offset_ptr<T1, P1, O1, A1>
- (r, boost::interprocess::ipcdetail::static_cast_tag());
+ (r, boost::interprocess::ipcdetail::static_cast_tag());
 }
 
 //!Simulation of const_cast between pointers. Never throws.
 template<class T1, class P1, class O1, std::size_t A1, class T2, class P2, class O2, std::size_t A2>
 inline boost::interprocess::offset_ptr<T1, P1, O1, A1>
    const_pointer_cast(const boost::interprocess::offset_ptr<T2, P2, O2, A2> & r)
-{
+{
    return boost::interprocess::offset_ptr<T1, P1, O1, A1>
- (r, boost::interprocess::ipcdetail::const_cast_tag());
+ (r, boost::interprocess::ipcdetail::const_cast_tag());
 }
 
 //!Simulation of dynamic_cast between pointers. Never throws.
 template<class T1, class P1, class O1, std::size_t A1, class T2, class P2, class O2, std::size_t A2>
 inline boost::interprocess::offset_ptr<T1, P1, O1, A1>
    dynamic_pointer_cast(const boost::interprocess::offset_ptr<T2, P2, O2, A2> & r)
-{
+{
    return boost::interprocess::offset_ptr<T1, P1, O1, A1>
- (r, boost::interprocess::ipcdetail::dynamic_cast_tag());
+ (r, boost::interprocess::ipcdetail::dynamic_cast_tag());
 }
 
 //!Simulation of reinterpret_cast between pointers. Never throws.
 template<class T1, class P1, class O1, std::size_t A1, class T2, class P2, class O2, std::size_t A2>
 inline boost::interprocess::offset_ptr<T1, P1, O1, A1>
    reinterpret_pointer_cast(const boost::interprocess::offset_ptr<T2, P2, O2, A2> & r)
-{
+{
    return boost::interprocess::offset_ptr<T1, P1, O1, A1>
- (r, boost::interprocess::ipcdetail::reinterpret_cast_tag());
+ (r, boost::interprocess::ipcdetail::reinterpret_cast_tag());
 }
 
 } //namespace interprocess {
@@ -437,17 +635,17 @@
    static const bool value = true;
 };
 
-//#if !defined(_MSC_VER) || (_MSC_VER >= 1400)
+
 namespace interprocess {
-//#endif
+
 //!to_raw_pointer() enables boost::mem_fn to recognize offset_ptr.
 //!Never throws.
 template <class T, class P, class O, std::size_t A>
 inline T * to_raw_pointer(boost::interprocess::offset_ptr<T, P, O, A> const & p)
-{ return p.get(); }
-//#if !defined(_MSC_VER) || (_MSC_VER >= 1400)
+{ return ipcdetail::to_raw_pointer(p); }
+
 } //namespace interprocess
-//#endif
+
 
 /// @endcond
 } //namespace boost {
@@ -479,28 +677,34 @@
 template<class T, class P, class O, std::size_t A, std::size_t NumBits>
 struct pointer_plus_bits<boost::interprocess::offset_ptr<T, P, O, A>, NumBits>
 {
- typedef boost::interprocess::offset_ptr<T, P, O, A> pointer;
+ typedef boost::interprocess::offset_ptr<T, P, O, A> pointer;
+ typedef ::boost::interprocess::pointer_size_t_caster<T*> caster_t;
    //Bits are stored in the lower bits of the pointer except the LSB,
    //because this bit is used to represent the null pointer.
- static const std::size_t Mask = ((std::size_t(1) << NumBits)-1)<<1u;
+ static const std::size_t Mask = ((std::size_t(1) << NumBits) - 1) << 1u;
 
    static pointer get_pointer(const pointer &n)
- { return reinterpret_cast<T*>(std::size_t(n.get()) & ~std::size_t(Mask)); }
+ {
+ caster_t caster(n.get());
+ return pointer(caster_t(caster.size() & ~Mask).pointer());
+ }
 
- static void set_pointer(pointer &n, pointer p)
+ static void set_pointer(pointer &n, const pointer &p)
    {
- std::size_t pint = std::size_t(p.get());
- BOOST_ASSERT(0 == (std::size_t(pint) & Mask));
- n = reinterpret_cast<T*>(pint | (std::size_t(n.get()) & std::size_t(Mask)));
+ caster_t n_caster(n.get());
+ caster_t p_caster(p.get());
+ BOOST_ASSERT(0 == (p_caster.size() & Mask));
+ n = caster_t(p_caster.size() | (n_caster.size() & Mask)).pointer();
    }
 
    static std::size_t get_bits(const pointer &n)
- { return(std::size_t(n.get()) & std::size_t(Mask)) >> 1u; }
+ { return (caster_t(n.get()).size() & Mask) >> 1u; }
 
    static void set_bits(pointer &n, std::size_t b)
    {
       BOOST_ASSERT(b < (std::size_t(1) << NumBits));
- n = reinterpret_cast<T*>(std::size_t(get_pointer(n).get()) | (b << 1u));
+ caster_t n_caster(n.get());
+ n = caster_t((n_caster.size() & ~Mask) | (b << 1u)).pointer();
    }
 };
 
@@ -510,8 +714,6 @@
 template<class T, class U>
 struct pointer_to_other;
 
-
-
 //Backwards compatibility with pointer_to_other
 template <class PointedType, class DifferenceType, class OffsetType, std::size_t OffsetAlignment, class U>
 struct pointer_to_other

Modified: branches/release/boost/interprocess/permissions.hpp
==============================================================================
--- branches/release/boost/interprocess/permissions.hpp (original)
+++ branches/release/boost/interprocess/permissions.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/segment_manager.hpp
==============================================================================
--- branches/release/boost/interprocess/segment_manager.hpp (original)
+++ branches/release/boost/interprocess/segment_manager.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -69,9 +69,9 @@
    typedef typename MemoryAlgorithm::void_pointer void_pointer;
    typedef typename MemoryAlgorithm::mutex_family mutex_family;
    typedef MemoryAlgorithm memory_algorithm;
-
+
    /// @cond
-
+
    //Experimental. Don't use
    typedef typename MemoryAlgorithm::multiallocation_chain multiallocation_chain;
    typedef typename MemoryAlgorithm::difference_type difference_type;
@@ -165,7 +165,7 @@
    //!Allocates nbytes bytes. Throws boost::interprocess::bad_alloc
    //!on failure
    void * allocate(size_type nbytes)
- {
+ {
       void * ret = MemoryAlgorithm::allocate(nbytes);
       if(!ret)
          throw bad_alloc();
@@ -180,7 +180,7 @@
    //!Allocates nbytes bytes. This function is only used in
    //!single-segment management. Throws bad_alloc when fails
    void * allocate_aligned(size_type nbytes, size_type alignment)
- {
+ {
       void * ret = MemoryAlgorithm::allocate_aligned(nbytes, alignment);
       if(!ret)
          throw bad_alloc();
@@ -293,7 +293,7 @@
    void prot_anonymous_destroy(const void *object, ipcdetail::in_place_interface &table)
    {
 
- //Get control data from associated with this object
+ //Get control data from associated with this object
       typedef ipcdetail::block_header<size_type> block_header_t;
       block_header_t *ctrl_data = block_header_t::block_header_from_value(object, table.size, table.alignment);
 
@@ -407,7 +407,7 @@
    //!"size" is the size of the memory segment where
    //!the segment manager is being constructed.
    //!Can throw
- segment_manager(size_type size)
+ explicit segment_manager(size_type size)
       : Base(size, priv_get_reserved_bytes())
       , m_header(static_cast<Base*>(get_this_pointer()))
    {
@@ -446,7 +446,7 @@
    //!Returns throwing "construct" proxy
    //!object
    template <class T>
- typename construct_proxy<T>::type
+ typename construct_proxy<T>::type
       construct(char_ptr_holder_t name)
    { return typename construct_proxy<T>::type (this, name, false, true); }
 
@@ -466,27 +466,27 @@
    //!Returns no throwing "search or construct"
    //!proxy object
    template <class T>
- typename construct_proxy<T>::type
+ typename construct_proxy<T>::type
       find_or_construct(char_ptr_holder_t name, std::nothrow_t)
    { return typename construct_proxy<T>::type (this, name, true, false); }
 
    //!Returns throwing "construct from iterators" proxy object
    template <class T>
- typename construct_iter_proxy<T>::type
+ typename construct_iter_proxy<T>::type
       construct_it(char_ptr_holder_t name)
    { return typename construct_iter_proxy<T>::type (this, name, false, true); }
 
    //!Returns throwing "search or construct from iterators"
    //!proxy object
    template <class T>
- typename construct_iter_proxy<T>::type
+ typename construct_iter_proxy<T>::type
       find_or_construct_it(char_ptr_holder_t name)
    { return typename construct_iter_proxy<T>::type (this, name, true, true); }
 
    //!Returns no throwing "construct from iterators"
    //!proxy object
    template <class T>
- typename construct_iter_proxy<T>::type
+ typename construct_iter_proxy<T>::type
       construct_it(char_ptr_holder_t name, std::nothrow_t)
    { return typename construct_iter_proxy<T>::type (this, name, false, false); }
 
@@ -575,18 +575,18 @@
    //!creation of "num" named objects in the managed memory segment.
    //!Can throw boost::interprocess::bad_alloc if there is no enough memory.
    void reserve_named_objects(size_type num)
- {
+ {
       //-------------------------------
       scoped_lock<rmutex> guard(m_header);
       //-------------------------------
- m_header.m_named_index.reserve(num);
+ m_header.m_named_index.reserve(num);
    }
 
    //!Preallocates needed index resources to optimize the
    //!creation of "num" unique objects in the managed memory segment.
    //!Can throw boost::interprocess::bad_alloc if there is no enough memory.
    void reserve_unique_objects(size_type num)
- {
+ {
       //-------------------------------
       scoped_lock<rmutex> guard(m_header);
       //-------------------------------
@@ -596,32 +596,32 @@
    //!Calls shrink_to_fit in both named and unique object indexes
    //!to try to free unused memory from those indexes.
    void shrink_to_fit_indexes()
- {
+ {
       //-------------------------------
       scoped_lock<rmutex> guard(m_header);
       //-------------------------------
- m_header.m_named_index.shrink_to_fit();
- m_header.m_unique_index.shrink_to_fit();
+ m_header.m_named_index.shrink_to_fit();
+ m_header.m_unique_index.shrink_to_fit();
    }
 
    //!Returns the number of named objects stored in
    //!the segment.
    size_type get_num_named_objects()
- {
+ {
       //-------------------------------
       scoped_lock<rmutex> guard(m_header);
       //-------------------------------
- return m_header.m_named_index.size();
+ return m_header.m_named_index.size();
    }
 
    //!Returns the number of unique objects stored in
    //!the segment.
    size_type get_num_unique_objects()
- {
+ {
       //-------------------------------
       scoped_lock<rmutex> guard(m_header);
       //-------------------------------
- return m_header.m_unique_index.size();
+ return m_header.m_unique_index.size();
    }
 
    //!Obtains the minimum size needed by the
@@ -713,7 +713,7 @@
    //!returned pair is 0.
    template <class T>
    std::pair<T*, size_type> priv_find_impl (const CharType* name, bool lock)
- {
+ {
       //The name can't be null, no anonymous object can be found by name
       BOOST_ASSERT(name != 0);
       ipcdetail::placement_destroy<T> table;
@@ -805,7 +805,7 @@
          return 0;
       }
       CharType *name = static_cast<CharType*>(ctrl_data->template name<CharType>());
-
+
       //Sanity checks
       BOOST_ASSERT(ctrl_data->sizeof_char() == sizeof(CharType));
       BOOST_ASSERT(ctrl_data->m_num_char == std::char_traits<CharType>::length(name));
@@ -951,7 +951,7 @@
       typedef ipcdetail::index_key<CharT, void_pointer> index_key_t;
       typedef typename index_type::iterator index_it;
       typedef typename index_type::value_type intrusive_value_type;
-
+
       //-------------------------------
       scoped_lock<rmutex> guard(m_header);
       //-------------------------------
@@ -972,7 +972,7 @@
       void *memory = iv;
       void *values = ctrl_data->value();
       std::size_t num = ctrl_data->m_value_bytes/table.size;
-
+
       //Sanity check
       BOOST_ASSERT((ctrl_data->m_value_bytes % table.size) == 0);
       BOOST_ASSERT(sizeof(CharT) == ctrl_data->sizeof_char());
@@ -1184,7 +1184,7 @@
       //the memory allocation as the intrusive value is built in that
       //memory
       value_eraser<index_type> v_eraser(index, it);
-
+
       //Construct array, this can throw
       ipcdetail::array_construct(ptr, num, table);
 
@@ -1197,7 +1197,7 @@
    //!Generic named new function for
    //!named functions
    template<class CharT>
- void * priv_generic_named_construct(unsigned char type,
+ void * priv_generic_named_construct(unsigned char type,
                                const CharT *name,
                         size_type num,
                                bool try2find,
@@ -1346,7 +1346,7 @@
    {
       named_index_t m_named_index;
       unique_index_t m_unique_index;
-
+
       header_t(Base *restricted_segment_mngr)
          : m_named_index (restricted_segment_mngr)
          , m_unique_index(restricted_segment_mngr)

Modified: branches/release/boost/interprocess/shared_memory_object.hpp
==============================================================================
--- branches/release/boost/interprocess/shared_memory_object.hpp (original)
+++ branches/release/boost/interprocess/shared_memory_object.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -87,10 +87,10 @@
    //!After the call, "moved" does not represent any shared memory.
    //!Does not throw
    shared_memory_object &operator=(BOOST_RV_REF(shared_memory_object) moved)
- {
+ {
       shared_memory_object tmp(boost::move(moved));
       this->swap(tmp);
- return *this;
+ return *this;
    }
 
    //!Swaps the shared_memory_objects. Does not throw
@@ -99,7 +99,7 @@
    //!Erases a shared memory object from the system.
    //!Returns false on error. Never throws
    static bool remove(const char *name);
-
+
    //!Sets the size of the shared memory mapping
    void truncate(offset_t length);
 
@@ -157,10 +157,10 @@
 { return ipcdetail::get_file_size((file_handle_t)m_handle, size); }
 
 inline void shared_memory_object::swap(shared_memory_object &other)
-{
+{
    std::swap(m_handle, other.m_handle);
    std::swap(m_mode, other.m_mode);
- m_filename.swap(other.m_filename);
+ m_filename.swap(other.m_filename);
 }
 
 inline mapping_handle_t shared_memory_object::get_mapping_handle() const

Modified: branches/release/boost/interprocess/smart_ptr/deleter.hpp
==============================================================================
--- branches/release/boost/interprocess/smart_ptr/deleter.hpp (original)
+++ branches/release/boost/interprocess/smart_ptr/deleter.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2011.
+// (C) Copyright Ion Gaztanaga 2007-2012.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/interprocess/smart_ptr/detail/shared_count.hpp
==============================================================================
--- branches/release/boost/interprocess/smart_ptr/detail/shared_count.hpp (original)
+++ branches/release/boost/interprocess/smart_ptr/detail/shared_count.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -4,7 +4,7 @@
 //
 // (C) Copyright Peter Dimov and Multi Media Ltd. 2001, 2002, 2003
 // (C) Copyright Peter Dimov 2004-2005
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -116,7 +116,7 @@
    }
 
    ~shared_count() // nothrow
- {
+ {
       if(m_pi)
          m_pi->release();
    }

Modified: branches/release/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp
==============================================================================
--- branches/release/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp (original)
+++ branches/release/boost/interprocess/smart_ptr/detail/sp_counted_base.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2011.
+// (C) Copyright Ion Gaztanaga 2007-2012.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp
==============================================================================
--- branches/release/boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp (original)
+++ branches/release/boost/interprocess/smart_ptr/detail/sp_counted_base_atomic.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -9,7 +9,7 @@
 
 // Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
 // Copyright 2004-2005 Peter Dimov
-// Copyright 2007-2011 Ion Gaztanaga
+// Copyright 2007-2012 Ion Gaztanaga
 //
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/interprocess/smart_ptr/enable_shared_from_this.hpp
==============================================================================
--- branches/release/boost/interprocess/smart_ptr/enable_shared_from_this.hpp (original)
+++ branches/release/boost/interprocess/smart_ptr/enable_shared_from_this.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -3,7 +3,7 @@
 // This file is the adaptation for Interprocess of boost/enable_shared_from_this.hpp
 //
 // (C) Copyright Peter Dimov 2002
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/boost/interprocess/smart_ptr/intrusive_ptr.hpp
==============================================================================
--- branches/release/boost/interprocess/smart_ptr/intrusive_ptr.hpp (original)
+++ branches/release/boost/interprocess/smart_ptr/intrusive_ptr.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -3,7 +3,7 @@
 // This file is the adaptation for Interprocess of boost/intrusive_ptr.hpp
 //
 // (C) Copyright Peter Dimov 2001, 2002
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -125,7 +125,7 @@
       this_type(rhs).swap(*this);
       return *this;
    }
-
+
    //!Returns a reference to the internal pointer.
    //!Does not throw
    pointer &get()
@@ -219,9 +219,9 @@
 template<class T, class VP> inline
 bool operator<(intrusive_ptr<T, VP> const & a,
                intrusive_ptr<T, VP> const & b)
-{
+{
    return std::less<typename intrusive_ptr<T, VP>::pointer>()
- (a.get(), b.get());
+ (a.get(), b.get());
 }
 
 //!Exchanges the contents of the two intrusive_ptrs.

Modified: branches/release/boost/interprocess/smart_ptr/scoped_ptr.hpp
==============================================================================
--- branches/release/boost/interprocess/smart_ptr/scoped_ptr.hpp (original)
+++ branches/release/boost/interprocess/smart_ptr/scoped_ptr.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -4,7 +4,7 @@
 //
 // (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
 // (C) Copyright Peter Dimov 2001, 2002
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/boost/interprocess/smart_ptr/shared_ptr.hpp
==============================================================================
--- branches/release/boost/interprocess/smart_ptr/shared_ptr.hpp (original)
+++ branches/release/boost/interprocess/smart_ptr/shared_ptr.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -4,7 +4,7 @@
 //
 // (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
 // (C) Copyright Peter Dimov 2001, 2002, 2003
-// (C) Copyright Ion Gaztanaga 2006-2011.
+// (C) Copyright Ion Gaztanaga 2006-2012.
 // 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)
@@ -52,7 +52,7 @@
   (shared_count<T, VoidAllocator, Deleter> const & pn
   ,enable_shared_from_this<T, VoidAllocator, Deleter> *pe
   ,T *ptr)
-
+
 {
    (void)ptr;
    if(pe != 0){
@@ -125,7 +125,7 @@
    //!Requirements: Deleter and A's copy constructor must not throw.
    explicit shared_ptr(const pointer&p, const VoidAllocator &a = VoidAllocator(), const Deleter &d = Deleter())
       : m_pn(p, a, d)
- {
+ {
       //Check that the pointer passed is of the same type that
       //the pointer the allocator defines or it's a raw pointer
       typedef typename boost::intrusive::
@@ -223,15 +223,15 @@
    //!This is equivalent to:
    //!this_type().swap(*this);
    void reset()
- {
- this_type().swap(*this);
+ {
+ this_type().swap(*this);
    }
 
    //!This is equivalent to:
    //!this_type(p, a, d).swap(*this);
    template<class Pointer>
    void reset(const Pointer &p, const VoidAllocator &a = VoidAllocator(), const Deleter &d = Deleter())
- {
+ {
       //Check that the pointer passed is of the same type that
       //the pointer the allocator defines or it's a raw pointer
       typedef typename boost::intrusive::
@@ -239,7 +239,7 @@
             rebind_pointer<T>::type ParameterPointer;
       BOOST_STATIC_ASSERT((ipcdetail::is_same<pointer, ParameterPointer>::value) ||
                           (ipcdetail::is_pointer<Pointer>::value));
- this_type(p, a, d).swap(*this);
+ this_type(p, a, d).swap(*this);
    }
 
    template<class Y>

Modified: branches/release/boost/interprocess/smart_ptr/unique_ptr.hpp
==============================================================================
--- branches/release/boost/interprocess/smart_ptr/unique_ptr.hpp (original)
+++ branches/release/boost/interprocess/smart_ptr/unique_ptr.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -5,7 +5,7 @@
 // This file is the adaptation for Interprocess of
 // Howard Hinnant's unique_ptr emulation code.
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -272,7 +272,7 @@
    //!Returns: A reference to the stored deleter.
    //!
    //!Throws: nothing.
- deleter_reference get_deleter()
+ deleter_reference get_deleter()
    { return ptr_.second(); }
 
    //!Returns: A const reference to the stored deleter.
@@ -328,7 +328,7 @@
    BOOST_MOVABLE_BUT_NOT_COPYABLE(unique_ptr)
    template <class U, class E> unique_ptr(unique_ptr<U, E>&);
    template <class U> unique_ptr(U&, typename ipcdetail::unique_ptr_error<U>::type = 0);
-
+
    template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&);
    template <class U> typename ipcdetail::unique_ptr_error<U>::type operator=(U&);
    /// @endcond

Modified: branches/release/boost/interprocess/smart_ptr/weak_ptr.hpp
==============================================================================
--- branches/release/boost/interprocess/smart_ptr/weak_ptr.hpp (original)
+++ branches/release/boost/interprocess/smart_ptr/weak_ptr.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -3,7 +3,7 @@
 // This file is the adaptation for Interprocess of boost/weak_ptr.hpp
 //
 // (C) Copyright Peter Dimov 2001, 2002, 2003
-// (C) Copyright Ion Gaztanaga 2006-2011.
+// (C) Copyright Ion Gaztanaga 2006-2012.
 // 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)
@@ -99,7 +99,7 @@
    template<class Y>
    weak_ptr(weak_ptr<Y, A, D> const & r)
       : m_pn(r.m_pn) // never throws
- {
+ {
       //Construct a temporary shared_ptr so that nobody
       //can destroy the value while constructing this
       const shared_ptr<T, A, D> &ref = r.lock();
@@ -126,7 +126,7 @@
    //!implied guarantees) via different means, without creating a temporary.
    template<class Y>
    weak_ptr & operator=(weak_ptr<Y, A, D> const & r) // never throws
- {
+ {
       //Construct a temporary shared_ptr so that nobody
       //can destroy the value while constructing this
       const shared_ptr<T, A, D> &ref = r.lock();
@@ -174,7 +174,7 @@
    //!testing purposes, not for production code.
    long use_count() const // never throws
    { return m_pn.use_count(); }
-
+
    //!Returns: Returns: use_count() == 0.
    //!
    //!Throws: nothing.
@@ -199,7 +199,7 @@
    template<class T2, class A2, class D2>
    bool _internal_less(weak_ptr<T2, A2, D2> const & rhs) const
    { return m_pn < rhs.m_pn; }
-
+
    template<class Y>
    void _internal_assign(const ipcdetail::shared_count<Y, A, D> & pn2)
    {

Modified: branches/release/boost/interprocess/streams/bufferstream.hpp
==============================================================================
--- branches/release/boost/interprocess/streams/bufferstream.hpp (original)
+++ branches/release/boost/interprocess/streams/bufferstream.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -8,7 +8,7 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 //
-// This file comes from SGI's sstream file. Modified by Ion Gaztanaga 2005.
+// This file comes from SGI's sstream file. Modified by Ion Gaztanaga 2005-2012.
 // Changed internal SGI string to a buffer. Added efficient
 // internal buffer get/set/swap functions, so that we can obtain/establish the
 // internal buffer without any reallocation or copy. Kill those temporaries!
@@ -42,7 +42,7 @@
 #include <ios>
 #include <istream>
 #include <ostream>
-#include <string> // char traits
+#include <string> // char traits
 #include <cstddef> // ptrdiff_t
 #include <boost/assert.hpp>
 #include <boost/interprocess/interprocess_fwd.hpp>
@@ -177,7 +177,7 @@
    {
       bool in = false;
       bool out = false;
-
+
       const std::ios_base::openmode inout =
          std::ios_base::in | std::ios_base::out;
 

Modified: branches/release/boost/interprocess/streams/vectorstream.hpp
==============================================================================
--- branches/release/boost/interprocess/streams/vectorstream.hpp (original)
+++ branches/release/boost/interprocess/streams/vectorstream.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -8,7 +8,7 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 //
-// This file comes from SGI's sstream file. Modified by Ion Gaztanaga 2005.
+// This file comes from SGI's sstream file. Modified by Ion Gaztanaga 2005-2012.
 // Changed internal SGI string to a generic, templatized vector. Added efficient
 // internal buffer get/set/swap functions, so that we can obtain/establish the
 // internal buffer without any reallocation or copy. Kill those temporaries!
@@ -43,7 +43,7 @@
 #include <ios>
 #include <istream>
 #include <ostream>
-#include <string> // char traits
+#include <string> // char traits
 #include <cstddef> // ptrdiff_t
 #include <boost/interprocess/interprocess_fwd.hpp>
 #include <boost/assert.hpp>
@@ -100,7 +100,7 @@
    //!This function resets the read/write position in the stream.
    //!Does not throw.
    void swap_vector(vector_type &vect)
- {
+ {
       if (this->m_mode & std::ios_base::out){
          //Update high water if necessary
          //And resize vector to remove extra size
@@ -119,7 +119,7 @@
    //!Returns a const reference to the internal vector.
    //!Does not throw.
    const vector_type &vector() const
- {
+ {
       if (this->m_mode & std::ios_base::out){
          if (mp_high_water < base_t::pptr()){
             //Restore the vector's size if necessary

Modified: branches/release/boost/interprocess/sync/detail/condition_algorithm_8a.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/detail/condition_algorithm_8a.hpp (original)
+++ branches/release/boost/interprocess/sync/detail/condition_algorithm_8a.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -14,6 +14,7 @@
 #include <boost/interprocess/detail/config_begin.hpp>
 #include <boost/interprocess/detail/workaround.hpp>
 #include <boost/interprocess/sync/scoped_lock.hpp>
+#include <boost/interprocess/sync/detail/locks.hpp>
 #include <limits>
 
 namespace boost {
@@ -161,6 +162,15 @@
 // mutex_type &get_mtx_unblock_lock()
 // };
 //
+// Must be initialized as following
+//
+// get_nwaiters_blocked() == 0
+// get_nwaiters_gone() == 0
+// get_nwaiters_to_unblock() == 0
+// get_sem_block_queue() == initial count 0
+// get_sem_block_lock() == initial count 1
+// get_mtx_unblock_lock() (unlocked)
+//
 template<class ConditionMembers>
 class condition_algorithm_8a
 {
@@ -174,16 +184,10 @@
    typedef typename ConditionMembers::mutex_type mutex_type;
    typedef typename ConditionMembers::integer_type integer_type;
 
- // nwaiters_blocked == 0
- // nwaiters_gone() == 0
- // nwaiters_to_unblock == 0
- // sem_block_queue() == initial count 0
- // sem_block_lock() == initial count 1
- // mtx_unblock_lock (unlocked)
-
    public:
- template<class InterprocessMutex>
- static bool wait (ConditionMembers &data, bool timeout_enabled, const boost::posix_time::ptime &abs_time, InterprocessMutex &mut);
+ template<class Lock>
+ static bool wait ( ConditionMembers &data, Lock &lock
+ , bool timeout_enabled, const boost::posix_time::ptime &abs_time);
    static void signal(ConditionMembers &data, bool broadcast);
 };
 
@@ -235,9 +239,13 @@
 }
 
 template<class ConditionMembers>
-template<class InterprocessMutex>
+template<class Lock>
 inline bool condition_algorithm_8a<ConditionMembers>::wait
- (ConditionMembers &data, bool tout_enabled, const boost::posix_time::ptime &abs_time, InterprocessMutex &mtxExternal)
+ ( ConditionMembers &data
+ , Lock &lock
+ , bool tout_enabled
+ , const boost::posix_time::ptime &abs_time
+ )
 {
    //Initialize to avoid warnings
    integer_type nsignals_was_left = 0;
@@ -247,19 +255,13 @@
    ++data.get_nwaiters_blocked();
    data.get_sem_block_lock().post();
 
- struct scoped_unlock
- {
- InterprocessMutex & mut;
- scoped_unlock(InterprocessMutex & m)
- : mut(m)
- { m.unlock(); }
-
- ~scoped_unlock()
- { mut.lock(); }
- } unlocker(mtxExternal);
-
-
- bool bTimedOut = tout_enabled ? !data.get_sem_block_queue().timed_wait(abs_time) : (data.get_sem_block_queue().wait(), false);
+ //Unlock external lock and program for relock
+ lock_inverter<Lock> inverted_lock(lock);
+ scoped_lock<lock_inverter<Lock> > external_unlock(inverted_lock);
+
+ bool bTimedOut = tout_enabled
+ ? !data.get_sem_block_queue().timed_wait(abs_time)
+ : (data.get_sem_block_queue().wait(), false);
 
    {
       scoped_lock<mutex_type> locker(data.get_mtx_unblock_lock());
@@ -290,7 +292,7 @@
          data.get_nwaiters_gone() = 0;
       }
       //locker's destructor triggers data.get_mtx_unblock_lock().unlock()
- }
+ }
 
    if ( 1 == nsignals_was_left ) {
       if ( 0 != nwaiters_was_gone ) {
@@ -302,11 +304,87 @@
       data.get_sem_block_lock().post(); // open the gate
    }
 
- //mtxExternal.lock(); called from unlocker
+ //lock.lock(); called from unlocker destructor
 
    return ( bTimedOut ) ? false : true;
 }
 
+
+template<class ConditionMembers>
+class condition_8a_wrapper
+{
+ //Non-copyable
+ condition_8a_wrapper(const condition_8a_wrapper &);
+ condition_8a_wrapper &operator=(const condition_8a_wrapper &);
+
+ ConditionMembers m_data;
+ typedef ipcdetail::condition_algorithm_8a<ConditionMembers> algo_type;
+
+ public:
+
+ condition_8a_wrapper(){}
+
+ ~condition_8a_wrapper(){}
+
+ ConditionMembers & get_members()
+ { return m_data; }
+
+ const ConditionMembers & get_members() const
+ { return m_data; }
+
+ void notify_one()
+ { algo_type::signal(m_data, false); }
+
+ void notify_all()
+ { algo_type::signal(m_data, true); }
+
+ template <typename L>
+ void wait(L& lock)
+ {
+ if (!lock)
+ throw lock_exception();
+ algo_type::wait(m_data, lock, false, boost::posix_time::ptime());
+ }
+
+ template <typename L, typename Pr>
+ void wait(L& lock, Pr pred)
+ {
+ if (!lock)
+ throw lock_exception();
+
+ while (!pred())
+ algo_type::wait(m_data, lock, false, boost::posix_time::ptime());
+ }
+
+ template <typename L>
+ bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time)
+ {
+ if(abs_time == boost::posix_time::pos_infin){
+ this->wait(lock);
+ return true;
+ }
+ if (!lock)
+ throw lock_exception();
+ return algo_type::wait(m_data, lock, true, abs_time);
+ }
+
+ template <typename L, typename Pr>
+ bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
+ {
+ if(abs_time == boost::posix_time::pos_infin){
+ this->wait(lock, pred);
+ return true;
+ }
+ if (!lock)
+ throw lock_exception();
+ while (!pred()){
+ if (!algo_type::wait(m_data, lock, true, abs_time))
+ return pred();
+ }
+ return true;
+ }
+};
+
 } //namespace ipcdetail
 } //namespace interprocess
 } //namespace boost

Modified: branches/release/boost/interprocess/sync/file_lock.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/file_lock.hpp (original)
+++ branches/release/boost/interprocess/sync/file_lock.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -64,10 +64,10 @@
    //!After the call, "moved" does not represent any file mapping.
    //!Does not throw
    file_lock &operator=(BOOST_RV_REF(file_lock) moved)
- {
+ {
       file_lock tmp(boost::move(moved));
       this->swap(tmp);
- return *this;
+ return *this;
    }
 
    //!Closes a file lock. Does not throw.
@@ -81,7 +81,7 @@
       m_file_hnd = other.m_file_hnd;
       other.m_file_hnd = tmp;
    }
-
+
    //Exclusive locking
 
    //!Effects: The calling thread tries to obtain exclusive ownership of the mutex,
@@ -171,7 +171,7 @@
 
    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;

Modified: branches/release/boost/interprocess/sync/interprocess_condition.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/interprocess_condition.hpp (original)
+++ branches/release/boost/interprocess/sync/interprocess_condition.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -22,6 +22,7 @@
 
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
 #include <boost/interprocess/sync/interprocess_mutex.hpp>
+#include <boost/interprocess/sync/detail/locks.hpp>
 #include <boost/interprocess/exceptions.hpp>
 #include <boost/limits.hpp>
 #include <boost/assert.hpp>
@@ -54,6 +55,11 @@
 
 //!This class is a condition variable that can be placed in shared memory or
 //!memory mapped files.
+//!Destroys the object of type std::condition_variable_any
+//!
+//!Unlike std::condition_variable in C++11, it is NOT safe to invoke the destructor if all
+//!threads have been only notified. It is required that they have exited their respective wait
+//!functions.
 class interprocess_condition
 {
    /// @cond
@@ -62,13 +68,16 @@
    interprocess_condition &operator=(const interprocess_condition &);
    friend class named_condition;
    /// @endcond
+
    public:
    //!Constructs a interprocess_condition. On error throws interprocess_exception.
- interprocess_condition(){}
+ interprocess_condition()
+ {}
 
    //!Destroys *this
    //!liberating system resources.
- ~interprocess_condition(){}
+ ~interprocess_condition()
+ {}
 
    //!If there is a thread waiting on *this, change that
    //!thread's state to ready. Otherwise there is no effect.
@@ -85,10 +94,9 @@
    //!this->notify_one() or this->notify_all(), and then reacquires the lock.
    template <typename L>
    void wait(L& lock)
- {
- if (!lock)
- throw lock_exception();
- this->do_wait(*lock.mutex());
+ {
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ m_condition.wait(internal_lock);
    }
 
    //!The same as:
@@ -96,11 +104,8 @@
    template <typename L, typename Pr>
    void wait(L& lock, Pr pred)
    {
- if (!lock)
- throw lock_exception();
-
- while (!pred())
- this->do_wait(*lock.mutex());
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ m_condition.wait(internal_lock, pred);
    }
 
    //!Releases the lock on the interprocess_mutex object associated with lock, blocks
@@ -111,13 +116,8 @@
    template <typename L>
    bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time)
    {
- if(abs_time == boost::posix_time::pos_infin){
- this->wait(lock);
- return true;
- }
- if (!lock)
- throw lock_exception();
- return this->do_timed_wait(abs_time, *lock.mutex());
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ return m_condition.timed_wait(internal_lock, abs_time);
    }
 
    //!The same as: while (!pred()) {
@@ -126,28 +126,12 @@
    template <typename L, typename Pr>
    bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
    {
- if(abs_time == boost::posix_time::pos_infin){
- this->wait(lock, pred);
- return true;
- }
- if (!lock)
- throw lock_exception();
- while (!pred()){
- if (!this->do_timed_wait(abs_time, *lock.mutex()))
- return pred();
- }
-
- return true;
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ return m_condition.timed_wait(internal_lock, abs_time, pred);
    }
 
    /// @cond
 
- void do_wait(interprocess_mutex &mut)
- { m_condition.do_wait(mut.mutex); }
-
- bool do_timed_wait(const boost::posix_time::ptime &abs_time, interprocess_mutex &mut)
- { return m_condition.do_timed_wait(abs_time, mut.mutex); }
-
    private:
    #if defined (BOOST_INTERPROCESS_USE_GENERIC_EMULATION)
       #undef BOOST_INTERPROCESS_USE_GENERIC_EMULATION

Modified: branches/release/boost/interprocess/sync/interprocess_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/interprocess_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/interprocess_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -70,6 +70,25 @@
    interprocess_mutex(const interprocess_mutex &);
    interprocess_mutex &operator=(const interprocess_mutex &);
    friend class interprocess_condition;
+
+ public:
+ #if defined(BOOST_INTERPROCESS_USE_GENERIC_EMULATION)
+ #undef BOOST_INTERPROCESS_USE_GENERIC_EMULATION
+ typedef ipcdetail::spin_mutex internal_mutex_type;
+ private:
+ friend class ipcdetail::robust_emulation_helpers::mutex_traits<interprocess_mutex>;
+ void take_ownership(){ m_mutex.take_ownership(); }
+ public:
+ #elif defined(BOOST_INTERPROCESS_USE_POSIX)
+ #undef BOOST_INTERPROCESS_USE_POSIX
+ typedef ipcdetail::posix_mutex internal_mutex_type;
+ #elif defined(BOOST_INTERPROCESS_USE_WINDOWS)
+ #undef BOOST_INTERPROCESS_USE_WINDOWS
+ typedef ipcdetail::windows_mutex internal_mutex_type;
+ #else
+ #error "Unknown platform for interprocess_mutex"
+ #endif
+
    /// @endcond
    public:
 
@@ -107,23 +126,16 @@
    //!Effects: The calling thread releases the exclusive ownership of the mutex.
    //!Throws: interprocess_exception on error.
    void unlock();
+
    /// @cond
- private:
+ internal_mutex_type &internal_mutex()
+ { return m_mutex; }
 
- #if defined(BOOST_INTERPROCESS_USE_GENERIC_EMULATION)
- #undef BOOST_INTERPROCESS_USE_GENERIC_EMULATION
- friend class ipcdetail::robust_emulation_helpers::mutex_traits<interprocess_mutex>;
- void take_ownership(){ mutex.take_ownership(); }
- ipcdetail::spin_mutex mutex;
- #elif defined(BOOST_INTERPROCESS_USE_POSIX)
- #undef BOOST_INTERPROCESS_USE_POSIX
- ipcdetail::posix_mutex mutex;
- #elif defined(BOOST_INTERPROCESS_USE_WINDOWS)
- #undef BOOST_INTERPROCESS_USE_WINDOWS
- ipcdetail::windows_mutex mutex;
- #else
- #error "Unknown platform for interprocess_mutex"
- #endif
+ const internal_mutex_type &internal_mutex() const
+ { return m_mutex; }
+
+ private:
+ internal_mutex_type m_mutex;
    /// @endcond
 };
 
@@ -144,23 +156,25 @@
       boost::posix_time::ptime wait_time
          = boost::posix_time::microsec_clock::universal_time()
          + boost::posix_time::milliseconds(BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS);
- if (!mutex.timed_lock(wait_time))
+ if (!m_mutex.timed_lock(wait_time))
       {
- throw interprocess_exception(timeout_when_locking_error, "Interprocess mutex timeout when locking. Possible deadlock: owner died without unlocking?");
+ throw interprocess_exception(timeout_when_locking_error
+ , "Interprocess mutex timeout when locking. Possible deadlock: "
+ "owner died without unlocking?");
       }
    #else
- mutex.lock();
+ m_mutex.lock();
    #endif
 }
 
 inline bool interprocess_mutex::try_lock()
-{ return mutex.try_lock(); }
+{ return m_mutex.try_lock(); }
 
 inline bool interprocess_mutex::timed_lock(const boost::posix_time::ptime &abs_time)
-{ return mutex.timed_lock(abs_time); }
+{ return m_mutex.timed_lock(abs_time); }
 
 inline void interprocess_mutex::unlock()
-{ mutex.unlock(); }
+{ m_mutex.unlock(); }
 
 } //namespace interprocess {
 } //namespace boost {

Modified: branches/release/boost/interprocess/sync/interprocess_recursive_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/interprocess_recursive_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/interprocess_recursive_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/interprocess_semaphore.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/interprocess_semaphore.hpp (original)
+++ branches/release/boost/interprocess/sync/interprocess_semaphore.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/interprocess_upgradable_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/interprocess_upgradable_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/interprocess_upgradable_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,8 @@
-//////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+//
+// Code based on Howard Hinnant's upgrade_mutex class
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -249,7 +251,7 @@
          if(mp_ctrl){
             //Recover upgradable lock
             mp_ctrl->upgradable_in = 1;
- ++mp_ctrl->num_upr_shar;
+ ++mp_ctrl->num_upr_shar;
             //Execute the second half of exclusive locking
             mp_ctrl->exclusive_in = 0;
          }
@@ -333,8 +335,12 @@
    //The exclusive lock must block in the first gate
    //if an exclusive or upgradable lock has been acquired
    while (this->m_ctrl.exclusive_in || this->m_ctrl.upgradable_in){
- if(!this->m_first_gate.timed_wait(lock, abs_time))
- return !(this->m_ctrl.exclusive_in || this->m_ctrl.upgradable_in);
+ if(!this->m_first_gate.timed_wait(lock, abs_time)){
+ if(this->m_ctrl.exclusive_in || this->m_ctrl.upgradable_in){
+ return false;
+ }
+ break;
+ }
    }
 
    //Mark that exclusive lock has been acquired
@@ -346,7 +352,10 @@
    //Now wait until all readers are gone
    while (this->m_ctrl.num_upr_shar){
       if(!this->m_second_gate.timed_wait(lock, abs_time)){
- return !(this->m_ctrl.num_upr_shar);
+ if(this->m_ctrl.num_upr_shar){
+ return false;
+ }
+ break;
       }
    }
    rollback.release();
@@ -418,9 +427,12 @@
          || this->m_ctrl.upgradable_in
          || this->m_ctrl.num_upr_shar == constants::max_readers){
       if(!this->m_first_gate.timed_wait(lock, abs_time)){
- return!(this->m_ctrl.exclusive_in
- || this->m_ctrl.upgradable_in
- || this->m_ctrl.num_upr_shar == constants::max_readers);
+ if((this->m_ctrl.exclusive_in
+ || this->m_ctrl.upgradable_in
+ || this->m_ctrl.num_upr_shar == constants::max_readers)){
+ return false;
+ }
+ break;
       }
    }
 
@@ -492,9 +504,12 @@
    //or there are too many sharable locks
    while (this->m_ctrl.exclusive_in
          || this->m_ctrl.num_upr_shar == constants::max_readers){
- if(!this->m_first_gate.timed_wait(lock, abs_time)){
- return!(this->m_ctrl.exclusive_in
- || this->m_ctrl.num_upr_shar == constants::max_readers);
+ if(!this->m_first_gate.timed_wait(lock, abs_time)){
+ if(this->m_ctrl.exclusive_in
+ || this->m_ctrl.num_upr_shar == constants::max_readers){
+ return false;
+ }
+ break;
       }
    }
 
@@ -561,7 +576,7 @@
    //Simulate unlock_upgradable() without
    //notifying sharables.
    this->m_ctrl.upgradable_in = 0;
- --this->m_ctrl.num_upr_shar;
+ --this->m_ctrl.num_upr_shar;
    //Execute the second half of exclusive locking
    this->m_ctrl.exclusive_in = 1;
 
@@ -584,7 +599,7 @@
    }
    //Now unlock upgradable and mark exclusive
    this->m_ctrl.upgradable_in = 0;
- --this->m_ctrl.num_upr_shar;
+ --this->m_ctrl.num_upr_shar;
    this->m_ctrl.exclusive_in = 1;
    return true;
 }
@@ -592,13 +607,17 @@
 inline bool interprocess_upgradable_mutex::timed_unlock_upgradable_and_lock
    (const boost::posix_time::ptime &abs_time)
 {
+ if(abs_time == boost::posix_time::pos_infin){
+ this->unlock_upgradable_and_lock();
+ return true;
+ }
    scoped_lock_t lock(m_mut, abs_time);
    if(!lock.owns()) return false;
 
    //Simulate unlock_upgradable() without
    //notifying sharables.
    this->m_ctrl.upgradable_in = 0;
- --this->m_ctrl.num_upr_shar;
+ --this->m_ctrl.num_upr_shar;
    //Execute the second half of exclusive locking
    this->m_ctrl.exclusive_in = 1;
 
@@ -607,7 +626,10 @@
 
    while (this->m_ctrl.num_upr_shar){
       if(!this->m_second_gate.timed_wait(lock, abs_time)){
- return !(this->m_ctrl.num_upr_shar);
+ if(this->m_ctrl.num_upr_shar){
+ return false;
+ }
+ break;
       }
    }
    rollback.release();

Modified: branches/release/boost/interprocess/sync/lock_options.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/lock_options.hpp (original)
+++ branches/release/boost/interprocess/sync/lock_options.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/mutex_family.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/mutex_family.hpp (original)
+++ branches/release/boost/interprocess/sync/mutex_family.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/named_condition.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/named_condition.hpp (original)
+++ branches/release/boost/interprocess/sync/named_condition.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -22,6 +22,7 @@
 #include <boost/interprocess/detail/interprocess_tester.hpp>
 #include <boost/interprocess/permissions.hpp>
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
+#include <boost/interprocess/sync/detail/locks.hpp>
 #if !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && defined (BOOST_INTERPROCESS_WINDOWS)
    #include <boost/interprocess/sync/windows/named_condition.hpp>
    #define BOOST_INTERPROCESS_USE_WINDOWS
@@ -153,24 +154,38 @@
 
 template <typename L>
 inline void named_condition::wait(L& lock)
-{ m_cond.wait(lock); }
+{
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ m_cond.wait(internal_lock);
+}
 
 template <typename L, typename Pr>
 inline void named_condition::wait(L& lock, Pr pred)
-{ m_cond.wait(lock, pred); }
+{
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ m_cond.wait(internal_lock, pred);
+}
 
 template <typename L>
 inline bool named_condition::timed_wait
    (L& lock, const boost::posix_time::ptime &abs_time)
-{ return m_cond.timed_wait(lock, abs_time); }
+{
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ return m_cond.timed_wait(internal_lock, abs_time);
+}
 
 template <typename L, typename Pr>
 inline bool named_condition::timed_wait
    (L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
-{ return m_cond.timed_wait(lock, abs_time, pred); }
+{
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ return m_cond.timed_wait(internal_lock, abs_time, pred);
+}
 
 inline bool named_condition::remove(const char *name)
-{ return condition_type::remove(name); }
+{
+ return condition_type::remove(name);
+}
 
 /// @endcond
 

Modified: branches/release/boost/interprocess/sync/named_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/named_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/named_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -108,21 +108,20 @@
    friend class ipcdetail::interprocess_tester;
    void dont_close_on_destruction();
 
+ public:
    #if defined(BOOST_INTERPROCESS_USE_POSIX_SEMAPHORES)
- typedef ipcdetail::posix_named_mutex impl_t;
- impl_t m_mut;
+ typedef ipcdetail::posix_named_mutex internal_mutex_type;
       #undef BOOST_INTERPROCESS_USE_POSIX_SEMAPHORES
    #elif defined(BOOST_INTERPROCESS_USE_WINDOWS)
- typedef ipcdetail::windows_named_mutex impl_t;
- impl_t m_mut;
+ typedef ipcdetail::windows_named_mutex internal_mutex_type;
       #undef BOOST_INTERPROCESS_USE_WINDOWS
    #else
- typedef ipcdetail::shm_named_mutex impl_t;
- impl_t m_mut;
- public:
- interprocess_mutex *mutex() const
- { return m_mut.mutex(); }
+ typedef ipcdetail::shm_named_mutex internal_mutex_type;
    #endif
+ internal_mutex_type &internal_mutex()
+ { return m_mut; }
+
+ internal_mutex_type m_mut;
 
    /// @endcond
 };
@@ -160,7 +159,7 @@
 { return m_mut.timed_lock(abs_time); }
 
 inline bool named_mutex::remove(const char *name)
-{ return impl_t::remove(name); }
+{ return internal_mutex_type::remove(name); }
 
 /// @endcond
 

Modified: branches/release/boost/interprocess/sync/named_recursive_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/named_recursive_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/named_recursive_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/named_semaphore.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/named_semaphore.hpp (original)
+++ branches/release/boost/interprocess/sync/named_semaphore.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
  //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/named_upgradable_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/named_upgradable_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/named_upgradable_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -56,7 +56,7 @@
    //!If the upgradable mutex can't be created throws interprocess_exception
    named_upgradable_mutex(create_only_t create_only, const char *name, const permissions &perm = permissions());
 
- //!Opens or creates a global upgradable mutex with a name, and an initial count.
+ //!Opens or creates a global upgradable mutex with a name.
    //!If the upgradable mutex is created, this call is equivalent to
    //!named_upgradable_mutex(create_only_t, ...)
    //!If the upgradable mutex is already created, this call is equivalent to
@@ -215,6 +215,12 @@
    //!Throws: An exception derived from interprocess_exception on error.
    bool try_unlock_sharable_and_lock();
 
+ //!Precondition: The thread must have sharable ownership of the mutex.
+ //!Effects: The thread atomically releases sharable ownership and tries to acquire
+ //! upgradable ownership. This operation will fail if there are threads with sharable
+ //! or upgradable ownership, but it will maintain sharable ownership.
+ //!Returns: If acquires upgradable ownership, returns true. Otherwise returns false.
+ //!Throws: An exception derived from interprocess_exception on error.
    bool try_unlock_sharable_and_lock_upgradable();
 
    //!Erases a named upgradable mutex from the system.
@@ -288,13 +294,7 @@
 
 inline bool named_upgradable_mutex::timed_lock
    (const boost::posix_time::ptime &abs_time)
-{
- if(abs_time == boost::posix_time::pos_infin){
- this->lock();
- return true;
- }
- return this->mutex()->timed_lock(abs_time);
-}
+{ return this->mutex()->timed_lock(abs_time); }
 
 inline void named_upgradable_mutex::lock_upgradable()
 { this->mutex()->lock_upgradable(); }
@@ -307,13 +307,7 @@
 
 inline bool named_upgradable_mutex::timed_lock_upgradable
    (const boost::posix_time::ptime &abs_time)
-{
- if(abs_time == boost::posix_time::pos_infin){
- this->lock_upgradable();
- return true;
- }
- return this->mutex()->timed_lock_upgradable(abs_time);
-}
+{ return this->mutex()->timed_lock_upgradable(abs_time); }
 
 inline void named_upgradable_mutex::lock_sharable()
 { this->mutex()->lock_sharable(); }
@@ -326,13 +320,7 @@
 
 inline bool named_upgradable_mutex::timed_lock_sharable
    (const boost::posix_time::ptime &abs_time)
-{
- if(abs_time == boost::posix_time::pos_infin){
- this->lock_sharable();
- return true;
- }
- return this->mutex()->timed_lock_sharable(abs_time);
-}
+{ return this->mutex()->timed_lock_sharable(abs_time); }
 
 inline void named_upgradable_mutex::unlock_and_lock_upgradable()
 { this->mutex()->unlock_and_lock_upgradable(); }

Modified: branches/release/boost/interprocess/sync/null_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/null_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/null_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/posix/condition.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/posix/condition.hpp (original)
+++ branches/release/boost/interprocess/sync/posix/condition.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -19,7 +19,7 @@
 #include <boost/interprocess/detail/workaround.hpp>
 
 #include <pthread.h>
-#include <errno.h>
+#include <errno.h>
 #include <boost/interprocess/sync/posix/pthread_helpers.hpp>
 #include <boost/interprocess/sync/posix/ptime_to_timespec.hpp>
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
@@ -145,21 +145,21 @@
 {
     int res = 0;
     res = pthread_cond_destroy(&m_condition);
- BOOST_ASSERT(res == 0);
+ BOOST_ASSERT(res == 0); (void)res;
 }
 
 inline void posix_condition::notify_one()
 {
     int res = 0;
     res = pthread_cond_signal(&m_condition);
- BOOST_ASSERT(res == 0);
+ BOOST_ASSERT(res == 0); (void)res;
 }
 
 inline void posix_condition::notify_all()
 {
     int res = 0;
     res = pthread_cond_broadcast(&m_condition);
- BOOST_ASSERT(res == 0);
+ BOOST_ASSERT(res == 0); (void)res;
 }
 
 inline void posix_condition::do_wait(posix_mutex &mut)
@@ -167,7 +167,7 @@
    pthread_mutex_t* pmutex = &mut.m_mut;
    int res = 0;
    res = pthread_cond_wait(&m_condition, pmutex);
- BOOST_ASSERT(res == 0);
+ BOOST_ASSERT(res == 0); (void)res;
 }
 
 inline bool posix_condition::do_timed_wait

Modified: branches/release/boost/interprocess/sync/posix/mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/posix/mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/posix/mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -35,7 +35,7 @@
 #include <boost/interprocess/detail/workaround.hpp>
 
 #include <pthread.h>
-#include <errno.h>
+#include <errno.h>
 #include <boost/interprocess/exceptions.hpp>
 #include <boost/interprocess/sync/posix/ptime_to_timespec.hpp>
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
@@ -140,6 +140,7 @@
 {
    int res = 0;
    res = pthread_mutex_unlock(&m_mut);
+ (void)res;
    BOOST_ASSERT(res == 0);
 }
 

Modified: branches/release/boost/interprocess/sync/posix/named_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/posix/named_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/posix/named_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/posix/named_semaphore.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/posix/named_semaphore.hpp (original)
+++ branches/release/boost/interprocess/sync/posix/named_semaphore.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/posix/pthread_helpers.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/posix/pthread_helpers.hpp (original)
+++ branches/release/boost/interprocess/sync/posix/pthread_helpers.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -19,8 +19,8 @@
 #include <boost/interprocess/detail/workaround.hpp>
 
 #include <pthread.h>
-#include <errno.h>
-#include <boost/interprocess/exceptions.hpp>
+#include <errno.h>
+#include <boost/interprocess/exceptions.hpp>
 
 namespace boost {
 namespace interprocess {
@@ -86,7 +86,7 @@
 
       void release() {mp_mut = 0; }
 
- private:
+ private:
       pthread_mutex_t *mp_mut;
    };
 
@@ -105,7 +105,7 @@
 
       void release() { mp_cond = 0; }
 
- private:
+ private:
       pthread_cond_t *mp_cond;
    };
 
@@ -151,7 +151,7 @@
 
       void release() {mp_barrier = 0; }
 
- private:
+ private:
       pthread_barrier_t *mp_barrier;
    };
 

Modified: branches/release/boost/interprocess/sync/posix/ptime_to_timespec.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/posix/ptime_to_timespec.hpp (original)
+++ branches/release/boost/interprocess/sync/posix/ptime_to_timespec.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/posix/recursive_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/posix/recursive_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/posix/recursive_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -31,7 +31,7 @@
 #include <boost/interprocess/detail/workaround.hpp>
 
 #include <pthread.h>
-#include <errno.h>
+#include <errno.h>
 #include <boost/interprocess/sync/posix/pthread_helpers.hpp>
 #include <boost/interprocess/sync/posix/ptime_to_timespec.hpp>
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
@@ -130,7 +130,7 @@
 {
    int res = 0;
    res = pthread_mutex_unlock(&m_mut);
- BOOST_ASSERT(res == 0);
+ BOOST_ASSERT(res == 0); (void)res;
 }
 
 } //namespace ipcdetail {

Modified: branches/release/boost/interprocess/sync/posix/semaphore.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/posix/semaphore.hpp (original)
+++ branches/release/boost/interprocess/sync/posix/semaphore.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/posix/semaphore_wrapper.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/posix/semaphore_wrapper.hpp (original)
+++ branches/release/boost/interprocess/sync/posix/semaphore_wrapper.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -103,7 +103,7 @@
 inline void semaphore_close(sem_t *handle)
 {
    int ret = sem_close(handle);
- if(ret != 0){
+ if(ret != 0){
       BOOST_ASSERT(0);
    }
 }
@@ -138,7 +138,7 @@
 inline void semaphore_destroy(sem_t *handle)
 {
    int ret = sem_destroy(handle);
- if(ret != 0){
+ if(ret != 0){
       BOOST_ASSERT(0);
    }
 }

Modified: branches/release/boost/interprocess/sync/scoped_lock.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/scoped_lock.hpp (original)
+++ branches/release/boost/interprocess/sync/scoped_lock.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -157,7 +157,7 @@
    //! a)if try_unlock_upgradable_and_lock() returns true then mutex() obtains
    //! the value from upgr.release() and owns() is set to true.
    //! b)if try_unlock_upgradable_and_lock() returns false then upgr is
- //! unaffected and this scoped_lock construction as the same effects as
+ //! unaffected and this scoped_lock construction as the same effects as
    //! a default construction.
    //! c)Else upgr.owns() is false. mutex() obtains the value from upgr.release()
    //! and owns() is set to false
@@ -259,7 +259,7 @@
    //! mutex after the assignment (and scop will not), but the mutex's lock
    //! count will be decremented by one.
    scoped_lock &operator=(BOOST_RV_REF(scoped_lock) scop)
- {
+ {
       if(this->owns())
          this->unlock();
       m_locked = scop.owns();

Modified: branches/release/boost/interprocess/sync/sharable_lock.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/sharable_lock.hpp (original)
+++ branches/release/boost/interprocess/sync/sharable_lock.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -189,7 +189,7 @@
    //! before the assignment. In this case, this will own the mutex after the assignment
    //! (and upgr will not), but the mutex's lock count will be decremented by one.
    sharable_lock &operator=(BOOST_RV_REF(sharable_lock<mutex_type>) upgr)
- {
+ {
       if(this->owns())
          this->unlock();
       m_locked = upgr.owns();
@@ -203,7 +203,7 @@
    //!Notes: The sharable_lock changes from a state of not owning the
    //! mutex, to owning the mutex, blocking if necessary.
    void lock()
- {
+ {
       if(!mp_mutex || m_locked)
          throw lock_exception();
       mp_mutex->lock_sharable();
@@ -219,7 +219,7 @@
    //! mutex_type does not support try_lock_sharable(), this function will
    //! fail at compile time if instantiated, but otherwise have no effect.
    bool try_lock()
- {
+ {
       if(!mp_mutex || m_locked)
          throw lock_exception();
       m_locked = mp_mutex->try_lock_sharable();
@@ -236,7 +236,7 @@
    //! timed_lock_sharable(), this function will fail at compile time if
    //! instantiated, but otherwise have no effect.
    bool timed_lock(const boost::posix_time::ptime& abs_time)
- {
+ {
       if(!mp_mutex || m_locked)
          throw lock_exception();
       m_locked = mp_mutex->timed_lock_sharable(abs_time);

Modified: branches/release/boost/interprocess/sync/shm/named_condition.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/shm/named_condition.hpp (original)
+++ branches/release/boost/interprocess/sync/shm/named_condition.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -29,8 +29,11 @@
 #include <boost/interprocess/sync/named_mutex.hpp>
 #include <boost/interprocess/permissions.hpp>
 #if defined (BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
-#include <boost/interprocess/sync/interprocess_mutex.hpp>
-#include <boost/interprocess/sync/scoped_lock.hpp>
+ #include <boost/interprocess/sync/interprocess_mutex.hpp>
+ #include <boost/interprocess/sync/scoped_lock.hpp>
+ #include <boost/interprocess/sync/detail/condition_any_algorithm.hpp>
+#else
+ #include <boost/interprocess/sync/detail/locks.hpp>
 #endif
 
 
@@ -122,106 +125,35 @@
    /// @cond
    private:
 
- struct condition_holder
- {
- interprocess_condition cond_;
- //If named_mutex is implemented using semaphores
- //we need to store an additional mutex
- #if defined (BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
- interprocess_mutex mutex_;
- #endif
- };
-
- interprocess_condition *condition() const
- { return &static_cast<condition_holder*>(m_shmem.get_user_address())->cond_; }
-
- template <class Lock>
- class lock_inverter
+ #if defined (BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
+ class internal_condition_members
    {
- Lock &l_;
       public:
- lock_inverter(Lock &l)
- : l_(l)
- {}
- void lock() { l_.unlock(); }
- void unlock() { l_.lock(); }
+ typedef interprocess_mutex mutex_type;
+ typedef interprocess_condition condvar_type;
+
+ condvar_type& get_condvar() { return m_cond; }
+ mutex_type& get_mutex() { return m_mtx; }
+
+ private:
+ mutex_type m_mtx;
+ condvar_type m_cond;
    };
 
- //If named mutex uses POSIX semaphores, then the shm based condition variable
- //must use it's internal lock to wait, as sem_t does not store a pthread_mutex_t
- //instance needed by pthread_mutex_cond_t
- #if defined (BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
- interprocess_mutex *mutex() const
- { return &static_cast<condition_holder*>(m_shmem.get_user_address())->mutex_; }
-
- template <class Lock>
- void do_wait(Lock& lock)
- {
- //shm_named_condition only works with named_mutex
- BOOST_STATIC_ASSERT((is_convertible<typename Lock::mutex_type&, named_mutex&>::value == true));
-
- //lock internal before unlocking external to avoid race with a notifier
- scoped_lock<interprocess_mutex> internal_lock(*this->mutex());
- lock_inverter<Lock> inverted_lock(lock);
- scoped_lock<lock_inverter<Lock> > external_unlock(inverted_lock);
-
- //unlock internal first to avoid deadlock with near simultaneous waits
- scoped_lock<interprocess_mutex> internal_unlock;
- internal_lock.swap(internal_unlock);
- this->condition()->wait(internal_unlock);
- }
-
- template <class Lock>
- bool do_timed_wait(Lock& lock, const boost::posix_time::ptime &abs_time)
- {
- //shm_named_condition only works with named_mutex
- BOOST_STATIC_ASSERT((is_convertible<typename Lock::mutex_type&, named_mutex&>::value == true));
- //lock internal before unlocking external to avoid race with a notifier
- scoped_lock<interprocess_mutex> internal_lock(*this->mutex(), abs_time);
- if(!internal_lock) return false;
- lock_inverter<Lock> inverted_lock(lock);
- scoped_lock<lock_inverter<Lock> > external_unlock(inverted_lock);
-
- //unlock internal first to avoid deadlock with near simultaneous waits
- scoped_lock<interprocess_mutex> internal_unlock;
- internal_lock.swap(internal_unlock);
- return this->condition()->timed_wait(internal_unlock, abs_time);
- }
- #else //defined (BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
- template<class Lock>
- class lock_wrapper
- {
- typedef void (lock_wrapper::*unspecified_bool_type)();
- public:
-
- typedef interprocess_mutex mutex_type;
-
- lock_wrapper(Lock &l)
- : l_(l)
- {}
-
- mutex_type* mutex() const
- { return l_.mutex()->mutex(); }
-
- void lock() { l_.lock(); }
-
- void unlock() { l_.unlock(); }
-
- operator unspecified_bool_type() const
- { return l_ ? &lock_wrapper::lock : 0; }
-
- private:
- Lock &l_;
- };
+ typedef ipcdetail::condition_any_wrapper<internal_condition_members> internal_condition;
+ #else //defined (BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
+ typedef interprocess_condition internal_condition;
    #endif //defined (BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
 
+ internal_condition m_cond;
+
    friend class boost::interprocess::ipcdetail::interprocess_tester;
    void dont_close_on_destruction();
 
    managed_open_or_create_impl<shared_memory_object> m_shmem;
 
    template <class T, class Arg> friend class boost::interprocess::ipcdetail::named_creation_functor;
- typedef boost::interprocess::ipcdetail::named_creation_functor<condition_holder> construct_func_t;
+ typedef boost::interprocess::ipcdetail::named_creation_functor<internal_condition> construct_func_t;
    /// @endcond
 };
 
@@ -233,7 +165,7 @@
 inline shm_named_condition::shm_named_condition(create_only_t, const char *name, const permissions &perm)
    : m_shmem (create_only
                ,name
- ,sizeof(condition_holder) +
+ ,sizeof(internal_condition) +
                   managed_open_or_create_impl<shared_memory_object>::
                      ManagedOpenOrCreateUserOffset
                ,read_write
@@ -245,7 +177,7 @@
 inline shm_named_condition::shm_named_condition(open_or_create_t, const char *name, const permissions &perm)
    : m_shmem (open_or_create
                ,name
- ,sizeof(condition_holder) +
+ ,sizeof(internal_condition) +
                   managed_open_or_create_impl<shared_memory_object>::
                      ManagedOpenOrCreateUserOffset
                ,read_write
@@ -268,102 +200,65 @@
 #if defined(BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
 
 inline void shm_named_condition::notify_one()
-{
- scoped_lock<interprocess_mutex> internal_lock(*this->mutex());
- this->condition()->notify_one();
-}
+{ m_cond.notify_one(); }
 
 inline void shm_named_condition::notify_all()
-{
- scoped_lock<interprocess_mutex> internal_lock(*this->mutex());
- this->condition()->notify_all();
-}
+{ m_cond.notify_all(); }
 
 template <typename L>
 inline void shm_named_condition::wait(L& lock)
-{
- if (!lock)
- throw lock_exception();
- this->do_wait(lock);
-}
+{ m_cond.wait(lock); }
 
 template <typename L, typename Pr>
 inline void shm_named_condition::wait(L& lock, Pr pred)
-{
- if (!lock)
- throw lock_exception();
- while (!pred())
- this->do_wait(lock);
-}
+{ m_cond.wait(lock, pred); }
 
 template <typename L>
 inline bool shm_named_condition::timed_wait
    (L& lock, const boost::posix_time::ptime &abs_time)
-{
- if(abs_time == boost::posix_time::pos_infin){
- this->wait(lock);
- return true;
- }
- if (!lock)
- throw lock_exception();
- return this->do_timed_wait(lock, abs_time);
-}
+{ return m_cond.timed_wait(lock, abs_time); }
 
 template <typename L, typename Pr>
 inline bool shm_named_condition::timed_wait
    (L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
-{
- if(abs_time == boost::posix_time::pos_infin){
- this->wait(lock, pred);
- return true;
- }
- if (!lock)
- throw lock_exception();
-
- while (!pred()){
- if(!this->do_timed_wait(lock, abs_time)){
- return pred();
- }
- }
- return true;
-}
+{ return m_cond.timed_wait(lock, abs_time, pred); }
 
 #else
 
 inline void shm_named_condition::notify_one()
-{ this->condition()->notify_one(); }
+{ m_cond.notify_one(); }
 
 inline void shm_named_condition::notify_all()
-{ this->condition()->notify_all(); }
+{ m_cond.notify_all(); }
 
 template <typename L>
 inline void shm_named_condition::wait(L& lock)
 {
- lock_wrapper<L> newlock(lock);
- this->condition()->wait(newlock);
+ internal_mutex_lock<L> internal_lock(lock);
+ m_cond.wait(internal_lock);
 }
 
 template <typename L, typename Pr>
 inline void shm_named_condition::wait(L& lock, Pr pred)
 {
- lock_wrapper<L> newlock(lock);
- this->condition()->wait(newlock, pred);
+ internal_mutex_lock<L> internal_lock(lock);
+ m_cond.wait(internal_lock, pred);
 }
 
 template <typename L>
 inline bool shm_named_condition::timed_wait
    (L& lock, const boost::posix_time::ptime &abs_time)
 {
- lock_wrapper<L> newlock(lock);
- return this->condition()->timed_wait(newlock, abs_time);
+ internal_mutex_lock<L> internal_lock(lock);
+ return m_cond.timed_wait(internal_lock, abs_time);
 }
 
 template <typename L, typename Pr>
 inline bool shm_named_condition::timed_wait
    (L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
 {
- lock_wrapper<L> newlock(lock);
- return this->condition()->timed_wait(newlock, abs_time, pred);
+ internal_mutex_lock<L> internal_lock(lock);
+ return m_cond.timed_wait(internal_lock, abs_time, pred);
 }
 
 #endif

Modified: branches/release/boost/interprocess/sync/shm/named_creation_functor.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/shm/named_creation_functor.hpp (original)
+++ branches/release/boost/interprocess/sync/shm/named_creation_functor.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2007-2012. 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)
 //
@@ -38,7 +38,7 @@
    { new(address)T(m_arg); }
 
    bool operator()(void *address, std::size_t, bool created) const
- {
+ {
       switch(m_creation_type){
          case DoOpen:
             return true;

Modified: branches/release/boost/interprocess/sync/shm/named_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/shm/named_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/shm/named_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -100,8 +100,9 @@
    static bool remove(const char *name);
 
    /// @cond
- interprocess_mutex *mutex() const
- { return static_cast<interprocess_mutex*>(m_shmem.get_user_address()); }
+ typedef interprocess_mutex internal_mutex_type;
+ interprocess_mutex &internal_mutex()
+ { return *static_cast<interprocess_mutex*>(m_shmem.get_user_address()); }
 
    private:
    friend class ipcdetail::interprocess_tester;
@@ -153,13 +154,13 @@
 {}
 
 inline void shm_named_mutex::lock()
-{ this->mutex()->lock(); }
+{ this->internal_mutex().lock(); }
 
 inline void shm_named_mutex::unlock()
-{ this->mutex()->unlock(); }
+{ this->internal_mutex().unlock(); }
 
 inline bool shm_named_mutex::try_lock()
-{ return this->mutex()->try_lock(); }
+{ return this->internal_mutex().try_lock(); }
 
 inline bool shm_named_mutex::timed_lock(const boost::posix_time::ptime &abs_time)
 {
@@ -167,7 +168,7 @@
       this->lock();
       return true;
    }
- return this->mutex()->timed_lock(abs_time);
+ return this->internal_mutex().timed_lock(abs_time);
 }
 
 inline bool shm_named_mutex::remove(const char *name)

Modified: branches/release/boost/interprocess/sync/shm/named_recursive_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/shm/named_recursive_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/shm/named_recursive_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/shm/named_semaphore.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/shm/named_semaphore.hpp (original)
+++ branches/release/boost/interprocess/sync/shm/named_semaphore.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
  //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/shm/named_upgradable_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/shm/named_upgradable_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/shm/named_upgradable_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/spin/condition.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/spin/condition.hpp (original)
+++ branches/release/boost/interprocess/sync/spin/condition.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -110,7 +110,7 @@
 }
 
 inline spin_condition::~spin_condition()
-{
+{
    //Trivial destructor
 }
 
@@ -171,7 +171,7 @@
                                      InterprocessMutex &mut)
 {
    boost::posix_time::ptime now = microsec_clock::universal_time();
-
+
    if(tout_enabled){
       if(now >= abs_time) return false;
    }
@@ -205,7 +205,7 @@
 
    //By default, we suppose that no timeout has happened
    bool timed_out = false, unlock_enter_mut= false;
-
+
    //Loop until a notification indicates that the thread should
    //exit or timeout occurs
    while(1){
@@ -253,7 +253,7 @@
             continue;
          }
          else if(result == NOTIFY_ONE){
- //If it was a NOTIFY_ONE command, only this thread should
+ //If it was a NOTIFY_ONE command, only this thread should
             //exit. This thread has atomically marked command as sleep before
             //so no other thread will exit.
             //Decrement wait count.

Modified: branches/release/boost/interprocess/sync/spin/mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/spin/mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/spin/mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -73,7 +73,7 @@
 
 inline bool spin_mutex::try_lock(void)
 {
- boost::uint32_t prev_s = ipcdetail::atomic_cas32(const_cast<boost::uint32_t*>(&m_s), 1, 0);
+ boost::uint32_t prev_s = ipcdetail::atomic_cas32(const_cast<boost::uint32_t*>(&m_s), 1, 0);
    return m_s == 1 && prev_s == 0;
 }
 

Modified: branches/release/boost/interprocess/sync/spin/recursive_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/spin/recursive_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/spin/recursive_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/spin/semaphore.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/spin/semaphore.hpp (original)
+++ branches/release/boost/interprocess/sync/spin/semaphore.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/upgradable_lock.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/upgradable_lock.hpp (original)
+++ branches/release/boost/interprocess/sync/upgradable_lock.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -207,7 +207,7 @@
    //!Notes: The sharable_lock changes from a state of not owning the mutex,
    //! to owning the mutex, blocking if necessary.
    void lock()
- {
+ {
       if(!mp_mutex || m_locked)
          throw lock_exception();
       mp_mutex->lock_upgradable();
@@ -223,7 +223,7 @@
    //! mutex_type does not support try_lock_upgradable(), this function will
    //! fail at compile time if instantiated, but otherwise have no effect.
    bool try_lock()
- {
+ {
       if(!mp_mutex || m_locked)
          throw lock_exception();
       m_locked = mp_mutex->try_lock_upgradable();
@@ -240,7 +240,7 @@
    //! timed_lock_upgradable(abs_time), this function will fail at compile
    //! time if instantiated, but otherwise have no effect.
    bool timed_lock(const boost::posix_time::ptime& abs_time)
- {
+ {
       if(!mp_mutex || m_locked)
          throw lock_exception();
       m_locked = mp_mutex->timed_lock_upgradable(abs_time);

Modified: branches/release/boost/interprocess/sync/windows/condition.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/windows/condition.hpp (original)
+++ branches/release/boost/interprocess/sync/windows/condition.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -33,63 +33,34 @@
    windows_condition &operator=(const windows_condition &);
 
    public:
- windows_condition();
- ~windows_condition();
+ windows_condition()
+ : m_condition_data()
+ {}
 
- void notify_one();
- void notify_all();
+ ~windows_condition()
+ {}
+
+ void notify_one()
+ { m_condition_data.notify_one(); }
+
+ void notify_all()
+ { m_condition_data.notify_all(); }
 
    template <typename L>
    bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time)
- {
- if(abs_time == boost::posix_time::pos_infin){
- this->wait(lock);
- return true;
- }
- if (!lock)
- throw lock_exception();
- return this->do_timed_wait(abs_time, *lock.mutex());
- }
+ { return m_condition_data.timed_wait(lock, abs_time); }
 
    template <typename L, typename Pr>
    bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
- {
- if(abs_time == boost::posix_time::pos_infin){
- this->wait(lock, pred);
- return true;
- }
- if (!lock)
- throw lock_exception();
- while (!pred()){
- if (!this->do_timed_wait(abs_time, *lock.mutex()))
- return pred();
- }
- return true;
- }
+ { return m_condition_data.timed_wait(lock, abs_time, pred); }
 
    template <typename L>
    void wait(L& lock)
- {
- if (!lock)
- throw lock_exception();
- do_wait(*lock.mutex());
- }
+ { m_condition_data.wait(lock); }
 
    template <typename L, typename Pr>
    void wait(L& lock, Pr pred)
- {
- if (!lock)
- throw lock_exception();
-
- while (!pred())
- do_wait(*lock.mutex());
- }
-
- template<class InterprocessMutex>
- void do_wait(InterprocessMutex &mut);
-
- template<class InterprocessMutex>
- bool do_timed_wait(const boost::posix_time::ptime &abs_time, InterprocessMutex &mut);
+ { m_condition_data.wait(lock, pred); }
 
    private:
 
@@ -132,33 +103,11 @@
       windows_semaphore m_sem_block_queue;
       windows_semaphore m_sem_block_lock;
       windows_mutex m_mtx_unblock_lock;
- } m_condition_data;
+ };
 
- typedef condition_algorithm_8a<condition_data> algorithm_type;
+ ipcdetail::condition_8a_wrapper<condition_data> m_condition_data;
 };
 
-inline windows_condition::windows_condition()
- : m_condition_data()
-{}
-
-inline windows_condition::~windows_condition()
-{}
-
-inline void windows_condition::notify_one()
-{ algorithm_type::signal(m_condition_data, false); }
-
-inline void windows_condition::notify_all()
-{ algorithm_type::signal(m_condition_data, true); }
-
-template<class InterprocessMutex>
-inline void windows_condition::do_wait(InterprocessMutex &mut)
-{ algorithm_type::wait(m_condition_data, false, boost::posix_time::ptime(), mut); }
-
-template<class InterprocessMutex>
-inline bool windows_condition::do_timed_wait
- (const boost::posix_time::ptime &abs_time, InterprocessMutex &mut)
-{ return algorithm_type::wait(m_condition_data, true, abs_time, mut); }
-
 } //namespace ipcdetail
 } //namespace interprocess
 } //namespace boost

Modified: branches/release/boost/interprocess/sync/windows/mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/windows/mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/windows/mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/windows/named_condition.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/windows/named_condition.hpp (original)
+++ branches/release/boost/interprocess/sync/windows/named_condition.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -17,313 +17,13 @@
 
 #include <boost/interprocess/detail/config_begin.hpp>
 #include <boost/interprocess/detail/workaround.hpp>
-#include <boost/interprocess/creation_tags.hpp>
-#include <boost/interprocess/permissions.hpp>
-#include <boost/interprocess/detail/interprocess_tester.hpp>
-#include <boost/interprocess/detail/posix_time_types_wrk.hpp>
-#include <boost/interprocess/sync/windows/named_sync.hpp>
-#include <boost/interprocess/sync/windows/winapi_semaphore_wrapper.hpp>
-#include <boost/interprocess/sync/detail/condition_algorithm_8a.hpp>
+#include <boost/interprocess/sync/windows/named_condition_any.hpp>
 
 namespace boost {
 namespace interprocess {
 namespace ipcdetail {
 
-class windows_named_condition
-{
- /// @cond
-
- //Non-copyable
- windows_named_condition();
- windows_named_condition(const windows_named_condition &);
- windows_named_condition &operator=(const windows_named_condition &);
- /// @endcond
-
- public:
- windows_named_condition(create_only_t, const char *name, const permissions &perm = permissions());
-
- windows_named_condition(open_or_create_t, const char *name, const permissions &perm = permissions());
-
- windows_named_condition(open_only_t, const char *name);
-
- ~windows_named_condition();
-
- //!If there is a thread waiting on *this, change that
- //!thread's state to ready. Otherwise there is no effect.*/
- void notify_one();
-
- //!Change the state of all threads waiting on *this to ready.
- //!If there are no waiting threads, notify_all() has no effect.
- void notify_all();
-
- //!Releases the lock on the named_mutex object associated with lock, blocks
- //!the current thread of execution until readied by a call to
- //!this->notify_one() or this->notify_all(), and then reacquires the lock.
- template <typename L>
- void wait(L& lock);
-
- //!The same as:
- //!while (!pred()) wait(lock)
- template <typename L, typename Pr>
- void wait(L& lock, Pr pred);
-
- //!Releases the lock on the named_mutex object associated with lock, blocks
- //!the current thread of execution until readied by a call to
- //!this->notify_one() or this->notify_all(), or until time abs_time is reached,
- //!and then reacquires the lock.
- //!Returns: false if time abs_time is reached, otherwise true.
- template <typename L>
- bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time);
-
- //!The same as: while (!pred()) {
- //! if (!timed_wait(lock, abs_time)) return pred();
- //! } return true;
- template <typename L, typename Pr>
- bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred);
-
- static bool remove(const char *name);
-
- /// @cond
- private:
- friend class interprocess_tester;
- void dont_close_on_destruction();
-
- template <class InterprocessMutex>
- void do_wait(InterprocessMutex& lock);
-
- template <class InterprocessMutex>
- bool do_timed_wait(const boost::posix_time::ptime &abs_time, InterprocessMutex& lock);
-
- struct condition_data
- {
- typedef boost::int32_t integer_type;
- typedef winapi_semaphore_wrapper semaphore_type;
- typedef winapi_mutex_wrapper mutex_type;
-
- integer_type &get_nwaiters_blocked()
- { return m_nwaiters_blocked; }
-
- integer_type &get_nwaiters_gone()
- { return m_nwaiters_gone; }
-
- integer_type &get_nwaiters_to_unblock()
- { return m_nwaiters_to_unblock; }
-
- semaphore_type &get_sem_block_queue()
- { return m_sem_block_queue; }
-
- semaphore_type &get_sem_block_lock()
- { return m_sem_block_lock; }
-
- mutex_type &get_mtx_unblock_lock()
- { return m_mtx_unblock_lock; }
-
- integer_type m_nwaiters_blocked;
- integer_type m_nwaiters_gone;
- integer_type m_nwaiters_to_unblock;
- winapi_semaphore_wrapper m_sem_block_queue;
- winapi_semaphore_wrapper m_sem_block_lock;
- winapi_mutex_wrapper m_mtx_unblock_lock;
- } m_condition_data;
-
- typedef condition_algorithm_8a<condition_data> algorithm_type;
-
- class named_cond_callbacks : public windows_named_sync_interface
- {
- typedef __int64 sem_count_t;
- mutable sem_count_t sem_counts [2];
-
- public:
- named_cond_callbacks(condition_data &cond_data)
- : m_condition_data(cond_data)
- {}
-
- virtual std::size_t get_data_size() const
- { return sizeof(sem_counts); }
-
- virtual const void *buffer_with_final_data_to_file()
- {
- sem_counts[0] = m_condition_data.m_sem_block_queue.value();
- sem_counts[1] = m_condition_data.m_sem_block_lock.value();
- return &sem_counts;
- }
-
- virtual const void *buffer_with_init_data_to_file()
- {
- sem_counts[0] = 0;
- sem_counts[1] = 1;
- return &sem_counts;
- }
-
- virtual void *buffer_to_store_init_data_from_file()
- { return &sem_counts; }
-
- virtual bool open(create_enum_t, const char *id_name)
- {
- m_condition_data.m_nwaiters_blocked = 0;
- m_condition_data.m_nwaiters_gone = 0;
- m_condition_data.m_nwaiters_to_unblock = 0;
-
- //Now open semaphores and mutex.
- //Use local variables + swap to guarantee consistent
- //initialization and cleanup in case any opening fails
- permissions perm;
- perm.set_unrestricted();
- std::string aux_str = "Global\\bipc.cond.";
- aux_str += id_name;
- std::size_t pos = aux_str.size();
-
- //sem_block_queue
- aux_str += "_bq";
- winapi_semaphore_wrapper sem_block_queue;
- bool created;
- if(!sem_block_queue.open_or_create
- (aux_str.c_str(), sem_counts[0], winapi_semaphore_wrapper::MaxCount, perm, created))
- return false;
- aux_str.erase(pos);
-
- //sem_block_lock
- aux_str += "_bl";
- winapi_semaphore_wrapper sem_block_lock;
- if(!sem_block_lock.open_or_create
- (aux_str.c_str(), sem_counts[1], winapi_semaphore_wrapper::MaxCount, perm, created))
- return false;
- aux_str.erase(pos);
-
- //mtx_unblock_lock
- aux_str += "_ul";
- winapi_mutex_wrapper mtx_unblock_lock;
- if(!mtx_unblock_lock.open_or_create(aux_str.c_str(), perm))
- return false;
-
- //All ok, commit data
- m_condition_data.m_sem_block_queue.swap(sem_block_queue);
- m_condition_data.m_sem_block_lock.swap(sem_block_lock);
- m_condition_data.m_mtx_unblock_lock.swap(mtx_unblock_lock);
- return true;
- }
-
- virtual void close()
- {
- m_condition_data.m_sem_block_queue.close();
- m_condition_data.m_sem_block_lock.close();
- m_condition_data.m_mtx_unblock_lock.close();
- m_condition_data.m_nwaiters_blocked = 0;
- m_condition_data.m_nwaiters_gone = 0;
- m_condition_data.m_nwaiters_to_unblock = 0;
- }
-
- virtual ~named_cond_callbacks()
- {}
-
- private:
- condition_data &m_condition_data;
- };
-
- windows_named_sync m_named_sync;
- /// @endcond
-};
-
-inline windows_named_condition::~windows_named_condition()
-{
- named_cond_callbacks callbacks(m_condition_data);
- m_named_sync.close(callbacks);
-}
-
-inline void windows_named_condition::dont_close_on_destruction()
-{}
-
-inline windows_named_condition::windows_named_condition
- (create_only_t, const char *name, const permissions &perm)
- : m_condition_data()
-{
- named_cond_callbacks callbacks(m_condition_data);
- m_named_sync.open_or_create(DoCreate, name, perm, callbacks);
-}
-
-inline windows_named_condition::windows_named_condition
- (open_or_create_t, const char *name, const permissions &perm)
- : m_condition_data()
-{
- named_cond_callbacks callbacks(m_condition_data);
- m_named_sync.open_or_create(DoOpenOrCreate, name, perm, callbacks);
-}
-
-inline windows_named_condition::windows_named_condition(open_only_t, const char *name)
- : m_condition_data()
-{
- named_cond_callbacks callbacks(m_condition_data);
- m_named_sync.open_or_create(DoOpen, name, permissions(), callbacks);
-}
-
-inline void windows_named_condition::notify_one()
-{ algorithm_type::signal(m_condition_data, false); }
-
-inline void windows_named_condition::notify_all()
-{ algorithm_type::signal(m_condition_data, true); }
-
-template<class InterprocessMutex>
-inline void windows_named_condition::do_wait(InterprocessMutex &mut)
-{ algorithm_type::wait(m_condition_data, false, boost::posix_time::ptime(), mut); }
-
-template<class InterprocessMutex>
-inline bool windows_named_condition::do_timed_wait
- (const boost::posix_time::ptime &abs_time, InterprocessMutex &mut)
-{ return algorithm_type::wait(m_condition_data, true, abs_time, mut); }
-
-template <typename L>
-inline void windows_named_condition::wait(L& lock)
-{
- if (!lock)
- throw lock_exception();
- this->do_wait(*lock.mutex());
-}
-
-template <typename L, typename Pr>
-inline void windows_named_condition::wait(L& lock, Pr pred)
-{
- if (!lock)
- throw lock_exception();
- while (!pred())
- this->do_wait(*lock.mutex());
-}
-
-template <typename L>
-inline bool windows_named_condition::timed_wait
- (L& lock, const boost::posix_time::ptime &abs_time)
-{
- if(abs_time == boost::posix_time::pos_infin){
- this->wait(lock);
- return true;
- }
- if (!lock)
- throw lock_exception();
- return this->do_timed_wait(abs_time, *lock.mutex());
-}
-
-template <typename L, typename Pr>
-inline bool windows_named_condition::timed_wait
- (L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
-{
- if(abs_time == boost::posix_time::pos_infin){
- this->wait(lock, pred);
- return true;
- }
- if (!lock)
- throw lock_exception();
-
- while (!pred()){
- if(!this->do_timed_wait(abs_time, *lock.mutex())){
- return pred();
- }
- }
- return true;
-}
-
-inline bool windows_named_condition::remove(const char *name)
-{
- return windows_named_sync::remove(name);
-}
+typedef windows_named_condition_any windows_named_condition;
 
 } //namespace ipcdetail {
 } //namespace interprocess {

Modified: branches/release/boost/interprocess/sync/windows/recursive_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/windows/recursive_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/windows/recursive_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/windows/semaphore.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/windows/semaphore.hpp (original)
+++ branches/release/boost/interprocess/sync/windows/semaphore.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/windows/sync_utils.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/windows/sync_utils.hpp (original)
+++ branches/release/boost/interprocess/sync/windows/sync_utils.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/xsi/simple_xsi_semaphore.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/xsi/simple_xsi_semaphore.hpp (original)
+++ branches/release/boost/interprocess/sync/xsi/simple_xsi_semaphore.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2011-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2011-2012. 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)
 //

Modified: branches/release/boost/interprocess/sync/xsi/xsi_named_mutex.hpp
==============================================================================
--- branches/release/boost/interprocess/sync/xsi/xsi_named_mutex.hpp (original)
+++ branches/release/boost/interprocess/sync/xsi/xsi_named_mutex.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-2012. 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)
 //
@@ -72,10 +72,10 @@
    //!After the call, "moved" does not represent any named mutex.
    //!Does not throw
    xsi_named_mutex &operator=(BOOST_RV_REF(xsi_named_mutex) moved)
- {
+ {
       xsi_named_mutex tmp(boost::move(moved));
       this->swap(tmp);
- return *this;
+ return *this;
    }
 
    //!Swaps two xsi_named_mutex. Does not throw
@@ -142,7 +142,7 @@
    std::swap(m_id, other.m_id);
    std::swap(m_semid, other.m_semid);
    std::swap(m_perm, other.m_perm);
- m_path.swap(other.m_path);
+ m_path.swap(other.m_path);
 }
 
 inline mapping_handle_t xsi_named_mutex::get_mapping_handle() const

Modified: branches/release/boost/interprocess/windows_shared_memory.hpp
==============================================================================
--- branches/release/boost/interprocess/windows_shared_memory.hpp (original)
+++ branches/release/boost/interprocess/windows_shared_memory.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -88,10 +88,10 @@
    //!After the call, "moved" does not represent any shared memory.
    //!Does not throw
    windows_shared_memory &operator=(BOOST_RV_REF(windows_shared_memory) moved)
- {
+ {
       windows_shared_memory tmp(boost::move(moved));
       this->swap(tmp);
- return *this;
+ return *this;
    }
 
    //!Swaps to shared_memory_objects. Does not throw
@@ -140,10 +140,10 @@
 { return m_name.c_str(); }
 
 inline void windows_shared_memory::swap(windows_shared_memory &other)
-{
+{
    std::swap(m_handle, other.m_handle);
    std::swap(m_mode, other.m_mode);
- m_name.swap(other.m_name);
+ m_name.swap(other.m_name);
 }
 
 inline mapping_handle_t windows_shared_memory::get_mapping_handle() const

Modified: branches/release/boost/interprocess/xsi_shared_memory.hpp
==============================================================================
--- branches/release/boost/interprocess/xsi_shared_memory.hpp (original)
+++ branches/release/boost/interprocess/xsi_shared_memory.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2009-2012. 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)
 //
@@ -89,10 +89,10 @@
    //!After the call, "moved" does not represent any shared memory.
    //!Does not throw
    xsi_shared_memory &operator=(BOOST_RV_REF(xsi_shared_memory) moved)
- {
+ {
       xsi_shared_memory tmp(boost::move(moved));
       this->swap(tmp);
- return *this;
+ return *this;
    }
 
    //!Swaps two xsi_shared_memorys. Does not throw

Modified: branches/release/boost/intrusive/avltree.hpp
==============================================================================
--- branches/release/boost/intrusive/avltree.hpp (original)
+++ branches/release/boost/intrusive/avltree.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -89,7 +89,7 @@
    typedef typename Config::value_traits value_traits;
    /// @cond
    static const bool external_value_traits =
- detail::external_value_traits_is_true<value_traits>::value;
+ detail::external_value_traits_bool_is_true<value_traits>::value;
    typedef typename detail::eval_if_c
       < external_value_traits
       , detail::eval_value_traits<value_traits>

Modified: branches/release/boost/intrusive/circular_slist_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/circular_slist_algorithms.hpp (original)
+++ branches/release/boost/intrusive/circular_slist_algorithms.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -172,18 +172,17 @@
    static node_ptr get_previous_previous_node(const node_ptr & this_node)
    { return get_previous_previous_node(this_node, this_node); }
 
- //! <b>Requires</b>: this_node and prev_prev_init_node must be in the same circular list.
+ //! <b>Requires</b>: this_node and p must be in the same circular list.
    //!
    //! <b>Effects</b>: Returns the previous node of the previous node of this_node in the
- //! circular list starting. the search from prev_init_node. The first node checked
- //! for equality is NodeTraits::get_next((NodeTraits::get_next(prev_prev_init_node)).
+ //! circular list starting. the search from p. The first node checked
+ //! for equality is NodeTraits::get_next((NodeTraits::get_next(p)).
    //!
    //! <b>Complexity</b>: Linear to the number of elements in the circular list.
    //!
    //! <b>Throws</b>: Nothing.
- static node_ptr get_previous_previous_node(const node_ptr & prev_prev_init_node, const node_ptr & this_node)
+ static node_ptr get_previous_previous_node(node_ptr p, const node_ptr & this_node)
    {
- node_ptr p = prev_prev_init_node;
       node_ptr p_next = NodeTraits::get_next(p);
       node_ptr p_next_next = NodeTraits::get_next(p_next);
       while (this_node != p_next_next){

Modified: branches/release/boost/intrusive/detail/avltree_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/avltree_node.hpp (original)
+++ branches/release/boost/intrusive/detail/avltree_node.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -68,19 +68,28 @@
 
    typedef typename node::balance balance;
 
- static const node_ptr & get_parent(const const_node_ptr & n)
+ static node_ptr get_parent(const const_node_ptr & n)
+ { return n->parent_; }
+
+ static node_ptr get_parent(const node_ptr & n)
    { return n->parent_; }
 
    static void set_parent(const node_ptr & n, const node_ptr & p)
    { n->parent_ = p; }
 
- static const node_ptr & get_left(const const_node_ptr & n)
+ static node_ptr get_left(const const_node_ptr & n)
+ { return n->left_; }
+
+ static node_ptr get_left(const node_ptr & n)
    { return n->left_; }
 
    static void set_left(const node_ptr & n, const node_ptr & l)
    { n->left_ = l; }
 
- static const node_ptr & get_right(const const_node_ptr & n)
+ static node_ptr get_right(const const_node_ptr & n)
+ { return n->right_; }
+
+ static node_ptr get_right(const node_ptr & n)
    { return n->right_; }
 
    static void set_right(const node_ptr & n, const node_ptr & r)
@@ -89,6 +98,9 @@
    static balance get_balance(const const_node_ptr & n)
    { return n->balance_; }
 
+ static balance get_balance(const node_ptr & n)
+ { return n->balance_; }
+
    static void set_balance(const node_ptr & n, balance b)
    { n->balance_ = b; }
 
@@ -125,13 +137,13 @@
    static void set_parent(const node_ptr & n, const node_ptr & p)
    { ptr_bit::set_pointer(n->parent_, p); }
 
- static const node_ptr & get_left(const const_node_ptr & n)
+ static node_ptr get_left(const const_node_ptr & n)
    { return n->left_; }
 
    static void set_left(const node_ptr & n, const node_ptr & l)
    { n->left_ = l; }
 
- static const node_ptr & get_right(const const_node_ptr & n)
+ static node_ptr get_right(const const_node_ptr & n)
    { return n->right_; }
 
    static void set_right(const node_ptr & n, const node_ptr & r)

Modified: branches/release/boost/intrusive/detail/common_slist_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/common_slist_algorithms.hpp (original)
+++ branches/release/boost/intrusive/detail/common_slist_algorithms.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -31,9 +31,8 @@
    typedef typename NodeTraits::const_node_ptr const_node_ptr;
    typedef NodeTraits node_traits;
 
- static node_ptr get_previous_node(const node_ptr & prev_init_node, const node_ptr & this_node)
+ static node_ptr get_previous_node(node_ptr p, const node_ptr & this_node)
    {
- node_ptr p = prev_init_node;
       for( node_ptr p_next
          ; this_node != (p_next = NodeTraits::get_next(p))
          ; p = p_next){

Modified: branches/release/boost/intrusive/detail/list_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/list_node.hpp (original)
+++ branches/release/boost/intrusive/detail/list_node.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -44,13 +44,19 @@
    typedef typename pointer_traits
       <VoidPointer>:: template rebind_pointer<const node>::type const_node_ptr;
 
- static const node_ptr &get_previous(const const_node_ptr & n)
+ static node_ptr get_previous(const const_node_ptr & n)
+ { return n->prev_; }
+
+ static node_ptr get_previous(const node_ptr & n)
    { return n->prev_; }
 
    static void set_previous(const node_ptr & n, const node_ptr & prev)
    { n->prev_ = prev; }
 
- static const node_ptr &get_next(const const_node_ptr & n)
+ static node_ptr get_next(const const_node_ptr & n)
+ { return n->next_; }
+
+ static node_ptr get_next(const node_ptr & n)
    { return n->next_; }
 
    static void set_next(const node_ptr & n, const node_ptr & next)

Modified: branches/release/boost/intrusive/detail/rbtree_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/rbtree_node.hpp (original)
+++ branches/release/boost/intrusive/detail/rbtree_node.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -68,19 +68,28 @@
 
    typedef typename node::color color;
 
- static const node_ptr & get_parent(const const_node_ptr & n)
+ static node_ptr get_parent(const const_node_ptr & n)
+ { return n->parent_; }
+
+ static node_ptr get_parent(const node_ptr & n)
    { return n->parent_; }
 
    static void set_parent(const node_ptr & n, const node_ptr & p)
    { n->parent_ = p; }
 
- static const node_ptr & get_left(const const_node_ptr & n)
+ static node_ptr get_left(const const_node_ptr & n)
+ { return n->left_; }
+
+ static node_ptr get_left(const node_ptr & n)
    { return n->left_; }
 
    static void set_left(const node_ptr & n, const node_ptr & l)
    { n->left_ = l; }
 
- static const node_ptr & get_right(const const_node_ptr & n)
+ static node_ptr get_right(const const_node_ptr & n)
+ { return n->right_; }
+
+ static node_ptr get_right(const node_ptr & n)
    { return n->right_; }
 
    static void set_right(const node_ptr & n, const node_ptr & r)
@@ -89,6 +98,9 @@
    static color get_color(const const_node_ptr & n)
    { return n->color_; }
 
+ static color get_color(const node_ptr & n)
+ { return n->color_; }
+
    static void set_color(const node_ptr & n, color c)
    { n->color_ = c; }
 
@@ -117,16 +129,25 @@
    static node_ptr get_parent(const const_node_ptr & n)
    { return ptr_bit::get_pointer(n->parent_); }
 
+ static node_ptr get_parent(const node_ptr & n)
+ { return ptr_bit::get_pointer(n->parent_); }
+
    static void set_parent(const node_ptr & n, const node_ptr & p)
    { ptr_bit::set_pointer(n->parent_, p); }
 
- static const node_ptr & get_left(const const_node_ptr & n)
+ static node_ptr get_left(const const_node_ptr & n)
+ { return n->left_; }
+
+ static node_ptr get_left(const node_ptr & n)
    { return n->left_; }
 
    static void set_left(const node_ptr & n, const node_ptr & l)
    { n->left_ = l; }
 
- static const node_ptr & get_right(const const_node_ptr & n)
+ static node_ptr get_right(const const_node_ptr & n)
+ { return n->right_; }
+
+ static node_ptr get_right(const node_ptr & n)
    { return n->right_; }
 
    static void set_right(const node_ptr & n, const node_ptr & r)
@@ -135,6 +156,9 @@
    static color get_color(const const_node_ptr & n)
    { return (color)ptr_bit::get_bits(n->parent_); }
 
+ static color get_color(const node_ptr & n)
+ { return (color)ptr_bit::get_bits(n->parent_); }
+
    static void set_color(const node_ptr & n, color c)
    { ptr_bit::set_bits(n->parent_, c != 0); }
 

Modified: branches/release/boost/intrusive/detail/slist_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/slist_node.hpp (original)
+++ branches/release/boost/intrusive/detail/slist_node.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -42,7 +42,10 @@
    typedef typename pointer_traits
       <VoidPointer>::template rebind_pointer<const node>::type const_node_ptr;
 
- static const node_ptr &get_next(const const_node_ptr & n)
+ static node_ptr get_next(const const_node_ptr & n)
+ { return n->next_; }
+
+ static node_ptr get_next(const node_ptr & n)
    { return n->next_; }
 
    static void set_next(const node_ptr & n, const node_ptr & next)

Modified: branches/release/boost/intrusive/detail/tree_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/tree_algorithms.hpp (original)
+++ branches/release/boost/intrusive/detail/tree_algorithms.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -485,15 +485,14 @@
    //! <b>Complexity</b>: Logarithmic to the size of the subtree.
    //!
    //! <b>Throws</b>: Nothing.
- static node_ptr minimum (const node_ptr & node)
+ static node_ptr minimum (node_ptr node)
    {
- node_ptr p(node);
- for(node_ptr p_left = NodeTraits::get_left(p)
+ for(node_ptr p_left = NodeTraits::get_left(node)
          ;p_left
- ;p_left = NodeTraits::get_left(p)){
- p = p_left;
+ ;p_left = NodeTraits::get_left(node)){
+ node = p_left;
       }
- return p;
+ return node;
    }
 
    //! <b>Requires</b>: 'node' is a node of a tree but not the header.
@@ -503,15 +502,14 @@
    //! <b>Complexity</b>: Logarithmic to the size of the subtree.
    //!
    //! <b>Throws</b>: Nothing.
- static node_ptr maximum(const node_ptr & node)
+ static node_ptr maximum(node_ptr node)
    {
- node_ptr p(node);
- for(node_ptr p_right = NodeTraits::get_right(p)
+ for(node_ptr p_right = NodeTraits::get_right(node)
          ;p_right
- ;p_right = NodeTraits::get_right(p)){
- p = p_right;
+ ;p_right = NodeTraits::get_right(node)){
+ node = p_right;
       }
- return p;
+ return node;
    }
 
    //! <b>Requires</b>: 'node' must not be part of any tree.
@@ -1171,14 +1169,13 @@
    //! <b>Complexity</b>: Logarithmic to the number of nodes in the tree.
    //!
    //! <b>Throws</b>: Nothing.
- static std::size_t depth(const const_node_ptr & node)
+ static std::size_t depth(const_node_ptr node)
    {
- const_node_ptr p(node);
       std::size_t depth = 0;
       node_ptr p_parent;
- while(p != NodeTraits::get_parent(p_parent = NodeTraits::get_parent(p))){
+ while(node != NodeTraits::get_parent(p_parent = NodeTraits::get_parent(node))){
          ++depth;
- p = p_parent;
+ node = p_parent;
       }
       return depth;
    }
@@ -1295,12 +1292,10 @@
    }
 
    template<class Disposer>
- static void dispose_subtree(const node_ptr & node, Disposer disposer)
+ static void dispose_subtree(node_ptr x, Disposer disposer)
    {
- node_ptr save;
- node_ptr x(node);
       while (x){
- save = NodeTraits::get_left(x);
+ node_ptr save(NodeTraits::get_left(x));
          if (save) {
             // Right rotation
             NodeTraits::set_left(x, NodeTraits::get_right(save));

Modified: branches/release/boost/intrusive/detail/tree_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/tree_node.hpp (original)
+++ branches/release/boost/intrusive/detail/tree_node.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -41,19 +41,28 @@
    typedef typename pointer_traits<VoidPointer>::template
       rebind_pointer<const node>::type const_node_ptr;
 
- static const node_ptr & get_parent(const const_node_ptr & n)
+ static node_ptr get_parent(const const_node_ptr & n)
+ { return n->parent_; }
+
+ static node_ptr get_parent(const node_ptr & n)
    { return n->parent_; }
 
    static void set_parent(const node_ptr & n, const node_ptr & p)
    { n->parent_ = p; }
 
- static const node_ptr & get_left(const const_node_ptr & n)
+ static node_ptr get_left(const const_node_ptr & n)
+ { return n->left_; }
+
+ static node_ptr get_left(const node_ptr & n)
    { return n->left_; }
 
    static void set_left(const node_ptr & n, const node_ptr & l)
    { n->left_ = l; }
 
- static const node_ptr & get_right(const const_node_ptr & n)
+ static node_ptr get_right(const const_node_ptr & n)
+ { return n->right_; }
+
+ static node_ptr get_right(const node_ptr & n)
    { return n->right_; }
 
    static void set_right(const node_ptr & n, const node_ptr & r)

Modified: branches/release/boost/intrusive/detail/utilities.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/utilities.hpp (original)
+++ branches/release/boost/intrusive/detail/utilities.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -41,64 +41,29 @@
    static const bool value = sizeof(test<T>(0)) == sizeof(detail::two);
 };
 
-template <class T>
-struct internal_base_hook_bool
-{
- template<bool Add>
- struct two_or_three {one _[2 + Add];};
- template <class U> static one test(...);
- template <class U> static two_or_three<U::boost_intrusive_tags::is_base_hook> test (int);
- static const std::size_t value = sizeof(test<T>(0));
-};
-
-template <class T>
-struct internal_base_hook_bool_is_true
-{
- static const bool value = internal_base_hook_bool<T>::value > sizeof(one)*2;
-};
-
-template <class T>
-struct internal_any_hook_bool
-{
- template<bool Add>
- struct two_or_three {one _[2 + Add];};
- template <class U> static one test(...);
- template <class U> static two_or_three<U::is_any_hook> test (int);
- static const std::size_t value = sizeof(test<T>(0));
-};
-
-template <class T>
-struct internal_any_hook_bool_is_true
-{
- static const bool value = internal_any_hook_bool<T>::value > sizeof(one)*2;
-};
-
-
-template <class T>
-struct external_value_traits_bool
-{
- template<bool Add>
- struct two_or_three {one _[2 + Add];};
- template <class U> static one test(...);
- template <class U> static two_or_three<U::external_value_traits> test (int);
- static const std::size_t value = sizeof(test<T>(0));
-};
-
-template <class T>
-struct external_bucket_traits_bool
-{
- template<bool Add>
- struct two_or_three {one _[2 + Add];};
- template <class U> static one test(...);
- template <class U> static two_or_three<U::external_bucket_traits> test (int);
- static const std::size_t value = sizeof(test<T>(0));
-};
-
-template <class T>
-struct external_value_traits_is_true
-{
- static const bool value = external_value_traits_bool<T>::value > sizeof(one)*2;
-};
+#define BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(TRAITS_PREFIX, TYPEDEF_TO_FIND) \
+template <class T>\
+struct TRAITS_PREFIX##_bool\
+{\
+ template<bool Add>\
+ struct two_or_three {one _[2 + Add];};\
+ template <class U> static one test(...);\
+ template <class U> static two_or_three<U::TYPEDEF_TO_FIND> test (int);\
+ static const std::size_t value = sizeof(test<T>(0));\
+};\
+\
+template <class T>\
+struct TRAITS_PREFIX##_bool_is_true\
+{\
+ static const bool value = TRAITS_PREFIX##_bool<T>::value > sizeof(one)*2;\
+};\
+//
+
+BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_base_hook, boost_intrusive_tags::is_base_hook)
+BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_any_hook, is_any_hook)
+BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(external_value_traits, external_value_traits)
+BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(external_bucket_traits, external_bucket_traits)
+BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(resizable, resizable)
 
 template<class Node, class Tag, link_mode_type LinkMode, int>
 struct node_holder
@@ -644,7 +609,7 @@
 {
    typedef typename Container::value_traits value_traits;
    static const bool value = store_cont_ptr_on_it_impl
- <value_traits, external_value_traits_is_true<value_traits>::value>::value;
+ <value_traits, external_value_traits_bool_is_true<value_traits>::value>::value;
 };
 
 template<class Container, bool IsConst>

Modified: branches/release/boost/intrusive/hashtable.hpp
==============================================================================
--- branches/release/boost/intrusive/hashtable.hpp (original)
+++ branches/release/boost/intrusive/hashtable.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -135,7 +135,7 @@
 struct real_from_supposed_value_traits
 {
    typedef typename detail::eval_if_c
- < detail::external_value_traits_is_true
+ < detail::external_value_traits_bool_is_true
          <SupposedValueTraits>::value
       , detail::eval_value_traits
          <SupposedValueTraits>
@@ -384,7 +384,7 @@
       slist_node_ptr possible_end = node_traits::get_next(last_node_group);
 
       while(!(bucket_beg <= possible_end && possible_end <= bucket_end)){
- first_node_of_group = dcast_bucket_ptr(possible_end);
+ first_node_of_group = group_functions::dcast_bucket_ptr(possible_end);
          last_node_group = group_traits::get_next(first_node_of_group);
          possible_end = node_traits::get_next(last_node_group);
       }
@@ -395,7 +395,7 @@
    {
       //Just iterate using group links and obtain the node
       //before "first_in_group)"
- node_ptr prev_node = dcast_bucket_ptr(bucket_node);
+ node_ptr prev_node = group_functions::dcast_bucket_ptr(bucket_node);
       node_ptr nxt(node_traits::get_next(prev_node));
       while(nxt != first_in_group){
          prev_node = group_traits::get_next(nxt);
@@ -480,7 +480,7 @@
       , const slist_node_ptr &first_end_ptr, const slist_node_ptr &last_end_ptr)
    {
       slist_node_ptr prev;
- node_ptr elem(dcast_bucket_ptr(i));
+ node_ptr elem(group_functions::dcast_bucket_ptr(i));
 
       //It's the last in group if the next_node is a bucket
       slist_node_ptr nxt(node_traits::get_next(elem));
@@ -687,7 +687,7 @@
 
    /// @cond
    static const bool external_value_traits =
- detail::external_value_traits_is_true<value_traits>::value;
+ detail::external_value_traits_bool_is_true<value_traits>::value;
    typedef typename detail::eval_if_c
       < external_value_traits
       , detail::eval_value_traits<value_traits>
@@ -695,7 +695,7 @@
>::type real_value_traits;
    typedef typename Config::bucket_traits bucket_traits;
    static const bool external_bucket_traits =
- detail::external_bucket_traits_is_true<bucket_traits>::value;
+ detail::external_bucket_traits_bool_is_true<bucket_traits>::value;
    typedef typename detail::eval_if_c
       < external_bucket_traits
       , detail::eval_bucket_traits<bucket_traits>
@@ -894,14 +894,14 @@
                   , const value_traits &v_traits = value_traits())
       : data_(b_traits, hash_func, equal_func, v_traits)
    {
- priv_initialize_buckets();
+ this->priv_initialize_buckets();
       this->priv_size_traits().set_size(size_type(0));
- size_type bucket_size = this->priv_buckets_len();
+ size_type bucket_size = this->priv_bucket_count();
       BOOST_INTRUSIVE_INVARIANT_ASSERT(bucket_size != 0);
       //Check power of two bucket array if the option is activated
       BOOST_INTRUSIVE_INVARIANT_ASSERT
          (!power_2_buckets || (0 == (bucket_size & (bucket_size-1))));
- priv_split_traits().set_size(bucket_size>>1);
+ this->priv_split_traits().set_size(bucket_size>>1);
    }
 
    //! <b>Effects</b>: to-do
@@ -913,7 +913,7 @@
              , ::boost::move(x.priv_value_traits())
              )
    {
- priv_swap_cache(cache_begin_t(), x);
+ this->priv_swap_cache(cache_begin_t(), x);
       x.priv_initialize_cache();
       if(constant_time_size){
          this->priv_size_traits().set_size(size_type(0));
@@ -976,7 +976,7 @@
    //!
    //! <b>Throws</b>: Nothing.
    iterator end()
- { return iterator(priv_invalid_local_it(), 0); }
+ { return iterator(this->priv_invalid_local_it(), 0); }
 
    //! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_set.
    //!
@@ -992,7 +992,7 @@
    //!
    //! <b>Throws</b>: Nothing.
    const_iterator cend() const
- { return const_iterator(priv_invalid_local_it(), 0); }
+ { return const_iterator(this->priv_invalid_local_it(), 0); }
 
    //! <b>Effects</b>: Returns the hasher object used by the unordered_set.
    //!
@@ -1026,9 +1026,9 @@
          return this->begin() == this->end();
       }
       else{
- size_type buckets_len = this->priv_buckets_len();
- const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_buckets());
- for (size_type n = 0; n < buckets_len; ++n, ++b){
+ size_type bucket_count = this->priv_bucket_count();
+ const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_bucket_pointer());
+ for (size_type n = 0; n < bucket_count; ++n, ++b){
             if(!b->empty()){
                return false;
             }
@@ -1049,9 +1049,9 @@
          return this->priv_size_traits().get_size();
       else{
          size_type len = 0;
- size_type buckets_len = this->priv_buckets_len();
- const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_buckets());
- for (size_type n = 0; n < buckets_len; ++n, ++b){
+ size_type bucket_count = this->priv_bucket_count();
+ const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_bucket_pointer());
+ for (size_type n = 0; n < bucket_count; ++n, ++b){
             len += b->size();
          }
          return len;
@@ -1077,7 +1077,7 @@
       //These can't throw
       swap(this->priv_bucket_traits(), other.priv_bucket_traits());
       swap(this->priv_value_traits(), other.priv_value_traits());
- priv_swap_cache(cache_begin_t(), other);
+ this->priv_swap_cache(cache_begin_t(), other);
       if(constant_time_size){
          size_type backup = this->priv_size_traits().get_size();
          this->priv_size_traits().set_size(other.priv_size_traits().get_size());
@@ -1125,8 +1125,8 @@
          //If src bucket count is bigger or equal, structural copy is possible
          if(!incremental && (src_bucket_count >= dst_bucket_count)){
             //First clone the first ones
- const bucket_ptr src_buckets = src.priv_buckets();
- const bucket_ptr dst_buckets = this->priv_buckets();
+ const bucket_ptr src_buckets = src.priv_bucket_pointer();
+ const bucket_ptr dst_buckets = this->priv_bucket_pointer();
             size_type constructed;
             typedef node_cast_adaptor<detail::node_disposer<Disposer, hashtable_impl> > NodeDisposer;
             typedef node_cast_adaptor<detail::node_cloner<Cloner, hashtable_impl> > NodeCloner;
@@ -1147,7 +1147,7 @@
                   ; constructed < src_bucket_count
                   ; ++constructed){
                   bucket_type &dst_b =
- dst_buckets[priv_hash_to_bucket(constructed, dst_bucket_count, dst_bucket_count)];
+ dst_buckets[this->priv_hash_to_bucket(constructed, dst_bucket_count, dst_bucket_count)];
                   bucket_type &src_b = src_buckets[constructed];
                   for( siterator b(src_b.begin()), e(src_b.end())
                      ; b != e
@@ -1161,8 +1161,8 @@
             rollback.release();
             this->priv_size_traits().set_size(src.priv_size_traits().get_size());
             this->priv_split_traits().set_size(dst_bucket_count);
- priv_insertion_update_cache(0u);
- priv_erasure_update_cache();
+ this->priv_insertion_update_cache(0u);
+ this->priv_erasure_update_cache();
          }
          else if(store_hash){
             //Unlike previous cloning algorithm, this can throw
@@ -1209,7 +1209,7 @@
       siterator prev;
       siterator it = this->priv_find
          (value, this->priv_hasher(), this->priv_equal(), bucket_num, hash_value, prev);
- return priv_insert_equal_find(value, bucket_num, hash_value, it);
+ return this->priv_insert_equal_find(value, bucket_num, hash_value, it);
    }
 
    //! <b>Requires</b>: Dereferencing iterator must yield an lvalue
@@ -1323,7 +1323,7 @@
       siterator prev;
       siterator prev_pos =
          this->priv_find(key, hash_func, equal_func, bucket_num, commit_data.hash, prev);
- bool success = prev_pos == priv_invalid_local_it();
+ bool success = prev_pos == this->priv_invalid_local_it();
       if(success){
          prev_pos = prev;
       }
@@ -1351,14 +1351,14 @@
    //! After a successful rehashing insert_commit_data remains valid.
    iterator insert_unique_commit(reference value, const insert_commit_data &commit_data)
    {
- size_type bucket_num = priv_hash_to_bucket(commit_data.hash);
- bucket_type &b = this->priv_buckets()[bucket_num];
+ size_type bucket_num = this->priv_hash_to_bucket(commit_data.hash);
+ bucket_type &b = this->priv_bucket_pointer()[bucket_num];
       this->priv_size_traits().increment();
- node_ptr n = pointer_traits<node_ptr>::pointer_to(priv_value_to_node(value));
+ node_ptr n = pointer_traits<node_ptr>::pointer_to(this->priv_value_to_node(value));
       node_functions_t::store_hash(n, commit_data.hash, store_hash_t());
       if(safemode_or_autounlink)
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n));
- priv_insertion_update_cache(bucket_num);
+ this->priv_insertion_update_cache(bucket_num);
       group_functions_t::insert_in_group(node_ptr(), n, optimize_multikey_t());
       return iterator(b.insert_after(b.before_begin(), *n), this);
    }
@@ -1443,9 +1443,9 @@
                               /// @endcond
                               )
    {
- priv_erase(i, disposer, optimize_multikey_t());
+ this->priv_erase(i, disposer, optimize_multikey_t());
       this->priv_size_traits().decrement();
- priv_erasure_update_cache();
+ this->priv_erasure_update_cache();
    }
 
    //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
@@ -1468,8 +1468,9 @@
          siterator first_local_it(b.slist_it());
          size_type first_bucket_num = this->priv_get_bucket_num(first_local_it);
 
+ const bucket_ptr bucket_pointer = this->priv_bucket_pointer();
          siterator before_first_local_it
- = priv_get_previous(priv_buckets()[first_bucket_num], first_local_it);
+ = this->priv_get_previous(bucket_pointer[first_bucket_num], first_local_it);
          size_type last_bucket_num;
          siterator last_local_it;
 
@@ -1477,14 +1478,14 @@
          //of the last bucket
          if(e == this->end()){
             last_bucket_num = this->bucket_count() - 1;
- last_local_it = priv_buckets()[last_bucket_num].end();
+ last_local_it = bucket_pointer[last_bucket_num].end();
          }
          else{
             last_local_it = e.slist_it();
             last_bucket_num = this->priv_get_bucket_num(last_local_it);
          }
- priv_erase_range(before_first_local_it, first_bucket_num, last_local_it, last_bucket_num, disposer);
- priv_erasure_update_cache(first_bucket_num, last_bucket_num);
+ this->priv_erase_range(before_first_local_it, first_bucket_num, last_local_it, last_bucket_num, disposer);
+ this->priv_erasure_update_cache(first_bucket_num, last_bucket_num);
       }
    }
 
@@ -1505,7 +1506,7 @@
    //! to the erased elements. No destructors are called.
    template<class Disposer>
    size_type erase_and_dispose(const_reference value, Disposer disposer)
- { return this->erase_and_dispose(value, priv_hasher(), priv_equal(), disposer); }
+ { return this->erase_and_dispose(value, this->priv_hasher(), this->priv_equal(), disposer); }
 
    //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
    //!
@@ -1531,7 +1532,7 @@
       siterator prev;
       siterator it =
          this->priv_find(key, hash_func, equal_func, bucket_num, h, prev);
- bool success = it != priv_invalid_local_it();
+ bool success = it != this->priv_invalid_local_it();
       size_type count(0);
       if(!success){
          return 0;
@@ -1539,15 +1540,15 @@
       else if(optimize_multikey){
          siterator last = bucket_type::s_iterator_to
             (*node_traits::get_next(group_functions_t::get_last_in_group
- (dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())));
+ (hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())));
          this->priv_erase_range_impl(bucket_num, prev, last, disposer, count);
       }
       else{
          //If found erase all equal values
- bucket_type &b = this->priv_buckets()[bucket_num];
+ bucket_type &b = this->priv_bucket_pointer()[bucket_num];
          for(siterator end = b.end(); it != end; ++count, ++it){
             slist_node_ptr n(it.pointed_node());
- const value_type &v = priv_value_from_slist_node(n);
+ const value_type &v = this->priv_value_from_slist_node(n);
             if(compare_hash){
                std::size_t vh = this->priv_stored_or_compute_hash(v, store_hash_t());
                if(h != vh || !equal_func(key, v)){
@@ -1561,7 +1562,7 @@
          }
          b.erase_after_and_dispose(prev, it, make_node_disposer(disposer));
       }
- priv_erasure_update_cache();
+ this->priv_erasure_update_cache();
       return count;
    }
 
@@ -1576,7 +1577,7 @@
    //! to the erased elements. No destructors are called.
    void clear()
    {
- priv_clear_buckets();
+ this->priv_clear_buckets();
       this->priv_size_traits().set_size(size_type(0));
    }
 
@@ -1596,13 +1597,13 @@
    {
       if(!constant_time_size || !this->empty()){
          size_type num_buckets = this->bucket_count();
- bucket_ptr b = this->priv_buckets();
+ bucket_ptr b = this->priv_bucket_pointer();
          for(; num_buckets--; ++b){
             b->clear_and_dispose(make_node_disposer(disposer));
          }
          this->priv_size_traits().set_size(size_type(0));
       }
- priv_initialize_cache();
+ this->priv_initialize_cache();
    }
 
    //! <b>Effects</b>: Returns the number of contained elements with the given value
@@ -1805,7 +1806,7 @@
    //! <b>Throws</b>: If the internal hash function throws.
    iterator iterator_to(reference value)
    {
- return iterator(bucket_type::s_iterator_to(priv_value_to_node(value)), this);
+ return iterator(bucket_type::s_iterator_to(this->priv_value_to_node(value)), this);
    }
 
    //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
@@ -1899,7 +1900,7 @@
    //!
    //! <b>Throws</b>: Nothing.
    size_type bucket_count() const
- { return this->priv_buckets_len(); }
+ { return this->priv_bucket_count(); }
 
    //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
    //!
@@ -1909,7 +1910,7 @@
    //!
    //! <b>Throws</b>: Nothing.
    size_type bucket_size(size_type n) const
- { return this->priv_buckets()[n].size(); }
+ { return this->priv_bucket_pointer()[n].size(); }
 
    //! <b>Effects</b>: Returns the index of the bucket in which elements
    //! with keys equivalent to k would be found, if any such element existed.
@@ -1936,7 +1937,7 @@
    //! <b>Note</b>: the return value is in the range [0, this->bucket_count()).
    template<class KeyType, class KeyHasher>
    size_type bucket(const KeyType& k, const KeyHasher &hash_func) const
- { return priv_hash_to_bucket(hash_func(k)); }
+ { return this->priv_hash_to_bucket(hash_func(k)); }
 
    //! <b>Effects</b>: Returns the bucket array pointer passed in the constructor
    //! or the last rehash function.
@@ -1945,7 +1946,7 @@
    //!
    //! <b>Throws</b>: Nothing.
    bucket_ptr bucket_pointer() const
- { return this->priv_buckets(); }
+ { return this->priv_bucket_pointer(); }
 
    //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
    //!
@@ -1959,7 +1960,7 @@
    //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
    //! containing all of the elements in the nth bucket.
    local_iterator begin(size_type n)
- { return local_iterator(this->priv_buckets()[n].begin(), this); }
+ { return local_iterator(this->priv_bucket_pointer()[n].begin(), this); }
 
    //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
    //!
@@ -1988,7 +1989,7 @@
    //! containing all of the elements in the nth bucket.
    const_local_iterator cbegin(size_type n) const
    {
- siterator sit = const_cast<bucket_type&>(this->priv_buckets()[n]).begin();
+ siterator sit = const_cast<bucket_type&>(this->priv_bucket_pointer()[n]).begin();
       return const_local_iterator(sit, this);
    }
 
@@ -2004,7 +2005,7 @@
    //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
    //! containing all of the elements in the nth bucket.
    local_iterator end(size_type n)
- { return local_iterator(this->priv_buckets()[n].end(), this); }
+ { return local_iterator(this->priv_bucket_pointer()[n].end(), this); }
 
    //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
    //!
@@ -2032,19 +2033,19 @@
    //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
    //! containing all of the elements in the nth bucket.
    const_local_iterator cend(size_type n) const
- { return const_local_iterator(const_cast<bucket_type&>(this->priv_buckets()[n]).end(), this); }
+ { return const_local_iterator(const_cast<bucket_type&>(this->priv_bucket_pointer()[n]).end(), this); }
 
- //! <b>Requires</b>: new_buckets must be a pointer to a new bucket array
- //! or the same as the old bucket array. new_size is the length of the
- //! the array pointed by new_buckets. If new_buckets == this->bucket_pointer()
- //! n can be bigger or smaller than this->bucket_count().
+ //! <b>Requires</b>: new_bucket_traits can hold a pointer to a new bucket array
+ //! or the same as the old bucket array with a different length. new_size is the length of the
+ //! the array pointed by new_buckets. If new_bucket_traits.bucket_begin() == this->bucket_pointer()
+ //! new_bucket_traits.bucket_count() can be bigger or smaller than this->bucket_count().
    //! 'new_bucket_traits' copy constructor should not throw.
    //!
- //! <b>Effects</b>: Updates the internal reference with the new bucket erases
+ //! <b>Effects</b>: Updates the internal reference with the new bucket, erases
    //! the values from the old bucket and inserts then in the new one.
    //! Bucket traits hold by *this is assigned from new_bucket_traits.
    //! If the container is configured as incremental<>, the split bucket is set
- //! to the new bucket_len().
+ //! to the new bucket_count().
    //!
    //! If store_hash option is true, this method does not use the hash function.
    //!
@@ -2053,27 +2054,27 @@
    //! <b>Throws</b>: If the hasher functor throws. Basic guarantee.
    void rehash(const bucket_traits &new_bucket_traits)
    {
- bucket_ptr new_buckets = new_bucket_traits.bucket_begin();
- size_type new_buckets_len = new_bucket_traits.bucket_count();
- bucket_ptr old_buckets = this->priv_buckets();
- size_type old_buckets_len = this->priv_buckets_len();
+ const bucket_ptr new_buckets = new_bucket_traits.bucket_begin();
+ size_type new_bucket_count = new_bucket_traits.bucket_count();
+ const bucket_ptr old_buckets = this->priv_bucket_pointer();
+ size_type old_bucket_count = this->priv_bucket_count();
 
       //Check power of two bucket array if the option is activated
       BOOST_INTRUSIVE_INVARIANT_ASSERT
- (!power_2_buckets || (0 == (new_buckets_len & (new_buckets_len-1u))));
+ (!power_2_buckets || (0 == (new_bucket_count & (new_bucket_count-1u))));
 
- size_type n = priv_get_cache_bucket_num();
+ size_type n = this->priv_get_cache_bucket_num();
       const bool same_buffer = old_buckets == new_buckets;
       //If the new bucket length is a common factor
       //of the old one we can avoid hash calculations.
- const bool fast_shrink = (!incremental) && (old_buckets_len > new_buckets_len) &&
- (power_2_buckets ||(old_buckets_len % new_buckets_len) == 0);
+ const bool fast_shrink = (!incremental) && (old_bucket_count > new_bucket_count) &&
+ (power_2_buckets ||(old_bucket_count % new_bucket_count) == 0);
       //If we are shrinking the same bucket array and it's
       //is a fast shrink, just rehash the last nodes
- size_type new_first_bucket_num = new_buckets_len;
- if(same_buffer && fast_shrink && (n < new_buckets_len)){
- n = new_buckets_len;
- new_first_bucket_num = priv_get_cache_bucket_num();
+ size_type new_first_bucket_num = new_bucket_count;
+ if(same_buffer && fast_shrink && (n < new_bucket_count)){
+ n = new_bucket_count;
+ new_first_bucket_num = this->priv_get_cache_bucket_num();
       }
 
       //Anti-exception stuff: they destroy the elements if something goes wrong.
@@ -2084,19 +2085,19 @@
       bucket_type & newbuck = new_buckets[0];
       bucket_type & oldbuck = old_buckets[0];
       detail::exception_array_disposer<bucket_type, NodeDisposer, size_type>
- rollback1(newbuck, node_disp, new_buckets_len);
+ rollback1(newbuck, node_disp, new_bucket_count);
       detail::exception_array_disposer<bucket_type, NodeDisposer, size_type>
- rollback2(oldbuck, node_disp, old_buckets_len);
+ rollback2(oldbuck, node_disp, old_bucket_count);
 
       //Put size in a safe value for rollback exception
       size_type size_backup = this->priv_size_traits().get_size();
       this->priv_size_traits().set_size(0);
       //Put cache to safe position
- priv_initialize_cache();
- priv_insertion_update_cache(size_type(0u));
+ this->priv_initialize_cache();
+ this->priv_insertion_update_cache(size_type(0u));
 
       //Iterate through nodes
- for(; n < old_buckets_len; ++n){
+ for(; n < old_bucket_count; ++n){
          bucket_type &old_bucket = old_buckets[n];
 
          if(!fast_shrink){
@@ -2104,14 +2105,14 @@
             siterator end(old_bucket.end());
             siterator i(old_bucket.begin());
             for(;i != end; ++i){
- const value_type &v = priv_value_from_slist_node(i.pointed_node());
+ const value_type &v = this->priv_value_from_slist_node(i.pointed_node());
                const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t());
- const size_type new_n = priv_hash_to_bucket(hash_value, new_buckets_len, new_buckets_len);
+ const size_type new_n = this->priv_hash_to_bucket(hash_value, new_bucket_count, new_bucket_count);
                if(cache_begin && new_n < new_first_bucket_num)
                   new_first_bucket_num = new_n;
                siterator last = bucket_type::s_iterator_to
                   (*group_functions_t::get_last_in_group
- (dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t()));
+ (hashtable_impl::dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t()));
                if(same_buffer && new_n == n){
                   before_i = last;
                }
@@ -2123,7 +2124,7 @@
             }
          }
          else{
- const size_type new_n = priv_hash_to_bucket(n, new_buckets_len, new_buckets_len);
+ const size_type new_n = this->priv_hash_to_bucket(n, new_bucket_count, new_bucket_count);
             if(cache_begin && new_n < new_first_bucket_num)
                new_first_bucket_num = new_n;
             bucket_type &new_b = new_buckets[new_n];
@@ -2131,16 +2132,16 @@
                new_b.splice_after( new_b.before_begin()
                                  , old_bucket
                                  , old_bucket.before_begin()
- , priv_get_last(old_bucket));
+ , hashtable_impl::priv_get_last(old_bucket));
             }
          }
       }
 
       this->priv_size_traits().set_size(size_backup);
- this->priv_split_traits().set_size(new_buckets_len);
+ this->priv_split_traits().set_size(new_bucket_count);
       this->priv_real_bucket_traits() = new_bucket_traits;
- priv_initialize_cache();
- priv_insertion_update_cache(new_first_bucket_num);
+ this->priv_initialize_cache();
+ this->priv_insertion_update_cache(new_first_bucket_num);
       rollback1.release();
       rollback2.release();
    }
@@ -2158,57 +2159,57 @@
    {
       //This function is only available for containers with incremental hashing
       BOOST_STATIC_ASSERT(( incremental && power_2_buckets ));
- size_type split_idx = priv_split_traits().get_size();
- size_type bucket_len = priv_buckets_len();
+ const size_type split_idx = this->priv_split_traits().get_size();
+ const size_type bucket_count = this->priv_bucket_count();
+ const bucket_ptr bucket_pointer = this->priv_bucket_pointer();
 
       if(grow){
          //Test if the split variable can be changed
- if(split_idx >= bucket_len)
+ if(split_idx >= bucket_count)
             return false;
 
- size_type bucket_len = priv_buckets_len();
- size_type bucket_to_rehash = split_idx - bucket_len/2;
- bucket_type &old_bucket = this->priv_buckets()[bucket_to_rehash];
+ const size_type bucket_to_rehash = split_idx - bucket_count/2;
+ bucket_type &old_bucket = bucket_pointer[bucket_to_rehash];
          siterator before_i(old_bucket.before_begin());
- siterator end(old_bucket.end());
+ const siterator end(old_bucket.end());
          siterator i(old_bucket.begin());
- priv_split_traits().increment();
+ this->priv_split_traits().increment();
 
          //Anti-exception stuff: if an exception is thrown while
          //moving elements from old_bucket to the target bucket, all moved
          //elements are moved back to the original one.
          detail::incremental_rehash_rollback<bucket_type, split_traits> rollback
- ( this->priv_buckets()[split_idx], old_bucket, priv_split_traits());
+ ( bucket_pointer[split_idx], old_bucket, this->priv_split_traits());
          for(;i != end; ++i){
- const value_type &v = priv_value_from_slist_node(i.pointed_node());
+ const value_type &v = this->priv_value_from_slist_node(i.pointed_node());
             const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t());
- const size_type new_n = priv_hash_to_bucket(hash_value);
+ const size_type new_n = this->priv_hash_to_bucket(hash_value);
             siterator last = bucket_type::s_iterator_to
                (*group_functions_t::get_last_in_group
- (dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t()));
+ (hashtable_impl::dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t()));
             if(new_n == bucket_to_rehash){
                before_i = last;
             }
             else{
- bucket_type &new_b = this->priv_buckets()[new_n];
+ bucket_type &new_b = bucket_pointer[new_n];
                new_b.splice_after(new_b.before_begin(), old_bucket, before_i, last);
             }
             i = before_i;
          }
          rollback.release();
- priv_erasure_update_cache();
+ this->priv_erasure_update_cache();
          return true;
       }
       else{
          //Test if the split variable can be changed
- if(split_idx <= bucket_len/2)
+ if(split_idx <= bucket_count/2)
             return false;
- const size_type target_bucket_num = split_idx - 1 - bucket_len/2;
- bucket_type &target_bucket = this->priv_buckets()[target_bucket_num];
- bucket_type &source_bucket = this->priv_buckets()[split_idx-1];
+ const size_type target_bucket_num = split_idx - 1 - bucket_count/2;
+ bucket_type &target_bucket = bucket_pointer[target_bucket_num];
+ bucket_type &source_bucket = bucket_pointer[split_idx-1];
          target_bucket.splice_after(target_bucket.cbefore_begin(), source_bucket);
- priv_split_traits().decrement();
- priv_insertion_update_cache(target_bucket_num);
+ this->priv_split_traits().decrement();
+ this->priv_insertion_update_cache(target_bucket_num);
          return true;
       }
    }
@@ -2231,7 +2232,7 @@
       //This function is only available for containers with incremental hashing
       BOOST_STATIC_ASSERT(( incremental && power_2_buckets ));
       size_type new_bucket_traits_size = new_bucket_traits.bucket_count();
- size_type cur_bucket_traits = this->priv_buckets_len();
+ size_type cur_bucket_traits = this->priv_bucket_count();
       if(new_bucket_traits_size/2 != cur_bucket_traits && new_bucket_traits_size != cur_bucket_traits/2){
          return false;
       }
@@ -2249,8 +2250,8 @@
             return false;
       }
 
- const size_type ini_n = priv_get_cache_bucket_num();
- const bucket_ptr old_buckets = this->priv_buckets();
+ const size_type ini_n = this->priv_get_cache_bucket_num();
+ const bucket_ptr old_buckets = this->priv_bucket_pointer();
       this->priv_real_bucket_traits() = new_bucket_traits;
       if(new_bucket_traits.bucket_begin() != old_buckets){
          for(size_type n = ini_n; n < split_idx; ++n){
@@ -2259,8 +2260,8 @@
             new_bucket.splice_after(new_bucket.cbefore_begin(), old_bucket);
          }
          //Put cache to safe position
- priv_initialize_cache();
- priv_insertion_update_cache(ini_n);
+ this->priv_initialize_cache();
+ this->priv_insertion_update_cache(ini_n);
       }
       return true;
    }
@@ -2321,22 +2322,22 @@
    private:
 
    std::size_t priv_hash_to_bucket(std::size_t hash_value) const
- { return priv_hash_to_bucket(hash_value, this->priv_real_bucket_traits().bucket_count(), priv_split_traits().get_size()); }
+ { return this->priv_hash_to_bucket(hash_value, this->priv_real_bucket_traits().bucket_count(), this->priv_split_traits().get_size()); }
 
- std::size_t priv_hash_to_bucket(std::size_t hash_value, std::size_t bucket_len, std::size_t split) const
+ std::size_t priv_hash_to_bucket(std::size_t hash_value, std::size_t bucket_count, std::size_t split) const
    {
- std::size_t bucket_number = priv_hash_to_bucket_impl(hash_value, bucket_len, power_2_buckets_t());
+ std::size_t bucket_number = hashtable_impl::priv_hash_to_bucket_impl(hash_value, bucket_count, power_2_buckets_t());
       if(incremental)
          if(bucket_number >= split)
- bucket_number -= bucket_len/2;
+ bucket_number -= bucket_count/2;
       return bucket_number;
    }
 
- std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_len, detail::false_) const
- { return hash_value % bucket_len; }
+ static std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_count, detail::false_)
+ { return hash_value % bucket_count; }
 
- std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_len, detail::true_) const
- { return hash_value & (bucket_len - 1); }
+ static std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_count, detail::true_)
+ { return hash_value & (bucket_count - 1); }
 
    const key_equal &priv_equal() const
    { return static_cast<const key_equal&>(this->data_.internal_.bucket_hash_equal_.get()); }
@@ -2351,10 +2352,10 @@
    { return data_; }
 
    value_type &priv_value_from_slist_node(slist_node_ptr n)
- { return *this->get_real_value_traits().to_value_ptr(dcast_bucket_ptr(n)); }
+ { return *this->get_real_value_traits().to_value_ptr(hashtable_impl::dcast_bucket_ptr(n)); }
 
    const value_type &priv_value_from_slist_node(slist_node_ptr n) const
- { return *this->get_real_value_traits().to_value_ptr(dcast_bucket_ptr(n)); }
+ { return *this->get_real_value_traits().to_value_ptr(hashtable_impl::dcast_bucket_ptr(n)); }
 
    const real_bucket_traits &priv_real_bucket_traits(detail::false_) const
    { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_; }
@@ -2386,15 +2387,12 @@
    hasher &priv_hasher()
    { return static_cast<hasher&>(this->data_.internal_.bucket_hash_equal_.bucket_hash.get()); }
 
- bucket_ptr priv_buckets() const
+ bucket_ptr priv_bucket_pointer() const
    { return this->priv_real_bucket_traits().bucket_begin(); }
 
- size_type priv_buckets_len() const
+ size_type priv_bucket_count() const
    { return this->priv_real_bucket_traits().bucket_count(); }
 
- static node_ptr uncast(const const_node_ptr & ptr)
- { return node_ptr(const_cast<node*>(boost::intrusive::detail::to_raw_pointer(ptr))); }
-
    node &priv_value_to_node(value_type &v)
    { return *this->get_real_value_traits().to_node_ptr(v); }
 
@@ -2417,11 +2415,11 @@
    void priv_erase_range_impl
       (size_type bucket_num, siterator before_first_it, siterator end, Disposer disposer, size_type &num_erased)
    {
- const bucket_ptr buckets = priv_buckets();
+ const bucket_ptr buckets = this->priv_bucket_pointer();
       bucket_type &b = buckets[bucket_num];
 
       if(before_first_it == b.before_begin() && end == b.end()){
- priv_erase_range_impl(bucket_num, 1, disposer, num_erased);
+ this->priv_erase_range_impl(bucket_num, 1, disposer, num_erased);
       }
       else{
          num_erased = 0;
@@ -2429,7 +2427,7 @@
          ++to_erase;
          slist_node_ptr end_ptr = end.pointed_node();
          while(to_erase != end){
- group_functions_t::erase_from_group(end_ptr, dcast_bucket_ptr(to_erase.pointed_node()), optimize_multikey_t());
+ group_functions_t::erase_from_group(end_ptr, hashtable_impl::dcast_bucket_ptr(to_erase.pointed_node()), optimize_multikey_t());
             to_erase = b.erase_after_and_dispose(before_first_it, make_node_disposer(disposer));
             ++num_erased;
          }
@@ -2442,7 +2440,7 @@
       (size_type first_bucket_num, size_type num_buckets, Disposer disposer, size_type &num_erased)
    {
       //Now fully clear the intermediate buckets
- const bucket_ptr buckets = priv_buckets();
+ const bucket_ptr buckets = this->priv_bucket_pointer();
       num_erased = 0;
       for(size_type i = first_bucket_num; i < (num_buckets + first_bucket_num); ++i){
          bucket_type &b = buckets[i];
@@ -2451,7 +2449,7 @@
          ++nxt;
          siterator end(b.end());
          while(nxt != end){
- group_functions_t::init_group(dcast_bucket_ptr(nxt.pointed_node()), optimize_multikey_t());
+ group_functions_t::init_group(hashtable_impl::dcast_bucket_ptr(nxt.pointed_node()), optimize_multikey_t());
             nxt = b.erase_after_and_dispose
                (b_begin, make_node_disposer(disposer));
             this->priv_size_traits().decrement();
@@ -2467,14 +2465,14 @@
    {
       size_type num_erased;
       if (first_bucket == last_bucket){
- priv_erase_range_impl(first_bucket, before_first_it, last_it, disposer, num_erased);
+ this->priv_erase_range_impl(first_bucket, before_first_it, last_it, disposer, num_erased);
       }
       else {
- bucket_type *b = (&this->priv_buckets()[0]);
- priv_erase_range_impl(first_bucket, before_first_it, b[first_bucket].end(), disposer, num_erased);
+ bucket_type *b = (&this->priv_bucket_pointer()[0]);
+ this->priv_erase_range_impl(first_bucket, before_first_it, b[first_bucket].end(), disposer, num_erased);
          if(size_type n = (last_bucket - first_bucket - 1))
- priv_erase_range_impl(first_bucket + 1, n, disposer, num_erased);
- priv_erase_range_impl(last_bucket, b[last_bucket].before_begin(), last_it, disposer, num_erased);
+ this->priv_erase_range_impl(first_bucket + 1, n, disposer, num_erased);
+ this->priv_erase_range_impl(last_bucket, b[last_bucket].before_begin(), last_it, disposer, num_erased);
       }
    }
 
@@ -2485,10 +2483,10 @@
    { return node_traits::get_hash(this->get_real_value_traits().to_node_ptr(v)); }
 
    std::size_t priv_stored_or_compute_hash(const value_type &v, detail::false_) const
- { return priv_hasher()(v); }
+ { return this->priv_hasher()(v); }
 
    std::size_t priv_stored_hash(slist_node_ptr n, detail::true_) const
- { return node_traits::get_hash(dcast_bucket_ptr(n)); }
+ { return node_traits::get_hash(hashtable_impl::dcast_bucket_ptr(n)); }
 
    std::size_t priv_stored_hash(slist_node_ptr, detail::false_) const
    {
@@ -2501,7 +2499,7 @@
    {
       siterator it(b.begin()), itend(b.end());
       while(it != itend){
- node_ptr to_erase(dcast_bucket_ptr(it.pointed_node()));
+ node_ptr to_erase(hashtable_impl::dcast_bucket_ptr(it.pointed_node()));
          ++it;
          group_algorithms::init(to_erase);
       }
@@ -2511,7 +2509,7 @@
    {}
 
    std::size_t priv_get_bucket_num(siterator it)
- { return priv_get_bucket_num_hash_dispatch(it, store_hash_t()); }
+ { return this->priv_get_bucket_num_hash_dispatch(it, store_hash_t()); }
 
    std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::true_)
    {
@@ -2520,15 +2518,15 @@
    }
 
    std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::false_)
- { return priv_get_bucket_num_no_hash_store(it, optimize_multikey_t()); }
+ { return this->priv_get_bucket_num_no_hash_store(it, optimize_multikey_t()); }
 
    std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::true_)
    {
- bucket_ptr f(priv_buckets()), l(f + priv_buckets_len() - 1);
+ const bucket_ptr f(this->priv_bucket_pointer()), l(f + this->priv_bucket_count() - 1);
       slist_node_ptr bb = group_functions_t::get_bucket_before_begin
          ( f->end().pointed_node()
          , l->end().pointed_node()
- , dcast_bucket_ptr(it.pointed_node()));
+ , hashtable_impl::dcast_bucket_ptr(it.pointed_node()));
       //Now get the bucket_impl from the iterator
       const bucket_type &b = static_cast<const bucket_type&>
          (bucket_type::slist_type::container_from_end_iterator(bucket_type::s_iterator_to(*bb)));
@@ -2538,7 +2536,7 @@
 
    std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::false_)
    {
- bucket_ptr f(priv_buckets()), l(f + priv_buckets_len() - 1);
+ bucket_ptr f(this->priv_bucket_pointer()), l(f + this->priv_bucket_count() - 1);
       slist_node_ptr first_ptr(f->cend().pointed_node())
                    , last_ptr(l->cend().pointed_node());
 
@@ -2557,12 +2555,12 @@
 
    siterator priv_get_previous
       (bucket_type &b, siterator i)
- { return priv_get_previous(b, i, optimize_multikey_t()); }
+ { return this->priv_get_previous(b, i, optimize_multikey_t()); }
 
    siterator priv_get_previous
       (bucket_type &b, siterator i, detail::true_)
    {
- node_ptr elem(dcast_bucket_ptr(i.pointed_node()));
+ node_ptr elem(hashtable_impl::dcast_bucket_ptr(i.pointed_node()));
       node_ptr prev_in_group(group_traits::get_next(elem));
       bool first_in_group = node_traits::get_next(prev_in_group) != elem;
       typename bucket_type::node &n = first_in_group
@@ -2577,7 +2575,7 @@
    { return b.previous(i); }
 
    static siterator priv_get_last(bucket_type &b)
- { return priv_get_last(b, optimize_multikey_t()); }
+ { return hashtable_impl::priv_get_last(b, optimize_multikey_t()); }
 
    static siterator priv_get_last(bucket_type &b, detail::true_)
    {
@@ -2585,11 +2583,11 @@
       //This requires checking the first node of the next group or
       //the bucket node.
       slist_node_ptr end_ptr(b.end().pointed_node());
- node_ptr possible_end(node_traits::get_next( dcast_bucket_ptr(end_ptr)));
+ node_ptr possible_end(node_traits::get_next( hashtable_impl::dcast_bucket_ptr(end_ptr)));
       node_ptr last_node_group(possible_end);
 
       while(end_ptr != possible_end){
- last_node_group = group_traits::get_next(dcast_bucket_ptr(possible_end));
+ last_node_group = group_traits::get_next(hashtable_impl::dcast_bucket_ptr(possible_end));
          possible_end = node_traits::get_next(last_node_group);
       }
       return bucket_type::s_iterator_to(*last_node_group);
@@ -2597,87 +2595,7 @@
 
    static siterator priv_get_last(bucket_type &b, detail::false_)
    { return b.previous(b.end()); }
-/*
- siterator priv_get_previous_and_next_in_group
- (siterator i, node_ptr &nxt_in_group)
- {
- siterator prev;
- node_ptr elem(dcast_bucket_ptr(i.pointed_node()));
- bucket_ptr f(priv_buckets()), l(f + priv_buckets_len() - 1);
-
- slist_node_ptr first_end_ptr(f->cend().pointed_node());
- slist_node_ptr last_end_ptr (l->cend().pointed_node());
-
- node_ptr nxt(node_traits::get_next(elem));
- node_ptr prev_in_group(group_traits::get_next(elem));
- bool last_in_group = (first_end_ptr <= nxt && nxt <= last_end_ptr) ||
- (group_traits::get_next(nxt) != elem);
- bool first_in_group = node_traits::get_next(prev_in_group) != elem;
 
- if(first_in_group){
- node_ptr start_pos;
- if(last_in_group){
- start_pos = elem;
- nxt_in_group = node_ptr();
- }
- else{
- start_pos = prev_in_group;
- nxt_in_group = node_traits::get_next(elem);
- }
- slist_node_ptr bucket_node;
- if(store_hash){
- bucket_node = this->priv_buckets()
- [this->priv_hash_to_bucket
- (this->priv_stored_hash(elem, store_hash_t()))
- ].before_begin().pointed_node();
- }
- else{
- bucket_node = group_functions_t::get_bucket_before_begin
- (first_end_ptr, last_end_ptr, start_pos);
- }
- prev = bucket_type::s_iterator_to
- (*group_functions_t::get_prev_to_first_in_group(bucket_node, elem));
- }
- else{
- if(last_in_group){
- nxt_in_group = group_functions_t::get_first_in_group_of_last_in_group(elem);
- }
- else{
- nxt_in_group = node_traits::get_next(elem);
- }
- prev = bucket_type::s_iterator_to(*group_traits::get_next(elem));
- }
- return prev;
- }
-*/
-
-/*
- template<class Disposer>
- void priv_erase(const_iterator i, Disposer disposer, detail::true_)
- {
- siterator elem(i.slist_it());
- node_ptr nxt_in_group;
- siterator prev = priv_get_previous_and_next_in_group(elem, nxt_in_group);
- bucket_type::s_erase_after_and_dispose(prev, make_node_disposer(disposer));
- if(nxt_in_group)
- group_algorithms::unlink_after(nxt_in_group);
- if(safemode_or_autounlink)
- group_algorithms::init(dcast_bucket_ptr(elem.pointed_node()));
- }
-*/
-
-/*
- if(store_hash){
- bucket_node = this->priv_buckets()
- [this->priv_hash_to_bucket
- (this->priv_stored_hash(elem, store_hash_t()))
- ].before_begin().pointed_node();
- }
- else{
- bucket_node = group_functions_t::get_bucket_before_begin
- (first_end_ptr, last_end_ptr, start_pos);
- }
-*/
    template<class Disposer>
    void priv_erase(const_iterator i, Disposer disposer, detail::true_)
    {
@@ -2685,14 +2603,14 @@
       slist_node_ptr f_bucket_end, l_bucket_end;
       if(store_hash){
          f_bucket_end = l_bucket_end =
- (this->priv_buckets()
+ (this->priv_bucket_pointer()
             [this->priv_hash_to_bucket
                (this->priv_stored_hash(elem, store_hash_t()))
             ]).before_begin().pointed_node();
       }
       else{
- f_bucket_end = this->priv_buckets()->cend().pointed_node();
- l_bucket_end = f_bucket_end + priv_buckets_len() - 1;
+ f_bucket_end = this->priv_bucket_pointer()->cend().pointed_node();
+ l_bucket_end = f_bucket_end + this->priv_bucket_count() - 1;
       }
       node_ptr nxt_in_group;
       siterator prev = bucket_type::s_iterator_to
@@ -2703,15 +2621,15 @@
       if(nxt_in_group)
          group_algorithms::unlink_after(nxt_in_group);
       if(safemode_or_autounlink)
- group_algorithms::init(dcast_bucket_ptr(elem));
+ group_algorithms::init(hashtable_impl::dcast_bucket_ptr(elem));
    }
 
    template <class Disposer>
    void priv_erase(const_iterator i, Disposer disposer, detail::false_)
    {
       siterator to_erase(i.slist_it());
- bucket_type &b = this->priv_buckets()[this->priv_get_bucket_num(to_erase)];
- siterator prev(priv_get_previous(b, to_erase));
+ bucket_type &b = this->priv_bucket_pointer()[this->priv_get_bucket_num(to_erase)];
+ siterator prev(this->priv_get_previous(b, to_erase));
       b.erase_after_and_dispose(prev, make_node_disposer(disposer));
    }
 
@@ -2722,28 +2640,28 @@
    }
 
    siterator priv_invalid_local_it() const
- { return priv_invalid_bucket()->end(); }
+ { return this->priv_invalid_bucket()->end(); }
 
    siterator priv_begin() const
- { return priv_begin(cache_begin_t()); }
+ { return this->priv_begin(cache_begin_t()); }
 
    siterator priv_begin(detail::false_) const
    {
       size_type n = 0;
- size_type buckets_len = this->priv_buckets_len();
- for (n = 0; n < buckets_len; ++n){
- bucket_type &b = this->priv_buckets()[n];
+ size_type bucket_count = this->priv_bucket_count();
+ for (n = 0; n < bucket_count; ++n){
+ bucket_type &b = this->priv_bucket_pointer()[n];
          if(!b.empty()){
             return b.begin();
          }
       }
- return priv_invalid_local_it();
+ return this->priv_invalid_local_it();
    }
 
    siterator priv_begin(detail::true_) const
    {
- if(this->data_.internal_.bucket_hash_equal_.cached_begin_ == priv_invalid_bucket()){
- return priv_invalid_local_it();
+ if(this->data_.internal_.bucket_hash_equal_.cached_begin_ == this->priv_invalid_bucket()){
+ return this->priv_invalid_local_it();
       }
       else{
          return this->data_.internal_.bucket_hash_equal_.cached_begin_->begin();
@@ -2751,20 +2669,20 @@
    }
 
    void priv_initialize_cache()
- { priv_initialize_cache(cache_begin_t()); }
+ { this->priv_initialize_cache(cache_begin_t()); }
 
    void priv_initialize_cache(detail::true_)
- { this->data_.internal_.bucket_hash_equal_.cached_begin_ = priv_invalid_bucket(); }
+ { this->data_.internal_.bucket_hash_equal_.cached_begin_ = this->priv_invalid_bucket(); }
 
    void priv_initialize_cache(detail::false_)
    {}
 
    void priv_insertion_update_cache(size_type insertion_bucket)
- { priv_insertion_update_cache(insertion_bucket, cache_begin_t()); }
+ { this->priv_insertion_update_cache(insertion_bucket, cache_begin_t()); }
 
    void priv_insertion_update_cache(size_type insertion_bucket, detail::true_)
    {
- bucket_ptr p = priv_buckets() + insertion_bucket;
+ bucket_ptr p = this->priv_bucket_pointer() + insertion_bucket;
       if(p < this->data_.internal_.bucket_hash_equal_.cached_begin_){
          this->data_.internal_.bucket_hash_equal_.cached_begin_ = p;
       }
@@ -2774,16 +2692,16 @@
    {}
 
    void priv_erasure_update_cache(size_type first_bucket, size_type last_bucket)
- { priv_erasure_update_cache(first_bucket, last_bucket, cache_begin_t()); }
+ { this->priv_erasure_update_cache(first_bucket, last_bucket, cache_begin_t()); }
 
    void priv_erasure_update_cache(size_type first_bucket_num, size_type last_bucket_num, detail::true_)
    {
       //If the last bucket is the end, the cache must be updated
       //to the last position if all
- if(priv_get_cache_bucket_num() == first_bucket_num &&
- priv_buckets()[first_bucket_num].empty() ){
- priv_set_cache(priv_buckets() + last_bucket_num);
- priv_erasure_update_cache();
+ if(this->priv_get_cache_bucket_num() == first_bucket_num &&
+ this->priv_bucket_pointer()[first_bucket_num].empty() ){
+ this->priv_set_cache(this->priv_bucket_pointer() + last_bucket_num);
+ this->priv_erasure_update_cache();
       }
    }
 
@@ -2791,23 +2709,23 @@
    {}
 
    void priv_erasure_update_cache()
- { priv_erasure_update_cache(cache_begin_t()); }
+ { this->priv_erasure_update_cache(cache_begin_t()); }
 
    void priv_erasure_update_cache(detail::true_)
    {
       if(constant_time_size && !size()){
- priv_initialize_cache();
+ this->priv_initialize_cache();
       }
       else{
- size_type current_n = this->data_.internal_.bucket_hash_equal_.cached_begin_ - priv_buckets();
- for( const size_type num_buckets = this->priv_buckets_len()
+ size_type current_n = this->data_.internal_.bucket_hash_equal_.cached_begin_ - this->priv_bucket_pointer();
+ for( const size_type num_buckets = this->priv_bucket_count()
             ; current_n < num_buckets
             ; ++current_n, ++this->data_.internal_.bucket_hash_equal_.cached_begin_){
             if(!this->data_.internal_.bucket_hash_equal_.cached_begin_->empty()){
                return;
             }
          }
- priv_initialize_cache();
+ this->priv_initialize_cache();
       }
    }
 
@@ -2824,22 +2742,22 @@
    {}
 
    bucket_ptr priv_get_cache()
- { return priv_get_cache(cache_begin_t()); }
+ { return this->priv_get_cache(cache_begin_t()); }
 
    bucket_ptr priv_get_cache(detail::true_)
    { return this->data_.internal_.bucket_hash_equal_.cached_begin_; }
 
    bucket_ptr priv_get_cache(detail::false_)
- { return this->priv_buckets(); }
+ { return this->priv_bucket_pointer(); }
 
    void priv_set_cache(const bucket_ptr &p)
    { this->data_.internal_.bucket_hash_equal_.set_cache(p); }
 
    size_type priv_get_cache_bucket_num()
- { return priv_get_cache_bucket_num(cache_begin_t()); }
+ { return this->priv_get_cache_bucket_num(cache_begin_t()); }
 
    size_type priv_get_cache_bucket_num(detail::true_)
- { return this->data_.internal_.bucket_hash_equal_.cached_begin_ - this->priv_buckets(); }
+ { return this->data_.internal_.bucket_hash_equal_.cached_begin_ - this->priv_bucket_pointer(); }
 
    size_type priv_get_cache_bucket_num(detail::false_)
    { return 0u; }
@@ -2847,25 +2765,25 @@
    void priv_clear_buckets()
    {
       this->priv_clear_buckets
- ( priv_get_cache()
- , this->priv_buckets_len() - (priv_get_cache() - priv_buckets()));
+ ( this->priv_get_cache()
+ , this->priv_bucket_count() - (this->priv_get_cache() - this->priv_bucket_pointer()));
    }
 
    void priv_initialize_buckets()
- { this->priv_clear_buckets(priv_buckets(), this->priv_buckets_len()); }
+ { this->priv_clear_buckets(this->priv_bucket_pointer(), this->priv_bucket_count()); }
 
- void priv_clear_buckets(bucket_ptr buckets_ptr, size_type buckets_len)
+ void priv_clear_buckets(bucket_ptr buckets_ptr, size_type bucket_count)
    {
- for(; buckets_len--; ++buckets_ptr){
+ for(; bucket_count--; ++buckets_ptr){
          if(safemode_or_autounlink){
- priv_clear_group_nodes(*buckets_ptr, optimize_multikey_t());
+ hashtable_impl::priv_clear_group_nodes(*buckets_ptr, optimize_multikey_t());
             buckets_ptr->clear_and_dispose(detail::init_disposer<node_algorithms>());
          }
          else{
             buckets_ptr->clear();
          }
       }
- priv_initialize_cache();
+ this->priv_initialize_cache();
    }
 
    template<class KeyType, class KeyHasher, class KeyValueEqual>
@@ -2874,25 +2792,25 @@
       , KeyValueEqual equal_func, size_type &bucket_number, std::size_t &h, siterator &previt) const
    {
       h = hash_func(key);
- return priv_find_with_hash(key, equal_func, bucket_number, h, previt);
+ return this->priv_find_with_hash(key, equal_func, bucket_number, h, previt);
    }
 
    template<class KeyType, class KeyValueEqual>
    siterator priv_find_with_hash
       ( const KeyType &key, KeyValueEqual equal_func, size_type &bucket_number, const std::size_t h, siterator &previt) const
    {
- bucket_number = priv_hash_to_bucket(h);
- bucket_type &b = this->priv_buckets()[bucket_number];
+ bucket_number = this->priv_hash_to_bucket(h);
+ bucket_type &b = this->priv_bucket_pointer()[bucket_number];
       previt = b.before_begin();
       if(constant_time_size && this->empty()){
- return priv_invalid_local_it();
+ return this->priv_invalid_local_it();
       }
 
       siterator it = previt;
       ++it;
 
       while(it != b.end()){
- const value_type &v = priv_value_from_slist_node(it.pointed_node());
+ const value_type &v = this->priv_value_from_slist_node(it.pointed_node());
          if(compare_hash){
             std::size_t vh = this->priv_stored_or_compute_hash(v, store_hash_t());
             if(h == vh && equal_func(key, v)){
@@ -2905,7 +2823,7 @@
          if(optimize_multikey){
             previt = bucket_type::s_iterator_to
                (*group_functions_t::get_last_in_group
- (dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()));
+ (hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()));
             it = previt;
          }
          else{
@@ -2914,7 +2832,7 @@
          ++it;
       }
       previt = b.before_begin();
- return priv_invalid_local_it();
+ return this->priv_invalid_local_it();
    }
 
    iterator priv_insert_equal_with_hash(reference value, std::size_t hash_value)
@@ -2923,18 +2841,18 @@
       siterator prev;
       siterator it = this->priv_find_with_hash
          (value, this->priv_equal(), bucket_num, hash_value, prev);
- return priv_insert_equal_find(value, bucket_num, hash_value, it);
+ return this->priv_insert_equal_find(value, bucket_num, hash_value, it);
    }
 
    iterator priv_insert_equal_find(reference value, size_type bucket_num, std::size_t hash_value, siterator it)
    {
- bucket_type &b = this->priv_buckets()[bucket_num];
- bool found_equal = it != priv_invalid_local_it();
+ bucket_type &b = this->priv_bucket_pointer()[bucket_num];
+ bool found_equal = it != this->priv_invalid_local_it();
       if(!found_equal){
          it = b.before_begin();
       }
       //Now store hash if needed
- node_ptr n = pointer_traits<node_ptr>::pointer_to(priv_value_to_node(value));
+ node_ptr n = pointer_traits<node_ptr>::pointer_to(this->priv_value_to_node(value));
       node_functions_t::store_hash(n, hash_value, store_hash_t());
       //Checks for some modes
       if(safemode_or_autounlink)
@@ -2942,11 +2860,11 @@
       //Shorcut for optimize_multikey cases
       if(optimize_multikey){
          node_ptr first_in_group = found_equal ?
- dcast_bucket_ptr(it.pointed_node()) : node_ptr();
+ hashtable_impl::dcast_bucket_ptr(it.pointed_node()) : node_ptr();
          group_functions_t::insert_in_group(first_in_group, n, optimize_multikey_t());
       }
       //Update cache and increment size if needed
- priv_insertion_update_cache(bucket_num);
+ this->priv_insertion_update_cache(bucket_num);
       this->priv_size_traits().increment();
       //Insert the element in the bucket after it
       return iterator(b.insert_after(it, *n), this);
@@ -2966,20 +2884,20 @@
       siterator prev;
       //Let's see if the element is present
       std::pair<siterator, siterator> to_return
- ( priv_find(key, hash_func, equal_func, bucket_number_first, h, prev)
- , priv_invalid_local_it());
+ ( this->priv_find(key, hash_func, equal_func, bucket_number_first, h, prev)
+ , this->priv_invalid_local_it());
       if(to_return.first == to_return.second){
          bucket_number_second = bucket_number_first;
          return to_return;
       }
       //If it's present, find the first that it's not equal in
       //the same bucket
- bucket_type &b = this->priv_buckets()[bucket_number_first];
+ bucket_type &b = this->priv_bucket_pointer()[bucket_number_first];
       siterator it = to_return.first;
       if(optimize_multikey){
          to_return.second = bucket_type::s_iterator_to
             (*node_traits::get_next(group_functions_t::get_last_in_group
- (dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())));
+ (hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())));
          count = std::distance(it, to_return.second);
          if(to_return.second != b.end()){
             bucket_number_second = bucket_number_first;
@@ -2990,7 +2908,7 @@
          ++count;
          ++it;
          while(it != b.end()){
- const value_type &v = priv_value_from_slist_node(it.pointed_node());
+ const value_type &v = this->priv_value_from_slist_node(it.pointed_node());
             if(compare_hash){
                std::size_t hv = this->priv_stored_or_compute_hash(v, store_hash_t());
                if(hv != h || !equal_func(key, v)){
@@ -3011,9 +2929,9 @@
 
       //If we reached the end, find the first, non-empty bucket
       for(bucket_number_second = bucket_number_first+1
- ; bucket_number_second != this->priv_buckets_len()
+ ; bucket_number_second != this->priv_bucket_count()
          ; ++bucket_number_second){
- bucket_type &b = this->priv_buckets()[bucket_number_second];
+ bucket_type &b = this->priv_bucket_pointer()[bucket_number_second];
          if(!b.empty()){
             to_return.second = b.begin();
             return to_return;
@@ -3021,7 +2939,7 @@
       }
 
       //Otherwise, return the end node
- to_return.second = priv_invalid_local_it();
+ to_return.second = this->priv_invalid_local_it();
       return to_return;
    }
    /// @endcond
@@ -3055,7 +2973,9 @@
    typedef typename detail::get_value_traits
       <T, typename packed_options::value_traits>::type value_traits;
    static const bool external_value_traits =
- detail::external_value_traits_is_true<value_traits>::value;
+ detail::external_value_traits_bool_is_true<value_traits>::value;/*
+ static const bool resizable_bucket_traits =
+ detail::resizable_bool_is_true<bucket_traits_traits>::value;*/
    typedef typename detail::eval_if_c
       < external_value_traits
       , detail::eval_value_traits<value_traits>

Modified: branches/release/boost/intrusive/list.hpp
==============================================================================
--- branches/release/boost/intrusive/list.hpp (original)
+++ branches/release/boost/intrusive/list.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -83,7 +83,7 @@
    typedef typename Config::value_traits value_traits;
    /// @cond
    static const bool external_value_traits =
- detail::external_value_traits_is_true<value_traits>::value;
+ detail::external_value_traits_bool_is_true<value_traits>::value;
    typedef typename detail::eval_if_c
       < external_value_traits
       , detail::eval_value_traits<value_traits>

Modified: branches/release/boost/intrusive/options.hpp
==============================================================================
--- branches/release/boost/intrusive/options.hpp (original)
+++ branches/release/boost/intrusive/options.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -57,12 +57,6 @@
    typedef typename ValueTraits::value_traits type;
 };
 
-template <class T>
-struct external_bucket_traits_is_true
-{
- static const bool value = external_bucket_traits_bool<T>::value == 3;
-};
-
 template <class BucketTraits>
 struct eval_bucket_traits
 {

Modified: branches/release/boost/intrusive/pointer_traits.hpp
==============================================================================
--- branches/release/boost/intrusive/pointer_traits.hpp (original)
+++ branches/release/boost/intrusive/pointer_traits.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -170,7 +170,7 @@
 
    template<class UPtr>
    static pointer priv_static_cast_from(boost::false_type, const UPtr &uptr)
- { return pointer_to(static_cast<element_type&>(*uptr)); }
+ { return pointer_to(*static_cast<element_type*>(to_raw_pointer(uptr))); }
 
    //priv_const_cast_from
    template<class UPtr>

Modified: branches/release/boost/intrusive/rbtree.hpp
==============================================================================
--- branches/release/boost/intrusive/rbtree.hpp (original)
+++ branches/release/boost/intrusive/rbtree.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -89,7 +89,7 @@
    typedef typename Config::value_traits value_traits;
    /// @cond
    static const bool external_value_traits =
- detail::external_value_traits_is_true<value_traits>::value;
+ detail::external_value_traits_bool_is_true<value_traits>::value;
    typedef typename detail::eval_if_c
       < external_value_traits
       , detail::eval_value_traits<value_traits>

Modified: branches/release/boost/intrusive/rbtree_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/rbtree_algorithms.hpp (original)
+++ branches/release/boost/intrusive/rbtree_algorithms.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -805,26 +805,26 @@
       // NodeTraits::get_parent(NodeTraits::get_parent(p)) == p;
    }
 
- static void rebalance_after_erasure(const node_ptr & header, const node_ptr &xnode, const node_ptr &xnode_parent)
+ static void rebalance_after_erasure(const node_ptr & header, node_ptr x, node_ptr x_parent)
    {
- node_ptr x(xnode), x_parent(xnode_parent);
- while(x != NodeTraits::get_parent(header) && (x == node_ptr() || NodeTraits::get_color(x) == NodeTraits::black())){
+ while(x != NodeTraits::get_parent(header) && (!x || NodeTraits::get_color(x) == NodeTraits::black())){
          if(x == NodeTraits::get_left(x_parent)){
             node_ptr w = NodeTraits::get_right(x_parent);
+ BOOST_ASSERT(w);
             if(NodeTraits::get_color(w) == NodeTraits::red()){
                NodeTraits::set_color(w, NodeTraits::black());
                NodeTraits::set_color(x_parent, NodeTraits::red());
                tree_algorithms::rotate_left(x_parent, header);
                w = NodeTraits::get_right(x_parent);
             }
- if((NodeTraits::get_left(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black()) &&
- (NodeTraits::get_right(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black())){
+ if((!NodeTraits::get_left(w) || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black()) &&
+ (!NodeTraits::get_right(w) || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black())){
                NodeTraits::set_color(w, NodeTraits::red());
                x = x_parent;
                x_parent = NodeTraits::get_parent(x_parent);
             }
             else {
- if(NodeTraits::get_right(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black()){
+ if(!NodeTraits::get_right(w) || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black()){
                   NodeTraits::set_color(NodeTraits::get_left(w), NodeTraits::black());
                   NodeTraits::set_color(w, NodeTraits::red());
                   tree_algorithms::rotate_right(w, header);
@@ -847,14 +847,14 @@
                tree_algorithms::rotate_right(x_parent, header);
                w = NodeTraits::get_left(x_parent);
             }
- if((NodeTraits::get_right(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black()) &&
- (NodeTraits::get_left(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black())){
+ if((!NodeTraits::get_right(w) || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black()) &&
+ (!NodeTraits::get_left(w) || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black())){
                NodeTraits::set_color(w, NodeTraits::red());
                x = x_parent;
                x_parent = NodeTraits::get_parent(x_parent);
             }
             else {
- if(NodeTraits::get_left(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black()){
+ if(!NodeTraits::get_left(w) || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black()){
                   NodeTraits::set_color(NodeTraits::get_right(w), NodeTraits::black());
                   NodeTraits::set_color(w, NodeTraits::red());
                   tree_algorithms::rotate_left(w, header);
@@ -874,9 +874,8 @@
    }
 
 
- static void rebalance_after_insertion(const node_ptr & header, const node_ptr &pnode)
+ static void rebalance_after_insertion(const node_ptr & header, node_ptr p)
    {
- node_ptr p(pnode);
       NodeTraits::set_color(p, NodeTraits::red());
       while(p != NodeTraits::get_parent(header) && NodeTraits::get_color(NodeTraits::get_parent(p)) == NodeTraits::red()){
          node_ptr p_parent(NodeTraits::get_parent(p));

Modified: branches/release/boost/intrusive/sgtree.hpp
==============================================================================
--- branches/release/boost/intrusive/sgtree.hpp (original)
+++ branches/release/boost/intrusive/sgtree.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -215,7 +215,7 @@
    typedef typename Config::value_traits value_traits;
    /// @cond
    static const bool external_value_traits =
- detail::external_value_traits_is_true<value_traits>::value;
+ detail::external_value_traits_bool_is_true<value_traits>::value;
    typedef typename detail::eval_if_c
       < external_value_traits
       , detail::eval_value_traits<value_traits>

Modified: branches/release/boost/intrusive/slist.hpp
==============================================================================
--- branches/release/boost/intrusive/slist.hpp (original)
+++ branches/release/boost/intrusive/slist.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -112,7 +112,7 @@
    typedef typename Config::value_traits value_traits;
    /// @cond
    static const bool external_value_traits =
- detail::external_value_traits_is_true<value_traits>::value;
+ detail::external_value_traits_bool_is_true<value_traits>::value;
    typedef typename detail::eval_if_c
       < external_value_traits
       , detail::eval_value_traits<value_traits>

Modified: branches/release/boost/intrusive/splaytree.hpp
==============================================================================
--- branches/release/boost/intrusive/splaytree.hpp (original)
+++ branches/release/boost/intrusive/splaytree.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -88,7 +88,7 @@
    typedef typename Config::value_traits value_traits;
    /// @cond
    static const bool external_value_traits =
- detail::external_value_traits_is_true<value_traits>::value;
+ detail::external_value_traits_bool_is_true<value_traits>::value;
    typedef typename detail::eval_if_c
       < external_value_traits
       , detail::eval_value_traits<value_traits>

Modified: branches/release/boost/intrusive/treap.hpp
==============================================================================
--- branches/release/boost/intrusive/treap.hpp (original)
+++ branches/release/boost/intrusive/treap.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -91,7 +91,7 @@
    typedef typename Config::value_traits value_traits;
    /// @cond
    static const bool external_value_traits =
- detail::external_value_traits_is_true<value_traits>::value;
+ detail::external_value_traits_bool_is_true<value_traits>::value;
    typedef typename detail::eval_if_c
       < external_value_traits
       , detail::eval_value_traits<value_traits>

Modified: branches/release/libs/container/doc/Jamfile.v2
==============================================================================
--- branches/release/libs/container/doc/Jamfile.v2 (original)
+++ branches/release/libs/container/doc/Jamfile.v2 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -27,6 +27,8 @@
         <doxygen:param>MACRO_EXPANSION=YES
         <doxygen:param>"PREDEFINED=\"insert_const_ref_type= const T&\" \\
                                    \"BOOST_CONTAINER_DOXYGEN_INVOKED\" \\
+ \"BOOST_CONTAINER_IMPDEF(T)=implementation_defined\" \\
+ \"BOOST_CONTAINER_SEEDOC(T)=see_documentation\" \\
                                    \"BOOST_RV_REF(T)=T &&\" \\
                                    \"BOOST_RV_REF_BEG=\" \\
                                    \"BOOST_RV_REF_END=&&\" \\

Modified: branches/release/libs/container/doc/container.qbk
==============================================================================
--- branches/release/libs/container/doc/container.qbk (original)
+++ branches/release/libs/container/doc/container.qbk 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -38,7 +38,7 @@
 * The library offers new useful containers:
   * [classref boost::container::flat_map flat_map],
     [classref boost::container::flat_set flat_set],
- [classref boost::container::flat_multiset flat_multiset] and
+ [classref boost::container::flat_multimap flat_multimap] and
     [classref boost::container::flat_multiset flat_multiset]: drop-in
     replacements for standard associative containers but more memory friendly and with faster
     searches.
@@ -614,6 +614,21 @@
 
 [section:release_notes Release Notes]
 
+[section:release_notes_boost_1_52_00 Boost 1.52 Release]
+
+* Improved `stable_vector`'s template code bloat and type safety.
+* Changed typedefs and reordered functions of sequence containers to improve doxygen documentation.
+* Fixed bugs
+ [@https://svn.boost.org/trac/boost/ticket/6615 #6615],
+ [@https://svn.boost.org/trac/boost/ticket/7139 #7139],
+ [@https://svn.boost.org/trac/boost/ticket/7215 #7215],
+ [@https://svn.boost.org/trac/boost/ticket/7232 #7232],
+ [@https://svn.boost.org/trac/boost/ticket/7269 #7269].
+* Implemented LWG Issue #149 (range insertion now returns an iterator) & cleaned up insertion code in most containers
+* Corrected aliasing errors.
+
+[endsect]
+
 [section:release_notes_boost_1_51_00 Boost 1.51 Release]
 
 * Fixed bugs
@@ -623,7 +638,6 @@
   [@https://svn.boost.org/trac/boost/ticket/7103 #7103].
   [@https://svn.boost.org/trac/boost/ticket/7123 #7123],
 
-
 [endsect]
 
 [section:release_notes_boost_1_50_00 Boost 1.50 Release]
@@ -631,12 +645,11 @@
 * Added Scoped Allocator Model support.
 
 * Fixed bugs
+ [@https://svn.boost.org/trac/boost/ticket/6606 #6606],
   [@https://svn.boost.org/trac/boost/ticket/6533 #6533],
   [@https://svn.boost.org/trac/boost/ticket/6536 #6536],
   [@https://svn.boost.org/trac/boost/ticket/6566 #6566],
   [@https://svn.boost.org/trac/boost/ticket/6575 #6575],
- [@https://svn.boost.org/trac/boost/ticket/6606 #6606],
- [@https://svn.boost.org/trac/boost/ticket/6615 #6615],
   
 [endsect]
 

Modified: branches/release/libs/container/proj/to-do.txt
==============================================================================
--- branches/release/libs/container/proj/to-do.txt (original)
+++ branches/release/libs/container/proj/to-do.txt 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -34,10 +34,128 @@
 
 check move if noexcept conditions in vector, deque and stable_vector
 
+Add noexcept testing using static_assert (Howard Hinnants's suggestion):
+
+ #include <type_traits>
+
+ struct A
+ {
+ void foo() noexcept;
+ };
+
+ static_assert(noexcept(std::declval<A&>().foo()), "A::foo() should be noexcept");
+
 Detect always equal or unequal allocators at compiler time. operator== returns true_type or false_type
 
 change virtual functions with pointers to avoid template instantiation for every type
 
 Add hash for containers
 
-Add std:: hashing support
\ No newline at end of file
+Add std:: hashing support
+
+Take out from class definition iterators in slist & list
+
+Fix trivial destructor after move and other optimizing traits
+
+Define typedefs exactly like the standard to generate better documentation. for implementation defined types:
+ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ #define BOOST_CONTAINER_IMPLDEF(TYPE) TYPE
+ #else
+ #define BOOST_CONTAINER_IMPLDEF(TYPE) implementation_defined
+ #endif
+Mark previous() in slist/and forward_list as non-standard
+
+Replace all insert_const_ref_type with BOOST_MOVE_CONVERSION_AWARE_CATCH_XXX
+
+
+
+Function order:
+
+----------type------------
+value_type;
+pointer;
+const_pointer;
+reference;
+const_reference;
+size_type;
+difference_type;
+allocator_type;
+stored_allocator_type;
+iterator;
+const_iterator;
+reverse_iterator;
+const_reverse_iterator;
+----------func------------
+container()
+container(allocator_type)
+container(size_type)
+container(size_type, value_type, allocator_type = ())
+container(InpIt, InpIt)
+container(const container &)
+container(container &&)
+container(const container &, allocator_type)
+container(container &&, allocator_type)
+container(initializer_list<T>, allocator)
+~container()
+container operator=(const container &)
+container operator=(container &&)
+container operator=(initializer_list<T>)
+assign(size_type, const T &)
+
+assign(InpIt, InptIt)
+assign(initializer_list)
+get_allocator()
+
+begin()
+begin() const
+end()
+end() const
+rbegin()
+rbegin() const
+rend()
+rend() const
+
+cbegin() const
+cend() const
+crbegin() const
+crend() const
+
+empty()
+size()
+max_size()
+resize(size_type)
+resize(size_type, cont T&)
+capacity()
+reserve(size_type)
+shrink_to_fit()
+
+front()
+front() const
+back()
+back() const
+operator[] ()
+operator[] ()const
+at()
+at() const
+
+
+data()
+data() const
+
+emplace_front()
+emplace_back()
+emplace()
+push_front(const T&)
+push_front(T&&)
+push_back(const T&)
+push_back(T&&)
+insert(iterator, const T &)
+insert(iterator, T &&)
+insert(size_type, const T &)
+insert(InpIt, InpIt)
+pop_front()
+pop_back()
+erase(const_iterator)
+erase(const_iterator, const_iterator)
+swap(container &)
+clear()
\ No newline at end of file

Modified: branches/release/libs/container/proj/vc7ide/allocator_traits_test.vcproj
==============================================================================
--- branches/release/libs/container/proj/vc7ide/allocator_traits_test.vcproj (original)
+++ branches/release/libs/container/proj/vc7ide/allocator_traits_test.vcproj 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -132,6 +132,9 @@
                         Name="Header Files"
                         Filter="h;hpp;hxx;hm;inl;inc;xsd"
                         UniqueIdentifier="{93815995-89BD-b043-5E8B-65FBE52E2AFB}">
+ <File
+ RelativePath="..\..\..\..\boost\container\detail\node_alloc_holder.hpp">
+ </File>
                 </Filter>
         </Files>
         <Globals>

Modified: branches/release/libs/container/proj/vc7ide/container.sln
==============================================================================
--- branches/release/libs/container/proj/vc7ide/container.sln (original)
+++ branches/release/libs/container/proj/vc7ide/container.sln 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -51,6 +51,10 @@
         ProjectSection(ProjectDependencies) = postProject
         EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hash_table_test", "hash_table_test.vcproj", "{58CCE183-6092-48FE-A4F7-BA0D3A792606}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
 Global
         GlobalSection(SolutionConfiguration) = preSolution
                 Debug = Debug
@@ -111,6 +115,10 @@
                 {B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Debug.Build.0 = Debug|Win32
                 {B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.ActiveCfg = Release|Win32
                 {B4E9FB12-7D7C-4461-83A9-5EB2C78E608F}.Release.Build.0 = Release|Win32
+ {58CCE183-6092-48FE-A4F7-BA0D3A792606}.Debug.ActiveCfg = Debug|Win32
+ {58CCE183-6092-48FE-A4F7-BA0D3A792606}.Debug.Build.0 = Debug|Win32
+ {58CCE183-6092-48FE-A4F7-BA0D3A792606}.Release.ActiveCfg = Release|Win32
+ {58CCE183-6092-48FE-A4F7-BA0D3A792606}.Release.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(ExtensibilityGlobals) = postSolution
         EndGlobalSection

Modified: branches/release/libs/container/proj/vc7ide/container.vcproj
==============================================================================
--- branches/release/libs/container/proj/vc7ide/container.vcproj (original)
+++ branches/release/libs/container/proj/vc7ide/container.vcproj 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -146,6 +146,9 @@
                                 RelativePath="..\..\test\expand_bwd_test_template.hpp">
                         </File>
                         <File
+ RelativePath="..\..\test\forward_to_input_iterator.hpp">
+ </File>
+ <File
                                 RelativePath="..\..\test\heap_allocator_v1.hpp">
                         </File>
                         <File
@@ -261,7 +264,7 @@
                                         RelativePath="..\..\..\..\boost\container\detail\math_functions.hpp">
                                 </File>
                                 <File
- RelativePath="..\..\..\..\boost\container\allocator\memory_util.hpp">
+ RelativePath="..\..\..\..\boost\container\detail\memory_util.hpp">
                                 </File>
                                 <File
                                         RelativePath="..\..\..\..\boost\container\detail\mpl.hpp">

Modified: branches/release/libs/container/test/check_equal_containers.hpp
==============================================================================
--- branches/release/libs/container/test/check_equal_containers.hpp (original)
+++ branches/release/libs/container/test/check_equal_containers.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -12,6 +12,8 @@
 #define BOOST_CONTAINER_TEST_CHECK_EQUAL_CONTAINER_HPP
 
 #include <boost/container/detail/config_begin.hpp>
+#include <boost/container/detail/pair.hpp>
+#include <boost/container/detail/mpl.hpp>
 #include <functional>
 #include <iostream>
 #include <algorithm>
@@ -20,6 +22,24 @@
 namespace container {
 namespace test{
 
+template< class T1, class T2>
+bool CheckEqual( const T1 &t1, const T2 &t2
+ , typename boost::container::container_detail::enable_if_c
+ <!boost::container::container_detail::is_pair<T1>::value &&
+ !boost::container::container_detail::is_pair<T2>::value
+ >::type* = 0)
+{ return t1 == t2; }
+
+template< class Pair1, class Pair2>
+bool CheckEqual( const Pair1 &pair1, const Pair2 &pair2
+ , typename boost::container::container_detail::enable_if_c
+ <boost::container::container_detail::is_pair<Pair1>::value &&
+ boost::container::container_detail::is_pair<Pair2>::value
+ >::type* = 0)
+{
+ return CheckEqual(pair1.first, pair2.first) && CheckEqual(pair1.second, pair2.second);
+}
+
 //Function to check if both containers are equal
 template<class MyBoostCont
         ,class MyStdCont>
@@ -38,9 +58,7 @@
    }
    std::size_t i = 0;
    for(; itboost != itboostend; ++itboost, ++itstd, ++i){
- value_type val(*itstd);
- const value_type &v = *itboost;
- if(v != val)
+ if(!CheckEqual(*itstd, *itboost))
          return false;
    }
    return true;

Modified: branches/release/libs/container/test/deque_test.cpp
==============================================================================
--- branches/release/libs/container/test/deque_test.cpp (original)
+++ branches/release/libs/container/test/deque_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -63,7 +63,7 @@
    typedef typename V1::value_type IntType;
    std::size_t size = cntdeque->size();
    stddeque->insert(stddeque->end(), 50, 1);
- cntdeque->insert(cntdeque->end(), 50, 1);
+ cntdeque->insert(cntdeque->end(), 50, IntType(1));
    if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
    {
       IntType move_me(1);

Modified: branches/release/libs/container/test/dummy_test_allocator.hpp
==============================================================================
--- branches/release/libs/container/test/dummy_test_allocator.hpp (original)
+++ branches/release/libs/container/test/dummy_test_allocator.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -111,7 +111,7 @@
    dummy_test_allocator(const dummy_test_allocator<T2> &)
    {}
 
- pointer address(reference value)
+ pointer address(reference value)
    { return pointer(container_detail::addressof(value)); }
 
    const_pointer address(const_reference value) const

Modified: branches/release/libs/container/test/expand_bwd_test_allocator.hpp
==============================================================================
--- branches/release/libs/container/test/expand_bwd_test_allocator.hpp (original)
+++ branches/release/libs/container/test/expand_bwd_test_allocator.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -108,7 +108,7 @@
    { return m_size; }
 
    friend void swap(self_t &alloc1, self_t &alloc2)
- {
+ {
       container_detail::do_swap(alloc1.mp_buffer, alloc2.mp_buffer);
       container_detail::do_swap(alloc1.m_size, alloc2.m_size);
       container_detail::do_swap(alloc1.m_offset, alloc2.m_offset);

Modified: branches/release/libs/container/test/list_test.hpp
==============================================================================
--- branches/release/libs/container/test/list_test.hpp (original)
+++ branches/release/libs/container/test/list_test.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -18,6 +18,7 @@
 #include <vector>
 #include <functional>
 #include "print_container.hpp"
+#include "input_from_forward_iterator.hpp"
 #include <boost/move/move.hpp>
 #include <string>
 
@@ -177,7 +178,20 @@
             aux_vect2[i] = -1;
          }
          boostlist->assign(boost::make_move_iterator(&aux_vect[0])
- ,boost::make_move_iterator(&aux_vect[50]));
+ ,boost::make_move_iterator(&aux_vect[50]));
+ stdlist->assign(&aux_vect2[0], &aux_vect2[50]);
+ if(!CheckEqualContainers(boostlist, stdlist)) return 1;
+
+ for(int i = 0; i < 50; ++i){
+ IntType move_me(-1);
+ aux_vect[i] = boost::move(move_me);
+ }
+
+ for(int i = 0; i < 50; ++i){
+ aux_vect2[i] = -1;
+ }
+ boostlist->assign(boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
+ ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[50])));
          stdlist->assign(&aux_vect2[0], &aux_vect2[50]);
          if(!CheckEqualContainers(boostlist, stdlist)) return 1;
       }
@@ -206,10 +220,36 @@
          for(int i = 0; i < 50; ++i){
             aux_vect2[i] = -1;
          }
- boostlist->insert(boostlist->begin()
+ typename MyBoostList::iterator old_begin = boostlist->begin();
+ typename MyBoostList::iterator it_insert =
+ boostlist->insert(boostlist->begin()
                         ,boost::make_move_iterator(&aux_vect[0])
                         ,boost::make_move_iterator(&aux_vect[50]));
+ if(it_insert != boostlist->begin() || std::distance(it_insert, old_begin) != 50)
+ return 1;
+
          stdlist->insert(stdlist->begin(), &aux_vect2[0], &aux_vect2[50]);
+ if(!CheckEqualContainers(boostlist, stdlist))
+ return 1;
+
+ for(int i = 0; i < 50; ++i){
+ IntType move_me(-1);
+ aux_vect[i] = boost::move(move_me);
+ }
+
+ for(int i = 0; i < 50; ++i){
+ aux_vect2[i] = -1;
+ }
+
+ old_begin = boostlist->begin();
+ it_insert = boostlist->insert(boostlist->end()
+ ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
+ ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[50])));
+ if(std::distance(it_insert, boostlist->end()) != 50)
+ return 1;
+ stdlist->insert(stdlist->end(), &aux_vect2[0], &aux_vect2[50]);
+ if(!CheckEqualContainers(boostlist, stdlist))
+ return 1;
       }
 
       boostlist->unique();

Modified: branches/release/libs/container/test/movable_int.hpp
==============================================================================
--- branches/release/libs/container/test/movable_int.hpp (original)
+++ branches/release/libs/container/test/movable_int.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -73,6 +73,12 @@
    int get_int() const
    { return m_int; }
 
+ friend bool operator==(const movable_int &l, int r)
+ { return l.get_int() == r; }
+
+ friend bool operator==(int l, const movable_int &r)
+ { return l == r.get_int(); }
+
    private:
    int m_int;
 };
@@ -144,6 +150,12 @@
    int get_int() const
    { return m_int; }
 
+ friend bool operator==(const movable_and_copyable_int &l, int r)
+ { return l.get_int() == r; }
+
+ friend bool operator==(int l, const movable_and_copyable_int &r)
+ { return l == r.get_int(); }
+
    private:
    int m_int;
 };
@@ -202,6 +214,12 @@
    int get_int() const
    { return m_int; }
 
+ friend bool operator==(const copyable_int &l, int r)
+ { return l.get_int() == r; }
+
+ friend bool operator==(int l, const copyable_int &r)
+ { return l == r.get_int(); }
+
    private:
    int m_int;
 };
@@ -256,10 +274,17 @@
    int get_int() const
    { return m_int; }
 
+ friend bool operator==(const non_copymovable_int &l, int r)
+ { return l.get_int() == r; }
+
+ friend bool operator==(int l, const non_copymovable_int &r)
+ { return l == r.get_int(); }
+
    private:
    int m_int;
 };
 
+
 } //namespace test {
 } //namespace container {
 } //namespace boost {

Modified: branches/release/libs/container/test/scoped_allocator_usage_test.cpp
==============================================================================
--- branches/release/libs/container/test/scoped_allocator_usage_test.cpp (original)
+++ branches/release/libs/container/test/scoped_allocator_usage_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -20,8 +20,6 @@
 {
 public:
         typedef Ty value_type;
- typedef typename std::allocator<Ty>::pointer pointer;
- typedef typename std::allocator<Ty>::size_type size_type;
 
         SimpleAllocator(int value)
                 : m_state(value)
@@ -32,12 +30,12 @@
                 : m_state(other.m_state)
         {}
 
- pointer allocate(size_type n)
+ Ty* allocate(std::size_t n)
         {
                 return m_allocator.allocate(n);
         }
 
- void deallocate(pointer p, size_type n)
+ void deallocate(Ty* p, std::size_t n)
         {
                 m_allocator.deallocate(p, n);
         }

Modified: branches/release/libs/container/test/set_test.hpp
==============================================================================
--- branches/release/libs/container/test/set_test.hpp (original)
+++ branches/release/libs/container/test/set_test.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -88,13 +88,13 @@
          IntType move_me(i);
          aux_vect3[i] = boost::move(move_me);
       }
-/*
- MyBoostSet *boostset3 = MyBoostSet
+
+ MyBoostSet *boostset3 = new MyBoostSet
             ( ordered_unique_range
             , boost::make_move_iterator(&aux_vect[0])
             , boost::make_move_iterator(aux_vect + 50));
       MyStdSet *stdset3 = new MyStdSet(aux_vect2, aux_vect2 + 50);
- MyBoostMultiSet *boostmultiset3 = MyBoostMultiSet
+ MyBoostMultiSet *boostmultiset3 = new MyBoostMultiSet
             ( ordered_range
             , boost::make_move_iterator(&aux_vect3[0])
             , boost::make_move_iterator(aux_vect3 + 50));
@@ -108,15 +108,15 @@
          std::cout << "Error in construct<MyBoostMultiSet>(MyBoostMultiSet3)" << std::endl;
          return 1;
       }
-*/
+
       delete boostset2;
       delete boostmultiset2;
       delete stdset2;
       delete stdmultiset2;
- //delete boostset3;
- //delete boostmultiset3;
- //delete stdset3;
- //delete stdmultiset3;
+ delete boostset3;
+ delete boostmultiset3;
+ delete stdset3;
+ delete stdmultiset3;
    }
 
    int i, j;

Modified: branches/release/libs/container/test/stable_vector_test.cpp
==============================================================================
--- branches/release/libs/container/test/stable_vector_test.cpp (original)
+++ branches/release/libs/container/test/stable_vector_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -30,13 +30,13 @@
 namespace container {
 
 //Explicit instantiation to detect compilation errors
-template class stable_vector<test::movable_and_copyable_int,
+template class stable_vector<test::movable_and_copyable_int,
    test::dummy_test_allocator<test::movable_and_copyable_int> >;
 
-template class stable_vector<test::movable_and_copyable_int,
+template class stable_vector<test::movable_and_copyable_int,
    test::simple_allocator<test::movable_and_copyable_int> >;
 
-template class stable_vector<test::movable_and_copyable_int,
+template class stable_vector<test::movable_and_copyable_int,
    std::allocator<test::movable_and_copyable_int> >;
 
 }}

Modified: branches/release/libs/container/test/vector_test.hpp
==============================================================================
--- branches/release/libs/container/test/vector_test.hpp (original)
+++ branches/release/libs/container/test/vector_test.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -8,6 +8,9 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 
+#ifndef BOOST_CONTAINER_TEST_VECTOR_TEST_HEADER
+#define BOOST_CONTAINER_TEST_VECTOR_TEST_HEADER
+
 #include <boost/container/detail/config_begin.hpp>
 #include <algorithm>
 #include <memory>
@@ -24,6 +27,7 @@
 #include <string>
 #include <vector>
 #include "emplace_test.hpp"
+#include "input_from_forward_iterator.hpp"
 
 namespace boost{
 namespace container {
@@ -133,10 +137,11 @@
             for(int i = 0; i < 50; ++i){
                aux_vect2[i] = -1;
             }
-
- boostvector->insert(boostvector->end()
+ typename MyBoostVector::iterator insert_it =
+ boostvector->insert(boostvector->end()
                               ,boost::make_move_iterator(&aux_vect[0])
                               ,boost::make_move_iterator(aux_vect + 50));
+ if(std::size_t(std::distance(insert_it, boostvector->end())) != 50) return 1;
             stdvector->insert(stdvector->end(), aux_vect2, aux_vect2 + 50);
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
 
@@ -147,22 +152,47 @@
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
          }
          {
+ boostvector->resize(100);
+ stdvector->resize(100);
+ if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
+
             IntType aux_vect[50];
             for(int i = 0; i < 50; ++i){
- IntType new_int(-1);
+ IntType new_int(-2);
                aux_vect[i] = boost::move(new_int);
             }
             int aux_vect2[50];
             for(int i = 0; i < 50; ++i){
- aux_vect2[i] = -1;
+ aux_vect2[i] = -2;
             }
- boostvector->insert(boostvector->begin()
+ typename MyBoostVector::size_type old_size = boostvector->size();
+ typename MyBoostVector::iterator insert_it =
+ boostvector->insert(boostvector->begin() + old_size
                               ,boost::make_move_iterator(&aux_vect[0])
                               ,boost::make_move_iterator(aux_vect + 50));
- stdvector->insert(stdvector->begin(), aux_vect2, aux_vect2 + 50);
+ if(boostvector->begin() + old_size != insert_it) return 1;
+ stdvector->insert(stdvector->begin() + old_size, aux_vect2, aux_vect2 + 50);
+ if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
+
+ for(int i = 0; i < 50; ++i){
+ IntType new_int(-3);
+ aux_vect[i] = boost::move(new_int);
+ }
+
+ for(int i = 0; i < 50; ++i){
+ aux_vect2[i] = -3;
+ }
+ old_size = boostvector->size();
+ //Now try with input iterators instead
+ insert_it = boostvector->insert(boostvector->begin() + old_size
+ ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
+ ,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50))
+ );
+ if(boostvector->begin() + old_size != insert_it) return 1;
+ stdvector->insert(stdvector->begin() + old_size, aux_vect2, aux_vect2 + 50);
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
          }
-/*
+/* //deque has no reserve
          boostvector->reserve(boostvector->size()*2);
          stdvector->reserve(stdvector->size()*2);
          if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
@@ -175,13 +205,27 @@
          MyStdVector(*stdvector).swap(*stdvector);
          if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
 
+ { //push_back with not enough capacity
          IntType push_back_this(1);
          boostvector->push_back(boost::move(push_back_this));
          stdvector->push_back(int(1));
          boostvector->push_back(IntType(1));
          stdvector->push_back(int(1));
+ if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
+ }
+ { //push_back with enough capacity
+ boostvector->pop_back();
+ boostvector->pop_back();
+ stdvector->pop_back();
+ stdvector->pop_back();
 
+ IntType push_back_this(1);
+ boostvector->push_back(boost::move(push_back_this));
+ stdvector->push_back(int(1));
+ boostvector->push_back(IntType(1));
+ stdvector->push_back(int(1));
          if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
+ }
 
          if(!vector_copyable_only(boostvector, stdvector
                         ,container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
@@ -204,14 +248,22 @@
          //Test insertion from list
          {
             std::list<int> l(50, int(1));
- boostvector->insert(boostvector->begin(), l.begin(), l.end());
+ typename MyBoostVector::iterator it_insert =
+ boostvector->insert(boostvector->begin(), l.begin(), l.end());
+ if(boostvector->begin() != it_insert) return 1;
             stdvector->insert(stdvector->begin(), l.begin(), l.end());
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
             boostvector->assign(l.begin(), l.end());
             stdvector->assign(l.begin(), l.end());
             if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
+
+ boostvector->clear();
+ stdvector->clear();
+ boostvector->assign(make_input_from_forward_iterator(l.begin()), make_input_from_forward_iterator(l.end()));
+ stdvector->assign(l.begin(), l.end());
+ if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
          }
-/*
+/* deque has no reserve or capacity
          std::size_t cap = boostvector->capacity();
          boostvector->reserve(cap*2);
          stdvector->reserve(cap*2);
@@ -252,3 +304,6 @@
 } //namespace boost{
 
 #include <boost/container/detail/config_end.hpp>
+
+#endif //BOOST_CONTAINER_TEST_VECTOR_TEST_HEADER
+

Modified: branches/release/libs/interprocess/doc/interprocess.qbk
==============================================================================
--- branches/release/libs/interprocess/doc/interprocess.qbk (original)
+++ branches/release/libs/interprocess/doc/interprocess.qbk 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,5 +1,5 @@
 [/
- / Copyright (c) 2005-2011 Ion Gaztanaga
+ / Copyright (c) 2005-2012 Ion Gaztanaga
  /
  / 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)
@@ -622,14 +622,9 @@
 Windows shared memory creation is a bit different from portable shared memory
 creation: the size of the segment must be specified when creating the object and
 can't be specified through `truncate` like with the shared memory object.
-
 Take in care that when the last process attached to a shared memory is destroyed
 [*the shared memory is destroyed] so there is [*no persistency] with native windows
-shared memory. Native windows shared memory has also another limitation: a process can
-open and map the whole shared memory created by another process but it can't know
-which is the size of that memory. This limitation is imposed by the Windows API so
-the user must somehow transmit the size of the segment to processes opening the
-segment.
+shared memory.
 
 Sharing memory between services and user applications is also different. To share memory
 between services and user applications the name of the shared memory must start with the
@@ -865,7 +860,7 @@
 object or a file mapping are the same class and this has many advantages.
 
 One can, for example, mix in STL containers mapped regions from shared memory
-and memory mapped files. The libraries that only depend on mapped regions can
+and memory mapped files. Libraries that only depend on mapped regions can
 be used to work with shared memory or memory mapped files without recompiling them.
 
 [endsect]
@@ -881,7 +876,7 @@
 in a different way (allocation of more or less dynamic memory, for example), there is
 no guarantee that the file/shared memory is going to be mapped in the same address.
 
-If two processes map the same object in different addresses, this invalids the use
+If two processes map the same object in different addresses, this invalidates the use
 of pointers in that memory, since the pointer (which is an absolute address) would
 only make sense for the process that wrote it. The solution for this is to use offsets
 (distance) between objects instead of pointers: If two objects are placed in the same
@@ -1592,11 +1587,26 @@
 
 [c++]
 
+ #include <boost/interprocess/sync/interprocess_condition_any.hpp>
+
+* [classref boost::interprocess::interprocess_condition_any interprocess_condition_any]:
+ An anonymous condition variable that can be placed in shared memory or memory
+ mapped files to be used with any lock type.
+
+[c++]
+
    #include <boost/interprocess/sync/named_condition.hpp>
 
 * [classref boost::interprocess::named_condition named_condition]: A named
   condition variable to be used with [classref boost::interprocess::named_mutex named_mutex].
 
+[c++]
+
+ #include <boost/interprocess/sync/named_condition_any.hpp>
+
+* [classref boost::interprocess::named_condition named_condition]: A named
+ condition variable to be used with any lock type.
+
 Named conditions are similar to anonymous conditions, but they are used in
 combination with named mutexes. Several times, we don't want to store
 synchronization objects with the synchronized data:
@@ -1725,12 +1735,12 @@
 
 [endsect]
 
-[section:upgradable_mutexes Upgradable Mutexes]
+[section:sharable_upgradable_mutexes Sharable and Upgradable Mutexes]
 
-[section:upgradable_whats_a_mutex What's An Upgradable Mutex?]
+[section:upgradable_whats_a_mutex What's a Sharable and an Upgradable Mutex?]
 
-An upgradable mutex is a special mutex that offers more locking possibilities than
-a normal mutex. Sometimes, we can distinguish between [*reading] the data and
+Sharable and upgradable mutex are special mutex types that offers more locking possibilities
+than a normal mutex. Sometimes, we can distinguish between [*reading] the data and
 [*modifying] the data. If just some threads need to modify the data, and a plain mutex
 is used to protect the data from concurrent access, concurrency is pretty limited:
 two threads that only read the data will be serialized instead of being executed
@@ -1740,20 +1750,21 @@
 concurrent access between threads that read and modify or between threads that modify,
 we can increase performance. This is specially true in applications where data reading
 is more common than data modification and the synchronized data reading code needs
-some time to execute. With an upgradable mutex we can acquire 3
-lock types:
+some time to execute. With a sharable mutex we can acquire 2 lock types:
 
 * [*Exclusive lock]: Similar to a plain mutex. If a thread acquires an exclusive
    lock, no other thread can acquire any lock (exclusive or other) until the exclusive
- lock is released. If any thread has a sharable or upgradable lock a thread trying
+ lock is released. If any thread other has any lock other than exclusive, a thread trying
    to acquire an exclusive lock will block.
    This lock will be acquired by threads that will modify the data.
 
 * [*Sharable lock]: If a thread acquires a sharable lock, other threads
- can acquire a sharable lock or an upgradable lock. If any thread has acquired
+ can't acquire the exclusive lock. If any thread has acquired
    the exclusive lock a thread trying to acquire a sharable lock will block.
    This locking is executed by threads that just need to read the data.
 
+With an upgradable mutex we can acquire previous locks plus a new upgradable lock:
+
 * [*Upgradable lock]: Acquiring an upgradable lock is similar to acquiring
    a [*privileged sharable lock]. If a thread acquires an upgradable lock, other threads
    can acquire a sharable lock. If any thread has acquired the exclusive or upgradable lock
@@ -1772,20 +1783,34 @@
 
 To sum up:
 
-[table Locking Possibilities
+[table Locking Possibilities for a Sharable Mutex
+ [[If a thread has acquired the...] [Other threads can acquire...]]
+ [[Sharable lock] [many sharable locks]]
+ [[Exclusive lock] [no locks]]
+]
+
+[table Locking Possibilities for an Upgradable Mutex
    [[If a thread has acquired the...] [Other threads can acquire...]]
    [[Sharable lock] [many sharable locks and 1 upgradable lock]]
    [[Upgradable lock] [many sharable locks]]
    [[Exclusive lock] [no locks]]
 ]
 
-A thread that has acquired a lock can try to acquire another lock type atomically.
+[endsect]
+
+[section:upgradable_transitions Lock transitions for Upgradable Mutex]
+
+A sharable mutex has no option to change the acquired lock for another lock
+atomically.
+
+On the other hand, for an upgradable mutex, a thread that has
+acquired a lock can try to acquire another lock type atomically.
 All lock transitions are not guaranteed to succeed. Even if a transition is guaranteed
 to succeed, some transitions will block the thread waiting until other threads release
 the sharable locks. [*Atomically] means that no other thread will acquire an Upgradable
 or Exclusive lock in the transition, [*so data is guaranteed to remain unchanged]:
 
-[table Transition Possibilities
+[table Transition Possibilities for an Upgradable Mutex
    [[If a thread has acquired the...] [It can atomically release the previous lock and...]]
    [[Sharable lock] [try to obtain (not guaranteed) immediately the Exclusive lock if no other thread has exclusive or upgrable lock]]
    [[Sharable lock] [try to obtain (not guaranteed) immediately the Upgradable lock if no other thread has exclusive or upgrable lock]]
@@ -1803,18 +1828,18 @@
 
 [endsect]
 
-[section:upgradable_mutexes_operations Upgradable Mutex Operations]
+[section:sharable_upgradable_mutexes_operations Upgradable Mutex Operations]
 
 All the upgradable mutex types from [*Boost.Interprocess] implement
 the following operations:
 
-[section:upgradable_mutexes_operations_exclusive Exclusive Locking]
+[section:sharable_upgradable_mutexes_operations_exclusive Exclusive Locking (Sharable & Upgradable Mutexes)]
 
 [blurb ['[*void lock()]]]
 
 [*Effects:]
 The calling thread tries to obtain exclusive ownership of the mutex, and if
-another thread has exclusive, sharable or upgradable ownership of the mutex,
+another thread has any ownership of the mutex (exclusive or other),
 it waits until it can obtain the ownership.
 
 [*Throws:] *interprocess_exception* on error.
@@ -1823,8 +1848,8 @@
 
 [*Effects:]
 The calling thread tries to acquire exclusive ownership of the mutex without
-waiting. If no other thread has exclusive, sharable or upgradable ownership of
-the mutex this succeeds.
+waiting. If no other thread has any ownership of the mutex (exclusive or other)
+this succeeds.
 
 [*Returns:] If it can acquire exclusive ownership immediately returns true.
 If it has to wait, returns false.
@@ -1835,8 +1860,8 @@
 
 [*Effects:]
 The calling thread tries to acquire exclusive ownership of the mutex
-waiting if necessary until no other thread has exclusive,
-sharable or upgradable ownership of the mutex or abs_time is reached.
+waiting if necessary until no other thread has any ownership of the mutex
+(exclusive or other) or abs_time is reached.
 
 [*Returns:] If acquires exclusive ownership, returns true. Otherwise
 returns false.
@@ -1853,7 +1878,7 @@
 
 [endsect]
 
-[section:upgradable_mutexes_operations_sharable Sharable Locking]
+[section:sharable_upgradable_mutexes_operations_sharable Sharable Locking (Sharable & Upgradable Mutexes)]
 
 [blurb ['[*void lock_sharable()]]]
 
@@ -1898,7 +1923,7 @@
 
 [endsect]
 
-[section:upgradable_mutexes_operations_upgradable Upgradable Locking]
+[section:upgradable_mutexes_operations_upgradable Upgradable Locking (Upgradable Mutex only)]
 
 [blurb ['[*void lock_upgradable()]]]
 
@@ -1943,7 +1968,7 @@
 
 [endsect]
 
-[section:upgradable_mutexes_operations_demotions Demotions]
+[section:upgradable_mutexes_operations_demotions Demotions (Upgradable Mutex only)]
 
 [blurb ['[*void unlock_and_lock_upgradable()]]]
 
@@ -1974,7 +1999,7 @@
 
 [endsect]
 
-[section:upgradable_mutexes_operations_promotions Promotions]
+[section:upgradable_mutexes_operations_promotions Promotions (Upgradable Mutex only)]
 [blurb ['[*void unlock_upgradable_and_lock()]]]
 
 [*Precondition:] The thread must have upgradable ownership of the mutex.
@@ -2036,7 +2061,23 @@
 
 [endsect]
 
-[section:upgradable_mutexes_mutex_interprocess_mutexes Boost.Interprocess Upgradable Mutex Types And Headers]
+[section:sharable_upgradable_mutexes_mutex_interprocess_mutexes Boost.Interprocess Sharable & Upgradable Mutex Types And Headers]
+
+Boost.Interprocess offers the following sharable mutex types:
+
+[c++]
+
+ #include <boost/interprocess/sync/interprocess_sharable_mutex.hpp>
+
+* [classref boost::interprocess::interprocess_sharable_mutex interprocess_sharable_mutex]: A non-recursive,
+ anonymous sharable mutex that can be placed in shared memory or memory mapped files.
+
+[c++]
+
+ #include <boost/interprocess/sync/named_sharable_mutex.hpp>
+
+* [classref boost::interprocess::named_sharable_mutex named_sharable_mutex]: A non-recursive,
+ named sharable mutex.
 
 Boost.Interprocess offers the following upgradable mutex types:
 
@@ -2056,7 +2097,7 @@
 
 [endsect]
 
-[section:upgradable_mutexes_locks Sharable Lock And Upgradable Lock]
+[section:sharable_upgradable_locks Sharable Lock And Upgradable Lock]
 
 As with plain mutexes, it's important to release the acquired lock even in the presence
 of exceptions. [*Boost.Interprocess] mutexes are best used with the
@@ -2089,20 +2130,16 @@
 `sharable_lock` calls [*unlock_sharable()] in its destructor, and
 `upgradable_lock` calls [*unlock_upgradable()] in its destructor, so the
 upgradable mutex is always unlocked when an exception occurs.
-Scoped lock has many constructors to lock,
-try_lock, timed_lock a mutex or not to lock it at all.
-
 
 [c++]
 
    using namespace boost::interprocess;
 
- //Let's create any mutex type:
- MutexType mutex;
+ SharableOrUpgradableMutex sh_or_up_mutex;
 
    {
       //This will call lock_sharable()
- sharable_lock<MutexType> lock(mutex);
+ sharable_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex);
 
       //Some code
 
@@ -2111,7 +2148,7 @@
 
    {
       //This won't lock the mutex()
- sharable_lock<MutexType> lock(mutex, defer_lock);
+ sharable_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex, defer_lock);
 
       //Lock it on demand. This will call lock_sharable()
       lock.lock();
@@ -2123,7 +2160,7 @@
 
    {
       //This will call try_lock_sharable()
- sharable_lock<MutexType> lock(mutex, try_to_lock);
+ sharable_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex, try_to_lock);
 
       //Check if the mutex has been successfully locked
       if(lock){
@@ -2136,7 +2173,7 @@
       boost::posix_time::ptime abs_time = ...
 
       //This will call timed_lock_sharable()
- scoped_lock<MutexType> lock(mutex, abs_time);
+ scoped_lock<SharableOrUpgradableMutex> lock(sh_or_up_mutex, abs_time);
 
       //Check if the mutex has been successfully locked
       if(lock){
@@ -2145,9 +2182,11 @@
       //If the mutex was locked it will be unlocked
    }
 
+ UpgradableMutex up_mutex;
+
    {
       //This will call lock_upgradable()
- upgradable_lock<MutexType> lock(mutex);
+ upgradable_lock<UpgradableMutex> lock(up_mutex);
 
       //Some code
 
@@ -2156,7 +2195,7 @@
 
    {
       //This won't lock the mutex()
- upgradable_lock<MutexType> lock(mutex, defer_lock);
+ upgradable_lock<UpgradableMutex> lock(up_mutex, defer_lock);
 
       //Lock it on demand. This will call lock_upgradable()
       lock.lock();
@@ -2168,7 +2207,7 @@
 
    {
       //This will call try_lock_upgradable()
- upgradable_lock<MutexType> lock(mutex, try_to_lock);
+ upgradable_lock<UpgradableMutex> lock(up_mutex, try_to_lock);
 
       //Check if the mutex has been successfully locked
       if(lock){
@@ -2181,7 +2220,7 @@
       boost::posix_time::ptime abs_time = ...
 
       //This will call timed_lock_upgradable()
- scoped_lock<MutexType> lock(mutex, abs_time);
+ scoped_lock<UpgradableMutex> lock(up_mutex, abs_time);
 
       //Check if the mutex has been successfully locked
       if(lock){
@@ -6574,11 +6613,13 @@
 
 [section:notes_windows Notes for Windows users]
 
-[*Boost.Interprocess] uses the COM library to implement some features and initializes
-the COM library with concurrency model `COINIT_APARTMENTTHREADED`.
-If the COM library was already initialized by the calling thread for other model, [*Boost.Interprocess]
+[section:notes_windows_com_init COM Initialization]
+
+[*Boost.Interprocess] uses the Windows COM library to implement some features and initializes
+it with concurrency model `COINIT_APARTMENTTHREADED`.
+If the COM library was already initialized by the calling thread for another concurrency model, [*Boost.Interprocess]
 handles this gracefully and uses COM calls for the already initialized model. If for some reason, you
-might want [*Boost.Interprocess] to initialize the COM library with another model, define the macro
+want [*Boost.Interprocess] to initialize the COM library with another model, define the macro
 `BOOST_INTERPROCESS_WINDOWS_COINIT_MODEL` before including [*Boost.Interprocess] to one of these values:
 
 * `COINIT_APARTMENTTHREADED_BIPC`
@@ -6588,6 +6629,46 @@
 
 [endsect]
 
+[section:notes_windows_shm_folder Shared memory emulation folder]
+
+Shared memory (`shared_memory_object`) is implemented in windows using memory mapped files, placed in a
+directory in the shared documents folder (`SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Common AppData`).
+This directory name is the last bootup time (obtained via COM calls), so that each bootup shared memory is created in a new
+folder obtaining kernel persistence shared memory.
+
+Unfortunately, due to COM implementation related errors, in Boost 1.48 & Boost 1.49 the bootup-time folder was dumped and files
+were directly created in shared documents folder, reverting to filesystem persistence shared memory. Boost 1.50 fixed those issues
+and recovered bootup time directory and kernel persistence. If you need to reproduce Boost 1.48 & Boost 1.49 behaviour to communicate
+with applications compiled with that version, comment `#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME` directive
+in the Windows configuration part of `boost/interprocess/detail/workaround.hpp`.
+
+[endsect]
+
+[endsect]
+
+[section:notes_linux Notes for Linux users]
+
+[section:notes_linux_overcommit Overcommit]
+
+The committed address space is the total amount of virtual memory (swap or physical memory/RAM) that the kernel might have to supply
+if all applications decide to access all of the memory they've requested from the kernel.
+By default, Linux allows processes to commit more virtual memory than available in the system. If that memory is not
+accessed, no physical memory + swap is actually used.
+
+The reason for this behaviour is that Linux tries to optimize memory usage on forked processes; fork() creates a full copy of
+the process space, but with overcommitted memory, in this new forked instance only pages which have been written to actually need
+to be allocated by the kernel. If applications access more memory than available, then the kernel must free memory in the hard way:
+the OOM (Out Of Memory)-killer picks some processes to kill in order to recover memory.
+
+[*Boost.Interprocess] has no way to change this behaviour and users might suffer the OOM-killer when accessing shared memory.
+According to the [@http://www.kernel.org/doc/Documentation/vm/overcommit-accounting Kernel documentation], the
+Linux kernel supports several overcommit modes. If you need non-kill guarantees in your application, you should
+change this overcommit behaviour.
+
+[endsect]
+
+[endsect]
+
 [endsect]
 
 [section:thanks_to Thanks to...]
@@ -6635,11 +6716,30 @@
 
 [section:release_notes Release Notes]
 
+[section:release_notes_boost_1_52_00 Boost 1.52 Release]
+
+* Added `shrink_by` and `advise` functions in `mapped_region`.
+* [*ABI breaking]Reimplemented `message_queue` with a circular buffer index (the
+ old behavior used an ordered array, leading to excessive copies). This
+ should greatly increase performance but breaks ABI. Old behaviour/ABI can be used
+ undefining macro `BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX` in `boost/interprocess/detail/workaround.hpp`
+* Improved `message_queue` insertion time avoiding priority search for common cases
+ (both array and circular buffer configurations).
+* Implemented `sharable_mutex` and `interproces_condition_any`.
+* Improved `offset_ptr` performance.
+* Added integer overflow checks.
+
+[endsect]
+
 [section:release_notes_boost_1_51_00 Boost 1.51 Release]
 
 * Synchronous and asynchronous flushing for `mapped_region::flush`.
-* Source & ABI breaking: Removed `get_offset` method from `mapped_region` as
+* [*Source & ABI breaking]: Removed `get_offset` method from `mapped_region` as
    it has no practical utility and `m_offset` member was not for anything else.
+* [*Source & ABI breaking]: Removed `flush` from `managed_shared_memory`.
+ as it is unspecified according to POSIX:
+ [@http://pubs.opengroup.org/onlinepubs/009695399/functions/msync.html
+ ['"The effect of msync() on a shared memory object or a typed memory object is unspecified"] ].
 * Fixed bug
   [@https://svn.boost.org/trac/boost/ticket/7152 #7152],
 

Modified: branches/release/libs/interprocess/example/Jamfile.v2
==============================================================================
--- branches/release/libs/interprocess/example/Jamfile.v2 (original)
+++ branches/release/libs/interprocess/example/Jamfile.v2 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 # Boost Interprocess Library Example Jamfile
 
-# (C) Copyright Ion Gaztanaga 2006.
+# (C) Copyright Ion Gaztanaga 2006-2012.
 # Use, modification and distribution are subject to 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)

Modified: branches/release/libs/interprocess/example/comp_doc_anonymous_conditionA.cpp
==============================================================================
--- branches/release/libs/interprocess/example/comp_doc_anonymous_conditionA.cpp (original)
+++ branches/release/libs/interprocess/example/comp_doc_anonymous_conditionA.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/comp_doc_anonymous_conditionB.cpp
==============================================================================
--- branches/release/libs/interprocess/example/comp_doc_anonymous_conditionB.cpp (original)
+++ branches/release/libs/interprocess/example/comp_doc_anonymous_conditionB.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/comp_doc_anonymous_mutexA.cpp
==============================================================================
--- branches/release/libs/interprocess/example/comp_doc_anonymous_mutexA.cpp (original)
+++ branches/release/libs/interprocess/example/comp_doc_anonymous_mutexA.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/comp_doc_anonymous_mutexB.cpp
==============================================================================
--- branches/release/libs/interprocess/example/comp_doc_anonymous_mutexB.cpp (original)
+++ branches/release/libs/interprocess/example/comp_doc_anonymous_mutexB.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/comp_doc_anonymous_semaphoreA.cpp
==============================================================================
--- branches/release/libs/interprocess/example/comp_doc_anonymous_semaphoreA.cpp (original)
+++ branches/release/libs/interprocess/example/comp_doc_anonymous_semaphoreA.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/comp_doc_anonymous_semaphoreB.cpp
==============================================================================
--- branches/release/libs/interprocess/example/comp_doc_anonymous_semaphoreB.cpp (original)
+++ branches/release/libs/interprocess/example/comp_doc_anonymous_semaphoreB.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/comp_doc_anonymous_upgradable_mutexA.cpp
==============================================================================
--- branches/release/libs/interprocess/example/comp_doc_anonymous_upgradable_mutexA.cpp (original)
+++ branches/release/libs/interprocess/example/comp_doc_anonymous_upgradable_mutexA.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/comp_doc_anonymous_upgradable_mutexB.cpp
==============================================================================
--- branches/release/libs/interprocess/example/comp_doc_anonymous_upgradable_mutexB.cpp (original)
+++ branches/release/libs/interprocess/example/comp_doc_anonymous_upgradable_mutexB.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/comp_doc_message_queueA.cpp
==============================================================================
--- branches/release/libs/interprocess/example/comp_doc_message_queueA.cpp (original)
+++ branches/release/libs/interprocess/example/comp_doc_message_queueA.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/comp_doc_message_queueB.cpp
==============================================================================
--- branches/release/libs/interprocess/example/comp_doc_message_queueB.cpp (original)
+++ branches/release/libs/interprocess/example/comp_doc_message_queueB.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_adaptive_pool.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_adaptive_pool.cpp (original)
+++ branches/release/libs/interprocess/example/doc_adaptive_pool.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_allocator.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_allocator.cpp (original)
+++ branches/release/libs/interprocess/example/doc_allocator.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_anonymous_condition_shared_data.hpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_anonymous_condition_shared_data.hpp (original)
+++ branches/release/libs/interprocess/example/doc_anonymous_condition_shared_data.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_anonymous_mutex_shared_data.hpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_anonymous_mutex_shared_data.hpp (original)
+++ branches/release/libs/interprocess/example/doc_anonymous_mutex_shared_data.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_anonymous_semaphore_shared_data.hpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_anonymous_semaphore_shared_data.hpp (original)
+++ branches/release/libs/interprocess/example/doc_anonymous_semaphore_shared_data.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_anonymous_shared_memory.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_anonymous_shared_memory.cpp (original)
+++ branches/release/libs/interprocess/example/doc_anonymous_shared_memory.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -23,7 +23,7 @@
 
       //Write all the memory to 1
       std::memset(region.get_address(), 1, region.get_size());
-
+
       //The segment is unmapped when "region" goes out of scope
    }
    catch(interprocess_exception &ex){

Modified: branches/release/libs/interprocess/example/doc_bufferstream.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_bufferstream.cpp (original)
+++ branches/release/libs/interprocess/example/doc_bufferstream.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -93,7 +93,7 @@
    //Clear errors and rewind
    mybufstream.clear();
    mybufstream.seekp(0, std::ios::beg);
-
+
    //Now write again the data trying to do a buffer overflow
    for(int i = 0, m = data.size()*5; i < m; ++i){
       mybufstream << data[i%5] << std::endl;

Modified: branches/release/libs/interprocess/example/doc_cached_adaptive_pool.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_cached_adaptive_pool.cpp (original)
+++ branches/release/libs/interprocess/example/doc_cached_adaptive_pool.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_cached_node_allocator.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_cached_node_allocator.cpp (original)
+++ branches/release/libs/interprocess/example/doc_cached_node_allocator.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_complex_map.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_complex_map.cpp (original)
+++ branches/release/libs/interprocess/example/doc_complex_map.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_cont.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_cont.cpp (original)
+++ branches/release/libs/interprocess/example/doc_cont.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_file_mapping.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_file_mapping.cpp (original)
+++ branches/release/libs/interprocess/example/doc_file_mapping.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_intrusive.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_intrusive.cpp (original)
+++ branches/release/libs/interprocess/example/doc_intrusive.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_ipc_message.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_ipc_message.cpp (original)
+++ branches/release/libs/interprocess/example/doc_ipc_message.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_managed_aligned_allocation.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_managed_aligned_allocation.cpp (original)
+++ branches/release/libs/interprocess/example/doc_managed_aligned_allocation.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -111,7 +111,7 @@
       m_segment.deallocate(ptrs.back());
       ptrs.pop_back();
       ptrs.push_back(m_segment.allocate_aligned(128, 128));
- }
+ }
    return 0;
 }
 */

Modified: branches/release/libs/interprocess/example/doc_managed_allocation_command.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_managed_allocation_command.cpp (original)
+++ branches/release/libs/interprocess/example/doc_managed_allocation_command.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_managed_construction_info.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_managed_construction_info.cpp (original)
+++ branches/release/libs/interprocess/example/doc_managed_construction_info.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_managed_copy_on_write.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_managed_copy_on_write.cpp (original)
+++ branches/release/libs/interprocess/example/doc_managed_copy_on_write.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -81,7 +81,7 @@
    {
       //Now create a read-only version
       managed_mapped_file managed_file_ro(open_read_only, ManagedFile);
-
+
       //Check the original is intact
       if(!managed_file_ro.find<int>("MyInt").first && managed_file_ro.find<int>("MyInt2").first)
          throw int(0);

Modified: branches/release/libs/interprocess/example/doc_managed_external_buffer.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_managed_external_buffer.cpp (original)
+++ branches/release/libs/interprocess/example/doc_managed_external_buffer.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -54,7 +54,7 @@
    //from the first one and duplicate all the data.
    static boost::aligned_storage<memsize>::type static_buffer2;
    std::memcpy(&static_buffer2, &static_buffer, memsize);
-
+
    //Now open the duplicated managed memory passing the memory as argument
    wmanaged_external_buffer objects_in_static_memory2
       (open_only, &static_buffer2, memsize);

Modified: branches/release/libs/interprocess/example/doc_managed_grow.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_managed_grow.cpp (original)
+++ branches/release/libs/interprocess/example/doc_managed_grow.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_managed_heap_memory.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_managed_heap_memory.cpp (original)
+++ branches/release/libs/interprocess/example/doc_managed_heap_memory.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -50,7 +50,7 @@
    //use previously obtained handle to find the new pointer.
    mylist = static_cast<MyList *>
                (heap_memory.get_address_from_handle(list_handle));
-
+
    //Fill list until there is no more memory in the buffer
    try{
       while(1) {
@@ -61,7 +61,7 @@
       //memory is full
    }
 
- //Let's obtain the new size of the list
+ //Let's obtain the new size of the list
    MyList::size_type new_size = mylist->size();
 
    assert(new_size > old_size);

Modified: branches/release/libs/interprocess/example/doc_managed_mapped_file.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_managed_mapped_file.cpp (original)
+++ branches/release/libs/interprocess/example/doc_managed_mapped_file.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -25,7 +25,7 @@
    MyList;
 
 int main ()
-{
+{
    //Define file names
    //<-
    #if 1
@@ -77,7 +77,7 @@
          //so use previously obtained handle to find the new pointer.
          MyList *mylist = static_cast<MyList *>
                            (mfile_memory.get_address_from_handle(list_handle));
-
+
          //Fill list until there is no more room in the file
          try{
             while(1) {
@@ -88,7 +88,7 @@
             //mapped file is full
          }
 
- //Let's obtain the new size of the list
+ //Let's obtain the new size of the list
          MyList::size_type new_size = mylist->size();
 
          assert(new_size > old_size);

Modified: branches/release/libs/interprocess/example/doc_managed_multiple_allocation.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_managed_multiple_allocation.cpp (original)
+++ branches/release/libs/interprocess/example/doc_managed_multiple_allocation.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -64,8 +64,7 @@
 
    //Initialize our data
    while(!chain.empty()){
- void *buf = chain.front();
- chain.pop_front();
+ void *buf = chain.pop_front();
       allocated_buffers.push_back(buf);
       //The iterator must be incremented before overwriting memory
       //because otherwise, the iterator is invalidated.

Modified: branches/release/libs/interprocess/example/doc_managed_raw_allocation.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_managed_raw_allocation.cpp (original)
+++ branches/release/libs/interprocess/example/doc_managed_raw_allocation.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_map.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_map.cpp (original)
+++ branches/release/libs/interprocess/example/doc_map.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_move_containers.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_move_containers.cpp (original)
+++ branches/release/libs/interprocess/example/doc_move_containers.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -28,7 +28,7 @@
    typedef allocator<char, SegmentManager> CharAllocator;
    typedef basic_string<char, std::char_traits<char>
                         ,CharAllocator> MyShmString;
- typedef allocator<MyShmString, SegmentManager> StringAllocator;
+ typedef allocator<MyShmString, SegmentManager> StringAllocator;
    typedef vector<MyShmString, StringAllocator> MyShmStringVector;
 
    //Remove shared memory on construction and destruction
@@ -73,7 +73,7 @@
    //strings, leading to a great performance.
    MyShmString string_to_compare(charallocator);
    string_to_compare = "this is a long, long, long, long, long, long, string...";
-
+
    myshmvector->reserve(50);
    for(int i = 0; i < 50; ++i){
       MyShmString move_me(string_to_compare);

Modified: branches/release/libs/interprocess/example/doc_multi_index.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_multi_index.cpp (original)
+++ branches/release/libs/interprocess/example/doc_multi_index.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_named_alloc.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_named_alloc.cpp (original)
+++ branches/release/libs/interprocess/example/doc_named_alloc.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -112,12 +112,12 @@
       std::pair<MyType*, managed_shared_memory::size_type> res;
 
       //Find the array
- res = segment.find<MyType> ("MyType array");
+ res = segment.find<MyType> ("MyType array");
       //Length should be 10
       if(res.second != 10) return 1;
 
       //Find the object
- res = segment.find<MyType> ("MyType instance");
+ res = segment.find<MyType> ("MyType instance");
       //Length should be 1
       if(res.second != 1) return 1;
 

Modified: branches/release/libs/interprocess/example/doc_named_condition_shared_data.hpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_named_condition_shared_data.hpp (original)
+++ branches/release/libs/interprocess/example/doc_named_condition_shared_data.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_named_mutex.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_named_mutex.cpp (original)
+++ branches/release/libs/interprocess/example/doc_named_mutex.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -77,7 +77,7 @@
       //->
 
       for(int i = 0; i < 10; ++i){
-
+
          //Do some operations...
 
          //Write to file atomically

Modified: branches/release/libs/interprocess/example/doc_node_allocator.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_node_allocator.cpp (original)
+++ branches/release/libs/interprocess/example/doc_node_allocator.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_offset_ptr.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_offset_ptr.cpp (original)
+++ branches/release/libs/interprocess/example/doc_offset_ptr.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_private_adaptive_pool.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_private_adaptive_pool.cpp (original)
+++ branches/release/libs/interprocess/example/doc_private_adaptive_pool.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -68,7 +68,7 @@
    //is the same, this private_adaptive_pool will have its own pool so
    //"allocator_instance2" CAN'T deallocate nodes allocated by "allocator_instance".
    //"allocator_instance2" is NOT equal to "allocator_instance"
- assert(allocator_instance != allocator_instance2);
+ assert(allocator_instance != allocator_instance2);
 
    //Create another adaptive_pool using copy-constructor.
    private_adaptive_pool_t allocator_instance3(allocator_instance2);

Modified: branches/release/libs/interprocess/example/doc_private_node_allocator.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_private_node_allocator.cpp (original)
+++ branches/release/libs/interprocess/example/doc_private_node_allocator.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -68,7 +68,7 @@
    //is the same, this private_node_allocator will have its own pool so
    //"allocator_instance2" CAN'T deallocate nodes allocated by "allocator_instance".
    //"allocator_instance2" is NOT equal to "allocator_instance"
- assert(allocator_instance != allocator_instance2);
+ assert(allocator_instance != allocator_instance2);
 
    //Create another node_allocator using copy-constructor.
    private_node_allocator_t allocator_instance3(allocator_instance2);

Modified: branches/release/libs/interprocess/example/doc_scoped_ptr.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_scoped_ptr.cpp (original)
+++ branches/release/libs/interprocess/example/doc_scoped_ptr.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -86,7 +86,7 @@
       my_class * my_object = shmem.construct<my_class>("my_object")();
       my_class * my_object2 = shmem.construct<my_class>(anonymous_instance)();
       shmem.destroy_ptr(my_object2);
-
+
       //Since the next shared memory allocation can throw
       //assign it to a scoped_ptr so that if an exception occurs
       //we destroy the object automatically

Modified: branches/release/libs/interprocess/example/doc_shared_memory.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_shared_memory.cpp (original)
+++ branches/release/libs/interprocess/example/doc_shared_memory.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_shared_ptr.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_shared_ptr.cpp (original)
+++ branches/release/libs/interprocess/example/doc_shared_ptr.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011.
+// (C) Copyright Ion Gaztanaga 2006-2012.
 // 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)
@@ -128,11 +128,11 @@
       //Now destroy the remaining owner. "object to share" will be destroyed
       file.destroy_ptr(owner2);
       assert(file.find<type_to_share>("object to share").first == 0);
-
+
       //Test observer
       assert(local_observer1.expired());
       assert(local_observer1.use_count() == 0);
-
+
       //The reference count will be deallocated when all weak pointers
       //disappear. After that, the file is unmapped.
    }

Modified: branches/release/libs/interprocess/example/doc_shared_ptr_explicit.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_shared_ptr_explicit.cpp (original)
+++ branches/release/libs/interprocess/example/doc_shared_ptr_explicit.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011.
+// (C) Copyright Ion Gaztanaga 2006-2012.
 // 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)
@@ -62,7 +62,7 @@
    //<-
    #endif
    //->
-
+
    //Create a shared pointer in shared memory
    //pointing to a newly created object in the segment
    my_shared_ptr &shared_ptr_instance =

Modified: branches/release/libs/interprocess/example/doc_spawn_vector.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_spawn_vector.cpp (original)
+++ branches/release/libs/interprocess/example/doc_spawn_vector.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_unique_ptr.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_unique_ptr.cpp (original)
+++ branches/release/libs/interprocess/example/doc_unique_ptr.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011.
+// (C) Copyright Ion Gaztanaga 2006-2012.
 // 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)
@@ -97,11 +97,11 @@
          unique_vector->push_back(boost::move(p));
          assert(unique_vector->back()->number_ == i);
       }
-
+
       //Now create a list of unique pointers
       unique_ptr_list_t *unique_list =
          file.construct<unique_ptr_list_t>("unique list")(file.get_segment_manager());
-
+
       //Pass ownership of all values to the list
       for(int i = 99; !unique_vector->empty(); --i){
          unique_list->push_front(boost::move(unique_vector->back()));
@@ -131,7 +131,7 @@
       for(int i = 0; i < 100; ++i, ++list_it){
          assert((*list_it)->number_ == i);
       }
-
+
       //Now destroy the list. All elements will be automatically deallocated.
       file.destroy_ptr(unique_list);
    }

Modified: branches/release/libs/interprocess/example/doc_unordered_map.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_unordered_map.cpp (original)
+++ branches/release/libs/interprocess/example/doc_unordered_map.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_upgradable_mutex_shared_data.hpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_upgradable_mutex_shared_data.hpp (original)
+++ branches/release/libs/interprocess/example/doc_upgradable_mutex_shared_data.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_vectorstream.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_vectorstream.cpp (original)
+++ branches/release/libs/interprocess/example/doc_vectorstream.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_where_allocate.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_where_allocate.cpp (original)
+++ branches/release/libs/interprocess/example/doc_where_allocate.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -27,7 +27,7 @@
    typedef basic_string<char, std::char_traits<char>, CharAllocator>
       MyShmString;
    typedef allocator<MyShmString, managed_shared_memory::segment_manager>
- StringAllocator;
+ StringAllocator;
    typedef vector<MyShmString, StringAllocator>
       MyShmStringVector;
 

Modified: branches/release/libs/interprocess/example/doc_windows_shared_memory.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_windows_shared_memory.cpp (original)
+++ branches/release/libs/interprocess/example/doc_windows_shared_memory.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/example/doc_xsi_shared_memory.cpp
==============================================================================
--- branches/release/libs/interprocess/example/doc_xsi_shared_memory.cpp (original)
+++ branches/release/libs/interprocess/example/doc_xsi_shared_memory.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/proj/to-do.txt
==============================================================================
--- branches/release/libs/interprocess/proj/to-do.txt (original)
+++ branches/release/libs/interprocess/proj/to-do.txt 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -249,3 +249,17 @@
 
 ipcdetail::intermodule_singleton<MyRobustMutexLockFile>::get();
 
+Add unsigned overflow checking with shortcut as explained here:
+
+https://github.com/ivmai/bdwgc/commit/83231d0ab5ed60015797c3d1ad9056295ac3b2bb
+
+# define GC_SIZE_MAX (~(size_t)0)
+ #endif
++#define GC_SQRT_SIZE_MAX ((1U << (WORDSZ / 2)) - 1)
++
+void * calloc(size_t n, size_t lb)
+{
+- if (lb && n > GC_SIZE_MAX / lb)
++ if ((lb | n) > GC_SQRT_SIZE_MAX /* fast initial test */
++ && lb && n > GC_SIZE_MAX / lb)
+ return NULL;

Modified: branches/release/libs/interprocess/proj/vc7ide/Interprocess.sln
==============================================================================
--- branches/release/libs/interprocess/proj/vc7ide/Interprocess.sln (original)
+++ branches/release/libs/interprocess/proj/vc7ide/Interprocess.sln 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -463,6 +463,22 @@
         ProjectSection(ProjectDependencies) = postProject
         EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sharable_mutex_test", "sharable_mutex.vcproj", "{4E88C1C2-0961-F7A4-F48E-A6A7D3B06004}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "condition_any_test", "condition_any_test.vcproj", "{5875E186-48F8-0992-26A7-D34F4A053798}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "named_sharable_mutex_test", "named_sharable_mutex.vcproj", "{4FB82CC8-9671-FA47-48FE-723BA0D91604}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "named_condition_any_test", "named_condition_any_test.vcproj", "{58CC2563-6092-48FE-FAF7-BA046A792658}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
 Global
         GlobalSection(SolutionConfiguration) = preSolution
                 Debug = Debug
@@ -935,6 +951,22 @@
                 {E35C288C-F48E-6914-4FA7-5BA006383C10}.Debug.Build.0 = Debug|Win32
                 {E35C288C-F48E-6914-4FA7-5BA006383C10}.Release.ActiveCfg = Release|Win32
                 {E35C288C-F48E-6914-4FA7-5BA006383C10}.Release.Build.0 = Release|Win32
+ {4E88C1C2-0961-F7A4-F48E-A6A7D3B06004}.Debug.ActiveCfg = Debug|Win32
+ {4E88C1C2-0961-F7A4-F48E-A6A7D3B06004}.Debug.Build.0 = Debug|Win32
+ {4E88C1C2-0961-F7A4-F48E-A6A7D3B06004}.Release.ActiveCfg = Release|Win32
+ {4E88C1C2-0961-F7A4-F48E-A6A7D3B06004}.Release.Build.0 = Release|Win32
+ {5875E186-48F8-0992-26A7-D34F4A053798}.Debug.ActiveCfg = Debug|Win32
+ {5875E186-48F8-0992-26A7-D34F4A053798}.Debug.Build.0 = Debug|Win32
+ {5875E186-48F8-0992-26A7-D34F4A053798}.Release.ActiveCfg = Release|Win32
+ {5875E186-48F8-0992-26A7-D34F4A053798}.Release.Build.0 = Release|Win32
+ {4FB82CC8-9671-FA47-48FE-723BA0D91604}.Debug.ActiveCfg = Debug|Win32
+ {4FB82CC8-9671-FA47-48FE-723BA0D91604}.Debug.Build.0 = Debug|Win32
+ {4FB82CC8-9671-FA47-48FE-723BA0D91604}.Release.ActiveCfg = Release|Win32
+ {4FB82CC8-9671-FA47-48FE-723BA0D91604}.Release.Build.0 = Release|Win32
+ {58CC2563-6092-48FE-FAF7-BA046A792658}.Debug.ActiveCfg = Debug|Win32
+ {58CC2563-6092-48FE-FAF7-BA046A792658}.Debug.Build.0 = Debug|Win32
+ {58CC2563-6092-48FE-FAF7-BA046A792658}.Release.ActiveCfg = Release|Win32
+ {58CC2563-6092-48FE-FAF7-BA046A792658}.Release.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(ExtensibilityGlobals) = postSolution
         EndGlobalSection

Modified: branches/release/libs/interprocess/proj/vc7ide/condition_test.vcproj
==============================================================================
--- branches/release/libs/interprocess/proj/vc7ide/condition_test.vcproj (original)
+++ branches/release/libs/interprocess/proj/vc7ide/condition_test.vcproj 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -13,7 +13,7 @@
                 <Configuration
                         Name="Debug|Win32"
                         OutputDirectory="../../Bin/Win32/Debug"
- IntermediateDirectory="Debug/shared_condition_test"
+ IntermediateDirectory="Debug/condition_test"
                         ConfigurationType="1"
                         CharacterSet="2">
                         <Tool
@@ -35,11 +35,11 @@
                         <Tool
                                 Name="VCLinkerTool"
                                 AdditionalDependencies="winmm.lib"
- OutputFile="$(OutDir)/shared_condition_test_d.exe"
+ OutputFile="$(OutDir)/condition_test_d.exe"
                                 LinkIncremental="1"
                                 AdditionalLibraryDirectories="../../../../stage/lib"
                                 GenerateDebugInformation="TRUE"
- ProgramDatabaseFile="$(OutDir)/shared_condition_test.pdb"
+ ProgramDatabaseFile="$(OutDir)/condition_test.pdb"
                                 SubSystem="1"
                                 TargetMachine="1"
                                 FixedBaseAddress="1"/>
@@ -67,7 +67,7 @@
                 <Configuration
                         Name="Release|Win32"
                         OutputDirectory="../../Bin/Win32/Release"
- IntermediateDirectory="Release/shared_condition_test"
+ IntermediateDirectory="Release/condition_test"
                         ConfigurationType="1"
                         CharacterSet="2">
                         <Tool
@@ -86,7 +86,7 @@
                         <Tool
                                 Name="VCLinkerTool"
                                 AdditionalDependencies="winmm.lib"
- OutputFile="$(OutDir)/shared_condition_test.exe"
+ OutputFile="$(OutDir)/condition_test.exe"
                                 LinkIncremental="1"
                                 AdditionalLibraryDirectories="../../../../stage/lib"
                                 GenerateDebugInformation="TRUE"

Modified: branches/release/libs/interprocess/proj/vc7ide/interprocesslib.vcproj
==============================================================================
--- branches/release/libs/interprocess/proj/vc7ide/interprocesslib.vcproj (original)
+++ branches/release/libs/interprocess/proj/vc7ide/interprocesslib.vcproj 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -195,6 +195,9 @@
                                 RelativePath="..\..\..\..\boost\interprocess\sync\interprocess_condition.hpp">
                         </File>
                         <File
+ RelativePath="..\..\..\..\boost\interprocess\sync\interprocess_condition_any.hpp">
+ </File>
+ <File
                                 RelativePath="..\..\..\..\boost\interprocess\sync\interprocess_mutex.hpp">
                         </File>
                         <File
@@ -204,6 +207,9 @@
                                 RelativePath="..\..\..\..\boost\interprocess\sync\interprocess_semaphore.hpp">
                         </File>
                         <File
+ RelativePath="..\..\..\..\boost\interprocess\sync\interprocess_sharable_mutex.hpp">
+ </File>
+ <File
                                 RelativePath="..\..\..\..\boost\interprocess\sync\interprocess_upgradable_mutex.hpp">
                         </File>
                         <File
@@ -216,6 +222,9 @@
                                 RelativePath="..\..\..\..\boost\interprocess\sync\named_condition.hpp">
                         </File>
                         <File
+ RelativePath="..\..\..\..\boost\interprocess\sync\named_condition_any.hpp">
+ </File>
+ <File
                                 RelativePath="..\..\..\..\boost\interprocess\sync\named_mutex.hpp">
                         </File>
                         <File
@@ -225,6 +234,9 @@
                                 RelativePath="..\..\..\..\boost\interprocess\sync\named_semaphore.hpp">
                         </File>
                         <File
+ RelativePath="..\..\..\..\boost\interprocess\sync\named_sharable_mutex.hpp">
+ </File>
+ <File
                                 RelativePath="..\..\..\..\boost\interprocess\sync\named_upgradable_mutex.hpp">
                         </File>
                         <File
@@ -312,6 +324,9 @@
                                         RelativePath="..\..\..\..\boost\interprocess\sync\windows\named_condition.hpp">
                                 </File>
                                 <File
+ RelativePath="..\..\..\..\boost\interprocess\sync\windows\named_condition_any.hpp">
+ </File>
+ <File
                                         RelativePath="..\..\..\..\boost\interprocess\sync\windows\named_mutex.hpp">
                                 </File>
                                 <File
@@ -346,6 +361,9 @@
                                         RelativePath="..\..\..\..\boost\interprocess\sync\shm\named_condition.hpp">
                                 </File>
                                 <File
+ RelativePath="..\..\..\..\boost\interprocess\sync\shm\named_condition_any.hpp">
+ </File>
+ <File
                                         RelativePath="..\..\..\..\boost\interprocess\sync\shm\named_creation_functor.hpp">
                                 </File>
                                 <File
@@ -367,6 +385,12 @@
                                 <File
                                         RelativePath="..\..\..\..\boost\interprocess\sync\detail\condition_algorithm_8a.hpp">
                                 </File>
+ <File
+ RelativePath="..\..\..\..\boost\interprocess\sync\detail\condition_any_algorithm.hpp">
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\interprocess\sync\detail\locks.hpp">
+ </File>
                         </Filter>
                 </Filter>
                 <Filter
@@ -658,9 +682,6 @@
                                 RelativePath="..\..\test\heap_allocator_v1.hpp">
                         </File>
                         <File
- RelativePath="..\..\test\Jamfile.v2">
- </File>
- <File
                                 RelativePath="..\..\test\list_test.hpp">
                         </File>
                         <File

Modified: branches/release/libs/interprocess/proj/vc7ide/message_queue.vcproj
==============================================================================
--- branches/release/libs/interprocess/proj/vc7ide/message_queue.vcproj (original)
+++ branches/release/libs/interprocess/proj/vc7ide/message_queue.vcproj 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -13,7 +13,7 @@
                 <Configuration
                         Name="Debug|Win32"
                         OutputDirectory="../../Bin/Win32/Debug"
- IntermediateDirectory="Debug/shared_message_queue_test"
+ IntermediateDirectory="Debug/message_queue_test"
                         ConfigurationType="1"
                         CharacterSet="2">
                         <Tool
@@ -35,7 +35,7 @@
                         <Tool
                                 Name="VCLinkerTool"
                                 AdditionalDependencies="winmm.lib"
- OutputFile="$(OutDir)/shared_message_queue_test_d.exe"
+ OutputFile="$(OutDir)/message_queue_test_d.exe"
                                 LinkIncremental="1"
                                 AdditionalLibraryDirectories="../../../../stage/lib"
                                 GenerateDebugInformation="TRUE"
@@ -67,7 +67,7 @@
                 <Configuration
                         Name="Release|Win32"
                         OutputDirectory="../../Bin/Win32/Release"
- IntermediateDirectory="Release/shared_message_queue_test"
+ IntermediateDirectory="Release/message_queue_test"
                         ConfigurationType="1"
                         CharacterSet="2">
                         <Tool
@@ -86,7 +86,7 @@
                         <Tool
                                 Name="VCLinkerTool"
                                 AdditionalDependencies="winmm.lib"
- OutputFile="$(OutDir)/shared_message_queue_test.exe"
+ OutputFile="$(OutDir)/message_queue_test.exe"
                                 LinkIncremental="1"
                                 AdditionalLibraryDirectories="../../../../stage/lib"
                                 GenerateDebugInformation="TRUE"

Modified: branches/release/libs/interprocess/test/adaptive_node_pool_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/adaptive_node_pool_test.cpp (original)
+++ branches/release/libs/interprocess/test/adaptive_node_pool_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2007-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/adaptive_pool_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/adaptive_pool_test.cpp (original)
+++ branches/release/libs/interprocess/test/adaptive_pool_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/allocator_v1.hpp
==============================================================================
--- branches/release/libs/interprocess/test/allocator_v1.hpp (original)
+++ branches/release/libs/interprocess/test/allocator_v1.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -29,6 +29,7 @@
 #include <algorithm>
 #include <cstddef>
 #include <stdexcept>
+#include <boost/static_assert.hpp>
 
 //!\file
 //!Describes an allocator_v1 that allocates portions of fixed size
@@ -86,7 +87,7 @@
    //!Obtains an allocator_v1 of other type
    template<class T2>
    struct rebind
- {
+ {
       typedef allocator_v1<T2, SegmentManager> other;
    };
 
@@ -118,7 +119,12 @@
    //!Allocates memory for an array of count elements.
    //!Throws boost::interprocess::bad_alloc if there is no enough memory
    pointer allocate(size_type count, cvoid_ptr hint = 0)
- { (void)hint; return pointer(static_cast<value_type*>(mp_mngr->allocate(count*sizeof(value_type)))); }
+ {
+ if(size_overflows<sizeof(T)>(count)){
+ throw bad_alloc();
+ }
+ (void)hint; return pointer(static_cast<T*>(mp_mngr->allocate(count*sizeof(T))));
+ }
 
    //!Deallocates memory previously allocated. Never throws
    void deallocate(const pointer &ptr, size_type)

Modified: branches/release/libs/interprocess/test/allocexcept_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/allocexcept_test.cpp (original)
+++ branches/release/libs/interprocess/test/allocexcept_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -59,7 +59,7 @@
       int i;
       for(i = 0; true; ++i){
          myvec.push_back(InstanceCounter());
- }
+ }
    }
    catch(boost::interprocess::bad_alloc &){
       if(InstanceCounter::counter != 0)
@@ -74,7 +74,7 @@
       InstanceCounter ic;
       for(i = 0; true; ++i){
          myvec.insert(myvec.begin(), i, ic);
- }
+ }
    }
    catch(boost::interprocess::bad_alloc &){
       if(InstanceCounter::counter != 0)

Modified: branches/release/libs/interprocess/test/anonymous_shared_memory_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/anonymous_shared_memory_test.cpp (original)
+++ branches/release/libs/interprocess/test/anonymous_shared_memory_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/boost_interprocess_check.hpp
==============================================================================
--- branches/release/libs/interprocess/test/boost_interprocess_check.hpp (original)
+++ branches/release/libs/interprocess/test/boost_interprocess_check.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/bufferstream_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/bufferstream_test.cpp (original)
+++ branches/release/libs/interprocess/test/bufferstream_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -60,10 +60,10 @@
          bufstream >> str1 >> number1;
          std_stringstream >> str2 >> number2;
          if((str1 != str2) || (str1 != str3)){
- assert(0); return 1;
+ assert(0); return 1;
          }
          if((number1 != number2) || (number1 != i)){
- assert(0); return 1;
+ assert(0); return 1;
          }
       }
       //We shouldn't have reached the end of the buffer reading
@@ -90,7 +90,7 @@
          bufstream << "testline: " << i << std::endl;
          std_stringstream << "testline: " << i << std::endl;
       }
-
+
       //Contents should be different
       if(std::strcmp(buffer, std_stringstream.str().c_str()) == 0){
          return 1;

Modified: branches/release/libs/interprocess/test/cached_adaptive_pool_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/cached_adaptive_pool_test.cpp (original)
+++ branches/release/libs/interprocess/test/cached_adaptive_pool_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/cached_node_allocator_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/cached_node_allocator_test.cpp (original)
+++ branches/release/libs/interprocess/test/cached_node_allocator_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/check_equal_containers.hpp
==============================================================================
--- branches/release/libs/interprocess/test/check_equal_containers.hpp (original)
+++ branches/release/libs/interprocess/test/check_equal_containers.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -15,11 +15,31 @@
 #include <functional>
 #include <iostream>
 #include <algorithm>
+#include <boost/container/detail/pair.hpp>
 
 namespace boost{
 namespace interprocess{
 namespace test{
 
+template< class T1, class T2>
+bool CheckEqual( const T1 &t1, const T2 &t2
+ , typename boost::container::container_detail::enable_if_c
+ <!boost::container::container_detail::is_pair<T1>::value &&
+ !boost::container::container_detail::is_pair<T2>::value
+ >::type* = 0)
+{ return t1 == t2; }
+
+template< class Pair1, class Pair2>
+bool CheckEqual( const Pair1 &pair1, const Pair2 &pair2
+ , typename boost::container::container_detail::enable_if_c
+ <boost::container::container_detail::is_pair<Pair1>::value &&
+ boost::container::container_detail::is_pair<Pair2>::value
+ >::type* = 0)
+{
+ return CheckEqual(pair1.first, pair2.first) && CheckEqual(pair1.second, pair2.second);
+}
+
+
 //Function to check if both containers are equal
 template<class MyShmCont
         ,class MyStdCont>
@@ -38,9 +58,7 @@
    }
    std::size_t i = 0;
    for(; itshm != itshmend; ++itshm, ++itstd, ++i){
- value_type val(*itstd);
- const value_type &v = *itshm;
- if(v != val)
+ if(!CheckEqual(*itstd, *itshm))
          return false;
    }
    return true;

Modified: branches/release/libs/interprocess/test/condition_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/condition_test.cpp (original)
+++ branches/release/libs/interprocess/test/condition_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/condition_test_template.hpp
==============================================================================
--- branches/release/libs/interprocess/test/condition_test_template.hpp (original)
+++ branches/release/libs/interprocess/test/condition_test_template.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -10,7 +10,7 @@
 // It is provided "as is" without express or implied warranty.
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -48,7 +48,7 @@
     const int NANOSECONDS_PER_MILLISECOND = 1000000;
 
     boost::xtime xt;
-
+
     #if BOOST_VERSION >= 105100 //TIME_UTC is a macro in C11, breaking change in Boost.Thread
     int ret = boost::xtime_get(&xt, boost::TIME_UTC_);
     BOOST_INTERPROCES_CHECK(ret == static_cast<int>(boost::TIME_UTC_));(void)ret;
@@ -168,6 +168,8 @@
    condition_test_data<Condition, Mutex> data;
 
    boost::thread thread(bind_function(&condition_test_thread<Condition, Mutex>, &data));
+ //Make sure thread is blocked
+ boost::thread::sleep(delay(1));
    {
       boost::interprocess::scoped_lock<Mutex>
          lock(data.mutex);
@@ -187,16 +189,18 @@
    boost::thread_group threads;
    condition_test_data<Condition, Mutex> data;
 
- for (int i = 0; i < NUMTHREADS; ++i)
+ for (int i = 0; i < NUMTHREADS; ++i){
        threads.create_thread(bind_function(&condition_test_thread<Condition, Mutex>, &data));
-
+ }
+ //Make sure all threads are blocked
+ boost::thread::sleep(delay(1));
    {
       boost::interprocess::scoped_lock<Mutex>
          lock(data.mutex);
       BOOST_INTERPROCES_CHECK(lock ? true : false);
       data.notified++;
- data.condition.notify_all();
    }
+ data.condition.notify_all();
 
    threads.join_all();
    BOOST_INTERPROCES_CHECK(data.awoken == NUMTHREADS);
@@ -396,16 +400,16 @@
 template <class Condition, class Mutex>
 bool do_test_condition()
 {
- std::cout << "do_test_condition_notify_one<" << typeid(Condition).name() << "," << typeid(Mutex).name() << std::endl;
+ std::cout << "do_test_condition_notify_one<" << typeid(Condition).name() << "," << typeid(Mutex).name() << '\n' << std::endl;
    do_test_condition_notify_one<Condition, Mutex>();
- std::cout << "do_test_condition_notify_all<" << typeid(Condition).name() << "," << typeid(Mutex).name() << std::endl;
+ std::cout << "do_test_condition_notify_all<" << typeid(Condition).name() << "," << typeid(Mutex).name() << '\n' << std::endl;
    do_test_condition_notify_all<Condition, Mutex>();
- std::cout << "do_test_condition_waits<" << typeid(Condition).name() << "," << typeid(Mutex).name() << std::endl;
+ std::cout << "do_test_condition_waits<" << typeid(Condition).name() << "," << typeid(Mutex).name() << '\n' << std::endl;
    do_test_condition_waits<Condition, Mutex>();
- //std::cout << "do_test_condition_queue_notify_one<" << typeid(Condition).name() << "," << typeid(Mutex).name() << std::endl;
- //do_test_condition_queue_notify_one<Condition, Mutex>();
- //std::cout << "do_test_condition_queue_notify_all<" << typeid(Condition).name() << "," << typeid(Mutex).name() << std::endl;
- //do_test_condition_queue_notify_all<Condition, Mutex>();
+ std::cout << "do_test_condition_queue_notify_one<" << typeid(Condition).name() << "," << typeid(Mutex).name() << '\n' << std::endl;
+ do_test_condition_queue_notify_one<Condition, Mutex>();
+ std::cout << "do_test_condition_queue_notify_all<" << typeid(Condition).name() << "," << typeid(Mutex).name() << '\n' << std::endl;
+ do_test_condition_queue_notify_all<Condition, Mutex>();
    return true;
 }
 

Modified: branches/release/libs/interprocess/test/data_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/data_test.cpp (original)
+++ branches/release/libs/interprocess/test/data_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/deque_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/deque_test.cpp (original)
+++ branches/release/libs/interprocess/test/deque_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -57,7 +57,7 @@
    typedef typename V1::value_type IntType;
    std::size_t size = shmdeque->size();
    stddeque->insert(stddeque->end(), 50, 1);
- shmdeque->insert(shmdeque->end(), 50, 1);
+ shmdeque->insert(shmdeque->end(), 50, IntType(1));
    if(!test::CheckEqualContainers(shmdeque, stddeque)) return false;
    {
       IntType move_me(1);
@@ -261,11 +261,11 @@
 
          shmdeque->resize(100);
          stddeque->resize(100);
- if(!test::CheckEqualContainers(shmdeque, stddeque)) return 1;
+ if(!test::CheckEqualContainers(shmdeque, stddeque)) return 1;
 
          shmdeque->resize(200);
          stddeque->resize(200);
- if(!test::CheckEqualContainers(shmdeque, stddeque)) return 1;
+ if(!test::CheckEqualContainers(shmdeque, stddeque)) return 1;
 
          segment.template destroy<MyShmDeque>("MyShmDeque");
          delete stddeque;
@@ -278,7 +278,7 @@
          std::cout << ex.what() << std::endl;
          return false;
       }*/
-
+
       std::cout << std::endl << "Test OK!" << std::endl;
    }/*
    catch(...){

Modified: branches/release/libs/interprocess/test/dummy_test_allocator.hpp
==============================================================================
--- branches/release/libs/interprocess/test/dummy_test_allocator.hpp (original)
+++ branches/release/libs/interprocess/test/dummy_test_allocator.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/emplace_test.hpp
==============================================================================
--- branches/release/libs/interprocess/test/emplace_test.hpp (original)
+++ branches/release/libs/interprocess/test/emplace_test.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/enable_shared_from_this_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/enable_shared_from_this_test.cpp (original)
+++ branches/release/libs/interprocess/test/enable_shared_from_this_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -3,7 +3,7 @@
 //
 // This file is the adaptation of shared_from_this_test.cpp from smart_ptr library
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/expand_bwd_test_allocator.hpp
==============================================================================
--- branches/release/libs/interprocess/test/expand_bwd_test_allocator.hpp (original)
+++ branches/release/libs/interprocess/test/expand_bwd_test_allocator.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -109,7 +109,7 @@
    { return m_size; }
 
    friend void swap(self_t &alloc1, self_t &alloc2)
- {
+ {
       ipcdetail::do_swap(alloc1.mp_buffer, alloc2.mp_buffer);
       ipcdetail::do_swap(alloc1.m_size, alloc2.m_size);
       ipcdetail::do_swap(alloc1.m_offset, alloc2.m_offset);
@@ -126,7 +126,7 @@
       (void)preferred_size; (void)reuse; (void)command;
       //This allocator only expands backwards!
       assert(m_allocations == 0 || (command & boost::interprocess::expand_bwd));
-
+
       received_size = limit_size;
 
       if(m_allocations == 0){

Modified: branches/release/libs/interprocess/test/expand_bwd_test_template.hpp
==============================================================================
--- branches/release/libs/interprocess/test/expand_bwd_test_template.hpp (original)
+++ branches/release/libs/interprocess/test/expand_bwd_test_template.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/file_lock_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/file_lock_test.cpp (original)
+++ branches/release/libs/interprocess/test/file_lock_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/file_mapping_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/file_mapping_test.cpp (original)
+++ branches/release/libs/interprocess/test/file_mapping_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -62,7 +62,7 @@
                               ,FileSize - FileSize/2
                               );
 
- //Fill two regions with a pattern
+ //Fill two regions with a pattern
          unsigned char *filler = static_cast<unsigned char*>(region.get_address());
          for(std::size_t i = 0
             ;i < FileSize/2
@@ -92,7 +92,7 @@
 
          //Create a memory buffer
          std::auto_ptr<unsigned char> memory (new unsigned char [FileSize/2 +1]);
-
+
          //Fill buffer
          file.read(static_cast<char*>(static_cast<void*>(memory.get()))
                   , FileSize/2);

Modified: branches/release/libs/interprocess/test/flat_map_index_allocation_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/flat_map_index_allocation_test.cpp (original)
+++ branches/release/libs/interprocess/test/flat_map_index_allocation_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/flat_tree_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/flat_tree_test.cpp (original)
+++ branches/release/libs/interprocess/test/flat_tree_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -23,11 +23,11 @@
 #include "emplace_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;

Modified: branches/release/libs/interprocess/test/get_process_id_name.hpp
==============================================================================
--- branches/release/libs/interprocess/test/get_process_id_name.hpp (original)
+++ branches/release/libs/interprocess/test/get_process_id_name.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/heap_allocator_v1.hpp
==============================================================================
--- branches/release/libs/interprocess/test/heap_allocator_v1.hpp (original)
+++ branches/release/libs/interprocess/test/heap_allocator_v1.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //
@@ -83,7 +83,7 @@
    //!Obtains an heap_allocator_v1 of other type
    template<class T2>
    struct rebind
- {
+ {
       typedef heap_allocator_v1<T2, SegmentManager> other;
    };
 

Modified: branches/release/libs/interprocess/test/intermodule_singleton_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/intermodule_singleton_test.cpp (original)
+++ branches/release/libs/interprocess/test/intermodule_singleton_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -87,7 +87,7 @@
       return 1;
    }
 
- return 0;
+ return 0;
 }
 
 //A class simulating a logger
@@ -249,7 +249,7 @@
    //LoggerSingleton.
    //After that LoggerSingleton will be destroyed and
    //lastly LogPhoenixTester will be destroyed checking
- //LoggerSingleton was correctly destroyed.
+ //LoggerSingleton was correctly destroyed.
    return 0;
 }
 

Modified: branches/release/libs/interprocess/test/intersegment_ptr_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/intersegment_ptr_test.cpp (original)
+++ branches/release/libs/interprocess/test/intersegment_ptr_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2007-2012. 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)
 //
@@ -48,7 +48,7 @@
    pcint_t pcint(0);
    pvint_t pvint(0);
    pcvint_t pcvint(0);
-
+
    pint = &dummy_int;
    pcint = &dummy_int;
    pvint = &dummy_int;
@@ -75,7 +75,7 @@
    typedef intersegment_ptr<int> pint_t;
    const int NumValues = 5;
    int values[NumValues];
-
+
    //Initialize p
    pint_t p = values;
    if(p.get() != values)
@@ -376,7 +376,7 @@
       shared_memory_object::remove("kk0");
       managed_multi_shared_memory mshm(create_only, "kk", 4096);
    }
-
+
    shared_memory_object::remove("kk0");
    return true;
 }

Modified: branches/release/libs/interprocess/test/intrusive_ptr_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/intrusive_ptr_test.cpp (original)
+++ branches/release/libs/interprocess/test/intrusive_ptr_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,7 +1,7 @@
 //////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Peter Dimov 2002-2005.
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/iset_index_allocation_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/iset_index_allocation_test.cpp (original)
+++ branches/release/libs/interprocess/test/iset_index_allocation_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/iunordered_set_index_allocation_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/iunordered_set_index_allocation_test.cpp (original)
+++ branches/release/libs/interprocess/test/iunordered_set_index_allocation_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/list_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/list_test.cpp (original)
+++ branches/release/libs/interprocess/test/list_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/list_test.hpp
==============================================================================
--- branches/release/libs/interprocess/test/list_test.hpp (original)
+++ branches/release/libs/interprocess/test/list_test.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 ////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -219,7 +219,7 @@
             shmlist->splice(shmlist->begin(), othershmlist);
             stdlist->splice(stdlist->begin(), otherstdlist);
             if(!CheckEqualContainers(shmlist, stdlist))
- return 1;
+ return 1;
          }
 
          listsize = (int)shmlist->size();

Modified: branches/release/libs/interprocess/test/managed_mapped_file_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/managed_mapped_file_test.cpp (original)
+++ branches/release/libs/interprocess/test/managed_mapped_file_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -83,7 +83,7 @@
 
       //Construct a vector in the memory-mapped file
       mfile_vect = mfile.construct<MyVect> ("MyVector") (myallocator);
-
+
       //Flush cached data from memory-mapped file to disk
       mfile.flush();
    }

Modified: branches/release/libs/interprocess/test/managed_shared_memory_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/managed_shared_memory_test.cpp (original)
+++ branches/release/libs/interprocess/test/managed_shared_memory_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/managed_windows_shared_memory_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/managed_windows_shared_memory_test.cpp (original)
+++ branches/release/libs/interprocess/test/managed_windows_shared_memory_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -123,7 +123,7 @@
             if(!shmem_vect)
                return -1;
          }
-
+
          //Destroy and check it is not present
          w_shm_new.destroy_ptr(w_shm_vect);
          if(0 != w_shm_new.find<MyVect>("MyVector").first)

Modified: branches/release/libs/interprocess/test/managed_xsi_shared_memory_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/managed_xsi_shared_memory_test.cpp (original)
+++ branches/release/libs/interprocess/test/managed_xsi_shared_memory_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/map_index_allocation_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/map_index_allocation_test.cpp (original)
+++ branches/release/libs/interprocess/test/map_index_allocation_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/map_test.hpp
==============================================================================
--- branches/release/libs/interprocess/test/map_test.hpp (original)
+++ branches/release/libs/interprocess/test/map_test.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 ////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -67,7 +67,7 @@
 
       MyStdMultiMap *stdmultimap = new MyStdMultiMap;
 
- //Test construction from a range
+ //Test construction from a range
       {
          //This is really nasty, but we have no other simple choice
          IntPairType aux_vect[50];
@@ -555,7 +555,7 @@
          stdmapcopy = *stdmap;
          shmmmapcopy = *shmmultimap;
          stdmmapcopy = *stdmultimap;
-
+
          if(!CheckEqualContainers(&shmmapcopy, &stdmapcopy))
             return 1;
          if(!CheckEqualContainers(&shmmmapcopy, &stdmmapcopy))

Modified: branches/release/libs/interprocess/test/mapped_file_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/mapped_file_test.cpp (original)
+++ branches/release/libs/interprocess/test/mapped_file_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -37,7 +37,7 @@
    ~file_destroyer()
    {
       //The last destructor will destroy the file
- file_mapping::remove(get_filename().c_str());
+ file_mapping::remove(get_filename().c_str());
    }
 };
 
@@ -72,7 +72,7 @@
    test::test_named_creation<mapped_file_creation_test_wrapper>();
 
    //Create and get name, size and address
- {
+ {
       mapped_file file1(create_only, get_filename().c_str(), FileSize, read_write, 0, permissions());
 
       //Overwrite all memory

Modified: branches/release/libs/interprocess/test/memory_algorithm_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/memory_algorithm_test.cpp (original)
+++ branches/release/libs/interprocess/test/memory_algorithm_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/memory_algorithm_test_template.hpp
==============================================================================
--- branches/release/libs/interprocess/test/memory_algorithm_test_template.hpp (original)
+++ branches/release/libs/interprocess/test/memory_algorithm_test_template.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -118,7 +118,7 @@
                  std::memset(buffers[i], 0, a.size(buffers[i]));
       }
    }
-
+
    //Deallocate it in non sequential order
    for(int j = 0, max = (int)buffers.size()
       ;j < max
@@ -170,7 +170,7 @@
          preferred_size = min_size*2;
       }
    }
-
+
    //Deallocate it in non sequential order
    for(int j = 0, max = (int)buffers.size()
       ;j < max
@@ -243,7 +243,7 @@
          return false;
       }
    }
-
+
    //Deallocate it in non sequential order
    for(int j = 0, max = (int)buffers.size()
       ;j < max
@@ -310,7 +310,7 @@
          }
       }
    }
-
+
    //Now erase null values from the vector
    buffers.erase( std::remove(buffers.begin(), buffers.end(), static_cast<void*>(0))
                 , buffers.end());
@@ -349,7 +349,7 @@
          std::memset(ptr, 0, size);
          buffers.push_back(ptr);
       }
-
+
       //Now deallocate all except the latest
       //Now try to expand to the double of the sizeof_object
       for(int i = 0, max = (int)buffers.size() - 1
@@ -381,7 +381,7 @@
       }
       //There is only a single block so deallocate it
       a.deallocate(ptr);
-
+
       if(!a.all_memory_deallocated() || !a.check_sanity())
          return false;
    }
@@ -405,7 +405,7 @@
                continue_loop = false;
             break;
          }
-
+
          if(((std::size_t)ptr & (j - 1)) != 0)
             return false;
          a.deallocate(ptr);
@@ -441,7 +441,7 @@
             else{
                any_allocated = true;
             }
-
+
             if(((std::size_t)ptr & (j - 1)) != 0)
                return false;
          }
@@ -679,8 +679,7 @@
 
          typename multiallocation_chain::size_type n = chain.size();
          while(!chain.empty()){
- buffers.push_back(ipcdetail::to_raw_pointer(chain.front()));
- chain.pop_front();
+ buffers.push_back(ipcdetail::to_raw_pointer(chain.pop_front()));
          }
          if(n != std::size_t((i+1)*2))
             return false;
@@ -788,8 +787,7 @@
             break;
          typename multiallocation_chain::size_type n = chain.size();
          while(!chain.empty()){
- buffers.push_back(ipcdetail::to_raw_pointer(chain.front()));
- chain.pop_front();
+ buffers.push_back(ipcdetail::to_raw_pointer(chain.pop_front()));
          }
          if(n != ArraySize)
             return false;

Modified: branches/release/libs/interprocess/test/message_queue_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/message_queue_test.cpp (original)
+++ branches/release/libs/interprocess/test/message_queue_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -48,6 +48,8 @@
       message_queue::size_type recvd = 0;
       unsigned int priority = 0;
       std::size_t tstamp;
+ unsigned int priority_prev;
+ std::size_t tstamp_prev;
 
       //We will send 100 message with priority 0-9
       //The message will contain the timestamp of the message
@@ -56,8 +58,31 @@
          mq1.send(&tstamp, sizeof(tstamp), (unsigned int)(i%10));
       }
 
- unsigned int priority_prev = (std::numeric_limits<unsigned int>::max)();
- std::size_t tstamp_prev = 0;
+ priority_prev = (std::numeric_limits<unsigned int>::max)();
+ tstamp_prev = 0;
+
+ //Receive all messages and test those are ordered
+ //by priority and by FIFO in the same priority
+ for(std::size_t i = 0; i < 100; ++i){
+ mq1.receive(&tstamp, sizeof(tstamp), recvd, priority);
+ if(priority > priority_prev)
+ return false;
+ if(priority == priority_prev &&
+ tstamp <= tstamp_prev){
+ return false;
+ }
+ priority_prev = priority;
+ tstamp_prev = tstamp;
+ }
+
+ //Now retry it with different priority order
+ for(std::size_t i = 0; i < 100; ++i){
+ tstamp = i;
+ mq1.send(&tstamp, sizeof(tstamp), (unsigned int)(9 - i%10));
+ }
+
+ priority_prev = (std::numeric_limits<unsigned int>::max)();
+ tstamp_prev = 0;
 
       //Receive all messages and test those are ordered
       //by priority and by FIFO in the same priority
@@ -83,7 +108,7 @@
 //another buffer and checks it against the original data-base
 bool test_serialize_db()
 {
- //Typedef data to create a Interprocess map
+ //Typedef data to create a Interprocess map
    typedef std::pair<const std::size_t, std::size_t> MyPair;
    typedef std::less<std::size_t> MyLess;
    typedef node_allocator<MyPair, managed_external_buffer::segment_manager>
@@ -157,7 +182,7 @@
             break;
          }
       }
-
+
       //The buffer will contain a copy of the original database
       //so let's interpret the buffer with managed_external_buffer
       managed_external_buffer db_destiny(open_only, &buffer_destiny[0], BufferSize);
@@ -188,7 +213,7 @@
             return false;
          }
       }
-
+
       //Destroy maps from db-s
       db_origin.destroy_ptr(map1);
       db_destiny.destroy_ptr(map2);

Modified: branches/release/libs/interprocess/test/movable_int.hpp
==============================================================================
--- branches/release/libs/interprocess/test/movable_int.hpp (original)
+++ branches/release/libs/interprocess/test/movable_int.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -19,12 +19,21 @@
 namespace interprocess {
 namespace test {
 
+template<class T>
+struct is_copyable;
+
+template<>
+struct is_copyable<int>
+{
+ static const bool value = true;
+};
+
+
 class movable_int
 {
    BOOST_MOVABLE_BUT_NOT_COPYABLE(movable_int)
 
    public:
-
    movable_int()
       : m_int(0)
    {}
@@ -64,6 +73,12 @@
    int get_int() const
    { return m_int; }
 
+ friend bool operator==(const movable_int &l, int r)
+ { return l.get_int() == r; }
+
+ friend bool operator==(int l, const movable_int &r)
+ { return l == r.get_int(); }
+
    private:
    int m_int;
 };
@@ -77,11 +92,18 @@
     return os;
 }
 
+
+template<>
+struct is_copyable<movable_int>
+{
+ static const bool value = false;
+};
+
 class movable_and_copyable_int
 {
    BOOST_COPYABLE_AND_MOVABLE(movable_and_copyable_int)
- public:
 
+ public:
    movable_and_copyable_int()
       : m_int(0)
    {}
@@ -94,13 +116,13 @@
       : m_int(mmi.m_int)
    {}
   
- movable_and_copyable_int &operator= (BOOST_COPY_ASSIGN_REF(movable_and_copyable_int) mi)
- { this->m_int = mi.m_int; return *this; }
-
    movable_and_copyable_int(BOOST_RV_REF(movable_and_copyable_int) mmi)
       : m_int(mmi.m_int)
    { mmi.m_int = 0; }
 
+ movable_and_copyable_int &operator= (BOOST_COPY_ASSIGN_REF(movable_and_copyable_int) mi)
+ { this->m_int = mi.m_int; return *this; }
+
    movable_and_copyable_int & operator= (BOOST_RV_REF(movable_and_copyable_int) mmi)
    { this->m_int = mmi.m_int; mmi.m_int = 0; return *this; }
 
@@ -128,6 +150,12 @@
    int get_int() const
    { return m_int; }
 
+ friend bool operator==(const movable_and_copyable_int &l, int r)
+ { return l.get_int() == r; }
+
+ friend bool operator==(int l, const movable_and_copyable_int &r)
+ { return l == r.get_int(); }
+
    private:
    int m_int;
 };
@@ -141,6 +169,12 @@
     return os;
 }
 
+template<>
+struct is_copyable<movable_and_copyable_int>
+{
+ static const bool value = true;
+};
+
 class copyable_int
 {
    public:
@@ -156,9 +190,6 @@
       : m_int(mmi.m_int)
    {}
   
- copyable_int & operator= (const copyable_int &mi)
- { this->m_int = mi.m_int; return *this; }
-
    copyable_int & operator= (int i)
    { this->m_int = i; return *this; }
 
@@ -183,10 +214,31 @@
    int get_int() const
    { return m_int; }
 
+ friend bool operator==(const copyable_int &l, int r)
+ { return l.get_int() == r; }
+
+ friend bool operator==(int l, const copyable_int &r)
+ { return l == r.get_int(); }
+
    private:
    int m_int;
 };
 
+template<class E, class T>
+std::basic_ostream<E, T> & operator<<
+ (std::basic_ostream<E, T> & os, copyable_int const & p)
+
+{
+ os << p.get_int();
+ return os;
+}
+
+template<>
+struct is_copyable<copyable_int>
+{
+ static const bool value = true;
+};
+
 class non_copymovable_int
 {
    non_copymovable_int(const non_copymovable_int& mmi);
@@ -222,21 +274,16 @@
    int get_int() const
    { return m_int; }
 
+ friend bool operator==(const non_copymovable_int &l, int r)
+ { return l.get_int() == r; }
+
+ friend bool operator==(int l, const non_copymovable_int &r)
+ { return l == r.get_int(); }
+
    private:
    int m_int;
 };
 
-template<class E, class T>
-std::basic_ostream<E, T> & operator<<
- (std::basic_ostream<E, T> & os, copyable_int const & p)
-
-{
- os << p.get_int();
- return os;
-}
-
-
-
 } //namespace test {
 } //namespace interprocess {
 } //namespace boost {

Modified: branches/release/libs/interprocess/test/multi_index_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/multi_index_test.cpp (original)
+++ branches/release/libs/interprocess/test/multi_index_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/mutex_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/mutex_test.cpp (original)
+++ branches/release/libs/interprocess/test/mutex_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/mutex_test_template.hpp
==============================================================================
--- branches/release/libs/interprocess/test/mutex_test_template.hpp (original)
+++ branches/release/libs/interprocess/test/mutex_test_template.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -232,7 +232,7 @@
 void test_mutex_lock()
 {
    shared_val = 0;
-
+
    M mtx;
 
    data<M> d1(1);
@@ -260,7 +260,7 @@
 void test_mutex_lock_timeout()
 {
    shared_val = 0;
-
+
    M mtx;
 
    int wait_time_s = BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS / 1000;

Modified: branches/release/libs/interprocess/test/mutex_timeout_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/mutex_timeout_test.cpp (original)
+++ branches/release/libs/interprocess/test/mutex_timeout_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/named_allocation_test_template.hpp
==============================================================================
--- branches/release/libs/interprocess/test/named_allocation_test_template.hpp (original)
+++ branches/release/libs/interprocess/test/named_allocation_test_template.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/named_condition_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/named_condition_test.cpp (original)
+++ branches/release/libs/interprocess/test/named_condition_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -12,6 +12,7 @@
 #include <boost/interprocess/detail/workaround.hpp>
 #include <boost/interprocess/sync/named_mutex.hpp>
 #include <boost/interprocess/sync/named_condition.hpp>
+#include <boost/interprocess/sync/detail/locks.hpp>
 #include "condition_test_template.hpp"
 #include "named_creation_template.hpp"
 #include <string>
@@ -25,7 +26,7 @@
    std::string name;
 
    ~condition_deleter()
- {
+ {
       if(name.empty())
          named_condition::remove(test::add_to_process_id_name("named_condition"));
       else
@@ -56,76 +57,32 @@
    { --count; }
 
 
- template<class Lock>
- class lock_wrapper
- {
- typedef void (lock_wrapper::*unspecified_bool_type)();
- public:
-
- typedef named_mutex mutex_type;
-
- lock_wrapper(Lock &l)
- : l_(l)
- {}
-
- mutex_type* mutex() const
- { return l_.mutex(); }
-
- void lock() { l_.lock(); }
-
- void unlock() { l_.unlock(); }
-
- operator unspecified_bool_type() const
- { return l_ ? &lock_wrapper::lock : 0; }
-
- private:
- Lock &l_;
- };
-/*
- template<class Lock>
- class lock_wrapper
- {
- public:
-
- typedef named_mutex mutex_type;
-
- lock_wrapper(Lock &l)
- : l_(l)
- {}
-
- mutex_type* mutex() const
- { return l_.mutex(); }
-
- private:
- Lock &l_;
- };
-*/
    template <typename L>
    void wait(L& lock)
    {
- lock_wrapper<L> newlock(lock);
- named_condition::wait(newlock);
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ named_condition::wait(internal_lock);
    }
 
    template <typename L, typename Pr>
    void wait(L& lock, Pr pred)
    {
- lock_wrapper<L> newlock(lock);
- named_condition::wait(newlock, pred);
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ named_condition::wait(internal_lock, pred);
    }
 
    template <typename L>
    bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time)
    {
- lock_wrapper<L> newlock(lock);
- return named_condition::timed_wait(newlock, abs_time);
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ return named_condition::timed_wait(internal_lock, abs_time);
    }
 
    template <typename L, typename Pr>
    bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
    {
- lock_wrapper<L> newlock(lock);
- return named_condition::timed_wait(newlock, abs_time, pred);
+ ipcdetail::internal_mutex_lock<L> internal_lock(lock);
+ return named_condition::timed_wait(internal_lock, abs_time, pred);
    }
 
    static int count;
@@ -167,7 +124,7 @@
    std::string name;
 
    ~mutex_deleter()
- {
+ {
       if(name.empty())
          named_mutex::remove(test::add_to_process_id_name("named_mutex"));
       else
@@ -190,6 +147,11 @@
       ++count;
    }
 
+ typedef named_mutex internal_mutex_type;
+
+ internal_mutex_type &internal_mutex()
+ { return *this; }
+
    ~named_mutex_test_wrapper()
    { --count; }
 

Modified: branches/release/libs/interprocess/test/named_construct_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/named_construct_test.cpp (original)
+++ branches/release/libs/interprocess/test/named_construct_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/named_creation_template.hpp
==============================================================================
--- branches/release/libs/interprocess/test/named_creation_template.hpp (original)
+++ branches/release/libs/interprocess/test/named_creation_template.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -23,7 +23,7 @@
 
 template <class NamedResource>
 inline void create_then_open_then_open_or_create()
-{
+{
    try{
       //Create it and open it twice
       NamedResource nresource1(create_only);
@@ -38,7 +38,7 @@
 
 template <class NamedResource>
 inline void open_or_create_then_create()
-{
+{
    //Create it with open_or_create and try to create it twice
    NamedResource nresource1(open_or_create);
    try{
@@ -51,7 +51,7 @@
 
 template <class NamedResource>
 inline void dont_create_and_open()
-{
+{
    //Try to open it without creating
    try{
       NamedResource nresource1(open_only);

Modified: branches/release/libs/interprocess/test/named_mutex_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/named_mutex_test.cpp (original)
+++ branches/release/libs/interprocess/test/named_mutex_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/named_recursive_mutex_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/named_recursive_mutex_test.cpp (original)
+++ branches/release/libs/interprocess/test/named_recursive_mutex_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/named_semaphore_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/named_semaphore_test.cpp (original)
+++ branches/release/libs/interprocess/test/named_semaphore_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/named_upgradable_mutex_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/named_upgradable_mutex_test.cpp (original)
+++ branches/release/libs/interprocess/test/named_upgradable_mutex_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/node_allocator_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/node_allocator_test.cpp (original)
+++ branches/release/libs/interprocess/test/node_allocator_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/node_pool_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/node_pool_test.cpp (original)
+++ branches/release/libs/interprocess/test/node_pool_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2007-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/node_pool_test.hpp
==============================================================================
--- branches/release/libs/interprocess/test/node_pool_test.hpp (original)
+++ branches/release/libs/interprocess/test/node_pool_test.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2007-2012. 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)
 //
@@ -49,7 +49,7 @@
    if((pool.get_real_num_node() - 1) != pool.num_free_nodes()){
       return false;
    }
-
+
    //Now deallocate all and check again
    for(std::size_t i = 0; i < num_alloc; ++i){
        pool.deallocate_node(nodes[i]);
@@ -59,7 +59,7 @@
    if(4*pool.get_real_num_node() != pool.num_free_nodes()){
       return false;
    }
-
+
    pool.deallocate_free_blocks();
 
    if(0 != pool.num_free_nodes()){
@@ -92,7 +92,7 @@
    if(0 != pool.num_free_nodes()){
       return false;
    }
-
+
    //Now deallocate one of each block per iteration
    for(std::size_t node_i = 0; node_i < nodes_per_block; ++node_i){
       //Deallocate a node per block
@@ -104,7 +104,7 @@
       if(max_blocks*(node_i+1) != pool.num_free_nodes()){
          return false;
       }
-
+
       //Now try to deallocate free blocks
       pool.deallocate_free_blocks();
 

Modified: branches/release/libs/interprocess/test/null_index_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/null_index_test.cpp (original)
+++ branches/release/libs/interprocess/test/null_index_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/offset_ptr_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/offset_ptr_test.cpp (original)
+++ branches/release/libs/interprocess/test/offset_ptr_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2007-2012. 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)
 //
@@ -60,7 +60,7 @@
    pcint_t pcint(0);
    pvint_t pvint(0);
    pcvint_t pcvint(0);
-
+
    pint = &dummy_int;
    pcint = &dummy_int;
    pvint = &dummy_int;
@@ -153,7 +153,7 @@
    typedef offset_ptr<int> pint_t;
    const int NumValues = 5;
    int values[NumValues];
-
+
    //Initialize p
    pint_t p = values;
    if(p.get() != values)

Modified: branches/release/libs/interprocess/test/print_container.hpp
==============================================================================
--- branches/release/libs/interprocess/test/print_container.hpp (original)
+++ branches/release/libs/interprocess/test/print_container.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -49,7 +49,7 @@
       std::cout << *itshm << std::endl;
    }
    std::cout << "MyStdCont" << std::endl;
-
+
    for(; itstd != itstdend; ++itstd){
       std::cout << *itstd << std::endl;
    }

Modified: branches/release/libs/interprocess/test/private_adaptive_pool_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/private_adaptive_pool_test.cpp (original)
+++ branches/release/libs/interprocess/test/private_adaptive_pool_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/private_node_allocator_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/private_node_allocator_test.cpp (original)
+++ branches/release/libs/interprocess/test/private_node_allocator_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/recursive_mutex_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/recursive_mutex_test.cpp (original)
+++ branches/release/libs/interprocess/test/recursive_mutex_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/robust_emulation_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/robust_emulation_test.cpp (original)
+++ branches/release/libs/interprocess/test/robust_emulation_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2010-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2010-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/robust_mutex_test.hpp
==============================================================================
--- branches/release/libs/interprocess/test/robust_mutex_test.hpp (original)
+++ branches/release/libs/interprocess/test/robust_mutex_test.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2010-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2010-2012. 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)
 //
@@ -69,7 +69,7 @@
       while(!*go_ahead){
          ipcdetail::thread_yield();
       }
-
+
       std::cout << "... recovering mutex[0]" << std::endl;
       //First try to recover lock[0], put into consistent
       //state and relock it again

Modified: branches/release/libs/interprocess/test/robust_recursive_emulation_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/robust_recursive_emulation_test.cpp (original)
+++ branches/release/libs/interprocess/test/robust_recursive_emulation_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2010-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2010-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/semaphore_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/semaphore_test.cpp (original)
+++ branches/release/libs/interprocess/test/semaphore_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/set_test.hpp
==============================================================================
--- branches/release/libs/interprocess/test/set_test.hpp (original)
+++ branches/release/libs/interprocess/test/set_test.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 ////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -58,7 +58,7 @@
 
       MyStdMultiSet *stdmultiset = new MyStdMultiSet;
 
- //Test construction from a range
+ //Test construction from a range
       {
          IntType aux_vect[50];
          for(int i = 0; i < 50; ++i){
@@ -567,7 +567,7 @@
 
          shmmsetcopy = *shmmultiset;
          stdmsetcopy = *stdmultiset;
-
+
          if(!CheckEqualContainers(&shmmsetcopy, &stdmsetcopy))
             return 1;
       }

Modified: branches/release/libs/interprocess/test/sharable_mutex_test_template.hpp
==============================================================================
--- branches/release/libs/interprocess/test/sharable_mutex_test_template.hpp (original)
+++ branches/release/libs/interprocess/test/sharable_mutex_test_template.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -10,7 +10,7 @@
 // It is provided "as is" without express or implied warranty.
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/shared_memory_mapping_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/shared_memory_mapping_test.cpp (original)
+++ branches/release/libs/interprocess/test/shared_memory_mapping_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -31,7 +31,7 @@
    std::string process_id2(process_id);
    process_id2 += "_2";
    try{
- const std::size_t FileSize = 99999*2;
+ const std::size_t FileSize = 99999*4;
       {
          //Remove shared memory
          shared_memory_object::remove(process_id.c_str());
@@ -59,7 +59,7 @@
                               ,FileSize - FileSize/2
                               ,0);
 
- //Fill two regions with a pattern
+ //Fill two regions with a pattern
          unsigned char *filler = static_cast<unsigned char*>(region.get_address());
          for(std::size_t i = 0
             ;i < FileSize/2
@@ -129,6 +129,52 @@
                return 1;
             }
          }
+ //Now shrink
+ const std::size_t original_region_size = region.get_size();
+ if(!region.shrink_by(region.get_size()/2, false) || region.get_size() != original_region_size/2){
+ return 1;
+ }
+ const std::size_t shrunk_region_size = region.get_size();
+ if(!region.shrink_by(region.get_size()/2, true) || region.get_size() != shrunk_region_size/2){
+ return 1;
+ }
+
+ //Now advise
+ #if defined(POSIX_MADV_NORMAL) || defined(MADV_NORMAL)
+ std::cout << "Advice normal" << std::endl;
+ if(!region.advise(mapped_region::advice_normal)){
+ return 1;
+ }
+ #endif
+
+ #if defined(POSIX_MADV_SEQUENTIAL) || defined(MADV_SEQUENTIAL)
+ std::cout << "Advice sequential" << std::endl;
+ if(!region.advise(mapped_region::advice_sequential)){
+ return 1;
+ }
+ #endif
+
+ #if defined(POSIX_MADV_RANDOM) || defined(MADV_RANDOM)
+ std::cout << "Advice random" << std::endl;
+ if(!region.advise(mapped_region::advice_random)){
+ return 1;
+ }
+ #endif
+
+ #if defined(POSIX_MADV_WILLNEED) || defined(MADV_WILLNEED)
+ std::cout << "Advice 'will need'" << std::endl;
+ if(!region.advise(mapped_region::advice_willneed)){
+ return 1;
+ }
+ #endif
+
+ #if defined(POSIX_MADV_DONTNEED) || (defined(MADV_DONTNEED) && defined(BOOST_INTERPROCESS_MADV_DONTNEED_HAS_NONDESTRUCTIVE_SEMANTICS))
+ std::cout << "Advice 'dont't need'" << std::endl;
+ if(!region.advise(mapped_region::advice_dontneed)){
+ return 1;
+ }
+ #endif
+
       }
       {
          //Check for busy address space

Modified: branches/release/libs/interprocess/test/shared_memory_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/shared_memory_test.cpp (original)
+++ branches/release/libs/interprocess/test/shared_memory_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -62,7 +62,7 @@
       test::test_named_creation<shared_memory_creation_test_wrapper>();
 
       //Create and get name, size and address
- {
+ {
          shared_memory_object::remove(ShmName);
          shared_memory shm1(create_only, ShmName, ShmSize, read_write, 0, permissions());
 

Modified: branches/release/libs/interprocess/test/shared_ptr_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/shared_ptr_test.cpp (original)
+++ branches/release/libs/interprocess/test/shared_ptr_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,7 +1,7 @@
 //////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Peter Dimov 2002-2005, 2007.
-// (C) Copyright Ion Gaztanaga 2006-2011.
+// (C) Copyright Ion Gaztanaga 2006-2012.
 // 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)
@@ -144,7 +144,7 @@
    {
       managed_shared_memory shmem(create_only, process_name.c_str(), 20000);
 
- {
+ {
          const int NumElements = 100;
          //Construct the allocator of strings
          string_allocator_t string_allocator(shmem.get_segment_manager());
@@ -202,7 +202,7 @@
          }
          //Now fill a vector of weak_ptr-s
          string_weak_ptr_vector_t my_weakptr_vector(string_weak_ptr_allocator);
- my_weakptr_vector.insert(my_weakptr_vector.begin(), NumElements, string_weak_ptr);
+ my_weakptr_vector.insert(my_weakptr_vector.begin(), NumElements, string_weak_ptr);
          //The shared count should remain the same
          if(string_shared_ptr.use_count() != static_cast<long>(my_sharedptr_vector.size()+1)){
             return 1;

Modified: branches/release/libs/interprocess/test/slist_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/slist_test.cpp (original)
+++ branches/release/libs/interprocess/test/slist_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/stable_vector_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/stable_vector_test.cpp (original)
+++ branches/release/libs/interprocess/test/stable_vector_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/string_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/string_test.cpp (original)
+++ branches/release/libs/interprocess/test/string_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -82,7 +82,7 @@
             (create_only,
             process_name.c_str(),//segment name
             65536); //segment size in bytes
-
+
       ShmemAllocatorChar shmallocator (segment.get_segment_manager());
 
       //Initialize vector with a range or iterators and allocator
@@ -166,16 +166,16 @@
       shm_swapper.swap(auxShmString);
       std_swapper.swap(auxStdString);
       if(!StringEqual()(auxShmString, auxStdString))
- return 1;
+ return 1;
       if(!StringEqual()(shm_swapper, std_swapper))
- return 1;
+ return 1;
 
       shm_swapper.swap(auxShmString);
       std_swapper.swap(auxStdString);
       if(!StringEqual()(auxShmString, auxStdString))
- return 1;
+ return 1;
       if(!StringEqual()(shm_swapper, std_swapper))
- return 1;
+ return 1;
 
       auxShmString = "LongLongLongLongLongLongLongLongLongLongLongLongLongString";
       auxStdString = "LongLongLongLongLongLongLongLongLongLongLongLongLongString";
@@ -184,16 +184,16 @@
       shm_swapper.swap(auxShmString);
       std_swapper.swap(auxStdString);
       if(!StringEqual()(auxShmString, auxStdString))
- return 1;
+ return 1;
       if(!StringEqual()(shm_swapper, std_swapper))
- return 1;
+ return 1;
 
       shm_swapper.swap(auxShmString);
       std_swapper.swap(auxStdString);
       if(!StringEqual()(auxShmString, auxStdString))
- return 1;
+ return 1;
       if(!StringEqual()(shm_swapper, std_swapper))
- return 1;
+ return 1;
 
       //No sort
       std::sort(shmStringVect->begin(), shmStringVect->end());

Modified: branches/release/libs/interprocess/test/tree_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/tree_test.cpp (original)
+++ branches/release/libs/interprocess/test/tree_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -42,19 +42,19 @@
 
 //We will work with narrow characters for shared memory objects
 //Alias an integer node allocator type
-typedef allocator<int, my_managed_shared_memory::segment_manager>
+typedef allocator<int, my_managed_shared_memory::segment_manager>
    shmem_allocator_t;
-typedef allocator<std::pair<const int, int>, my_managed_shared_memory::segment_manager>
+typedef allocator<std::pair<const int, int>, my_managed_shared_memory::segment_manager>
    shmem_node_pair_allocator_t;
-typedef allocator<test::movable_int, my_managed_shared_memory::segment_manager>
+typedef allocator<test::movable_int, my_managed_shared_memory::segment_manager>
    shmem_movable_allocator_t;
-typedef allocator<std::pair<const test::movable_int, test::movable_int>, my_managed_shared_memory::segment_manager>
+typedef allocator<std::pair<const test::movable_int, test::movable_int>, my_managed_shared_memory::segment_manager>
    shmem_movable_node_pair_allocator_t;
-typedef allocator<test::movable_and_copyable_int, my_managed_shared_memory::segment_manager>
+typedef allocator<test::movable_and_copyable_int, my_managed_shared_memory::segment_manager>
    shmem_move_copy_allocator_t;
-typedef allocator<test::copyable_int, my_managed_shared_memory::segment_manager>
+typedef allocator<test::copyable_int, my_managed_shared_memory::segment_manager>
    shmem_copy_allocator_t;
-typedef allocator<std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int>, my_managed_shared_memory::segment_manager>
+typedef allocator<std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int>, my_managed_shared_memory::segment_manager>
    shmem_move_copy_node_pair_allocator_t;
 
 //Alias standard types

Modified: branches/release/libs/interprocess/test/unique_ptr_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/unique_ptr_test.cpp (original)
+++ branches/release/libs/interprocess/test/unique_ptr_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -56,7 +56,7 @@
    shared_memory_object::remove(process_name.c_str());
    {
       managed_shared_memory segment(create_only, process_name.c_str(), 10000);
-
+
       //Create unique_ptr using dynamic allocation
       my_unique_ptr_class my_ptr (segment.construct<MyClass>(anonymous_instance)()
                                  ,segment.get_deleter<MyClass>());
@@ -83,7 +83,7 @@
       assert(my_ptr2.get() == 0);
       assert(list.begin()->get() == ptr1);
       assert(list.rbegin()->get() == ptr2);
-
+
       //Construct a set and fill
       typedef std::less<my_unique_ptr_class> set_less_t;
       MySet set(set_less_t(), segment.get_segment_manager());

Modified: branches/release/libs/interprocess/test/unordered_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/unordered_test.cpp (original)
+++ branches/release/libs/interprocess/test/unordered_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2007-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/upgradable_mutex_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/upgradable_mutex_test.cpp (original)
+++ branches/release/libs/interprocess/test/upgradable_mutex_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/user_buffer_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/user_buffer_test.cpp (original)
+++ branches/release/libs/interprocess/test/user_buffer_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -201,7 +201,7 @@
    heaplist->merge(otherheaplist, std::greater<int>());
    stdlist->merge(otherstdlist, std::greater<int>());
    if(!CheckEqual(userlist, stdlist, heaplist)) return 1;
-
+
    user_buffer.destroy<MyUserList>(L"MyUserList");
    delete stdlist;
 
@@ -212,7 +212,7 @@
       }
    }
    catch(boost::interprocess::bad_alloc &){}
-
+
    MyHeapList::size_type heap_list_size = heaplist->size();
 
    //Copy heap buffer to another
@@ -246,7 +246,7 @@
    }
    catch(boost::interprocess::bad_alloc &){}
 
- MyUserList::size_type user_list_size = userlist->size();
+ MyUserList::size_type user_list_size = userlist->size();
 
    if(user_list_size <= heap_list_size){
       return 1;

Modified: branches/release/libs/interprocess/test/util.hpp
==============================================================================
--- branches/release/libs/interprocess/test/util.hpp (original)
+++ branches/release/libs/interprocess/test/util.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/vector_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/vector_test.cpp (original)
+++ branches/release/libs/interprocess/test/vector_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/vector_test.hpp
==============================================================================
--- branches/release/libs/interprocess/test/vector_test.hpp (original)
+++ branches/release/libs/interprocess/test/vector_test.hpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -102,15 +102,15 @@
 
          shmvector->resize(100);
          stdvector->resize(100);
- if(!test::CheckEqualContainers(shmvector, stdvector)) return 1;
+ if(!test::CheckEqualContainers(shmvector, stdvector)) return 1;
 
          shmvector->resize(200);
          stdvector->resize(200);
- if(!test::CheckEqualContainers(shmvector, stdvector)) return 1;
+ if(!test::CheckEqualContainers(shmvector, stdvector)) return 1;
 
          shmvector->resize(0);
          stdvector->resize(0);
- if(!test::CheckEqualContainers(shmvector, stdvector)) return 1;
+ if(!test::CheckEqualContainers(shmvector, stdvector)) return 1;
 
          for(int i = 0; i < max; ++i){
             IntType new_int(i);

Modified: branches/release/libs/interprocess/test/vectorstream_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/vectorstream_test.cpp (original)
+++ branches/release/libs/interprocess/test/vectorstream_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2006-2012. 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)
 //
@@ -37,7 +37,7 @@
 
 static int vectorstream_test()
 {
- { //Test high watermarking initialization
+ { //Test high watermarking initialization
       my_stringstream_t my_stringstream;
       int a (0);
       my_stringstream << 11;
@@ -45,7 +45,7 @@
       if(a != 11)
          return 1;
    }
- { //Test high watermarking initialization
+ { //Test high watermarking initialization
       my_vectorstream_t my_stringstream;
       int a (0);
       my_stringstream << 13;
@@ -66,7 +66,7 @@
          my_stringstream << "testline: " << i << std::endl;
          std_stringstream << "testline: " << i << std::endl;
       }
-
+
       if(std::strcmp(my_stringstream.vector().c_str(), std_stringstream.str().c_str()) != 0){
          return 1;
       }
@@ -75,10 +75,10 @@
          my_stringstream >> str1 >> number1;
          std_stringstream >> str2 >> number2;
          if((str1 != str2) || (str1 != str3)){
- assert(0); return 1;
+ assert(0); return 1;
          }
          if((number1 != number2) || (number1 != i)){
- assert(0); return 1;
+ assert(0); return 1;
          }
       }
    }
@@ -105,10 +105,10 @@
          my_vectorstream >> str1 >> number1;
          std_stringstream >> str2 >> number2;
          if((str1 != str2) || (str1 != str3)){
- assert(0); return 1;
+ assert(0); return 1;
          }
          if((number1 != number2) || (number1 != i)){
- assert(0); return 1;
+ assert(0); return 1;
          }
       }
    }
@@ -131,10 +131,10 @@
          my_stringstream >> str1 >> number1;
          std_stringstream >> str2 >> number2;
          if((str1 != str2) || (str1 != str3)){
- assert(0); return 1;
+ assert(0); return 1;
          }
          if((number1 != number2) || (number1 != i)){
- assert(0); return 1;
+ assert(0); return 1;
          }
       }
    }

Modified: branches/release/libs/interprocess/test/windows_shared_memory_mapping_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/windows_shared_memory_mapping_test.cpp (original)
+++ branches/release/libs/interprocess/test/windows_shared_memory_mapping_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -48,7 +48,7 @@
                                  ,FileSize - FileSize/2
                                  ,0);
 
- //Fill two regions with a pattern
+ //Fill two regions with a pattern
             unsigned char *filler = static_cast<unsigned char*>(region.get_address());
             for(std::size_t i = 0
                ;i < FileSize/2

Modified: branches/release/libs/interprocess/test/windows_shared_memory_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/windows_shared_memory_test.cpp (original)
+++ branches/release/libs/interprocess/test/windows_shared_memory_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //

Modified: branches/release/libs/interprocess/test/xsi_shared_memory_mapping_test.cpp
==============================================================================
--- branches/release/libs/interprocess/test/xsi_shared_memory_mapping_test.cpp (original)
+++ branches/release/libs/interprocess/test/xsi_shared_memory_mapping_test.cpp 2012-09-24 08:17:34 EDT (Mon, 24 Sep 2012)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2004-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2004-2012. 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)
 //
@@ -93,7 +93,7 @@
                //Create a mapped region
                mapped_region region (mapping, read_write, 0, FileSize, 0);
 
- //Fill two regions with a pattern
+ //Fill two regions with a pattern
                unsigned char *filler = static_cast<unsigned char*>(region.get_address());
                for(std::size_t i = 0; i < FileSize; ++i){
                   *filler++ = static_cast<unsigned char>(i);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk