From b7429a09aa5b51b40bbeb75245ddc6a2c817b961 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 16 Aug 2015 20:42:15 -0300 Subject: [PATCH 1/2] Add script to copy required files using the bcp tool --- build.cmd | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 build.cmd diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000..747a3aa --- /dev/null +++ b/build.cmd @@ -0,0 +1,9 @@ +bcp ^ + boost/container/flat_map.hpp ^ + boost/container/flat_set.hpp ^ + boost/container/static_vector.hpp ^ + boost/crc.hpp ^ + boost/range/algorithm/ ^ + boost/range/algorithm_ext/ ^ + boost/smart_ptr/intrusive_ptr.hpp ^ + --boost="%BOOST_PATH%" . From d05c3b4c4bf1b90c260a1487ef4e5c60d291d9a1 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 16 Aug 2015 20:45:50 -0300 Subject: [PATCH 2/2] Upgrade to boost v1.59.0 --- Readme.md | 20 +- boost/align.hpp | 20 - boost/aligned_storage.hpp | 143 - boost/any.hpp | 324 -- boost/array.hpp | 446 --- boost/asio.hpp | 121 - boost/assign.hpp | 24 - boost/atomic.hpp | 18 - boost/bimap.hpp | 19 - boost/bind.hpp | 24 - boost/blank.hpp | 106 - boost/blank_fwd.hpp | 22 - boost/call_traits.hpp | 20 - boost/cast.hpp | 20 - boost/cerrno.hpp | 331 -- boost/chrono.hpp | 20 - boost/circular_buffer.hpp | 65 - boost/circular_buffer_fwd.hpp | 43 - boost/compressed_pair.hpp | 20 - boost/concept/detail/concept_undef.hpp | 0 boost/concept/detail/general.hpp | 11 +- boost/concept/requires.hpp | 93 - boost/concept_archetype.hpp | 669 ---- boost/concept_check.hpp | 6 +- boost/config/compiler/clang.hpp | 19 +- boost/config/compiler/intel.hpp | 73 +- boost/config/compiler/sunpro_cc.hpp | 45 +- boost/config/compiler/visualc.hpp | 67 +- boost/config/compiler/xlcpp.hpp | 258 ++ boost/config/platform/haiku.hpp | 31 + boost/config/platform/solaris.hpp | 5 +- boost/config/select_compiler_config.hpp | 10 +- boost/config/select_platform_config.hpp | 4 + boost/config/stdlib/dinkumware.hpp | 21 +- boost/config/stdlib/libcomo.hpp | 12 +- boost/config/stdlib/libcpp.hpp | 10 + boost/config/stdlib/libstdcpp3.hpp | 44 +- boost/config/stdlib/modena.hpp | 10 + boost/config/stdlib/msl.hpp | 19 +- boost/config/stdlib/roguewave.hpp | 9 + boost/config/stdlib/sgi.hpp | 13 +- boost/config/stdlib/stlport.hpp | 18 +- boost/config/stdlib/vacpp.hpp | 13 +- boost/container/adaptive_pool.hpp | 349 -- boost/container/allocator.hpp | 367 -- boost/container/allocator_traits.hpp | 445 ++- boost/container/container_fwd.hpp | 45 +- boost/container/deque.hpp | 2069 ----------- boost/container/detail/adaptive_node_pool.hpp | 162 - .../detail/adaptive_node_pool_impl.hpp | 875 ----- .../container/detail/advanced_insert_int.hpp | 372 +- boost/container/detail/algorithm.hpp | 35 + boost/container/detail/algorithms.hpp | 62 - boost/container/detail/alloc_helpers.hpp | 60 + boost/container/detail/alloc_lib.h | 326 -- .../container/detail/alloc_lib_auto_link.hpp | 20 - boost/container/detail/allocation_type.hpp | 8 +- .../detail/allocator_version_traits.hpp | 168 - boost/container/detail/auto_link.hpp | 38 - boost/container/detail/config_begin.hpp | 22 +- .../{utilities.hpp => copy_move_algo.hpp} | 659 ++-- boost/container/detail/destroyers.hpp | 86 +- boost/container/detail/flat_tree.hpp | 313 +- boost/container/detail/function_detector.hpp | 92 - boost/container/detail/hash_table.hpp | 383 -- boost/container/detail/iterator.hpp | 40 + .../detail/iterator_to_raw_pointer.hpp | 58 + boost/container/detail/iterators.hpp | 147 +- boost/container/detail/math_functions.hpp | 119 - boost/container/detail/memory_util.hpp | 90 - boost/container/detail/min_max.hpp | 37 + boost/container/detail/mpl.hpp | 168 +- .../detail/multiallocation_chain.hpp | 292 -- boost/container/detail/mutex.hpp | 284 -- boost/container/detail/next_capacity.hpp | 75 + boost/container/detail/node_alloc_holder.hpp | 399 -- boost/container/detail/node_pool.hpp | 156 - boost/container/detail/node_pool_impl.hpp | 366 -- boost/container/detail/pair.hpp | 131 +- boost/container/detail/placement_new.hpp | 11 +- boost/container/detail/pool_common.hpp | 53 - boost/container/detail/pool_common_alloc.hpp | 98 - boost/container/detail/preprocessor.hpp | 228 -- boost/container/detail/singleton.hpp | 117 - boost/container/detail/std_fwd.hpp | 23 +- boost/container/detail/to_raw_pointer.hpp | 33 + boost/container/detail/transform_iterator.hpp | 177 - boost/container/detail/tree.hpp | 1182 ------ boost/container/detail/type_traits.hpp | 251 +- boost/container/detail/value_init.hpp | 6 +- .../detail/variadic_templates_tools.hpp | 6 +- boost/container/detail/version_type.hpp | 13 +- boost/container/detail/workaround.hpp | 18 +- boost/container/flat_map.hpp | 399 +- boost/container/flat_set.hpp | 351 +- boost/container/list.hpp | 1462 -------- boost/container/map.hpp | 1406 ------- boost/container/new_allocator.hpp | 175 + boost/container/node_allocator.hpp | 344 -- boost/container/options.hpp | 76 - boost/container/scoped_allocator.hpp | 1534 -------- boost/container/scoped_allocator_fwd.hpp | 87 - boost/container/set.hpp | 1126 ------ boost/container/slist.hpp | 1730 --------- boost/container/stable_vector.hpp | 1949 ---------- boost/container/static_vector.hpp | 170 +- boost/container/string.hpp | 2918 --------------- boost/container/throw_exception.hpp | 6 +- boost/container/vector.hpp | 1650 ++++---- boost/core/addressof.hpp | 2 +- boost/core/demangle.hpp | 121 - boost/core/explicit_operator_bool.hpp | 154 - boost/core/ignore_unused.hpp | 70 - boost/core/is_same.hpp | 40 - boost/core/lightweight_test.hpp | 171 - boost/core/lightweight_test_trait.hpp | 56 - boost/core/null_deleter.hpp | 44 - boost/core/scoped_enum.hpp | 192 - boost/core/swap.hpp | 60 - boost/core/typeinfo.hpp | 151 - boost/core/underlying_type.hpp | 79 - boost/cregex.hpp | 39 - boost/cstdfloat.hpp | 58 - boost/cstdint.hpp | 9 +- boost/cstdlib.hpp | 41 - boost/date_time.hpp | 17 - boost/detail/algorithm.hpp | 82 - boost/detail/allocator_utilities.hpp | 187 - boost/detail/atomic_count.hpp | 21 - boost/detail/atomic_redef_macros.hpp | 19 - boost/detail/atomic_undef_macros.hpp | 39 - boost/detail/basic_pointerbuf.hpp | 139 - boost/detail/binary_search.hpp | 216 -- boost/detail/bitmask.hpp | 47 - boost/detail/call_traits.hpp | 172 - boost/detail/catch_exceptions.hpp | 142 - boost/detail/compressed_pair.hpp | 443 --- boost/detail/container_fwd.hpp | 157 - boost/detail/dynamic_bitset.hpp | 241 -- boost/detail/endian.hpp | 11 - boost/detail/fenv.hpp | 101 - boost/detail/has_default_constructor.hpp | 29 - boost/detail/identifier.hpp | 87 - boost/detail/indirect_traits.hpp | 1 - boost/detail/interlocked.hpp | 218 -- boost/detail/is_incrementable.hpp | 133 - boost/detail/is_xxx.hpp | 27 - boost/detail/lcast_precision.hpp | 184 - boost/detail/lightweight_main.hpp | 36 - boost/detail/lightweight_mutex.hpp | 22 - boost/detail/lightweight_test.hpp | 17 - boost/detail/lightweight_thread.hpp | 135 - boost/detail/named_template_params.hpp | 177 - boost/detail/no_exceptions_support.hpp | 17 - boost/detail/numeric_traits.hpp | 182 - boost/detail/ob_compressed_pair.hpp | 499 --- boost/detail/quick_allocator.hpp | 23 - boost/detail/reference_content.hpp | 120 - boost/detail/scoped_enum_emulation.hpp | 17 - boost/detail/select_type.hpp | 36 - boost/detail/sp_typeinfo.hpp | 36 - boost/detail/templated_streams.hpp | 74 - boost/detail/utf8_codecvt_facet.hpp | 191 - boost/detail/utf8_codecvt_facet.ipp | 284 -- boost/detail/winapi/GetCurrentProcess.hpp | 29 - boost/detail/winapi/GetCurrentThread.hpp | 38 - boost/detail/winapi/GetLastError.hpp | 31 - boost/detail/winapi/GetProcessTimes.hpp | 39 - boost/detail/winapi/GetThreadTimes.hpp | 37 - boost/detail/winapi/LocalFree.hpp | 33 - boost/detail/winapi/basic_types.hpp | 134 - boost/detail/winapi/config.hpp | 53 - boost/detail/winapi/crypt.hpp | 88 - boost/detail/winapi/directory_management.hpp | 46 - boost/detail/winapi/dll.hpp | 86 - boost/detail/winapi/error_handling.hpp | 93 - boost/detail/winapi/file_management.hpp | 130 - boost/detail/winapi/handles.hpp | 46 - boost/detail/winapi/memory.hpp | 60 - boost/detail/winapi/process.hpp | 36 - boost/detail/winapi/security.hpp | 65 - boost/detail/winapi/synchronization.hpp | 293 -- boost/detail/winapi/system.hpp | 62 - boost/detail/winapi/thread.hpp | 49 - boost/detail/winapi/thread_pool.hpp | 96 - boost/detail/winapi/time.hpp | 105 - boost/detail/winapi/timers.hpp | 44 - boost/detail/winapi/tls.hpp | 49 - boost/detail/winapi/waitable_timer.hpp | 110 - boost/dynamic_bitset.hpp | 17 - boost/dynamic_bitset_fwd.hpp | 25 - boost/enable_shared_from_this.hpp | 18 - boost/exception_ptr.hpp | 11 - boost/filesystem.hpp | 20 - boost/flyweight.hpp | 22 - boost/foreach.hpp | 1121 ------ boost/foreach_fwd.hpp | 51 - boost/format.hpp | 59 - boost/function.hpp | 66 - boost/function_equal.hpp | 28 - boost/function_output_iterator.hpp | 62 - boost/functional.hpp | 548 --- boost/generator_iterator.hpp | 85 - boost/geometry.hpp | 19 - boost/get_pointer.hpp | 48 - boost/implicit_cast.hpp | 36 - boost/indirect_reference.hpp | 43 - boost/integer.hpp | 49 +- boost/integer_fwd.hpp | 23 + boost/intrusive/any_hook.hpp | 336 -- boost/intrusive/avl_set.hpp | 950 ----- boost/intrusive/avl_set_hook.hpp | 291 -- boost/intrusive/avltree.hpp | 549 --- boost/intrusive/avltree_algorithms.hpp | 687 ---- boost/intrusive/bs_set.hpp | 948 ----- boost/intrusive/bs_set_hook.hpp | 286 -- boost/intrusive/bstree.hpp | 2177 ----------- boost/intrusive/bstree_algorithms.hpp | 2127 ----------- boost/intrusive/circular_list_algorithms.hpp | 507 --- boost/intrusive/circular_slist_algorithms.hpp | 407 -- boost/intrusive/derivation_value_traits.hpp | 77 - boost/intrusive/detail/algo_type.hpp | 46 - boost/intrusive/detail/algorithm.hpp | 90 + .../detail/any_node_and_algorithms.hpp | 280 -- boost/intrusive/detail/array_initializer.hpp | 90 - boost/intrusive/detail/assert.hpp | 41 - boost/intrusive/detail/avltree_node.hpp | 188 - .../detail/common_slist_algorithms.hpp | 194 - .../detail/default_header_holder.hpp | 65 - boost/intrusive/detail/ebo_functor_holder.hpp | 226 -- boost/intrusive/detail/empty_node_checker.hpp | 40 - boost/intrusive/detail/equal_to_value.hpp | 44 - boost/intrusive/detail/exception_disposer.hpp | 84 - boost/intrusive/detail/function_detector.hpp | 88 - boost/intrusive/detail/generic_hook.hpp | 217 -- boost/intrusive/detail/get_value_traits.hpp | 218 -- .../has_member_function_callable_with.hpp | 585 ++- boost/intrusive/detail/hashtable_node.hpp | 287 -- boost/intrusive/detail/hook_traits.hpp | 182 - boost/intrusive/detail/iiterator.hpp | 227 -- .../detail/is_stateful_value_traits.hpp | 77 - boost/intrusive/detail/iterator.hpp | 155 + boost/intrusive/detail/key_nodeptr_comp.hpp | 72 - boost/intrusive/detail/list_iterator.hpp | 129 - boost/intrusive/detail/list_node.hpp | 67 - boost/intrusive/detail/math.hpp | 271 -- boost/intrusive/detail/memory_util.hpp | 92 - .../detail/minimal_less_equal_header.hpp | 30 + .../intrusive/detail/minimal_pair_header.hpp | 30 + boost/intrusive/detail/mpl.hpp | 356 +- .../intrusive/detail/node_cloner_disposer.hpp | 109 - boost/intrusive/detail/node_holder.hpp | 31 - boost/intrusive/detail/node_to_value.hpp | 126 - boost/intrusive/detail/parent_from_member.hpp | 120 - boost/intrusive/detail/pointer_element.hpp | 16 +- boost/intrusive/detail/preprocessor.hpp | 42 - boost/intrusive/detail/rbtree_node.hpp | 200 - boost/intrusive/detail/reverse_iterator.hpp | 53 +- boost/intrusive/detail/simple_disposers.hpp | 46 - boost/intrusive/detail/size_holder.hpp | 80 - boost/intrusive/detail/slist_iterator.hpp | 120 - boost/intrusive/detail/slist_node.hpp | 59 - boost/intrusive/detail/std_fwd.hpp | 19 +- boost/intrusive/detail/to_raw_pointer.hpp | 6 +- boost/intrusive/detail/transform_iterator.hpp | 176 - boost/intrusive/detail/tree_iterator.hpp | 141 - boost/intrusive/detail/tree_node.hpp | 75 - boost/intrusive/detail/uncast.hpp | 51 - boost/intrusive/detail/workaround.hpp | 16 +- boost/intrusive/hashtable.hpp | 3304 ----------------- boost/intrusive/intrusive_fwd.hpp | 729 ---- boost/intrusive/linear_slist_algorithms.hpp | 342 -- boost/intrusive/link_mode.hpp | 63 - boost/intrusive/list.hpp | 1556 -------- boost/intrusive/list_hook.hpp | 286 -- boost/intrusive/member_value_traits.hpp | 84 - boost/intrusive/options.hpp | 248 -- boost/intrusive/pack_options.hpp | 374 -- boost/intrusive/parent_from_member.hpp | 48 - boost/intrusive/pointer_plus_bits.hpp | 94 - boost/intrusive/pointer_rebind.hpp | 18 +- boost/intrusive/pointer_traits.hpp | 93 +- boost/intrusive/priority_compare.hpp | 64 - boost/intrusive/rbtree.hpp | 547 --- boost/intrusive/rbtree_algorithms.hpp | 573 --- boost/intrusive/set.hpp | 950 ----- boost/intrusive/set_hook.hpp | 294 -- boost/intrusive/sg_set.hpp | 974 ----- boost/intrusive/sgtree.hpp | 992 ----- boost/intrusive/sgtree_algorithms.hpp | 378 -- boost/intrusive/slist.hpp | 2276 ------------ boost/intrusive/slist_hook.hpp | 289 -- boost/intrusive/splay_set.hpp | 987 ----- boost/intrusive/splaytree.hpp | 627 ---- boost/intrusive/splaytree_algorithms.hpp | 727 ---- boost/intrusive/treap.hpp | 1193 ------ boost/intrusive/treap_algorithms.hpp | 673 ---- boost/intrusive/treap_set.hpp | 1008 ----- boost/intrusive/trivial_value_traits.hpp | 58 - boost/intrusive/unordered_set.hpp | 2163 ----------- boost/intrusive/unordered_set_hook.hpp | 443 --- boost/intrusive_ptr.hpp | 18 - boost/io_fwd.hpp | 67 - boost/is_placeholder.hpp | 31 - boost/iterator/counting_iterator.hpp | 220 -- .../iterator/detail/any_conversion_eater.hpp | 21 - boost/iterator/detail/minimum_category.hpp | 19 - boost/iterator/filter_iterator.hpp | 137 - boost/iterator/function_input_iterator.hpp | 169 - boost/iterator/indirect_iterator.hpp | 145 - boost/iterator/is_lvalue_iterator.hpp | 157 - boost/iterator/is_readable_iterator.hpp | 114 - boost/iterator/iterator_archetypes.hpp | 509 --- boost/iterator/iterator_categories.hpp | 7 - boost/iterator/iterator_facade.hpp | 11 +- boost/iterator/minimum_category.hpp | 95 - boost/iterator/new_iterator_tests.hpp | 264 -- boost/iterator/permutation_iterator.hpp | 76 - boost/iterator/transform_iterator.hpp | 171 - boost/iterator/zip_iterator.hpp | 573 --- boost/iterator_adaptors.hpp | 13 - boost/last_value.hpp | 54 - boost/lexical_cast.hpp | 105 - boost/local_function.hpp | 459 --- boost/locale.hpp | 27 - boost/make_shared.hpp | 17 - boost/make_unique.hpp | 14 - boost/math_fwd.hpp | 108 - boost/mem_fn.hpp | 24 - boost/memory_order.hpp | 57 - boost/move/adl_move_swap.hpp | 233 ++ boost/move/algorithm.hpp | 274 -- boost/move/core.hpp | 107 +- boost/move/default_delete.hpp | 8 + boost/move/detail/config_begin.hpp | 3 +- boost/move/detail/fwd_macros.hpp | 465 +++ boost/move/detail/iterator_traits.hpp | 87 + boost/move/detail/meta_utils.hpp | 337 +- boost/move/detail/meta_utils_core.hpp | 120 + boost/move/detail/move_helpers.hpp | 61 +- boost/move/detail/type_traits.hpp | 1078 ++++++ boost/move/detail/unique_ptr_meta_utils.hpp | 8 + boost/move/detail/workaround.hpp | 29 + boost/move/iterator.hpp | 16 +- boost/move/make_unique.hpp | 454 +-- boost/move/move.hpp | 27 - boost/move/traits.hpp | 31 +- boost/move/unique_ptr.hpp | 36 +- boost/move/utility.hpp | 141 - boost/move/utility_core.hpp | 92 +- boost/mpi.hpp | 35 - boost/mpl/O1_size.hpp | 40 - boost/mpl/O1_size_fwd.hpp | 24 - boost/mpl/accumulate.hpp | 39 - boost/mpl/advance.hpp | 76 - boost/mpl/advance_fwd.hpp | 28 - boost/mpl/alias.hpp | 21 - boost/mpl/arithmetic.hpp | 25 - boost/mpl/as_sequence.hpp | 38 - boost/mpl/at.hpp | 52 - boost/mpl/at_fwd.hpp | 24 - boost/mpl/aux_/O1_size_impl.hpp | 87 - boost/mpl/aux_/advance_backward.hpp | 128 - boost/mpl/aux_/advance_forward.hpp | 127 - boost/mpl/aux_/apply_1st.hpp | 35 - boost/mpl/aux_/arithmetic_op.hpp | 92 - boost/mpl/aux_/at_impl.hpp | 45 - boost/mpl/aux_/back_impl.hpp | 43 - boost/mpl/aux_/basic_bind.hpp | 21 - boost/mpl/aux_/begin_end_impl.hpp | 101 - boost/mpl/aux_/clear_impl.hpp | 35 - boost/mpl/aux_/comparison_op.hpp | 83 - boost/mpl/aux_/config/dependent_nttp.hpp | 35 - boost/mpl/aux_/config/forwarding.hpp | 27 - boost/mpl/aux_/config/operators.hpp | 34 - boost/mpl/aux_/config/typeof.hpp | 38 - boost/mpl/aux_/contains_impl.hpp | 61 - boost/mpl/aux_/count_impl.hpp | 44 - boost/mpl/aux_/empty_impl.hpp | 43 - boost/mpl/aux_/erase_impl.hpp | 69 - boost/mpl/aux_/erase_key_impl.hpp | 32 - boost/mpl/aux_/filter_iter.hpp | 140 - boost/mpl/aux_/find_if_pred.hpp | 31 - boost/mpl/aux_/fold_impl.hpp | 43 - boost/mpl/aux_/fold_impl_body.hpp | 365 -- boost/mpl/aux_/fold_op.hpp | 37 - boost/mpl/aux_/fold_pred.hpp | 37 - boost/mpl/aux_/front_impl.hpp | 41 - boost/mpl/aux_/has_begin.hpp | 23 - boost/mpl/aux_/has_key_impl.hpp | 34 - boost/mpl/aux_/has_size.hpp | 23 - boost/mpl/aux_/has_tag.hpp | 23 - boost/mpl/aux_/insert_impl.hpp | 68 - boost/mpl/aux_/insert_range_impl.hpp | 77 - boost/mpl/aux_/inserter_algorithm.hpp | 159 - boost/mpl/aux_/is_msvc_eti_arg.hpp | 64 - boost/mpl/aux_/iter_apply.hpp | 47 - boost/mpl/aux_/iter_fold_if_impl.hpp | 210 -- boost/mpl/aux_/iter_fold_impl.hpp | 42 - boost/mpl/aux_/iter_push_front.hpp | 36 - boost/mpl/aux_/joint_iter.hpp | 120 - boost/mpl/aux_/lambda_spec.hpp | 49 - boost/mpl/aux_/largest_int.hpp | 63 - boost/mpl/aux_/msvc_eti_base.hpp | 77 - boost/mpl/aux_/msvc_type.hpp | 62 - boost/mpl/aux_/numeric_cast_utils.hpp | 77 - boost/mpl/aux_/numeric_op.hpp | 315 -- boost/mpl/aux_/order_impl.hpp | 76 - boost/mpl/aux_/overload_names.hpp | 48 - boost/mpl/aux_/partition_op.hpp | 58 - boost/mpl/aux_/pop_back_impl.hpp | 34 - boost/mpl/aux_/pop_front_impl.hpp | 44 - boost/mpl/aux_/preprocessor/is_seq.hpp | 54 - boost/mpl/aux_/preprocessor/range.hpp | 9 +- boost/mpl/aux_/preprocessor/token_equal.hpp | 56 - boost/mpl/aux_/ptr_to_ref.hpp | 46 - boost/mpl/aux_/push_back_impl.hpp | 70 - boost/mpl/aux_/push_front_impl.hpp | 71 - boost/mpl/aux_/range_c/O1_size.hpp | 31 - boost/mpl/aux_/range_c/back.hpp | 34 - boost/mpl/aux_/range_c/empty.hpp | 37 - boost/mpl/aux_/range_c/front.hpp | 33 - boost/mpl/aux_/range_c/iterator.hpp | 106 - boost/mpl/aux_/range_c/size.hpp | 37 - boost/mpl/aux_/range_c/tag.hpp | 24 - boost/mpl/aux_/reverse_fold_impl.hpp | 44 - boost/mpl/aux_/reverse_fold_impl_body.hpp | 412 -- boost/mpl/aux_/reverse_iter_fold_impl.hpp | 43 - boost/mpl/aux_/sequence_wrapper.hpp | 292 -- boost/mpl/aux_/shift_op.hpp | 87 - boost/mpl/aux_/single_element_iter.hpp | 118 - boost/mpl/aux_/size_impl.hpp | 52 - boost/mpl/aux_/sort_impl.hpp | 121 - boost/mpl/aux_/test.hpp | 32 - boost/mpl/aux_/test/assert.hpp | 29 - boost/mpl/aux_/test/data.hpp | 25 - boost/mpl/aux_/test/test_case.hpp | 21 - boost/mpl/aux_/traits_lambda_spec.hpp | 63 - boost/mpl/aux_/transform_iter.hpp | 123 - boost/mpl/aux_/unwrap.hpp | 51 - boost/mpl/back.hpp | 39 - boost/mpl/back_fwd.hpp | 24 - boost/mpl/back_inserter.hpp | 34 - boost/mpl/base.hpp | 35 - boost/mpl/begin.hpp | 19 - boost/mpl/begin_end.hpp | 57 - boost/mpl/begin_end_fwd.hpp | 27 - boost/mpl/bitand.hpp | 45 - boost/mpl/bitor.hpp | 45 - boost/mpl/bitwise.hpp | 24 - boost/mpl/bitxor.hpp | 23 - boost/mpl/char.hpp | 22 - boost/mpl/char_fwd.hpp | 27 - boost/mpl/clear.hpp | 39 - boost/mpl/clear_fwd.hpp | 24 - boost/mpl/comparison.hpp | 24 - boost/mpl/contains.hpp | 41 - boost/mpl/contains_fwd.hpp | 25 - boost/mpl/copy.hpp | 58 - boost/mpl/copy_if.hpp | 96 - boost/mpl/count.hpp | 40 - boost/mpl/count_fwd.hpp | 24 - boost/mpl/count_if.hpp | 79 - boost/mpl/deque.hpp | 58 - boost/mpl/deref.hpp | 41 - boost/mpl/distance.hpp | 78 - boost/mpl/distance_fwd.hpp | 28 - boost/mpl/divides.hpp | 21 - boost/mpl/empty.hpp | 39 - boost/mpl/empty_base.hpp | 59 - boost/mpl/empty_fwd.hpp | 24 - boost/mpl/empty_sequence.hpp | 42 - boost/mpl/end.hpp | 19 - boost/mpl/equal.hpp | 112 - boost/mpl/equal_to.hpp | 21 - boost/mpl/erase.hpp | 42 - boost/mpl/erase_fwd.hpp | 24 - boost/mpl/erase_key.hpp | 41 - boost/mpl/erase_key_fwd.hpp | 24 - boost/mpl/filter_view.hpp | 46 - boost/mpl/find.hpp | 38 - boost/mpl/find_if.hpp | 50 - boost/mpl/fold.hpp | 48 - boost/mpl/for_each.hpp | 123 - boost/mpl/front.hpp | 39 - boost/mpl/front_fwd.hpp | 24 - boost/mpl/front_inserter.hpp | 33 - boost/mpl/greater.hpp | 21 - boost/mpl/greater_equal.hpp | 21 - boost/mpl/has_key.hpp | 41 - boost/mpl/has_key_fwd.hpp | 25 - boost/mpl/index_if.hpp | 60 - boost/mpl/index_of.hpp | 39 - boost/mpl/inherit.hpp | 229 -- boost/mpl/inherit_linearly.hpp | 39 - boost/mpl/insert.hpp | 41 - boost/mpl/insert_fwd.hpp | 24 - boost/mpl/insert_range.hpp | 41 - boost/mpl/insert_range_fwd.hpp | 24 - boost/mpl/inserter.hpp | 32 - boost/mpl/is_sequence.hpp | 112 - boost/mpl/iter_fold.hpp | 49 - boost/mpl/iter_fold_if.hpp | 117 - boost/mpl/iterator_category.hpp | 35 - boost/mpl/iterator_range.hpp | 42 - boost/mpl/iterator_tags.hpp | 27 - boost/mpl/joint_view.hpp | 65 - boost/mpl/key_type.hpp | 42 - boost/mpl/key_type_fwd.hpp | 25 - boost/mpl/less.hpp | 21 - boost/mpl/less_equal.hpp | 21 - boost/mpl/limits/list.hpp | 21 - boost/mpl/limits/map.hpp | 21 - boost/mpl/limits/set.hpp | 21 - boost/mpl/limits/string.hpp | 21 - boost/mpl/limits/unrolling.hpp | 21 - boost/mpl/limits/vector.hpp | 21 - boost/mpl/list.hpp | 57 - boost/mpl/list/aux_/O1_size.hpp | 33 - boost/mpl/list/aux_/begin_end.hpp | 44 - boost/mpl/list/aux_/clear.hpp | 34 - boost/mpl/list/aux_/empty.hpp | 34 - boost/mpl/list/aux_/front.hpp | 33 - boost/mpl/list/aux_/include_preprocessed.hpp | 35 - boost/mpl/list/aux_/item.hpp | 55 - boost/mpl/list/aux_/iterator.hpp | 76 - boost/mpl/list/aux_/numbered.hpp | 68 - boost/mpl/list/aux_/numbered_c.hpp | 71 - boost/mpl/list/aux_/pop_front.hpp | 34 - .../list/aux_/preprocessed/plain/list10.hpp | 149 - .../list/aux_/preprocessed/plain/list10_c.hpp | 164 - .../list/aux_/preprocessed/plain/list20.hpp | 169 - .../list/aux_/preprocessed/plain/list20_c.hpp | 173 - .../list/aux_/preprocessed/plain/list30.hpp | 189 - .../list/aux_/preprocessed/plain/list30_c.hpp | 183 - .../list/aux_/preprocessed/plain/list40.hpp | 209 -- .../list/aux_/preprocessed/plain/list40_c.hpp | 193 - .../list/aux_/preprocessed/plain/list50.hpp | 229 -- .../list/aux_/preprocessed/plain/list50_c.hpp | 203 - boost/mpl/list/aux_/push_back.hpp | 36 - boost/mpl/list/aux_/push_front.hpp | 39 - boost/mpl/list/aux_/size.hpp | 33 - boost/mpl/list/aux_/tag.hpp | 24 - boost/mpl/list/list0.hpp | 42 - boost/mpl/list/list0_c.hpp | 31 - boost/mpl/list/list10.hpp | 43 - boost/mpl/list/list10_c.hpp | 43 - boost/mpl/list/list20.hpp | 43 - boost/mpl/list/list20_c.hpp | 43 - boost/mpl/list/list30.hpp | 43 - boost/mpl/list/list30_c.hpp | 43 - boost/mpl/list/list40.hpp | 43 - boost/mpl/list/list40_c.hpp | 43 - boost/mpl/list/list50.hpp | 43 - boost/mpl/list/list50_c.hpp | 43 - boost/mpl/list_c.hpp | 60 - boost/mpl/logical.hpp | 21 - boost/mpl/long.hpp | 22 - boost/mpl/long_fwd.hpp | 27 - boost/mpl/lower_bound.hpp | 143 - boost/mpl/map.hpp | 57 - boost/mpl/map/aux_/at_impl.hpp | 144 - boost/mpl/map/aux_/begin_end_impl.hpp | 50 - boost/mpl/map/aux_/clear_impl.hpp | 35 - boost/mpl/map/aux_/contains_impl.hpp | 43 - boost/mpl/map/aux_/empty_impl.hpp | 34 - boost/mpl/map/aux_/erase_impl.hpp | 41 - boost/mpl/map/aux_/erase_key_impl.hpp | 53 - boost/mpl/map/aux_/has_key_impl.hpp | 44 - boost/mpl/map/aux_/include_preprocessed.hpp | 53 - boost/mpl/map/aux_/insert_impl.hpp | 72 - boost/mpl/map/aux_/item.hpp | 138 - boost/mpl/map/aux_/iterator.hpp | 169 - boost/mpl/map/aux_/key_type_impl.hpp | 36 - boost/mpl/map/aux_/map0.hpp | 74 - boost/mpl/map/aux_/numbered.hpp | 110 - .../map/aux_/preprocessed/no_ctps/map10.hpp | 350 -- .../map/aux_/preprocessed/no_ctps/map20.hpp | 370 -- .../map/aux_/preprocessed/no_ctps/map30.hpp | 390 -- .../map/aux_/preprocessed/no_ctps/map40.hpp | 410 -- .../map/aux_/preprocessed/no_ctps/map50.hpp | 430 --- .../mpl/map/aux_/preprocessed/plain/map10.hpp | 290 -- .../mpl/map/aux_/preprocessed/plain/map20.hpp | 310 -- .../mpl/map/aux_/preprocessed/plain/map30.hpp | 330 -- .../mpl/map/aux_/preprocessed/plain/map40.hpp | 350 -- .../mpl/map/aux_/preprocessed/plain/map50.hpp | 370 -- .../aux_/preprocessed/typeof_based/map10.hpp | 150 - .../aux_/preprocessed/typeof_based/map20.hpp | 170 - .../aux_/preprocessed/typeof_based/map30.hpp | 190 - .../aux_/preprocessed/typeof_based/map40.hpp | 210 -- .../aux_/preprocessed/typeof_based/map50.hpp | 230 -- boost/mpl/map/aux_/size_impl.hpp | 33 - boost/mpl/map/aux_/tag.hpp | 24 - boost/mpl/map/aux_/value_type_impl.hpp | 36 - boost/mpl/map/map0.hpp | 36 - boost/mpl/map/map10.hpp | 44 - boost/mpl/map/map20.hpp | 44 - boost/mpl/map/map30.hpp | 44 - boost/mpl/map/map40.hpp | 44 - boost/mpl/map/map50.hpp | 44 - boost/mpl/math/fixed_c.hpp | 36 - boost/mpl/math/is_even.hpp | 54 - boost/mpl/math/rational_c.hpp | 37 - boost/mpl/max.hpp | 19 - boost/mpl/max_element.hpp | 72 - boost/mpl/min.hpp | 19 - boost/mpl/min_element.hpp | 40 - boost/mpl/min_max.hpp | 46 - boost/mpl/minus.hpp | 21 - boost/mpl/modulus.hpp | 22 - boost/mpl/multiplies.hpp | 53 - boost/mpl/multiset/aux_/count_impl.hpp | 82 - boost/mpl/multiset/aux_/insert_impl.hpp | 34 - boost/mpl/multiset/aux_/item.hpp | 114 - boost/mpl/multiset/aux_/multiset0.hpp | 34 - boost/mpl/multiset/aux_/tag.hpp | 23 - boost/mpl/multiset/multiset0.hpp | 36 - boost/mpl/negate.hpp | 81 - boost/mpl/not_equal_to.hpp | 21 - boost/mpl/numeric_cast.hpp | 41 - boost/mpl/order.hpp | 41 - boost/mpl/order_fwd.hpp | 25 - boost/mpl/pair.hpp | 70 - boost/mpl/pair_view.hpp | 169 - boost/mpl/partition.hpp | 53 - boost/mpl/plus.hpp | 21 - boost/mpl/pop_back.hpp | 39 - boost/mpl/pop_back_fwd.hpp | 24 - boost/mpl/pop_front.hpp | 39 - boost/mpl/pop_front_fwd.hpp | 24 - boost/mpl/print.hpp | 75 - boost/mpl/prior.hpp | 19 - boost/mpl/push_back.hpp | 53 - boost/mpl/push_back_fwd.hpp | 24 - boost/mpl/push_front.hpp | 52 - boost/mpl/push_front_fwd.hpp | 24 - boost/mpl/range_c.hpp | 48 - boost/mpl/remove.hpp | 52 - boost/mpl/remove_if.hpp | 83 - boost/mpl/replace.hpp | 55 - boost/mpl/replace_if.hpp | 88 - boost/mpl/reverse.hpp | 38 - boost/mpl/reverse_fold.hpp | 50 - boost/mpl/reverse_iter_fold.hpp | 56 - boost/mpl/same_as.hpp | 55 - boost/mpl/sequence_tag.hpp | 124 - boost/mpl/sequence_tag_fwd.hpp | 26 - boost/mpl/set.hpp | 57 - boost/mpl/set/aux_/at_impl.hpp | 40 - boost/mpl/set/aux_/begin_end_impl.hpp | 43 - boost/mpl/set/aux_/clear_impl.hpp | 35 - boost/mpl/set/aux_/empty_impl.hpp | 34 - boost/mpl/set/aux_/erase_impl.hpp | 41 - boost/mpl/set/aux_/erase_key_impl.hpp | 53 - boost/mpl/set/aux_/has_key_impl.hpp | 60 - boost/mpl/set/aux_/include_preprocessed.hpp | 42 - boost/mpl/set/aux_/insert_impl.hpp | 65 - boost/mpl/set/aux_/item.hpp | 80 - boost/mpl/set/aux_/iterator.hpp | 98 - boost/mpl/set/aux_/key_type_impl.hpp | 34 - boost/mpl/set/aux_/numbered.hpp | 48 - boost/mpl/set/aux_/numbered_c.hpp | 48 - .../mpl/set/aux_/preprocessed/plain/set10.hpp | 140 - .../set/aux_/preprocessed/plain/set10_c.hpp | 145 - .../mpl/set/aux_/preprocessed/plain/set20.hpp | 168 - .../set/aux_/preprocessed/plain/set20_c.hpp | 154 - .../mpl/set/aux_/preprocessed/plain/set30.hpp | 195 - .../set/aux_/preprocessed/plain/set30_c.hpp | 164 - .../mpl/set/aux_/preprocessed/plain/set40.hpp | 221 -- .../set/aux_/preprocessed/plain/set40_c.hpp | 174 - .../mpl/set/aux_/preprocessed/plain/set50.hpp | 250 -- .../set/aux_/preprocessed/plain/set50_c.hpp | 184 - boost/mpl/set/aux_/set0.hpp | 69 - boost/mpl/set/aux_/size_impl.hpp | 33 - boost/mpl/set/aux_/tag.hpp | 24 - boost/mpl/set/aux_/value_type_impl.hpp | 34 - boost/mpl/set/set0.hpp | 35 - boost/mpl/set/set0_c.hpp | 32 - boost/mpl/set/set10.hpp | 44 - boost/mpl/set/set10_c.hpp | 45 - boost/mpl/set/set20.hpp | 44 - boost/mpl/set/set20_c.hpp | 45 - boost/mpl/set/set30.hpp | 44 - boost/mpl/set/set30_c.hpp | 45 - boost/mpl/set/set40.hpp | 44 - boost/mpl/set/set40_c.hpp | 45 - boost/mpl/set/set50.hpp | 44 - boost/mpl/set/set50_c.hpp | 45 - boost/mpl/set_c.hpp | 60 - boost/mpl/shift_left.hpp | 22 - boost/mpl/shift_right.hpp | 22 - boost/mpl/single_view.hpp | 38 - boost/mpl/size.hpp | 42 - boost/mpl/size_fwd.hpp | 24 - boost/mpl/size_t.hpp | 25 - boost/mpl/size_t_fwd.hpp | 28 - boost/mpl/sizeof.hpp | 36 - boost/mpl/sort.hpp | 27 - boost/mpl/stable_partition.hpp | 75 - boost/mpl/string.hpp | 607 --- boost/mpl/switch.hpp | 49 - boost/mpl/tag.hpp | 52 - boost/mpl/times.hpp | 21 - boost/mpl/transform.hpp | 145 - boost/mpl/transform_view.hpp | 46 - boost/mpl/unique.hpp | 85 - boost/mpl/unpack_args.hpp | 150 - boost/mpl/upper_bound.hpp | 141 - boost/mpl/value_type.hpp | 42 - boost/mpl/value_type_fwd.hpp | 25 - boost/mpl/vector.hpp | 57 - boost/mpl/vector/aux_/O1_size.hpp | 56 - boost/mpl/vector/aux_/at.hpp | 116 - boost/mpl/vector/aux_/back.hpp | 59 - boost/mpl/vector/aux_/begin_end.hpp | 49 - boost/mpl/vector/aux_/clear.hpp | 55 - boost/mpl/vector/aux_/empty.hpp | 68 - boost/mpl/vector/aux_/front.hpp | 56 - .../mpl/vector/aux_/include_preprocessed.hpp | 55 - boost/mpl/vector/aux_/item.hpp | 103 - boost/mpl/vector/aux_/iterator.hpp | 130 - boost/mpl/vector/aux_/numbered.hpp | 218 -- boost/mpl/vector/aux_/numbered_c.hpp | 77 - boost/mpl/vector/aux_/pop_back.hpp | 40 - boost/mpl/vector/aux_/pop_front.hpp | 40 - .../aux_/preprocessed/no_ctps/vector10.hpp | 1528 -------- .../aux_/preprocessed/no_ctps/vector10_c.hpp | 149 - .../aux_/preprocessed/no_ctps/vector20.hpp | 1804 --------- .../aux_/preprocessed/no_ctps/vector20_c.hpp | 195 - .../aux_/preprocessed/no_ctps/vector30.hpp | 2124 ----------- .../aux_/preprocessed/no_ctps/vector30_c.hpp | 238 -- .../aux_/preprocessed/no_ctps/vector40.hpp | 2444 ------------ .../aux_/preprocessed/no_ctps/vector40_c.hpp | 281 -- .../aux_/preprocessed/no_ctps/vector50.hpp | 2764 -------------- .../aux_/preprocessed/no_ctps/vector50_c.hpp | 325 -- .../aux_/preprocessed/plain/vector10.hpp | 829 ----- .../aux_/preprocessed/plain/vector10_c.hpp | 149 - .../aux_/preprocessed/plain/vector20.hpp | 1144 ------ .../aux_/preprocessed/plain/vector20_c.hpp | 195 - .../aux_/preprocessed/plain/vector30.hpp | 1464 -------- .../aux_/preprocessed/plain/vector30_c.hpp | 238 -- .../aux_/preprocessed/plain/vector40.hpp | 1784 --------- .../aux_/preprocessed/plain/vector40_c.hpp | 281 -- .../aux_/preprocessed/plain/vector50.hpp | 2104 ----------- .../aux_/preprocessed/plain/vector50_c.hpp | 325 -- .../preprocessed/typeof_based/vector10.hpp | 139 - .../preprocessed/typeof_based/vector10_c.hpp | 154 - .../preprocessed/typeof_based/vector20.hpp | 159 - .../preprocessed/typeof_based/vector20_c.hpp | 163 - .../preprocessed/typeof_based/vector30.hpp | 179 - .../preprocessed/typeof_based/vector30_c.hpp | 173 - .../preprocessed/typeof_based/vector40.hpp | 199 - .../preprocessed/typeof_based/vector40_c.hpp | 183 - .../preprocessed/typeof_based/vector50.hpp | 219 -- .../preprocessed/typeof_based/vector50_c.hpp | 193 - boost/mpl/vector/aux_/push_back.hpp | 40 - boost/mpl/vector/aux_/push_front.hpp | 40 - boost/mpl/vector/aux_/size.hpp | 49 - boost/mpl/vector/aux_/tag.hpp | 32 - boost/mpl/vector/aux_/vector0.hpp | 52 - boost/mpl/vector/vector0.hpp | 34 - boost/mpl/vector/vector0_c.hpp | 31 - boost/mpl/vector/vector10.hpp | 45 - boost/mpl/vector/vector10_c.hpp | 46 - boost/mpl/vector/vector20.hpp | 45 - boost/mpl/vector/vector20_c.hpp | 46 - boost/mpl/vector/vector30.hpp | 45 - boost/mpl/vector/vector30_c.hpp | 47 - boost/mpl/vector/vector40.hpp | 45 - boost/mpl/vector/vector40_c.hpp | 46 - boost/mpl/vector/vector50.hpp | 45 - boost/mpl/vector/vector50_c.hpp | 46 - boost/mpl/vector_c.hpp | 61 - boost/mpl/zip_view.hpp | 65 - boost/multi_array.hpp | 499 --- boost/multi_index_container.hpp | 1362 ------- boost/multi_index_container_fwd.hpp | 121 - boost/non_type.hpp | 27 - boost/nondet_random.hpp | 22 - boost/none.hpp | 28 - boost/none_t.hpp | 24 - boost/operators.hpp | 948 ----- boost/optional.hpp | 18 - boost/parameter.hpp | 21 - boost/phoenix.hpp | 13 - boost/pointee.hpp | 74 - boost/pointer_cast.hpp | 45 - boost/pointer_to_other.hpp | 55 - boost/polymorphic_cast.hpp | 91 - boost/predef.h | 19 - boost/preprocessor.hpp | 19 - boost/preprocessor/arithmetic.hpp | 25 - boost/preprocessor/arithmetic/dec.hpp | 1 + boost/preprocessor/arithmetic/div.hpp | 39 - boost/preprocessor/arithmetic/mul.hpp | 53 - boost/preprocessor/array.hpp | 32 - boost/preprocessor/array/detail/get_data.hpp | 55 - boost/preprocessor/array/enum.hpp | 33 - boost/preprocessor/array/insert.hpp | 55 - boost/preprocessor/array/pop_back.hpp | 37 - boost/preprocessor/array/pop_front.hpp | 38 - boost/preprocessor/array/push_back.hpp | 35 - boost/preprocessor/array/push_front.hpp | 35 - boost/preprocessor/array/remove.hpp | 54 - boost/preprocessor/array/replace.hpp | 49 - boost/preprocessor/array/reverse.hpp | 29 - boost/preprocessor/array/to_list.hpp | 47 - boost/preprocessor/array/to_seq.hpp | 46 - boost/preprocessor/array/to_tuple.hpp | 33 - boost/preprocessor/assert_msg.hpp | 17 - boost/preprocessor/comma.hpp | 17 - boost/preprocessor/comparison.hpp | 24 - boost/preprocessor/comparison/equal.hpp | 34 - boost/preprocessor/comparison/greater.hpp | 38 - .../preprocessor/comparison/greater_equal.hpp | 38 - boost/preprocessor/comparison/less.hpp | 46 - boost/preprocessor/config/config.hpp | 13 +- boost/preprocessor/config/limits.hpp | 30 - boost/preprocessor/control.hpp | 22 - boost/preprocessor/debug.hpp | 18 - boost/preprocessor/debug/assert.hpp | 44 - boost/preprocessor/debug/line.hpp | 35 - boost/preprocessor/detail/is_nullary.hpp | 30 - boost/preprocessor/detail/is_unary.hpp | 30 - boost/preprocessor/detail/null.hpp | 17 - boost/preprocessor/enum.hpp | 17 - .../enum_params_with_a_default.hpp | 17 - .../enum_params_with_defaults.hpp | 17 - boost/preprocessor/enum_shifted.hpp | 17 - boost/preprocessor/expand.hpp | 17 - boost/preprocessor/facilities.hpp | 23 - boost/preprocessor/facilities/apply.hpp | 34 - boost/preprocessor/facilities/intercept.hpp | 277 -- boost/preprocessor/facilities/is_empty.hpp | 1 - .../preprocessor/facilities/is_empty_or_1.hpp | 31 - boost/preprocessor/for.hpp | 17 - boost/preprocessor/if.hpp | 17 - boost/preprocessor/iteration.hpp | 19 - boost/preprocessor/library.hpp | 36 - boost/preprocessor/limits.hpp | 17 - boost/preprocessor/list.hpp | 37 - boost/preprocessor/list/append.hpp | 40 - boost/preprocessor/list/at.hpp | 39 - boost/preprocessor/list/cat.hpp | 42 - boost/preprocessor/list/enum.hpp | 41 - boost/preprocessor/list/filter.hpp | 54 - boost/preprocessor/list/first_n.hpp | 58 - boost/preprocessor/list/for_each.hpp | 49 - boost/preprocessor/list/for_each_product.hpp | 141 - boost/preprocessor/list/rest_n.hpp | 55 - boost/preprocessor/list/size.hpp | 58 - boost/preprocessor/list/to_array.hpp | 155 - boost/preprocessor/list/to_seq.hpp | 32 - boost/preprocessor/list/to_tuple.hpp | 61 - boost/preprocessor/list/transform.hpp | 49 - boost/preprocessor/logical.hpp | 29 - boost/preprocessor/logical/bitnor.hpp | 38 - boost/preprocessor/logical/bitor.hpp | 38 - boost/preprocessor/logical/bitxor.hpp | 38 - boost/preprocessor/logical/nor.hpp | 30 - boost/preprocessor/logical/or.hpp | 30 - boost/preprocessor/logical/xor.hpp | 30 - boost/preprocessor/max.hpp | 17 - boost/preprocessor/min.hpp | 17 - boost/preprocessor/punctuation.hpp | 22 - boost/preprocessor/punctuation/paren.hpp | 23 - boost/preprocessor/punctuation/paren_if.hpp | 38 - .../punctuation/remove_parens.hpp | 39 - boost/preprocessor/repeat_2nd.hpp | 17 - boost/preprocessor/repeat_3rd.hpp | 17 - boost/preprocessor/repeat_from_to.hpp | 17 - boost/preprocessor/repeat_from_to_2nd.hpp | 17 - boost/preprocessor/repeat_from_to_3rd.hpp | 17 - boost/preprocessor/repetition.hpp | 32 - boost/preprocessor/repetition/deduce_r.hpp | 22 - boost/preprocessor/repetition/deduce_z.hpp | 22 - boost/preprocessor/repetition/enum.hpp | 66 - .../repetition/enum_params_with_a_default.hpp | 25 - .../repetition/enum_params_with_defaults.hpp | 24 - .../preprocessor/repetition/enum_shifted.hpp | 68 - .../repetition/enum_shifted_binary_params.hpp | 51 - .../preprocessor/repetition/enum_trailing.hpp | 63 - .../enum_trailing_binary_params.hpp | 53 - boost/preprocessor/repetition/for.hpp | 20 +- boost/preprocessor/selection.hpp | 18 - boost/preprocessor/selection/max.hpp | 39 - boost/preprocessor/selection/min.hpp | 39 - boost/preprocessor/seq.hpp | 44 - .../seq/detail/binary_transform.hpp | 48 - boost/preprocessor/seq/detail/is_empty.hpp | 49 + boost/preprocessor/seq/filter.hpp | 54 - boost/preprocessor/seq/fold_right.hpp | 288 -- boost/preprocessor/seq/for_each.hpp | 60 - boost/preprocessor/seq/for_each_i.hpp | 68 +- boost/preprocessor/seq/for_each_product.hpp | 126 - boost/preprocessor/seq/insert.hpp | 28 - boost/preprocessor/seq/pop_back.hpp | 29 - boost/preprocessor/seq/pop_front.hpp | 27 - boost/preprocessor/seq/push_back.hpp | 19 - boost/preprocessor/seq/push_front.hpp | 19 - boost/preprocessor/seq/remove.hpp | 29 - boost/preprocessor/seq/replace.hpp | 29 - boost/preprocessor/seq/rest_n.hpp | 20 +- boost/preprocessor/seq/reverse.hpp | 39 - boost/preprocessor/seq/size.hpp | 1 + boost/preprocessor/seq/to_array.hpp | 28 - boost/preprocessor/seq/to_list.hpp | 29 - boost/preprocessor/seq/to_tuple.hpp | 27 - .../preprocessor/seq/variadic_seq_to_seq.hpp | 28 - boost/preprocessor/slot.hpp | 17 - boost/preprocessor/slot/counter.hpp | 25 - boost/preprocessor/tuple.hpp | 35 - boost/preprocessor/tuple/elem.hpp | 4 +- boost/preprocessor/tuple/enum.hpp | 22 - boost/preprocessor/tuple/insert.hpp | 37 - boost/preprocessor/tuple/pop_back.hpp | 64 - boost/preprocessor/tuple/pop_front.hpp | 65 - boost/preprocessor/tuple/push_back.hpp | 31 - boost/preprocessor/tuple/push_front.hpp | 32 - boost/preprocessor/tuple/rem.hpp | 4 +- boost/preprocessor/tuple/remove.hpp | 64 - boost/preprocessor/tuple/replace.hpp | 37 - boost/preprocessor/tuple/reverse.hpp | 117 - boost/preprocessor/tuple/to_array.hpp | 39 - boost/preprocessor/tuple/to_seq.hpp | 119 - boost/preprocessor/variadic.hpp | 23 - .../variadic/detail/is_single_return.hpp | 28 - boost/preprocessor/variadic/to_array.hpp | 32 - boost/preprocessor/variadic/to_list.hpp | 25 - boost/preprocessor/variadic/to_seq.hpp | 25 - boost/preprocessor/variadic/to_tuple.hpp | 24 - boost/preprocessor/while.hpp | 17 - boost/preprocessor/wstringize.hpp | 29 - boost/program_options.hpp | 25 - boost/progress.hpp | 143 - boost/python.hpp | 73 - boost/random.hpp | 85 - boost/range.hpp | 23 - boost/range/adaptor/adjacent_filtered.hpp | 237 -- boost/range/adaptor/argument_fwd.hpp | 80 - boost/range/adaptor/copied.hpp | 68 - boost/range/adaptor/define_adaptor.hpp | 109 - boost/range/adaptor/filtered.hpp | 118 - boost/range/adaptor/formatted.hpp | 229 -- boost/range/adaptor/indexed.hpp | 370 -- boost/range/adaptor/indirected.hpp | 100 - boost/range/adaptor/map.hpp | 204 - boost/range/adaptor/replaced.hpp | 169 - boost/range/adaptor/replaced_if.hpp | 177 - boost/range/adaptor/reversed.hpp | 103 - boost/range/adaptor/sliced.hpp | 96 - boost/range/adaptor/strided.hpp | 697 ---- boost/range/adaptor/tokenized.hpp | 137 - boost/range/adaptor/transformed.hpp | 137 - boost/range/adaptor/type_erased.hpp | 196 - boost/range/adaptor/uniqued.hpp | 97 - boost/range/adaptors.hpp | 31 - boost/range/algorithm.hpp | 104 - boost/range/algorithm_ext.hpp | 28 - boost/range/any_range.hpp | 204 - boost/range/as_array.hpp | 45 - boost/range/as_literal.hpp | 127 - boost/range/atl.hpp | 724 ---- boost/range/category.hpp | 29 - boost/range/combine.hpp | 45 - boost/range/const_reverse_iterator.hpp | 35 - boost/range/counting_range.hpp | 76 - boost/range/detail/any_iterator.hpp | 587 --- boost/range/detail/any_iterator_buffer.hpp | 117 - boost/range/detail/any_iterator_interface.hpp | 277 -- boost/range/detail/any_iterator_wrapper.hpp | 640 ---- boost/range/detail/as_literal.hpp | 33 - boost/range/detail/collection_traits.hpp | 266 -- .../range/detail/collection_traits_detail.hpp | 501 --- boost/range/detail/combine_cxx03.hpp | 131 - boost/range/detail/combine_cxx11.hpp | 40 - boost/range/detail/combine_no_rvalue.hpp | 73 - boost/range/detail/combine_rvalue.hpp | 32 - boost/range/detail/common.hpp | 5 +- .../detail/default_constructible_unary_fn.hpp | 64 - .../detail/demote_iterator_traversal_tag.hpp | 91 - boost/range/detail/detail_str.hpp | 376 -- boost/range/detail/difference_type.hpp | 121 - boost/range/detail/empty.hpp | 120 - boost/range/detail/join_iterator.hpp | 354 -- boost/range/detail/microsoft.hpp | 931 ----- boost/range/detail/remove_extent.hpp | 157 - boost/range/detail/size_type.hpp | 55 - boost/range/detail/sizer.hpp | 35 - boost/range/detail/str_types.hpp | 38 - boost/range/detail/value_type.hpp | 72 - boost/range/difference_type.hpp | 22 +- boost/range/irange.hpp | 236 -- boost/range/istream_range.hpp | 37 - boost/range/iterator.hpp | 34 +- boost/range/iterator_range_core.hpp | 22 +- boost/range/iterator_range_hash.hpp | 22 - boost/range/join.hpp | 91 - boost/range/metafunctions.hpp | 31 - boost/range/mfc.hpp | 984 ----- boost/range/mfc_map.hpp | 114 - boost/range/numeric.hpp | 188 - boost/range/pointer.hpp | 30 - boost/range/reference.hpp | 29 - boost/range/result_iterator.hpp | 33 - boost/range/reverse_result_iterator.hpp | 32 - boost/range/size.hpp | 9 + boost/range/size_type.hpp | 33 +- boost/range/sub_range.hpp | 287 -- boost/range/traversal.hpp | 31 - boost/ratio.hpp | 14 - boost/rational.hpp | 611 --- boost/regex.h | 100 - boost/regex.hpp | 37 - boost/regex_fwd.hpp | 33 - boost/scope_exit.hpp | 1415 ------- boost/scoped_array.hpp | 16 - boost/scoped_ptr.hpp | 16 - boost/shared_array.hpp | 19 - boost/shared_container_iterator.hpp | 69 - boost/shared_ptr.hpp | 19 - boost/signal.hpp | 366 -- boost/signals.hpp | 10 - boost/signals2.hpp | 23 - boost/smart_ptr.hpp | 31 - boost/smart_ptr/detail/sp_convertible.hpp | 1 + boost/spirit.hpp | 27 - boost/strong_typedef.hpp | 66 - boost/swap.hpp | 17 - boost/thread.hpp | 26 - boost/throw_exception.hpp | 102 - boost/timer.hpp | 72 - boost/token_functions.hpp | 650 ---- boost/token_iterator.hpp | 128 - boost/tokenizer.hpp | 98 - boost/type.hpp | 18 - boost/type_index.hpp | 265 -- boost/type_traits.hpp | 102 - boost/type_traits/add_cv.hpp | 46 - boost/type_traits/aligned_storage.hpp | 13 - boost/type_traits/alignment_of.hpp | 126 - boost/type_traits/alignment_traits.hpp | 15 - boost/type_traits/arithmetic_traits.hpp | 20 - boost/type_traits/array_traits.hpp | 15 - boost/type_traits/broken_compiler_spec.hpp | 14 - boost/type_traits/common_type.hpp | 157 - boost/type_traits/composite_traits.hpp | 29 - boost/type_traits/conditional.hpp | 25 - boost/type_traits/cv_traits.hpp | 24 - boost/type_traits/decay.hpp | 44 - boost/type_traits/detail/common_type_imp.hpp | 333 -- .../detail/has_postfix_operator.hpp | 202 - .../detail/has_prefix_operator.hpp | 210 -- boost/type_traits/detail/size_t_trait_def.hpp | 51 - .../type_traits/detail/size_t_trait_undef.hpp | 16 - boost/type_traits/detail/wrap.hpp | 18 - boost/type_traits/extent.hpp | 141 - .../type_traits/floating_point_promotion.hpp | 91 - boost/type_traits/has_bit_and.hpp | 49 - boost/type_traits/has_bit_and_assign.hpp | 55 - boost/type_traits/has_bit_or.hpp | 49 - boost/type_traits/has_bit_or_assign.hpp | 55 - boost/type_traits/has_bit_xor.hpp | 49 - boost/type_traits/has_bit_xor_assign.hpp | 55 - boost/type_traits/has_complement.hpp | 32 - boost/type_traits/has_dereference.hpp | 31 - boost/type_traits/has_divides.hpp | 40 - boost/type_traits/has_divides_assign.hpp | 47 - boost/type_traits/has_equal_to.hpp | 49 - boost/type_traits/has_greater.hpp | 49 - boost/type_traits/has_greater_equal.hpp | 49 - boost/type_traits/has_left_shift.hpp | 49 - boost/type_traits/has_left_shift_assign.hpp | 55 - boost/type_traits/has_less.hpp | 49 - boost/type_traits/has_less_equal.hpp | 49 - boost/type_traits/has_logical_and.hpp | 40 - boost/type_traits/has_logical_not.hpp | 32 - boost/type_traits/has_logical_or.hpp | 40 - boost/type_traits/has_modulus.hpp | 49 - boost/type_traits/has_modulus_assign.hpp | 55 - boost/type_traits/has_multiplies.hpp | 40 - boost/type_traits/has_multiplies_assign.hpp | 47 - boost/type_traits/has_negate.hpp | 25 - boost/type_traits/has_new_operator.hpp | 154 - boost/type_traits/has_not_equal_to.hpp | 49 - boost/type_traits/has_nothrow_assign.hpp | 44 - boost/type_traits/has_nothrow_constructor.hpp | 53 - boost/type_traits/has_nothrow_copy.hpp | 53 - boost/type_traits/has_nothrow_destructor.hpp | 25 - boost/type_traits/has_operator.hpp | 51 - boost/type_traits/has_post_decrement.hpp | 44 - boost/type_traits/has_post_increment.hpp | 44 - boost/type_traits/has_pre_decrement.hpp | 44 - boost/type_traits/has_pre_increment.hpp | 44 - boost/type_traits/has_right_shift.hpp | 49 - boost/type_traits/has_right_shift_assign.hpp | 55 - boost/type_traits/has_trivial_assign.hpp | 57 - boost/type_traits/has_trivial_constructor.hpp | 51 - boost/type_traits/has_trivial_copy.hpp | 82 - boost/type_traits/has_trivial_destructor.hpp | 49 - boost/type_traits/has_trivial_move_assign.hpp | 57 - .../has_trivial_move_constructor.hpp | 57 - boost/type_traits/has_unary_minus.hpp | 25 - boost/type_traits/has_unary_plus.hpp | 23 - boost/type_traits/has_virtual_destructor.hpp | 29 - boost/type_traits/intrinsics.hpp | 43 +- boost/type_traits/is_base_of_tr1.hpp | 48 - boost/type_traits/is_complex.hpp | 34 - boost/type_traits/is_compound.hpp | 46 - boost/type_traits/is_copy_assignable.hpp | 147 - boost/type_traits/is_copy_constructible.hpp | 125 - boost/type_traits/is_empty.hpp | 142 - boost/type_traits/is_final.hpp | 41 - boost/type_traits/is_floating_point.hpp | 27 - .../type_traits/is_member_object_pointer.hpp | 46 - .../is_nothrow_move_assignable.hpp | 92 - .../is_nothrow_move_constructible.hpp | 90 - boost/type_traits/is_object.hpp | 45 - boost/type_traits/is_stateless.hpp | 48 - boost/type_traits/is_virtual_base_of.hpp | 102 - boost/type_traits/object_traits.hpp | 33 - boost/type_traits/promote.hpp | 40 - boost/type_traits/rank.hpp | 89 - boost/type_traits/reference_traits.hpp | 15 - boost/type_traits/remove_all_extents.hpp | 40 - boost/type_traits/remove_extent.hpp | 40 - boost/type_traits/remove_volatile.hpp | 77 - boost/type_traits/same_traits.hpp | 15 - boost/type_traits/transform_traits.hpp | 21 - boost/type_traits/transform_traits_spec.hpp | 14 - boost/type_traits/type_with_alignment.hpp | 357 -- boost/unordered_map.hpp | 19 - boost/unordered_set.hpp | 19 - boost/utility/compare_pointees.hpp | 68 - .../detail/in_place_factory_prefix.hpp | 36 - .../detail/in_place_factory_suffix.hpp | 23 - boost/utility/detail/result_of_iterate.hpp | 221 -- boost/utility/empty_deleter.hpp | 43 - boost/utility/explicit_operator_bool.hpp | 17 - boost/utility/in_place_factory.hpp | 86 - boost/utility/result_of.hpp | 210 -- boost/utility/string_ref.hpp | 536 --- boost/utility/string_ref_fwd.hpp | 37 - boost/utility/swap.hpp | 17 - boost/utility/typed_in_place_factory.hpp | 77 - boost/utility/value_init.hpp | 281 -- boost/variant.hpp | 27 - boost/version.hpp | 12 +- boost/visit_each.hpp | 27 - boost/wave.hpp | 23 - boost/weak_ptr.hpp | 18 - 1151 files changed, 7596 insertions(+), 161426 deletions(-) delete mode 100644 boost/align.hpp delete mode 100644 boost/aligned_storage.hpp delete mode 100644 boost/any.hpp delete mode 100644 boost/array.hpp delete mode 100644 boost/asio.hpp delete mode 100644 boost/assign.hpp delete mode 100644 boost/atomic.hpp delete mode 100644 boost/bimap.hpp delete mode 100644 boost/bind.hpp delete mode 100644 boost/blank.hpp delete mode 100644 boost/blank_fwd.hpp delete mode 100644 boost/call_traits.hpp delete mode 100644 boost/cast.hpp delete mode 100644 boost/cerrno.hpp delete mode 100644 boost/chrono.hpp delete mode 100644 boost/circular_buffer.hpp delete mode 100644 boost/circular_buffer_fwd.hpp delete mode 100644 boost/compressed_pair.hpp mode change 100755 => 100644 boost/concept/detail/concept_undef.hpp delete mode 100644 boost/concept/requires.hpp delete mode 100644 boost/concept_archetype.hpp create mode 100644 boost/config/compiler/xlcpp.hpp create mode 100644 boost/config/platform/haiku.hpp delete mode 100644 boost/container/adaptive_pool.hpp delete mode 100644 boost/container/allocator.hpp delete mode 100644 boost/container/deque.hpp delete mode 100644 boost/container/detail/adaptive_node_pool.hpp delete mode 100644 boost/container/detail/adaptive_node_pool_impl.hpp create mode 100644 boost/container/detail/algorithm.hpp delete mode 100644 boost/container/detail/algorithms.hpp create mode 100644 boost/container/detail/alloc_helpers.hpp delete mode 100644 boost/container/detail/alloc_lib.h delete mode 100644 boost/container/detail/alloc_lib_auto_link.hpp delete mode 100644 boost/container/detail/allocator_version_traits.hpp delete mode 100644 boost/container/detail/auto_link.hpp rename boost/container/detail/{utilities.hpp => copy_move_algo.hpp} (59%) delete mode 100644 boost/container/detail/function_detector.hpp delete mode 100644 boost/container/detail/hash_table.hpp create mode 100644 boost/container/detail/iterator.hpp create mode 100644 boost/container/detail/iterator_to_raw_pointer.hpp delete mode 100644 boost/container/detail/math_functions.hpp delete mode 100644 boost/container/detail/memory_util.hpp create mode 100644 boost/container/detail/min_max.hpp delete mode 100644 boost/container/detail/multiallocation_chain.hpp delete mode 100644 boost/container/detail/mutex.hpp create mode 100644 boost/container/detail/next_capacity.hpp delete mode 100644 boost/container/detail/node_alloc_holder.hpp delete mode 100644 boost/container/detail/node_pool.hpp delete mode 100644 boost/container/detail/node_pool_impl.hpp delete mode 100644 boost/container/detail/pool_common.hpp delete mode 100644 boost/container/detail/pool_common_alloc.hpp delete mode 100644 boost/container/detail/preprocessor.hpp delete mode 100644 boost/container/detail/singleton.hpp create mode 100644 boost/container/detail/to_raw_pointer.hpp delete mode 100644 boost/container/detail/transform_iterator.hpp delete mode 100644 boost/container/detail/tree.hpp delete mode 100644 boost/container/list.hpp delete mode 100644 boost/container/map.hpp create mode 100644 boost/container/new_allocator.hpp delete mode 100644 boost/container/node_allocator.hpp delete mode 100644 boost/container/options.hpp delete mode 100644 boost/container/scoped_allocator.hpp delete mode 100644 boost/container/scoped_allocator_fwd.hpp delete mode 100644 boost/container/set.hpp delete mode 100644 boost/container/slist.hpp delete mode 100644 boost/container/stable_vector.hpp delete mode 100644 boost/container/string.hpp delete mode 100644 boost/core/demangle.hpp delete mode 100644 boost/core/explicit_operator_bool.hpp delete mode 100644 boost/core/ignore_unused.hpp delete mode 100644 boost/core/is_same.hpp delete mode 100644 boost/core/lightweight_test.hpp delete mode 100644 boost/core/lightweight_test_trait.hpp delete mode 100644 boost/core/null_deleter.hpp delete mode 100644 boost/core/scoped_enum.hpp delete mode 100644 boost/core/swap.hpp delete mode 100644 boost/core/typeinfo.hpp delete mode 100644 boost/core/underlying_type.hpp delete mode 100644 boost/cregex.hpp delete mode 100644 boost/cstdfloat.hpp delete mode 100644 boost/cstdlib.hpp delete mode 100644 boost/date_time.hpp delete mode 100644 boost/detail/algorithm.hpp delete mode 100644 boost/detail/allocator_utilities.hpp delete mode 100644 boost/detail/atomic_count.hpp delete mode 100644 boost/detail/atomic_redef_macros.hpp delete mode 100644 boost/detail/atomic_undef_macros.hpp delete mode 100644 boost/detail/basic_pointerbuf.hpp delete mode 100644 boost/detail/binary_search.hpp delete mode 100644 boost/detail/bitmask.hpp delete mode 100644 boost/detail/call_traits.hpp delete mode 100644 boost/detail/catch_exceptions.hpp delete mode 100644 boost/detail/compressed_pair.hpp delete mode 100644 boost/detail/container_fwd.hpp delete mode 100644 boost/detail/dynamic_bitset.hpp delete mode 100644 boost/detail/endian.hpp delete mode 100644 boost/detail/fenv.hpp delete mode 100644 boost/detail/has_default_constructor.hpp delete mode 100644 boost/detail/identifier.hpp delete mode 100644 boost/detail/interlocked.hpp delete mode 100644 boost/detail/is_incrementable.hpp delete mode 100644 boost/detail/is_xxx.hpp delete mode 100644 boost/detail/lcast_precision.hpp delete mode 100644 boost/detail/lightweight_main.hpp delete mode 100644 boost/detail/lightweight_mutex.hpp delete mode 100644 boost/detail/lightweight_test.hpp delete mode 100644 boost/detail/lightweight_thread.hpp delete mode 100644 boost/detail/named_template_params.hpp delete mode 100644 boost/detail/no_exceptions_support.hpp delete mode 100644 boost/detail/numeric_traits.hpp delete mode 100644 boost/detail/ob_compressed_pair.hpp delete mode 100644 boost/detail/quick_allocator.hpp delete mode 100644 boost/detail/reference_content.hpp delete mode 100644 boost/detail/scoped_enum_emulation.hpp delete mode 100644 boost/detail/select_type.hpp delete mode 100644 boost/detail/sp_typeinfo.hpp delete mode 100644 boost/detail/templated_streams.hpp delete mode 100644 boost/detail/utf8_codecvt_facet.hpp delete mode 100644 boost/detail/utf8_codecvt_facet.ipp delete mode 100644 boost/detail/winapi/GetCurrentProcess.hpp delete mode 100644 boost/detail/winapi/GetCurrentThread.hpp delete mode 100644 boost/detail/winapi/GetLastError.hpp delete mode 100644 boost/detail/winapi/GetProcessTimes.hpp delete mode 100644 boost/detail/winapi/GetThreadTimes.hpp delete mode 100644 boost/detail/winapi/LocalFree.hpp delete mode 100644 boost/detail/winapi/basic_types.hpp delete mode 100644 boost/detail/winapi/config.hpp delete mode 100644 boost/detail/winapi/crypt.hpp delete mode 100644 boost/detail/winapi/directory_management.hpp delete mode 100644 boost/detail/winapi/dll.hpp delete mode 100644 boost/detail/winapi/error_handling.hpp delete mode 100644 boost/detail/winapi/file_management.hpp delete mode 100644 boost/detail/winapi/handles.hpp delete mode 100644 boost/detail/winapi/memory.hpp delete mode 100644 boost/detail/winapi/process.hpp delete mode 100644 boost/detail/winapi/security.hpp delete mode 100644 boost/detail/winapi/synchronization.hpp delete mode 100644 boost/detail/winapi/system.hpp delete mode 100644 boost/detail/winapi/thread.hpp delete mode 100644 boost/detail/winapi/thread_pool.hpp delete mode 100644 boost/detail/winapi/time.hpp delete mode 100644 boost/detail/winapi/timers.hpp delete mode 100644 boost/detail/winapi/tls.hpp delete mode 100644 boost/detail/winapi/waitable_timer.hpp delete mode 100644 boost/dynamic_bitset.hpp delete mode 100644 boost/dynamic_bitset_fwd.hpp delete mode 100644 boost/enable_shared_from_this.hpp delete mode 100644 boost/exception_ptr.hpp delete mode 100644 boost/filesystem.hpp delete mode 100644 boost/flyweight.hpp delete mode 100644 boost/foreach.hpp delete mode 100644 boost/foreach_fwd.hpp delete mode 100644 boost/format.hpp delete mode 100644 boost/function.hpp delete mode 100644 boost/function_equal.hpp delete mode 100644 boost/function_output_iterator.hpp delete mode 100644 boost/functional.hpp delete mode 100644 boost/generator_iterator.hpp delete mode 100644 boost/geometry.hpp delete mode 100644 boost/get_pointer.hpp delete mode 100644 boost/implicit_cast.hpp delete mode 100644 boost/indirect_reference.hpp delete mode 100644 boost/intrusive/any_hook.hpp delete mode 100644 boost/intrusive/avl_set.hpp delete mode 100644 boost/intrusive/avl_set_hook.hpp delete mode 100644 boost/intrusive/avltree.hpp delete mode 100644 boost/intrusive/avltree_algorithms.hpp delete mode 100644 boost/intrusive/bs_set.hpp delete mode 100644 boost/intrusive/bs_set_hook.hpp delete mode 100644 boost/intrusive/bstree.hpp delete mode 100644 boost/intrusive/bstree_algorithms.hpp delete mode 100644 boost/intrusive/circular_list_algorithms.hpp delete mode 100644 boost/intrusive/circular_slist_algorithms.hpp delete mode 100644 boost/intrusive/derivation_value_traits.hpp delete mode 100644 boost/intrusive/detail/algo_type.hpp create mode 100644 boost/intrusive/detail/algorithm.hpp delete mode 100644 boost/intrusive/detail/any_node_and_algorithms.hpp delete mode 100644 boost/intrusive/detail/array_initializer.hpp delete mode 100644 boost/intrusive/detail/assert.hpp delete mode 100644 boost/intrusive/detail/avltree_node.hpp delete mode 100644 boost/intrusive/detail/common_slist_algorithms.hpp delete mode 100644 boost/intrusive/detail/default_header_holder.hpp delete mode 100644 boost/intrusive/detail/ebo_functor_holder.hpp delete mode 100644 boost/intrusive/detail/empty_node_checker.hpp delete mode 100644 boost/intrusive/detail/equal_to_value.hpp delete mode 100644 boost/intrusive/detail/exception_disposer.hpp delete mode 100644 boost/intrusive/detail/function_detector.hpp delete mode 100644 boost/intrusive/detail/generic_hook.hpp delete mode 100644 boost/intrusive/detail/get_value_traits.hpp delete mode 100644 boost/intrusive/detail/hashtable_node.hpp delete mode 100644 boost/intrusive/detail/hook_traits.hpp delete mode 100644 boost/intrusive/detail/iiterator.hpp delete mode 100644 boost/intrusive/detail/is_stateful_value_traits.hpp create mode 100644 boost/intrusive/detail/iterator.hpp delete mode 100644 boost/intrusive/detail/key_nodeptr_comp.hpp delete mode 100644 boost/intrusive/detail/list_iterator.hpp delete mode 100644 boost/intrusive/detail/list_node.hpp delete mode 100644 boost/intrusive/detail/math.hpp delete mode 100644 boost/intrusive/detail/memory_util.hpp create mode 100644 boost/intrusive/detail/minimal_less_equal_header.hpp create mode 100644 boost/intrusive/detail/minimal_pair_header.hpp delete mode 100644 boost/intrusive/detail/node_cloner_disposer.hpp delete mode 100644 boost/intrusive/detail/node_holder.hpp delete mode 100644 boost/intrusive/detail/node_to_value.hpp delete mode 100644 boost/intrusive/detail/parent_from_member.hpp delete mode 100644 boost/intrusive/detail/preprocessor.hpp delete mode 100644 boost/intrusive/detail/rbtree_node.hpp delete mode 100644 boost/intrusive/detail/simple_disposers.hpp delete mode 100644 boost/intrusive/detail/size_holder.hpp delete mode 100644 boost/intrusive/detail/slist_iterator.hpp delete mode 100644 boost/intrusive/detail/slist_node.hpp delete mode 100644 boost/intrusive/detail/transform_iterator.hpp delete mode 100644 boost/intrusive/detail/tree_iterator.hpp delete mode 100644 boost/intrusive/detail/tree_node.hpp delete mode 100644 boost/intrusive/detail/uncast.hpp delete mode 100644 boost/intrusive/hashtable.hpp delete mode 100644 boost/intrusive/intrusive_fwd.hpp delete mode 100644 boost/intrusive/linear_slist_algorithms.hpp delete mode 100644 boost/intrusive/link_mode.hpp delete mode 100644 boost/intrusive/list.hpp delete mode 100644 boost/intrusive/list_hook.hpp delete mode 100644 boost/intrusive/member_value_traits.hpp delete mode 100644 boost/intrusive/options.hpp delete mode 100644 boost/intrusive/pack_options.hpp delete mode 100644 boost/intrusive/parent_from_member.hpp delete mode 100644 boost/intrusive/pointer_plus_bits.hpp delete mode 100644 boost/intrusive/priority_compare.hpp delete mode 100644 boost/intrusive/rbtree.hpp delete mode 100644 boost/intrusive/rbtree_algorithms.hpp delete mode 100644 boost/intrusive/set.hpp delete mode 100644 boost/intrusive/set_hook.hpp delete mode 100644 boost/intrusive/sg_set.hpp delete mode 100644 boost/intrusive/sgtree.hpp delete mode 100644 boost/intrusive/sgtree_algorithms.hpp delete mode 100644 boost/intrusive/slist.hpp delete mode 100644 boost/intrusive/slist_hook.hpp delete mode 100644 boost/intrusive/splay_set.hpp delete mode 100644 boost/intrusive/splaytree.hpp delete mode 100644 boost/intrusive/splaytree_algorithms.hpp delete mode 100644 boost/intrusive/treap.hpp delete mode 100644 boost/intrusive/treap_algorithms.hpp delete mode 100644 boost/intrusive/treap_set.hpp delete mode 100644 boost/intrusive/trivial_value_traits.hpp delete mode 100644 boost/intrusive/unordered_set.hpp delete mode 100644 boost/intrusive/unordered_set_hook.hpp delete mode 100644 boost/intrusive_ptr.hpp delete mode 100644 boost/io_fwd.hpp delete mode 100644 boost/is_placeholder.hpp delete mode 100644 boost/iterator/counting_iterator.hpp delete mode 100644 boost/iterator/detail/any_conversion_eater.hpp delete mode 100644 boost/iterator/detail/minimum_category.hpp delete mode 100644 boost/iterator/filter_iterator.hpp delete mode 100644 boost/iterator/function_input_iterator.hpp delete mode 100644 boost/iterator/indirect_iterator.hpp delete mode 100644 boost/iterator/is_lvalue_iterator.hpp delete mode 100644 boost/iterator/is_readable_iterator.hpp delete mode 100644 boost/iterator/iterator_archetypes.hpp delete mode 100644 boost/iterator/minimum_category.hpp delete mode 100644 boost/iterator/new_iterator_tests.hpp delete mode 100644 boost/iterator/permutation_iterator.hpp delete mode 100644 boost/iterator/transform_iterator.hpp delete mode 100644 boost/iterator/zip_iterator.hpp delete mode 100644 boost/iterator_adaptors.hpp delete mode 100644 boost/last_value.hpp delete mode 100644 boost/lexical_cast.hpp delete mode 100644 boost/local_function.hpp delete mode 100644 boost/locale.hpp delete mode 100644 boost/make_shared.hpp delete mode 100644 boost/make_unique.hpp delete mode 100644 boost/math_fwd.hpp delete mode 100644 boost/mem_fn.hpp delete mode 100644 boost/memory_order.hpp create mode 100644 boost/move/adl_move_swap.hpp delete mode 100644 boost/move/algorithm.hpp create mode 100644 boost/move/detail/fwd_macros.hpp create mode 100644 boost/move/detail/iterator_traits.hpp create mode 100644 boost/move/detail/meta_utils_core.hpp create mode 100644 boost/move/detail/type_traits.hpp delete mode 100644 boost/move/move.hpp delete mode 100644 boost/move/utility.hpp delete mode 100644 boost/mpi.hpp delete mode 100644 boost/mpl/O1_size.hpp delete mode 100644 boost/mpl/O1_size_fwd.hpp delete mode 100644 boost/mpl/accumulate.hpp delete mode 100644 boost/mpl/advance.hpp delete mode 100644 boost/mpl/advance_fwd.hpp delete mode 100644 boost/mpl/alias.hpp delete mode 100644 boost/mpl/arithmetic.hpp delete mode 100644 boost/mpl/as_sequence.hpp delete mode 100644 boost/mpl/at.hpp delete mode 100644 boost/mpl/at_fwd.hpp delete mode 100644 boost/mpl/aux_/O1_size_impl.hpp delete mode 100644 boost/mpl/aux_/advance_backward.hpp delete mode 100644 boost/mpl/aux_/advance_forward.hpp delete mode 100644 boost/mpl/aux_/apply_1st.hpp delete mode 100644 boost/mpl/aux_/arithmetic_op.hpp delete mode 100644 boost/mpl/aux_/at_impl.hpp delete mode 100644 boost/mpl/aux_/back_impl.hpp delete mode 100644 boost/mpl/aux_/basic_bind.hpp delete mode 100644 boost/mpl/aux_/begin_end_impl.hpp delete mode 100644 boost/mpl/aux_/clear_impl.hpp delete mode 100644 boost/mpl/aux_/comparison_op.hpp delete mode 100644 boost/mpl/aux_/config/dependent_nttp.hpp delete mode 100644 boost/mpl/aux_/config/forwarding.hpp delete mode 100644 boost/mpl/aux_/config/operators.hpp delete mode 100644 boost/mpl/aux_/config/typeof.hpp delete mode 100644 boost/mpl/aux_/contains_impl.hpp delete mode 100644 boost/mpl/aux_/count_impl.hpp delete mode 100644 boost/mpl/aux_/empty_impl.hpp delete mode 100644 boost/mpl/aux_/erase_impl.hpp delete mode 100644 boost/mpl/aux_/erase_key_impl.hpp delete mode 100644 boost/mpl/aux_/filter_iter.hpp delete mode 100644 boost/mpl/aux_/find_if_pred.hpp delete mode 100644 boost/mpl/aux_/fold_impl.hpp delete mode 100644 boost/mpl/aux_/fold_impl_body.hpp delete mode 100644 boost/mpl/aux_/fold_op.hpp delete mode 100644 boost/mpl/aux_/fold_pred.hpp delete mode 100644 boost/mpl/aux_/front_impl.hpp delete mode 100644 boost/mpl/aux_/has_begin.hpp delete mode 100644 boost/mpl/aux_/has_key_impl.hpp delete mode 100644 boost/mpl/aux_/has_size.hpp delete mode 100644 boost/mpl/aux_/has_tag.hpp delete mode 100644 boost/mpl/aux_/insert_impl.hpp delete mode 100644 boost/mpl/aux_/insert_range_impl.hpp delete mode 100644 boost/mpl/aux_/inserter_algorithm.hpp delete mode 100644 boost/mpl/aux_/is_msvc_eti_arg.hpp delete mode 100644 boost/mpl/aux_/iter_apply.hpp delete mode 100644 boost/mpl/aux_/iter_fold_if_impl.hpp delete mode 100644 boost/mpl/aux_/iter_fold_impl.hpp delete mode 100644 boost/mpl/aux_/iter_push_front.hpp delete mode 100644 boost/mpl/aux_/joint_iter.hpp delete mode 100644 boost/mpl/aux_/lambda_spec.hpp delete mode 100644 boost/mpl/aux_/largest_int.hpp delete mode 100644 boost/mpl/aux_/msvc_eti_base.hpp delete mode 100644 boost/mpl/aux_/msvc_type.hpp delete mode 100644 boost/mpl/aux_/numeric_cast_utils.hpp delete mode 100644 boost/mpl/aux_/numeric_op.hpp delete mode 100644 boost/mpl/aux_/order_impl.hpp delete mode 100644 boost/mpl/aux_/overload_names.hpp delete mode 100644 boost/mpl/aux_/partition_op.hpp delete mode 100644 boost/mpl/aux_/pop_back_impl.hpp delete mode 100644 boost/mpl/aux_/pop_front_impl.hpp delete mode 100644 boost/mpl/aux_/preprocessor/is_seq.hpp delete mode 100644 boost/mpl/aux_/preprocessor/token_equal.hpp delete mode 100644 boost/mpl/aux_/ptr_to_ref.hpp delete mode 100644 boost/mpl/aux_/push_back_impl.hpp delete mode 100644 boost/mpl/aux_/push_front_impl.hpp delete mode 100644 boost/mpl/aux_/range_c/O1_size.hpp delete mode 100644 boost/mpl/aux_/range_c/back.hpp delete mode 100644 boost/mpl/aux_/range_c/empty.hpp delete mode 100644 boost/mpl/aux_/range_c/front.hpp delete mode 100644 boost/mpl/aux_/range_c/iterator.hpp delete mode 100644 boost/mpl/aux_/range_c/size.hpp delete mode 100644 boost/mpl/aux_/range_c/tag.hpp delete mode 100644 boost/mpl/aux_/reverse_fold_impl.hpp delete mode 100644 boost/mpl/aux_/reverse_fold_impl_body.hpp delete mode 100644 boost/mpl/aux_/reverse_iter_fold_impl.hpp delete mode 100644 boost/mpl/aux_/sequence_wrapper.hpp delete mode 100644 boost/mpl/aux_/shift_op.hpp delete mode 100644 boost/mpl/aux_/single_element_iter.hpp delete mode 100644 boost/mpl/aux_/size_impl.hpp delete mode 100644 boost/mpl/aux_/sort_impl.hpp delete mode 100644 boost/mpl/aux_/test.hpp delete mode 100644 boost/mpl/aux_/test/assert.hpp delete mode 100644 boost/mpl/aux_/test/data.hpp delete mode 100644 boost/mpl/aux_/test/test_case.hpp delete mode 100644 boost/mpl/aux_/traits_lambda_spec.hpp delete mode 100644 boost/mpl/aux_/transform_iter.hpp delete mode 100644 boost/mpl/aux_/unwrap.hpp delete mode 100644 boost/mpl/back.hpp delete mode 100644 boost/mpl/back_fwd.hpp delete mode 100644 boost/mpl/back_inserter.hpp delete mode 100644 boost/mpl/base.hpp delete mode 100644 boost/mpl/begin.hpp delete mode 100644 boost/mpl/begin_end.hpp delete mode 100644 boost/mpl/begin_end_fwd.hpp delete mode 100644 boost/mpl/bitand.hpp delete mode 100644 boost/mpl/bitor.hpp delete mode 100644 boost/mpl/bitwise.hpp delete mode 100644 boost/mpl/bitxor.hpp delete mode 100644 boost/mpl/char.hpp delete mode 100644 boost/mpl/char_fwd.hpp delete mode 100644 boost/mpl/clear.hpp delete mode 100644 boost/mpl/clear_fwd.hpp delete mode 100644 boost/mpl/comparison.hpp delete mode 100644 boost/mpl/contains.hpp delete mode 100644 boost/mpl/contains_fwd.hpp delete mode 100644 boost/mpl/copy.hpp delete mode 100644 boost/mpl/copy_if.hpp delete mode 100644 boost/mpl/count.hpp delete mode 100644 boost/mpl/count_fwd.hpp delete mode 100644 boost/mpl/count_if.hpp delete mode 100644 boost/mpl/deque.hpp delete mode 100644 boost/mpl/deref.hpp delete mode 100644 boost/mpl/distance.hpp delete mode 100644 boost/mpl/distance_fwd.hpp delete mode 100644 boost/mpl/divides.hpp delete mode 100644 boost/mpl/empty.hpp delete mode 100644 boost/mpl/empty_base.hpp delete mode 100644 boost/mpl/empty_fwd.hpp delete mode 100644 boost/mpl/empty_sequence.hpp delete mode 100644 boost/mpl/end.hpp delete mode 100644 boost/mpl/equal.hpp delete mode 100644 boost/mpl/equal_to.hpp delete mode 100644 boost/mpl/erase.hpp delete mode 100644 boost/mpl/erase_fwd.hpp delete mode 100644 boost/mpl/erase_key.hpp delete mode 100644 boost/mpl/erase_key_fwd.hpp delete mode 100644 boost/mpl/filter_view.hpp delete mode 100644 boost/mpl/find.hpp delete mode 100644 boost/mpl/find_if.hpp delete mode 100644 boost/mpl/fold.hpp delete mode 100644 boost/mpl/for_each.hpp delete mode 100644 boost/mpl/front.hpp delete mode 100644 boost/mpl/front_fwd.hpp delete mode 100644 boost/mpl/front_inserter.hpp delete mode 100644 boost/mpl/greater.hpp delete mode 100644 boost/mpl/greater_equal.hpp delete mode 100644 boost/mpl/has_key.hpp delete mode 100644 boost/mpl/has_key_fwd.hpp delete mode 100644 boost/mpl/index_if.hpp delete mode 100644 boost/mpl/index_of.hpp delete mode 100644 boost/mpl/inherit.hpp delete mode 100644 boost/mpl/inherit_linearly.hpp delete mode 100644 boost/mpl/insert.hpp delete mode 100644 boost/mpl/insert_fwd.hpp delete mode 100644 boost/mpl/insert_range.hpp delete mode 100644 boost/mpl/insert_range_fwd.hpp delete mode 100644 boost/mpl/inserter.hpp delete mode 100644 boost/mpl/is_sequence.hpp delete mode 100644 boost/mpl/iter_fold.hpp delete mode 100644 boost/mpl/iter_fold_if.hpp delete mode 100644 boost/mpl/iterator_category.hpp delete mode 100644 boost/mpl/iterator_range.hpp delete mode 100644 boost/mpl/iterator_tags.hpp delete mode 100644 boost/mpl/joint_view.hpp delete mode 100644 boost/mpl/key_type.hpp delete mode 100644 boost/mpl/key_type_fwd.hpp delete mode 100644 boost/mpl/less.hpp delete mode 100644 boost/mpl/less_equal.hpp delete mode 100644 boost/mpl/limits/list.hpp delete mode 100644 boost/mpl/limits/map.hpp delete mode 100644 boost/mpl/limits/set.hpp delete mode 100644 boost/mpl/limits/string.hpp delete mode 100644 boost/mpl/limits/unrolling.hpp delete mode 100644 boost/mpl/limits/vector.hpp delete mode 100644 boost/mpl/list.hpp delete mode 100644 boost/mpl/list/aux_/O1_size.hpp delete mode 100644 boost/mpl/list/aux_/begin_end.hpp delete mode 100644 boost/mpl/list/aux_/clear.hpp delete mode 100644 boost/mpl/list/aux_/empty.hpp delete mode 100644 boost/mpl/list/aux_/front.hpp delete mode 100644 boost/mpl/list/aux_/include_preprocessed.hpp delete mode 100644 boost/mpl/list/aux_/item.hpp delete mode 100644 boost/mpl/list/aux_/iterator.hpp delete mode 100644 boost/mpl/list/aux_/numbered.hpp delete mode 100644 boost/mpl/list/aux_/numbered_c.hpp delete mode 100644 boost/mpl/list/aux_/pop_front.hpp delete mode 100644 boost/mpl/list/aux_/preprocessed/plain/list10.hpp delete mode 100644 boost/mpl/list/aux_/preprocessed/plain/list10_c.hpp delete mode 100644 boost/mpl/list/aux_/preprocessed/plain/list20.hpp delete mode 100644 boost/mpl/list/aux_/preprocessed/plain/list20_c.hpp delete mode 100644 boost/mpl/list/aux_/preprocessed/plain/list30.hpp delete mode 100644 boost/mpl/list/aux_/preprocessed/plain/list30_c.hpp delete mode 100644 boost/mpl/list/aux_/preprocessed/plain/list40.hpp delete mode 100644 boost/mpl/list/aux_/preprocessed/plain/list40_c.hpp delete mode 100644 boost/mpl/list/aux_/preprocessed/plain/list50.hpp delete mode 100644 boost/mpl/list/aux_/preprocessed/plain/list50_c.hpp delete mode 100644 boost/mpl/list/aux_/push_back.hpp delete mode 100644 boost/mpl/list/aux_/push_front.hpp delete mode 100644 boost/mpl/list/aux_/size.hpp delete mode 100644 boost/mpl/list/aux_/tag.hpp delete mode 100644 boost/mpl/list/list0.hpp delete mode 100644 boost/mpl/list/list0_c.hpp delete mode 100644 boost/mpl/list/list10.hpp delete mode 100644 boost/mpl/list/list10_c.hpp delete mode 100644 boost/mpl/list/list20.hpp delete mode 100644 boost/mpl/list/list20_c.hpp delete mode 100644 boost/mpl/list/list30.hpp delete mode 100644 boost/mpl/list/list30_c.hpp delete mode 100644 boost/mpl/list/list40.hpp delete mode 100644 boost/mpl/list/list40_c.hpp delete mode 100644 boost/mpl/list/list50.hpp delete mode 100644 boost/mpl/list/list50_c.hpp delete mode 100644 boost/mpl/list_c.hpp delete mode 100644 boost/mpl/logical.hpp delete mode 100644 boost/mpl/long.hpp delete mode 100644 boost/mpl/long_fwd.hpp delete mode 100644 boost/mpl/lower_bound.hpp delete mode 100644 boost/mpl/map.hpp delete mode 100644 boost/mpl/map/aux_/at_impl.hpp delete mode 100644 boost/mpl/map/aux_/begin_end_impl.hpp delete mode 100644 boost/mpl/map/aux_/clear_impl.hpp delete mode 100644 boost/mpl/map/aux_/contains_impl.hpp delete mode 100644 boost/mpl/map/aux_/empty_impl.hpp delete mode 100644 boost/mpl/map/aux_/erase_impl.hpp delete mode 100644 boost/mpl/map/aux_/erase_key_impl.hpp delete mode 100644 boost/mpl/map/aux_/has_key_impl.hpp delete mode 100644 boost/mpl/map/aux_/include_preprocessed.hpp delete mode 100644 boost/mpl/map/aux_/insert_impl.hpp delete mode 100644 boost/mpl/map/aux_/item.hpp delete mode 100644 boost/mpl/map/aux_/iterator.hpp delete mode 100644 boost/mpl/map/aux_/key_type_impl.hpp delete mode 100644 boost/mpl/map/aux_/map0.hpp delete mode 100644 boost/mpl/map/aux_/numbered.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/no_ctps/map10.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/no_ctps/map20.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/no_ctps/map30.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/no_ctps/map40.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/no_ctps/map50.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/plain/map10.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/plain/map20.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/plain/map30.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/plain/map40.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/plain/map50.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/typeof_based/map10.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/typeof_based/map20.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/typeof_based/map30.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/typeof_based/map40.hpp delete mode 100644 boost/mpl/map/aux_/preprocessed/typeof_based/map50.hpp delete mode 100644 boost/mpl/map/aux_/size_impl.hpp delete mode 100644 boost/mpl/map/aux_/tag.hpp delete mode 100644 boost/mpl/map/aux_/value_type_impl.hpp delete mode 100644 boost/mpl/map/map0.hpp delete mode 100644 boost/mpl/map/map10.hpp delete mode 100644 boost/mpl/map/map20.hpp delete mode 100644 boost/mpl/map/map30.hpp delete mode 100644 boost/mpl/map/map40.hpp delete mode 100644 boost/mpl/map/map50.hpp delete mode 100644 boost/mpl/math/fixed_c.hpp delete mode 100644 boost/mpl/math/is_even.hpp delete mode 100644 boost/mpl/math/rational_c.hpp delete mode 100644 boost/mpl/max.hpp delete mode 100644 boost/mpl/max_element.hpp delete mode 100644 boost/mpl/min.hpp delete mode 100644 boost/mpl/min_element.hpp delete mode 100644 boost/mpl/min_max.hpp delete mode 100644 boost/mpl/minus.hpp delete mode 100644 boost/mpl/modulus.hpp delete mode 100644 boost/mpl/multiplies.hpp delete mode 100644 boost/mpl/multiset/aux_/count_impl.hpp delete mode 100644 boost/mpl/multiset/aux_/insert_impl.hpp delete mode 100644 boost/mpl/multiset/aux_/item.hpp delete mode 100644 boost/mpl/multiset/aux_/multiset0.hpp delete mode 100644 boost/mpl/multiset/aux_/tag.hpp delete mode 100644 boost/mpl/multiset/multiset0.hpp delete mode 100644 boost/mpl/negate.hpp delete mode 100644 boost/mpl/not_equal_to.hpp delete mode 100644 boost/mpl/numeric_cast.hpp delete mode 100644 boost/mpl/order.hpp delete mode 100644 boost/mpl/order_fwd.hpp delete mode 100644 boost/mpl/pair.hpp delete mode 100644 boost/mpl/pair_view.hpp delete mode 100644 boost/mpl/partition.hpp delete mode 100644 boost/mpl/plus.hpp delete mode 100644 boost/mpl/pop_back.hpp delete mode 100644 boost/mpl/pop_back_fwd.hpp delete mode 100644 boost/mpl/pop_front.hpp delete mode 100644 boost/mpl/pop_front_fwd.hpp delete mode 100644 boost/mpl/print.hpp delete mode 100644 boost/mpl/prior.hpp delete mode 100644 boost/mpl/push_back.hpp delete mode 100644 boost/mpl/push_back_fwd.hpp delete mode 100644 boost/mpl/push_front.hpp delete mode 100644 boost/mpl/push_front_fwd.hpp delete mode 100644 boost/mpl/range_c.hpp delete mode 100644 boost/mpl/remove.hpp delete mode 100644 boost/mpl/remove_if.hpp delete mode 100644 boost/mpl/replace.hpp delete mode 100644 boost/mpl/replace_if.hpp delete mode 100644 boost/mpl/reverse.hpp delete mode 100644 boost/mpl/reverse_fold.hpp delete mode 100644 boost/mpl/reverse_iter_fold.hpp delete mode 100644 boost/mpl/same_as.hpp delete mode 100644 boost/mpl/sequence_tag.hpp delete mode 100644 boost/mpl/sequence_tag_fwd.hpp delete mode 100644 boost/mpl/set.hpp delete mode 100644 boost/mpl/set/aux_/at_impl.hpp delete mode 100644 boost/mpl/set/aux_/begin_end_impl.hpp delete mode 100644 boost/mpl/set/aux_/clear_impl.hpp delete mode 100644 boost/mpl/set/aux_/empty_impl.hpp delete mode 100644 boost/mpl/set/aux_/erase_impl.hpp delete mode 100644 boost/mpl/set/aux_/erase_key_impl.hpp delete mode 100644 boost/mpl/set/aux_/has_key_impl.hpp delete mode 100644 boost/mpl/set/aux_/include_preprocessed.hpp delete mode 100644 boost/mpl/set/aux_/insert_impl.hpp delete mode 100644 boost/mpl/set/aux_/item.hpp delete mode 100644 boost/mpl/set/aux_/iterator.hpp delete mode 100644 boost/mpl/set/aux_/key_type_impl.hpp delete mode 100644 boost/mpl/set/aux_/numbered.hpp delete mode 100644 boost/mpl/set/aux_/numbered_c.hpp delete mode 100644 boost/mpl/set/aux_/preprocessed/plain/set10.hpp delete mode 100644 boost/mpl/set/aux_/preprocessed/plain/set10_c.hpp delete mode 100644 boost/mpl/set/aux_/preprocessed/plain/set20.hpp delete mode 100644 boost/mpl/set/aux_/preprocessed/plain/set20_c.hpp delete mode 100644 boost/mpl/set/aux_/preprocessed/plain/set30.hpp delete mode 100644 boost/mpl/set/aux_/preprocessed/plain/set30_c.hpp delete mode 100644 boost/mpl/set/aux_/preprocessed/plain/set40.hpp delete mode 100644 boost/mpl/set/aux_/preprocessed/plain/set40_c.hpp delete mode 100644 boost/mpl/set/aux_/preprocessed/plain/set50.hpp delete mode 100644 boost/mpl/set/aux_/preprocessed/plain/set50_c.hpp delete mode 100644 boost/mpl/set/aux_/set0.hpp delete mode 100644 boost/mpl/set/aux_/size_impl.hpp delete mode 100644 boost/mpl/set/aux_/tag.hpp delete mode 100644 boost/mpl/set/aux_/value_type_impl.hpp delete mode 100644 boost/mpl/set/set0.hpp delete mode 100644 boost/mpl/set/set0_c.hpp delete mode 100644 boost/mpl/set/set10.hpp delete mode 100644 boost/mpl/set/set10_c.hpp delete mode 100644 boost/mpl/set/set20.hpp delete mode 100644 boost/mpl/set/set20_c.hpp delete mode 100644 boost/mpl/set/set30.hpp delete mode 100644 boost/mpl/set/set30_c.hpp delete mode 100644 boost/mpl/set/set40.hpp delete mode 100644 boost/mpl/set/set40_c.hpp delete mode 100644 boost/mpl/set/set50.hpp delete mode 100644 boost/mpl/set/set50_c.hpp delete mode 100644 boost/mpl/set_c.hpp delete mode 100644 boost/mpl/shift_left.hpp delete mode 100644 boost/mpl/shift_right.hpp delete mode 100644 boost/mpl/single_view.hpp delete mode 100644 boost/mpl/size.hpp delete mode 100644 boost/mpl/size_fwd.hpp delete mode 100644 boost/mpl/size_t.hpp delete mode 100644 boost/mpl/size_t_fwd.hpp delete mode 100644 boost/mpl/sizeof.hpp delete mode 100644 boost/mpl/sort.hpp delete mode 100644 boost/mpl/stable_partition.hpp delete mode 100644 boost/mpl/string.hpp delete mode 100644 boost/mpl/switch.hpp delete mode 100644 boost/mpl/tag.hpp delete mode 100644 boost/mpl/times.hpp delete mode 100644 boost/mpl/transform.hpp delete mode 100644 boost/mpl/transform_view.hpp delete mode 100644 boost/mpl/unique.hpp delete mode 100644 boost/mpl/unpack_args.hpp delete mode 100644 boost/mpl/upper_bound.hpp delete mode 100644 boost/mpl/value_type.hpp delete mode 100644 boost/mpl/value_type_fwd.hpp delete mode 100644 boost/mpl/vector.hpp delete mode 100644 boost/mpl/vector/aux_/O1_size.hpp delete mode 100644 boost/mpl/vector/aux_/at.hpp delete mode 100644 boost/mpl/vector/aux_/back.hpp delete mode 100644 boost/mpl/vector/aux_/begin_end.hpp delete mode 100644 boost/mpl/vector/aux_/clear.hpp delete mode 100644 boost/mpl/vector/aux_/empty.hpp delete mode 100644 boost/mpl/vector/aux_/front.hpp delete mode 100644 boost/mpl/vector/aux_/include_preprocessed.hpp delete mode 100644 boost/mpl/vector/aux_/item.hpp delete mode 100644 boost/mpl/vector/aux_/iterator.hpp delete mode 100644 boost/mpl/vector/aux_/numbered.hpp delete mode 100644 boost/mpl/vector/aux_/numbered_c.hpp delete mode 100644 boost/mpl/vector/aux_/pop_back.hpp delete mode 100644 boost/mpl/vector/aux_/pop_front.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/no_ctps/vector10.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/no_ctps/vector10_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/no_ctps/vector20.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/no_ctps/vector20_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/no_ctps/vector30.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/no_ctps/vector30_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/no_ctps/vector40.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/no_ctps/vector40_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/no_ctps/vector50.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/no_ctps/vector50_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/plain/vector10.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/plain/vector10_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/plain/vector20.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/plain/vector20_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/plain/vector30.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/plain/vector30_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/plain/vector40.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/plain/vector40_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/plain/vector50.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/plain/vector50_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/typeof_based/vector10.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/typeof_based/vector10_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/typeof_based/vector20.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/typeof_based/vector20_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/typeof_based/vector30.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/typeof_based/vector30_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/typeof_based/vector40.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/typeof_based/vector40_c.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/typeof_based/vector50.hpp delete mode 100644 boost/mpl/vector/aux_/preprocessed/typeof_based/vector50_c.hpp delete mode 100644 boost/mpl/vector/aux_/push_back.hpp delete mode 100644 boost/mpl/vector/aux_/push_front.hpp delete mode 100644 boost/mpl/vector/aux_/size.hpp delete mode 100644 boost/mpl/vector/aux_/tag.hpp delete mode 100644 boost/mpl/vector/aux_/vector0.hpp delete mode 100644 boost/mpl/vector/vector0.hpp delete mode 100644 boost/mpl/vector/vector0_c.hpp delete mode 100644 boost/mpl/vector/vector10.hpp delete mode 100644 boost/mpl/vector/vector10_c.hpp delete mode 100644 boost/mpl/vector/vector20.hpp delete mode 100644 boost/mpl/vector/vector20_c.hpp delete mode 100644 boost/mpl/vector/vector30.hpp delete mode 100644 boost/mpl/vector/vector30_c.hpp delete mode 100644 boost/mpl/vector/vector40.hpp delete mode 100644 boost/mpl/vector/vector40_c.hpp delete mode 100644 boost/mpl/vector/vector50.hpp delete mode 100644 boost/mpl/vector/vector50_c.hpp delete mode 100644 boost/mpl/vector_c.hpp delete mode 100644 boost/mpl/zip_view.hpp delete mode 100644 boost/multi_array.hpp delete mode 100644 boost/multi_index_container.hpp delete mode 100644 boost/multi_index_container_fwd.hpp delete mode 100644 boost/non_type.hpp delete mode 100644 boost/nondet_random.hpp delete mode 100644 boost/none.hpp delete mode 100644 boost/none_t.hpp delete mode 100644 boost/operators.hpp delete mode 100644 boost/optional.hpp delete mode 100755 boost/parameter.hpp delete mode 100644 boost/phoenix.hpp delete mode 100644 boost/pointee.hpp delete mode 100644 boost/pointer_cast.hpp delete mode 100644 boost/pointer_to_other.hpp delete mode 100644 boost/polymorphic_cast.hpp delete mode 100644 boost/predef.h delete mode 100644 boost/preprocessor.hpp delete mode 100644 boost/preprocessor/arithmetic.hpp delete mode 100644 boost/preprocessor/arithmetic/div.hpp delete mode 100644 boost/preprocessor/arithmetic/mul.hpp delete mode 100644 boost/preprocessor/array.hpp delete mode 100644 boost/preprocessor/array/detail/get_data.hpp delete mode 100644 boost/preprocessor/array/enum.hpp delete mode 100644 boost/preprocessor/array/insert.hpp delete mode 100644 boost/preprocessor/array/pop_back.hpp delete mode 100644 boost/preprocessor/array/pop_front.hpp delete mode 100644 boost/preprocessor/array/push_back.hpp delete mode 100644 boost/preprocessor/array/push_front.hpp delete mode 100644 boost/preprocessor/array/remove.hpp delete mode 100644 boost/preprocessor/array/replace.hpp delete mode 100644 boost/preprocessor/array/reverse.hpp delete mode 100644 boost/preprocessor/array/to_list.hpp delete mode 100644 boost/preprocessor/array/to_seq.hpp delete mode 100644 boost/preprocessor/array/to_tuple.hpp delete mode 100644 boost/preprocessor/assert_msg.hpp delete mode 100644 boost/preprocessor/comma.hpp delete mode 100644 boost/preprocessor/comparison.hpp delete mode 100644 boost/preprocessor/comparison/equal.hpp delete mode 100644 boost/preprocessor/comparison/greater.hpp delete mode 100644 boost/preprocessor/comparison/greater_equal.hpp delete mode 100644 boost/preprocessor/comparison/less.hpp delete mode 100644 boost/preprocessor/config/limits.hpp delete mode 100644 boost/preprocessor/control.hpp delete mode 100644 boost/preprocessor/debug.hpp delete mode 100644 boost/preprocessor/debug/assert.hpp delete mode 100644 boost/preprocessor/debug/line.hpp delete mode 100644 boost/preprocessor/detail/is_nullary.hpp delete mode 100644 boost/preprocessor/detail/is_unary.hpp delete mode 100644 boost/preprocessor/detail/null.hpp delete mode 100644 boost/preprocessor/enum.hpp delete mode 100644 boost/preprocessor/enum_params_with_a_default.hpp delete mode 100644 boost/preprocessor/enum_params_with_defaults.hpp delete mode 100644 boost/preprocessor/enum_shifted.hpp delete mode 100644 boost/preprocessor/expand.hpp delete mode 100644 boost/preprocessor/facilities.hpp delete mode 100644 boost/preprocessor/facilities/apply.hpp delete mode 100644 boost/preprocessor/facilities/intercept.hpp delete mode 100644 boost/preprocessor/facilities/is_empty_or_1.hpp delete mode 100644 boost/preprocessor/for.hpp delete mode 100644 boost/preprocessor/if.hpp delete mode 100644 boost/preprocessor/iteration.hpp delete mode 100644 boost/preprocessor/library.hpp delete mode 100644 boost/preprocessor/limits.hpp delete mode 100644 boost/preprocessor/list.hpp delete mode 100644 boost/preprocessor/list/append.hpp delete mode 100644 boost/preprocessor/list/at.hpp delete mode 100644 boost/preprocessor/list/cat.hpp delete mode 100644 boost/preprocessor/list/enum.hpp delete mode 100644 boost/preprocessor/list/filter.hpp delete mode 100644 boost/preprocessor/list/first_n.hpp delete mode 100644 boost/preprocessor/list/for_each.hpp delete mode 100644 boost/preprocessor/list/for_each_product.hpp delete mode 100644 boost/preprocessor/list/rest_n.hpp delete mode 100644 boost/preprocessor/list/size.hpp delete mode 100644 boost/preprocessor/list/to_array.hpp delete mode 100644 boost/preprocessor/list/to_seq.hpp delete mode 100644 boost/preprocessor/list/to_tuple.hpp delete mode 100644 boost/preprocessor/list/transform.hpp delete mode 100644 boost/preprocessor/logical.hpp delete mode 100644 boost/preprocessor/logical/bitnor.hpp delete mode 100644 boost/preprocessor/logical/bitor.hpp delete mode 100644 boost/preprocessor/logical/bitxor.hpp delete mode 100644 boost/preprocessor/logical/nor.hpp delete mode 100644 boost/preprocessor/logical/or.hpp delete mode 100644 boost/preprocessor/logical/xor.hpp delete mode 100644 boost/preprocessor/max.hpp delete mode 100644 boost/preprocessor/min.hpp delete mode 100644 boost/preprocessor/punctuation.hpp delete mode 100644 boost/preprocessor/punctuation/paren.hpp delete mode 100644 boost/preprocessor/punctuation/paren_if.hpp delete mode 100644 boost/preprocessor/punctuation/remove_parens.hpp delete mode 100644 boost/preprocessor/repeat_2nd.hpp delete mode 100644 boost/preprocessor/repeat_3rd.hpp delete mode 100644 boost/preprocessor/repeat_from_to.hpp delete mode 100644 boost/preprocessor/repeat_from_to_2nd.hpp delete mode 100644 boost/preprocessor/repeat_from_to_3rd.hpp delete mode 100644 boost/preprocessor/repetition.hpp delete mode 100644 boost/preprocessor/repetition/deduce_r.hpp delete mode 100644 boost/preprocessor/repetition/deduce_z.hpp delete mode 100644 boost/preprocessor/repetition/enum.hpp delete mode 100644 boost/preprocessor/repetition/enum_params_with_a_default.hpp delete mode 100644 boost/preprocessor/repetition/enum_params_with_defaults.hpp delete mode 100644 boost/preprocessor/repetition/enum_shifted.hpp delete mode 100644 boost/preprocessor/repetition/enum_shifted_binary_params.hpp delete mode 100644 boost/preprocessor/repetition/enum_trailing.hpp delete mode 100644 boost/preprocessor/repetition/enum_trailing_binary_params.hpp delete mode 100644 boost/preprocessor/selection.hpp delete mode 100644 boost/preprocessor/selection/max.hpp delete mode 100644 boost/preprocessor/selection/min.hpp delete mode 100644 boost/preprocessor/seq.hpp delete mode 100644 boost/preprocessor/seq/detail/binary_transform.hpp create mode 100644 boost/preprocessor/seq/detail/is_empty.hpp delete mode 100644 boost/preprocessor/seq/filter.hpp delete mode 100644 boost/preprocessor/seq/fold_right.hpp delete mode 100644 boost/preprocessor/seq/for_each.hpp delete mode 100644 boost/preprocessor/seq/for_each_product.hpp delete mode 100644 boost/preprocessor/seq/insert.hpp delete mode 100644 boost/preprocessor/seq/pop_back.hpp delete mode 100644 boost/preprocessor/seq/pop_front.hpp delete mode 100644 boost/preprocessor/seq/push_back.hpp delete mode 100644 boost/preprocessor/seq/push_front.hpp delete mode 100644 boost/preprocessor/seq/remove.hpp delete mode 100644 boost/preprocessor/seq/replace.hpp delete mode 100644 boost/preprocessor/seq/reverse.hpp delete mode 100644 boost/preprocessor/seq/to_array.hpp delete mode 100644 boost/preprocessor/seq/to_list.hpp delete mode 100644 boost/preprocessor/seq/to_tuple.hpp delete mode 100644 boost/preprocessor/seq/variadic_seq_to_seq.hpp delete mode 100644 boost/preprocessor/slot.hpp delete mode 100644 boost/preprocessor/slot/counter.hpp delete mode 100644 boost/preprocessor/tuple.hpp delete mode 100644 boost/preprocessor/tuple/enum.hpp delete mode 100644 boost/preprocessor/tuple/insert.hpp delete mode 100644 boost/preprocessor/tuple/pop_back.hpp delete mode 100644 boost/preprocessor/tuple/pop_front.hpp delete mode 100644 boost/preprocessor/tuple/push_back.hpp delete mode 100644 boost/preprocessor/tuple/push_front.hpp delete mode 100644 boost/preprocessor/tuple/remove.hpp delete mode 100644 boost/preprocessor/tuple/replace.hpp delete mode 100644 boost/preprocessor/tuple/reverse.hpp delete mode 100644 boost/preprocessor/tuple/to_array.hpp delete mode 100644 boost/preprocessor/tuple/to_seq.hpp delete mode 100644 boost/preprocessor/variadic.hpp delete mode 100644 boost/preprocessor/variadic/detail/is_single_return.hpp delete mode 100644 boost/preprocessor/variadic/to_array.hpp delete mode 100644 boost/preprocessor/variadic/to_list.hpp delete mode 100644 boost/preprocessor/variadic/to_seq.hpp delete mode 100644 boost/preprocessor/variadic/to_tuple.hpp delete mode 100644 boost/preprocessor/while.hpp delete mode 100644 boost/preprocessor/wstringize.hpp delete mode 100644 boost/program_options.hpp delete mode 100644 boost/progress.hpp delete mode 100644 boost/python.hpp delete mode 100644 boost/random.hpp delete mode 100644 boost/range.hpp delete mode 100644 boost/range/adaptor/adjacent_filtered.hpp delete mode 100644 boost/range/adaptor/argument_fwd.hpp delete mode 100644 boost/range/adaptor/copied.hpp delete mode 100644 boost/range/adaptor/define_adaptor.hpp delete mode 100644 boost/range/adaptor/filtered.hpp delete mode 100644 boost/range/adaptor/formatted.hpp delete mode 100644 boost/range/adaptor/indexed.hpp delete mode 100644 boost/range/adaptor/indirected.hpp delete mode 100644 boost/range/adaptor/map.hpp delete mode 100644 boost/range/adaptor/replaced.hpp delete mode 100644 boost/range/adaptor/replaced_if.hpp delete mode 100644 boost/range/adaptor/reversed.hpp delete mode 100644 boost/range/adaptor/sliced.hpp delete mode 100644 boost/range/adaptor/strided.hpp delete mode 100644 boost/range/adaptor/tokenized.hpp delete mode 100644 boost/range/adaptor/transformed.hpp delete mode 100644 boost/range/adaptor/type_erased.hpp delete mode 100644 boost/range/adaptor/uniqued.hpp delete mode 100644 boost/range/adaptors.hpp delete mode 100644 boost/range/algorithm.hpp delete mode 100644 boost/range/algorithm_ext.hpp delete mode 100644 boost/range/any_range.hpp delete mode 100644 boost/range/as_array.hpp delete mode 100644 boost/range/as_literal.hpp delete mode 100644 boost/range/atl.hpp delete mode 100644 boost/range/category.hpp delete mode 100644 boost/range/combine.hpp delete mode 100644 boost/range/const_reverse_iterator.hpp delete mode 100644 boost/range/counting_range.hpp delete mode 100644 boost/range/detail/any_iterator.hpp delete mode 100644 boost/range/detail/any_iterator_buffer.hpp delete mode 100644 boost/range/detail/any_iterator_interface.hpp delete mode 100644 boost/range/detail/any_iterator_wrapper.hpp delete mode 100644 boost/range/detail/as_literal.hpp delete mode 100644 boost/range/detail/collection_traits.hpp delete mode 100644 boost/range/detail/collection_traits_detail.hpp delete mode 100644 boost/range/detail/combine_cxx03.hpp delete mode 100644 boost/range/detail/combine_cxx11.hpp delete mode 100644 boost/range/detail/combine_no_rvalue.hpp delete mode 100644 boost/range/detail/combine_rvalue.hpp delete mode 100644 boost/range/detail/default_constructible_unary_fn.hpp delete mode 100644 boost/range/detail/demote_iterator_traversal_tag.hpp delete mode 100644 boost/range/detail/detail_str.hpp delete mode 100644 boost/range/detail/difference_type.hpp delete mode 100644 boost/range/detail/empty.hpp delete mode 100644 boost/range/detail/join_iterator.hpp delete mode 100644 boost/range/detail/microsoft.hpp delete mode 100644 boost/range/detail/remove_extent.hpp delete mode 100644 boost/range/detail/size_type.hpp delete mode 100644 boost/range/detail/sizer.hpp delete mode 100644 boost/range/detail/str_types.hpp delete mode 100644 boost/range/detail/value_type.hpp delete mode 100644 boost/range/irange.hpp delete mode 100644 boost/range/istream_range.hpp delete mode 100644 boost/range/iterator_range_hash.hpp delete mode 100644 boost/range/join.hpp delete mode 100644 boost/range/metafunctions.hpp delete mode 100644 boost/range/mfc.hpp delete mode 100644 boost/range/mfc_map.hpp delete mode 100644 boost/range/numeric.hpp delete mode 100644 boost/range/pointer.hpp delete mode 100644 boost/range/reference.hpp delete mode 100644 boost/range/result_iterator.hpp delete mode 100644 boost/range/reverse_result_iterator.hpp delete mode 100644 boost/range/sub_range.hpp delete mode 100644 boost/range/traversal.hpp delete mode 100644 boost/ratio.hpp delete mode 100644 boost/rational.hpp delete mode 100644 boost/regex.h delete mode 100644 boost/regex.hpp delete mode 100644 boost/regex_fwd.hpp delete mode 100644 boost/scope_exit.hpp delete mode 100644 boost/scoped_array.hpp delete mode 100644 boost/scoped_ptr.hpp delete mode 100644 boost/shared_array.hpp delete mode 100644 boost/shared_container_iterator.hpp delete mode 100644 boost/shared_ptr.hpp delete mode 100644 boost/signal.hpp delete mode 100644 boost/signals.hpp delete mode 100644 boost/signals2.hpp delete mode 100644 boost/smart_ptr.hpp delete mode 100644 boost/spirit.hpp delete mode 100644 boost/strong_typedef.hpp delete mode 100644 boost/swap.hpp delete mode 100644 boost/thread.hpp delete mode 100644 boost/throw_exception.hpp delete mode 100644 boost/timer.hpp delete mode 100644 boost/token_functions.hpp delete mode 100644 boost/token_iterator.hpp delete mode 100644 boost/tokenizer.hpp delete mode 100644 boost/type.hpp delete mode 100644 boost/type_index.hpp delete mode 100644 boost/type_traits.hpp delete mode 100644 boost/type_traits/add_cv.hpp delete mode 100755 boost/type_traits/aligned_storage.hpp delete mode 100644 boost/type_traits/alignment_of.hpp delete mode 100644 boost/type_traits/alignment_traits.hpp delete mode 100644 boost/type_traits/arithmetic_traits.hpp delete mode 100644 boost/type_traits/array_traits.hpp delete mode 100644 boost/type_traits/broken_compiler_spec.hpp delete mode 100644 boost/type_traits/common_type.hpp delete mode 100644 boost/type_traits/composite_traits.hpp delete mode 100644 boost/type_traits/conditional.hpp delete mode 100644 boost/type_traits/cv_traits.hpp delete mode 100755 boost/type_traits/decay.hpp delete mode 100644 boost/type_traits/detail/common_type_imp.hpp delete mode 100644 boost/type_traits/detail/has_postfix_operator.hpp delete mode 100644 boost/type_traits/detail/has_prefix_operator.hpp delete mode 100644 boost/type_traits/detail/size_t_trait_def.hpp delete mode 100644 boost/type_traits/detail/size_t_trait_undef.hpp delete mode 100644 boost/type_traits/detail/wrap.hpp delete mode 100644 boost/type_traits/extent.hpp delete mode 100644 boost/type_traits/floating_point_promotion.hpp delete mode 100644 boost/type_traits/has_bit_and.hpp delete mode 100644 boost/type_traits/has_bit_and_assign.hpp delete mode 100644 boost/type_traits/has_bit_or.hpp delete mode 100644 boost/type_traits/has_bit_or_assign.hpp delete mode 100644 boost/type_traits/has_bit_xor.hpp delete mode 100644 boost/type_traits/has_bit_xor_assign.hpp delete mode 100644 boost/type_traits/has_complement.hpp delete mode 100644 boost/type_traits/has_dereference.hpp delete mode 100644 boost/type_traits/has_divides.hpp delete mode 100644 boost/type_traits/has_divides_assign.hpp delete mode 100644 boost/type_traits/has_equal_to.hpp delete mode 100644 boost/type_traits/has_greater.hpp delete mode 100644 boost/type_traits/has_greater_equal.hpp delete mode 100644 boost/type_traits/has_left_shift.hpp delete mode 100644 boost/type_traits/has_left_shift_assign.hpp delete mode 100644 boost/type_traits/has_less.hpp delete mode 100644 boost/type_traits/has_less_equal.hpp delete mode 100644 boost/type_traits/has_logical_and.hpp delete mode 100644 boost/type_traits/has_logical_not.hpp delete mode 100644 boost/type_traits/has_logical_or.hpp delete mode 100644 boost/type_traits/has_modulus.hpp delete mode 100644 boost/type_traits/has_modulus_assign.hpp delete mode 100644 boost/type_traits/has_multiplies.hpp delete mode 100644 boost/type_traits/has_multiplies_assign.hpp delete mode 100644 boost/type_traits/has_negate.hpp delete mode 100644 boost/type_traits/has_new_operator.hpp delete mode 100644 boost/type_traits/has_not_equal_to.hpp delete mode 100644 boost/type_traits/has_nothrow_assign.hpp delete mode 100644 boost/type_traits/has_nothrow_constructor.hpp delete mode 100644 boost/type_traits/has_nothrow_copy.hpp delete mode 100644 boost/type_traits/has_nothrow_destructor.hpp delete mode 100644 boost/type_traits/has_operator.hpp delete mode 100644 boost/type_traits/has_post_decrement.hpp delete mode 100644 boost/type_traits/has_post_increment.hpp delete mode 100644 boost/type_traits/has_pre_decrement.hpp delete mode 100644 boost/type_traits/has_pre_increment.hpp delete mode 100644 boost/type_traits/has_right_shift.hpp delete mode 100644 boost/type_traits/has_right_shift_assign.hpp delete mode 100644 boost/type_traits/has_trivial_assign.hpp delete mode 100644 boost/type_traits/has_trivial_constructor.hpp delete mode 100644 boost/type_traits/has_trivial_copy.hpp delete mode 100644 boost/type_traits/has_trivial_destructor.hpp delete mode 100644 boost/type_traits/has_trivial_move_assign.hpp delete mode 100644 boost/type_traits/has_trivial_move_constructor.hpp delete mode 100644 boost/type_traits/has_unary_minus.hpp delete mode 100644 boost/type_traits/has_unary_plus.hpp delete mode 100644 boost/type_traits/has_virtual_destructor.hpp delete mode 100644 boost/type_traits/is_base_of_tr1.hpp delete mode 100644 boost/type_traits/is_complex.hpp delete mode 100644 boost/type_traits/is_compound.hpp delete mode 100644 boost/type_traits/is_copy_assignable.hpp delete mode 100644 boost/type_traits/is_copy_constructible.hpp delete mode 100644 boost/type_traits/is_empty.hpp delete mode 100644 boost/type_traits/is_final.hpp delete mode 100755 boost/type_traits/is_floating_point.hpp delete mode 100755 boost/type_traits/is_member_object_pointer.hpp delete mode 100644 boost/type_traits/is_nothrow_move_assignable.hpp delete mode 100644 boost/type_traits/is_nothrow_move_constructible.hpp delete mode 100644 boost/type_traits/is_object.hpp delete mode 100644 boost/type_traits/is_stateless.hpp delete mode 100644 boost/type_traits/is_virtual_base_of.hpp delete mode 100644 boost/type_traits/object_traits.hpp delete mode 100644 boost/type_traits/promote.hpp delete mode 100644 boost/type_traits/rank.hpp delete mode 100644 boost/type_traits/reference_traits.hpp delete mode 100644 boost/type_traits/remove_all_extents.hpp delete mode 100644 boost/type_traits/remove_extent.hpp delete mode 100644 boost/type_traits/remove_volatile.hpp delete mode 100644 boost/type_traits/same_traits.hpp delete mode 100644 boost/type_traits/transform_traits.hpp delete mode 100644 boost/type_traits/transform_traits_spec.hpp delete mode 100644 boost/type_traits/type_with_alignment.hpp delete mode 100644 boost/unordered_map.hpp delete mode 100644 boost/unordered_set.hpp delete mode 100644 boost/utility/compare_pointees.hpp delete mode 100644 boost/utility/detail/in_place_factory_prefix.hpp delete mode 100644 boost/utility/detail/in_place_factory_suffix.hpp delete mode 100644 boost/utility/detail/result_of_iterate.hpp delete mode 100644 boost/utility/empty_deleter.hpp delete mode 100644 boost/utility/explicit_operator_bool.hpp delete mode 100644 boost/utility/in_place_factory.hpp delete mode 100644 boost/utility/result_of.hpp delete mode 100644 boost/utility/string_ref.hpp delete mode 100644 boost/utility/string_ref_fwd.hpp delete mode 100644 boost/utility/swap.hpp delete mode 100644 boost/utility/typed_in_place_factory.hpp delete mode 100644 boost/utility/value_init.hpp delete mode 100644 boost/variant.hpp delete mode 100644 boost/visit_each.hpp delete mode 100644 boost/wave.hpp delete mode 100644 boost/weak_ptr.hpp diff --git a/Readme.md b/Readme.md index 121b02a..4b507ef 100644 --- a/Readme.md +++ b/Readme.md @@ -1,22 +1,4 @@ Boost libraries - trimmed down for Citra ======================================== -This is a subset of Boost v1.57.0. - -Currently imported libraries: ------------------------------ -* concept -* config -* container -* core -* intrusive -* iterator -* move -* mpl -* preprocessor -* range -* smart_ptr (`intrusive_ptr` only) -* type_traits -* utility - -Additionally, all global boost headers are available, but not guaranteed to work unless their dependencies are included in any of the libraries mentioned above. +This is a subset of Boost v1.59.0 generated using the bcp tool. To get a list of boost modules guaranteed to exist, check the build script. diff --git a/boost/align.hpp b/boost/align.hpp deleted file mode 100644 index d5ae6d3..0000000 --- a/boost/align.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - (c) 2014 Glen Joseph Fernandes - glenjofe at gmail dot com - - Distributed under the Boost Software - License, Version 1.0. - http://boost.org/LICENSE_1_0.txt -*/ -#ifndef BOOST_ALIGN_HPP -#define BOOST_ALIGN_HPP - -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/boost/aligned_storage.hpp b/boost/aligned_storage.hpp deleted file mode 100644 index b5455f0..0000000 --- a/boost/aligned_storage.hpp +++ /dev/null @@ -1,143 +0,0 @@ -//----------------------------------------------------------------------------- -// boost aligned_storage.hpp header file -// See http://www.boost.org for updates, documentation, and revision history. -//----------------------------------------------------------------------------- -// -// Copyright (c) 2002-2003 -// Eric Friedman, Itay Maman -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_ALIGNED_STORAGE_HPP -#define BOOST_ALIGNED_STORAGE_HPP - -#include // for std::size_t - -#include "boost/config.hpp" -#include "boost/detail/workaround.hpp" -#include "boost/type_traits/alignment_of.hpp" -#include "boost/type_traits/type_with_alignment.hpp" -#include "boost/type_traits/is_pod.hpp" - -#include "boost/mpl/eval_if.hpp" -#include "boost/mpl/identity.hpp" - -#include "boost/type_traits/detail/bool_trait_def.hpp" - -namespace boost { - -namespace detail { namespace aligned_storage { - -BOOST_STATIC_CONSTANT( - std::size_t - , alignment_of_max_align = ::boost::alignment_of::value - ); - -// -// To be TR1 conforming this must be a POD type: -// -template < - std::size_t size_ - , std::size_t alignment_ -> -struct aligned_storage_imp -{ - union data_t - { - char buf[size_]; - - typename ::boost::mpl::eval_if_c< - alignment_ == std::size_t(-1) - , ::boost::mpl::identity< ::boost::detail::max_align > - , ::boost::type_with_alignment - >::type align_; - } data_; - void* address() const { return const_cast(this); } -}; - -template< std::size_t alignment_ > -struct aligned_storage_imp<0u,alignment_> -{ - /* intentionally empty */ - void* address() const { return 0; } -}; - -}} // namespace detail::aligned_storage - -template < - std::size_t size_ - , std::size_t alignment_ = std::size_t(-1) -> -class aligned_storage : -#ifndef __BORLANDC__ - private -#else - public -#endif - ::boost::detail::aligned_storage::aligned_storage_imp -{ - -public: // constants - - typedef ::boost::detail::aligned_storage::aligned_storage_imp type; - - BOOST_STATIC_CONSTANT( - std::size_t - , size = size_ - ); - BOOST_STATIC_CONSTANT( - std::size_t - , alignment = ( - alignment_ == std::size_t(-1) - ? ::boost::detail::aligned_storage::alignment_of_max_align - : alignment_ - ) - ); - -private: // noncopyable - - aligned_storage(const aligned_storage&); - aligned_storage& operator=(const aligned_storage&); - -public: // structors - - aligned_storage() - { - } - - ~aligned_storage() - { - } - -public: // accessors - - void* address() - { - return static_cast(this)->address(); - } - - const void* address() const - { - return static_cast(this)->address(); - } -}; - -// -// Make sure that is_pod recognises aligned_storage<>::type -// as a POD (Note that aligned_storage<> itself is not a POD): -// -template -struct is_pod< ::boost::detail::aligned_storage::aligned_storage_imp > - BOOST_TT_AUX_BOOL_C_BASE(true) -{ - BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true) -}; - - -} // namespace boost - -#include "boost/type_traits/detail/bool_trait_undef.hpp" - -#endif // BOOST_ALIGNED_STORAGE_HPP diff --git a/boost/any.hpp b/boost/any.hpp deleted file mode 100644 index 580b5b4..0000000 --- a/boost/any.hpp +++ /dev/null @@ -1,324 +0,0 @@ -// See http://www.boost.org/libs/any for Documentation. - -#ifndef BOOST_ANY_INCLUDED -#define BOOST_ANY_INCLUDED - -#if defined(_MSC_VER) -# pragma once -#endif - -// what: variant type boost::any -// who: contributed by Kevlin Henney, -// with features contributed and bugs found by -// Antony Polukhin, Ed Brey, Mark Rodgers, -// Peter Dimov, and James Curran -// when: July 2001, April 2013 - May 2013 - -#include - -#include "boost/config.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost -{ - class any - { - public: // structors - - any() BOOST_NOEXCEPT - : content(0) - { - } - - template - any(const ValueType & value) - : content(new holder< - BOOST_DEDUCED_TYPENAME remove_cv::type>::type - >(value)) - { - } - - any(const any & other) - : content(other.content ? other.content->clone() : 0) - { - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - // Move constructor - any(any&& other) BOOST_NOEXCEPT - : content(other.content) - { - other.content = 0; - } - - // Perfect forwarding of ValueType - template - any(ValueType&& value - , typename boost::disable_if >::type* = 0 // disable if value has type `any&` - , typename boost::disable_if >::type* = 0) // disable if value has type `const ValueType&&` - : content(new holder< typename decay::type >(static_cast(value))) - { - } -#endif - - ~any() BOOST_NOEXCEPT - { - delete content; - } - - public: // modifiers - - any & swap(any & rhs) BOOST_NOEXCEPT - { - std::swap(content, rhs.content); - return *this; - } - - -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - template - any & operator=(const ValueType & rhs) - { - any(rhs).swap(*this); - return *this; - } - - any & operator=(any rhs) - { - any(rhs).swap(*this); - return *this; - } - -#else - any & operator=(const any& rhs) - { - any(rhs).swap(*this); - return *this; - } - - // move assignement - any & operator=(any&& rhs) BOOST_NOEXCEPT - { - rhs.swap(*this); - any().swap(rhs); - return *this; - } - - // Perfect forwarding of ValueType - template - any & operator=(ValueType&& rhs) - { - any(static_cast(rhs)).swap(*this); - return *this; - } -#endif - - public: // queries - - bool empty() const BOOST_NOEXCEPT - { - return !content; - } - - void clear() BOOST_NOEXCEPT - { - any().swap(*this); - } - - const boost::typeindex::type_info& type() const BOOST_NOEXCEPT - { - return content ? content->type() : boost::typeindex::type_id().type_info(); - } - -#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - private: // types -#else - public: // types (public so any_cast can be non-friend) -#endif - - class placeholder - { - public: // structors - - virtual ~placeholder() - { - } - - public: // queries - - virtual const boost::typeindex::type_info& type() const BOOST_NOEXCEPT = 0; - - virtual placeholder * clone() const = 0; - - }; - - template - class holder : public placeholder - { - public: // structors - - holder(const ValueType & value) - : held(value) - { - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - holder(ValueType&& value) - : held(static_cast< ValueType&& >(value)) - { - } -#endif - public: // queries - - virtual const boost::typeindex::type_info& type() const BOOST_NOEXCEPT - { - return boost::typeindex::type_id().type_info(); - } - - virtual placeholder * clone() const - { - return new holder(held); - } - - public: // representation - - ValueType held; - - private: // intentionally left unimplemented - holder & operator=(const holder &); - }; - -#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - - private: // representation - - template - friend ValueType * any_cast(any *) BOOST_NOEXCEPT; - - template - friend ValueType * unsafe_any_cast(any *) BOOST_NOEXCEPT; - -#else - - public: // representation (public so any_cast can be non-friend) - -#endif - - placeholder * content; - - }; - - inline void swap(any & lhs, any & rhs) BOOST_NOEXCEPT - { - lhs.swap(rhs); - } - - class BOOST_SYMBOL_VISIBLE bad_any_cast : -#ifndef BOOST_NO_RTTI - public std::bad_cast -#else - public std::exception -#endif - { - public: - virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW - { - return "boost::bad_any_cast: " - "failed conversion using boost::any_cast"; - } - }; - - template - ValueType * any_cast(any * operand) BOOST_NOEXCEPT - { - return operand && operand->type() == boost::typeindex::type_id() - ? &static_cast::type> *>(operand->content)->held - : 0; - } - - template - inline const ValueType * any_cast(const any * operand) BOOST_NOEXCEPT - { - return any_cast(const_cast(operand)); - } - - template - ValueType any_cast(any & operand) - { - typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; - - - nonref * result = any_cast(&operand); - if(!result) - boost::throw_exception(bad_any_cast()); - - // Attempt to avoid construction of a temporary object in cases when - // `ValueType` is not a reference. Example: - // `static_cast(*result);` - // which is equal to `std::string(*result);` - typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_< - boost::is_reference, - ValueType, - BOOST_DEDUCED_TYPENAME boost::add_reference::type - >::type ref_type; - - return static_cast(*result); - } - - template - inline ValueType any_cast(const any & operand) - { - typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; - return any_cast(const_cast(operand)); - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template - inline ValueType any_cast(any&& operand) - { - BOOST_STATIC_ASSERT_MSG( - boost::is_rvalue_reference::value /*true if ValueType is rvalue or just a value*/ - || boost::is_const< typename boost::remove_reference::type >::value, - "boost::any_cast shall not be used for getting nonconst references to temporary objects" - ); - return any_cast(operand); - } -#endif - - - // Note: The "unsafe" versions of any_cast are not part of the - // public interface and may be removed at any time. They are - // required where we know what type is stored in the any and can't - // use typeid() comparison, e.g., when our types may travel across - // different shared libraries. - template - inline ValueType * unsafe_any_cast(any * operand) BOOST_NOEXCEPT - { - return &static_cast *>(operand->content)->held; - } - - template - inline const ValueType * unsafe_any_cast(const any * operand) BOOST_NOEXCEPT - { - return unsafe_any_cast(const_cast(operand)); - } -} - -// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#endif diff --git a/boost/array.hpp b/boost/array.hpp deleted file mode 100644 index fa06fa9..0000000 --- a/boost/array.hpp +++ /dev/null @@ -1,446 +0,0 @@ -/* The following code declares class array, - * an STL container (as wrapper) for arrays of constant size. - * - * See - * http://www.boost.org/libs/array/ - * for documentation. - * - * The original author site is at: http://www.josuttis.com/ - * - * (C) Copyright Nicolai M. Josuttis 2001. - * - * Distributed under the 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 Apr 2012 - (mtc) Added support for boost::hash - * 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility. - * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group. - * See or Trac issue #3168 - * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow) - * 10 Mar 2010 - added workaround for SUNCC and !STLPort [trac #3893] (Marshall Clow) - * 29 Jan 2004 - c_array() added, BOOST_NO_PRIVATE_IN_AGGREGATE removed (Nico Josuttis) - * 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries. - * 05 Aug 2001 - minor update (Nico Josuttis) - * 20 Jan 2001 - STLport fix (Beman Dawes) - * 29 Sep 2000 - Initial Revision (Nico Josuttis) - * - * Jan 29, 2004 - */ -#ifndef BOOST_ARRAY_HPP -#define BOOST_ARRAY_HPP - -#include - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -# pragma warning(push) -# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe -# pragma warning(disable:4510) // boost::array' : default constructor could not be generated -# pragma warning(disable:4610) // warning C4610: class 'boost::array' can never be instantiated - user defined constructor required -#endif - -#include -#include -#include -#include - -// Handles broken standard libraries better than -#include -#include -#include -#include - -// FIXES for broken compilers -#include - - -namespace boost { - - template - class array { - public: - T elems[N]; // fixed-size array of elements of type T - - public: - // type definitions - typedef T value_type; - typedef T* iterator; - typedef const T* const_iterator; - typedef T& reference; - typedef const T& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - // iterator support - iterator begin() { return elems; } - const_iterator begin() const { return elems; } - const_iterator cbegin() const { return elems; } - - iterator end() { return elems+N; } - const_iterator end() const { return elems+N; } - const_iterator cend() const { return elems+N; } - - // reverse iterator support -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; -#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310) - // workaround for broken reverse_iterator in VC7 - typedef std::reverse_iterator > reverse_iterator; - typedef std::reverse_iterator > const_reverse_iterator; -#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; -#else - // workaround for broken reverse_iterator implementations - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; -#endif - - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - const_reverse_iterator crbegin() const { - return const_reverse_iterator(end()); - } - - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - const_reverse_iterator crend() const { - return const_reverse_iterator(begin()); - } - - // operator[] - reference operator[](size_type i) - { - BOOST_ASSERT_MSG( i < N, "out of range" ); - return elems[i]; - } - - const_reference operator[](size_type i) const - { - BOOST_ASSERT_MSG( i < N, "out of range" ); - return elems[i]; - } - - // at() with range check - reference at(size_type i) { rangecheck(i); return elems[i]; } - const_reference at(size_type i) const { rangecheck(i); return elems[i]; } - - // front() and back() - reference front() - { - return elems[0]; - } - - const_reference front() const - { - return elems[0]; - } - - reference back() - { - return elems[N-1]; - } - - const_reference back() const - { - return elems[N-1]; - } - - // size is constant - static size_type size() { return N; } - static bool empty() { return false; } - static size_type max_size() { return N; } - enum { static_size = N }; - - // swap (note: linear complexity) - void swap (array& y) { - for (size_type i = 0; i < N; ++i) - boost::swap(elems[i],y.elems[i]); - } - - // direct access to data (read-only) - const T* data() const { return elems; } - T* data() { return elems; } - - // use array as C array (direct read/write access to data) - T* c_array() { return elems; } - - // assignment with type conversion - template - array& operator= (const array& rhs) { - std::copy(rhs.begin(),rhs.end(), begin()); - return *this; - } - - // assign one value to all elements - void assign (const T& value) { fill ( value ); } // A synonym for fill - void fill (const T& value) - { - std::fill_n(begin(),size(),value); - } - - // check range (may be private because it is static) - static void rangecheck (size_type i) { - if (i >= size()) { - std::out_of_range e("array<>: index out of range"); - boost::throw_exception(e); - } - } - - }; - -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - template< class T > - class array< T, 0 > { - - public: - // type definitions - typedef T value_type; - typedef T* iterator; - typedef const T* const_iterator; - typedef T& reference; - typedef const T& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - // iterator support - iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); } - const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } - const_iterator cbegin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } - - iterator end() { return begin(); } - const_iterator end() const { return begin(); } - const_iterator cend() const { return cbegin(); } - - // reverse iterator support -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; -#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310) - // workaround for broken reverse_iterator in VC7 - typedef std::reverse_iterator > reverse_iterator; - typedef std::reverse_iterator > const_reverse_iterator; -#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; -#else - // workaround for broken reverse_iterator implementations - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; -#endif - - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - const_reverse_iterator crbegin() const { - return const_reverse_iterator(end()); - } - - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - const_reverse_iterator crend() const { - return const_reverse_iterator(begin()); - } - - // operator[] - reference operator[](size_type /*i*/) - { - return failed_rangecheck(); - } - - const_reference operator[](size_type /*i*/) const - { - return failed_rangecheck(); - } - - // at() with range check - reference at(size_type /*i*/) { return failed_rangecheck(); } - const_reference at(size_type /*i*/) const { return failed_rangecheck(); } - - // front() and back() - reference front() - { - return failed_rangecheck(); - } - - const_reference front() const - { - return failed_rangecheck(); - } - - reference back() - { - return failed_rangecheck(); - } - - const_reference back() const - { - return failed_rangecheck(); - } - - // size is constant - static size_type size() { return 0; } - static bool empty() { return true; } - static size_type max_size() { return 0; } - enum { static_size = 0 }; - - void swap (array& /*y*/) { - } - - // direct access to data (read-only) - const T* data() const { return 0; } - T* data() { return 0; } - - // use array as C array (direct read/write access to data) - T* c_array() { return 0; } - - // assignment with type conversion - template - array& operator= (const array& ) { - return *this; - } - - // assign one value to all elements - void assign (const T& value) { fill ( value ); } - void fill (const T& ) {} - - // check range (may be private because it is static) - static reference failed_rangecheck () { - std::out_of_range e("attempt to access element of an empty array"); - boost::throw_exception(e); -#if defined(BOOST_NO_EXCEPTIONS) || (!defined(BOOST_MSVC) && !defined(__PATHSCALE__)) - // - // We need to return something here to keep - // some compilers happy: however we will never - // actually get here.... - // - static T placeholder; - return placeholder; -#endif - } - }; -#endif - - // comparisons - template - bool operator== (const array& x, const array& y) { - return std::equal(x.begin(), x.end(), y.begin()); - } - template - bool operator< (const array& x, const array& y) { - return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); - } - template - bool operator!= (const array& x, const array& y) { - return !(x==y); - } - template - bool operator> (const array& x, const array& y) { - return y - bool operator<= (const array& x, const array& y) { - return !(y - bool operator>= (const array& x, const array& y) { - return !(x - inline void swap (array& x, array& y) { - x.swap(y); - } - -#if defined(__SUNPRO_CC) -// Trac ticket #4757; the Sun Solaris compiler can't handle -// syntax like 'T(&get_c_array(boost::array& arg))[N]' -// -// We can't just use this for all compilers, because the -// borland compilers can't handle this form. - namespace detail { - template struct c_array - { - typedef T type[N]; - }; - } - - // Specific for boost::array: simply returns its elems data member. - template - typename detail::c_array::type& get_c_array(boost::array& arg) - { - return arg.elems; - } - - // Specific for boost::array: simply returns its elems data member. - template - typename const detail::c_array::type& get_c_array(const boost::array& arg) - { - return arg.elems; - } -#else -// Specific for boost::array: simply returns its elems data member. - template - T(&get_c_array(boost::array& arg))[N] - { - return arg.elems; - } - - // Const version. - template - const T(&get_c_array(const boost::array& arg))[N] - { - return arg.elems; - } -#endif - -#if 0 - // Overload for std::array, assuming that std::array will have - // explicit conversion functions as discussed at the WG21 meeting - // in Summit, March 2009. - template - T(&get_c_array(std::array& arg))[N] - { - return static_cast(arg); - } - - // Const version. - template - const T(&get_c_array(const std::array& arg))[N] - { - return static_cast(arg); - } -#endif - - - template - std::size_t hash_value(const array& arr) - { - return boost::hash_range(arr.begin(), arr.end()); - } - -} /* namespace boost */ - - -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -# pragma warning(pop) -#endif - -#endif /*BOOST_ARRAY_HPP*/ diff --git a/boost/asio.hpp b/boost/asio.hpp deleted file mode 100644 index 871fcbe..0000000 --- a/boost/asio.hpp +++ /dev/null @@ -1,121 +0,0 @@ -// -// asio.hpp -// ~~~~~~~~ -// -// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the 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 www.boost.org/libs/asio for documentation. -// - -#ifndef BOOST_ASIO_HPP -#define BOOST_ASIO_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // BOOST_ASIO_HPP diff --git a/boost/assign.hpp b/boost/assign.hpp deleted file mode 100644 index fffb7ec..0000000 --- a/boost/assign.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Boost.Assign library -// -// Copyright Thorsten Ottosen 2003-2004. Use, modification and -// distribution is 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) -// -// For more information, see http://www.boost.org/libs/assign/ -// - - -#ifndef BOOST_ASSIGN_HPP -#define BOOST_ASSIGN_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include - -#endif diff --git a/boost/atomic.hpp b/boost/atomic.hpp deleted file mode 100644 index cc28b1a..0000000 --- a/boost/atomic.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef BOOST_ATOMIC_HPP -#define BOOST_ATOMIC_HPP - -// Copyright (c) 2011 Helge Bahmann -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// This header includes all Boost.Atomic public headers - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -#endif diff --git a/boost/bimap.hpp b/boost/bimap.hpp deleted file mode 100644 index 51d726d..0000000 --- a/boost/bimap.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Boost.Bimap -// -// Copyright (c) 2006-2007 Matias Capeletto -// -// Distributed under the 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 www.boost.org/libs/bimap for documentation. - -// Convenience header - -#include - -namespace boost -{ - using ::boost::bimaps::bimap; -} - diff --git a/boost/bind.hpp b/boost/bind.hpp deleted file mode 100644 index fd3421e..0000000 --- a/boost/bind.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef BOOST_BIND_HPP_INCLUDED -#define BOOST_BIND_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// -// bind.hpp - binds function objects to arguments -// -// Copyright (c) 2009 Peter Dimov -// -// Distributed under the 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/bind/bind.html for documentation. -// - -#include - -#endif // #ifndef BOOST_BIND_HPP_INCLUDED diff --git a/boost/blank.hpp b/boost/blank.hpp deleted file mode 100644 index d0fe5ab..0000000 --- a/boost/blank.hpp +++ /dev/null @@ -1,106 +0,0 @@ -//----------------------------------------------------------------------------- -// boost blank.hpp header file -// See http://www.boost.org for updates, documentation, and revision history. -//----------------------------------------------------------------------------- -// -// Copyright (c) 2003 -// Eric Friedman -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_BLANK_HPP -#define BOOST_BLANK_HPP - -#include "boost/blank_fwd.hpp" - -#if !defined(BOOST_NO_IOSTREAM) -#include // for std::basic_ostream forward declare -#include "boost/detail/templated_streams.hpp" -#endif // BOOST_NO_IOSTREAM - -#include "boost/mpl/bool.hpp" -#include "boost/type_traits/is_empty.hpp" -#include "boost/type_traits/is_pod.hpp" -#include "boost/type_traits/is_stateless.hpp" - -namespace boost { - -struct blank -{ -}; - -// type traits specializations -// - -template <> -struct is_pod< blank > - : mpl::true_ -{ -}; - -template <> -struct is_empty< blank > - : mpl::true_ -{ -}; - -template <> -struct is_stateless< blank > - : mpl::true_ -{ -}; - -// relational operators -// - -inline bool operator==(const blank&, const blank&) -{ - return true; -} - -inline bool operator<=(const blank&, const blank&) -{ - return true; -} - -inline bool operator>=(const blank&, const blank&) -{ - return true; -} - -inline bool operator!=(const blank&, const blank&) -{ - return false; -} - -inline bool operator<(const blank&, const blank&) -{ - return false; -} - -inline bool operator>(const blank&, const blank&) -{ - return false; -} - -// streaming support -// -#if !defined(BOOST_NO_IOSTREAM) - -BOOST_TEMPLATED_STREAM_TEMPLATE(E,T) -inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<( - BOOST_TEMPLATED_STREAM(ostream, E,T)& out - , const blank& - ) -{ - // (output nothing) - return out; -} - -#endif // BOOST_NO_IOSTREAM - -} // namespace boost - -#endif // BOOST_BLANK_HPP diff --git a/boost/blank_fwd.hpp b/boost/blank_fwd.hpp deleted file mode 100644 index 8bfe97c..0000000 --- a/boost/blank_fwd.hpp +++ /dev/null @@ -1,22 +0,0 @@ -//----------------------------------------------------------------------------- -// boost blank_fwd.hpp header file -// See http://www.boost.org for updates, documentation, and revision history. -//----------------------------------------------------------------------------- -// -// Copyright (c) 2003 -// Eric Friedman -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_BLANK_FWD_HPP -#define BOOST_BLANK_FWD_HPP - -namespace boost { - -struct blank; - -} // namespace boost - -#endif // BOOST_BLANK_FWD_HPP diff --git a/boost/call_traits.hpp b/boost/call_traits.hpp deleted file mode 100644 index 2c1328e..0000000 --- a/boost/call_traits.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000. -// 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). -// -// See http://www.boost.org/libs/utility for most recent version including documentation. - -// See boost/detail/call_traits.hpp -// for full copyright notices. - -#ifndef BOOST_CALL_TRAITS_HPP -#define BOOST_CALL_TRAITS_HPP - -#ifndef BOOST_CONFIG_HPP -#include -#endif - -#include - -#endif // BOOST_CALL_TRAITS_HPP diff --git a/boost/cast.hpp b/boost/cast.hpp deleted file mode 100644 index ab452bd..0000000 --- a/boost/cast.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// boost cast.hpp header file -// -// (C) Copyright Antony Polukhin 2014. -// -// Distributed under the 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/conversion for Documentation. - -// This is a DEPRECATED header file! -// Use or instead - -#ifndef BOOST_CAST_HPP -#define BOOST_CAST_HPP - -# include -# include - -#endif // BOOST_CAST_HPP diff --git a/boost/cerrno.hpp b/boost/cerrno.hpp deleted file mode 100644 index 6f26698..0000000 --- a/boost/cerrno.hpp +++ /dev/null @@ -1,331 +0,0 @@ -// Boost cerrno.hpp header -------------------------------------------------// - -// Copyright Beman Dawes 2005. -// Use, modification, and distribution is 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) - -// See library home page at http://www.boost.org/libs/system - -#ifndef BOOST_CERRNO_HPP -#define BOOST_CERRNO_HPP - -#include - -// supply errno values likely to be missing, particularly on Windows - -#ifndef EAFNOSUPPORT -#define EAFNOSUPPORT 9901 -#endif - -#ifndef EADDRINUSE -#define EADDRINUSE 9902 -#endif - -#ifndef EADDRNOTAVAIL -#define EADDRNOTAVAIL 9903 -#endif - -#ifndef EISCONN -#define EISCONN 9904 -#endif - -#ifndef EBADMSG -#define EBADMSG 9905 -#endif - -#ifndef ECONNABORTED -#define ECONNABORTED 9906 -#endif - -#ifndef EALREADY -#define EALREADY 9907 -#endif - -#ifndef ECONNREFUSED -#define ECONNREFUSED 9908 -#endif - -#ifndef ECONNRESET -#define ECONNRESET 9909 -#endif - -#ifndef EDESTADDRREQ -#define EDESTADDRREQ 9910 -#endif - -#ifndef EHOSTUNREACH -#define EHOSTUNREACH 9911 -#endif - -#ifndef EIDRM -#define EIDRM 9912 -#endif - -#ifndef EMSGSIZE -#define EMSGSIZE 9913 -#endif - -#ifndef ENETDOWN -#define ENETDOWN 9914 -#endif - -#ifndef ENETRESET -#define ENETRESET 9915 -#endif - -#ifndef ENETUNREACH -#define ENETUNREACH 9916 -#endif - -#ifndef ENOBUFS -#define ENOBUFS 9917 -#endif - -#ifndef ENOLINK -#define ENOLINK 9918 -#endif - -#ifndef ENODATA -#define ENODATA 9919 -#endif - -#ifndef ENOMSG -#define ENOMSG 9920 -#endif - -#ifndef ENOPROTOOPT -#define ENOPROTOOPT 9921 -#endif - -#ifndef ENOSR -#define ENOSR 9922 -#endif - -#ifndef ENOTSOCK -#define ENOTSOCK 9923 -#endif - -#ifndef ENOSTR -#define ENOSTR 9924 -#endif - -#ifndef ENOTCONN -#define ENOTCONN 9925 -#endif - -#ifndef ENOTSUP -#define ENOTSUP 9926 -#endif - -#ifndef ECANCELED -#define ECANCELED 9927 -#endif - -#ifndef EINPROGRESS -#define EINPROGRESS 9928 -#endif - -#ifndef EOPNOTSUPP -#define EOPNOTSUPP 9929 -#endif - -#ifndef EWOULDBLOCK -#define EWOULDBLOCK 9930 -#endif - -#ifndef EOWNERDEAD -#define EOWNERDEAD 9931 -#endif - -#ifndef EPROTO -#define EPROTO 9932 -#endif - -#ifndef EPROTONOSUPPORT -#define EPROTONOSUPPORT 9933 -#endif - -#ifndef ENOTRECOVERABLE -#define ENOTRECOVERABLE 9934 -#endif - -#ifndef ETIME -#define ETIME 9935 -#endif - -#ifndef ETXTBSY -#define ETXTBSY 9936 -#endif - -#ifndef ETIMEDOUT -#define ETIMEDOUT 9938 -#endif - -#ifndef ELOOP -#define ELOOP 9939 -#endif - -#ifndef EOVERFLOW -#define EOVERFLOW 9940 -#endif - -#ifndef EPROTOTYPE -#define EPROTOTYPE 9941 -#endif - -#ifndef ENOSYS -#define ENOSYS 9942 -#endif - -#ifndef EINVAL -#define EINVAL 9943 -#endif - -#ifndef ERANGE -#define ERANGE 9944 -#endif - -#ifndef EILSEQ -#define EILSEQ 9945 -#endif - -// Windows Mobile doesn't appear to define these: - -#ifndef E2BIG -#define E2BIG 9946 -#endif - -#ifndef EDOM -#define EDOM 9947 -#endif - -#ifndef EFAULT -#define EFAULT 9948 -#endif - -#ifndef EBADF -#define EBADF 9949 -#endif - -#ifndef EPIPE -#define EPIPE 9950 -#endif - -#ifndef EXDEV -#define EXDEV 9951 -#endif - -#ifndef EBUSY -#define EBUSY 9952 -#endif - -#ifndef ENOTEMPTY -#define ENOTEMPTY 9953 -#endif - -#ifndef ENOEXEC -#define ENOEXEC 9954 -#endif - -#ifndef EEXIST -#define EEXIST 9955 -#endif - -#ifndef EFBIG -#define EFBIG 9956 -#endif - -#ifndef ENAMETOOLONG -#define ENAMETOOLONG 9957 -#endif - -#ifndef ENOTTY -#define ENOTTY 9958 -#endif - -#ifndef EINTR -#define EINTR 9959 -#endif - -#ifndef ESPIPE -#define ESPIPE 9960 -#endif - -#ifndef EIO -#define EIO 9961 -#endif - -#ifndef EISDIR -#define EISDIR 9962 -#endif - -#ifndef ECHILD -#define ECHILD 9963 -#endif - -#ifndef ENOLCK -#define ENOLCK 9964 -#endif - -#ifndef ENOSPC -#define ENOSPC 9965 -#endif - -#ifndef ENXIO -#define ENXIO 9966 -#endif - -#ifndef ENODEV -#define ENODEV 9967 -#endif - -#ifndef ENOENT -#define ENOENT 9968 -#endif - -#ifndef ESRCH -#define ESRCH 9969 -#endif - -#ifndef ENOTDIR -#define ENOTDIR 9970 -#endif - -#ifndef ENOMEM -#define ENOMEM 9971 -#endif - -#ifndef EPERM -#define EPERM 9972 -#endif - -#ifndef EACCES -#define EACCES 9973 -#endif - -#ifndef EROFS -#define EROFS 9974 -#endif - -#ifndef EDEADLK -#define EDEADLK 9975 -#endif - -#ifndef EAGAIN -#define EAGAIN 9976 -#endif - -#ifndef ENFILE -#define ENFILE 9977 -#endif - -#ifndef EMFILE -#define EMFILE 9978 -#endif - -#ifndef EMLINK -#define EMLINK 9979 -#endif - -#endif // include guard diff --git a/boost/chrono.hpp b/boost/chrono.hpp deleted file mode 100644 index a3a3522..0000000 --- a/boost/chrono.hpp +++ /dev/null @@ -1,20 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2010. -// Distributed under the 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/stm for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_CHRONO_HPP -#define BOOST_CHRONO_HPP - -//----------------------------------------------------------------------------- -#include -//----------------------------------------------------------------------------- - -#endif // BOOST_CHRONO_HPP diff --git a/boost/circular_buffer.hpp b/boost/circular_buffer.hpp deleted file mode 100644 index f5eff60..0000000 --- a/boost/circular_buffer.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// Circular buffer library header file. - -// Copyright (c) 2003-2008 Jan Gaspar - -// Use, modification, and distribution is 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) - -// See www.boost.org/libs/circular_buffer for documentation. - -#if !defined(BOOST_CIRCULAR_BUFFER_HPP) -#define BOOST_CIRCULAR_BUFFER_HPP - -#if defined(_MSC_VER) - #pragma once -#endif - -#include -#include -#include - -// BOOST_CB_ENABLE_DEBUG: Debug support control. -#if defined(NDEBUG) || defined(BOOST_CB_DISABLE_DEBUG) - #define BOOST_CB_ENABLE_DEBUG 0 -#else - #define BOOST_CB_ENABLE_DEBUG 1 -#endif - -// BOOST_CB_ASSERT: Runtime assertion. -#if BOOST_CB_ENABLE_DEBUG - #include - #define BOOST_CB_ASSERT(Expr) BOOST_ASSERT(Expr) -#else - #define BOOST_CB_ASSERT(Expr) ((void)0) -#endif - -// BOOST_CB_IS_CONVERTIBLE: Check if Iterator::value_type is convertible to Type. -#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407) - #define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) ((void)0) -#else - #include - #include - #define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) \ - BOOST_STATIC_ASSERT((is_convertible::value_type, Type>::value)) -#endif - -// BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS: -// Check if the STL provides templated iterator constructors for its containers. -#if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) - #define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS BOOST_STATIC_ASSERT(false); -#else - #define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS ((void)0); -#endif - -#include -#include -#include -#include - -#undef BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS -#undef BOOST_CB_IS_CONVERTIBLE -#undef BOOST_CB_ASSERT -#undef BOOST_CB_ENABLE_DEBUG - -#endif // #if !defined(BOOST_CIRCULAR_BUFFER_HPP) diff --git a/boost/circular_buffer_fwd.hpp b/boost/circular_buffer_fwd.hpp deleted file mode 100644 index 621fb95..0000000 --- a/boost/circular_buffer_fwd.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Forward declaration of the circular buffer and its adaptor. - -// Copyright (c) 2003-2008 Jan Gaspar - -// Use, modification, and distribution is 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) - -// See www.boost.org/libs/circular_buffer for documentation. - -#if !defined(BOOST_CIRCULAR_BUFFER_FWD_HPP) -#define BOOST_CIRCULAR_BUFFER_FWD_HPP - -#if defined(_MSC_VER) - #pragma once -#endif - -#include -#if !defined(BOOST_NO_STD_ALLOCATOR) - #include -#else - #include -#endif - -namespace boost { - -#if !defined(BOOST_NO_STD_ALLOCATOR) - #define BOOST_CB_DEFAULT_ALLOCATOR(T) std::allocator -#else - #define BOOST_CB_DEFAULT_ALLOCATOR(T) BOOST_DEDUCED_TYPENAME std::vector::allocator_type -#endif - -template -class circular_buffer; - -template -class circular_buffer_space_optimized; - -#undef BOOST_CB_DEFAULT_ALLOCATOR - -} // namespace boost - -#endif // #if !defined(BOOST_CIRCULAR_BUFFER_FWD_HPP) diff --git a/boost/compressed_pair.hpp b/boost/compressed_pair.hpp deleted file mode 100644 index a7be0f2..0000000 --- a/boost/compressed_pair.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000. -// 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). -// -// See http://www.boost.org/libs/utility for most recent version including documentation. - -// See boost/detail/compressed_pair.hpp -// for full copyright notices. - -#ifndef BOOST_COMPRESSED_PAIR_HPP -#define BOOST_COMPRESSED_PAIR_HPP - -#ifndef BOOST_CONFIG_HPP -#include -#endif - -#include - -#endif // BOOST_COMPRESSED_PAIR_HPP diff --git a/boost/concept/detail/concept_undef.hpp b/boost/concept/detail/concept_undef.hpp old mode 100755 new mode 100644 diff --git a/boost/concept/detail/general.hpp b/boost/concept/detail/general.hpp index c88a1ed..525ea65 100644 --- a/boost/concept/detail/general.hpp +++ b/boost/concept/detail/general.hpp @@ -4,6 +4,7 @@ #ifndef BOOST_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP # define BOOST_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP +# include # include # include @@ -65,19 +66,11 @@ struct requirement_ # endif -// Version check from https://svn.boost.org/trac/boost/changeset/82886 -// (boost/static_assert.hpp) -#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) -#define BOOST_CONCEPT_UNUSED_TYPEDEF __attribute__((unused)) -#else -#define BOOST_CONCEPT_UNUSED_TYPEDEF /**/ -#endif - # define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ typedef ::boost::concepts::detail::instantiate< \ &::boost::concepts::requirement_::failed> \ BOOST_PP_CAT(boost_concept_check,__LINE__) \ - BOOST_CONCEPT_UNUSED_TYPEDEF + BOOST_ATTRIBUTE_UNUSED }} diff --git a/boost/concept/requires.hpp b/boost/concept/requires.hpp deleted file mode 100644 index 365ce10..0000000 --- a/boost/concept/requires.hpp +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright David Abrahams 2006. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_CONCEPT_REQUIRES_DWA2006430_HPP -# define BOOST_CONCEPT_REQUIRES_DWA2006430_HPP - -# include -# include -# include - -namespace boost { - -// unaryfunptr_arg_type from parameter/aux_/parenthesized_type.hpp - -namespace ccheck_aux { - -// A metafunction that transforms void(*)(T) -> T -template -struct unaryfunptr_arg_type; - -template -struct unaryfunptr_arg_type -{ - typedef Arg type; -}; - -template <> -struct unaryfunptr_arg_type -{ - typedef void type; -}; - -} // namespace ccheck_aux - -// Template for use in handwritten assertions -template -struct requires_ : More -{ - BOOST_CONCEPT_ASSERT((Model)); -}; - -// Template for use by macros, where models must be wrapped in parens. -// This isn't in namespace detail to keep extra cruft out of resulting -// error messages. -template -struct _requires_ -{ - enum { value = 0 }; - BOOST_CONCEPT_ASSERT_FN(ModelFn); -}; - -template -struct Requires_ : ::boost::ccheck_aux::unaryfunptr_arg_type -{ -}; - -# if BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(1010)) -# define BOOST_CONCEPT_REQUIRES_(r,data,t) | (::boost::_requires_::value) -# else -# define BOOST_CONCEPT_REQUIRES_(r,data,t) + (::boost::_requires_::value) -# endif - -#if defined(NDEBUG) - -# define BOOST_CONCEPT_REQUIRES(models, result) \ - typename ::boost::ccheck_aux::unaryfunptr_arg_type::type - -#elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - -// Same thing as below without the initial typename -# define BOOST_CONCEPT_REQUIRES(models, result) \ - ::boost::Requires_< \ - (0 BOOST_PP_SEQ_FOR_EACH(BOOST_CONCEPT_REQUIRES_, ~, models)), \ - ::boost::ccheck_aux::unaryfunptr_arg_type \ - >::type - -#else - -// This just ICEs on MSVC6 :( -# define BOOST_CONCEPT_REQUIRES(models, result) \ - typename ::boost::Requires_< \ - (0 BOOST_PP_SEQ_FOR_EACH(BOOST_CONCEPT_REQUIRES_, ~, models)), \ - void(*)result \ - >::type - -#endif - -// C++0x proposed syntax changed. This supports an older usage -#define BOOST_CONCEPT_WHERE(models,result) BOOST_CONCEPT_REQUIRES(models,result) - -} // namespace boost::concept_check - -#endif // BOOST_CONCEPT_REQUIRES_DWA2006430_HPP diff --git a/boost/concept_archetype.hpp b/boost/concept_archetype.hpp deleted file mode 100644 index f21c817..0000000 --- a/boost/concept_archetype.hpp +++ /dev/null @@ -1,669 +0,0 @@ -// -// (C) Copyright Jeremy Siek 2000. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Revision History: -// -// 17 July 2001: Added const to some member functions. (Jeremy Siek) -// 05 May 2001: Removed static dummy_cons object. (Jeremy Siek) - -// See http://www.boost.org/libs/concept_check for documentation. - -#ifndef BOOST_CONCEPT_ARCHETYPES_HPP -#define BOOST_CONCEPT_ARCHETYPES_HPP - -#include -#include -#include -#include - -namespace boost { - - //=========================================================================== - // Basic Archetype Classes - - namespace detail { - class dummy_constructor { }; - } - - // A type that models no concept. The template parameter - // is only there so that null_archetype types can be created - // that have different type. - template - class null_archetype { - private: - null_archetype() { } - null_archetype(const null_archetype&) { } - null_archetype& operator=(const null_archetype&) { return *this; } - public: - null_archetype(detail::dummy_constructor) { } -#ifndef __MWERKS__ - template - friend void dummy_friend(); // just to avoid warnings -#endif - }; - - // This is a helper class that provides a way to get a reference to - // an object. The get() function will never be called at run-time - // (nothing in this file will) so this seemingly very bad function - // is really quite innocent. The name of this class needs to be - // changed. - template - class static_object - { - public: - static T& get() - { -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - return *reinterpret_cast(0); -#else - static char d[sizeof(T)]; - return *reinterpret_cast(d); -#endif - } - }; - - template > - class default_constructible_archetype : public Base { - public: - default_constructible_archetype() - : Base(static_object::get()) { } - default_constructible_archetype(detail::dummy_constructor x) : Base(x) { } - }; - - template > - class assignable_archetype : public Base { - assignable_archetype() { } - assignable_archetype(const assignable_archetype&) { } - public: - assignable_archetype& operator=(const assignable_archetype&) { - return *this; - } - assignable_archetype(detail::dummy_constructor x) : Base(x) { } - }; - - template > - class copy_constructible_archetype : public Base { - public: - copy_constructible_archetype() - : Base(static_object::get()) { } - copy_constructible_archetype(const copy_constructible_archetype&) - : Base(static_object::get()) { } - copy_constructible_archetype(detail::dummy_constructor x) : Base(x) { } - }; - - template > - class sgi_assignable_archetype : public Base { - public: - sgi_assignable_archetype(const sgi_assignable_archetype&) - : Base(static_object::get()) { } - sgi_assignable_archetype& operator=(const sgi_assignable_archetype&) { - return *this; - } - sgi_assignable_archetype(const detail::dummy_constructor& x) : Base(x) { } - }; - - struct default_archetype_base { - default_archetype_base(detail::dummy_constructor) { } - }; - - // Careful, don't use same type for T and Base. That results in the - // conversion operator being invalid. Since T is often - // null_archetype, can't use null_archetype for Base. - template - class convertible_to_archetype : public Base { - private: - convertible_to_archetype() { } - convertible_to_archetype(const convertible_to_archetype& ) { } - convertible_to_archetype& operator=(const convertible_to_archetype&) - { return *this; } - public: - convertible_to_archetype(detail::dummy_constructor x) : Base(x) { } - operator const T&() const { return static_object::get(); } - }; - - template - class convertible_from_archetype : public Base { - private: - convertible_from_archetype() { } - convertible_from_archetype(const convertible_from_archetype& ) { } - convertible_from_archetype& operator=(const convertible_from_archetype&) - { return *this; } - public: - convertible_from_archetype(detail::dummy_constructor x) : Base(x) { } - convertible_from_archetype(const T&) { } - convertible_from_archetype& operator=(const T&) - { return *this; } - }; - - class boolean_archetype { - public: - boolean_archetype(const boolean_archetype&) { } - operator bool() const { return true; } - boolean_archetype(detail::dummy_constructor) { } - private: - boolean_archetype() { } - boolean_archetype& operator=(const boolean_archetype&) { return *this; } - }; - - template > - class equality_comparable_archetype : public Base { - public: - equality_comparable_archetype(detail::dummy_constructor x) : Base(x) { } - }; - template - boolean_archetype - operator==(const equality_comparable_archetype&, - const equality_comparable_archetype&) - { - return boolean_archetype(static_object::get()); - } - template - boolean_archetype - operator!=(const equality_comparable_archetype&, - const equality_comparable_archetype&) - { - return boolean_archetype(static_object::get()); - } - - - template > - class equality_comparable2_first_archetype : public Base { - public: - equality_comparable2_first_archetype(detail::dummy_constructor x) - : Base(x) { } - }; - template > - class equality_comparable2_second_archetype : public Base { - public: - equality_comparable2_second_archetype(detail::dummy_constructor x) - : Base(x) { } - }; - template - boolean_archetype - operator==(const equality_comparable2_first_archetype&, - const equality_comparable2_second_archetype&) - { - return boolean_archetype(static_object::get()); - } - template - boolean_archetype - operator!=(const equality_comparable2_first_archetype&, - const equality_comparable2_second_archetype&) - { - return boolean_archetype(static_object::get()); - } - - - template > - class less_than_comparable_archetype : public Base { - public: - less_than_comparable_archetype(detail::dummy_constructor x) : Base(x) { } - }; - template - boolean_archetype - operator<(const less_than_comparable_archetype&, - const less_than_comparable_archetype&) - { - return boolean_archetype(static_object::get()); - } - - - - template > - class comparable_archetype : public Base { - public: - comparable_archetype(detail::dummy_constructor x) : Base(x) { } - }; - template - boolean_archetype - operator<(const comparable_archetype&, - const comparable_archetype&) - { - return boolean_archetype(static_object::get()); - } - template - boolean_archetype - operator<=(const comparable_archetype&, - const comparable_archetype&) - { - return boolean_archetype(static_object::get()); - } - template - boolean_archetype - operator>(const comparable_archetype&, - const comparable_archetype&) - { - return boolean_archetype(static_object::get()); - } - template - boolean_archetype - operator>=(const comparable_archetype&, - const comparable_archetype&) - { - return boolean_archetype(static_object::get()); - } - - - // The purpose of the optags is so that one can specify - // exactly which types the operator< is defined between. - // This is useful for allowing the operations: - // - // A a; B b; - // a < b - // b < a - // - // without also allowing the combinations: - // - // a < a - // b < b - // - struct optag1 { }; - struct optag2 { }; - struct optag3 { }; - -#define BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(OP, NAME) \ - template , class Tag = optag1 > \ - class NAME##_first_archetype : public Base { \ - public: \ - NAME##_first_archetype(detail::dummy_constructor x) : Base(x) { } \ - }; \ - \ - template , class Tag = optag1 > \ - class NAME##_second_archetype : public Base { \ - public: \ - NAME##_second_archetype(detail::dummy_constructor x) : Base(x) { } \ - }; \ - \ - template \ - boolean_archetype \ - operator OP (const NAME##_first_archetype&, \ - const NAME##_second_archetype&) \ - { \ - return boolean_archetype(static_object::get()); \ - } - - BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(==, equal_op) - BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(!=, not_equal_op) - BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(<, less_than_op) - BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(<=, less_equal_op) - BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(>, greater_than_op) - BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(>=, greater_equal_op) - -#define BOOST_DEFINE_OPERATOR_ARCHETYPE(OP, NAME) \ - template > \ - class NAME##_archetype : public Base { \ - public: \ - NAME##_archetype(detail::dummy_constructor x) : Base(x) { } \ - NAME##_archetype(const NAME##_archetype&) \ - : Base(static_object::get()) { } \ - NAME##_archetype& operator=(const NAME##_archetype&) { return *this; } \ - }; \ - template \ - NAME##_archetype \ - operator OP (const NAME##_archetype&,\ - const NAME##_archetype&) \ - { \ - return \ - NAME##_archetype(static_object::get()); \ - } - - BOOST_DEFINE_OPERATOR_ARCHETYPE(+, addable) - BOOST_DEFINE_OPERATOR_ARCHETYPE(-, subtractable) - BOOST_DEFINE_OPERATOR_ARCHETYPE(*, multipliable) - BOOST_DEFINE_OPERATOR_ARCHETYPE(/, dividable) - BOOST_DEFINE_OPERATOR_ARCHETYPE(%, modable) - - // As is, these are useless because of the return type. - // Need to invent a better way... -#define BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(OP, NAME) \ - template > \ - class NAME##_first_archetype : public Base { \ - public: \ - NAME##_first_archetype(detail::dummy_constructor x) : Base(x) { } \ - }; \ - \ - template > \ - class NAME##_second_archetype : public Base { \ - public: \ - NAME##_second_archetype(detail::dummy_constructor x) : Base(x) { } \ - }; \ - \ - template \ - Return \ - operator OP (const NAME##_first_archetype&, \ - const NAME##_second_archetype&) \ - { \ - return Return(static_object::get()); \ - } - - BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(+, plus_op) - BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(*, time_op) - BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(/, divide_op) - BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(-, subtract_op) - BOOST_DEFINE_BINARY_OPERATOR_ARCHETYPE(%, mod_op) - - //=========================================================================== - // Function Object Archetype Classes - - template - class generator_archetype { - public: - const Return& operator()() { - return static_object::get(); - } - }; - - class void_generator_archetype { - public: - void operator()() { } - }; - - template - class unary_function_archetype { - private: - unary_function_archetype() { } - public: - unary_function_archetype(detail::dummy_constructor) { } - const Return& operator()(const Arg&) const { - return static_object::get(); - } - }; - - template - class binary_function_archetype { - private: - binary_function_archetype() { } - public: - binary_function_archetype(detail::dummy_constructor) { } - const Return& operator()(const Arg1&, const Arg2&) const { - return static_object::get(); - } - }; - - template - class unary_predicate_archetype { - typedef boolean_archetype Return; - unary_predicate_archetype() { } - public: - unary_predicate_archetype(detail::dummy_constructor) { } - const Return& operator()(const Arg&) const { - return static_object::get(); - } - }; - - template > - class binary_predicate_archetype { - typedef boolean_archetype Return; - binary_predicate_archetype() { } - public: - binary_predicate_archetype(detail::dummy_constructor) { } - const Return& operator()(const Arg1&, const Arg2&) const { - return static_object::get(); - } - }; - - //=========================================================================== - // Iterator Archetype Classes - - template - class input_iterator_archetype - { - private: - typedef input_iterator_archetype self; - public: - typedef std::input_iterator_tag iterator_category; - typedef T value_type; - struct reference { - operator const value_type&() const { return static_object::get(); } - }; - typedef const T* pointer; - typedef std::ptrdiff_t difference_type; - self& operator=(const self&) { return *this; } - bool operator==(const self&) const { return true; } - bool operator!=(const self&) const { return true; } - reference operator*() const { return reference(); } - self& operator++() { return *this; } - self operator++(int) { return *this; } - }; - - template - class input_iterator_archetype_no_proxy - { - private: - typedef input_iterator_archetype_no_proxy self; - public: - typedef std::input_iterator_tag iterator_category; - typedef T value_type; - typedef const T& reference; - typedef const T* pointer; - typedef std::ptrdiff_t difference_type; - self& operator=(const self&) { return *this; } - bool operator==(const self&) const { return true; } - bool operator!=(const self&) const { return true; } - reference operator*() const { return static_object::get(); } - self& operator++() { return *this; } - self operator++(int) { return *this; } - }; - - template - struct output_proxy { - output_proxy& operator=(const T&) { return *this; } - }; - - template - class output_iterator_archetype - { - public: - typedef output_iterator_archetype self; - public: - typedef std::output_iterator_tag iterator_category; - typedef output_proxy value_type; - typedef output_proxy reference; - typedef void pointer; - typedef void difference_type; - output_iterator_archetype(detail::dummy_constructor) { } - output_iterator_archetype(const self&) { } - self& operator=(const self&) { return *this; } - bool operator==(const self&) const { return true; } - bool operator!=(const self&) const { return true; } - reference operator*() const { return output_proxy(); } - self& operator++() { return *this; } - self operator++(int) { return *this; } - private: - output_iterator_archetype() { } - }; - - template - class input_output_iterator_archetype - { - private: - typedef input_output_iterator_archetype self; - struct in_out_tag : public std::input_iterator_tag, public std::output_iterator_tag { }; - public: - typedef in_out_tag iterator_category; - typedef T value_type; - struct reference { - reference& operator=(const T&) { return *this; } - operator value_type() { return static_object::get(); } - }; - typedef const T* pointer; - typedef std::ptrdiff_t difference_type; - input_output_iterator_archetype() { } - self& operator=(const self&) { return *this; } - bool operator==(const self&) const { return true; } - bool operator!=(const self&) const { return true; } - reference operator*() const { return reference(); } - self& operator++() { return *this; } - self operator++(int) { return *this; } - }; - - template - class forward_iterator_archetype - { - public: - typedef forward_iterator_archetype self; - public: - typedef std::forward_iterator_tag iterator_category; - typedef T value_type; - typedef const T& reference; - typedef T const* pointer; - typedef std::ptrdiff_t difference_type; - forward_iterator_archetype() { } - self& operator=(const self&) { return *this; } - bool operator==(const self&) const { return true; } - bool operator!=(const self&) const { return true; } - reference operator*() const { return static_object::get(); } - self& operator++() { return *this; } - self operator++(int) { return *this; } - }; - - template - class mutable_forward_iterator_archetype - { - public: - typedef mutable_forward_iterator_archetype self; - public: - typedef std::forward_iterator_tag iterator_category; - typedef T value_type; - typedef T& reference; - typedef T* pointer; - typedef std::ptrdiff_t difference_type; - mutable_forward_iterator_archetype() { } - self& operator=(const self&) { return *this; } - bool operator==(const self&) const { return true; } - bool operator!=(const self&) const { return true; } - reference operator*() const { return static_object::get(); } - self& operator++() { return *this; } - self operator++(int) { return *this; } - }; - - template - class bidirectional_iterator_archetype - { - public: - typedef bidirectional_iterator_archetype self; - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef T value_type; - typedef const T& reference; - typedef T* pointer; - typedef std::ptrdiff_t difference_type; - bidirectional_iterator_archetype() { } - self& operator=(const self&) { return *this; } - bool operator==(const self&) const { return true; } - bool operator!=(const self&) const { return true; } - reference operator*() const { return static_object::get(); } - self& operator++() { return *this; } - self operator++(int) { return *this; } - self& operator--() { return *this; } - self operator--(int) { return *this; } - }; - - template - class mutable_bidirectional_iterator_archetype - { - public: - typedef mutable_bidirectional_iterator_archetype self; - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef T value_type; - typedef T& reference; - typedef T* pointer; - typedef std::ptrdiff_t difference_type; - mutable_bidirectional_iterator_archetype() { } - self& operator=(const self&) { return *this; } - bool operator==(const self&) const { return true; } - bool operator!=(const self&) const { return true; } - reference operator*() const { return static_object::get(); } - self& operator++() { return *this; } - self operator++(int) { return *this; } - self& operator--() { return *this; } - self operator--(int) { return *this; } - }; - - template - class random_access_iterator_archetype - { - public: - typedef random_access_iterator_archetype self; - public: - typedef std::random_access_iterator_tag iterator_category; - typedef T value_type; - typedef const T& reference; - typedef T* pointer; - typedef std::ptrdiff_t difference_type; - random_access_iterator_archetype() { } - self& operator=(const self&) { return *this; } - bool operator==(const self&) const { return true; } - bool operator!=(const self&) const { return true; } - reference operator*() const { return static_object::get(); } - self& operator++() { return *this; } - self operator++(int) { return *this; } - self& operator--() { return *this; } - self operator--(int) { return *this; } - reference operator[](difference_type) const - { return static_object::get(); } - self& operator+=(difference_type) { return *this; } - self& operator-=(difference_type) { return *this; } - difference_type operator-(const self&) const - { return difference_type(); } - self operator+(difference_type) const { return *this; } - self operator-(difference_type) const { return *this; } - bool operator<(const self&) const { return true; } - bool operator<=(const self&) const { return true; } - bool operator>(const self&) const { return true; } - bool operator>=(const self&) const { return true; } - }; - template - random_access_iterator_archetype - operator+(typename random_access_iterator_archetype::difference_type, - const random_access_iterator_archetype& x) - { return x; } - - - template - class mutable_random_access_iterator_archetype - { - public: - typedef mutable_random_access_iterator_archetype self; - public: - typedef std::random_access_iterator_tag iterator_category; - typedef T value_type; - typedef T& reference; - typedef T* pointer; - typedef std::ptrdiff_t difference_type; - mutable_random_access_iterator_archetype() { } - self& operator=(const self&) { return *this; } - bool operator==(const self&) const { return true; } - bool operator!=(const self&) const { return true; } - reference operator*() const { return static_object::get(); } - self& operator++() { return *this; } - self operator++(int) { return *this; } - self& operator--() { return *this; } - self operator--(int) { return *this; } - reference operator[](difference_type) const - { return static_object::get(); } - self& operator+=(difference_type) { return *this; } - self& operator-=(difference_type) { return *this; } - difference_type operator-(const self&) const - { return difference_type(); } - self operator+(difference_type) const { return *this; } - self operator-(difference_type) const { return *this; } - bool operator<(const self&) const { return true; } - bool operator<=(const self&) const { return true; } - bool operator>(const self&) const { return true; } - bool operator>=(const self&) const { return true; } - }; - template - mutable_random_access_iterator_archetype - operator+ - (typename mutable_random_access_iterator_archetype::difference_type, - const mutable_random_access_iterator_archetype& x) - { return x; } - -} // namespace boost - -#endif // BOOST_CONCEPT_ARCHETYPES_H diff --git a/boost/concept_check.hpp b/boost/concept_check.hpp index 292f37d..2d6fa32 100644 --- a/boost/concept_check.hpp +++ b/boost/concept_check.hpp @@ -818,9 +818,8 @@ namespace boost BOOST_CONCEPT_USAGE(Sequence) { S - c(n), - c2(n, t), - c3(first, last); + c(n, t), + c2(first, last); c.insert(p, t); c.insert(p, n, t); @@ -833,7 +832,6 @@ namespace boost ignore_unused_variable_warning(c); ignore_unused_variable_warning(c2); - ignore_unused_variable_warning(c3); ignore_unused_variable_warning(r); const_constraints(c); } diff --git a/boost/config/compiler/clang.hpp b/boost/config/compiler/clang.hpp index 95ddcbe..47ea65b 100644 --- a/boost/config/compiler/clang.hpp +++ b/boost/config/compiler/clang.hpp @@ -189,7 +189,7 @@ # define BOOST_NO_CXX11_USER_DEFINED_LITERALS #endif -#if !(__has_feature(cxx_alignas) || __has_extension(cxx_alignas)) +#if !__has_feature(cxx_alignas) # define BOOST_NO_CXX11_ALIGNAS #endif @@ -205,23 +205,23 @@ # define BOOST_NO_CXX11_FINAL #endif -#if !(__has_feature(cxx_binary_literals) || __has_extension(cxx_binary_literals)) +#if !(__has_feature(__cxx_binary_literals__) || __has_extension(__cxx_binary_literals__)) # define BOOST_NO_CXX14_BINARY_LITERALS #endif -#if !(__has_feature(cxx_decltype_auto) || __has_extension(cxx_decltype_auto)) +#if !__has_feature(__cxx_decltype_auto__) # define BOOST_NO_CXX14_DECLTYPE_AUTO #endif -#if !(__has_feature(cxx_aggregate_nsdmi) || __has_extension(cxx_aggregate_nsdmi)) +#if !__has_feature(__cxx_aggregate_nsdmi__) # define BOOST_NO_CXX14_AGGREGATE_NSDMI #endif -#if !(__has_feature(cxx_init_captures) || __has_extension(cxx_init_captures)) +#if !__has_feature(__cxx_init_captures__) # define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES #endif -#if !(__has_feature(cxx_generic_lambdas) || __has_extension(cxx_generic_lambdas)) +#if !__has_feature(__cxx_generic_lambdas__) # define BOOST_NO_CXX14_GENERIC_LAMBDAS #endif @@ -239,16 +239,15 @@ // so instead verify that we have a feature that was introduced at the same time as working C++14 // constexpr (generic lambda's in this case): // -#if !__has_feature(cxx_generic_lambdas) \ - || !(__has_feature(cxx_relaxed_constexpr) || __has_extension(cxx_relaxed_constexpr)) +#if !__has_feature(__cxx_generic_lambdas__) || !__has_feature(__cxx_relaxed_constexpr__) # define BOOST_NO_CXX14_CONSTEXPR #endif -#if !(__has_feature(cxx_return_type_deduction) || __has_extension(cxx_return_type_deduction)) +#if !__has_feature(__cxx_return_type_deduction__) # define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION #endif -#if !(__has_feature(cxx_variable_templates) || __has_extension(cxx_variable_templates)) +#if !__has_feature(__cxx_variable_templates__) # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif diff --git a/boost/config/compiler/intel.hpp b/boost/config/compiler/intel.hpp index b47610c..ecfacc5 100644 --- a/boost/config/compiler/intel.hpp +++ b/boost/config/compiler/intel.hpp @@ -14,6 +14,76 @@ // Intel compiler setup: +#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500) && (defined(_MSC_VER) || defined(__GNUC__)) + +#ifdef _MSC_VER + +#include + +#if (__INTEL_COMPILER >= 1500) && (_MSC_VER >= 1900) +// +// These appear to be supported, even though VC++ may not support them: +// +#define BOOST_HAS_EXPM1 +#define BOOST_HAS_LOG1P +#undef BOOST_NO_CXX14_BINARY_LITERALS +// This one may be a little risky to enable?? +#undef BOOST_NO_SFINAE_EXPR + +#endif + +#else + +#include + +#endif + +#undef BOOST_COMPILER + +#if defined(__INTEL_COMPILER) +#if __INTEL_COMPILER == 9999 +# define BOOST_INTEL_CXX_VERSION 1200 // Intel bug in 12.1. +#else +# define BOOST_INTEL_CXX_VERSION __INTEL_COMPILER +#endif +#elif defined(__ICL) +# define BOOST_INTEL_CXX_VERSION __ICL +#elif defined(__ICC) +# define BOOST_INTEL_CXX_VERSION __ICC +#elif defined(__ECC) +# define BOOST_INTEL_CXX_VERSION __ECC +#endif + +// Flags determined by comparing output of 'icpc -dM -E' with and without '-std=c++0x' +#if (!(defined(_WIN32) || defined(_WIN64)) && defined(__STDC_HOSTED__) && (__STDC_HOSTED__ && (BOOST_INTEL_CXX_VERSION <= 1200))) || defined(__GXX_EXPERIMENTAL_CPP0X__) || defined(__GXX_EXPERIMENTAL_CXX0X__) +# define BOOST_INTEL_STDCXX0X +#endif +#if defined(_MSC_VER) && (_MSC_VER >= 1600) +# define BOOST_INTEL_STDCXX0X +#endif + +#ifdef __GNUC__ +# define BOOST_INTEL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#endif + +#if !defined(BOOST_COMPILER) +# if defined(BOOST_INTEL_STDCXX0X) +# define BOOST_COMPILER "Intel C++ C++0x mode version " BOOST_STRINGIZE(BOOST_INTEL_CXX_VERSION) +# else +# define BOOST_COMPILER "Intel C++ version " BOOST_STRINGIZE(BOOST_INTEL_CXX_VERSION) +# endif +#endif + +#define BOOST_INTEL BOOST_INTEL_CXX_VERSION + +#if defined(_WIN32) || defined(_WIN64) +# define BOOST_INTEL_WIN BOOST_INTEL +#else +# define BOOST_INTEL_LINUX BOOST_INTEL +#endif + +#else + #include "boost/config/compiler/common_edg.hpp" #if defined(__INTEL_COMPILER) @@ -442,9 +512,10 @@ template<> struct assert_intrinsic_wchar_t {}; # define BOOST_HAS_INT128 #endif +#endif // // last known and checked version: -#if (BOOST_INTEL_CXX_VERSION > 1310) +#if (BOOST_INTEL_CXX_VERSION > 1500) # if defined(BOOST_ASSERT_CONFIG) # error "Unknown compiler version - please run the configure tests and report the results" # elif defined(_MSC_VER) diff --git a/boost/config/compiler/sunpro_cc.hpp b/boost/config/compiler/sunpro_cc.hpp index e715165..2fd6d3e 100644 --- a/boost/config/compiler/sunpro_cc.hpp +++ b/boost/config/compiler/sunpro_cc.hpp @@ -86,26 +86,22 @@ # define BOOST_SYMBOL_VISIBLE __global #endif - - -// -// Issues that effect all known versions: -// +#if (__SUNPRO_CC < 0x5130) +// C++03 features in 12.4: #define BOOST_NO_TWO_PHASE_NAME_LOOKUP +#define BOOST_NO_SFINAE_EXPR #define BOOST_NO_ADL_BARRIER +#define BOOST_NO_CXX11_VARIADIC_MACROS +#endif -// -// C++0x features -// -# define BOOST_HAS_LONG_LONG - +#if (__SUNPRO_CC < 0x5130) || (__cplusplus < 201100) +// C++11 only featuires in 12.4: #define BOOST_NO_CXX11_AUTO_DECLARATIONS #define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS #define BOOST_NO_CXX11_CHAR16_T #define BOOST_NO_CXX11_CHAR32_T #define BOOST_NO_CXX11_CONSTEXPR #define BOOST_NO_CXX11_DECLTYPE -#define BOOST_NO_CXX11_DECLTYPE_N3276 #define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS #define BOOST_NO_CXX11_DELETED_FUNCTIONS #define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS @@ -120,19 +116,34 @@ #define BOOST_NO_CXX11_RAW_LITERALS #define BOOST_NO_CXX11_RVALUE_REFERENCES #define BOOST_NO_CXX11_SCOPED_ENUMS -#define BOOST_NO_SFINAE_EXPR #define BOOST_NO_CXX11_STATIC_ASSERT #define BOOST_NO_CXX11_TEMPLATE_ALIASES #define BOOST_NO_CXX11_UNICODE_LITERALS -#define BOOST_NO_CXX11_VARIADIC_TEMPLATES -#define BOOST_NO_CXX11_VARIADIC_MACROS -#define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX -#define BOOST_NO_CXX11_USER_DEFINED_LITERALS #define BOOST_NO_CXX11_ALIGNAS #define BOOST_NO_CXX11_TRAILING_RESULT_TYPES #define BOOST_NO_CXX11_INLINE_NAMESPACES -#define BOOST_NO_CXX11_REF_QUALIFIERS #define BOOST_NO_CXX11_FINAL +#endif + +// +// Issues that effect all known versions: +// +// Variadic templates pass our test case, but enabling this +// causes the compiler to issue a signal 11 and bail out +// in various libraries. The others fail our test cases. +// +#define BOOST_NO_CXX11_VARIADIC_TEMPLATES +#define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX +#define BOOST_NO_CXX11_FIXED_LENGTH_VARIADIC_TEMPLATE_EXPANSION_PACKS +#define BOOST_NO_CXX11_DECLTYPE_N3276 +#define BOOST_NO_CXX11_USER_DEFINED_LITERALS +#define BOOST_NO_CXX11_REF_QUALIFIERS +#define BOOST_NO_COMPLETE_VALUE_INITIALIZATION +// +// C++0x features +// +# define BOOST_HAS_LONG_LONG + // C++ 14: #if !defined(__cpp_aggregate_nsdmi) || (__cpp_aggregate_nsdmi < 201304) diff --git a/boost/config/compiler/visualc.hpp b/boost/config/compiler/visualc.hpp index 57b617d..93908ce 100644 --- a/boost/config/compiler/visualc.hpp +++ b/boost/config/compiler/visualc.hpp @@ -67,21 +67,6 @@ #endif -// MSVC (including the latest checked version) has not yet completely -// implemented value-initialization, as is reported: -// "VC++ does not value-initialize members of derived classes without -// user-declared constructor", reported in 2009 by Sylvester Hesp: -// https://connect.microsoft.com/VisualStudio/feedback/details/484295 -// "Presence of copy constructor breaks member class initialization", -// reported in 2009 by Alex Vakulenko: -// https://connect.microsoft.com/VisualStudio/feedback/details/499606 -// "Value-initialization in new-expression", reported in 2005 by -// Pavel Kuznetsov (MetaCommunications Engineering): -// https://connect.microsoft.com/VisualStudio/feedback/details/100744 -// See also: http://www.boost.org/libs/utility/value_init.htm#compiler_issues -// (Niels Dekker, LKEB, May 2010) -# define BOOST_NO_COMPLETE_VALUE_INITIALIZATION - #ifndef _NATIVE_WCHAR_T_DEFINED # define BOOST_NO_INTRINSIC_WCHAR_T #endif @@ -104,7 +89,7 @@ #if (_MSC_VER >= 1400) && !defined(_DEBUG) # define BOOST_HAS_NRVO #endif -#if _MSC_VER >= 1500 // 150X == VC++ 9.0 +#if _MSC_VER >= 1600 // 160X == VC++ 10.0 # define BOOST_HAS_PRAGMA_DETECT_MISMATCH #endif // @@ -172,45 +157,57 @@ # define BOOST_NO_CXX11_DECLTYPE_N3276 #endif -// C++11 features supported by VC++ 14 (aka 2014) CTP1 -// Because the CTP is unsupported, unrelease, and only alpha quality, -// it is only supported if BOOST_MSVC_ENABLE_2014_JUN_CTP is defined. +// C++11 features supported by VC++ 14 (aka 2015) // -#if (_MSC_FULL_VER < 190021730) || !defined(BOOST_MSVC_ENABLE_2014_JUN_CTP) +#if (_MSC_FULL_VER < 190023026) # define BOOST_NO_CXX11_NOEXCEPT # define BOOST_NO_CXX11_REF_QUALIFIERS # define BOOST_NO_CXX11_USER_DEFINED_LITERALS # define BOOST_NO_CXX11_ALIGNAS # define BOOST_NO_CXX11_INLINE_NAMESPACES +# define BOOST_NO_CXX11_CHAR16_T +# define BOOST_NO_CXX11_CHAR32_T +# define BOOST_NO_CXX11_UNICODE_LITERALS # define BOOST_NO_CXX14_DECLTYPE_AUTO # define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES # define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION +# define BOOST_NO_CXX14_BINARY_LITERALS +# define BOOST_NO_CXX14_GENERIC_LAMBDAS +# define BOOST_NO_CXX14_DIGIT_SEPARATORS #endif +// MSVC including version 14 has not yet completely +// implemented value-initialization, as is reported: +// "VC++ does not value-initialize members of derived classes without +// user-declared constructor", reported in 2009 by Sylvester Hesp: +// https://connect.microsoft.com/VisualStudio/feedback/details/484295 +// "Presence of copy constructor breaks member class initialization", +// reported in 2009 by Alex Vakulenko: +// https://connect.microsoft.com/VisualStudio/feedback/details/499606 +// "Value-initialization in new-expression", reported in 2005 by +// Pavel Kuznetsov (MetaCommunications Engineering): +// https://connect.microsoft.com/VisualStudio/feedback/details/100744 +// Reported again by John Maddock in 2015 for VC14: +// https://connect.microsoft.com/VisualStudio/feedback/details/1582233/c-subobjects-still-not-value-initialized-correctly +// See also: http://www.boost.org/libs/utility/value_init.htm#compiler_issues +// (Niels Dekker, LKEB, May 2010) +#define BOOST_NO_COMPLETE_VALUE_INITIALIZATION // C++11 features not supported by any versions -#define BOOST_NO_CXX11_CHAR16_T -#define BOOST_NO_CXX11_CHAR32_T -#define BOOST_NO_CXX11_CONSTEXPR -#define BOOST_NO_CXX11_UNICODE_LITERALS #define BOOST_NO_SFINAE_EXPR #define BOOST_NO_TWO_PHASE_NAME_LOOKUP +// +// This is somewhat supported in VC14, but we may need to wait for +// a service release before enabling: +// +#define BOOST_NO_CXX11_CONSTEXPR // C++ 14: #if !defined(__cpp_aggregate_nsdmi) || (__cpp_aggregate_nsdmi < 201304) # define BOOST_NO_CXX14_AGGREGATE_NSDMI #endif -#if !defined(__cpp_binary_literals) || (__cpp_binary_literals < 201304) -# define BOOST_NO_CXX14_BINARY_LITERALS -#endif #if !defined(__cpp_constexpr) || (__cpp_constexpr < 201304) # define BOOST_NO_CXX14_CONSTEXPR #endif -#if (__cplusplus < 201304) // There's no SD6 check for this.... -# define BOOST_NO_CXX14_DIGIT_SEPARATORS -#endif -#if !defined(__cpp_generic_lambdas) || (__cpp_generic_lambdas < 201304) -# define BOOST_NO_CXX14_GENERIC_LAMBDAS -#endif #if !defined(__cpp_variable_templates) || (__cpp_variable_templates < 201304) # define BOOST_NO_CXX14_VARIABLE_TEMPLATES #endif @@ -290,8 +287,8 @@ #endif // -// last known and checked version is 19.00.22129 (VC14 CTP4): -#if (_MSC_VER > 1800 && _MSC_FULL_VER > 190022129) +// last known and checked version is 19.00.23026 (VC++ 2015 RTM): +#if (_MSC_VER > 1900) # if defined(BOOST_ASSERT_CONFIG) # error "Unknown compiler version - please run the configure tests and report the results" # else diff --git a/boost/config/compiler/xlcpp.hpp b/boost/config/compiler/xlcpp.hpp new file mode 100644 index 0000000..e369ece --- /dev/null +++ b/boost/config/compiler/xlcpp.hpp @@ -0,0 +1,258 @@ +// (C) Copyright Douglas Gregor 2010 +// +// 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) + +// See http://www.boost.org for most recent version. + +// compiler setup for IBM XL C/C++ for Linux (Little Endian) based on clang. + +#define BOOST_HAS_PRAGMA_ONCE + +// Detecting `-fms-extension` compiler flag assuming that _MSC_VER defined when that flag is used. +#if defined (_MSC_VER) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4)) +# define BOOST_HAS_PRAGMA_DETECT_MISMATCH +#endif + +// When compiling with clang before __has_extension was defined, +// even if one writes 'defined(__has_extension) && __has_extension(xxx)', +// clang reports a compiler error. So the only workaround found is: + +#ifndef __has_extension +#define __has_extension __has_feature +#endif + +#if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS) +# define BOOST_NO_EXCEPTIONS +#endif + +#if !__has_feature(cxx_rtti) && !defined(BOOST_NO_RTTI) +# define BOOST_NO_RTTI +#endif + +#if !__has_feature(cxx_rtti) && !defined(BOOST_NO_TYPEID) +# define BOOST_NO_TYPEID +#endif + +#if defined(__int64) && !defined(__GNUC__) +# define BOOST_HAS_MS_INT64 +#endif + +#define BOOST_HAS_NRVO + +// Branch prediction hints +#if defined(__has_builtin) +#if __has_builtin(__builtin_expect) +#define BOOST_LIKELY(x) __builtin_expect(x, 1) +#define BOOST_UNLIKELY(x) __builtin_expect(x, 0) +#endif +#endif + +// Clang supports "long long" in all compilation modes. +#define BOOST_HAS_LONG_LONG + +// +// Dynamic shared object (DSO) and dynamic-link library (DLL) support +// +#if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32) +# define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default"))) +# define BOOST_SYMBOL_IMPORT +# define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default"))) +#endif + +// +// The BOOST_FALLTHROUGH macro can be used to annotate implicit fall-through +// between switch labels. +// +#if __cplusplus >= 201103L && defined(__has_warning) +# if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") +# define BOOST_FALLTHROUGH [[clang::fallthrough]] +# endif +#endif + +#if !__has_feature(cxx_auto_type) +# define BOOST_NO_CXX11_AUTO_DECLARATIONS +# define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS +#endif + +// +// Currently clang on Windows using VC++ RTL does not support C++11's char16_t or char32_t +// +#if defined(_MSC_VER) || !(defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) +# define BOOST_NO_CXX11_CHAR16_T +# define BOOST_NO_CXX11_CHAR32_T +#endif + +#if !__has_feature(cxx_constexpr) +# define BOOST_NO_CXX11_CONSTEXPR +#endif + +#if !__has_feature(cxx_decltype) +# define BOOST_NO_CXX11_DECLTYPE +#endif + +#if !__has_feature(cxx_decltype_incomplete_return_types) +# define BOOST_NO_CXX11_DECLTYPE_N3276 +#endif + +#if !__has_feature(cxx_defaulted_functions) +# define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS +#endif + +#if !__has_feature(cxx_deleted_functions) +# define BOOST_NO_CXX11_DELETED_FUNCTIONS +#endif + +#if !__has_feature(cxx_explicit_conversions) +# define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS +#endif + +#if !__has_feature(cxx_default_function_template_args) +# define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS +#endif + +#if !__has_feature(cxx_generalized_initializers) +# define BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#endif + +#if !__has_feature(cxx_lambdas) +# define BOOST_NO_CXX11_LAMBDAS +#endif + +#if !__has_feature(cxx_local_type_template_args) +# define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS +#endif + +#if !__has_feature(cxx_noexcept) +# define BOOST_NO_CXX11_NOEXCEPT +#endif + +#if !__has_feature(cxx_nullptr) +# define BOOST_NO_CXX11_NULLPTR +#endif + +#if !__has_feature(cxx_range_for) +# define BOOST_NO_CXX11_RANGE_BASED_FOR +#endif + +#if !__has_feature(cxx_raw_string_literals) +# define BOOST_NO_CXX11_RAW_LITERALS +#endif + +#if !__has_feature(cxx_reference_qualified_functions) +# define BOOST_NO_CXX11_REF_QUALIFIERS +#endif + +#if !__has_feature(cxx_generalized_initializers) +# define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX +#endif + +#if !__has_feature(cxx_rvalue_references) +# define BOOST_NO_CXX11_RVALUE_REFERENCES +#endif + +#if !__has_feature(cxx_strong_enums) +# define BOOST_NO_CXX11_SCOPED_ENUMS +#endif + +#if !__has_feature(cxx_static_assert) +# define BOOST_NO_CXX11_STATIC_ASSERT +#endif + +#if !__has_feature(cxx_alias_templates) +# define BOOST_NO_CXX11_TEMPLATE_ALIASES +#endif + +#if !__has_feature(cxx_unicode_literals) +# define BOOST_NO_CXX11_UNICODE_LITERALS +#endif + +#if !__has_feature(cxx_variadic_templates) +# define BOOST_NO_CXX11_VARIADIC_TEMPLATES +#endif + +#if !__has_feature(cxx_user_literals) +# define BOOST_NO_CXX11_USER_DEFINED_LITERALS +#endif + +#if !__has_feature(cxx_alignas) +# define BOOST_NO_CXX11_ALIGNAS +#endif + +#if !__has_feature(cxx_trailing_return) +# define BOOST_NO_CXX11_TRAILING_RESULT_TYPES +#endif + +#if !__has_feature(cxx_inline_namespaces) +# define BOOST_NO_CXX11_INLINE_NAMESPACES +#endif + +#if !__has_feature(cxx_override_control) +# define BOOST_NO_CXX11_FINAL +#endif + +#if !(__has_feature(__cxx_binary_literals__) || __has_extension(__cxx_binary_literals__)) +# define BOOST_NO_CXX14_BINARY_LITERALS +#endif + +#if !__has_feature(__cxx_decltype_auto__) +# define BOOST_NO_CXX14_DECLTYPE_AUTO +#endif + +#if !__has_feature(__cxx_aggregate_nsdmi__) +# define BOOST_NO_CXX14_AGGREGATE_NSDMI +#endif + +#if !__has_feature(__cxx_init_captures__) +# define BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES +#endif + +#if !__has_feature(__cxx_generic_lambdas__) +# define BOOST_NO_CXX14_GENERIC_LAMBDAS +#endif + +// clang < 3.5 has a defect with dependent type, like following. +// +// template +// constexpr typename enable_if >::type foo(T &) +// { } // error: no return statement in constexpr function +// +// This issue also affects C++11 mode, but C++11 constexpr requires return stmt. +// Therefore we don't care such case. +// +// Note that we can't check Clang version directly as the numbering system changes depending who's +// creating the Clang release (see https://github.com/boostorg/config/pull/39#issuecomment-59927873) +// so instead verify that we have a feature that was introduced at the same time as working C++14 +// constexpr (generic lambda's in this case): +// +#if !__has_feature(__cxx_generic_lambdas__) || !__has_feature(__cxx_relaxed_constexpr__) +# define BOOST_NO_CXX14_CONSTEXPR +#endif + +#if !__has_feature(__cxx_return_type_deduction__) +# define BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION +#endif + +#if !__has_feature(__cxx_variable_templates__) +# define BOOST_NO_CXX14_VARIABLE_TEMPLATES +#endif + +#if __cplusplus < 201400 +// All versions with __cplusplus above this value seem to support this: +# define BOOST_NO_CXX14_DIGIT_SEPARATORS +#endif + + +// Unused attribute: +#if defined(__GNUC__) && (__GNUC__ >= 4) +# define BOOST_ATTRIBUTE_UNUSED __attribute__((unused)) +#endif + +#ifndef BOOST_COMPILER +# define BOOST_COMPILER "Clang version " __clang_version__ +#endif + +// Macro used to identify the Clang compiler. +#define BOOST_CLANG 1 + diff --git a/boost/config/platform/haiku.hpp b/boost/config/platform/haiku.hpp new file mode 100644 index 0000000..750866c --- /dev/null +++ b/boost/config/platform/haiku.hpp @@ -0,0 +1,31 @@ +// (C) Copyright Jessica Hamilton 2014. +// 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) + +// See http://www.boost.org for most recent version. + +// Haiku specific config options: + +#define BOOST_PLATFORM "Haiku" + +#define BOOST_HAS_UNISTD_H +#define BOOST_HAS_STDINT_H + +#ifndef BOOST_DISABLE_THREADS +# define BOOST_HAS_THREADS +#endif + +#define BOOST_NO_CXX11_HDR_TYPE_TRAITS +#define BOOST_NO_CXX11_ATOMIC_SMART_PTR +#define BOOST_NO_CXX11_STATIC_ASSERT +#define BOOST_NO_CXX11_VARIADIC_MACROS + +// +// thread API's not auto detected: +// +#define BOOST_HAS_SCHED_YIELD +#define BOOST_HAS_GETTIMEOFDAY + +// boilerplate code: +#include diff --git a/boost/config/platform/solaris.hpp b/boost/config/platform/solaris.hpp index 9f92566..6e4efc9 100644 --- a/boost/config/platform/solaris.hpp +++ b/boost/config/platform/solaris.hpp @@ -23,6 +23,9 @@ # undef BOOST_HAS_PTHREADS #endif - +#define BOOST_HAS_STDINT_H +#define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE +#define BOOST_HAS_LOG1P +#define BOOST_HAS_EXPM1 diff --git a/boost/config/select_compiler_config.hpp b/boost/config/select_compiler_config.hpp index 3d8bdd8..4d87093 100644 --- a/boost/config/select_compiler_config.hpp +++ b/boost/config/select_compiler_config.hpp @@ -39,7 +39,7 @@ // Intel # define BOOST_COMPILER_CONFIG "boost/config/compiler/intel.hpp" -#elif defined __clang__ && !defined(__CUDACC__) +#elif defined __clang__ && !defined(__CUDACC__) && !defined(__ibmxl__) // when using clang and cuda at same time, you want to appear as gcc // Clang C++ emulates GCC, so it has to appear early. # define BOOST_COMPILER_CONFIG "boost/config/compiler/clang.hpp" @@ -48,7 +48,7 @@ // Digital Mars C++ # define BOOST_COMPILER_CONFIG "boost/config/compiler/digitalmars.hpp" -# elif defined __GNUC__ +# elif defined(__GNUC__) && !defined(__ibmxl__) // GNU C++: # define BOOST_COMPILER_CONFIG "boost/config/compiler/gcc.hpp" @@ -92,8 +92,12 @@ // MPW MrCpp or SCpp # define BOOST_COMPILER_CONFIG "boost/config/compiler/mpw.hpp" +#elif defined(__ibmxl__) +// IBM XL C/C++ for Linux (Little Endian) +# define BOOST_COMPILER_CONFIG "boost/config/compiler/xlcpp.hpp" + #elif defined(__IBMCPP__) -// IBM Visual Age +// IBM Visual Age or IBM XL C/C++ for Linux (Big Endian) # define BOOST_COMPILER_CONFIG "boost/config/compiler/vacpp.hpp" #elif defined(__PGI) diff --git a/boost/config/select_platform_config.hpp b/boost/config/select_platform_config.hpp index 2dddc6a..acd1409 100644 --- a/boost/config/select_platform_config.hpp +++ b/boost/config/select_platform_config.hpp @@ -41,6 +41,10 @@ // win32: # define BOOST_PLATFORM_CONFIG "boost/config/platform/win32.hpp" +#elif defined(__HAIKU__) +// Haiku +# define BOOST_PLATFORM_CONFIG "boost/config/platform/haiku.hpp" + #elif defined(__BEOS__) // BeOS # define BOOST_PLATFORM_CONFIG "boost/config/platform/beos.hpp" diff --git a/boost/config/stdlib/dinkumware.hpp b/boost/config/stdlib/dinkumware.hpp index a6ac64a..90c45c6 100644 --- a/boost/config/stdlib/dinkumware.hpp +++ b/boost/config/stdlib/dinkumware.hpp @@ -96,7 +96,7 @@ #include #endif #include -#if ( (!_HAS_EXCEPTIONS && !defined(__ghs__)) || (!_HAS_NAMESPACE && defined(__ghs__)) ) && !defined(__TI_COMPILER_VERSION__) +#if ( (!_HAS_EXCEPTIONS && !defined(__ghs__)) || (!_HAS_NAMESPACE && defined(__ghs__)) ) && !defined(__TI_COMPILER_VERSION__) && !defined(__VISUALDSPVERSION__) # define BOOST_NO_STD_TYPEINFO #endif @@ -147,6 +147,16 @@ # define BOOST_NO_CXX11_STD_ALIGN #endif +#if defined(__has_include) +#if !__has_include() +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#elif __cplusplus < 201402 +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif +#elif !defined(_CPPLIB_VER) || (_CPPLIB_VER < 650) +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif + #if defined(BOOST_INTEL) && (BOOST_INTEL <= 1400) // Intel's compiler can't handle this header yet: # define BOOST_NO_CXX11_HDR_ATOMIC @@ -155,7 +165,16 @@ // 520..610 have std::addressof, but it doesn't support functions // +#if !defined(_CPPLIB_VER) || _CPPLIB_VER < 650 # define BOOST_NO_CXX11_ADDRESSOF +#endif + +// Bug specific to VC14, +// See https://connect.microsoft.com/VisualStudio/feedback/details/1348277/link-error-when-using-std-codecvt-utf8-utf16-char16-t +// and discussion here: http://blogs.msdn.com/b/vcblog/archive/2014/11/12/visual-studio-2015-preview-now-available.aspx?PageIndex=2 +#if _CPPLIB_VER == 650 +# define BOOST_NO_CXX11_HDR_CODECVT +#endif #ifdef _CPPLIB_VER # define BOOST_DINKUMWARE_STDLIB _CPPLIB_VER diff --git a/boost/config/stdlib/libcomo.hpp b/boost/config/stdlib/libcomo.hpp index 5aacfb2..941498d 100644 --- a/boost/config/stdlib/libcomo.hpp +++ b/boost/config/stdlib/libcomo.hpp @@ -62,6 +62,16 @@ # define BOOST_NO_CXX11_STD_ALIGN # define BOOST_NO_CXX11_ADDRESSOF +#if defined(__has_include) +#if !__has_include() +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#elif __cplusplus < 201402 +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif +#else +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif + // // Intrinsic type_traits support. // The SGI STL has it's own __type_traits class, which @@ -71,5 +81,3 @@ #define BOOST_HAS_SGI_TYPE_TRAITS #define BOOST_STDLIB "Comeau standard library " BOOST_STRINGIZE(__LIBCOMO_VERSION__) - - diff --git a/boost/config/stdlib/libcpp.hpp b/boost/config/stdlib/libcpp.hpp index eee2d75..ab5d123 100644 --- a/boost/config/stdlib/libcpp.hpp +++ b/boost/config/stdlib/libcpp.hpp @@ -67,4 +67,14 @@ // libc++ uses a non-standard messages_base #define BOOST_NO_STD_MESSAGES +#if defined(__has_include) +#if !__has_include() +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#elif __cplusplus <= 201103 +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif +#elif __cplusplus < 201402 +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif + // --- end --- diff --git a/boost/config/stdlib/libstdcpp3.hpp b/boost/config/stdlib/libstdcpp3.hpp index b26d1ff..7d27b0c 100644 --- a/boost/config/stdlib/libstdcpp3.hpp +++ b/boost/config/stdlib/libstdcpp3.hpp @@ -36,7 +36,8 @@ || defined(_GLIBCXX__PTHREADS) \ || defined(_GLIBCXX_HAS_GTHREADS) \ || defined(_WIN32) \ - || defined(_AIX) + || defined(_AIX) \ + || defined(__HAIKU__) // // If the std lib has thread support turned on, then turn it on in Boost // as well. We do this because some gcc-3.4 std lib headers define _REENTANT @@ -122,12 +123,12 @@ #ifdef __clang__ #if __has_include() -# define BOOST_LIBSTDCXX_VERSION 50000 +# define BOOST_LIBSTDCXX_VERSION 50100 #elif __has_include() # define BOOST_LIBSTDCXX_VERSION 40900 #elif __has_include() # define BOOST_LIBSTDCXX_VERSION 40800 -#elif __has_include() +#elif __has_include() # define BOOST_LIBSTDCXX_VERSION 40700 #elif __has_include() # define BOOST_LIBSTDCXX_VERSION 40600 @@ -145,6 +146,14 @@ // #endif +#if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x5130) && (__cplusplus >= 201103L) +// +// Oracle Solaris compiler uses it's own verison of libstdc++ but doesn't +// set __GNUC__ +// +#define BOOST_LIBSTDCXX_VERSION 40800 +#endif + #if !defined(BOOST_LIBSTDCXX_VERSION) # define BOOST_LIBSTDCXX_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #endif @@ -204,6 +213,8 @@ # define BOOST_NO_CXX11_HDR_ATOMIC # define BOOST_NO_CXX11_HDR_THREAD #endif +// C++0x features in GCC 4.9.0 and later +// #if (BOOST_LIBSTDCXX_VERSION < 40900) || !defined(BOOST_LIBSTDCXX11) // Although is present and compilable against, the actual implementation is not functional // even for the simplest patterns such as "\d" or "[0-9]". This is the case at least in gcc up to 4.8, inclusively. @@ -214,13 +225,33 @@ // As of clang-3.6, libstdc++ header throws up errors with clang: # define BOOST_NO_CXX11_HDR_ATOMIC #endif - -// C++0x headers not yet (fully!) implemented // +// C++0x features in GCC 5.1 and later +// +#if (BOOST_LIBSTDCXX_VERSION < 50100) || !defined(BOOST_LIBSTDCXX11) # define BOOST_NO_CXX11_HDR_TYPE_TRAITS # define BOOST_NO_CXX11_HDR_CODECVT # define BOOST_NO_CXX11_ATOMIC_SMART_PTR # define BOOST_NO_CXX11_STD_ALIGN +#endif + +#if defined(__has_include) +#if !__has_include() +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#elif __cplusplus <= 201103 +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif +#elif __cplusplus < 201402 || (BOOST_LIBSTDCXX_VERSION < 40900) || !defined(BOOST_LIBSTDCXX11) +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif + +// +// Headers not present on Solaris with the Oracle compiler: +#if defined(__SUNPRO_CC) +#define BOOST_NO_CXX11_HDR_FUTURE +#define BOOST_NO_CXX11_HDR_FORWARD_LIST +#define BOOST_NO_CXX11_HDR_ATOMIC +#endif #if (!defined(_GLIBCXX_HAS_GTHREADS) || !defined(_GLIBCXX_USE_C99_STDINT_TR1)) // Headers not always available: @@ -233,6 +264,9 @@ # ifndef BOOST_NO_CXX11_HDR_THREAD # define BOOST_NO_CXX11_HDR_THREAD # endif +# ifndef BOOST_NO_CXX14_HDR_SHARED_MUTEX +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +# endif #endif #if (!defined(_GTHREAD_USE_MUTEX_TIMEDLOCK) || (_GTHREAD_USE_MUTEX_TIMEDLOCK == 0)) && !defined(BOOST_NO_CXX11_HDR_MUTEX) diff --git a/boost/config/stdlib/modena.hpp b/boost/config/stdlib/modena.hpp index f2a8388..7a85e0c 100644 --- a/boost/config/stdlib/modena.hpp +++ b/boost/config/stdlib/modena.hpp @@ -51,6 +51,16 @@ # define BOOST_NO_CXX11_STD_ALIGN # define BOOST_NO_CXX11_ADDRESSOF +#if defined(__has_include) +#if !__has_include() +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#elif __cplusplus < 201402 +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif +#else +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif + #define BOOST_STDLIB "Modena C++ standard library" diff --git a/boost/config/stdlib/msl.hpp b/boost/config/stdlib/msl.hpp index b8f43a1..dd2775e 100644 --- a/boost/config/stdlib/msl.hpp +++ b/boost/config/stdlib/msl.hpp @@ -75,13 +75,14 @@ # define BOOST_NO_CXX11_STD_ALIGN # define BOOST_NO_CXX11_ADDRESSOF +#if defined(__has_include) +#if !__has_include() +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#elif __cplusplus < 201402 +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif +#else +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif + #define BOOST_STDLIB "Metrowerks Standard Library version " BOOST_STRINGIZE(__MSL_CPP__) - - - - - - - - - diff --git a/boost/config/stdlib/roguewave.hpp b/boost/config/stdlib/roguewave.hpp index 2b4e863..97a2b0b 100644 --- a/boost/config/stdlib/roguewave.hpp +++ b/boost/config/stdlib/roguewave.hpp @@ -187,3 +187,12 @@ # define BOOST_NO_CXX11_STD_ALIGN # define BOOST_NO_CXX11_ADDRESSOF +#if defined(__has_include) +#if !__has_include() +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#elif __cplusplus < 201402 +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif +#else +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif diff --git a/boost/config/stdlib/sgi.hpp b/boost/config/stdlib/sgi.hpp index bda77c2..c805271 100644 --- a/boost/config/stdlib/sgi.hpp +++ b/boost/config/stdlib/sgi.hpp @@ -145,7 +145,14 @@ # define BOOST_NO_CXX11_STD_ALIGN # define BOOST_NO_CXX11_ADDRESSOF -#define BOOST_STDLIB "SGI standard library" - - +#if defined(__has_include) +#if !__has_include() +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#elif __cplusplus < 201402 +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif +#else +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif +#define BOOST_STDLIB "SGI standard library" \ No newline at end of file diff --git a/boost/config/stdlib/stlport.hpp b/boost/config/stdlib/stlport.hpp index fd5d3a5..bbc4176 100644 --- a/boost/config/stdlib/stlport.hpp +++ b/boost/config/stdlib/stlport.hpp @@ -235,12 +235,14 @@ namespace boost { using std::min; using std::max; } # define BOOST_NO_CXX11_STD_ALIGN # define BOOST_NO_CXX11_ADDRESSOF +#if defined(__has_include) +#if !__has_include() +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#elif __cplusplus < 201402 +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif +#else +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif + #define BOOST_STDLIB "STLPort standard library version " BOOST_STRINGIZE(__SGI_STL_PORT) - - - - - - - - diff --git a/boost/config/stdlib/vacpp.hpp b/boost/config/stdlib/vacpp.hpp index a58ec1c..4ccd0d2 100644 --- a/boost/config/stdlib/vacpp.hpp +++ b/boost/config/stdlib/vacpp.hpp @@ -51,7 +51,14 @@ # define BOOST_NO_CXX11_STD_ALIGN # define BOOST_NO_CXX11_ADDRESSOF +#if defined(__has_include) +#if !__has_include() +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#elif __cplusplus < 201402 +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif +#else +# define BOOST_NO_CXX14_HDR_SHARED_MUTEX +#endif + #define BOOST_STDLIB "Visual Age default standard library" - - - diff --git a/boost/container/adaptive_pool.hpp b/boost/container/adaptive_pool.hpp deleted file mode 100644 index c12d511..0000000 --- a/boost/container/adaptive_pool.hpp +++ /dev/null @@ -1,349 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_ADAPTIVE_POOL_HPP -#define BOOST_CONTAINER_ADAPTIVE_POOL_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - - -namespace boost { -namespace container { - -//!An STL node allocator that uses a modified DLMalloc as memory -//!source. -//! -//!This node allocator shares a segregated storage between all instances -//!of adaptive_pool with equal sizeof(T). -//! -//!NodesPerBlock is the number of nodes allocated at once when the allocator -//!needs runs out of nodes. MaxFreeBlocks is the maximum number of totally free blocks -//!that the adaptive node pool will hold. The rest of the totally free blocks will be -//!deallocated to the memory manager. -//! -//!OverheadPercent is the (approximated) maximum size overhead (1-20%) of the allocator: -//!(memory usable for nodes / total memory allocated from the memory allocator) -template < class T - , std::size_t NodesPerBlock BOOST_CONTAINER_DOCONLY(= ADP_nodes_per_block) - , std::size_t MaxFreeBlocks BOOST_CONTAINER_DOCONLY(= ADP_max_free_blocks) - , std::size_t OverheadPercent BOOST_CONTAINER_DOCONLY(= ADP_overhead_percent) - BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I unsigned Version) - > -class adaptive_pool -{ - //!If Version is 1, the allocator is a STL conforming allocator. If Version is 2, - //!the allocator offers advanced expand in place and burst allocation capabilities. - public: - typedef unsigned int allocation_type; - typedef adaptive_pool - self_t; - - static const std::size_t nodes_per_block = NodesPerBlock; - static const std::size_t max_free_blocks = MaxFreeBlocks; - static const std::size_t overhead_percent = OverheadPercent; - static const std::size_t real_nodes_per_block = NodesPerBlock; - - BOOST_CONTAINER_DOCIGN(BOOST_STATIC_ASSERT((Version <=2))); - - public: - //------- - typedef T value_type; - typedef T * pointer; - typedef const T * const_pointer; - typedef typename ::boost::container:: - container_detail::unvoid::type & reference; - typedef const typename ::boost::container:: - container_detail::unvoid::type & const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - typedef boost::container::container_detail:: - version_type version; - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef boost::container::container_detail:: - basic_multiallocation_chain multiallocation_chain_void; - typedef boost::container::container_detail:: - transform_multiallocation_chain - multiallocation_chain; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - //!Obtains adaptive_pool from - //!adaptive_pool - template - struct rebind - { - typedef adaptive_pool - < T2 - , NodesPerBlock - , MaxFreeBlocks - , OverheadPercent - BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I Version) - > other; - }; - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - //!Not assignable from related adaptive_pool - template - adaptive_pool& operator= - (const adaptive_pool&); - - //!Not assignable from other adaptive_pool - adaptive_pool& operator=(const adaptive_pool&); - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - //!Default constructor - adaptive_pool() BOOST_CONTAINER_NOEXCEPT - {} - - //!Copy constructor from other adaptive_pool. - adaptive_pool(const adaptive_pool &) BOOST_CONTAINER_NOEXCEPT - {} - - //!Copy constructor from related adaptive_pool. - template - adaptive_pool - (const adaptive_pool &) BOOST_CONTAINER_NOEXCEPT - {} - - //!Destructor - ~adaptive_pool() BOOST_CONTAINER_NOEXCEPT - {} - - //!Returns the number of elements that could be allocated. - //!Never throws - size_type max_size() const BOOST_CONTAINER_NOEXCEPT - { return size_type(-1)/sizeof(T); } - - //!Allocate memory for an array of count elements. - //!Throws std::bad_alloc if there is no enough memory - pointer allocate(size_type count, const void * = 0) - { - if(count > this->max_size()) - boost::container::throw_bad_alloc(); - - if(Version == 1 && count == 1){ - typedef typename container_detail::shared_adaptive_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - return pointer(static_cast(singleton_t::instance().allocate_node())); - } - else{ - return static_cast(boost_cont_malloc(count*sizeof(T))); - } - } - - //!Deallocate allocated memory. - //!Never throws - void deallocate(const pointer &ptr, size_type count) BOOST_CONTAINER_NOEXCEPT - { - (void)count; - if(Version == 1 && count == 1){ - typedef container_detail::shared_adaptive_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - singleton_t::instance().deallocate_node(ptr); - } - else{ - boost_cont_free(ptr); - } - } - - std::pair - allocation_command(allocation_type command, - size_type limit_size, - size_type preferred_size, - size_type &received_size, pointer reuse = pointer()) - { - std::pair ret = - this->priv_allocation_command(command, limit_size, preferred_size, received_size, reuse); - if(!ret.first && !(command & BOOST_CONTAINER_NOTHROW_ALLOCATION)) - boost::container::throw_bad_alloc(); - return ret; - } - - //!Returns maximum the number of objects the previously allocated memory - //!pointed by p can hold. - size_type size(pointer p) const BOOST_CONTAINER_NOEXCEPT - { return boost_cont_size(p); } - - //!Allocates just one object. Memory allocated with this function - //!must be deallocated only with deallocate_one(). - //!Throws bad_alloc if there is no enough memory - pointer allocate_one() - { - typedef container_detail::shared_adaptive_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - return (pointer)singleton_t::instance().allocate_node(); - } - - //!Allocates many elements of size == 1. - //!Elements must be individually deallocated with deallocate_one() - void allocate_individual(std::size_t num_elements, multiallocation_chain &chain) - { - typedef container_detail::shared_adaptive_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - singleton_t::instance().allocate_nodes(num_elements, static_cast(chain)); - //typename shared_pool_t::multiallocation_chain ch; - //singleton_t::instance().allocate_nodes(num_elements, ch); - //chain.incorporate_after - //(chain.before_begin(), (T*)&*ch.begin(), (T*)&*ch.last(), ch.size()); - } - - //!Deallocates memory previously allocated with allocate_one(). - //!You should never use deallocate_one to deallocate memory allocated - //!with other functions different from allocate_one(). Never throws - void deallocate_one(pointer p) BOOST_CONTAINER_NOEXCEPT - { - typedef container_detail::shared_adaptive_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - singleton_t::instance().deallocate_node(p); - } - - void deallocate_individual(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT - { - typedef container_detail::shared_adaptive_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - //typename shared_pool_t::multiallocation_chain ch(&*chain.begin(), &*chain.last(), chain.size()); - //singleton_t::instance().deallocate_nodes(ch); - singleton_t::instance().deallocate_nodes(chain); - } - - //!Allocates many elements of size elem_size. - //!Elements must be individually deallocated with deallocate() - void allocate_many(size_type elem_size, std::size_t n_elements, multiallocation_chain &chain) - { - BOOST_STATIC_ASSERT(( Version > 1 ));/* - boost_cont_memchain ch; - BOOST_CONTAINER_MEMCHAIN_INIT(&ch); - if(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){ - boost::container::throw_bad_alloc(); - } - chain.incorporate_after(chain.before_begin() - ,(T*)BOOST_CONTAINER_MEMCHAIN_FIRSTMEM(&ch) - ,(T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch) - ,BOOST_CONTAINER_MEMCHAIN_SIZE(&ch) );*/ - if(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast(&chain))){ - boost::container::throw_bad_alloc(); - } - } - - //!Allocates n_elements elements, each one of size elem_sizes[i] - //!Elements must be individually deallocated with deallocate() - void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain) - { - BOOST_STATIC_ASSERT(( Version > 1 ));/* - boost_cont_memchain ch; - BOOST_CONTAINER_MEMCHAIN_INIT(&ch); - if(!boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){ - boost::container::throw_bad_alloc(); - } - chain.incorporate_after(chain.before_begin() - ,(T*)BOOST_CONTAINER_MEMCHAIN_FIRSTMEM(&ch) - ,(T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch) - ,BOOST_CONTAINER_MEMCHAIN_SIZE(&ch) );*/ - if(!boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast(&chain))){ - boost::container::throw_bad_alloc(); - } - } - - void deallocate_many(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT - {/* - boost_cont_memchain ch; - void *beg(&*chain.begin()), *last(&*chain.last()); - size_t size(chain.size()); - BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&ch, beg, last, size); - boost_cont_multidealloc(&ch);*/ - boost_cont_multidealloc(reinterpret_cast(&chain)); - } - - //!Deallocates all free blocks of the pool - static void deallocate_free_blocks() BOOST_CONTAINER_NOEXCEPT - { - typedef container_detail::shared_adaptive_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - singleton_t::instance().deallocate_free_blocks(); - } - - //!Swaps allocators. Does not throw. If each allocator is placed in a - //!different memory segment, the result is undefined. - friend void swap(adaptive_pool &, adaptive_pool &) BOOST_CONTAINER_NOEXCEPT - {} - - //!An allocator always compares to true, as memory allocated with one - //!instance can be deallocated by another instance - friend bool operator==(const adaptive_pool &, const adaptive_pool &) BOOST_CONTAINER_NOEXCEPT - { return true; } - - //!An allocator always compares to false, as memory allocated with one - //!instance can be deallocated by another instance - friend bool operator!=(const adaptive_pool &, const adaptive_pool &) BOOST_CONTAINER_NOEXCEPT - { return false; } - - private: - std::pair priv_allocation_command - (allocation_type command, std::size_t limit_size - ,std::size_t preferred_size,std::size_t &received_size, void *reuse_ptr) - { - boost_cont_command_ret_t ret = {0 , 0}; - if(limit_size > this->max_size() || preferred_size > this->max_size()){ -// ret.first = 0; - return std::pair(pointer(), false); - } - std::size_t l_size = limit_size*sizeof(T); - std::size_t p_size = preferred_size*sizeof(T); - std::size_t r_size; - { - ret = boost_cont_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr); - } - received_size = r_size/sizeof(T); - return std::pair(static_cast(ret.first), !!ret.second); - } -}; - -} //namespace container { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_CONTAINER_ADAPTIVE_POOL_HPP diff --git a/boost/container/allocator.hpp b/boost/container/allocator.hpp deleted file mode 100644 index 14d5645..0000000 --- a/boost/container/allocator.hpp +++ /dev/null @@ -1,367 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013. Distributed under the 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_ALLOCATOR_HPP -#define BOOST_CONTAINER_ALLOCATOR_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace container { - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -template -class allocator -{ - typedef allocator self_t; - public: - typedef void value_type; - typedef void * pointer; - typedef const void* const_pointer; - typedef int & reference; - typedef const int & const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef boost::container::container_detail:: - version_type version; - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef boost::container::container_detail:: - basic_multiallocation_chain multiallocation_chain; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - //!Obtains an allocator that allocates - //!objects of type T2 - template - struct rebind - { - typedef allocator< T2 - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - , Version, AllocationDisableMask - #endif - > other; - }; - - //!Default constructor - //!Never throws - allocator() - {} - - //!Constructor from other allocator. - //!Never throws - allocator(const allocator &) - {} - - //!Constructor from related allocator. - //!Never throws - template - allocator(const allocator &) - {} -}; - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -//!\file -//! This class is an extended STL-compatible that offers advanced allocation mechanism -//!(in-place expansion, shrinking, burst-allocation...) -//! -//! This allocator is a wrapper around a modified DLmalloc. -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template -#else -//! If Version is 1, the allocator is a STL conforming allocator. If Version is 2, -//! the allocator offers advanced expand in place and burst allocation capabilities. -// -//! AllocationDisableMask works only if Version is 2 and it can be an inclusive OR -//! of allocation types the user wants to disable. -template -#endif //#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -class allocator -{ - typedef unsigned int allocation_type; - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - - //Self type - typedef allocator self_t; - - //Not assignable from related allocator - template - allocator& operator=(const allocator&); - - //Not assignable from other allocator - allocator& operator=(const allocator&); - - static const unsigned int ForbiddenMask = - BOOST_CONTAINER_ALLOCATE_NEW | BOOST_CONTAINER_EXPAND_BWD | BOOST_CONTAINER_EXPAND_FWD ; - - //The mask can't disable all the allocation types - BOOST_STATIC_ASSERT(( (AllocationDisableMask & ForbiddenMask) != ForbiddenMask )); - - //The mask is only valid for version 2 allocators - BOOST_STATIC_ASSERT(( Version != 1 || (AllocationDisableMask == 0) )); - - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - typedef T value_type; - typedef T * pointer; - typedef const T * const_pointer; - typedef T & reference; - typedef const T & const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - typedef boost::container::container_detail:: - version_type version; - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef boost::container::container_detail:: - basic_multiallocation_chain void_multiallocation_chain; - - typedef boost::container::container_detail:: - transform_multiallocation_chain - multiallocation_chain; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - //!Obtains an allocator that allocates - //!objects of type T2 - template - struct rebind - { - typedef allocator other; - }; - - //!Default constructor - //!Never throws - allocator() BOOST_CONTAINER_NOEXCEPT - {} - - //!Constructor from other allocator. - //!Never throws - allocator(const allocator &) BOOST_CONTAINER_NOEXCEPT - {} - - //!Constructor from related allocator. - //!Never throws - template - allocator(const allocator &) BOOST_CONTAINER_NOEXCEPT - {} - - //!Allocates memory for an array of count elements. - //!Throws std::bad_alloc if there is no enough memory - //!If Version is 2, this allocated memory can only be deallocated - //!with deallocate() or (for Version == 2) deallocate_many() - pointer allocate(size_type count, const void * hint= 0) - { - (void)hint; - if(count > this->max_size()) - boost::container::throw_bad_alloc(); - void *ret = boost_cont_malloc(count*sizeof(T)); - if(!ret) - boost::container::throw_bad_alloc(); - return static_cast(ret); - } - - //!Deallocates previously allocated memory. - //!Never throws - void deallocate(pointer ptr, size_type) BOOST_CONTAINER_NOEXCEPT - { boost_cont_free(ptr); } - - //!Returns the maximum number of elements that could be allocated. - //!Never throws - size_type max_size() const BOOST_CONTAINER_NOEXCEPT - { return size_type(-1)/sizeof(T); } - - //!Swaps two allocators, does nothing - //!because this allocator is stateless - friend void swap(self_t &, self_t &) BOOST_CONTAINER_NOEXCEPT - {} - - //!An allocator always compares to true, as memory allocated with one - //!instance can be deallocated by another instance - friend bool operator==(const allocator &, const allocator &) BOOST_CONTAINER_NOEXCEPT - { return true; } - - //!An allocator always compares to false, as memory allocated with one - //!instance can be deallocated by another instance - friend bool operator!=(const allocator &, const allocator &) BOOST_CONTAINER_NOEXCEPT - { return false; } - - //!An advanced function that offers in-place expansion shrink to fit and new allocation - //!capabilities. Memory allocated with this function can only be deallocated with deallocate() - //!or deallocate_many(). - //!This function is available only with Version == 2 - std::pair - allocation_command(allocation_type command, - size_type limit_size, - size_type preferred_size, - size_type &received_size, pointer reuse = pointer()) - { - BOOST_STATIC_ASSERT(( Version > 1 )); - const allocation_type mask(AllocationDisableMask); - command &= ~mask; - std::pair ret = - priv_allocation_command(command, limit_size, preferred_size, received_size, reuse); - if(!ret.first && !(command & BOOST_CONTAINER_NOTHROW_ALLOCATION)) - boost::container::throw_bad_alloc(); - return ret; - } - - //!Returns maximum the number of objects the previously allocated memory - //!pointed by p can hold. - //!Memory must not have been allocated with - //!allocate_one or allocate_individual. - //!This function is available only with Version == 2 - size_type size(pointer p) const BOOST_CONTAINER_NOEXCEPT - { - BOOST_STATIC_ASSERT(( Version > 1 )); - return boost_cont_size(p); - } - - //!Allocates just one object. Memory allocated with this function - //!must be deallocated only with deallocate_one(). - //!Throws bad_alloc if there is no enough memory - //!This function is available only with Version == 2 - pointer allocate_one() - { - BOOST_STATIC_ASSERT(( Version > 1 )); - return this->allocate(1); - } - - //!Allocates many elements of size == 1. - //!Elements must be individually deallocated with deallocate_one() - //!This function is available only with Version == 2 - void allocate_individual(std::size_t num_elements, multiallocation_chain &chain) - { - BOOST_STATIC_ASSERT(( Version > 1 )); - this->allocate_many(1, num_elements, chain); - } - - //!Deallocates memory previously allocated with allocate_one(). - //!You should never use deallocate_one to deallocate memory allocated - //!with other functions different from allocate_one() or allocate_individual. - //Never throws - void deallocate_one(pointer p) BOOST_CONTAINER_NOEXCEPT - { - BOOST_STATIC_ASSERT(( Version > 1 )); - return this->deallocate(p, 1); - } - - //!Deallocates memory allocated with allocate_one() or allocate_individual(). - //!This function is available only with Version == 2 - void deallocate_individual(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT - { - BOOST_STATIC_ASSERT(( Version > 1 )); - return this->deallocate_many(chain); - } - - //!Allocates many elements of size elem_size. - //!Elements must be individually deallocated with deallocate() - //!This function is available only with Version == 2 - void allocate_many(size_type elem_size, std::size_t n_elements, multiallocation_chain &chain) - { - BOOST_STATIC_ASSERT(( Version > 1 ));/* - boost_cont_memchain ch; - BOOST_CONTAINER_MEMCHAIN_INIT(&ch); - if(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){ - boost::container::throw_bad_alloc(); - } - chain.incorporate_after(chain.before_begin() - ,(T*)BOOST_CONTAINER_MEMCHAIN_FIRSTMEM(&ch) - ,(T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch) - ,BOOST_CONTAINER_MEMCHAIN_SIZE(&ch) );*/ - if(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast(&chain))){ - boost::container::throw_bad_alloc(); - } - } - - //!Allocates n_elements elements, each one of size elem_sizes[i] - //!Elements must be individually deallocated with deallocate() - //!This function is available only with Version == 2 - void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain) - { - BOOST_STATIC_ASSERT(( Version > 1 )); - boost_cont_memchain ch; - BOOST_CONTAINER_MEMCHAIN_INIT(&ch); - if(!boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){ - boost::container::throw_bad_alloc(); - } - chain.incorporate_after(chain.before_begin() - ,(T*)BOOST_CONTAINER_MEMCHAIN_FIRSTMEM(&ch) - ,(T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch) - ,BOOST_CONTAINER_MEMCHAIN_SIZE(&ch) ); - /* - if(!boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast(&chain))){ - boost::container::throw_bad_alloc(); - }*/ - } - - //!Deallocates several elements allocated by - //!allocate_many(), allocate(), or allocation_command(). - //!This function is available only with Version == 2 - void deallocate_many(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT - { - BOOST_STATIC_ASSERT(( Version > 1 )); - boost_cont_memchain ch; - void *beg(&*chain.begin()), *last(&*chain.last()); - size_t size(chain.size()); - BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&ch, beg, last, size); - boost_cont_multidealloc(&ch); - //boost_cont_multidealloc(reinterpret_cast(&chain)); - } - - private: - - std::pair priv_allocation_command - (allocation_type command, std::size_t limit_size - ,std::size_t preferred_size,std::size_t &received_size, void *reuse_ptr) - { - boost_cont_command_ret_t ret = {0 , 0}; - if((limit_size > this->max_size()) | (preferred_size > this->max_size())){ - return std::pair(pointer(), false); - } - std::size_t l_size = limit_size*sizeof(T); - std::size_t p_size = preferred_size*sizeof(T); - std::size_t r_size; - { - ret = boost_cont_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr); - } - received_size = r_size/sizeof(T); - return std::pair(static_cast(ret.first), !!ret.second); - } -}; - -} //namespace container { -} //namespace boost { - -#include - -#endif //BOOST_CONTAINER_ALLOCATOR_HPP - diff --git a/boost/container/allocator_traits.hpp b/boost/container/allocator_traits.hpp index a85831f..2c7900e 100644 --- a/boost/container/allocator_traits.hpp +++ b/boost/container/allocator_traits.hpp @@ -13,43 +13,82 @@ // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// - #ifndef BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP #define BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include + +// container #include -#include -#include -#include #include +#include //is_empty #include -#include - -#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#include +#ifndef BOOST_CONTAINER_DETAIL_STD_FWD_HPP +#include #endif +// intrusive +#include +#include +// move +#include +// move/detail +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif +// other boost +#include +#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME allocate +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 2 +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 2 +#include + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME destroy +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 1 +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 1 +#include + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME construct +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace container_detail { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 1 +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 9 +#include + +#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED namespace boost { namespace container { -namespace allocator_traits_detail { - -} #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED +namespace allocator_traits_detail { + +BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_max_size, max_size) +BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_select_on_container_copy_construction, select_on_container_copy_construction) + +} //namespace allocator_traits_detail { + namespace container_detail { //workaround needed for C++03 compilers with no construct() //supporting rvalue references -template +template struct is_std_allocator { static const bool value = false; }; @@ -57,56 +96,81 @@ template struct is_std_allocator< std::allocator > { static const bool value = true; }; +template +struct is_not_std_allocator +{ static const bool value = !is_std_allocator::value; }; + +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer) +BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(const_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference) +BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(void_pointer) +BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(const_void_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(is_always_equal) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(is_partially_propagable) + } //namespace container_detail { #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED //! The class template allocator_traits supplies a uniform interface to all allocator types. //! This class is a C++03-compatible implementation of std::allocator_traits -template +template struct allocator_traits { //allocator_type - typedef Alloc allocator_type; + typedef Allocator allocator_type; //value_type - typedef typename Alloc::value_type value_type; + typedef typename allocator_type::value_type value_type; #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Alloc::pointer if such a type exists; otherwise, value_type* + //! Allocator::pointer if such a type exists; otherwise, value_type* //! typedef unspecified pointer; - //! Alloc::const_pointer if such a type exists ; otherwise, pointer_traits::rebind::rebind::rebind. + //! Allocator::void_pointer if such a type exists ; otherwise, pointer_traits::rebind. //! typedef see_documentation void_pointer; - //! Alloc::const_void_pointer if such a type exists ; otherwis e, pointer_traits::rebind::rebind::difference_type. + //! Allocator::difference_type if such a type exists ; otherwise, pointer_traits::difference_type. //! typedef see_documentation difference_type; - //! Alloc::size_type if such a type exists ; otherwise, make_unsigned::type + //! Allocator::size_type if such a type exists ; otherwise, make_unsigned::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. + //! Allocator::propagate_on_container_copy_assignment if such a type exists, otherwise a type + //! with an internal constant static boolean member value == false. 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. + //! Allocator::propagate_on_container_move_assignment if such a type exists, otherwise a type + //! with an internal constant static boolean member value == false. 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. + //! Allocator::propagate_on_container_swap if such a type exists, otherwise a type + //! with an internal constant static boolean member value == false. typedef see_documentation propagate_on_container_swap; - //! Defines an allocator: Alloc::rebind::other if such a type exists; otherwise, Alloc - //! if Alloc is a class template instantiation of the form Alloc, where Args is zero or + //! Allocator::is_always_equal if such a type exists, otherwise a type + //! with an internal constant static boolean member value == is_empty::value + typedef see_documentation is_always_equal; + //! Allocator::is_partially_propagable if such a type exists, otherwise a type + //! with an internal constant static boolean member value == false + //! Note: Non-standard extension used to implement `small_vector_allocator`. + typedef see_documentation is_partially_propagable; + //! Defines an allocator: Allocator::rebind::other if such a type exists; otherwise, Allocator + //! if Allocator is a class template instantiation of the form Allocator, 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 @@ -119,114 +183,121 @@ struct allocator_traits template using rebind_traits = allocator_traits >; //! Non-standard extension: Portable allocator rebind for C++03 and C++11 compilers. - //! type is an allocator related to Alloc deduced deduced by rules explained in rebind_alloc. + //! type is an allocator related to Allocator deduced deduced by rules explained in rebind_alloc. template struct portable_rebind_alloc { typedef see_documentation type; }; #else //pointer - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator, pointer, value_type*) pointer; //const_pointer - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Allocator, const_pointer, typename boost::intrusive::pointer_traits::template rebind_pointer) const_pointer; //reference - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, - reference, typename container_detail::unvoid::type&) + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator, + reference, typename container_detail::unvoid_ref::type) reference; //const_reference - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, - const_reference, const typename container_detail::unvoid::type&) + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator, + const_reference, typename container_detail::unvoid_ref::type) const_reference; //void_pointer - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Allocator, void_pointer, typename boost::intrusive::pointer_traits::template rebind_pointer) void_pointer; //const_void_pointer - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Allocator, const_void_pointer, typename boost::intrusive::pointer_traits::template rebind_pointer) const_void_pointer; //difference_type - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator, difference_type, std::ptrdiff_t) difference_type; //size_type - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator, size_type, std::size_t) size_type; //propagate_on_container_copy_assignment - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator, propagate_on_container_copy_assignment, container_detail::false_type) propagate_on_container_copy_assignment; //propagate_on_container_move_assignment - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator, propagate_on_container_move_assignment, container_detail::false_type) propagate_on_container_move_assignment; //propagate_on_container_swap - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator, propagate_on_container_swap, container_detail::false_type) propagate_on_container_swap; + //is_always_equal + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator, + is_always_equal, container_detail::is_empty) + is_always_equal; + //is_partially_propagable + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator, + is_partially_propagable, container_detail::false_type) + is_partially_propagable; + //rebind_alloc & rebind_traits #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) //C++11 - template using rebind_alloc = typename boost::intrusive::pointer_rebind::type; + template using rebind_alloc = typename boost::intrusive::pointer_rebind::type; template using rebind_traits = allocator_traits< rebind_alloc >; #else // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) //Some workaround for C++03 or C++11 compilers with no template aliases template - struct rebind_alloc : boost::intrusive::pointer_rebind::type + struct rebind_alloc : boost::intrusive::pointer_rebind::type { - typedef typename boost::intrusive::pointer_rebind::type Base; + typedef typename boost::intrusive::pointer_rebind::type Base; #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template - rebind_alloc(BOOST_FWD_REF(Args)... args) - : Base(boost::forward(args)...) - {} + template + rebind_alloc(BOOST_FWD_REF(Args)... args) : Base(boost::forward(args)...) {} #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - #define BOOST_PP_LOCAL_MACRO(n) \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - rebind_alloc(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - : Base(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \ - {} \ - // - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() + #define BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC(N) \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N\ + explicit rebind_alloc(BOOST_MOVE_UREF##N) : Base(BOOST_MOVE_FWD##N){}\ + // + BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC) + #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) }; template struct rebind_traits - : allocator_traits::type> + : allocator_traits::type> {}; #endif // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + + //portable_rebind_alloc template struct portable_rebind_alloc - { typedef typename boost::intrusive::pointer_rebind::type type; }; + { typedef typename boost::intrusive::pointer_rebind::type type; }; #endif //BOOST_CONTAINER_DOXYGEN_INVOKED //! Returns: a.allocate(n) //! - static pointer allocate(Alloc &a, size_type n) + static pointer allocate(Allocator &a, size_type n) { return a.allocate(n); } //! Returns: a.deallocate(p, n) //! //! Throws: Nothing - static void deallocate(Alloc &a, pointer p, size_type n) + static void deallocate(Allocator &a, pointer p, size_type n) { a.deallocate(p, n); } //! Effects: calls a.allocate(n, p) if that call is well-formed; //! otherwise, invokes a.allocate(n) - static pointer allocate(Alloc &a, size_type n, const_void_pointer p) + static pointer allocate(Allocator &a, size_type n, const_void_pointer p) { const bool value = boost::container::container_detail:: has_member_function_callable_with_allocate - ::value; + ::value; container_detail::bool_ flag; return allocator_traits::priv_allocate(flag, a, n, p); } @@ -234,46 +305,35 @@ struct allocator_traits //! Effects: calls a.destroy(p) if that call is well-formed; //! otherwise, invokes p->~T(). template - static void destroy(Alloc &a, T*p) BOOST_CONTAINER_NOEXCEPT + static void destroy(Allocator &a, T*p) BOOST_NOEXCEPT_OR_NOTHROW { typedef T* destroy_pointer; const bool value = boost::container::container_detail:: has_member_function_callable_with_destroy - ::value; + ::value; container_detail::bool_ flag; allocator_traits::priv_destroy(flag, a, p); } //! Returns: a.max_size() if that expression is well-formed; otherwise, //! numeric_limits::max(). - static size_type max_size(const Alloc &a) BOOST_CONTAINER_NOEXCEPT + static size_type max_size(const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW { - const bool value = boost::container::container_detail:: - has_member_function_callable_with_max_size - ::value; + const bool value = allocator_traits_detail::has_max_size::value; container_detail::bool_ flag; return allocator_traits::priv_max_size(flag, a); } //! Returns: a.select_on_container_copy_construction() if that expression is well-formed; //! otherwise, a. - static - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - typename container_detail::if_c - < boost::container::container_detail:: - has_member_function_callable_with_select_on_container_copy_construction - ::value - , Alloc - , const Alloc & - >::type - #else - Alloc - #endif - select_on_container_copy_construction(const Alloc &a) + static BOOST_CONTAINER_DOC1ST(Allocator, + typename container_detail::if_c + < allocator_traits_detail::has_select_on_container_copy_construction::value + BOOST_MOVE_I Allocator BOOST_MOVE_I const Allocator & >::type) + select_on_container_copy_construction(const Allocator &a) { - const bool value = boost::container::container_detail:: - has_member_function_callable_with_select_on_container_copy_construction - ::value; + const bool value = allocator_traits_detail::has_select_on_container_copy_construction + ::value; container_detail::bool_ flag; return allocator_traits::priv_select_on_container_copy_construction(flag, a); } @@ -282,123 +342,124 @@ struct allocator_traits //! Effects: calls a.construct(p, std::forward(args)...) if that call is well-formed; //! otherwise, invokes ::new (static_cast(p)) T(std::forward(args)...) template - static void construct(Alloc & a, T* p, BOOST_FWD_REF(Args)... args) + static void construct(Allocator & a, T* p, BOOST_FWD_REF(Args)... args) { - container_detail::bool_::value> flag; + static const bool value = ::boost::move_detail::and_ + < container_detail::is_not_std_allocator + , boost::container::container_detail::has_member_function_callable_with_construct + < Allocator, T*, Args... > + >::value; + container_detail::bool_ flag; allocator_traits::priv_construct(flag, a, p, ::boost::forward(args)...); } #endif - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + + //! Returns: a.storage_is_unpropagable(p) if is_partially_propagable::value is true; otherwise, + //! false. + static bool storage_is_unpropagable(const Allocator &a, pointer p) BOOST_NOEXCEPT_OR_NOTHROW + { + container_detail::bool_ flag; + return allocator_traits::priv_storage_is_unpropagable(flag, a, p); + } + + //! Returns: true if is_always_equal::value == true, otherwise, + //! a == b. + static bool equal(const Allocator &a, const Allocator &b) BOOST_NOEXCEPT_OR_NOTHROW + { + container_detail::bool_ flag; + return allocator_traits::priv_equal(flag, a, b); + } + #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + private: + static pointer priv_allocate(container_detail::true_type, Allocator &a, size_type n, const_void_pointer p) + { return a.allocate(n, p); } + + static pointer priv_allocate(container_detail::false_type, Allocator &a, size_type n, const_void_pointer) + { return a.allocate(n); } + + template + static void priv_destroy(container_detail::true_type, Allocator &a, T* p) BOOST_NOEXCEPT_OR_NOTHROW + { a.destroy(p); } + + template + static void priv_destroy(container_detail::false_type, Allocator &, T* p) BOOST_NOEXCEPT_OR_NOTHROW + { p->~T(); (void)p; } + + static size_type priv_max_size(container_detail::true_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW + { return a.max_size(); } + + static size_type priv_max_size(container_detail::false_type, const Allocator &) BOOST_NOEXCEPT_OR_NOTHROW + { return size_type(-1)/sizeof(value_type); } + + static Allocator priv_select_on_container_copy_construction(container_detail::true_type, const Allocator &a) + { return a.select_on_container_copy_construction(); } + + static const Allocator &priv_select_on_container_copy_construction(container_detail::false_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW + { return a; } + + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + template + static void priv_construct(container_detail::true_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args) + { a.construct( p, ::boost::forward(args)...); } + + template + static void priv_construct(container_detail::false_type, Allocator &, T *p, BOOST_FWD_REF(Args) ...args) + { ::new((void*)p, boost_container_new_t()) T(::boost::forward(args)...); } + #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + public: + + #define BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL(N) \ + template\ + static void construct(Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + static const bool value = ::boost::move_detail::and_ \ + < container_detail::is_not_std_allocator \ + , boost::container::container_detail::has_member_function_callable_with_construct \ + < Allocator, T* BOOST_MOVE_I##N BOOST_MOVE_FWD_T##N > \ + >::value; \ + container_detail::bool_ flag;\ + (priv_construct)(flag, a, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + }\ + // + BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL) + #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL + private: - static pointer priv_allocate(container_detail::true_type, Alloc &a, size_type n, const_void_pointer p) - { return a.allocate(n, p); } + ///////////////////////////////// + // priv_construct + ///////////////////////////////// + #define BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL(N) \ + template\ + static void priv_construct(container_detail::true_type, Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + { a.construct( p BOOST_MOVE_I##N BOOST_MOVE_FWD##N ); }\ + \ + template\ + static void priv_construct(container_detail::false_type, Allocator &, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + { ::new((void*)p, boost_container_new_t()) T(BOOST_MOVE_FWD##N); }\ + // + BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL) + #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL - static pointer priv_allocate(container_detail::false_type, Alloc &a, size_type n, const_void_pointer) - { return allocator_traits::allocate(a, n); } + #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template - static void priv_destroy(container_detail::true_type, Alloc &a, T* p) BOOST_CONTAINER_NOEXCEPT - { a.destroy(p); } + template + static void priv_construct(container_detail::false_type, Allocator &, T *p, const ::boost::container::default_init_t&) + { ::new((void*)p) T; } - template - static void priv_destroy(container_detail::false_type, Alloc &, T* p) BOOST_CONTAINER_NOEXCEPT - { p->~T(); (void)p; } + static bool priv_storage_is_unpropagable(container_detail::true_type, const Allocator &a, pointer p) + { return a.storage_is_unpropagable(p); } - static size_type priv_max_size(container_detail::true_type, const Alloc &a) BOOST_CONTAINER_NOEXCEPT - { return a.max_size(); } + static bool priv_storage_is_unpropagable(container_detail::false_type, const Allocator &, pointer) + { return false; } - static size_type priv_max_size(container_detail::false_type, const Alloc &) BOOST_CONTAINER_NOEXCEPT - { return size_type(-1); } + static bool priv_equal(container_detail::true_type, const Allocator &, const Allocator &) + { return true; } - static Alloc priv_select_on_container_copy_construction(container_detail::true_type, const Alloc &a) - { return a.select_on_container_copy_construction(); } + static bool priv_equal(container_detail::false_type, const Allocator &a, const Allocator &b) + { return a == b; } - static const Alloc &priv_select_on_container_copy_construction(container_detail::false_type, const Alloc &a) BOOST_CONTAINER_NOEXCEPT - { return a; } - - #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template - static void priv_construct(container_detail::false_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) - { - const bool value = boost::container::container_detail:: - has_member_function_callable_with_construct - < Alloc, T*, Args... >::value; - container_detail::bool_ flag; - priv_construct_dispatch2(flag, a, p, ::boost::forward(args)...); - } - - template - static void priv_construct(container_detail::true_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) - { - priv_construct_dispatch2(container_detail::false_type(), a, p, ::boost::forward(args)...); - } - - template - static void priv_construct_dispatch2(container_detail::true_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) - { a.construct( p, ::boost::forward(args)...); } - - template - static void priv_construct_dispatch2(container_detail::false_type, Alloc &, T *p, BOOST_FWD_REF(Args) ...args) - { ::new((void*)p, boost_container_new_t()) T(::boost::forward(args)...); } - #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - public: - #define BOOST_PP_LOCAL_MACRO(n) \ - template \ - static void construct(Alloc &a, T *p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - container_detail::bool_ \ - ::value> flag; \ - allocator_traits::priv_construct(flag, a, 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() - - private: - #define BOOST_PP_LOCAL_MACRO(n) \ - template \ - static void priv_construct(container_detail::false_type, Alloc &a, T *p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ - { \ - const bool value = \ - boost::container::container_detail::has_member_function_callable_with_construct \ - < Alloc, T* BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_FWD_TYPE, _) >::value; \ - container_detail::bool_ flag; \ - priv_construct_dispatch2(flag, a, p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - } \ - \ - template \ - static void priv_construct(container_detail::true_type, Alloc &a, T *p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ - { \ - priv_construct_dispatch2(container_detail::false_type(), a, p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - } \ - \ - template \ - static void priv_construct_dispatch2(container_detail::true_type, Alloc &a, T *p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ - { a.construct( p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); } \ - \ - template \ - static void priv_construct_dispatch2(container_detail::false_type, Alloc &, T *p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ - { ::new((void*)p, boost_container_new_t()) T(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); }\ - // - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() - #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - template - static void priv_construct_dispatch2(container_detail::false_type, Alloc &, T *p, ::boost::container::default_init_t) - { ::new((void*)p) T; } #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED }; } //namespace container { diff --git a/boost/container/container_fwd.hpp b/boost/container/container_fwd.hpp index 20ac778..a9b421c 100644 --- a/boost/container/container_fwd.hpp +++ b/boost/container/container_fwd.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_CONTAINER_FWD_HPP #define BOOST_CONTAINER_CONTAINER_FWD_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -80,27 +84,34 @@ enum tree_type_enum #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED +template +class new_allocator; + template > + ,class Allocator = new_allocator > class vector; template > + ,class Allocator = new_allocator > class stable_vector; template class static_vector; +template < class T, std::size_t N + , class Allocator= new_allocator > +class small_vector; + template > + ,class Allocator = new_allocator > class deque; template > + ,class Allocator = new_allocator > class list; template > + ,class Allocator = new_allocator > class slist; template @@ -110,67 +121,67 @@ typedef tree_opt tree_assoc_defaults; template - ,class Allocator = std::allocator + ,class Allocator = new_allocator ,class Options = tree_assoc_defaults > class set; template - ,class Allocator = std::allocator + ,class Allocator = new_allocator ,class Options = tree_assoc_defaults > class multiset; template - ,class Allocator = std::allocator > + ,class Allocator = new_allocator > ,class Options = tree_assoc_defaults > class map; template - ,class Allocator = std::allocator > + ,class Allocator = new_allocator > ,class Options = tree_assoc_defaults > class multimap; template - ,class Allocator = std::allocator > + ,class Allocator = new_allocator > class flat_set; template - ,class Allocator = std::allocator > + ,class Allocator = new_allocator > class flat_multiset; template - ,class Allocator = std::allocator > > + ,class Allocator = new_allocator > > class flat_map; template - ,class Allocator = std::allocator > > + ,class Allocator = new_allocator > > class flat_multimap; template - ,class Allocator = std::allocator > + ,class Allocator = new_allocator > class basic_string; typedef basic_string - ,std::allocator > + ,new_allocator > string; typedef basic_string - ,std::allocator > + ,new_allocator > wstring; static const std::size_t ADP_nodes_per_block = 256u; diff --git a/boost/container/deque.hpp b/boost/container/deque.hpp deleted file mode 100644 index d8a546c..0000000 --- a/boost/container/deque.hpp +++ /dev/null @@ -1,2069 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_DEQUE_HPP -#define BOOST_CONTAINER_DEQUE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) -#include -#endif - -namespace boost { -namespace container { - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -template -class deque; - -template -struct deque_value_traits -{ - typedef T value_type; - static const bool trivial_dctr = boost::has_trivial_destructor::value; - static const bool trivial_dctr_after_move = ::boost::has_trivial_destructor_after_move::value; - static const bool trivial_copy = has_trivial_copy::value; - static const bool nothrow_copy = has_nothrow_copy::value; - static const bool trivial_assign = has_trivial_assign::value; - //static const bool nothrow_assign = has_nothrow_assign::value; - static const bool nothrow_assign = false; -}; - -// Note: this function is simply a kludge to work around several compilers' -// bugs in handling constant expressions. -template -struct deque_buf_size -{ - static const std::size_t min_size = 512u; - static const std::size_t sizeof_t = sizeof(T); - static const std::size_t value = sizeof_t < min_size ? (min_size/sizeof_t) : std::size_t(1); -}; - -namespace container_detail { - -// Class invariants: -// For any nonsingular iterator i: -// i.node is the address of an element in the map array. The -// contents of i.node is a pointer to the beginning of a node. -// i.first == //(i.node) -// i.last == i.first + node_size -// i.cur is a pointer in the range [i.first, i.last). NOTE: -// the implication of this is that i.cur is always a dereferenceable -// pointer, even if i is a past-the-end iterator. -// Start and Finish are always nonsingular iterators. NOTE: this means -// that an empty deque must have one node, and that a deque -// with N elements, where N is the buffer size, must have two nodes. -// For every node other than start.node and finish.node, every element -// in the node is an initialized object. If start.node == finish.node, -// then [start.cur, finish.cur) are initialized objects, and -// the elements outside that range are uninitialized storage. Otherwise, -// [start.cur, start.last) and [finish.first, finish.cur) are initialized -// objects, and [start.first, start.cur) and [finish.cur, finish.last) -// are uninitialized storage. -// [map, map + map_size) is a valid, non-empty range. -// [start.node, finish.node] is a valid range contained within -// [map, map + map_size). -// Allocator pointer in the range [map, map + map_size) points to an allocated node -// if and only if the pointer is in the range [start.node, finish.node]. -template -class deque_iterator -{ - public: - typedef std::random_access_iterator_tag iterator_category; - typedef typename boost::intrusive::pointer_traits::element_type value_type; - typedef typename boost::intrusive::pointer_traits::difference_type difference_type; - typedef typename if_c - < IsConst - , typename boost::intrusive::pointer_traits::template - rebind_pointer::type - , Pointer - >::type pointer; - typedef typename if_c - < IsConst - , const value_type& - , value_type& - >::type reference; - - static std::size_t s_buffer_size() - { return deque_buf_size::value; } - - typedef Pointer val_alloc_ptr; - typedef typename boost::intrusive::pointer_traits:: - template rebind_pointer::type index_pointer; - - Pointer m_cur; - Pointer m_first; - Pointer m_last; - index_pointer m_node; - - public: - - Pointer get_cur() const { return m_cur; } - Pointer get_first() const { return m_first; } - Pointer get_last() const { return m_last; } - index_pointer get_node() const { return m_node; } - - deque_iterator(val_alloc_ptr x, index_pointer y) BOOST_CONTAINER_NOEXCEPT - : m_cur(x), m_first(*y), m_last(*y + s_buffer_size()), m_node(y) - {} - - deque_iterator() BOOST_CONTAINER_NOEXCEPT - : m_cur(), m_first(), m_last(), m_node() //Value initialization to achieve "null iterators" (N3644) - {} - - deque_iterator(deque_iterator const& x) BOOST_CONTAINER_NOEXCEPT - : m_cur(x.get_cur()), m_first(x.get_first()), m_last(x.get_last()), m_node(x.get_node()) - {} - - deque_iterator(Pointer cur, Pointer first, Pointer last, index_pointer node) BOOST_CONTAINER_NOEXCEPT - : m_cur(cur), m_first(first), m_last(last), m_node(node) - {} - - deque_iterator unconst() const BOOST_CONTAINER_NOEXCEPT - { - return deque_iterator(this->get_cur(), this->get_first(), this->get_last(), this->get_node()); - } - - reference operator*() const BOOST_CONTAINER_NOEXCEPT - { return *this->m_cur; } - - pointer operator->() const BOOST_CONTAINER_NOEXCEPT - { return this->m_cur; } - - difference_type operator-(const deque_iterator& x) const BOOST_CONTAINER_NOEXCEPT - { - if(!this->m_cur && !x.m_cur){ - return 0; - } - return difference_type(this->s_buffer_size()) * (this->m_node - x.m_node - 1) + - (this->m_cur - this->m_first) + (x.m_last - x.m_cur); - } - - deque_iterator& operator++() BOOST_CONTAINER_NOEXCEPT - { - ++this->m_cur; - if (this->m_cur == this->m_last) { - this->priv_set_node(this->m_node + 1); - this->m_cur = this->m_first; - } - return *this; - } - - deque_iterator operator++(int) BOOST_CONTAINER_NOEXCEPT - { - deque_iterator tmp(*this); - ++*this; - return tmp; - } - - deque_iterator& operator--() BOOST_CONTAINER_NOEXCEPT - { - if (this->m_cur == this->m_first) { - this->priv_set_node(this->m_node - 1); - this->m_cur = this->m_last; - } - --this->m_cur; - return *this; - } - - deque_iterator operator--(int) BOOST_CONTAINER_NOEXCEPT - { - deque_iterator tmp(*this); - --*this; - return tmp; - } - - deque_iterator& operator+=(difference_type n) BOOST_CONTAINER_NOEXCEPT - { - difference_type offset = n + (this->m_cur - this->m_first); - if (offset >= 0 && offset < difference_type(this->s_buffer_size())) - this->m_cur += n; - else { - difference_type node_offset = - offset > 0 ? offset / difference_type(this->s_buffer_size()) - : -difference_type((-offset - 1) / this->s_buffer_size()) - 1; - this->priv_set_node(this->m_node + node_offset); - this->m_cur = this->m_first + - (offset - node_offset * difference_type(this->s_buffer_size())); - } - return *this; - } - - deque_iterator operator+(difference_type n) const BOOST_CONTAINER_NOEXCEPT - { deque_iterator tmp(*this); return tmp += n; } - - deque_iterator& operator-=(difference_type n) BOOST_CONTAINER_NOEXCEPT - { return *this += -n; } - - deque_iterator operator-(difference_type n) const BOOST_CONTAINER_NOEXCEPT - { deque_iterator tmp(*this); return tmp -= n; } - - reference operator[](difference_type n) const BOOST_CONTAINER_NOEXCEPT - { return *(*this + n); } - - friend bool operator==(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return l.m_cur == r.m_cur; } - - friend bool operator!=(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return l.m_cur != r.m_cur; } - - friend bool operator<(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return (l.m_node == r.m_node) ? (l.m_cur < r.m_cur) : (l.m_node < r.m_node); } - - friend bool operator>(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return r < l; } - - friend bool operator<=(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return !(r < l); } - - friend bool operator>=(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return !(l < r); } - - void priv_set_node(index_pointer new_node) BOOST_CONTAINER_NOEXCEPT - { - this->m_node = new_node; - this->m_first = *new_node; - this->m_last = this->m_first + this->s_buffer_size(); - } - - friend deque_iterator operator+(difference_type n, deque_iterator x) BOOST_CONTAINER_NOEXCEPT - { return x += n; } -}; - -} //namespace container_detail { - -// Deque base class. It has two purposes. First, its constructor -// and destructor allocate (but don't initialize) storage. This makes -// exception safety easier. -template -class deque_base -{ - BOOST_COPYABLE_AND_MOVABLE(deque_base) - public: - typedef allocator_traits 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::type ptr_alloc_t; - typedef allocator_traits 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; - typedef typename ptr_alloc_traits_type::reference ptr_alloc_ref; - typedef typename ptr_alloc_traits_type::const_reference ptr_alloc_cref; - typedef Allocator allocator_type; - typedef allocator_type stored_allocator_type; - typedef val_alloc_size size_type; - - protected: - - typedef deque_value_traits traits_t; - typedef ptr_alloc_t map_allocator_type; - - static size_type s_buffer_size() BOOST_CONTAINER_NOEXCEPT - { return deque_buf_size::value; } - - val_alloc_ptr priv_allocate_node() - { return this->alloc().allocate(s_buffer_size()); } - - void priv_deallocate_node(val_alloc_ptr p) BOOST_CONTAINER_NOEXCEPT - { this->alloc().deallocate(p, s_buffer_size()); } - - ptr_alloc_ptr priv_allocate_map(size_type n) - { return this->ptr_alloc().allocate(n); } - - void priv_deallocate_map(ptr_alloc_ptr p, size_type n) BOOST_CONTAINER_NOEXCEPT - { this->ptr_alloc().deallocate(p, n); } - - typedef container_detail::deque_iterator iterator; - typedef container_detail::deque_iterator const_iterator; - - deque_base(size_type num_elements, const allocator_type& a) - : members_(a) - { this->priv_initialize_map(num_elements); } - - explicit deque_base(const allocator_type& a) - : members_(a) - {} - - deque_base() - : members_() - {} - - explicit deque_base(BOOST_RV_REF(deque_base) x) - : members_( boost::move(x.ptr_alloc()) - , boost::move(x.alloc()) ) - {} - - ~deque_base() - { - if (this->members_.m_map) { - this->priv_destroy_nodes(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1); - this->priv_deallocate_map(this->members_.m_map, this->members_.m_map_size); - } - } - - private: - deque_base(const deque_base&); - - protected: - - void swap_members(deque_base &x) BOOST_CONTAINER_NOEXCEPT - { - std::swap(this->members_.m_start, x.members_.m_start); - std::swap(this->members_.m_finish, x.members_.m_finish); - std::swap(this->members_.m_map, x.members_.m_map); - std::swap(this->members_.m_map_size, x.members_.m_map_size); - } - - void priv_initialize_map(size_type num_elements) - { -// if(num_elements){ - size_type num_nodes = num_elements / s_buffer_size() + 1; - - this->members_.m_map_size = container_detail::max_value((size_type) InitialMapSize, num_nodes + 2); - this->members_.m_map = this->priv_allocate_map(this->members_.m_map_size); - - ptr_alloc_ptr nstart = this->members_.m_map + (this->members_.m_map_size - num_nodes) / 2; - ptr_alloc_ptr nfinish = nstart + num_nodes; - - BOOST_TRY { - this->priv_create_nodes(nstart, nfinish); - } - BOOST_CATCH(...){ - this->priv_deallocate_map(this->members_.m_map, this->members_.m_map_size); - this->members_.m_map = 0; - this->members_.m_map_size = 0; - BOOST_RETHROW - } - BOOST_CATCH_END - - this->members_.m_start.priv_set_node(nstart); - this->members_.m_finish.priv_set_node(nfinish - 1); - this->members_.m_start.m_cur = this->members_.m_start.m_first; - this->members_.m_finish.m_cur = this->members_.m_finish.m_first + - num_elements % s_buffer_size(); -// } - } - - void priv_create_nodes(ptr_alloc_ptr nstart, ptr_alloc_ptr nfinish) - { - ptr_alloc_ptr cur; - BOOST_TRY { - for (cur = nstart; cur < nfinish; ++cur) - *cur = this->priv_allocate_node(); - } - BOOST_CATCH(...){ - this->priv_destroy_nodes(nstart, cur); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - void priv_destroy_nodes(ptr_alloc_ptr nstart, ptr_alloc_ptr nfinish) BOOST_CONTAINER_NOEXCEPT - { - for (ptr_alloc_ptr n = nstart; n < nfinish; ++n) - this->priv_deallocate_node(*n); - } - - void priv_clear_map() BOOST_CONTAINER_NOEXCEPT - { - if (this->members_.m_map) { - this->priv_destroy_nodes(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1); - this->priv_deallocate_map(this->members_.m_map, this->members_.m_map_size); - this->members_.m_map = 0; - this->members_.m_map_size = 0; - this->members_.m_start = iterator(); - this->members_.m_finish = this->members_.m_start; - } - } - - enum { InitialMapSize = 8 }; - - protected: - struct members_holder - : public ptr_alloc_t - , public allocator_type - { - members_holder() - : map_allocator_type(), allocator_type() - , m_map(0), m_map_size(0) - , m_start(), m_finish(m_start) - {} - - explicit members_holder(const allocator_type &a) - : map_allocator_type(a), allocator_type(a) - , m_map(0), m_map_size(0) - , m_start(), m_finish(m_start) - {} - - template - members_holder(BOOST_FWD_REF(PtrAllocConvertible) pa, BOOST_FWD_REF(ValAllocConvertible) va) - : map_allocator_type(boost::forward(pa)) - , allocator_type (boost::forward(va)) - , m_map(0), m_map_size(0) - , m_start(), m_finish(m_start) - {} - - ptr_alloc_ptr m_map; - val_alloc_size m_map_size; - iterator m_start; - iterator m_finish; - } members_; - - ptr_alloc_t &ptr_alloc() BOOST_CONTAINER_NOEXCEPT - { return members_; } - - const ptr_alloc_t &ptr_alloc() const BOOST_CONTAINER_NOEXCEPT - { return members_; } - - allocator_type &alloc() BOOST_CONTAINER_NOEXCEPT - { return members_; } - - const allocator_type &alloc() const BOOST_CONTAINER_NOEXCEPT - { return members_; } -}; -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -//! A double-ended queue is a sequence that supports random access to elements, constant time insertion -//! and removal of elements at the end of the sequence, and linear time insertion and removal of elements in the middle. -//! -//! \tparam T The type of object that is stored in the deque -//! \tparam Allocator The allocator used for all internal memory management -template > -#else -template -#endif -class deque : protected deque_base -{ - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - typedef deque_base Base; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - - ////////////////////////////////////////////// - // - // types - // - ////////////////////////////////////////////// - - typedef T value_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator 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(container_detail::reverse_iterator) reverse_iterator; - typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) const_reverse_iterator; - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - private: // Internal typedefs - BOOST_COPYABLE_AND_MOVABLE(deque) - typedef typename Base::ptr_alloc_ptr index_pointer; - static size_type s_buffer_size() - { return Base::s_buffer_size(); } - typedef allocator_traits allocator_traits_type; - - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - ////////////////////////////////////////////// - // - // construct/copy/destroy - // - ////////////////////////////////////////////// - - //! Effects: Default constructors a deque. - //! - //! Throws: If allocator_type's default constructor throws. - //! - //! Complexity: Constant. - deque() - : Base() - {} - - //! Effects: Constructs a deque taking the allocator as parameter. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - explicit deque(const allocator_type& a) BOOST_CONTAINER_NOEXCEPT - : Base(a) - {} - - //! Effects: Constructs a deque that will use a copy of allocator a - //! and inserts n value initialized values. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's value initialization throws. - //! - //! Complexity: Linear to n. - explicit deque(size_type n) - : Base(n, allocator_type()) - { - container_detail::insert_value_initialized_n_proxy proxy; - proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n); - //deque_base will deallocate in case of exception... - } - - //! Effects: Constructs a deque that will use a copy of allocator a - //! and inserts n default initialized values. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's default initialization or copy constructor throws. - //! - //! Complexity: Linear to n. - //! - //! Note: Non-standard extension - deque(size_type n, default_init_t) - : Base(n, allocator_type()) - { - container_detail::insert_default_initialized_n_proxy proxy; - proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n); - //deque_base will deallocate in case of exception... - } - - //! Effects: Constructs a deque that will use a copy of allocator a - //! and inserts n copies of value. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's copy constructor throws. - //! - //! Complexity: 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); } - - //! Effects: Constructs a deque that will use a copy of allocator a - //! and inserts a copy of the range [first, last) in the deque. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's constructor taking a dereferenced InIt throws. - //! - //! Complexity: Linear to the range [first, last). - template - 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::value - >::type * = 0 - #endif - ) - : Base(a) - { - typedef typename std::iterator_traits::iterator_category ItCat; - this->priv_range_initialize(first, last, ItCat()); - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs a deque that will use a copy of allocator a - //! and inserts a copy of the range [il.begin(), il.end()) in the deque. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's constructor taking a dereferenced std::initializer_list iterator throws. - //! - //! Complexity: Linear to the range [il.begin(), il.end()). - deque(std::initializer_list il, const allocator_type& a = allocator_type()) - : Base(a) - { - this->priv_range_initialize(il.begin(), il.end(), std::input_iterator_tag()); - } -#endif - - //! Effects: Copy constructs a deque. - //! - //! Postcondition: x == *this. - //! - //! Complexity: 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); - } - } - - //! Effects: Move constructor. Moves mx's resources to *this. - //! - //! Throws: If allocator_type's copy constructor throws. - //! - //! Complexity: Constant. - deque(BOOST_RV_REF(deque) x) - : Base(boost::move(static_cast(x))) - { this->swap_members(x); } - - //! Effects: Copy constructs a vector using the specified allocator. - //! - //! Postcondition: x == *this. - //! - //! Throws: If allocation - //! throws or T's copy constructor throws. - //! - //! Complexity: 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); - } - } - - //! Effects: Move constructor using the specified allocator. - //! Moves mx's resources to *this if a == allocator_type(). - //! Otherwise copies values from x to *this. - //! - //! Throws: If allocation or T's copy constructor throws. - //! - //! Complexity: 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); - } - } - } - - //! Effects: Destroys the deque. All stored values are destroyed - //! and used memory is deallocated. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements. - ~deque() BOOST_CONTAINER_NOEXCEPT - { - this->priv_destroy_range(this->members_.m_start, this->members_.m_finish); - } - - //! Effects: Makes *this contain the same elements as x. - //! - //! Postcondition: this->size() == x.size(). *this contains a copy - //! of each of x's elements. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: 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_ 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; - } - - //! Effects: Move assignment. All x's values are transferred to *this. - //! - //! Throws: If allocator_traits_type::propagate_on_container_move_assignment - //! is false and (allocation throws or value_type's move constructor throws) - //! - //! Complexity: Constant if allocator_traits_type:: - //! propagate_on_container_move_assignment is true or - //! this->get>allocator() == x.get_allocator(). Linear otherwise. - deque& operator= (BOOST_RV_REF(deque) x) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) - { - BOOST_ASSERT(this != &x); - allocator_type &this_alloc = this->alloc(); - allocator_type &x_alloc = x.alloc(); - const bool propagate_alloc = allocator_traits_type:: - propagate_on_container_move_assignment::value; - container_detail::bool_ flag; - const bool allocators_equal = this_alloc == x_alloc; (void)allocators_equal; - //Resources can be transferred if both allocators are - //going to be equal after this function (either propagated or already equal) - if(propagate_alloc || allocators_equal){ - //Destroy objects but retain memory in case x reuses it in the future - this->clear(); - //Move allocator if needed - container_detail::move_alloc(this_alloc, x_alloc, flag); - container_detail::move_alloc(this->ptr_alloc(), x.ptr_alloc(), flag); - //Nothrow swap - this->swap_members(x); - } - //Else do a one by one move - else{ - this->assign( boost::make_move_iterator(x.begin()) - , boost::make_move_iterator(x.end())); - } - return *this; - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Makes *this contain the same elements as il. - //! - //! Postcondition: this->size() == il.size(). *this contains a copy - //! of each of x's elements. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to the number of elements in il. - deque& operator=(std::initializer_list il) - { - this->assign(il.begin(), il.end()); - return *this; - } -#endif - - //! Effects: Assigns the n copies of val to *this. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to n. - void assign(size_type n, const T& val) - { - typedef constant_iterator c_it; - this->assign(c_it(val, n), c_it()); - } - - //! Effects: Assigns the the range [first, last) to *this. - //! - //! Throws: If memory allocation throws or - //! T's constructor from dereferencing InIt throws. - //! - //! Complexity: Linear to n. - template - void assign(InIt first, InIt last - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - && container_detail::is_input_iterator::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 - void assign(FwdIt first, FwdIt last - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - && !container_detail::is_input_iterator::value - >::type * = 0 - ) - { - const size_type len = std::distance(first, last); - if (len > size()) { - FwdIt mid = first; - std::advance(mid, this->size()); - boost::container::copy(first, mid, begin()); - this->insert(this->cend(), mid, last); - } - else{ - this->erase(boost::container::copy(first, last, this->begin()), cend()); - } - } - #endif - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Assigns the the range [il.begin(), il.end()) to *this. - //! - //! Throws: If memory allocation throws or - //! T's constructor from dereferencing std::initializer_list iterator throws. - //! - //! Complexity: Linear to il.size(). - void assign(std::initializer_list il) - { this->assign(il.begin(), il.end()); } -#endif - - //! Effects: Returns a copy of the internal allocator. - //! - //! Throws: If allocator's copy constructor throws. - //! - //! Complexity: Constant. - allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT - { return Base::alloc(); } - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT - { return Base::alloc(); } - - ////////////////////////////////////////////// - // - // iterators - // - ////////////////////////////////////////////// - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT - { return Base::alloc(); } - - //! Effects: Returns an iterator to the first element contained in the deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator begin() BOOST_CONTAINER_NOEXCEPT - { return this->members_.m_start; } - - //! Effects: Returns a const_iterator to the first element contained in the deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator begin() const BOOST_CONTAINER_NOEXCEPT - { return this->members_.m_start; } - - //! Effects: Returns an iterator to the end of the deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator end() BOOST_CONTAINER_NOEXCEPT - { return this->members_.m_finish; } - - //! Effects: Returns a const_iterator to the end of the deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator end() const BOOST_CONTAINER_NOEXCEPT - { return this->members_.m_finish; } - - //! Effects: Returns a reverse_iterator pointing to the beginning - //! of the reversed deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT - { return reverse_iterator(this->members_.m_finish); } - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT - { return const_reverse_iterator(this->members_.m_finish); } - - //! Effects: Returns a reverse_iterator pointing to the end - //! of the reversed deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT - { return reverse_iterator(this->members_.m_start); } - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT - { return const_reverse_iterator(this->members_.m_start); } - - //! Effects: Returns a const_iterator to the first element contained in the deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT - { return this->members_.m_start; } - - //! Effects: Returns a const_iterator to the end of the deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT - { return this->members_.m_finish; } - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT - { return const_reverse_iterator(this->members_.m_finish); } - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT - { return const_reverse_iterator(this->members_.m_start); } - - ////////////////////////////////////////////// - // - // capacity - // - ////////////////////////////////////////////// - - //! Effects: Returns true if the deque contains no elements. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - bool empty() const BOOST_CONTAINER_NOEXCEPT - { return this->members_.m_finish == this->members_.m_start; } - - //! Effects: Returns the number of the elements contained in the deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type size() const BOOST_CONTAINER_NOEXCEPT - { return this->members_.m_finish - this->members_.m_start; } - - //! Effects: Returns the largest possible size of the deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type max_size() const BOOST_CONTAINER_NOEXCEPT - { return allocator_traits_type::max_size(this->alloc()); } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are value initialized. - //! - //! Throws: If memory allocation throws, or T's constructor throws. - //! - //! Complexity: 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::insert_value_initialized_n_proxy proxy; - priv_insert_back_aux_impl(n, proxy); - } - } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are default initialized. - //! - //! Throws: If memory allocation throws, or T's constructor throws. - //! - //! Complexity: Linear to the difference between size() and new_size. - //! - //! Note: Non-standard extension - void resize(size_type new_size, default_init_t) - { - 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::insert_default_initialized_n_proxy proxy; - priv_insert_back_aux_impl(n, proxy); - } - } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are copy constructed from x. - //! - //! Throws: If memory allocation throws, or T's copy constructor throws. - //! - //! Complexity: 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); - } - - //! Effects: Tries to deallocate the excess of memory created - //! with previous allocations. The size of the deque is unchanged - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: Constant. - 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 - // - ////////////////////////////////////////////// - - //! Requires: !empty() - //! - //! Effects: Returns a reference to the first - //! element of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference front() BOOST_CONTAINER_NOEXCEPT - { return *this->members_.m_start; } - - //! Requires: !empty() - //! - //! Effects: Returns a const reference to the first element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference front() const BOOST_CONTAINER_NOEXCEPT - { return *this->members_.m_start; } - - //! Requires: !empty() - //! - //! Effects: Returns a reference to the last - //! element of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference back() BOOST_CONTAINER_NOEXCEPT - { return *(end()-1); } - - //! Requires: !empty() - //! - //! Effects: Returns a const reference to the last - //! element of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference back() const BOOST_CONTAINER_NOEXCEPT - { return *(cend()-1); } - - //! Requires: size() > n. - //! - //! Effects: Returns a reference to the nth element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT - { return this->members_.m_start[difference_type(n)]; } - - //! Requires: size() > n. - //! - //! Effects: Returns a const reference to the nth element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT - { return this->members_.m_start[difference_type(n)]; } - - //! Requires: size() > n. - //! - //! Effects: Returns a reference to the nth element - //! from the beginning of the container. - //! - //! Throws: std::range_error if n >= size() - //! - //! Complexity: Constant. - reference at(size_type n) - { this->priv_range_check(n); return (*this)[n]; } - - //! Requires: size() > n. - //! - //! Effects: Returns a const reference to the nth element - //! from the beginning of the container. - //! - //! Throws: std::range_error if n >= size() - //! - //! Complexity: Constant. - const_reference at(size_type n) const - { this->priv_range_check(n); return (*this)[n]; } - - ////////////////////////////////////////////// - // - // modifiers - // - ////////////////////////////////////////////// - - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... in the beginning of the deque. - //! - //! Throws: If memory allocation throws or the in-place constructor throws. - //! - //! Complexity: Amortized constant time - template - void emplace_front(Args&&... args) - { - if(this->priv_push_front_simple_available()){ - allocator_traits_type::construct - ( this->alloc() - , this->priv_push_front_simple_pos() - , boost::forward(args)...); - this->priv_push_front_simple_commit(); - } - else{ - typedef container_detail::insert_non_movable_emplace_proxy type; - this->priv_insert_front_aux_impl(1, type(boost::forward(args)...)); - } - } - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... in the end of the deque. - //! - //! Throws: If memory allocation throws or the in-place constructor throws. - //! - //! Complexity: Amortized constant time - template - void emplace_back(Args&&... args) - { - if(this->priv_push_back_simple_available()){ - allocator_traits_type::construct - ( this->alloc() - , this->priv_push_back_simple_pos() - , boost::forward(args)...); - this->priv_push_back_simple_commit(); - } - else{ - typedef container_detail::insert_non_movable_emplace_proxy type; - this->priv_insert_back_aux_impl(1, type(boost::forward(args)...)); - } - } - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... before p - //! - //! Throws: If memory allocation throws or the in-place constructor throws. - //! - //! Complexity: If p is end(), amortized constant time - //! Linear time otherwise. - template - iterator emplace(const_iterator p, Args&&... args) - { - if(p == this->cbegin()){ - this->emplace_front(boost::forward(args)...); - return this->begin(); - } - else if(p == this->cend()){ - this->emplace_back(boost::forward(args)...); - return (this->end()-1); - } - else{ - typedef container_detail::insert_emplace_proxy type; - return this->priv_insert_aux_impl(p, 1, type(boost::forward(args)...)); - } - } - - #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING - - //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_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - if(priv_push_front_simple_available()){ \ - allocator_traits_type::construct \ - ( this->alloc() \ - , this->priv_push_front_simple_pos() \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ - priv_push_front_simple_commit(); \ - } \ - else{ \ - typedef container_detail::BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, n) \ - type; \ - priv_insert_front_aux_impl \ - (1, type(BOOST_PP_ENUM(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_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - if(priv_push_back_simple_available()){ \ - allocator_traits_type::construct \ - ( this->alloc() \ - , this->priv_push_back_simple_pos() \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ - priv_push_back_simple_commit(); \ - } \ - else{ \ - typedef container_detail::BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, n) \ - type; \ - priv_insert_back_aux_impl \ - (1, type(BOOST_PP_ENUM(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, _)) \ - { \ - if(p == this->cbegin()){ \ - this->emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ - return this->begin(); \ - } \ - else if(p == cend()){ \ - this->emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ - return (this->end()-1); \ - } \ - else{ \ - typedef container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n) \ - type; \ - return this->priv_insert_aux_impl \ - (p, 1, type(BOOST_PP_ENUM(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 - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: Inserts a copy of x at the front of the deque. - //! - //! Throws: If memory allocation throws or - //! T's copy constructor throws. - //! - //! Complexity: Amortized constant time. - void push_front(const T &x); - - //! Effects: Constructs a new element in the front of the deque - //! and moves the resources of mx to this new element. - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: 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) - //! Effects: Inserts a copy of x at the end of the deque. - //! - //! Throws: If memory allocation throws or - //! T's copy constructor throws. - //! - //! Complexity: Amortized constant time. - void push_back(const T &x); - - //! Effects: Constructs a new element in the end of the deque - //! and moves the resources of mx to this new element. - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: 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) - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a copy of x before p. - //! - //! Returns: an iterator to the inserted element. - //! - //! Throws: If memory allocation throws or x's copy constructor throws. - //! - //! Complexity: If p is end(), amortized constant time - //! Linear time otherwise. - iterator insert(const_iterator p, const T &x); - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a new element before p with mx's resources. - //! - //! Returns: an iterator to the inserted element. - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: If p is end(), amortized constant time - //! Linear time otherwise. - iterator insert(const_iterator p, T &&x); - #else - BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator, const_iterator) - #endif - - //! Requires: pos must be a valid iterator of *this. - //! - //! Effects: Insert n copies of x before pos. - //! - //! Returns: an iterator to the first inserted element or pos if n is 0. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to n. - iterator insert(const_iterator pos, size_type n, const value_type& x) - { - typedef constant_iterator c_it; - return this->insert(pos, c_it(x, n), c_it()); - } - - //! Requires: pos must be a valid iterator of *this. - //! - //! Effects: Insert a copy of the [first, last) range before pos. - //! - //! Returns: an iterator to the first inserted element or pos if first == last. - //! - //! Throws: If memory allocation throws, T's constructor from a - //! dereferenced InIt throws or T's copy constructor throws. - //! - //! Complexity: Linear to std::distance [first, last). - template - 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::value - && container_detail::is_input_iterator::value - >::type * = 0 - #endif - ) - { - size_type n = 0; - iterator it(pos.unconst()); - for(;first != last; ++first, ++n){ - it = this->emplace(it, *first); - ++it; - } - it -= n; - return it; - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Requires: pos must be a valid iterator of *this. - //! - //! Effects: Insert a copy of the [il.begin(), il.end()) range before pos. - //! - //! Returns: an iterator to the first inserted element or pos if il.begin() == il.end(). - //! - //! Throws: If memory allocation throws, T's constructor from a - //! dereferenced std::initializer_list throws or T's copy constructor throws. - //! - //! Complexity: Linear to std::distance [il.begin(), il.end()). - iterator insert(const_iterator pos, std::initializer_list il) - { return insert(pos, il.begin(), il.end()); } -#endif - - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - template - 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::value - && !container_detail::is_input_iterator::value - >::type * = 0 - #endif - ) - { - container_detail::insert_range_proxy proxy(first); - return priv_insert_aux_impl(p, (size_type)std::distance(first, last), proxy); - } - #endif - - //! Effects: Removes the first element from the deque. - //! - //! Throws: Nothing. - //! - //! Complexity: 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(); - } - - //! Effects: Removes the last element from the deque. - //! - //! Throws: Nothing. - //! - //! Complexity: 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(); - } - - //! Effects: Erases the element at p. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the elements between pos and the - //! last element (if pos is near the end) or the first element - //! if(pos is near the beginning). - //! Constant if pos is the first or the last element. - iterator erase(const_iterator pos) BOOST_CONTAINER_NOEXCEPT - { - iterator next = pos.unconst(); - ++next; - size_type index = pos - this->members_.m_start; - if (index < (this->size()/2)) { - boost::move_backward(this->begin(), pos.unconst(), next); - pop_front(); - } - else { - boost::move(next, this->end(), pos.unconst()); - pop_back(); - } - return this->members_.m_start + index; - } - - //! Effects: Erases the elements pointed by [first, last). - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the distance between first and - //! last plus the elements between pos and the - //! last element (if pos is near the end) or the first element - //! if(pos is near the beginning). - iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT - { - if (first == this->members_.m_start && last == this->members_.m_finish) { - this->clear(); - return this->members_.m_finish; - } - else { - const size_type n = static_cast(last - first); - const size_type elems_before = static_cast(first - this->members_.m_start); - if (elems_before < (this->size() - n) - elems_before) { - boost::move_backward(begin(), first.unconst(), last.unconst()); - iterator new_start = this->members_.m_start + n; - if(!Base::traits_t::trivial_dctr_after_move) - this->priv_destroy_range(this->members_.m_start, new_start); - this->priv_destroy_nodes(this->members_.m_start.m_node, new_start.m_node); - this->members_.m_start = new_start; - } - else { - boost::move(last.unconst(), end(), first.unconst()); - 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; - } - return this->members_.m_start + elems_before; - } - } - - //! Effects: Swaps the contents of *this and x. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - void swap(deque &x) - { - this->swap_members(x); - container_detail::bool_ flag; - container_detail::swap_alloc(this->alloc(), x.alloc(), flag); - container_detail::swap_alloc(this->ptr_alloc(), x.ptr_alloc(), flag); - } - - //! Effects: Erases all the elements of the deque. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements in the deque. - void clear() BOOST_CONTAINER_NOEXCEPT - { - for (index_pointer node = this->members_.m_start.m_node + 1; - node < this->members_.m_finish.m_node; - ++node) { - this->priv_destroy_range(*node, *node + this->s_buffer_size()); - this->priv_deallocate_node(*node); - } - - if (this->members_.m_start.m_node != this->members_.m_finish.m_node) { - this->priv_destroy_range(this->members_.m_start.m_cur, this->members_.m_start.m_last); - this->priv_destroy_range(this->members_.m_finish.m_first, this->members_.m_finish.m_cur); - this->priv_deallocate_node(this->members_.m_finish.m_first); - } - else - this->priv_destroy_range(this->members_.m_start.m_cur, this->members_.m_finish.m_cur); - - this->members_.m_finish = this->members_.m_start; - } - - //! Effects: Returns true if x and y are equal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator==(const deque& x, const deque& y) - { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); } - - //! Effects: Returns true if x and y are unequal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator!=(const deque& x, const deque& y) - { return !(x == y); } - - //! Effects: Returns true if x is less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<(const deque& x, const deque& y) - { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } - - //! Effects: Returns true if x is greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>(const deque& x, const deque& y) - { return y < x; } - - //! Effects: Returns true if x is equal or less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<=(const deque& x, const deque& y) - { return !(y < x); } - - //! Effects: Returns true if x is equal or greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>=(const deque& x, const deque& y) - { return !(x < y); } - - //! Effects: x.swap(y) - //! - //! Complexity: Constant. - friend void swap(deque& x, deque& y) - { x.swap(y); } - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - - void priv_erase_last_n(size_type n) - { - 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; - } - } - - void priv_range_check(size_type n) const - { if (n >= this->size()) throw_out_of_range("deque::at out of range"); } - - template - iterator priv_insert(const_iterator p, BOOST_FWD_REF(U) x) - { - if (p == cbegin()){ - this->push_front(::boost::forward(x)); - return begin(); - } - else if (p == cend()){ - this->push_back(::boost::forward(x)); - return --end(); - } - else { - return priv_insert_aux_impl - ( p, (size_type)1 - , container_detail::get_insert_value_proxy(::boost::forward(x))); - } - } - - template - void priv_push_front(BOOST_FWD_REF(U) x) - { - if(this->priv_push_front_simple_available()){ - allocator_traits_type::construct - ( this->alloc(), this->priv_push_front_simple_pos(), ::boost::forward(x)); - this->priv_push_front_simple_commit(); - } - else{ - priv_insert_aux_impl - ( this->cbegin(), (size_type)1 - , container_detail::get_insert_value_proxy(::boost::forward(x))); - } - } - - template - void priv_push_back(BOOST_FWD_REF(U) x) - { - if(this->priv_push_back_simple_available()){ - allocator_traits_type::construct - ( this->alloc(), this->priv_push_back_simple_pos(), ::boost::forward(x)); - this->priv_push_back_simple_commit(); - } - else{ - priv_insert_aux_impl - ( this->cend(), (size_type)1 - , container_detail::get_insert_value_proxy(::boost::forward(x))); - } - } - - bool priv_push_back_simple_available() const - { - return this->members_.m_map && - (this->members_.m_finish.m_cur != (this->members_.m_finish.m_last - 1)); - } - - T *priv_push_back_simple_pos() const - { - return container_detail::to_raw_pointer(this->members_.m_finish.m_cur); - } - - void priv_push_back_simple_commit() - { - ++this->members_.m_finish.m_cur; - } - - bool priv_push_front_simple_available() const - { - return this->members_.m_map && - (this->members_.m_start.m_cur != this->members_.m_start.m_first); - } - - T *priv_push_front_simple_pos() const - { return container_detail::to_raw_pointer(this->members_.m_start.m_cur) - 1; } - - void priv_push_front_simple_commit() - { --this->members_.m_start.m_cur; } - - void priv_destroy_range(iterator p, iterator p2) - { - for(;p != p2; ++p){ - allocator_traits_type::destroy - ( this->alloc() - , container_detail::to_raw_pointer(container_detail::iterator_to_pointer(p)) - ); - } - } - - void priv_destroy_range(pointer p, pointer p2) - { - for(;p != p2; ++p){ - allocator_traits_type::destroy - ( this->alloc() - , container_detail::to_raw_pointer(container_detail::iterator_to_pointer(p)) - ); - } - } - - template - iterator priv_insert_aux_impl(const_iterator p, size_type n, InsertProxy proxy) - { - iterator pos(p.unconst()); - const size_type pos_n = p - this->cbegin(); - if(!this->members_.m_map){ - this->priv_initialize_map(0); - pos = this->begin(); - } - - const size_type elemsbefore = static_cast(pos - this->members_.m_start); - const size_type length = this->size(); - if (elemsbefore < length / 2) { - const iterator new_start = this->priv_reserve_elements_at_front(n); - const iterator old_start = this->members_.m_start; - if(!elemsbefore){ - proxy.uninitialized_copy_n_and_update(this->alloc(), new_start, n); - this->members_.m_start = new_start; - } - else{ - pos = this->members_.m_start + elemsbefore; - if (elemsbefore >= n) { - const iterator start_n = this->members_.m_start + n; - ::boost::container::uninitialized_move_alloc - (this->alloc(), this->members_.m_start, start_n, new_start); - this->members_.m_start = new_start; - boost::move(start_n, pos, old_start); - proxy.copy_n_and_update(this->alloc(), pos - n, n); - } - else { - const size_type mid_count = n - elemsbefore; - const iterator mid_start = old_start - mid_count; - proxy.uninitialized_copy_n_and_update(this->alloc(), mid_start, mid_count); - this->members_.m_start = mid_start; - ::boost::container::uninitialized_move_alloc - (this->alloc(), old_start, pos, new_start); - this->members_.m_start = new_start; - proxy.copy_n_and_update(this->alloc(), old_start, elemsbefore); - } - } - } - else { - const iterator new_finish = this->priv_reserve_elements_at_back(n); - const iterator old_finish = this->members_.m_finish; - const size_type elemsafter = length - elemsbefore; - if(!elemsafter){ - proxy.uninitialized_copy_n_and_update(this->alloc(), old_finish, n); - this->members_.m_finish = new_finish; - } - else{ - pos = old_finish - elemsafter; - if (elemsafter >= n) { - iterator finish_n = old_finish - difference_type(n); - ::boost::container::uninitialized_move_alloc - (this->alloc(), finish_n, old_finish, old_finish); - this->members_.m_finish = new_finish; - boost::move_backward(pos, finish_n, old_finish); - proxy.copy_n_and_update(this->alloc(), pos, n); - } - else { - const size_type raw_gap = n - elemsafter; - ::boost::container::uninitialized_move_alloc - (this->alloc(), pos, old_finish, old_finish + raw_gap); - BOOST_TRY{ - proxy.copy_n_and_update(this->alloc(), pos, elemsafter); - proxy.uninitialized_copy_n_and_update(this->alloc(), old_finish, raw_gap); - } - BOOST_CATCH(...){ - this->priv_destroy_range(old_finish, old_finish + elemsafter); - BOOST_RETHROW - } - BOOST_CATCH_END - this->members_.m_finish = new_finish; - } - } - } - return this->begin() + pos_n; - } - - template - iterator priv_insert_back_aux_impl(size_type n, InsertProxy proxy) - { - if(!this->members_.m_map){ - this->priv_initialize_map(0); - } - - iterator new_finish = this->priv_reserve_elements_at_back(n); - iterator old_finish = this->members_.m_finish; - proxy.uninitialized_copy_n_and_update(this->alloc(), old_finish, n); - this->members_.m_finish = new_finish; - return iterator(this->members_.m_finish - n); - } - - template - iterator priv_insert_front_aux_impl(size_type n, InsertProxy proxy) - { - if(!this->members_.m_map){ - this->priv_initialize_map(0); - } - - iterator new_start = this->priv_reserve_elements_at_front(n); - proxy.uninitialized_copy_n_and_update(this->alloc(), new_start, n); - this->members_.m_start = new_start; - return new_start; - } - - iterator priv_fill_insert(const_iterator pos, size_type n, const value_type& x) - { - typedef constant_iterator 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, - // but none of the deque's elements have yet been constructed. - void priv_fill_initialize(const value_type& value) - { - index_pointer cur; - BOOST_TRY { - for (cur = this->members_.m_start.m_node; cur < this->members_.m_finish.m_node; ++cur){ - boost::container::uninitialized_fill_alloc - (this->alloc(), *cur, *cur + this->s_buffer_size(), value); - } - boost::container::uninitialized_fill_alloc - (this->alloc(), this->members_.m_finish.m_first, this->members_.m_finish.m_cur, value); - } - BOOST_CATCH(...){ - this->priv_destroy_range(this->members_.m_start, iterator(*cur, cur)); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - template - void priv_range_initialize(InIt first, InIt last, std::input_iterator_tag) - { - this->priv_initialize_map(0); - BOOST_TRY { - for ( ; first != last; ++first) - this->emplace_back(*first); - } - BOOST_CATCH(...){ - this->clear(); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - template - void priv_range_initialize(FwdIt first, FwdIt last, std::forward_iterator_tag) - { - size_type n = 0; - n = std::distance(first, last); - this->priv_initialize_map(n); - - index_pointer cur_node; - BOOST_TRY { - for (cur_node = this->members_.m_start.m_node; - cur_node < this->members_.m_finish.m_node; - ++cur_node) { - FwdIt mid = first; - std::advance(mid, this->s_buffer_size()); - ::boost::container::uninitialized_copy_alloc(this->alloc(), first, mid, *cur_node); - first = mid; - } - ::boost::container::uninitialized_copy_alloc(this->alloc(), first, last, this->members_.m_finish.m_first); - } - BOOST_CATCH(...){ - this->priv_destroy_range(this->members_.m_start, iterator(*cur_node, cur_node)); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - // Called only if this->members_.m_finish.m_cur == this->members_.m_finish.m_first. - void priv_pop_back_aux() BOOST_CONTAINER_NOEXCEPT - { - this->priv_deallocate_node(this->members_.m_finish.m_first); - this->members_.m_finish.priv_set_node(this->members_.m_finish.m_node - 1); - this->members_.m_finish.m_cur = this->members_.m_finish.m_last - 1; - allocator_traits_type::destroy - ( this->alloc() - , container_detail::to_raw_pointer(this->members_.m_finish.m_cur) - ); - } - - // Called only if this->members_.m_start.m_cur == this->members_.m_start.m_last - 1. Note that - // if the deque has at least one element (a precondition for this member - // function), and if this->members_.m_start.m_cur == this->members_.m_start.m_last, then the deque - // must have at least two nodes. - void priv_pop_front_aux() BOOST_CONTAINER_NOEXCEPT - { - allocator_traits_type::destroy - ( this->alloc() - , container_detail::to_raw_pointer(this->members_.m_start.m_cur) - ); - this->priv_deallocate_node(this->members_.m_start.m_first); - this->members_.m_start.priv_set_node(this->members_.m_start.m_node + 1); - this->members_.m_start.m_cur = this->members_.m_start.m_first; - } - - iterator priv_reserve_elements_at_front(size_type n) - { - size_type vacancies = this->members_.m_start.m_cur - this->members_.m_start.m_first; - if (n > vacancies){ - size_type new_elems = n-vacancies; - size_type new_nodes = (new_elems + this->s_buffer_size() - 1) / - this->s_buffer_size(); - size_type s = (size_type)(this->members_.m_start.m_node - this->members_.m_map); - if (new_nodes > s){ - this->priv_reallocate_map(new_nodes, true); - } - size_type i = 1; - BOOST_TRY { - for (; i <= new_nodes; ++i) - *(this->members_.m_start.m_node - i) = this->priv_allocate_node(); - } - BOOST_CATCH(...) { - for (size_type j = 1; j < i; ++j) - this->priv_deallocate_node(*(this->members_.m_start.m_node - j)); - BOOST_RETHROW - } - BOOST_CATCH_END - } - return this->members_.m_start - difference_type(n); - } - - iterator priv_reserve_elements_at_back(size_type n) - { - size_type vacancies = (this->members_.m_finish.m_last - this->members_.m_finish.m_cur) - 1; - if (n > vacancies){ - size_type new_elems = n - vacancies; - size_type new_nodes = (new_elems + this->s_buffer_size() - 1)/s_buffer_size(); - size_type s = (size_type)(this->members_.m_map_size - (this->members_.m_finish.m_node - this->members_.m_map)); - if (new_nodes + 1 > s){ - this->priv_reallocate_map(new_nodes, false); - } - size_type i; - BOOST_TRY { - for (i = 1; i <= new_nodes; ++i) - *(this->members_.m_finish.m_node + i) = this->priv_allocate_node(); - } - BOOST_CATCH(...) { - for (size_type j = 1; j < i; ++j) - this->priv_deallocate_node(*(this->members_.m_finish.m_node + j)); - BOOST_RETHROW - } - BOOST_CATCH_END - } - return this->members_.m_finish + difference_type(n); - } - - void priv_reallocate_map(size_type nodes_to_add, bool add_at_front) - { - size_type old_num_nodes = this->members_.m_finish.m_node - this->members_.m_start.m_node + 1; - size_type new_num_nodes = old_num_nodes + nodes_to_add; - - index_pointer new_nstart; - if (this->members_.m_map_size > 2 * new_num_nodes) { - new_nstart = this->members_.m_map + (this->members_.m_map_size - new_num_nodes) / 2 - + (add_at_front ? nodes_to_add : 0); - if (new_nstart < this->members_.m_start.m_node) - boost::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart); - else - boost::move_backward - (this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart + old_num_nodes); - } - else { - size_type new_map_size = - this->members_.m_map_size + container_detail::max_value(this->members_.m_map_size, nodes_to_add) + 2; - - index_pointer new_map = this->priv_allocate_map(new_map_size); - new_nstart = new_map + (new_map_size - new_num_nodes) / 2 - + (add_at_front ? nodes_to_add : 0); - boost::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart); - this->priv_deallocate_map(this->members_.m_map, this->members_.m_map_size); - - this->members_.m_map = new_map; - this->members_.m_map_size = new_map_size; - } - - this->members_.m_start.priv_set_node(new_nstart); - this->members_.m_finish.priv_set_node(new_nstart + old_num_nodes - 1); - } - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -}; - -}} - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -namespace boost { - -//!has_trivial_destructor_after_move<> == true_type -//!specialization for optimizations -template -struct has_trivial_destructor_after_move > - : public ::boost::has_trivial_destructor_after_move -{}; - -} - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -#include - -#endif // #ifndef BOOST_CONTAINER_DEQUE_HPP diff --git a/boost/container/detail/adaptive_node_pool.hpp b/boost/container/detail/adaptive_node_pool.hpp deleted file mode 100644 index 4e73754..0000000 --- a/boost/container/detail/adaptive_node_pool.hpp +++ /dev/null @@ -1,162 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_ADAPTIVE_NODE_POOL_HPP -#define BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace boost { -namespace container { -namespace container_detail { - -template -struct select_private_adaptive_node_pool_impl -{ - typedef boost::container::container_detail:: - private_adaptive_node_pool_impl - < fake_segment_manager - , unsigned(AlignOnly)*::boost::container::adaptive_pool_flag::align_only - | ::boost::container::adaptive_pool_flag::size_ordered | ::boost::container::adaptive_pool_flag::address_ordered - > type; -}; - -//!Pooled memory allocator using an smart adaptive pool. Includes -//!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< std::size_t NodeSize - , std::size_t NodesPerBlock - , std::size_t MaxFreeBlocks - , std::size_t OverheadPercent - > -class private_adaptive_node_pool - : public select_private_adaptive_node_pool_impl<(OverheadPercent == 0)>::type -{ - typedef typename select_private_adaptive_node_pool_impl::type base_t; - //Non-copyable - private_adaptive_node_pool(const private_adaptive_node_pool &); - private_adaptive_node_pool &operator=(const private_adaptive_node_pool &); - - public: - typedef typename base_t::multiallocation_chain multiallocation_chain; - static const std::size_t nodes_per_block = NodesPerBlock; - - //!Constructor. Never throws - private_adaptive_node_pool() - : base_t(0 - , NodeSize - , NodesPerBlock - , MaxFreeBlocks - , (unsigned char)OverheadPercent) - {} -}; - -//!Pooled memory allocator using adaptive pool. Includes -//!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< std::size_t NodeSize - , std::size_t NodesPerBlock - , std::size_t MaxFreeBlocks - , std::size_t OverheadPercent - > -class shared_adaptive_node_pool - : public private_adaptive_node_pool - -{ - private: - typedef private_adaptive_node_pool - private_node_allocator_t; - public: - typedef typename private_node_allocator_t::multiallocation_chain multiallocation_chain; - - //!Constructor. Never throws - shared_adaptive_node_pool() - : private_node_allocator_t(){} - - //!Destructor. Deallocates all allocated blocks. Never throws - ~shared_adaptive_node_pool() - {} - - //!Allocates array of count elements. Can throw std::bad_alloc - void *allocate_node() - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - return private_node_allocator_t::allocate_node(); - } - - //!Deallocates an array pointed by ptr. Never throws - void deallocate_node(void *ptr) - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - private_node_allocator_t::deallocate_node(ptr); - } - - //!Allocates a singly linked list of n nodes ending in null pointer. - //!can throw std::bad_alloc - void allocate_nodes(const std::size_t n, multiallocation_chain &chain) - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - return private_node_allocator_t::allocate_nodes(n, chain); - } - - void deallocate_nodes(multiallocation_chain &chain) - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - private_node_allocator_t::deallocate_nodes(chain); - } - - //!Deallocates all the free blocks of memory. Never throws - void deallocate_free_blocks() - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - private_node_allocator_t::deallocate_free_blocks(); - } - - private: - default_mutex mutex_; -}; - -} //namespace container_detail { -} //namespace container { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_HPP diff --git a/boost/container/detail/adaptive_node_pool_impl.hpp b/boost/container/detail/adaptive_node_pool_impl.hpp deleted file mode 100644 index dc1a7f1..0000000 --- a/boost/container/detail/adaptive_node_pool_impl.hpp +++ /dev/null @@ -1,875 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_ADAPTIVE_NODE_POOL_IMPL_HPP -#define BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_IMPL_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace container { - -namespace adaptive_pool_flag { - -static const unsigned int none = 0u; -static const unsigned int align_only = 1u << 0u; -static const unsigned int size_ordered = 1u << 1u; -static const unsigned int address_ordered = 1u << 2u; - -} //namespace adaptive_pool_flag{ - -namespace container_detail { - -template -struct hdr_offset_holder_t -{ - hdr_offset_holder_t(size_type offset = 0) - : hdr_offset(offset) - {} - size_type hdr_offset; -}; - -template -struct less_func; - -template -struct less_func -{ - static bool less(SizeType, SizeType, const void *, const void *) - { return true; } -}; - -template -struct less_func -{ - static bool less(SizeType ls, SizeType rs, const void *, const void *) - { return ls < rs; } -}; - -template -struct less_func -{ - static bool less(SizeType, SizeType, const void *la, const void *ra) - { return &la < &ra; } -}; - -template -struct less_func -{ - static bool less(SizeType ls, SizeType rs, const void *la, const void *ra) - { return (ls < rs) || ((ls == rs) && (la < ra)); } -}; - -template -struct block_container_traits -{ - typedef typename bi::make_set_base_hook - < bi::void_pointer - , bi::optimize_size - , bi::link_mode >::type hook_t; - - template - struct container - { - typedef typename bi::make_multiset - , bi::size_type >::type type; - }; - - template - static void reinsert_was_used(Container &container, typename Container::reference v, bool) - { - typedef typename Container::const_iterator const_block_iterator; - const const_block_iterator this_block - (Container::s_iterator_to(const_cast(v))); - const_block_iterator next_block(this_block); - if(++next_block != container.cend()){ - if(this_block->free_nodes.size() > next_block->free_nodes.size()){ - container.erase(this_block); - container.insert(v); - } - } - } - - template - static void insert_was_empty(Container &container, typename Container::value_type &v, bool) - { - container.insert(v); - } - - template - static void erase_first(Container &container) - { - container.erase(container.cbegin()); - } - - template - static void erase_last(Container &container) - { - container.erase(--container.cend()); - } -}; - -template -struct block_container_traits -{ - typedef typename bi::make_list_base_hook - < bi::void_pointer - , bi::link_mode >::type hook_t; - - template - struct container - { - typedef typename bi::make_list - , bi::size_type, bi::constant_time_size >::type type; - }; - - template - static void reinsert_was_used(Container &container, typename Container::value_type &v, bool is_full) - { - if(is_full){ - container.erase(Container::s_iterator_to(v)); - container.push_back(v); - } - } - - template - static void insert_was_empty(Container &container, typename Container::value_type &v, bool is_full) - { - if(is_full){ - container.push_back(v); - } - else{ - container.push_front(v); - } - } - - template - static void erase_first(Container &container) - { - container.pop_front(); - } - - template - static void erase_last(Container &container) - { - container.pop_back(); - } -}; - -template -struct adaptive_pool_types -{ - typedef VoidPointer void_pointer; - static const bool ordered = (Flags & (adaptive_pool_flag::size_ordered | adaptive_pool_flag::address_ordered)) != 0; - typedef block_container_traits block_container_traits_t; - typedef typename block_container_traits_t::hook_t hook_t; - typedef hdr_offset_holder_t hdr_offset_holder; - static const unsigned int order_flags = Flags & (adaptive_pool_flag::size_ordered | adaptive_pool_flag::address_ordered); - typedef MultiallocationChain free_nodes_t; - - struct block_info_t - : public hdr_offset_holder, - public hook_t - { - //An intrusive list of free node from this block - free_nodes_t free_nodes; - friend bool operator <(const block_info_t &l, const block_info_t &r) - { - return less_func:: - less(l.free_nodes.size(), r.free_nodes.size(), &l , &r); - } - - friend bool operator ==(const block_info_t &l, const block_info_t &r) - { return &l == &r; } - }; - typedef typename block_container_traits_t:: template container::type block_container_t; -}; - -template -inline size_type calculate_alignment - ( size_type overhead_percent, size_type real_node_size - , size_type hdr_size, size_type hdr_offset_size, size_type payload_per_allocation) -{ - //to-do: handle real_node_size != node_size - const size_type divisor = overhead_percent*real_node_size; - const size_type dividend = hdr_offset_size*100; - size_type elements_per_subblock = (dividend - 1)/divisor + 1; - size_type candidate_power_of_2 = - upper_power_of_2(elements_per_subblock*real_node_size + hdr_offset_size); - bool overhead_satisfied = false; - //Now calculate the wors-case overhead for a subblock - const size_type max_subblock_overhead = hdr_size + payload_per_allocation; - while(!overhead_satisfied){ - elements_per_subblock = (candidate_power_of_2 - max_subblock_overhead)/real_node_size; - const size_type overhead_size = candidate_power_of_2 - elements_per_subblock*real_node_size; - if(overhead_size*100/candidate_power_of_2 < overhead_percent){ - overhead_satisfied = true; - } - else{ - candidate_power_of_2 <<= 1; - } - } - return candidate_power_of_2; -} - -template -inline void calculate_num_subblocks - (size_type alignment, size_type real_node_size, size_type elements_per_block - , size_type &num_subblocks, size_type &real_num_node, size_type overhead_percent - , size_type hdr_size, size_type hdr_offset_size, size_type payload_per_allocation) -{ - const size_type hdr_subblock_elements = (alignment - hdr_size - payload_per_allocation)/real_node_size; - size_type elements_per_subblock = (alignment - hdr_offset_size)/real_node_size; - size_type possible_num_subblock = (elements_per_block - 1)/elements_per_subblock + 1; - while(((possible_num_subblock-1)*elements_per_subblock + hdr_subblock_elements) < elements_per_block){ - ++possible_num_subblock; - } - elements_per_subblock = (alignment - hdr_offset_size)/real_node_size; - bool overhead_satisfied = false; - while(!overhead_satisfied){ - const size_type total_data = (elements_per_subblock*(possible_num_subblock-1) + hdr_subblock_elements)*real_node_size; - const size_type total_size = alignment*possible_num_subblock; - if((total_size - total_data)*100/total_size < overhead_percent){ - overhead_satisfied = true; - } - else{ - ++possible_num_subblock; - } - } - num_subblocks = possible_num_subblock; - real_num_node = (possible_num_subblock-1)*elements_per_subblock + hdr_subblock_elements; -} - -template -class private_adaptive_node_pool_impl -{ - //Non-copyable - private_adaptive_node_pool_impl(); - private_adaptive_node_pool_impl(const private_adaptive_node_pool_impl &); - private_adaptive_node_pool_impl &operator=(const private_adaptive_node_pool_impl &); - typedef private_adaptive_node_pool_impl this_type; - - typedef typename SegmentManagerBase::void_pointer void_pointer; - static const typename SegmentManagerBase:: - size_type PayloadPerAllocation = SegmentManagerBase::PayloadPerAllocation; - //Flags - //align_only - static const bool AlignOnly = (Flags & adaptive_pool_flag::align_only) != 0; - typedef bool_ IsAlignOnly; - typedef true_ AlignOnlyTrue; - typedef false_ AlignOnlyFalse; - //size_ordered - static const bool SizeOrdered = (Flags & adaptive_pool_flag::size_ordered) != 0; - typedef bool_ IsSizeOrdered; - typedef true_ SizeOrderedTrue; - typedef false_ SizeOrderedFalse; - //address_ordered - static const bool AddressOrdered = (Flags & adaptive_pool_flag::address_ordered) != 0; - typedef bool_ IsAddressOrdered; - typedef true_ AddressOrderedTrue; - typedef false_ AddressOrderedFalse; - - public: - typedef typename SegmentManagerBase::multiallocation_chain multiallocation_chain; - typedef typename SegmentManagerBase::size_type size_type; - - private: - typedef adaptive_pool_types - adaptive_pool_types_t; - typedef typename adaptive_pool_types_t::free_nodes_t free_nodes_t; - typedef typename adaptive_pool_types_t::block_info_t block_info_t; - typedef typename adaptive_pool_types_t::block_container_t block_container_t; - typedef typename adaptive_pool_types_t::block_container_traits_t block_container_traits_t; - typedef typename block_container_t::iterator block_iterator; - typedef typename block_container_t::const_iterator const_block_iterator; - typedef typename adaptive_pool_types_t::hdr_offset_holder hdr_offset_holder; - - static const size_type MaxAlign = alignment_of::value; - static const size_type HdrSize = ((sizeof(block_info_t)-1)/MaxAlign+1)*MaxAlign; - static const size_type HdrOffsetSize = ((sizeof(hdr_offset_holder)-1)/MaxAlign+1)*MaxAlign; - - public: - //!Segment manager typedef - typedef SegmentManagerBase segment_manager_base_type; - - //!Constructor from a segment manager. Never throws - private_adaptive_node_pool_impl - ( segment_manager_base_type *segment_mngr_base - , size_type node_size - , size_type nodes_per_block - , size_type max_free_blocks - , unsigned char overhead_percent - ) - : m_max_free_blocks(max_free_blocks) - , m_real_node_size(lcm(node_size, size_type(alignment_of::value))) - //Round the size to a power of two value. - //This is the total memory size (including payload) that we want to - //allocate from the general-purpose allocator - , m_real_block_alignment - (AlignOnly ? - upper_power_of_2(HdrSize + m_real_node_size*nodes_per_block) : - calculate_alignment( (size_type)overhead_percent, m_real_node_size - , HdrSize, HdrOffsetSize, PayloadPerAllocation)) - //This is the real number of nodes per block - , m_num_subblocks(0) - , m_real_num_node(AlignOnly ? (m_real_block_alignment - PayloadPerAllocation - HdrSize)/m_real_node_size : 0) - //General purpose allocator - , mp_segment_mngr_base(segment_mngr_base) - , m_block_container() - , m_totally_free_blocks(0) - { - if(!AlignOnly){ - calculate_num_subblocks - ( m_real_block_alignment - , m_real_node_size - , nodes_per_block - , m_num_subblocks - , m_real_num_node - , (size_type)overhead_percent - , HdrSize - , HdrOffsetSize - , PayloadPerAllocation); - } - } - - //!Destructor. Deallocates all allocated blocks. Never throws - ~private_adaptive_node_pool_impl() - { this->priv_clear(); } - - size_type get_real_num_node() const - { return m_real_num_node; } - - //!Returns the segment manager. Never throws - segment_manager_base_type* get_segment_manager_base()const - { return container_detail::to_raw_pointer(mp_segment_mngr_base); } - - //!Allocates array of count elements. Can throw - void *allocate_node() - { - this->priv_invariants(); - //If there are no free nodes we allocate a new block - if(!m_block_container.empty()){ - //We take the first free node the multiset can't be empty - free_nodes_t &free_nodes = m_block_container.begin()->free_nodes; - BOOST_ASSERT(!free_nodes.empty()); - const size_type free_nodes_count = free_nodes.size(); - void *first_node = container_detail::to_raw_pointer(free_nodes.pop_front()); - if(free_nodes.empty()){ - block_container_traits_t::erase_first(m_block_container); - } - m_totally_free_blocks -= static_cast(free_nodes_count == m_real_num_node); - this->priv_invariants(); - return first_node; - } - else{ - multiallocation_chain chain; - this->priv_append_from_new_blocks(1, chain, IsAlignOnly()); - return container_detail::to_raw_pointer(chain.pop_front()); - } - } - - //!Deallocates an array pointed by ptr. Never throws - void deallocate_node(void *pElem) - { - this->priv_invariants(); - block_info_t &block_info = *this->priv_block_from_node(pElem); - BOOST_ASSERT(block_info.free_nodes.size() < m_real_num_node); - - //We put the node at the beginning of the free node list - block_info.free_nodes.push_back(void_pointer(pElem)); - - //The loop reinserts all blocks except the last one - this->priv_reinsert_block(block_info, block_info.free_nodes.size() == 1); - this->priv_deallocate_free_blocks(m_max_free_blocks); - this->priv_invariants(); - } - - //!Allocates n nodes. - //!Can throw - void allocate_nodes(const size_type n, multiallocation_chain &chain) - { - size_type i = 0; - BOOST_TRY{ - this->priv_invariants(); - while(i != n){ - //If there are no free nodes we allocate all needed blocks - if (m_block_container.empty()){ - this->priv_append_from_new_blocks(n - i, chain, IsAlignOnly()); - BOOST_ASSERT(m_block_container.empty() || (++m_block_container.cbegin() == m_block_container.cend())); - BOOST_ASSERT(chain.size() == n); - break; - } - free_nodes_t &free_nodes = m_block_container.begin()->free_nodes; - const size_type free_nodes_count_before = free_nodes.size(); - m_totally_free_blocks -= static_cast(free_nodes_count_before == m_real_num_node); - const size_type num_left = n-i; - const size_type num_elems = (num_left < free_nodes_count_before) ? num_left : free_nodes_count_before; - typedef typename free_nodes_t::iterator free_nodes_iterator; - - if(num_left < free_nodes_count_before){ - const free_nodes_iterator it_bbeg(free_nodes.before_begin()); - free_nodes_iterator it_bend(it_bbeg); - for(size_type j = 0; j != num_elems; ++j){ - ++it_bend; - } - free_nodes_iterator it_end = it_bend; ++it_end; - free_nodes_iterator it_beg = it_bbeg; ++it_beg; - free_nodes.erase_after(it_bbeg, it_end, num_elems); - chain.incorporate_after(chain.last(), &*it_beg, &*it_bend, num_elems); - //chain.splice_after(chain.last(), free_nodes, it_bbeg, it_bend, num_elems); - BOOST_ASSERT(!free_nodes.empty()); - } - else{ - const free_nodes_iterator it_beg(free_nodes.begin()), it_bend(free_nodes.last()); - free_nodes.clear(); - chain.incorporate_after(chain.last(), &*it_beg, &*it_bend, num_elems); - block_container_traits_t::erase_first(m_block_container); - } - i += num_elems; - } - } - BOOST_CATCH(...){ - this->deallocate_nodes(chain); - BOOST_RETHROW - } - BOOST_CATCH_END - this->priv_invariants(); - } - - //!Deallocates a linked list of nodes. Never throws - void deallocate_nodes(multiallocation_chain &nodes) - { - this->priv_invariants(); - //To take advantage of node locality, wait until two - //nodes belong to different blocks. Only then reinsert - //the block of the first node in the block tree. - //Cache of the previous block - block_info_t *prev_block_info = 0; - - //If block was empty before this call, it's not already - //inserted in the block tree. - bool prev_block_was_empty = false; - typedef typename free_nodes_t::iterator free_nodes_iterator; - { - const free_nodes_iterator itbb(nodes.before_begin()), ite(nodes.end()); - free_nodes_iterator itf(nodes.begin()), itbf(itbb); - size_type splice_node_count = size_type(-1); - while(itf != ite){ - void *pElem = container_detail::to_raw_pointer(container_detail::iterator_to_pointer(itf)); - block_info_t &block_info = *this->priv_block_from_node(pElem); - BOOST_ASSERT(block_info.free_nodes.size() < m_real_num_node); - ++splice_node_count; - - //If block change is detected calculate the cached block position in the tree - if(&block_info != prev_block_info){ - if(prev_block_info){ //Make sure we skip the initial "dummy" cache - free_nodes_iterator it(itbb); ++it; - nodes.erase_after(itbb, itf, splice_node_count); - prev_block_info->free_nodes.incorporate_after(prev_block_info->free_nodes.last(), &*it, &*itbf, splice_node_count); - this->priv_reinsert_block(*prev_block_info, prev_block_was_empty); - splice_node_count = 0; - } - //Update cache with new data - prev_block_was_empty = block_info.free_nodes.empty(); - prev_block_info = &block_info; - } - itbf = itf; - ++itf; - } - } - if(prev_block_info){ - //The loop reinserts all blocks except the last one - const free_nodes_iterator itfirst(nodes.begin()), itlast(nodes.last()); - const size_type splice_node_count = nodes.size(); - nodes.clear(); - prev_block_info->free_nodes.incorporate_after(prev_block_info->free_nodes.last(), &*itfirst, &*itlast, splice_node_count); - this->priv_reinsert_block(*prev_block_info, prev_block_was_empty); - this->priv_invariants(); - this->priv_deallocate_free_blocks(m_max_free_blocks); - } - } - - void deallocate_free_blocks() - { this->priv_deallocate_free_blocks(0); } - - size_type num_free_nodes() - { - typedef typename block_container_t::const_iterator citerator; - size_type count = 0; - citerator it (m_block_container.begin()), itend(m_block_container.end()); - for(; it != itend; ++it){ - count += it->free_nodes.size(); - } - return count; - } - - void swap(private_adaptive_node_pool_impl &other) - { - BOOST_ASSERT(m_max_free_blocks == other.m_max_free_blocks); - BOOST_ASSERT(m_real_node_size == other.m_real_node_size); - BOOST_ASSERT(m_real_block_alignment == other.m_real_block_alignment); - BOOST_ASSERT(m_real_num_node == other.m_real_num_node); - std::swap(mp_segment_mngr_base, other.mp_segment_mngr_base); - std::swap(m_totally_free_blocks, other.m_totally_free_blocks); - m_block_container.swap(other.m_block_container); - } - - //Deprecated, use deallocate_free_blocks - void deallocate_free_chunks() - { this->priv_deallocate_free_blocks(0); } - - private: - - void priv_deallocate_free_blocks(size_type max_free_blocks) - { //Trampoline function to ease inlining - if(m_totally_free_blocks > max_free_blocks){ - this->priv_deallocate_free_blocks_impl(max_free_blocks); - } - } - - void priv_deallocate_free_blocks_impl(size_type max_free_blocks) - { - this->priv_invariants(); - //Now check if we've reached the free nodes limit - //and check if we have free blocks. If so, deallocate as much - //as we can to stay below the limit - multiallocation_chain chain; - { - const const_block_iterator itend = m_block_container.cend(); - const_block_iterator it = itend; - --it; - size_type totally_free_blocks = m_totally_free_blocks; - - for( ; totally_free_blocks > max_free_blocks; --totally_free_blocks){ - BOOST_ASSERT(it->free_nodes.size() == m_real_num_node); - void *addr = priv_first_subblock_from_block(const_cast(&*it)); - --it; - block_container_traits_t::erase_last(m_block_container); - chain.push_front(void_pointer(addr)); - } - BOOST_ASSERT((m_totally_free_blocks - max_free_blocks) == chain.size()); - m_totally_free_blocks = max_free_blocks; - } - this->mp_segment_mngr_base->deallocate_many(chain); - } - - void priv_reinsert_block(block_info_t &prev_block_info, const bool prev_block_was_empty) - { - //Cache the free nodes from the block - const size_type this_block_free_nodes = prev_block_info.free_nodes.size(); - const bool is_full = this_block_free_nodes == m_real_num_node; - - //Update free block count - m_totally_free_blocks += static_cast(is_full); - if(prev_block_was_empty){ - block_container_traits_t::insert_was_empty(m_block_container, prev_block_info, is_full); - } - else{ - block_container_traits_t::reinsert_was_used(m_block_container, prev_block_info, is_full); - } - } - - class block_destroyer; - friend class block_destroyer; - - class block_destroyer - { - public: - block_destroyer(const this_type *impl, multiallocation_chain &chain) - : mp_impl(impl), m_chain(chain) - {} - - void operator()(typename block_container_t::pointer to_deallocate) - { return this->do_destroy(to_deallocate, IsAlignOnly()); } - - private: - void do_destroy(typename block_container_t::pointer to_deallocate, AlignOnlyTrue) - { - BOOST_ASSERT(to_deallocate->free_nodes.size() == mp_impl->m_real_num_node); - m_chain.push_back(to_deallocate); - } - - void do_destroy(typename block_container_t::pointer to_deallocate, AlignOnlyFalse) - { - BOOST_ASSERT(to_deallocate->free_nodes.size() == mp_impl->m_real_num_node); - BOOST_ASSERT(0 == to_deallocate->hdr_offset); - hdr_offset_holder *hdr_off_holder = - mp_impl->priv_first_subblock_from_block(container_detail::to_raw_pointer(to_deallocate)); - m_chain.push_back(hdr_off_holder); - } - - const this_type *mp_impl; - multiallocation_chain &m_chain; - }; - - //This macro will activate invariant checking. Slow, but helpful for debugging the code. - //#define BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS - void priv_invariants() - #ifdef BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS - #undef BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS - { - const const_block_iterator itend(m_block_container.end()); - - { //We iterate through the block tree to free the memory - const_block_iterator it(m_block_container.begin()); - - if(it != itend){ - for(++it; it != itend; ++it){ - const_block_iterator prev(it); - --prev; - BOOST_ASSERT(*prev < *it); - (void)prev; (void)it; - } - } - } - { //Check that the total free nodes are correct - const_block_iterator it(m_block_container.cbegin()); - size_type total_free_nodes = 0; - for(; it != itend; ++it){ - total_free_nodes += it->free_nodes.size(); - } - BOOST_ASSERT(total_free_nodes >= m_totally_free_blocks*m_real_num_node); - } - { //Check that the total totally free blocks are correct - BOOST_ASSERT(m_block_container.size() >= m_totally_free_blocks); - const_block_iterator it = m_block_container.cend(); - size_type total_free_blocks = m_totally_free_blocks; - while(total_free_blocks--){ - BOOST_ASSERT((--it)->free_nodes.size() == m_real_num_node); - } - } - - if(!AlignOnly){ - //Check that header offsets are correct - const_block_iterator it = m_block_container.begin(); - for(; it != itend; ++it){ - hdr_offset_holder *hdr_off_holder = this->priv_first_subblock_from_block(const_cast(&*it)); - for(size_type i = 0, max = m_num_subblocks; i < max; ++i){ - const size_type offset = reinterpret_cast(const_cast(&*it)) - reinterpret_cast(hdr_off_holder); - BOOST_ASSERT(hdr_off_holder->hdr_offset == offset); - BOOST_ASSERT(0 == ((size_type)hdr_off_holder & (m_real_block_alignment - 1))); - BOOST_ASSERT(0 == (hdr_off_holder->hdr_offset & (m_real_block_alignment - 1))); - hdr_off_holder = reinterpret_cast(reinterpret_cast(hdr_off_holder) + m_real_block_alignment); - } - } - } - } - #else - {} //empty - #endif - - //!Deallocates all used memory. Never throws - void priv_clear() - { - #ifndef NDEBUG - block_iterator it = m_block_container.begin(); - block_iterator itend = m_block_container.end(); - size_type n_free_nodes = 0; - for(; it != itend; ++it){ - //Check for memory leak - BOOST_ASSERT(it->free_nodes.size() == m_real_num_node); - ++n_free_nodes; - } - BOOST_ASSERT(n_free_nodes == m_totally_free_blocks); - #endif - //Check for memory leaks - this->priv_invariants(); - multiallocation_chain chain; - m_block_container.clear_and_dispose(block_destroyer(this, chain)); - this->mp_segment_mngr_base->deallocate_many(chain); - m_totally_free_blocks = 0; - } - - block_info_t *priv_block_from_node(void *node, AlignOnlyFalse) const - { - hdr_offset_holder *hdr_off_holder = - reinterpret_cast((std::size_t)node & size_type(~(m_real_block_alignment - 1))); - BOOST_ASSERT(0 == ((std::size_t)hdr_off_holder & (m_real_block_alignment - 1))); - BOOST_ASSERT(0 == (hdr_off_holder->hdr_offset & (m_real_block_alignment - 1))); - block_info_t *block = reinterpret_cast - (reinterpret_cast(hdr_off_holder) + hdr_off_holder->hdr_offset); - BOOST_ASSERT(block->hdr_offset == 0); - return block; - } - - block_info_t *priv_block_from_node(void *node, AlignOnlyTrue) const - { - return (block_info_t *)((std::size_t)node & std::size_t(~(m_real_block_alignment - 1))); - } - - block_info_t *priv_block_from_node(void *node) const - { return this->priv_block_from_node(node, IsAlignOnly()); } - - hdr_offset_holder *priv_first_subblock_from_block(block_info_t *block) const - { return this->priv_first_subblock_from_block(block, IsAlignOnly()); } - - hdr_offset_holder *priv_first_subblock_from_block(block_info_t *block, AlignOnlyFalse) const - { - hdr_offset_holder *const hdr_off_holder = reinterpret_cast - (reinterpret_cast(block) - (m_num_subblocks-1)*m_real_block_alignment); - BOOST_ASSERT(hdr_off_holder->hdr_offset == size_type(reinterpret_cast(block) - reinterpret_cast(hdr_off_holder))); - BOOST_ASSERT(0 == ((std::size_t)hdr_off_holder & (m_real_block_alignment - 1))); - BOOST_ASSERT(0 == (hdr_off_holder->hdr_offset & (m_real_block_alignment - 1))); - return hdr_off_holder; - } - - hdr_offset_holder *priv_first_subblock_from_block(block_info_t *block, AlignOnlyTrue) const - { - return reinterpret_cast(block); - } - - void priv_dispatch_block_chain_or_free - ( multiallocation_chain &chain, block_info_t &c_info, size_type num_node - , char *mem_address, size_type total_elements, bool insert_block_if_free) - { - BOOST_ASSERT(chain.size() <= total_elements); - //First add all possible nodes to the chain - const size_type left = total_elements - chain.size(); - const size_type max_chain = (num_node < left) ? num_node : left; - mem_address = static_cast(container_detail::to_raw_pointer - (chain.incorporate_after(chain.last(), void_pointer(mem_address), m_real_node_size, max_chain))); - //Now store remaining nodes in the free list - if(const size_type max_free = num_node - max_chain){ - free_nodes_t & free_nodes = c_info.free_nodes; - free_nodes.incorporate_after(free_nodes.last(), void_pointer(mem_address), m_real_node_size, max_free); - if(insert_block_if_free){ - m_block_container.push_front(c_info); - } - } - } - - //!Allocates a several blocks of nodes. Can throw - void priv_append_from_new_blocks(size_type min_elements, multiallocation_chain &chain, AlignOnlyTrue) - { - BOOST_ASSERT(m_block_container.empty()); - BOOST_ASSERT(min_elements > 0); - const size_type n = (min_elements - 1)/m_real_num_node + 1; - const size_type real_block_size = m_real_block_alignment - PayloadPerAllocation; - const size_type total_elements = chain.size() + min_elements; - for(size_type i = 0; i != n; ++i){ - //We allocate a new NodeBlock and put it the last - //element of the tree - char *mem_address = static_cast - (mp_segment_mngr_base->allocate_aligned(real_block_size, m_real_block_alignment)); - if(!mem_address){ - //In case of error, free memory deallocating all nodes (the new ones allocated - //in this function plus previously stored nodes in chain). - this->deallocate_nodes(chain); - throw_bad_alloc(); - } - block_info_t &c_info = *new(mem_address)block_info_t(); - mem_address += HdrSize; - if(i != (n-1)){ - chain.incorporate_after(chain.last(), void_pointer(mem_address), m_real_node_size, m_real_num_node); - } - else{ - this->priv_dispatch_block_chain_or_free(chain, c_info, m_real_num_node, mem_address, total_elements, true); - } - } - } - - void priv_append_from_new_blocks(size_type min_elements, multiallocation_chain &chain, AlignOnlyFalse) - { - BOOST_ASSERT(m_block_container.empty()); - BOOST_ASSERT(min_elements > 0); - const size_type n = (min_elements - 1)/m_real_num_node + 1; - const size_type real_block_size = m_real_block_alignment*m_num_subblocks - PayloadPerAllocation; - const size_type elements_per_subblock = (m_real_block_alignment - HdrOffsetSize)/m_real_node_size; - const size_type hdr_subblock_elements = (m_real_block_alignment - HdrSize - PayloadPerAllocation)/m_real_node_size; - const size_type total_elements = chain.size() + min_elements; - - for(size_type i = 0; i != n; ++i){ - //We allocate a new NodeBlock and put it the last - //element of the tree - char *mem_address = static_cast - (mp_segment_mngr_base->allocate_aligned(real_block_size, m_real_block_alignment)); - if(!mem_address){ - //In case of error, free memory deallocating all nodes (the new ones allocated - //in this function plus previously stored nodes in chain). - this->deallocate_nodes(chain); - throw_bad_alloc(); - } - //First initialize header information on the last subblock - char *hdr_addr = mem_address + m_real_block_alignment*(m_num_subblocks-1); - block_info_t &c_info = *new(hdr_addr)block_info_t(); - //Some structural checks - BOOST_ASSERT(static_cast(&static_cast(c_info).hdr_offset) == - static_cast(&c_info)); (void)c_info; - if(i != (n-1)){ - for( size_type subblock = 0, maxsubblock = m_num_subblocks - 1 - ; subblock < maxsubblock - ; ++subblock, mem_address += m_real_block_alignment){ - //Initialize header offset mark - new(mem_address) hdr_offset_holder(size_type(hdr_addr - mem_address)); - chain.incorporate_after - (chain.last(), void_pointer(mem_address + HdrOffsetSize), m_real_node_size, elements_per_subblock); - } - chain.incorporate_after(chain.last(), void_pointer(hdr_addr + HdrSize), m_real_node_size, hdr_subblock_elements); - } - else{ - for( size_type subblock = 0, maxsubblock = m_num_subblocks - 1 - ; subblock < maxsubblock - ; ++subblock, mem_address += m_real_block_alignment){ - //Initialize header offset mark - new(mem_address) hdr_offset_holder(size_type(hdr_addr - mem_address)); - this->priv_dispatch_block_chain_or_free - (chain, c_info, elements_per_subblock, mem_address + HdrOffsetSize, total_elements, false); - } - this->priv_dispatch_block_chain_or_free - (chain, c_info, hdr_subblock_elements, hdr_addr + HdrSize, total_elements, true); - } - } - } - - private: - typedef typename boost::intrusive::pointer_traits - ::template rebind_pointer::type segment_mngr_base_ptr_t; - const size_type m_max_free_blocks; - const size_type m_real_node_size; - //Round the size to a power of two value. - //This is the total memory size (including payload) that we want to - //allocate from the general-purpose allocator - const size_type m_real_block_alignment; - size_type m_num_subblocks; - //This is the real number of nodes per block - //const - size_type m_real_num_node; - segment_mngr_base_ptr_t mp_segment_mngr_base; //Segment manager - block_container_t m_block_container; //Intrusive block list - size_type m_totally_free_blocks; //Free blocks -}; - -} //namespace container_detail { -} //namespace container { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_IMPL_HPP diff --git a/boost/container/detail/advanced_insert_int.hpp b/boost/container/detail/advanced_insert_int.hpp index 34eb544..56df588 100644 --- a/boost/container/detail/advanced_insert_int.hpp +++ b/boost/container/detail/advanced_insert_int.hpp @@ -11,44 +11,55 @@ #ifndef BOOST_CONTAINER_ADVANCED_INSERT_INT_HPP #define BOOST_CONTAINER_ADVANCED_INSERT_INT_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include +// container #include +// container/detail +#include #include -#include -#include #include -#include #include +#include #include -#include //std::iterator_traits +#include +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif +// move +#include +// other #include #include namespace boost { namespace container { namespace container_detail { -template +template struct move_insert_range_proxy { - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::value_type value_type; + typedef typename allocator_traits::size_type size_type; + typedef typename allocator_traits::value_type value_type; explicit move_insert_range_proxy(FwdIt first) : first_(first) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) { this->first_ = ::boost::container::uninitialized_move_alloc_n_source (a, this->first_, n, p); } - void copy_n_and_update(A &, Iterator p, size_type n) + void copy_n_and_update(Allocator &, Iterator p, size_type n) { this->first_ = ::boost::container::move_n_source(this->first_, n, p); } @@ -57,22 +68,22 @@ struct move_insert_range_proxy }; -template +template struct insert_range_proxy { - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::value_type value_type; + typedef typename allocator_traits::size_type size_type; + typedef typename allocator_traits::value_type value_type; explicit insert_range_proxy(FwdIt first) : first_(first) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) { this->first_ = ::boost::container::uninitialized_copy_alloc_n_source(a, this->first_, n, p); } - void copy_n_and_update(A &, Iterator p, size_type n) + void copy_n_and_update(Allocator &, Iterator p, size_type n) { this->first_ = ::boost::container::copy_n_source(this->first_, n, p); } @@ -81,20 +92,20 @@ struct insert_range_proxy }; -template +template struct insert_n_copies_proxy { - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::value_type value_type; + typedef typename allocator_traits::size_type size_type; + typedef typename allocator_traits::value_type value_type; explicit insert_n_copies_proxy(const value_type &v) : v_(v) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) const + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { boost::container::uninitialized_fill_alloc_n(a, v_, n, p); } - void copy_n_and_update(A &, Iterator p, size_type n) const + void copy_n_and_update(Allocator &, Iterator p, size_type n) const { for (; 0 < n; --n, ++p){ *p = v_; @@ -104,38 +115,38 @@ struct insert_n_copies_proxy const value_type &v_; }; -template +template struct insert_value_initialized_n_proxy { - typedef ::boost::container::allocator_traits alloc_traits; - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::value_type value_type; + typedef ::boost::container::allocator_traits alloc_traits; + typedef typename allocator_traits::size_type size_type; + typedef typename allocator_traits::value_type value_type; - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) const + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { boost::container::uninitialized_value_init_alloc_n(a, n, p); } - void copy_n_and_update(A &, Iterator, size_type) const + void copy_n_and_update(Allocator &, Iterator, size_type) const { BOOST_ASSERT(false); } }; -template +template struct insert_default_initialized_n_proxy { - typedef ::boost::container::allocator_traits alloc_traits; - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::value_type value_type; + typedef ::boost::container::allocator_traits alloc_traits; + typedef typename allocator_traits::size_type size_type; + typedef typename allocator_traits::value_type value_type; - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) const + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { boost::container::uninitialized_default_init_alloc_n(a, n, p); } - void copy_n_and_update(A &, Iterator, size_type) const + void copy_n_and_update(Allocator &, Iterator, size_type) const { BOOST_ASSERT(false); } }; -template +template struct insert_copy_proxy { - typedef boost::container::allocator_traits alloc_traits; + typedef boost::container::allocator_traits alloc_traits; typedef typename alloc_traits::size_type size_type; typedef typename alloc_traits::value_type value_type; @@ -143,13 +154,13 @@ struct insert_copy_proxy : v_(v) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) const + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; alloc_traits::construct( a, iterator_to_raw_pointer(p), v_); } - void copy_n_and_update(A &, Iterator p, size_type n) const + void copy_n_and_update(Allocator &, Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; *p =v_; @@ -159,10 +170,10 @@ struct insert_copy_proxy }; -template +template struct insert_move_proxy { - typedef boost::container::allocator_traits alloc_traits; + typedef boost::container::allocator_traits alloc_traits; typedef typename alloc_traits::size_type size_type; typedef typename alloc_traits::value_type value_type; @@ -170,13 +181,13 @@ struct insert_move_proxy : v_(v) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) const + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; alloc_traits::construct( a, iterator_to_raw_pointer(p), ::boost::move(v_) ); } - void copy_n_and_update(A &, Iterator p, size_type n) const + void copy_n_and_update(Allocator &, Iterator p, size_type n) const { BOOST_ASSERT(n == 1); (void)n; *p = ::boost::move(v_); @@ -185,50 +196,48 @@ struct insert_move_proxy value_type &v_; }; -template -insert_move_proxy get_insert_value_proxy(BOOST_RV_REF(typename std::iterator_traits::value_type) v) +template +insert_move_proxy get_insert_value_proxy(BOOST_RV_REF(typename boost::container::iterator_traits::value_type) v) { - return insert_move_proxy(v); + return insert_move_proxy(v); } -template -insert_copy_proxy get_insert_value_proxy(const typename std::iterator_traits::value_type &v) +template +insert_copy_proxy get_insert_value_proxy(const typename boost::container::iterator_traits::value_type &v) { - return insert_copy_proxy(v); + return insert_copy_proxy(v); } }}} //namespace boost { namespace container { namespace container_detail { -#ifdef BOOST_CONTAINER_PERFECT_FORWARDING +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include #include -#include -//#include //For debugging purposes namespace boost { namespace container { namespace container_detail { -template -struct insert_non_movable_emplace_proxy +template +struct insert_nonmovable_emplace_proxy { - typedef boost::container::allocator_traits alloc_traits; + typedef boost::container::allocator_traits alloc_traits; typedef typename alloc_traits::size_type size_type; typedef typename alloc_traits::value_type value_type; typedef typename build_number_seq::type index_tuple_t; - explicit insert_non_movable_emplace_proxy(Args&&... args) + explicit insert_nonmovable_emplace_proxy(BOOST_FWD_REF(Args)... args) : args_(args...) {} - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) { this->priv_uninitialized_copy_some_and_update(a, index_tuple_t(), p, n); } private: template - void priv_uninitialized_copy_some_and_update(A &a, const index_tuple&, Iterator p, size_type n) + void priv_uninitialized_copy_some_and_update(Allocator &a, const index_tuple&, Iterator p, size_type n) { BOOST_ASSERT(n == 1); (void)n; alloc_traits::construct( a, iterator_to_raw_pointer(p), ::boost::forward(get(this->args_))... ); @@ -238,30 +247,30 @@ struct insert_non_movable_emplace_proxy tuple args_; }; -template +template struct insert_emplace_proxy - : public insert_non_movable_emplace_proxy + : public insert_nonmovable_emplace_proxy { - typedef insert_non_movable_emplace_proxy base_t; - typedef boost::container::allocator_traits alloc_traits; + typedef insert_nonmovable_emplace_proxy base_t; + typedef boost::container::allocator_traits alloc_traits; typedef typename base_t::value_type value_type; typedef typename base_t::size_type size_type; typedef typename base_t::index_tuple_t index_tuple_t; - explicit insert_emplace_proxy(Args&&... args) + explicit insert_emplace_proxy(BOOST_FWD_REF(Args)... args) : base_t(::boost::forward(args)...) {} - void copy_n_and_update(A &a, Iterator p, size_type n) + void copy_n_and_update(Allocator &a, Iterator p, size_type n) { this->priv_copy_some_and_update(a, index_tuple_t(), p, n); } private: template - void priv_copy_some_and_update(A &a, const index_tuple&, Iterator p, size_type n) + void priv_copy_some_and_update(Allocator &a, const index_tuple&, Iterator p, size_type n) { BOOST_ASSERT(n ==1); (void)n; - aligned_storage::value> v; + typename aligned_storage::value>::type v; value_type *vp = static_cast(static_cast(&v)); alloc_traits::construct(a, vp, ::boost::forward(get(this->args_))...); @@ -278,191 +287,182 @@ struct insert_emplace_proxy }; //Specializations to avoid an unneeded temporary when emplacing from a single argument o type value_type -template -struct insert_emplace_proxy::value_type> - : public insert_move_proxy +template +struct insert_emplace_proxy::value_type> + : public insert_move_proxy { - explicit insert_emplace_proxy(typename boost::container::allocator_traits::value_type &&v) - : insert_move_proxy(v) + explicit insert_emplace_proxy(typename boost::container::allocator_traits::value_type &&v) + : insert_move_proxy(v) {} }; //We use "add_const" here as adding "const" only confuses MSVC12(and maybe later) provoking //compiler error C2752 ("more than one partial specialization matches"). //Any problem is solvable with an extra layer of indirection? ;-) -template -struct insert_emplace_proxy::value_type>::type +template +struct insert_emplace_proxy::value_type>::type > - : public insert_copy_proxy + : public insert_copy_proxy { - explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) - : insert_copy_proxy(v) + explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) + : insert_copy_proxy(v) {} }; -template -struct insert_emplace_proxy::value_type &> - : public insert_copy_proxy +template +struct insert_emplace_proxy::value_type &> + : public insert_copy_proxy { - explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) - : insert_copy_proxy(v) + explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) + : insert_copy_proxy(v) {} }; -template -struct insert_emplace_proxy::value_type>::type & +template +struct insert_emplace_proxy::value_type>::type & > - : public insert_copy_proxy + : public insert_copy_proxy { - explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) - : insert_copy_proxy(v) + explicit insert_emplace_proxy(const typename boost::container::allocator_traits::value_type &v) + : insert_copy_proxy(v) {} }; }}} //namespace boost { namespace container { namespace container_detail { -#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING +#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#include #include namespace boost { namespace container { namespace container_detail { -#define BOOST_PP_LOCAL_MACRO(N) \ -template \ -struct BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N) \ -{ \ - typedef boost::container::allocator_traits alloc_traits; \ - typedef typename alloc_traits::size_type size_type; \ - typedef typename alloc_traits::value_type value_type; \ - \ - explicit BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N) \ - ( BOOST_PP_ENUM(N, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ - BOOST_PP_EXPR_IF(N, :) BOOST_PP_ENUM(N, BOOST_CONTAINER_PP_PARAM_INIT, _) \ - {} \ - \ - void uninitialized_copy_n_and_update(A &a, Iterator p, size_type n) \ - { \ - BOOST_ASSERT(n == 1); (void)n; \ - alloc_traits::construct \ - ( a, iterator_to_raw_pointer(p) \ - BOOST_PP_ENUM_TRAILING(N, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) \ - ); \ - } \ - \ - void copy_n_and_update(A &, Iterator, size_type) \ - { BOOST_ASSERT(false); } \ - \ - protected: \ - BOOST_PP_REPEAT(N, BOOST_CONTAINER_PP_PARAM_DEFINE, _) \ -}; \ - \ -template \ -struct BOOST_PP_CAT(insert_emplace_proxy_arg, N) \ - : BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N) \ - < A, Iterator BOOST_PP_ENUM_TRAILING_PARAMS(N, P) > \ -{ \ - typedef BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, N) \ - base_t; \ - typedef typename base_t::value_type value_type; \ - typedef typename base_t::size_type size_type; \ - typedef boost::container::allocator_traits alloc_traits; \ - \ - explicit BOOST_PP_CAT(insert_emplace_proxy_arg, N) \ - ( BOOST_PP_ENUM(N, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ - : base_t(BOOST_PP_ENUM(N, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ) \ - {} \ - \ - void copy_n_and_update(A &a, Iterator p, size_type n) \ - { \ - BOOST_ASSERT(n == 1); (void)n; \ - aligned_storage::value> v; \ - value_type *vp = static_cast(static_cast(&v)); \ - alloc_traits::construct(a, vp \ - BOOST_PP_ENUM_TRAILING(N, BOOST_CONTAINER_PP_MEMBER_FORWARD, _)); \ - BOOST_TRY{ \ - *p = ::boost::move(*vp); \ - } \ - BOOST_CATCH(...){ \ - alloc_traits::destroy(a, vp); \ - BOOST_RETHROW \ - } \ - BOOST_CATCH_END \ - alloc_traits::destroy(a, vp); \ - } \ -}; \ -//! -#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) -#include BOOST_PP_LOCAL_ITERATE() +#define BOOST_CONTAINER_ADVANCED_INSERT_INT_CODE(N) \ +template< class Allocator, class Iterator BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ +struct insert_nonmovable_emplace_proxy##N\ +{\ + typedef boost::container::allocator_traits alloc_traits;\ + typedef typename alloc_traits::size_type size_type;\ + typedef typename alloc_traits::value_type value_type;\ + \ + explicit insert_nonmovable_emplace_proxy##N(BOOST_MOVE_UREF##N)\ + BOOST_MOVE_COLON##N BOOST_MOVE_FWD_INIT##N {}\ + \ + void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n)\ + {\ + BOOST_ASSERT(n == 1); (void)n;\ + alloc_traits::construct(a, iterator_to_raw_pointer(p) BOOST_MOVE_I##N BOOST_MOVE_MFWD##N);\ + }\ + \ + void copy_n_and_update(Allocator &, Iterator, size_type)\ + { BOOST_ASSERT(false); }\ + \ + protected:\ + BOOST_MOVE_MREF##N\ +};\ +\ +template< class Allocator, class Iterator BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ +struct insert_emplace_proxy_arg##N\ + : insert_nonmovable_emplace_proxy##N< Allocator, Iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N >\ +{\ + typedef insert_nonmovable_emplace_proxy##N\ + < Allocator, Iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N > base_t;\ + typedef typename base_t::value_type value_type;\ + typedef typename base_t::size_type size_type;\ + typedef boost::container::allocator_traits alloc_traits;\ + \ + explicit insert_emplace_proxy_arg##N(BOOST_MOVE_UREF##N)\ + : base_t(BOOST_MOVE_FWD##N){}\ + \ + void copy_n_and_update(Allocator &a, Iterator p, size_type n)\ + {\ + BOOST_ASSERT(n == 1); (void)n;\ + typename aligned_storage::value>::type v;\ + BOOST_ASSERT((((size_type)(&v)) % alignment_of::value) == 0);\ + value_type *vp = static_cast(static_cast(&v));\ + alloc_traits::construct(a, vp BOOST_MOVE_I##N BOOST_MOVE_MFWD##N);\ + BOOST_TRY{\ + *p = ::boost::move(*vp);\ + }\ + BOOST_CATCH(...){\ + alloc_traits::destroy(a, vp);\ + BOOST_RETHROW\ + }\ + BOOST_CATCH_END\ + alloc_traits::destroy(a, vp);\ + }\ +};\ +// +BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ADVANCED_INSERT_INT_CODE) +#undef BOOST_CONTAINER_ADVANCED_INSERT_INT_CODE #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) //Specializations to avoid an unneeded temporary when emplacing from a single argument o type value_type -template -struct insert_emplace_proxy_arg1::value_type> > - : public insert_move_proxy +template +struct insert_emplace_proxy_arg1::value_type> > + : public insert_move_proxy { - explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits::value_type &v) - : insert_move_proxy(v) + explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits::value_type &v) + : insert_move_proxy(v) {} }; -template -struct insert_emplace_proxy_arg1::value_type> - : public insert_copy_proxy +template +struct insert_emplace_proxy_arg1::value_type> + : public insert_copy_proxy { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) - : insert_copy_proxy(v) + explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) + : insert_copy_proxy(v) {} }; #else //e.g. MSVC10 & MSVC11 //Specializations to avoid an unneeded temporary when emplacing from a single argument o type value_type -template -struct insert_emplace_proxy_arg1::value_type> - : public insert_move_proxy +template +struct insert_emplace_proxy_arg1::value_type> + : public insert_move_proxy { - explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits::value_type &&v) - : insert_move_proxy(v) + explicit insert_emplace_proxy_arg1(typename boost::container::allocator_traits::value_type &&v) + : insert_move_proxy(v) {} }; //We use "add_const" here as adding "const" only confuses MSVC10&11 provoking //compiler error C2752 ("more than one partial specialization matches"). //Any problem is solvable with an extra layer of indirection? ;-) -template -struct insert_emplace_proxy_arg1::value_type>::type +template +struct insert_emplace_proxy_arg1::value_type>::type > - : public insert_copy_proxy + : public insert_copy_proxy { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) - : insert_copy_proxy(v) + explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) + : insert_copy_proxy(v) {} }; -template -struct insert_emplace_proxy_arg1::value_type &> - : public insert_copy_proxy +template +struct insert_emplace_proxy_arg1::value_type &> + : public insert_copy_proxy { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) - : insert_copy_proxy(v) + explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) + : insert_copy_proxy(v) {} }; -template -struct insert_emplace_proxy_arg1::value_type>::type & +template +struct insert_emplace_proxy_arg1::value_type>::type & > - : public insert_copy_proxy + : public insert_copy_proxy { - explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) - : insert_copy_proxy(v) + explicit insert_emplace_proxy_arg1(const typename boost::container::allocator_traits::value_type &v) + : insert_copy_proxy(v) {} }; @@ -470,7 +470,7 @@ struct insert_emplace_proxy_arg1 diff --git a/boost/container/detail/algorithm.hpp b/boost/container/detail/algorithm.hpp new file mode 100644 index 0000000..67e7876 --- /dev/null +++ b/boost/container/detail/algorithm.hpp @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014. +// +// Distributed under the 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_ALGORITHM_HPP +#define BOOST_CONTAINER_DETAIL_ALGORITHM_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include + +namespace boost { +namespace container { + +using boost::intrusive::algo_equal; +using boost::intrusive::algo_lexicographical_compare; + +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ALGORITHM_HPP diff --git a/boost/container/detail/algorithms.hpp b/boost/container/detail/algorithms.hpp deleted file mode 100644 index af15f65..0000000 --- a/boost/container/detail/algorithms.hpp +++ /dev/null @@ -1,62 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. -// -// Distributed under the 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_ALGORITHMS_HPP -#define BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include - -namespace boost { -namespace container { - -template -inline void construct_in_place(A &a, T* dest, InpIt source) -{ boost::container::allocator_traits::construct(a, dest, *source); } - -template -inline void construct_in_place(A &a, T *dest, value_init_construct_iterator) -{ - boost::container::allocator_traits::construct(a, dest); -} - -template -class default_init_construct_iterator; - -template -inline void construct_in_place(A &a, T *dest, default_init_construct_iterator) -{ - boost::container::allocator_traits::construct(a, dest, default_init); -} - -template -class emplace_iterator; - -template -inline void construct_in_place(A &a, T *dest, emplace_iterator ei) -{ - ei.construct_in_place(a, dest); -} - -} //namespace container { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP - diff --git a/boost/container/detail/alloc_helpers.hpp b/boost/container/detail/alloc_helpers.hpp new file mode 100644 index 0000000..656e0c2 --- /dev/null +++ b/boost/container/detail/alloc_helpers.hpp @@ -0,0 +1,60 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the 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_ALLOC_TRAITS_HPP +#define BOOST_CONTAINER_DETAIL_ALLOC_TRAITS_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +// move +#include +#include + +namespace boost { +namespace container { +namespace container_detail { + +template +inline void swap_alloc(AllocatorType &, AllocatorType &, container_detail::false_type) + BOOST_NOEXCEPT_OR_NOTHROW +{} + +template +inline void swap_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) +{ boost::adl_move_swap(l, r); } + +template +inline void assign_alloc(AllocatorType &, const AllocatorType &, container_detail::false_type) + BOOST_NOEXCEPT_OR_NOTHROW +{} + +template +inline void assign_alloc(AllocatorType &l, const AllocatorType &r, container_detail::true_type) +{ l = r; } + +template +inline void move_alloc(AllocatorType &, AllocatorType &, container_detail::false_type) + BOOST_NOEXCEPT_OR_NOTHROW +{} + +template +inline void move_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) +{ l = ::boost::move(r); } + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ALLOC_TRAITS_HPP diff --git a/boost/container/detail/alloc_lib.h b/boost/container/detail/alloc_lib.h deleted file mode 100644 index 4802d9d..0000000 --- a/boost/container/detail/alloc_lib.h +++ /dev/null @@ -1,326 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_ALLOC_LIB_EXT_H -#define BOOST_CONTAINER_ALLOC_LIB_EXT_H - -#include - -#ifdef _MSC_VER -#pragma warning (push) -#pragma warning (disable : 4127) - -/* - we need to import/export our code only if the user has specifically - asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost - libraries to be dynamically linked, or BOOST_CONTAINER_DYN_LINK - if they want just this one to be dynamically liked: -*/ -#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTAINER_DYN_LINK) - -/* export if this is our own source, otherwise import: */ -#ifdef BOOST_CONTAINER_SOURCE -# define BOOST_CONTAINER_DECL __declspec(dllexport) -#else -# define BOOST_CONTAINER_DECL __declspec(dllimport) -#endif /* BOOST_CONTAINER_SOURCE */ -#endif /* DYN_LINK */ -#endif /* _MSC_VER */ - -/* if BOOST_CONTAINER_DECL isn't defined yet define it now: */ -#ifndef BOOST_CONTAINER_DECL -#define BOOST_CONTAINER_DECL -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/*!An forward iterator to traverse the elements of a memory chain container.*/ -typedef struct multialloc_node_impl -{ - struct multialloc_node_impl *next_node_ptr; -} boost_cont_memchain_node; - - -/*!An forward iterator to traverse the elements of a memory chain container.*/ -typedef struct multialloc_it_impl -{ - boost_cont_memchain_node *node_ptr; -} boost_cont_memchain_it; - -/*!Memory chain: A container holding memory portions allocated by boost_cont_multialloc_nodes - and boost_cont_multialloc_arrays functions.*/ -typedef struct boost_cont_memchain_impl -{ - size_t num_mem; - boost_cont_memchain_node root_node; - boost_cont_memchain_node *last_node_ptr; -} boost_cont_memchain; - -/*!Advances the iterator one position so that it points to the next element in the memory chain*/ -#define BOOST_CONTAINER_MEMIT_NEXT(IT) (IT.node_ptr = IT.node_ptr->next_node_ptr) - -/*!Returns the address of the memory chain currently pointed by the iterator*/ -#define BOOST_CONTAINER_MEMIT_ADDR(IT) ((void*)IT.node_ptr) - -/*!Initializer for an iterator pointing to the position before the first element*/ -#define BOOST_CONTAINER_MEMCHAIN_BEFORE_BEGIN_IT(PMEMCHAIN) { &((PMEMCHAIN)->root_node) } - -/*!Initializer for an iterator pointing to the first element*/ -#define BOOST_CONTAINER_MEMCHAIN_BEGIN_IT(PMEMCHAIN) {(PMEMCHAIN)->root_node.next_node_ptr } - -/*!Initializer for an iterator pointing to the last element*/ -#define BOOST_CONTAINER_MEMCHAIN_LAST_IT(PMEMCHAIN) {(PMEMCHAIN)->last_node_ptr } - -/*!Initializer for an iterator pointing to one past the last element (end iterator)*/ -#define BOOST_CONTAINER_MEMCHAIN_END_IT(PMEMCHAIN) {(boost_cont_memchain_node *)0 } - -/*!True if IT is the end iterator, false otherwise*/ -#define BOOST_CONTAINER_MEMCHAIN_IS_END_IT(PMEMCHAIN, IT) (!(IT).node_ptr) - -/*!The address of the first memory portion hold by the memory chain*/ -#define BOOST_CONTAINER_MEMCHAIN_FIRSTMEM(PMEMCHAIN)((void*)((PMEMCHAIN)->root_node.next_node_ptr)) - -/*!The address of the last memory portion hold by the memory chain*/ -#define BOOST_CONTAINER_MEMCHAIN_LASTMEM(PMEMCHAIN) ((void*)((PMEMCHAIN)->last_node_ptr)) - -/*!The number of memory portions hold by the memory chain*/ -#define BOOST_CONTAINER_MEMCHAIN_SIZE(PMEMCHAIN) ((PMEMCHAIN)->num_mem) - -/*!Initializes the memory chain from the first memory portion, the last memory - portion and number of portions obtained from another memory chain*/ -#define BOOST_CONTAINER_MEMCHAIN_INIT_FROM(PMEMCHAIN, FIRST, LAST, NUM)\ - (PMEMCHAIN)->last_node_ptr = (boost_cont_memchain_node *)(LAST), \ - (PMEMCHAIN)->root_node.next_node_ptr = (boost_cont_memchain_node *)(FIRST), \ - (PMEMCHAIN)->num_mem = (NUM);\ -/**/ - -/*!Default initializes a memory chain. Postconditions: begin iterator is end iterator, - the number of portions is zero.*/ -#define BOOST_CONTAINER_MEMCHAIN_INIT(PMEMCHAIN)\ - ((PMEMCHAIN)->root_node.next_node_ptr = 0, (PMEMCHAIN)->last_node_ptr = &((PMEMCHAIN)->root_node), (PMEMCHAIN)->num_mem = 0)\ -/**/ - -/*!True if the memory chain is empty (holds no memory portions*/ -#define BOOST_CONTAINER_MEMCHAIN_EMPTY(PMEMCHAIN)\ - ((PMEMCHAIN)->num_mem == 0)\ -/**/ - -/*!Inserts a new memory portions in the front of the chain*/ -#define BOOST_CONTAINER_MEMCHAIN_PUSH_BACK(PMEMCHAIN, MEM)\ - do{\ - boost_cont_memchain *____chain____ = (PMEMCHAIN);\ - boost_cont_memchain_node *____tmp_mem____ = (boost_cont_memchain_node *)(MEM);\ - ____chain____->last_node_ptr->next_node_ptr = ____tmp_mem____;\ - ____tmp_mem____->next_node_ptr = 0;\ - ____chain____->last_node_ptr = ____tmp_mem____;\ - ++____chain____->num_mem;\ - }while(0)\ -/**/ - -/*!Inserts a new memory portions in the back of the chain*/ -#define BOOST_CONTAINER_MEMCHAIN_PUSH_FRONT(PMEMCHAIN, MEM)\ - do{\ - boost_cont_memchain *____chain____ = (PMEMCHAIN);\ - boost_cont_memchain_node *____tmp_mem____ = (boost_cont_memchain_node *)(MEM);\ - boost_cont_memchain *____root____ = &((PMEMCHAIN)->root_node);\ - if(!____chain____->root_node.next_node_ptr){\ - ____chain____->last_node_ptr = ____tmp_mem____;\ - }\ - boost_cont_memchain_node *____old_first____ = ____root____->next_node_ptr;\ - ____tmp_mem____->next_node_ptr = ____old_first____;\ - ____root____->next_node_ptr = ____tmp_mem____;\ - ++____chain____->num_mem;\ - }while(0)\ -/**/ - -/*!Erases the memory portion after the portion pointed by BEFORE_IT from the memory chain*/ -/*!Precondition: BEFORE_IT must be a valid iterator of the memory chain and it can't be the end iterator*/ -#define BOOST_CONTAINER_MEMCHAIN_ERASE_AFTER(PMEMCHAIN, BEFORE_IT)\ - do{\ - boost_cont_memchain *____chain____ = (PMEMCHAIN);\ - boost_cont_memchain_node *____prev_node____ = (BEFORE_IT).node_ptr;\ - boost_cont_memchain_node *____erase_node____ = ____prev_node____->next_node_ptr;\ - if(____chain____->last_node_ptr == ____erase_node____){\ - ____chain____->last_node_ptr = &____chain____->root_node;\ - }\ - ____prev_node____->next_node_ptr = ____erase_node____->next_node_ptr;\ - --____chain____->num_mem;\ - }while(0)\ -/**/ - -/*!Erases the first portion from the memory chain. - Precondition: the memory chain must not be empty*/ -#define BOOST_CONTAINER_MEMCHAIN_POP_FRONT(PMEMCHAIN)\ - do{\ - boost_cont_memchain *____chain____ = (PMEMCHAIN);\ - boost_cont_memchain_node *____prev_node____ = &____chain____->root_node;\ - boost_cont_memchain_node *____erase_node____ = ____prev_node____->next_node_ptr;\ - if(____chain____->last_node_ptr == ____erase_node____){\ - ____chain____->last_node_ptr = &____chain____->root_node;\ - }\ - ____prev_node____->next_node_ptr = ____erase_node____->next_node_ptr;\ - --____chain____->num_mem;\ - }while(0)\ -/**/ - -/*!Joins two memory chains inserting the portions of the second chain at the back of the first chain*/ -/* -#define BOOST_CONTAINER_MEMCHAIN_SPLICE_BACK(PMEMCHAIN, PMEMCHAIN2)\ - do{\ - boost_cont_memchain *____chain____ = (PMEMCHAIN);\ - boost_cont_memchain *____chain2____ = (PMEMCHAIN2);\ - if(!____chain2____->root_node.next_node_ptr){\ - break;\ - }\ - else if(!____chain____->first_mem){\ - ____chain____->first_mem = ____chain2____->first_mem;\ - ____chain____->last_node_ptr = ____chain2____->last_node_ptr;\ - ____chain____->num_mem = ____chain2____->num_mem;\ - BOOST_CONTAINER_MEMCHAIN_INIT(*____chain2____);\ - }\ - else{\ - ____chain____->last_node_ptr->next_node_ptr = ____chain2____->first_mem;\ - ____chain____->last_node_ptr = ____chain2____->last_node_ptr;\ - ____chain____->num_mem += ____chain2____->num_mem;\ - }\ - }while(0)\*/ -/**/ - -/*!Joins two memory chains inserting the portions of the second chain at the back of the first chain*/ -#define BOOST_CONTAINER_MEMCHAIN_INCORPORATE_AFTER(PMEMCHAIN, BEFORE_IT, FIRST, BEFORELAST, NUM)\ - do{\ - boost_cont_memchain *____chain____ = (PMEMCHAIN);\ - boost_cont_memchain_node *____pnode____ = (BEFORE_IT).node_ptr;\ - boost_cont_memchain_node *____next____ = ____pnode____->next_node_ptr;\ - boost_cont_memchain_node *____first____ = (boost_cont_memchain_node *)(FIRST);\ - boost_cont_memchain_node *____blast____ = (boost_cont_memchain_node *)(BEFORELAST);\ - size_t ____num____ = (NUM);\ - if(!____num____){\ - break;\ - }\ - if(____pnode____ == ____chain____->last_node_ptr){\ - ____chain____->last_node_ptr = ____blast____;\ - }\ - ____pnode____->next_node_ptr = ____first____;\ - ____blast____->next_node_ptr = ____next____;\ - ____chain____->num_mem += ____num____;\ - }while(0)\ -/**/ - -BOOST_CONTAINER_DECL size_t boost_cont_size(const void *p); - -BOOST_CONTAINER_DECL void* boost_cont_malloc(size_t bytes); - -BOOST_CONTAINER_DECL void boost_cont_free(void* mem); - -BOOST_CONTAINER_DECL void* boost_cont_memalign(size_t bytes, size_t alignment); - -/*!Indicates the all elements allocated by boost_cont_multialloc_nodes or boost_cont_multialloc_arrays - must be contiguous.*/ -#define DL_MULTIALLOC_ALL_CONTIGUOUS ((size_t)(-1)) - -/*!Indicates the number of contiguous elements allocated by boost_cont_multialloc_nodes or boost_cont_multialloc_arrays - should be selected by those functions.*/ -#define DL_MULTIALLOC_DEFAULT_CONTIGUOUS ((size_t)(0)) - -BOOST_CONTAINER_DECL int boost_cont_multialloc_nodes - (size_t n_elements, size_t elem_size, size_t contiguous_elements, boost_cont_memchain *pchain); - -BOOST_CONTAINER_DECL int boost_cont_multialloc_arrays - (size_t n_elements, const size_t *sizes, size_t sizeof_element, size_t contiguous_elements, boost_cont_memchain *pchain); - -BOOST_CONTAINER_DECL void boost_cont_multidealloc(boost_cont_memchain *pchain); - -BOOST_CONTAINER_DECL size_t boost_cont_footprint(); - -BOOST_CONTAINER_DECL size_t boost_cont_allocated_memory(); - -BOOST_CONTAINER_DECL size_t boost_cont_chunksize(const void *p); - -BOOST_CONTAINER_DECL int boost_cont_all_deallocated(); - -typedef struct boost_cont_malloc_stats_impl -{ - size_t max_system_bytes; - size_t system_bytes; - size_t in_use_bytes; -} boost_cont_malloc_stats_t; - -BOOST_CONTAINER_DECL boost_cont_malloc_stats_t boost_cont_malloc_stats(); - -BOOST_CONTAINER_DECL size_t boost_cont_in_use_memory(); - -BOOST_CONTAINER_DECL int boost_cont_trim(size_t pad); - -BOOST_CONTAINER_DECL int boost_cont_mallopt - (int parameter_number, int parameter_value); - -BOOST_CONTAINER_DECL int boost_cont_grow - (void* oldmem, size_t minbytes, size_t maxbytes, size_t *received); - -BOOST_CONTAINER_DECL int boost_cont_shrink - (void* oldmem, size_t minbytes, size_t maxbytes, size_t *received, int do_commit); - -BOOST_CONTAINER_DECL void* boost_cont_alloc - (size_t minbytes, size_t preferred_bytes, size_t *received_bytes); - -BOOST_CONTAINER_DECL int boost_cont_malloc_check(); - -typedef unsigned int allocation_type; - -enum -{ - // constants for allocation commands - BOOST_CONTAINER_ALLOCATE_NEW = 0X01, - BOOST_CONTAINER_EXPAND_FWD = 0X02, - BOOST_CONTAINER_EXPAND_BWD = 0X04, - BOOST_CONTAINER_SHRINK_IN_PLACE = 0X08, - BOOST_CONTAINER_NOTHROW_ALLOCATION = 0X10, -// BOOST_CONTAINER_ZERO_MEMORY = 0X20, - BOOST_CONTAINER_TRY_SHRINK_IN_PLACE = 0X40, - BOOST_CONTAINER_EXPAND_BOTH = BOOST_CONTAINER_EXPAND_FWD | BOOST_CONTAINER_EXPAND_BWD, - BOOST_CONTAINER_EXPAND_OR_NEW = BOOST_CONTAINER_ALLOCATE_NEW | BOOST_CONTAINER_EXPAND_BOTH -}; - -//#define BOOST_CONTAINERDLMALLOC__FOOTERS -#ifndef BOOST_CONTAINERDLMALLOC__FOOTERS -enum { BOOST_CONTAINER_ALLOCATION_PAYLOAD = sizeof(size_t) }; -#else -enum { BOOST_CONTAINER_ALLOCATION_PAYLOAD = sizeof(size_t)*2 }; -#endif - -typedef struct boost_cont_command_ret_impl -{ - void *first; - int second; -}boost_cont_command_ret_t; - -BOOST_CONTAINER_DECL boost_cont_command_ret_t boost_cont_allocation_command - ( allocation_type command - , size_t sizeof_object - , size_t limit_objects - , size_t preferred_objects - , size_t *received_objects - , void *reuse_ptr - ); - -BOOST_CONTAINER_DECL int boost_cont_mallopt(int param_number, int value); - -#ifdef __cplusplus -} //extern "C" { -#endif - -#ifdef _MSC_VER -#pragma warning (pop) -#endif - - -#endif //#define BOOST_CONTAINERDLMALLOC__EXT_H diff --git a/boost/container/detail/alloc_lib_auto_link.hpp b/boost/container/detail/alloc_lib_auto_link.hpp deleted file mode 100644 index e0a01b6..0000000 --- a/boost/container/detail/alloc_lib_auto_link.hpp +++ /dev/null @@ -1,20 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_BOOST_CONT_EXT_AUTO_LINK_HPP -#define BOOST_CONTAINER_DETAIL_BOOST_CONT_EXT_AUTO_LINK_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#endif //#ifndef BOOST_CONTAINER_DETAIL_BOOST_CONT_EXT_AUTO_LINK_HPP diff --git a/boost/container/detail/allocation_type.hpp b/boost/container/detail/allocation_type.hpp index 65d543a..1e8aa67 100644 --- a/boost/container/detail/allocation_type.hpp +++ b/boost/container/detail/allocation_type.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_ALLOCATION_TYPE_HPP #define BOOST_CONTAINER_ALLOCATION_TYPE_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -36,7 +40,7 @@ enum allocation_type_v try_shrink_in_place_v = 0x40 }; -typedef int allocation_type; +typedef unsigned int allocation_type; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED static const allocation_type allocate_new = (allocation_type)allocate_new_v; static const allocation_type expand_fwd = (allocation_type)expand_fwd_v; diff --git a/boost/container/detail/allocator_version_traits.hpp b/boost/container/detail/allocator_version_traits.hpp deleted file mode 100644 index 18bb2ac..0000000 --- a/boost/container/detail/allocator_version_traits.hpp +++ /dev/null @@ -1,168 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2012-2013. Distributed under the 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_ALLOCATOR_VERSION_TRAITS_HPP -#define BOOST_CONTAINER_DETAIL_ALLOCATOR_VERSION_TRAITS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include //allocator_traits -#include -#include //multiallocation_chain -#include //version_type -#include //allocation_type -#include //integral_constant -#include //pointer_traits -#include //pair -#include //BOOST_TRY - -namespace boost { -namespace container { -namespace container_detail { - -template::value> -struct allocator_version_traits -{ - typedef ::boost::container::container_detail::integral_constant - alloc_version; - - typedef typename Allocator::multiallocation_chain multiallocation_chain; - - typedef typename boost::container::allocator_traits::pointer pointer; - typedef typename boost::container::allocator_traits::size_type size_type; - - //Node allocation interface - static pointer allocate_one(Allocator &a) - { return a.allocate_one(); } - - static void deallocate_one(Allocator &a, const pointer &p) - { a.deallocate_one(p); } - - static void allocate_individual(Allocator &a, size_type n, multiallocation_chain &m) - { return a.allocate_individual(n, m); } - - static void deallocate_individual(Allocator &a, multiallocation_chain &holder) - { a.deallocate_individual(holder); } - - static std::pair - allocation_command(Allocator &a, allocation_type command, - size_type limit_size, size_type preferred_size, - size_type &received_size, const pointer &reuse) - { - return a.allocation_command - (command, limit_size, preferred_size, received_size, reuse); - } -}; - -template -struct allocator_version_traits -{ - typedef ::boost::container::container_detail::integral_constant - alloc_version; - - typedef typename boost::container::allocator_traits::pointer pointer; - typedef typename boost::container::allocator_traits::size_type size_type; - typedef typename boost::container::allocator_traits::value_type value_type; - - typedef typename boost::intrusive::pointer_traits:: - template rebind_pointer::type void_ptr; - typedef container_detail::basic_multiallocation_chain - multialloc_cached_counted; - typedef boost::container::container_detail:: - transform_multiallocation_chain - < multialloc_cached_counted, value_type> multiallocation_chain; - - //Node allocation interface - static pointer allocate_one(Allocator &a) - { return a.allocate(1); } - - static void deallocate_one(Allocator &a, const pointer &p) - { a.deallocate(p, 1); } - - static void deallocate_individual(Allocator &a, multiallocation_chain &holder) - { - size_type n = holder.size(); - typename multiallocation_chain::iterator it = holder.begin(); - while(n--){ - pointer p = boost::intrusive::pointer_traits::pointer_to(*it); - ++it; - a.deallocate(p, 1); - } - } - - struct allocate_individual_rollback - { - allocate_individual_rollback(Allocator &a, multiallocation_chain &chain) - : mr_a(a), mp_chain(&chain) - {} - - ~allocate_individual_rollback() - { - if(mp_chain) - allocator_version_traits::deallocate_individual(mr_a, *mp_chain); - } - - void release() - { - mp_chain = 0; - } - - Allocator &mr_a; - multiallocation_chain * mp_chain; - }; - - static void allocate_individual(Allocator &a, size_type n, multiallocation_chain &m) - { - allocate_individual_rollback rollback(a, m); - while(n--){ - m.push_front(a.allocate(1)); - } - rollback.release(); - } - - static std::pair - allocation_command(Allocator &a, allocation_type command, - size_type, size_type preferred_size, - size_type &received_size, const pointer &) - { - std::pair ret(pointer(), false); - if(!(command & allocate_new)){ - if(!(command & nothrow_allocation)){ - throw_logic_error("version 1 allocator without allocate_new flag"); - } - } - else{ - received_size = preferred_size; - BOOST_TRY{ - ret.first = a.allocate(received_size); - } - BOOST_CATCH(...){ - if(!(command & nothrow_allocation)){ - BOOST_RETHROW - } - } - BOOST_CATCH_END - } - return ret; - } -}; - -} //namespace container_detail { -} //namespace container { -} //namespace boost { - -#include - -#endif // ! defined(BOOST_CONTAINER_DETAIL_ALLOCATOR_VERSION_TRAITS_HPP) diff --git a/boost/container/detail/auto_link.hpp b/boost/container/detail/auto_link.hpp deleted file mode 100644 index 2e47333..0000000 --- a/boost/container/detail/auto_link.hpp +++ /dev/null @@ -1,38 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013. Distributed under the 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_AUTO_LINK_HPP_INCLUDED -#define BOOST_CONTAINER_DETAIL_AUTO_LINK_HPP_INCLUDED - -#if defined(_MSC_VER) -# pragma once -#endif - -// -// Automatically link to the correct build variant where possible. -// -#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_CONTAINER_NO_LIB) && !defined(BOOST_CONTAINER_SOURCE) -// -// Set the name of our library, this will get undef'ed by auto_link.hpp -// once it's done with it: -// -#define BOOST_LIB_NAME boost_container -// -// If we're importing code from a dll, then tell auto_link.hpp about it: -// -#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTAINER_DYN_LINK) -# define BOOST_DYN_LINK -#endif -// -// And include the header that does the work: -// -#include -#endif // auto-linking disabled - -#endif //#ifndef BOOST_CONTAINER_DETAIL_AUTO_LINK_HPP_INCLUDED diff --git a/boost/container/detail/config_begin.hpp b/boost/container/detail/config_begin.hpp index ca9dd59..3f509e3 100644 --- a/boost/container/detail/config_begin.hpp +++ b/boost/container/detail/config_begin.hpp @@ -17,32 +17,34 @@ #ifdef BOOST_MSVC #pragma warning (push) - #pragma warning (disable : 4702) // unreachable code - #pragma warning (disable : 4706) // assignment within conditional expression #pragma warning (disable : 4127) // conditional expression is constant #pragma warning (disable : 4146) // unary minus operator applied to unsigned type, result still unsigned - #pragma warning (disable : 4284) // odd return type for operator-> + #pragma warning (disable : 4197) // top-level volatile in cast is ignored #pragma warning (disable : 4244) // possible loss of data #pragma warning (disable : 4251) // "identifier" : class "type" needs to have dll-interface to be used by clients of class "type2" #pragma warning (disable : 4267) // conversion from "X" to "Y", possible loss of data #pragma warning (disable : 4275) // non DLL-interface classkey "identifier" used as base for DLL-interface classkey "identifier" + #pragma warning (disable : 4284) // odd return type for operator-> + #pragma warning (disable : 4324) // structure was padded due to __declspec(align( + #pragma warning (disable : 4345) // behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized #pragma warning (disable : 4355) // "this" : used in base member initializer list #pragma warning (disable : 4503) // "identifier" : decorated name length exceeded, name was truncated + #pragma warning (disable : 4510) // default constructor could not be generated #pragma warning (disable : 4511) // copy constructor could not be generated #pragma warning (disable : 4512) // assignment operator could not be generated #pragma warning (disable : 4514) // unreferenced inline removed #pragma warning (disable : 4521) // Disable "multiple copy constructors specified" #pragma warning (disable : 4522) // "class" : multiple assignment operators specified + #pragma warning (disable : 4541) // 'typeid' used on polymorphic type '' with /GR-; unpredictable behavior may result + #pragma warning (disable : 4584) // X is already a base-class of Y + #pragma warning (disable : 4610) // struct can never be instantiated - user defined constructor required + #pragma warning (disable : 4671) // the copy constructor is inaccessible + #pragma warning (disable : 4673) // throwing '' the following types will not be considered at the catch site #pragma warning (disable : 4675) // "method" should be declared "static" and have exactly one parameter + #pragma warning (disable : 4702) // unreachable code + #pragma warning (disable : 4706) // assignment within conditional expression #pragma warning (disable : 4710) // function not inlined #pragma warning (disable : 4711) // function selected for automatic inline expansion #pragma warning (disable : 4786) // identifier truncated in debug info #pragma warning (disable : 4996) // "function": was declared deprecated - #pragma warning (disable : 4197) // top-level volatile in cast is ignored - #pragma warning (disable : 4541) // 'typeid' used on polymorphic type 'boost::exception' - // with /GR-; unpredictable behavior may result - #pragma warning (disable : 4673) // throwing '' the following types will not be considered at the catch site - #pragma warning (disable : 4671) // the copy constructor is inaccessible - #pragma warning (disable : 4584) // X is already a base-class of Y - #pragma warning (disable : 4510) // default constructor could not be generated #endif //BOOST_MSVC diff --git a/boost/container/detail/utilities.hpp b/boost/container/detail/copy_move_algo.hpp similarity index 59% rename from boost/container/detail/utilities.hpp rename to boost/container/detail/copy_move_algo.hpp index 25f035d..23fa730 100644 --- a/boost/container/detail/utilities.hpp +++ b/boost/container/detail/copy_move_algo.hpp @@ -7,225 +7,37 @@ // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// - #ifndef BOOST_CONTAINER_DETAIL_UTILITIES_HPP #define BOOST_CONTAINER_DETAIL_UTILITIES_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif -#include -#include - -#include -#include //for ::memmove / ::memcpy -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +// container +#include +// container/detail +#include +#include #include #include -#include +// move +#include +#include +#include +// other #include -#include -#include -#include -#include -#include //std::distance +// std +#include //for emmove/memcpy namespace boost { namespace container { - -////////////////////////////////////////////////////////////////////////////// -// -// swap -// -////////////////////////////////////////////////////////////////////////////// - -namespace container_swap { - -template::value > -struct has_member_swap -{ - static const bool value = boost::container::container_detail:: - has_member_function_callable_with_swap::value; -}; - -template -struct has_member_swap -{ - static const bool value = false; -}; - -} //namespace container_swap { - -template inline -typename container_detail::enable_if_c - ::value, void>::type -swap_dispatch(T &left, T &right) //swap using member swap -{ - left.swap(right); // may throw -} - -template inline -typename container_detail::enable_if_c - ::value/* && boost::has_move_emulation_enabled::value*/, void>::type - swap_dispatch(T &left, T &right) -{ - T temp(boost::move(left)); // may throw - left = boost::move(right); // may throw - right = boost::move(temp); // may throw -} -/* -template inline -typename container_detail::enable_if_c - ::value && !boost::has_move_emulation_enabled::value, void>::type - swap_dispatch(T &left, T &right) -{ - using std::swap; - swap(left, right); // may throw -} -*/ namespace container_detail { -template -inline T* addressof(T& obj) -{ - return static_cast( - static_cast( - const_cast( - &reinterpret_cast(obj) - ))); -} - -template -const T &max_value(const T &a, const T &b) -{ return a > b ? a : b; } - -template -const T &min_value(const T &a, const T &b) -{ return a < b ? a : b; } - -enum NextCapacityOption { NextCapacityDouble, NextCapacity60Percent }; - -template -struct next_capacity_calculator; - -template -struct next_capacity_calculator -{ - static SizeType get(const SizeType max_size - ,const SizeType capacity - ,const SizeType n) - { - const SizeType remaining = max_size - capacity; - if ( remaining < n ) - boost::container::throw_length_error("get_next_capacity, allocator's max_size reached"); - const SizeType additional = max_value(n, capacity); - return ( remaining < additional ) ? max_size : ( capacity + additional ); - } -}; - - -template -struct next_capacity_calculator -{ - static SizeType get(const SizeType max_size - ,const SizeType capacity - ,const SizeType n) - { - const SizeType remaining = max_size - capacity; - if ( remaining < n ) - boost::container::throw_length_error("get_next_capacity, allocator's max_size reached"); - const SizeType m3 = max_size/3; - - if (capacity < m3) - return capacity + max_value(3*(capacity+1)/5, n); - - if (capacity < m3*2) - return capacity + max_value((capacity+1)/2, n); - return max_size; - } -}; - -template -inline T* to_raw_pointer(T* p) -{ return p; } - -template -inline typename boost::intrusive::pointer_traits::element_type* - to_raw_pointer(const Pointer &p) -{ return boost::container::container_detail::to_raw_pointer(p.operator->()); } - -template -inline T* iterator_to_pointer(T* i) -{ return i; } - -template -inline typename std::iterator_traits::pointer - iterator_to_pointer(const Iterator &i) -{ return i.operator->(); } - -template -inline - typename boost::intrusive::pointer_traits - ::pointer>::element_type* - iterator_to_raw_pointer(const Iterator &i) -{ return (to_raw_pointer)((iterator_to_pointer)(i)); } - - -template -inline void swap_alloc(AllocatorType &, AllocatorType &, container_detail::false_type) - BOOST_CONTAINER_NOEXCEPT -{} - -template -inline void swap_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) -{ boost::container::swap_dispatch(l, r); } - -template -inline void assign_alloc(AllocatorType &, const AllocatorType &, container_detail::false_type) - BOOST_CONTAINER_NOEXCEPT -{} - -template -inline void assign_alloc(AllocatorType &l, const AllocatorType &r, container_detail::true_type) -{ l = r; } - -template -inline void move_alloc(AllocatorType &, AllocatorType &, container_detail::false_type) - BOOST_CONTAINER_NOEXCEPT -{} - -template -inline void move_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) -{ l = ::boost::move(r); } - -//Rounds "orig_size" by excess to round_to bytes -template -inline SizeType get_rounded_size(SizeType orig_size, SizeType round_to) -{ - return ((orig_size-1)/round_to+1)*round_to; -} - -template -struct ct_rounded_size -{ - enum { value = ((OrigSize-1)/RoundTo+1)*RoundTo }; -}; - template struct are_elements_contiguous { @@ -242,6 +54,15 @@ struct are_elements_contiguous static const bool value = true; }; +///////////////////////// +// move iterators +///////////////////////// + +template +struct are_elements_contiguous< ::boost::move_iterator > + : are_elements_contiguous +{}; + ///////////////////////// // predeclarations ///////////////////////// @@ -302,127 +123,149 @@ struct are_elements_contiguous< ::boost::interprocess::offset_ptr struct are_contiguous_and_same -{ - static const bool is_same_io = - is_same< typename remove_const< typename ::std::iterator_traits::value_type >::type - , typename ::std::iterator_traits::value_type - >::value; - static const bool value = is_same_io && - are_elements_contiguous::value && - are_elements_contiguous::value; -}; + : boost::move_detail::and_ + < are_elements_contiguous + , are_elements_contiguous + , is_same< typename remove_const< typename ::boost::container::iterator_traits::value_type >::type + , typename ::boost::container::iterator_traits::value_type + > + > +{}; template struct is_memtransfer_copy_assignable -{ - static const bool value = are_contiguous_and_same::value && - boost::has_trivial_assign< typename ::std::iterator_traits::value_type >::value; -}; + : boost::move_detail::and_ + < are_contiguous_and_same + , container_detail::is_trivially_copy_assignable< typename ::boost::container::iterator_traits::value_type > + > +{}; template struct is_memtransfer_copy_constructible -{ - static const bool value = are_contiguous_and_same::value && - boost::has_trivial_copy< typename ::std::iterator_traits::value_type >::value; -}; + : boost::move_detail::and_ + < are_contiguous_and_same + , container_detail::is_trivially_copy_constructible< typename ::boost::container::iterator_traits::value_type > + > +{}; template struct enable_if_memtransfer_copy_constructible - : public enable_if_c::value, R> + : enable_if, R> {}; template struct disable_if_memtransfer_copy_constructible - : public enable_if_c::value, R> + : disable_if, R> {}; template struct enable_if_memtransfer_copy_assignable - : public enable_if_c::value, R> + : enable_if, R> {}; template struct disable_if_memtransfer_copy_assignable - : public enable_if_c::value, R> + : disable_if, R> {}; template // F models ForwardIterator -inline F memmove(I f, I l, F r) BOOST_CONTAINER_NOEXCEPT +inline F memmove(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename std::iterator_traits::value_type value_type; - typename std::iterator_traits::difference_type n = std::distance(f, l); - ::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); - std::advance(r, n); + typedef typename boost::container::iterator_traits::value_type value_type; + typename boost::container::iterator_traits::difference_type n = boost::container::iterator_distance(f, l); + if(n){ + std::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); + boost::container::iterator_advance(r, n); + } return r; } template // F models ForwardIterator -F memmove_n(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +F memmove_n(I f, typename boost::container::iterator_traits::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename std::iterator_traits::value_type value_type; - ::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); - std::advance(r, n); + typedef typename boost::container::iterator_traits::value_type value_type; + if(n){ + std::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); + boost::container::iterator_advance(r, n); + } return r; } template // F models ForwardIterator -I memmove_n_source(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT +I memmove_n_source(I f, typename boost::container::iterator_traits::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename std::iterator_traits::value_type value_type; - ::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); - std::advance(f, n); + if(n){ + typedef typename boost::container::iterator_traits::value_type value_type; + std::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); + boost::container::iterator_advance(f, n); + } return f; } template // F models ForwardIterator -I memmove_n_source_dest(I f, typename std::iterator_traits::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT +I memmove_n_source_dest(I f, typename boost::container::iterator_traits::difference_type n, F &r) BOOST_NOEXCEPT_OR_NOTHROW { - typedef typename std::iterator_traits::value_type value_type; - ::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); - std::advance(f, n); - std::advance(r, n); + typedef typename boost::container::iterator_traits::value_type value_type; + if(n){ + std::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n); + boost::container::iterator_advance(f, n); + boost::container::iterator_advance(r, n); + } return f; } template struct is_memzero_initializable { - typedef typename ::std::iterator_traits::value_type value_type; + typedef typename ::boost::container::iterator_traits::value_type value_type; static const bool value = are_elements_contiguous::value && - ( ::boost::is_integral::value || ::boost::is_enum::value + ( container_detail::is_integral::value || container_detail::is_enum::value #if defined(BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL) - || ::boost::is_pointer::value + || container_detail::is_pointer::value #endif #if defined(BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_ZERO) - || ::boost::is_floating_point::value + || container_detail::is_floating_point::value #endif #if defined(BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_ZERO) && defined(BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL) - || ::boost::is_pod::value + || container_detail::is_pod::value #endif ); }; template struct enable_if_memzero_initializable - : public enable_if_c::value, R> + : enable_if_c::value, R> {}; template struct disable_if_memzero_initializable - : public enable_if_c::value, R> + : enable_if_c::value, R> +{}; + +template +struct enable_if_trivially_destructible + : enable_if_c < false/*container_detail::is_trivially_destructible + ::value_type>::value*/ + , R> +{}; + +template +struct disable_if_trivially_destructible + : enable_if_c ::value_type>::value*/ + , R> {}; } //namespace container_detail { - ////////////////////////////////////////////////////////////////////////////// // // uninitialized_move_alloc @@ -438,22 +281,22 @@ struct disable_if_memzero_initializable //! //! Returns: r template - // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible::type - uninitialized_move_alloc(A &a, I f, I l, F r) + uninitialized_move_alloc(Allocator &a, I f, I l, F r) { F back = r; BOOST_TRY{ while (f != l) { - allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); + allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -462,11 +305,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible::type - uninitialized_move_alloc(A &, I f, I l, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_move_alloc(Allocator &, I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove(f, l, r); } ////////////////////////////////////////////////////////////////////////////// @@ -483,22 +326,22 @@ inline typename container_detail::enable_if_memtransfer_copy_constructibleReturns: r template - // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible::type - uninitialized_move_alloc_n(A &a, I f, typename std::iterator_traits::difference_type n, F r) + uninitialized_move_alloc_n(Allocator &a, I f, typename boost::container::iterator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); + allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -507,11 +350,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible::type - uninitialized_move_alloc_n(A &, I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_move_alloc_n(Allocator &, I f, typename boost::container::iterator_traits::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -528,22 +371,22 @@ inline typename container_detail::enable_if_memtransfer_copy_constructibleReturns: f (after incremented) template - // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible::type - uninitialized_move_alloc_n_source(A &a, I f, typename std::iterator_traits::difference_type n, F r) + uninitialized_move_alloc_n_source(Allocator &a, I f, typename boost::container::iterator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); + allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), boost::move(*f)); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -552,11 +395,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible::type - uninitialized_move_alloc_n_source(A &, I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_move_alloc_n_source(Allocator &, I f, typename boost::container::iterator_traits::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n_source(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -573,22 +416,22 @@ inline typename container_detail::enable_if_memtransfer_copy_constructibleReturns: r template - // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible::type - uninitialized_copy_alloc(A &a, I f, I l, F r) + uninitialized_copy_alloc(Allocator &a, I f, I l, F r) { F back = r; BOOST_TRY{ while (f != l) { - allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), *f); + allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), *f); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -597,11 +440,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible::type - uninitialized_copy_alloc(A &, I f, I l, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_copy_alloc(Allocator &, I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove(f, l, r); } ////////////////////////////////////////////////////////////////////////////// @@ -618,22 +461,22 @@ inline typename container_detail::enable_if_memtransfer_copy_constructibleReturns: r template - // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible::type - uninitialized_copy_alloc_n(A &a, I f, typename std::iterator_traits::difference_type n, F r) + uninitialized_copy_alloc_n(Allocator &a, I f, typename boost::container::iterator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), *f); + allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), *f); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -642,11 +485,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible::type - uninitialized_copy_alloc_n(A &, I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_copy_alloc_n(Allocator &, I f, typename boost::container::iterator_traits::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -663,22 +506,22 @@ inline typename container_detail::enable_if_memtransfer_copy_constructibleReturns: f (after incremented) template - // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_constructible::type - uninitialized_copy_alloc_n_source(A &a, I f, typename std::iterator_traits::difference_type n, F r) + uninitialized_copy_alloc_n_source(Allocator &a, I f, typename boost::container::iterator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), *f); + allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), *f); ++f; ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -687,11 +530,11 @@ inline typename container_detail::disable_if_memtransfer_copy_constructible // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_constructible::type - uninitialized_copy_alloc_n_source(A &, I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + uninitialized_copy_alloc_n_source(Allocator &, I f, typename boost::container::iterator_traits::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n_source(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -708,21 +551,21 @@ inline typename container_detail::enable_if_memtransfer_copy_constructibleReturns: r template - // F models ForwardIterator inline typename container_detail::disable_if_memzero_initializable::type - uninitialized_value_init_alloc_n(A &a, typename allocator_traits::difference_type n, F r) + uninitialized_value_init_alloc_n(Allocator &a, typename allocator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r)); + allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r)); ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -731,14 +574,14 @@ inline typename container_detail::disable_if_memzero_initializable::type } template - // F models ForwardIterator inline typename container_detail::enable_if_memzero_initializable::type - uninitialized_value_init_alloc_n(A &, typename allocator_traits::difference_type n, F r) + uninitialized_value_init_alloc_n(Allocator &, typename allocator_traits::difference_type n, F r) { - typedef typename std::iterator_traits::value_type value_type; - ::memset((void*)container_detail::iterator_to_raw_pointer(r), 0, sizeof(value_type)*n); - std::advance(r, n); + typedef typename boost::container::iterator_traits::value_type value_type; + std::memset((void*)container_detail::iterator_to_raw_pointer(r), 0, sizeof(value_type)*n); + boost::container::iterator_advance(r, n); return r; } @@ -756,20 +599,20 @@ inline typename container_detail::enable_if_memzero_initializable::type //! //! Returns: r template - // F models ForwardIterator -inline F uninitialized_default_init_alloc_n(A &a, typename allocator_traits::difference_type n, F r) +inline F uninitialized_default_init_alloc_n(Allocator &a, typename allocator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), default_init); + allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), default_init); ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -791,21 +634,21 @@ inline F uninitialized_default_init_alloc_n(A &a, typename allocator_traits:: //! //! Returns: r template - -inline void uninitialized_fill_alloc(A &a, F f, F l, const T &t) +inline void uninitialized_fill_alloc(Allocator &a, F f, F l, const T &t) { F back = f; BOOST_TRY{ while (f != l) { - allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(f), t); + allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(f), t); ++f; } } BOOST_CATCH(...){ for (; back != l; ++back){ - allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -827,21 +670,21 @@ inline void uninitialized_fill_alloc(A &a, F f, F l, const T &t) //! //! Returns: r template - // F models ForwardIterator -inline F uninitialized_fill_alloc_n(A &a, const T &v, typename allocator_traits::difference_type n, F r) +inline F uninitialized_fill_alloc_n(Allocator &a, const T &v, typename allocator_traits::difference_type n, F r) { F back = r; BOOST_TRY{ while (n--) { - allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), v); + allocator_traits::construct(a, container_detail::iterator_to_raw_pointer(r), v); ++r; } } BOOST_CATCH(...){ for (; back != r; ++back){ - allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); + allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(back)); } BOOST_RETHROW; } @@ -872,7 +715,7 @@ template // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable::type - copy(I f, I l, F r) BOOST_CONTAINER_NOEXCEPT + copy(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove(f, l, r); } ////////////////////////////////////////////////////////////////////////////// @@ -885,7 +728,7 @@ template // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_assignable::type - copy_n(I f, typename std::iterator_traits::difference_type n, F r) + copy_n(I f, typename boost::container::iterator_traits::difference_type n, F r) { while (n--) { *r = *f; @@ -898,7 +741,7 @@ template // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable::type - copy_n(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + copy_n(I f, typename boost::container::iterator_traits::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -911,7 +754,7 @@ template // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_assignable::type - copy_n_source(I f, typename std::iterator_traits::difference_type n, F r) + copy_n_source(I f, typename boost::container::iterator_traits::difference_type n, F r) { while (n--) { *r = *f; @@ -924,7 +767,7 @@ template // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable::type - copy_n_source(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + copy_n_source(I f, typename boost::container::iterator_traits::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n_source(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -937,7 +780,7 @@ template // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_assignable::type - copy_n_source_dest(I f, typename std::iterator_traits::difference_type n, F &r) + copy_n_source_dest(I f, typename boost::container::iterator_traits::difference_type n, F &r) { while (n--) { *r = *f; @@ -950,7 +793,7 @@ template // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable::type - copy_n_source_dest(I f, typename std::iterator_traits::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT + copy_n_source_dest(I f, typename boost::container::iterator_traits::difference_type n, F &r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n_source_dest(f, n, r); } ////////////////////////////////////////////////////////////////////////////// @@ -976,7 +819,7 @@ template // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable::type - move(I f, I l, F r) BOOST_CONTAINER_NOEXCEPT + move(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove(f, l, r); } ////////////////////////////////////////////////////////////////////////////// @@ -989,7 +832,7 @@ template // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_assignable::type - move_n(I f, typename std::iterator_traits::difference_type n, F r) + move_n(I f, typename boost::container::iterator_traits::difference_type n, F r) { while (n--) { *r = ::boost::move(*f); @@ -1002,34 +845,41 @@ template // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable::type - move_n(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT + move_n(I f, typename boost::container::iterator_traits::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n(f, n, r); } + ////////////////////////////////////////////////////////////////////////////// // -// move_n_source +// move_backward // ////////////////////////////////////////////////////////////////////////////// template - // F models ForwardIterator -inline typename container_detail::disable_if_memtransfer_copy_assignable::type - move_n_source(I f, typename std::iterator_traits::difference_type n, F r) + // F models ForwardIterator +inline typename container_detail::disable_if_memtransfer_copy_assignable::type + move_backward(I f, I l, F r) { - while (n--) { - *r = ::boost::move(*f); - ++f; ++r; + while (f != l) { + --l; --r; + *r = ::boost::move(*l); } - return f; + return r; } template - // F models ForwardIterator -inline typename container_detail::enable_if_memtransfer_copy_assignable::type - move_n_source(I f, typename std::iterator_traits::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT -{ return container_detail::memmove_n_source(f, n, r); } + // F models ForwardIterator +inline typename container_detail::enable_if_memtransfer_copy_assignable::type + move_backward(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW +{ + typedef typename boost::container::iterator_traits::value_type value_type; + const typename boost::container::iterator_traits::difference_type n = boost::container::iterator_distance(f, l); + r -= n; + std::memmove((container_detail::iterator_to_raw_pointer)(r), (container_detail::iterator_to_raw_pointer)(f), sizeof(value_type)*n); + return r; +} ////////////////////////////////////////////////////////////////////////////// // @@ -1041,7 +891,7 @@ template // F models ForwardIterator inline typename container_detail::disable_if_memtransfer_copy_assignable::type - move_n_source_dest(I f, typename std::iterator_traits::difference_type n, F &r) + move_n_source_dest(I f, typename boost::container::iterator_traits::difference_type n, F &r) { while (n--) { *r = ::boost::move(*f); @@ -1054,33 +904,60 @@ template // F models ForwardIterator inline typename container_detail::enable_if_memtransfer_copy_assignable::type - move_n_source_dest(I f, typename std::iterator_traits::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT + move_n_source_dest(I f, typename boost::container::iterator_traits::difference_type n, F &r) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::memmove_n_source_dest(f, n, r); } ////////////////////////////////////////////////////////////////////////////// // -// destroy_n +// move_n_source // ////////////////////////////////////////////////////////////////////////////// template - // I models InputIterator -inline void destroy_alloc_n(A &a, I f, typename std::iterator_traits::difference_type n - ,typename boost::container::container_detail::enable_if_c - < !boost::has_trivial_destructor::value_type>::value >::type* = 0) + // F models ForwardIterator +inline typename container_detail::disable_if_memtransfer_copy_assignable::type + move_n_source(I f, typename boost::container::iterator_traits::difference_type n, F r) +{ + while (n--) { + *r = ::boost::move(*f); + ++f; ++r; + } + return f; +} + +template + // F models ForwardIterator +inline typename container_detail::enable_if_memtransfer_copy_assignable::type + move_n_source(I f, typename boost::container::iterator_traits::difference_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW +{ return container_detail::memmove_n_source(f, n, r); } + +////////////////////////////////////////////////////////////////////////////// +// +// destroy_alloc_n +// +////////////////////////////////////////////////////////////////////////////// + +template + // U models unsigned integral constant +inline typename container_detail::disable_if_trivially_destructible::type + destroy_alloc_n(Allocator &a, I f, U n) { while(n--){ - allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(f++)); + allocator_traits::destroy(a, container_detail::iterator_to_raw_pointer(f)); + ++f; } } template - // I models InputIterator -inline void destroy_alloc_n(A &, I, typename std::iterator_traits::difference_type - ,typename boost::container::container_detail::enable_if_c - < boost::has_trivial_destructor::value_type>::value >::type* = 0) + // U models unsigned integral constant +inline typename container_detail::enable_if_trivially_destructible::type + destroy_alloc_n(Allocator &, I, U) {} ////////////////////////////////////////////////////////////////////////////// @@ -1091,17 +968,17 @@ inline void destroy_alloc_n(A &, I, typename std::iterator_traits::difference template inline typename container_detail::disable_if_memtransfer_copy_assignable::type - deep_swap_alloc_n( A &a, F short_range_f, typename allocator_traits::size_type n_i - , G large_range_f, typename allocator_traits::size_type n_j) + deep_swap_alloc_n( Allocator &a, F short_range_f, typename allocator_traits::size_type n_i + , G large_range_f, typename allocator_traits::size_type n_j) { - typename allocator_traits::size_type n = 0; + typename allocator_traits::size_type n = 0; for (; n != n_i ; ++short_range_f, ++large_range_f, ++n){ - boost::container::swap_dispatch(*short_range_f, *large_range_f); + boost::adl_move_swap(*short_range_f, *large_range_f); } boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i); @@ -1111,18 +988,18 @@ static const std::size_t DeepSwapAllocNMaxStorage = std::size_t(1) << std::size_ template inline typename container_detail::enable_if_c < container_detail::is_memtransfer_copy_assignable::value && (MaxTmpBytes <= DeepSwapAllocNMaxStorage) && false , void>::type - deep_swap_alloc_n( A &a, F short_range_f, typename allocator_traits::size_type n_i - , G large_range_f, typename allocator_traits::size_type n_j) + deep_swap_alloc_n( Allocator &a, F short_range_f, typename allocator_traits::size_type n_i + , G large_range_f, typename allocator_traits::size_type n_j) { - typedef typename allocator_traits::value_type value_type; - typedef typename boost::aligned_storage + typedef typename allocator_traits::value_type value_type; + typedef typename container_detail::aligned_storage ::value>::type storage_type; storage_type storage; @@ -1130,29 +1007,29 @@ inline typename container_detail::enable_if_c void *const large_ptr = static_cast(container_detail::iterator_to_raw_pointer(large_range_f)); void *const short_ptr = static_cast(container_detail::iterator_to_raw_pointer(short_range_f)); void *const stora_ptr = static_cast(container_detail::iterator_to_raw_pointer(storage)); - ::memcpy(stora_ptr, large_ptr, n_i_bytes); - ::memcpy(large_ptr, short_ptr, n_i_bytes); - ::memcpy(short_ptr, stora_ptr, n_i_bytes); - std::advance(large_range_f, n_i); - std::advance(short_range_f, n_i); + std::memcpy(stora_ptr, large_ptr, n_i_bytes); + std::memcpy(large_ptr, short_ptr, n_i_bytes); + std::memcpy(short_ptr, stora_ptr, n_i_bytes); + boost::container::iterator_advance(large_range_f, n_i); + boost::container::iterator_advance(short_range_f, n_i); boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i); } template inline typename container_detail::enable_if_c < container_detail::is_memtransfer_copy_assignable::value && true//(MaxTmpBytes > DeepSwapAllocNMaxStorage) , void>::type - deep_swap_alloc_n( A &a, F short_range_f, typename allocator_traits::size_type n_i - , G large_range_f, typename allocator_traits::size_type n_j) + deep_swap_alloc_n( Allocator &a, F short_range_f, typename allocator_traits::size_type n_i + , G large_range_f, typename allocator_traits::size_type n_j) { - typedef typename allocator_traits::value_type value_type; - typedef typename boost::aligned_storage + typedef typename allocator_traits::value_type value_type; + typedef typename container_detail::aligned_storage ::value>::type storage_type; storage_type storage; const std::size_t sizeof_storage = sizeof(storage); @@ -1173,39 +1050,39 @@ inline typename container_detail::enable_if_c case 4: break; case 0: do{ - ::memcpy(stora_ptr, large_ptr, sizeof_storage); - ::memcpy(large_ptr, short_ptr, sizeof_storage); - ::memcpy(short_ptr, stora_ptr, sizeof_storage); + std::memcpy(stora_ptr, large_ptr, sizeof_storage); + std::memcpy(large_ptr, short_ptr, sizeof_storage); + std::memcpy(short_ptr, stora_ptr, sizeof_storage); large_ptr += sizeof_storage; short_ptr += sizeof_storage; BOOST_CONTAINER_FALLTHOUGH case 3: - ::memcpy(stora_ptr, large_ptr, sizeof_storage); - ::memcpy(large_ptr, short_ptr, sizeof_storage); - ::memcpy(short_ptr, stora_ptr, sizeof_storage); + std::memcpy(stora_ptr, large_ptr, sizeof_storage); + std::memcpy(large_ptr, short_ptr, sizeof_storage); + std::memcpy(short_ptr, stora_ptr, sizeof_storage); large_ptr += sizeof_storage; short_ptr += sizeof_storage; BOOST_CONTAINER_FALLTHOUGH case 2: - ::memcpy(stora_ptr, large_ptr, sizeof_storage); - ::memcpy(large_ptr, short_ptr, sizeof_storage); - ::memcpy(short_ptr, stora_ptr, sizeof_storage); + std::memcpy(stora_ptr, large_ptr, sizeof_storage); + std::memcpy(large_ptr, short_ptr, sizeof_storage); + std::memcpy(short_ptr, stora_ptr, sizeof_storage); large_ptr += sizeof_storage; short_ptr += sizeof_storage; BOOST_CONTAINER_FALLTHOUGH case 1: - ::memcpy(stora_ptr, large_ptr, sizeof_storage); - ::memcpy(large_ptr, short_ptr, sizeof_storage); - ::memcpy(short_ptr, stora_ptr, sizeof_storage); + std::memcpy(stora_ptr, large_ptr, sizeof_storage); + std::memcpy(large_ptr, short_ptr, sizeof_storage); + std::memcpy(short_ptr, stora_ptr, sizeof_storage); large_ptr += sizeof_storage; short_ptr += sizeof_storage; } while(--n); } - ::memcpy(stora_ptr, large_ptr, szt_rem); - ::memcpy(large_ptr, short_ptr, szt_rem); - ::memcpy(short_ptr, stora_ptr, szt_rem); - std::advance(large_range_f, n_i); - std::advance(short_range_f, n_i); + std::memcpy(stora_ptr, large_ptr, szt_rem); + std::memcpy(large_ptr, short_ptr, szt_rem); + std::memcpy(short_ptr, stora_ptr, szt_rem); + boost::container::iterator_advance(large_range_f, n_i); + boost::container::iterator_advance(short_range_f, n_i); boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i); } @@ -1218,12 +1095,12 @@ inline typename container_detail::enable_if_c ////////////////////////////////////////////////////////////////////////////// template - -void copy_assign_range_alloc_n( A &a, I inp_start, typename allocator_traits::size_type n_i - , O out_start, typename allocator_traits::size_type n_o ) +void copy_assign_range_alloc_n( Allocator &a, I inp_start, typename allocator_traits::size_type n_i + , O out_start, typename allocator_traits::size_type n_o ) { if (n_o < n_i){ inp_start = boost::container::copy_n_source_dest(inp_start, n_o, out_start); // may throw @@ -1242,12 +1119,12 @@ void copy_assign_range_alloc_n( A &a, I inp_start, typename allocator_traits: ////////////////////////////////////////////////////////////////////////////// template - -void move_assign_range_alloc_n( A &a, I inp_start, typename allocator_traits::size_type n_i - , O out_start, typename allocator_traits::size_type n_o ) +void move_assign_range_alloc_n( Allocator &a, I inp_start, typename allocator_traits::size_type n_i + , O out_start, typename allocator_traits::size_type n_o ) { if (n_o < n_i){ inp_start = boost::container::move_n_source_dest(inp_start, n_o, out_start); // may throw @@ -1262,6 +1139,4 @@ void move_assign_range_alloc_n( A &a, I inp_start, typename allocator_traits: } //namespace container { } //namespace boost { -#include - #endif //#ifndef BOOST_CONTAINER_DETAIL_UTILITIES_HPP diff --git a/boost/container/detail/destroyers.hpp b/boost/container/detail/destroyers.hpp index ea9b617..52b44c0 100644 --- a/boost/container/detail/destroyers.hpp +++ b/boost/container/detail/destroyers.hpp @@ -13,16 +13,20 @@ #ifndef BOOST_CONTAINER_DESTROYERS_HPP #define BOOST_CONTAINER_DESTROYERS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include -#include -#include #include +#include +#include namespace boost { namespace container { @@ -30,22 +34,20 @@ namespace container_detail { //!A deleter for scoped_ptr that deallocates the memory //!allocated for an object using a STL allocator. -template +template struct scoped_deallocator { - typedef allocator_traits allocator_traits_type; + typedef allocator_traits allocator_traits_type; typedef typename allocator_traits_type::pointer pointer; typedef container_detail::integral_constant::value> alloc_version; - typedef container_detail::integral_constant allocator_v1; - typedef container_detail::integral_constant allocator_v2; + version::value> alloc_version; private: - void priv_deallocate(allocator_v1) + void priv_deallocate(version_1) { m_alloc.deallocate(m_ptr, 1); } - void priv_deallocate(allocator_v2) + void priv_deallocate(version_2) { m_alloc.deallocate_one(m_ptr); } BOOST_MOVABLE_BUT_NOT_COPYABLE(scoped_deallocator) @@ -53,9 +55,9 @@ struct scoped_deallocator public: pointer m_ptr; - A& m_alloc; + Allocator& m_alloc; - scoped_deallocator(pointer p, A& a) + scoped_deallocator(pointer p, Allocator& a) : m_ptr(p), m_alloc(a) {} @@ -143,8 +145,6 @@ struct scoped_destroy_deallocator typedef container_detail::integral_constant::value> alloc_version; - typedef container_detail::integral_constant allocator_v1; - typedef container_detail::integral_constant allocator_v2; scoped_destroy_deallocator(pointer p, Allocator& a) : m_ptr(p), m_alloc(a) {} @@ -162,10 +162,10 @@ struct scoped_destroy_deallocator private: - void priv_deallocate(const pointer &p, allocator_v1) + void priv_deallocate(const pointer &p, version_1) { AllocTraits::deallocate(m_alloc, p, 1); } - void priv_deallocate(const pointer &p, allocator_v2) + void priv_deallocate(const pointer &p, version_2) { m_alloc.deallocate_one(p); } pointer m_ptr; @@ -239,13 +239,13 @@ struct null_scoped_destructor_n {} }; -template +template class scoped_destructor { - typedef boost::container::allocator_traits AllocTraits; + typedef boost::container::allocator_traits AllocTraits; public: - typedef typename A::value_type value_type; - scoped_destructor(A &a, value_type *pv) + typedef typename Allocator::value_type value_type; + scoped_destructor(Allocator &a, value_type *pv) : pv_(pv), a_(a) {} @@ -266,17 +266,17 @@ class scoped_destructor private: value_type *pv_; - A &a_; + Allocator &a_; }; -template +template class value_destructor { - typedef boost::container::allocator_traits AllocTraits; + typedef boost::container::allocator_traits AllocTraits; public: - typedef typename A::value_type value_type; - value_destructor(A &a, value_type &rv) + typedef typename Allocator::value_type value_type; + value_destructor(Allocator &a, value_type &rv) : rv_(rv), a_(a) {} @@ -287,7 +287,7 @@ class value_destructor private: value_type &rv_; - A &a_; + Allocator &a_; }; template @@ -299,21 +299,19 @@ class allocator_destroyer typedef container_detail::integral_constant::value> alloc_version; - typedef container_detail::integral_constant allocator_v1; - typedef container_detail::integral_constant allocator_v2; private: Allocator & a_; private: - void priv_deallocate(const pointer &p, allocator_v1) + void priv_deallocate(const pointer &p, version_1) { AllocTraits::deallocate(a_,p, 1); } - void priv_deallocate(const pointer &p, allocator_v2) + void priv_deallocate(const pointer &p, version_2) { a_.deallocate_one(p); } public: - allocator_destroyer(Allocator &a) + explicit allocator_destroyer(Allocator &a) : a_(a) {} @@ -324,41 +322,41 @@ class allocator_destroyer } }; -template +template class allocator_destroyer_and_chain_builder { - typedef allocator_traits allocator_traits_type; + typedef allocator_traits allocator_traits_type; typedef typename allocator_traits_type::value_type value_type; - typedef typename A::multiallocation_chain multiallocation_chain; + typedef typename Allocator::multiallocation_chain multiallocation_chain; - A & a_; + Allocator & a_; multiallocation_chain &c_; public: - allocator_destroyer_and_chain_builder(A &a, multiallocation_chain &c) + allocator_destroyer_and_chain_builder(Allocator &a, multiallocation_chain &c) : a_(a), c_(c) {} - void operator()(const typename A::pointer &p) + void operator()(const typename Allocator::pointer &p) { - allocator_traits::destroy(a_, container_detail::to_raw_pointer(p)); + allocator_traits::destroy(a_, container_detail::to_raw_pointer(p)); c_.push_back(p); } }; -template +template class allocator_multialloc_chain_node_deallocator { - typedef allocator_traits allocator_traits_type; + typedef allocator_traits 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 chain_builder; + typedef typename Allocator::multiallocation_chain multiallocation_chain; + typedef allocator_destroyer_and_chain_builder chain_builder; - A & a_; + Allocator & a_; multiallocation_chain c_; public: - allocator_multialloc_chain_node_deallocator(A &a) + allocator_multialloc_chain_node_deallocator(Allocator &a) : a_(a), c_() {} diff --git a/boost/container/detail/flat_tree.hpp b/boost/container/detail/flat_tree.hpp index a6f7568..f274211 100644 --- a/boost/container/detail/flat_tree.hpp +++ b/boost/container/detail/flat_tree.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_FLAT_TREE_HPP #define BOOST_CONTAINER_FLAT_TREE_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -20,29 +24,29 @@ #include -#include -#include -#include - -#include #include -#include #include #include #include #include +#include //algo_equal(), algo_lexicographical_compare +#include #include #ifdef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER #include #endif -#include +#include #include +#include +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif + +#include //pair namespace boost { - namespace container { - namespace container_detail { template @@ -78,30 +82,29 @@ template struct get_flat_tree_iterators { #ifdef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER - typedef Pointer iterator; + typedef Pointer iterator; typedef typename boost::intrusive:: - pointer_traits::element_type iterator_element_type; + pointer_traits::element_type iterator_element_type; typedef typename boost::intrusive:: pointer_traits:: template - rebind_pointer::type const_iterator; + rebind_pointer::type const_iterator; #else //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER typedef typename boost::container::container_detail:: - vec_iterator iterator; + vec_iterator iterator; typedef typename boost::container::container_detail:: - vec_iterator const_iterator; + vec_iterator const_iterator; #endif //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER - typedef boost::container::container_detail:: - reverse_iterator reverse_iterator; - typedef boost::container::container_detail:: - reverse_iterator const_reverse_iterator; + typedef boost::container::reverse_iterator reverse_iterator; + typedef boost::container::reverse_iterator const_reverse_iterator; }; template + class Compare, class Allocator> class flat_tree { - typedef boost::container::vector vector_t; - typedef A allocator_t; + typedef boost::container::vector vector_t; + typedef Allocator allocator_t; + typedef allocator_traits allocator_traits_type; public: typedef flat_tree_value_compare value_compare; @@ -126,11 +129,11 @@ class flat_tree : value_compare(boost::move(static_cast(d))), m_vect(boost::move(d.m_vect)) {} - Data(const Data &d, const A &a) + Data(const Data &d, const Allocator &a) : value_compare(static_cast(d)), m_vect(d.m_vect, a) {} - Data(BOOST_RV_REF(Data) d, const A &a) + Data(BOOST_RV_REF(Data) d, const Allocator &a) : value_compare(boost::move(static_cast(d))), m_vect(boost::move(d.m_vect), a) {} @@ -163,7 +166,7 @@ class flat_tree void swap(Data &d) { value_compare& mycomp = *this, & othercomp = d; - boost::container::swap_dispatch(mycomp, othercomp); + boost::adl_move_swap(mycomp, othercomp); this->m_vect.swap(d.m_vect); } @@ -265,8 +268,10 @@ class flat_tree flat_tree& operator=(BOOST_COPY_ASSIGN_REF(flat_tree) x) { m_data = x.m_data; return *this; } - flat_tree& operator=(BOOST_RV_REF(flat_tree) mx) - { m_data = boost::move(mx.m_data); return *this; } + flat_tree& operator=(BOOST_RV_REF(flat_tree) x) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_move_assignable::value ) + { m_data = boost::move(x.m_data); return *this; } public: // accessors: @@ -331,6 +336,8 @@ class flat_tree { return this->m_data.m_vect.max_size(); } void swap(flat_tree& other) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_swappable::value ) { this->m_data.swap(other.m_data); } public: @@ -428,7 +435,7 @@ class flat_tree #endif ) { - const size_type len = static_cast(std::distance(first, last)); + const size_type len = static_cast(boost::container::iterator_distance(first, last)); this->reserve(this->size()+len); this->priv_insert_equal_loop(first, last); } @@ -455,7 +462,7 @@ class flat_tree #endif ) { - const size_type len = static_cast(std::distance(first, last)); + const size_type len = static_cast(boost::container::iterator_distance(first, last)); this->reserve(this->size()+len); this->priv_insert_equal_loop_ordered(first, last); } @@ -463,20 +470,22 @@ class flat_tree template 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::value && - !container_detail::is_forward_iterator::value + , typename container_detail::disable_if_or + < void + , container_detail::is_input_iterator + , container_detail::is_forward_iterator >::type * = 0 #endif ) - { this->priv_insert_ordered_range(false, first, last); } + { this->m_data.m_vect.merge(first, last); } template 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::value || - container_detail::is_forward_iterator::value + , typename container_detail::enable_if_or + < void + , container_detail::is_input_iterator + , container_detail::is_forward_iterator >::type * = 0 #endif ) @@ -497,14 +506,14 @@ class flat_tree >::type * = 0 #endif ) - { this->priv_insert_ordered_range(true, first, last); } + { this->m_data.m_vect.merge_unique(first, last, value_compare()); } - #ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template - std::pair emplace_unique(Args&&... args) + std::pair emplace_unique(BOOST_FWD_REF(Args)... args) { - aligned_storage::value> v; + typename aligned_storage::value>::type v; value_type &val = *static_cast(static_cast(&v)); stored_allocator_type &a = this->get_stored_allocator(); stored_allocator_traits::construct(a, &val, ::boost::forward(args)... ); @@ -513,9 +522,9 @@ class flat_tree } template - iterator emplace_hint_unique(const_iterator hint, Args&&... args) + iterator emplace_hint_unique(const_iterator hint, BOOST_FWD_REF(Args)... args) { - aligned_storage::value> v; + typename aligned_storage::value>::type v; value_type &val = *static_cast(static_cast(&v)); stored_allocator_type &a = this->get_stored_allocator(); stored_allocator_traits::construct(a, &val, ::boost::forward(args)... ); @@ -524,9 +533,9 @@ class flat_tree } template - iterator emplace_equal(Args&&... args) + iterator emplace_equal(BOOST_FWD_REF(Args)... args) { - aligned_storage::value> v; + typename aligned_storage::value>::type v; value_type &val = *static_cast(static_cast(&v)); stored_allocator_type &a = this->get_stored_allocator(); stored_allocator_traits::construct(a, &val, ::boost::forward(args)... ); @@ -535,9 +544,9 @@ class flat_tree } template - iterator emplace_hint_equal(const_iterator hint, Args&&... args) + iterator emplace_hint_equal(const_iterator hint, BOOST_FWD_REF(Args)... args) { - aligned_storage::value> v; + typename aligned_storage::value>::type v; value_type &val = *static_cast(static_cast(&v)); stored_allocator_type &a = this->get_stored_allocator(); stored_allocator_traits::construct(a, &val, ::boost::forward(args)... ); @@ -545,64 +554,57 @@ class flat_tree return this->insert_equal(hint, ::boost::move(val)); } - #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - #define BOOST_PP_LOCAL_MACRO(n) \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - std::pair \ - emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - aligned_storage::value> v; \ - value_type &val = *static_cast(static_cast(&v)); \ - stored_allocator_type &a = this->get_stored_allocator(); \ - stored_allocator_traits::construct(a, &val \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - value_destructor d(a, val); \ - return this->insert_unique(::boost::move(val)); \ - } \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace_hint_unique(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - aligned_storage::value> v; \ - value_type &val = *static_cast(static_cast(&v)); \ - stored_allocator_type &a = this->get_stored_allocator(); \ - stored_allocator_traits::construct(a, &val \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - value_destructor d(a, val); \ - return this->insert_unique(hint, ::boost::move(val)); \ - } \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - aligned_storage::value> v; \ - value_type &val = *static_cast(static_cast(&v)); \ - stored_allocator_type &a = this->get_stored_allocator(); \ - stored_allocator_traits::construct(a, &val \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - value_destructor d(a, val); \ - return this->insert_equal(::boost::move(val)); \ - } \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace_hint_equal(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - aligned_storage::value> v; \ - value_type &val = *static_cast(static_cast(&v)); \ - stored_allocator_type &a = this->get_stored_allocator(); \ - stored_allocator_traits::construct(a, &val \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - value_destructor d(a, val); \ - return this->insert_equal(hint, ::boost::move(val)); \ - } \ - //! - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() + #define BOOST_CONTAINER_FLAT_TREE_EMPLACE_CODE(N) \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + std::pair emplace_unique(BOOST_MOVE_UREF##N)\ + {\ + typename aligned_storage::value>::type v;\ + value_type &val = *static_cast(static_cast(&v));\ + stored_allocator_type &a = this->get_stored_allocator();\ + stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_destructor d(a, val);\ + return this->insert_unique(::boost::move(val));\ + }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_hint_unique(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + typename aligned_storage::value>::type v;\ + value_type &val = *static_cast(static_cast(&v));\ + stored_allocator_type &a = this->get_stored_allocator();\ + stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_destructor d(a, val);\ + return this->insert_unique(hint, ::boost::move(val));\ + }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_equal(BOOST_MOVE_UREF##N)\ + {\ + typename aligned_storage::value>::type v;\ + value_type &val = *static_cast(static_cast(&v));\ + stored_allocator_type &a = this->get_stored_allocator();\ + stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_destructor d(a, val);\ + return this->insert_equal(::boost::move(val));\ + }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_hint_equal(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + typename aligned_storage ::value>::type v;\ + value_type &val = *static_cast(static_cast(&v));\ + stored_allocator_type &a = this->get_stored_allocator();\ + stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + value_destructor d(a, val);\ + return this->insert_equal(hint, ::boost::move(val));\ + }\ + // + BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_TREE_EMPLACE_CODE) + #undef BOOST_CONTAINER_FLAT_TREE_EMPLACE_CODE - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) iterator erase(const_iterator position) { return this->m_data.m_vect.erase(position); } @@ -632,6 +634,18 @@ class flat_tree void shrink_to_fit() { this->m_data.m_vect.shrink_to_fit(); } + iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW + { return this->m_data.m_vect.nth(n); } + + const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW + { return this->m_data.m_vect.nth(n); } + + size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW + { return this->m_data.m_vect.index_of(p); } + + size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW + { return this->m_data.m_vect.index_of(p); } + // set operations: iterator find(const key_type& k) { @@ -694,13 +708,12 @@ class flat_tree friend bool operator==(const flat_tree& x, const flat_tree& y) { - return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); + return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); } friend bool operator<(const flat_tree& x, const flat_tree& y) { - return std::lexicographical_compare(x.begin(), x.end(), - y.begin(), y.end()); + return ::boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } friend bool operator!=(const flat_tree& x, const flat_tree& y) @@ -844,8 +857,8 @@ class flat_tree } template - RanIt priv_upper_bound(RanIt first, const RanIt last, - const key_type & key) const + RanIt priv_upper_bound + (RanIt first, const RanIt last,const key_type & key) const { const Compare &key_cmp = this->m_data.get_comp(); KeyOfValue key_extract; @@ -893,9 +906,9 @@ class flat_tree //Middle is equal to key last = first; last += len; + RanIt const first_ret = this->priv_lower_bound(first, middle, key); return std::pair - ( this->priv_lower_bound(first, middle, key) - , this->priv_upper_bound(++middle, last, key)); + ( first_ret, this->priv_upper_bound(++middle, last, key)); } } return std::pair(first, first); @@ -928,92 +941,28 @@ class flat_tree for ( ; first != last; ++first){ //If ordered, then try hint version //to achieve constant-time complexity per insertion + //in some cases pos = this->insert_equal(pos, *first); ++pos; } } - - template - void priv_insert_ordered_range(const bool unique_values, BidirIt first, BidirIt last) - { - size_type len = static_cast(std::distance(first, last)); - //Prereserve all memory so that iterators are not invalidated - this->reserve(this->size()+len); - //Auxiliary data for insertion positions. - const size_type BurstSize = len; - const ::boost::movelib::unique_ptr positions = - ::boost::movelib::make_unique_definit(BurstSize); - - const const_iterator b(this->cbegin()); - const const_iterator ce(this->cend()); - const_iterator pos(b); - const value_compare &val_cmp = this->m_data; - //Loop in burst sizes - bool back_insert = false; - while(len && !back_insert){ - const size_type burst = len < BurstSize ? len : BurstSize; - size_type unique_burst = 0u; - size_type checked = 0; - for(; checked != burst; ++checked){ - //Get the insertion position for each key, use std::iterator_traits::value_type - //because it can be different from container::value_type - //(e.g. conversion between std::pair -> boost::container::pair - const typename std::iterator_traits::value_type & val = *first; - pos = const_cast(*this).priv_lower_bound(pos, ce, KeyOfValue()(val)); - //Check if already present - if (pos != ce){ - ++first; - --len; - positions[checked] = (unique_values && !val_cmp(val, *pos)) ? - size_type(-1) : (++unique_burst, static_cast(pos - b)); - } - else{ //this element and the remaining should be back inserted - back_insert = true; - break; - } - } - if(unique_burst){ - //Insert all in a single step in the precalculated positions - this->m_data.m_vect.insert_ordered_at(unique_burst, positions.get() + checked, first); - //Next search position updated, iterator still valid because we've preserved the vector - pos += unique_burst; - } - } - //The remaining range should be back inserted - if(unique_values){ - while(len--){ - BidirIt next(first); - ++next; - if(next == last || val_cmp(*first, *next)){ - const bool room = this->m_data.m_vect.stable_emplace_back(*first); - (void)room; - BOOST_ASSERT(room); - } - first = next; - } - BOOST_ASSERT(first == last); - } - else{ - BOOST_ASSERT(size_type(std::distance(first, last)) == len); - if(len) - this->m_data.m_vect.insert(this->m_data.m_vect.cend(), len, first, last); - } - } }; } //namespace container_detail { } //namespace container { -/* + //!has_trivial_destructor_after_move<> == true_type //!specialization for optimizations -template -struct has_trivial_destructor_after_move > +template +struct has_trivial_destructor_after_move > { - static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value; + typedef typename ::boost::container::allocator_traits::pointer pointer; + static const bool value = ::boost::has_trivial_destructor_after_move::value && + ::boost::has_trivial_destructor_after_move::value; }; -*/ + } //namespace boost { #include diff --git a/boost/container/detail/function_detector.hpp b/boost/container/detail/function_detector.hpp deleted file mode 100644 index 242eb41..0000000 --- a/boost/container/detail/function_detector.hpp +++ /dev/null @@ -1,92 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2009-2013. -// -// Distributed under the 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. -// -///////////////////////////////////////////////////////////////////////////// -// This code was modified from the code posted by Alexandre Courpron in his -// article "Interface Detection" in The Code Project: -// http://www.codeproject.com/KB/architecture/Detector.aspx -/////////////////////////////////////////////////////////////////////////////// -// Copyright 2007 Alexandre Courpron -// -// Permission to use, copy, modify, redistribute and sell this software, -// provided that this copyright notice appears on all copies of the software. -/////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_CONTAINER_DETAIL_FUNCTION_DETECTOR_HPP -#define BOOST_CONTAINER_DETAIL_FUNCTION_DETECTOR_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include - -namespace boost { -namespace container { -namespace function_detector { - - typedef char NotFoundType; - struct StaticFunctionType { NotFoundType x [2]; }; - struct NonStaticFunctionType { NotFoundType x [3]; }; - - enum - { NotFound = 0, - StaticFunction = sizeof( StaticFunctionType ) - sizeof( NotFoundType ), - NonStaticFunction = sizeof( NonStaticFunctionType ) - sizeof( NotFoundType ) - }; - -} //namespace boost { -} //namespace container { -} //namespace function_detector { - -#define BOOST_CONTAINER_CREATE_FUNCTION_DETECTOR(Identifier, InstantiationKey) \ - namespace boost { \ - namespace container { \ - namespace function_detector { \ - template < class T, \ - class NonStaticType, \ - class NonStaticConstType, \ - class StaticType > \ - class DetectMember_##InstantiationKey_##Identifier { \ - template < NonStaticType > \ - struct TestNonStaticNonConst ; \ - \ - template < NonStaticConstType > \ - struct TestNonStaticConst ; \ - \ - template < StaticType > \ - struct TestStatic ; \ - \ - template \ - static NonStaticFunctionType Test( TestNonStaticNonConst<&U::Identifier>*, int ); \ - \ - template \ - static NonStaticFunctionType Test( TestNonStaticConst<&U::Identifier>*, int ); \ - \ - template \ - static StaticFunctionType Test( TestStatic<&U::Identifier>*, int ); \ - \ - template \ - static NotFoundType Test( ... ); \ - public : \ - static const int check = NotFound + (sizeof(Test(0, 0)) - sizeof(NotFoundType));\ - };\ -}}} //namespace boost::container::function_detector { - -#define BOOST_CONTAINER_DETECT_FUNCTION(Class, InstantiationKey, ReturnType, Identifier, Params) \ - ::boost::container::function_detector::DetectMember_##InstantiationKey_##Identifier< Class,\ - ReturnType (Class::*)Params,\ - ReturnType (Class::*)Params const,\ - ReturnType (*)Params \ - >::check - -#include - -#endif //@ifndef BOOST_CONTAINER_DETAIL_FUNCTION_DETECTOR_HPP diff --git a/boost/container/detail/hash_table.hpp b/boost/container/detail/hash_table.hpp deleted file mode 100644 index da7bb53..0000000 --- a/boost/container/detail/hash_table.hpp +++ /dev/null @@ -1,383 +0,0 @@ -/* -template , class Pred = equal_to, - class Alloc = allocator > -class hash_set -{ -public: - // types - typedef Value key_type; - typedef key_type value_type; - typedef Hash hasher; - typedef Pred key_equal; - typedef Alloc allocator_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename allocator_traits::pointer pointer; - typedef typename allocator_traits::const_pointer const_pointer; - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::difference_type difference_type; - - typedef /unspecified/ iterator; - typedef /unspecified/ const_iterator; - typedef /unspecified/ local_iterator; - typedef /unspecified/ const_local_iterator; - - hash_set() - noexcept( - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value); - explicit hash_set(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - template - hash_set(InputIterator f, InputIterator l, - size_type n = 0, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - explicit hash_set(const allocator_type&); - hash_set(const hash_set&); - hash_set(const hash_set&, const Allocator&); - hash_set(hash_set&&) - noexcept( - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value); - hash_set(hash_set&&, const Allocator&); - hash_set(initializer_list, size_type n = 0, - const hasher& hf = hasher(), const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - ~hash_set(); - hash_set& operator=(const hash_set&); - hash_set& operator=(hash_set&&) - noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); - hash_set& operator=(initializer_list); - - allocator_type get_allocator() const noexcept; - - bool empty() const noexcept; - size_type size() const noexcept; - size_type max_size() const noexcept; - - iterator begin() noexcept; - iterator end() noexcept; - const_iterator begin() const noexcept; - const_iterator end() const noexcept; - const_iterator cbegin() const noexcept; - const_iterator cend() const noexcept; - - template - pair emplace(Args&&... args); - template - iterator emplace_hint(const_iterator position, Args&&... args); - pair insert(const value_type& obj); - pair insert(value_type&& obj); - iterator insert(const_iterator hint, const value_type& obj); - iterator insert(const_iterator hint, value_type&& obj); - template - void insert(InputIterator first, InputIterator last); - void insert(initializer_list); - - iterator erase(const_iterator position); - size_type erase(const key_type& k); - iterator erase(const_iterator first, const_iterator last); - void clear() noexcept; - - void swap(hash_set&) - noexcept( - (!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value) && - __is_nothrow_swappable::value && - __is_nothrow_swappable::value); - - hasher hash_function() const; - key_equal key_eq() const; - - iterator find(const key_type& k); - const_iterator find(const key_type& k) const; - size_type count(const key_type& k) const; - pair equal_range(const key_type& k); - pair equal_range(const key_type& k) const; - - size_type bucket_count() const noexcept; - size_type max_bucket_count() const noexcept; - - size_type bucket_size(size_type n) const; - size_type bucket(const key_type& k) const; - - local_iterator begin(size_type n); - local_iterator end(size_type n); - const_local_iterator begin(size_type n) const; - const_local_iterator end(size_type n) const; - const_local_iterator cbegin(size_type n) const; - const_local_iterator cend(size_type n) const; - - float load_factor() const noexcept; - float max_load_factor() const noexcept; - void max_load_factor(float z); - void rehash(size_type n); - void reserve(size_type n); -}; - -template , class Pred = equal_to, - class Alloc = allocator > > -class hash_map -{ -public: - // types - typedef Key key_type; - typedef T mapped_type; - typedef Hash hasher; - typedef Pred key_equal; - typedef Alloc allocator_type; - typedef pair value_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename allocator_traits::pointer pointer; - typedef typename allocator_traits::const_pointer const_pointer; - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::difference_type difference_type; - - typedef /unspecified/ iterator; - typedef /unspecified/ const_iterator; - typedef /unspecified/ local_iterator; - typedef /unspecified/ const_local_iterator; - - hash_map() - noexcept( - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value); - explicit hash_map(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - template - hash_map(InputIterator f, InputIterator l, - size_type n = 0, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - explicit hash_map(const allocator_type&); - hash_map(const hash_map&); - hash_map(const hash_map&, const Allocator&); - hash_map(hash_map&&) - noexcept( - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value); - hash_map(hash_map&&, const Allocator&); - hash_map(initializer_list, size_type n = 0, - const hasher& hf = hasher(), const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - ~hash_map(); - hash_map& operator=(const hash_map&); - hash_map& operator=(hash_map&&) - noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); - hash_map& operator=(initializer_list); - - allocator_type get_allocator() const noexcept; - - bool empty() const noexcept; - size_type size() const noexcept; - size_type max_size() const noexcept; - - iterator begin() noexcept; - iterator end() noexcept; - const_iterator begin() const noexcept; - const_iterator end() const noexcept; - const_iterator cbegin() const noexcept; - const_iterator cend() const noexcept; - - template - pair emplace(Args&&... args); - template - iterator emplace_hint(const_iterator position, Args&&... args); - pair insert(const value_type& obj); - template - pair insert(P&& obj); - iterator insert(const_iterator hint, const value_type& obj); - template - iterator insert(const_iterator hint, P&& obj); - template - void insert(InputIterator first, InputIterator last); - void insert(initializer_list); - - iterator erase(const_iterator position); - size_type erase(const key_type& k); - iterator erase(const_iterator first, const_iterator last); - void clear() noexcept; - - void swap(hash_map&) - noexcept( - (!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value) && - __is_nothrow_swappable::value && - __is_nothrow_swappable::value); - - hasher hash_function() const; - key_equal key_eq() const; - - iterator find(const key_type& k); - const_iterator find(const key_type& k) const; - size_type count(const key_type& k) const; - pair equal_range(const key_type& k); - pair equal_range(const key_type& k) const; - - mapped_type& operator[](const key_type& k); - mapped_type& operator[](key_type&& k); - - mapped_type& at(const key_type& k); - const mapped_type& at(const key_type& k) const; - - size_type bucket_count() const noexcept; - size_type max_bucket_count() const noexcept; - - size_type bucket_size(size_type n) const; - size_type bucket(const key_type& k) const; - - local_iterator begin(size_type n); - local_iterator end(size_type n); - const_local_iterator begin(size_type n) const; - const_local_iterator end(size_type n) const; - const_local_iterator cbegin(size_type n) const; - const_local_iterator cend(size_type n) const; - - float load_factor() const noexcept; - float max_load_factor() const noexcept; - void max_load_factor(float z); - void rehash(size_type n); - void reserve(size_type n); -}; - -*/ - -template , class Pred = equal_to, - class Alloc = allocator > -class hash_table -{ -public: - // types - typedef Value key_type; - typedef key_type value_type; - typedef Hash hasher; - typedef Pred key_equal; - typedef Alloc allocator_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename allocator_traits::pointer pointer; - typedef typename allocator_traits::const_pointer const_pointer; - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::difference_type difference_type; - - typedef /unspecified/ iterator; - typedef /unspecified/ const_iterator; - typedef /unspecified/ local_iterator; - typedef /unspecified/ const_local_iterator; - - hash_set() - noexcept( - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value); - explicit hash_set(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - template - hash_set(InputIterator f, InputIterator l, - size_type n = 0, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - explicit hash_set(const allocator_type&); - hash_set(const hash_set&); - hash_set(const hash_set&, const Allocator&); - hash_set(hash_set&&) - noexcept( - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value); - hash_set(hash_set&&, const Allocator&); - hash_set(initializer_list, size_type n = 0, - const hasher& hf = hasher(), const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - ~hash_set(); - hash_set& operator=(const hash_set&); - hash_set& operator=(hash_set&&) - noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); - hash_set& operator=(initializer_list); - - allocator_type get_allocator() const noexcept; - - bool empty() const noexcept; - size_type size() const noexcept; - size_type max_size() const noexcept; - - iterator begin() noexcept; - iterator end() noexcept; - const_iterator begin() const noexcept; - const_iterator end() const noexcept; - const_iterator cbegin() const noexcept; - const_iterator cend() const noexcept; - - template - pair emplace(Args&&... args); - template - iterator emplace_hint(const_iterator position, Args&&... args); - pair insert(const value_type& obj); - pair insert(value_type&& obj); - iterator insert(const_iterator hint, const value_type& obj); - iterator insert(const_iterator hint, value_type&& obj); - template - void insert(InputIterator first, InputIterator last); - void insert(initializer_list); - - iterator erase(const_iterator position); - size_type erase(const key_type& k); - iterator erase(const_iterator first, const_iterator last); - void clear() noexcept; - - void swap(hash_set&) - noexcept( - (!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value) && - __is_nothrow_swappable::value && - __is_nothrow_swappable::value); - - hasher hash_function() const; - key_equal key_eq() const; - - iterator find(const key_type& k); - const_iterator find(const key_type& k) const; - size_type count(const key_type& k) const; - pair equal_range(const key_type& k); - pair equal_range(const key_type& k) const; - - size_type bucket_count() const noexcept; - size_type max_bucket_count() const noexcept; - - size_type bucket_size(size_type n) const; - size_type bucket(const key_type& k) const; - - local_iterator begin(size_type n); - local_iterator end(size_type n); - const_local_iterator begin(size_type n) const; - const_local_iterator end(size_type n) const; - const_local_iterator cbegin(size_type n) const; - const_local_iterator cend(size_type n) const; - - float load_factor() const noexcept; - float max_load_factor() const noexcept; - void max_load_factor(float z); - void rehash(size_type n); - void reserve(size_type n); -}; diff --git a/boost/container/detail/iterator.hpp b/boost/container/detail/iterator.hpp new file mode 100644 index 0000000..8538acc --- /dev/null +++ b/boost/container/detail/iterator.hpp @@ -0,0 +1,40 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014. +// +// Distributed under the 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_ITERATOR_HPP +#define BOOST_CONTAINER_DETAIL_ITERATOR_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include + +namespace boost { +namespace container { + +using ::boost::intrusive::iterator_traits; +using ::boost::intrusive::iterator_distance; +using ::boost::intrusive::iterator_advance; +using ::boost::intrusive::iterator; +using ::boost::intrusive::iterator_enable_if_tag; +using ::boost::intrusive::iterator_disable_if_tag; +using ::boost::intrusive::iterator_arrow_result; + +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP diff --git a/boost/container/detail/iterator_to_raw_pointer.hpp b/boost/container/detail/iterator_to_raw_pointer.hpp new file mode 100644 index 0000000..83736d8 --- /dev/null +++ b/boost/container/detail/iterator_to_raw_pointer.hpp @@ -0,0 +1,58 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the 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_ITERATOR_TO_RAW_POINTER_HPP +#define BOOST_CONTAINER_DETAIL_ITERATOR_TO_RAW_POINTER_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include +#include +#include + +namespace boost { +namespace container { +namespace container_detail { + +template +inline T* iterator_to_pointer(T* i) +{ return i; } + +template +inline typename boost::container::iterator_traits::pointer + iterator_to_pointer(const Iterator &i) +{ return i.operator->(); } + +template +struct iterator_to_element_ptr +{ + typedef typename boost::container::iterator_traits::pointer pointer; + typedef typename boost::intrusive::pointer_traits::element_type element_type; + typedef element_type* type; +}; + +template +inline typename iterator_to_element_ptr::type + iterator_to_raw_pointer(const Iterator &i) +{ + return ::boost::intrusive::detail::to_raw_pointer + ( ::boost::container::container_detail::iterator_to_pointer(i) ); +} + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_ITERATOR_TO_RAW_POINTER_HPP diff --git a/boost/container/detail/iterators.hpp b/boost/container/detail/iterators.hpp index 0dabd3c..e8cfcf9 100644 --- a/boost/container/detail/iterators.hpp +++ b/boost/container/detail/iterators.hpp @@ -14,7 +14,11 @@ #ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP #define BOOST_CONTAINER_DETAIL_ITERATORS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -26,20 +30,19 @@ #include #include -#ifdef BOOST_CONTAINER_PERFECT_FORWARDING -#include +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include #else -#include +#include #endif - -#include +#include namespace boost { namespace container { template class constant_iterator - : public std::iterator + : public ::boost::container::iterator { typedef constant_iterator this_type; @@ -150,7 +153,7 @@ class constant_iterator template class value_init_construct_iterator - : public std::iterator + : public ::boost::container::iterator { typedef value_init_construct_iterator this_type; @@ -261,7 +264,7 @@ class value_init_construct_iterator template class default_init_construct_iterator - : public std::iterator + : public ::boost::container::iterator { typedef default_init_construct_iterator this_type; @@ -373,7 +376,7 @@ class default_init_construct_iterator template class repeat_iterator - : public std::iterator + : public ::boost::container::iterator { typedef repeat_iterator this_type; @@ -483,7 +486,7 @@ class repeat_iterator template class emplace_iterator - : public std::iterator + : public ::boost::container::iterator { typedef emplace_iterator this_type; @@ -564,8 +567,8 @@ class emplace_iterator //const T& operator[](difference_type) const; //const T* operator->() const; - template - void construct_in_place(A &a, T* ptr) + template + void construct_in_place(Allocator &a, T* ptr) { (*m_pe)(a, ptr); } private: @@ -597,54 +600,49 @@ class emplace_iterator { return difference_type(m_num - other.m_num); } }; -#ifdef BOOST_CONTAINER_PERFECT_FORWARDING +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template struct emplace_functor { typedef typename container_detail::build_number_seq::type index_tuple_t; - emplace_functor(Args&&... args) + emplace_functor(BOOST_FWD_REF(Args)... args) : args_(args...) {} - template - void operator()(A &a, T *ptr) + template + void operator()(Allocator &a, T *ptr) { emplace_functor::inplace_impl(a, ptr, index_tuple_t()); } - template - void inplace_impl(A &a, T* ptr, const container_detail::index_tuple&) + template + void inplace_impl(Allocator &a, T* ptr, const container_detail::index_tuple&) { - allocator_traits::construct + allocator_traits::construct (a, ptr, ::boost::forward(container_detail::get(args_))...); } container_detail::tuple args_; }; -#else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING +#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#define BOOST_PP_LOCAL_MACRO(n) \ - BOOST_PP_EXPR_IF(n, template <) \ - BOOST_PP_ENUM_PARAMS(n, class P) \ - BOOST_PP_EXPR_IF(n, >) \ - struct BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \ - { \ - BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \ - ( BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ - BOOST_PP_EXPR_IF(n, :) BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_INIT, _){} \ - \ - template \ - void operator()(A &a, T *ptr) \ - { \ - allocator_traits::construct \ - (a, ptr BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_MEMBER_FORWARD, _) ); \ - } \ - BOOST_PP_REPEAT(n, BOOST_CONTAINER_PP_PARAM_DEFINE, _) \ - }; \ - //! -#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) -#include BOOST_PP_LOCAL_ITERATE() +#define BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE(N) \ +BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ +struct emplace_functor##N\ +{\ + explicit emplace_functor##N( BOOST_MOVE_UREF##N )\ + BOOST_MOVE_COLON##N BOOST_MOVE_FWD_INIT##N{}\ + \ + template\ + void operator()(Allocator &a, T *ptr)\ + { allocator_traits::construct(a, ptr BOOST_MOVE_I##N BOOST_MOVE_MFWD##N); }\ + \ + BOOST_MOVE_MREF##N\ +};\ +// +BOOST_MOVE_ITERATE_0TO9(BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE) +#undef BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE #endif @@ -653,11 +651,13 @@ namespace container_detail { template struct has_iterator_category { + struct two { char _[2]; }; + template static char test(int, typename X::iterator_category*); template - static int test(int, ...); + static two test(int, ...); static const bool value = (1 == sizeof(test(0, 0))); }; @@ -675,6 +675,12 @@ struct is_input_iterator static const bool value = false; }; +template +struct is_not_input_iterator +{ + static const bool value = !is_input_iterator::value; +}; + template::value > struct is_forward_iterator { @@ -709,8 +715,8 @@ struct iiterator_types { typedef typename IIterator::value_type it_value_type; typedef typename iiterator_node_value_type::type value_type; - typedef typename std::iterator_traits::pointer it_pointer; - typedef typename std::iterator_traits::difference_type difference_type; + typedef typename boost::container::iterator_traits::pointer it_pointer; + typedef typename boost::container::iterator_traits::difference_type difference_type; typedef typename ::boost::intrusive::pointer_traits:: template rebind_pointer::type pointer; typedef typename ::boost::intrusive::pointer_traits:: @@ -723,9 +729,9 @@ struct iiterator_types }; template -struct std_iterator +struct iterator_types { - typedef typename std::iterator + typedef typename ::boost::container::iterator < typename iiterator_types::iterator_category , typename iiterator_types::value_type , typename iiterator_types::difference_type @@ -734,9 +740,9 @@ struct std_iterator }; template -struct std_iterator +struct iterator_types { - typedef typename std::iterator + typedef typename ::boost::container::iterator < typename iiterator_types::iterator_category , typename iiterator_types::value_type , typename iiterator_types::difference_type @@ -745,9 +751,9 @@ struct std_iterator }; template -class iterator +class iterator_from_iiterator { - typedef typename std_iterator::type types_t; + typedef typename iterator_types::type types_t; public: typedef typename types_t::pointer pointer; @@ -756,63 +762,64 @@ class iterator typedef typename types_t::iterator_category iterator_category; typedef typename types_t::value_type value_type; - iterator() + iterator_from_iiterator() {} - explicit iterator(IIterator iit) BOOST_CONTAINER_NOEXCEPT + explicit iterator_from_iiterator(IIterator iit) BOOST_NOEXCEPT_OR_NOTHROW : m_iit(iit) {} - iterator(iterator const& other) BOOST_CONTAINER_NOEXCEPT + iterator_from_iiterator(iterator_from_iiterator const& other) BOOST_NOEXCEPT_OR_NOTHROW : m_iit(other.get()) {} - iterator& operator++() BOOST_CONTAINER_NOEXCEPT + iterator_from_iiterator& operator++() BOOST_NOEXCEPT_OR_NOTHROW { ++this->m_iit; return *this; } - iterator operator++(int) BOOST_CONTAINER_NOEXCEPT + iterator_from_iiterator operator++(int) BOOST_NOEXCEPT_OR_NOTHROW { - iterator result (*this); + iterator_from_iiterator result (*this); ++this->m_iit; return result; } - iterator& operator--() BOOST_CONTAINER_NOEXCEPT + iterator_from_iiterator& operator--() BOOST_NOEXCEPT_OR_NOTHROW { - //If the iterator is not a bidirectional iterator, operator-- should not exist - BOOST_STATIC_ASSERT((is_bidirectional_iterator::value)); + //If the iterator_from_iiterator is not a bidirectional iterator, operator-- should not exist + BOOST_STATIC_ASSERT((is_bidirectional_iterator::value)); --this->m_iit; return *this; } - iterator operator--(int) BOOST_CONTAINER_NOEXCEPT + iterator_from_iiterator operator--(int) BOOST_NOEXCEPT_OR_NOTHROW { - iterator result (*this); + iterator_from_iiterator result (*this); --this->m_iit; return result; } - friend bool operator== (const iterator& l, const iterator& r) BOOST_CONTAINER_NOEXCEPT + friend bool operator== (const iterator_from_iiterator& l, const iterator_from_iiterator& r) BOOST_NOEXCEPT_OR_NOTHROW { return l.m_iit == r.m_iit; } - friend bool operator!= (const iterator& l, const iterator& r) BOOST_CONTAINER_NOEXCEPT + friend bool operator!= (const iterator_from_iiterator& l, const iterator_from_iiterator& r) BOOST_NOEXCEPT_OR_NOTHROW { return !(l == r); } - reference operator*() const BOOST_CONTAINER_NOEXCEPT - { return (*this->m_iit).get_data(); } + reference operator*() const BOOST_NOEXCEPT_OR_NOTHROW + { return this->m_iit->get_data(); } - pointer operator->() const BOOST_CONTAINER_NOEXCEPT + pointer operator->() const BOOST_NOEXCEPT_OR_NOTHROW { return ::boost::intrusive::pointer_traits::pointer_to(this->operator*()); } - const IIterator &get() const BOOST_CONTAINER_NOEXCEPT + const IIterator &get() const BOOST_NOEXCEPT_OR_NOTHROW { return this->m_iit; } private: IIterator m_iit; }; -using ::boost::intrusive::detail::reverse_iterator; - } //namespace container_detail { + +using ::boost::intrusive::reverse_iterator; + } //namespace container { } //namespace boost { diff --git a/boost/container/detail/math_functions.hpp b/boost/container/detail/math_functions.hpp deleted file mode 100644 index 6853b9c..0000000 --- a/boost/container/detail/math_functions.hpp +++ /dev/null @@ -1,119 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Stephen Cleary 2000. -// (C) Copyright Ion Gaztanaga 2007-2013. -// -// Distributed under the 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. -// -// This file is a slightly modified file from Boost.Pool -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_CONTAINER_DETAIL_MATH_FUNCTIONS_HPP -#define BOOST_CONTAINER_DETAIL_MATH_FUNCTIONS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include - -namespace boost { -namespace container { -namespace container_detail { - -// Greatest common divisor and least common multiple - -// -// gcd is an algorithm that calculates the greatest common divisor of two -// integers, using Euclid's algorithm. -// -// Pre: A > 0 && B > 0 -// Recommended: A > B -template -inline Integer gcd(Integer A, Integer B) -{ - do - { - const Integer tmp(B); - B = A % B; - A = tmp; - } while (B != 0); - - return A; -} - -// -// lcm is an algorithm that calculates the least common multiple of two -// integers. -// -// Pre: A > 0 && B > 0 -// Recommended: A > B -template -inline Integer lcm(const Integer & A, const Integer & B) -{ - Integer ret = A; - ret /= gcd(A, B); - ret *= B; - return ret; -} - -template -inline Integer log2_ceil(const Integer & A) -{ - Integer i = 0; - Integer power_of_2 = 1; - - while(power_of_2 < A){ - power_of_2 <<= 1; - ++i; - } - return i; -} - -template -inline Integer upper_power_of_2(const Integer & A) -{ - Integer power_of_2 = 1; - - while(power_of_2 < A){ - power_of_2 <<= 1; - } - return power_of_2; -} - -//This function uses binary search to discover the -//highest set bit of the integer -inline std::size_t floor_log2 (std::size_t x) -{ - const std::size_t Bits = sizeof(std::size_t)*CHAR_BIT; - const bool Size_t_Bits_Power_2= !(Bits & (Bits-1)); - BOOST_STATIC_ASSERT(((Size_t_Bits_Power_2)== true)); - - 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) - log2 += shift, n = tmp; - } - - return log2; -} - -} // namespace container_detail -} // namespace container -} // namespace boost - -#include - -#endif diff --git a/boost/container/detail/memory_util.hpp b/boost/container/detail/memory_util.hpp deleted file mode 100644 index 7f055cb..0000000 --- a/boost/container/detail/memory_util.hpp +++ /dev/null @@ -1,90 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the 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_ALLOCATOR_MEMORY_UTIL_HPP -#define BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include - - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME allocate -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (2, 2, )) -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME destroy -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, )) -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME max_size -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, )) -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME select_on_container_copy_construction -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, )) -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME construct -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#ifdef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_SINGLE_ITERATION -# define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, )) -#else -# define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS+1, )) -#endif -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME swap -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, )) -#include BOOST_PP_ITERATE() - -namespace boost { -namespace container { -namespace container_detail { - -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_pointer) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(void_pointer) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_void_pointer) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(value_compare) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(wrapped_value_compare) - -} //namespace container_detail { -} //namespace container { -} //namespace boost { - -#include - -#endif // ! defined(BOOST_CONTAINER_ALLOCATOR_MEMORY_UTIL_HPP) diff --git a/boost/container/detail/min_max.hpp b/boost/container/detail/min_max.hpp new file mode 100644 index 0000000..7486db7 --- /dev/null +++ b/boost/container/detail/min_max.hpp @@ -0,0 +1,37 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_MIN_MAX_HPP +#define BOOST_CONTAINER_DETAIL_MIN_MAX_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +namespace boost { +namespace container { +namespace container_detail { + +template +const T &max_value(const T &a, const T &b) +{ return a > b ? a : b; } + +template +const T &min_value(const T &a, const T &b) +{ return a < b ? a : b; } + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_MIN_MAX_HPP diff --git a/boost/container/detail/mpl.hpp b/boost/container/detail/mpl.hpp index ceac52a..e1684ea 100644 --- a/boost/container/detail/mpl.hpp +++ b/boost/container/detail/mpl.hpp @@ -13,12 +13,18 @@ #ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP #define BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include +#include +#include #include @@ -26,103 +32,35 @@ namespace boost { namespace container { namespace container_detail { -template -struct integral_constant -{ - static const T value = val; - typedef integral_constant type; -}; - -template< bool C_ > -struct bool_ : integral_constant -{ - static const bool value = C_; - operator bool() const { return bool_::value; } -}; - -typedef bool_ true_; -typedef bool_ false_; - -typedef true_ true_type; -typedef false_ false_type; - -typedef char yes_type; -struct no_type -{ - char padding[8]; -}; - -template -struct enable_if_c { - typedef T type; -}; - -template -struct enable_if_c {}; - -template -struct enable_if : public enable_if_c {}; - -template -struct disable_if : public enable_if_c {}; - -template -struct disable_if_c : public enable_if_c {}; - -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - -template -struct is_convertible -{ - static const bool value = __is_convertible_to(T, U); -}; - -#else - -template -class is_convertible -{ - typedef char true_t; - class false_t { char dummy[2]; }; - //use any_conversion as first parameter since in MSVC - //overaligned types can't go through ellipsis - static false_t dispatch(...); - static true_t dispatch(U); - static T &trigger(); - public: - static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t); -}; - -#endif - -template< - bool C - , typename T1 - , typename T2 - > -struct if_c -{ - typedef T1 type; -}; - -template< - typename T1 - , typename T2 - > -struct if_c -{ - typedef T2 type; -}; - -template< - typename T1 - , typename T2 - , typename T3 - > -struct if_ -{ - typedef typename if_c<0 != T1::value, T2, T3>::type type; -}; +using boost::move_detail::integral_constant; +using boost::move_detail::true_type; +using boost::move_detail::false_type; +using boost::move_detail::enable_if_c; +using boost::move_detail::enable_if; +using boost::move_detail::enable_if_convertible; +using boost::move_detail::disable_if_c; +using boost::move_detail::disable_if; +using boost::move_detail::disable_if_convertible; +using boost::move_detail::is_convertible; +using boost::move_detail::if_c; +using boost::move_detail::if_; +using boost::move_detail::identity; +using boost::move_detail::bool_; +using boost::move_detail::true_; +using boost::move_detail::false_; +using boost::move_detail::yes_type; +using boost::move_detail::no_type; +using boost::move_detail::bool_; +using boost::move_detail::true_; +using boost::move_detail::false_; +using boost::move_detail::unvoid_ref; +using boost::move_detail::and_; +using boost::move_detail::or_; +using boost::move_detail::not_; +using boost::move_detail::enable_if_and; +using boost::move_detail::disable_if_and; +using boost::move_detail::enable_if_or; +using boost::move_detail::disable_if_or; template @@ -139,40 +77,6 @@ struct select1st { return x; } }; -// identity is an extension: it is not part of the standard. -template -struct identity -{ - typedef T argument_type; - typedef T result_type; - - typedef T type; - const T& operator()(const T& x) const - { return x; } -}; - -template -struct ls_zeros -{ - static const std::size_t value = (S & std::size_t(1)) ? 0 : (1u + ls_zeros<(S >> 1u)>::value); -}; - -template<> -struct ls_zeros<0> -{ - static const std::size_t value = 0; -}; - -template<> -struct ls_zeros<1> -{ - static const std::size_t value = 0; -}; - -template struct unvoid { typedef T type; }; -template <> struct unvoid { struct type { }; }; -template <> struct unvoid { struct type { }; }; - } //namespace container_detail { } //namespace container { } //namespace boost { diff --git a/boost/container/detail/multiallocation_chain.hpp b/boost/container/detail/multiallocation_chain.hpp deleted file mode 100644 index 96f6202..0000000 --- a/boost/container/detail/multiallocation_chain.hpp +++ /dev/null @@ -1,292 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_MULTIALLOCATION_CHAIN_HPP -#define BOOST_CONTAINER_DETAIL_MULTIALLOCATION_CHAIN_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace container { -namespace container_detail { - -template -class basic_multiallocation_chain -{ - private: - typedef bi::slist_base_hook - ,bi::link_mode - > node; - - typedef typename boost::intrusive::pointer_traits - ::template rebind_pointer::type char_ptr; - typedef typename boost::intrusive:: - pointer_traits::difference_type difference_type; - - typedef bi::slist< node - , bi::linear - , bi::cache_last - , bi::size_type::type> - > slist_impl_t; - slist_impl_t slist_impl_; - - typedef typename boost::intrusive::pointer_traits - ::template rebind_pointer::type node_ptr; - typedef typename boost::intrusive:: - pointer_traits node_ptr_traits; - - static node & to_node(const VoidPointer &p) - { return *static_cast(static_cast(container_detail::to_raw_pointer(p))); } - - static VoidPointer from_node(node &n) - { return node_ptr_traits::pointer_to(n); } - - static node_ptr to_node_ptr(const 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; - - basic_multiallocation_chain() - : slist_impl_() - {} - - basic_multiallocation_chain(const void_pointer &b, const void_pointer &before_e, size_type n) - : slist_impl_(to_node_ptr(b), to_node_ptr(before_e), n) - {} - - basic_multiallocation_chain(BOOST_RV_REF(basic_multiallocation_chain) other) - : slist_impl_(::boost::move(other.slist_impl_)) - {} - - basic_multiallocation_chain& operator=(BOOST_RV_REF(basic_multiallocation_chain) other) - { - slist_impl_ = ::boost::move(other.slist_impl_); - return *this; - } - - bool empty() const - { return slist_impl_.empty(); } - - size_type size() const - { return slist_impl_.size(); } - - iterator before_begin() - { return slist_impl_.before_begin(); } - - iterator begin() - { return slist_impl_.begin(); } - - iterator end() - { return slist_impl_.end(); } - - iterator last() - { return slist_impl_.last(); } - - void clear() - { slist_impl_.clear(); } - - iterator insert_after(iterator it, void_pointer m) - { return slist_impl_.insert_after(it, to_node(m)); } - - void push_front(const void_pointer &m) - { return slist_impl_.push_front(to_node(m)); } - - void push_back(const void_pointer &m) - { return slist_impl_.push_back(to_node(m)); } - - void_pointer pop_front() - { - node & n = slist_impl_.front(); - void_pointer ret = from_node(n); - slist_impl_.pop_front(); - return ret; - } - - void splice_after(iterator after_this, basic_multiallocation_chain &x, iterator before_b, iterator before_e, size_type n) - { slist_impl_.splice_after(after_this, x.slist_impl_, before_b, before_e, n); } - - void splice_after(iterator after_this, basic_multiallocation_chain &x) - { slist_impl_.splice_after(after_this, x.slist_impl_); } - - void erase_after(iterator before_b, iterator e, size_type n) - { slist_impl_.erase_after(before_b, e, n); } - - void_pointer incorporate_after(iterator after_this, const void_pointer &b, size_type unit_bytes, size_type num_units) - { - typedef typename boost::intrusive::pointer_traits char_pointer_traits; - char_ptr elem = char_pointer_traits::static_cast_from(b); - if(num_units){ - char_ptr prev_elem = elem; - elem += unit_bytes; - for(size_type i = 0; i != num_units-1; ++i, elem += unit_bytes){ - ::new (container_detail::to_raw_pointer(prev_elem)) void_pointer(elem); - prev_elem = elem; - } - slist_impl_.incorporate_after(after_this, to_node_ptr(b), to_node_ptr(prev_elem), num_units); - } - return elem; - } - - void incorporate_after(iterator after_this, void_pointer b, void_pointer before_e, size_type n) - { slist_impl_.incorporate_after(after_this, to_node_ptr(b), to_node_ptr(before_e), n); } - - void swap(basic_multiallocation_chain &x) - { slist_impl_.swap(x.slist_impl_); } - - static iterator iterator_to(const void_pointer &p) - { return slist_impl_t::s_iterator_to(to_node(p)); } - - std::pair extract_data() - { - std::pair ret - (slist_impl_.begin().operator->() - ,slist_impl_.last().operator->()); - slist_impl_.clear(); - return ret; - } -}; - -template -struct cast_functor -{ - typedef typename container_detail::add_reference::type result_type; - template - result_type operator()(U &ptr) const - { return *static_cast(static_cast(&ptr)); } -}; - -template -class transform_multiallocation_chain - : public MultiallocationChain -{ - private: - BOOST_MOVABLE_BUT_NOT_COPYABLE(transform_multiallocation_chain) - //transform_multiallocation_chain(const transform_multiallocation_chain &); - //transform_multiallocation_chain & operator=(const transform_multiallocation_chain &); - - typedef typename MultiallocationChain::void_pointer void_pointer; - typedef typename boost::intrusive::pointer_traits - void_pointer_traits; - typedef typename void_pointer_traits::template - rebind_pointer::type pointer; - typedef typename boost::intrusive::pointer_traits - pointer_traits; - - 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 > iterator; - typedef typename MultiallocationChain::size_type size_type; - - transform_multiallocation_chain() - : MultiallocationChain() - {} - - transform_multiallocation_chain(BOOST_RV_REF(transform_multiallocation_chain) other) - : MultiallocationChain(::boost::move(static_cast(other))) - {} - - transform_multiallocation_chain(BOOST_RV_REF(MultiallocationChain) other) - : MultiallocationChain(::boost::move(static_cast(other))) - {} - - transform_multiallocation_chain& operator=(BOOST_RV_REF(transform_multiallocation_chain) other) - { - return static_cast - (this->MultiallocationChain::operator=(::boost::move(static_cast(other)))); - } -/* - void push_front(const pointer &mem) - { holder_.push_front(mem); } - - void push_back(const pointer &mem) - { return holder_.push_back(mem); } - - void swap(transform_multiallocation_chain &other_chain) - { holder_.swap(other_chain.holder_); } - - void splice_after(iterator after_this, transform_multiallocation_chain &x, iterator before_b, iterator before_e, size_type n) - { holder_.splice_after(after_this.base(), x.holder_, before_b.base(), before_e.base(), n); } - - void incorporate_after(iterator after_this, pointer b, pointer before_e, size_type n) - { holder_.incorporate_after(after_this.base(), b, before_e, n); } -*/ - pointer pop_front() - { return cast(this->MultiallocationChain::pop_front()); } -/* - bool empty() const - { return holder_.empty(); } - - iterator before_begin() - { return iterator(holder_.before_begin()); } -*/ - iterator begin() - { return iterator(this->MultiallocationChain::begin()); } -/* - iterator end() - { return iterator(holder_.end()); } - - iterator last() - { return iterator(holder_.last()); } - - size_type size() const - { return holder_.size(); } - - void clear() - { holder_.clear(); } -*/ - iterator insert_after(iterator it, pointer m) - { return iterator(this->MultiallocationChain::insert_after(it.base(), m)); } - - static iterator iterator_to(const pointer &p) - { return iterator(MultiallocationChain::iterator_to(p)); } - - std::pair extract_data() - { - std::pair data(this->MultiallocationChain::extract_data()); - return std::pair(cast(data.first), cast(data.second)); - } -/* - MultiallocationChain &extract_multiallocation_chain() - { return holder_; }*/ -}; - -}}} - -// namespace container_detail { -// namespace container { -// namespace boost { - -#include - -#endif //BOOST_CONTAINER_DETAIL_MULTIALLOCATION_CHAIN_HPP diff --git a/boost/container/detail/mutex.hpp b/boost/container/detail/mutex.hpp deleted file mode 100644 index c53afa1..0000000 --- a/boost/container/detail/mutex.hpp +++ /dev/null @@ -1,284 +0,0 @@ -// Copyright (C) 2000 Stephen Cleary -// -// Distributed under the 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 for updates, documentation, and revision history. - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013. Distributed under the 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_MUTEX_HPP -#define BOOST_CONTAINER_MUTEX_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -//#define BOOST_CONTAINER_NO_MT -//#define BOOST_CONTAINER_NO_SPINLOCKS - -#include -#include - -// Extremely Light-Weight wrapper classes for OS thread synchronization - -#define BOOST_MUTEX_HELPER_NONE 0 -#define BOOST_MUTEX_HELPER_WIN32 1 -#define BOOST_MUTEX_HELPER_PTHREAD 2 -#define BOOST_MUTEX_HELPER_SPINLOCKS 3 - -#if !defined(BOOST_HAS_THREADS) && !defined(BOOST_NO_MT) -# define BOOST_NO_MT -#endif - -#if defined(BOOST_NO_MT) || defined(BOOST_CONTAINER_NO_MT) - // No multithreading -> make locks into no-ops - #define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_NONE -#else - //Taken from dlmalloc - #if !defined(BOOST_CONTAINER_NO_SPINLOCKS) && \ - ((defined(__GNUC__) && \ - ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \ - defined(__i386__) || defined(__x86_64__))) || \ - (defined(_MSC_VER) && _MSC_VER>=1310)) - #define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_SPINLOCKS - #endif - - #if defined(BOOST_WINDOWS) - #include - #ifndef BOOST_MUTEX_HELPER - #define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_WIN32 - #endif - #elif defined(BOOST_HAS_UNISTD_H) - #include - #if !defined(BOOST_MUTEX_HELPER) && (defined(_POSIX_THREADS) || defined(BOOST_HAS_PTHREADS)) - #define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_PTHREAD - #endif - #endif -#endif - -#ifndef BOOST_MUTEX_HELPER - #error Unable to determine platform mutex type; #define BOOST_NO_MT to assume single-threaded -#endif - -#if BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_NONE - //... -#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_SPINLOCKS - #if defined(_MSC_VER) - #ifndef _M_AMD64 - /* These are already defined on AMD64 builds */ - #ifdef __cplusplus - extern "C" { - #endif /* __cplusplus */ - long __cdecl _InterlockedCompareExchange(long volatile *Dest, long Exchange, long Comp); - long __cdecl _InterlockedExchange(long volatile *Target, long Value); - #ifdef __cplusplus - } - #endif /* __cplusplus */ - #endif /* _M_AMD64 */ - #pragma intrinsic (_InterlockedCompareExchange) - #pragma intrinsic (_InterlockedExchange) - #define interlockedcompareexchange _InterlockedCompareExchange - #define interlockedexchange _InterlockedExchange - #elif defined(WIN32) && defined(__GNUC__) - #define interlockedcompareexchange(a, b, c) __sync_val_compare_and_swap(a, c, b) - #define interlockedexchange __sync_lock_test_and_set - #endif /* Win32 */ - - /* First, define CAS_LOCK and CLEAR_LOCK on ints */ - /* Note CAS_LOCK defined to return 0 on success */ - - #if defined(__GNUC__)&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) - #define BOOST_CONTAINER_CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1) - #define BOOST_CONTAINER_CLEAR_LOCK(sl) __sync_lock_release(sl) - - #elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) - /* Custom spin locks for older gcc on x86 */ - static FORCEINLINE int boost_container_x86_cas_lock(int *sl) { - int ret; - int val = 1; - int cmp = 0; - __asm__ __volatile__ ("lock; cmpxchgl %1, %2" - : "=a" (ret) - : "r" (val), "m" (*(sl)), "0"(cmp) - : "memory", "cc"); - return ret; - } - - static FORCEINLINE void boost_container_x86_clear_lock(int* sl) { - assert(*sl != 0); - int prev = 0; - int ret; - __asm__ __volatile__ ("lock; xchgl %0, %1" - : "=r" (ret) - : "m" (*(sl)), "0"(prev) - : "memory"); - } - - #define BOOST_CONTAINER_CAS_LOCK(sl) boost_container_x86_cas_lock(sl) - #define BOOST_CONTAINER_CLEAR_LOCK(sl) boost_container_x86_clear_lock(sl) - - #else /* Win32 MSC */ - #define BOOST_CONTAINER_CAS_LOCK(sl) interlockedexchange((long volatile*)sl, (long)1) - #define BOOST_CONTAINER_CLEAR_LOCK(sl) interlockedexchange((long volatile*)sl, (long)0) - #endif - - /* How to yield for a spin lock */ - #define SPINS_PER_YIELD 63 - #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) - #define SLEEP_EX_DURATION 50 /* delay for yield/sleep */ - #define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE) - #elif defined (__SVR4) && defined (__sun) /* solaris */ - #include - #define SPIN_LOCK_YIELD thr_yield(); - #elif !defined(LACKS_SCHED_H) - #include - #define SPIN_LOCK_YIELD sched_yield(); - #else - #define SPIN_LOCK_YIELD - #endif /* ... yield ... */ - - #define BOOST_CONTAINER_SPINS_PER_YIELD 63 - inline int boost_interprocess_spin_acquire_lock(int *sl) { - int spins = 0; - while (*(volatile int *)sl != 0 || - BOOST_CONTAINER_CAS_LOCK(sl)) { - if ((++spins & BOOST_CONTAINER_SPINS_PER_YIELD) == 0) { - SPIN_LOCK_YIELD; - } - } - return 0; - } - #define BOOST_CONTAINER_MLOCK_T int - #define BOOST_CONTAINER_TRY_LOCK(sl) !BOOST_CONTAINER_CAS_LOCK(sl) - #define BOOST_CONTAINER_RELEASE_LOCK(sl) BOOST_CONTAINER_CLEAR_LOCK(sl) - #define BOOST_CONTAINER_ACQUIRE_LOCK(sl) (BOOST_CONTAINER_CAS_LOCK(sl)? boost_interprocess_spin_acquire_lock(sl) : 0) - #define BOOST_CONTAINER_INITIAL_LOCK(sl) (*sl = 0) - #define BOOST_CONTAINER_DESTROY_LOCK(sl) (0) -#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_WIN32 - // -#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_PTHREAD - #include -#endif - -namespace boost { -namespace container { -namespace container_detail { - -#if BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_NONE - class null_mutex - { - private: - null_mutex(const null_mutex &); - void operator=(const null_mutex &); - - public: - null_mutex() { } - - static void lock() { } - static void unlock() { } - }; - - typedef null_mutex default_mutex; -#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_SPINLOCKS - - class spin_mutex - { - private: - BOOST_CONTAINER_MLOCK_T sl; - spin_mutex(const spin_mutex &); - void operator=(const spin_mutex &); - - public: - spin_mutex() { BOOST_CONTAINER_INITIAL_LOCK(&sl); } - - void lock() { BOOST_CONTAINER_ACQUIRE_LOCK(&sl); } - void unlock() { BOOST_CONTAINER_RELEASE_LOCK(&sl); } - }; - typedef spin_mutex default_mutex; -#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_WIN32 - class mutex - { - private: - CRITICAL_SECTION mtx; - - mutex(const mutex &); - void operator=(const mutex &); - - public: - mutex() - { InitializeCriticalSection(&mtx); } - - ~mutex() - { DeleteCriticalSection(&mtx); } - - void lock() - { EnterCriticalSection(&mtx); } - - void unlock() - { LeaveCriticalSection(&mtx); } - }; - - typedef mutex default_mutex; -#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_PTHREAD - class mutex - { - private: - pthread_mutex_t mtx; - - mutex(const mutex &); - void operator=(const mutex &); - - public: - mutex() - { pthread_mutex_init(&mtx, 0); } - - ~mutex() - { pthread_mutex_destroy(&mtx); } - - void lock() - { pthread_mutex_lock(&mtx); } - - void unlock() - { pthread_mutex_unlock(&mtx); } - }; - - typedef mutex default_mutex; -#endif - -template -class scoped_lock -{ - public: - scoped_lock(Mutex &m) - : m_(m) - { m_.lock(); } - ~scoped_lock() - { m_.unlock(); } - - private: - Mutex &m_; -}; - -} // namespace container_detail -} // namespace container -} // namespace boost - -#undef BOOST_MUTEX_HELPER_WIN32 -#undef BOOST_MUTEX_HELPER_PTHREAD -#undef BOOST_MUTEX_HELPER_NONE -#undef BOOST_MUTEX_HELPER -#undef BOOST_MUTEX_HELPER_SPINLOCKS - -#include - -#endif diff --git a/boost/container/detail/next_capacity.hpp b/boost/container/detail/next_capacity.hpp new file mode 100644 index 0000000..3bc98a3 --- /dev/null +++ b/boost/container/detail/next_capacity.hpp @@ -0,0 +1,75 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the 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_NEXT_CAPACITY_HPP +#define BOOST_CONTAINER_DETAIL_NEXT_CAPACITY_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +// container +#include +// container/detail +#include + +namespace boost { +namespace container { +namespace container_detail { + +enum NextCapacityOption { NextCapacityDouble, NextCapacity60Percent }; + +template +struct next_capacity_calculator; + +template +struct next_capacity_calculator +{ + static SizeType get(const SizeType max_size + ,const SizeType capacity + ,const SizeType n) + { + const SizeType remaining = max_size - capacity; + if ( remaining < n ) + boost::container::throw_length_error("get_next_capacity, allocator's max_size reached"); + const SizeType additional = max_value(n, capacity); + return ( remaining < additional ) ? max_size : ( capacity + additional ); + } +}; + +template +struct next_capacity_calculator +{ + static SizeType get(const SizeType max_size + ,const SizeType capacity + ,const SizeType n) + { + const SizeType remaining = max_size - capacity; + if ( remaining < n ) + boost::container::throw_length_error("get_next_capacity, allocator's max_size reached"); + const SizeType m3 = max_size/3; + + if (capacity < m3) + return capacity + max_value(3*(capacity+1)/5, n); + + if (capacity < m3*2) + return capacity + max_value((capacity+1)/2, n); + return max_size; + } +}; + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_NEXT_CAPACITY_HPP diff --git a/boost/container/detail/node_alloc_holder.hpp b/boost/container/detail/node_alloc_holder.hpp deleted file mode 100644 index 250c559..0000000 --- a/boost/container/detail/node_alloc_holder.hpp +++ /dev/null @@ -1,399 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_NODE_ALLOC_HPP_ -#define BOOST_CONTAINER_DETAIL_NODE_ALLOC_HPP_ - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef BOOST_CONTAINER_PERFECT_FORWARDING -#include -#endif - -#include - - - -namespace boost { -namespace container { -namespace container_detail { - -template -struct node_compare - : private ValueCompare -{ - typedef ValueCompare wrapped_value_compare; - typedef typename wrapped_value_compare::key_type key_type; - typedef typename wrapped_value_compare::value_type value_type; - typedef typename wrapped_value_compare::key_of_value key_of_value; - - explicit node_compare(const wrapped_value_compare &pred) - : wrapped_value_compare(pred) - {} - - node_compare() - : wrapped_value_compare() - {} - - wrapped_value_compare &value_comp() - { return static_cast(*this); } - - wrapped_value_compare &value_comp() const - { return static_cast(*this); } - - bool operator()(const Node &a, const Node &b) const - { return wrapped_value_compare::operator()(a.get_data(), b.get_data()); } -}; - -template -struct node_alloc_holder -{ - //If the intrusive container is an associative container, obtain the predicate, which will - //be of type node_compare<>. If not an associative container value_compare will be a "nat" type. - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, ICont, - value_compare, container_detail::nat) intrusive_value_compare; - //In that case obtain the value predicate from the node predicate via wrapped_value_compare - //if intrusive_value_compare is node_compare<>, nat otherwise - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, ICont, - wrapped_value_compare, container_detail::nat) value_compare; - - typedef allocator_traits allocator_traits_type; - typedef typename allocator_traits_type::value_type value_type; - typedef ICont intrusive_container; - typedef typename ICont::value_type Node; - typedef typename allocator_traits_type::template - portable_rebind_alloc::type NodeAlloc; - typedef allocator_traits node_allocator_traits_type; - typedef container_detail::allocator_version_traits node_allocator_version_traits_type; - typedef A ValAlloc; - typedef typename node_allocator_traits_type::pointer NodePtr; - typedef container_detail::scoped_deallocator Deallocator; - typedef typename node_allocator_traits_type::size_type size_type; - typedef typename node_allocator_traits_type::difference_type difference_type; - typedef container_detail::integral_constant allocator_v1; - typedef container_detail::integral_constant allocator_v2; - typedef container_detail::integral_constant::value> alloc_version; - typedef typename ICont::iterator icont_iterator; - typedef typename ICont::const_iterator icont_citerator; - typedef allocator_destroyer Destroyer; - typedef allocator_traits NodeAllocTraits; - typedef allocator_version_traits AllocVersionTraits; - - private: - BOOST_COPYABLE_AND_MOVABLE(node_alloc_holder) - - public: - - //Constructors for sequence containers - node_alloc_holder() - : members_() - {} - - explicit node_alloc_holder(const ValAlloc &a) - : members_(a) - {} - - explicit node_alloc_holder(const node_alloc_holder &x) - : members_(NodeAllocTraits::select_on_container_copy_construction(x.node_alloc())) - {} - - explicit node_alloc_holder(BOOST_RV_REF(node_alloc_holder) x) - : members_(boost::move(x.node_alloc())) - { this->icont().swap(x.icont()); } - - //Constructors for associative containers - explicit node_alloc_holder(const ValAlloc &a, const value_compare &c) - : members_(a, c) - {} - - explicit node_alloc_holder(const node_alloc_holder &x, const value_compare &c) - : members_(NodeAllocTraits::select_on_container_copy_construction(x.node_alloc()), c) - {} - - explicit node_alloc_holder(const value_compare &c) - : members_(c) - {} - - //helpers for move assignments - explicit node_alloc_holder(BOOST_RV_REF(node_alloc_holder) x, const value_compare &c) - : members_(boost::move(x.node_alloc()), c) - { this->icont().swap(x.icont()); } - - void copy_assign_alloc(const node_alloc_holder &x) - { - container_detail::bool_ flag; - container_detail::assign_alloc( static_cast(this->members_) - , static_cast(x.members_), flag); - } - - void move_assign_alloc( node_alloc_holder &x) - { - container_detail::bool_ flag; - container_detail::move_alloc( static_cast(this->members_) - , static_cast(x.members_), flag); - } - - ~node_alloc_holder() - { this->clear(alloc_version()); } - - size_type max_size() const - { return allocator_traits_type::max_size(this->node_alloc()); } - - NodePtr allocate_one() - { return AllocVersionTraits::allocate_one(this->node_alloc()); } - - void deallocate_one(const NodePtr &p) - { AllocVersionTraits::deallocate_one(this->node_alloc(), p); } - - #ifdef BOOST_CONTAINER_PERFECT_FORWARDING - - template - NodePtr create_node(Args &&...args) - { - NodePtr p = this->allocate_one(); - Deallocator node_deallocator(p, this->node_alloc()); - allocator_traits::construct - ( this->node_alloc() - , container_detail::addressof(p->m_data), boost::forward(args)...); - node_deallocator.release(); - //This does not throw - typedef typename Node::hook_type hook_type; - ::new(static_cast(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; - return (p); - } - - #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, >) \ - NodePtr create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - NodePtr p = this->allocate_one(); \ - Deallocator node_deallocator(p, this->node_alloc()); \ - allocator_traits::construct \ - (this->node_alloc(), container_detail::addressof(p->m_data) \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ - node_deallocator.release(); \ - typedef typename Node::hook_type hook_type; \ - ::new(static_cast(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; \ - return (p); \ - } \ - //! - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() - - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING - - template - NodePtr create_node_from_it(const It &it) - { - NodePtr p = this->allocate_one(); - Deallocator node_deallocator(p, this->node_alloc()); - ::boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), it); - node_deallocator.release(); - //This does not throw - typedef typename Node::hook_type hook_type; - ::new(static_cast(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; - return (p); - } - - void destroy_node(const NodePtr &nodep) - { - allocator_traits::destroy(this->node_alloc(), container_detail::to_raw_pointer(nodep)); - this->deallocate_one(nodep); - } - - void swap(node_alloc_holder &x) - { - this->icont().swap(x.icont()); - container_detail::bool_ flag; - container_detail::swap_alloc(this->node_alloc(), x.node_alloc(), flag); - } - - template - void allocate_many_and_construct - (FwdIterator beg, difference_type n, Inserter inserter) - { - if(n){ - typedef typename node_allocator_version_traits_type::multiallocation_chain multiallocation_chain; - - //Try to allocate memory in a single block - typedef typename multiallocation_chain::iterator multialloc_iterator; - multiallocation_chain mem; - NodeAlloc &nalloc = this->node_alloc(); - node_allocator_version_traits_type::allocate_individual(nalloc, n, mem); - multialloc_iterator itbeg(mem.begin()), itlast(mem.last()); - mem.clear(); - Node *p = 0; - BOOST_TRY{ - Deallocator node_deallocator(NodePtr(), nalloc); - container_detail::scoped_destructor sdestructor(nalloc, 0); - while(n--){ - p = container_detail::to_raw_pointer(iterator_to_pointer(itbeg)); - node_deallocator.set(p); - ++itbeg; - //This can throw - boost::container::construct_in_place(nalloc, container_detail::addressof(p->m_data), beg); - sdestructor.set(p); - ++beg; - //This does not throw - typedef typename Node::hook_type hook_type; - ::new(static_cast(p), boost_container_new_t()) hook_type; - //This can throw in some containers (predicate might throw). - //(sdestructor will destruct the node and node_deallocator will deallocate it in case of exception) - inserter(*p); - sdestructor.set(0); - } - sdestructor.release(); - node_deallocator.release(); - } - BOOST_CATCH(...){ - mem.incorporate_after(mem.last(), &*itbeg, &*itlast, n); - node_allocator_version_traits_type::deallocate_individual(this->node_alloc(), mem); - BOOST_RETHROW - } - BOOST_CATCH_END - } - } - - void clear(allocator_v1) - { this->icont().clear_and_dispose(Destroyer(this->node_alloc())); } - - void clear(allocator_v2) - { - typename NodeAlloc::multiallocation_chain chain; - allocator_destroyer_and_chain_builder builder(this->node_alloc(), chain); - this->icont().clear_and_dispose(builder); - //BOOST_STATIC_ASSERT((::boost::has_move_emulation_enabled::value == true)); - if(!chain.empty()) - this->node_alloc().deallocate_individual(chain); - } - - icont_iterator erase_range(const icont_iterator &first, const icont_iterator &last, allocator_v1) - { return this->icont().erase_and_dispose(first, last, Destroyer(this->node_alloc())); } - - icont_iterator erase_range(const icont_iterator &first, const icont_iterator &last, allocator_v2) - { - typedef typename NodeAlloc::multiallocation_chain multiallocation_chain; - NodeAlloc & nalloc = this->node_alloc(); - multiallocation_chain chain; - allocator_destroyer_and_chain_builder chain_builder(nalloc, chain); - icont_iterator ret_it = this->icont().erase_and_dispose(first, last, chain_builder); - nalloc.deallocate_individual(chain); - return ret_it; - } - - template - size_type erase_key(const Key& k, const Comparator &comp, allocator_v1) - { return this->icont().erase_and_dispose(k, comp, Destroyer(this->node_alloc())); } - - template - size_type erase_key(const Key& k, const Comparator &comp, allocator_v2) - { - allocator_multialloc_chain_node_deallocator chain_holder(this->node_alloc()); - return this->icont().erase_and_dispose(k, comp, chain_holder.get_chain_builder()); - } - - protected: - struct cloner - { - cloner(node_alloc_holder &holder) - : m_holder(holder) - {} - - NodePtr operator()(const Node &other) const - { return m_holder.create_node(other.get_data()); } - - node_alloc_holder &m_holder; - }; - - struct members_holder - : public NodeAlloc - { - private: - members_holder(const members_holder&); - members_holder & operator=(const members_holder&); - - public: - members_holder() - : NodeAlloc(), m_icont() - {} - - template - explicit members_holder(BOOST_FWD_REF(ConvertibleToAlloc) c2alloc) - : NodeAlloc(boost::forward(c2alloc)) - , m_icont() - {} - - template - members_holder(BOOST_FWD_REF(ConvertibleToAlloc) c2alloc, const value_compare &c) - : NodeAlloc(boost::forward(c2alloc)) - , m_icont(typename ICont::value_compare(c)) - {} - - explicit members_holder(const value_compare &c) - : NodeAlloc() - , m_icont(typename ICont::value_compare(c)) - {} - - //The intrusive container - ICont m_icont; - }; - - ICont &non_const_icont() const - { return const_cast(this->members_.m_icont); } - - ICont &icont() - { return this->members_.m_icont; } - - const ICont &icont() const - { return this->members_.m_icont; } - - NodeAlloc &node_alloc() - { return static_cast(this->members_); } - - const NodeAlloc &node_alloc() const - { return static_cast(this->members_); } - - members_holder members_; -}; - -} //namespace container_detail { -} //namespace container { -} //namespace boost { - -#include - -#endif // BOOST_CONTAINER_DETAIL_NODE_ALLOC_HPP_ diff --git a/boost/container/detail/node_pool.hpp b/boost/container/detail/node_pool.hpp deleted file mode 100644 index 60d8266..0000000 --- a/boost/container/detail/node_pool.hpp +++ /dev/null @@ -1,156 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_NODE_POOL_HPP -#define BOOST_CONTAINER_DETAIL_NODE_POOL_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include //std::unary_function -#include //std::swap -#include - -namespace boost { -namespace container { -namespace container_detail { - -//!Pooled memory allocator using single segregated storage. Includes -//!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< std::size_t NodeSize, std::size_t NodesPerBlock > -class private_node_pool - //Inherit from the implementation to avoid template bloat - : public boost::container::container_detail:: - private_node_pool_impl -{ - typedef boost::container::container_detail:: - private_node_pool_impl base_t; - //Non-copyable - private_node_pool(const private_node_pool &); - private_node_pool &operator=(const private_node_pool &); - - public: - typedef typename base_t::multiallocation_chain multiallocation_chain; - static const std::size_t nodes_per_block = NodesPerBlock; - - //!Constructor from a segment manager. Never throws - private_node_pool() - : base_t(0, NodeSize, NodesPerBlock) - {} - -}; - -template< std::size_t NodeSize - , std::size_t NodesPerBlock - > -class shared_node_pool - : public private_node_pool -{ - private: - typedef private_node_pool private_node_allocator_t; - - public: - typedef typename private_node_allocator_t::free_nodes_t free_nodes_t; - typedef typename private_node_allocator_t::multiallocation_chain multiallocation_chain; - - //!Constructor from a segment manager. Never throws - shared_node_pool() - : private_node_allocator_t(){} - - //!Destructor. Deallocates all allocated blocks. Never throws - ~shared_node_pool() - {} - - //!Allocates array of count elements. Can throw std::bad_alloc - void *allocate_node() - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - return private_node_allocator_t::allocate_node(); - } - - //!Deallocates an array pointed by ptr. Never throws - void deallocate_node(void *ptr) - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - private_node_allocator_t::deallocate_node(ptr); - } - - //!Allocates a singly linked list of n nodes ending in null pointer. - //!can throw std::bad_alloc - void allocate_nodes(const std::size_t n, multiallocation_chain &chain) - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - return private_node_allocator_t::allocate_nodes(n, chain); - } - - void deallocate_nodes(multiallocation_chain &chain) - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - private_node_allocator_t::deallocate_nodes(chain); - } - - //!Deallocates all the free blocks of memory. Never throws - void deallocate_free_blocks() - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - private_node_allocator_t::deallocate_free_blocks(); - } - - //!Deallocates all blocks. Never throws - void purge_blocks() - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - private_node_allocator_t::purge_blocks(); - } - - std::size_t num_free_nodes() - { - //----------------------- - scoped_lock guard(mutex_); - //----------------------- - return private_node_allocator_t::num_free_nodes(); - } - - private: - default_mutex mutex_; -}; - -} //namespace container_detail { -} //namespace container { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_CONTAINER_DETAIL_NODE_POOL_HPP diff --git a/boost/container/detail/node_pool_impl.hpp b/boost/container/detail/node_pool_impl.hpp deleted file mode 100644 index 2450e51..0000000 --- a/boost/container/detail/node_pool_impl.hpp +++ /dev/null @@ -1,366 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_NODE_POOL_IMPL_HPP -#define BOOST_CONTAINER_DETAIL_NODE_POOL_IMPL_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace container { -namespace container_detail { - -template -class private_node_pool_impl -{ - //Non-copyable - private_node_pool_impl(); - private_node_pool_impl(const private_node_pool_impl &); - private_node_pool_impl &operator=(const private_node_pool_impl &); - - //A node object will hold node_t when it's not allocated - public: - typedef typename SegmentManagerBase::void_pointer void_pointer; - typedef typename node_slist::slist_hook_t slist_hook_t; - typedef typename node_slist::node_t node_t; - typedef typename node_slist::node_slist_t free_nodes_t; - typedef typename SegmentManagerBase::multiallocation_chain multiallocation_chain; - typedef typename SegmentManagerBase::size_type size_type; - - private: - typedef typename bi::make_slist - < node_t, bi::base_hook - , bi::linear - , bi::constant_time_size >::type blockslist_t; - public: - - //!Segment manager typedef - typedef SegmentManagerBase segment_manager_base_type; - - //!Constructor from a segment manager. Never throws - private_node_pool_impl(segment_manager_base_type *segment_mngr_base, size_type node_size, size_type nodes_per_block) - : m_nodes_per_block(nodes_per_block) - , m_real_node_size(lcm(node_size, size_type(alignment_of::value))) - //General purpose allocator - , mp_segment_mngr_base(segment_mngr_base) - , m_blocklist() - , m_freelist() - //Debug node count - , m_allocated(0) - {} - - //!Destructor. Deallocates all allocated blocks. Never throws - ~private_node_pool_impl() - { this->purge_blocks(); } - - size_type get_real_num_node() const - { return m_nodes_per_block; } - - //!Returns the segment manager. Never throws - segment_manager_base_type* get_segment_manager_base()const - { return container_detail::to_raw_pointer(mp_segment_mngr_base); } - - void *allocate_node() - { return this->priv_alloc_node(); } - - //!Deallocates an array pointed by ptr. Never throws - void deallocate_node(void *ptr) - { this->priv_dealloc_node(ptr); } - - //!Allocates a singly linked list of n nodes ending in null pointer. - void allocate_nodes(const size_type n, multiallocation_chain &chain) - { - //Preallocate all needed blocks to fulfill the request - size_type cur_nodes = m_freelist.size(); - if(cur_nodes < n){ - this->priv_alloc_block(((n - cur_nodes) - 1)/m_nodes_per_block + 1); - } - - //We just iterate the needed nodes to get the last we'll erase - typedef typename free_nodes_t::iterator free_iterator; - free_iterator before_last_new_it = m_freelist.before_begin(); - for(size_type j = 0; j != n; ++j){ - ++before_last_new_it; - } - - //Cache the first node of the allocated range before erasing - free_iterator first_node(m_freelist.begin()); - free_iterator last_node (before_last_new_it); - - //Erase the range. Since we already have the distance, this is O(1) - m_freelist.erase_after( m_freelist.before_begin() - , ++free_iterator(before_last_new_it) - , n); - - //Now take the last erased node and just splice it in the end - //of the intrusive list that will be traversed by the multialloc iterator. - chain.incorporate_after(chain.before_begin(), &*first_node, &*last_node, n); - m_allocated += n; - } - - void deallocate_nodes(multiallocation_chain &chain) - { - typedef typename multiallocation_chain::iterator iterator; - iterator it(chain.begin()), itend(chain.end()); - while(it != itend){ - void *pElem = &*it; - ++it; - this->priv_dealloc_node(pElem); - } - } - - //!Deallocates all the free blocks of memory. Never throws - void deallocate_free_blocks() - { - typedef typename free_nodes_t::iterator nodelist_iterator; - typename blockslist_t::iterator bit(m_blocklist.before_begin()), - it(m_blocklist.begin()), - itend(m_blocklist.end()); - free_nodes_t backup_list; - nodelist_iterator backup_list_last = backup_list.before_begin(); - - //Execute the algorithm and get an iterator to the last value - size_type blocksize = get_rounded_size - (m_real_node_size*m_nodes_per_block, (size_type) alignment_of::value); - - while(it != itend){ - //Collect all the nodes from the block pointed by it - //and push them in the list - free_nodes_t free_nodes; - nodelist_iterator last_it = free_nodes.before_begin(); - const void *addr = get_block_from_hook(&*it, blocksize); - - m_freelist.remove_and_dispose_if - (is_between(addr, blocksize), push_in_list(free_nodes, last_it)); - - //If the number of nodes is equal to m_nodes_per_block - //this means that the block can be deallocated - if(free_nodes.size() == m_nodes_per_block){ - //Unlink the nodes - free_nodes.clear(); - it = m_blocklist.erase_after(bit); - mp_segment_mngr_base->deallocate((void*)addr); - } - //Otherwise, insert them in the backup list, since the - //next "remove_if" does not need to check them again. - else{ - //Assign the iterator to the last value if necessary - if(backup_list.empty() && !m_freelist.empty()){ - backup_list_last = last_it; - } - //Transfer nodes. This is constant time. - backup_list.splice_after - ( backup_list.before_begin() - , free_nodes - , free_nodes.before_begin() - , last_it - , free_nodes.size()); - bit = it; - ++it; - } - } - //We should have removed all the nodes from the free list - BOOST_ASSERT(m_freelist.empty()); - - //Now pass all the node to the free list again - m_freelist.splice_after - ( m_freelist.before_begin() - , backup_list - , backup_list.before_begin() - , backup_list_last - , backup_list.size()); - } - - size_type num_free_nodes() - { return m_freelist.size(); } - - //!Deallocates all used memory. Precondition: all nodes allocated from this pool should - //!already be deallocated. Otherwise, undefined behaviour. Never throws - void purge_blocks() - { - //check for memory leaks - BOOST_ASSERT(m_allocated==0); - size_type blocksize = get_rounded_size - (m_real_node_size*m_nodes_per_block, (size_type)alignment_of::value); - - //We iterate though the NodeBlock list to free the memory - while(!m_blocklist.empty()){ - void *addr = get_block_from_hook(&m_blocklist.front(), blocksize); - m_blocklist.pop_front(); - mp_segment_mngr_base->deallocate((void*)addr); - } - //Just clear free node list - m_freelist.clear(); - } - - void swap(private_node_pool_impl &other) - { - BOOST_ASSERT(m_nodes_per_block == other.m_nodes_per_block); - BOOST_ASSERT(m_real_node_size == other.m_real_node_size); - std::swap(mp_segment_mngr_base, other.mp_segment_mngr_base); - m_blocklist.swap(other.m_blocklist); - m_freelist.swap(other.m_freelist); - std::swap(m_allocated, other.m_allocated); - } - - private: - - struct push_in_list - { - push_in_list(free_nodes_t &l, typename free_nodes_t::iterator &it) - : slist_(l), last_it_(it) - {} - - void operator()(typename free_nodes_t::pointer p) const - { - slist_.push_front(*p); - if(slist_.size() == 1){ //Cache last element - ++last_it_ = slist_.begin(); - } - } - - private: - free_nodes_t &slist_; - typename free_nodes_t::iterator &last_it_; - }; - - struct is_between - { - typedef typename free_nodes_t::value_type argument_type; - typedef bool result_type; - - is_between(const void *addr, std::size_t size) - : beg_(static_cast(addr)), end_(beg_+size) - {} - - bool operator()(typename free_nodes_t::const_reference v) const - { - return (beg_ <= reinterpret_cast(&v) && - end_ > reinterpret_cast(&v)); - } - private: - const char * beg_; - const char * end_; - }; - - //!Allocates one node, using single segregated storage algorithm. - //!Never throws - node_t *priv_alloc_node() - { - //If there are no free nodes we allocate a new block - if (m_freelist.empty()) - this->priv_alloc_block(1); - //We take the first free node - node_t *n = (node_t*)&m_freelist.front(); - m_freelist.pop_front(); - ++m_allocated; - return n; - } - - //!Deallocates one node, using single segregated storage algorithm. - //!Never throws - void priv_dealloc_node(void *pElem) - { - //We put the node at the beginning of the free node list - node_t * to_deallocate = static_cast(pElem); - m_freelist.push_front(*to_deallocate); - BOOST_ASSERT(m_allocated>0); - --m_allocated; - } - - //!Allocates several blocks of nodes. Can throw - void priv_alloc_block(size_type num_blocks) - { - BOOST_ASSERT(num_blocks > 0); - size_type blocksize = - get_rounded_size(m_real_node_size*m_nodes_per_block, (size_type)alignment_of::value); - - BOOST_TRY{ - for(size_type i = 0; i != num_blocks; ++i){ - //We allocate a new NodeBlock and put it as first - //element in the free Node list - char *pNode = reinterpret_cast - (mp_segment_mngr_base->allocate(blocksize + sizeof(node_t))); - char *pBlock = pNode; - m_blocklist.push_front(get_block_hook(pBlock, blocksize)); - - //We initialize all Nodes in Node Block to insert - //them in the free Node list - for(size_type j = 0; j < m_nodes_per_block; ++j, pNode += m_real_node_size){ - m_freelist.push_front(*new (pNode) node_t); - } - } - } - BOOST_CATCH(...){ - //to-do: if possible, an efficient way to deallocate allocated blocks - BOOST_RETHROW - } - BOOST_CATCH_END - } - - //!Deprecated, use deallocate_free_blocks - void deallocate_free_chunks() - { this->deallocate_free_blocks(); } - - //!Deprecated, use purge_blocks - void purge_chunks() - { this->purge_blocks(); } - - private: - //!Returns a reference to the block hook placed in the end of the block - static node_t & get_block_hook (void *block, size_type blocksize) - { - return *reinterpret_cast(reinterpret_cast(block) + blocksize); - } - - //!Returns the starting address of the block reference to the block hook placed in the end of the block - void *get_block_from_hook (node_t *hook, size_type blocksize) - { - return (reinterpret_cast(hook) - blocksize); - } - - private: - typedef typename boost::intrusive::pointer_traits - ::template rebind_pointer::type segment_mngr_base_ptr_t; - - const size_type m_nodes_per_block; - const size_type m_real_node_size; - segment_mngr_base_ptr_t mp_segment_mngr_base; //Segment manager - blockslist_t m_blocklist; //Intrusive container of blocks - free_nodes_t m_freelist; //Intrusive container of free nods - size_type m_allocated; //Used nodes for debugging -}; - - -} //namespace container_detail { -} //namespace container { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_IMPL_HPP diff --git a/boost/container/detail/pair.hpp b/boost/container/detail/pair.hpp index b7ad84c..35e8846 100644 --- a/boost/container/detail/pair.hpp +++ b/boost/container/detail/pair.hpp @@ -13,7 +13,11 @@ #ifndef BOOST_CONTAINER_CONTAINER_DETAIL_PAIR_HPP #define BOOST_CONTAINER_CONTAINER_DETAIL_PAIR_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -24,16 +28,50 @@ #include #include #include +#include //swap -#include //std::pair -#include //std::swap - +#include //pair #include +/* +namespace boost{ -#ifndef BOOST_CONTAINER_PERFECT_FORWARDING -#include -#endif +template +inline rv< std::pair > &move(std::pair &r) +{ + return reinterpret_cast< rv< std::pair > &>(r); +} + +template +inline rv< std::pair > &move(rv< std::pair > &r) +{ + return r; +} + +template +inline typename ::boost::move_detail::enable_if_and + < T & + , boost::container::container_detail::is_std_pair + , ::boost::move_detail::is_rv + >::type + forward(const typename ::boost::move_detail::identity::type &x) BOOST_NOEXCEPT +{ + return const_cast(x); +} + +template +inline typename ::boost::move_detail::enable_if_and + < const T & + , boost::container::container_detail::is_std_pair + , ::boost::move_detail::is_not_rv + >::type + forward(const typename ::boost::move_detail::identity::type &x) BOOST_NOEXCEPT +{ + return x; +} + +} //namespace boost { +*/ namespace boost { namespace container { @@ -60,6 +98,24 @@ struct is_pair< std::pair > static const bool value = true; }; +template +struct is_not_pair +{ + static const bool value = !is_pair::value; +}; + +template +struct is_std_pair +{ + static const bool value = false; +}; + +template +struct is_std_pair< std::pair > +{ + static const bool value = true; +}; + struct pair_nat; struct piecewise_construct_t { }; @@ -166,37 +222,7 @@ struct pair //template // pair(piecewise_construct_t, tuple first_args, // tuple second_args); -/* - //Variadic versions - template - pair(BOOST_CONTAINER_PP_PARAM(U, u), typename container_detail::disable_if - < container_detail::is_pair< typename container_detail::remove_ref_const::type >, pair_nat>::type* = 0) - : first(::boost::forward(u)) - , second() - {} - #ifdef BOOST_CONTAINER_PERFECT_FORWARDING - - template - pair(U &&u, V &&v) - : first(::boost::forward(u)) - , second(::boost::forward(v), ::boost::forward(args)...) - {} - - #else - - #define BOOST_PP_LOCAL_MACRO(n) \ - template \ - pair(BOOST_CONTAINER_PP_PARAM(U, u) \ - ,BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - : first(::boost::forward(u)) \ - , second(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \ - {} \ - //! - #define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() - #endif -*/ //pair copy assignment pair& operator=(BOOST_COPY_ASSIGN_REF(pair) p) { @@ -214,10 +240,11 @@ struct pair } template - typename ::boost::container::container_detail::enable_if_c - < !(::boost::container::container_detail::is_same::value && - ::boost::container::container_detail::is_same::value) - , pair &>::type + typename ::boost::container::container_detail::disable_if_or + < pair & + , ::boost::container::container_detail::is_same + , ::boost::container::container_detail::is_same + >::type operator=(const pair&p) { first = p.first; @@ -226,18 +253,18 @@ struct pair } template - typename ::boost::container::container_detail::enable_if_c - < !(::boost::container::container_detail::is_same::value && - ::boost::container::container_detail::is_same::value) - , pair &>::type + typename ::boost::container::container_detail::disable_if_or + < pair & + , ::boost::container::container_detail::is_same + , ::boost::container::container_detail::is_same + >::type operator=(BOOST_RV_REF_BEG pair BOOST_RV_REF_END p) { first = ::boost::move(p.first); second = ::boost::move(p.second); return *this; } - - //std::pair copy assignment +//std::pair copy assignment pair& operator=(const std::pair &p) { first = p.first; @@ -272,9 +299,8 @@ struct pair //swap void swap(pair& p) { - using std::swap; - swap(this->first, p.first); - swap(this->second, p.second); + ::boost::adl_move_swap(this->first, p.first); + ::boost::adl_move_swap(this->second, p.second); } }; @@ -309,10 +335,7 @@ inline pair make_pair(T1 x, T2 y) template inline void swap(pair& x, pair& y) -{ - swap(x.first, y.first); - swap(x.second, y.second); -} +{ x.swap(y); } } //namespace container_detail { } //namespace container { diff --git a/boost/container/detail/placement_new.hpp b/boost/container/detail/placement_new.hpp index 2489d8a..c50981f 100644 --- a/boost/container/detail/placement_new.hpp +++ b/boost/container/detail/placement_new.hpp @@ -1,6 +1,8 @@ +#ifndef BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP +#define BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP /////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the 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,10 +10,11 @@ // /////////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP -#define BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP +#ifndef BOOST_CONFIG_HPP +# include +#endif -#if defined(_MSC_VER) +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/pool_common.hpp b/boost/container/detail/pool_common.hpp deleted file mode 100644 index 11fb6c2..0000000 --- a/boost/container/detail/pool_common.hpp +++ /dev/null @@ -1,53 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_POOL_COMMON_HPP -#define BOOST_CONTAINER_DETAIL_POOL_COMMON_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include - -namespace boost { -namespace container { -namespace container_detail { - -template -struct node_slist -{ - //This hook will be used to chain the individual nodes - typedef typename bi::make_slist_base_hook - , bi::link_mode >::type slist_hook_t; - - //A node object will hold node_t when it's not allocated - typedef slist_hook_t node_t; - - typedef typename bi::make_slist - , bi::cache_last, bi::base_hook >::type node_slist_t; -}; - -template -struct is_stateless_segment_manager -{ - static const bool value = false; -}; - -} //namespace container_detail { -} //namespace container { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_IMPL_HPP diff --git a/boost/container/detail/pool_common_alloc.hpp b/boost/container/detail/pool_common_alloc.hpp deleted file mode 100644 index dfae7ef..0000000 --- a/boost/container/detail/pool_common_alloc.hpp +++ /dev/null @@ -1,98 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_POOL_COMMON_ALLOC_HPP -#define BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include - -#include -#include -#include -#include - -namespace boost{ -namespace container{ -namespace container_detail{ - -struct node_slist_helper - : public boost::container::container_detail::node_slist -{}; - -struct fake_segment_manager -{ - typedef void * void_pointer; - static const std::size_t PayloadPerAllocation = BOOST_CONTAINER_ALLOCATION_PAYLOAD; - - typedef boost::container::container_detail:: - basic_multiallocation_chain multiallocation_chain; - static void deallocate(void_pointer p) - { boost_cont_free(p); } - - static void deallocate_many(multiallocation_chain &chain) - { - std::size_t size = chain.size(); - std::pair ptrs = chain.extract_data(); - boost_cont_memchain dlchain; - BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&dlchain, ptrs.first, ptrs.second, size); - boost_cont_multidealloc(&dlchain); - } - - typedef std::ptrdiff_t difference_type; - typedef std::size_t size_type; - - static void *allocate_aligned(std::size_t nbytes, std::size_t alignment) - { - void *ret = boost_cont_memalign(nbytes, alignment); - if(!ret) - boost::container::throw_bad_alloc(); - return ret; - } - - static void *allocate(std::size_t nbytes) - { - void *ret = boost_cont_malloc(nbytes); - if(!ret) - boost::container::throw_bad_alloc(); - return ret; - } -}; - -} //namespace boost{ -} //namespace container{ -} //namespace container_detail{ - -namespace boost { -namespace container { -namespace container_detail { - -template -struct is_stateless_segment_manager; - -template<> -struct is_stateless_segment_manager - -{ - static const bool value = true; -}; - -} //namespace container_detail { -} //namespace container { -} //namespace boost { - -#include - -#endif //BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP diff --git a/boost/container/detail/preprocessor.hpp b/boost/container/detail/preprocessor.hpp deleted file mode 100644 index 838eff2..0000000 --- a/boost/container/detail/preprocessor.hpp +++ /dev/null @@ -1,228 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2008-2013. Distributed under the 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_PREPROCESSOR_HPP -#define BOOST_CONTAINER_DETAIL_PREPROCESSOR_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include - -#ifdef BOOST_CONTAINER_PERFECT_FORWARDING -//#error "This file is not needed when perfect forwarding is available" -#endif //BOOST_CONTAINER_PERFECT_FORWARDING - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS 10 - -//Note: -//We define template parameters as const references to -//be able to bind temporaries. After that we will un-const them. -//This cast is ugly but it is necessary until "perfect forwarding" -//is achieved in C++0x. Meanwhile, if we want to be able to -//bind rvalues with non-const references, we have to be ugly -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - #define BOOST_CONTAINER_PP_PARAM_LIST(z, n, data) \ - BOOST_PP_CAT(P, n) && BOOST_PP_CAT(p, n) \ - //! -#else - #define BOOST_CONTAINER_PP_PARAM_LIST(z, n, data) \ - const BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n) \ - //! -#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -#define BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q(z, n, Data) \ -const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \ -//! - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - #define BOOST_CONTAINER_PP_PARAM(U, u) \ - U && u \ - //! -#else - #define BOOST_CONTAINER_PP_PARAM(U, u) \ - const U & u \ - //! -#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - - #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) )) \ - //! - -#else //BOOST_NO_CXX11_RVALUE_REFERENCES - - #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \ - BOOST_PP_CAT(m_p, n) (const_cast(BOOST_PP_CAT(p, n))) \ - //! -#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - - #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) - - namespace boost { - namespace container { - namespace container_detail { - template - struct ref_holder; - - template - struct ref_holder - { - explicit ref_holder(T &t) - : t_(t) - {} - T &t_; - T & get() { return t_; } - }; - - template - struct ref_holder - { - explicit ref_holder(const T &t) - : t_(t) - {} - const T &t_; - const T & get() { return t_; } - }; - - template - struct ref_holder - { - explicit ref_holder(const T &t) - : t_(t) - {} - const T &t_; - const T & get() { return t_; } - }; - - template - struct ref_holder - { - explicit ref_holder(T &&t) - : t_(t) - {} - T &t_; - T && get() { return ::boost::move(t_); } - }; - - template - struct ref_holder - { - explicit 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::container::container_detail::ref_holder BOOST_PP_CAT(m_p, n); \ - //! - - #else //BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG - - #define BOOST_CONTAINER_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) - -#else //BOOST_NO_CXX11_RVALUE_REFERENCES - - #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data) \ - BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \ - //! -#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) - - #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) BOOST_PP_CAT(this->m_p, n).get() \ - //! - -#else //!defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) - - #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) \ - ::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(this->m_p, n) ) \ - //! - -#endif //!defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG) - -#define BOOST_CONTAINER_PP_PARAM_INC(z, n, data) \ - BOOST_PP_CAT(++this->m_p, n) \ -//! - -#define BOOST_CONTAINER_PP_IDENTITY(z, n, data) data - - -#define BOOST_CONTAINER_PP_PARAM_FORWARD(z, n, data) \ -::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ) \ -//! - -#define BOOST_CONTAINER_PP_DECLVAL(z, n, data) \ -::boost::move_detail::declval< BOOST_PP_CAT(P, n) >() \ -//! - -#define BOOST_CONTAINER_PP_MEMBER_IT_FORWARD(z, n, data) \ -BOOST_PP_CAT(*this->m_p, n) \ -//! - -#define BOOST_CONTAINER_PP_TEMPLATE_PARAM_VOID_DEFAULT(z, n, data) \ - BOOST_PP_CAT(class P, n) = void \ -//! - -#define BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT(z, n, default_type) \ - BOOST_PP_CAT(class P, n) = default_type \ -//! - -#define BOOST_CONTAINER_PP_STATIC_PARAM_REF_DECLARE(z, n, data) \ - static BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n); \ -//! - -#define BOOST_CONTAINER_PP_PARAM_PASS(z, n, data) \ - BOOST_PP_CAT(p, n) \ -//! - -#define BOOST_CONTAINER_PP_FWD_TYPE(z, n, data) \ - typename ::boost::move_detail::forward_type< BOOST_PP_CAT(P, n) >::type \ -//! - -#include - -//#else - -//#ifdef BOOST_CONTAINER_PERFECT_FORWARDING -//#error "This file is not needed when perfect forwarding is available" -//#endif //BOOST_CONTAINER_PERFECT_FORWARDING - -#endif //#ifndef BOOST_CONTAINER_DETAIL_PREPROCESSOR_HPP diff --git a/boost/container/detail/singleton.hpp b/boost/container/detail/singleton.hpp deleted file mode 100644 index a2372c3..0000000 --- a/boost/container/detail/singleton.hpp +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2000 Stephen Cleary -// Copyright (C) 2008 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) -// -// See http://www.boost.org for updates, documentation, and revision history. -// -// This file is a modified file from Boost.Pool - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013. Distributed under the 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_SINGLETON_DETAIL_HPP -#define BOOST_CONTAINER_DETAIL_SINGLETON_DETAIL_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -// -// The following helper classes are placeholders for a generic "singleton" -// class. The classes below support usage of singletons, including use in -// program startup/shutdown code, AS LONG AS there is only one thread -// running before main() begins, and only one thread running after main() -// exits. -// -// This class is also limited in that it can only provide singleton usage for -// classes with default constructors. -// - -// The design of this class is somewhat twisted, but can be followed by the -// calling inheritance. Let us assume that there is some user code that -// calls "singleton_default::instance()". The following (convoluted) -// sequence ensures that the same function will be called before main(): -// instance() contains a call to create_object.do_nothing() -// Thus, object_creator is implicitly instantiated, and create_object -// must exist. -// Since create_object is a static member, its constructor must be -// called before main(). -// The constructor contains a call to instance(), thus ensuring that -// instance() will be called before main(). -// The first time instance() is called (i.e., before main()) is the -// latest point in program execution where the object of type T -// can be created. -// Thus, any call to instance() will auto-magically result in a call to -// instance() before main(), unless already present. -// Furthermore, since the instance() function contains the object, instead -// of the singleton_default class containing a static instance of the -// object, that object is guaranteed to be constructed (at the latest) in -// the first call to instance(). This permits calls to instance() from -// static code, even if that code is called before the file-scope objects -// in this file have been initialized. - -namespace boost { -namespace container { -namespace container_detail { - -// T must be: no-throw default constructible and no-throw destructible -template -struct singleton_default -{ - private: - struct object_creator - { - // This constructor does nothing more than ensure that instance() - // is called before main() begins, thus creating the static - // T object before multithreading race issues can come up. - object_creator() { singleton_default::instance(); } - inline void do_nothing() const { } - }; - static object_creator create_object; - - singleton_default(); - - public: - typedef T object_type; - - // If, at any point (in user code), singleton_default::instance() - // is called, then the following function is instantiated. - static object_type & instance() - { - // This is the object that we return a reference to. - // It is guaranteed to be created before main() begins because of - // the next line. - static object_type obj; - - // The following line does nothing else than force the instantiation - // of singleton_default::create_object, whose constructor is - // called before main() begins. - create_object.do_nothing(); - - return obj; - } -}; -template -typename singleton_default::object_creator -singleton_default::create_object; - -} // namespace container_detail -} // namespace container -} // namespace boost - -#include - -#endif //BOOST_CONTAINER_DETAIL_SINGLETON_DETAIL_HPP diff --git a/boost/container/detail/std_fwd.hpp b/boost/container/detail/std_fwd.hpp index a2edecc..1277df0 100644 --- a/boost/container/detail/std_fwd.hpp +++ b/boost/container/detail/std_fwd.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_STD_FWD_HPP #define BOOST_CONTAINER_DETAIL_STD_FWD_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -19,12 +23,20 @@ // Standard predeclarations ////////////////////////////////////////////////////////////////////////////// -#if defined(__clang__) && defined(_LIBCPP_VERSION) +#if defined(_LIBCPP_VERSION) #define BOOST_CONTAINER_CLANG_INLINE_STD_NS #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wc++11-extensions" + #if defined(__clang__) + #pragma GCC diagnostic ignored "-Wc++11-extensions" + #endif #define BOOST_CONTAINER_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD #define BOOST_CONTAINER_STD_NS_END _LIBCPP_END_NAMESPACE_STD +#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE_VERSION) //GCC >= 4.6 + #define BOOST_CONTAINER_STD_NS_BEG namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + #define BOOST_CONTAINER_STD_NS_END _GLIBCXX_END_NAMESPACE_VERSION } // namespace +#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE) //GCC >= 4.2 + #define BOOST_CONTAINER_STD_NS_BEG _GLIBCXX_BEGIN_NAMESPACE(std) + #define BOOST_CONTAINER_STD_NS_END _GLIBCXX_END_NAMESPACE #else #define BOOST_CONTAINER_STD_NS_BEG namespace std{ #define BOOST_CONTAINER_STD_NS_END } @@ -49,6 +61,11 @@ struct forward_iterator_tag; struct bidirectional_iterator_tag; struct random_access_iterator_tag; +template +class insert_iterator; + +struct allocator_arg_t; + BOOST_CONTAINER_STD_NS_END #ifdef BOOST_CONTAINER_CLANG_INLINE_STD_NS diff --git a/boost/container/detail/to_raw_pointer.hpp b/boost/container/detail/to_raw_pointer.hpp new file mode 100644 index 0000000..0b4445a --- /dev/null +++ b/boost/container/detail/to_raw_pointer.hpp @@ -0,0 +1,33 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the 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_TO_RAW_POINTER_HPP +#define BOOST_CONTAINER_DETAIL_TO_RAW_POINTER_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include + +namespace boost { +namespace container { +namespace container_detail { + +using ::boost::intrusive::detail::to_raw_pointer; + +} //namespace container_detail { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_DETAIL_TO_RAW_POINTER_HPP diff --git a/boost/container/detail/transform_iterator.hpp b/boost/container/detail/transform_iterator.hpp deleted file mode 100644 index c4e746c..0000000 --- a/boost/container/detail/transform_iterator.hpp +++ /dev/null @@ -1,177 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. -// (C) Copyright Gennaro Prota 2003 - 2004. -// -// Distributed under the 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_TRANSFORM_ITERATORS_HPP -#define BOOST_CONTAINER_DETAIL_TRANSFORM_ITERATORS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include - -namespace boost { -namespace container { - -template -struct operator_arrow_proxy -{ - operator_arrow_proxy(const PseudoReference &px) - : m_value(px) - {} - - typedef PseudoReference element_type; - - PseudoReference* operator->() const { return &m_value; } - - mutable PseudoReference m_value; -}; - -template -struct operator_arrow_proxy -{ - operator_arrow_proxy(T &px) - : m_value(px) - {} - - typedef T element_type; - - T* operator->() const { return const_cast(&m_value); } - - T &m_value; -}; - -template -class transform_iterator - : public UnaryFunction - , public std::iterator - < typename Iterator::iterator_category - , typename container_detail::remove_reference::type - , typename Iterator::difference_type - , operator_arrow_proxy - , typename UnaryFunction::result_type> -{ - public: - explicit transform_iterator(const Iterator &it, const UnaryFunction &f = UnaryFunction()) - : UnaryFunction(f), m_it(it) - {} - - explicit transform_iterator() - : UnaryFunction(), m_it() - {} - - //Constructors - transform_iterator& operator++() - { increment(); return *this; } - - transform_iterator operator++(int) - { - transform_iterator result (*this); - increment(); - return result; - } - - friend bool operator== (const transform_iterator& i, const transform_iterator& i2) - { return i.equal(i2); } - - friend bool operator!= (const transform_iterator& i, const transform_iterator& i2) - { return !(i == i2); } - -/* - friend bool operator> (const transform_iterator& i, const transform_iterator& i2) - { return i2 < i; } - - friend bool operator<= (const transform_iterator& i, const transform_iterator& i2) - { return !(i > i2); } - - friend bool operator>= (const transform_iterator& i, const transform_iterator& i2) - { return !(i < i2); } -*/ - friend typename Iterator::difference_type operator- (const transform_iterator& i, const transform_iterator& i2) - { return i2.distance_to(i); } - - //Arithmetic - transform_iterator& operator+=(typename Iterator::difference_type off) - { this->advance(off); return *this; } - - transform_iterator operator+(typename Iterator::difference_type off) const - { - transform_iterator other(*this); - other.advance(off); - return other; - } - - friend transform_iterator operator+(typename Iterator::difference_type off, const transform_iterator& right) - { return right + off; } - - transform_iterator& operator-=(typename Iterator::difference_type off) - { this->advance(-off); return *this; } - - transform_iterator operator-(typename Iterator::difference_type off) const - { return *this + (-off); } - - typename UnaryFunction::result_type operator*() const - { return dereference(); } - - operator_arrow_proxy - operator->() const - { return operator_arrow_proxy(dereference()); } - - Iterator & base() - { return m_it; } - - const Iterator & base() const - { return m_it; } - - private: - Iterator m_it; - - void increment() - { ++m_it; } - - void decrement() - { --m_it; } - - bool equal(const transform_iterator &other) const - { return m_it == other.m_it; } - - bool less(const transform_iterator &other) const - { return other.m_it < m_it; } - - typename UnaryFunction::result_type dereference() const - { return UnaryFunction::operator()(*m_it); } - - void advance(typename Iterator::difference_type n) - { std::advance(m_it, n); } - - typename Iterator::difference_type distance_to(const transform_iterator &other)const - { return std::distance(other.m_it, m_it); } -}; - -template -transform_iterator -make_transform_iterator(Iterator it, UnaryFunc fun) -{ - return transform_iterator(it, fun); -} - -} //namespace container { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_CONTAINER_DETAIL_TRANSFORM_ITERATORS_HPP diff --git a/boost/container/detail/tree.hpp b/boost/container/detail/tree.hpp deleted file mode 100644 index e59bca0..0000000 --- a/boost/container/detail/tree.hpp +++ /dev/null @@ -1,1182 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_TREE_HPP -#define BOOST_CONTAINER_TREE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// -#include -#include -#include -#include -#include -// -#include -#include -#include -// -#ifndef BOOST_CONTAINER_PERFECT_FORWARDING -#include -#endif - -#include //std::pair -#include -#include - -namespace boost { -namespace container { -namespace container_detail { - -template -struct tree_value_compare - : public KeyCompare -{ - typedef Value value_type; - typedef KeyCompare key_compare; - typedef KeyOfValue key_of_value; - typedef Key key_type; - - explicit tree_value_compare(const key_compare &kcomp) - : KeyCompare(kcomp) - {} - - tree_value_compare() - : KeyCompare() - {} - - const key_compare &key_comp() const - { return static_cast(*this); } - - key_compare &key_comp() - { return static_cast(*this); } - - template - struct is_key - { - static const bool value = is_same::value; - }; - - template - typename enable_if_c::value, const key_type &>::type - key_forward(const T &key) const - { return key; } - - template - typename enable_if_c::value, const key_type &>::type - key_forward(const T &key) const - { return KeyOfValue()(key); } - - template - bool operator()(const KeyType &key1, const KeyType2 &key2) const - { return key_compare::operator()(this->key_forward(key1), this->key_forward(key2)); } -}; - -template -struct intrusive_tree_hook; - -template -struct intrusive_tree_hook -{ - typedef typename container_detail::bi::make_set_base_hook - < container_detail::bi::void_pointer - , container_detail::bi::link_mode - , container_detail::bi::optimize_size - >::type type; -}; - -template -struct intrusive_tree_hook -{ - typedef typename container_detail::bi::make_avl_set_base_hook - < container_detail::bi::void_pointer - , container_detail::bi::link_mode - , container_detail::bi::optimize_size - >::type type; -}; - -template -struct intrusive_tree_hook -{ - typedef typename container_detail::bi::make_bs_set_base_hook - < container_detail::bi::void_pointer - , container_detail::bi::link_mode - >::type type; -}; - -template -struct intrusive_tree_hook -{ - typedef typename container_detail::bi::make_bs_set_base_hook - < container_detail::bi::void_pointer - , container_detail::bi::link_mode - >::type type; -}; - -//This trait is used to type-pun std::pair because in C++03 -//compilers std::pair is useless for C++11 features -template -struct tree_internal_data_type -{ - typedef T type; -}; - -template -struct tree_internal_data_type< std::pair > -{ - typedef pair type; -}; - -//The node to be store in the tree -template -struct tree_node - : public intrusive_tree_hook::type -{ - private: - //BOOST_COPYABLE_AND_MOVABLE(tree_node) - tree_node(); - - public: - typedef typename intrusive_tree_hook - ::type hook_type; - typedef T value_type; - typedef typename tree_internal_data_type::type internal_type; - - typedef tree_node< T, VoidPointer - , tree_type_value, OptimizeSize> node_type; - - T &get_data() - { - T* ptr = reinterpret_cast(&this->m_data); - return *ptr; - } - - const T &get_data() const - { - const T* ptr = reinterpret_cast(&this->m_data); - return *ptr; - } - - internal_type m_data; - - template - void do_assign(const std::pair &p) - { - const_cast(m_data.first) = p.first; - m_data.second = p.second; - } - - template - void do_assign(const pair &p) - { - const_cast(m_data.first) = p.first; - m_data.second = p.second; - } - - template - void do_assign(const V &v) - { m_data = v; } - - template - void do_move_assign(std::pair &p) - { - const_cast(m_data.first) = ::boost::move(p.first); - m_data.second = ::boost::move(p.second); - } - - template - void do_move_assign(pair &p) - { - const_cast(m_data.first) = ::boost::move(p.first); - m_data.second = ::boost::move(p.second); - } - - template - void do_move_assign(V &v) - { m_data = ::boost::move(v); } -}; - -template -struct iiterator_node_value_type< tree_node > { - typedef T type; -}; - -template -class insert_equal_end_hint_functor -{ - Icont &icont_; - - public: - insert_equal_end_hint_functor(Icont &icont) - : icont_(icont) - {} - - void operator()(Node &n) - { this->icont_.insert_equal(this->icont_.cend(), n); } -}; - -template -class push_back_functor -{ - Icont &icont_; - - public: - push_back_functor(Icont &icont) - : icont_(icont) - {} - - void operator()(Node &n) - { this->icont_.push_back(n); } -}; - -}//namespace container_detail { - -namespace container_detail { - -template< class NodeType, class NodeCompareType - , class SizeType, class HookType - , boost::container::tree_type_enum tree_type_value> -struct intrusive_tree_dispatch; - -template -struct intrusive_tree_dispatch - -{ - typedef typename container_detail::bi::make_rbtree - - ,container_detail::bi::base_hook - ,container_detail::bi::constant_time_size - ,container_detail::bi::size_type - >::type type; -}; - -template -struct intrusive_tree_dispatch - -{ - typedef typename container_detail::bi::make_avltree - - ,container_detail::bi::base_hook - ,container_detail::bi::constant_time_size - ,container_detail::bi::size_type - >::type type; -}; - -template -struct intrusive_tree_dispatch - -{ - typedef typename container_detail::bi::make_sgtree - - ,container_detail::bi::base_hook - ,container_detail::bi::floating_point - ,container_detail::bi::size_type - >::type type; -}; - -template -struct intrusive_tree_dispatch - -{ - typedef typename container_detail::bi::make_splaytree - - ,container_detail::bi::base_hook - ,container_detail::bi::constant_time_size - ,container_detail::bi::size_type - >::type type; -}; - -template -struct intrusive_tree_type -{ - private: - typedef typename boost::container:: - allocator_traits::value_type value_type; - typedef typename boost::container:: - allocator_traits::void_pointer void_pointer; - typedef typename boost::container:: - allocator_traits::size_type size_type; - typedef typename container_detail::tree_node - < value_type, void_pointer - , tree_type_value, OptimizeSize> node_type; - typedef node_compare node_compare_type; - //Deducing the hook type from node_type (e.g. node_type::hook_type) would - //provoke an early instantiation of node_type that could ruin recursive - //tree definitions, so retype the complete type to avoid any problem. - typedef typename intrusive_tree_hook - ::type hook_type; - public: - typedef typename intrusive_tree_dispatch - < node_type, node_compare_type - , size_type, hook_type - , tree_type_value>::type type; -}; - -//Trait to detect manually rebalanceable tree types -template -struct is_manually_balanceable -{ static const bool value = true; }; - -template<> struct is_manually_balanceable -{ static const bool value = false; }; - -template<> struct is_manually_balanceable -{ static const bool value = false; }; - -//Proxy traits to implement different operations depending on the -//is_manually_balanceable<>::value -template< boost::container::tree_type_enum tree_type_value - , bool IsManuallyRebalanceable = is_manually_balanceable::value> -struct intrusive_tree_proxy -{ - template - static void rebalance(Icont &) {} -}; - -template -struct intrusive_tree_proxy -{ - template - static void rebalance(Icont &c) - { c.rebalance(); } -}; - -} //namespace container_detail { - -namespace container_detail { - -//This functor will be used with Intrusive clone functions to obtain -//already allocated nodes from a intrusive container instead of -//allocating new ones. When the intrusive container runs out of nodes -//the node holder is used instead. -template -class RecyclingCloner -{ - typedef typename AllocHolder::intrusive_container intrusive_container; - typedef typename AllocHolder::Node node_type; - typedef typename AllocHolder::NodePtr node_ptr_type; - - public: - RecyclingCloner(AllocHolder &holder, intrusive_container &itree) - : m_holder(holder), m_icont(itree) - {} - - static void do_assign(node_ptr_type &p, const node_type &other, bool_) - { p->do_assign(other.m_data); } - - static void do_assign(node_ptr_type &p, const node_type &other, bool_) - { p->do_move_assign(const_cast(other).m_data); } - - node_ptr_type operator()(const node_type &other) const - { - if(node_ptr_type p = m_icont.unlink_leftmost_without_rebalance()){ - //First recycle a node (this can't throw) - BOOST_TRY{ - //This can throw - this->do_assign(p, other, bool_()); - return p; - } - BOOST_CATCH(...){ - //If there is an exception destroy the whole source - m_holder.destroy_node(p); - while((p = m_icont.unlink_leftmost_without_rebalance())){ - m_holder.destroy_node(p); - } - BOOST_RETHROW - } - BOOST_CATCH_END - } - else{ - return m_holder.create_node(other.m_data); - } - } - - AllocHolder &m_holder; - intrusive_container &m_icont; -}; - -template -//where KeyValueCompare is tree_value_compare -struct key_node_compare - : private KeyValueCompare -{ - explicit key_node_compare(const KeyValueCompare &comp) - : KeyValueCompare(comp) - {} - - template - struct is_node - { - static const bool value = is_same::value; - }; - - template - typename enable_if_c::value, const typename KeyValueCompare::value_type &>::type - key_forward(const T &node) const - { return node.get_data(); } - - template - typename enable_if_c::value, const T &>::type - key_forward(const T &key) const - { return key; } - - template - bool operator()(const KeyType &key1, const KeyType2 &key2) const - { return KeyValueCompare::operator()(this->key_forward(key1), this->key_forward(key2)); } -}; - -template -class tree - : protected container_detail::node_alloc_holder - < A - , typename container_detail::intrusive_tree_type - < A, tree_value_compare //ValComp - , Options::tree_type, Options::optimize_size>::type - > -{ - typedef tree_value_compare - ValComp; - typedef typename container_detail::intrusive_tree_type - < A, ValComp, Options::tree_type - , Options::optimize_size>::type Icont; - typedef container_detail::node_alloc_holder - AllocHolder; - typedef typename AllocHolder::NodePtr NodePtr; - typedef tree < Key, Value, KeyOfValue - , KeyCompare, A, Options> ThisType; - typedef typename AllocHolder::NodeAlloc NodeAlloc; - typedef typename AllocHolder::ValAlloc ValAlloc; - typedef typename AllocHolder::Node Node; - typedef typename Icont::iterator iiterator; - typedef typename Icont::const_iterator iconst_iterator; - typedef container_detail::allocator_destroyer Destroyer; - typedef typename AllocHolder::allocator_v1 allocator_v1; - typedef typename AllocHolder::allocator_v2 allocator_v2; - typedef typename AllocHolder::alloc_version alloc_version; - typedef intrusive_tree_proxy intrusive_tree_proxy_t; - - BOOST_COPYABLE_AND_MOVABLE(tree) - - public: - - typedef Key key_type; - typedef Value value_type; - typedef A allocator_type; - typedef KeyCompare key_compare; - typedef ValComp value_compare; - typedef typename boost::container:: - allocator_traits::pointer pointer; - typedef typename boost::container:: - allocator_traits::const_pointer const_pointer; - typedef typename boost::container:: - allocator_traits::reference reference; - typedef typename boost::container:: - allocator_traits::const_reference const_reference; - typedef typename boost::container:: - allocator_traits::size_type size_type; - typedef typename boost::container:: - allocator_traits::difference_type difference_type; - typedef difference_type tree_difference_type; - typedef pointer tree_pointer; - typedef const_pointer tree_const_pointer; - typedef reference tree_reference; - typedef const_reference tree_const_reference; - typedef NodeAlloc stored_allocator_type; - - private: - - typedef key_node_compare KeyNodeCompare; - - public: - typedef container_detail::iterator iterator; - typedef container_detail::iterator const_iterator; - typedef container_detail::reverse_iterator reverse_iterator; - typedef container_detail::reverse_iterator const_reverse_iterator; - - tree() - : AllocHolder(ValComp(key_compare())) - {} - - explicit tree(const key_compare& comp, const allocator_type& a = allocator_type()) - : AllocHolder(a, ValComp(comp)) - {} - - explicit tree(const allocator_type& a) - : AllocHolder(a) - {} - - template - tree(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::value - || container_detail::is_same::value - >::type * = 0 - #endif - ) - : AllocHolder(a, value_compare(comp)) - { - //Use cend() as hint to achieve linear time for - //ordered ranges as required by the standard - //for the constructor - const const_iterator end_it(this->cend()); - if(unique_insertion){ - for ( ; first != last; ++first){ - this->insert_unique(end_it, *first); - } - } - else{ - for ( ; first != last; ++first){ - this->insert_equal(end_it, *first); - } - } - } - - template - tree(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::value - || container_detail::is_same::value) - >::type * = 0 - #endif - ) - : AllocHolder(a, value_compare(comp)) - { - if(unique_insertion){ - //Use cend() as hint to achieve linear time for - //ordered ranges as required by the standard - //for the constructor - const const_iterator end_it(this->cend()); - for ( ; first != last; ++first){ - this->insert_unique(end_it, *first); - } - } - else{ - //Optimized allocation and construction - this->allocate_many_and_construct - ( first, std::distance(first, last) - , insert_equal_end_hint_functor(this->icont())); - } - } - - template - tree( 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::value - || container_detail::is_same::value - >::type * = 0 - #endif - ) - : AllocHolder(a, value_compare(comp)) - { - for ( ; first != last; ++first){ - this->push_back_impl(*first); - } - } - - template - tree( 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::value - || container_detail::is_same::value) - >::type * = 0 - #endif - ) - : AllocHolder(a, value_compare(comp)) - { - //Optimized allocation and construction - this->allocate_many_and_construct - ( first, std::distance(first, last) - , container_detail::push_back_functor(this->icont())); - } - - tree(const tree& x) - : AllocHolder(x, x.value_comp()) - { - this->icont().clone_from - (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc())); - } - - tree(BOOST_RV_REF(tree) x) - : AllocHolder(::boost::move(static_cast(x)), x.value_comp()) - {} - - tree(const tree& x, const allocator_type &a) - : AllocHolder(a, x.value_comp()) - { - this->icont().clone_from - (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc())); - } - - tree(BOOST_RV_REF(tree) x, const allocator_type &a) - : AllocHolder(a, x.value_comp()) - { - if(this->node_alloc() == x.node_alloc()){ - this->icont().swap(x.icont()); - } - else{ - this->icont().clone_from - (x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc())); - } - } - - ~tree() - {} //AllocHolder clears the tree - - tree& operator=(BOOST_COPY_ASSIGN_REF(tree) x) - { - if (&x != this){ - NodeAlloc &this_alloc = this->get_stored_allocator(); - const NodeAlloc &x_alloc = x.get_stored_allocator(); - container_detail::bool_:: - propagate_on_container_copy_assignment::value> flag; - if(flag && this_alloc != x_alloc){ - this->clear(); - } - this->AllocHolder::copy_assign_alloc(x); - //Transfer all the nodes to a temporary tree - //If anything goes wrong, all the nodes will be destroyed - //automatically - Icont other_tree(::boost::move(this->icont())); - - //Now recreate the source tree reusing nodes stored by other_tree - this->icont().clone_from - (x.icont() - , RecyclingCloner(*this, other_tree) - , Destroyer(this->node_alloc())); - - //If there are remaining nodes, destroy them - NodePtr p; - while((p = other_tree.unlink_leftmost_without_rebalance())){ - AllocHolder::destroy_node(p); - } - } - return *this; - } - - tree& operator=(BOOST_RV_REF(tree) x) - { - BOOST_ASSERT(this != &x); - NodeAlloc &this_alloc = this->node_alloc(); - NodeAlloc &x_alloc = x.node_alloc(); - const bool propagate_alloc = allocator_traits:: - propagate_on_container_move_assignment::value; - const bool allocators_equal = this_alloc == x_alloc; (void)allocators_equal; - //Resources can be transferred if both allocators are - //going to be equal after this function (either propagated or already equal) - if(propagate_alloc || allocators_equal){ - //Destroy - this->clear(); - //Move allocator if needed - this->AllocHolder::move_assign_alloc(x); - //Obtain resources - this->icont() = boost::move(x.icont()); - } - //Else do a one by one move - else{ - //Transfer all the nodes to a temporary tree - //If anything goes wrong, all the nodes will be destroyed - //automatically - Icont other_tree(::boost::move(this->icont())); - - //Now recreate the source tree reusing nodes stored by other_tree - this->icont().clone_from - (x.icont() - , RecyclingCloner(*this, other_tree) - , Destroyer(this->node_alloc())); - - //If there are remaining nodes, destroy them - NodePtr p; - while((p = other_tree.unlink_leftmost_without_rebalance())){ - AllocHolder::destroy_node(p); - } - } - return *this; - } - - public: - // accessors: - value_compare value_comp() const - { return this->icont().value_comp().value_comp(); } - - key_compare key_comp() const - { return this->icont().value_comp().value_comp().key_comp(); } - - allocator_type get_allocator() const - { return allocator_type(this->node_alloc()); } - - const stored_allocator_type &get_stored_allocator() const - { return this->node_alloc(); } - - stored_allocator_type &get_stored_allocator() - { return this->node_alloc(); } - - iterator begin() - { return iterator(this->icont().begin()); } - - const_iterator begin() const - { return this->cbegin(); } - - iterator end() - { return iterator(this->icont().end()); } - - const_iterator end() const - { return this->cend(); } - - reverse_iterator rbegin() - { return reverse_iterator(end()); } - - const_reverse_iterator rbegin() const - { return this->crbegin(); } - - reverse_iterator rend() - { return reverse_iterator(begin()); } - - const_reverse_iterator rend() const - { return this->crend(); } - - //! Effects: Returns a const_iterator to the first element contained in the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cbegin() const - { return const_iterator(this->non_const_icont().begin()); } - - //! Effects: Returns a const_iterator to the end of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cend() const - { return const_iterator(this->non_const_icont().end()); } - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crbegin() const - { return const_reverse_iterator(cend()); } - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crend() const - { return const_reverse_iterator(cbegin()); } - - bool empty() const - { return !this->size(); } - - size_type size() const - { return this->icont().size(); } - - size_type max_size() const - { return AllocHolder::max_size(); } - - void swap(ThisType& x) - { AllocHolder::swap(x); } - - public: - - typedef typename Icont::insert_commit_data insert_commit_data; - - // insert/erase - std::pair insert_unique_check - (const key_type& key, insert_commit_data &data) - { - std::pair ret = - this->icont().insert_unique_check(key, KeyNodeCompare(value_comp()), data); - return std::pair(iterator(ret.first), ret.second); - } - - std::pair insert_unique_check - (const_iterator hint, const key_type& key, insert_commit_data &data) - { - std::pair ret = - this->icont().insert_unique_check(hint.get(), key, KeyNodeCompare(value_comp()), data); - return std::pair(iterator(ret.first), ret.second); - } - - iterator insert_unique_commit(const value_type& v, insert_commit_data &data) - { - NodePtr tmp = AllocHolder::create_node(v); - scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); - iterator ret(this->icont().insert_unique_commit(*tmp, data)); - destroy_deallocator.release(); - return ret; - } - - template - iterator insert_unique_commit - (BOOST_FWD_REF(MovableConvertible) mv, insert_commit_data &data) - { - NodePtr tmp = AllocHolder::create_node(boost::forward(mv)); - scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); - iterator ret(this->icont().insert_unique_commit(*tmp, data)); - destroy_deallocator.release(); - return ret; - } - - std::pair insert_unique(const value_type& v) - { - insert_commit_data data; - std::pair ret = - this->insert_unique_check(KeyOfValue()(v), data); - if(ret.second){ - ret.first = this->insert_unique_commit(v, data); - } - return ret; - } - - template - std::pair insert_unique(BOOST_FWD_REF(MovableConvertible) mv) - { - insert_commit_data data; - std::pair ret = - this->insert_unique_check(KeyOfValue()(mv), data); - if(ret.second){ - ret.first = this->insert_unique_commit(boost::forward(mv), data); - } - return ret; - } - - private: - - template - void push_back_impl(BOOST_FWD_REF(MovableConvertible) mv) - { - NodePtr tmp(AllocHolder::create_node(boost::forward(mv))); - //push_back has no-throw guarantee so avoid any deallocator/destroyer - this->icont().push_back(*tmp); - } - - std::pair emplace_unique_impl(NodePtr p) - { - value_type &v = p->get_data(); - insert_commit_data data; - scoped_destroy_deallocator destroy_deallocator(p, this->node_alloc()); - std::pair ret = - this->insert_unique_check(KeyOfValue()(v), data); - if(!ret.second){ - return ret; - } - //No throw insertion part, release rollback - destroy_deallocator.release(); - return std::pair - ( iterator(iiterator(this->icont().insert_unique_commit(*p, data))) - , true ); - } - - iterator emplace_unique_hint_impl(const_iterator hint, NodePtr p) - { - value_type &v = p->get_data(); - insert_commit_data data; - std::pair ret = - this->insert_unique_check(hint, KeyOfValue()(v), data); - if(!ret.second){ - Destroyer(this->node_alloc())(p); - return ret.first; - } - return iterator(iiterator(this->icont().insert_unique_commit(*p, data))); - } - - public: - - #ifdef BOOST_CONTAINER_PERFECT_FORWARDING - - template - std::pair emplace_unique(Args&&... args) - { return this->emplace_unique_impl(AllocHolder::create_node(boost::forward(args)...)); } - - template - iterator emplace_hint_unique(const_iterator hint, Args&&... args) - { return this->emplace_unique_hint_impl(hint, AllocHolder::create_node(boost::forward(args)...)); } - - template - iterator emplace_equal(Args&&... args) - { - NodePtr tmp(AllocHolder::create_node(boost::forward(args)...)); - scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); - iterator ret(this->icont().insert_equal(this->icont().end(), *tmp)); - destroy_deallocator.release(); - return ret; - } - - template - iterator emplace_hint_equal(const_iterator hint, Args&&... args) - { - NodePtr tmp(AllocHolder::create_node(boost::forward(args)...)); - scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); - iterator ret(this->icont().insert_equal(hint.get(), *tmp)); - destroy_deallocator.release(); - return ret; - } - - #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, >) \ - std::pair emplace_unique(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - return this->emplace_unique_impl \ - (AllocHolder::create_node(BOOST_PP_ENUM(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_hint_unique(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - return this->emplace_unique_hint_impl \ - (hint, AllocHolder::create_node(BOOST_PP_ENUM(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_equal(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - NodePtr tmp(AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ - scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); \ - iterator ret(this->icont().insert_equal(this->icont().end(), *tmp)); \ - destroy_deallocator.release(); \ - return ret; \ - } \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace_hint_equal(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - NodePtr tmp(AllocHolder::create_node(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \ - scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); \ - iterator ret(this->icont().insert_equal(hint.get(), *tmp)); \ - destroy_deallocator.release(); \ - return ret; \ - } \ - //! - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() - - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING - - iterator insert_unique(const_iterator hint, const value_type& v) - { - insert_commit_data data; - std::pair ret = - this->insert_unique_check(hint, KeyOfValue()(v), data); - if(!ret.second) - return ret.first; - return this->insert_unique_commit(v, data); - } - - template - iterator insert_unique(const_iterator hint, BOOST_FWD_REF(MovableConvertible) mv) - { - insert_commit_data data; - std::pair ret = - this->insert_unique_check(hint, KeyOfValue()(mv), data); - if(!ret.second) - return ret.first; - return this->insert_unique_commit(boost::forward(mv), data); - } - - template - void insert_unique(InputIterator first, InputIterator last) - { - for( ; first != last; ++first) - this->insert_unique(*first); - } - - iterator insert_equal(const value_type& v) - { - NodePtr tmp(AllocHolder::create_node(v)); - scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); - iterator ret(this->icont().insert_equal(this->icont().end(), *tmp)); - destroy_deallocator.release(); - return ret; - } - - template - iterator insert_equal(BOOST_FWD_REF(MovableConvertible) mv) - { - NodePtr tmp(AllocHolder::create_node(boost::forward(mv))); - scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); - iterator ret(this->icont().insert_equal(this->icont().end(), *tmp)); - destroy_deallocator.release(); - return ret; - } - - iterator insert_equal(const_iterator hint, const value_type& v) - { - NodePtr tmp(AllocHolder::create_node(v)); - scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); - iterator ret(this->icont().insert_equal(hint.get(), *tmp)); - destroy_deallocator.release(); - return ret; - } - - template - iterator insert_equal(const_iterator hint, BOOST_FWD_REF(MovableConvertible) mv) - { - NodePtr tmp(AllocHolder::create_node(boost::forward(mv))); - scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); - iterator ret(this->icont().insert_equal(hint.get(), *tmp)); - destroy_deallocator.release(); - return ret; - } - - template - void insert_equal(InputIterator first, InputIterator last) - { - for( ; first != last; ++first) - this->insert_equal(*first); - } - - iterator erase(const_iterator position) - { return iterator(this->icont().erase_and_dispose(position.get(), Destroyer(this->node_alloc()))); } - - size_type erase(const key_type& k) - { return AllocHolder::erase_key(k, KeyNodeCompare(value_comp()), alloc_version()); } - - iterator erase(const_iterator first, const_iterator last) - { return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); } - - void clear() - { AllocHolder::clear(alloc_version()); } - - // search operations. Const and non-const overloads even if no iterator is returned - // so splay implementations can to their rebalancing when searching in non-const versions - iterator find(const key_type& k) - { return iterator(this->icont().find(k, KeyNodeCompare(value_comp()))); } - - const_iterator find(const key_type& k) const - { return const_iterator(this->non_const_icont().find(k, KeyNodeCompare(value_comp()))); } - - size_type count(const key_type& k) const - { return size_type(this->icont().count(k, KeyNodeCompare(value_comp()))); } - - iterator lower_bound(const key_type& k) - { return iterator(this->icont().lower_bound(k, KeyNodeCompare(value_comp()))); } - - const_iterator lower_bound(const key_type& k) const - { return const_iterator(this->non_const_icont().lower_bound(k, KeyNodeCompare(value_comp()))); } - - iterator upper_bound(const key_type& k) - { return iterator(this->icont().upper_bound(k, KeyNodeCompare(value_comp()))); } - - const_iterator upper_bound(const key_type& k) const - { return const_iterator(this->non_const_icont().upper_bound(k, KeyNodeCompare(value_comp()))); } - - std::pair equal_range(const key_type& k) - { - std::pair ret = - this->icont().equal_range(k, KeyNodeCompare(value_comp())); - return std::pair(iterator(ret.first), iterator(ret.second)); - } - - std::pair equal_range(const key_type& k) const - { - std::pair ret = - this->non_const_icont().equal_range(k, KeyNodeCompare(value_comp())); - return std::pair - (const_iterator(ret.first), const_iterator(ret.second)); - } - - std::pair lower_bound_range(const key_type& k) - { - std::pair ret = - this->icont().lower_bound_range(k, KeyNodeCompare(value_comp())); - return std::pair(iterator(ret.first), iterator(ret.second)); - } - - std::pair lower_bound_range(const key_type& k) const - { - std::pair ret = - this->non_const_icont().lower_bound_range(k, KeyNodeCompare(value_comp())); - return std::pair - (const_iterator(ret.first), const_iterator(ret.second)); - } - - void rebalance() - { intrusive_tree_proxy_t::rebalance(this->icont()); } - - friend bool operator==(const tree& x, const tree& y) - { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); } - - friend bool operator<(const tree& x, const tree& y) - { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } - - friend bool operator!=(const tree& x, const tree& y) - { return !(x == y); } - - friend bool operator>(const tree& x, const tree& y) - { return y < x; } - - friend bool operator<=(const tree& x, const tree& y) - { return !(y < x); } - - friend bool operator>=(const tree& x, const tree& y) - { return !(x < y); } - - friend void swap(tree& x, tree& y) - { x.swap(y); } -}; - -} //namespace container_detail { -} //namespace container { -/* -//!has_trivial_destructor_after_move<> == true_type -//!specialization for optimizations -template -struct has_trivial_destructor_after_move - > -{ - static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value; -}; -*/ -} //namespace boost { - -#include - -#endif //BOOST_CONTAINER_TREE_HPP diff --git a/boost/container/detail/type_traits.hpp b/boost/container/detail/type_traits.hpp index 9ff3614..e02709a 100644 --- a/boost/container/detail/type_traits.hpp +++ b/boost/container/detail/type_traits.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // (C) Copyright John Maddock 2000. -// (C) Copyright Ion Gaztanaga 2005-2013. +// (C) Copyright Ion Gaztanaga 2005-2015. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -8,230 +8,61 @@ // // See http://www.boost.org/libs/container for documentation. // -// The alignment_of implementation comes from John Maddock's boost::alignment_of code +// The alignment and Type traits implementation comes from +// John Maddock's TypeTraits library. // +// Some other tricks come from Howard Hinnant's papers and StackOverflow replies ////////////////////////////////////////////////////////////////////////////// - #ifndef BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP #define BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif -#include -#include +#include namespace boost { namespace container { namespace container_detail { -struct nat{}; +using ::boost::move_detail::is_same; +using ::boost::move_detail::is_different; +using ::boost::move_detail::is_pointer; +using ::boost::move_detail::add_reference; +using ::boost::move_detail::add_const; +using ::boost::move_detail::add_const_reference; +using ::boost::move_detail::remove_const; +using ::boost::move_detail::remove_reference; +using ::boost::move_detail::make_unsigned; +using ::boost::move_detail::is_floating_point; +using ::boost::move_detail::is_integral; +using ::boost::move_detail::is_enum; +using ::boost::move_detail::is_pod; +using ::boost::move_detail::is_empty; +using ::boost::move_detail::is_trivially_destructible; +using ::boost::move_detail::is_trivially_default_constructible; +using ::boost::move_detail::is_trivially_copy_constructible; +using ::boost::move_detail::is_trivially_move_constructible; +using ::boost::move_detail::is_trivially_copy_assignable; +using ::boost::move_detail::is_trivially_move_assignable; +using ::boost::move_detail::is_nothrow_default_constructible; +using ::boost::move_detail::is_nothrow_copy_constructible; +using ::boost::move_detail::is_nothrow_move_constructible; +using ::boost::move_detail::is_nothrow_copy_assignable; +using ::boost::move_detail::is_nothrow_move_assignable; +using ::boost::move_detail::is_nothrow_swappable; +using ::boost::move_detail::alignment_of; +using ::boost::move_detail::aligned_storage; +using ::boost::move_detail::nat; +using ::boost::move_detail::max_align_t; -template -struct LowPriorityConversion -{ - // Convertible from T with user-defined-conversion rank. - LowPriorityConversion(const U&) { } -}; - -//boost::alignment_of yields to 10K lines of preprocessed code, so we -//need an alternative -template struct alignment_of; - -template -struct alignment_of_hack -{ - char c; - T t; - alignment_of_hack(); -}; - -template -struct alignment_logic -{ - enum{ value = A < S ? A : S }; -}; - -template< typename T > -struct alignment_of -{ - enum{ value = alignment_logic - < sizeof(alignment_of_hack) - sizeof(T) - , sizeof(T)>::value }; -}; - -//This is not standard, but should work with all compilers -union max_align -{ - char char_; - short short_; - int int_; - long long_; - #ifdef BOOST_HAS_LONG_LONG - long long long_long_; - #endif - float float_; - double double_; - long double long_double_; - void * void_ptr_; -}; - -template -struct remove_reference -{ - typedef T type; -}; - -template -struct remove_reference -{ - typedef T type; -}; - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - -template -struct remove_reference -{ - typedef T type; -}; - -#else - -} // namespace container_detail { -} //namespace container { - -template -class rv; - -namespace container { -namespace container_detail { - -template -struct remove_reference< ::boost::rv > -{ - typedef T type; -}; - -#endif - -template -struct is_reference -{ - enum { value = false }; -}; - -template -struct is_reference -{ - enum { value = true }; -}; - -template -struct is_pointer -{ - enum { value = false }; -}; - -template -struct is_pointer -{ - enum { value = true }; -}; - -template -struct add_reference -{ - typedef T& type; -}; - -template -struct add_reference -{ - typedef T& type; -}; - -template<> -struct add_reference -{ - typedef nat &type; -}; - -template<> -struct add_reference -{ - typedef const nat &type; -}; - -template -struct add_const_reference -{ typedef const T &type; }; - -template -struct add_const_reference -{ typedef T& type; }; - -template -struct add_const -{ typedef const T type; }; - -template -struct is_same -{ - typedef char yes_type; - struct no_type - { - char padding[8]; - }; - - template - static yes_type is_same_tester(V*, V*); - static no_type is_same_tester(...); - - static T *t; - static U *u; - - static const bool value = sizeof(yes_type) == sizeof(is_same_tester(t,u)); -}; - -template -struct remove_const -{ - typedef T type; -}; - -template -struct remove_const< const T> -{ - typedef T type; -}; - -template -struct remove_ref_const -{ - typedef typename remove_const< typename remove_reference::type >::type type; -}; - -template -struct make_unsigned -{ - typedef T type; -}; - -template <> struct make_unsigned {}; -template <> struct make_unsigned {typedef unsigned char type;}; -template <> struct make_unsigned {typedef unsigned short type;}; -template <> struct make_unsigned {typedef unsigned int type;}; -template <> struct make_unsigned {typedef unsigned long type;}; -#ifdef BOOST_HAS_LONG_LONG -template <> struct make_unsigned {typedef unsigned long long type;}; -#endif - -} // namespace container_detail +} //namespace container_detail { } //namespace container { } //namespace boost { -#include - #endif //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP diff --git a/boost/container/detail/value_init.hpp b/boost/container/detail/value_init.hpp index 68f9678..eb4c976 100644 --- a/boost/container/detail/value_init.hpp +++ b/boost/container/detail/value_init.hpp @@ -13,7 +13,11 @@ #ifndef BOOST_CONTAINER_DETAIL_VALUE_INIT_HPP #define BOOST_CONTAINER_DETAIL_VALUE_INIT_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/variadic_templates_tools.hpp b/boost/container/detail/variadic_templates_tools.hpp index b07fe30..ec8b8ce 100644 --- a/boost/container/detail/variadic_templates_tools.hpp +++ b/boost/container/detail/variadic_templates_tools.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP #define BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/detail/version_type.hpp b/boost/container/detail/version_type.hpp index 2eabc62..a20b3ee 100644 --- a/boost/container/detail/version_type.hpp +++ b/boost/container/detail/version_type.hpp @@ -16,7 +16,11 @@ #ifndef BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP #define BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -30,8 +34,6 @@ namespace boost{ namespace container { namespace container_detail { -//using namespace boost; - template struct version_type : public container_detail::integral_constant @@ -95,6 +97,11 @@ struct is_version }; } //namespace container_detail { + +typedef container_detail::integral_constant version_0; +typedef container_detail::integral_constant version_1; +typedef container_detail::integral_constant version_2; + } //namespace container { } //namespace boost{ diff --git a/boost/container/detail/workaround.hpp b/boost/container/detail/workaround.hpp index 55ebe33..026e65d 100644 --- a/boost/container/detail/workaround.hpp +++ b/boost/container/detail/workaround.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP #define BOOST_CONTAINER_DETAIL_WORKAROUND_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -22,18 +26,6 @@ #define BOOST_CONTAINER_PERFECT_FORWARDING #endif -#if defined(BOOST_NO_CXX11_NOEXCEPT) - #if defined(BOOST_MSVC) - #define BOOST_CONTAINER_NOEXCEPT throw() - #else - #define BOOST_CONTAINER_NOEXCEPT - #endif - #define BOOST_CONTAINER_NOEXCEPT_IF(x) -#else - #define BOOST_CONTAINER_NOEXCEPT noexcept - #define BOOST_CONTAINER_NOEXCEPT_IF(x) noexcept(x) -#endif - #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && defined(__GXX_EXPERIMENTAL_CXX0X__)\ && (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ < 40700) #define BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST diff --git a/boost/container/flat_map.hpp b/boost/container/flat_map.hpp index e7ff31a..ef0e1cb 100644 --- a/boost/container/flat_map.hpp +++ b/boost/container/flat_map.hpp @@ -7,29 +7,41 @@ // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// - #ifndef BOOST_CONTAINER_FLAT_MAP_HPP #define BOOST_CONTAINER_FLAT_MAP_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include - -#include -#include -#include -#include -#include -#include -#include +// container #include +#include +#include //new_allocator #include +// container/detail +#include +#include +#include +#include //equal() +// move #include -#include #include +// move/detail +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif +#include +// intrusive +#include //pair +#include //less, equal +//others #include #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) @@ -88,7 +100,7 @@ static D force_copy(S s) //! \tparam Allocator is the allocator to allocate the value_types //! (e.g. allocator< std::pair > ). #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template , class Allocator = std::allocator< std::pair< Key, T> > > +template , class Allocator = new_allocator< std::pair< Key, T> > > #else template #endif @@ -115,6 +127,7 @@ class flat_map typedef typename impl_tree_t::value_type impl_value_type; typedef typename impl_tree_t::const_iterator impl_const_iterator; + typedef typename impl_tree_t::iterator impl_iterator; typedef typename impl_tree_t::allocator_type impl_allocator_type; typedef container_detail::flat_tree_value_compare < Compare @@ -128,6 +141,9 @@ class flat_map ::pointer>::reverse_iterator reverse_iterator_impl; typedef typename container_detail::get_flat_tree_iterators ::pointer>::const_reverse_iterator const_reverse_iterator_impl; + public: + typedef typename impl_tree_t::stored_allocator_type impl_stored_allocator_type; + private: #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED public: @@ -170,7 +186,7 @@ class flat_map flat_map() : m_flat_tree() { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -181,7 +197,7 @@ class flat_map explicit flat_map(const Compare& comp, const allocator_type& a = allocator_type()) : m_flat_tree(comp, container_detail::force(a)) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -191,7 +207,7 @@ class flat_map explicit flat_map(const allocator_type& a) : m_flat_tree(container_detail::force(a)) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -205,7 +221,20 @@ class flat_map const allocator_type& a = allocator_type()) : m_flat_tree(true, first, last, comp, container_detail::force(a)) { - //Allocator type must be std::pair + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } + + //! Effects: Constructs an empty flat_map using the specified + //! allocator, and inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! comp and otherwise N logN, where N is last - first. + template + flat_map(InputIterator first, InputIterator last, const allocator_type& a) + : m_flat_tree(true, first, last, Compare(), container_detail::force(a)) + { + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -224,7 +253,7 @@ class flat_map , const Compare& comp = Compare(), const allocator_type& a = allocator_type()) : m_flat_tree(ordered_range, first, last, comp, a) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -238,7 +267,19 @@ class flat_map const allocator_type& a = allocator_type()) : m_flat_tree(true, il.begin(), il.end(), comp, container_detail::force(a)) { - //Allocator type must be std::pair + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } + + //! Effects: Constructs an empty flat_map using the specified + //! allocator, and inserts elements from the range [il.begin() ,il.end()). + //! + //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using + //! comp and otherwise N logN, where N is last - first. + flat_map(std::initializer_list il, const allocator_type& a) + : m_flat_tree(true, il.begin(), il.end(), Compare(), container_detail::force(a)) + { + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -256,7 +297,7 @@ class flat_map const allocator_type& a = allocator_type()) : m_flat_tree(ordered_range, il.begin(), il.end(), comp, a) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } #endif @@ -267,7 +308,7 @@ class flat_map flat_map(const flat_map& x) : m_flat_tree(x.m_flat_tree) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -280,7 +321,7 @@ class flat_map flat_map(BOOST_RV_REF(flat_map) x) : m_flat_tree(boost::move(x.m_flat_tree)) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -290,7 +331,7 @@ class flat_map flat_map(const flat_map& x, const allocator_type &a) : m_flat_tree(x.m_flat_tree, a) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -301,7 +342,7 @@ class flat_map flat_map(BOOST_RV_REF(flat_map) x, const allocator_type &a) : m_flat_tree(boost::move(x.m_flat_tree), a) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -321,7 +362,8 @@ class flat_map //! propagate_on_container_move_assignment is true or //! this->get>allocator() == x.get_allocator(). Linear otherwise. flat_map& operator=(BOOST_RV_REF(flat_map) x) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_move_assignable::value ) { m_flat_tree = boost::move(x.m_flat_tree); return *this; } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) @@ -334,11 +376,11 @@ class flat_map } #endif - //! Effects: Returns a copy of the Allocator that + //! Effects: Returns a copy of the allocator that //! was passed to the object's constructor. //! //! Complexity: Constant. - allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT + allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.get_allocator()); } //! Effects: Returns a reference to the internal allocator. @@ -348,7 +390,7 @@ class flat_map //! Complexity: Constant. //! //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT + stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force(m_flat_tree.get_stored_allocator()); } //! Effects: Returns a reference to the internal allocator. @@ -358,7 +400,7 @@ class flat_map //! Complexity: Constant. //! //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT + const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force(m_flat_tree.get_stored_allocator()); } ////////////////////////////////////////////// @@ -372,7 +414,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - iterator begin() BOOST_CONTAINER_NOEXCEPT + iterator begin() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.begin()); } //! Effects: Returns a const_iterator to the first element contained in the container. @@ -380,7 +422,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator begin() const BOOST_CONTAINER_NOEXCEPT + const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.begin()); } //! Effects: Returns an iterator to the end of the container. @@ -388,7 +430,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - iterator end() BOOST_CONTAINER_NOEXCEPT + iterator end() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.end()); } //! Effects: Returns a const_iterator to the end of the container. @@ -396,7 +438,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator end() const BOOST_CONTAINER_NOEXCEPT + const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.end()); } //! Effects: Returns a reverse_iterator pointing to the beginning @@ -405,7 +447,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT + reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rbegin()); } //! Effects: Returns a const_reverse_iterator pointing to the beginning @@ -414,7 +456,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rbegin()); } //! Effects: Returns a reverse_iterator pointing to the end @@ -423,7 +465,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT + reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rend()); } //! Effects: Returns a const_reverse_iterator pointing to the end @@ -432,7 +474,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rend()); } //! Effects: Returns a const_iterator to the first element contained in the container. @@ -440,7 +482,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT + const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.cbegin()); } //! Effects: Returns a const_iterator to the end of the container. @@ -448,7 +490,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT + const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.cend()); } //! Effects: Returns a const_reverse_iterator pointing to the beginning @@ -457,7 +499,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.crbegin()); } //! Effects: Returns a const_reverse_iterator pointing to the end @@ -466,7 +508,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.crend()); } ////////////////////////////////////////////// @@ -480,7 +522,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - bool empty() const BOOST_CONTAINER_NOEXCEPT + bool empty() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.empty(); } //! Effects: Returns the number of the elements contained in the container. @@ -488,7 +530,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - size_type size() const BOOST_CONTAINER_NOEXCEPT + size_type size() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.size(); } //! Effects: Returns the largest possible size of the container. @@ -496,7 +538,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - size_type max_size() const BOOST_CONTAINER_NOEXCEPT + size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.max_size(); } //! Effects: Number of elements for which memory has been allocated. @@ -505,7 +547,7 @@ class flat_map //! Throws: Nothing. //! //! Complexity: Constant. - size_type capacity() const BOOST_CONTAINER_NOEXCEPT + size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.capacity(); } //! Effects: If n is less than or equal to capacity(), this call has no @@ -539,7 +581,7 @@ class flat_map //! Effects: If there is no key equivalent to x in the flat_map, inserts //! value_type(x, T()) into the flat_map. //! - //! Returns: Allocator reference to the mapped_type corresponding to x in *this. + //! Returns: A reference to the mapped_type corresponding to x in *this. //! //! Complexity: Logarithmic. mapped_type &operator[](const key_type& k); @@ -547,7 +589,7 @@ class flat_map //! Effects: If there is no key equivalent to x in the flat_map, inserts //! value_type(move(x), T()) into the flat_map (the key is move-constructed) //! - //! Returns: Allocator reference to the mapped_type corresponding to x in *this. + //! Returns: A reference to the mapped_type corresponding to x in *this. //! //! Complexity: Logarithmic. mapped_type &operator[](key_type &&k) ; @@ -556,7 +598,23 @@ class flat_map BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript) #endif - //! Returns: Allocator reference to the element whose key is equivalent to x. + //! @copydoc ::boost::container::flat_set::nth(size_type) + iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW + { return container_detail::force_copy(m_flat_tree.nth(n)); } + + //! @copydoc ::boost::container::flat_set::nth(size_type) const + const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW + { return container_detail::force_copy(m_flat_tree.nth(n)); } + + //! @copydoc ::boost::container::flat_set::index_of(iterator) + size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW + { return m_flat_tree.index_of(container_detail::force_copy(p)); } + + //! @copydoc ::boost::container::flat_set::index_of(const_iterator) const + size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW + { return m_flat_tree.index_of(container_detail::force_copy(p)); } + + //! Returns: A reference to the element whose key is equivalent to x. //! //! Throws: An exception object of type out_of_range if no such element is present. //! @@ -570,7 +628,7 @@ class flat_map return i->second; } - //! Returns: Allocator reference to the element whose key is equivalent to x. + //! Returns: A reference to the element whose key is equivalent to x. //! //! Throws: An exception object of type out_of_range if no such element is present. //! @@ -590,7 +648,7 @@ class flat_map // ////////////////////////////////////////////// - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! Effects: Inserts an object x of type T constructed with //! std::forward(args)... if and only if there is no element in the container @@ -605,7 +663,7 @@ class flat_map //! //! Note: If an element is inserted it might invalidate elements. template - std::pair emplace(Args&&... args) + std::pair emplace(BOOST_FWD_REF(Args)... args) { return container_detail::force_copy< std::pair >(m_flat_tree.emplace_unique(boost::forward(args)...)); } //! Effects: Inserts an object of type T constructed with @@ -621,32 +679,34 @@ class flat_map //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace_hint(const_iterator hint, Args&&... args) + iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) { return container_detail::force_copy (m_flat_tree.emplace_hint_unique( container_detail::force_copy(hint) , boost::forward(args)...)); } - #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - #define BOOST_PP_LOCAL_MACRO(n) \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - std::pair emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return container_detail::force_copy< std::pair > \ - (m_flat_tree.emplace_unique(BOOST_PP_ENUM(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_hint(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return container_detail::force_copy(m_flat_tree.emplace_hint_unique \ - (container_detail::force_copy(hint) \ - 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() + #define BOOST_CONTAINER_FLAT_MAP_EMPLACE_CODE(N) \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + std::pair emplace(BOOST_MOVE_UREF##N)\ + {\ + return container_detail::force_copy< std::pair >\ + (m_flat_tree.emplace_unique(BOOST_MOVE_FWD##N));\ + }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + return container_detail::force_copy(m_flat_tree.emplace_hint_unique\ + (container_detail::force_copy(hint) BOOST_MOVE_I##N BOOST_MOVE_FWD##N));\ + }\ + // + BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_MAP_EMPLACE_CODE) + #undef BOOST_CONTAINER_FLAT_MAP_EMPLACE_CODE - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) //! Effects: Inserts x if and only if there is no element in the container //! with key equivalent to the key of x. @@ -660,7 +720,7 @@ class flat_map //! //! Note: If an element is inserted it might invalidate elements. std::pair insert(const value_type& x) - { return container_detail::force_copy >( + { return container_detail::force_copy >( m_flat_tree.insert_unique(container_detail::force(x))); } //! Effects: Inserts a new value_type move constructed from the pair if and @@ -850,6 +910,8 @@ class flat_map //! //! Complexity: Constant. void swap(flat_map& x) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_swappable::value ) { m_flat_tree.swap(x.m_flat_tree); } //! Effects: erase(a.begin(),a.end()). @@ -857,7 +919,7 @@ class flat_map //! Postcondition: size() == 0. //! //! Complexity: linear in size(). - void clear() BOOST_CONTAINER_NOEXCEPT + void clear() BOOST_NOEXCEPT_OR_NOTHROW { m_flat_tree.clear(); } ////////////////////////////////////////////// @@ -893,7 +955,7 @@ class flat_map iterator find(const key_type& x) { return container_detail::force_copy(m_flat_tree.find(x)); } - //! Returns: Allocator const_iterator pointing to an element with the key + //! Returns: A const_iterator pointing to an element with the key //! equivalent to x, or end() if such an element is not found. //! //! Complexity: Logarithmic.s @@ -913,7 +975,7 @@ class flat_map iterator lower_bound(const key_type& x) { return container_detail::force_copy(m_flat_tree.lower_bound(x)); } - //! Returns: Allocator const iterator pointing to the first element with key not + //! Returns: A const iterator pointing to the first element with key not //! less than k, or a.end() if such an element is not found. //! //! Complexity: Logarithmic @@ -927,7 +989,7 @@ class flat_map iterator upper_bound(const key_type& x) { return container_detail::force_copy(m_flat_tree.upper_bound(x)); } - //! Returns: Allocator const iterator pointing to the first element with key not + //! Returns: A const iterator pointing to the first element with key not //! less than x, or end() if such an element is not found. //! //! Complexity: Logarithmic @@ -950,7 +1012,7 @@ class flat_map //! //! Complexity: Linear to the number of elements in the container. friend bool operator==(const flat_map& x, const flat_map& y) - { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); } + { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); } //! Effects: Returns true if x and y are unequal //! @@ -962,7 +1024,7 @@ class flat_map //! //! Complexity: Linear to the number of elements in the container. friend bool operator<(const flat_map& x, const flat_map& y) - { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + { return ::boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } //! Effects: Returns true if x is greater than y //! @@ -1020,10 +1082,13 @@ class flat_map //!has_trivial_destructor_after_move<> == true_type //!specialization for optimizations -template -struct has_trivial_destructor_after_move > +template +struct has_trivial_destructor_after_move > { - static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value; + typedef typename ::boost::container::allocator_traits::pointer pointer; + static const bool value = ::boost::has_trivial_destructor_after_move::value && + ::boost::has_trivial_destructor_after_move::value && + ::boost::has_trivial_destructor_after_move::value; }; namespace container { @@ -1060,7 +1125,7 @@ namespace container { //! \tparam Allocator is the allocator to allocate the value_types //! (e.g. allocator< std::pair > ). #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template , class Allocator = std::allocator< std::pair< Key, T> > > +template , class Allocator = new_allocator< std::pair< Key, T> > > #else template #endif @@ -1085,6 +1150,7 @@ class flat_multimap typedef typename impl_tree_t::value_type impl_value_type; typedef typename impl_tree_t::const_iterator impl_const_iterator; + typedef typename impl_tree_t::iterator impl_iterator; typedef typename impl_tree_t::allocator_type impl_allocator_type; typedef container_detail::flat_tree_value_compare < Compare @@ -1098,6 +1164,9 @@ class flat_multimap ::pointer>::reverse_iterator reverse_iterator_impl; typedef typename container_detail::get_flat_tree_iterators ::pointer>::const_reverse_iterator const_reverse_iterator_impl; + public: + typedef typename impl_tree_t::stored_allocator_type impl_stored_allocator_type; + private: #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED public: @@ -1139,7 +1208,7 @@ class flat_multimap flat_multimap() : m_flat_tree() { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -1151,7 +1220,7 @@ class flat_multimap const allocator_type& a = allocator_type()) : m_flat_tree(comp, container_detail::force(a)) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -1161,7 +1230,7 @@ class flat_multimap explicit flat_multimap(const allocator_type& a) : m_flat_tree(container_detail::force(a)) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -1176,7 +1245,20 @@ class flat_multimap const allocator_type& a = allocator_type()) : m_flat_tree(false, first, last, comp, container_detail::force(a)) { - //Allocator type must be std::pair + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } + + //! Effects: Constructs an empty flat_multimap using the specified + //! allocator, and inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! comp and otherwise N logN, where N is last - first. + template + flat_multimap(InputIterator first, InputIterator last, const allocator_type& a) + : m_flat_tree(false, first, last, Compare(), container_detail::force(a)) + { + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -1195,7 +1277,7 @@ class flat_multimap const allocator_type& a = allocator_type()) : m_flat_tree(ordered_range, first, last, comp, a) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -1208,7 +1290,19 @@ class flat_multimap flat_multimap(std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) : m_flat_tree(false, il.begin(), il.end(), comp, container_detail::force(a)) { - //Allocator type must be std::pair + //A type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } + + //! Effects: Constructs an empty flat_map using the specified + //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using + //! comp and otherwise N logN, where N is last - first. + flat_multimap(std::initializer_list il, const allocator_type& a) + : m_flat_tree(false, il.begin(), il.end(), Compare(), container_detail::force(a)) + { + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -1225,7 +1319,7 @@ class flat_multimap const allocator_type& a = allocator_type()) : m_flat_tree(ordered_range, il.begin(), il.end(), comp, a) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } #endif @@ -1236,7 +1330,7 @@ class flat_multimap flat_multimap(const flat_multimap& x) : m_flat_tree(x.m_flat_tree) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -1248,7 +1342,7 @@ class flat_multimap flat_multimap(BOOST_RV_REF(flat_multimap) x) : m_flat_tree(boost::move(x.m_flat_tree)) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -1258,7 +1352,7 @@ class flat_multimap flat_multimap(const flat_multimap& x, const allocator_type &a) : m_flat_tree(x.m_flat_tree, a) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -1269,7 +1363,7 @@ class flat_multimap flat_multimap(BOOST_RV_REF(flat_multimap) x, const allocator_type &a) : m_flat_tree(boost::move(x.m_flat_tree), a) { - //Allocator type must be std::pair + //A type must be std::pair BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); } @@ -1283,7 +1377,8 @@ class flat_multimap //! //! Complexity: Constant. flat_multimap& operator=(BOOST_RV_REF(flat_multimap) x) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_move_assignable::value ) { m_flat_tree = boost::move(x.m_flat_tree); return *this; } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) @@ -1298,11 +1393,11 @@ class flat_multimap } #endif - //! Effects: Returns a copy of the Allocator that + //! Effects: Returns a copy of the allocator that //! was passed to the object's constructor. //! //! Complexity: Constant. - allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT + allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.get_allocator()); } //! Effects: Returns a reference to the internal allocator. @@ -1312,7 +1407,7 @@ class flat_multimap //! Complexity: Constant. //! //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT + stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force(m_flat_tree.get_stored_allocator()); } //! Effects: Returns a reference to the internal allocator. @@ -1322,7 +1417,7 @@ class flat_multimap //! Complexity: Constant. //! //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT + const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force(m_flat_tree.get_stored_allocator()); } ////////////////////////////////////////////// @@ -1336,7 +1431,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - iterator begin() BOOST_CONTAINER_NOEXCEPT + iterator begin() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.begin()); } //! Effects: Returns a const_iterator to the first element contained in the container. @@ -1344,7 +1439,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator begin() const BOOST_CONTAINER_NOEXCEPT + const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.begin()); } //! Effects: Returns an iterator to the end of the container. @@ -1352,7 +1447,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - iterator end() BOOST_CONTAINER_NOEXCEPT + iterator end() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.end()); } //! Effects: Returns a const_iterator to the end of the container. @@ -1360,7 +1455,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator end() const BOOST_CONTAINER_NOEXCEPT + const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.end()); } //! Effects: Returns a reverse_iterator pointing to the beginning @@ -1369,7 +1464,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT + reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rbegin()); } //! Effects: Returns a const_reverse_iterator pointing to the beginning @@ -1378,7 +1473,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rbegin()); } //! Effects: Returns a reverse_iterator pointing to the end @@ -1387,7 +1482,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT + reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rend()); } //! Effects: Returns a const_reverse_iterator pointing to the end @@ -1396,7 +1491,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.rend()); } //! Effects: Returns a const_iterator to the first element contained in the container. @@ -1404,7 +1499,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT + const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.cbegin()); } //! Effects: Returns a const_iterator to the end of the container. @@ -1412,7 +1507,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT + const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.cend()); } //! Effects: Returns a const_reverse_iterator pointing to the beginning @@ -1421,7 +1516,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.crbegin()); } //! Effects: Returns a const_reverse_iterator pointing to the end @@ -1430,7 +1525,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::force_copy(m_flat_tree.crend()); } ////////////////////////////////////////////// @@ -1444,7 +1539,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - bool empty() const BOOST_CONTAINER_NOEXCEPT + bool empty() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.empty(); } //! Effects: Returns the number of the elements contained in the container. @@ -1452,7 +1547,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - size_type size() const BOOST_CONTAINER_NOEXCEPT + size_type size() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.size(); } //! Effects: Returns the largest possible size of the container. @@ -1460,7 +1555,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - size_type max_size() const BOOST_CONTAINER_NOEXCEPT + size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.max_size(); } //! Effects: Number of elements for which memory has been allocated. @@ -1469,7 +1564,7 @@ class flat_multimap //! Throws: Nothing. //! //! Complexity: Constant. - size_type capacity() const BOOST_CONTAINER_NOEXCEPT + size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW { return m_flat_tree.capacity(); } //! Effects: If n is less than or equal to capacity(), this call has no @@ -1493,13 +1588,23 @@ class flat_multimap void shrink_to_fit() { m_flat_tree.shrink_to_fit(); } - ////////////////////////////////////////////// - // - // modifiers - // - ////////////////////////////////////////////// + //! @copydoc ::boost::container::flat_set::nth(size_type) + iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW + { return container_detail::force_copy(m_flat_tree.nth(n)); } - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! @copydoc ::boost::container::flat_set::nth(size_type) const + const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW + { return container_detail::force_copy(m_flat_tree.nth(n)); } + + //! @copydoc ::boost::container::flat_set::index_of(iterator) + size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW + { return m_flat_tree.index_of(container_detail::force_copy(p)); } + + //! @copydoc ::boost::container::flat_set::index_of(const_iterator) const + size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW + { return m_flat_tree.index_of(container_detail::force_copy(p)); } + + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! Effects: Inserts an object of type T constructed with //! std::forward(args)... and returns the iterator pointing to the @@ -1510,7 +1615,7 @@ class flat_multimap //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace(Args&&... args) + iterator emplace(BOOST_FWD_REF(Args)... args) { return container_detail::force_copy(m_flat_tree.emplace_equal(boost::forward(args)...)); } //! Effects: Inserts an object of type T constructed with @@ -1526,31 +1631,30 @@ class flat_multimap //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace_hint(const_iterator hint, Args&&... args) + iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args) { return container_detail::force_copy(m_flat_tree.emplace_hint_equal (container_detail::force_copy(hint), boost::forward(args)...)); } - #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - #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(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return container_detail::force_copy(m_flat_tree.emplace_equal \ - (BOOST_PP_ENUM(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_hint(const_iterator hint \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return container_detail::force_copy(m_flat_tree.emplace_hint_equal \ - (container_detail::force_copy(hint) \ - 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() + #define BOOST_CONTAINER_FLAT_MULTIMAP_EMPLACE_CODE(N) \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace(BOOST_MOVE_UREF##N)\ + { return container_detail::force_copy(m_flat_tree.emplace_equal(BOOST_MOVE_FWD##N)); }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + return container_detail::force_copy(m_flat_tree.emplace_hint_equal\ + (container_detail::force_copy(hint) BOOST_MOVE_I##N BOOST_MOVE_FWD##N));\ + }\ + // + BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_MULTIMAP_EMPLACE_CODE) + #undef BOOST_CONTAINER_FLAT_MULTIMAP_EMPLACE_CODE - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) //! Effects: Inserts x and returns the iterator pointing to the //! newly inserted element. @@ -1740,6 +1844,8 @@ class flat_multimap //! //! Complexity: Constant. void swap(flat_multimap& x) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_swappable::value ) { m_flat_tree.swap(x.m_flat_tree); } //! Effects: erase(a.begin(),a.end()). @@ -1747,7 +1853,7 @@ class flat_multimap //! Postcondition: size() == 0. //! //! Complexity: linear in size(). - void clear() BOOST_CONTAINER_NOEXCEPT + void clear() BOOST_NOEXCEPT_OR_NOTHROW { m_flat_tree.clear(); } ////////////////////////////////////////////// @@ -1803,7 +1909,7 @@ class flat_multimap iterator lower_bound(const key_type& x) { return container_detail::force_copy(m_flat_tree.lower_bound(x)); } - //! Returns: Allocator const iterator pointing to the first element with key + //! Returns: A const iterator pointing to the first element with key //! not less than k, or a.end() if such an element is not found. //! //! Complexity: Logarithmic @@ -1817,7 +1923,7 @@ class flat_multimap iterator upper_bound(const key_type& x) {return container_detail::force_copy(m_flat_tree.upper_bound(x)); } - //! Returns: Allocator const iterator pointing to the first element with key + //! Returns: A const iterator pointing to the first element with key //! not less than x, or end() if such an element is not found. //! //! Complexity: Logarithmic @@ -1840,7 +1946,7 @@ class flat_multimap //! //! Complexity: Linear to the number of elements in the container. friend bool operator==(const flat_multimap& x, const flat_multimap& y) - { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); } + { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); } //! Effects: Returns true if x and y are unequal //! @@ -1852,7 +1958,7 @@ class flat_multimap //! //! Complexity: Linear to the number of elements in the container. friend bool operator<(const flat_multimap& x, const flat_multimap& y) - { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + { return ::boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } //! Effects: Returns true if x is greater than y //! @@ -1887,10 +1993,13 @@ namespace boost { //!has_trivial_destructor_after_move<> == true_type //!specialization for optimizations -template -struct has_trivial_destructor_after_move< boost::container::flat_multimap > +template +struct has_trivial_destructor_after_move< boost::container::flat_multimap > { - static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value; + typedef typename ::boost::container::allocator_traits::pointer pointer; + static const bool value = ::boost::has_trivial_destructor_after_move::value && + ::boost::has_trivial_destructor_after_move::value && + ::boost::has_trivial_destructor_after_move::value; }; } //namespace boost { @@ -1899,4 +2008,4 @@ struct has_trivial_destructor_after_move< boost::container::flat_multimap -#endif /* BOOST_CONTAINER_FLAT_MAP_HPP */ +#endif // BOOST_CONTAINER_FLAT_MAP_HPP diff --git a/boost/container/flat_set.hpp b/boost/container/flat_set.hpp index 1307f34..8f59279 100644 --- a/boost/container/flat_set.hpp +++ b/boost/container/flat_set.hpp @@ -7,31 +7,43 @@ // See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// - #ifndef BOOST_CONTAINER_FLAT_SET_HPP #define BOOST_CONTAINER_FLAT_SET_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include +// container +#include #include -#include -#include -#include +#include //new_allocator +// container/detail #include #include -#include -#include -#include +// move #include - +#include +// move/detail +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif +#include +// intrusive/detail +#include //pair +#include //less, equal +// std #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #include #endif + namespace boost { namespace container { @@ -51,7 +63,7 @@ namespace container { //! \tparam Compare is the comparison functor used to order keys //! \tparam Allocator is the allocator to be used to allocate memory for this container #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template , class Allocator = std::allocator > +template , class Allocator = new_allocator > #else template #endif @@ -132,6 +144,16 @@ class flat_set : base_t(true, first, last, comp, a) {} + //! Effects: Constructs an empty container using the specified + //! allocator, and inserts elements from the range [first ,last ). + //! + //! Complexity: Linear in N if the range [first ,last ) is already sorted using + //! comp and otherwise N logN, where N is last - first. + template + flat_set(InputIterator first, InputIterator last, const allocator_type& a) + : base_t(true, first, last, Compare(), a) + {} + //! Effects: Constructs an empty container using the specified comparison object and //! allocator, and inserts elements from the ordered unique range [first ,last). This function //! is more efficient than the normal range creation for ordered ranges. @@ -158,9 +180,16 @@ class flat_set flat_set(std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) : base_t(true, il.begin(), il.end(), comp, a) - { + {} - } + //! Effects: Constructs an empty container using the specified + //! allocator, and inserts elements from the range [il.begin(), il.end()). + //! + //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using + //! comp and otherwise N logN, where N is il.begin() - il.end(). + flat_set(std::initializer_list il, const allocator_type& a) + : base_t(true, il.begin(), il.end(), Compare(), a) + {} //! Effects: Constructs an empty container using the specified comparison object and //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function @@ -175,9 +204,7 @@ class flat_set flat_set(ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) : base_t(ordered_range, il.begin(), il.end(), comp, a) - { - - } + {} #endif //! Effects: Copy constructs the container. @@ -187,13 +214,13 @@ class flat_set : base_t(static_cast(x)) {} - //! Effects: Move constructs thecontainer. Constructs *this using mx's resources. + //! Effects: Move constructs thecontainer. Constructs *this using x's resources. //! //! Complexity: Constant. //! - //! Postcondition: mx is emptied. - flat_set(BOOST_RV_REF(flat_set) mx) - : base_t(boost::move(static_cast(mx))) + //! Postcondition: x is emptied. + flat_set(BOOST_RV_REF(flat_set) x) + : base_t(BOOST_MOVE_BASE(base_t, x)) {} //! Effects: Copy constructs a container using the specified allocator. @@ -204,11 +231,11 @@ class flat_set {} //! Effects: Move constructs a container using the specified allocator. - //! Constructs *this using mx's resources. + //! Constructs *this using x's resources. //! - //! Complexity: Constant if a == mx.get_allocator(), linear otherwise - flat_set(BOOST_RV_REF(flat_set) mx, const allocator_type &a) - : base_t(boost::move(static_cast(mx)), a) + //! Complexity: Constant if a == x.get_allocator(), linear otherwise + flat_set(BOOST_RV_REF(flat_set) x, const allocator_type &a) + : base_t(BOOST_MOVE_BASE(base_t, x), a) {} //! Effects: Makes *this a copy of x. @@ -224,8 +251,9 @@ class flat_set //! propagate_on_container_move_assignment is true or //! this->get>allocator() == x.get_allocator(). Linear otherwise. flat_set& operator=(BOOST_RV_REF(flat_set) x) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) - { return static_cast(this->base_t::operator=(boost::move(static_cast(x)))); } + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_move_assignable::value ) + { return static_cast(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) //! Effects: Copy all elements from il to *this. @@ -240,11 +268,11 @@ class flat_set #endif #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED - //! Effects: Returns a copy of the Allocator that + //! Effects: Returns a copy of the allocator that //! was passed to the object's constructor. //! //! Complexity: Constant. - allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT; + allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a reference to the internal allocator. //! @@ -253,7 +281,7 @@ class flat_set //! Complexity: Constant. //! //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT; + stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a reference to the internal allocator. //! @@ -262,35 +290,35 @@ class flat_set //! Complexity: Constant. //! //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT; + const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns an iterator to the first element contained in the container. //! //! Throws: Nothing. //! //! Complexity: Constant. - iterator begin() BOOST_CONTAINER_NOEXCEPT; + iterator begin() BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a const_iterator to the first element contained in the container. //! //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator begin() const BOOST_CONTAINER_NOEXCEPT; + const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns an iterator to the end of the container. //! //! Throws: Nothing. //! //! Complexity: Constant. - iterator end() BOOST_CONTAINER_NOEXCEPT; + iterator end() BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a const_iterator to the end of the container. //! //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator end() const BOOST_CONTAINER_NOEXCEPT; + const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a reverse_iterator pointing to the beginning //! of the reversed container. @@ -298,7 +326,7 @@ class flat_set //! Throws: Nothing. //! //! Complexity: Constant. - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT; + reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a const_reverse_iterator pointing to the beginning //! of the reversed container. @@ -306,7 +334,7 @@ class flat_set //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a reverse_iterator pointing to the end //! of the reversed container. @@ -314,7 +342,7 @@ class flat_set //! Throws: Nothing. //! //! Complexity: Constant. - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT; + reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a const_reverse_iterator pointing to the end //! of the reversed container. @@ -322,21 +350,21 @@ class flat_set //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a const_iterator to the first element contained in the container. //! //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT; + const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a const_iterator to the end of the container. //! //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT; + const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a const_reverse_iterator pointing to the beginning //! of the reversed container. @@ -344,7 +372,7 @@ class flat_set //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns a const_reverse_iterator pointing to the end //! of the reversed container. @@ -352,28 +380,28 @@ class flat_set //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns true if the container contains no elements. //! //! Throws: Nothing. //! //! Complexity: Constant. - bool empty() const BOOST_CONTAINER_NOEXCEPT; + bool empty() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns the number of the elements contained in the container. //! //! Throws: Nothing. //! //! Complexity: Constant. - size_type size() const BOOST_CONTAINER_NOEXCEPT; + size_type size() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns the largest possible size of the container. //! //! Throws: Nothing. //! //! Complexity: Constant. - size_type max_size() const BOOST_CONTAINER_NOEXCEPT; + size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Number of elements for which memory has been allocated. //! capacity() is always greater than or equal to size(). @@ -381,7 +409,7 @@ class flat_set //! Throws: Nothing. //! //! Complexity: Constant. - size_type capacity() const BOOST_CONTAINER_NOEXCEPT; + size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: If n is less than or equal to capacity(), this call has no //! effect. Otherwise, it is a request for allocation of additional memory. @@ -410,7 +438,7 @@ class flat_set // ////////////////////////////////////////////// - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! Effects: Inserts an object x of type Key constructed with //! std::forward(args)... if and only if there is no element in the container @@ -425,7 +453,7 @@ class flat_set //! //! Note: If an element is inserted it might invalidate elements. template - std::pair emplace(Args&&... args) + std::pair emplace(BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_unique(boost::forward(args)...); } //! Effects: Inserts an object of type Key constructed with @@ -441,26 +469,24 @@ class flat_set //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace_hint(const_iterator p, Args&&... args) + iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_hint_unique(p, boost::forward(args)...); } - #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - #define BOOST_PP_LOCAL_MACRO(n) \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - std::pair emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_unique(BOOST_PP_ENUM(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_hint(const_iterator p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_hint_unique \ - (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() + #define BOOST_CONTAINER_FLAT_SET_EMPLACE_CODE(N) \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + std::pair emplace(BOOST_MOVE_UREF##N)\ + { return this->base_t::emplace_unique(BOOST_MOVE_FWD##N); }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + { return this->base_t::emplace_hint_unique(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ + // + BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_SET_EMPLACE_CODE) + #undef BOOST_CONTAINER_FLAT_SET_EMPLACE_CODE - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! Effects: Inserts x if and only if there is no element in the container @@ -613,14 +639,16 @@ class flat_set //! Throws: Nothing. //! //! Complexity: Constant. - void swap(flat_set& x); + void swap(flat_set& x) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_swappable::value ); //! Effects: erase(a.begin(),a.end()). //! //! Postcondition: size() == 0. //! //! Complexity: linear in size(). - void clear() BOOST_CONTAINER_NOEXCEPT; + void clear() BOOST_NOEXCEPT_OR_NOTHROW; //! Effects: Returns the comparison object out //! of which a was constructed. @@ -640,12 +668,63 @@ class flat_set //! Complexity: Logarithmic. iterator find(const key_type& x); - //! Returns: Allocator const_iterator pointing to an element with the key + //! Returns: A const_iterator pointing to an element with the key //! equivalent to x, or end() if such an element is not found. //! //! Complexity: Logarithmic. const_iterator find(const key_type& x) const; + //! Requires: size() >= n. + //! + //! Effects: Returns an iterator to the nth element + //! from the beginning of the container. Returns end() + //! if n == size(). + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + //! + //! Note: Non-standard extension + iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW; + + //! Requires: size() >= n. + //! + //! Effects: Returns a const_iterator to the nth element + //! from the beginning of the container. Returns end() + //! if n == size(). + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + //! + //! Note: Non-standard extension + const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW; + + //! Requires: size() >= n. + //! + //! Effects: Returns an iterator to the nth element + //! from the beginning of the container. Returns end() + //! if n == size(). + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + //! + //! Note: Non-standard extension + size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW; + + //! Requires: begin() <= p <= end(). + //! + //! Effects: Returns the index of the element pointed by p + //! and size() if p == end(). + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + //! + //! Note: Non-standard extension + size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW; + #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! Returns: The number of elements with key equivalent to x. @@ -661,7 +740,7 @@ class flat_set //! Complexity: Logarithmic iterator lower_bound(const key_type& x); - //! Returns: Allocator const iterator pointing to the first element with key not + //! Returns: A const iterator pointing to the first element with key not //! less than k, or a.end() if such an element is not found. //! //! Complexity: Logarithmic @@ -673,7 +752,7 @@ class flat_set //! Complexity: Logarithmic iterator upper_bound(const key_type& x); - //! Returns: Allocator const iterator pointing to the first element with key not + //! Returns: A const iterator pointing to the first element with key not //! less than x, or end() if such an element is not found. //! //! Complexity: Logarithmic @@ -750,10 +829,13 @@ class flat_set //!has_trivial_destructor_after_move<> == true_type //!specialization for optimizations -template -struct has_trivial_destructor_after_move > +template +struct has_trivial_destructor_after_move > { - static const bool value = has_trivial_destructor_after_move::value &&has_trivial_destructor_after_move::value; + typedef typename ::boost::container::allocator_traits::pointer pointer; + static const bool value = ::boost::has_trivial_destructor_after_move::value && + ::boost::has_trivial_destructor_after_move::value && + ::boost::has_trivial_destructor_after_move::value; }; namespace container { @@ -777,7 +859,7 @@ namespace container { //! \tparam Compare is the comparison functor used to order keys //! \tparam Allocator is the allocator to be used to allocate memory for this container #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template , class Allocator = std::allocator > +template , class Allocator = new_allocator > #else template #endif @@ -840,6 +922,12 @@ class flat_multiset : base_t(false, first, last, comp, a) {} + //! @copydoc ::boost::container::flat_set::flat_set(InputIterator, InputIterator, const allocator_type&) + template + flat_multiset(InputIterator first, InputIterator last, const allocator_type& a) + : base_t(false, first, last, Compare(), a) + {} + //! Effects: Constructs an empty flat_multiset using the specified comparison object and //! allocator, and inserts elements from the ordered range [first ,last ). This function //! is more efficient than the normal range creation for ordered ranges. @@ -863,6 +951,11 @@ class flat_multiset : base_t(false, il.begin(), il.end(), comp, a) {} + //! @copydoc ::boost::container::flat_set::flat_set(std::initializer_list, const allocator_type&) + flat_multiset(std::initializer_list il, const allocator_type& a) + : base_t(false, il.begin(), il.end(), Compare(), a) + {} + //! @copydoc ::boost::container::flat_set::flat_set(ordered_unique_range_t, std::initializer_list, const Compare& comp, const allocator_type&) flat_multiset(ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) @@ -876,8 +969,8 @@ class flat_multiset {} //! @copydoc ::boost::container::flat_set(flat_set &&) - flat_multiset(BOOST_RV_REF(flat_multiset) mx) - : base_t(boost::move(static_cast(mx))) + flat_multiset(BOOST_RV_REF(flat_multiset) x) + : base_t(boost::move(static_cast(x))) {} //! @copydoc ::boost::container::flat_set(const flat_set &, const allocator_type &) @@ -886,8 +979,8 @@ class flat_multiset {} //! @copydoc ::boost::container::flat_set(flat_set &&, const allocator_type &) - flat_multiset(BOOST_RV_REF(flat_multiset) mx, const allocator_type &a) - : base_t(boost::move(static_cast(mx)), a) + flat_multiset(BOOST_RV_REF(flat_multiset) x, const allocator_type &a) + : base_t(BOOST_MOVE_BASE(base_t, x), a) {} //! @copydoc ::boost::container::flat_set::operator=(const flat_set &) @@ -895,9 +988,10 @@ class flat_multiset { return static_cast(this->base_t::operator=(static_cast(x))); } //! @copydoc ::boost::container::flat_set::operator=(flat_set &&) - flat_multiset& operator=(BOOST_RV_REF(flat_multiset) mx) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) - { return static_cast(this->base_t::operator=(boost::move(static_cast(mx)))); } + flat_multiset& operator=(BOOST_RV_REF(flat_multiset) x) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_move_assignable::value ) + { return static_cast(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); } #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) //! @copydoc ::boost::container::flat_set::operator=(std::initializer_list) @@ -912,61 +1006,61 @@ class flat_multiset #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! @copydoc ::boost::container::flat_set::get_allocator() - allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT; + allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::get_stored_allocator() - stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT; + stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::get_stored_allocator() const - const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT; + const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::begin() - iterator begin() BOOST_CONTAINER_NOEXCEPT; + iterator begin() BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::begin() const const_iterator begin() const; //! @copydoc ::boost::container::flat_set::cbegin() const - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT; + const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::end() - iterator end() BOOST_CONTAINER_NOEXCEPT; + iterator end() BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::end() const - const_iterator end() const BOOST_CONTAINER_NOEXCEPT; + const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::cend() const - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT; + const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::rbegin() - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT; + reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::rbegin() const - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::crbegin() const - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::rend() - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT; + reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::rend() const - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::crend() const - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::empty() const - bool empty() const BOOST_CONTAINER_NOEXCEPT; + bool empty() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::size() const - size_type size() const BOOST_CONTAINER_NOEXCEPT; + size_type size() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::max_size() const - size_type max_size() const BOOST_CONTAINER_NOEXCEPT; + size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::capacity() const - size_type capacity() const BOOST_CONTAINER_NOEXCEPT; + size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::reserve(size_type) void reserve(size_type cnt); @@ -982,7 +1076,7 @@ class flat_multiset // ////////////////////////////////////////////// - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! Effects: Inserts an object of type Key constructed with //! std::forward(args)... and returns the iterator pointing to the @@ -993,7 +1087,7 @@ class flat_multiset //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace(Args&&... args) + iterator emplace(BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_equal(boost::forward(args)...); } //! Effects: Inserts an object of type Key constructed with @@ -1008,26 +1102,24 @@ class flat_multiset //! //! Note: If an element is inserted it might invalidate elements. template - iterator emplace_hint(const_iterator p, Args&&... args) + iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args) { return this->base_t::emplace_hint_equal(p, boost::forward(args)...); } - #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - #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(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_equal(BOOST_PP_ENUM(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_hint(const_iterator p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_hint_equal \ - (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() + #define BOOST_CONTAINER_FLAT_MULTISET_EMPLACE_CODE(N) \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace(BOOST_MOVE_UREF##N)\ + { return this->base_t::emplace_equal(BOOST_MOVE_FWD##N); }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + { return this->base_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\ + // + BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_FLAT_MULTISET_EMPLACE_CODE) + #undef BOOST_CONTAINER_FLAT_MULTISET_EMPLACE_CODE - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! Effects: Inserts x and returns the iterator pointing to the @@ -1140,10 +1232,12 @@ class flat_multiset iterator erase(const_iterator first, const_iterator last); //! @copydoc ::boost::container::flat_set::swap - void swap(flat_multiset& x); + void swap(flat_multiset& x) + BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value + && boost::container::container_detail::is_nothrow_swappable::value ); //! @copydoc ::boost::container::flat_set::clear - void clear() BOOST_CONTAINER_NOEXCEPT; + void clear() BOOST_NOEXCEPT_OR_NOTHROW; //! @copydoc ::boost::container::flat_set::key_comp key_compare key_comp() const; @@ -1157,6 +1251,18 @@ class flat_multiset //! @copydoc ::boost::container::flat_set::find(const key_type& ) const const_iterator find(const key_type& x) const; + //! @copydoc ::boost::container::flat_set::nth(size_type) + iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW; + + //! @copydoc ::boost::container::flat_set::nth(size_type) const + const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW; + + //! @copydoc ::boost::container::flat_set::index_of(iterator) + size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW; + + //! @copydoc ::boost::container::flat_set::index_of(const_iterator) const + size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW; + //! @copydoc ::boost::container::flat_set::count(const key_type& ) const size_type count(const key_type& x) const; @@ -1233,10 +1339,13 @@ class flat_multiset //!has_trivial_destructor_after_move<> == true_type //!specialization for optimizations -template -struct has_trivial_destructor_after_move > +template +struct has_trivial_destructor_after_move > { - static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value; + typedef typename ::boost::container::allocator_traits::pointer pointer; + static const bool value = ::boost::has_trivial_destructor_after_move::value && + ::boost::has_trivial_destructor_after_move::value && + ::boost::has_trivial_destructor_after_move::value; }; namespace container { @@ -1247,4 +1356,4 @@ namespace container { #include -#endif /* BOOST_CONTAINER_FLAT_SET_HPP */ +#endif // BOOST_CONTAINER_FLAT_SET_HPP diff --git a/boost/container/list.hpp b/boost/container/list.hpp deleted file mode 100644 index 33cc6ee..0000000 --- a/boost/container/list.hpp +++ /dev/null @@ -1,1462 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_LIST_HPP -#define BOOST_CONTAINER_LIST_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) -#else -//Preprocessor library to emulate perfect forwarding -#include -#endif - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) -#include -#endif - -#include -#include -#include -#include -#include - -namespace boost { -namespace container { - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -namespace container_detail { - -template -struct list_hook -{ - typedef typename container_detail::bi::make_list_base_hook - , container_detail::bi::link_mode >::type type; -}; - -template -struct list_node - : public list_hook::type -{ - private: - list_node(); - - public: - typedef T value_type; - typedef typename list_hook::type hook_type; - - T m_data; - - T &get_data() - { return this->m_data; } - - const T &get_data() const - { return this->m_data; } -}; - -template -struct iiterator_node_value_type< list_node > { - typedef T type; -}; - -template -struct intrusive_list_type -{ - typedef boost::container::allocator_traits allocator_traits_type; - typedef typename allocator_traits_type::value_type value_type; - typedef typename boost::intrusive::pointer_traits - ::template - rebind_pointer::type - void_pointer; - typedef typename container_detail::list_node - node_type; - typedef typename container_detail::bi::make_list - < node_type - , container_detail::bi::base_hook::type> - , container_detail::bi::constant_time_size - , container_detail::bi::size_type - - >::type container_type; - typedef container_type type ; -}; - -} //namespace container_detail { -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -//! A list is a doubly linked list. That is, it is a Sequence that supports both -//! forward and backward traversal, and (amortized) constant time insertion and -//! removal of elements at the beginning or the end, or in the middle. Lists have -//! the important property that insertion and splicing do not invalidate iterators -//! to list elements, and that even removal invalidates only the iterators that point -//! to the elements that are removed. The ordering of iterators may be changed -//! (that is, list::iterator might have a different predecessor or successor -//! after a list operation than it did before), but the iterators themselves will -//! not be invalidated or made to point to different elements unless that invalidation -//! or mutation is explicit. -//! -//! \tparam T The type of object that is stored in the list -//! \tparam Allocator The allocator used for all internal memory management -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template > -#else -template -#endif -class list - : protected container_detail::node_alloc_holder - ::type> -{ - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef typename - container_detail::intrusive_list_type::type Icont; - typedef container_detail::node_alloc_holder AllocHolder; - typedef typename AllocHolder::NodePtr NodePtr; - typedef typename AllocHolder::NodeAlloc NodeAlloc; - typedef typename AllocHolder::ValAlloc ValAlloc; - typedef typename AllocHolder::Node Node; - typedef container_detail::allocator_destroyer Destroyer; - typedef typename AllocHolder::allocator_v1 allocator_v1; - typedef typename AllocHolder::allocator_v2 allocator_v2; - typedef typename AllocHolder::alloc_version alloc_version; - typedef boost::container::allocator_traits allocator_traits_type; - - class equal_to_value - { - typedef typename AllocHolder::value_type value_type; - const value_type &t_; - - public: - equal_to_value(const value_type &t) - : t_(t) - {} - - bool operator()(const value_type &t)const - { return t_ == t; } - }; - - template - struct ValueCompareToNodeCompare - : Pred - { - ValueCompareToNodeCompare(Pred pred) - : Pred(pred) - {} - - bool operator()(const Node &a, const Node &b) const - { return static_cast(*this)(a.m_data, b.m_data); } - - bool operator()(const Node &a) const - { return static_cast(*this)(a.m_data); } - }; - - BOOST_COPYABLE_AND_MOVABLE(list) - - typedef container_detail::iterator iterator_impl; - typedef container_detail::iterator const_iterator_impl; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - ////////////////////////////////////////////// - // - // types - // - ////////////////////////////////////////////// - - typedef T value_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator 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(container_detail::reverse_iterator) reverse_iterator; - typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) const_reverse_iterator; - - ////////////////////////////////////////////// - // - // construct/copy/destroy - // - ////////////////////////////////////////////// - - //! Effects: Default constructs a list. - //! - //! Throws: If allocator_type's default constructor throws. - //! - //! Complexity: Constant. - list() - : AllocHolder() - {} - - //! Effects: Constructs a list taking the allocator as parameter. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - explicit list(const allocator_type &a) BOOST_CONTAINER_NOEXCEPT - : AllocHolder(a) - {} - - //! Effects: Constructs a list that will use a copy of allocator a - //! and inserts n copies of value. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's default or copy constructor throws. - //! - //! Complexity: Linear to n. - explicit list(size_type n) - : AllocHolder(Allocator()) - { this->resize(n); } - - //! Effects: Constructs a list that will use a copy of allocator a - //! and inserts n copies of value. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's default or copy constructor throws. - //! - //! Complexity: Linear to n. - list(size_type n, const T& value, const Allocator& a = Allocator()) - : AllocHolder(a) - { this->insert(this->cbegin(), n, value); } - - //! Effects: Copy constructs a list. - //! - //! Postcondition: x == *this. - //! - //! Throws: If allocator_type's default constructor throws. - //! - //! Complexity: Linear to the elements x contains. - list(const list& x) - : AllocHolder(x) - { this->insert(this->cbegin(), x.begin(), x.end()); } - - //! Effects: Move constructor. Moves mx's resources to *this. - //! - //! Throws: If allocator_type's copy constructor throws. - //! - //! Complexity: Constant. - list(BOOST_RV_REF(list) x) - : AllocHolder(boost::move(static_cast(x))) - {} - - //! Effects: Copy constructs a list using the specified allocator. - //! - //! Postcondition: x == *this. - //! - //! Throws: If allocator_type's default constructor or copy constructor throws. - //! - //! Complexity: Linear to the elements x contains. - list(const list& x, const allocator_type &a) - : AllocHolder(a) - { this->insert(this->cbegin(), x.begin(), x.end()); } - - //! Effects: Move constructor sing the specified allocator. - //! Moves mx's resources to *this. - //! - //! Throws: If allocation or value_type's copy constructor throws. - //! - //! Complexity: Constant if a == x.get_allocator(), linear otherwise. - list(BOOST_RV_REF(list) x, const allocator_type &a) - : AllocHolder(a) - { - if(this->node_alloc() == x.node_alloc()){ - this->icont().swap(x.icont()); - } - else{ - this->insert(this->cbegin(), x.begin(), x.end()); - } - } - - //! Effects: Constructs a list that will use a copy of allocator a - //! and inserts a copy of the range [first, last) in the list. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's constructor taking a dereferenced InIt throws. - //! - //! Complexity: Linear to the range [first, last). - template - list(InpIt first, InpIt last, const Allocator &a = Allocator()) - : AllocHolder(a) - { this->insert(this->cbegin(), first, last); } - - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs a list that will use a copy of allocator a - //! and inserts a copy of the range [il.begin(), il.end()) in the list. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's constructor taking a dereferenced - //! std::initializer_list iterator throws. - //! - //! Complexity: Linear to the range [il.begin(), il.end()). - list(std::initializer_list il, const Allocator &a = Allocator()) - : AllocHolder(a) - { this->insert(this->cbegin(), il.begin(), il.end()); } -#endif - - //! Effects: Destroys the list. All stored values are destroyed - //! and used memory is deallocated. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements. - ~list() BOOST_CONTAINER_NOEXCEPT - {} //AllocHolder clears the list - - //! Effects: Makes *this contain the same elements as x. - //! - //! Postcondition: this->size() == x.size(). *this contains a copy - //! of each of x's elements. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: 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_ flag; - if(flag && this_alloc != x_alloc){ - this->clear(); - } - this->AllocHolder::copy_assign_alloc(x); - this->assign(x.begin(), x.end()); - } - return *this; - } - - //! Effects: Move assignment. All x's values are transferred to *this. - //! - //! Postcondition: x.empty(). *this contains a the elements x had - //! before the function. - //! - //! Throws: If allocator_traits_type::propagate_on_container_move_assignment - //! is false and (allocation throws or value_type's move constructor throws) - //! - //! Complexity: Constant if allocator_traits_type:: - //! propagate_on_container_move_assignment is true or - //! this->get>allocator() == x.get_allocator(). Linear otherwise. - list& operator=(BOOST_RV_REF(list) x) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) - { - BOOST_ASSERT(this != &x); - NodeAlloc &this_alloc = this->node_alloc(); - NodeAlloc &x_alloc = x.node_alloc(); - const bool propagate_alloc = allocator_traits_type:: - propagate_on_container_move_assignment::value; - const bool allocators_equal = this_alloc == x_alloc; (void)allocators_equal; - //Resources can be transferred if both allocators are - //going to be equal after this function (either propagated or already equal) - if(propagate_alloc || allocators_equal){ - //Destroy - this->clear(); - //Move allocator if needed - this->AllocHolder::move_assign_alloc(x); - //Obtain resources - this->icont() = boost::move(x.icont()); - } - //Else do a one by one move - else{ - this->assign( boost::make_move_iterator(x.begin()) - , boost::make_move_iterator(x.end())); - } - return *this; - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Makes *this contain the same elements as il. - //! - //! Postcondition: this->size() == il.size(). *this contains a copy - //! of each of x's elements. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to the number of elements in x. - list& operator=(std::initializer_list il) - { - assign(il.begin(), il.end()); - return *this; - } -#endif - - //! Effects: Assigns the n copies of val to *this. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to n. - void assign(size_type n, const T& val) - { - typedef constant_iterator cvalue_iterator; - return this->assign(cvalue_iterator(val, n), cvalue_iterator()); - } - - //! Effects: Assigns the the range [first, last) to *this. - //! - //! Throws: If memory allocation throws or - //! T's constructor from dereferencing InpIt throws. - //! - //! Complexity: Linear to n. - template - void assign(InpIt first, InpIt last - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible::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); - } - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Assigns the the range [il.begin(), il.end()) to *this. - //! - //! Throws: If memory allocation throws or - //! T's constructor from dereferencing std::initializer_list iterator throws. - //! - //! Complexity: Linear to n. - void assign(std::initializer_list il) - { assign(il.begin(), il.end()); } -#endif - - //! Effects: Returns a copy of the internal allocator. - //! - //! Throws: If allocator's copy constructor throws. - //! - //! Complexity: Constant. - allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT - { return allocator_type(this->node_alloc()); } - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT - { return this->node_alloc(); } - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT - { return this->node_alloc(); } - - ////////////////////////////////////////////// - // - // iterators - // - ////////////////////////////////////////////// - - //! Effects: Returns an iterator to the first element contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator begin() BOOST_CONTAINER_NOEXCEPT - { return iterator(this->icont().begin()); } - - //! Effects: Returns a const_iterator to the first element contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator begin() const BOOST_CONTAINER_NOEXCEPT - { return this->cbegin(); } - - //! Effects: Returns an iterator to the end of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator end() BOOST_CONTAINER_NOEXCEPT - { return iterator(this->icont().end()); } - - //! Effects: Returns a const_iterator to the end of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator end() const BOOST_CONTAINER_NOEXCEPT - { return this->cend(); } - - //! Effects: Returns a reverse_iterator pointing to the beginning - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT - { return reverse_iterator(end()); } - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT - { return this->crbegin(); } - - //! Effects: Returns a reverse_iterator pointing to the end - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT - { return reverse_iterator(begin()); } - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT - { return this->crend(); } - - //! Effects: Returns a const_iterator to the first element contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT - { return const_iterator(this->non_const_icont().begin()); } - - //! Effects: Returns a const_iterator to the end of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT - { return const_iterator(this->non_const_icont().end()); } - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT - { return const_reverse_iterator(this->cend()); } - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT - { return const_reverse_iterator(this->cbegin()); } - - ////////////////////////////////////////////// - // - // capacity - // - ////////////////////////////////////////////// - - //! Effects: Returns true if the list contains no elements. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - bool empty() const BOOST_CONTAINER_NOEXCEPT - { return !this->size(); } - - //! Effects: Returns the number of the elements contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type size() const BOOST_CONTAINER_NOEXCEPT - { return this->icont().size(); } - - //! Effects: Returns the largest possible size of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type max_size() const BOOST_CONTAINER_NOEXCEPT - { return AllocHolder::max_size(); } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are value initialized. - //! - //! Throws: If memory allocation throws, or T's copy constructor throws. - //! - //! Complexity: Linear to the difference between size() and new_size. - void resize(size_type new_size) - { - if(!priv_try_shrink(new_size)){ - typedef value_init_construct_iterator value_init_iterator; - this->insert(this->cend(), value_init_iterator(new_size - this->size()), value_init_iterator()); - } - } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are copy constructed from x. - //! - //! Throws: If memory allocation throws, or T's copy constructor throws. - //! - //! Complexity: 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); - } - } - - ////////////////////////////////////////////// - // - // element access - // - ////////////////////////////////////////////// - - //! Requires: !empty() - //! - //! Effects: Returns a reference to the first element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference front() BOOST_CONTAINER_NOEXCEPT - { return *this->begin(); } - - //! Requires: !empty() - //! - //! Effects: Returns a const reference to the first element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference front() const BOOST_CONTAINER_NOEXCEPT - { return *this->begin(); } - - //! Requires: !empty() - //! - //! Effects: Returns a reference to the first element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference back() BOOST_CONTAINER_NOEXCEPT - { return *(--this->end()); } - - //! Requires: !empty() - //! - //! Effects: Returns a const reference to the first element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference back() const BOOST_CONTAINER_NOEXCEPT - { return *(--this->end()); } - - ////////////////////////////////////////////// - // - // modifiers - // - ////////////////////////////////////////////// - - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... in the end of the list. - //! - //! Throws: If memory allocation throws or - //! T's in-place constructor throws. - //! - //! Complexity: Constant - template - void emplace_back(Args&&... args) - { this->emplace(this->cend(), boost::forward(args)...); } - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... in the beginning of the list. - //! - //! Throws: If memory allocation throws or - //! T's in-place constructor throws. - //! - //! Complexity: Constant - template - void emplace_front(Args&&... args) - { this->emplace(this->cbegin(), boost::forward(args)...); } - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... before p. - //! - //! Throws: If memory allocation throws or - //! T's in-place constructor throws. - //! - //! Complexity: Constant - template - iterator emplace(const_iterator p, Args&&... args) - { - NodePtr pnode(AllocHolder::create_node(boost::forward(args)...)); - return iterator(this->icont().insert(p.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_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)); \ - } \ - //! - #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) - //! Effects: Inserts a copy of x at the beginning of the list. - //! - //! Throws: If memory allocation throws or - //! T's copy constructor throws. - //! - //! Complexity: Amortized constant time. - void push_front(const T &x); - - //! Effects: Constructs a new element in the beginning of the list - //! and moves the resources of mx to this new element. - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: 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) - //! Effects: Inserts a copy of x at the end of the list. - //! - //! Throws: If memory allocation throws or - //! T's copy constructor throws. - //! - //! Complexity: Amortized constant time. - void push_back(const T &x); - - //! Effects: Constructs a new element in the end of the list - //! and moves the resources of mx to this new element. - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: 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) - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a copy of x before p. - //! - //! Returns: an iterator to the inserted element. - //! - //! Throws: If memory allocation throws or x's copy constructor throws. - //! - //! Complexity: Amortized constant time. - iterator insert(const_iterator p, const T &x); - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a new element before p with mx's resources. - //! - //! Returns: an iterator to the inserted element. - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: Amortized constant time. - iterator insert(const_iterator p, T &&x); - #else - BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator, const_iterator) - #endif - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Inserts n copies of x before p. - //! - //! Returns: an iterator to the first inserted element or p if n is 0. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to n. - iterator insert(const_iterator p, size_type n, const T& x) - { - typedef constant_iterator cvalue_iterator; - return this->insert(p, cvalue_iterator(x, n), cvalue_iterator()); - } - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a copy of the [first, last) range before p. - //! - //! Returns: an iterator to the first inserted element or p if first == last. - //! - //! Throws: If memory allocation throws, T's constructor from a - //! dereferenced InpIt throws. - //! - //! Complexity: Linear to std::distance [first, last). - template - 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::value - && (container_detail::is_input_iterator::value - || container_detail::is_same::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; - } - - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - template - iterator insert(const_iterator p, FwdIt first, FwdIt last - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - && !(container_detail::is_input_iterator::value - || container_detail::is_same::value - ) - >::type * = 0 - ) - { - //Optimized allocation and construction - insertion_functor func(this->icont(), p.get()); - iterator before_p(p.get()); - --before_p; - this->allocate_many_and_construct(first, std::distance(first, last), func); - return ++before_p; - } - #endif - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a copy of the [il.begin(), il.end()) range before p. - //! - //! Returns: an iterator to the first inserted element or p if if.begin() == il.end(). - //! - //! Throws: If memory allocation throws, T's constructor from a - //! dereferenced std::initializer_list iterator throws. - //! - //! Complexity: Linear to std::distance [il.begin(), il.end()). - iterator insert(const_iterator p, std::initializer_list il) - { return insert(p, il.begin(), il.end()); } -#endif - - //! Effects: Removes the first element from the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Amortized constant time. - void pop_front() BOOST_CONTAINER_NOEXCEPT - { this->erase(this->cbegin()); } - - //! Effects: Removes the last element from the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Amortized constant time. - void pop_back() BOOST_CONTAINER_NOEXCEPT - { const_iterator tmp = this->cend(); this->erase(--tmp); } - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Erases the element at p p. - //! - //! Throws: Nothing. - //! - //! Complexity: Amortized constant time. - iterator erase(const_iterator p) BOOST_CONTAINER_NOEXCEPT - { return iterator(this->icont().erase_and_dispose(p.get(), Destroyer(this->node_alloc()))); } - - //! Requires: first and last must be valid iterator to elements in *this. - //! - //! Effects: Erases the elements pointed by [first, last). - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the distance between first and last. - iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT - { return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); } - - //! Effects: Swaps the contents of *this and x. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - void swap(list& x) - { AllocHolder::swap(x); } - - //! Effects: Erases all the elements of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements in the list. - void clear() BOOST_CONTAINER_NOEXCEPT - { AllocHolder::clear(alloc_version()); } - - ////////////////////////////////////////////// - // - // slist operations - // - ////////////////////////////////////////////// - - //! Requires: p must point to an element contained - //! by the list. x != *this. this' allocator and x's allocator shall compare equal - //! - //! Effects: Transfers all the elements of list x to this list, before the - //! the element pointed by p. No destructors or copy constructors are called. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: 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, list& x) BOOST_CONTAINER_NOEXCEPT - { - BOOST_ASSERT(this != &x); - BOOST_ASSERT(this->node_alloc() == x.node_alloc()); - this->icont().splice(p.get(), x.icont()); - } - - //! Requires: p must point to an element contained - //! by the list. x != *this. this' allocator and x's allocator shall compare equal - //! - //! Effects: Transfers all the elements of list x to this list, before the - //! the element pointed by p. No destructors or copy constructors are called. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: 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(x)); } - - //! Requires: p must point to an element contained - //! by this list. i must point to an element contained in list x. - //! this' allocator and x's allocator shall compare equal - //! - //! Effects: 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. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: 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, list &x, const_iterator i) BOOST_CONTAINER_NOEXCEPT - { - //BOOST_ASSERT(this != &x); - BOOST_ASSERT(this->node_alloc() == x.node_alloc()); - this->icont().splice(p.get(), x.icont(), i.get()); - } - - //! Requires: p must point to an element contained - //! by this list. i must point to an element contained in list x. - //! this' allocator and x's allocator shall compare equal. - //! - //! Effects: 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. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: 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(x), i); } - - //! Requires: p must point to an element contained - //! by this list. first and last must point to elements contained in list x. - //! this' allocator and x's allocator shall compare equal - //! - //! Effects: 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. - //! - //! Throws: Nothing - //! - //! Complexity: Linear to the number of elements transferred. - //! - //! Note: 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, list &x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT - { - BOOST_ASSERT(this->node_alloc() == x.node_alloc()); - this->icont().splice(p.get(), x.icont(), first.get(), last.get()); - } - - //! Requires: p must point to an element contained - //! by this list. first and last must point to elements contained in list x. - //! this' allocator and x's allocator shall compare equal. - //! - //! Effects: 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. - //! - //! Throws: Nothing - //! - //! Complexity: Linear to the number of elements transferred. - //! - //! Note: 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(x), first, last); } - - //! Requires: 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). this' allocator and x's allocator shall compare equal - //! - //! Effects: 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. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: 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. - //! - //! Note: Non-standard extension - void splice(const_iterator p, list &x, const_iterator first, const_iterator last, size_type n) BOOST_CONTAINER_NOEXCEPT - { - BOOST_ASSERT(this->node_alloc() == x.node_alloc()); - this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n); - } - - //! Requires: 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). this' allocator and x's allocator shall compare equal - //! - //! Effects: 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. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: 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. - //! - //! Note: 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(x), first, last, n); } - - //! Effects: Removes all the elements that compare equal to value. - //! - //! Throws: If comparison throws. - //! - //! Complexity: Linear time. It performs exactly size() comparisons for equality. - //! - //! Note: 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) - { this->remove_if(equal_to_value(value)); } - - //! Effects: Removes all the elements for which a specified - //! predicate is satisfied. - //! - //! Throws: If pred throws. - //! - //! Complexity: Linear time. It performs exactly size() calls to the predicate. - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - template - void remove_if(Pred pred) - { - typedef ValueCompareToNodeCompare Predicate; - this->icont().remove_and_dispose_if(Predicate(pred), Destroyer(this->node_alloc())); - } - - //! Effects: Removes adjacent duplicate elements or adjacent - //! elements that are equal from the list. - //! - //! Throws: If comparison throws. - //! - //! Complexity: Linear time (size()-1 comparisons equality comparisons). - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - void unique() - { this->unique(value_equal()); } - - //! Effects: Removes adjacent duplicate elements or adjacent - //! elements that satisfy some binary predicate from the list. - //! - //! Throws: If pred throws. - //! - //! Complexity: Linear time (size()-1 comparisons calls to pred()). - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - template - void unique(BinaryPredicate binary_pred) - { - typedef ValueCompareToNodeCompare Predicate; - this->icont().unique_and_dispose(Predicate(binary_pred), Destroyer(this->node_alloc())); - } - - //! Requires: The lists x and *this must be distinct. - //! - //! Effects: This function removes all of x's elements and inserts them - //! in order into *this according to std::less. 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. - //! - //! Throws: If comparison throws. - //! - //! Complexity: This function is linear time: it performs at most - //! size() + x.size() - 1 comparisons. - void merge(list &x) - { this->merge(x, value_less()); } - - //! Requires: The lists x and *this must be distinct. - //! - //! Effects: This function removes all of x's elements and inserts them - //! in order into *this according to std::less. 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. - //! - //! Throws: If comparison throws. - //! - //! Complexity: 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(x)); } - - //! Requires: 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. - //! - //! Effects: 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. - //! - //! Throws: If comp throws. - //! - //! Complexity: This function is linear time: it performs at most - //! size() + x.size() - 1 comparisons. - //! - //! Note: Iterators and references to *this are not invalidated. - template - void merge(list &x, const StrictWeakOrdering &comp) - { - BOOST_ASSERT(this->node_alloc() == x.node_alloc()); - this->icont().merge(x.icont(), - ValueCompareToNodeCompare(comp)); - } - - //! Requires: 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. - //! - //! Effects: 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. - //! - //! Throws: If comp throws. - //! - //! Complexity: This function is linear time: it performs at most - //! size() + x.size() - 1 comparisons. - //! - //! Note: Iterators and references to *this are not invalidated. - template - void merge(BOOST_RV_REF(list) x, StrictWeakOrdering comp) - { this->merge(static_cast(x), comp); } - - //! Effects: This function sorts the list *this according to std::less. - //! The sort is stable, that is, the relative order of equivalent elements is preserved. - //! - //! Throws: If comparison throws. - //! - //! Notes: Iterators and references are not invalidated. - //! - //! Complexity: The number of comparisons is approximately N log N, where N - //! is the list's size. - void sort() - { this->sort(value_less()); } - - //! Effects: This function sorts the list *this according to std::less. - //! The sort is stable, that is, the relative order of equivalent elements is preserved. - //! - //! Throws: If comp throws. - //! - //! Notes: Iterators and references are not invalidated. - //! - //! Complexity: The number of comparisons is approximately N log N, where N - //! is the list's size. - template - void sort(StrictWeakOrdering comp) - { - // nothing if the list has length 0 or 1. - if (this->size() < 2) - return; - this->icont().sort(ValueCompareToNodeCompare(comp)); - } - - //! Effects: Reverses the order of elements in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: This function is linear time. - //! - //! Note: Iterators and references are not invalidated - void reverse() BOOST_CONTAINER_NOEXCEPT - { this->icont().reverse(); } - - //! Effects: Returns true if x and y are equal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator==(const list& x, const list& y) - { - if(x.size() != y.size()){ - return false; - } - typedef typename list::const_iterator const_iterator; - const_iterator end1 = x.end(); - - const_iterator i1 = x.begin(); - const_iterator i2 = y.begin(); - while (i1 != end1 && *i1 == *i2) { - ++i1; - ++i2; - } - return i1 == end1; - } - - //! Effects: Returns true if x and y are unequal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator!=(const list& x, const list& y) - { return !(x == y); } - - //! Effects: Returns true if x is less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<(const list& x, const list& y) - { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } - - //! Effects: Returns true if x is greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>(const list& x, const list& y) - { return y < x; } - - //! Effects: Returns true if x is equal or less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<=(const list& x, const list& y) - { return !(y < x); } - - //! Effects: Returns true if x is equal or greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>=(const list& x, const list& y) - { return !(x < y); } - - //! Effects: x.swap(y) - //! - //! Complexity: Constant. - friend void swap(list& x, list& y) - { x.swap(y); } - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - 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); - return iterator(this->icont().insert(p.get(), *tmp)); - } - - iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x) - { - NodePtr tmp = AllocHolder::create_node(boost::move(x)); - return iterator(this->icont().insert(p.get(), *tmp)); - } - - void priv_push_back (const T &x) - { this->insert(this->cend(), x); } - - void priv_push_back (BOOST_RV_REF(T) x) - { this->insert(this->cend(), boost::move(x)); } - - void priv_push_front (const T &x) - { this->insert(this->cbegin(), x); } - - void priv_push_front (BOOST_RV_REF(T) x) - { this->insert(this->cbegin(), boost::move(x)); } - - class insertion_functor; - friend class insertion_functor; - - class insertion_functor - { - Icont &icont_; - typedef typename Icont::const_iterator iconst_iterator; - const iconst_iterator pos_; - - public: - insertion_functor(Icont &icont, typename Icont::const_iterator pos) - : icont_(icont), pos_(pos) - {} - - void operator()(Node &n) - { - this->icont_.insert(pos_, n); - } - }; - - //Functors for member algorithm defaults - struct value_less - { - bool operator()(const value_type &a, const value_type &b) const - { return a < b; } - }; - - struct value_equal - { - bool operator()(const value_type &a, const value_type &b) const - { return a == b; } - }; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -}; - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -} //namespace container { - -//!has_trivial_destructor_after_move<> == true_type -//!specialization for optimizations -template -struct has_trivial_destructor_after_move > - : public ::boost::has_trivial_destructor_after_move -{}; - -namespace container { - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -}} - -#include - -#endif // BOOST_CONTAINER_LIST_HPP diff --git a/boost/container/map.hpp b/boost/container/map.hpp deleted file mode 100644 index 6abfa1a..0000000 --- a/boost/container/map.hpp +++ /dev/null @@ -1,1406 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_MAP_HPP -#define BOOST_CONTAINER_MAP_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) -#include -#endif - -namespace boost { -namespace container { - -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED - -//! A map is a kind of associative container that supports unique keys (contains at -//! most one of each key value) and provides for fast retrieval of values of another -//! type T based on the keys. The map class supports bidirectional iterators. -//! -//! A map satisfies all of the requirements of a container and of a reversible -//! container and of an associative container. The value_type stored -//! by this container is the value_type is std::pair. -//! -//! \tparam Key is the key_type of the map -//! \tparam Value is the mapped_type -//! \tparam Compare is the ordering function for Keys (e.g. std::less). -//! \tparam Allocator is the allocator to allocate the value_types -//! (e.g. allocator< std::pair > ). -//! \tparam MapOptions is an packed option type generated using using boost::container::tree_assoc_options. -template < class Key, class T, class Compare = std::less - , class Allocator = std::allocator< std::pair< const Key, T> >, class MapOptions = tree_assoc_defaults > -#else -template -#endif -class map - ///@cond - : public container_detail::tree - < Key, std::pair - , container_detail::select1st< std::pair > - , Compare, Allocator, MapOptions> - ///@endcond -{ - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - BOOST_COPYABLE_AND_MOVABLE(map) - - typedef std::pair value_type_impl; - typedef container_detail::tree - , Compare, Allocator, MapOptions> base_t; - typedef container_detail::pair movable_value_type_impl; - typedef container_detail::tree_value_compare - < Key, value_type_impl, Compare, container_detail::select1st - > value_compare_impl; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - ////////////////////////////////////////////// - // - // types - // - ////////////////////////////////////////////// - - typedef Key key_type; - typedef ::boost::container::allocator_traits allocator_traits_type; - typedef T mapped_type; - typedef std::pair value_type; - typedef typename boost::container::allocator_traits::pointer pointer; - typedef typename boost::container::allocator_traits::const_pointer const_pointer; - typedef typename boost::container::allocator_traits::reference reference; - typedef typename boost::container::allocator_traits::const_reference const_reference; - typedef typename boost::container::allocator_traits::size_type size_type; - typedef typename boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; - typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare; - typedef Compare key_compare; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; - typedef std::pair nonconst_value_type; - typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type; - - ////////////////////////////////////////////// - // - // construct/copy/destroy - // - ////////////////////////////////////////////// - - //! Effects: Default constructs an empty map. - //! - //! Complexity: Constant. - map() - : base_t() - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty map using the specified comparison object - //! and allocator. - //! - //! Complexity: Constant. - explicit map(const Compare& comp, - const allocator_type& a = allocator_type()) - : base_t(comp, a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty map using the specified allocator. - //! - //! Complexity: Constant. - explicit map(const allocator_type& a) - : base_t(a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty map using the specified comparison object and - //! allocator, and inserts elements from the range [first ,last ). - //! - //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. - template - map(InputIterator first, InputIterator last, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(true, first, last, comp, a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty map using the specified comparison object and - //! allocator, and inserts elements from the ordered unique range [first ,last). This function - //! is more efficient than the normal range creation for ordered ranges. - //! - //! Requires: [first ,last) must be ordered according to the predicate and must be - //! unique values. - //! - //! Complexity: Linear in N. - //! - //! Note: Non-standard extension. - template - map( ordered_unique_range_t, InputIterator first, InputIterator last - , const Compare& comp = Compare(), const allocator_type& a = allocator_type()) - : base_t(ordered_range, first, last, comp, a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs an empty map using the specified comparison object and - //! allocator, and inserts elements from the range [il.begin(), il.end()). - //! - //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is il.first() - il.end(). - map(std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) - : base_t(true, il.begin(), il.end(), comp, a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - map(ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(ordered_range, il.begin(), il.end(), comp, a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } -#endif - - //! Effects: Copy constructs a map. - //! - //! Complexity: Linear in x.size(). - map(const map& x) - : base_t(static_cast(x)) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Move constructs a map. Constructs *this using x's resources. - //! - //! Complexity: Constant. - //! - //! Postcondition: x is emptied. - map(BOOST_RV_REF(map) x) - : base_t(boost::move(static_cast(x))) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Copy constructs a map using the specified allocator. - //! - //! Complexity: Linear in x.size(). - map(const map& x, const allocator_type &a) - : base_t(static_cast(x), a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Move constructs a map using the specified allocator. - //! Constructs *this using x's resources. - //! - //! Complexity: Constant if x == x.get_allocator(), linear otherwise. - //! - //! Postcondition: x is emptied. - map(BOOST_RV_REF(map) x, const allocator_type &a) - : base_t(boost::move(static_cast(x)), a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Makes *this a copy of x. - //! - //! Complexity: Linear in x.size(). - map& operator=(BOOST_COPY_ASSIGN_REF(map) x) - { return static_cast(this->base_t::operator=(static_cast(x))); } - - //! Effects: this->swap(x.get()). - //! - //! Throws: If allocator_traits_type::propagate_on_container_move_assignment - //! is false and (allocation throws or value_type's move constructor throws) - //! - //! Complexity: Constant if allocator_traits_type:: - //! propagate_on_container_move_assignment is true or - //! this->get>allocator() == x.get_allocator(). Linear otherwise. - map& operator=(BOOST_RV_REF(map) x) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) - { return static_cast(this->base_t::operator=(boost::move(static_cast(x)))); } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Assign content of il to *this. - //! - map& operator=(std::initializer_list il) - { - this->clear(); - insert(il.begin(), il.end()); - return *this; - } -#endif - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Returns a copy of the Allocator that - //! was passed to the object's constructor. - //! - //! Complexity: Constant. - allocator_type get_allocator() const; - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns an iterator to the first element contained in the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator begin() BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns a const_iterator to the first element contained in the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator begin() const BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns a const_iterator to the first element contained in the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns an iterator to the end of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator end() BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns a const_iterator to the end of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator end() const BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns a const_iterator to the end of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns a reverse_iterator pointing to the beginning - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns a reverse_iterator pointing to the end - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns true if the container contains no elements. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - bool empty() const BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns the number of the elements contained in the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type size() const BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns the largest possible size of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type max_size() const BOOST_CONTAINER_NOEXCEPT; - - #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: If there is no key equivalent to x in the map, inserts - //! value_type(x, T()) into the map. - //! - //! Returns: Allocator reference to the mapped_type corresponding to x in *this. - //! - //! Complexity: Logarithmic. - mapped_type& operator[](const key_type &k); - - //! Effects: If there is no key equivalent to x in the map, inserts - //! value_type(boost::move(x), T()) into the map (the key is move-constructed) - //! - //! Returns: Allocator reference to the mapped_type corresponding to x in *this. - //! - //! Complexity: Logarithmic. - mapped_type& operator[](key_type &&k); - #else - BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript) - #endif - - //! Returns: Allocator reference to the element whose key is equivalent to x. - //! Throws: An exception object of type out_of_range if no such element is present. - //! Complexity: logarithmic. - T& at(const key_type& k) - { - iterator i = this->find(k); - if(i == this->end()){ - throw_out_of_range("map::at key not found"); - } - return i->second; - } - - //! Returns: Allocator reference to the element whose key is equivalent to x. - //! Throws: An exception object of type out_of_range if no such element is present. - //! Complexity: logarithmic. - const T& at(const key_type& k) const - { - const_iterator i = this->find(k); - if(i == this->end()){ - throw_out_of_range("map::at key not found"); - } - return i->second; - } - - ////////////////////////////////////////////// - // - // modifiers - // - ////////////////////////////////////////////// - - //! Effects: Inserts x if and only if there is no element in the container - //! with key equivalent to the key of x. - //! - //! Returns: The bool component of the returned pair is true if and only - //! if the insertion takes place, and the iterator component of the pair - //! points to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic. - std::pair insert(const value_type& x) - { return this->base_t::insert_unique(x); } - - //! Effects: Inserts a new value_type created from the pair if and only if - //! there is no element in the container with key equivalent to the key of x. - //! - //! Returns: The bool component of the returned pair is true if and only - //! if the insertion takes place, and the iterator component of the pair - //! points to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic. - std::pair insert(const nonconst_value_type& x) - { return this->base_t::insert_unique(x); } - - //! Effects: Inserts a new value_type move constructed from the pair if and - //! only if there is no element in the container with key equivalent to the key of x. - //! - //! Returns: The bool component of the returned pair is true if and only - //! if the insertion takes place, and the iterator component of the pair - //! points to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic. - std::pair insert(BOOST_RV_REF(nonconst_value_type) x) - { return this->base_t::insert_unique(boost::move(x)); } - - //! Effects: Inserts a new value_type move constructed from the pair if and - //! only if there is no element in the container with key equivalent to the key of x. - //! - //! Returns: The bool component of the returned pair is true if and only - //! if the insertion takes place, and the iterator component of the pair - //! points to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic. - std::pair insert(BOOST_RV_REF(movable_value_type) x) - { return this->base_t::insert_unique(boost::move(x)); } - - //! Effects: Move constructs a new value from x if and only if there is - //! no element in the container with key equivalent to the key of x. - //! - //! Returns: The bool component of the returned pair is true if and only - //! if the insertion takes place, and the iterator component of the pair - //! points to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic. - std::pair insert(BOOST_RV_REF(value_type) x) - { return this->base_t::insert_unique(boost::move(x)); } - - //! Effects: Inserts a copy of x in the container if and only if there is - //! no element in the container with key equivalent to the key of x. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - iterator insert(const_iterator p, const value_type& x) - { return this->base_t::insert_unique(p, x); } - - //! Effects: Move constructs a new value from x if and only if there is - //! no element in the container with key equivalent to the key of x. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - iterator insert(const_iterator p, BOOST_RV_REF(nonconst_value_type) x) - { return this->base_t::insert_unique(p, boost::move(x)); } - - //! Effects: Move constructs a new value from x if and only if there is - //! no element in the container with key equivalent to the key of x. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x) - { return this->base_t::insert_unique(p, boost::move(x)); } - - //! Effects: Inserts a copy of x in the container. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic. - iterator insert(const_iterator p, const nonconst_value_type& x) - { return this->base_t::insert_unique(p, x); } - - //! Effects: Inserts an element move constructed from x in the container. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic. - iterator insert(const_iterator p, BOOST_RV_REF(value_type) x) - { return this->base_t::insert_unique(p, boost::move(x)); } - - //! Requires: first, last are not iterators into *this. - //! - //! Effects: inserts each element from the range [first,last) if and only - //! if there is no element with key equivalent to the key of that element. - //! - //! Complexity: At most N log(size()+N) (N is the distance from first to last) - template - void insert(InputIterator first, InputIterator last) - { this->base_t::insert_unique(first, last); } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: inserts each element from the range [il.begin(), il.end()) if and only - //! if there is no element with key equivalent to the key of that element. - //! - //! Complexity: At most N log(size()+N) (N is the distance from il.begin() to il.end()) - void insert(std::initializer_list il) - { this->base_t::insert_unique(il.begin(), il.end()); } -#endif - - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Inserts an object x of type T constructed with - //! std::forward(args)... in the container if and only if there is - //! no element in the container with an equivalent key. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: The bool component of the returned pair is true if and only - //! if the insertion takes place, and the iterator component of the pair - //! points to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - template - std::pair emplace(Args&&... args) - { return this->base_t::emplace_unique(boost::forward(args)...); } - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... in the container if and only if there is - //! no element in the container with an equivalent key. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - template - iterator emplace_hint(const_iterator p, Args&&... args) - { return this->base_t::emplace_hint_unique(p, boost::forward(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, >) \ - std::pair emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_unique(BOOST_PP_ENUM(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_hint(const_iterator p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_hint_unique(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 - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Erases the element pointed to by p. - //! - //! Returns: Returns an iterator pointing to the element immediately - //! following q prior to the element being erased. If no such element exists, - //! returns end(). - //! - //! Complexity: Amortized constant time - iterator erase(const_iterator p) BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Erases all elements in the container with key equivalent to x. - //! - //! Returns: Returns the number of erased elements. - //! - //! Complexity: log(size()) + count(k) - size_type erase(const key_type& x) BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Erases all the elements in the range [first, last). - //! - //! Returns: Returns last. - //! - //! Complexity: log(size())+N where N is the distance from first to last. - iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Swaps the contents of *this and x. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - void swap(map& x); - - //! Effects: erase(a.begin(),a.end()). - //! - //! Postcondition: size() == 0. - //! - //! Complexity: linear in size(). - void clear() BOOST_CONTAINER_NOEXCEPT; - - //! Effects: Returns the comparison object out - //! of which a was constructed. - //! - //! Complexity: Constant. - key_compare key_comp() const; - - //! Effects: Returns an object of value_compare constructed out - //! of the comparison object. - //! - //! Complexity: Constant. - value_compare value_comp() const; - - //! Returns: An iterator pointing to an element with the key - //! equivalent to x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic. - iterator find(const key_type& x); - - //! Returns: Allocator const_iterator pointing to an element with the key - //! equivalent to x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic. - const_iterator find(const key_type& x) const; - - #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Returns: The number of elements with key equivalent to x. - //! - //! Complexity: log(size())+count(k) - size_type count(const key_type& x) const - { return static_cast(this->find(x) != this->cend()); } - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Returns: An iterator pointing to the first element with key not less - //! than k, or a.end() if such an element is not found. - //! - //! Complexity: Logarithmic - iterator lower_bound(const key_type& x); - - //! Returns: Allocator const iterator pointing to the first element with key not - //! less than k, or a.end() if such an element is not found. - //! - //! Complexity: Logarithmic - const_iterator lower_bound(const key_type& x) const; - - //! Returns: An iterator pointing to the first element with key not less - //! than x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic - iterator upper_bound(const key_type& x); - - //! Returns: Allocator const iterator pointing to the first element with key not - //! less than x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic - const_iterator upper_bound(const key_type& x) const; - - //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). - //! - //! Complexity: Logarithmic - std::pair equal_range(const key_type& x); - - //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). - //! - //! Complexity: Logarithmic - std::pair equal_range(const key_type& x) const; - - //! Effects: Rebalances the tree. It's a no-op for Red-Black and AVL trees. - //! - //! Complexity: Linear - void rebalance(); - - //! Effects: Returns true if x and y are equal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator==(const map& x, const map& y); - - //! Effects: Returns true if x and y are unequal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator!=(const map& x, const map& y); - - //! Effects: Returns true if x is less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<(const map& x, const map& y); - - //! Effects: Returns true if x is greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>(const map& x, const map& y); - - //! Effects: Returns true if x is equal or less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<=(const map& x, const map& y); - - //! Effects: Returns true if x is equal or greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>=(const map& x, const map& y); - - //! Effects: x.swap(y) - //! - //! Complexity: Constant. - friend void swap(map& x, map& y); - - #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - mapped_type& priv_subscript(const key_type &k) - { - //we can optimize this - iterator i = this->lower_bound(k); - // i->first is greater than or equivalent to k. - if (i == this->end() || this->key_comp()(k, (*i).first)){ - container_detail::value_init m; - movable_value_type val(k, boost::move(m.m_t)); - i = insert(i, boost::move(val)); - } - return (*i).second; - } - - mapped_type& priv_subscript(BOOST_RV_REF(key_type) mk) - { - key_type &k = mk; - //we can optimize this - iterator i = this->lower_bound(k); - // i->first is greater than or equivalent to k. - if (i == this->end() || this->key_comp()(k, (*i).first)){ - container_detail::value_init m; - movable_value_type val(boost::move(k), boost::move(m.m_t)); - i = insert(i, boost::move(val)); - } - return (*i).second; - } - - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -}; - - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -} //namespace container { - -//!has_trivial_destructor_after_move<> == true_type -//!specialization for optimizations -template -struct has_trivial_destructor_after_move > -{ - static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value; -}; - -namespace container { - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED - -//! A multimap is a kind of associative container that supports equivalent keys -//! (possibly containing multiple copies of the same key value) and provides for -//! fast retrieval of values of another type T based on the keys. The multimap class -//! supports bidirectional iterators. -//! -//! A multimap satisfies all of the requirements of a container and of a reversible -//! container and of an associative container. The value_type stored -//! by this container is the value_type is std::pair. -//! -//! \tparam Key is the key_type of the map -//! \tparam Value is the mapped_type -//! \tparam Compare is the ordering function for Keys (e.g. std::less). -//! \tparam Allocator is the allocator to allocate the value_types -//! (e.g. allocator< std::pair > ). -//! \tparam MultiMapOptions is an packed option type generated using using boost::container::tree_assoc_options. -template < class Key, class T, class Compare = std::less - , class Allocator = std::allocator< std::pair< const Key, T> >, class MultiMapOptions = tree_assoc_defaults> -#else -template -#endif -class multimap - ///@cond - : public container_detail::tree - < Key, std::pair - , container_detail::select1st< std::pair > - , Compare, Allocator, MultiMapOptions> - ///@endcond -{ - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - BOOST_COPYABLE_AND_MOVABLE(multimap) - - typedef std::pair value_type_impl; - typedef container_detail::tree - , Compare, Allocator, MultiMapOptions> base_t; - typedef container_detail::pair movable_value_type_impl; - typedef container_detail::tree_value_compare - < Key, value_type_impl, Compare, container_detail::select1st - > value_compare_impl; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - ////////////////////////////////////////////// - // - // types - // - ////////////////////////////////////////////// - - typedef Key key_type; - typedef T mapped_type; - typedef std::pair value_type; - typedef typename boost::container::allocator_traits::pointer pointer; - typedef typename boost::container::allocator_traits::const_pointer const_pointer; - typedef typename boost::container::allocator_traits::reference reference; - typedef typename boost::container::allocator_traits::const_reference const_reference; - typedef typename boost::container::allocator_traits::size_type size_type; - typedef typename boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; - typedef BOOST_CONTAINER_IMPDEF(value_compare_impl) value_compare; - typedef Compare key_compare; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; - typedef std::pair nonconst_value_type; - typedef BOOST_CONTAINER_IMPDEF(movable_value_type_impl) movable_value_type; - - ////////////////////////////////////////////// - // - // construct/copy/destroy - // - ////////////////////////////////////////////// - - //! Effects: Default constructs an empty multimap. - //! - //! Complexity: Constant. - multimap() - : base_t() - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty multimap using the specified allocator. - //! - //! Complexity: Constant. - explicit multimap(const Compare& comp, const allocator_type& a = allocator_type()) - : base_t(comp, a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty multimap using the specified comparison - //! object and allocator. - //! - //! Complexity: Constant. - explicit multimap(const allocator_type& a) - : base_t(a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty multimap using the specified comparison object - //! and allocator, and inserts elements from the range [first ,last ). - //! - //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. - template - multimap(InputIterator first, InputIterator last, - const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(false, first, last, comp, a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Constructs an empty multimap using the specified comparison object and - //! allocator, and inserts elements from the ordered range [first ,last). This function - //! is more efficient than the normal range creation for ordered ranges. - //! - //! Requires: [first ,last) must be ordered according to the predicate. - //! - //! Complexity: Linear in N. - //! - //! Note: Non-standard extension. - template - multimap(ordered_range_t, InputIterator first, InputIterator last, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(ordered_range, first, last, comp, a) - {} - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs an empty multimap using the specified comparison object and - //! allocator, and inserts elements from the range [il.begin(), il.end()). - //! - //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is il.first() - il.end(). - multimap(std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(false, il.begin(), il.end(), comp, a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - multimap(ordered_range_t, std::initializer_list il, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(ordered_range, il.begin(), il.end(), comp, a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } -#endif - - //! Effects: Copy constructs a multimap. - //! - //! Complexity: Linear in x.size(). - multimap(const multimap& x) - : base_t(static_cast(x)) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Move constructs a multimap. Constructs *this using x's resources. - //! - //! Complexity: Constant. - //! - //! Postcondition: x is emptied. - multimap(BOOST_RV_REF(multimap) x) - : base_t(boost::move(static_cast(x))) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Copy constructs a multimap. - //! - //! Complexity: Linear in x.size(). - multimap(const multimap& x, const allocator_type &a) - : base_t(static_cast(x), a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Move constructs a multimap using the specified allocator. - //! Constructs *this using x's resources. - //! Complexity: Constant if a == x.get_allocator(), linear otherwise. - //! - //! Postcondition: x is emptied. - multimap(BOOST_RV_REF(multimap) x, const allocator_type &a) - : base_t(boost::move(static_cast(x)), a) - { - //Allocator type must be std::pair - BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); - } - - //! Effects: Makes *this a copy of x. - //! - //! Complexity: Linear in x.size(). - multimap& operator=(BOOST_COPY_ASSIGN_REF(multimap) x) - { return static_cast(this->base_t::operator=(static_cast(x))); } - - //! Effects: this->swap(x.get()). - //! - //! Complexity: Constant. - multimap& operator=(BOOST_RV_REF(multimap) x) - { return static_cast(this->base_t::operator=(boost::move(static_cast(x)))); } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Assign content of il to *this. - //! - multimap& operator=(std::initializer_list il) - { - this->clear(); - insert(il.begin(), il.end()); - return *this; - } -#endif - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! @copydoc ::boost::container::set::get_allocator() - allocator_type get_allocator() const; - - //! @copydoc ::boost::container::set::get_stored_allocator() - stored_allocator_type &get_stored_allocator(); - - //! @copydoc ::boost::container::set::get_stored_allocator() const - const stored_allocator_type &get_stored_allocator() const; - - //! @copydoc ::boost::container::set::begin() - iterator begin(); - - //! @copydoc ::boost::container::set::begin() const - const_iterator begin() const; - - //! @copydoc ::boost::container::set::cbegin() const - const_iterator cbegin() const; - - //! @copydoc ::boost::container::set::end() - iterator end() BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::end() const - const_iterator end() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::cend() const - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::rbegin() - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::rbegin() const - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::crbegin() const - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::rend() - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::rend() const - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::crend() const - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::empty() const - bool empty() const; - - //! @copydoc ::boost::container::set::size() const - size_type size() const; - - //! @copydoc ::boost::container::set::max_size() const - size_type max_size() const; - - #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... in the container. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - template - iterator emplace(Args&&... args) - { return this->base_t::emplace_equal(boost::forward(args)...); } - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... in the container. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - template - iterator emplace_hint(const_iterator p, Args&&... args) - { return this->base_t::emplace_hint_equal(p, boost::forward(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(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_equal(BOOST_PP_ENUM(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_hint(const_iterator p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_hint_equal(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 - - //! Effects: Inserts x and returns the iterator pointing to the - //! newly inserted element. - //! - //! Complexity: Logarithmic. - iterator insert(const value_type& x) - { return this->base_t::insert_equal(x); } - - //! Effects: Inserts a new value constructed from x and returns - //! the iterator pointing to the newly inserted element. - //! - //! Complexity: Logarithmic. - iterator insert(const nonconst_value_type& x) - { return this->base_t::insert_equal(x); } - - //! Effects: Inserts a new value move-constructed from x and returns - //! the iterator pointing to the newly inserted element. - //! - //! Complexity: Logarithmic. - iterator insert(BOOST_RV_REF(nonconst_value_type) x) - { return this->base_t::insert_equal(boost::move(x)); } - - //! Effects: Inserts a new value move-constructed from x and returns - //! the iterator pointing to the newly inserted element. - //! - //! Complexity: Logarithmic. - iterator insert(BOOST_RV_REF(movable_value_type) x) - { return this->base_t::insert_equal(boost::move(x)); } - - //! Effects: Inserts a copy of x in the container. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - iterator insert(const_iterator p, const value_type& x) - { return this->base_t::insert_equal(p, x); } - - //! Effects: Inserts a new value constructed from x in the container. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - iterator insert(const_iterator p, const nonconst_value_type& x) - { return this->base_t::insert_equal(p, x); } - - //! Effects: Inserts a new value move constructed from x in the container. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - iterator insert(const_iterator p, BOOST_RV_REF(nonconst_value_type) x) - { return this->base_t::insert_equal(p, boost::move(x)); } - - //! Effects: Inserts a new value move constructed from x in the container. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - iterator insert(const_iterator p, BOOST_RV_REF(movable_value_type) x) - { return this->base_t::insert_equal(p, boost::move(x)); } - - //! Requires: first, last are not iterators into *this. - //! - //! Effects: inserts each element from the range [first,last) . - //! - //! Complexity: At most N log(size()+N) (N is the distance from first to last) - template - void insert(InputIterator first, InputIterator last) - { this->base_t::insert_equal(first, last); } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: inserts each element from the range [il.begin(), il.end(). - //! - //! Complexity: At most N log(size()+N) (N is the distance from il.begin() to il.end()) - void insert(std::initializer_list il) - { this->base_t::insert_equal(il.begin(), il.end()); } -#endif - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! @copydoc ::boost::container::set::erase(const_iterator) - iterator erase(const_iterator p); - - //! @copydoc ::boost::container::set::erase(const key_type&) - size_type erase(const key_type& x); - - //! @copydoc ::boost::container::set::erase(const_iterator,const_iterator) - iterator erase(const_iterator first, const_iterator last); - - //! @copydoc ::boost::container::set::swap - void swap(flat_multiset& x); - - //! @copydoc ::boost::container::set::clear - void clear() BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::key_comp - key_compare key_comp() const; - - //! @copydoc ::boost::container::set::value_comp - value_compare value_comp() const; - - //! Returns: An iterator pointing to an element with the key - //! equivalent to x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic. - iterator find(const key_type& x); - - //! Returns: Allocator const iterator pointing to an element with the key - //! equivalent to x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic. - const_iterator find(const key_type& x) const; - - //! Returns: The number of elements with key equivalent to x. - //! - //! Complexity: log(size())+count(k) - size_type count(const key_type& x) const; - - //! Returns: An iterator pointing to the first element with key not less - //! than k, or a.end() if such an element is not found. - //! - //! Complexity: Logarithmic - iterator lower_bound(const key_type& x); - - //! Returns: Allocator const iterator pointing to the first element with key not - //! less than k, or a.end() if such an element is not found. - //! - //! Complexity: Logarithmic - const_iterator lower_bound(const key_type& x) const; - - //! Returns: An iterator pointing to the first element with key not less - //! than x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic - iterator upper_bound(const key_type& x); - - //! Returns: Allocator const iterator pointing to the first element with key not - //! less than x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic - const_iterator upper_bound(const key_type& x) const; - - //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). - //! - //! Complexity: Logarithmic - std::pair equal_range(const key_type& x); - - //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). - //! - //! Complexity: Logarithmic - std::pair equal_range(const key_type& x) const; - - //! Effects: Rebalances the tree. It's a no-op for Red-Black and AVL trees. - //! - //! Complexity: Linear - void rebalance(); - - //! Effects: Returns true if x and y are equal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator==(const multimap& x, const multimap& y); - - //! Effects: Returns true if x and y are unequal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator!=(const multimap& x, const multimap& y); - - //! Effects: Returns true if x is less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<(const multimap& x, const multimap& y); - - //! Effects: Returns true if x is greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>(const multimap& x, const multimap& y); - - //! Effects: Returns true if x is equal or less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<=(const multimap& x, const multimap& y); - - //! Effects: Returns true if x is equal or greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>=(const multimap& x, const multimap& y); - - //! Effects: x.swap(y) - //! - //! Complexity: Constant. - friend void swap(multimap& x, multimap& y); - - #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) -}; - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -} //namespace container { - -//!has_trivial_destructor_after_move<> == true_type -//!specialization for optimizations -template -struct has_trivial_destructor_after_move > -{ - static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value; -}; - -namespace container { - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -}} - -#include - -#endif /* BOOST_CONTAINER_MAP_HPP */ - diff --git a/boost/container/new_allocator.hpp b/boost/container/new_allocator.hpp new file mode 100644 index 0000000..1ac15d8 --- /dev/null +++ b/boost/container/new_allocator.hpp @@ -0,0 +1,175 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the 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_NEW_ALLOCATOR_HPP +#define BOOST_CONTAINER_NEW_ALLOCATOR_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include +#include +#include +#include + +//!\file + +namespace boost { +namespace container { + +template +struct new_allocator_bool +{ static const bool value = Value; }; + +template +class new_allocator; + +//! Specialization of new_allocator for void types +template<> +class new_allocator +{ + public: + typedef void value_type; + typedef void * pointer; + typedef const void* const_pointer; + //!A integral constant of type bool with value true + typedef BOOST_CONTAINER_IMPDEF(new_allocator_bool) propagate_on_container_move_assignment; + //!A integral constant of type bool with value true + typedef BOOST_CONTAINER_IMPDEF(new_allocator_bool) is_always_equal; + // reference-to-void members are impossible + + //!Obtains an new_allocator that allocates + //!objects of type T2 + template + struct rebind + { + typedef new_allocator< T2> other; + }; + + //!Default constructor + //!Never throws + new_allocator() BOOST_NOEXCEPT_OR_NOTHROW + {} + + //!Constructor from other new_allocator. + //!Never throws + new_allocator(const new_allocator &) BOOST_NOEXCEPT_OR_NOTHROW + {} + + //!Constructor from related new_allocator. + //!Never throws + template + new_allocator(const new_allocator &) BOOST_NOEXCEPT_OR_NOTHROW + {} + + //!Swaps two allocators, does nothing + //!because this new_allocator is stateless + friend void swap(new_allocator &, new_allocator &) BOOST_NOEXCEPT_OR_NOTHROW + {} + + //!An new_allocator always compares to true, as memory allocated with one + //!instance can be deallocated by another instance + friend bool operator==(const new_allocator &, const new_allocator &) BOOST_NOEXCEPT_OR_NOTHROW + { return true; } + + //!An new_allocator always compares to false, as memory allocated with one + //!instance can be deallocated by another instance + friend bool operator!=(const new_allocator &, const new_allocator &) BOOST_NOEXCEPT_OR_NOTHROW + { return false; } +}; + + +//! This class is a reduced STL-compatible allocator that allocates memory using operator new +template +class new_allocator +{ + public: + typedef T value_type; + typedef T * pointer; + typedef const T * const_pointer; + typedef T & reference; + typedef const T & const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + //!A integral constant of type bool with value true + typedef BOOST_CONTAINER_IMPDEF(new_allocator_bool) propagate_on_container_move_assignment; + //!A integral constant of type bool with value true + typedef BOOST_CONTAINER_IMPDEF(new_allocator_bool) is_always_equal; + + //!Obtains an new_allocator that allocates + //!objects of type T2 + template + struct rebind + { + typedef new_allocator other; + }; + + //!Default constructor + //!Never throws + new_allocator() BOOST_NOEXCEPT_OR_NOTHROW + {} + + //!Constructor from other new_allocator. + //!Never throws + new_allocator(const new_allocator &) BOOST_NOEXCEPT_OR_NOTHROW + {} + + //!Constructor from related new_allocator. + //!Never throws + template + new_allocator(const new_allocator &) BOOST_NOEXCEPT_OR_NOTHROW + {} + + //!Allocates memory for an array of count elements. + //!Throws std::bad_alloc if there is no enough memory + pointer allocate(size_type count) + { + if(BOOST_UNLIKELY(count > this->max_size())) + throw_bad_alloc(); + return static_cast(::operator new(count*sizeof(T))); + } + + //!Deallocates previously allocated memory. + //!Never throws + void deallocate(pointer ptr, size_type) BOOST_NOEXCEPT_OR_NOTHROW + { ::operator delete((void*)ptr); } + + //!Returns the maximum number of elements that could be allocated. + //!Never throws + size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW + { return size_type(-1)/sizeof(T); } + + //!Swaps two allocators, does nothing + //!because this new_allocator is stateless + friend void swap(new_allocator &, new_allocator &) BOOST_NOEXCEPT_OR_NOTHROW + {} + + //!An new_allocator always compares to true, as memory allocated with one + //!instance can be deallocated by another instance + friend bool operator==(const new_allocator &, const new_allocator &) BOOST_NOEXCEPT_OR_NOTHROW + { return true; } + + //!An new_allocator always compares to false, as memory allocated with one + //!instance can be deallocated by another instance + friend bool operator!=(const new_allocator &, const new_allocator &) BOOST_NOEXCEPT_OR_NOTHROW + { return false; } +}; + +} //namespace container { +} //namespace boost { + +#include + +#endif //BOOST_CONTAINER_ALLOCATOR_HPP diff --git a/boost/container/node_allocator.hpp b/boost/container/node_allocator.hpp deleted file mode 100644 index 8004339..0000000 --- a/boost/container/node_allocator.hpp +++ /dev/null @@ -1,344 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2008-2013. Distributed under the 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_POOLED_NODE_ALLOCATOR_HPP -#define BOOST_CONTAINER_POOLED_NODE_ALLOCATOR_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace container { - -//!An STL node allocator that uses a modified DlMalloc as memory -//!source. -//! -//!This node allocator shares a segregated storage between all instances -//!of node_allocator with equal sizeof(T). -//! -//!NodesPerBlock is the number of nodes allocated at once when the allocator -//!runs out of nodes -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template - < class T - , std::size_t NodesPerBlock = NodeAlloc_nodes_per_block> -#else -template - < class T - , std::size_t NodesPerBlock - , std::size_t Version> -#endif -class node_allocator -{ - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - //! If Version is 1, the allocator is a STL conforming allocator. If Version is 2, - //! the allocator offers advanced expand in place and burst allocation capabilities. - public: - typedef unsigned int allocation_type; - typedef node_allocator self_t; - - static const std::size_t nodes_per_block = NodesPerBlock; - - BOOST_STATIC_ASSERT((Version <=2)); - #endif - - public: - //------- - typedef T value_type; - typedef T * pointer; - typedef const T * const_pointer; - typedef typename ::boost::container:: - container_detail::unvoid::type & reference; - typedef const typename ::boost::container:: - container_detail::unvoid::type & const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - typedef boost::container::container_detail:: - version_type version; - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef boost::container::container_detail:: - basic_multiallocation_chain multiallocation_chain_void; - typedef boost::container::container_detail:: - transform_multiallocation_chain - multiallocation_chain; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - //!Obtains node_allocator from - //!node_allocator - template - struct rebind - { - typedef node_allocator< T2, NodesPerBlock - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - , Version - #endif - > other; - }; - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - //!Not assignable from related node_allocator - template - node_allocator& operator= - (const node_allocator&); - - //!Not assignable from other node_allocator - node_allocator& operator=(const node_allocator&); - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - - //!Default constructor - node_allocator() BOOST_CONTAINER_NOEXCEPT - {} - - //!Copy constructor from other node_allocator. - node_allocator(const node_allocator &) BOOST_CONTAINER_NOEXCEPT - {} - - //!Copy constructor from related node_allocator. - template - node_allocator - (const node_allocator &) BOOST_CONTAINER_NOEXCEPT - {} - - //!Destructor - ~node_allocator() BOOST_CONTAINER_NOEXCEPT - {} - - //!Returns the number of elements that could be allocated. - //!Never throws - size_type max_size() const - { return size_type(-1)/sizeof(T); } - - //!Allocate memory for an array of count elements. - //!Throws std::bad_alloc if there is no enough memory - pointer allocate(size_type count, const void * = 0) - { - if(count > this->max_size()) - boost::container::throw_bad_alloc(); - - if(Version == 1 && count == 1){ - typedef container_detail::shared_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - return pointer(static_cast(singleton_t::instance().allocate_node())); - } - else{ - void *ret = boost_cont_malloc(count*sizeof(T)); - if(!ret) - boost::container::throw_bad_alloc(); - return static_cast(ret); - } - } - - //!Deallocate allocated memory. - //!Never throws - void deallocate(const pointer &ptr, size_type count) BOOST_CONTAINER_NOEXCEPT - { - (void)count; - if(Version == 1 && count == 1){ - typedef container_detail::shared_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - singleton_t::instance().deallocate_node(ptr); - } - else{ - boost_cont_free(ptr); - } - } - - //!Deallocates all free blocks of the pool - static void deallocate_free_blocks() BOOST_CONTAINER_NOEXCEPT - { - typedef container_detail::shared_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - singleton_t::instance().deallocate_free_blocks(); - } - - std::pair - allocation_command(allocation_type command, - size_type limit_size, - size_type preferred_size, - size_type &received_size, pointer reuse = pointer()) - { - BOOST_STATIC_ASSERT(( Version > 1 )); - std::pair ret = - priv_allocation_command(command, limit_size, preferred_size, received_size, reuse); - if(!ret.first && !(command & BOOST_CONTAINER_NOTHROW_ALLOCATION)) - boost::container::throw_bad_alloc(); - return ret; - } - - //!Returns maximum the number of objects the previously allocated memory - //!pointed by p can hold. - size_type size(pointer p) const BOOST_CONTAINER_NOEXCEPT - { - BOOST_STATIC_ASSERT(( Version > 1 )); - return boost_cont_size(p); - } - - //!Allocates just one object. Memory allocated with this function - //!must be deallocated only with deallocate_one(). - //!Throws bad_alloc if there is no enough memory - pointer allocate_one() - { - BOOST_STATIC_ASSERT(( Version > 1 )); - typedef container_detail::shared_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - return (pointer)singleton_t::instance().allocate_node(); - } - - //!Allocates many elements of size == 1. - //!Elements must be individually deallocated with deallocate_one() - void allocate_individual(std::size_t num_elements, multiallocation_chain &chain) - { - BOOST_STATIC_ASSERT(( Version > 1 )); - typedef container_detail::shared_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - typename shared_pool_t::multiallocation_chain ch; - singleton_t::instance().allocate_nodes(num_elements, ch); - chain.incorporate_after(chain.before_begin(), (T*)&*ch.begin(), (T*)&*ch.last(), ch.size()); - } - - //!Deallocates memory previously allocated with allocate_one(). - //!You should never use deallocate_one to deallocate memory allocated - //!with other functions different from allocate_one(). Never throws - void deallocate_one(pointer p) BOOST_CONTAINER_NOEXCEPT - { - BOOST_STATIC_ASSERT(( Version > 1 )); - typedef container_detail::shared_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - singleton_t::instance().deallocate_node(p); - } - - void deallocate_individual(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT - { - BOOST_STATIC_ASSERT(( Version > 1 )); - typedef container_detail::shared_node_pool - shared_pool_t; - typedef container_detail::singleton_default singleton_t; - typename shared_pool_t::multiallocation_chain ch(&*chain.begin(), &*chain.last(), chain.size()); - singleton_t::instance().deallocate_nodes(ch); - } - - //!Allocates many elements of size elem_size. - //!Elements must be individually deallocated with deallocate() - void allocate_many(size_type elem_size, std::size_t n_elements, multiallocation_chain &chain) - { - BOOST_STATIC_ASSERT(( Version > 1 )); - boost_cont_memchain ch; - BOOST_CONTAINER_MEMCHAIN_INIT(&ch); - if(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){ - boost::container::throw_bad_alloc(); - } - chain.incorporate_after( chain.before_begin() - , (T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch) - , (T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch) - , BOOST_CONTAINER_MEMCHAIN_SIZE(&ch)); - } - - //!Allocates n_elements elements, each one of size elem_sizes[i] - //!Elements must be individually deallocated with deallocate() - void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain) - { - BOOST_STATIC_ASSERT(( Version > 1 )); - boost_cont_memchain ch; - boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch); - if(BOOST_CONTAINER_MEMCHAIN_EMPTY(&ch)){ - boost::container::throw_bad_alloc(); - } - chain.incorporate_after( chain.before_begin() - , (T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch) - , (T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch) - , BOOST_CONTAINER_MEMCHAIN_SIZE(&ch)); - } - - void deallocate_many(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT - { - BOOST_STATIC_ASSERT(( Version > 1 )); - void *first = &*chain.begin(); - void *last = &*chain.last(); - size_t num = chain.size(); - boost_cont_memchain ch; - BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&ch, first, last, num); - boost_cont_multidealloc(&ch); - } - - //!Swaps allocators. Does not throw. If each allocator is placed in a - //!different memory segment, the result is undefined. - friend void swap(self_t &, self_t &) BOOST_CONTAINER_NOEXCEPT - {} - - //!An allocator always compares to true, as memory allocated with one - //!instance can be deallocated by another instance - friend bool operator==(const node_allocator &, const node_allocator &) BOOST_CONTAINER_NOEXCEPT - { return true; } - - //!An allocator always compares to false, as memory allocated with one - //!instance can be deallocated by another instance - friend bool operator!=(const node_allocator &, const node_allocator &) BOOST_CONTAINER_NOEXCEPT - { return false; } - - private: - std::pair priv_allocation_command - (allocation_type command, std::size_t limit_size - ,std::size_t preferred_size,std::size_t &received_size, void *reuse_ptr) - { - boost_cont_command_ret_t ret = {0 , 0}; - if(limit_size > this->max_size() || preferred_size > this->max_size()){ - //ret.first = 0; - return std::pair(pointer(), false); - } - std::size_t l_size = limit_size*sizeof(T); - std::size_t p_size = preferred_size*sizeof(T); - std::size_t r_size; - { - ret = boost_cont_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr); - } - received_size = r_size/sizeof(T); - return std::pair(static_cast(ret.first), !!ret.second); - } -}; - -} //namespace container { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_CONTAINER_POOLED_NODE_ALLOCATOR_HPP diff --git a/boost/container/options.hpp b/boost/container/options.hpp deleted file mode 100644 index c36ad30..0000000 --- a/boost/container/options.hpp +++ /dev/null @@ -1,76 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2013-2013 -// -// Distributed under the 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_OPTIONS_HPP -#define BOOST_CONTAINER_OPTIONS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include - -namespace boost { -namespace container { - -#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - -template -struct tree_opt -{ - static const boost::container::tree_type_enum tree_type = TreeType; - static const bool optimize_size = OptimizeSize; -}; - -#endif //!defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - -//!This option setter specifies the underlying tree type -//!(red-black, AVL, Scapegoat or Splay) for ordered associative containers -BOOST_INTRUSIVE_OPTION_CONSTANT(tree_type, tree_type_enum, TreeType, tree_type) - -//!This option setter specifies if node size is optimized -//!storing rebalancing data masked into pointers for ordered associative containers -BOOST_INTRUSIVE_OPTION_CONSTANT(optimize_size, bool, Enabled, optimize_size) - -//! Helper metafunction to combine options into a single type to be used -//! by \c boost::container::set, \c boost::container::multiset -//! \c boost::container::map and \c boost::container::multimap. -//! Supported options are: \c boost::container::optimize_size and \c boost::container::tree_type -#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct tree_assoc_options -{ - /// @cond - typedef typename ::boost::intrusive::pack_options - < tree_assoc_defaults, - #if !defined(BOOST_CONTAINER_VARIADIC_TEMPLATES) - O1, O2, O3, O4 - #else - Options... - #endif - >::type packed_options; - typedef tree_opt implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -} //namespace container { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_CONTAINER_OPTIONS_HPP diff --git a/boost/container/scoped_allocator.hpp b/boost/container/scoped_allocator.hpp deleted file mode 100644 index 0a29871..0000000 --- a/boost/container/scoped_allocator.hpp +++ /dev/null @@ -1,1534 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Pablo Halpern 2009. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the 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_ALLOCATOR_SCOPED_ALLOCATOR_HPP -#define BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP - -#if defined (_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { namespace container { - -//! Remark: if a specialization is derived from true_type, indicates that T may be constructed -//! with an allocator as its last constructor argument. Ideally, all constructors of T (including the -//! copy and move constructors) should have a variant that accepts a final argument of -//! allocator_type. -//! -//! Requires: if a specialization is derived from true_type, T must have a nested type, -//! allocator_type and at least one constructor for which allocator_type is the last -//! parameter. If not all constructors of T can be called with a final allocator_type argument, -//! and if T is used in a context where a container must call such a constructor, then the program is -//! ill-formed. -//! -//! -//! template > -//! class Z { -//! public: -//! typedef Allocator allocator_type; -//! -//! // Default constructor with optional allocator suffix -//! Z(const allocator_type& a = allocator_type()); -//! -//! // Copy constructor and allocator-extended copy constructor -//! Z(const Z& zz); -//! Z(const Z& zz, const allocator_type& a); -//! }; -//! -//! // Specialize trait for class template Z -//! template > -//! struct constructible_with_allocator_suffix > -//! : ::boost::true_type { }; -//! -//! -//! Note: This trait is a workaround inspired by "N2554: The Scoped Allocator Model (Rev 2)" -//! (Pablo Halpern, 2008-02-29) to backport the scoped allocator model to C++03, as -//! in C++03 there is no mechanism to detect if a type can be constructed from arbitrary arguments. -//! Applications aiming portability with several compilers should always define this trait. -//! -//! In conforming C++11 compilers or compilers supporting SFINAE expressions -//! (when BOOST_NO_SFINAE_EXPR is NOT defined), this trait is ignored and C++11 rules will be used -//! to detect if a type should be constructed with suffix or prefix allocator arguments. -template -struct constructible_with_allocator_suffix - : ::boost::false_type -{}; - -//! Remark: if a specialization is derived from true_type, indicates that T may be constructed -//! with allocator_arg and T::allocator_type as its first two constructor arguments. -//! Ideally, all constructors of T (including the copy and move constructors) should have a variant -//! that accepts these two initial arguments. -//! -//! Requires: if a specialization is derived from true_type, T must have a nested type, -//! allocator_type and at least one constructor for which allocator_arg_t is the first -//! parameter and allocator_type is the second parameter. If not all constructors of T can be -//! called with these initial arguments, and if T is used in a context where a container must call such -//! a constructor, then the program is ill-formed. -//! -//! -//! template > -//! class Y { -//! public: -//! typedef Allocator allocator_type; -//! -//! // Default constructor with and allocator-extended default constructor -//! Y(); -//! Y(allocator_arg_t, const allocator_type& a); -//! -//! // Copy constructor and allocator-extended copy constructor -//! Y(const Y& yy); -//! Y(allocator_arg_t, const allocator_type& a, const Y& yy); -//! -//! // Variadic constructor and allocator-extended variadic constructor -//! template Y(Args&& args...); -//! template -//! Y(allocator_arg_t, const allocator_type& a, Args&&... args); -//! }; -//! -//! // Specialize trait for class template Y -//! template > -//! struct constructible_with_allocator_prefix > -//! : ::boost::true_type { }; -//! -//! -//! -//! Note: This trait is a workaround inspired by "N2554: The Scoped Allocator Model (Rev 2)" -//! (Pablo Halpern, 2008-02-29) to backport the scoped allocator model to C++03, as -//! in C++03 there is no mechanism to detect if a type can be constructed from arbitrary arguments. -//! Applications aiming portability with several compilers should always define this trait. -//! -//! In conforming C++11 compilers or compilers supporting SFINAE expressions -//! (when BOOST_NO_SFINAE_EXPR is NOT defined), this trait is ignored and C++11 rules will be used -//! to detect if a type should be constructed with suffix or prefix allocator arguments. -template -struct constructible_with_allocator_prefix - : ::boost::false_type -{}; - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -namespace container_detail { - -template -struct uses_allocator_imp -{ - // Use SFINAE (Substitution Failure Is Not An Error) to detect the - // presence of an 'allocator_type' nested type convertilble from Alloc. - - private: - // Match this function if TypeT::allocator_type exists and is - // implicitly convertible from Alloc - template - static char test(int, typename U::allocator_type); - - // Match this function if TypeT::allocator_type does not exist or is - // not convertible from Alloc. - template - static int test(LowPriorityConversion, LowPriorityConversion); - - static Alloc alloc; // Declared but not defined - - public: - enum { value = sizeof(test(0, alloc)) == sizeof(char) }; -}; - -} //namespace container_detail { - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -//! Remark: Automatically detects if T has a nested allocator_type that is convertible from -//! Alloc. Meets the BinaryTypeTrait requirements ([meta.rqmts] 20.4.1). A program may -//! specialize this type to derive from true_type for a T of user-defined type if T does not -//! have a nested allocator_type but is nonetheless constructible using the specified Alloc. -//! -//! Result: derived from true_type if Convertible and -//! derived from false_type otherwise. -template -struct uses_allocator - : boost::integral_constant::value> -{}; - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -namespace container_detail { - -template -struct is_scoped_allocator_imp -{ - template - static char test(int, typename T::outer_allocator_type*); - - template - static int test(LowPriorityConversion, void*); - - static const bool value = (sizeof(char) == sizeof(test(0, 0))); -}; - -template::value > -struct outermost_allocator_type_impl -{ - typedef typename MaybeScopedAlloc::outer_allocator_type outer_type; - typedef typename outermost_allocator_type_impl::type type; -}; - -template -struct outermost_allocator_type_impl -{ - typedef MaybeScopedAlloc type; -}; - -template::value > -struct outermost_allocator_imp -{ - typedef MaybeScopedAlloc type; - - static type &get(MaybeScopedAlloc &a) - { return a; } - - static const type &get(const MaybeScopedAlloc &a) - { return a; } -}; - -template -struct outermost_allocator_imp -{ - typedef typename MaybeScopedAlloc::outer_allocator_type outer_type; - typedef typename outermost_allocator_type_impl::type type; - - static type &get(MaybeScopedAlloc &a) - { return outermost_allocator_imp::get(a.outer_allocator()); } - - static const type &get(const MaybeScopedAlloc &a) - { return outermost_allocator_imp::get(a.outer_allocator()); } -}; - -} //namespace container_detail { - -template -struct is_scoped_allocator - : boost::integral_constant::value> -{}; - -template -struct outermost_allocator - : container_detail::outermost_allocator_imp -{}; - -template -typename container_detail::outermost_allocator_imp::type & - get_outermost_allocator(Alloc &a) -{ return container_detail::outermost_allocator_imp::get(a); } - -template -const typename container_detail::outermost_allocator_imp::type & - get_outermost_allocator(const Alloc &a) -{ return container_detail::outermost_allocator_imp::get(a); } - -namespace container_detail { - -// Check if we can detect is_convertible using advanced SFINAE expressions -#if !defined(BOOST_NO_SFINAE_EXPR) - - //! Code inspired by Mathias Gaunard's is_convertible.cpp found in the Boost mailing list - //! http://boost.2283326.n4.nabble.com/type-traits-is-constructible-when-decltype-is-supported-td3575452.html - //! Thanks Mathias! - - //With variadic templates, we need a single class to implement the trait - #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - template - struct is_constructible_impl - { - typedef char yes_type; - struct no_type - { char padding[2]; }; - - template - struct dummy; - - template - static yes_type test(dummy()...))>*); - - template - static no_type test(...); - - static const bool value = sizeof(test(0)) == sizeof(yes_type); - }; - - template - struct is_constructible - : boost::integral_constant::value> - {}; - - template - struct is_constructible_with_allocator_prefix - : is_constructible - {}; - - #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - //Without variadic templates, we need to use the preprocessor to generate - //some specializations. - - #define BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS \ - BOOST_PP_ADD(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, 3) - //! - - //Generate N+1 template parameters so that we can specialize N - template - struct is_constructible_impl; - - //Generate N specializations, from 0 to - //BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS parameters - #define BOOST_PP_LOCAL_MACRO(n) \ - template \ - struct is_constructible_impl \ - \ - { \ - typedef char yes_type; \ - struct no_type \ - { char padding[2]; }; \ - \ - template \ - struct dummy; \ - \ - template \ - static yes_type test(dummy*); \ - \ - template \ - static no_type test(...); \ - \ - static const bool value = sizeof(test(0)) == sizeof(yes_type); \ - }; \ - //! - - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() - - //Finally just inherit from the implementation to define he trait - template< class T - BOOST_PP_ENUM_TRAILING( BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS - , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT - , void) - > - struct is_constructible - : boost::integral_constant - < bool - , is_constructible_impl - < T - BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, P) - , void>::value - > - {}; - - //Finally just inherit from the implementation to define he trait - template - struct is_constructible_with_allocator_prefix - : is_constructible - < T, allocator_arg_t, InnerAlloc - BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, 2), P) - > - {}; -/* - template - struct is_constructible_with_allocator_suffix - : is_constructible - < T - BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_SUB(BOOST_CONTAINER_MAX_IS_CONSTRUCTIBLE_PARAMETERS, 1), P) - , InnerAlloc - > - {};*/ - - #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - -#else // #if !defined(BOOST_NO_SFINAE_EXPR) - - //Without advanced SFINAE expressions, we can't use is_constructible - //so backup to constructible_with_allocator_xxx - - #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - template < class T, class InnerAlloc, class ...Args> - struct is_constructible_with_allocator_prefix - : constructible_with_allocator_prefix - {}; -/* - template < class T, class InnerAlloc, class ...Args> - struct is_constructible_with_allocator_suffix - : constructible_with_allocator_suffix - {};*/ - - #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - template < class T - , class InnerAlloc - BOOST_PP_ENUM_TRAILING( BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS - , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT - , void) - > - struct is_constructible_with_allocator_prefix - : constructible_with_allocator_prefix - {}; -/* - template < class T - , class InnerAlloc - BOOST_PP_ENUM_TRAILING( BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS - , BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT - , void) - > - struct is_constructible_with_allocator_suffix - : constructible_with_allocator_suffix - {};*/ - - #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - -#endif // #if !defined(BOOST_NO_SFINAE_EXPR) - -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - -template < typename OutermostAlloc - , typename InnerAlloc - , typename T - , class ...Args - > -inline void dispatch_allocator_prefix_suffix - ( boost::true_type use_alloc_prefix, OutermostAlloc& outermost_alloc - , InnerAlloc& inner_alloc, T* p, BOOST_FWD_REF(Args) ...args) -{ - (void)use_alloc_prefix; - allocator_traits::construct - ( outermost_alloc, p, allocator_arg, inner_alloc, ::boost::forward(args)...); -} - -template < typename OutermostAlloc - , typename InnerAlloc - , typename T - , class ...Args - > -inline void dispatch_allocator_prefix_suffix - ( boost::false_type use_alloc_prefix, OutermostAlloc& outermost_alloc - , InnerAlloc &inner_alloc, T* p, BOOST_FWD_REF(Args)...args) -{ - (void)use_alloc_prefix; - allocator_traits::construct - (outermost_alloc, p, ::boost::forward(args)..., inner_alloc); -} - -template < typename OutermostAlloc - , typename InnerAlloc - , typename T - , class ...Args - > -inline void dispatch_uses_allocator - ( boost::true_type uses_allocator, OutermostAlloc& outermost_alloc - , InnerAlloc& inner_alloc, T* p, BOOST_FWD_REF(Args)...args) -{ - (void)uses_allocator; - //BOOST_STATIC_ASSERT((is_constructible_with_allocator_prefix::value || - // is_constructible_with_allocator_suffix::value )); - dispatch_allocator_prefix_suffix - ( is_constructible_with_allocator_prefix() - , outermost_alloc, inner_alloc, p, ::boost::forward(args)...); -} - -template < typename OutermostAlloc - , typename InnerAlloc - , typename T - , class ...Args - > -inline void dispatch_uses_allocator - ( boost::false_type uses_allocator, OutermostAlloc & outermost_alloc - , InnerAlloc & inner_alloc - ,T* p, BOOST_FWD_REF(Args)...args) -{ - (void)uses_allocator; (void)inner_alloc; - allocator_traits::construct - (outermost_alloc, p, ::boost::forward(args)...); -} - -#else //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - -#define BOOST_PP_LOCAL_MACRO(n) \ -template < typename OutermostAlloc \ - , typename InnerAlloc \ - , typename T \ - BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \ - > \ -inline void dispatch_allocator_prefix_suffix( \ - boost::true_type use_alloc_prefix, \ - OutermostAlloc& outermost_alloc, \ - InnerAlloc& inner_alloc, \ - T* p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ -{ \ - (void)use_alloc_prefix, \ - allocator_traits::construct \ - (outermost_alloc, p, allocator_arg, inner_alloc \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ -} \ - \ -template < typename OutermostAlloc \ - , typename InnerAlloc \ - , typename T \ - BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \ - > \ -inline void dispatch_allocator_prefix_suffix( \ - boost::false_type use_alloc_prefix, \ - OutermostAlloc& outermost_alloc, \ - InnerAlloc& inner_alloc, \ - T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ -{ \ - (void)use_alloc_prefix; \ - allocator_traits::construct \ - (outermost_alloc, p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) \ - , inner_alloc); \ -} \ - \ -template < typename OutermostAlloc \ - , typename InnerAlloc \ - , typename T \ - BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \ - > \ -inline void dispatch_uses_allocator(boost::true_type uses_allocator, \ - OutermostAlloc& outermost_alloc, \ - InnerAlloc& inner_alloc, \ - T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ -{ \ - (void)uses_allocator; \ - dispatch_allocator_prefix_suffix \ - (is_constructible_with_allocator_prefix \ - < T, InnerAlloc BOOST_PP_ENUM_TRAILING_PARAMS(n, P)>() \ - , outermost_alloc, inner_alloc, p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ -} \ - \ -template < typename OutermostAlloc \ - , typename InnerAlloc \ - , typename T \ - BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \ - > \ -inline void dispatch_uses_allocator(boost::false_type uses_allocator \ - ,OutermostAlloc & outermost_alloc \ - ,InnerAlloc & inner_alloc \ - ,T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ -{ \ - (void)uses_allocator; (void)inner_alloc; \ - allocator_traits::construct \ - (outermost_alloc, 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 //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - -template -class scoped_allocator_adaptor_base - : public OuterAlloc -{ - typedef allocator_traits outer_traits_type; - BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor_base) - - public: - template - struct rebind_base - { - typedef scoped_allocator_adaptor_base other; - }; - - typedef OuterAlloc outer_allocator_type; - typedef scoped_allocator_adaptor inner_allocator_type; - typedef allocator_traits inner_traits_type; - typedef scoped_allocator_adaptor - scoped_allocator_type; - typedef boost::integral_constant< - bool, - outer_traits_type::propagate_on_container_copy_assignment::value || - inner_allocator_type::propagate_on_container_copy_assignment::value - > propagate_on_container_copy_assignment; - typedef boost::integral_constant< - bool, - outer_traits_type::propagate_on_container_move_assignment::value || - inner_allocator_type::propagate_on_container_move_assignment::value - > propagate_on_container_move_assignment; - typedef boost::integral_constant< - bool, - outer_traits_type::propagate_on_container_swap::value || - inner_allocator_type::propagate_on_container_swap::value - > propagate_on_container_swap; - - scoped_allocator_adaptor_base() - {} - - template - scoped_allocator_adaptor_base(BOOST_FWD_REF(OuterA2) outerAlloc, const InnerAllocs &...args) - : outer_allocator_type(::boost::forward(outerAlloc)) - , m_inner(args...) - {} - - scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other) - : outer_allocator_type(other.outer_allocator()) - , m_inner(other.inner_allocator()) - {} - - scoped_allocator_adaptor_base(BOOST_RV_REF(scoped_allocator_adaptor_base) other) - : outer_allocator_type(::boost::move(other.outer_allocator())) - , m_inner(::boost::move(other.inner_allocator())) - {} - - template - scoped_allocator_adaptor_base - (const scoped_allocator_adaptor_base& other) - : outer_allocator_type(other.outer_allocator()) - , m_inner(other.inner_allocator()) - {} - - template - scoped_allocator_adaptor_base - (BOOST_RV_REF_BEG scoped_allocator_adaptor_base - BOOST_RV_REF_END other) - : outer_allocator_type(other.outer_allocator()) - , m_inner(other.inner_allocator()) - {} - - public: - struct internal_type_t{}; - - template - scoped_allocator_adaptor_base - ( internal_type_t - , BOOST_FWD_REF(OuterA2) outerAlloc - , const inner_allocator_type &inner) - : outer_allocator_type(::boost::forward(outerAlloc)) - , m_inner(inner) - {} - - public: - - scoped_allocator_adaptor_base &operator= - (BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other) - { - outer_allocator_type::operator=(other.outer_allocator()); - m_inner = other.inner_allocator(); - return *this; - } - - scoped_allocator_adaptor_base &operator=(BOOST_RV_REF(scoped_allocator_adaptor_base) other) - { - outer_allocator_type::operator=(boost::move(other.outer_allocator())); - m_inner = ::boost::move(other.inner_allocator()); - return *this; - } - - void swap(scoped_allocator_adaptor_base &r) - { - boost::container::swap_dispatch(this->outer_allocator(), r.outer_allocator()); - boost::container::swap_dispatch(this->m_inner, r.inner_allocator()); - } - - friend void swap(scoped_allocator_adaptor_base &l, scoped_allocator_adaptor_base &r) - { l.swap(r); } - - inner_allocator_type& inner_allocator() BOOST_CONTAINER_NOEXCEPT - { return m_inner; } - - inner_allocator_type const& inner_allocator() const BOOST_CONTAINER_NOEXCEPT - { return m_inner; } - - outer_allocator_type & outer_allocator() BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this); } - - const outer_allocator_type &outer_allocator() const BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this); } - - scoped_allocator_type select_on_container_copy_construction() const - { - return scoped_allocator_type - (internal_type_t() - ,outer_traits_type::select_on_container_copy_construction(this->outer_allocator()) - ,inner_traits_type::select_on_container_copy_construction(this->inner_allocator()) - ); - } - - private: - inner_allocator_type m_inner; -}; - -#else //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - -//Let's add a dummy first template parameter to allow creating -//specializations up to maximum InnerAlloc count -template < - typename OuterAlloc - , bool Dummy - BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, class Q) - > -class scoped_allocator_adaptor_base; - -//Specializations for the adaptor with InnerAlloc allocators - -#define BOOST_PP_LOCAL_MACRO(n) \ -template \ -class scoped_allocator_adaptor_base \ - : public OuterAlloc \ -{ \ - typedef allocator_traits outer_traits_type; \ - BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor_base) \ - \ - public: \ - template \ - struct rebind_base \ - { \ - typedef scoped_allocator_adaptor_base other; \ - }; \ - \ - typedef OuterAlloc outer_allocator_type; \ - typedef scoped_allocator_adaptor inner_allocator_type; \ - typedef scoped_allocator_adaptor scoped_allocator_type; \ - typedef allocator_traits inner_traits_type; \ - typedef boost::integral_constant< \ - bool, \ - outer_traits_type::propagate_on_container_copy_assignment::value || \ - inner_allocator_type::propagate_on_container_copy_assignment::value \ - > propagate_on_container_copy_assignment; \ - typedef boost::integral_constant< \ - bool, \ - outer_traits_type::propagate_on_container_move_assignment::value || \ - inner_allocator_type::propagate_on_container_move_assignment::value \ - > propagate_on_container_move_assignment; \ - typedef boost::integral_constant< \ - bool, \ - outer_traits_type::propagate_on_container_swap::value || \ - inner_allocator_type::propagate_on_container_swap::value \ - > propagate_on_container_swap; \ - \ - scoped_allocator_adaptor_base() \ - {} \ - \ - template \ - scoped_allocator_adaptor_base(BOOST_FWD_REF(OuterA2) outerAlloc \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q, _)) \ - : outer_allocator_type(::boost::forward(outerAlloc)) \ - , m_inner(BOOST_PP_ENUM_PARAMS(n, q)) \ - {} \ - \ - scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other) \ - : outer_allocator_type(other.outer_allocator()) \ - , m_inner(other.inner_allocator()) \ - {} \ - \ - scoped_allocator_adaptor_base(BOOST_RV_REF(scoped_allocator_adaptor_base) other) \ - : outer_allocator_type(::boost::move(other.outer_allocator())) \ - , m_inner(::boost::move(other.inner_allocator())) \ - {} \ - \ - template \ - scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other) \ - : outer_allocator_type(other.outer_allocator()) \ - , m_inner(other.inner_allocator()) \ - {} \ - \ - template \ - scoped_allocator_adaptor_base \ - (BOOST_RV_REF_BEG scoped_allocator_adaptor_base BOOST_RV_REF_END other) \ - : outer_allocator_type(other.outer_allocator()) \ - , m_inner(other.inner_allocator()) \ - {} \ - \ - public: \ - struct internal_type_t{}; \ - \ - template \ - scoped_allocator_adaptor_base \ - ( internal_type_t \ - , BOOST_FWD_REF(OuterA2) outerAlloc \ - , const inner_allocator_type &inner) \ - : outer_allocator_type(::boost::forward(outerAlloc)) \ - , m_inner(inner) \ - {} \ - \ - public: \ - scoped_allocator_adaptor_base &operator= \ - (BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other) \ - { \ - outer_allocator_type::operator=(other.outer_allocator()); \ - m_inner = other.inner_allocator(); \ - return *this; \ - } \ - \ - scoped_allocator_adaptor_base &operator=(BOOST_RV_REF(scoped_allocator_adaptor_base) other) \ - { \ - outer_allocator_type::operator=(boost::move(other.outer_allocator())); \ - m_inner = ::boost::move(other.inner_allocator()); \ - return *this; \ - } \ - \ - void swap(scoped_allocator_adaptor_base &r) \ - { \ - boost::container::swap_dispatch(this->outer_allocator(), r.outer_allocator()); \ - boost::container::swap_dispatch(this->m_inner, r.inner_allocator()); \ - } \ - \ - friend void swap(scoped_allocator_adaptor_base &l, scoped_allocator_adaptor_base &r) \ - { l.swap(r); } \ - \ - inner_allocator_type& inner_allocator() \ - { return m_inner; } \ - \ - inner_allocator_type const& inner_allocator() const \ - { return m_inner; } \ - \ - outer_allocator_type & outer_allocator() \ - { return static_cast(*this); } \ - \ - const outer_allocator_type &outer_allocator() const \ - { return static_cast(*this); } \ - \ - scoped_allocator_type select_on_container_copy_construction() const \ - { \ - return scoped_allocator_type \ - (internal_type_t() \ - ,outer_traits_type::select_on_container_copy_construction(this->outer_allocator()) \ - ,inner_traits_type::select_on_container_copy_construction(this->inner_allocator()) \ - ); \ - } \ - private: \ - inner_allocator_type m_inner; \ -}; \ -//! -#define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) -#include BOOST_PP_LOCAL_ITERATE() - -#endif //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - -//Specialization for adaptor without any InnerAlloc -template -class scoped_allocator_adaptor_base - < OuterAlloc - #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - , true - BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, nat) - #endif - > - : public OuterAlloc -{ - BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor_base) - public: - - template - struct rebind_base - { - typedef scoped_allocator_adaptor_base - ::template portable_rebind_alloc::type - #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - , true - BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat) - #endif - > other; - }; - - typedef OuterAlloc outer_allocator_type; - typedef allocator_traits outer_traits_type; - typedef scoped_allocator_adaptor inner_allocator_type; - typedef inner_allocator_type scoped_allocator_type; - typedef allocator_traits inner_traits_type; - typedef typename outer_traits_type:: - propagate_on_container_copy_assignment propagate_on_container_copy_assignment; - typedef typename outer_traits_type:: - propagate_on_container_move_assignment propagate_on_container_move_assignment; - typedef typename outer_traits_type:: - propagate_on_container_swap propagate_on_container_swap; - - scoped_allocator_adaptor_base() - {} - - template - scoped_allocator_adaptor_base(BOOST_FWD_REF(OuterA2) outerAlloc) - : outer_allocator_type(::boost::forward(outerAlloc)) - {} - - scoped_allocator_adaptor_base(const scoped_allocator_adaptor_base& other) - : outer_allocator_type(other.outer_allocator()) - {} - - scoped_allocator_adaptor_base(BOOST_RV_REF(scoped_allocator_adaptor_base) other) - : outer_allocator_type(::boost::move(other.outer_allocator())) - {} - - template - scoped_allocator_adaptor_base - (const scoped_allocator_adaptor_base< - OuterA2 - #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - , true - BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat) - #endif - >& other) - : outer_allocator_type(other.outer_allocator()) - {} - - template - scoped_allocator_adaptor_base - (BOOST_RV_REF_BEG scoped_allocator_adaptor_base< - OuterA2 - #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - , true - BOOST_PP_ENUM_TRAILING(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, BOOST_CONTAINER_PP_IDENTITY, container_detail::nat) - #endif - > BOOST_RV_REF_END other) - : outer_allocator_type(other.outer_allocator()) - {} - - public: - struct internal_type_t{}; - - template - scoped_allocator_adaptor_base(internal_type_t, BOOST_FWD_REF(OuterA2) outerAlloc, const inner_allocator_type &) - : outer_allocator_type(::boost::forward(outerAlloc)) - {} - - public: - scoped_allocator_adaptor_base &operator=(BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor_base) other) - { - outer_allocator_type::operator=(other.outer_allocator()); - return *this; - } - - scoped_allocator_adaptor_base &operator=(BOOST_RV_REF(scoped_allocator_adaptor_base) other) - { - outer_allocator_type::operator=(boost::move(other.outer_allocator())); - return *this; - } - - void swap(scoped_allocator_adaptor_base &r) - { - boost::container::swap_dispatch(this->outer_allocator(), r.outer_allocator()); - } - - friend void swap(scoped_allocator_adaptor_base &l, scoped_allocator_adaptor_base &r) - { l.swap(r); } - - inner_allocator_type& inner_allocator() - { return static_cast(*this); } - - inner_allocator_type const& inner_allocator() const - { return static_cast(*this); } - - outer_allocator_type & outer_allocator() - { return static_cast(*this); } - - const outer_allocator_type &outer_allocator() const - { return static_cast(*this); } - - scoped_allocator_type select_on_container_copy_construction() const - { - return scoped_allocator_type - (internal_type_t() - ,outer_traits_type::select_on_container_copy_construction(this->outer_allocator()) - //Don't use inner_traits_type::select_on_container_copy_construction(this->inner_allocator()) - //as inner_allocator() is equal to *this and that would trigger an infinite loop - , this->inner_allocator() - ); - } -}; - -} //namespace container_detail { - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -//Scoped allocator -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) - - //! This class is a C++03-compatible implementation of std::scoped_allocator_adaptor. - //! The class template scoped_allocator_adaptor is an allocator template that specifies - //! the memory resource (the outer allocator) to be used by a container (as any other - //! allocator does) and also specifies an inner allocator resource to be passed to - //! the constructor of every element within the container. - //! - //! This adaptor is - //! instantiated with one outer and zero or more inner allocator types. If - //! instantiated with only one allocator type, the inner allocator becomes the - //! scoped_allocator_adaptor itself, thus using the same allocator resource for the - //! container and every element within the container and, if the elements themselves - //! are containers, each of their elements recursively. If instantiated with more than - //! one allocator, the first allocator is the outer allocator for use by the container, - //! the second allocator is passed to the constructors of the container's elements, - //! and, if the elements themselves are containers, the third allocator is passed to - //! the elements' elements, and so on. If containers are nested to a depth greater - //! than the number of allocators, the last allocator is used repeatedly, as in the - //! single-allocator case, for any remaining recursions. - //! - //! [Note: The - //! scoped_allocator_adaptor is derived from the outer allocator type so it can be - //! substituted for the outer allocator type in most expressions. -end note] - //! - //! In the construct member functions, OUTERMOST(x) is x if x does not have - //! an outer_allocator() member function and - //! OUTERMOST(x.outer_allocator()) otherwise; OUTERMOST_ALLOC_TRAITS(x) is - //! allocator_traits. - //! - //! [Note: OUTERMOST(x) and - //! OUTERMOST_ALLOC_TRAITS(x) are recursive operations. It is incumbent upon - //! the definition of outer_allocator() to ensure that the recursion terminates. - //! It will terminate for all instantiations of scoped_allocator_adaptor. -end note] - template - class scoped_allocator_adaptor - - #else // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) - - template - class scoped_allocator_adaptor - - #endif // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) - -#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - -template -class scoped_allocator_adaptor -#endif - : public container_detail::scoped_allocator_adaptor_base - -{ - BOOST_COPYABLE_AND_MOVABLE(scoped_allocator_adaptor) - - public: - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef container_detail::scoped_allocator_adaptor_base - base_type; - typedef typename base_type::internal_type_t internal_type_t; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef OuterAlloc outer_allocator_type; - //! Type: For exposition only - //! - typedef allocator_traits outer_traits_type; - //! Type: scoped_allocator_adaptor if sizeof...(InnerAllocs) is zero; otherwise, - //! scoped_allocator_adaptor. - typedef typename base_type::inner_allocator_type inner_allocator_type; - typedef allocator_traits inner_traits_type; - typedef typename outer_traits_type::value_type value_type; - typedef typename outer_traits_type::size_type size_type; - typedef typename outer_traits_type::difference_type difference_type; - typedef typename outer_traits_type::pointer pointer; - typedef typename outer_traits_type::const_pointer const_pointer; - typedef typename outer_traits_type::void_pointer void_pointer; - typedef typename outer_traits_type::const_void_pointer const_void_pointer; - //! Type: true_type if allocator_traits::propagate_on_container_copy_assignment::value is - //! true for any Allocator in the set of OuterAlloc and InnerAllocs...; otherwise, false_type. - typedef typename base_type:: - propagate_on_container_copy_assignment propagate_on_container_copy_assignment; - //! Type: true_type if allocator_traits::propagate_on_container_move_assignment::value is - //! true for any Allocator in the set of OuterAlloc and InnerAllocs...; otherwise, false_type. - typedef typename base_type:: - propagate_on_container_move_assignment propagate_on_container_move_assignment; - //! Type: true_type if allocator_traits::propagate_on_container_swap::value is true for any - //! Allocator in the set of OuterAlloc and InnerAllocs...; otherwise, false_type. - typedef typename base_type:: - propagate_on_container_swap propagate_on_container_swap; - - //! Type: Rebinds scoped allocator to - //! typedef scoped_allocator_adaptor - //! < typename outer_traits_type::template portable_rebind_alloc::type - //! , InnerAllocs... > - template - struct rebind - { - typedef scoped_allocator_adaptor - < typename outer_traits_type::template portable_rebind_alloc::type - #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , InnerAllocs... - #else - BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS, Q) - #endif - > other; - }; - - //! Effects: value-initializes the OuterAlloc base class - //! and the inner allocator object. - scoped_allocator_adaptor() - {} - - ~scoped_allocator_adaptor() - {} - - //! Effects: initializes each allocator within the adaptor with - //! the corresponding allocator from other. - scoped_allocator_adaptor(const scoped_allocator_adaptor& other) - : base_type(other.base()) - {} - - //! Effects: move constructs each allocator within the adaptor with - //! the corresponding allocator from other. - scoped_allocator_adaptor(BOOST_RV_REF(scoped_allocator_adaptor) other) - : base_type(::boost::move(other.base())) - {} - - #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Requires: OuterAlloc shall be constructible from OuterA2. - //! - //! Effects: initializes the OuterAlloc base class with boost::forward(outerAlloc) and inner - //! with innerAllocs...(hence recursively initializing each allocator within the adaptor with the - //! corresponding allocator from the argument list). - template - scoped_allocator_adaptor(BOOST_FWD_REF(OuterA2) outerAlloc, const InnerAllocs & ...innerAllocs) - : base_type(::boost::forward(outerAlloc), innerAllocs...) - {} - #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - #define BOOST_PP_LOCAL_MACRO(n) \ - template \ - scoped_allocator_adaptor(BOOST_FWD_REF(OuterA2) outerAlloc \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q, _)) \ - : base_type(::boost::forward(outerAlloc) \ - BOOST_PP_ENUM_TRAILING_PARAMS(n, q) \ - ) \ - {} \ - //! - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() - - #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Requires: OuterAlloc shall be constructible from OuterA2. - //! - //! Effects: initializes each allocator within the adaptor with the corresponding allocator from other. - template - scoped_allocator_adaptor(const scoped_allocator_adaptor &other) - : base_type(other.base()) - {} - - //! Requires: OuterAlloc shall be constructible from OuterA2. - //! - //! Effects: initializes each allocator within the adaptor with the corresponding allocator - //! rvalue from other. - template - scoped_allocator_adaptor(BOOST_RV_REF_BEG scoped_allocator_adaptor BOOST_RV_REF_END other) - : base_type(::boost::move(other.base())) - {} - - scoped_allocator_adaptor &operator=(BOOST_COPY_ASSIGN_REF(scoped_allocator_adaptor) other) - { return static_cast(base_type::operator=(static_cast(other))); } - - scoped_allocator_adaptor &operator=(BOOST_RV_REF(scoped_allocator_adaptor) other) - { return static_cast(base_type::operator=(boost::move(static_cast(other)))); } - - #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED - //! Effects: swaps *this with r. - //! - void swap(scoped_allocator_adaptor &r); - - //! Effects: swaps *this with r. - //! - friend void swap(scoped_allocator_adaptor &l, scoped_allocator_adaptor &r); - - //! Returns: - //! static_cast(*this). - outer_allocator_type & outer_allocator() BOOST_CONTAINER_NOEXCEPT; - - //! Returns: - //! static_cast(*this). - const outer_allocator_type &outer_allocator() const BOOST_CONTAINER_NOEXCEPT; - - //! Returns: - //! *this if sizeof...(InnerAllocs) is zero; otherwise, inner. - inner_allocator_type& inner_allocator() BOOST_CONTAINER_NOEXCEPT; - - //! Returns: - //! *this if sizeof...(InnerAllocs) is zero; otherwise, inner. - inner_allocator_type const& inner_allocator() const BOOST_CONTAINER_NOEXCEPT; - - #endif //BOOST_CONTAINER_DOXYGEN_INVOKED - - //! Returns: - //! allocator_traits::max_size(outer_allocator()). - size_type max_size() const BOOST_CONTAINER_NOEXCEPT - { - return outer_traits_type::max_size(this->outer_allocator()); - } - - //! Effects: - //! calls OUTERMOST_ALLOC_TRAITS(*this)::destroy(OUTERMOST(*this), p). - template - void destroy(T* p) BOOST_CONTAINER_NOEXCEPT - { - allocator_traits::type> - ::destroy(get_outermost_allocator(this->outer_allocator()), p); - } - - //! Returns: - //! allocator_traits::allocate(outer_allocator(), n). - pointer allocate(size_type n) - { - return outer_traits_type::allocate(this->outer_allocator(), n); - } - - //! Returns: - //! allocator_traits::allocate(outer_allocator(), n, hint). - pointer allocate(size_type n, const_void_pointer hint) - { - return outer_traits_type::allocate(this->outer_allocator(), n, hint); - } - - //! Effects: - //! allocator_traits::deallocate(outer_allocator(), p, n). - void deallocate(pointer p, size_type n) - { - outer_traits_type::deallocate(this->outer_allocator(), p, n); - } - - #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED - //! Returns: Allocator new scoped_allocator_adaptor object where each allocator - //! A in the adaptor is initialized from the result of calling - //! allocator_traits::select_on_container_copy_construction() on - //! the corresponding allocator in *this. - scoped_allocator_adaptor select_on_container_copy_construction() const; - #endif //BOOST_CONTAINER_DOXYGEN_INVOKED - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - base_type &base() { return *this; } - - const base_type &base() const { return *this; } - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: - //! 1) If uses_allocator::value is false calls - //! OUTERMOST_ALLOC_TRAITS(*this)::construct - //! (OUTERMOST(*this), p, std::forward(args)...). - //! - //! 2) Otherwise, if uses_allocator::value is true and - //! is_constructible::value is true, calls - //! OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, allocator_arg, - //! inner_allocator(), std::forward(args)...). - //! - //! [Note: In compilers without advanced decltype SFINAE support, is_constructible can't - //! be implemented so that condition will be replaced by - //! constructible_with_allocator_prefix::value. -end note] - //! - //! 3) Otherwise, if uses_allocator::value is true and - //! is_constructible::value is true, calls - //! OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, - //! std::forward(args)..., inner_allocator()). - //! - //! [Note: In compilers without advanced decltype SFINAE support, is_constructible can't be - //! implemented so that condition will be replaced by - //! constructible_with_allocator_suffix::value. -end note] - //! - //! 4) Otherwise, the program is ill-formed. - //! - //! [Note: An error will result if uses_allocator evaluates - //! to true but the specific constructor does not take an allocator. This definition prevents a silent - //! failure to pass an inner allocator to a contained element. -end note] - template < typename T, class ...Args> - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - void - #else - typename container_detail::enable_if_c::value, void>::type - #endif - construct(T* p, BOOST_FWD_REF(Args)...args) - { - container_detail::dispatch_uses_allocator - ( uses_allocator() - , get_outermost_allocator(this->outer_allocator()) - , this->inner_allocator() - , p, ::boost::forward(args)...); - } - - #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //Disable this overload if the first argument is pair as some compilers have - //overload selection problems when the first parameter is a pair. - #define BOOST_PP_LOCAL_MACRO(n) \ - template < typename T \ - BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) \ - > \ - typename container_detail::enable_if_c::value, void>::type \ - construct(T* p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - container_detail::dispatch_uses_allocator \ - ( uses_allocator() \ - , get_outermost_allocator(this->outer_allocator()) \ - , this->inner_allocator() \ - , 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 // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - template - void construct(std::pair* p) - { this->construct_pair(p); } - - template - void construct(container_detail::pair* p) - { this->construct_pair(p); } - - template - void construct(std::pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y) - { this->construct_pair(p, ::boost::forward(x), ::boost::forward(y)); } - - template - void construct(container_detail::pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y) - { this->construct_pair(p, ::boost::forward(x), ::boost::forward(y)); } - - template - void construct(std::pair* p, const std::pair& x) - { this->construct_pair(p, x); } - - template - void construct( container_detail::pair* p - , const container_detail::pair& x) - { this->construct_pair(p, x); } - - template - void construct( std::pair* p - , BOOST_RV_REF_BEG std::pair BOOST_RV_REF_END x) - { this->construct_pair(p, x); } - - template - void construct( container_detail::pair* p - , BOOST_RV_REF_BEG container_detail::pair BOOST_RV_REF_END x) - { this->construct_pair(p, x); } - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - template - void construct_pair(Pair* p) - { - this->construct(container_detail::addressof(p->first)); - BOOST_TRY{ - this->construct(container_detail::addressof(p->second)); - } - BOOST_CATCH(...){ - this->destroy(container_detail::addressof(p->first)); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - template - void construct_pair(Pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y) - { - this->construct(container_detail::addressof(p->first), ::boost::forward(x)); - BOOST_TRY{ - this->construct(container_detail::addressof(p->second), ::boost::forward(y)); - } - BOOST_CATCH(...){ - this->destroy(container_detail::addressof(p->first)); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - template - void construct_pair(Pair* p, const Pair2& pr) - { - this->construct(container_detail::addressof(p->first), pr.first); - BOOST_TRY{ - this->construct(container_detail::addressof(p->second), pr.second); - } - BOOST_CATCH(...){ - this->destroy(container_detail::addressof(p->first)); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - template - void construct_pair(Pair* p, BOOST_RV_REF(Pair2) pr) - { - this->construct(container_detail::addressof(p->first), ::boost::move(pr.first)); - BOOST_TRY{ - this->construct(container_detail::addressof(p->second), ::boost::move(pr.second)); - } - BOOST_CATCH(...){ - this->destroy(container_detail::addressof(p->first)); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - //template - //void construct(pair* p, piecewise_construct_t, tuple x, tuple y); - - public: - //Internal function - template - scoped_allocator_adaptor(internal_type_t, BOOST_FWD_REF(OuterA2) outer, const inner_allocator_type& inner) - : base_type(internal_type_t(), ::boost::forward(outer), inner) - {} - - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -}; - -template -inline bool operator==( - const scoped_allocator_adaptor& a, - const scoped_allocator_adaptor& b) -{ - #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - const bool has_zero_inner = sizeof...(InnerAllocs) == 0u; - #else - const bool has_zero_inner = - boost::container::container_detail::is_same - ::value; - #endif - - return a.outer_allocator() == b.outer_allocator() - && (has_zero_inner || a.inner_allocator() == b.inner_allocator()); -} - -template -inline bool operator!=( - const scoped_allocator_adaptor& a, - const scoped_allocator_adaptor& b) -{ - return ! (a == b); -} - -}} // namespace boost { namespace container { - -#include - -#endif // BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP diff --git a/boost/container/scoped_allocator_fwd.hpp b/boost/container/scoped_allocator_fwd.hpp deleted file mode 100644 index f19e27e..0000000 --- a/boost/container/scoped_allocator_fwd.hpp +++ /dev/null @@ -1,87 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the 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_ALLOCATOR_SCOPED_ALLOCATOR_FWD_HPP -#define BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_FWD_HPP - -//! \file -//! This header file forward declares boost::container::scoped_allocator_adaptor -//! and defines the following types: - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#include -#include -#endif - -namespace boost { namespace container { - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) - - template - class scoped_allocator_adaptor; - - #else // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) - - template - class scoped_allocator_adaptor; - - template - class scoped_allocator_adaptor; - - #endif // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST) - - -#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - -template -class scoped_allocator_adaptor; - -#endif - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -//! The allocator_arg_t struct is an empty structure type used as a unique type to -//! disambiguate constructor and function overloading. Specifically, several types -//! have constructors with allocator_arg_t as the first argument, immediately followed -//! by an argument of a type that satisfies the Allocator requirements -struct allocator_arg_t{}; - -//! A instance of type allocator_arg_t -//! -static const allocator_arg_t allocator_arg = allocator_arg_t(); - -template -struct constructible_with_allocator_suffix; - -template -struct constructible_with_allocator_prefix; - -template -struct uses_allocator; - -}} // namespace boost { namespace container { - -#include - -#endif // BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_FWD_HPP diff --git a/boost/container/set.hpp b/boost/container/set.hpp deleted file mode 100644 index 3e2c2aa..0000000 --- a/boost/container/set.hpp +++ /dev/null @@ -1,1126 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_SET_HPP -#define BOOST_CONTAINER_SET_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#ifndef BOOST_CONTAINER_PERFECT_FORWARDING -#include -#endif -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) -#include -#endif - -namespace boost { -namespace container { - -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED - -//! A set is a kind of associative container that supports unique keys (contains at -//! most one of each key value) and provides for fast retrieval of the keys themselves. -//! Class set supports bidirectional iterators. -//! -//! A set satisfies all of the requirements of a container and of a reversible container -//! , and of an associative container. A set also provides most operations described in -//! for unique keys. -//! -//! \tparam Key is the type to be inserted in the set, which is also the key_type -//! \tparam Compare is the comparison functor used to order keys -//! \tparam Allocator is the allocator to be used to allocate memory for this container -//! \tparam SetOptions is an packed option type generated using using boost::container::tree_assoc_options. -template , class Allocator = std::allocator, class SetOptions = tree_assoc_defaults > -#else -template -#endif -class set - ///@cond - : public container_detail::tree - < Key, Key, container_detail::identity, Compare, Allocator, SetOptions> - ///@endcond -{ - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - BOOST_COPYABLE_AND_MOVABLE(set) - typedef container_detail::tree - < Key, Key, container_detail::identity, Compare, Allocator, SetOptions> base_t; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - ////////////////////////////////////////////// - // - // types - // - ////////////////////////////////////////////// - typedef Key key_type; - typedef Key value_type; - typedef Compare key_compare; - typedef Compare value_compare; - typedef ::boost::container::allocator_traits allocator_traits_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; - - ////////////////////////////////////////////// - // - // construct/copy/destroy - // - ////////////////////////////////////////////// - - //! Effects: Default constructs an empty set. - //! - //! Complexity: Constant. - set() - : base_t() - {} - - //! Effects: Constructs an empty set using the specified comparison object - //! and allocator. - //! - //! Complexity: Constant. - explicit set(const Compare& comp, - const allocator_type& a = allocator_type()) - : base_t(comp, a) - {} - - //! Effects: Constructs an empty set using the specified allocator object. - //! - //! Complexity: Constant. - explicit set(const allocator_type& a) - : base_t(a) - {} - - //! Effects: Constructs an empty set using the specified comparison object and - //! allocator, and inserts elements from the range [first ,last ). - //! - //! Complexity: Linear in N if the range [first ,last ) is already sorted using - //! comp and otherwise N logN, where N is last - first. - template - set(InputIterator first, InputIterator last, const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(true, first, last, comp, a) - {} - - //! Effects: Constructs an empty set using the specified comparison object and - //! allocator, and inserts elements from the ordered unique range [first ,last). This function - //! is more efficient than the normal range creation for ordered ranges. - //! - //! Requires: [first ,last) must be ordered according to the predicate and must be - //! unique values. - //! - //! Complexity: Linear in N. - //! - //! Note: Non-standard extension. - template - set( ordered_unique_range_t, InputIterator first, InputIterator last - , const Compare& comp = Compare(), const allocator_type& a = allocator_type()) - : base_t(ordered_range, first, last, comp, a) - {} - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs an empty set using the specified comparison object and - //! allocator, and inserts elements from the range [il.begin(), il.end()). - //! - //! Complexity: Linear in N if the range [il.begin(), il.end()) is already sorted using - //! comp and otherwise N logN, where N is il.begin() - il.end(). - set(std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) - : base_t(true, il.begin(), il.end(), comp, a) - {} - - //! Effects: Constructs an empty set using the specified comparison object and - //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function - //! is more efficient than the normal range creation for ordered ranges. - //! - //! Requires: [il.begin(), il.end()) must be ordered according to the predicate and must be - //! unique values. - //! - //! Complexity: Linear in N. - //! - //! Note: Non-standard extension. - set(ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) - : base_t(ordered_range, il.begin(), il.end(), comp, a) - {} -#endif - - //! Effects: Copy constructs a set. - //! - //! Complexity: Linear in x.size(). - set(const set& x) - : base_t(static_cast(x)) - {} - - //! Effects: Move constructs a set. Constructs *this using x's resources. - //! - //! Complexity: Constant. - //! - //! Postcondition: x is emptied. - set(BOOST_RV_REF(set) x) - : base_t(boost::move(static_cast(x))) - {} - - //! Effects: Copy constructs a set using the specified allocator. - //! - //! Complexity: Linear in x.size(). - set(const set& x, const allocator_type &a) - : base_t(static_cast(x), a) - {} - - //! Effects: Move constructs a set using the specified allocator. - //! Constructs *this using x's resources. - //! - //! Complexity: Constant if a == x.get_allocator(), linear otherwise. - set(BOOST_RV_REF(set) x, const allocator_type &a) - : base_t(boost::move(static_cast(x)), a) - {} - - //! Effects: Makes *this a copy of x. - //! - //! Complexity: Linear in x.size(). - set& operator=(BOOST_COPY_ASSIGN_REF(set) x) - { return static_cast(this->base_t::operator=(static_cast(x))); } - - //! Effects: this->swap(x.get()). - //! - //! Throws: If allocator_traits_type::propagate_on_container_move_assignment - //! is false and (allocation throws or value_type's move constructor throws) - //! - //! Complexity: Constant if allocator_traits_type:: - //! propagate_on_container_move_assignment is true or - //! this->get>allocator() == x.get_allocator(). Linear otherwise. - set& operator=(BOOST_RV_REF(set) x) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) - { return static_cast(this->base_t::operator=(boost::move(static_cast(x)))); } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - set& operator=(std::initializer_list il) - { - this->clear(); - insert(il.begin(), il.end()); - return *this; - } -#endif - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Returns a copy of the Allocator that - //! was passed to the object's constructor. - //! - //! Complexity: Constant. - allocator_type get_allocator() const; - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator(); - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const; - - //! Effects: Returns an iterator to the first element contained in the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant - iterator begin(); - - //! Effects: Returns a const_iterator to the first element contained in the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator begin() const; - - //! Effects: Returns a const_iterator to the first element contained in the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cbegin() const; - - //! Effects: Returns an iterator to the end of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator end(); - - //! Effects: Returns a const_iterator to the end of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator end() const; - - //! Effects: Returns a const_iterator to the end of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cend() const; - - //! Effects: Returns a reverse_iterator pointing to the beginning - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rbegin(); - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rbegin() const; - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crbegin() const; - - //! Effects: Returns a reverse_iterator pointing to the end - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rend(); - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rend() const; - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crend() const; - - //! Effects: Returns true if the container contains no elements. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - bool empty() const; - - //! Effects: Returns the number of the elements contained in the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type size() const; - - //! Effects: Returns the largest possible size of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type max_size() const; - #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Inserts an object x of type Key constructed with - //! std::forward(args)... if and only if there is - //! no element in the container with equivalent value. - //! and returns the iterator pointing to the - //! newly inserted element. - //! - //! Returns: The bool component of the returned pair is true if and only - //! if the insertion takes place, and the iterator component of the pair - //! points to the element with key equivalent to the key of x. - //! - //! Throws: If memory allocation throws or - //! Key's in-place constructor throws. - //! - //! Complexity: Logarithmic. - template - std::pair emplace(Args&&... args) - { return this->base_t::emplace_unique(boost::forward(args)...); } - - //! Effects: Inserts an object of type Key constructed with - //! std::forward(args)... if and only if there is - //! no element in the container with equivalent value. - //! p is a hint pointing to where the insert - //! should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic. - template - iterator emplace_hint(const_iterator p, Args&&... args) - { return this->base_t::emplace_hint_unique(p, boost::forward(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, >) \ - std::pair emplace(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_unique(BOOST_PP_ENUM(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_hint(const_iterator p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_hint_unique(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 - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: Inserts x if and only if there is no element in the container - //! with key equivalent to the key of x. - //! - //! Returns: The bool component of the returned pair is true if and only - //! if the insertion takes place, and the iterator component of the pair - //! points to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic. - std::pair insert(const value_type &x); - - //! Effects: Move constructs a new value from x if and only if there is - //! no element in the container with key equivalent to the key of x. - //! - //! Returns: The bool component of the returned pair is true if and only - //! if the insertion takes place, and the iterator component of the pair - //! points to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic. - std::pair insert(value_type &&x); - #else - private: - typedef std::pair insert_return_pair; - public: - BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, insert_return_pair, this->priv_insert) - #endif - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: Inserts a copy of x in the container if and only if there is - //! no element in the container with key equivalent to the key of x. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - iterator insert(const_iterator p, const value_type &x); - - //! Effects: Inserts an element move constructed from x in the container. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent to the key of x. - //! - //! Complexity: Logarithmic. - iterator insert(const_iterator p, value_type &&x); - #else - BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator) - #endif - - //! Requires: first, last are not iterators into *this. - //! - //! Effects: inserts each element from the range [first,last) if and only - //! if there is no element with key equivalent to the key of that element. - //! - //! Complexity: At most N log(size()+N) (N is the distance from first to last) - template - void insert(InputIterator first, InputIterator last) - { this->base_t::insert_unique(first, last); } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: inserts each element from the range [il.begin(),il.end()) if and only - //! if there is no element with key equivalent to the key of that element. - //! - //! Complexity: At most N log(size()+N) (N is the distance from il.begin() to il.end()) - void insert(std::initializer_list il) - { this->base_t::insert_unique(il.begin(), il.end()); } -#endif - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Erases the element pointed to by p. - //! - //! Returns: Returns an iterator pointing to the element immediately - //! following q prior to the element being erased. If no such element exists, - //! returns end(). - //! - //! Complexity: Amortized constant time - iterator erase(const_iterator p); - - //! Effects: Erases all elements in the container with key equivalent to x. - //! - //! Returns: Returns the number of erased elements. - //! - //! Complexity: log(size()) + count(k) - size_type erase(const key_type& x); - - //! Effects: Erases all the elements in the range [first, last). - //! - //! Returns: Returns last. - //! - //! Complexity: log(size())+N where N is the distance from first to last. - iterator erase(const_iterator first, const_iterator last); - - //! Effects: Swaps the contents of *this and x. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - void swap(set& x); - - //! Effects: erase(a.begin(),a.end()). - //! - //! Postcondition: size() == 0. - //! - //! Complexity: linear in size(). - void clear(); - - //! Effects: Returns the comparison object out - //! of which a was constructed. - //! - //! Complexity: Constant. - key_compare key_comp() const; - - //! Effects: Returns an object of value_compare constructed out - //! of the comparison object. - //! - //! Complexity: Constant. - value_compare value_comp() const; - - //! Returns: An iterator pointing to an element with the key - //! equivalent to x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic. - iterator find(const key_type& x); - - //! Returns: Allocator const_iterator pointing to an element with the key - //! equivalent to x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic. - const_iterator find(const key_type& x) const; - - #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Returns: The number of elements with key equivalent to x. - //! - //! Complexity: log(size())+count(k) - size_type count(const key_type& x) const - { return static_cast(this->base_t::find(x) != this->base_t::cend()); } - - //! Returns: The number of elements with key equivalent to x. - //! - //! Complexity: log(size())+count(k) - size_type count(const key_type& x) - { return static_cast(this->base_t::find(x) != this->base_t::end()); } - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Returns: An iterator pointing to the first element with key not less - //! than k, or a.end() if such an element is not found. - //! - //! Complexity: Logarithmic - iterator lower_bound(const key_type& x); - - //! Returns: Allocator const iterator pointing to the first element with key not - //! less than k, or a.end() if such an element is not found. - //! - //! Complexity: Logarithmic - const_iterator lower_bound(const key_type& x) const; - - //! Returns: An iterator pointing to the first element with key not less - //! than x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic - iterator upper_bound(const key_type& x); - - //! Returns: Allocator const iterator pointing to the first element with key not - //! less than x, or end() if such an element is not found. - //! - //! Complexity: Logarithmic - const_iterator upper_bound(const key_type& x) const; - - #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). - //! - //! Complexity: Logarithmic - std::pair equal_range(const key_type& x) - { return this->base_t::lower_bound_range(x); } - - //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). - //! - //! Complexity: Logarithmic - std::pair equal_range(const key_type& x) const - { return this->base_t::lower_bound_range(x); } - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). - //! - //! Complexity: Logarithmic - std::pair equal_range(const key_type& x); - - //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). - //! - //! Complexity: Logarithmic - std::pair equal_range(const key_type& x) const; - - //! Effects: Rebalances the tree. It's a no-op for Red-Black and AVL trees. - //! - //! Complexity: Linear - void rebalance(); - - //! Effects: Returns true if x and y are equal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator==(const set& x, const set& y); - - //! Effects: Returns true if x and y are unequal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator!=(const set& x, const set& y); - - //! Effects: Returns true if x is less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<(const set& x, const set& y); - - //! Effects: Returns true if x is greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>(const set& x, const set& y); - - //! Effects: Returns true if x is equal or less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<=(const set& x, const set& y); - - //! Effects: Returns true if x is equal or greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>=(const set& x, const set& y); - - //! Effects: x.swap(y) - //! - //! Complexity: Constant. - friend void swap(set& x, set& y); - - #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - template - std::pair priv_insert(BOOST_FWD_REF(KeyType) x) - { return this->base_t::insert_unique(::boost::forward(x)); } - - template - iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) - { return this->base_t::insert_unique(p, ::boost::forward(x)); } - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -}; - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -} //namespace container { - -//!has_trivial_destructor_after_move<> == true_type -//!specialization for optimizations -template -struct has_trivial_destructor_after_move > -{ - static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value; -}; - -namespace container { - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED - -//! A multiset is a kind of associative container that supports equivalent keys -//! (possibly contains multiple copies of the same key value) and provides for -//! fast retrieval of the keys themselves. Class multiset supports bidirectional iterators. -//! -//! A multiset satisfies all of the requirements of a container and of a reversible -//! container, and of an associative container). multiset also provides most operations -//! described for duplicate keys. -//! -//! \tparam Key is the type to be inserted in the set, which is also the key_type -//! \tparam Compare is the comparison functor used to order keys -//! \tparam Allocator is the allocator to be used to allocate memory for this container -//! \tparam MultiSetOptions is an packed option type generated using using boost::container::tree_assoc_options. -template , class Allocator = std::allocator, class MultiSetOptions = tree_assoc_defaults > -#else -template -#endif -class multiset - /// @cond - : public container_detail::tree - , Compare, Allocator, MultiSetOptions> - /// @endcond -{ - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - BOOST_COPYABLE_AND_MOVABLE(multiset) - typedef container_detail::tree - , Compare, Allocator, MultiSetOptions> base_t; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - - ////////////////////////////////////////////// - // - // types - // - ////////////////////////////////////////////// - typedef Key key_type; - typedef Key value_type; - typedef Compare key_compare; - typedef Compare value_compare; - typedef ::boost::container::allocator_traits allocator_traits_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator; - typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator; - - ////////////////////////////////////////////// - // - // construct/copy/destroy - // - ////////////////////////////////////////////// - - //! @copydoc ::boost::container::set::set() - multiset() - : base_t() - {} - - //! @copydoc ::boost::container::set::set(const Compare&, const allocator_type&) - explicit multiset(const Compare& comp, - const allocator_type& a = allocator_type()) - : base_t(comp, a) - {} - - //! @copydoc ::boost::container::set::set(const allocator_type&) - explicit multiset(const allocator_type& a) - : base_t(a) - {} - - //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare& comp, const allocator_type&) - template - multiset(InputIterator first, InputIterator last, - const Compare& comp = Compare(), - const allocator_type& a = allocator_type()) - : base_t(false, first, last, comp, a) - {} - - //! Effects: Constructs an empty multiset using the specified comparison object and - //! allocator, and inserts elements from the ordered range [first ,last ). This function - //! is more efficient than the normal range creation for ordered ranges. - //! - //! Requires: [first ,last) must be ordered according to the predicate. - //! - //! Complexity: Linear in N. - //! - //! Note: Non-standard extension. - template - multiset( ordered_range_t, InputIterator first, InputIterator last - , const Compare& comp = Compare() - , const allocator_type& a = allocator_type()) - : base_t(ordered_range, first, last, comp, a) - {} - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! @copydoc ::boost::container::set::set(std::initializer_list, const Compare& comp, const allocator_type&) - multiset(std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) - : base_t(false, il.begin(), il.end(), comp, a) - {} - - //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list, const Compare& comp, const allocator_type&) - multiset(ordered_unique_range_t, std::initializer_list il, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) - : base_t(ordered_range, il.begin(), il.end(), comp, a) - {} -#endif - - - //! @copydoc ::boost::container::set::set(const set &) - multiset(const multiset& x) - : base_t(static_cast(x)) - {} - - //! @copydoc ::boost::container::set(set &&) - multiset(BOOST_RV_REF(multiset) x) - : base_t(boost::move(static_cast(x))) - {} - - //! @copydoc ::boost::container::set(const set &, const allocator_type &) - multiset(const multiset& x, const allocator_type &a) - : base_t(static_cast(x), a) - {} - - //! @copydoc ::boost::container::set(set &&, const allocator_type &) - multiset(BOOST_RV_REF(multiset) x, const allocator_type &a) - : base_t(boost::move(static_cast(x)), a) - {} - - //! @copydoc ::boost::container::set::operator=(const set &) - multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x) - { return static_cast(this->base_t::operator=(static_cast(x))); } - - //! @copydoc ::boost::container::set::operator=(set &&) - multiset& operator=(BOOST_RV_REF(multiset) x) - { return static_cast(this->base_t::operator=(boost::move(static_cast(x)))); } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! @copydoc ::boost::container::set::operator=(std::initializer_list) - multiset& operator=(std::initializer_list il) - { - this->clear(); - insert(il.begin(), il.end()); - return *this; - } -#endif - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! @copydoc ::boost::container::set::get_allocator() - allocator_type get_allocator() const; - - //! @copydoc ::boost::container::set::get_stored_allocator() - stored_allocator_type &get_stored_allocator(); - - //! @copydoc ::boost::container::set::get_stored_allocator() const - const stored_allocator_type &get_stored_allocator() const; - - //! @copydoc ::boost::container::set::begin() - iterator begin(); - - //! @copydoc ::boost::container::set::begin() const - const_iterator begin() const; - - //! @copydoc ::boost::container::set::cbegin() const - const_iterator cbegin() const; - - //! @copydoc ::boost::container::set::end() - iterator end() BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::end() const - const_iterator end() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::cend() const - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::rbegin() - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::rbegin() const - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::crbegin() const - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::rend() - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::rend() const - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::crend() const - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::empty() const - bool empty() const; - - //! @copydoc ::boost::container::set::size() const - size_type size() const; - - //! @copydoc ::boost::container::set::max_size() const - size_type max_size() const; - - #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Inserts an object of type Key constructed with - //! std::forward(args)... and returns the iterator pointing to the - //! newly inserted element. - //! - //! Complexity: Logarithmic. - template - iterator emplace(Args&&... args) - { return this->base_t::emplace_equal(boost::forward(args)...); } - - //! Effects: Inserts an object of type Key constructed with - //! std::forward(args)... - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - template - iterator emplace_hint(const_iterator p, Args&&... args) - { return this->base_t::emplace_hint_equal(p, boost::forward(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(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_equal(BOOST_PP_ENUM(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_hint(const_iterator p \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { return this->base_t::emplace_hint_equal(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 - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: Inserts x and returns the iterator pointing to the - //! newly inserted element. - //! - //! Complexity: Logarithmic. - iterator insert(const value_type &x); - - //! Effects: Inserts a copy of x in the container. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - iterator insert(value_type &&x); - #else - BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->priv_insert) - #endif - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: Inserts a copy of x in the container. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - iterator insert(const_iterator p, const value_type &x); - - //! Effects: Inserts a value move constructed from x in the container. - //! p is a hint pointing to where the insert should start to search. - //! - //! Returns: An iterator pointing to the element with key equivalent - //! to the key of x. - //! - //! Complexity: Logarithmic in general, but amortized constant if t - //! is inserted right before p. - iterator insert(const_iterator p, value_type &&x); - #else - BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, value_type, iterator, this->priv_insert, const_iterator, const_iterator) - #endif - - //! Requires: first, last are not iterators into *this. - //! - //! Effects: inserts each element from the range [first,last) . - //! - //! Complexity: At most N log(size()+N) (N is the distance from first to last) - template - void insert(InputIterator first, InputIterator last) - { this->base_t::insert_equal(first, last); } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! @copydoc ::boost::container::set::insert(std::initializer_list) - void insert(std::initializer_list il) - { this->base_t::insert_unique(il.begin(), il.end()); } -#endif - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! @copydoc ::boost::container::set::erase(const_iterator) - iterator erase(const_iterator p); - - //! @copydoc ::boost::container::set::erase(const key_type&) - size_type erase(const key_type& x); - - //! @copydoc ::boost::container::set::erase(const_iterator,const_iterator) - iterator erase(const_iterator first, const_iterator last); - - //! @copydoc ::boost::container::set::swap - void swap(flat_multiset& x); - - //! @copydoc ::boost::container::set::clear - void clear() BOOST_CONTAINER_NOEXCEPT; - - //! @copydoc ::boost::container::set::key_comp - key_compare key_comp() const; - - //! @copydoc ::boost::container::set::value_comp - value_compare value_comp() const; - - //! @copydoc ::boost::container::set::find(const key_type& ) - iterator find(const key_type& x); - - //! @copydoc ::boost::container::set::find(const key_type& ) const - const_iterator find(const key_type& x) const; - - //! @copydoc ::boost::container::set::count(const key_type& ) const - size_type count(const key_type& x) const; - - //! @copydoc ::boost::container::set::lower_bound(const key_type& ) - iterator lower_bound(const key_type& x); - - //! @copydoc ::boost::container::set::lower_bound(const key_type& ) const - const_iterator lower_bound(const key_type& x) const; - - //! @copydoc ::boost::container::set::upper_bound(const key_type& ) - iterator upper_bound(const key_type& x); - - //! @copydoc ::boost::container::set::upper_bound(const key_type& ) const - const_iterator upper_bound(const key_type& x) const; - - //! @copydoc ::boost::container::set::equal_range(const key_type& ) const - std::pair equal_range(const key_type& x) const; - - //! @copydoc ::boost::container::set::equal_range(const key_type& ) - std::pair equal_range(const key_type& x); - - //! @copydoc ::boost::container::set::rebalance() - void rebalance(); - - //! Effects: Returns true if x and y are equal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator==(const multiset& x, const multiset& y); - - //! Effects: Returns true if x and y are unequal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator!=(const multiset& x, const multiset& y); - - //! Effects: Returns true if x is less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<(const multiset& x, const multiset& y); - - //! Effects: Returns true if x is greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>(const multiset& x, const multiset& y); - - //! Effects: Returns true if x is equal or less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<=(const multiset& x, const multiset& y); - - //! Effects: Returns true if x is equal or greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>=(const multiset& x, const multiset& y); - - //! Effects: x.swap(y) - //! - //! Complexity: Constant. - friend void swap(multiset& x, multiset& y); - - #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - template - iterator priv_insert(BOOST_FWD_REF(KeyType) x) - { return this->base_t::insert_equal(::boost::forward(x)); } - - template - iterator priv_insert(const_iterator p, BOOST_FWD_REF(KeyType) x) - { return this->base_t::insert_equal(p, ::boost::forward(x)); } - - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -}; - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -} //namespace container { - -//!has_trivial_destructor_after_move<> == true_type -//!specialization for optimizations -template -struct has_trivial_destructor_after_move > -{ - static const bool value = has_trivial_destructor_after_move::value && has_trivial_destructor_after_move::value; -}; - -namespace container { - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -}} - -#include - -#endif /* BOOST_CONTAINER_SET_HPP */ - diff --git a/boost/container/slist.hpp b/boost/container/slist.hpp deleted file mode 100644 index b6b4c38..0000000 --- a/boost/container/slist.hpp +++ /dev/null @@ -1,1730 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the 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_SLIST_HPP -#define BOOST_CONTAINER_SLIST_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) -//Preprocessor library to emulate perfect forwarding -#else -#include -#endif - -#include -#include -#include -#include -#include - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) -#include -#endif - - -namespace boost { -namespace container { - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -template -class slist; - -namespace container_detail { - -template -struct slist_hook -{ - typedef typename container_detail::bi::make_slist_base_hook - , container_detail::bi::link_mode >::type type; -}; - -template -struct slist_node - : public slist_hook::type -{ - private: - slist_node(); - - public: - typedef T value_type; - typedef typename slist_hook::type hook_type; - - T m_data; - - T &get_data() - { return this->m_data; } - - const T &get_data() const - { return this->m_data; } -}; - -template -struct iiterator_node_value_type< slist_node > { - typedef T type; -}; - -template -struct intrusive_slist_type -{ - typedef boost::container::allocator_traits allocator_traits_type; - typedef typename allocator_traits_type::value_type value_type; - typedef typename boost::intrusive::pointer_traits - ::template - rebind_pointer::type - void_pointer; - typedef typename container_detail::slist_node - node_type; - - typedef typename container_detail::bi::make_slist - ::type> - ,container_detail::bi::constant_time_size - , container_detail::bi::size_type - - >::type container_type; - typedef container_type type ; -}; - -} //namespace container_detail { - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -//! An slist is a singly linked list: a list where each element is linked to the next -//! element, but not to the previous element. That is, it is a Sequence that -//! supports forward but not backward traversal, and (amortized) constant time -//! insertion and removal of elements. Slists, like lists, have the important -//! property that insertion and splicing do not invalidate iterators to list elements, -//! and that even removal invalidates only the iterators that point to the elements -//! that are removed. The ordering of iterators may be changed (that is, -//! slist::iterator might have a different predecessor or successor after a list -//! operation than it did before), but the iterators themselves will not be invalidated -//! or made to point to different elements unless that invalidation or mutation is explicit. -//! -//! The main difference between slist and list is that list's iterators are bidirectional -//! iterators, while slist's iterators are forward iterators. This means that slist is -//! less versatile than list; frequently, however, bidirectional iterators are -//! unnecessary. You should usually use slist unless you actually need the extra -//! functionality of list, because singly linked lists are smaller and faster than double -//! linked lists. -//! -//! Important performance note: like every other Sequence, slist defines the member -//! functions insert and erase. Using these member functions carelessly, however, can -//! result in disastrously slow programs. The problem is that insert's first argument is -//! an iterator p, and that it inserts the new element(s) before p. This means that -//! insert must find the iterator just before p; this is a constant-time operation -//! for list, since list has bidirectional iterators, but for slist it must find that -//! iterator by traversing the list from the beginning up to p. In other words: -//! insert and erase are slow operations anywhere but near the beginning of the slist. -//! -//! Slist provides the member functions insert_after and erase_after, which are constant -//! time operations: you should always use insert_after and erase_after whenever -//! possible. If you find that insert_after and erase_after aren't adequate for your -//! needs, and that you often need to use insert and erase in the middle of the list, -//! then you should probably use list instead of slist. -//! -//! \tparam T The type of object that is stored in the list -//! \tparam Allocator The allocator used for all internal memory management -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template > -#else -template -#endif -class slist - : protected container_detail::node_alloc_holder - ::type> -{ - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef typename - container_detail::intrusive_slist_type::type Icont; - typedef container_detail::node_alloc_holder AllocHolder; - typedef typename AllocHolder::NodePtr NodePtr; - typedef typename AllocHolder::NodeAlloc NodeAlloc; - typedef typename AllocHolder::ValAlloc ValAlloc; - typedef typename AllocHolder::Node Node; - typedef container_detail::allocator_destroyer Destroyer; - typedef typename AllocHolder::allocator_v1 allocator_v1; - typedef typename AllocHolder::allocator_v2 allocator_v2; - typedef typename AllocHolder::alloc_version alloc_version; - typedef boost::container::allocator_traits allocator_traits_type; - - class equal_to_value - { - typedef typename AllocHolder::value_type value_type; - const value_type &t_; - - public: - equal_to_value(const value_type &t) - : t_(t) - {} - - bool operator()(const value_type &t)const - { return t_ == t; } - }; - - template - struct ValueCompareToNodeCompare - : Pred - { - ValueCompareToNodeCompare(Pred pred) - : Pred(pred) - {} - - bool operator()(const Node &a, const Node &b) const - { return static_cast(*this)(a.m_data, b.m_data); } - - bool operator()(const Node &a) const - { return static_cast(*this)(a.m_data); } - }; - - BOOST_COPYABLE_AND_MOVABLE(slist) - typedef container_detail::iterator iterator_impl; - typedef container_detail::iterator const_iterator_impl; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - ////////////////////////////////////////////// - // - // types - // - ////////////////////////////////////////////// - - typedef T value_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator 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; - - public: - - ////////////////////////////////////////////// - // - // construct/copy/destroy - // - ////////////////////////////////////////////// - - //! Effects: Constructs a list taking the allocator as parameter. - //! - //! Throws: If allocator_type's copy constructor throws. - //! - //! Complexity: Constant. - slist() - : AllocHolder() - {} - - //! Effects: Constructs a list taking the allocator as parameter. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - explicit slist(const allocator_type& a) BOOST_CONTAINER_NOEXCEPT - : AllocHolder(a) - {} - - explicit slist(size_type n) - : AllocHolder(allocator_type()) - { this->resize(n); } - - //! Effects: Constructs a list that will use a copy of allocator a - //! and inserts n copies of value. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's default or copy constructor throws. - //! - //! Complexity: Linear to n. - explicit slist(size_type n, const value_type& x, const allocator_type& a = allocator_type()) - : AllocHolder(a) - { this->insert_after(this->cbefore_begin(), n, x); } - - //! Effects: Constructs a list that will use a copy of allocator a - //! and inserts a copy of the range [first, last) in the list. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's constructor taking a dereferenced InIt throws. - //! - //! Complexity: Linear to the range [first, last). - template - slist(InpIt first, InpIt last, const allocator_type& a = allocator_type()) - : AllocHolder(a) - { this->insert_after(this->cbefore_begin(), first, last); } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs a list that will use a copy of allocator a - //! and inserts a copy of the range [il.begin(), il.end()) in the list. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's constructor taking a dereferenced std::initializer_list iterator throws. - //! - //! Complexity: Linear to the range [il.begin(), il.end()). - slist(std::initializer_list il, const allocator_type& a = allocator_type()) - : AllocHolder(a) - { this->insert_after(this->cbefore_begin(), il.begin(), il.end()); } -#endif - - //! Effects: Copy constructs a list. - //! - //! Postcondition: x == *this. - //! - //! Throws: If allocator_type's default constructor - //! - //! Complexity: Linear to the elements x contains. - slist(const slist& x) - : AllocHolder(x) - { this->insert_after(this->cbefore_begin(), x.begin(), x.end()); } - - //! Effects: Move constructor. Moves mx's resources to *this. - //! - //! Throws: If allocator_type's copy constructor throws. - //! - //! Complexity: Constant. - slist(BOOST_RV_REF(slist) x) - : AllocHolder(boost::move(static_cast(x))) - {} - - //! Effects: Copy constructs a list using the specified allocator. - //! - //! Postcondition: x == *this. - //! - //! Throws: If allocator_type's default constructor - //! - //! Complexity: Linear to the elements x contains. - slist(const slist& x, const allocator_type &a) - : AllocHolder(a) - { this->insert_after(this->cbefore_begin(), x.begin(), x.end()); } - - //! Effects: Move constructor using the specified allocator. - //! Moves x's resources to *this. - //! - //! Throws: If allocation or value_type's copy constructor throws. - //! - //! Complexity: Constant if a == x.get_allocator(), linear otherwise. - slist(BOOST_RV_REF(slist) x, const allocator_type &a) - : AllocHolder(a) - { - if(this->node_alloc() == x.node_alloc()){ - this->icont().swap(x.icont()); - } - else{ - this->insert_after(this->cbefore_begin(), x.begin(), x.end()); - } - } - - //! Effects: Destroys the list. All stored values are destroyed - //! and used memory is deallocated. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements. - ~slist() BOOST_CONTAINER_NOEXCEPT - {} //AllocHolder clears the slist - - //! Effects: Makes *this contain the same elements as x. - //! - //! Postcondition: this->size() == x.size(). *this contains a copy - //! of each of x's elements. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to the number of elements in x. - slist& operator= (BOOST_COPY_ASSIGN_REF(slist) x) - { - if (&x != this){ - NodeAlloc &this_alloc = this->node_alloc(); - const NodeAlloc &x_alloc = x.node_alloc(); - container_detail::bool_ flag; - if(flag && this_alloc != x_alloc){ - this->clear(); - } - this->AllocHolder::copy_assign_alloc(x); - this->assign(x.begin(), x.end()); - } - return *this; - } - - //! Effects: Makes *this contain the same elements as x. - //! - //! Postcondition: this->size() == x.size(). *this contains a copy - //! of each of x's elements. - //! - //! Throws: If allocator_traits_type::propagate_on_container_move_assignment - //! is false and (allocation throws or value_type's move constructor throws) - //! - //! Complexity: Constant if allocator_traits_type:: - //! propagate_on_container_move_assignment is true or - //! this->get>allocator() == x.get_allocator(). Linear otherwise. - slist& operator= (BOOST_RV_REF(slist) x) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) - { - BOOST_ASSERT(this != &x); - NodeAlloc &this_alloc = this->node_alloc(); - NodeAlloc &x_alloc = x.node_alloc(); - const bool propagate_alloc = allocator_traits_type:: - propagate_on_container_move_assignment::value; - const bool allocators_equal = this_alloc == x_alloc; (void)allocators_equal; - //Resources can be transferred if both allocators are - //going to be equal after this function (either propagated or already equal) - if(propagate_alloc || allocators_equal){ - //Destroy - this->clear(); - //Move allocator if needed - this->AllocHolder::move_assign_alloc(x); - //Obtain resources - this->icont() = boost::move(x.icont()); - } - //Else do a one by one move - else{ - this->assign( boost::make_move_iterator(x.begin()) - , boost::make_move_iterator(x.end())); - } - return *this; - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Makes *this contain the same elements as in il. - //! - //! Postcondition: this->size() == il.size(). *this contains a copy - //! of each of il's elements. - //! - //! Throws: If allocator_traits_type::propagate_on_container_move_assignment - //! is false and (allocation throws or value_type's move constructor throws) - slist& operator=(std::initializer_list il) - { - assign(il.begin(), il.end()); - return *this; - } -#endif - - //! Effects: Assigns the n copies of val to *this. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to n. - void assign(size_type n, const T& val) - { - typedef constant_iterator cvalue_iterator; - return this->assign(cvalue_iterator(val, n), cvalue_iterator()); - } - - //! Effects: Assigns the range [first, last) to *this. - //! - //! Throws: If memory allocation throws or - //! T's constructor from dereferencing InpIt throws. - //! - //! Complexity: Linear to n. - template - void assign(InpIt first, InpIt last - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible::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); - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Assigns the range [il.begin(), il.end()) to *this. - //! - //! Throws: If memory allocation throws or - //! T's constructor from dereferencing std::initializer_list iterator throws. - //! - //! Complexity: Linear to range [il.begin(), il.end()). - - void assign(std::initializer_list il) - { - assign(il.begin(), il.end()); - } -#endif - //! Effects: Returns a copy of the internal allocator. - //! - //! Throws: If allocator's copy constructor throws. - //! - //! Complexity: Constant. - allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT - { return allocator_type(this->node_alloc()); } - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT - { return this->node_alloc(); } - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT - { return this->node_alloc(); } - - ////////////////////////////////////////////// - // - // iterators - // - ////////////////////////////////////////////// - - //! Effects: Returns a non-dereferenceable iterator that, - //! when incremented, yields begin(). This iterator may be used - //! as the argument to insert_after, erase_after, etc. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator before_begin() BOOST_CONTAINER_NOEXCEPT - { return iterator(end()); } - - //! Effects: 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. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator before_begin() const BOOST_CONTAINER_NOEXCEPT - { return this->cbefore_begin(); } - - //! Effects: Returns an iterator to the first element contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator begin() BOOST_CONTAINER_NOEXCEPT - { return iterator(this->icont().begin()); } - - //! Effects: Returns a const_iterator to the first element contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator begin() const BOOST_CONTAINER_NOEXCEPT - { return this->cbegin(); } - - //! Effects: Returns an iterator to the end of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator end() BOOST_CONTAINER_NOEXCEPT - { return iterator(this->icont().end()); } - - //! Effects: Returns a const_iterator to the end of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator end() const BOOST_CONTAINER_NOEXCEPT - { return this->cend(); } - - //! Effects: 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. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cbefore_begin() const BOOST_CONTAINER_NOEXCEPT - { return const_iterator(end()); } - - //! Effects: Returns a const_iterator to the first element contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT - { return const_iterator(this->non_const_icont().begin()); } - - //! Effects: Returns a const_iterator to the end of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT - { return const_iterator(this->non_const_icont().end()); } - - //! Returns: 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. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements before i. - //! - //! Note: Non-standard extension. - iterator previous(iterator p) BOOST_CONTAINER_NOEXCEPT - { return iterator(this->icont().previous(p.get())); } - - //! Returns: 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. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements before i. - //! - //! Note: Non-standard extension. - const_iterator previous(const_iterator p) - { return const_iterator(this->icont().previous(p.get())); } - - ////////////////////////////////////////////// - // - // capacity - // - ////////////////////////////////////////////// - - //! Effects: Returns true if the list contains no elements. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - bool empty() const - { return !this->size(); } - - //! Effects: Returns the number of the elements contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type size() const - { return this->icont().size(); } - - //! Effects: Returns the largest possible size of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type max_size() const - { return AllocHolder::max_size(); } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are value initialized. - //! - //! Throws: If memory allocation throws, or T's copy constructor throws. - //! - //! Complexity: 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 value_init_construct_iterator value_init_iterator; - this->insert_after(last_pos, value_init_iterator(new_size - this->size()), value_init_iterator()); - } - } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are copy constructed from x. - //! - //! Throws: If memory allocation throws, or T's copy constructor throws. - //! - //! Complexity: 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 - // - ////////////////////////////////////////////// - - //! Requires: !empty() - //! - //! Effects: Returns a reference to the first element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference front() - { return *this->begin(); } - - //! Requires: !empty() - //! - //! Effects: Returns a const reference to the first element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference front() const - { return *this->begin(); } - - ////////////////////////////////////////////// - // - // modifiers - // - ////////////////////////////////////////////// - - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... in the front of the list - //! - //! Throws: If memory allocation throws or - //! T's copy constructor throws. - //! - //! Complexity: Amortized constant time. - template - void emplace_front(Args&&... args) - { this->emplace_after(this->cbefore_begin(), boost::forward(args)...); } - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... after prev - //! - //! Throws: If memory allocation throws or - //! T's in-place constructor throws. - //! - //! Complexity: Constant - template - iterator emplace_after(const_iterator prev, Args&&... args) - { - NodePtr pnode(AllocHolder::create_node(boost::forward(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_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 - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: Inserts a copy of x at the beginning of the list. - //! - //! Throws: If memory allocation throws or - //! T's copy constructor throws. - //! - //! Complexity: Amortized constant time. - void push_front(const T &x); - - //! Effects: Constructs a new element in the beginning of the list - //! and moves the resources of mx to this new element. - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: 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) - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Inserts a copy of the value after prev_p. - //! - //! Returns: An iterator to the inserted element. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Amortized constant time. - //! - //! Note: Does not affect the validity of iterators and references of - //! previous values. - iterator insert_after(const_iterator prev_p, const T &x); - - //! Requires: prev_p must be a valid iterator of *this. - //! - //! Effects: Inserts a move constructed copy object from the value after the - //! p pointed by prev_p. - //! - //! Returns: An iterator to the inserted element. - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: Amortized constant time. - //! - //! Note: Does not affect the validity of iterators and references of - //! previous values. - iterator insert_after(const_iterator prev_p, T &&x); - #else - BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert_after, T, iterator, priv_insert_after, const_iterator, const_iterator) - #endif - - //! Requires: prev_p must be a valid iterator of *this. - //! - //! Effects: Inserts n copies of x after prev_p. - //! - //! Returns: an iterator to the last inserted element or prev_p if n is 0. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! - //! Complexity: Linear to n. - //! - //! Note: Does not affect the validity of iterators and references of - //! previous values. - iterator insert_after(const_iterator prev_p, size_type n, const value_type& x) - { - typedef constant_iterator cvalue_iterator; - return this->insert_after(prev_p, cvalue_iterator(x, n), cvalue_iterator()); - } - - //! Requires: prev_p must be a valid iterator of *this. - //! - //! Effects: Inserts the range pointed by [first, last) after prev_p. - //! - //! Returns: an iterator to the last inserted element or prev_p if first == last. - //! - //! Throws: If memory allocation throws, T's constructor from a - //! dereferenced InpIt throws. - //! - //! Complexity: Linear to the number of elements inserted. - //! - //! Note: Does not affect the validity of iterators and references of - //! previous values. - template - iterator insert_after(const_iterator prev_p, InpIt first, InpIt last - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - && (container_detail::is_input_iterator::value - || container_detail::is_same::value - ) - >::type * = 0 - #endif - ) - { - iterator ret_it(prev_p.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_NO_CXX11_HDR_INITIALIZER_LIST) - //! Requires: prev_p must be a valid iterator of *this. - //! - //! Effects: Inserts the range pointed by [il.begin(), il.end()) after prev_p. - //! - //! Returns: an iterator to the last inserted element or prev_p if il.begin() == il.end(). - //! - //! Throws: If memory allocation throws, T's constructor from a - //! dereferenced std::initializer_list iterator throws. - //! - //! Complexity: Linear to the number of elements inserted. - //! - //! Note: Does not affect the validity of iterators and references of - //! previous values. - iterator insert_after(const_iterator prev_p, std::initializer_list il) - { - return insert_after(prev_p, il.begin(), il.end()); - } -#endif - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - template - iterator insert_after(const_iterator prev, FwdIt first, FwdIt last - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - && !(container_detail::is_input_iterator::value - || container_detail::is_same::value - ) - >::type * = 0 - ) - { - //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()); - } - #endif - - //! Effects: Removes the first element from the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Amortized constant time. - void pop_front() - { this->icont().pop_front_and_dispose(Destroyer(this->node_alloc())); } - - //! Effects: Erases the element after the element pointed by prev_p - //! of the list. - //! - //! Returns: the first element remaining beyond the removed elements, - //! or end() if no such element exists. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: Does not invalidate iterators or references to non erased elements. - iterator erase_after(const_iterator prev_p) - { - return iterator(this->icont().erase_after_and_dispose(prev_p.get(), Destroyer(this->node_alloc()))); - } - - //! Effects: Erases the range (before_first, last) from - //! the list. - //! - //! Returns: the first element remaining beyond the removed elements, - //! or end() if no such element exists. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of erased elements. - //! - //! Note: Does not invalidate iterators or references to non erased elements. - iterator erase_after(const_iterator before_first, const_iterator last) - { - return iterator(this->icont().erase_after_and_dispose(before_first.get(), last.get(), Destroyer(this->node_alloc()))); - } - - //! Effects: Swaps the contents of *this and x. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements on *this and x. - void swap(slist& x) - { AllocHolder::swap(x); } - - //! Effects: Erases all the elements of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements in the list. - void clear() - { this->icont().clear_and_dispose(Destroyer(this->node_alloc())); } - - ////////////////////////////////////////////// - // - // slist operations - // - ////////////////////////////////////////////// - - //! Requires: p must point to an element contained - //! by the list. x != *this - //! - //! Effects: Transfers all the elements of list x to this list, after the - //! the element pointed by p. No destructors or copy constructors are called. - //! - //! Throws: std::runtime_error if this' allocator and x's allocator - //! are not equal. - //! - //! Complexity: Linear to the elements in x. - //! - //! Note: 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_p, slist& x) BOOST_CONTAINER_NOEXCEPT - { - BOOST_ASSERT(this != &x); - BOOST_ASSERT(this->node_alloc() == x.node_alloc()); - this->icont().splice_after(prev_p.get(), x.icont()); - } - - //! Requires: p must point to an element contained - //! by the list. x != *this - //! - //! Effects: Transfers all the elements of list x to this list, after the - //! the element pointed by p. No destructors or copy constructors are called. - //! - //! Throws: std::runtime_error if this' allocator and x's allocator - //! are not equal. - //! - //! Complexity: Linear to the elements in x. - //! - //! Note: 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_p, BOOST_RV_REF(slist) x) BOOST_CONTAINER_NOEXCEPT - { this->splice_after(prev_p, static_cast(x)); } - - //! Requires: prev_p must be a valid iterator of this. - //! i must point to an element contained in list x. - //! this' allocator and x's allocator shall compare equal. - //! - //! Effects: Transfers the value pointed by i, from list x to this list, - //! after the element pointed by prev_p. - //! If prev_p == prev or prev_p == ++prev, this function is a null operation. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: 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_p, slist& x, const_iterator prev) BOOST_CONTAINER_NOEXCEPT - { - BOOST_ASSERT(this->node_alloc() == x.node_alloc()); - this->icont().splice_after(prev_p.get(), x.icont(), prev.get()); - } - - //! Requires: prev_p must be a valid iterator of this. - //! i must point to an element contained in list x. - //! this' allocator and x's allocator shall compare equal. - //! - //! Effects: Transfers the value pointed by i, from list x to this list, - //! after the element pointed by prev_p. - //! If prev_p == prev or prev_p == ++prev, this function is a null operation. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: 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_p, BOOST_RV_REF(slist) x, const_iterator prev) BOOST_CONTAINER_NOEXCEPT - { this->splice_after(prev_p, static_cast(x), prev); } - - //! Requires: prev_p must be a valid iterator of this. - //! before_first and before_last must be valid iterators of x. - //! prev_p must not be contained in [before_first, before_last) range. - //! this' allocator and x's allocator shall compare equal. - //! - //! Effects: Transfers the range [before_first + 1, before_last + 1) - //! from list x to this list, after the element pointed by prev_p. - //! - //! Throws: Nothing - //! - //! Complexity: Linear to the number of transferred elements. - //! - //! Note: 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_p, slist& x, - const_iterator before_first, const_iterator before_last) BOOST_CONTAINER_NOEXCEPT - { - BOOST_ASSERT(this->node_alloc() == x.node_alloc()); - this->icont().splice_after - (prev_p.get(), x.icont(), before_first.get(), before_last.get()); - } - - //! Requires: prev_p must be a valid iterator of this. - //! before_first and before_last must be valid iterators of x. - //! prev_p must not be contained in [before_first, before_last) range. - //! this' allocator and x's allocator shall compare equal. - //! - //! Effects: Transfers the range [before_first + 1, before_last + 1) - //! from list x to this list, after the element pointed by prev_p. - //! - //! Throws: Nothing - //! - //! Complexity: Linear to the number of transferred elements. - //! - //! Note: 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_p, BOOST_RV_REF(slist) x, - const_iterator before_first, const_iterator before_last) BOOST_CONTAINER_NOEXCEPT - { this->splice_after(prev_p, static_cast(x), before_first, before_last); } - - //! Requires: prev_p must be a valid iterator of this. - //! before_first and before_last must be valid iterators of x. - //! prev_p must not be contained in [before_first, before_last) range. - //! n == std::distance(before_first, before_last). - //! this' allocator and x's allocator shall compare equal. - //! - //! Effects: Transfers the range [before_first + 1, before_last + 1) - //! from list x to this list, after the element pointed by prev_p. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: 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_p, slist& x, - const_iterator before_first, const_iterator before_last, - size_type n) BOOST_CONTAINER_NOEXCEPT - { - BOOST_ASSERT(this->node_alloc() == x.node_alloc()); - this->icont().splice_after - (prev_p.get(), x.icont(), before_first.get(), before_last.get(), n); - } - - //! Requires: prev_p must be a valid iterator of this. - //! before_first and before_last must be valid iterators of x. - //! prev_p must not be contained in [before_first, before_last) range. - //! n == std::distance(before_first, before_last). - //! this' allocator and x's allocator shall compare equal. - //! - //! Effects: Transfers the range [before_first + 1, before_last + 1) - //! from list x to this list, after the element pointed by prev_p. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: 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_p, BOOST_RV_REF(slist) x, - const_iterator before_first, const_iterator before_last, - size_type n) BOOST_CONTAINER_NOEXCEPT - { this->splice_after(prev_p, static_cast(x), before_first, before_last, n); } - - //! Effects: Removes all the elements that compare equal to value. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear time. It performs exactly size() comparisons for equality. - //! - //! Note: 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) - { this->remove_if(equal_to_value(value)); } - - //! Effects: Removes all the elements for which a specified - //! predicate is satisfied. - //! - //! Throws: If pred throws. - //! - //! Complexity: Linear time. It performs exactly size() calls to the predicate. - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - template - void remove_if(Pred pred) - { - typedef ValueCompareToNodeCompare Predicate; - this->icont().remove_and_dispose_if(Predicate(pred), Destroyer(this->node_alloc())); - } - - //! Effects: Removes adjacent duplicate elements or adjacent - //! elements that are equal from the list. - //! - //! Throws: If comparison throws. - //! - //! Complexity: Linear time (size()-1 comparisons equality comparisons). - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - void unique() - { this->unique(value_equal()); } - - //! Effects: Removes adjacent duplicate elements or adjacent - //! elements that satisfy some binary predicate from the list. - //! - //! Throws: If pred throws. - //! - //! Complexity: Linear time (size()-1 comparisons calls to pred()). - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - template - void unique(Pred pred) - { - typedef ValueCompareToNodeCompare Predicate; - this->icont().unique_and_dispose(Predicate(pred), Destroyer(this->node_alloc())); - } - - //! Requires: The lists x and *this must be distinct. - //! - //! Effects: This function removes all of x's elements and inserts them - //! in order into *this according to std::less. 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. - //! - //! Throws: If comparison throws. - //! - //! Complexity: This function is linear time: it performs at most - //! size() + x.size() - 1 comparisons. - void merge(slist & x) - { this->merge(x, value_less()); } - - //! Requires: The lists x and *this must be distinct. - //! - //! Effects: This function removes all of x's elements and inserts them - //! in order into *this according to std::less. 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. - //! - //! Throws: If comparison throws. - //! - //! Complexity: 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(x)); } - - //! Requires: 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. - //! - //! Effects: 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. - //! - //! Throws: If comp throws. - //! - //! Complexity: This function is linear time: it performs at most - //! size() + x.size() - 1 comparisons. - //! - //! Note: Iterators and references to *this are not invalidated. - template - void merge(slist& x, StrictWeakOrdering comp) - { - BOOST_ASSERT(this->node_alloc() == x.node_alloc()); - this->icont().merge(x.icont(), - ValueCompareToNodeCompare(comp)); - } - - //! Requires: 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. - //! - //! Effects: 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. - //! - //! Throws: If comp throws. - //! - //! Complexity: This function is linear time: it performs at most - //! size() + x.size() - 1 comparisons. - //! - //! Note: Iterators and references to *this are not invalidated. - template - void merge(BOOST_RV_REF(slist) x, StrictWeakOrdering comp) - { this->merge(static_cast(x), comp); } - - //! Effects: This function sorts the list *this according to std::less. - //! The sort is stable, that is, the relative order of equivalent elements is preserved. - //! - //! Throws: If comparison throws. - //! - //! Notes: Iterators and references are not invalidated. - //! - //! Complexity: The number of comparisons is approximately N log N, where N - //! is the list's size. - void sort() - { this->sort(value_less()); } - - //! Effects: This function sorts the list *this according to std::less. - //! The sort is stable, that is, the relative order of equivalent elements is preserved. - //! - //! Throws: If comp throws. - //! - //! Notes: Iterators and references are not invalidated. - //! - //! Complexity: The number of comparisons is approximately N log N, where N - //! is the list's size. - template - void sort(StrictWeakOrdering comp) - { - // nothing if the slist has length 0 or 1. - if (this->size() < 2) - return; - this->icont().sort(ValueCompareToNodeCompare(comp)); - } - - //! Effects: Reverses the order of elements in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: This function is linear time. - //! - //! Note: Iterators and references are not invalidated - void reverse() BOOST_CONTAINER_NOEXCEPT - { this->icont().reverse(); } - - ////////////////////////////////////////////// - // - // list compatibility interface - // - ////////////////////////////////////////////// - - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... before p - //! - //! Throws: If memory allocation throws or - //! T's in-place constructor throws. - //! - //! Complexity: Linear to the elements before p - template - iterator emplace(const_iterator p, Args&&... args) - { return this->emplace_after(this->previous(p), boost::forward(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 - - #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a copy of x before p. - //! - //! Returns: an iterator to the inserted element. - //! - //! Throws: If memory allocation throws or x's copy constructor throws. - //! - //! Complexity: Linear to the elements before p. - iterator insert(const_iterator p, const T &x); - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a new element before p with mx's resources. - //! - //! Returns: an iterator to the inserted element. - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: Linear to the elements before p. - iterator insert(const_iterator prev_p, T &&x); - #else - BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator, const_iterator) - #endif - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Inserts n copies of x before p. - //! - //! Returns: an iterator to the first inserted element or p if n == 0. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to n plus linear to the elements before p. - iterator insert(const_iterator p, size_type n, const value_type& x) - { - const_iterator prev(this->previous(p)); - this->insert_after(prev, n, x); - return ++iterator(prev.get()); - } - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a copy of the [first, last) range before p. - //! - //! Returns: an iterator to the first inserted element or p if first == last. - //! - //! Throws: If memory allocation throws, T's constructor from a - //! dereferenced InpIt throws. - //! - //! Complexity: Linear to std::distance [first, last) plus - //! linear to the elements before p. - template - iterator insert(const_iterator p, InIter first, InIter last) - { - const_iterator prev(this->previous(p)); - this->insert_after(prev, first, last); - return ++iterator(prev.get()); - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a copy of the [il.begin(), il.end()) range before p. - //! - //! Returns: an iterator to the first inserted element or p if il.begin() == il.end(). - //! - //! Throws: If memory allocation throws, T's constructor from a - //! dereferenced std::initializer_list iterator throws. - //! - //! Complexity: Linear to the range [il.begin(), il.end()) plus - //! linear to the elements before p. - iterator insert(const_iterator p, std::initializer_list il) - { - return insert(p, il.begin(), il.end()); - } -#endif - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Erases the element at p p. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements before p. - iterator erase(const_iterator p) BOOST_CONTAINER_NOEXCEPT - { return iterator(this->erase_after(previous(p))); } - - //! Requires: first and last must be valid iterator to elements in *this. - //! - //! Effects: Erases the elements pointed by [first, last). - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the distance between first and last plus - //! linear to the elements before first. - iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT - { return iterator(this->erase_after(previous(first), last)); } - - //! Requires: p must point to an element contained - //! by the list. x != *this. this' allocator and x's allocator shall compare equal - //! - //! Effects: Transfers all the elements of list x to this list, before the - //! the element pointed by p. No destructors or copy constructors are called. - //! - //! Throws: Nothing - //! - //! Complexity: Linear in distance(begin(), p), and linear in x.size(). - //! - //! Note: 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) BOOST_CONTAINER_NOEXCEPT - { this->splice_after(this->previous(p), x); } - - //! Requires: p must point to an element contained - //! by the list. x != *this. this' allocator and x's allocator shall compare equal - //! - //! Effects: Transfers all the elements of list x to this list, before the - //! the element pointed by p. No destructors or copy constructors are called. - //! - //! Throws: Nothing - //! - //! Complexity: Linear in distance(begin(), p), and linear in x.size(). - //! - //! Note: 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) BOOST_CONTAINER_NOEXCEPT - { this->splice(p, static_cast(x)); } - - //! Requires: p must point to an element contained - //! by this list. i must point to an element contained in list x. - //! this' allocator and x's allocator shall compare equal - //! - //! Effects: 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. - //! - //! Throws: Nothing - //! - //! Complexity: Linear in distance(begin(), p), and in distance(x.begin(), i). - //! - //! Note: 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) BOOST_CONTAINER_NOEXCEPT - { this->splice_after(this->previous(p), x, this->previous(i)); } - - //! Requires: p must point to an element contained - //! by this list. i must point to an element contained in list x. - //! this' allocator and x's allocator shall compare equal. - //! - //! Effects: 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. - //! - //! Throws: Nothing - //! - //! Complexity: Linear in distance(begin(), p), and in distance(x.begin(), i). - //! - //! Note: 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) BOOST_CONTAINER_NOEXCEPT - { this->splice(p, static_cast(x), i); } - - //! Requires: p must point to an element contained - //! by this list. first and last must point to elements contained in list x. - //! - //! Effects: 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. - //! this' allocator and x's allocator shall compare equal. - //! - //! Throws: Nothing - //! - //! Complexity: Linear in distance(begin(), p), in distance(x.begin(), first), - //! and in distance(first, last). - //! - //! Note: 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) BOOST_CONTAINER_NOEXCEPT - { this->splice_after(this->previous(p), x, this->previous(first), this->previous(last)); } - - //! Requires: p must point to an element contained - //! by this list. first and last must point to elements contained in list x. - //! this' allocator and x's allocator shall compare equal - //! - //! Effects: 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. - //! - //! Throws: Nothing - //! - //! Complexity: Linear in distance(begin(), p), in distance(x.begin(), first), - //! and in distance(first, last). - //! - //! Note: 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) BOOST_CONTAINER_NOEXCEPT - { this->splice(p, static_cast(x), first, last); } - - //! Effects: Returns true if x and y are equal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator==(const slist& x, const slist& y) - { - if(x.size() != y.size()){ - return false; - } - typedef typename slist::const_iterator const_iterator; - const_iterator end1 = x.end(); - - const_iterator i1 = x.begin(); - const_iterator i2 = y.begin(); - while (i1 != end1 && *i1 == *i2){ - ++i1; - ++i2; - } - return i1 == end1; - } - - //! Effects: Returns true if x and y are unequal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator!=(const slist& x, const slist& y) - { return !(x == y); } - - //! Effects: Returns true if x is less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<(const slist& x, const slist& y) - { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } - - //! Effects: Returns true if x is greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>(const slist& x, const slist& y) - { return y < x; } - - //! Effects: Returns true if x is equal or less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<=(const slist& x, const slist& y) - { return !(y < x); } - - //! Effects: Returns true if x is equal or greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>=(const slist& x, const slist& y) - { return !(x < y); } - - //! Effects: x.swap(y) - //! - //! Complexity: Constant. - friend void swap(slist& x, slist& y) - { x.swap(y); } - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - - void priv_push_front (const T &x) - { this->insert_after(this->cbefore_begin(), x); } - - void priv_push_front (BOOST_RV_REF(T) x) - { this->insert_after(this->cbefore_begin(), ::boost::move(x)); } - - bool priv_try_shrink(size_type new_size, const_iterator &last_pos) - { - 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; - } - } - - template - iterator priv_insert(const_iterator p, BOOST_FWD_REF(U) x) - { return this->insert_after(previous(p), ::boost::forward(x)); } - - template - iterator priv_insert_after(const_iterator prev_p, BOOST_FWD_REF(U) x) - { return iterator(this->icont().insert_after(prev_p.get(), *this->create_node(::boost::forward(x)))); } - - class insertion_functor; - friend class insertion_functor; - - class insertion_functor - { - 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()) - {} - - void operator()(Node &n) - { - ret_ = this->icont_.insert_after(prev_, n); - } - - iiterator inserted_first() const - { return ret_; } - }; - - //Functors for member algorithm defaults - struct value_less - { - bool operator()(const value_type &a, const value_type &b) const - { return a < b; } - }; - - struct value_equal - { - bool operator()(const value_type &a, const value_type &b) const - { return a == b; } - }; - - struct value_equal_to_this - { - explicit value_equal_to_this(const value_type &ref) - : m_ref(ref){} - - bool operator()(const value_type &val) const - { return m_ref == val; } - - const value_type &m_ref; - }; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -}; - -}} - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -namespace boost { - -//!has_trivial_destructor_after_move<> == true_type -//!specialization for optimizations -template -struct has_trivial_destructor_after_move > - : public ::boost::has_trivial_destructor_after_move -{}; - -namespace container { - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -}} //namespace boost{ namespace container { - -// Specialization of insert_iterator so that insertions will be constant -// time rather than linear time. - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -//Ummm, I don't like to define things in namespace std, but -//there is no other way -namespace std { - -template -class insert_iterator > -{ - protected: - typedef boost::container::slist Container; - Container* container; - typename Container::iterator iter; - public: - typedef Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(Container& x, - typename Container::iterator i, - bool is_previous = false) - : container(&x), iter(is_previous ? i : x.previous(i)){ } - - insert_iterator& - operator=(const typename Container::value_type& value) - { - iter = container->insert_after(iter, value); - return *this; - } - insert_iterator& operator*(){ return *this; } - insert_iterator& operator++(){ return *this; } - insert_iterator& operator++(int){ return *this; } -}; - -} //namespace std; - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -#include - -#endif // BOOST_CONTAINER_SLIST_HPP diff --git a/boost/container/stable_vector.hpp b/boost/container/stable_vector.hpp deleted file mode 100644 index b8b4157..0000000 --- a/boost/container/stable_vector.hpp +++ /dev/null @@ -1,1949 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2008-2013. Distributed under the 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. -// -////////////////////////////////////////////////////////////////////////////// -// Stable vector. -// -// Copyright 2008 Joaquin M Lopez Munoz. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_CONTAINER_STABLE_VECTOR_HPP -#define BOOST_CONTAINER_STABLE_VECTOR_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -#include - -//#define STABLE_VECTOR_ENABLE_INVARIANT_CHECKING - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -namespace boost { -namespace container { - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) -#include -#endif - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -namespace stable_vector_detail{ - -template -class clear_on_destroy -{ - public: - clear_on_destroy(C &c) - : c_(c), do_clear_(true) - {} - - void release() - { do_clear_ = false; } - - ~clear_on_destroy() - { - if(do_clear_){ - c_.clear(); - c_.priv_clear_pool(); - } - } - - private: - clear_on_destroy(const clear_on_destroy &); - clear_on_destroy &operator=(const clear_on_destroy &); - C &c_; - bool do_clear_; -}; - -template -struct node; - -template -struct node_base -{ - private: - typedef typename boost::intrusive:: - pointer_traits void_ptr_traits; - typedef typename void_ptr_traits:: - template rebind_pointer - ::type node_base_ptr; - typedef typename void_ptr_traits:: - template rebind_pointer - ::type node_base_ptr_ptr; - - public: - node_base(const node_base_ptr_ptr &n) - : up(n) - {} - - node_base() - : up() - {} - - node_base_ptr_ptr up; -}; - -template -struct node - : public node_base - ::template - rebind_pointer::type - > -{ - private: - node(); - - public: - typename ::boost::intrusive::pointer_traits::element_type value; -}; - -template -struct index_traits -{ - typedef boost::intrusive:: - pointer_traits - void_ptr_traits; - typedef stable_vector_detail:: - node_base node_base_type; - typedef typename void_ptr_traits::template - rebind_pointer::type node_base_ptr; - typedef typename void_ptr_traits::template - rebind_pointer::type node_base_ptr_ptr; - typedef boost::intrusive:: - pointer_traits node_base_ptr_traits; - typedef boost::intrusive:: - pointer_traits node_base_ptr_ptr_traits; - typedef typename allocator_traits:: - template portable_rebind_alloc - ::type node_base_ptr_allocator; - typedef ::boost::container::vector - 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()){ - index_iterator end_node_it(index_traits::get_fix_up_end(index)); - node_base_ptr &end_node_idx_ref = *(--end_node_it); - 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 - -template -class stable_vector_iterator -{ - typedef boost::intrusive::pointer_traits non_const_ptr_traits; - public: - typedef std::random_access_iterator_tag iterator_category; - typedef typename non_const_ptr_traits::element_type value_type; - typedef typename non_const_ptr_traits::difference_type difference_type; - typedef typename ::boost::container::container_detail::if_c - < IsConst - , typename non_const_ptr_traits::template - rebind_pointer::type - , Pointer - >::type pointer; - typedef boost::intrusive::pointer_traits ptr_traits; - typedef typename ptr_traits::reference reference; - - private: - typedef typename non_const_ptr_traits::template - rebind_pointer::type void_ptr; - typedef stable_vector_detail::node node_type; - typedef stable_vector_detail::node_base node_base_type; - typedef typename non_const_ptr_traits::template - rebind_pointer::type node_ptr; - typedef boost::intrusive:: - pointer_traits node_ptr_traits; - typedef typename non_const_ptr_traits::template - rebind_pointer::type node_base_ptr; - typedef typename non_const_ptr_traits::template - rebind_pointer::type node_base_ptr_ptr; - - node_base_ptr m_pn; - - public: - - explicit stable_vector_iterator(node_base_ptr p) BOOST_CONTAINER_NOEXCEPT - : m_pn(p) - {} - - stable_vector_iterator() BOOST_CONTAINER_NOEXCEPT - : m_pn() //Value initialization to achieve "null iterators" (N3644) - {} - - stable_vector_iterator(stable_vector_iterator const& other) BOOST_CONTAINER_NOEXCEPT - : m_pn(other.node_pointer()) - {} - - node_ptr node_pointer() const BOOST_CONTAINER_NOEXCEPT - { return node_ptr_traits::static_cast_from(m_pn); } - - public: - //Pointer like operators - reference operator*() const BOOST_CONTAINER_NOEXCEPT - { return node_pointer()->value; } - - pointer operator->() const BOOST_CONTAINER_NOEXCEPT - { return ptr_traits::pointer_to(this->operator*()); } - - //Increment / Decrement - stable_vector_iterator& operator++() BOOST_CONTAINER_NOEXCEPT - { - node_base_ptr_ptr p(this->m_pn->up); - this->m_pn = *(++p); - return *this; - } - - stable_vector_iterator operator++(int) BOOST_CONTAINER_NOEXCEPT - { stable_vector_iterator tmp(*this); ++*this; return stable_vector_iterator(tmp); } - - stable_vector_iterator& operator--() BOOST_CONTAINER_NOEXCEPT - { - node_base_ptr_ptr p(this->m_pn->up); - this->m_pn = *(--p); - return *this; - } - - stable_vector_iterator operator--(int) BOOST_CONTAINER_NOEXCEPT - { stable_vector_iterator tmp(*this); --*this; return stable_vector_iterator(tmp); } - - reference operator[](difference_type off) const BOOST_CONTAINER_NOEXCEPT - { return node_ptr_traits::static_cast_from(this->m_pn->up[off])->value; } - - stable_vector_iterator& operator+=(difference_type off) BOOST_CONTAINER_NOEXCEPT - { - if(off) this->m_pn = this->m_pn->up[off]; - return *this; - } - - friend stable_vector_iterator operator+(const stable_vector_iterator &left, difference_type off) BOOST_CONTAINER_NOEXCEPT - { - stable_vector_iterator tmp(left); - tmp += off; - return tmp; - } - - friend stable_vector_iterator operator+(difference_type off, const stable_vector_iterator& right) BOOST_CONTAINER_NOEXCEPT - { - stable_vector_iterator tmp(right); - tmp += off; - return tmp; - } - - stable_vector_iterator& operator-=(difference_type off) BOOST_CONTAINER_NOEXCEPT - { *this += -off; return *this; } - - friend stable_vector_iterator operator-(const stable_vector_iterator &left, difference_type off) BOOST_CONTAINER_NOEXCEPT - { - stable_vector_iterator tmp(left); - tmp -= off; - return tmp; - } - - friend difference_type operator-(const stable_vector_iterator& left, const stable_vector_iterator& right) BOOST_CONTAINER_NOEXCEPT - { return left.m_pn->up - right.m_pn->up; } - - //Comparison operators - friend bool operator== (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return l.m_pn == r.m_pn; } - - friend bool operator!= (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return l.m_pn != r.m_pn; } - - friend bool operator< (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return l.m_pn->up < r.m_pn->up; } - - friend bool operator<= (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return l.m_pn->up <= r.m_pn->up; } - - friend bool operator> (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return l.m_pn->up > r.m_pn->up; } - - friend bool operator>= (const stable_vector_iterator& l, const stable_vector_iterator& r) BOOST_CONTAINER_NOEXCEPT - { return l.m_pn->up >= r.m_pn->up; } -}; - - #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(); - - #else //STABLE_VECTOR_ENABLE_INVARIANT_CHECKING - - #define STABLE_VECTOR_CHECK_INVARIANT - - #endif //#if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING) - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -//! 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. -//! -//! Here are the details taken from the author's blog -//! ( -//! Introducing stable_vector): -//! -//! 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. -//! 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 -//! assigned the return value of end() always remain valid until the destruction of -//! the associated stable_vector. -//! -//! Operation complexity: The big-O complexities of stable_vector operations match -//! exactly those of std::vector. In general, insertion/deletion is constant time at -//! the end of the sequence and linear elsewhere. Unlike std::vector, stable_vector -//! does not internally perform any value_type destruction, copy or assignment -//! operations other than those exactly corresponding to the insertion of new -//! elements or deletion of stored elements, which can sometimes compensate in terms -//! of performance for the extra burden of doing more pointer manipulation and an -//! 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. -//! -//! \tparam T The type of object that is stored in the stable_vector -//! \tparam Allocator The allocator used for all internal memory management -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template > -#else -template -#endif -class stable_vector -{ - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - typedef allocator_traits allocator_traits_type; - typedef boost::intrusive:: - pointer_traits - ptr_traits; - typedef typename ptr_traits:: - template rebind_pointer::type void_ptr; - typedef typename allocator_traits_type:: - template portable_rebind_alloc - ::type void_allocator_type; - typedef stable_vector_detail::index_traits - 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 stable_vector_detail::node - node_type; - typedef typename ptr_traits::template - rebind_pointer::type node_ptr; - typedef boost::intrusive:: - pointer_traits node_ptr_traits; - typedef typename ptr_traits::template - rebind_pointer::type const_node_ptr; - typedef boost::intrusive:: - pointer_traits 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 allocator_v1; - typedef ::boost::container::container_detail:: - integral_constant allocator_v2; - typedef ::boost::container::container_detail::integral_constant - ::value> alloc_version; - typedef typename allocator_traits_type:: - template portable_rebind_alloc - ::type node_allocator_type; - - typedef ::boost::container::container_detail:: - allocator_version_traits allocator_version_traits_t; - typedef typename allocator_version_traits_t::multiallocation_chain multiallocation_chain; - - node_ptr allocate_one() - { return allocator_version_traits_t::allocate_one(this->priv_node_alloc()); } - - void deallocate_one(const node_ptr &p) - { allocator_version_traits_t::deallocate_one(this->priv_node_alloc(), p); } - - void allocate_individual(typename allocator_traits_type::size_type n, multiallocation_chain &m) - { allocator_version_traits_t::allocate_individual(this->priv_node_alloc(), n, m); } - - void deallocate_individual(multiallocation_chain &holder) - { allocator_version_traits_t::deallocate_individual(this->priv_node_alloc(), holder); } - - friend class stable_vector_detail::clear_on_destroy; - typedef stable_vector_iterator - < typename allocator_traits::pointer - , false> iterator_impl; - typedef stable_vector_iterator - < typename allocator_traits::pointer - , false> const_iterator_impl; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - public: - - ////////////////////////////////////////////// - // - // types - // - ////////////////////////////////////////////// - typedef T value_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator 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(container_detail::reverse_iterator) reverse_iterator; - typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) const_reverse_iterator; - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - BOOST_COPYABLE_AND_MOVABLE(stable_vector) - static const size_type ExtraPointers = index_traits_type::ExtraPointers; - - class insert_rollback; - friend class insert_rollback; - - class push_back_rollback; - friend class push_back_rollback; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - ////////////////////////////////////////////// - // - // construct/copy/destroy - // - ////////////////////////////////////////////// - - //! Effects: Default constructs a stable_vector. - //! - //! Throws: If allocator_type's default constructor throws. - //! - //! Complexity: Constant. - stable_vector() - : internal_data(), index() - { - STABLE_VECTOR_CHECK_INVARIANT; - } - - //! Effects: Constructs a stable_vector taking the allocator as parameter. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - explicit stable_vector(const allocator_type& al) BOOST_CONTAINER_NOEXCEPT - : internal_data(al), index(al) - { - STABLE_VECTOR_CHECK_INVARIANT; - } - - //! Effects: Constructs a stable_vector that will use a copy of allocator a - //! and inserts n value initialized values. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's default or copy constructor throws. - //! - //! Complexity: Linear to n. - explicit stable_vector(size_type n) - : internal_data(), index() - { - stable_vector_detail::clear_on_destroy cod(*this); - this->resize(n); - STABLE_VECTOR_CHECK_INVARIANT; - cod.release(); - } - - //! Effects: Constructs a stable_vector that will use a copy of allocator a - //! and inserts n default initialized values. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's default or copy constructor throws. - //! - //! Complexity: Linear to n. - //! - //! Note: Non-standard extension - stable_vector(size_type n, default_init_t) - : internal_data(), index() - { - stable_vector_detail::clear_on_destroy cod(*this); - this->resize(n, default_init); - STABLE_VECTOR_CHECK_INVARIANT; - cod.release(); - } - - //! Effects: Constructs a stable_vector that will use a copy of allocator a - //! and inserts n copies of value. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's default or copy constructor throws. - //! - //! Complexity: Linear to n. - stable_vector(size_type n, const T& t, const allocator_type& al = allocator_type()) - : internal_data(al), index(al) - { - stable_vector_detail::clear_on_destroy cod(*this); - this->insert(this->cend(), n, t); - STABLE_VECTOR_CHECK_INVARIANT; - cod.release(); - } - - //! Effects: Constructs a stable_vector that will use a copy of allocator a - //! and inserts a copy of the range [first, last) in the stable_vector. - //! - //! Throws: If allocator_type's default constructor - //! throws or T's constructor taking a dereferenced InIt throws. - //! - //! Complexity: Linear to the range [first, last). - template - stable_vector(InputIterator first,InputIterator last, const allocator_type& al = allocator_type()) - : internal_data(al), index(al) - { - stable_vector_detail::clear_on_destroy cod(*this); - this->insert(this->cend(), first, last); - STABLE_VECTOR_CHECK_INVARIANT; - cod.release(); - } - - //! Effects: Copy constructs a stable_vector. - //! - //! Postcondition: x == *this. - //! - //! Complexity: Linear to the elements x contains. - stable_vector(const stable_vector& x) - : internal_data(allocator_traits:: - select_on_container_copy_construction(x.priv_node_alloc())) - , index(allocator_traits:: - select_on_container_copy_construction(x.index.get_stored_allocator())) - { - stable_vector_detail::clear_on_destroy cod(*this); - this->insert(this->cend(), x.begin(), x.end()); - STABLE_VECTOR_CHECK_INVARIANT; - cod.release(); - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs a stable_vector that will use a copy of allocator a - //! and inserts a copy of the range [il.begin(), il.last()) in the stable_vector - //! - //! Throws: If allocator_type's default constructor - //! throws or T's constructor taking a dereferenced initializer_list iterator throws. - //! - //! Complexity: Linear to the range [il.begin(), il.end()). - stable_vector(std::initializer_list il, const allocator_type& l = allocator_type()) - : internal_data(l), index(l) - { - stable_vector_detail::clear_on_destroy cod(*this); - insert(cend(), il.begin(), il.end()) - STABLE_VECTOR_CHECK_INVARIANT; - cod.release(); - } -#endif - - //! Effects: Move constructor. Moves mx's resources to *this. - //! - //! Throws: If allocator_type's copy constructor throws. - //! - //! Complexity: Constant. - stable_vector(BOOST_RV_REF(stable_vector) x) - : internal_data(boost::move(x.priv_node_alloc())), index(boost::move(x.index)) - { - this->priv_swap_members(x); - } - - //! Effects: Copy constructs a stable_vector using the specified allocator. - //! - //! Postcondition: x == *this. - //! - //! Complexity: Linear to the elements x contains. - stable_vector(const stable_vector& x, const allocator_type &a) - : internal_data(a), index(a) - { - stable_vector_detail::clear_on_destroy cod(*this); - this->insert(this->cend(), x.begin(), x.end()); - STABLE_VECTOR_CHECK_INVARIANT; - cod.release(); - } - - //! Effects: Move constructor using the specified allocator. - //! Moves mx's resources to *this. - //! - //! Throws: If allocator_type's copy constructor throws. - //! - //! Complexity: Constant if a == x.get_allocator(), linear otherwise - stable_vector(BOOST_RV_REF(stable_vector) x, const allocator_type &a) - : internal_data(a), index(a) - { - if(this->priv_node_alloc() == x.priv_node_alloc()){ - this->priv_swap_members(x); - } - else{ - stable_vector_detail::clear_on_destroy cod(*this); - this->insert(this->cend(), x.begin(), x.end()); - STABLE_VECTOR_CHECK_INVARIANT; - cod.release(); - } - } - - //! Effects: Destroys the stable_vector. All stored values are destroyed - //! and used memory is deallocated. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements. - ~stable_vector() - { - this->clear(); - this->priv_clear_pool(); - } - - //! Effects: Makes *this contain the same elements as x. - //! - //! Postcondition: this->size() == x.size(). *this contains a copy - //! of each of x's elements. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to the number of elements in x. - stable_vector& operator=(BOOST_COPY_ASSIGN_REF(stable_vector) x) - { - STABLE_VECTOR_CHECK_INVARIANT; - if (&x != this){ - node_allocator_type &this_alloc = this->priv_node_alloc(); - const node_allocator_type &x_alloc = x.priv_node_alloc(); - container_detail::bool_ flag; - if(flag && this_alloc != x_alloc){ - this->clear(); - this->shrink_to_fit(); - } - 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; - } - - //! Effects: Move assignment. All mx's values are transferred to *this. - //! - //! Postcondition: x.empty(). *this contains a the elements x had - //! before the function. - //! - //! Throws: If allocator_traits_type::propagate_on_container_move_assignment - //! is false and (allocation throws or T's move constructor throws) - //! - //! Complexity: Constant if allocator_traits_type:: - //! propagate_on_container_move_assignment is true or - //! this->get>allocator() == x.get_allocator(). Linear otherwise. - stable_vector& operator=(BOOST_RV_REF(stable_vector) x) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) - { - //for move constructor, no aliasing (&x != this) is assummed. - BOOST_ASSERT(this != &x); - node_allocator_type &this_alloc = this->priv_node_alloc(); - node_allocator_type &x_alloc = x.priv_node_alloc(); - const bool propagate_alloc = allocator_traits_type:: - propagate_on_container_move_assignment::value; - container_detail::bool_ flag; - const bool allocators_equal = this_alloc == x_alloc; (void)allocators_equal; - //Resources can be transferred if both allocators are - //going to be equal after this function (either propagated or already equal) - if(propagate_alloc || allocators_equal){ - //Destroy objects but retain memory in case x reuses it in the future - this->clear(); - //Move allocator if needed - container_detail::move_alloc(this_alloc, x_alloc, flag); - //Take resources - this->index = boost::move(x.index); - this->priv_swap_members(x); - } - //Else do a one by one move - else{ - this->assign( boost::make_move_iterator(x.begin()) - , boost::make_move_iterator(x.end())); - } - return *this; - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Make *this container contains elements from il. - //! - //! Complexity: Linear to the range [il.begin(), il.end()). - stable_vector& operator=(std::initializer_list il) - { - STABLE_VECTOR_CHECK_INVARIANT; - assign(il.begin(), il.end()); - return *this; - } -#endif - - //! Effects: Assigns the n copies of val to *this. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to n. - void assign(size_type n, const T& t) - { - typedef constant_iterator cvalue_iterator; - this->assign(cvalue_iterator(t, n), cvalue_iterator()); - } - - //! Effects: Assigns the the range [first, last) to *this. - //! - //! Throws: If memory allocation throws or - //! T's constructor from dereferencing InpIt throws. - //! - //! Complexity: Linear to n. - template - void assign(InputIterator first,InputIterator last - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - >::type * = 0 - #endif - ) - { - 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); - } - } - -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Assigns the the range [il.begin(), il.end()) to *this. - //! - //! Throws: If memory allocation throws or - //! T's constructor from dereferencing initializer_list iterator throws. - //! - void assign(std::initializer_list il) - { - STABLE_VECTOR_CHECK_INVARIANT; - assign(il.begin(), il.end()); - } -#endif - - //! Effects: Returns a copy of the internal allocator. - //! - //! Throws: If allocator's copy constructor throws. - //! - //! Complexity: Constant. - allocator_type get_allocator() const - { return this->priv_node_alloc(); } - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT - { return this->priv_node_alloc(); } - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT - { return this->priv_node_alloc(); } - - ////////////////////////////////////////////// - // - // iterators - // - ////////////////////////////////////////////// - - //! Effects: Returns an iterator to the first element contained in the stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator begin() BOOST_CONTAINER_NOEXCEPT - { return (this->index.empty()) ? this->end(): iterator(node_ptr_traits::static_cast_from(this->index.front())); } - - //! Effects: Returns a const_iterator to the first element contained in the stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator begin() const BOOST_CONTAINER_NOEXCEPT - { return (this->index.empty()) ? this->cend() : const_iterator(node_ptr_traits::static_cast_from(this->index.front())) ; } - - //! Effects: Returns an iterator to the end of the stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator end() BOOST_CONTAINER_NOEXCEPT - { return iterator(this->priv_get_end_node()); } - - //! Effects: Returns a const_iterator to the end of the stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator end() const BOOST_CONTAINER_NOEXCEPT - { return const_iterator(this->priv_get_end_node()); } - - //! Effects: Returns a reverse_iterator pointing to the beginning - //! of the reversed stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT - { return reverse_iterator(this->end()); } - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT - { return const_reverse_iterator(this->end()); } - - //! Effects: Returns a reverse_iterator pointing to the end - //! of the reversed stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT - { return reverse_iterator(this->begin()); } - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT - { return const_reverse_iterator(this->begin()); } - - //! Effects: Returns a const_iterator to the first element contained in the stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT - { return this->begin(); } - - //! Effects: Returns a const_iterator to the end of the stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT - { return this->end(); } - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT - { return this->rbegin(); } - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crend()const BOOST_CONTAINER_NOEXCEPT - { return this->rend(); } - - ////////////////////////////////////////////// - // - // capacity - // - ////////////////////////////////////////////// - - //! Effects: Returns true if the stable_vector contains no elements. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - bool empty() const BOOST_CONTAINER_NOEXCEPT - { return this->index.size() <= ExtraPointers; } - - //! Effects: Returns the number of the elements contained in the stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type size() const BOOST_CONTAINER_NOEXCEPT - { - const size_type index_size = this->index.size(); - return (index_size - ExtraPointers) & (std::size_t(0u) -std::size_t(index_size != 0)); - } - - //! Effects: Returns the largest possible size of the stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type max_size() const BOOST_CONTAINER_NOEXCEPT - { return this->index.max_size() - ExtraPointers; } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are value initialized. - //! - //! Throws: If memory allocation throws, or T's value initialization throws. - //! - //! Complexity: Linear to the difference between size() and new_size. - void resize(size_type n) - { - typedef value_init_construct_iterator value_init_iterator; - STABLE_VECTOR_CHECK_INVARIANT; - if(n > this->size()) - this->insert(this->cend(), value_init_iterator(n - this->size()), value_init_iterator()); - else if(n < this->size()) - this->erase(this->cbegin() + n, this->cend()); - } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are default initialized. - //! - //! Throws: If memory allocation throws, or T's default initialization throws. - //! - //! Complexity: Linear to the difference between size() and new_size. - //! - //! Note: Non-standard extension - void resize(size_type n, default_init_t) - { - typedef default_init_construct_iterator default_init_iterator; - STABLE_VECTOR_CHECK_INVARIANT; - if(n > this->size()) - this->insert(this->cend(), default_init_iterator(n - this->size()), default_init_iterator()); - else if(n < this->size()) - this->erase(this->cbegin() + n, this->cend()); - } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are copy constructed from x. - //! - //! Throws: If memory allocation throws, or T's copy constructor throws. - //! - //! Complexity: Linear to the difference between size() and new_size. - void resize(size_type n, const T& t) - { - STABLE_VECTOR_CHECK_INVARIANT; - if(n > this->size()) - this->insert(this->cend(), n - this->size(), t); - else if(n < this->size()) - this->erase(this->cbegin() + n, this->cend()); - } - - //! Effects: Number of elements for which memory has been allocated. - //! capacity() is always greater than or equal to size(). - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type capacity() const BOOST_CONTAINER_NOEXCEPT - { - 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; - const size_type index_offset = - (ExtraPointers + extra_capacity) & (size_type(0u) - size_type(index_size != 0)); - return index_size - index_offset; - } - - //! Effects: 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 - //! n; otherwise, capacity() is unchanged. In either case, size() is unchanged. - //! - //! Throws: If memory allocation allocation throws. - void reserve(size_type n) - { - STABLE_VECTOR_CHECK_INVARIANT; - if(n > this->max_size()){ - throw_length_error("stable_vector::reserve max_size() exceeded"); - } - - size_type sz = this->size(); - size_type old_capacity = this->capacity(); - if(n > old_capacity){ - 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){ - index_traits_type::fix_up_pointers_from(this->index, this->index.begin()); - } - //Now fill pool if data is not enough - if((n - sz) > this->internal_data.pool_size){ - this->priv_increase_pool((n - sz) - this->internal_data.pool_size); - } - } - } - - //! Effects: Tries to deallocate the excess of memory created - //! with previous allocations. The size of the stable_vector is unchanged - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: 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 - // - ////////////////////////////////////////////// - - //! Requires: !empty() - //! - //! Effects: Returns a reference to the first - //! element of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference front() BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this->index.front()).value; } - - //! Requires: !empty() - //! - //! Effects: Returns a const reference to the first - //! element of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference front() const BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this->index.front()).value; } - - //! Requires: !empty() - //! - //! Effects: Returns a reference to the last - //! element of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference back() BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this->index[this->size()-1u]).value; } - - //! Requires: !empty() - //! - //! Effects: Returns a const reference to the last - //! element of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference back() const BOOST_CONTAINER_NOEXCEPT - { return static_cast(*this->index[this->size()-1u]).value; } - - //! Requires: size() > n. - //! - //! Effects: Returns a reference to the nth element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT - { - BOOST_ASSERT(n < this->size()); - return static_cast(*this->index[n]).value; - } - - //! Requires: size() > n. - //! - //! Effects: Returns a const reference to the nth element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT - { - BOOST_ASSERT(n < this->size()); - return static_cast(*this->index[n]).value; - } - - //! Requires: size() > n. - //! - //! Effects: Returns a reference to the nth element - //! from the beginning of the container. - //! - //! Throws: std::range_error if n >= size() - //! - //! Complexity: Constant. - reference at(size_type n) - { - if(n >= this->size()){ - throw_out_of_range("vector::at invalid subscript"); - } - return operator[](n); - } - - //! Requires: size() > n. - //! - //! Effects: Returns a const reference to the nth element - //! from the beginning of the container. - //! - //! Throws: std::range_error if n >= size() - //! - //! Complexity: Constant. - const_reference at(size_type n)const - { - if(n >= this->size()){ - throw_out_of_range("vector::at invalid subscript"); - } - return operator[](n); - } - - ////////////////////////////////////////////// - // - // modifiers - // - ////////////////////////////////////////////// - - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... in the end of the stable_vector. - //! - //! Throws: If memory allocation throws or the in-place constructor throws. - //! - //! Complexity: Amortized constant time. - template - void emplace_back(Args &&...args) - { - typedef emplace_functor EmplaceFunctor; - typedef emplace_iterator EmplaceIterator; - EmplaceFunctor &&ef = EmplaceFunctor(boost::forward(args)...); - this->insert(this->cend(), EmplaceIterator(ef), EmplaceIterator()); - } - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... before p - //! - //! Throws: If memory allocation throws or the in-place constructor throws. - //! - //! Complexity: If p is end(), amortized constant time - //! Linear time otherwise. - template - iterator emplace(const_iterator p, Args && ...args) - { - size_type pos_n = p - cbegin(); - typedef emplace_functor EmplaceFunctor; - typedef emplace_iterator EmplaceIterator; - EmplaceFunctor &&ef = EmplaceFunctor(boost::forward(args)...); - this->insert(p, EmplaceIterator(ef), EmplaceIterator()); - return iterator(this->begin() + pos_n); - } - - #else - - #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, _)) \ - { \ - typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \ - BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >) \ - EmplaceFunctor; \ - typedef emplace_iterator EmplaceIterator; \ - EmplaceFunctor ef BOOST_PP_LPAREN_IF(n) \ - BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) \ - BOOST_PP_RPAREN_IF(n); \ - this->insert(this->cend() , EmplaceIterator(ef), EmplaceIterator()); \ - } \ - \ - 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, _)) \ - { \ - typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \ - BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >) \ - EmplaceFunctor; \ - typedef emplace_iterator EmplaceIterator; \ - EmplaceFunctor ef BOOST_PP_LPAREN_IF(n) \ - BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) \ - BOOST_PP_RPAREN_IF(n); \ - size_type pos_n = p - this->cbegin(); \ - this->insert(p, EmplaceIterator(ef), EmplaceIterator()); \ - return iterator(this->begin() + pos_n); \ - } \ - //! - #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) - //! Effects: Inserts a copy of x at the end of the stable_vector. - //! - //! Throws: If memory allocation throws or - //! T's copy constructor throws. - //! - //! Complexity: Amortized constant time. - void push_back(const T &x); - - //! Effects: Constructs a new element in the end of the stable_vector - //! and moves the resources of mx to this new element. - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: 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) - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a copy of x before p. - //! - //! Returns: An iterator to the inserted element. - //! - //! Throws: If memory allocation throws or x's copy constructor throws. - //! - //! Complexity: If p is end(), amortized constant time - //! Linear time otherwise. - iterator insert(const_iterator p, const T &x); - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a new element before p with mx's resources. - //! - //! Returns: an iterator to the inserted element. - //! - //! Throws: If memory allocation throws. - //! - //! Complexity: If p is end(), amortized constant time - //! Linear time otherwise. - iterator insert(const_iterator p, T &&x); - #else - BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator, const_iterator) - #endif - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert n copies of x before p. - //! - //! Returns: an iterator to the first inserted element or p if n is 0. - //! - //! Throws: If memory allocation throws or T's copy constructor throws. - //! - //! Complexity: Linear to n. - iterator insert(const_iterator p, size_type n, const T& t) - { - STABLE_VECTOR_CHECK_INVARIANT; - typedef constant_iterator cvalue_iterator; - return this->insert(p, cvalue_iterator(t, n), cvalue_iterator()); - } - - //! Requires: p must be a valid iterator of *this. -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Insert a copy of the [il.begin(), il.end()) range before p. - //! - //! Returns: an iterator to the first inserted element or p if first == last. - //! - //! Complexity: Linear to std::distance [il.begin(), il.end()). - iterator insert(const_iterator p, std::initializer_list il) - { - STABLE_VECTOR_CHECK_INVARIANT; - return insert(p, il.begin(), il.end()); - } -#endif - - //! Requires: pos must be a valid iterator of *this. - //! - //! Effects: Insert a copy of the [first, last) range before p. - //! - //! Returns: an iterator to the first inserted element or p if first == last. - //! - //! Throws: If memory allocation throws, T's constructor from a - //! dereferenced InpIt throws or T's copy constructor throws. - //! - //! Complexity: Linear to std::distance [first, last). - template - iterator insert(const_iterator p, InputIterator first, InputIterator last - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - && container_detail::is_input_iterator::value - >::type * = 0 - #endif - ) - { - STABLE_VECTOR_CHECK_INVARIANT; - const size_type pos_n = p - this->cbegin(); - for(; first != last; ++first){ - this->emplace(p, *first); - } - return this->begin() + pos_n; - } - - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - template - iterator insert(const_iterator p, FwdIt first, FwdIt last - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - && !container_detail::is_input_iterator::value - >::type * = 0 - ) - { - const size_type num_new = static_cast(std::distance(first, last)); - const size_type idx = static_cast(p - this->cbegin()); - if(num_new){ - //Fills the node pool and inserts num_new null pointers in idx. - //If a new buffer was needed fixes up pointers up to idx 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(idx, 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 p in priv_insert_forward_non_templated(...) - index_traits_type::fix_up_pointers_from(this->index, it_past_newly_constructed); - } - return this->begin() + idx; - } - #endif - - //! Effects: Removes the last element from the stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant time. - void pop_back() BOOST_CONTAINER_NOEXCEPT - { this->erase(--this->cend()); } - - //! Effects: Erases the element at p. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the elements between p and the - //! last element. Constant if p is the last element. - iterator erase(const_iterator p) BOOST_CONTAINER_NOEXCEPT - { - STABLE_VECTOR_CHECK_INVARIANT; - const size_type d = p - this->cbegin(); - index_iterator it = this->index.begin() + d; - this->priv_delete_node(p.node_pointer()); - it = this->index.erase(it); - index_traits_type::fix_up_pointers_from(this->index, it); - return iterator(node_ptr_traits::static_cast_from(*it)); - } - - //! Effects: Erases the elements pointed by [first, last). - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the distance between first and last - //! plus linear to the elements between p and the last element. - iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT - { - STABLE_VECTOR_CHECK_INVARIANT; - const const_iterator cbeg(this->cbegin()); - const size_type d1 = static_cast(first - cbeg), - d2 = static_cast(last - cbeg); - size_type d_dif = d2 - d1; - if(d_dif){ - multiallocation_chain holder; - const index_iterator it1(this->index.begin() + d1); - const index_iterator it2(it1 + d_dif); - index_iterator it(it1); - while(d_dif--){ - node_base_ptr &nb = *it; - ++it; - node_type &n = *node_ptr_traits::static_cast_from(nb); - this->priv_destroy_node(n); - holder.push_back(node_ptr_traits::pointer_to(n)); - } - this->priv_put_in_pool(holder); - const index_iterator e = this->index.erase(it1, it2); - index_traits_type::fix_up_pointers_from(this->index, e); - } - return iterator(last.node_pointer()); - } - - //! Effects: Swaps the contents of *this and x. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - void swap(stable_vector & x) - { - STABLE_VECTOR_CHECK_INVARIANT; - container_detail::bool_ flag; - container_detail::swap_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag); - //vector's allocator is swapped here - this->index.swap(x.index); - this->priv_swap_members(x); - } - - //! Effects: Erases all the elements of the stable_vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements in the stable_vector. - void clear() BOOST_CONTAINER_NOEXCEPT - { this->erase(this->cbegin(),this->cend()); } - - //! Effects: Returns true if x and y are equal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator==(const stable_vector& x, const stable_vector& y) - { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); } - - //! Effects: Returns true if x and y are unequal - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator!=(const stable_vector& x, const stable_vector& y) - { return !(x == y); } - - //! Effects: Returns true if x is less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<(const stable_vector& x, const stable_vector& y) - { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } - - //! Effects: Returns true if x is greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>(const stable_vector& x, const stable_vector& y) - { return y < x; } - - //! Effects: Returns true if x is equal or less than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator<=(const stable_vector& x, const stable_vector& y) - { return !(y < x); } - - //! Effects: Returns true if x is equal or greater than y - //! - //! Complexity: Linear to the number of elements in the container. - friend bool operator>=(const stable_vector& x, const stable_vector& y) - { return !(x < y); } - - //! Effects: x.swap(y) - //! - //! Complexity: Constant. - friend void swap(stable_vector& x, stable_vector& y) - { x.swap(y); } - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - - class insert_rollback - { - public: - - 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) - {} - - ~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); - } - } - - private: - stable_vector &m_sv; - index_iterator &m_it_past_constructed; - const index_iterator &m_it_past_new; - }; - - class push_back_rollback - { - public: - push_back_rollback(stable_vector &sv, const node_ptr &p) - : m_sv(sv), m_p(p) - {} - - ~push_back_rollback() - { - if(m_p){ - m_sv.priv_put_in_pool(m_p); - } - } - - void release() - { m_p = node_ptr(); } - - private: - stable_vector &m_sv; - node_ptr m_p; - }; - - index_iterator priv_insert_forward_non_templated(size_type idx, size_type num_new) - { - 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); - } - - //Now try to make room in the vector - const node_base_ptr_ptr old_buffer = this->index.data(); - this->index.insert(this->index.begin() + idx, 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 + idx); - } - return index_beg + idx; - } - - bool priv_capacity_bigger_than_size() const - { - return this->index.capacity() > this->index.size() && - this->internal_data.pool_size > 0; - } - - template - void priv_push_back(BOOST_MOVE_CATCH_FWD(U) x) - { - 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(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(this->cend(), ::boost::forward(x)); - } - } - - iterator priv_insert(const_iterator p, const value_type &t) - { - typedef constant_iterator cvalue_iterator; - return this->insert(p, cvalue_iterator(t, 1), cvalue_iterator()); - } - - iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x) - { - typedef repeat_iterator repeat_it; - typedef boost::move_iterator repeat_move_it; - //Just call more general insert(p, size, value) and return iterator - return this->insert(p, repeat_move_it(repeat_it(x, 1)), repeat_move_it(repeat_it())); - } - - void priv_clear_pool() - { - 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(); - - 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; - } - } - - void priv_increase_pool(size_type n) - { - 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, m); - holder.splice_after(holder.before_begin(), m, m.before_begin(), m.last(), n); - this->internal_data.pool_size += n; - std::pair data(holder.extract_data()); - pool_first_ref = data.first; - pool_last_ref = data.second; - } - - void priv_put_in_pool(const node_ptr &p) - { - 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 ret(holder.extract_data()); - pool_first_ref = ret.first; - pool_last_ref = ret.second; - } - - void priv_put_in_pool(multiallocation_chain &ch) - { - node_base_ptr &pool_first_ref = *(this->index.end()-(ExtraPointers-1)); - node_base_ptr &pool_last_ref = this->index.back(); - ch.incorporate_after( ch.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->internal_data.pool_size = ch.size(); - const std::pair ret(ch.extract_data()); - pool_first_ref = ret.first; - pool_last_ref = ret.second; - } - - node_ptr priv_get_from_pool() - { - //Precondition: index is not empty - BOOST_ASSERT(!this->index.empty()); - node_base_ptr &pool_first_ref = *(this->index.end() - (ExtraPointers-1)); - 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{ - const std::pair data(holder.extract_data()); - pool_first_ref = data.first; - pool_last_ref = data.second; - } - return ret; - } - - node_base_ptr priv_get_end_node() const - { return node_base_ptr_traits::pointer_to(const_cast(this->internal_data.end_node)); } - - void priv_destroy_node(const node_type &n) - { - allocator_traits:: - destroy(this->priv_node_alloc(), container_detail::addressof(n.value)); - static_cast(&n)->~node_base_type(); - } - - void priv_delete_node(const node_ptr &n) - { - this->priv_destroy_node(*n); - this->priv_put_in_pool(n); - } - - template - 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(container_detail::to_raw_pointer(p)), boost_container_new_t()) - node_base_type(index_traits_type::ptr_to_node_base_ptr(*up_index)); - } - - template - void priv_build_node_from_convertible(const node_ptr &p, BOOST_FWD_REF(ValueConvertible) value_convertible) - { - //This can throw - boost::container::allocator_traits::construct - ( this->priv_node_alloc() - , container_detail::addressof(p->value) - , ::boost::forward(value_convertible)); - //This does not throw - ::new(static_cast(container_detail::to_raw_pointer(p)), boost_container_new_t()) node_base_type; - } - - void priv_swap_members(stable_vector &x) - { - boost::container::swap_dispatch(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); - } - - #if defined(STABLE_VECTOR_ENABLE_INVARIANT_CHECKING) - bool priv_invariant()const - { - index_type & index_ref = const_cast(this->index); - - if(index.empty()) - return !this->capacity() && !this->size(); - if(this->priv_get_end_node() != *(index.end() - ExtraPointers)){ - return false; - } - - if(!index_traits_type::invariants(index_ref)){ - return false; - } - - size_type n = this->capacity() - this->size(); - node_base_ptr &pool_first_ref = *(index_ref.end() - (ExtraPointers-1)); - 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; - while(beg != end){ - ++num_pool; - ++beg; - } - return n >= num_pool && num_pool == internal_data.pool_size; - } - - class invariant_checker - { - invariant_checker(const invariant_checker &); - invariant_checker & operator=(const invariant_checker &); - const stable_vector* p; - - public: - invariant_checker(const stable_vector& v):p(&v){} - ~invariant_checker(){BOOST_ASSERT(p->priv_invariant());} - void touch(){} - }; - #endif - - class ebo_holder - : public node_allocator_type - { - private: - BOOST_MOVABLE_BUT_NOT_COPYABLE(ebo_holder) - - public: - template - explicit ebo_holder(BOOST_FWD_REF(AllocatorRLValue) a) - : node_allocator_type(boost::forward(a)) - , pool_size(0) - , end_node() - {} - - ebo_holder() - : node_allocator_type() - , pool_size(0) - , end_node() - {} - - size_type pool_size; - node_base_type end_node; - } internal_data; - - node_allocator_type &priv_node_alloc() { return internal_data; } - const node_allocator_type &priv_node_alloc() const { return internal_data; } - - index_type index; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -}; - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -#undef STABLE_VECTOR_CHECK_INVARIANT - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -/* - -//!has_trivial_destructor_after_move<> == true_type -//!specialization for optimizations -template -struct has_trivial_destructor_after_move > - : public has_trivial_destructor_after_move::value -{}; - -*/ - -}} - -#include - -#endif //BOOST_CONTAINER_STABLE_VECTOR_HPP diff --git a/boost/container/static_vector.hpp b/boost/container/static_vector.hpp index 1ae8011..c36832d 100644 --- a/boost/container/static_vector.hpp +++ b/boost/container/static_vector.hpp @@ -11,14 +11,23 @@ #ifndef BOOST_CONTAINER_STATIC_VECTOR_HPP #define BOOST_CONTAINER_STATIC_VECTOR_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include - +#include +#include #include -#include + +#include +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) +#include +#endif namespace boost { namespace container { @@ -32,34 +41,33 @@ class static_storage_allocator public: typedef T value_type; - static_storage_allocator() BOOST_CONTAINER_NOEXCEPT + static_storage_allocator() BOOST_NOEXCEPT_OR_NOTHROW {} - static_storage_allocator(const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT + static_storage_allocator(const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW {} - static_storage_allocator & operator=(const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT + static_storage_allocator & operator=(const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW {} - T* internal_storage() const BOOST_CONTAINER_NOEXCEPT + T* internal_storage() const BOOST_NOEXCEPT_OR_NOTHROW { return const_cast(static_cast(static_cast(&storage))); } - T* internal_storage() BOOST_CONTAINER_NOEXCEPT + T* internal_storage() BOOST_NOEXCEPT_OR_NOTHROW { return static_cast(static_cast(&storage)); } static const std::size_t internal_capacity = N; typedef boost::container::container_detail::version_type version; - friend bool operator==(const static_storage_allocator &, const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT + friend bool operator==(const static_storage_allocator &, const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW { return false; } - friend bool operator!=(const static_storage_allocator &, const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT + friend bool operator!=(const static_storage_allocator &, const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW { return true; } private: - typename boost::aligned_storage - ::value>::type storage; + typename aligned_storage::value>::type storage; }; } //namespace container_detail { @@ -135,7 +143,7 @@ public: //! //! @par Complexity //! Constant O(1). - static_vector() BOOST_CONTAINER_NOEXCEPT + static_vector() BOOST_NOEXCEPT_OR_NOTHROW : base_t() {} @@ -259,13 +267,13 @@ public: //! @param other The static_vector which content will be moved to this one. //! //! @par Throws - //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor throws. - //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor throws. + //! @li If \c has_nothrow_move::value is \c true and Value's move constructor throws. + //! @li If \c has_nothrow_move::value is \c false and Value's copy constructor throws. //! //! @par Complexity //! Linear O(N). static_vector(BOOST_RV_REF(static_vector) other) - : base_t(boost::move(static_cast(other))) + : base_t(BOOST_MOVE_BASE(base_t, other)) {} //! @pre other.size() <= capacity() @@ -275,14 +283,14 @@ public: //! @param other The static_vector which content will be moved to this one. //! //! @par Throws - //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor throws. - //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor throws. + //! @li If \c has_nothrow_move::value is \c true and Value's move constructor throws. + //! @li If \c has_nothrow_move::value is \c false and Value's copy constructor throws. //! //! @par Complexity //! Linear O(N). template static_vector(BOOST_RV_REF_BEG static_vector BOOST_RV_REF_END other) - : base_t(boost::move(static_cast::base_t&>(other))) + : base_t(BOOST_MOVE_BASE(typename static_vector::base_t, other)) {} //! @brief Copy assigns Values stored in the other static_vector to this one. @@ -310,9 +318,7 @@ public: //! @par Complexity //! Linear O(N). static_vector & operator=(std::initializer_list il) - { - return static_cast(base_t::operator=(il)); - } + { return static_cast(base_t::operator=(il)); } #endif //! @pre other.size() <= capacity() @@ -338,14 +344,14 @@ public: //! @param other The static_vector which content will be moved to this one. //! //! @par Throws - //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws. - //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws. + //! @li If \c has_nothrow_move::value is \c true and Value's move constructor or move assignment throws. + //! @li If \c has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws. //! //! @par Complexity //! Linear O(N). static_vector & operator=(BOOST_RV_REF(static_vector) other) { - return static_cast(base_t::operator=(boost::move(static_cast(other)))); + return static_cast(base_t::operator=(BOOST_MOVE_BASE(base_t, other))); } //! @pre other.size() <= capacity() @@ -355,8 +361,8 @@ public: //! @param other The static_vector which content will be moved to this one. //! //! @par Throws - //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws. - //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws. + //! @li If \c has_nothrow_move::value is \c true and Value's move constructor or move assignment throws. + //! @li If \c has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws. //! //! @par Complexity //! Linear O(N). @@ -364,7 +370,7 @@ public: static_vector & operator=(BOOST_RV_REF_BEG static_vector BOOST_RV_REF_END other) { return static_cast(base_t::operator= - (boost::move(static_cast::base_t&>(other)))); + (BOOST_MOVE_BASE(typename static_vector::base_t, other))); } #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -383,8 +389,8 @@ public: //! @param other The static_vector which content will be swapped with this one's content. //! //! @par Throws - //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws, - //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws, + //! @li If \c has_nothrow_move::value is \c true and Value's move constructor or move assignment throws, + //! @li If \c has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws, //! //! @par Complexity //! Linear O(N). @@ -397,8 +403,8 @@ public: //! @param other The static_vector which content will be swapped with this one's content. //! //! @par Throws - //! @li If \c boost::has_nothrow_move::value is \c true and Value's move constructor or move assignment throws, - //! @li If \c boost::has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws, + //! @li If \c has_nothrow_move::value is \c true and Value's move constructor or move assignment throws, + //! @li If \c has_nothrow_move::value is \c false and Value's copy constructor or copy assignment throws, //! //! @par Complexity //! Linear O(N). @@ -462,7 +468,7 @@ public: //! //! @par Complexity //! Linear O(N). - void reserve(size_type count) BOOST_CONTAINER_NOEXCEPT; + void reserve(size_type count) BOOST_NOEXCEPT_OR_NOTHROW; //! @pre size() < capacity() //! @@ -703,7 +709,7 @@ public: //! //! @par Complexity //! Constant O(1). - void clear() BOOST_CONTAINER_NOEXCEPT; + void clear() BOOST_NOEXCEPT_OR_NOTHROW; //! @pre i < size() //! @@ -769,6 +775,66 @@ public: //! Constant O(1). const_reference operator[](size_type i) const; + //! @pre i =< size() + //! + //! @brief Returns a iterator to the i-th element. + //! + //! @param i The element's index. + //! + //! @return a iterator to the i-th element. + //! + //! @par Throws + //! Nothing by default. + //! + //! @par Complexity + //! Constant O(1). + iterator nth(size_type i); + + //! @pre i =< size() + //! + //! @brief Returns a const_iterator to the i-th element. + //! + //! @param i The element's index. + //! + //! @return a const_iterator to the i-th element. + //! + //! @par Throws + //! Nothing by default. + //! + //! @par Complexity + //! Constant O(1). + const_iterator nth(size_type i) const; + + //! @pre begin() <= p <= end() + //! + //! @brief Returns the index of the element pointed by p. + //! + //! @param i The element's index. + //! + //! @return The index of the element pointed by p. + //! + //! @par Throws + //! Nothing by default. + //! + //! @par Complexity + //! Constant O(1). + size_type index_of(iterator p); + + //! @pre begin() <= p <= end() + //! + //! @brief Returns the index of the element pointed by p. + //! + //! @param i The index of the element pointed by p. + //! + //! @return a const_iterator to the i-th element. + //! + //! @par Throws + //! Nothing by default. + //! + //! @par Complexity + //! Constant O(1). + size_type index_of(const_iterator p) const; + //! @pre \c !empty() //! //! @brief Returns reference to the first element. @@ -833,7 +899,7 @@ public: //! //! @par Complexity //! Constant O(1). - Value * data() BOOST_CONTAINER_NOEXCEPT; + Value * data() BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Const pointer such that [data(), data() + size()) is a valid range. //! For a non-empty vector data() == &front(). @@ -843,7 +909,7 @@ public: //! //! @par Complexity //! Constant O(1). - const Value * data() const BOOST_CONTAINER_NOEXCEPT; + const Value * data() const BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns iterator to the first element. //! @@ -854,7 +920,7 @@ public: //! //! @par Complexity //! Constant O(1). - iterator begin() BOOST_CONTAINER_NOEXCEPT; + iterator begin() BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns const iterator to the first element. //! @@ -865,7 +931,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_iterator begin() const BOOST_CONTAINER_NOEXCEPT; + const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns const iterator to the first element. //! @@ -876,7 +942,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT; + const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns iterator to the one after the last element. //! @@ -887,7 +953,7 @@ public: //! //! @par Complexity //! Constant O(1). - iterator end() BOOST_CONTAINER_NOEXCEPT; + iterator end() BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns const iterator to the one after the last element. //! @@ -898,7 +964,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_iterator end() const BOOST_CONTAINER_NOEXCEPT; + const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns const iterator to the one after the last element. //! @@ -909,7 +975,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT; + const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns reverse iterator to the first element of the reversed container. //! @@ -921,7 +987,7 @@ public: //! //! @par Complexity //! Constant O(1). - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT; + reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns const reverse iterator to the first element of the reversed container. //! @@ -933,7 +999,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns const reverse iterator to the first element of the reversed container. //! @@ -945,7 +1011,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns reverse iterator to the one after the last element of the reversed container. //! @@ -957,7 +1023,7 @@ public: //! //! @par Complexity //! Constant O(1). - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT; + reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns const reverse iterator to the one after the last element of the reversed container. //! @@ -969,7 +1035,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns const reverse iterator to the one after the last element of the reversed container. //! @@ -981,7 +1047,7 @@ public: //! //! @par Complexity //! Constant O(1). - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT; + const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns container's capacity. //! @@ -992,7 +1058,7 @@ public: //! //! @par Complexity //! Constant O(1). - static size_type capacity() BOOST_CONTAINER_NOEXCEPT; + static size_type capacity() BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns container's capacity. //! @@ -1003,7 +1069,7 @@ public: //! //! @par Complexity //! Constant O(1). - static size_type max_size() BOOST_CONTAINER_NOEXCEPT; + static size_type max_size() BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Returns the number of stored elements. //! @@ -1014,7 +1080,7 @@ public: //! //! @par Complexity //! Constant O(1). - size_type size() const BOOST_CONTAINER_NOEXCEPT; + size_type size() const BOOST_NOEXCEPT_OR_NOTHROW; //! @brief Queries if the container contains elements. //! @@ -1026,7 +1092,7 @@ public: //! //! @par Complexity //! Constant O(1). - bool empty() const BOOST_CONTAINER_NOEXCEPT; + bool empty() const BOOST_NOEXCEPT_OR_NOTHROW; #else friend void swap(static_vector &x, static_vector &y) diff --git a/boost/container/string.hpp b/boost/container/string.hpp deleted file mode 100644 index 1c3cf3b..0000000 --- a/boost/container/string.hpp +++ /dev/null @@ -1,2918 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the 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_STRING_HPP -#define BOOST_CONTAINER_STRING_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace container { - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -namespace container_detail { -// ------------------------------------------------------------ -// Class basic_string_base. - -// basic_string_base is a helper class that makes it it easier to write -// an exception-safe version of basic_string. The constructor allocates, -// but does not initialize, a block of memory. The destructor -// deallocates, but does not destroy elements within, a block of -// memory. The destructor assumes that the memory either is the internal buffer, -// or else points to a block of memory that was allocated using string_base's -// allocator and whose size is this->m_storage. -template -class basic_string_base -{ - basic_string_base & operator=(const basic_string_base &); - basic_string_base(const basic_string_base &); - - typedef allocator_traits allocator_traits_type; - public: - typedef Allocator 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_traits; - - basic_string_base() - : members_() - { init(); } - - basic_string_base(const allocator_type& a) - : members_(a) - { init(); } - - basic_string_base(BOOST_RV_REF(allocator_type) a) - : members_(boost::move(a)) - { this->init(); } - - basic_string_base(const allocator_type& a, size_type n) - : members_(a) - { - this->init(); - this->allocate_initial_block(n); - } - - ~basic_string_base() - { - if(!this->is_short()){ - this->deallocate_block(); - this->is_short(true); - } - } - - private: - - //This is the structure controlling a long string - struct long_t - { - size_type is_short : 1; - size_type length : (sizeof(size_type)*CHAR_BIT - 1); - size_type storage; - pointer start; - - long_t() - {} - - long_t(const long_t &other) - { - this->is_short = other.is_short; - length = other.length; - storage = other.storage; - start = other.start; - } - - long_t &operator =(const long_t &other) - { - this->is_short = other.is_short; - length = other.length; - storage = other.storage; - start = other.start; - return *this; - } - }; - - //This type is the first part of the structure controlling a short string - //The "data" member stores - struct short_header - { - unsigned char is_short : 1; - unsigned char length : (CHAR_BIT - 1); - }; - - //This type has the same alignment and size as long_t but it's POD - //so, unlike long_t, it can be placed in a union - - typedef typename boost::aligned_storage< sizeof(long_t), - container_detail::alignment_of::value>::type long_raw_t; - - protected: - static const size_type MinInternalBufferChars = 8; - static const size_type AlignmentOfValueType = - alignment_of::value; - static const size_type ShortDataOffset = - container_detail::ct_rounded_size::value; - static const size_type ZeroCostInternalBufferChars = - (sizeof(long_t) - ShortDataOffset)/sizeof(value_type); - static const size_type UnalignedFinalInternalBufferChars = - (ZeroCostInternalBufferChars > MinInternalBufferChars) ? - ZeroCostInternalBufferChars : MinInternalBufferChars; - - struct short_t - { - short_header h; - value_type data[UnalignedFinalInternalBufferChars]; - }; - - union repr_t - { - long_raw_t r; - short_t s; - - const short_t &short_repr() const - { return s; } - - const long_t &long_repr() const - { return *static_cast(static_cast(&r)); } - - short_t &short_repr() - { return s; } - - long_t &long_repr() - { return *static_cast(static_cast(&r)); } - }; - - struct members_holder - : public Allocator - { - members_holder() - : Allocator() - {} - - template - explicit members_holder(BOOST_FWD_REF(AllocatorConvertible) a) - : Allocator(boost::forward(a)) - {} - - repr_t m_repr; - } members_; - - const Allocator &alloc() const - { return members_; } - - Allocator &alloc() - { return members_; } - - static const size_type InternalBufferChars = (sizeof(repr_t) - ShortDataOffset)/sizeof(value_type); - - private: - - static const size_type MinAllocation = InternalBufferChars*2; - - protected: - bool is_short() const - { return static_cast(this->members_.m_repr.s.h.is_short != 0); } - - void is_short(bool yes) - { - const bool was_short = this->is_short(); - if(yes && !was_short){ - allocator_traits_type::destroy - ( this->alloc() - , static_cast(static_cast(&this->members_.m_repr.r)) - ); - this->members_.m_repr.s.h.is_short = true; - } - else if(!yes && was_short){ - allocator_traits_type::construct - ( this->alloc() - , static_cast(static_cast(&this->members_.m_repr.r)) - ); - this->members_.m_repr.s.h.is_short = false; - } - } - - private: - void init() - { - this->members_.m_repr.s.h.is_short = 1; - this->members_.m_repr.s.h.length = 0; - } - - protected: - - typedef container_detail::integral_constant allocator_v1; - typedef container_detail::integral_constant allocator_v2; - typedef container_detail::integral_constant::value> alloc_version; - - std::pair - allocation_command(allocation_type command, - size_type limit_size, - size_type preferred_size, - size_type &received_size, pointer reuse = 0) - { - if(this->is_short() && (command & (expand_fwd | expand_bwd)) ){ - reuse = pointer(); - command &= ~(expand_fwd | expand_bwd); - } - return container_detail::allocator_version_traits::allocation_command - (this->alloc(), command, limit_size, preferred_size, received_size, reuse); - } - - size_type next_capacity(size_type additional_objects) const - { - return next_capacity_calculator - :: - get( allocator_traits_type::max_size(this->alloc()) - , this->priv_storage(), additional_objects ); - } - - void deallocate(pointer p, size_type n) - { - if (p && (n > InternalBufferChars)) - this->alloc().deallocate(p, n); - } - - void construct(pointer p, const value_type &value = value_type()) - { - allocator_traits_type::construct - ( this->alloc() - , container_detail::to_raw_pointer(p) - , value - ); - } - - void destroy(pointer p, size_type n) - { - value_type *raw_p = container_detail::to_raw_pointer(p); - for(; n--; ++raw_p){ - allocator_traits_type::destroy( this->alloc(), raw_p); - } - } - - void destroy(pointer p) - { - allocator_traits_type::destroy - ( this->alloc() - , container_detail::to_raw_pointer(p) - ); - } - - void allocate_initial_block(size_type n) - { - if (n <= this->max_size()) { - if(n > InternalBufferChars){ - size_type new_cap = this->next_capacity(n); - pointer p = this->allocation_command(allocate_new, n, new_cap, new_cap).first; - this->is_short(false); - this->priv_long_addr(p); - this->priv_long_size(0); - this->priv_storage(new_cap); - } - } - else{ - throw_length_error("basic_string::allocate_initial_block max_size() exceeded"); - } - } - - void deallocate_block() - { this->deallocate(this->priv_addr(), this->priv_storage()); } - - size_type max_size() const - { return allocator_traits_type::max_size(this->alloc()) - 1; } - - protected: - size_type priv_capacity() const - { return this->priv_storage() - 1; } - - pointer priv_short_addr() const - { return pointer_traits::pointer_to(const_cast(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() - ? 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; } - - size_type priv_storage() const - { return this->is_short() ? priv_short_storage() : priv_long_storage(); } - - size_type priv_short_storage() const - { return InternalBufferChars; } - - size_type priv_long_storage() const - { return this->members_.m_repr.long_repr().storage; } - - void priv_storage(size_type storage) - { - if(!this->is_short()) - this->priv_long_storage(storage); - } - - void priv_long_storage(size_type storage) - { - this->members_.m_repr.long_repr().storage = storage; - } - - size_type priv_size() const - { 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; } - - size_type priv_long_size() const - { return this->members_.m_repr.long_repr().length; } - - void priv_size(size_type sz) - { - if(this->is_short()) - this->priv_short_size(sz); - else - this->priv_long_size(sz); - } - - void priv_short_size(size_type sz) - { - this->members_.m_repr.s.h.length = (unsigned char)sz; - } - - void priv_long_size(size_type sz) - { - this->members_.m_repr.long_repr().length = sz; - } - - void swap_data(basic_string_base& other) - { - if(this->is_short()){ - if(other.is_short()){ - std::swap(this->members_.m_repr, other.members_.m_repr); - } - else{ - 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()){ - 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{ - boost::container::swap_dispatch(this->members_.m_repr.long_repr(), other.members_.m_repr.long_repr()); - } - } - } -}; - -} //namespace container_detail { - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -//! The basic_string class represents a Sequence of characters. It contains all the -//! usual operations of a Sequence, and, additionally, it contains standard string -//! operations such as search and concatenation. -//! -//! The basic_string class is parameterized by character type, and by that type's -//! Character Traits. -//! -//! This class has performance characteristics very much like vector<>, meaning, -//! for example, that it does not perform reference-count or copy-on-write, and that -//! concatenation of two strings is an O(N) operation. -//! -//! Some of basic_string's member functions use an unusual method of specifying positions -//! and ranges. In addition to the conventional method using iterators, many of -//! basic_string's member functions use a single value pos of type size_type to represent a -//! position (in which case the position is begin() + pos, and many of basic_string's -//! member functions use two values, pos and n, to represent a range. In that case pos is -//! the beginning of the range and n is its size. That is, the range is -//! [begin() + pos, begin() + pos + n). -//! -//! Note that the C++ standard does not specify the complexity of basic_string operations. -//! In this implementation, basic_string has performance characteristics very similar to -//! those of vector: access to a single character is O(1), while copy and concatenation -//! are O(N). -//! -//! In this implementation, begin(), -//! end(), rbegin(), rend(), operator[], c_str(), and data() do not invalidate iterators. -//! In this implementation, iterators are only invalidated by member functions that -//! explicitly change the string's contents. -//! -//! \tparam CharT The type of character it contains. -//! \tparam Traits The Character Traits type, which encapsulates basic character operations -//! \tparam Allocator The allocator, used for internal memory management. -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED -template , class Allocator = std::allocator > -#else -template -#endif -class basic_string - : private container_detail::basic_string_base -{ - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - typedef allocator_traits allocator_traits_type; - BOOST_COPYABLE_AND_MOVABLE(basic_string) - typedef container_detail::basic_string_base base_t; - static const typename base_t::size_type InternalBufferChars = base_t::InternalBufferChars; - - protected: - // Allocator helper class to use a char_traits as a function object. - - template - struct Eq_traits - { - //Compatibility with std::binary_function - typedef typename Tr::char_type first_argument_type; - typedef typename Tr::char_type second_argument_type; - typedef bool result_type; - - bool operator()(const first_argument_type& x, const second_argument_type& y) const - { return Tr::eq(x, y); } - }; - - template - struct Not_within_traits - { - typedef typename Tr::char_type argument_type; - typedef bool result_type; - - typedef const typename Tr::char_type* Pointer; - const Pointer m_first; - const Pointer m_last; - - Not_within_traits(Pointer f, Pointer l) - : m_first(f), m_last(l) {} - - bool operator()(const typename Tr::char_type& x) const - { - return std::find_if(m_first, m_last, - std::bind1st(Eq_traits(), x)) == m_last; - } - }; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: - ////////////////////////////////////////////// - // - // types - // - ////////////////////////////////////////////// - typedef Traits traits_type; - typedef CharT value_type; - typedef typename ::boost::container::allocator_traits::pointer pointer; - typedef typename ::boost::container::allocator_traits::const_pointer const_pointer; - typedef typename ::boost::container::allocator_traits::reference reference; - typedef typename ::boost::container::allocator_traits::const_reference const_reference; - typedef typename ::boost::container::allocator_traits::size_type size_type; - typedef typename ::boost::container::allocator_traits::difference_type difference_type; - typedef Allocator allocator_type; - typedef BOOST_CONTAINER_IMPDEF(allocator_type) stored_allocator_type; - typedef BOOST_CONTAINER_IMPDEF(pointer) iterator; - typedef BOOST_CONTAINER_IMPDEF(const_pointer) const_iterator; - typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) reverse_iterator; - typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) const_reverse_iterator; - static const size_type npos = size_type(-1); - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - typedef constant_iterator cvalue_iterator; - 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_traits; - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - public: // Constructor, destructor, assignment. - ////////////////////////////////////////////// - // - // construct/copy/destroy - // - ////////////////////////////////////////////// - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - struct reserve_t {}; - - basic_string(reserve_t, size_type n, - const allocator_type& a = allocator_type()) - //Select allocator as in copy constructor as reserve_t-based constructors - //are two step copies optimized for capacity - : base_t( allocator_traits_type::select_on_container_copy_construction(a) - , n + 1) - { this->priv_terminate_string(); } - - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - - //! Effects: Default constructs a basic_string. - //! - //! Throws: If allocator_type's default constructor throws. - basic_string() - : base_t() - { this->priv_terminate_string(); } - - - //! Effects: Constructs a basic_string taking the allocator as parameter. - //! - //! Throws: Nothing - explicit basic_string(const allocator_type& a) BOOST_CONTAINER_NOEXCEPT - : base_t(a) - { this->priv_terminate_string(); } - - //! Effects: Copy constructs a basic_string. - //! - //! Postcondition: x == *this. - //! - //! Throws: If allocator_type's default constructor or allocation throws. - basic_string(const basic_string& s) - : base_t(allocator_traits_type::select_on_container_copy_construction(s.alloc())) - { - this->priv_terminate_string(); - this->assign(s.begin(), s.end()); - } - - //! Effects: Move constructor. Moves s's resources to *this. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - basic_string(BOOST_RV_REF(basic_string) s) BOOST_CONTAINER_NOEXCEPT - : base_t(boost::move(s.alloc())) - { - if(s.alloc() == this->alloc()){ - this->swap_data(s); - } - else{ - this->assign(s.begin(), s.end()); - } - } - - //! Effects: Copy constructs a basic_string using the specified allocator. - //! - //! Postcondition: x == *this. - //! - //! Throws: If allocation throws. - basic_string(const basic_string& s, const allocator_type &a) - : base_t(a) - { - this->priv_terminate_string(); - this->assign(s.begin(), s.end()); - } - - //! Effects: Move constructor using the specified allocator. - //! Moves s's resources to *this. - //! - //! Throws: If allocation throws. - //! - //! Complexity: Constant if a == s.get_allocator(), linear otherwise. - 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->assign(s.begin(), s.end()); - } - } - - //! Effects: Constructs a basic_string taking the allocator as parameter, - //! and is initialized by a specific number of characters of the s string. - basic_string(const basic_string& s, size_type pos, size_type n = npos, - const allocator_type& a = allocator_type()) - : base_t(a) - { - this->priv_terminate_string(); - if (pos > s.size()) - throw_out_of_range("basic_string::basic_string out of range position"); - else - this->assign - (s.begin() + pos, s.begin() + pos + container_detail::min_value(n, s.size() - pos)); - } - - //! Effects: Constructs a basic_string taking the allocator as parameter, - //! and is initialized by a specific number of characters of the s c-string. - basic_string(const CharT* s, size_type n, const allocator_type& a = allocator_type()) - : base_t(a) - { - this->priv_terminate_string(); - this->assign(s, s + n); - } - - //! Effects: 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_terminate_string(); - this->assign(s, s + Traits::length(s)); - } - - //! Effects: 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_terminate_string(); - this->assign(n, c); - } - - //! Effects: Constructs a basic_string taking the allocator as parameter, - //! and is initialized by n default-initialized characters. - basic_string(size_type n, default_init_t, const allocator_type& a = allocator_type()) - : base_t(a, n + 1) - { - this->priv_size(n); - this->priv_terminate_string(); - } - - //! Effects: Constructs a basic_string taking the allocator as parameter, - //! and a range of iterators. - template - basic_string(InputIterator f, InputIterator l, const allocator_type& a = allocator_type()) - : base_t(a) - { - this->priv_terminate_string(); - this->assign(f, l); - } - - //! Effects: Destroys the basic_string. All used memory is deallocated. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - ~basic_string() BOOST_CONTAINER_NOEXCEPT - {} - - //! Effects: Copy constructs a string. - //! - //! Postcondition: x == *this. - //! - //! Complexity: Linear to the elements x contains. - basic_string& operator=(BOOST_COPY_ASSIGN_REF(basic_string) x) - { - if (&x != this){ - allocator_type &this_alloc = this->alloc(); - const allocator_type &x_alloc = x.alloc(); - container_detail::bool_ flag; - if(flag && this_alloc != x_alloc){ - if(!this->is_short()){ - this->deallocate_block(); - this->is_short(true); - Traits::assign(*this->priv_addr(), CharT(0)); - this->priv_short_size(0); - } - } - container_detail::assign_alloc(this->alloc(), x.alloc(), flag); - this->assign(x.begin(), x.end()); - } - return *this; - } - - //! Effects: Move constructor. Moves x's resources to *this. - //! - //! Throws: If allocator_traits_type::propagate_on_container_move_assignment - //! is false and allocation throws - //! - //! Complexity: Constant if allocator_traits_type:: - //! propagate_on_container_move_assignment is true or - //! this->get>allocator() == x.get_allocator(). Linear otherwise. - basic_string& operator=(BOOST_RV_REF(basic_string) x) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) - { - //for move constructor, no aliasing (&x != this) is assummed. - BOOST_ASSERT(this != &x); - allocator_type &this_alloc = this->alloc(); - allocator_type &x_alloc = x.alloc(); - const bool propagate_alloc = allocator_traits_type:: - propagate_on_container_move_assignment::value; - container_detail::bool_ flag; - const bool allocators_equal = this_alloc == x_alloc; (void)allocators_equal; - //Resources can be transferred if both allocators are - //going to be equal after this function (either propagated or already equal) - if(propagate_alloc || allocators_equal){ - //Destroy objects but retain memory in case x reuses it in the future - this->clear(); - //Move allocator if needed - container_detail::move_alloc(this_alloc, x_alloc, flag); - //Nothrow swap - this->swap_data(x); - } - //Else do a one by one move - else{ - this->assign( x.begin(), x.end()); - } - return *this; - } - - //! Effects: Assignment from a null-terminated c-string. - basic_string& operator=(const CharT* s) - { return this->assign(s, s + Traits::length(s)); } - - //! Effects: Assignment from character. - basic_string& operator=(CharT c) - { return this->assign(static_cast(1), c); } - - //! Effects: Returns a copy of the internal allocator. - //! - //! Throws: If allocator's copy constructor throws. - //! - //! Complexity: Constant. - allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT - { return this->alloc(); } - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT - { return this->alloc(); } - - //! Effects: Returns a reference to the internal allocator. - //! - //! Throws: Nothing - //! - //! Complexity: Constant. - //! - //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT - { return this->alloc(); } - - ////////////////////////////////////////////// - // - // iterators - // - ////////////////////////////////////////////// - - //! Effects: Returns an iterator to the first element contained in the vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator begin() BOOST_CONTAINER_NOEXCEPT - { return this->priv_addr(); } - - //! Effects: Returns a const_iterator to the first element contained in the vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator begin() const BOOST_CONTAINER_NOEXCEPT - { return this->priv_addr(); } - - //! Effects: Returns an iterator to the end of the vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator end() BOOST_CONTAINER_NOEXCEPT - { return this->priv_end_addr(); } - - //! Effects: Returns a const_iterator to the end of the vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator end() const BOOST_CONTAINER_NOEXCEPT - { return this->priv_end_addr(); } - - //! Effects: Returns a reverse_iterator pointing to the beginning - //! of the reversed vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT - { return reverse_iterator(this->priv_end_addr()); } - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT - { return this->crbegin(); } - - //! Effects: Returns a reverse_iterator pointing to the end - //! of the reversed vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT - { return reverse_iterator(this->priv_addr()); } - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT - { return this->crend(); } - - //! Effects: Returns a const_iterator to the first element contained in the vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT - { return this->priv_addr(); } - - //! Effects: Returns a const_iterator to the end of the vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT - { return this->priv_end_addr(); } - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT - { return const_reverse_iterator(this->priv_end_addr()); } - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT - { return const_reverse_iterator(this->priv_addr()); } - - ////////////////////////////////////////////// - // - // capacity - // - ////////////////////////////////////////////// - - //! Effects: Returns true if the vector contains no elements. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - bool empty() const BOOST_CONTAINER_NOEXCEPT - { return !this->priv_size(); } - - //! Effects: Returns the number of the elements contained in the vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type size() const BOOST_CONTAINER_NOEXCEPT - { return this->priv_size(); } - - //! Effects: Returns the number of the elements contained in the vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type length() const BOOST_CONTAINER_NOEXCEPT - { return this->size(); } - - //! Effects: Returns the largest possible size of the vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type max_size() const BOOST_CONTAINER_NOEXCEPT - { return base_t::max_size(); } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are copy constructed from x. - //! - //! Throws: If memory allocation throws - //! - //! Complexity: Linear to the difference between size() and new_size. - void resize(size_type n, CharT c) - { - if (n <= this->size()) - this->erase(this->begin() + n, this->end()); - else - this->append(n - this->size(), c); - } - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are value initialized. - //! - //! Throws: If memory allocation throws - //! - //! Complexity: Linear to the difference between size() and new_size. - void resize(size_type n) - { resize(n, CharT()); } - - - //! Effects: Inserts or erases elements at the end such that - //! the size becomes n. New elements are uninitialized. - //! - //! Throws: If memory allocation throws - //! - //! Complexity: Linear to the difference between size() and new_size. - //! - //! Note: Non-standard extension - void resize(size_type n, default_init_t) - { - if (n <= this->size()) - this->erase(this->begin() + n, this->end()); - else{ - this->priv_reserve(n, false); - this->priv_size(n); - this->priv_terminate_string(); - } - } - - //! Effects: Number of elements for which memory has been allocated. - //! capacity() is always greater than or equal to size(). - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - size_type capacity() const BOOST_CONTAINER_NOEXCEPT - { return this->priv_capacity(); } - - //! Effects: 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 - //! n; otherwise, capacity() is unchanged. In either case, size() is unchanged. - //! - //! Throws: If memory allocation allocation throws - void reserve(size_type res_arg) - { this->priv_reserve(res_arg); } - - //! Effects: Tries to deallocate the excess of memory created - //! with previous allocations. The size of the string is unchanged - //! - //! Throws: Nothing - //! - //! Complexity: Linear to size(). - void shrink_to_fit() - { - //Check if shrinking is possible - if(this->priv_storage() > InternalBufferChars){ - //Check if we should pass from dynamically allocated buffer - //to the internal storage - if(this->priv_size() < InternalBufferChars){ - //Dynamically allocated buffer attributes - pointer long_addr = this->priv_long_addr(); - size_type long_storage = this->priv_long_storage(); - size_type long_size = this->priv_long_size(); - //Shrink from allocated buffer to the internal one, including trailing null - Traits::copy( container_detail::to_raw_pointer(this->priv_short_addr()) - , container_detail::to_raw_pointer(long_addr) - , long_size+1); - this->is_short(true); - this->alloc().deallocate(long_addr, long_storage); - } - else{ - //Shrinking in dynamic buffer - this->priv_shrink_to_fit_dynamic_buffer(alloc_version()); - } - } - } - - ////////////////////////////////////////////// - // - // element access - // - ////////////////////////////////////////////// - - //! Requires: size() > n. - //! - //! Effects: Returns a reference to the nth element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT - { return *(this->priv_addr() + n); } - - //! Requires: size() > n. - //! - //! Effects: Returns a const reference to the nth element - //! from the beginning of the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT - { return *(this->priv_addr() + n); } - - //! Requires: size() > n. - //! - //! Effects: Returns a reference to the nth element - //! from the beginning of the container. - //! - //! Throws: std::range_error if n >= size() - //! - //! Complexity: Constant. - reference at(size_type n) - { - if (n >= this->size()) - throw_out_of_range("basic_string::at invalid subscript"); - return *(this->priv_addr() + n); - } - - //! Requires: size() > n. - //! - //! Effects: Returns a const reference to the nth element - //! from the beginning of the container. - //! - //! Throws: std::range_error if n >= size() - //! - //! Complexity: Constant. - const_reference at(size_type n) const { - if (n >= this->size()) - throw_out_of_range("basic_string::at invalid subscript"); - return *(this->priv_addr() + n); - } - - ////////////////////////////////////////////// - // - // modifiers - // - ////////////////////////////////////////////// - - //! Effects: Calls append(str.data, str.size()). - //! - //! Returns: *this - basic_string& operator+=(const basic_string& s) - { return this->append(s); } - - //! Effects: Calls append(s). - //! - //! Returns: *this - basic_string& operator+=(const CharT* s) - { return this->append(s); } - - //! Effects: Calls append(1, c). - //! - //! Returns: *this - basic_string& operator+=(CharT c) - { this->push_back(c); return *this; } - - //! Effects: Calls append(str.data(), str.size()). - //! - //! Returns: *this - basic_string& append(const basic_string& s) - { return this->append(s.begin(), s.end()); } - - //! Requires: pos <= str.size() - //! - //! Effects: Determines the effective length rlen of the string to append - //! as the smaller of n and str.size() - pos and calls append(str.data() + pos, rlen). - //! - //! Throws: If memory allocation throws and out_of_range if pos > str.size() - //! - //! Returns: *this - basic_string& append(const basic_string& s, size_type pos, size_type n) - { - if (pos > s.size()) - throw_out_of_range("basic_string::append out of range position"); - return this->append(s.begin() + pos, - s.begin() + pos + container_detail::min_value(n, s.size() - pos)); - } - - //! Requires: s points to an array of at least n elements of CharT. - //! - //! Effects: The function replaces the string controlled by *this with - //! a string of length size() + n whose irst size() elements are a copy of the - //! original string controlled by *this and whose remaining - //! elements are a copy of the initial n elements of s. - //! - //! Throws: If memory allocation throws length_error if size() + n > max_size(). - //! - //! Returns: *this - basic_string& append(const CharT* s, size_type n) - { return this->append(s, s + n); } - - //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT. - //! - //! Effects: Calls append(s, traits::length(s)). - //! - //! Returns: *this - basic_string& append(const CharT* s) - { return this->append(s, s + Traits::length(s)); } - - //! Effects: Equivalent to append(basic_string(n, c)). - //! - //! Returns: *this - basic_string& append(size_type n, CharT c) - { return this->append(cvalue_iterator(c, n), cvalue_iterator()); } - - //! Requires: [first,last) is a valid range. - //! - //! Effects: Equivalent to append(basic_string(first, last)). - //! - //! Returns: *this - template - basic_string& append(InputIter first, InputIter last) - { this->insert(this->end(), first, last); return *this; } - - //! Effects: Equivalent to append(static_cast(1), c). - void push_back(CharT c) - { - 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); - } - } - - //! Effects: Equivalent to assign(str, 0, npos). - //! - //! Returns: *this - basic_string& assign(const basic_string& s) - { return this->operator=(s); } - - //! Effects: The function replaces the string controlled by *this - //! with a string of length str.size() whose elements are a copy of the string - //! controlled by str. Leaves str in a valid but unspecified state. - //! - //! Throws: Nothing - //! - //! Returns: *this - basic_string& assign(BOOST_RV_REF(basic_string) ms) BOOST_CONTAINER_NOEXCEPT - { return this->swap_data(ms), *this; } - - //! Requires: pos <= str.size() - //! - //! Effects: Determines the effective length rlen of the string to assign as - //! the smaller of n and str.size() - pos and calls assign(str.data() + pos rlen). - //! - //! Throws: If memory allocation throws or out_of_range if pos > str.size(). - //! - //! Returns: *this - basic_string& assign(const basic_string& s, size_type pos, size_type n) - { - if (pos > s.size()) - throw_out_of_range("basic_string::assign out of range position"); - return this->assign(s.begin() + pos, - s.begin() + pos + container_detail::min_value(n, s.size() - pos)); - } - - //! Requires: s points to an array of at least n elements of CharT. - //! - //! Effects: Replaces the string controlled by *this with a string of - //! length n whose elements are a copy of those pointed to by s. - //! - //! Throws: If memory allocation throws or length_error if n > max_size(). - //! - //! Returns: *this - basic_string& assign(const CharT* s, size_type n) - { return this->assign(s, s + n); } - - //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT. - //! - //! Effects: Calls assign(s, traits::length(s)). - //! - //! Returns: *this - basic_string& assign(const CharT* s) - { return this->assign(s, s + Traits::length(s)); } - - //! Effects: Equivalent to assign(basic_string(n, c)). - //! - //! Returns: *this - basic_string& assign(size_type n, CharT c) - { return this->assign(cvalue_iterator(c, n), cvalue_iterator()); } - - //! Effects: Equivalent to assign(basic_string(first, last)). - //! - //! Returns: *this - basic_string& assign(const CharT* first, const CharT* last) - { - size_type n = static_cast(last - first); - this->reserve(n); - CharT* ptr = container_detail::to_raw_pointer(this->priv_addr()); - Traits::copy(ptr, first, n); - this->priv_construct_null(ptr + n); - this->priv_size(n); - return *this; - } - - //! Effects: Equivalent to assign(basic_string(first, last)). - //! - //! Returns: *this - template - basic_string& assign(InputIter first, InputIter last - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - >::type * = 0 - #endif - ) - { - 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; - } - - //! Requires: pos <= size(). - //! - //! Effects: Calls insert(pos, str.data(), str.size()). - //! - //! Throws: If memory allocation throws or out_of_range if pos > size(). - //! - //! Returns: *this - basic_string& insert(size_type pos, const basic_string& s) - { - const size_type sz = this->size(); - if (pos > sz) - throw_out_of_range("basic_string::insert out of range position"); - if (sz > this->max_size() - s.size()) - throw_length_error("basic_string::insert max_size() exceeded"); - this->insert(this->priv_addr() + pos, s.begin(), s.end()); - return *this; - } - - //! Requires: pos1 <= size() and pos2 <= str.size() - //! - //! Effects: Determines the effective length rlen of the string to insert as - //! the smaller of n and str.size() - pos2 and calls insert(pos1, str.data() + pos2, rlen). - //! - //! Throws: If memory allocation throws or out_of_range if pos1 > size() or pos2 > str.size(). - //! - //! Returns: *this - basic_string& insert(size_type pos1, const basic_string& s, size_type pos2, size_type n) - { - const size_type sz = this->size(); - const size_type str_size = s.size(); - if (pos1 > sz || pos2 > str_size) - throw_out_of_range("basic_string::insert out of range position"); - size_type len = container_detail::min_value(n, str_size - pos2); - if (sz > this->max_size() - len) - throw_length_error("basic_string::insert max_size() exceeded"); - const CharT *beg_ptr = container_detail::to_raw_pointer(s.begin()) + pos2; - const CharT *end_ptr = beg_ptr + len; - this->insert(this->priv_addr() + pos1, beg_ptr, end_ptr); - return *this; - } - - //! Requires: s points to an array of at least n elements of CharT and pos <= size(). - //! - //! Effects: Replaces the string controlled by *this with a string of length size() + n - //! whose first pos elements are a copy of the initial elements of the original string - //! controlled by *this and whose next n elements are a copy of the elements in s and whose - //! remaining elements are a copy of the remaining elements of the original string controlled by *this. - //! - //! Throws: If memory allocation throws, out_of_range if pos > size() or - //! length_error if size() + n > max_size(). - //! - //! Returns: *this - basic_string& insert(size_type pos, const CharT* s, size_type n) - { - if (pos > this->size()) - throw_out_of_range("basic_string::insert out of range position"); - if (this->size() > this->max_size() - n) - throw_length_error("basic_string::insert max_size() exceeded"); - this->insert(this->priv_addr() + pos, s, s + n); - return *this; - } - - //! Requires: pos <= size() and s points to an array of at least traits::length(s) + 1 elements of CharT - //! - //! Effects: Calls insert(pos, s, traits::length(s)). - //! - //! Throws: If memory allocation throws, out_of_range if pos > size() - //! length_error if size() > max_size() - Traits::length(s) - //! - //! Returns: *this - basic_string& insert(size_type pos, const CharT* s) - { - if (pos > this->size()) - throw_out_of_range("basic_string::insert out of range position"); - size_type len = Traits::length(s); - if (this->size() > this->max_size() - len) - throw_length_error("basic_string::insert max_size() exceeded"); - this->insert(this->priv_addr() + pos, s, s + len); - return *this; - } - - //! Effects: Equivalent to insert(pos, basic_string(n, c)). - //! - //! Throws: If memory allocation throws, out_of_range if pos > size() - //! length_error if size() > max_size() - n - //! - //! Returns: *this - basic_string& insert(size_type pos, size_type n, CharT c) - { - if (pos > this->size()) - throw_out_of_range("basic_string::insert out of range position"); - if (this->size() > this->max_size() - n) - throw_length_error("basic_string::insert max_size() exceeded"); - this->insert(const_iterator(this->priv_addr() + pos), n, c); - return *this; - } - - //! Requires: p is a valid iterator on *this. - //! - //! Effects: inserts a copy of c before the character referred to by p. - //! - //! Returns: 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(); - this->insert(p, cvalue_iterator(c, 1), cvalue_iterator()); - return this->priv_addr() + new_offset; - } - - - //! Requires: p is a valid iterator on *this. - //! - //! Effects: Inserts n copies of c before the character referred to by p. - //! - //! Returns: 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()); } - - //! Requires: p is a valid iterator on *this. [first,last) is a valid range. - //! - //! Effects: Equivalent to insert(p - begin(), basic_string(first, last)). - //! - //! Returns: an iterator to the first inserted element or p if first == last. - template - 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::value - && container_detail::is_input_iterator::value - >::type * = 0 - #endif - ) - { - 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 - iterator insert(const_iterator p, ForwardIter first, ForwardIter last - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - && !container_detail::is_input_iterator::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 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(container_detail::to_raw_pointer(p + n)), - container_detail::to_raw_pointer(p), - (elems_after - n) + 1); - this->priv_copy(first, last, const_cast(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(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 - 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 - - //! Requires: pos <= size() - //! - //! Effects: Determines the effective length xlen of the string to be removed as the smaller of n and size() - pos. - //! The function then replaces the string controlled by *this with a string of length size() - xlen - //! whose first pos elements are a copy of the initial elements of the original string controlled by *this, - //! and whose remaining elements are a copy of the elements of the original string controlled by *this - //! beginning at position pos + xlen. - //! - //! Throws: out_of_range if pos > size(). - //! - //! Returns: *this - basic_string& erase(size_type pos = 0, size_type n = npos) - { - if (pos > this->size()) - throw_out_of_range("basic_string::erase out of range position"); - const pointer addr = this->priv_addr(); - erase(addr + pos, addr + pos + container_detail::min_value(n, this->size() - pos)); - return *this; - } - - //! Effects: Removes the character referred to by p. - //! - //! Throws: Nothing - //! - //! Returns: An iterator which points to the element immediately following p prior to the element being - //! erased. If no such element exists, end() is returned. - iterator erase(const_iterator p) BOOST_CONTAINER_NOEXCEPT - { - // The move includes the terminating null. - CharT * const ptr = const_cast(container_detail::to_raw_pointer(p)); - const size_type old_size = this->priv_size(); - Traits::move(ptr, - container_detail::to_raw_pointer(p + 1), - old_size - (p - this->priv_addr())); - this->priv_size(old_size-1); - return iterator(ptr); - } - - //! Requires: first and last are valid iterators on *this, defining a range [first,last). - //! - //! Effects: Removes the characters in the range [first,last). - //! - //! Throws: Nothing - //! - //! Returns: An iterator which points to the element pointed to by last prior to - //! the other elements being erased. If no such element exists, end() is returned. - iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT - { - CharT * f = const_cast(container_detail::to_raw_pointer(first)); - if (first != last) { // The move includes the terminating null. - const size_type num_erased = last - first; - const size_type old_size = this->priv_size(); - Traits::move(f, - container_detail::to_raw_pointer(last), - (old_size + 1)-(last - this->priv_addr())); - const size_type new_length = old_size - num_erased; - this->priv_size(new_length); - } - return iterator(f); - } - - //! Requires: !empty() - //! - //! Throws: Nothing - //! - //! Effects: Equivalent to erase(size() - 1, 1). - void pop_back() BOOST_CONTAINER_NOEXCEPT - { - const size_type old_size = this->priv_size(); - Traits::assign(this->priv_addr()[old_size-1], CharT(0)); - this->priv_size(old_size-1);; - } - - //! Effects: Erases all the elements of the vector. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements in the vector. - void clear() BOOST_CONTAINER_NOEXCEPT - { - if (!this->empty()) { - Traits::assign(*this->priv_addr(), CharT(0)); - this->priv_size(0); - } - } - - //! Requires: pos1 <= size(). - //! - //! Effects: Calls replace(pos1, n1, str.data(), str.size()). - //! - //! Throws: if memory allocation throws or out_of_range if pos1 > size(). - //! - //! Returns: *this - basic_string& replace(size_type pos1, size_type n1, const basic_string& str) - { - if (pos1 > this->size()) - throw_out_of_range("basic_string::replace out of range position"); - const size_type len = container_detail::min_value(n1, this->size() - pos1); - if (this->size() - len >= this->max_size() - str.size()) - throw_length_error("basic_string::replace max_size() exceeded"); - const pointer addr = this->priv_addr(); - return this->replace( const_iterator(addr + pos1) - , const_iterator(addr + pos1 + len) - , str.begin(), str.end()); - } - - //! Requires: pos1 <= size() and pos2 <= str.size(). - //! - //! Effects: Determines the effective length rlen of the string to be - //! inserted as the smaller of n2 and str.size() - pos2 and calls - //! replace(pos1, n1, str.data() + pos2, rlen). - //! - //! Throws: if memory allocation throws, out_of_range if pos1 > size() or pos2 > str.size(). - //! - //! Returns: *this - basic_string& replace(size_type pos1, size_type n1, - const basic_string& str, size_type pos2, size_type n2) - { - if (pos1 > this->size() || pos2 > str.size()) - throw_out_of_range("basic_string::replace out of range position"); - 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) - throw_length_error("basic_string::replace max_size() exceeded"); - 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); - } - - //! Requires: pos1 <= size() and s points to an array of at least n2 elements of CharT. - //! - //! Effects: Determines the effective length xlen of the string to be removed as the - //! smaller of n1 and size() - pos1. If size() - xlen >= max_size() - n2 throws length_error. - //! Otherwise, the function replaces the string controlled by *this with a string of - //! length size() - xlen + n2 whose first pos1 elements are a copy of the initial elements - //! of the original string controlled by *this, whose next n2 elements are a copy of the - //! initial n2 elements of s, and whose remaining elements are a copy of the elements of - //! the original string controlled by *this beginning at position pos + xlen. - //! - //! Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error - //! if the length of the resulting string would exceed max_size() - //! - //! Returns: *this - basic_string& replace(size_type pos1, size_type n1, const CharT* s, size_type n2) - { - if (pos1 > this->size()) - throw_out_of_range("basic_string::replace out of range position"); - const size_type len = container_detail::min_value(n1, this->size() - pos1); - if (n2 > this->max_size() || size() - len >= this->max_size() - n2) - throw_length_error("basic_string::replace max_size() exceeded"); - const pointer addr = this->priv_addr(); - return this->replace(addr + pos1, addr + pos1 + len, s, s + n2); - } - - //! Requires: pos1 <= size() and s points to an array of at least n2 elements of CharT. - //! - //! Effects: Determines the effective length xlen of the string to be removed as the smaller - //! of n1 and size() - pos1. If size() - xlen >= max_size() - n2 throws length_error. Otherwise, - //! the function replaces the string controlled by *this with a string of length size() - xlen + n2 - //! whose first pos1 elements are a copy of the initial elements of the original string controlled - //! by *this, whose next n2 elements are a copy of the initial n2 elements of s, and whose - //! remaining elements are a copy of the elements of the original string controlled by *this - //! beginning at position pos + xlen. - //! - //! Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error - //! if the length of the resulting string would exceed max_size() - //! - //! Returns: *this - basic_string& replace(size_type pos, size_type n1, const CharT* s) - { - if (pos > this->size()) - throw_out_of_range("basic_string::replace out of range position"); - const size_type len = container_detail::min_value(n1, this->size() - pos); - const size_type n2 = Traits::length(s); - if (n2 > this->max_size() || this->size() - len >= this->max_size() - n2) - throw_length_error("basic_string::replace max_size() exceeded"); - const pointer addr = this->priv_addr(); - return this->replace(addr + pos, addr + pos + len, - s, s + Traits::length(s)); - } - - //! Requires: pos1 <= size(). - //! - //! Effects: Equivalent to replace(pos1, n1, basic_string(n2, c)). - //! - //! Throws: if memory allocation throws, out_of_range if pos1 > size() or length_error - //! if the length of the resulting string would exceed max_size() - //! - //! Returns: *this - basic_string& replace(size_type pos1, size_type n1, size_type n2, CharT c) - { - if (pos1 > this->size()) - throw_out_of_range("basic_string::replace out of range position"); - const size_type len = container_detail::min_value(n1, this->size() - pos1); - if (n2 > this->max_size() || this->size() - len >= this->max_size() - n2) - throw_length_error("basic_string::replace max_size() exceeded"); - const pointer addr = this->priv_addr(); - return this->replace(addr + pos1, addr + pos1 + len, n2, c); - } - - //! Requires: [begin(),i1) and [i1,i2) are valid ranges. - //! - //! Effects: Calls replace(i1 - begin(), i2 - i1, str). - //! - //! Throws: if memory allocation throws - //! - //! Returns: *this - basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str) - { return this->replace(i1, i2, str.begin(), str.end()); } - - //! Requires: [begin(),i1) and [i1,i2) are valid ranges and - //! s points to an array of at least n elements - //! - //! Effects: Calls replace(i1 - begin(), i2 - i1, s, n). - //! - //! Throws: if memory allocation throws - //! - //! Returns: *this - basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s, size_type n) - { return this->replace(i1, i2, s, s + n); } - - //! Requires: [begin(),i1) and [i1,i2) are valid ranges and s points to an - //! array of at least traits::length(s) + 1 elements of CharT. - //! - //! Effects: Calls replace(i1 - begin(), i2 - i1, s, traits::length(s)). - //! - //! Throws: if memory allocation throws - //! - //! Returns: *this - basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s) - { return this->replace(i1, i2, s, s + Traits::length(s)); } - - //! Requires: [begin(),i1) and [i1,i2) are valid ranges. - //! - //! Effects: Calls replace(i1 - begin(), i2 - i1, basic_string(n, c)). - //! - //! Throws: if memory allocation throws - //! - //! Returns: *this - basic_string& replace(const_iterator i1, const_iterator i2, size_type n, CharT c) - { - const size_type len = static_cast(i2 - i1); - if (len >= n) { - Traits::assign(const_cast(container_detail::to_raw_pointer(i1)), n, c); - erase(i1 + n, i2); - } - else { - Traits::assign(const_cast(container_detail::to_raw_pointer(i1)), len, c); - insert(i2, n - len, c); - } - return *this; - } - - //! Requires: [begin(),i1), [i1,i2) and [j1,j2) are valid ranges. - //! - //! Effects: Calls replace(i1 - begin(), i2 - i1, basic_string(j1, j2)). - //! - //! Throws: if memory allocation throws - //! - //! Returns: *this - template - 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::value - && container_detail::is_input_iterator::value - >::type * = 0 - #endif - ) - { - for ( ; i1 != i2 && j1 != j2; ++i1, ++j1){ - Traits::assign(*const_cast(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 - basic_string& replace(const_iterator i1, const_iterator i2, ForwardIter j1, ForwardIter j2 - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - && !container_detail::is_input_iterator::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(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(container_detail::to_raw_pointer(i1))); - this->insert(i2, m, j2); - } - return *this; - } - #endif - - //! Requires: pos <= size() - //! - //! Effects: Determines the effective length rlen of the string to copy as the - //! smaller of n and size() - pos. s shall designate an array of at least rlen elements. - //! The function then replaces the string designated by s with a string of length rlen - //! whose elements are a copy of the string controlled by *this beginning at position pos. - //! The function does not append a null object to the string designated by s. - //! - //! Throws: if memory allocation throws, out_of_range if pos > size(). - //! - //! Returns: rlen - size_type copy(CharT* s, size_type n, size_type pos = 0) const - { - if (pos > this->size()) - throw_out_of_range("basic_string::copy out of range position"); - 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; - } - - //! Effects: *this contains the same sequence of characters that was in s, - //! s contains the same sequence of characters that was in *this. - //! - //! Throws: Nothing - void swap(basic_string& x) - { - this->base_t::swap_data(x); - container_detail::bool_ flag; - container_detail::swap_alloc(this->alloc(), x.alloc(), flag); - } - - ////////////////////////////////////////////// - // - // data access - // - ////////////////////////////////////////////// - - //! Requires: The program shall not alter any of the values stored in the character array. - //! - //! Returns: Allocator pointer p such that p + i == &operator[](i) for each i in [0,size()]. - //! - //! Complexity: constant time. - const CharT* c_str() const BOOST_CONTAINER_NOEXCEPT - { return container_detail::to_raw_pointer(this->priv_addr()); } - - //! Requires: The program shall not alter any of the values stored in the character array. - //! - //! Returns: Allocator pointer p such that p + i == &operator[](i) for each i in [0,size()]. - //! - //! Complexity: constant time. - const CharT* data() const BOOST_CONTAINER_NOEXCEPT - { return container_detail::to_raw_pointer(this->priv_addr()); } - - ////////////////////////////////////////////// - // - // string operations - // - ////////////////////////////////////////////// - - //! Effects: Determines the lowest position xpos, if possible, such that both - //! of the following conditions obtain: 19 pos <= xpos and xpos + str.size() <= size(); - //! 2) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str. - //! - //! Throws: Nothing - //! - //! Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos. - size_type find(const basic_string& s, size_type pos = 0) const - { return find(s.c_str(), pos, s.size()); } - - //! Requires: s points to an array of at least n elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: find(basic_string(s,n),pos). - size_type find(const CharT* s, size_type pos, size_type n) const - { - if (pos + n > this->size()) - return npos; - else { - const pointer addr = this->priv_addr(); - pointer finish = addr + this->priv_size(); - const const_iterator result = - std::search(container_detail::to_raw_pointer(addr + pos), - container_detail::to_raw_pointer(finish), - s, s + n, Eq_traits()); - return result != finish ? result - begin() : npos; - } - } - - //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: find(basic_string(s), pos). - size_type find(const CharT* s, size_type pos = 0) const - { return this->find(s, pos, Traits::length(s)); } - - //! Throws: Nothing - //! - //! Returns: find(basic_string(1,c), pos). - size_type find(CharT c, size_type pos = 0) const - { - const size_type sz = this->size(); - if (pos >= sz) - return npos; - else { - const pointer addr = this->priv_addr(); - pointer finish = addr + sz; - const const_iterator result = - std::find_if(addr + pos, finish, - std::bind2nd(Eq_traits(), c)); - return result != finish ? result - begin() : npos; - } - } - - //! Effects: Determines the highest position xpos, if possible, such - //! that both of the following conditions obtain: - //! a) xpos <= pos and xpos + str.size() <= size(); - //! b) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str. - //! - //! Throws: Nothing - //! - //! Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos. - size_type rfind(const basic_string& str, size_type pos = npos) const - { return rfind(str.c_str(), pos, str.size()); } - - //! Requires: s points to an array of at least n elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: rfind(basic_string(s, n), pos). - size_type rfind(const CharT* s, size_type pos, size_type n) const - { - const size_type len = this->size(); - - if (n > len) - return npos; - else if (n == 0) - return container_detail::min_value(len, pos); - else { - const const_iterator last = begin() + container_detail::min_value(len - n, pos) + n; - const const_iterator result = find_end(begin(), last, - s, s + n, - Eq_traits()); - return result != last ? result - begin() : npos; - } - } - - //! Requires: pos <= size() and s points to an array of at least - //! traits::length(s) + 1 elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: rfind(basic_string(s), pos). - size_type rfind(const CharT* s, size_type pos = npos) const - { return rfind(s, pos, Traits::length(s)); } - - //! Throws: Nothing - //! - //! Returns: rfind(basic_string(1,c),pos). - size_type rfind(CharT c, size_type pos = npos) const - { - 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 = - std::find_if(const_reverse_iterator(last), rend(), - std::bind2nd(Eq_traits(), c)); - return rresult != rend() ? (rresult.base() - 1) - begin() : npos; - } - } - - //! Effects: Determines the lowest position xpos, if possible, such that both of the - //! following conditions obtain: a) pos <= xpos and xpos < size(); - //! b) traits::eq(at(xpos), str.at(I)) for some element I of the string controlled by str. - //! - //! Throws: Nothing - //! - //! Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos. - size_type find_first_of(const basic_string& s, size_type pos = 0) const - { return find_first_of(s.c_str(), pos, s.size()); } - - //! Requires: s points to an array of at least n elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: find_first_of(basic_string(s, n), pos). - size_type find_first_of(const CharT* s, size_type pos, size_type n) const - { - const size_type sz = this->size(); - if (pos >= sz) - return npos; - else { - const pointer addr = this->priv_addr(); - pointer finish = addr + sz; - const_iterator result = std::find_first_of - (addr + pos, finish, s, s + n, Eq_traits()); - return result != finish ? result - this->begin() : npos; - } - } - - //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: find_first_of(basic_string(s), pos). - size_type find_first_of(const CharT* s, size_type pos = 0) const - { return find_first_of(s, pos, Traits::length(s)); } - - //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: find_first_of(basic_string(1,c), pos). - size_type find_first_of(CharT c, size_type pos = 0) const - { return find(c, pos); } - - //! Effects: Determines the highest position xpos, if possible, such that both of - //! the following conditions obtain: a) xpos <= pos and xpos < size(); b) - //! traits::eq(at(xpos), str.at(I)) for some element I of the string controlled by str. - //! - //! Throws: Nothing - //! - //! Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos. - size_type find_last_of(const basic_string& str, size_type pos = npos) const - { return find_last_of(str.c_str(), pos, str.size()); } - - //! Requires: s points to an array of at least n elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: 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 = this->size(); - - if (len < 1) - return npos; - else { - 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()); - return rresult != rend() ? (rresult.base() - 1) - addr : npos; - } - } - - //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: find_last_of(basic_string(1,c),pos). - size_type find_last_of(const CharT* s, size_type pos = npos) const - { return find_last_of(s, pos, Traits::length(s)); } - - //! Throws: Nothing - //! - //! Returns: find_last_of(basic_string(s), pos). - size_type find_last_of(CharT c, size_type pos = npos) const - { return rfind(c, pos); } - - //! Effects: Determines the lowest position xpos, if possible, such that - //! both of the following conditions obtain: - //! a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), str.at(I)) for no - //! element I of the string controlled by str. - //! - //! Throws: Nothing - //! - //! Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos. - size_type find_first_not_of(const basic_string& str, size_type pos = 0) const - { return find_first_not_of(str.c_str(), pos, str.size()); } - - //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: 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 > this->size()) - return npos; - else { - 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(s, s + n)); - return result != finish ? result - addr : npos; - } - } - - //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: find_first_not_of(basic_string(s), pos). - size_type find_first_not_of(const CharT* s, size_type pos = 0) const - { return find_first_not_of(s, pos, Traits::length(s)); } - - //! Throws: Nothing - //! - //! Returns: find_first_not_of(basic_string(1, c), pos). - size_type find_first_not_of(CharT c, size_type pos = 0) const - { - if (pos > this->size()) - return npos; - else { - 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(), c))); - return result != finish ? result - begin() : npos; - } - } - - //! Effects: Determines the highest position xpos, if possible, such that - //! both of the following conditions obtain: a) xpos <= pos and xpos < size(); - //! b) traits::eq(at(xpos), str.at(I)) for no element I of the string controlled by str. - //! - //! Throws: Nothing - //! - //! Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos. - size_type find_last_not_of(const basic_string& str, size_type pos = npos) const - { return find_last_not_of(str.c_str(), pos, str.size()); } - - //! Requires: s points to an array of at least n elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: 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 = this->size(); - - if (len < 1) - return npos; - else { - const const_iterator last = begin() + container_detail::min_value(len - 1, pos) + 1; - const const_reverse_iterator rresult = - std::find_if(const_reverse_iterator(last), rend(), - Not_within_traits(s, s + n)); - return rresult != rend() ? (rresult.base() - 1) - begin() : npos; - } - } - - //! Requires: s points to an array of at least traits::length(s) + 1 elements of CharT. - //! - //! Throws: Nothing - //! - //! Returns: find_last_not_of(basic_string(s), pos). - size_type find_last_not_of(const CharT* s, size_type pos = npos) const - { return find_last_not_of(s, pos, Traits::length(s)); } - - //! Throws: Nothing - //! - //! Returns: 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 = this->size(); - - if (len < 1) - return npos; - else { - const const_iterator last = begin() + container_detail::min_value(len - 1, pos) + 1; - const const_reverse_iterator rresult = - std::find_if(const_reverse_iterator(last), rend(), - std::not1(std::bind2nd(Eq_traits(), c))); - return rresult != rend() ? (rresult.base() - 1) - begin() : npos; - } - } - - //! Requires: Requires: pos <= size() - //! - //! Effects: Determines the effective length rlen of the string to copy as - //! the smaller of n and size() - pos. - //! - //! Throws: If memory allocation throws or out_of_range if pos > size(). - //! - //! Returns: basic_string(data()+pos,rlen). - basic_string substr(size_type pos = 0, size_type n = npos) const - { - if (pos > this->size()) - throw_out_of_range("basic_string::substr out of range position"); - const pointer addr = this->priv_addr(); - return basic_string(addr + pos, - addr + pos + container_detail::min_value(n, size() - pos), this->alloc()); - } - - //! Effects: Determines the effective length rlen of the string to copy as - //! the smaller of size() and str.size(). The function then compares the two strings by - //! calling traits::compare(data(), str.data(), rlen). - //! - //! Throws: Nothing - //! - //! Returns: The nonzero result if the result of the comparison is nonzero. - //! 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 - { - 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()); - } - - //! Requires: pos1 <= size() - //! - //! Effects: Determines the effective length rlen of the string to copy as - //! the smaller of - //! - //! Throws: out_of_range if pos1 > size() - //! - //! Returns:basic_string(*this,pos1,n1).compare(str). - int compare(size_type pos1, size_type n1, const basic_string& str) const - { - if (pos1 > this->size()) - throw_out_of_range("basic_string::compare out of range position"); - 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()); - } - - //! Requires: pos1 <= size() and pos2 <= str.size() - //! - //! Effects: Determines the effective length rlen of the string to copy as - //! the smaller of - //! - //! Throws: out_of_range if pos1 > size() or pos2 > str.size() - //! - //! Returns: 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 > this->size() || pos2 > str.size()) - throw_out_of_range("basic_string::compare out of range position"); - 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)); - } - - //! Throws: Nothing - //! - //! Returns: compare(basic_string(s)). - int compare(const CharT* s) const - { - const pointer addr = this->priv_addr(); - return s_compare(addr, addr + this->priv_size(), s, s + Traits::length(s)); - } - - - //! Requires: pos1 > size() and s points to an array of at least n2 elements of CharT. - //! - //! Throws: out_of_range if pos1 > size() - //! - //! Returns: basic_string(*this, pos, n1).compare(basic_string(s, n2)). - int compare(size_type pos1, size_type n1, const CharT* s, size_type n2) const - { - if (pos1 > this->size()) - throw_out_of_range("basic_string::compare out of range position"); - const pointer addr = this->priv_addr(); - return s_compare( addr + pos1, - addr + pos1 + container_detail::min_value(n1, this->size() - pos1), - s, s + n2); - } - - //! Requires: pos1 > size() and s points to an array of at least traits::length(s) + 1 elements of CharT. - //! - //! Throws: out_of_range if pos1 > size() - //! - //! Returns: basic_string(*this, pos, n1).compare(basic_string(s, n2)). - int compare(size_type pos1, size_type n1, const CharT* s) const - { return this->compare(pos1, n1, s, Traits::length(s)); } - - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - private: - void priv_reserve(size_type res_arg, const bool null_terminate = true) - { - if (res_arg > this->max_size()){ - throw_length_error("basic_string::reserve max_size() exceeded"); - } - - if (this->capacity() < res_arg){ - size_type n = container_detail::max_value(res_arg, this->size()) + 1; - size_type new_cap = this->next_capacity(n); - pointer new_start = this->allocation_command - (allocate_new, n, new_cap, new_cap).first; - size_type new_length = 0; - - const pointer addr = this->priv_addr(); - new_length += priv_uninitialized_copy - (addr, addr + this->priv_size(), new_start); - if(null_terminate){ - 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_storage(new_cap); - } - } - - static int s_compare(const_pointer f1, const_pointer l1, - const_pointer f2, const_pointer l2) - { - const difference_type n1 = l1 - f1; - const difference_type n2 = l2 - f2; - const int cmp = Traits::compare(container_detail::to_raw_pointer(f1), - container_detail::to_raw_pointer(f2), - container_detail::min_value(n1, n2)); - return cmp != 0 ? cmp : (n1 < n2 ? -1 : (n1 > n2 ? 1 : 0)); - } - - template - void priv_shrink_to_fit_dynamic_buffer - ( AllocVersion - , typename container_detail::enable_if >::type* = 0) - { - //Allocate a new buffer. - size_type real_cap = 0; - 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 - BOOST_TRY{ - const std::pair 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) - , container_detail::to_raw_pointer(this->priv_long_addr()) - , long_size+1); - this->priv_long_addr(ret.first); - this->priv_storage(real_cap); - //And release old buffer - this->alloc().deallocate(long_addr, long_storage); - } - BOOST_CATCH(...){ - return; - } - BOOST_CATCH_END - } - - template - void priv_shrink_to_fit_dynamic_buffer - ( AllocVersion - , typename container_detail::enable_if >::type* = 0) - { - size_type received_size; - if(this->alloc().allocation_command - ( shrink_in_place | nothrow_allocation - , this->priv_long_storage(), this->priv_long_size()+1 - , received_size, this->priv_long_addr()).first){ - this->priv_storage(received_size); - } - } - - void priv_construct_null(pointer p) - { 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_end_addr()); } - - template inline - void priv_uninitialized_fill_n(FwdIt first, Count count, const CharT val) - { - //Save initial position - FwdIt init = first; - - BOOST_TRY{ - //Construct objects - for (; count--; ++first){ - this->construct(first, val); - } - } - BOOST_CATCH(...){ - //Call destructors - for (; init != first; ++init){ - this->destroy(init); - } - BOOST_RETHROW - } - BOOST_CATCH_END - } - - template inline - size_type priv_uninitialized_copy(InpIt first, InpIt last, FwdIt dest) - { - //Save initial destination position - FwdIt dest_init = dest; - size_type constructed = 0; - - BOOST_TRY{ - //Try to build objects - for (; first != last; ++dest, ++first, ++constructed){ - this->construct(dest, *first); - } - } - BOOST_CATCH(...){ - //Call destructors - for (; constructed--; ++dest_init){ - this->destroy(dest_init); - } - BOOST_RETHROW - } - BOOST_CATCH_END - return (constructed); - } - - template - void priv_copy(InputIterator first, InputIterator last, OutIterator result) - { - for ( ; first != last; ++first, ++result) - Traits::assign(*result, *first); - } - - void priv_copy(const CharT* first, const CharT* last, CharT* result) - { Traits::copy(result, first, last - first); } - - template - basic_string& priv_replace_dispatch(const_iterator first, const_iterator last, - Integer n, Integer x, - container_detail::true_) - { return this->replace(first, last, (size_type) n, (CharT) x); } - - template - basic_string& priv_replace_dispatch(const_iterator first, const_iterator last, - InputIter f, InputIter l, - container_detail::false_) - { - typedef typename std::iterator_traits::iterator_category Category; - return this->priv_replace(first, last, f, l, Category()); - } - - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -}; - -#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED - -//!Typedef for a basic_string of -//!narrow characters -typedef basic_string - - ,std::allocator > -string; - -//!Typedef for a basic_string of -//!narrow characters -typedef basic_string - - ,std::allocator > -wstring; - -#endif - -// ------------------------------------------------------------ -// Non-member functions. - -// Operator+ - -template inline - basic_string - operator+(const basic_string& x - ,const basic_string& y) -{ - typedef basic_string str_t; - typedef typename str_t::reserve_t reserve_t; - reserve_t reserve; - str_t result(reserve, x.size() + y.size(), x.get_stored_allocator()); - result.append(x); - result.append(y); - return result; -} - -template inline - basic_string operator+ - ( BOOST_RV_REF_BEG basic_string BOOST_RV_REF_END mx - , BOOST_RV_REF_BEG basic_string BOOST_RV_REF_END my) -{ - mx += my; - return boost::move(mx); -} - -template inline - basic_string operator+ - ( BOOST_RV_REF_BEG basic_string BOOST_RV_REF_END mx - , const basic_string& y) -{ - mx += y; - return boost::move(mx); -} - -template inline - basic_string operator+ - (const basic_string& x - ,BOOST_RV_REF_BEG basic_string BOOST_RV_REF_END my) -{ - my.insert(my.begin(), x.begin(), x.end()); - return boost::move(my); -} - -template inline - basic_string operator+ - (const CharT* s, basic_string y) -{ - y.insert(y.begin(), s, s + Traits::length(s)); - return y; -} - -template inline - basic_string operator+ - (basic_string x, const CharT* s) -{ - x += s; - return x; -} - -template inline - basic_string operator+ - (CharT c, basic_string y) -{ - y.insert(y.begin(), c); - return y; -} - -template inline - basic_string operator+ - (basic_string x, const CharT c) -{ - x += c; - return x; -} - -// Operator== and operator!= - -template -inline bool -operator==(const basic_string& x, - const basic_string& y) -{ - return x.size() == y.size() && - Traits::compare(x.data(), y.data(), x.size()) == 0; -} - -template -inline bool -operator==(const CharT* s, const basic_string& y) -{ - typename basic_string::size_type n = Traits::length(s); - return n == y.size() && Traits::compare(s, y.data(), n) == 0; -} - -template -inline bool -operator==(const basic_string& x, const CharT* s) -{ - typename basic_string::size_type n = Traits::length(s); - return x.size() == n && Traits::compare(x.data(), s, n) == 0; -} - -template -inline bool -operator!=(const basic_string& x, - const basic_string& y) - { return !(x == y); } - -template -inline bool -operator!=(const CharT* s, const basic_string& y) - { return !(s == y); } - -template -inline bool -operator!=(const basic_string& x, const CharT* s) - { return !(x == s); } - - -// Operator< (and also >, <=, and >=). - -template -inline bool -operator<(const basic_string& x, const basic_string& y) -{ - return x.compare(y) < 0; -// return basic_string -// ::s_compare(x.begin(), x.end(), y.begin(), y.end()) < 0; -} - -template -inline bool -operator<(const CharT* s, const basic_string& y) -{ - return y.compare(s) > 0; -// basic_string::size_type n = Traits::length(s); -// return basic_string -// ::s_compare(s, s + n, y.begin(), y.end()) < 0; -} - -template -inline bool -operator<(const basic_string& x, - const CharT* s) -{ - return x.compare(s) < 0; -// basic_string::size_type n = Traits::length(s); -// return basic_string -// ::s_compare(x.begin(), x.end(), s, s + n) < 0; -} - -template -inline bool -operator>(const basic_string& x, - const basic_string& y) { - return y < x; -} - -template -inline bool -operator>(const CharT* s, const basic_string& y) { - return y < s; -} - -template -inline bool -operator>(const basic_string& x, const CharT* s) -{ - return s < x; -} - -template -inline bool -operator<=(const basic_string& x, - const basic_string& y) -{ - return !(y < x); -} - -template -inline bool -operator<=(const CharT* s, const basic_string& y) - { return !(y < s); } - -template -inline bool -operator<=(const basic_string& x, const CharT* s) - { return !(s < x); } - -template -inline bool -operator>=(const basic_string& x, - const basic_string& y) - { return !(x < y); } - -template -inline bool -operator>=(const CharT* s, const basic_string& y) - { return !(s < y); } - -template -inline bool -operator>=(const basic_string& x, const CharT* s) - { return !(x < s); } - -// Swap. -template -inline void swap(basic_string& x, basic_string& y) -{ x.swap(y); } - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED -// I/O. -namespace container_detail { - -template -inline bool -string_fill(std::basic_ostream& os, - std::basic_streambuf* buf, - std::size_t n) -{ - CharT f = os.fill(); - std::size_t i; - bool ok = true; - - for (i = 0; i < n; i++) - ok = ok && !Traits::eq_int_type(buf->sputc(f), Traits::eof()); - return ok; -} - -} //namespace container_detail { -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -template -std::basic_ostream& -operator<<(std::basic_ostream& os, const basic_string& s) -{ - typename std::basic_ostream::sentry sentry(os); - bool ok = false; - - if (sentry) { - ok = true; - typename basic_string::size_type n = s.size(); - typename basic_string::size_type pad_len = 0; - const bool left = (os.flags() & std::ios::left) != 0; - const std::size_t w = os.width(0); - std::basic_streambuf* buf = os.rdbuf(); - - if (w != 0 && n < w) - pad_len = w - n; - - if (!left) - ok = container_detail::string_fill(os, buf, pad_len); - - ok = ok && - buf->sputn(s.data(), std::streamsize(n)) == std::streamsize(n); - - if (left) - ok = ok && container_detail::string_fill(os, buf, pad_len); - } - - if (!ok) - os.setstate(std::ios_base::failbit); - - return os; -} - - -template -std::basic_istream& -operator>>(std::basic_istream& is, basic_string& s) -{ - typename std::basic_istream::sentry sentry(is); - - if (sentry) { - std::basic_streambuf* buf = is.rdbuf(); - const std::ctype& ctype = std::use_facet >(is.getloc()); - - s.clear(); - std::size_t n = is.width(0); - if (n == 0) - n = static_cast(-1); - else - s.reserve(n); - - while (n-- > 0) { - typename Traits::int_type c1 = buf->sbumpc(); - - if (Traits::eq_int_type(c1, Traits::eof())) { - is.setstate(std::ios_base::eofbit); - break; - } - else { - CharT c = Traits::to_char_type(c1); - - if (ctype.is(std::ctype::space, c)) { - if (Traits::eq_int_type(buf->sputbackc(c), Traits::eof())) - is.setstate(std::ios_base::failbit); - break; - } - else - s.push_back(c); - } - } - - // If we have read no characters, then set failbit. - if (s.size() == 0) - is.setstate(std::ios_base::failbit); - } - else - is.setstate(std::ios_base::failbit); - - return is; -} - -template -std::basic_istream& -getline(std::istream& is, basic_string& s,CharT delim) -{ - typename basic_string::size_type nread = 0; - typename std::basic_istream::sentry sentry(is, true); - if (sentry) { - std::basic_streambuf* buf = is.rdbuf(); - s.clear(); - - while (nread < s.max_size()) { - int c1 = buf->sbumpc(); - if (Traits::eq_int_type(c1, Traits::eof())) { - is.setstate(std::ios_base::eofbit); - break; - } - else { - ++nread; - CharT c = Traits::to_char_type(c1); - if (!Traits::eq(c, delim)) - s.push_back(c); - else - break; // Character is extracted but not appended. - } - } - } - if (nread == 0 || nread >= s.max_size()) - is.setstate(std::ios_base::failbit); - - return is; -} - -template -inline std::basic_istream& -getline(std::basic_istream& is, basic_string& s) -{ - return getline(is, s, '\n'); -} - -template -inline std::size_t hash_value(basic_string, Allocator> const& v) -{ - return hash_range(v.begin(), v.end()); -} - -}} - -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -namespace boost { - -template -struct has_trivial_destructor_after_move; - -//!has_trivial_destructor_after_move<> == true_type -//!specialization for optimizations -template -struct has_trivial_destructor_after_move > - : public ::boost::has_trivial_destructor_after_move -{}; - -} - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -#include - -#endif // BOOST_CONTAINER_STRING_HPP diff --git a/boost/container/throw_exception.hpp b/boost/container/throw_exception.hpp index 0276885..2c893e9 100644 --- a/boost/container/throw_exception.hpp +++ b/boost/container/throw_exception.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_CONTAINER_THROW_EXCEPTION_HPP #define BOOST_CONTAINER_THROW_EXCEPTION_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/container/vector.hpp b/boost/container/vector.hpp index 765a2c6..1cf44c8 100644 --- a/boost/container/vector.hpp +++ b/boost/container/vector.hpp @@ -11,52 +11,59 @@ #ifndef BOOST_CONTAINER_CONTAINER_VECTOR_HPP #define BOOST_CONTAINER_CONTAINER_VECTOR_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include -#include -//#include //Already included by container_fwd.hpp -#include //for std::allocator -#include //for std::random_access_iterator_tag -#include //for std::pair,std::distance +// container +#include +#include +#include //new_allocator +#include +// container detail +#include +#include //equal() +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// intrusive +#include +// move +#include +#include +#include +#include +// move/detail +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif +#include +// other +#include +#include +#include + +//std #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #include //for std::initializer_list #endif -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - namespace boost { namespace container { @@ -81,7 +88,7 @@ class vec_iterator rebind_pointer::type , Pointer >::type pointer; - typedef typename boost::intrusive::pointer_traits ptr_traits; + typedef typename boost::intrusive::pointer_traits ptr_traits; typedef typename ptr_traits::reference reference; #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -89,13 +96,13 @@ class vec_iterator Pointer m_ptr; public: - const Pointer &get_ptr() const BOOST_CONTAINER_NOEXCEPT + const Pointer &get_ptr() const BOOST_NOEXCEPT_OR_NOTHROW { return m_ptr; } - Pointer &get_ptr() BOOST_CONTAINER_NOEXCEPT + Pointer &get_ptr() BOOST_NOEXCEPT_OR_NOTHROW { return m_ptr; } - explicit vec_iterator(Pointer ptr) BOOST_CONTAINER_NOEXCEPT + explicit vec_iterator(Pointer ptr) BOOST_NOEXCEPT_OR_NOTHROW : m_ptr(ptr) {} #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -103,84 +110,148 @@ class vec_iterator public: //Constructors - vec_iterator() BOOST_CONTAINER_NOEXCEPT + vec_iterator() BOOST_NOEXCEPT_OR_NOTHROW : m_ptr() //Value initialization to achieve "null iterators" (N3644) {} - vec_iterator(vec_iterator const& other) BOOST_CONTAINER_NOEXCEPT + vec_iterator(vec_iterator const& other) BOOST_NOEXCEPT_OR_NOTHROW : m_ptr(other.get_ptr()) {} //Pointer like operators - reference operator*() const BOOST_CONTAINER_NOEXCEPT + reference operator*() const BOOST_NOEXCEPT_OR_NOTHROW { return *m_ptr; } - pointer operator->() const BOOST_CONTAINER_NOEXCEPT + pointer operator->() const BOOST_NOEXCEPT_OR_NOTHROW { return ::boost::intrusive::pointer_traits::pointer_to(this->operator*()); } - reference operator[](difference_type off) const BOOST_CONTAINER_NOEXCEPT + reference operator[](difference_type off) const BOOST_NOEXCEPT_OR_NOTHROW { return m_ptr[off]; } //Increment / Decrement - vec_iterator& operator++() BOOST_CONTAINER_NOEXCEPT + vec_iterator& operator++() BOOST_NOEXCEPT_OR_NOTHROW { ++m_ptr; return *this; } - vec_iterator operator++(int) BOOST_CONTAINER_NOEXCEPT + vec_iterator operator++(int) BOOST_NOEXCEPT_OR_NOTHROW { return vec_iterator(m_ptr++); } - vec_iterator& operator--() BOOST_CONTAINER_NOEXCEPT + vec_iterator& operator--() BOOST_NOEXCEPT_OR_NOTHROW { --m_ptr; return *this; } - vec_iterator operator--(int) BOOST_CONTAINER_NOEXCEPT + vec_iterator operator--(int) BOOST_NOEXCEPT_OR_NOTHROW { return vec_iterator(m_ptr--); } //Arithmetic - vec_iterator& operator+=(difference_type off) BOOST_CONTAINER_NOEXCEPT + vec_iterator& operator+=(difference_type off) BOOST_NOEXCEPT_OR_NOTHROW { m_ptr += off; return *this; } - vec_iterator& operator-=(difference_type off) BOOST_CONTAINER_NOEXCEPT + vec_iterator& operator-=(difference_type off) BOOST_NOEXCEPT_OR_NOTHROW { m_ptr -= off; return *this; } - friend vec_iterator operator+(const vec_iterator &x, difference_type off) BOOST_CONTAINER_NOEXCEPT + friend vec_iterator operator+(const vec_iterator &x, difference_type off) BOOST_NOEXCEPT_OR_NOTHROW { return vec_iterator(x.m_ptr+off); } - friend vec_iterator operator+(difference_type off, vec_iterator right) BOOST_CONTAINER_NOEXCEPT + friend vec_iterator operator+(difference_type off, vec_iterator right) BOOST_NOEXCEPT_OR_NOTHROW { right.m_ptr += off; return right; } - friend vec_iterator operator-(vec_iterator left, difference_type off) BOOST_CONTAINER_NOEXCEPT + friend vec_iterator operator-(vec_iterator left, difference_type off) BOOST_NOEXCEPT_OR_NOTHROW { left.m_ptr -= off; return left; } - friend difference_type operator-(const vec_iterator &left, const vec_iterator& right) BOOST_CONTAINER_NOEXCEPT + friend difference_type operator-(const vec_iterator &left, const vec_iterator& right) BOOST_NOEXCEPT_OR_NOTHROW { return left.m_ptr - right.m_ptr; } //Comparison operators - friend bool operator== (const vec_iterator& l, const vec_iterator& r) BOOST_CONTAINER_NOEXCEPT + friend bool operator== (const vec_iterator& l, const vec_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW { return l.m_ptr == r.m_ptr; } - friend bool operator!= (const vec_iterator& l, const vec_iterator& r) BOOST_CONTAINER_NOEXCEPT + friend bool operator!= (const vec_iterator& l, const vec_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW { return l.m_ptr != r.m_ptr; } - friend bool operator< (const vec_iterator& l, const vec_iterator& r) BOOST_CONTAINER_NOEXCEPT + friend bool operator< (const vec_iterator& l, const vec_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW { return l.m_ptr < r.m_ptr; } - friend bool operator<= (const vec_iterator& l, const vec_iterator& r) BOOST_CONTAINER_NOEXCEPT + friend bool operator<= (const vec_iterator& l, const vec_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW { return l.m_ptr <= r.m_ptr; } - friend bool operator> (const vec_iterator& l, const vec_iterator& r) BOOST_CONTAINER_NOEXCEPT + friend bool operator> (const vec_iterator& l, const vec_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW { return l.m_ptr > r.m_ptr; } - friend bool operator>= (const vec_iterator& l, const vec_iterator& r) BOOST_CONTAINER_NOEXCEPT + friend bool operator>= (const vec_iterator& l, const vec_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW { return l.m_ptr >= r.m_ptr; } }; +template +struct vector_insert_ordered_cursor +{ + typedef typename iterator_traits::value_type size_type; + typedef typename iterator_traits::reference reference; + + vector_insert_ordered_cursor(BiDirPosConstIt posit, BiDirValueIt valueit) + : last_position_it(posit), last_value_it(valueit) + {} + + void operator --() + { + --last_value_it; + --last_position_it; + while(this->get_pos() == size_type(-1)){ + --last_value_it; + --last_position_it; + } + } + + size_type get_pos() const + { return *last_position_it; } + + reference get_val() + { return *last_value_it; } + + BiDirPosConstIt last_position_it; + BiDirValueIt last_value_it; +}; + +template +struct vector_merge_cursor +{ + typedef SizeType size_type; + typedef typename iterator_traits::reference reference; + + vector_merge_cursor(T *pbeg, T *plast, BiDirValueIt valueit, Comp cmp) + : m_pbeg(pbeg), m_pcur(--plast), m_valueit(valueit), m_cmp(cmp) + {} + + void operator --() + { + --m_valueit; + const T &t = *m_valueit; + while((m_pcur + 1) != m_pbeg){ + if(!m_cmp(t, *m_pcur)){ + break; + } + --m_pcur; + } + } + + size_type get_pos() const + { return static_cast((m_pcur + 1) - m_pbeg); } + + reference get_val() + { return *m_valueit; } + + T *const m_pbeg; + T *m_pcur; + BiDirValueIt m_valueit; + Comp m_cmp; +}; + } //namespace container_detail { template -const Pointer &vector_iterator_get_ptr(const container_detail::vec_iterator &it) BOOST_CONTAINER_NOEXCEPT +const Pointer &vector_iterator_get_ptr(const container_detail::vec_iterator &it) BOOST_NOEXCEPT_OR_NOTHROW { return it.get_ptr(); } template -Pointer &get_ptr(container_detail::vec_iterator &it) BOOST_CONTAINER_NOEXCEPT +Pointer &get_ptr(container_detail::vec_iterator &it) BOOST_NOEXCEPT_OR_NOTHROW { return it.get_ptr(); } namespace container_detail { @@ -199,7 +270,7 @@ struct vector_get_ptr_pointer_to_non_const typedef typename pointer_traits_t ::template rebind_pointer::type return_type; - static return_type get_ptr(const const_pointer &ptr) BOOST_CONTAINER_NOEXCEPT + static return_type get_ptr(const const_pointer &ptr) BOOST_NOEXCEPT_OR_NOTHROW { return boost::intrusive::pointer_traits::const_cast_from(ptr); } }; @@ -207,7 +278,7 @@ template struct vector_get_ptr_pointer_to_non_const { typedef const Pointer & return_type; - static return_type get_ptr(const Pointer &ptr) BOOST_CONTAINER_NOEXCEPT + static return_type get_ptr(const Pointer &ptr) BOOST_NOEXCEPT_OR_NOTHROW { return ptr; } }; @@ -215,7 +286,7 @@ struct vector_get_ptr_pointer_to_non_const template typename container_detail::vector_get_ptr_pointer_to_non_const::return_type - vector_iterator_get_ptr(const MaybeConstPointer &ptr) BOOST_CONTAINER_NOEXCEPT + vector_iterator_get_ptr(const MaybeConstPointer &ptr) BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::vector_get_ptr_pointer_to_non_const::get_ptr(ptr); } @@ -230,12 +301,12 @@ static const uninitialized_size_t uninitialized_size = uninitialized_size_t(); template struct vector_value_traits_base { - static const bool trivial_dctr = boost::has_trivial_destructor::value; - static const bool trivial_dctr_after_move = ::boost::has_trivial_destructor_after_move::value; - static const bool trivial_copy = has_trivial_copy::value; - static const bool nothrow_copy = has_nothrow_copy::value || trivial_copy; - static const bool trivial_assign = has_trivial_assign::value; - static const bool nothrow_assign = has_nothrow_assign::value || trivial_assign; + static const bool trivial_dctr = is_trivially_destructible::value; + static const bool trivial_dctr_after_move = has_trivial_destructor_after_move::value; + static const bool trivial_copy = is_trivially_copy_constructible::value; + static const bool nothrow_copy = is_nothrow_copy_constructible::value || trivial_copy; + static const bool trivial_assign = is_trivially_copy_assignable::value; + static const bool nothrow_assign = is_nothrow_copy_assignable::value || trivial_assign; }; @@ -266,20 +337,38 @@ struct vector_alloc_holder BOOST_MOVABLE_BUT_NOT_COPYABLE(vector_alloc_holder) public: + typedef Allocator allocator_type; typedef boost::container::allocator_traits allocator_traits_type; typedef typename allocator_traits_type::pointer pointer; typedef typename allocator_traits_type::size_type size_type; typedef typename allocator_traits_type::value_type value_type; + static bool is_propagable_from(const allocator_type &from_alloc, pointer p, const allocator_type &to_alloc, bool const propagate_allocator) + { + (void)propagate_allocator; (void)p; (void)to_alloc; (void)from_alloc; + return (!allocator_traits_type::is_partially_propagable::value || + !allocator_traits_type::storage_is_unpropagable(from_alloc, p)) && + (propagate_allocator || allocator_traits_type::equal(from_alloc, to_alloc)); + } + + static bool are_swap_propagable(const allocator_type &l_a, pointer l_p, const allocator_type &r_a, pointer r_p, bool const propagate_allocator) + { + (void)propagate_allocator; (void)l_p; (void)r_p; (void)l_a; (void)r_a; + return (!allocator_traits_type::is_partially_propagable::value || + (!allocator_traits_type::storage_is_unpropagable(r_a, r_p) && + !allocator_traits_type::storage_is_unpropagable(l_a, l_p)) + ) && (propagate_allocator || allocator_traits_type::equal(l_a, r_a)); + } + //Constructor, does not throw vector_alloc_holder() - BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor::value) + BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value) : Allocator(), m_start(), m_size(), m_capacity() {} //Constructor, does not throw template - explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a) BOOST_CONTAINER_NOEXCEPT + explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a) BOOST_NOEXCEPT_OR_NOTHROW : Allocator(boost::forward(a)), m_start(), m_size(), m_capacity() {} @@ -292,7 +381,8 @@ struct vector_alloc_holder , m_capacity() { if(initial_size){ - m_start = this->allocation_command(allocate_new, initial_size, initial_size, m_capacity, m_start).first; + pointer reuse = 0; + m_start = this->allocation_command(allocate_new, initial_size, m_capacity = initial_size, reuse); } } @@ -304,13 +394,13 @@ struct vector_alloc_holder , m_capacity() { if(initial_size){ - m_start = this->allocation_command - (allocate_new, initial_size, initial_size, m_capacity, m_start).first; + pointer reuse = 0; + m_start = this->allocation_command(allocate_new, initial_size, m_capacity = initial_size, reuse); } } - vector_alloc_holder(BOOST_RV_REF(vector_alloc_holder) holder) BOOST_CONTAINER_NOEXCEPT - : Allocator(boost::move(static_cast(holder))) + vector_alloc_holder(BOOST_RV_REF(vector_alloc_holder) holder) BOOST_NOEXCEPT_OR_NOTHROW + : Allocator(BOOST_MOVE_BASE(Allocator, holder)) , m_start(holder.m_start) , m_size(holder.m_size) , m_capacity(holder.m_capacity) @@ -319,35 +409,78 @@ struct vector_alloc_holder holder.m_size = holder.m_capacity = 0; } - void first_allocation(size_type cap) + vector_alloc_holder(pointer p, size_type capacity, BOOST_RV_REF(vector_alloc_holder) holder) + : Allocator(BOOST_MOVE_BASE(Allocator, holder)) + , m_start(p) + , m_size(holder.m_size) + , m_capacity(capacity) { - if(cap){ - m_start = this->allocation_command - (allocate_new, cap, cap, m_capacity, m_start).first; + allocator_type &this_alloc = this->alloc(); + allocator_type &x_alloc = holder.alloc(); + if(this->is_propagable_from(x_alloc, holder.start(), this_alloc, true)){ + if(this->m_capacity){ + this->alloc().deallocate(this->m_start, this->m_capacity); + } + m_start = holder.m_start; + m_capacity = holder.m_capacity; + holder.m_start = pointer(); + holder.m_capacity = holder.m_size = 0; + } + else if(this->m_capacity < holder.m_size){ + size_type const n = holder.m_size; + pointer reuse = pointer(); + m_start = this->allocation_command(allocate_new, n, m_capacity = n, reuse); #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS - ++this->num_alloc; + this->num_alloc += n != 0; #endif } } - void first_allocation_same_allocator_type(size_type cap) - { this->first_allocation(cap); } + vector_alloc_holder(pointer p, size_type n) + BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value) + : Allocator() + , m_start(p) + , m_size() + , m_capacity(n) + {} - ~vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT + template + vector_alloc_holder(pointer p, size_type n, BOOST_FWD_REF(AllocFwd) a) + : Allocator(::boost::forward(a)) + , m_start(p) + , m_size() + , m_capacity(n) + {} + + ~vector_alloc_holder() BOOST_NOEXCEPT_OR_NOTHROW { if(this->m_capacity){ this->alloc().deallocate(this->m_start, this->m_capacity); } } - std::pair - allocation_command(boost::container::allocation_type command, - size_type limit_size, - size_type preferred_size, - size_type &received_size, const pointer &reuse = pointer()) + pointer allocation_command(boost::container::allocation_type command, + size_type limit_size, size_type &prefer_in_recvd_out_size, pointer &reuse) { - return allocator_version_traits::allocation_command - (this->alloc(), command, limit_size, preferred_size, received_size, reuse); + typedef typename container_detail::version::type alloc_version; + return this->priv_allocation_command(alloc_version(), command, limit_size, prefer_in_recvd_out_size, reuse); + } + + bool try_expand_fwd(size_type at_least) + { + //There is not enough memory, try to expand the old one + const size_type new_cap = this->capacity() + at_least; + size_type real_cap = new_cap; + pointer reuse = this->start(); + bool const success = !!this->allocation_command(expand_fwd, new_cap, real_cap, reuse); + //Check for forward expansion + if(success){ + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_expand_fwd; + #endif + this->capacity(real_cap); + } + return success; } size_type next_capacity(size_type additional_objects) const @@ -362,37 +495,71 @@ struct vector_alloc_holder size_type m_size; size_type m_capacity; - void swap(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT + void swap_resources(vector_alloc_holder &x) BOOST_NOEXCEPT_OR_NOTHROW { - boost::container::swap_dispatch(this->m_start, x.m_start); - boost::container::swap_dispatch(this->m_size, x.m_size); - boost::container::swap_dispatch(this->m_capacity, x.m_capacity); + boost::adl_move_swap(this->m_start, x.m_start); + boost::adl_move_swap(this->m_size, x.m_size); + boost::adl_move_swap(this->m_capacity, x.m_capacity); } - void move_from_empty(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT + void steal_resources(vector_alloc_holder &x) BOOST_NOEXCEPT_OR_NOTHROW { - //this->m_size was previously initialized this->m_start = x.m_start; + this->m_size = x.m_size; this->m_capacity = x.m_capacity; x.m_start = pointer(); x.m_size = x.m_capacity = 0; } - Allocator &alloc() BOOST_CONTAINER_NOEXCEPT + Allocator &alloc() BOOST_NOEXCEPT_OR_NOTHROW { return *this; } - const Allocator &alloc() const BOOST_CONTAINER_NOEXCEPT + const Allocator &alloc() const BOOST_NOEXCEPT_OR_NOTHROW { return *this; } - const pointer &start() const BOOST_CONTAINER_NOEXCEPT { return m_start; } - const size_type &capacity() const BOOST_CONTAINER_NOEXCEPT { return m_capacity; } - void start(const pointer &p) BOOST_CONTAINER_NOEXCEPT { m_start = p; } - void capacity(const size_type &c) BOOST_CONTAINER_NOEXCEPT { m_capacity = c; } + const pointer &start() const BOOST_NOEXCEPT_OR_NOTHROW { return m_start; } + const size_type &capacity() const BOOST_NOEXCEPT_OR_NOTHROW { return m_capacity; } + void start(const pointer &p) BOOST_NOEXCEPT_OR_NOTHROW { m_start = p; } + void capacity(const size_type &c) BOOST_NOEXCEPT_OR_NOTHROW { m_capacity = c; } + + private: + void priv_first_allocation(size_type cap) + { + if(cap){ + pointer reuse = 0; + m_start = this->allocation_command(allocate_new, cap, cap, reuse); + m_capacity = cap; + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + ++this->num_alloc; + #endif + } + } + + pointer priv_allocation_command(version_1, boost::container::allocation_type command, + size_type , + size_type &prefer_in_recvd_out_size, + pointer &reuse) + { + (void)command; + BOOST_ASSERT( (command & allocate_new)); + BOOST_ASSERT(!(command & nothrow_allocation)); + pointer const p = allocator_traits_type::allocate(this->alloc(), prefer_in_recvd_out_size, reuse); + reuse = pointer(); + return p; + } + + pointer priv_allocation_command(version_2, boost::container::allocation_type command, + size_type limit_size, + size_type &prefer_in_recvd_out_size, + pointer &reuse) + { + return this->alloc().allocation_command(command, limit_size, prefer_in_recvd_out_size, reuse); + } }; //!This struct deallocates and allocated memory template -struct vector_alloc_holder > +struct vector_alloc_holder : public Allocator { private: @@ -409,13 +576,13 @@ struct vector_alloc_holder::value) + BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value) : Allocator(), m_size() {} //Constructor, does not throw template - explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a) BOOST_CONTAINER_NOEXCEPT + explicit vector_alloc_holder(BOOST_FWD_REF(AllocConvertible) a) BOOST_NOEXCEPT_OR_NOTHROW : Allocator(boost::forward(a)), m_size() {} @@ -426,7 +593,7 @@ struct vector_alloc_holderfirst_allocation(initial_size); + this->priv_first_allocation(initial_size); } //Constructor, does not throw @@ -435,11 +602,11 @@ struct vector_alloc_holderfirst_allocation(initial_size); + this->priv_first_allocation(initial_size); } vector_alloc_holder(BOOST_RV_REF(vector_alloc_holder) holder) - : Allocator(boost::move(static_cast(holder))) + : Allocator(BOOST_MOVE_BASE(Allocator, holder)) , m_size(holder.m_size) //Size is initialized here so vector should only call uninitialized_xxx after this { ::boost::container::uninitialized_move_alloc_n @@ -453,60 +620,62 @@ struct vector_alloc_holderfirst_allocation(n); + this->priv_first_allocation(n); ::boost::container::uninitialized_move_alloc_n (this->alloc(), container_detail::to_raw_pointer(holder.start()), n, container_detail::to_raw_pointer(this->start())); } - void first_allocation(size_type cap) + void priv_first_allocation(size_type cap) { if(cap > Allocator::internal_capacity){ throw_bad_alloc(); } } - void first_allocation_same_allocator_type(size_type) BOOST_CONTAINER_NOEXCEPT - {} - - //Destructor - ~vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT - {} - - void swap(vector_alloc_holder &x) + void deep_swap(vector_alloc_holder &x) { - this->priv_swap_members_impl(x); + this->priv_deep_swap(x); } template - void swap(vector_alloc_holder &x) + void deep_swap(vector_alloc_holder &x) { if(this->m_size > OtherAllocator::internal_capacity || x.m_size > Allocator::internal_capacity){ throw_bad_alloc(); } - this->priv_swap_members_impl(x); + this->priv_deep_swap(x); } - void move_from_empty(vector_alloc_holder &) - { //Containers with version 0 allocators can't be moved without move elements one by one + void swap_resources(vector_alloc_holder &x) BOOST_NOEXCEPT_OR_NOTHROW + { //Containers with version 0 allocators can't be moved without moving elements one by one throw_bad_alloc(); } - Allocator &alloc() BOOST_CONTAINER_NOEXCEPT + + void steal_resources(vector_alloc_holder &) + { //Containers with version 0 allocators can't be moved without moving elements one by one + throw_bad_alloc(); + } + + Allocator &alloc() BOOST_NOEXCEPT_OR_NOTHROW { return *this; } - const Allocator &alloc() const BOOST_CONTAINER_NOEXCEPT + const Allocator &alloc() const BOOST_NOEXCEPT_OR_NOTHROW { return *this; } - pointer start() const BOOST_CONTAINER_NOEXCEPT { return Allocator::internal_storage(); } - size_type capacity() const BOOST_CONTAINER_NOEXCEPT { return Allocator::internal_capacity; } + bool try_expand_fwd(size_type at_least) + { return !at_least; } + + pointer start() const BOOST_NOEXCEPT_OR_NOTHROW { return Allocator::internal_storage(); } + size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW { return Allocator::internal_capacity; } size_type m_size; private: template - void priv_swap_members_impl(vector_alloc_holder &x) + void priv_deep_swap(vector_alloc_holder &x) { - const std::size_t MaxTmpStorage = sizeof(value_type)*Allocator::internal_capacity; + const size_type MaxTmpStorage = sizeof(value_type)*Allocator::internal_capacity; value_type *const first_this = container_detail::to_raw_pointer(this->start()); value_type *const first_x = container_detail::to_raw_pointer(x.start()); @@ -516,7 +685,7 @@ struct vector_alloc_holder(this->alloc(), first_x, x.m_size, first_this, this->m_size); } - boost::container::swap_dispatch(this->m_size, x.m_size); + boost::adl_move_swap(this->m_size, x.m_size); } }; @@ -531,23 +700,37 @@ struct vector_alloc_holder) > +template ) > class vector { #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + struct value_less + { + typedef typename boost::container::allocator_traits::value_type value_type; + bool operator()(const value_type &a, const value_type &b) const + { return a < b; } + }; + typedef typename container_detail::version::type alloc_version; - boost::container::container_detail::vector_alloc_holder - m_holder; + typedef boost::container::container_detail::vector_alloc_holder alloc_holder_t; + alloc_holder_t m_holder; typedef allocator_traits allocator_traits_type; template friend class vector; - typedef typename ::boost::container::allocator_traits - ::pointer pointer_impl; + typedef typename allocator_traits_type::pointer pointer_impl; typedef container_detail::vec_iterator iterator_impl; typedef container_detail::vec_iterator const_iterator_impl; + protected: + static bool is_propagable_from(const Allocator &from_alloc, pointer_impl p, const Allocator &to_alloc, bool const propagate_allocator) + { return alloc_holder_t::is_propagable_from(from_alloc, p, to_alloc, propagate_allocator); } + + static bool are_swap_propagable( const Allocator &l_a, pointer_impl l_p + , const Allocator &r_a, pointer_impl r_p, bool const propagate_allocator) + { return alloc_holder_t::are_swap_propagable(l_a, l_p, r_a, r_p, propagate_allocator); } + #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED public: ////////////////////////////////////////////// @@ -572,19 +755,30 @@ class vector typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator; typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator; #endif - typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) reverse_iterator; - typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) const_reverse_iterator; + typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator) reverse_iterator; + typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator) const_reverse_iterator; #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: BOOST_COPYABLE_AND_MOVABLE(vector) typedef container_detail::vector_value_traits value_traits; - - typedef container_detail::integral_constant allocator_v0; - typedef container_detail::integral_constant allocator_v1; - typedef container_detail::integral_constant allocator_v2; - typedef constant_iterator cvalue_iterator; + + protected: + + void steal_resources(vector &x) + { return this->m_holder.steal_resources(x.m_holder); } + + struct initial_capacity_t{}; + template + vector(initial_capacity_t, pointer initial_memory, size_type capacity, BOOST_FWD_REF(AllocFwd) a) + : m_holder(initial_memory, capacity, ::boost::forward(a)) + {} + + vector(initial_capacity_t, pointer initial_memory, size_type capacity) + : m_holder(initial_memory, capacity) + {} + #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED public: @@ -596,11 +790,10 @@ class vector //! Effects: Constructs a vector taking the allocator as parameter. //! - //! Throws: If allocator_type's default constructor throws. + //! Throws: Nothing. //! //! Complexity: Constant. - vector() - BOOST_CONTAINER_NOEXCEPT_IF(::boost::has_nothrow_default_constructor::value) + vector() BOOST_NOEXCEPT_OR_NOTHROW : m_holder() {} @@ -609,14 +802,13 @@ class vector //! Throws: Nothing //! //! Complexity: Constant. - explicit vector(const Allocator& a) BOOST_CONTAINER_NOEXCEPT + explicit vector(const allocator_type& a) BOOST_NOEXCEPT_OR_NOTHROW : m_holder(a) {} - //! Effects: Constructs a vector that will use a copy of allocator a - //! and inserts n value initialized values. + //! Effects: Constructs a vector and inserts n value initialized values. //! - //! Throws: If allocator_type's default constructor or allocation + //! Throws: If allocator_type's allocation //! throws or T's value initialization throws. //! //! Complexity: Linear to n. @@ -633,7 +825,7 @@ class vector //! Effects: Constructs a vector that will use a copy of allocator a //! and inserts n default initialized values. //! - //! Throws: If allocator_type's default constructor or allocation + //! Throws: If allocator_type's allocation //! throws or T's default initialization throws. //! //! Complexity: Linear to n. @@ -649,10 +841,46 @@ class vector (this->m_holder.alloc(), n, container_detail::to_raw_pointer(this->m_holder.start())); } + //! Effects: Constructs a vector that will use a copy of allocator a + //! and inserts n value initialized values. + //! + //! Throws: If allocator_type's allocation + //! throws or T's value initialization throws. + //! + //! Complexity: Linear to n. + explicit vector(size_type n, const allocator_type &a) + : m_holder(container_detail::uninitialized_size, a, n) + { + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + this->num_alloc += n != 0; + #endif + boost::container::uninitialized_value_init_alloc_n + (this->m_holder.alloc(), n, container_detail::to_raw_pointer(this->m_holder.start())); + } + + //! Effects: Constructs a vector that will use a copy of allocator a + //! and inserts n default initialized values. + //! + //! Throws: If allocator_type's allocation + //! throws or T's default initialization throws. + //! + //! Complexity: Linear to n. + //! + //! Note: Non-standard extension + vector(size_type n, default_init_t, const allocator_type &a) + : m_holder(container_detail::uninitialized_size, a, n) + { + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + this->num_alloc += n != 0; + #endif + boost::container::uninitialized_default_init_alloc_n + (this->m_holder.alloc(), n, container_detail::to_raw_pointer(this->m_holder.start())); + } + //! Effects: Constructs a vector //! and inserts n copies of value. //! - //! Throws: If allocator_type's default constructor or allocation + //! Throws: If allocator_type's allocation //! throws or T's copy constructor throws. //! //! Complexity: Linear to n. @@ -686,32 +914,32 @@ class vector //! Effects: Constructs a vector //! and inserts a copy of the range [first, last) in the vector. //! - //! Throws: If allocator_type's default constructor or allocation + //! Throws: If allocator_type's allocation //! throws or T's constructor taking a dereferenced InIt throws. //! //! Complexity: Linear to the range [first, last). template vector(InIt first, InIt last) : m_holder() - { this->insert(this->cend(), first, last); } + { this->assign(first, last); } //! Effects: Constructs a vector that will use a copy of allocator a //! and inserts a copy of the range [first, last) in the vector. //! - //! Throws: If allocator_type's default constructor or allocation + //! Throws: If allocator_type's allocation //! throws or T's constructor taking a dereferenced InIt throws. //! //! Complexity: Linear to the range [first, last). template vector(InIt first, InIt last, const allocator_type& a) : m_holder(a) - { this->insert(this->cend(), first, last); } + { this->assign(first, last); } //! Effects: Copy constructs a vector. //! //! Postcondition: x == *this. //! - //! Throws: If allocator_type's default constructor or allocation + //! Throws: If allocator_type's allocation //! throws or T's copy constructor throws. //! //! Complexity: Linear to the elements x contains. @@ -728,30 +956,28 @@ class vector , x.size(), container_detail::to_raw_pointer(this->m_holder.start())); } -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) - //! Effects: Constructs a vector that will use a copy of allocator a - //! and inserts a copy of the range [il.begin(), il.last()) in the vector - //! - //! Throws: If allocator_type's default constructor - //! throws or T's constructor taking a dereferenced initializer_list iterator throws. - //! - //! Complexity: Linear to the range [il.begin(), il.end()). - vector(std::initializer_list il, const allocator_type& a = allocator_type()) - : m_holder(a) - { - insert(cend(), il.begin(), il.end()); - } -#endif - - //! Effects: Move constructor. Moves x's resources to *this. //! //! Throws: Nothing //! //! Complexity: Constant. - vector(BOOST_RV_REF(vector) x) BOOST_CONTAINER_NOEXCEPT + vector(BOOST_RV_REF(vector) x) BOOST_NOEXCEPT_OR_NOTHROW : m_holder(boost::move(x.m_holder)) - {} + { BOOST_STATIC_ASSERT((!allocator_traits_type::is_partially_propagable::value)); } + + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + //! Effects: Constructs a vector that will use a copy of allocator a + //! and inserts a copy of the range [il.begin(), il.last()) in the vector + //! + //! Throws: If T's constructor taking a dereferenced initializer_list iterator throws. + //! + //! Complexity: Linear to the range [il.begin(), il.end()). + vector(std::initializer_list il, const allocator_type& a = allocator_type()) + : m_holder(a) + { + this->assign(il.begin(), il.end()); + } + #endif #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) @@ -799,17 +1025,18 @@ class vector //! //! Complexity: Constant if a == x.get_allocator(), linear otherwise. vector(BOOST_RV_REF(vector) x, const allocator_type &a) - : m_holder(container_detail::uninitialized_size, a, x.size()) + : m_holder( container_detail::uninitialized_size, a + , is_propagable_from(x.get_stored_allocator(), x.m_holder.start(), a, true) ? 0 : x.size() + ) { - #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS - this->num_alloc += x.size() != 0; - #endif - if(x.m_holder.alloc() == a){ - this->m_holder.move_from_empty(x.m_holder); + if(is_propagable_from(x.get_stored_allocator(), x.m_holder.start(), a, true)){ + this->m_holder.steal_resources(x.m_holder); } else{ const size_type n = x.size(); - this->m_holder.first_allocation_same_allocator_type(n); + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS + this->num_alloc += n != 0; + #endif ::boost::container::uninitialized_move_alloc_n_source ( this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.start()) , n, container_detail::to_raw_pointer(this->m_holder.start())); @@ -822,7 +1049,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Linear to the number of elements. - ~vector() BOOST_CONTAINER_NOEXCEPT + ~vector() BOOST_NOEXCEPT_OR_NOTHROW { boost::container::destroy_alloc_n (this->get_stored_allocator(), container_detail::to_raw_pointer(this->m_holder.start()), this->m_holder.m_size); @@ -845,16 +1072,16 @@ class vector return *this; } -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) //! Effects: Make *this container contains elements from il. //! //! Complexity: Linear to the range [il.begin(), il.end()). vector& operator=(std::initializer_list il) { - assign(il.begin(), il.end()); + this->assign(il.begin(), il.end()); return *this; } -#endif + #endif //! Effects: Move assignment. All x's values are transferred to *this. //! @@ -868,7 +1095,8 @@ class vector //! propagate_on_container_move_assignment is true or //! this->get>allocator() == x.get_allocator(). Linear otherwise. vector& operator=(BOOST_RV_REF(vector) x) - BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value) + BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value + || allocator_traits_type::is_always_equal::value) { this->priv_move_assign(boost::move(x)); return *this; @@ -887,10 +1115,11 @@ class vector //! //! Note: Non-standard extension to support static_vector template - typename container_detail::enable_if_c - < container_detail::is_version::value && - !container_detail::is_same::value - , vector& >::type + typename container_detail::enable_if_and + < vector& + , container_detail::is_version + , container_detail::is_different + >::type operator=(BOOST_RV_REF_BEG vector BOOST_RV_REF_END x) { this->priv_move_assign(boost::move(x)); @@ -908,10 +1137,11 @@ class vector //! //! Note: Non-standard extension to support static_vector template - typename container_detail::enable_if_c - < container_detail::is_version::value && - !container_detail::is_same::value - , vector& >::type + typename container_detail::enable_if_and + < vector& + , container_detail::is_version + , container_detail::is_different + >::type operator=(const vector &x) { this->priv_copy_assign(x); @@ -928,11 +1158,15 @@ class vector //! Complexity: Linear to n. template void assign(InIt first, InIt last - BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I typename container_detail::enable_if_c - < !container_detail::is_convertible::value && - ( container_detail::is_input_iterator::value || - container_detail::is_same::value ) - >::type * = 0) ) + BOOST_CONTAINER_DOCIGN(BOOST_MOVE_I typename container_detail::disable_if_or + < void + BOOST_MOVE_I container_detail::is_convertible + BOOST_MOVE_I container_detail::and_ + < container_detail::is_different + BOOST_MOVE_I container_detail::is_not_input_iterator + > + >::type * = 0) + ) { //Overwrite all elements we can from [first, last) iterator cur = this->begin(); @@ -943,7 +1177,7 @@ class vector if (first == last){ //There are no more elements in the sequence, erase remaining - T* const end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; + T* const end_pos = this->back_raw(); const size_type n = static_cast(end_pos - container_detail::iterator_to_raw_pointer(cur)); this->priv_destroy_last_n(n); } @@ -953,7 +1187,7 @@ class vector } } -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) //! Effects: Assigns the the range [il.begin(), il.end()) to *this. //! //! Throws: If memory allocation throws or @@ -961,9 +1195,9 @@ class vector //! void assign(std::initializer_list il) { - assign(il.begin(), il.end()); + this->assign(il.begin(), il.end()); } -#endif + #endif //! Effects: Assigns the the range [first, last) to *this. //! @@ -973,22 +1207,23 @@ class vector //! Complexity: Linear to n. template void assign(FwdIt first, FwdIt last - BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I typename container_detail::enable_if_c - < !container_detail::is_convertible::value && - ( !container_detail::is_input_iterator::value && - !container_detail::is_same::value ) + BOOST_CONTAINER_DOCIGN(BOOST_MOVE_I typename container_detail::disable_if_or + < void + BOOST_MOVE_I container_detail::is_same + BOOST_MOVE_I container_detail::is_convertible + BOOST_MOVE_I container_detail::is_input_iterator >::type * = 0) ) { //For Fwd iterators the standard only requires EmplaceConstructible and assignable from *first //so we can't do any backwards allocation - const size_type input_sz = static_cast(std::distance(first, last)); + const size_type input_sz = static_cast(boost::container::iterator_distance(first, last)); const size_type old_capacity = this->capacity(); if(input_sz > old_capacity){ //If input range is too big, we need to reallocate size_type real_cap = 0; - std::pair ret = - this->m_holder.allocation_command(allocate_new|expand_fwd, input_sz, input_sz, real_cap, this->m_holder.start()); - if(!ret.second){ //New allocation, just emplace new values + pointer reuse(this->m_holder.start()); + pointer const ret(this->m_holder.allocation_command(allocate_new|expand_fwd, input_sz, real_cap = input_sz, reuse)); + if(!reuse){ //New allocation, just emplace new values #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_alloc; #endif @@ -997,7 +1232,7 @@ class vector this->priv_destroy_all(); this->m_holder.alloc().deallocate(old_p, old_capacity); } - this->m_holder.start(ret.first); + this->m_holder.start(ret); this->m_holder.capacity(real_cap); this->m_holder.m_size = 0; this->priv_uninitialized_construct_at_end(first, last); @@ -1042,7 +1277,7 @@ class vector //! Throws: If allocator's copy constructor throws. //! //! Complexity: Constant. - allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT + allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW { return this->m_holder.alloc(); } //! Effects: Returns a reference to the internal allocator. @@ -1052,7 +1287,7 @@ class vector //! Complexity: Constant. //! //! Note: Non-standard extension. - stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT + stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW { return this->m_holder.alloc(); } //! Effects: Returns a reference to the internal allocator. @@ -1062,7 +1297,7 @@ class vector //! Complexity: Constant. //! //! Note: Non-standard extension. - const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT + const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW { return this->m_holder.alloc(); } ////////////////////////////////////////////// @@ -1076,7 +1311,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - iterator begin() BOOST_CONTAINER_NOEXCEPT + iterator begin() BOOST_NOEXCEPT_OR_NOTHROW { return iterator(this->m_holder.start()); } //! Effects: Returns a const_iterator to the first element contained in the vector. @@ -1084,7 +1319,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator begin() const BOOST_CONTAINER_NOEXCEPT + const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW { return const_iterator(this->m_holder.start()); } //! Effects: Returns an iterator to the end of the vector. @@ -1092,7 +1327,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - iterator end() BOOST_CONTAINER_NOEXCEPT + iterator end() BOOST_NOEXCEPT_OR_NOTHROW { return iterator(this->m_holder.start() + this->m_holder.m_size); } //! Effects: Returns a const_iterator to the end of the vector. @@ -1100,7 +1335,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator end() const BOOST_CONTAINER_NOEXCEPT + const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW { return this->cend(); } //! Effects: Returns a reverse_iterator pointing to the beginning @@ -1109,7 +1344,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT + reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW { return reverse_iterator(this->end()); } //! Effects: Returns a const_reverse_iterator pointing to the beginning @@ -1118,7 +1353,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return this->crbegin(); } //! Effects: Returns a reverse_iterator pointing to the end @@ -1127,7 +1362,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT + reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW { return reverse_iterator(this->begin()); } //! Effects: Returns a const_reverse_iterator pointing to the end @@ -1136,7 +1371,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW { return this->crend(); } //! Effects: Returns a const_iterator to the first element contained in the vector. @@ -1144,7 +1379,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT + const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return const_iterator(this->m_holder.start()); } //! Effects: Returns a const_iterator to the end of the vector. @@ -1152,7 +1387,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - const_iterator cend() const BOOST_CONTAINER_NOEXCEPT + const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW { return const_iterator(this->m_holder.start() + this->m_holder.m_size); } //! Effects: Returns a const_reverse_iterator pointing to the beginning @@ -1161,7 +1396,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW { return const_reverse_iterator(this->end());} //! Effects: Returns a const_reverse_iterator pointing to the end @@ -1170,7 +1405,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT + const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW { return const_reverse_iterator(this->begin()); } ////////////////////////////////////////////// @@ -1184,7 +1419,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - bool empty() const BOOST_CONTAINER_NOEXCEPT + bool empty() const BOOST_NOEXCEPT_OR_NOTHROW { return !this->m_holder.m_size; } //! Effects: Returns the number of the elements contained in the vector. @@ -1192,7 +1427,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - size_type size() const BOOST_CONTAINER_NOEXCEPT + size_type size() const BOOST_NOEXCEPT_OR_NOTHROW { return this->m_holder.m_size; } //! Effects: Returns the largest possible size of the vector. @@ -1200,7 +1435,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - size_type max_size() const BOOST_CONTAINER_NOEXCEPT + size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW { return allocator_traits_type::max_size(this->m_holder.alloc()); } //! Effects: Inserts or erases elements at the end such that @@ -1238,7 +1473,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - size_type capacity() const BOOST_CONTAINER_NOEXCEPT + size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW { return this->m_holder.capacity(); } //! Effects: If n is less than or equal to capacity(), this call has no @@ -1250,7 +1485,7 @@ class vector void reserve(size_type new_cap) { if (this->capacity() < new_cap){ - this->priv_reserve(new_cap, alloc_version()); + this->priv_reserve_no_capacity(new_cap, alloc_version()); } } @@ -1277,7 +1512,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - reference front() BOOST_CONTAINER_NOEXCEPT + reference front() BOOST_NOEXCEPT_OR_NOTHROW { return *this->m_holder.start(); } //! Requires: !empty() @@ -1288,7 +1523,7 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - const_reference front() const BOOST_CONTAINER_NOEXCEPT + const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW { return *this->m_holder.start(); } //! Requires: !empty() @@ -1299,8 +1534,11 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - reference back() BOOST_CONTAINER_NOEXCEPT - { return this->m_holder.start()[this->m_holder.m_size - 1]; } + reference back() BOOST_NOEXCEPT_OR_NOTHROW + { + BOOST_ASSERT(this->m_holder.m_size > 0); + return this->m_holder.start()[this->m_holder.m_size - 1]; + } //! Requires: !empty() //! @@ -1310,8 +1548,11 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - const_reference back() const BOOST_CONTAINER_NOEXCEPT - { return this->m_holder.start()[this->m_holder.m_size - 1]; } + const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW + { + BOOST_ASSERT(this->m_holder.m_size > 0); + return this->m_holder.start()[this->m_holder.m_size - 1]; + } //! Requires: size() > n. //! @@ -1321,8 +1562,11 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT - { return this->m_holder.start()[n]; } + reference operator[](size_type n) BOOST_NOEXCEPT_OR_NOTHROW + { + BOOST_ASSERT(this->m_holder.m_size > n); + return this->m_holder.start()[n]; + } //! Requires: size() > n. //! @@ -1332,8 +1576,71 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT - { return this->m_holder.start()[n]; } + const_reference operator[](size_type n) const BOOST_NOEXCEPT_OR_NOTHROW + { + return this->m_holder.start()[n]; + } + + //! Requires: size() >= n. + //! + //! Effects: Returns an iterator to the nth element + //! from the beginning of the container. Returns end() + //! if n == size(). + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + //! + //! Note: Non-standard extension + iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW + { + BOOST_ASSERT(this->m_holder.m_size >= n); + return iterator(this->m_holder.start()+n); + } + + //! Requires: size() >= n. + //! + //! Effects: Returns a const_iterator to the nth element + //! from the beginning of the container. Returns end() + //! if n == size(). + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + //! + //! Note: Non-standard extension + const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW + { + BOOST_ASSERT(this->m_holder.m_size >= n); + return const_iterator(this->m_holder.start()+n); + } + + //! Requires: size() >= n. + //! + //! Effects: Returns an iterator to the nth element + //! from the beginning of the container. Returns end() + //! if n == size(). + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + //! + //! Note: Non-standard extension + size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW + { return this->priv_index_of(vector_iterator_get_ptr(p)); } + + //! Requires: begin() <= p <= end(). + //! + //! Effects: Returns the index of the element pointed by p + //! and size() if p == end(). + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + //! + //! Note: Non-standard extension + size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW + { return this->priv_index_of(vector_iterator_get_ptr(p)); } //! Requires: size() > n. //! @@ -1363,22 +1670,22 @@ class vector // ////////////////////////////////////////////// - //! Returns: Allocator pointer such that [data(),data() + size()) is a valid range. + //! Returns: A pointer such that [data(),data() + size()) is a valid range. //! For a non-empty vector, data() == &front(). //! //! Throws: Nothing. //! //! Complexity: Constant. - T* data() BOOST_CONTAINER_NOEXCEPT + T* data() BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::to_raw_pointer(this->m_holder.start()); } - //! Returns: Allocator pointer such that [data(),data() + size()) is a valid range. + //! Returns: A pointer such that [data(),data() + size()) is a valid range. //! For a non-empty vector, data() == &front(). //! //! Throws: Nothing. //! //! Complexity: Constant. - const T * data() const BOOST_CONTAINER_NOEXCEPT + const T * data() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::to_raw_pointer(this->m_holder.start()); } ////////////////////////////////////////////// @@ -1387,7 +1694,7 @@ class vector // ////////////////////////////////////////////// - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! Effects: Inserts an object of type T constructed with //! std::forward(args)... in the end of the vector. //! @@ -1396,21 +1703,40 @@ class vector //! //! Complexity: Amortized constant time. template - void emplace_back(Args &&...args) + void emplace_back(BOOST_FWD_REF(Args)...args) { - if (BOOST_LIKELY(this->m_holder.m_size < this->m_holder.capacity())){ - T* const back_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; + if (BOOST_LIKELY(this->room_enough())){ //There is more memory, just construct a new object at the end - allocator_traits_type::construct(this->m_holder.alloc(), back_pos, ::boost::forward(args)...); + allocator_traits_type::construct(this->m_holder.alloc(), this->back_raw(), ::boost::forward(args)...); ++this->m_holder.m_size; } else{ typedef container_detail::insert_emplace_proxy type; this->priv_forward_range_insert_no_capacity - (vector_iterator_get_ptr(this->cend()), 1, type(::boost::forward(args)...), alloc_version()); + (this->back_ptr(), 1, type(::boost::forward(args)...), alloc_version()); } } + //! Effects: Inserts an object of type T constructed with + //! std::forward(args)... in the end of the vector. + //! + //! Throws: If the in-place constructor throws. + //! + //! Complexity: Constant time. + //! + //! Note: Non-standard extension. + template + bool stable_emplace_back(BOOST_FWD_REF(Args)...args) + { + const bool is_room_enough = this->room_enough() || (alloc_version::value == 2 && this->m_holder.try_expand_fwd(1u)); + if (BOOST_LIKELY(is_room_enough)){ + //There is more memory, just construct a new object at the end + allocator_traits_type::construct(this->m_holder.alloc(), this->back_raw(), ::boost::forward(args)...); + ++this->m_holder.m_size; + } + return is_room_enough; + } + //! Requires: position must be a valid iterator of *this. //! //! Effects: Inserts an object of type T constructed with @@ -1422,51 +1748,55 @@ class vector //! Complexity: If position is end(), amortized constant time //! Linear time otherwise. template - iterator emplace(const_iterator position, Args && ...args) + iterator emplace(const_iterator position, BOOST_FWD_REF(Args) ...args) { //Just call more general insert(pos, size, value) and return iterator typedef container_detail::insert_emplace_proxy type; return this->priv_forward_range_insert( vector_iterator_get_ptr(position), 1 - , type(::boost::forward(args)...), alloc_version()); + , type(::boost::forward(args)...)); } - #else + #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - #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, _)) \ - { \ - T* const back_pos = container_detail::to_raw_pointer \ - (this->m_holder.start()) + this->m_holder.m_size; \ - if (BOOST_LIKELY(this->m_holder.m_size < this->m_holder.capacity())){ \ - allocator_traits_type::construct (this->m_holder.alloc() \ - , back_pos BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - ++this->m_holder.m_size; \ - } \ - else{ \ - typedef container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n) \ - type; \ - this->priv_forward_range_insert_no_capacity \ - ( vector_iterator_get_ptr(this->cend()), 1 \ - , type(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)), alloc_version()); \ - } \ - } \ - \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - iterator emplace(const_iterator pos \ - BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - typedef container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n) \ - type; \ - return this->priv_forward_range_insert \ - ( container_detail::to_raw_pointer(vector_iterator_get_ptr(pos)), 1 \ - , type(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)), alloc_version()); \ - } \ - //! - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() + #define BOOST_CONTAINER_VECTOR_EMPLACE_CODE(N) \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + void emplace_back(BOOST_MOVE_UREF##N)\ + {\ + if (BOOST_LIKELY(this->room_enough())){\ + allocator_traits_type::construct (this->m_holder.alloc()\ + , this->back_raw() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + ++this->m_holder.m_size;\ + }\ + else{\ + typedef container_detail::insert_emplace_proxy_arg##N type;\ + this->priv_forward_range_insert_no_capacity\ + ( this->back_ptr(), 1, type(BOOST_MOVE_FWD##N), alloc_version());\ + }\ + }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + bool stable_emplace_back(BOOST_MOVE_UREF##N)\ + {\ + const bool is_room_enough = this->room_enough() || (alloc_version::value == 2 && this->m_holder.try_expand_fwd(1u));\ + if (BOOST_LIKELY(is_room_enough)){\ + allocator_traits_type::construct (this->m_holder.alloc()\ + , this->back_raw() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + ++this->m_holder.m_size;\ + }\ + return is_room_enough;\ + }\ + \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ + iterator emplace(const_iterator pos BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + typedef container_detail::insert_emplace_proxy_arg##N type;\ + return this->priv_forward_range_insert(vector_iterator_get_ptr(pos), 1, type(BOOST_MOVE_FWD##N));\ + }\ + // + BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_VECTOR_EMPLACE_CODE) + #undef BOOST_CONTAINER_VECTOR_EMPLACE_CODE - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + #endif #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! Effects: Inserts a copy of x at the end of the vector. @@ -1525,7 +1855,7 @@ class vector iterator insert(const_iterator p, size_type n, const T& x) { container_detail::insert_n_copies_proxy proxy(x); - return this->priv_forward_range_insert(vector_iterator_get_ptr(p), n, proxy, alloc_version()); + return this->priv_forward_range_insert(vector_iterator_get_ptr(p), n, proxy); } //! Requires: p must be a valid iterator of *this. @@ -1537,13 +1867,16 @@ class vector //! Throws: If memory allocation throws, T's constructor from a //! dereferenced InpIt throws or T's copy/move constructor/assignment throws. //! - //! Complexity: Linear to std::distance [first, last). + //! Complexity: Linear to boost::container::iterator_distance [first, last). template iterator insert(const_iterator pos, InIt first, InIt last - BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I typename container_detail::enable_if_c - < !container_detail::is_convertible::value - && container_detail::is_input_iterator::value - >::type * = 0) + #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + , typename container_detail::disable_if_or + < void + , container_detail::is_convertible + , container_detail::is_not_input_iterator + >::type * = 0 + #endif ) { const size_type n_pos = pos - this->cbegin(); @@ -1558,19 +1891,20 @@ class vector #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) template iterator insert(const_iterator pos, FwdIt first, FwdIt last - , typename container_detail::enable_if_c - < !container_detail::is_convertible::value - && !container_detail::is_input_iterator::value + , typename container_detail::disable_if_or + < void + , container_detail::is_convertible + , container_detail::is_input_iterator >::type * = 0 ) { container_detail::insert_range_proxy proxy(first); - return this->priv_forward_range_insert(vector_iterator_get_ptr(pos), std::distance(first, last), proxy, alloc_version()); + return this->priv_forward_range_insert(vector_iterator_get_ptr(pos), boost::container::iterator_distance(first, last), proxy); } #endif //! Requires: p must be a valid iterator of *this. num, must - //! be equal to std::distance(first, last) + //! be equal to boost::container::iterator_distance(first, last) //! //! Effects: Insert a copy of the [first, last) range before pos. //! @@ -1579,9 +1913,9 @@ class vector //! Throws: If memory allocation throws, T's constructor from a //! dereferenced InpIt throws or T's copy/move constructor/assignment throws. //! - //! Complexity: Linear to std::distance [first, last). + //! Complexity: Linear to boost::container::iterator_distance [first, last). //! - //! Note: This function avoids a linear operation to calculate std::distance[first, last) + //! Note: This function avoids a linear operation to calculate boost::container::iterator_distance[first, last) //! for forward and bidirectional iterators, and a one by one insertion for input iterators. This is a //! a non-standard extension. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) @@ -1589,14 +1923,14 @@ class vector iterator insert(const_iterator pos, size_type num, InIt first, InIt last) { BOOST_ASSERT(container_detail::is_input_iterator::value || - num == static_cast(std::distance(first, last))); + num == static_cast(boost::container::iterator_distance(first, last))); (void)last; container_detail::insert_range_proxy proxy(first); - return this->priv_forward_range_insert(vector_iterator_get_ptr(pos), num, proxy, alloc_version()); + return this->priv_forward_range_insert(vector_iterator_get_ptr(pos), num, proxy); } #endif -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) //! Requires: position must be a valid iterator of *this. //! //! Effects: Insert a copy of the [il.begin(), il.end()) range before position. @@ -1606,16 +1940,16 @@ class vector //! Complexity: Linear to the range [il.begin(), il.end()). iterator insert(const_iterator position, std::initializer_list il) { - return insert(position, il.begin(), il.end()); + return this->insert(position, il.begin(), il.end()); } -#endif + #endif //! Effects: Removes the last element from the vector. //! //! Throws: Nothing. //! //! Complexity: Constant time. - void pop_back() BOOST_CONTAINER_NOEXCEPT + void pop_back() BOOST_NOEXCEPT_OR_NOTHROW { //Destroy last element this->priv_destroy_last(); @@ -1632,7 +1966,7 @@ class vector const pointer p = vector_iterator_get_ptr(position); T *const pos_ptr = container_detail::to_raw_pointer(p); T *const beg_ptr = container_detail::to_raw_pointer(this->m_holder.start()); - T *const new_end_ptr = ::boost::move(pos_ptr + 1, beg_ptr + this->m_holder.m_size, pos_ptr); + T *const new_end_ptr = ::boost::container::move(pos_ptr + 1, beg_ptr + this->m_holder.m_size, pos_ptr); //Move elements forward and destroy last this->priv_destroy_last(pos_ptr == new_end_ptr); return iterator(p); @@ -1647,11 +1981,11 @@ class vector iterator erase(const_iterator first, const_iterator last) { if (first != last){ - T* const old_end_ptr = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; + T* const old_end_ptr = this->back_raw(); T* const first_ptr = container_detail::to_raw_pointer(vector_iterator_get_ptr(first)); - T* const last_ptr = container_detail::to_raw_pointer(vector_iterator_get_ptr(last)); - T* const ptr = container_detail::to_raw_pointer(boost::move(last_ptr, old_end_ptr, first_ptr)); - this->priv_destroy_last_n(old_end_ptr - ptr, last_ptr == old_end_ptr); + T* const last_ptr = container_detail::to_raw_pointer(vector_iterator_get_ptr(last)); + T* const ptr = container_detail::to_raw_pointer(boost::container::move(last_ptr, old_end_ptr, first_ptr)); + this->priv_destroy_last_n(old_end_ptr - ptr); } return iterator(vector_iterator_get_ptr(first)); } @@ -1661,13 +1995,12 @@ class vector //! Throws: Nothing. //! //! Complexity: Constant. - void swap(vector& x) BOOST_CONTAINER_NOEXCEPT_IF((!container_detail::is_version::value)) + void swap(vector& x) + BOOST_NOEXCEPT_IF( ((allocator_traits_type::propagate_on_container_swap::value + || allocator_traits_type::is_always_equal::value) && + !container_detail::is_version::value)) { - //Just swap internals in case of !allocator_v0. Otherwise, deep swap - this->m_holder.swap(x.m_holder); - //And now the allocator - container_detail::bool_ flag; - container_detail::swap_alloc(this->m_holder.alloc(), x.m_holder.alloc(), flag); + this->priv_swap(x, container_detail::bool_::value>()); } #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -1681,11 +2014,13 @@ class vector //! Note: Non-standard extension to support static_vector template void swap(vector & x - , typename container_detail::enable_if_c - < container_detail::is_version::value && - !container_detail::is_same::value >::type * = 0 + , typename container_detail::enable_if_and + < void + , container_detail::is_version + , container_detail::is_different + >::type * = 0 ) - { this->m_holder.swap(x.m_holder); } + { this->m_holder.deep_swap(x.m_holder); } #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -1694,28 +2029,14 @@ class vector //! Throws: Nothing. //! //! Complexity: Linear to the number of elements in the container. - void clear() BOOST_CONTAINER_NOEXCEPT + void clear() BOOST_NOEXCEPT_OR_NOTHROW { this->priv_destroy_all(); } //! Effects: Returns true if x and y are equal //! //! Complexity: Linear to the number of elements in the container. friend bool operator==(const vector& x, const vector& y) - { - if(x.size() != y.size()){ - return false; - } - else{ - const_iterator first1(x.cbegin()), first2(y.cbegin()); - const const_iterator last1(x.cend()); - for (; first1 != last1; ++first1, ++first2) { - if (!(*first1 != *first2)) { - return false; - } - } - return true; - } - } + { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); } //! Effects: Returns true if x and y are unequal //! @@ -1773,36 +2094,44 @@ class vector //! Note: Non-standard extension. bool stable_reserve(size_type new_cap) { - const bool room_enough = this->capacity() < new_cap; - if(!room_enough && alloc_version::value < 2){ - return false; - } - else{ - //There is not enough memory, try to expand the old one - size_type real_cap = 0; - std::pair ret = this->m_holder.allocation_command - (expand_fwd, new_cap, new_cap, real_cap, this->m_holder.start()); - //Check for forward expansion - if(ret.second){ - #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS - ++this->num_expand_fwd; - #endif - this->m_holder.capacity(real_cap); - } - return ret.second; - } + const size_type cp = this->capacity(); + return cp >= new_cap || (alloc_version::value == 2 && this->m_holder.try_expand_fwd(new_cap - cp)); } //Absolutely experimental. This function might change, disappear or simply crash! template void insert_ordered_at(const size_type element_count, BiDirPosConstIt last_position_it, BiDirValueIt last_value_it) + { + typedef container_detail::vector_insert_ordered_cursor inserter_t; + return this->priv_insert_ordered_at(element_count, inserter_t(last_position_it, last_value_it)); + } + + template + void merge(BidirIt first, BidirIt last) + { this->merge(first, last, value_less()); } + + template + void merge(BidirIt first, BidirIt last, Compare comp) + { this->priv_merge(container_detail::false_type(), first, last, comp); } + + template + void merge_unique(BidirIt first, BidirIt last) + { this->priv_merge(container_detail::true_type(), first, last, value_less()); } + + template + void merge_unique(BidirIt first, BidirIt last, Compare comp) + { this->priv_merge(container_detail::true_type(), first, last, comp); } + + private: + template + void priv_insert_ordered_at(const size_type element_count, PositionValue position_value) { const size_type old_size_pos = this->size(); this->reserve(old_size_pos + element_count); T* const begin_ptr = container_detail::to_raw_pointer(this->m_holder.start()); size_type insertions_left = element_count; - size_type next_pos = old_size_pos; - size_type hole_size = element_count; + size_type prev_pos = old_size_pos; + size_type old_hole_size = element_count; //Exception rollback. If any copy throws before the hole is filled, values //already inserted/copied at the end of the buffer will be destroyed. @@ -1811,95 +2140,213 @@ class vector //Loop for each insertion backwards, first moving the elements after the insertion point, //then inserting the element. while(insertions_left){ - size_type pos = static_cast(*(--last_position_it)); - while(pos == size_type(-1)){ - --last_value_it; - pos = static_cast(*(--last_position_it)); - } - - BOOST_ASSERT(pos != size_type(-1) && pos <= old_size_pos); + --position_value; + size_type const pos = position_value.get_pos(); + BOOST_ASSERT(pos != size_type(-1) && pos <= old_size_pos && pos <= prev_pos); //If needed shift the range after the insertion point and the previous insertion point. //Function will take care if the shift crosses the size() boundary, using copy/move //or uninitialized copy/move if necessary. - size_type new_hole_size = (pos != next_pos) - ? priv_insert_ordered_at_shift_range(pos, next_pos, this->size(), insertions_left) - : hole_size + size_type new_hole_size = (pos != prev_pos) + ? priv_insert_ordered_at_shift_range(pos, prev_pos, this->size(), insertions_left) + : old_hole_size ; - if(new_hole_size > 0){ + if(new_hole_size){ //The hole was reduced by priv_insert_ordered_at_shift_range so expand exception rollback range backwards - past_hole_values_destroyer.increment_size_backwards(next_pos - pos); + past_hole_values_destroyer.increment_size_backwards(prev_pos - pos); //Insert the new value in the hole - allocator_traits_type::construct(this->m_holder.alloc(), begin_ptr + pos + insertions_left - 1, *(--last_value_it)); - --new_hole_size; - if(new_hole_size == 0){ + allocator_traits_type::construct(this->m_holder.alloc(), begin_ptr + pos + insertions_left - 1, position_value.get_val()); + if(--new_hole_size){ + //The hole was reduced by the new insertion by one + past_hole_values_destroyer.increment_size_backwards(size_type(1u)); + } + else{ //Hole was just filled, disable exception rollback and change vector size past_hole_values_destroyer.release(); this->m_holder.m_size += element_count; } - else{ - //The hole was reduced by the new insertion by one - past_hole_values_destroyer.increment_size_backwards(size_type(1u)); - } } else{ - if(hole_size){ + if(old_hole_size){ //Hole was just filled by priv_insert_ordered_at_shift_range, disable exception rollback and change vector size past_hole_values_destroyer.release(); this->m_holder.m_size += element_count; } //Insert the new value in the already constructed range - begin_ptr[pos + insertions_left - 1] = *(--last_value_it); + begin_ptr[pos + insertions_left - 1] = position_value.get_val(); } --insertions_left; - hole_size = new_hole_size; - next_pos = pos; + old_hole_size = new_hole_size; + prev_pos = pos; } } - #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - //! Effects: Inserts an object of type T constructed with - //! std::forward(args)... in the end of the vector. - //! - //! Throws: If memory allocation throws or the in-place constructor throws or - //! T's copy/move constructor throws. - //! - //! Complexity: Amortized constant time. - template - bool stable_emplace_back(Args &&...args) + template + void priv_merge(UniqueBool, BidirIt first, BidirIt last, Compare comp) { - const bool room_enough = this->m_holder.m_size < this->m_holder.capacity(); - if (BOOST_LIKELY(room_enough)){ - T* const back_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; - //There is more memory, just construct a new object at the end - allocator_traits_type::construct(this->m_holder.alloc(), back_pos, ::boost::forward(args)...); - ++this->m_holder.m_size; + size_type const n = static_cast(boost::container::iterator_distance(first, last)); + if(BOOST_LIKELY(n)){ + size_type const s = this->size(); + if(BOOST_LIKELY(s)){ + size_type const c = this->capacity(); + size_type const free_c = (c - s); + //Use a new buffer if current one is too small for new elements, + //or there is no room for position indexes + bool new_buffer = false; + if(free_c < n){ + new_buffer = true; + } + else if(!UniqueBool::value && free_c >= n){ + typedef container_detail::vector_merge_cursor inserter_t; + T* const pbeg = container_detail::to_raw_pointer(m_holder.start()); + return this->priv_insert_ordered_at(n, inserter_t(pbeg, pbeg + s, last, comp)); + } + else if(UniqueBool::value){ //Query for room to store n + 1 indexes (+1 to guarantee potential alignment overhead). + //No need to destroy them as they are integral types, which simplifies things a lot. + std::size_t const sz_vlt = sizeof(value_type); + std::size_t const sz_szt = sizeof(size_type); + new_buffer = (c-s-n)*sz_vlt/sz_szt < (n+1); + } + + if(new_buffer){ + size_type const new_size = s + n; + size_type new_cap = new_size; + pointer p = pointer(); + p = this->m_holder.allocation_command(allocate_new, new_size, new_cap, p); + this->priv_merge_in_new_buffer(UniqueBool(), first, n, comp, p, new_cap); + } + else{ + //Use trailing memory to store position offsets + uintptr_t const szt_align_mask = container_detail::alignment_of::value - 1; + boost::uintptr_t const addr = boost::uintptr_t(container_detail::to_raw_pointer(m_holder.start()) + s + n); + //Align memory before casting to address + size_type *const paddr = reinterpret_cast((addr + szt_align_mask) & ~szt_align_mask); + this->priv_insert_ordered_range(UniqueBool(), n, first, last, paddr, comp); + } + } + else{ + this->insert(this->cend(), n, first, last); + } } - return room_enough; } - #else + template + void priv_insert_ordered_range + (UniqueBool, size_type const n, BidirIt first, BidirIt const last, size_type positions[], Compare comp) + { + //Linear: at most N + M -1 comparisons + //Log: MlogN + //Average + //Linear: N + M - 2 + //Log: MlogN + //N+M - 2 + //N + //(N+M)/2 < MlogN + //(N/M+1)/2 <= logN + //bool const linear = !s || !n || (s <= n) || ((s+n)/n/2 < logN); + size_type const s = this->size(); + size_type remaining = n; + T* const pbeg = container_detail::to_raw_pointer(m_holder.start()); + T* const pend = pbeg + s; + T* pcur = pbeg; + size_type *position = positions; + size_type added_in_middle = 0; + if(first != last && pcur != pend){ + while(1){ + //maintain stability moving external values only if they are strictly less + if(comp(*first, *pcur)) { + *position = static_cast(pcur - pbeg); + BOOST_ASSERT((position == positions) || (*(position-1) == size_type(-1)) || (*(position-1) <= *position)); + ++position; + ++added_in_middle; + --remaining; + if(++first == last) break; + } + else if(UniqueBool::value && !comp(*pcur, *first)){ + *position = size_type(-1); + ++position; + --remaining; + if(++first == last) break; + } + else{ + if(++pcur == pend) break; + } + } + } + this->insert_ordered_at(added_in_middle, position, first); + this->insert(this->cend(), remaining, first, last); + } - #define BOOST_PP_LOCAL_MACRO(n) \ - BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ - bool stable_emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ - { \ - const bool room_enough = this->m_holder.m_size < this->m_holder.capacity(); \ - if (BOOST_LIKELY(room_enough)){ \ - T* const back_pos = container_detail::to_raw_pointer \ - (this->m_holder.start()) + this->m_holder.m_size; \ - allocator_traits_type::construct (this->m_holder.alloc() \ - , back_pos BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ - ++this->m_holder.m_size; \ - } \ - return room_enough; \ - } \ - //! - #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) - #include BOOST_PP_LOCAL_ITERATE() + template + void priv_merge_in_new_buffer + (UniqueBool, FwdIt first, size_type n, Compare comp, pointer new_storage, size_type const new_cap) + { + BOOST_ASSERT((new_cap >= this->size() ) && (new_cap - this->size()) >= n); + allocator_type &a = this->m_holder.alloc(); + typename value_traits::ArrayDeallocator new_buffer_deallocator(new_storage, a, new_cap); + typename value_traits::ArrayDestructor new_values_destroyer(new_storage, a, 0u); + T* pbeg = container_detail::to_raw_pointer(m_holder.start()); + size_type const old_size = this->size(); + T* const pend = pbeg + old_size; + T* d_first = container_detail::to_raw_pointer(new_storage); + size_type added = n; + //Merge in new buffer loop + while(1){ + if(!n) { + ::boost::container::uninitialized_move_alloc(this->m_holder.alloc(), pbeg, pend, d_first); + break; + } + else if(pbeg == pend) { + ::boost::container::uninitialized_move_alloc_n(this->m_holder.alloc(), first, n, d_first); + break; + } + //maintain stability moving external values only if they are strictly less + else if(comp(*first, *pbeg)) { + allocator_traits_type::construct( this->m_holder.alloc(), d_first, ::boost::move(*first) ); + new_values_destroyer.increment_size(1u); + ++first; + --n; + ++d_first; + } + else if(UniqueBool::value && !comp(*pbeg, *first)){ + ++first; + --n; + --added; + } + else{ + allocator_traits_type::construct( this->m_holder.alloc(), d_first, ::boost::move(*pbeg) ); + new_values_destroyer.increment_size(1u); + ++pbeg; + ++d_first; + } + } - #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING + //Nothrow operations + pointer const old_p = this->m_holder.start(); + size_type const old_cap = this->m_holder.capacity(); + boost::container::destroy_alloc_n(a, container_detail::to_raw_pointer(old_p), old_size); + a.deallocate(old_p, old_cap); + this->m_holder.m_size = old_size + added; + this->m_holder.start(new_storage); + this->m_holder.capacity(new_cap); + new_buffer_deallocator.release(); + new_values_destroyer.release(); + } - private: + bool room_enough() const + { return this->m_holder.m_size < this->m_holder.capacity(); } + + pointer back_ptr() const + { return this->m_holder.start() + this->m_holder.m_size; } + + T* back_raw() const + { return container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; } + + size_type priv_index_of(pointer p) const + { + BOOST_ASSERT(this->m_holder.start() <= p); + BOOST_ASSERT(p <= (this->m_holder.start()+this->size())); + return static_cast(p - this->m_holder.start()); + } template void priv_move_assign(BOOST_RV_REF_BEG vector BOOST_RV_REF_END x @@ -1920,33 +2367,42 @@ class vector template void priv_move_assign(BOOST_RV_REF_BEG vector BOOST_RV_REF_END x - , typename container_detail::enable_if_c - < !container_detail::is_version::value && - container_detail::is_same::value>::type * = 0) + , typename container_detail::disable_if_or + < void + , container_detail::is_version + , container_detail::is_different + >::type * = 0) { //for move constructor, no aliasing (&x != this) is assummed. BOOST_ASSERT(this != &x); allocator_type &this_alloc = this->m_holder.alloc(); allocator_type &x_alloc = x.m_holder.alloc(); - const bool propagate_alloc = allocator_traits_type:: - propagate_on_container_move_assignment::value; - container_detail::bool_ flag; - const bool allocators_equal = this_alloc == x_alloc; (void)allocators_equal; + const bool propagate_alloc = allocator_traits_type::propagate_on_container_move_assignment::value; + + const bool is_propagable_from_x = is_propagable_from(x_alloc, x.m_holder.start(), this_alloc, propagate_alloc); + const bool is_propagable_from_t = is_propagable_from(this_alloc, m_holder.start(), x_alloc, propagate_alloc); + const bool are_both_propagable = is_propagable_from_x && is_propagable_from_t; + //Resources can be transferred if both allocators are //going to be equal after this function (either propagated or already equal) - if(propagate_alloc || allocators_equal){ + if(are_both_propagable){ //Destroy objects but retain memory in case x reuses it in the future this->clear(); - //Move allocator if needed - container_detail::move_alloc(this_alloc, x_alloc, flag); - //Nothrow swap - this->m_holder.swap(x.m_holder); + this->m_holder.swap_resources(x.m_holder); + } + else if(is_propagable_from_x){ + this->clear(); + this->m_holder.alloc().deallocate(this->m_holder.m_start, this->m_holder.m_capacity); + this->m_holder.steal_resources(x.m_holder); } //Else do a one by one move else{ - this->assign( boost::make_move_iterator(x.begin()) - , boost::make_move_iterator(x.end())); + this->assign( boost::make_move_iterator(container_detail::iterator_to_raw_pointer(x.begin())) + , boost::make_move_iterator(container_detail::iterator_to_raw_pointer(x.end() )) + ); } + //Move allocator if needed + container_detail::move_alloc(this_alloc, x_alloc, container_detail::bool_()); } template @@ -1967,10 +2423,12 @@ class vector } template - void priv_copy_assign(const vector &x - , typename container_detail::enable_if_c - < !container_detail::is_version::value && - container_detail::is_same::value >::type * = 0) + typename container_detail::disable_if_or + < void + , container_detail::is_version + , container_detail::is_different + >::type + priv_copy_assign(const vector &x) { allocator_type &this_alloc = this->m_holder.alloc(); const allocator_type &x_alloc = x.m_holder.alloc(); @@ -1985,7 +2443,40 @@ class vector , container_detail::to_raw_pointer(x.m_holder.start() + x.m_holder.m_size)); } - void priv_reserve(size_type, allocator_v0) + template //Template it to avoid it in explicit instantiations + void priv_swap(Vector &x, container_detail::true_type) //version_0 + { this->m_holder.deep_swap(x.m_holder); } + + template //Template it to avoid it in explicit instantiations + void priv_swap(Vector &x, container_detail::false_type) //version_N + { + const bool propagate_alloc = allocator_traits_type::propagate_on_container_swap::value; + if(are_swap_propagable( this->get_stored_allocator(), this->m_holder.start() + , x.get_stored_allocator(), this->m_holder.start(), propagate_alloc)){ + //Just swap internals + this->m_holder.swap_resources(x.m_holder); + } + else{ + //Else swap element by element... + bool const t_smaller = this->size() < x.size(); + vector &sml = t_smaller ? *this : x; + vector &big = t_smaller ? x : *this; + + size_type const common_elements = sml.size(); + for(size_type i = 0; i != common_elements; ++i){ + boost::adl_move_swap(sml[i], big[i]); + } + //... and move-insert the remaining range + sml.insert( sml.cend() + , boost::make_move_iterator(container_detail::iterator_to_raw_pointer(big.nth(common_elements))) + , boost::make_move_iterator(container_detail::iterator_to_raw_pointer(big.end())) + ); + } + //And now swap the allocator + container_detail::swap_alloc(this->m_holder.alloc(), x.m_holder.alloc(), container_detail::bool_()); + } + + void priv_reserve_no_capacity(size_type, version_0) { throw_bad_alloc(); } container_detail::insert_range_proxy, T*> priv_dummy_empty_proxy() @@ -1994,28 +2485,27 @@ class vector (::boost::make_move_iterator((T *)0)); } - void priv_reserve(size_type new_cap, allocator_v1) + void priv_reserve_no_capacity(size_type new_cap, version_1) { //There is not enough memory, allocate a new buffer - pointer p = this->m_holder.allocate(new_cap); + //Pass the hint so that allocators can take advantage of this. + pointer const p = allocator_traits_type::allocate(this->m_holder.alloc(), new_cap, this->m_holder.m_start); //We will reuse insert code, so create a dummy input iterator this->priv_forward_range_insert_new_allocation - ( container_detail::to_raw_pointer(p), new_cap - , container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size - , 0, this->priv_dummy_empty_proxy()); + ( container_detail::to_raw_pointer(p), new_cap, this->back_raw(), 0, this->priv_dummy_empty_proxy()); } - void priv_reserve(size_type new_cap, allocator_v2) + void priv_reserve_no_capacity(size_type new_cap, version_2) { //There is not enough memory, allocate a new //buffer or expand the old one. bool same_buffer_start; size_type real_cap = 0; - std::pair ret = this->m_holder.allocation_command - (allocate_new | expand_fwd | expand_bwd, new_cap, new_cap, real_cap, this->m_holder.start()); + pointer reuse = 0; + pointer const ret(this->m_holder.allocation_command(allocate_new | expand_fwd | expand_bwd, new_cap, real_cap = new_cap, reuse)); //Check for forward expansion - same_buffer_start = ret.second && this->m_holder.start() == ret.first; + same_buffer_start = reuse && this->m_holder.start() == ret; if(same_buffer_start){ #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_expand_fwd; @@ -2023,9 +2513,9 @@ class vector this->m_holder.capacity(real_cap); } else{ //If there is no forward expansion, move objects, we will reuse insertion code - T * const new_mem = container_detail::to_raw_pointer(ret.first); - T * const ins_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; - if(ret.second){ //Backwards (and possibly forward) expansion + T * const new_mem = container_detail::to_raw_pointer(ret); + T * const ins_pos = this->back_raw(); + if(reuse){ //Backwards (and possibly forward) expansion #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_expand_bwd; #endif @@ -2042,26 +2532,17 @@ class vector } } - void priv_destroy_last() BOOST_CONTAINER_NOEXCEPT + void priv_destroy_last(const bool moved = false) BOOST_NOEXCEPT_OR_NOTHROW { - if(!value_traits::trivial_dctr){ - value_type* const p = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size - 1; + (void)moved; + if(!(value_traits::trivial_dctr || (value_traits::trivial_dctr_after_move && moved))){ + value_type* const p = this->back_raw() - 1; allocator_traits_type::destroy(this->get_stored_allocator(), p); } --this->m_holder.m_size; } - void priv_destroy_last(const bool moved) BOOST_CONTAINER_NOEXCEPT - { - (void)moved; - if(!(value_traits::trivial_dctr || (value_traits::trivial_dctr_after_move && moved))){ - value_type* const p = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size - 1; - allocator_traits_type::destroy(this->get_stored_allocator(), p); - } - --this->m_holder.m_size; - } - - void priv_destroy_last_n(const size_type n) BOOST_CONTAINER_NOEXCEPT + void priv_destroy_last_n(const size_type n) BOOST_NOEXCEPT_OR_NOTHROW { BOOST_ASSERT(n <= this->m_holder.m_size); if(!value_traits::trivial_dctr){ @@ -2071,26 +2552,15 @@ class vector this->m_holder.m_size -= n; } - void priv_destroy_last_n(const size_type n, const bool moved) BOOST_CONTAINER_NOEXCEPT - { - BOOST_ASSERT(n <= this->m_holder.m_size); - (void)moved; - if(!(value_traits::trivial_dctr || (value_traits::trivial_dctr_after_move && moved))){ - T* const destroy_pos = container_detail::to_raw_pointer(this->m_holder.start()) + (this->m_holder.m_size-n); - boost::container::destroy_alloc_n(this->get_stored_allocator(), destroy_pos, n); - } - this->m_holder.m_size -= n; - } - template void priv_uninitialized_construct_at_end(InpIt first, InpIt last) { - T* const old_end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; + T* const old_end_pos = this->back_raw(); T* const new_end_pos = boost::container::uninitialized_copy_alloc(this->m_holder.alloc(), first, last, old_end_pos); this->m_holder.m_size += new_end_pos - old_end_pos; } - void priv_destroy_all() BOOST_CONTAINER_NOEXCEPT + void priv_destroy_all() BOOST_NOEXCEPT_OR_NOTHROW { boost::container::destroy_alloc_n (this->get_stored_allocator(), container_detail::to_raw_pointer(this->m_holder.start()), this->m_holder.m_size); @@ -2101,8 +2571,7 @@ class vector iterator priv_insert(const const_iterator &p, BOOST_FWD_REF(U) x) { return this->priv_forward_range_insert - ( vector_iterator_get_ptr(p), 1, container_detail::get_insert_value_proxy - (::boost::forward(x)), alloc_version()); + ( vector_iterator_get_ptr(p), 1, container_detail::get_insert_value_proxy(::boost::forward(x))); } container_detail::insert_copy_proxy priv_single_insert_proxy(const T &x) @@ -2114,7 +2583,7 @@ class vector template void priv_push_back(BOOST_FWD_REF(U) u) { - if (BOOST_LIKELY(this->m_holder.m_size < this->m_holder.capacity())){ + if (BOOST_LIKELY(this->room_enough())){ //There is more memory, just construct a new object at the end allocator_traits_type::construct ( this->m_holder.alloc() @@ -2124,7 +2593,7 @@ class vector } else{ this->priv_forward_range_insert_no_capacity - ( vector_iterator_get_ptr(this->cend()), 1 + ( this->back_ptr(), 1 , this->priv_single_insert_proxy(::boost::forward(u)), alloc_version()); } } @@ -2152,10 +2621,10 @@ class vector } } - void priv_shrink_to_fit(allocator_v0) BOOST_CONTAINER_NOEXCEPT + void priv_shrink_to_fit(version_0) BOOST_NOEXCEPT_OR_NOTHROW {} - void priv_shrink_to_fit(allocator_v1) + void priv_shrink_to_fit(version_1) { const size_type cp = this->m_holder.capacity(); if(cp){ @@ -2167,7 +2636,8 @@ class vector } else if(sz < cp){ //Allocate a new buffer. - pointer p = this->m_holder.allocate(sz); + //Pass the hint so that allocators can take advantage of this. + pointer const p = allocator_traits_type::allocate(this->m_holder.alloc(), sz, this->m_holder.m_start); //We will reuse insert code, so create a dummy input iterator #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS @@ -2181,7 +2651,7 @@ class vector } } - void priv_shrink_to_fit(allocator_v2) BOOST_CONTAINER_NOEXCEPT + void priv_shrink_to_fit(version_2) BOOST_NOEXCEPT_OR_NOTHROW { const size_type cp = this->m_holder.capacity(); if(cp){ @@ -2192,10 +2662,10 @@ class vector this->m_holder.m_capacity = 0; } else{ - size_type received_size; + size_type received_size = sz; + pointer reuse(this->m_holder.start()); if(this->m_holder.allocation_command - ( shrink_in_place | nothrow_allocation - , cp, sz, received_size, this->m_holder.start()).first){ + (shrink_in_place | nothrow_allocation, cp, received_size, reuse)){ this->m_holder.capacity(received_size); #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_shrink; @@ -2207,7 +2677,7 @@ class vector template iterator priv_forward_range_insert_no_capacity - (const pointer &pos, const size_type, const InsertionProxy , allocator_v0) + (const pointer &pos, const size_type, const InsertionProxy , version_0) { throw_bad_alloc(); return iterator(pos); @@ -2215,14 +2685,15 @@ class vector template iterator priv_forward_range_insert_no_capacity - (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v1) + (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, version_1) { //Check if we have enough memory or try to expand current memory const size_type n_pos = pos - this->m_holder.start(); T *const raw_pos = container_detail::to_raw_pointer(pos); const size_type new_cap = this->m_holder.next_capacity(n); - T * new_buf = container_detail::to_raw_pointer(this->m_holder.alloc().allocate(new_cap)); + //Pass the hint so that allocators can take advantage of this. + T * const new_buf = container_detail::to_raw_pointer(allocator_traits_type::allocate(this->m_holder.alloc(), new_cap, this->m_holder.m_start)); #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_alloc; #endif @@ -2233,23 +2704,23 @@ class vector template iterator priv_forward_range_insert_no_capacity - (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v2) + (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, version_2) { //Check if we have enough memory or try to expand current memory T *const raw_pos = container_detail::to_raw_pointer(pos); const size_type n_pos = raw_pos - container_detail::to_raw_pointer(this->m_holder.start()); - size_type real_cap = 0; //There is not enough memory, allocate a new //buffer or expand the old one. - std::pair ret = (this->m_holder.allocation_command - (allocate_new | expand_fwd | expand_bwd, - this->m_holder.m_size + n, this->m_holder.next_capacity(n), real_cap, this->m_holder.start())); + size_type real_cap = this->m_holder.next_capacity(n); + pointer reuse(this->m_holder.start()); + pointer const ret (this->m_holder.allocation_command + (allocate_new | expand_fwd | expand_bwd, this->m_holder.m_size + n, real_cap, reuse)); //Buffer reallocated - if(ret.second){ + if(reuse){ //Forward expansion, delay insertion - if(this->m_holder.start() == ret.first){ + if(this->m_holder.start() == ret){ #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_expand_fwd; #endif @@ -2263,8 +2734,7 @@ class vector ++this->num_expand_bwd; #endif this->priv_forward_range_insert_expand_backwards - ( container_detail::to_raw_pointer(ret.first) - , real_cap, raw_pos, n, insert_range_proxy); + (container_detail::to_raw_pointer(ret), real_cap, raw_pos, n, insert_range_proxy); } } //New buffer @@ -2273,8 +2743,7 @@ class vector ++this->num_alloc; #endif this->priv_forward_range_insert_new_allocation - ( container_detail::to_raw_pointer(ret.first) - , real_cap, raw_pos, n, insert_range_proxy); + ( container_detail::to_raw_pointer(ret), real_cap, raw_pos, n, insert_range_proxy); } return iterator(this->m_holder.start() + n_pos); @@ -2282,42 +2751,7 @@ class vector template iterator priv_forward_range_insert - (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v0) - { - //Check if we have enough memory or try to expand current memory - const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; - - if (n > remaining){ - //This will trigger an error - throw_bad_alloc(); - } - const size_type n_pos = pos - this->m_holder.start(); - T *const raw_pos = container_detail::to_raw_pointer(pos); - this->priv_forward_range_insert_expand_forward(raw_pos, n, insert_range_proxy); - return iterator(this->m_holder.start() + n_pos); - } - - template - iterator priv_forward_range_insert - (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v1) - { - //Check if we have enough memory or try to expand current memory - const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; - T *const raw_pos = container_detail::to_raw_pointer(pos); - - if (n <= remaining){ - const size_type n_pos = raw_pos - container_detail::to_raw_pointer(this->m_holder.start()); - this->priv_forward_range_insert_expand_forward(raw_pos, n, insert_range_proxy); - return iterator(this->m_holder.start() + n_pos); - } - else{ - return this->priv_forward_range_insert_no_capacity(pos, n, insert_range_proxy, alloc_version()); - } - } - - template - iterator priv_forward_range_insert - (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v2) + (const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy) { BOOST_ASSERT(this->m_holder.capacity() >= this->m_holder.m_size); //Check if we have enough memory or try to expand current memory @@ -2338,7 +2772,7 @@ class vector template iterator priv_forward_range_insert_at_end - (const size_type n, const InsertionProxy insert_range_proxy, allocator_v0) + (const size_type n, const InsertionProxy insert_range_proxy, version_0) { //Check if we have enough memory or try to expand current memory const size_type remaining = this->m_holder.capacity() - this->m_holder.m_size; @@ -2351,81 +2785,11 @@ class vector return this->end(); } - template + template iterator priv_forward_range_insert_at_end - (const size_type n, const InsertionProxy insert_range_proxy, allocator_v1) + (const size_type n, const InsertionProxy insert_range_proxy, AllocVersion) { - return this->priv_forward_range_insert(vector_iterator_get_ptr(this->cend()), n, insert_range_proxy, allocator_v1()); - } - - template - iterator priv_forward_range_insert_at_end - (const size_type n, const InsertionProxy insert_range_proxy, allocator_v2) - { - return this->priv_forward_range_insert(vector_iterator_get_ptr(this->cend()), n, insert_range_proxy, allocator_v2()); - } - - //Absolutely experimental. This function might change, disappear or simply crash! - template - void priv_insert_ordered_at( size_type element_count, BiDirPosConstIt last_position_it - , bool do_skip, BiDirSkipConstIt last_skip_it, BiDirValueIt last_value_it) - { - const size_type old_size_pos = this->size(); - this->reserve(old_size_pos + element_count); - T* const begin_ptr = container_detail::to_raw_pointer(this->m_holder.start()); - size_type insertions_left = element_count; - size_type next_pos = old_size_pos; - size_type hole_size = element_count; - - //Exception rollback. If any copy throws before the hole is filled, values - //already inserted/copied at the end of the buffer will be destroyed. - typename value_traits::ArrayDestructor past_hole_values_destroyer - (begin_ptr + old_size_pos + element_count, this->m_holder.alloc(), size_type(0u)); - //Loop for each insertion backwards, first moving the elements after the insertion point, - //then inserting the element. - while(insertions_left){ - if(do_skip){ - size_type n = *(--last_skip_it); - std::advance(last_value_it, -difference_type(n)); - } - const size_type pos = static_cast(*(--last_position_it)); - BOOST_ASSERT(pos <= old_size_pos); - //If needed shift the range after the insertion point and the previous insertion point. - //Function will take care if the shift crosses the size() boundary, using copy/move - //or uninitialized copy/move if necessary. - size_type new_hole_size = (pos != next_pos) - ? priv_insert_ordered_at_shift_range(pos, next_pos, this->size(), insertions_left) - : hole_size - ; - if(new_hole_size > 0){ - //The hole was reduced by priv_insert_ordered_at_shift_range so expand exception rollback range backwards - past_hole_values_destroyer.increment_size_backwards(next_pos - pos); - //Insert the new value in the hole - allocator_traits_type::construct(this->m_holder.alloc(), begin_ptr + pos + insertions_left - 1, *(--last_value_it)); - --new_hole_size; - if(new_hole_size == 0){ - //Hole was just filled, disable exception rollback and change vector size - past_hole_values_destroyer.release(); - this->m_holder.m_size += element_count; - } - else{ - //The hole was reduced by the new insertion by one - past_hole_values_destroyer.increment_size_backwards(size_type(1u)); - } - } - else{ - if(hole_size){ - //Hole was just filled by priv_insert_ordered_at_shift_range, disable exception rollback and change vector size - past_hole_values_destroyer.release(); - this->m_holder.m_size += element_count; - } - //Insert the new value in the already constructed range - begin_ptr[pos + insertions_left - 1] = *(--last_value_it); - } - --insertions_left; - hole_size = new_hole_size; - next_pos = pos; - } + return this->priv_forward_range_insert(this->back_ptr(), n, insert_range_proxy); } //Takes the range pointed by [first_pos, last_pos) and shifts it to the right @@ -2446,7 +2810,7 @@ class vector //| prefix | range | suffix |raw_mem ~ //|____________|_______|__________________|_____________~ // - //New situation in Case Allocator (hole_size == 0): + //New situation in Case A (hole_size == 0): // range is moved through move assignments // // first_pos last_pos limit_pos @@ -2458,7 +2822,7 @@ class vector // |_>_>_>_>_>^ // // - //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 limit_pos @@ -2493,14 +2857,14 @@ class vector //Case A: if((last_pos + shift_count) <= limit_pos){ //All move assigned - boost::move_backward(first_ptr, last_ptr, last_ptr + shift_count); + boost::container::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->m_holder.alloc(), first_ptr, last_ptr, first_ptr + shift_count); - hole_size = last_pos + shift_count - limit_pos; + hole_size = first_pos + shift_count - limit_pos; } //Case C: else{ @@ -2509,7 +2873,7 @@ class vector T* const boundary_ptr = limit_ptr - shift_count; ::boost::container::uninitialized_move_alloc(this->m_holder.alloc(), boundary_ptr, last_ptr, limit_ptr); //The rest is move assigned - boost::move_backward(first_ptr, boundary_ptr, limit_ptr); + boost::container::move_backward(first_ptr, boundary_ptr, limit_ptr); } return hole_size; } @@ -2518,7 +2882,7 @@ class vector template void priv_forward_range_insert_at_end_expand_forward(const size_type n, InsertionProxy insert_range_proxy) { - T* const old_finish = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; + T* const old_finish = this->back_raw(); insert_range_proxy.uninitialized_copy_n_and_update(this->m_holder.alloc(), old_finish, n); this->m_holder.m_size += n; } @@ -2527,9 +2891,9 @@ class vector void priv_forward_range_insert_expand_forward(T* const pos, const size_type n, InsertionProxy insert_range_proxy) { //n can't be 0, because there is nothing to do in that case - if(!n) return; + if(BOOST_UNLIKELY(!n)) return; //There is enough memory - T* const old_finish = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; + T* const old_finish = this->back_raw(); const size_type elems_after = old_finish - pos; if (!elems_after){ @@ -2543,7 +2907,7 @@ class vector (this->m_holder.alloc(), old_finish - n, old_finish, old_finish); this->m_holder.m_size += n; //Copy previous to last objects to the initialized end - boost::move_backward(pos, old_finish - n, old_finish); + boost::container::move_backward(pos, old_finish - n, old_finish); //Insert new objects in the pos insert_range_proxy.copy_n_and_update(this->m_holder.alloc(), pos, n); } @@ -2694,7 +3058,7 @@ class vector old_values_destroyer.shrink_forward(new_size-s_before); this->m_holder.m_size = new_size; //Now move remaining last objects in the old buffer begin - ::boost::move(pos + raw_gap, old_finish, old_start); + ::boost::container::move(pos + raw_gap, old_finish, old_start); //Once moved, avoid calling the destructors if trivial after move if(value_traits::trivial_dctr_after_move){ old_values_destroyer.release(); @@ -2778,14 +3142,14 @@ class vector } this->m_holder.m_size = old_size + new_1st_range; //Now copy the second part of old_begin overwriting itself - T *const next = ::boost::move(old_start + s_before, pos, old_start); + T *const next = ::boost::container::move(old_start + s_before, pos, old_start); //Now copy the new_beg elements insert_range_proxy.copy_n_and_update(this->m_holder.alloc(), next, new_1st_range); //If there is no after work and the last old part needs to be moved to front, do it if(!do_after && (n != s_before)){ //Now displace old_end elements - ::boost::move(pos, old_finish, next + new_1st_range); + ::boost::container::move(pos, old_finish, next + new_1st_range); } } else { @@ -2835,7 +3199,7 @@ class vector insert_range_proxy.copy_n_and_update(this->m_holder.alloc(), old_start, rest_new); T* const move_start = old_start + rest_new; //Displace old_end - T* const move_end = ::boost::move(pos, old_finish, move_start); + T* const move_end = ::boost::container::move(pos, old_finish, move_start); //Destroy remaining moved elements from old_end except if they //have trivial destructor after being moved size_type n_destroy = s_before - n; @@ -2887,7 +3251,7 @@ class vector (this->m_holder.alloc(), finish_n, old_finish, old_finish); this->m_holder.m_size += n_after; //Displace the rest of old_end to the new position - boost::move_backward(pos, finish_n, old_finish); + boost::container::move_backward(pos, finish_n, old_finish); //Now overwrite with new_end //The new_end part is [first + (n - n_after), last) insert_range_proxy.copy_n_and_update(this->m_holder.alloc(), pos, n_after); @@ -2947,36 +3311,24 @@ class vector #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED }; -}} +}} //namespace boost::container #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED namespace boost { -/* //!has_trivial_destructor_after_move<> == true_type //!specialization for optimizations template struct has_trivial_destructor_after_move > - : public ::boost::has_trivial_destructor_after_move -{}; -*/ +{ + typedef typename ::boost::container::allocator_traits::pointer pointer; + static const bool value = ::boost::has_trivial_destructor_after_move::value && + ::boost::has_trivial_destructor_after_move::value; +}; + } -//#define BOOST_CONTAINER_PUT_SWAP_OVERLOAD_IN_NAMESPACE_STD - -#ifdef BOOST_CONTAINER_PUT_SWAP_OVERLOAD_IN_NAMESPACE_STD - -namespace std { - -template -inline void swap(boost::container::vector& x, boost::container::vector& y) -{ x.swap(y); } - -} //namespace std { - -#endif - #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #include diff --git a/boost/core/addressof.hpp b/boost/core/addressof.hpp index 6a770e2..889b582 100644 --- a/boost/core/addressof.hpp +++ b/boost/core/addressof.hpp @@ -107,7 +107,7 @@ template BOOST_FORCEINLINE T * addressof( T & v ) { -#if (defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) ) || defined( __SUNPRO_CC ) +#if (defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) ) || (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5120)) return boost::detail::addressof_impl::f( v, 0 ); diff --git a/boost/core/demangle.hpp b/boost/core/demangle.hpp deleted file mode 100644 index eebd0ce..0000000 --- a/boost/core/demangle.hpp +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED -#define BOOST_CORE_DEMANGLE_HPP_INCLUDED - -// core::demangle -// -// Copyright 2014 Peter Dimov -// Copyright 2014 Andrey Semashev -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt - -#include -#include - -#if defined(BOOST_HAS_PRAGMA_ONCE) -# pragma once -#endif - -#if defined( __clang__ ) && defined( __has_include ) -# if __has_include() -# define BOOST_CORE_HAS_CXXABI_H -# endif -#elif defined( __GLIBCXX__ ) || defined( __GLIBCPP__ ) -# define BOOST_CORE_HAS_CXXABI_H -#endif - -#if defined( BOOST_CORE_HAS_CXXABI_H ) -# include -# include -# include -#endif - -namespace boost -{ - -namespace core -{ - -inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT; -inline void demangle_free( char const * name ) BOOST_NOEXCEPT; - -class scoped_demangled_name -{ -private: - char const * m_p; - -public: - explicit scoped_demangled_name( char const * name ) BOOST_NOEXCEPT : - m_p( demangle_alloc( name ) ) - { - } - - ~scoped_demangled_name() BOOST_NOEXCEPT - { - demangle_free( m_p ); - } - - char const * get() const BOOST_NOEXCEPT - { - return m_p; - } - - BOOST_DELETED_FUNCTION(scoped_demangled_name( scoped_demangled_name const& )) - BOOST_DELETED_FUNCTION(scoped_demangled_name& operator= ( scoped_demangled_name const& )) -}; - - -#if defined( BOOST_CORE_HAS_CXXABI_H ) - -inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT -{ - int status = 0; - std::size_t size = 0; - return abi::__cxa_demangle( name, NULL, &size, &status ); -} - -inline void demangle_free( char const * name ) BOOST_NOEXCEPT -{ - std::free( const_cast< char* >( name ) ); -} - -inline std::string demangle( char const * name ) -{ - scoped_demangled_name demangled_name( name ); - char const * const p = demangled_name.get(); - if( p ) - { - return p; - } - else - { - return name; - } -} - -#else - -inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT -{ - return name; -} - -inline void demangle_free( char const * ) BOOST_NOEXCEPT -{ -} - -inline std::string demangle( char const * name ) -{ - return name; -} - -#endif - -} // namespace core - -} // namespace boost - -#undef BOOST_CORE_HAS_CXXABI_H - -#endif // #ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED diff --git a/boost/core/explicit_operator_bool.hpp b/boost/core/explicit_operator_bool.hpp deleted file mode 100644 index a8936e2..0000000 --- a/boost/core/explicit_operator_bool.hpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright Andrey Semashev 2007 - 2013. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ - -/*! - * \file explicit_operator_bool.hpp - * \author Andrey Semashev - * \date 08.03.2009 - * - * This header defines a compatibility macro that implements an unspecified - * \c bool operator idiom, which is superseded with explicit conversion operators in - * C++11. - */ - -#ifndef BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP -#define BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) - -/*! - * \brief The macro defines an explicit operator of conversion to \c bool - * - * The macro should be used inside the definition of a class that has to - * support the conversion. The class should also implement operator!, - * in terms of which the conversion operator will be implemented. - */ -#define BOOST_EXPLICIT_OPERATOR_BOOL()\ - BOOST_FORCEINLINE explicit operator bool () const\ - {\ - return !this->operator! ();\ - } - -/*! - * \brief The macro defines a noexcept explicit operator of conversion to \c bool - * - * The macro should be used inside the definition of a class that has to - * support the conversion. The class should also implement operator!, - * in terms of which the conversion operator will be implemented. - */ -#define BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()\ - BOOST_FORCEINLINE explicit operator bool () const BOOST_NOEXCEPT\ - {\ - return !this->operator! ();\ - } - -/*! - * \brief The macro defines a constexpr explicit operator of conversion to \c bool - * - * The macro should be used inside the definition of a class that has to - * support the conversion. The class should also implement operator!, - * in terms of which the conversion operator will be implemented. - */ -#define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()\ - BOOST_FORCEINLINE BOOST_CONSTEXPR explicit operator bool () const BOOST_NOEXCEPT\ - {\ - return !this->operator! ();\ - } - -#else // !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) - -#if (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)) && !defined(BOOST_NO_COMPILER_CONFIG) -// Sun C++ 5.3 can't handle the safe_bool idiom, so don't use it -#define BOOST_NO_UNSPECIFIED_BOOL -#endif // (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)) && !defined(BOOST_NO_COMPILER_CONFIG) - -#if !defined(BOOST_NO_UNSPECIFIED_BOOL) - -namespace boost { - -namespace detail { - -#if !defined(_MSC_VER) && !defined(__IBMCPP__) - - struct unspecified_bool - { - // NOTE TO THE USER: If you see this in error messages then you tried - // to apply an unsupported operator on the object that supports - // explicit conversion to bool. - struct OPERATORS_NOT_ALLOWED; - static void true_value(OPERATORS_NOT_ALLOWED*) {} - }; - typedef void (*unspecified_bool_type)(unspecified_bool::OPERATORS_NOT_ALLOWED*); - -#else - - // MSVC and VACPP are too eager to convert pointer to function to void* even though they shouldn't - struct unspecified_bool - { - // NOTE TO THE USER: If you see this in error messages then you tried - // to apply an unsupported operator on the object that supports - // explicit conversion to bool. - struct OPERATORS_NOT_ALLOWED; - void true_value(OPERATORS_NOT_ALLOWED*) {} - }; - typedef void (unspecified_bool::*unspecified_bool_type)(unspecified_bool::OPERATORS_NOT_ALLOWED*); - -#endif - -} // namespace detail - -} // namespace boost - -#define BOOST_EXPLICIT_OPERATOR_BOOL()\ - BOOST_FORCEINLINE operator boost::detail::unspecified_bool_type () const\ - {\ - return (!this->operator! () ? &boost::detail::unspecified_bool::true_value : (boost::detail::unspecified_bool_type)0);\ - } - -#define BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()\ - BOOST_FORCEINLINE operator boost::detail::unspecified_bool_type () const BOOST_NOEXCEPT\ - {\ - return (!this->operator! () ? &boost::detail::unspecified_bool::true_value : (boost::detail::unspecified_bool_type)0);\ - } - -#define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()\ - BOOST_FORCEINLINE BOOST_CONSTEXPR operator boost::detail::unspecified_bool_type () const BOOST_NOEXCEPT\ - {\ - return (!this->operator! () ? &boost::detail::unspecified_bool::true_value : (boost::detail::unspecified_bool_type)0);\ - } - -#else // !defined(BOOST_NO_UNSPECIFIED_BOOL) - -#define BOOST_EXPLICIT_OPERATOR_BOOL()\ - BOOST_FORCEINLINE operator bool () const\ - {\ - return !this->operator! ();\ - } - -#define BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()\ - BOOST_FORCEINLINE operator bool () const BOOST_NOEXCEPT\ - {\ - return !this->operator! ();\ - } - -#define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()\ - BOOST_FORCEINLINE BOOST_CONSTEXPR operator bool () const BOOST_NOEXCEPT\ - {\ - return !this->operator! ();\ - } - -#endif // !defined(BOOST_NO_UNSPECIFIED_BOOL) - -#endif // !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) - -#endif // BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP diff --git a/boost/core/ignore_unused.hpp b/boost/core/ignore_unused.hpp deleted file mode 100644 index 22047c2..0000000 --- a/boost/core/ignore_unused.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. -// -// Use, modification and distribution is 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) - -#ifndef BOOST_CORE_IGNORE_UNUSED_HPP -#define BOOST_CORE_IGNORE_UNUSED_HPP - -#include - -namespace boost { - -#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES - -template -inline void ignore_unused(Ts const& ...) -{} - -template -inline void ignore_unused() -{} - -#else - -template -inline void ignore_unused(T1 const&) -{} - -template -inline void ignore_unused(T1 const&, T2 const&) -{} - -template -inline void ignore_unused(T1 const&, T2 const&, T3 const&) -{} - -template -inline void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&) -{} - -template -inline void ignore_unused(T1 const&, T2 const&, T3 const&, T4 const&, T5 const&) -{} - -template -inline void ignore_unused() -{} - -template -inline void ignore_unused() -{} - -template -inline void ignore_unused() -{} - -template -inline void ignore_unused() -{} - -template -inline void ignore_unused() -{} - -#endif - -} // namespace boost - -#endif // BOOST_CORE_IGNORE_UNUSED_HPP diff --git a/boost/core/is_same.hpp b/boost/core/is_same.hpp deleted file mode 100644 index f373c65..0000000 --- a/boost/core/is_same.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef BOOST_CORE_IS_SAME_HPP_INCLUDED -#define BOOST_CORE_IS_SAME_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// is_same::value is true when T1 == T2 -// -// Copyright 2014 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt - -#include - -namespace boost -{ - -namespace core -{ - -template< class T1, class T2 > struct is_same -{ - BOOST_STATIC_CONSTANT( bool, value = false ); -}; - -template< class T > struct is_same< T, T > -{ - BOOST_STATIC_CONSTANT( bool, value = true ); -}; - -} // namespace core - -} // namespace boost - -#endif // #ifndef BOOST_CORE_IS_SAME_HPP_INCLUDED diff --git a/boost/core/lightweight_test.hpp b/boost/core/lightweight_test.hpp deleted file mode 100644 index f5943b3..0000000 --- a/boost/core/lightweight_test.hpp +++ /dev/null @@ -1,171 +0,0 @@ -#ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP -#define BOOST_CORE_LIGHTWEIGHT_TEST_HPP - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) -# pragma once -#endif - -// -// boost/core/lightweight_test.hpp - lightweight test library -// -// Copyright (c) 2002, 2009, 2014 Peter Dimov -// Copyright (2) Beman Dawes 2010, 2011 -// Copyright (3) Ion Gaztanaga 2013 -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt -// - -#include -#include -#include -#include - -// IDE's like Visual Studio perform better if output goes to std::cout or -// some other stream, so allow user to configure output stream: -#ifndef BOOST_LIGHTWEIGHT_TEST_OSTREAM -# define BOOST_LIGHTWEIGHT_TEST_OSTREAM std::cerr -#endif - -namespace boost -{ - -namespace detail -{ - -struct report_errors_reminder -{ - bool called_report_errors_function; - - report_errors_reminder() : called_report_errors_function(false) {} - - ~report_errors_reminder() - { - BOOST_ASSERT(called_report_errors_function); // verify report_errors() was called - } -}; - -inline report_errors_reminder& report_errors_remind() -{ - static report_errors_reminder r; - return r; -} - -inline int & test_errors() -{ - static int x = 0; - report_errors_remind(); - return x; -} - -inline void test_failed_impl(char const * expr, char const * file, int line, char const * function) -{ - BOOST_LIGHTWEIGHT_TEST_OSTREAM - << file << "(" << line << "): test '" << expr << "' failed in function '" - << function << "'" << std::endl; - ++test_errors(); -} - -inline void error_impl(char const * msg, char const * file, int line, char const * function) -{ - BOOST_LIGHTWEIGHT_TEST_OSTREAM - << file << "(" << line << "): " << msg << " in function '" - << function << "'" << std::endl; - ++test_errors(); -} - -inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function) -{ - BOOST_LIGHTWEIGHT_TEST_OSTREAM - << file << "(" << line << "): Exception '" << excep << "' not thrown in function '" - << function << "'" << std::endl; - ++test_errors(); -} - -template inline void test_eq_impl( char const * expr1, char const * expr2, - char const * file, int line, char const * function, T const & t, U const & u ) -{ - if( t == u ) - { - report_errors_remind(); - } - else - { - BOOST_LIGHTWEIGHT_TEST_OSTREAM - << file << "(" << line << "): test '" << expr1 << " == " << expr2 - << "' failed in function '" << function << "': " - << "'" << t << "' != '" << u << "'" << std::endl; - ++test_errors(); - } -} - -template inline void test_ne_impl( char const * expr1, char const * expr2, - char const * file, int line, char const * function, T const & t, U const & u ) -{ - if( t != u ) - { - report_errors_remind(); - } - else - { - BOOST_LIGHTWEIGHT_TEST_OSTREAM - << file << "(" << line << "): test '" << expr1 << " != " << expr2 - << "' failed in function '" << function << "': " - << "'" << t << "' == '" << u << "'" << std::endl; - ++test_errors(); - } -} - -} // namespace detail - -inline int report_errors() -{ - detail::report_errors_remind().called_report_errors_function = true; - - int errors = detail::test_errors(); - - if( errors == 0 ) - { - BOOST_LIGHTWEIGHT_TEST_OSTREAM - << "No errors detected." << std::endl; - return 0; - } - else - { - BOOST_LIGHTWEIGHT_TEST_OSTREAM - << errors << " error" << (errors == 1? "": "s") << " detected." << std::endl; - return 1; - } -} - -} // namespace boost - -#define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)) - -#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) ) - -#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) -#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) - -#ifndef BOOST_NO_EXCEPTIONS - #define BOOST_TEST_THROWS( EXPR, EXCEP ) \ - try { \ - EXPR; \ - ::boost::detail::throw_failed_impl \ - (#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ - } \ - catch(EXCEP const&) { \ - } \ - catch(...) { \ - ::boost::detail::throw_failed_impl \ - (#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ - } \ - // -#else - #define BOOST_TEST_THROWS( EXPR, EXCEP ) -#endif - -#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP diff --git a/boost/core/lightweight_test_trait.hpp b/boost/core/lightweight_test_trait.hpp deleted file mode 100644 index 0e2aab4..0000000 --- a/boost/core/lightweight_test_trait.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP -#define BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) -# pragma once -#endif - -// boost/core/lightweight_test_trait.hpp -// -// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE -// -// Copyright 2014 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt - -#include -#include - -namespace boost -{ - -namespace detail -{ - -template< class T > inline void test_trait_impl( char const * trait, void (*)( T ), - bool expected, char const * file, int line, char const * function ) -{ - if( T::value == expected ) - { - report_errors_remind(); - } - else - { - BOOST_LIGHTWEIGHT_TEST_OSTREAM - << file << "(" << line << "): predicate '" << trait << "' [" - << boost::core::demangled_name( BOOST_CORE_TYPEID(T) ) << "]" - << " test failed in function '" << function - << "' (should have been " << ( expected? "true": "false" ) << ")" - << std::endl; - - ++test_errors(); - } -} - -} // namespace detail - -} // namespace boost - -#define BOOST_TEST_TRAIT_TRUE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, true, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) ) -#define BOOST_TEST_TRAIT_FALSE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, false, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) ) - -#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP diff --git a/boost/core/null_deleter.hpp b/boost/core/null_deleter.hpp deleted file mode 100644 index f0af590..0000000 --- a/boost/core/null_deleter.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright Andrey Semashev 2007 - 2014. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -/*! - * \file null_deleter.hpp - * \author Andrey Semashev - * \date 22.04.2007 - * - * This header contains a \c null_deleter implementation. This is an empty - * function object that receives a pointer and does nothing with it. - * Such empty deletion strategy may be convenient, for example, when - * constructing shared_ptrs that point to some object that should not be - * deleted (i.e. a variable on the stack or some global singleton, like std::cout). - */ - -#ifndef BOOST_CORE_NULL_DELETER_HPP -#define BOOST_CORE_NULL_DELETER_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { - -//! A function object that does nothing and can be used as an empty deleter for \c shared_ptr -struct null_deleter -{ - //! Function object result type - typedef void result_type; - /*! - * Does nothing - */ - template< typename T > - void operator() (T*) const BOOST_NOEXCEPT {} -}; - -} // namespace boost - -#endif // BOOST_CORE_NULL_DELETER_HPP diff --git a/boost/core/scoped_enum.hpp b/boost/core/scoped_enum.hpp deleted file mode 100644 index 78c548b..0000000 --- a/boost/core/scoped_enum.hpp +++ /dev/null @@ -1,192 +0,0 @@ -// scoped_enum.hpp ---------------------------------------------------------// - -// Copyright Beman Dawes, 2009 -// Copyright (C) 2011-2012 Vicente J. Botet Escriba -// Copyright (C) 2012 Anthony Williams - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - -#ifndef BOOST_CORE_SCOPED_ENUM_HPP -#define BOOST_CORE_SCOPED_ENUM_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ - -#ifdef BOOST_NO_CXX11_SCOPED_ENUMS - - /** - * Meta-function to get the native enum type associated to an enum class or its emulation. - */ - template - struct native_type - { - /** - * The member typedef type names the native enum type associated to the scoped enum, - * which is it self if the compiler supports scoped enums or EnumType::enum_type if it is an emulated scoped enum. - */ - typedef typename EnumType::enum_type type; - }; - - /** - * Casts a scoped enum to its underlying type. - * - * This function is useful when working with scoped enum classes, which doens't implicitly convert to the underlying type. - * @param v A scoped enum. - * @returns The underlying type. - * @throws No-throws. - */ - template - UnderlyingType underlying_cast(EnumType v) - { - return v.get_underlying_value_(); - } - - /** - * Casts a scoped enum to its native enum type. - * - * This function is useful to make programs portable when the scoped enum emulation can not be use where native enums can. - * - * EnumType the scoped enum type - * - * @param v A scoped enum. - * @returns The native enum value. - * @throws No-throws. - */ - template - inline - typename EnumType::enum_type native_value(EnumType e) - { - return e.get_native_value_(); - } - -#else // BOOST_NO_CXX11_SCOPED_ENUMS - - template - struct native_type - { - typedef EnumType type; - }; - - template - UnderlyingType underlying_cast(EnumType v) - { - return static_cast(v); - } - - template - inline - EnumType native_value(EnumType e) - { - return e; - } - -#endif // BOOST_NO_CXX11_SCOPED_ENUMS -} - - -#ifdef BOOST_NO_CXX11_SCOPED_ENUMS - -#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS - -#define BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \ - explicit operator underlying_type() const BOOST_NOEXCEPT { return get_underlying_value_(); } - -#else - -#define BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR - -#endif - -/** - * Start a declaration of a scoped enum. - * - * @param EnumType The new scoped enum. - * @param UnderlyingType The underlying type. - */ -#define BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType, UnderlyingType) \ - struct EnumType { \ - typedef void is_boost_scoped_enum_tag; \ - typedef UnderlyingType underlying_type; \ - EnumType() BOOST_NOEXCEPT {} \ - explicit EnumType(underlying_type v) BOOST_NOEXCEPT : v_(v) {} \ - underlying_type get_underlying_value_() const BOOST_NOEXCEPT { return v_; } \ - BOOST_SCOPED_ENUM_UT_DECLARE_CONVERSION_OPERATOR \ - private: \ - underlying_type v_; \ - typedef EnumType self_type; \ - public: \ - enum enum_type - -#define BOOST_SCOPED_ENUM_DECLARE_END2() \ - enum_type get_native_value_() const BOOST_NOEXCEPT { return enum_type(v_); } \ - friend bool operator ==(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)==enum_type(rhs.v_); } \ - friend bool operator ==(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)==rhs; } \ - friend bool operator ==(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs==enum_type(rhs.v_); } \ - friend bool operator !=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)!=enum_type(rhs.v_); } \ - friend bool operator !=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)!=rhs; } \ - friend bool operator !=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs!=enum_type(rhs.v_); } \ - friend bool operator <(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>enum_type(rhs.v_); } \ - friend bool operator >(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>rhs; } \ - friend bool operator >(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs>enum_type(rhs.v_); } \ - friend bool operator >=(self_type lhs, self_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>=enum_type(rhs.v_); } \ - friend bool operator >=(self_type lhs, enum_type rhs) BOOST_NOEXCEPT { return enum_type(lhs.v_)>=rhs; } \ - friend bool operator >=(enum_type lhs, self_type rhs) BOOST_NOEXCEPT { return lhs>=enum_type(rhs.v_); } \ - }; - -#define BOOST_SCOPED_ENUM_DECLARE_END(EnumType) \ - ; \ - EnumType(enum_type v) BOOST_NOEXCEPT : v_(v) {} \ - BOOST_SCOPED_ENUM_DECLARE_END2() - -/** - * Starts a declaration of a scoped enum with the default int underlying type. - * - * @param EnumType The new scoped enum. - */ -#define BOOST_SCOPED_ENUM_DECLARE_BEGIN(EnumType) \ - BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType,int) - -/** - * Name of the native enum type. - * - * @param EnumType The new scoped enum. - */ -#define BOOST_SCOPED_ENUM_NATIVE(EnumType) EnumType::enum_type -/** - * Forward declares an scoped enum. - * - * @param EnumType The scoped enum. - */ -#define BOOST_SCOPED_ENUM_FORWARD_DECLARE(EnumType) struct EnumType - -#else // BOOST_NO_CXX11_SCOPED_ENUMS - -#define BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(EnumType,UnderlyingType) enum class EnumType : UnderlyingType -#define BOOST_SCOPED_ENUM_DECLARE_BEGIN(EnumType) enum class EnumType -#define BOOST_SCOPED_ENUM_DECLARE_END2() -#define BOOST_SCOPED_ENUM_DECLARE_END(EnumType) ; - -#define BOOST_SCOPED_ENUM_NATIVE(EnumType) EnumType -#define BOOST_SCOPED_ENUM_FORWARD_DECLARE(EnumType) enum class EnumType - -#endif // BOOST_NO_CXX11_SCOPED_ENUMS - -// Deprecated macros -#define BOOST_SCOPED_ENUM_START(name) BOOST_SCOPED_ENUM_DECLARE_BEGIN(name) -#define BOOST_SCOPED_ENUM_END BOOST_SCOPED_ENUM_DECLARE_END2() -#define BOOST_SCOPED_ENUM(name) BOOST_SCOPED_ENUM_NATIVE(name) - -#endif // BOOST_CORE_SCOPED_ENUM_HPP diff --git a/boost/core/swap.hpp b/boost/core/swap.hpp deleted file mode 100644 index baa1be9..0000000 --- a/boost/core/swap.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin, Niels Dekker -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// For more information, see http://www.boost.org - - -#ifndef BOOST_CORE_SWAP_HPP -#define BOOST_CORE_SWAP_HPP - -// Note: the implementation of this utility contains various workarounds: -// - swap_impl is put outside the boost namespace, to avoid infinite -// recursion (causing stack overflow) when swapping objects of a primitive -// type. -// - swap_impl has a using-directive, rather than a using-declaration, -// because some compilers (including MSVC 7.1, Borland 5.9.3, and -// Intel 8.1) don't do argument-dependent lookup when it has a -// using-declaration instead. -// - boost::swap has two template arguments, instead of one, to -// avoid ambiguity when swapping objects of a Boost type that does -// not have its own boost::swap overload. - -#include //for std::swap (C++11) -#include //for std::swap (C++98) -#include //for std::size_t -#include - -namespace boost_swap_impl -{ - template - BOOST_GPU_ENABLED - void swap_impl(T& left, T& right) - { - using namespace std;//use std::swap if argument dependent lookup fails - swap(left,right); - } - - template - BOOST_GPU_ENABLED - void swap_impl(T (& left)[N], T (& right)[N]) - { - for (std::size_t i = 0; i < N; ++i) - { - ::boost_swap_impl::swap_impl(left[i], right[i]); - } - } -} - -namespace boost -{ - template - BOOST_GPU_ENABLED - void swap(T1& left, T2& right) - { - ::boost_swap_impl::swap_impl(left, right); - } -} - -#endif diff --git a/boost/core/typeinfo.hpp b/boost/core/typeinfo.hpp deleted file mode 100644 index e67b4a3..0000000 --- a/boost/core/typeinfo.hpp +++ /dev/null @@ -1,151 +0,0 @@ -#ifndef BOOST_CORE_TYPEINFO_HPP_INCLUDED -#define BOOST_CORE_TYPEINFO_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// core::typeinfo, BOOST_CORE_TYPEID -// -// Copyright 2007, 2014 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -#if defined( BOOST_NO_TYPEID ) - -#include -#include - -namespace boost -{ - -namespace core -{ - -class typeinfo -{ -private: - - typeinfo( typeinfo const& ); - typeinfo& operator=( typeinfo const& ); - - char const * name_; - -public: - - explicit typeinfo( char const * name ): name_( name ) - { - } - - bool operator==( typeinfo const& rhs ) const - { - return this == &rhs; - } - - bool operator!=( typeinfo const& rhs ) const - { - return this != &rhs; - } - - bool before( typeinfo const& rhs ) const - { - return std::less< typeinfo const* >()( this, &rhs ); - } - - char const* name() const - { - return name_; - } -}; - -inline char const * demangled_name( core::typeinfo const & ti ) -{ - return ti.name(); -} - -} // namespace core - -namespace detail -{ - -template struct core_typeid_ -{ - static boost::core::typeinfo ti_; - - static char const * name() - { - return BOOST_CURRENT_FUNCTION; - } -}; - -#if defined(__SUNPRO_CC) -// see #4199, the Sun Studio compiler gets confused about static initialization -// constructor arguments. But an assignment works just fine. -template boost::core::typeinfo core_typeid_< T >::ti_ = core_typeid_< T >::name(); -#else -template boost::core::typeinfo core_typeid_< T >::ti_(core_typeid_< T >::name()); -#endif - -template struct core_typeid_< T & >: core_typeid_< T > -{ -}; - -template struct core_typeid_< T const >: core_typeid_< T > -{ -}; - -template struct core_typeid_< T volatile >: core_typeid_< T > -{ -}; - -template struct core_typeid_< T const volatile >: core_typeid_< T > -{ -}; - -} // namespace detail - -} // namespace boost - -#define BOOST_CORE_TYPEID(T) (boost::detail::core_typeid_::ti_) - -#else - -#include -#include - -namespace boost -{ - -namespace core -{ - -#if defined( BOOST_NO_STD_TYPEINFO ) - -typedef ::type_info typeinfo; - -#else - -typedef std::type_info typeinfo; - -#endif - -inline std::string demangled_name( core::typeinfo const & ti ) -{ - return core::demangle( ti.name() ); -} - -} // namespace core - -} // namespace boost - -#define BOOST_CORE_TYPEID(T) typeid(T) - -#endif - -#endif // #ifndef BOOST_CORE_TYPEINFO_HPP_INCLUDED diff --git a/boost/core/underlying_type.hpp b/boost/core/underlying_type.hpp deleted file mode 100644 index 7ecba31..0000000 --- a/boost/core/underlying_type.hpp +++ /dev/null @@ -1,79 +0,0 @@ -// underlying_type.hpp ---------------------------------------------------------// - -// Copyright Beman Dawes, 2009 -// Copyright (C) 2011-2012 Vicente J. Botet Escriba -// Copyright (C) 2012 Anthony Williams -// Copyright (C) 2014 Andrey Semashev - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - -#ifndef BOOST_CORE_UNDERLYING_TYPE_HPP -#define BOOST_CORE_UNDERLYING_TYPE_HPP - -#include - -// GCC 4.7 and later seem to provide std::underlying_type -#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) || (defined(BOOST_GCC) && BOOST_GCC >= 40700 && defined(__GXX_EXPERIMENTAL_CXX0X__)) -#include -#define BOOST_DETAIL_HAS_STD_UNDERLYING_TYPE -#endif - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { - -namespace detail { - -template< typename EnumType, typename Void = void > -struct underlying_type_impl; - -#if defined(BOOST_NO_CXX11_SCOPED_ENUMS) - -// Support for boost/core/scoped_enum.hpp -template< typename EnumType > -struct underlying_type_impl< EnumType, typename EnumType::is_boost_scoped_enum_tag > -{ - /** - * The member typedef type names the underlying type of EnumType. It is EnumType::underlying_type when the EnumType is an emulated scoped enum, - */ - typedef typename EnumType::underlying_type type; -}; - -#endif - -#if defined(BOOST_DETAIL_HAS_STD_UNDERLYING_TYPE) - -template< typename EnumType, typename Void > -struct underlying_type_impl -{ - typedef typename std::underlying_type< EnumType >::type type; -}; - -#endif - -} // namespace detail - -#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS) && !defined(BOOST_DETAIL_HAS_STD_UNDERLYING_TYPE) -#define BOOST_NO_UNDERLYING_TYPE -#endif - -/** - * Meta-function to get the underlying type of a scoped enum. - * - * Requires EnumType must be an enum type or the emulation of a scoped enum. - * If BOOST_NO_UNDERLYING_TYPE is defined, the implementation will not be able - * to deduce the underlying type of enums. The user is expected to specialize - * this trait in this case. - */ -template< typename EnumType > -struct underlying_type : - public detail::underlying_type_impl< EnumType > -{ -}; - -} // namespace boost - -#endif // BOOST_CORE_UNDERLYING_TYPE_HPP diff --git a/boost/cregex.hpp b/boost/cregex.hpp deleted file mode 100644 index b7a918e..0000000 --- a/boost/cregex.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Copyright (c) 1998-2002 - * John Maddock - * - * 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) - * - */ - - /* - * LOCATION: see http://www.boost.org/libs/regex for most recent version. - * FILE cregex.cpp - * VERSION see - * DESCRIPTION: Declares POSIX API functions - * + boost::RegEx high level wrapper. - */ - -#ifndef BOOST_RE_CREGEX_HPP -#define BOOST_RE_CREGEX_HPP - -#ifndef BOOST_REGEX_CONFIG_HPP -#include -#endif - -#include - -#endif /* include guard */ - - - - - - - - - - diff --git a/boost/cstdfloat.hpp b/boost/cstdfloat.hpp deleted file mode 100644 index 0af4e41..0000000 --- a/boost/cstdfloat.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2014. -// Copyright John Maddock 2014. -// Copyright Paul Bristow 2014. -// Distributed under the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt -// or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -// implements floating-point typedefs having -// specified widths, as described in N3626 (proposed for C++14). -// See: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3626.pdf - -#ifndef _BOOST_CSTDFLOAT_2014_01_09_HPP_ - #define _BOOST_CSTDFLOAT_2014_01_09_HPP_ - - // Include the floating-point type definitions. - #include - - // Support a specialization of std::numeric_limits<> for the wrapped quadmath library (if available). - #if !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_LIMITS) - #include - #endif - - // Support functions for the wrapped quadmath library (if available). - #if !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_CMATH) - #include - #endif - - // Support I/O stream operations for the wrapped quadmath library (if available). - #if !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_IOSTREAM) - #if defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_CMATH) - #error You can not use with BOOST_CSTDFLOAT_NO_LIBQUADMATH_CMATH defined. - #endif - #include - #endif - - // Support a specialization of std::complex<> for the wrapped quadmath library (if available). - #if !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_COMPLEX) - #if defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_LIMITS) - #error You can not use with BOOST_CSTDFLOAT_NO_LIBQUADMATH_LIMITS defined. - #endif - #if defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_CMATH) - #error You can not use with BOOST_CSTDFLOAT_NO_LIBQUADMATH_CMATH defined. - #endif - #if defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_IOSTREAM) - #error You can not use with BOOST_CSTDFLOAT_NO_LIBQUADMATH_IOSTREAM defined. - #endif - #include - #endif - - - // Undefine BOOST_NO_FLOAT128_T because this constant is not meant for public use. - #if defined(BOOST_CSTDFLOAT_HAS_INTERNAL_FLOAT128_T) - #undef BOOST_CSTDFLOAT_HAS_INTERNAL_FLOAT128_T - #endif - -#endif // _BOOST_CSTDFLOAT_2014_01_09_HPP_ diff --git a/boost/cstdint.hpp b/boost/cstdint.hpp index 98faeae..6988835 100644 --- a/boost/cstdint.hpp +++ b/boost/cstdint.hpp @@ -140,7 +140,7 @@ namespace boost } // namespace boost -#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4) || defined(__osf__) || defined(__VMS) +#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4) || defined(__osf__) || defined(__VMS) || defined(__SOLARIS9__) || defined(__NetBSD__) // FreeBSD and Tru64 have an that contains much of what we need. # include @@ -374,7 +374,7 @@ namespace boost || (defined(_XOPEN_UNIX) && (_XOPEN_UNIX+0 > 0) && !defined(__UCLIBC__)) \ || defined(__CYGWIN__) \ || defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) \ - || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) + || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(sun) namespace boost { using ::intptr_t; @@ -492,7 +492,7 @@ INT#_C macros if they're not already defined (John Maddock). // 64-bit types + intmax_t and uintmax_t ----------------------------------// #ifndef INT64_C # if defined(BOOST_HAS_LONG_LONG) && \ - (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX) || defined(_LLONG_MAX)) + (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX) || defined(_ULLONG_MAX) || defined(_LLONG_MAX)) # if defined(__hpux) // HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions @@ -501,7 +501,8 @@ INT#_C macros if they're not already defined (John Maddock). # elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615ULL) || \ (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615ULL) || \ (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615ULL) || \ - (defined(_LLONG_MAX) && _LLONG_MAX == 18446744073709551615ULL) + (defined(_ULLONG_MAX) && _ULLONG_MAX == 18446744073709551615ULL) || \ + (defined(_LLONG_MAX) && _LLONG_MAX == 9223372036854775807LL) # define INT64_C(value) value##LL # define UINT64_C(value) value##uLL diff --git a/boost/cstdlib.hpp b/boost/cstdlib.hpp deleted file mode 100644 index 6322146..0000000 --- a/boost/cstdlib.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// boost/cstdlib.hpp header ------------------------------------------------// - -// Copyright Beman Dawes 2001. Distributed under the 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/utility/cstdlib.html for documentation. - -// Revision History -// 26 Feb 01 Initial version (Beman Dawes) - -#ifndef BOOST_CSTDLIB_HPP -#define BOOST_CSTDLIB_HPP - -#include - -namespace boost -{ - // The intent is to propose the following for addition to namespace std - // in the C++ Standard Library, and to then deprecate EXIT_SUCCESS and - // EXIT_FAILURE. As an implementation detail, this header defines the - // new constants in terms of EXIT_SUCCESS and EXIT_FAILURE. In a new - // standard, the constants would be implementation-defined, although it - // might be worthwhile to "suggest" (which a standard is allowed to do) - // values of 0 and 1 respectively. - - // Rationale for having multiple failure values: some environments may - // wish to distinguish between different classes of errors. - // Rationale for choice of values: programs often use values < 100 for - // their own error reporting. Values > 255 are sometimes reserved for - // system detected errors. 200/201 were suggested to minimize conflict. - - const int exit_success = EXIT_SUCCESS; // implementation-defined value - const int exit_failure = EXIT_FAILURE; // implementation-defined value - const int exit_exception_failure = 200; // otherwise uncaught exception - const int exit_test_failure = 201; // report_error or - // report_critical_error called. -} - -#endif - diff --git a/boost/date_time.hpp b/boost/date_time.hpp deleted file mode 100644 index 51628cd..0000000 --- a/boost/date_time.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef BOOST_DATE_TIME_ALL_HPP___ -#define BOOST_DATE_TIME_ALL_HPP___ - -/* Copyright (c) 2006 CrystalClear Software, Inc. - * Use, modification and distribution is subject to the - * Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) - * Author: Jeff Garland - * $Date$ - */ - - // See www.boost.org/libs/date_time for documentation. - -//gregorian and posix time included by indirectly -#include "boost/date_time/local_time/local_time.hpp" - -#endif // BOOST_DATE_TIME_ALL_HPP___ diff --git a/boost/detail/algorithm.hpp b/boost/detail/algorithm.hpp deleted file mode 100644 index 3f9297b..0000000 --- a/boost/detail/algorithm.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// (C) Copyright Jeremy Siek 2001. -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -/* - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - */ - -#ifndef BOOST_ALGORITHM_HPP -# define BOOST_ALGORITHM_HPP -# include -// Algorithms on sequences -// -// The functions in this file have not yet gone through formal -// review, and are subject to change. This is a work in progress. -// They have been checked into the detail directory because -// there are some graph algorithms that use these functions. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { - - template - bool any_if(InputIterator first, InputIterator last, Predicate p) - { - return std::find_if(first, last, p) != last; - } - - template - bool any_if(const Container& c, Predicate p) - { - return any_if(boost::begin(c), boost::end(c), p); - } - - template - bool container_contains(InputIterator first, InputIterator last, T value) - { - return std::find(first, last, value) != last; - } - template - bool container_contains(const Container& c, const T& value) - { - return container_contains(boost::begin(c), boost::end(c), value); - } - -} // namespace boost - -#endif // BOOST_ALGORITHM_HPP diff --git a/boost/detail/allocator_utilities.hpp b/boost/detail/allocator_utilities.hpp deleted file mode 100644 index ed3de84..0000000 --- a/boost/detail/allocator_utilities.hpp +++ /dev/null @@ -1,187 +0,0 @@ -/* Copyright 2003-2013 Joaquin M Lopez Munoz. - * Distributed under the 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 Boost website at http://www.boost.org/ - */ - -#ifndef BOOST_DETAIL_ALLOCATOR_UTILITIES_HPP -#define BOOST_DETAIL_ALLOCATOR_UTILITIES_HPP - -#include /* keep it first to prevent nasty warns in MSVC */ -#include -#include -#include -#include -#include -#include - -namespace boost{ - -namespace detail{ - -/* Allocator adaption layer. Some stdlibs provide allocators without rebind - * and template ctors. These facilities are simulated with the external - * template class rebind_to and the aid of partial_std_allocator_wrapper. - */ - -namespace allocator{ - -/* partial_std_allocator_wrapper inherits the functionality of a std - * allocator while providing a templatized ctor and other bits missing - * in some stdlib implementation or another. - */ - -template -class partial_std_allocator_wrapper:public std::allocator -{ -public: - /* Oddly enough, STLport does not define std::allocator::value_type - * when configured to work without partial template specialization. - * No harm in supplying the definition here unconditionally. - */ - - typedef Type value_type; - - partial_std_allocator_wrapper(){}; - - template - partial_std_allocator_wrapper(const partial_std_allocator_wrapper&){} - - partial_std_allocator_wrapper(const std::allocator& x): - std::allocator(x) - { - }; - -#if defined(BOOST_DINKUMWARE_STDLIB) - /* Dinkumware guys didn't provide a means to call allocate() without - * supplying a hint, in disagreement with the standard. - */ - - Type* allocate(std::size_t n,const void* hint=0) - { - std::allocator& a=*this; - return a.allocate(n,hint); - } -#endif - -}; - -/* Detects whether a given allocator belongs to a defective stdlib not - * having the required member templates. - * Note that it does not suffice to check the Boost.Config stdlib - * macros, as the user might have passed a custom, compliant allocator. - * The checks also considers partial_std_allocator_wrapper to be - * a standard defective allocator. - */ - -#if defined(BOOST_NO_STD_ALLOCATOR)&&\ - (defined(BOOST_HAS_PARTIAL_STD_ALLOCATOR)||defined(BOOST_DINKUMWARE_STDLIB)) - -template -struct is_partial_std_allocator -{ - BOOST_STATIC_CONSTANT(bool, - value= - (is_same< - std::allocator, - Allocator - >::value)|| - (is_same< - partial_std_allocator_wrapper< - BOOST_DEDUCED_TYPENAME Allocator::value_type>, - Allocator - >::value)); -}; - -#else - -template -struct is_partial_std_allocator -{ - BOOST_STATIC_CONSTANT(bool,value=false); -}; - -#endif - -/* rebind operations for defective std allocators */ - -template -struct partial_std_allocator_rebind_to -{ - typedef partial_std_allocator_wrapper type; -}; - -/* rebind operation in all other cases */ - -template -struct rebinder -{ - template - struct result - { - typedef typename Allocator::BOOST_NESTED_TEMPLATE - rebind::other other; - }; -}; - -template -struct compliant_allocator_rebind_to -{ - typedef typename rebinder:: - BOOST_NESTED_TEMPLATE result::other type; -}; - -/* rebind front-end */ - -template -struct rebind_to: - mpl::eval_if_c< - is_partial_std_allocator::value, - partial_std_allocator_rebind_to, - compliant_allocator_rebind_to - > -{ -}; - -/* allocator-independent versions of construct and destroy */ - -template -void construct(void* p,const Type& t) -{ - new (p) Type(t); -} - -#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500)) -/* MSVC++ issues spurious warnings about unreferencend formal parameters - * in destroy when Type is a class with trivial dtor. - */ - -#pragma warning(push) -#pragma warning(disable:4100) -#endif - -template -void destroy(const Type* p) -{ - -#if BOOST_WORKAROUND(__SUNPRO_CC,BOOST_TESTED_AT(0x590)) - const_cast(p)->~Type(); -#else - p->~Type(); -#endif - -} - -#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500)) -#pragma warning(pop) -#endif - -} /* namespace boost::detail::allocator */ - -} /* namespace boost::detail */ - -} /* namespace boost */ - -#endif diff --git a/boost/detail/atomic_count.hpp b/boost/detail/atomic_count.hpp deleted file mode 100644 index 5411c7a..0000000 --- a/boost/detail/atomic_count.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED -#define BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// -// boost/detail/atomic_count.hpp - thread/SMP safe reference counter -// -// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt - -#include - -#endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED diff --git a/boost/detail/atomic_redef_macros.hpp b/boost/detail/atomic_redef_macros.hpp deleted file mode 100644 index dfd15f5..0000000 --- a/boost/detail/atomic_redef_macros.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - -#if defined(BOOST_INTEL) - -#pragma pop_macro("atomic_compare_exchange") -#pragma pop_macro("atomic_compare_exchange_explicit") -#pragma pop_macro("atomic_exchange") -#pragma pop_macro("atomic_exchange_explicit") -#pragma pop_macro("atomic_is_lock_free") -#pragma pop_macro("atomic_load") -#pragma pop_macro("atomic_load_explicit") -#pragma pop_macro("atomic_store") -#pragma pop_macro("atomic_store_explicit") - -#endif // #if defined(BOOST_INTEL) diff --git a/boost/detail/atomic_undef_macros.hpp b/boost/detail/atomic_undef_macros.hpp deleted file mode 100644 index 18d840a..0000000 --- a/boost/detail/atomic_undef_macros.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - -#if defined(BOOST_INTEL) - -#pragma push_macro("atomic_compare_exchange") -#undef atomic_compare_exchange - -#pragma push_macro("atomic_compare_exchange_explicit") -#undef atomic_compare_exchange_explicit - -#pragma push_macro("atomic_exchange") -#undef atomic_exchange - -#pragma push_macro("atomic_exchange_explicit") -#undef atomic_exchange_explicit - -#pragma push_macro("atomic_is_lock_free") -#undef atomic_is_lock_free - -#pragma push_macro("atomic_load") -#undef atomic_load - -#pragma push_macro("atomic_load_explicit") -#undef atomic_load_explicit - -#pragma push_macro("atomic_store") -#undef atomic_store - -#pragma push_macro("atomic_store_explicit") -#undef atomic_store_explicit - - -#endif // #if defined(BOOST_INTEL) - - diff --git a/boost/detail/basic_pointerbuf.hpp b/boost/detail/basic_pointerbuf.hpp deleted file mode 100644 index 1d8cf37..0000000 --- a/boost/detail/basic_pointerbuf.hpp +++ /dev/null @@ -1,139 +0,0 @@ -//----------------------------------------------------------------------------- -// boost detail/templated_streams.hpp header file -// See http://www.boost.org for updates, documentation, and revision history. -//----------------------------------------------------------------------------- -// -// Copyright (c) 2013 John Maddock, Antony Polukhin -// -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_DETAIL_BASIC_POINTERBUF_HPP -#define BOOST_DETAIL_BASIC_POINTERBUF_HPP - -// MS compatible compilers support #pragma once -#if defined(_MSC_VER) -# pragma once -#endif - -#include "boost/config.hpp" -#include - -namespace boost { namespace detail { - -// -// class basic_pointerbuf: -// acts as a stream buffer which wraps around a pair of pointers: -// -template -class basic_pointerbuf : public BufferT { -protected: - typedef BufferT base_type; - typedef basic_pointerbuf this_type; - typedef typename base_type::int_type int_type; - typedef typename base_type::char_type char_type; - typedef typename base_type::pos_type pos_type; - typedef ::std::streamsize streamsize; - typedef typename base_type::off_type off_type; - -public: - basic_pointerbuf() : base_type() { setbuf(0, 0); } - const charT* getnext() { return this->gptr(); } - -#ifndef BOOST_NO_USING_TEMPLATE - using base_type::pptr; - using base_type::pbase; -#else - charT* pptr() const { return base_type::pptr(); } - charT* pbase() const { return base_type::pbase(); } -#endif - -protected: - // VC mistakenly assumes that `setbuf` and other functions are not referenced. - // Marking those functions with `inline` suppresses the warnings. - // There must be no harm from marking virtual functions as inline: inline virtual - // call can be inlined ONLY when the compiler knows the "exact class". - inline base_type* setbuf(char_type* s, streamsize n); - inline typename this_type::pos_type seekpos(pos_type sp, ::std::ios_base::openmode which); - inline typename this_type::pos_type seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which); - -private: - basic_pointerbuf& operator=(const basic_pointerbuf&); - basic_pointerbuf(const basic_pointerbuf&); -}; - -template -BufferT* -basic_pointerbuf::setbuf(char_type* s, streamsize n) -{ - this->setg(s, s, s + n); - return this; -} - -template -typename basic_pointerbuf::pos_type -basic_pointerbuf::seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) -{ - typedef typename boost::int_t::least cast_type; - - if(which & ::std::ios_base::out) - return pos_type(off_type(-1)); - std::ptrdiff_t size = this->egptr() - this->eback(); - std::ptrdiff_t pos = this->gptr() - this->eback(); - charT* g = this->eback(); - switch(static_cast(way)) - { - case ::std::ios_base::beg: - if((off < 0) || (off > size)) - return pos_type(off_type(-1)); - else - this->setg(g, g + off, g + size); - break; - case ::std::ios_base::end: - if((off < 0) || (off > size)) - return pos_type(off_type(-1)); - else - this->setg(g, g + size - off, g + size); - break; - case ::std::ios_base::cur: - { - std::ptrdiff_t newpos = static_cast(pos + off); - if((newpos < 0) || (newpos > size)) - return pos_type(off_type(-1)); - else - this->setg(g, g + newpos, g + size); - break; - } - default: ; - } -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable:4244) -#endif - return static_cast(this->gptr() - this->eback()); -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif -} - -template -typename basic_pointerbuf::pos_type -basic_pointerbuf::seekpos(pos_type sp, ::std::ios_base::openmode which) -{ - if(which & ::std::ios_base::out) - return pos_type(off_type(-1)); - off_type size = static_cast(this->egptr() - this->eback()); - charT* g = this->eback(); - if(off_type(sp) <= size) - { - this->setg(g, g + off_type(sp), g + size); - } - return pos_type(off_type(-1)); -} - -}} // namespace boost::detail - -#endif // BOOST_DETAIL_BASIC_POINTERBUF_HPP - diff --git a/boost/detail/binary_search.hpp b/boost/detail/binary_search.hpp deleted file mode 100644 index 3dca9b6..0000000 --- a/boost/detail/binary_search.hpp +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) 2000 David Abrahams. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Copyright (c) 1994 -// Hewlett-Packard Company -// -// Permission to use, copy, modify, distribute and sell this software -// and its documentation for any purpose is hereby granted without fee, -// provided that the above copyright notice appear in all copies and -// that both that copyright notice and this permission notice appear -// in supporting documentation. Hewlett-Packard Company makes no -// representations about the suitability of this software for any -// purpose. It is provided "as is" without express or implied warranty. -// -// Copyright (c) 1996 -// Silicon Graphics Computer Systems, Inc. -// -// Permission to use, copy, modify, distribute and sell this software -// and its documentation for any purpose is hereby granted without fee, -// provided that the above copyright notice appear in all copies and -// that both that copyright notice and this permission notice appear -// in supporting documentation. Silicon Graphics makes no -// representations about the suitability of this software for any -// purpose. It is provided "as is" without express or implied warranty. -// -#ifndef BINARY_SEARCH_DWA_122600_H_ -# define BINARY_SEARCH_DWA_122600_H_ - -# include -# include - -namespace boost { namespace detail { - -template -ForwardIter lower_bound(ForwardIter first, ForwardIter last, - const Tp& val) -{ - typedef detail::iterator_traits traits; - - typename traits::difference_type len = boost::detail::distance(first, last); - typename traits::difference_type half; - ForwardIter middle; - - while (len > 0) { - half = len >> 1; - middle = first; - std::advance(middle, half); - if (*middle < val) { - first = middle; - ++first; - len = len - half - 1; - } - else - len = half; - } - return first; -} - -template -ForwardIter lower_bound(ForwardIter first, ForwardIter last, - const Tp& val, Compare comp) -{ - typedef detail::iterator_traits traits; - - typename traits::difference_type len = boost::detail::distance(first, last); - typename traits::difference_type half; - ForwardIter middle; - - while (len > 0) { - half = len >> 1; - middle = first; - std::advance(middle, half); - if (comp(*middle, val)) { - first = middle; - ++first; - len = len - half - 1; - } - else - len = half; - } - return first; -} - -template -ForwardIter upper_bound(ForwardIter first, ForwardIter last, - const Tp& val) -{ - typedef detail::iterator_traits traits; - - typename traits::difference_type len = boost::detail::distance(first, last); - typename traits::difference_type half; - ForwardIter middle; - - while (len > 0) { - half = len >> 1; - middle = first; - std::advance(middle, half); - if (val < *middle) - len = half; - else { - first = middle; - ++first; - len = len - half - 1; - } - } - return first; -} - -template -ForwardIter upper_bound(ForwardIter first, ForwardIter last, - const Tp& val, Compare comp) -{ - typedef detail::iterator_traits traits; - - typename traits::difference_type len = boost::detail::distance(first, last); - typename traits::difference_type half; - ForwardIter middle; - - while (len > 0) { - half = len >> 1; - middle = first; - std::advance(middle, half); - if (comp(val, *middle)) - len = half; - else { - first = middle; - ++first; - len = len - half - 1; - } - } - return first; -} - -template -std::pair -equal_range(ForwardIter first, ForwardIter last, const Tp& val) -{ - typedef detail::iterator_traits traits; - - typename traits::difference_type len = boost::detail::distance(first, last); - typename traits::difference_type half; - ForwardIter middle, left, right; - - while (len > 0) { - half = len >> 1; - middle = first; - std::advance(middle, half); - if (*middle < val) { - first = middle; - ++first; - len = len - half - 1; - } - else if (val < *middle) - len = half; - else { - left = boost::detail::lower_bound(first, middle, val); - std::advance(first, len); - right = boost::detail::upper_bound(++middle, first, val); - return std::pair(left, right); - } - } - return std::pair(first, first); -} - -template -std::pair -equal_range(ForwardIter first, ForwardIter last, const Tp& val, - Compare comp) -{ - typedef detail::iterator_traits traits; - - typename traits::difference_type len = boost::detail::distance(first, last); - typename traits::difference_type half; - ForwardIter middle, left, right; - - while (len > 0) { - half = len >> 1; - middle = first; - std::advance(middle, half); - if (comp(*middle, val)) { - first = middle; - ++first; - len = len - half - 1; - } - else if (comp(val, *middle)) - len = half; - else { - left = boost::detail::lower_bound(first, middle, val, comp); - std::advance(first, len); - right = boost::detail::upper_bound(++middle, first, val, comp); - return std::pair(left, right); - } - } - return std::pair(first, first); -} - -template -bool binary_search(ForwardIter first, ForwardIter last, - const Tp& val) { - ForwardIter i = boost::detail::lower_bound(first, last, val); - return i != last && !(val < *i); -} - -template -bool binary_search(ForwardIter first, ForwardIter last, - const Tp& val, - Compare comp) { - ForwardIter i = boost::detail::lower_bound(first, last, val, comp); - return i != last && !comp(val, *i); -} - -}} // namespace boost::detail - -#endif // BINARY_SEARCH_DWA_122600_H_ diff --git a/boost/detail/bitmask.hpp b/boost/detail/bitmask.hpp deleted file mode 100644 index c6714a1..0000000 --- a/boost/detail/bitmask.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// boost/detail/bitmask.hpp ------------------------------------------------// - -// Copyright Beman Dawes 2006 - -// Distributed under the Boost Software License, Version 1.0 -// http://www.boost.org/LICENSE_1_0.txt - -// Usage: enum foo { a=1, b=2, c=4 }; -// BOOST_BITMASK( foo ); -// -// void f( foo arg ); -// ... -// f( a | c ); - -#ifndef BOOST_BITMASK_HPP -#define BOOST_BITMASK_HPP - -#include - -#define BOOST_BITMASK(Bitmask) \ - \ - inline Bitmask operator| (Bitmask x , Bitmask y ) \ - { return static_cast( static_cast(x) \ - | static_cast(y)); } \ - \ - inline Bitmask operator& (Bitmask x , Bitmask y ) \ - { return static_cast( static_cast(x) \ - & static_cast(y)); } \ - \ - inline Bitmask operator^ (Bitmask x , Bitmask y ) \ - { return static_cast( static_cast(x) \ - ^ static_cast(y)); } \ - \ - inline Bitmask operator~ (Bitmask x ) \ - { return static_cast(~static_cast(x)); } \ - \ - inline Bitmask & operator&=(Bitmask & x , Bitmask y) \ - { x = x & y ; return x ; } \ - \ - inline Bitmask & operator|=(Bitmask & x , Bitmask y) \ - { x = x | y ; return x ; } \ - \ - inline Bitmask & operator^=(Bitmask & x , Bitmask y) \ - { x = x ^ y ; return x ; } - -#endif // BOOST_BITMASK_HPP - diff --git a/boost/detail/call_traits.hpp b/boost/detail/call_traits.hpp deleted file mode 100644 index 36dea00..0000000 --- a/boost/detail/call_traits.hpp +++ /dev/null @@ -1,172 +0,0 @@ -// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000. -// 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). -// -// See http://www.boost.org/libs/utility for most recent version including documentation. - -// call_traits: defines typedefs for function usage -// (see libs/utility/call_traits.htm) - -/* Release notes: - 23rd July 2000: - Fixed array specialization. (JM) - Added Borland specific fixes for reference types - (issue raised by Steve Cleary). -*/ - -#ifndef BOOST_DETAIL_CALL_TRAITS_HPP -#define BOOST_DETAIL_CALL_TRAITS_HPP - -#ifndef BOOST_CONFIG_HPP -#include -#endif -#include - -#include -#include -#include -#include - -namespace boost{ - -namespace detail{ - -template -struct ct_imp2 -{ - typedef const T& param_type; -}; - -template -struct ct_imp2 -{ - typedef const T param_type; -}; - -template -struct ct_imp -{ - typedef const T& param_type; -}; - -template -struct ct_imp -{ - typedef typename ct_imp2::param_type param_type; -}; - -template -struct ct_imp -{ - typedef typename ct_imp2::param_type param_type; -}; - -template -struct ct_imp -{ - typedef const T param_type; -}; - -} - -template -struct call_traits -{ -public: - typedef T value_type; - typedef T& reference; - typedef const T& const_reference; - // - // C++ Builder workaround: we should be able to define a compile time - // constant and pass that as a single template parameter to ct_imp, - // however compiler bugs prevent this - instead pass three bool's to - // ct_imp and add an extra partial specialisation - // of ct_imp to handle the logic. (JM) - typedef typename boost::detail::ct_imp< - T, - ::boost::is_pointer::value, - ::boost::is_arithmetic::value, - ::boost::is_enum::value - >::param_type param_type; -}; - -template -struct call_traits -{ - typedef T& value_type; - typedef T& reference; - typedef const T& const_reference; - typedef T& param_type; // hh removed const -}; - -#if BOOST_WORKAROUND( __BORLANDC__, < 0x5A0 ) -// these are illegal specialisations; cv-qualifies applied to -// references have no effect according to [8.3.2p1], -// C++ Builder requires them though as it treats cv-qualified -// references as distinct types... -template -struct call_traits -{ - typedef T& value_type; - typedef T& reference; - typedef const T& const_reference; - typedef T& param_type; // hh removed const -}; -template -struct call_traits -{ - typedef T& value_type; - typedef T& reference; - typedef const T& const_reference; - typedef T& param_type; // hh removed const -}; -template -struct call_traits -{ - typedef T& value_type; - typedef T& reference; - typedef const T& const_reference; - typedef T& param_type; // hh removed const -}; - -template -struct call_traits< T * > -{ - typedef T * value_type; - typedef T * & reference; - typedef T * const & const_reference; - typedef T * const param_type; // hh removed const -}; -#endif -#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) -template -struct call_traits -{ -private: - typedef T array_type[N]; -public: - // degrades array to pointer: - typedef const T* value_type; - typedef array_type& reference; - typedef const array_type& const_reference; - typedef const T* const param_type; -}; - -template -struct call_traits -{ -private: - typedef const T array_type[N]; -public: - // degrades array to pointer: - typedef const T* value_type; - typedef array_type& reference; - typedef const array_type& const_reference; - typedef const T* const param_type; -}; -#endif - -} - -#endif // BOOST_DETAIL_CALL_TRAITS_HPP diff --git a/boost/detail/catch_exceptions.hpp b/boost/detail/catch_exceptions.hpp deleted file mode 100644 index 823ebd1..0000000 --- a/boost/detail/catch_exceptions.hpp +++ /dev/null @@ -1,142 +0,0 @@ -// boost/catch_exceptions.hpp -----------------------------------------------// - -// Copyright Beman Dawes 1995-2001. Distributed under the 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/test for documentation. - -// Revision History -// 13 Jun 01 report_exception() made inline. (John Maddock, Jesse Jones) -// 26 Feb 01 Numerous changes suggested during formal review. (Beman) -// 25 Jan 01 catch_exceptions.hpp code factored out of cpp_main.cpp. -// 22 Jan 01 Remove test_tools dependencies to reduce coupling. -// 5 Nov 00 Initial boost version (Beman Dawes) - -#ifndef BOOST_CATCH_EXCEPTIONS_HPP -#define BOOST_CATCH_EXCEPTIONS_HPP - -// header dependencies are deliberately restricted to the standard library -// to reduce coupling to other boost libraries. -#include // for string -#include // for bad_alloc -#include // for bad_cast, bad_typeid -#include // for exception, bad_exception -#include // for std exception hierarchy -#include // for exit codes -#include // for ostream - -# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x0551) -# define BOOST_BUILT_IN_EXCEPTIONS_MISSING_WHAT -# endif - -#if defined(MPW_CPLUS) && (MPW_CPLUS <= 0x890) -# define BOOST_BUILT_IN_EXCEPTIONS_MISSING_WHAT - namespace std { class bad_typeid { }; } -# endif - -namespace boost -{ - - namespace detail - { - // A separate reporting function was requested during formal review. - inline void report_exception( std::ostream & os, - const char * name, const char * info ) - { os << "\n** uncaught exception: " << name << " " << info << std::endl; } - } - - // catch_exceptions ------------------------------------------------------// - - template< class Generator > // Generator is function object returning int - int catch_exceptions( Generator function_object, - std::ostream & out, std::ostream & err ) - { - int result = 0; // quiet compiler warnings - bool exception_thrown = true; // avoid setting result for each excptn type - -#ifndef BOOST_NO_EXCEPTIONS - try - { -#endif - result = function_object(); - exception_thrown = false; -#ifndef BOOST_NO_EXCEPTIONS - } - - // As a result of hard experience with strangely interleaved output - // under some compilers, there is a lot of use of endl in the code below - // where a simple '\n' might appear to do. - - // The rules for catch & arguments are a bit different from function - // arguments (ISO 15.3 paragraphs 18 & 19). Apparently const isn't - // required, but it doesn't hurt and some programmers ask for it. - - catch ( const char * ex ) - { detail::report_exception( out, "", ex ); } - catch ( const std::string & ex ) - { detail::report_exception( out, "", ex.c_str() ); } - - // std:: exceptions - catch ( const std::bad_alloc & ex ) - { detail::report_exception( out, "std::bad_alloc:", ex.what() ); } - -# ifndef BOOST_BUILT_IN_EXCEPTIONS_MISSING_WHAT - catch ( const std::bad_cast & ex ) - { detail::report_exception( out, "std::bad_cast:", ex.what() ); } - catch ( const std::bad_typeid & ex ) - { detail::report_exception( out, "std::bad_typeid:", ex.what() ); } -# else - catch ( const std::bad_cast & ) - { detail::report_exception( out, "std::bad_cast", "" ); } - catch ( const std::bad_typeid & ) - { detail::report_exception( out, "std::bad_typeid", "" ); } -# endif - - catch ( const std::bad_exception & ex ) - { detail::report_exception( out, "std::bad_exception:", ex.what() ); } - catch ( const std::domain_error & ex ) - { detail::report_exception( out, "std::domain_error:", ex.what() ); } - catch ( const std::invalid_argument & ex ) - { detail::report_exception( out, "std::invalid_argument:", ex.what() ); } - catch ( const std::length_error & ex ) - { detail::report_exception( out, "std::length_error:", ex.what() ); } - catch ( const std::out_of_range & ex ) - { detail::report_exception( out, "std::out_of_range:", ex.what() ); } - catch ( const std::range_error & ex ) - { detail::report_exception( out, "std::range_error:", ex.what() ); } - catch ( const std::overflow_error & ex ) - { detail::report_exception( out, "std::overflow_error:", ex.what() ); } - catch ( const std::underflow_error & ex ) - { detail::report_exception( out, "std::underflow_error:", ex.what() ); } - catch ( const std::logic_error & ex ) - { detail::report_exception( out, "std::logic_error:", ex.what() ); } - catch ( const std::runtime_error & ex ) - { detail::report_exception( out, "std::runtime_error:", ex.what() ); } - catch ( const std::exception & ex ) - { detail::report_exception( out, "std::exception:", ex.what() ); } - - catch ( ... ) - { detail::report_exception( out, "unknown exception", "" ); } -#endif // BOOST_NO_EXCEPTIONS - - if ( exception_thrown ) result = boost::exit_exception_failure; - - if ( result != 0 && result != exit_success ) - { - out << std::endl << "**** returning with error code " - << result << std::endl; - err - << "********** errors detected; see stdout for details ***********" - << std::endl; - } -#if !defined(BOOST_NO_CPP_MAIN_SUCCESS_MESSAGE) - else { out << std::flush << "no errors detected" << std::endl; } -#endif - return result; - } // catch_exceptions - -} // boost - -#endif // BOOST_CATCH_EXCEPTIONS_HPP - diff --git a/boost/detail/compressed_pair.hpp b/boost/detail/compressed_pair.hpp deleted file mode 100644 index 5dc21e2..0000000 --- a/boost/detail/compressed_pair.hpp +++ /dev/null @@ -1,443 +0,0 @@ -// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000. -// 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). -// -// See http://www.boost.org/libs/utility for most recent version including documentation. - -// compressed_pair: pair that "compresses" empty members -// (see libs/utility/doc/html/compressed_pair.html) -// -// JM changes 25 Jan 2004: -// For the case where T1 == T2 and both are empty, then first() and second() -// should return different objects. -// JM changes 25 Jan 2000: -// Removed default arguments from compressed_pair_switch to get -// C++ Builder 4 to accept them -// rewriten swap to get gcc and C++ builder to compile. -// added partial specialisations for case T1 == T2 to avoid duplicate constructor defs. - -#ifndef BOOST_DETAIL_COMPRESSED_PAIR_HPP -#define BOOST_DETAIL_COMPRESSED_PAIR_HPP - -#include - -#include -#include -#include -#include - -#ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable:4512) -#endif -namespace boost -{ - -template -class compressed_pair; - - -// compressed_pair - -namespace details -{ - // JM altered 26 Jan 2000: - template - struct compressed_pair_switch; - - template - struct compressed_pair_switch - {static const int value = 0;}; - - template - struct compressed_pair_switch - {static const int value = 3;}; - - template - struct compressed_pair_switch - {static const int value = 1;}; - - template - struct compressed_pair_switch - {static const int value = 2;}; - - template - struct compressed_pair_switch - {static const int value = 4;}; - - template - struct compressed_pair_switch - {static const int value = 5;}; - - template class compressed_pair_imp; - -#ifdef __GNUC__ - // workaround for GCC (JM): - using std::swap; -#endif - // - // can't call unqualified swap from within classname::swap - // as Koenig lookup rules will find only the classname::swap - // member function not the global declaration, so use cp_swap - // as a forwarding function (JM): - template - inline void cp_swap(T& t1, T& t2) - { -#ifndef __GNUC__ - using std::swap; -#endif - swap(t1, t2); - } - - // 0 derive from neither - - template - class compressed_pair_imp - { - public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_imp() {} - - compressed_pair_imp(first_param_type x, second_param_type y) - : first_(x), second_(y) {} - - compressed_pair_imp(first_param_type x) - : first_(x) {} - - compressed_pair_imp(second_param_type y) - : second_(y) {} - - first_reference first() {return first_;} - first_const_reference first() const {return first_;} - - second_reference second() {return second_;} - second_const_reference second() const {return second_;} - - void swap(::boost::compressed_pair& y) - { - cp_swap(first_, y.first()); - cp_swap(second_, y.second()); - } - private: - first_type first_; - second_type second_; - }; - - // 1 derive from T1 - - template - class compressed_pair_imp - : protected ::boost::remove_cv::type - { - public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_imp() {} - - compressed_pair_imp(first_param_type x, second_param_type y) - : first_type(x), second_(y) {} - - compressed_pair_imp(first_param_type x) - : first_type(x) {} - - compressed_pair_imp(second_param_type y) - : second_(y) {} - - first_reference first() {return *this;} - first_const_reference first() const {return *this;} - - second_reference second() {return second_;} - second_const_reference second() const {return second_;} - - void swap(::boost::compressed_pair& y) - { - // no need to swap empty base class: - cp_swap(second_, y.second()); - } - private: - second_type second_; - }; - - // 2 derive from T2 - - template - class compressed_pair_imp - : protected ::boost::remove_cv::type - { - public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_imp() {} - - compressed_pair_imp(first_param_type x, second_param_type y) - : second_type(y), first_(x) {} - - compressed_pair_imp(first_param_type x) - : first_(x) {} - - compressed_pair_imp(second_param_type y) - : second_type(y) {} - - first_reference first() {return first_;} - first_const_reference first() const {return first_;} - - second_reference second() {return *this;} - second_const_reference second() const {return *this;} - - void swap(::boost::compressed_pair& y) - { - // no need to swap empty base class: - cp_swap(first_, y.first()); - } - - private: - first_type first_; - }; - - // 3 derive from T1 and T2 - - template - class compressed_pair_imp - : protected ::boost::remove_cv::type, - protected ::boost::remove_cv::type - { - public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_imp() {} - - compressed_pair_imp(first_param_type x, second_param_type y) - : first_type(x), second_type(y) {} - - compressed_pair_imp(first_param_type x) - : first_type(x) {} - - compressed_pair_imp(second_param_type y) - : second_type(y) {} - - first_reference first() {return *this;} - first_const_reference first() const {return *this;} - - second_reference second() {return *this;} - second_const_reference second() const {return *this;} - // - // no need to swap empty bases: - void swap(::boost::compressed_pair&) {} - }; - - // JM - // 4 T1 == T2, T1 and T2 both empty - // Originally this did not store an instance of T2 at all - // but that led to problems beause it meant &x.first() == &x.second() - // which is not true for any other kind of pair, so now we store an instance - // of T2 just in case the user is relying on first() and second() returning - // different objects (albeit both empty). - template - class compressed_pair_imp - : protected ::boost::remove_cv::type - { - public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_imp() {} - - compressed_pair_imp(first_param_type x, second_param_type y) - : first_type(x), m_second(y) {} - - compressed_pair_imp(first_param_type x) - : first_type(x), m_second(x) {} - - first_reference first() {return *this;} - first_const_reference first() const {return *this;} - - second_reference second() {return m_second;} - second_const_reference second() const {return m_second;} - - void swap(::boost::compressed_pair&) {} - private: - T2 m_second; - }; - - // 5 T1 == T2 and are not empty: //JM - - template - class compressed_pair_imp - { - public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_imp() {} - - compressed_pair_imp(first_param_type x, second_param_type y) - : first_(x), second_(y) {} - - compressed_pair_imp(first_param_type x) - : first_(x), second_(x) {} - - first_reference first() {return first_;} - first_const_reference first() const {return first_;} - - second_reference second() {return second_;} - second_const_reference second() const {return second_;} - - void swap(::boost::compressed_pair& y) - { - cp_swap(first_, y.first()); - cp_swap(second_, y.second()); - } - private: - first_type first_; - second_type second_; - }; - -} // details - -template -class compressed_pair - : private ::boost::details::compressed_pair_imp::type, typename remove_cv::type>::value, - ::boost::is_empty::value, - ::boost::is_empty::value>::value> -{ -private: - typedef details::compressed_pair_imp::type, typename remove_cv::type>::value, - ::boost::is_empty::value, - ::boost::is_empty::value>::value> base; -public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair() : base() {} - compressed_pair(first_param_type x, second_param_type y) : base(x, y) {} - explicit compressed_pair(first_param_type x) : base(x) {} - explicit compressed_pair(second_param_type y) : base(y) {} - - first_reference first() {return base::first();} - first_const_reference first() const {return base::first();} - - second_reference second() {return base::second();} - second_const_reference second() const {return base::second();} - - void swap(compressed_pair& y) { base::swap(y); } -}; - -// JM -// Partial specialisation for case where T1 == T2: -// -template -class compressed_pair - : private details::compressed_pair_imp::type, typename remove_cv::type>::value, - ::boost::is_empty::value, - ::boost::is_empty::value>::value> -{ -private: - typedef details::compressed_pair_imp::type, typename remove_cv::type>::value, - ::boost::is_empty::value, - ::boost::is_empty::value>::value> base; -public: - typedef T first_type; - typedef T second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair() : base() {} - compressed_pair(first_param_type x, second_param_type y) : base(x, y) {} -#if !(defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)) - explicit -#endif - compressed_pair(first_param_type x) : base(x) {} - - first_reference first() {return base::first();} - first_const_reference first() const {return base::first();} - - second_reference second() {return base::second();} - second_const_reference second() const {return base::second();} - - void swap(::boost::compressed_pair& y) { base::swap(y); } -}; - -template -inline -void -swap(compressed_pair& x, compressed_pair& y) -{ - x.swap(y); -} - -} // boost - -#ifdef BOOST_MSVC -# pragma warning(pop) -#endif - -#endif // BOOST_DETAIL_COMPRESSED_PAIR_HPP - diff --git a/boost/detail/container_fwd.hpp b/boost/detail/container_fwd.hpp deleted file mode 100644 index 04ce972..0000000 --- a/boost/detail/container_fwd.hpp +++ /dev/null @@ -1,157 +0,0 @@ - -// Copyright 2005-2011 Daniel James. -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// Note: if you change this include guard, you also need to change -// container_fwd_compile_fail.cpp -#if !defined(BOOST_DETAIL_CONTAINER_FWD_HPP) -#define BOOST_DETAIL_CONTAINER_FWD_HPP - -#if defined(_MSC_VER) && \ - !defined(BOOST_DETAIL_TEST_CONFIG_ONLY) -# pragma once -#endif - -#include -#include - -//////////////////////////////////////////////////////////////////////////////// -// // -// Define BOOST_DETAIL_NO_CONTAINER_FWD if you don't want this header to // -// forward declare standard containers. // -// // -// BOOST_DETAIL_CONTAINER_FWD to make it foward declare containers even if it // -// normally doesn't. // -// // -// BOOST_DETAIL_NO_CONTAINER_FWD overrides BOOST_DETAIL_CONTAINER_FWD. // -// // -//////////////////////////////////////////////////////////////////////////////// - -#if !defined(BOOST_DETAIL_NO_CONTAINER_FWD) -# if defined(BOOST_DETAIL_CONTAINER_FWD) - // Force forward declarations. -# elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) - // STLport -# define BOOST_DETAIL_NO_CONTAINER_FWD -# elif defined(__LIBCOMO__) - // Comeau STL: -# define BOOST_DETAIL_NO_CONTAINER_FWD -# elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER) - // Rogue Wave library: -# define BOOST_DETAIL_NO_CONTAINER_FWD -# elif defined(_LIBCPP_VERSION) - // libc++ -# define BOOST_DETAIL_NO_CONTAINER_FWD -# elif defined(__GLIBCPP__) || defined(__GLIBCXX__) - // GNU libstdc++ 3 - // - // Disable forwarding for all recent versions, as the library has a - // versioned namespace mode, and I don't know how to detect it. -# if __GLIBCXX__ >= 20070513 \ - || defined(_GLIBCXX_DEBUG) \ - || defined(_GLIBCXX_PARALLEL) \ - || defined(_GLIBCXX_PROFILE) -# define BOOST_DETAIL_NO_CONTAINER_FWD -# else -# if defined(__GLIBCXX__) && __GLIBCXX__ >= 20040530 -# define BOOST_CONTAINER_FWD_COMPLEX_STRUCT -# endif -# endif -# elif defined(__STL_CONFIG_H) - // generic SGI STL - // - // Forward declaration seems to be okay, but it has a couple of odd - // implementations. -# define BOOST_CONTAINER_FWD_BAD_BITSET -# if !defined(__STL_NON_TYPE_TMPL_PARAM_BUG) -# define BOOST_CONTAINER_FWD_BAD_DEQUE -# endif -# elif defined(__MSL_CPP__) - // MSL standard lib: -# define BOOST_DETAIL_NO_CONTAINER_FWD -# elif defined(__IBMCPP__) - // The default VACPP std lib, forward declaration seems to be fine. -# elif defined(MSIPL_COMPILE_H) - // Modena C++ standard library -# define BOOST_DETAIL_NO_CONTAINER_FWD -# elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER) - // Dinkumware Library (this has to appear after any possible replacement - // libraries) -# else -# define BOOST_DETAIL_NO_CONTAINER_FWD -# endif -#endif - -#if !defined(BOOST_DETAIL_TEST_CONFIG_ONLY) - -#if defined(BOOST_DETAIL_NO_CONTAINER_FWD) && \ - !defined(BOOST_DETAIL_TEST_FORCE_CONTAINER_FWD) - -#include -#include -#include -#include -#include -#include -#include -#include - -#else - -#include - -#if defined(BOOST_CONTAINER_FWD_BAD_DEQUE) -#include -#endif - -#if defined(BOOST_CONTAINER_FWD_BAD_BITSET) -#include -#endif - -#if defined(BOOST_MSVC) -#pragma warning(push) -#pragma warning(disable:4099) // struct/class mismatch in fwd declarations -#endif - -namespace std -{ - template class allocator; - template class basic_string; - - template struct char_traits; - -#if defined(BOOST_CONTAINER_FWD_COMPLEX_STRUCT) - template struct complex; -#else - template class complex; -#endif - -#if !defined(BOOST_CONTAINER_FWD_BAD_DEQUE) - template class deque; -#endif - - template class list; - template class vector; - template class map; - template - class multimap; - template class set; - template class multiset; - -#if !defined(BOOST_CONTAINER_FWD_BAD_BITSET) - template class bitset; -#endif - template struct pair; -} - -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif - -#endif // BOOST_DETAIL_NO_CONTAINER_FWD && - // !defined(BOOST_DETAIL_TEST_FORCE_CONTAINER_FWD) - -#endif // BOOST_DETAIL_TEST_CONFIG_ONLY - -#endif diff --git a/boost/detail/dynamic_bitset.hpp b/boost/detail/dynamic_bitset.hpp deleted file mode 100644 index e0f675d..0000000 --- a/boost/detail/dynamic_bitset.hpp +++ /dev/null @@ -1,241 +0,0 @@ -// ----------------------------------------------------------- -// -// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek -// Copyright (c) 2003-2006, 2008 Gennaro Prota -// -// Copyright (c) 2014 Glen Joseph Fernandes -// glenfe at live dot com -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// ----------------------------------------------------------- - -#ifndef BOOST_DETAIL_DYNAMIC_BITSET_HPP -#define BOOST_DETAIL_DYNAMIC_BITSET_HPP - -#include -#include -#include "boost/config.hpp" -#include "boost/detail/workaround.hpp" - - -namespace boost { - - namespace detail { - namespace dynamic_bitset_impl { - - // Gives (read-)access to the object representation - // of an object of type T (3.9p4). CANNOT be used - // on a base sub-object - // - template - inline const unsigned char * object_representation (T* p) - { - return static_cast(static_cast(p)); - } - - template - struct shifter - { - static void left_shift(T & v) { - amount >= width ? (v = 0) - : (v >>= BOOST_DYNAMIC_BITSET_WRAP_CONSTANT(amount)); - } - }; - - // ------- count function implementation -------------- - - typedef unsigned char byte_type; - - // These two entities - // - // enum mode { access_by_bytes, access_by_blocks }; - // template struct mode_to_type {}; - // - // were removed, since the regression logs (as of 24 Aug 2008) - // showed that several compilers had troubles with recognizing - // - // const mode m = access_by_bytes - // - // as a constant expression - // - // * So, we'll use bool, instead of enum *. - // - template - struct value_to_type - { - value_to_type() {} - }; - const bool access_by_bytes = true; - const bool access_by_blocks = false; - - - // the table: wrapped in a class template, so - // that it is only instantiated if/when needed - // - template - struct count_table { static const byte_type table[]; }; - - template <> - struct count_table { /* no table */ }; - - - const unsigned int table_width = 8; - template - const byte_type count_table::table[] = - { - // Automatically generated by GPTableGen.exe v.1.0 - // - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 - }; - - - // overload for access by bytes - // - - template - inline std::size_t do_count(Iterator first, std::size_t length, - int /*dummy param*/, - value_to_type* ) - { - std::size_t num = 0; - if (length) - { - const byte_type * p = object_representation(&*first); - length *= sizeof(*first); - - do { - num += count_table<>::table[*p]; - ++p; - --length; - - } while (length); - } - - return num; - } - - - // overload for access by blocks - // - template - inline std::size_t do_count(Iterator first, std::size_t length, ValueType, - value_to_type*) - { - std::size_t num = 0; - while (length){ - - ValueType value = *first; - while (value) { - num += count_table<>::table[value & ((1u<>= table_width; - } - - ++first; - --length; - } - - return num; - } - - // ------------------------------------------------------- - - - // Some library implementations simply return a dummy - // value such as - // - // size_type(-1) / sizeof(T) - // - // from vector<>::max_size. This tries to get more - // meaningful info. - // - template - inline typename T::size_type vector_max_size_workaround(const T & v) - BOOST_NOEXCEPT - { - typedef typename T::allocator_type allocator_type; - - const allocator_type& alloc = v.get_allocator(); - -#if !defined(BOOST_NO_CXX11_ALLOCATOR) - typedef std::allocator_traits allocator_traits; - - const typename allocator_traits::size_type alloc_max = - allocator_traits::max_size(alloc); -#else - const typename allocator_type::size_type alloc_max = alloc.max_size(); -#endif - - const typename T::size_type container_max = v.max_size(); - - return alloc_max < container_max ? alloc_max : container_max; - } - - // for static_asserts - template - struct allowed_block_type { - enum { value = T(-1) > 0 }; // ensure T has no sign - }; - - template <> - struct allowed_block_type { - enum { value = false }; - }; - - - template - struct is_numeric { - enum { value = false }; - }; - -# define BOOST_dynamic_bitset_is_numeric(x) \ - template<> \ - struct is_numeric< x > { \ - enum { value = true }; \ - } /**/ - - BOOST_dynamic_bitset_is_numeric(bool); - BOOST_dynamic_bitset_is_numeric(char); - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_dynamic_bitset_is_numeric(wchar_t); -#endif - - BOOST_dynamic_bitset_is_numeric(signed char); - BOOST_dynamic_bitset_is_numeric(short int); - BOOST_dynamic_bitset_is_numeric(int); - BOOST_dynamic_bitset_is_numeric(long int); - - BOOST_dynamic_bitset_is_numeric(unsigned char); - BOOST_dynamic_bitset_is_numeric(unsigned short); - BOOST_dynamic_bitset_is_numeric(unsigned int); - BOOST_dynamic_bitset_is_numeric(unsigned long); - -#if defined(BOOST_HAS_LONG_LONG) - BOOST_dynamic_bitset_is_numeric(::boost::long_long_type); - BOOST_dynamic_bitset_is_numeric(::boost::ulong_long_type); -#endif - - // intentionally omitted - //BOOST_dynamic_bitset_is_numeric(float); - //BOOST_dynamic_bitset_is_numeric(double); - //BOOST_dynamic_bitset_is_numeric(long double); - -#undef BOOST_dynamic_bitset_is_numeric - - } // dynamic_bitset_impl - } // namespace detail - -} // namespace boost - -#endif // include guard - diff --git a/boost/detail/endian.hpp b/boost/detail/endian.hpp deleted file mode 100644 index f576c26..0000000 --- a/boost/detail/endian.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2013 Rene Rivera -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_DETAIL_ENDIAN_HPP -#define BOOST_DETAIL_ENDIAN_HPP - -// Use the Predef library for the detection of endianess. -#include - -#endif diff --git a/boost/detail/fenv.hpp b/boost/detail/fenv.hpp deleted file mode 100644 index b268f5c..0000000 --- a/boost/detail/fenv.hpp +++ /dev/null @@ -1,101 +0,0 @@ -/*============================================================================= - Copyright (c) 2010 Bryce Lelbach - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ - -#include - -#if defined(BOOST_NO_FENV_H) - #error This platform does not have a floating point environment -#endif - -#if !defined(BOOST_DETAIL_FENV_HPP) -#define BOOST_DETAIL_FENV_HPP - -/* If we're using clang + glibc, we have to get hacky. - * See http://llvm.org/bugs/show_bug.cgi?id=6907 */ -#if defined(__clang__) && (__clang_major__ < 3) && \ - defined(__GNU_LIBRARY__) && /* up to version 5 */ \ - defined(__GLIBC__) && /* version 6 + */ \ - !defined(_FENV_H) - #define _FENV_H - - #include - #include - - extern "C" { - extern int fegetexceptflag (fexcept_t*, int) __THROW; - extern int fesetexceptflag (__const fexcept_t*, int) __THROW; - extern int feclearexcept (int) __THROW; - extern int feraiseexcept (int) __THROW; - extern int fetestexcept (int) __THROW; - extern int fegetround (void) __THROW; - extern int fesetround (int) __THROW; - extern int fegetenv (fenv_t*) __THROW; - extern int fesetenv (__const fenv_t*) __THROW; - extern int feupdateenv (__const fenv_t*) __THROW; - extern int feholdexcept (fenv_t*) __THROW; - - #ifdef __USE_GNU - extern int feenableexcept (int) __THROW; - extern int fedisableexcept (int) __THROW; - extern int fegetexcept (void) __THROW; - #endif - } - - namespace std { namespace tr1 { - using ::fenv_t; - using ::fexcept_t; - using ::fegetexceptflag; - using ::fesetexceptflag; - using ::feclearexcept; - using ::feraiseexcept; - using ::fetestexcept; - using ::fegetround; - using ::fesetround; - using ::fegetenv; - using ::fesetenv; - using ::feupdateenv; - using ::feholdexcept; - } } - -#elif defined(__MINGW32__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 - - // MinGW (32-bit) has a bug in mingw32/bits/c++config.h, it does not define _GLIBCXX_HAVE_FENV_H, - // which prevents the C fenv.h header contents to be included in the C++ wrapper header fenv.h. This is at least - // the case with gcc 4.8.1 packages tested so far, up to 4.8.1-4. Note that there is no issue with - // MinGW-w64. - // To work around the bug we avoid including the C++ wrapper header and include the C header directly - // and import all relevant symbols into std:: ourselves. - - #include <../include/fenv.h> - - namespace std { - using ::fenv_t; - using ::fexcept_t; - using ::fegetexceptflag; - using ::fesetexceptflag; - using ::feclearexcept; - using ::feraiseexcept; - using ::fetestexcept; - using ::fegetround; - using ::fesetround; - using ::fegetenv; - using ::fesetenv; - using ::feupdateenv; - using ::feholdexcept; - } - -#else /* if we're not using GNU's C stdlib, fenv.h should work with clang */ - - #if defined(__SUNPRO_CC) /* lol suncc */ - #include - #endif - - #include - -#endif - -#endif /* BOOST_DETAIL_FENV_HPP */ diff --git a/boost/detail/has_default_constructor.hpp b/boost/detail/has_default_constructor.hpp deleted file mode 100644 index 319b30a..0000000 --- a/boost/detail/has_default_constructor.hpp +++ /dev/null @@ -1,29 +0,0 @@ - -// (C) Copyright Matthias Troyerk 2006. -// 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). -// -// See http://www.boost.org/libs/type_traits for most recent version including documentation. - -#ifndef BOOST_DETAIL_HAS_DEFAULT_CONSTRUCTOR_HPP_INCLUDED -#define BOOST_DETAIL_HAS_DEFAULT_CONSTRUCTOR_HPP_INCLUDED - -#include - -namespace boost { namespace detail { - -/// type trait to check for a default constructor -/// -/// The default implementation just checks for a trivial constructor. -/// Using some compiler magic it might be possible to provide a better default - -template -struct has_default_constructor - : public has_trivial_constructor -{}; - -} } // namespace boost::detail - - -#endif // BOOST_DETAIL_HAS_DEFAULT_CONSTRUCTOR_HPP_INCLUDED diff --git a/boost/detail/identifier.hpp b/boost/detail/identifier.hpp deleted file mode 100644 index 063d238..0000000 --- a/boost/detail/identifier.hpp +++ /dev/null @@ -1,87 +0,0 @@ -// boost/identifier.hpp ----------------------------------------------------// - -// Copyright Beman Dawes 2006 - -// Distributed under the 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 documentation at http://www.boost.org/libs/utility - -#ifndef BOOST_IDENTIFIER_HPP -#define BOOST_IDENTIFIER_HPP - -#include -#include -#include - -namespace boost -{ - namespace detail - { - // class template identifier ---------------------------------------------// - - // Always used as a base class so that different instantiations result in - // different class types even if instantiated with the same value type T. - - // Expected usage is that T is often an integer type, best passed by - // value. There is no reason why T can't be a possibly larger class such as - // std::string, best passed by const reference. - - // This implementation uses pass by value, based on expected common uses. - - template - class identifier - { - public: - typedef T value_type; - - const value_type value() const { return m_value; } - void assign( value_type v ) { m_value = v; } - - bool operator==( const D & rhs ) const { return m_value == rhs.m_value; } - bool operator!=( const D & rhs ) const { return m_value != rhs.m_value; } - bool operator< ( const D & rhs ) const { return m_value < rhs.m_value; } - bool operator<=( const D & rhs ) const { return m_value <= rhs.m_value; } - bool operator> ( const D & rhs ) const { return m_value > rhs.m_value; } - bool operator>=( const D & rhs ) const { return m_value >= rhs.m_value; } - - typedef void (*unspecified_bool_type)(D); // without the D, unspecified_bool_type - static void unspecified_bool_true(D){} // conversion allows relational operators - // between different identifier types - - operator unspecified_bool_type() const { return m_value == value_type() ? 0 : unspecified_bool_true; } - bool operator!() const { return m_value == value_type(); } - - // constructors are protected so that class can only be used as a base class - protected: - identifier() {} - explicit identifier( value_type v ) : m_value(v) {} - - private: - T m_value; - }; - - //#ifndef BOOST_NO_SFINAE - - // template - // typename enable_if< is_base_of< identifier< typename Id::value_type, Id >, Id >, - // Ostream & >::type operator<<( Ostream & os, const Id & id ) - // { - // return os << id.value(); - // } - - // template - // typename enable_if< is_base_of< identifier< typename Id::value_type, Id >, Id >, - // Istream & >::type operator>>( Istream & is, Id & id ) - // { - // typename Id::value_type v; - // is >> v; - // id.value( v ); - // return is; - // } - //#endif - - } // namespace detail -} // namespace boost - -#endif // BOOST_IDENTIFIER_HPP diff --git a/boost/detail/indirect_traits.hpp b/boost/detail/indirect_traits.hpp index 7c8f76b..6294e40 100644 --- a/boost/detail/indirect_traits.hpp +++ b/boost/detail/indirect_traits.hpp @@ -16,7 +16,6 @@ # include # include -# include # include # include diff --git a/boost/detail/interlocked.hpp b/boost/detail/interlocked.hpp deleted file mode 100644 index 2c91ce2..0000000 --- a/boost/detail/interlocked.hpp +++ /dev/null @@ -1,218 +0,0 @@ -#ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED -#define BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED - -// -// boost/detail/interlocked.hpp -// -// Copyright 2005 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// - -#include - -// MS compatible compilers support #pragma once -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -#if defined( BOOST_USE_WINDOWS_H ) - -# include - -# define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement -# define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange -# define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange -# define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER InterlockedCompareExchangePointer -# define BOOST_INTERLOCKED_EXCHANGE_POINTER InterlockedExchangePointer - -#elif defined( BOOST_USE_INTRIN_H ) - -#include - -# define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement -# define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange -# define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange -# define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd - -# if defined(_M_IA64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__x86_64) - -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer -# define BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer - -# else - -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ - ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) -# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ - ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) - -# endif - -#elif defined(_WIN32_WCE) - -#if _WIN32_WCE >= 0x600 - -extern "C" long __cdecl _InterlockedIncrement( long volatile * ); -extern "C" long __cdecl _InterlockedDecrement( long volatile * ); -extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long ); -extern "C" long __cdecl _InterlockedExchange( long volatile *, long ); -extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long ); - -# define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement -# define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange -# define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange -# define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd - -#else -// under Windows CE we still have old-style Interlocked* functions - -extern "C" long __cdecl InterlockedIncrement( long* ); -extern "C" long __cdecl InterlockedDecrement( long* ); -extern "C" long __cdecl InterlockedCompareExchange( long*, long, long ); -extern "C" long __cdecl InterlockedExchange( long*, long ); -extern "C" long __cdecl InterlockedExchangeAdd( long*, long ); - -# define BOOST_INTERLOCKED_INCREMENT InterlockedIncrement -# define BOOST_INTERLOCKED_DECREMENT InterlockedDecrement -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange -# define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange -# define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd - -#endif - -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ - ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long*)(dest),(long)(exchange),(long)(compare))) -# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ - ((void*)BOOST_INTERLOCKED_EXCHANGE((long*)(dest),(long)(exchange))) - -#elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN ) - -#if defined( BOOST_MSVC ) && BOOST_MSVC >= 1400 - -#include - -#else - -# if defined( __CLRCALL_PURE_OR_CDECL ) -# define BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL __CLRCALL_PURE_OR_CDECL -# else -# define BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL __cdecl -# endif - -extern "C" long BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * ); -extern "C" long BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * ); -extern "C" long BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long ); -extern "C" long BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long ); -extern "C" long BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long ); - -# undef BOOST_INTERLOCKED_CLRCALL_PURE_OR_CDECL - -# if defined( BOOST_MSVC ) && BOOST_MSVC >= 1310 -# pragma intrinsic( _InterlockedIncrement ) -# pragma intrinsic( _InterlockedDecrement ) -# pragma intrinsic( _InterlockedCompareExchange ) -# pragma intrinsic( _InterlockedExchange ) -# pragma intrinsic( _InterlockedExchangeAdd ) -# endif - -#endif - -# if defined(_M_IA64) || defined(_M_AMD64) - -extern "C" void* __cdecl _InterlockedCompareExchangePointer( void* volatile *, void*, void* ); -extern "C" void* __cdecl _InterlockedExchangePointer( void* volatile *, void* ); - -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer -# define BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer - -# else - -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ - ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) -# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ - ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) - -# endif - -# define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement -# define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange -# define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange -# define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd - -// Unlike __MINGW64__, __MINGW64_VERSION_MAJOR is defined by MinGW-w64 for both 32 and 64-bit targets. -#elif defined(__MINGW64_VERSION_MAJOR) - -// MinGW-w64 provides intrin.h for both 32 and 64-bit targets. -#include - -# define BOOST_INTERLOCKED_INCREMENT _InterlockedIncrement -# define BOOST_INTERLOCKED_DECREMENT _InterlockedDecrement -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange -# define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange -# define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd -# if defined(__x86_64__) || defined(__x86_64) -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER _InterlockedCompareExchangePointer -# define BOOST_INTERLOCKED_EXCHANGE_POINTER _InterlockedExchangePointer -# else -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ - ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) -# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ - ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) -# endif - -#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ ) - -#define BOOST_INTERLOCKED_IMPORT __declspec(dllimport) - -namespace boost -{ - -namespace detail -{ - -extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedIncrement( long volatile * ); -extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedDecrement( long volatile * ); -extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedCompareExchange( long volatile *, long, long ); -extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedExchange( long volatile *, long ); -extern "C" BOOST_INTERLOCKED_IMPORT long __stdcall InterlockedExchangeAdd( long volatile *, long ); - -# if defined(_M_IA64) || defined(_M_AMD64) -extern "C" BOOST_INTERLOCKED_IMPORT void* __stdcall InterlockedCompareExchangePointer( void* volatile *, void*, void* ); -extern "C" BOOST_INTERLOCKED_IMPORT void* __stdcall InterlockedExchangePointer( void* volatile *, void* ); -# endif - -} // namespace detail - -} // namespace boost - -# define BOOST_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement -# define BOOST_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE ::boost::detail::InterlockedCompareExchange -# define BOOST_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange -# define BOOST_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd - -# if defined(_M_IA64) || defined(_M_AMD64) -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER ::boost::detail::InterlockedCompareExchangePointer -# define BOOST_INTERLOCKED_EXCHANGE_POINTER ::boost::detail::InterlockedExchangePointer -# else -# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \ - ((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare))) -# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \ - ((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange))) -# endif - -#else - -# error "Interlocked intrinsics not available" - -#endif - -#endif // #ifndef BOOST_DETAIL_INTERLOCKED_HPP_INCLUDED diff --git a/boost/detail/is_incrementable.hpp b/boost/detail/is_incrementable.hpp deleted file mode 100644 index 6b36378..0000000 --- a/boost/detail/is_incrementable.hpp +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright David Abrahams 2004. Use, modification and distribution is -// 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) -#ifndef IS_INCREMENTABLE_DWA200415_HPP -# define IS_INCREMENTABLE_DWA200415_HPP - -# include -# include -# include -# include -# include - -// Must be the last include -# include - -namespace boost { namespace detail { - -// is_incrementable metafunction -// -// Requires: Given x of type T&, if the expression ++x is well-formed -// it must have complete type; otherwise, it must neither be ambiguous -// nor violate access. - -// This namespace ensures that ADL doesn't mess things up. -namespace is_incrementable_ -{ - // a type returned from operator++ when no increment is found in the - // type's own namespace - struct tag {}; - - // any soaks up implicit conversions and makes the following - // operator++ less-preferred than any other such operator that - // might be found via ADL. - struct any { template any(T const&); }; - - // This is a last-resort operator++ for when none other is found -# if BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2 - -} - -namespace is_incrementable_2 -{ - is_incrementable_::tag operator++(is_incrementable_::any const&); - is_incrementable_::tag operator++(is_incrementable_::any const&,int); -} -using namespace is_incrementable_2; - -namespace is_incrementable_ -{ - -# else - - tag operator++(any const&); - tag operator++(any const&,int); - -# endif - -# if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) -# define BOOST_comma(a,b) (a) -# else - // In case an operator++ is found that returns void, we'll use ++x,0 - tag operator,(tag,int); -# define BOOST_comma(a,b) (a,b) -# endif - -# if defined(BOOST_MSVC) -# pragma warning(push) -# pragma warning(disable:4913) // Warning about operator, -# endif - - // two check overloads help us identify which operator++ was picked - char (& check_(tag) )[2]; - - template - char check_(T const&); - - - template - struct impl - { - static typename boost::remove_cv::type& x; - - BOOST_STATIC_CONSTANT( - bool - , value = sizeof(is_incrementable_::check_(BOOST_comma(++x,0))) == 1 - ); - }; - - template - struct postfix_impl - { - static typename boost::remove_cv::type& x; - - BOOST_STATIC_CONSTANT( - bool - , value = sizeof(is_incrementable_::check_(BOOST_comma(x++,0))) == 1 - ); - }; - -# if defined(BOOST_MSVC) -# pragma warning(pop) -# endif - -} - -# undef BOOST_comma - -template -struct is_incrementable -BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::impl::value) -{ - BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::impl::value) - BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_incrementable,(T)) -}; - -template -struct is_postfix_incrementable -BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::impl::value) -{ - BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::postfix_impl::value) - BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_postfix_incrementable,(T)) -}; - -} // namespace detail - -BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_incrementable) -BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_postfix_incrementable) - -} // namespace boost - -# include - -#endif // IS_INCREMENTABLE_DWA200415_HPP diff --git a/boost/detail/is_xxx.hpp b/boost/detail/is_xxx.hpp deleted file mode 100644 index 3f9a126..0000000 --- a/boost/detail/is_xxx.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright David Abrahams 2005. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_DETAIL_IS_XXX_DWA20051011_HPP -# define BOOST_DETAIL_IS_XXX_DWA20051011_HPP - -# include -# include -# include - - -# define BOOST_DETAIL_IS_XXX_DEF(name, qualified_name, nargs) \ -template \ -struct is_##name : mpl::false_ \ -{ \ -}; \ - \ -template < BOOST_PP_ENUM_PARAMS_Z(1, nargs, class T) > \ -struct is_##name< \ - qualified_name< BOOST_PP_ENUM_PARAMS_Z(1, nargs, T) > \ -> \ - : mpl::true_ \ -{ \ -}; - - -#endif // BOOST_DETAIL_IS_XXX_DWA20051011_HPP diff --git a/boost/detail/lcast_precision.hpp b/boost/detail/lcast_precision.hpp deleted file mode 100644 index 93abce1..0000000 --- a/boost/detail/lcast_precision.hpp +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright Alexander Nasonov & Paul A. Bristow 2006. - -// 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) - -#ifndef BOOST_DETAIL_LCAST_PRECISION_HPP_INCLUDED -#define BOOST_DETAIL_LCAST_PRECISION_HPP_INCLUDED - -#include -#include -#include - -#include -#include - -#ifndef BOOST_NO_IS_ABSTRACT -// Fix for SF:1358600 - lexical_cast & pure virtual functions & VC 8 STL -#include -#include -#endif - -#if defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || \ - (defined(BOOST_MSVC) && (BOOST_MSVC<1310)) - -#define BOOST_LCAST_NO_COMPILE_TIME_PRECISION -#endif - -#ifdef BOOST_LCAST_NO_COMPILE_TIME_PRECISION -#include -#else -#include -#endif - -namespace boost { namespace detail { - -class lcast_abstract_stub {}; - -#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION -// Calculate an argument to pass to std::ios_base::precision from -// lexical_cast. See alternative implementation for broken standard -// libraries in lcast_get_precision below. Keep them in sync, please. -template -struct lcast_precision -{ -#ifdef BOOST_NO_IS_ABSTRACT - typedef std::numeric_limits limits; // No fix for SF:1358600. -#else - typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_< - boost::is_abstract - , std::numeric_limits - , std::numeric_limits - >::type limits; -#endif - - BOOST_STATIC_CONSTANT(bool, use_default_precision = - !limits::is_specialized || limits::is_exact - ); - - BOOST_STATIC_CONSTANT(bool, is_specialized_bin = - !use_default_precision && - limits::radix == 2 && limits::digits > 0 - ); - - BOOST_STATIC_CONSTANT(bool, is_specialized_dec = - !use_default_precision && - limits::radix == 10 && limits::digits10 > 0 - ); - - BOOST_STATIC_CONSTANT(std::streamsize, streamsize_max = - boost::integer_traits::const_max - ); - - BOOST_STATIC_CONSTANT(unsigned int, precision_dec = limits::digits10 + 1U); - - BOOST_STATIC_ASSERT(!is_specialized_dec || - precision_dec <= streamsize_max + 0UL - ); - - BOOST_STATIC_CONSTANT(unsigned long, precision_bin = - 2UL + limits::digits * 30103UL / 100000UL - ); - - BOOST_STATIC_ASSERT(!is_specialized_bin || - (limits::digits + 0UL < ULONG_MAX / 30103UL && - precision_bin > limits::digits10 + 0UL && - precision_bin <= streamsize_max + 0UL) - ); - - BOOST_STATIC_CONSTANT(std::streamsize, value = - is_specialized_bin ? precision_bin - : is_specialized_dec ? precision_dec : 6 - ); -}; -#endif - -template -inline std::streamsize lcast_get_precision(T* = 0) -{ -#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION - return lcast_precision::value; -#else // Follow lcast_precision algorithm at run-time: - -#ifdef BOOST_NO_IS_ABSTRACT - typedef std::numeric_limits limits; // No fix for SF:1358600. -#else - typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_< - boost::is_abstract - , std::numeric_limits - , std::numeric_limits - >::type limits; -#endif - - bool const use_default_precision = - !limits::is_specialized || limits::is_exact; - - if(!use_default_precision) - { // Includes all built-in floating-point types, float, double ... - // and UDT types for which digits (significand bits) is defined (not zero) - - bool const is_specialized_bin = - limits::radix == 2 && limits::digits > 0; - bool const is_specialized_dec = - limits::radix == 10 && limits::digits10 > 0; - std::streamsize const streamsize_max = - (boost::integer_traits::max)(); - - if(is_specialized_bin) - { // Floating-point types with - // limits::digits defined by the specialization. - - unsigned long const digits = limits::digits; - unsigned long const precision = 2UL + digits * 30103UL / 100000UL; - // unsigned long is selected because it is at least 32-bits - // and thus ULONG_MAX / 30103UL is big enough for all types. - BOOST_ASSERT( - digits < ULONG_MAX / 30103UL && - precision > limits::digits10 + 0UL && - precision <= streamsize_max + 0UL - ); - return precision; - } - else if(is_specialized_dec) - { // Decimal Floating-point type, most likely a User Defined Type - // rather than a real floating-point hardware type. - unsigned int const precision = limits::digits10 + 1U; - BOOST_ASSERT(precision <= streamsize_max + 0UL); - return precision; - } - } - - // Integral type (for which precision has no effect) - // or type T for which limits is NOT specialized, - // so assume stream precision remains the default 6 decimal digits. - // Warning: if your User-defined Floating-point type T is NOT specialized, - // then you may lose accuracy by only using 6 decimal digits. - // To avoid this, you need to specialize T with either - // radix == 2 and digits == the number of significand bits, - // OR - // radix = 10 and digits10 == the number of decimal digits. - - return 6; -#endif -} - -template -inline void lcast_set_precision(std::ios_base& stream, T*) -{ - stream.precision(lcast_get_precision()); -} - -template -inline void lcast_set_precision(std::ios_base& stream, Source*, Target*) -{ - std::streamsize const s = lcast_get_precision(static_cast(0)); - std::streamsize const t = lcast_get_precision(static_cast(0)); - stream.precision(s > t ? s : t); -} - -}} - -#endif // BOOST_DETAIL_LCAST_PRECISION_HPP_INCLUDED - diff --git a/boost/detail/lightweight_main.hpp b/boost/detail/lightweight_main.hpp deleted file mode 100644 index 1705309..0000000 --- a/boost/detail/lightweight_main.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// boost/detail/lightweight_main.hpp -------------------------------------------------// - -// Copyright Beman Dawes 2010 - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - -#include -#include - -//--------------------------------------------------------------------------------------// -// // -// exception reporting main() that calls cpp_main() // -// // -//--------------------------------------------------------------------------------------// - -int cpp_main(int argc, char* argv[]); - -int main(int argc, char* argv[]) -{ - try - { - return cpp_main(argc, argv); - } - - catch (const std::exception& ex) - { - std::cout - << "\nERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR\n" - << "\n****************************** std::exception *****************************\n" - << ex.what() - << "\n***************************************************************************\n" - << std::endl; - } - return 1; -} diff --git a/boost/detail/lightweight_mutex.hpp b/boost/detail/lightweight_mutex.hpp deleted file mode 100644 index b7a7f6d..0000000 --- a/boost/detail/lightweight_mutex.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED -#define BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// -// boost/detail/lightweight_mutex.hpp - lightweight mutex -// -// Copyright (c) 2002, 2003 Peter Dimov and Multi Media Ltd. -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt -// - -#include - -#endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED diff --git a/boost/detail/lightweight_test.hpp b/boost/detail/lightweight_test.hpp deleted file mode 100644 index 9fece8a..0000000 --- a/boost/detail/lightweight_test.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2014 Glen Fernandes - * - * Distributed under the Boost Software License, Version 1.0. (See - * accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ - -#ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP -#define BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP - -// The header file at this path is deprecated; -// use boost/core/lightweight_test.hpp instead. - -#include - -#endif diff --git a/boost/detail/lightweight_thread.hpp b/boost/detail/lightweight_thread.hpp deleted file mode 100644 index 6fe70a6..0000000 --- a/boost/detail/lightweight_thread.hpp +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED -#define BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// boost/detail/lightweight_thread.hpp -// -// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. -// Copyright (c) 2008 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt - -#include -#include -#include - -// pthread_create, pthread_join - -#if defined( BOOST_HAS_PTHREADS ) - -#include - -#else - -#include -#include - -typedef HANDLE pthread_t; - -int pthread_create( pthread_t * thread, void const *, unsigned (__stdcall * start_routine) (void*), void* arg ) -{ - HANDLE h = (HANDLE)_beginthreadex( 0, 0, start_routine, arg, 0, 0 ); - - if( h != 0 ) - { - *thread = h; - return 0; - } - else - { - return EAGAIN; - } -} - -int pthread_join( pthread_t thread, void ** /*value_ptr*/ ) -{ - ::WaitForSingleObject( thread, INFINITE ); - ::CloseHandle( thread ); - return 0; -} - -#endif - -// template int lw_thread_create( pthread_t & pt, F f ); - -namespace boost -{ - -namespace detail -{ - -class lw_abstract_thread -{ -public: - - virtual ~lw_abstract_thread() {} - virtual void run() = 0; -}; - -#if defined( BOOST_HAS_PTHREADS ) - -extern "C" void * lw_thread_routine( void * pv ) -{ - std::auto_ptr pt( static_cast( pv ) ); - - pt->run(); - - return 0; -} - -#else - -unsigned __stdcall lw_thread_routine( void * pv ) -{ - std::auto_ptr pt( static_cast( pv ) ); - - pt->run(); - - return 0; -} - -#endif - -template class lw_thread_impl: public lw_abstract_thread -{ -public: - - explicit lw_thread_impl( F f ): f_( f ) - { - } - - void run() - { - f_(); - } - -private: - - F f_; -}; - -template int lw_thread_create( pthread_t & pt, F f ) -{ - std::auto_ptr p( new lw_thread_impl( f ) ); - - int r = pthread_create( &pt, 0, lw_thread_routine, p.get() ); - - if( r == 0 ) - { - p.release(); - } - - return r; -} - -} // namespace detail -} // namespace boost - -#endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED diff --git a/boost/detail/named_template_params.hpp b/boost/detail/named_template_params.hpp deleted file mode 100644 index e7cb079..0000000 --- a/boost/detail/named_template_params.hpp +++ /dev/null @@ -1,177 +0,0 @@ -// (C) Copyright Jeremy Siek 2001. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// Revision History: - -// 04 Oct 2001 David Abrahams -// Changed name of "bind" to "select" to avoid problems with MSVC. - -#ifndef BOOST_DETAIL_NAMED_TEMPLATE_PARAMS_HPP -#define BOOST_DETAIL_NAMED_TEMPLATE_PARAMS_HPP - -#include -#include // for is_reference -#if defined(__BORLANDC__) -#include -#endif - -namespace boost { - namespace detail { - - struct default_argument { }; - - struct dummy_default_gen { - template - struct select { - typedef default_argument type; - }; - }; - - // This class template is a workaround for MSVC. - template struct default_generator { - typedef detail::dummy_default_gen type; - }; - - template struct is_default { - enum { value = false }; - typedef type_traits::no_type type; - }; - template <> struct is_default { - enum { value = true }; - typedef type_traits::yes_type type; - }; - - struct choose_default { - template - struct select { - typedef typename default_generator::type Gen; - typedef typename Gen::template select::type type; - }; - }; - struct choose_arg { - template - struct select { - typedef Arg type; - }; - }; - -#if defined(__BORLANDC__) - template - struct choose_arg_or_default { typedef choose_arg type; }; - template <> - struct choose_arg_or_default { - typedef choose_default type; - }; -#else - template - struct choose_arg_or_default { typedef choose_arg type; }; - template <> - struct choose_arg_or_default { - typedef choose_default type; - }; -#endif - - template - class resolve_default { -#if defined(__BORLANDC__) - typedef typename choose_arg_or_default::type>::type Selector; -#else - // This usually works for Borland, but I'm seeing weird errors in - // iterator_adaptor_test.cpp when using this method. - enum { is_def = is_default::value }; - typedef typename choose_arg_or_default::type Selector; -#endif - public: - typedef typename Selector - ::template select::type type; - }; - - // To differentiate an unnamed parameter from a traits generator - // we use is_convertible. - struct named_template_param_base { }; - - template - struct is_named_param_list { - enum { value = is_convertible::value }; - }; - - struct choose_named_params { - template struct select { typedef Prev type; }; - }; - struct choose_default_arg { - template struct select { - typedef detail::default_argument type; - }; - }; - - template struct choose_default_dispatch_; - template <> struct choose_default_dispatch_ { - typedef choose_named_params type; - }; - template <> struct choose_default_dispatch_ { - typedef choose_default_arg type; - }; - // The use of inheritance here is a Solaris Forte 6 workaround. - template struct choose_default_dispatch - : public choose_default_dispatch_ { }; - - template - struct choose_default_argument { - enum { is_named = is_named_param_list::value }; - typedef typename choose_default_dispatch::type Selector; - typedef typename Selector::template select::type type; - }; - - // This macro assumes that there is a class named default_##TYPE - // defined before the application of the macro. This class should - // have a single member class template named "select" with two - // template parameters: the type of the class being created (e.g., - // the iterator_adaptor type when creating iterator adaptors) and - // a traits class. The select class should have a single typedef - // named "type" that produces the default for TYPE. See - // boost/iterator_adaptors.hpp for an example usage. Also, - // applications of this macro must be placed in namespace - // boost::detail. - -#define BOOST_NAMED_TEMPLATE_PARAM(TYPE) \ - struct get_##TYPE##_from_named { \ - template \ - struct select { \ - typedef typename NamedParams::traits NamedTraits; \ - typedef typename NamedTraits::TYPE TYPE; \ - typedef typename resolve_default::type type; \ - }; \ - }; \ - struct pass_thru_##TYPE { \ - template struct select { \ - typedef typename resolve_default::type type; \ - };\ - }; \ - template \ - struct get_##TYPE##_dispatch { }; \ - template <> struct get_##TYPE##_dispatch<1> { \ - typedef get_##TYPE##_from_named type; \ - }; \ - template <> struct get_##TYPE##_dispatch<0> { \ - typedef pass_thru_##TYPE type; \ - }; \ - template \ - class get_##TYPE { \ - enum { is_named = is_named_param_list::value }; \ - typedef typename get_##TYPE##_dispatch::type Selector; \ - public: \ - typedef typename Selector::template select::type type; \ - }; \ - template <> struct default_generator { \ - typedef default_##TYPE type; \ - } - - - } // namespace detail -} // namespace boost - -#endif // BOOST_DETAIL_NAMED_TEMPLATE_PARAMS_HPP diff --git a/boost/detail/no_exceptions_support.hpp b/boost/detail/no_exceptions_support.hpp deleted file mode 100644 index 7d17454..0000000 --- a/boost/detail/no_exceptions_support.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2014 Glen Fernandes - * - * Distributed under the Boost Software License, Version 1.0. (See - * accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ - -#ifndef BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP -#define BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP - -// The header file at this path is deprecated; -// use boost/core/no_exceptions_support.hpp instead. - -#include - -#endif diff --git a/boost/detail/numeric_traits.hpp b/boost/detail/numeric_traits.hpp deleted file mode 100644 index 2f97ebf..0000000 --- a/boost/detail/numeric_traits.hpp +++ /dev/null @@ -1,182 +0,0 @@ -// (C) Copyright David Abrahams 2001, Howard Hinnant 2001. -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Template class numeric_traits -- -// -// Supplies: -// -// typedef difference_type -- a type used to represent the difference -// between any two values of Number. -// -// Support: -// 1. Not all specializations are supplied -// -// 2. Use of specializations that are not supplied will cause a -// compile-time error -// -// 3. Users are free to specialize numeric_traits for any type. -// -// 4. Right now, specializations are only supplied for integer types. -// -// 5. On implementations which do not supply compile-time constants in -// std::numeric_limits<>, only specializations for built-in integer types -// are supplied. -// -// 6. Handling of numbers whose range of representation is at least as -// great as boost::intmax_t can cause some differences to be -// unrepresentable in difference_type: -// -// Number difference_type -// ------ --------------- -// signed Number -// unsigned intmax_t -// -// template typename numeric_traits::difference_type -// numeric_distance(Number x, Number y) -// computes (y - x), attempting to avoid overflows. -// - -// See http://www.boost.org for most recent version including documentation. - -// Revision History -// 11 Feb 2001 - Use BOOST_STATIC_CONSTANT (David Abrahams) -// 11 Feb 2001 - Rolled back ineffective Borland-specific code -// (David Abrahams) -// 10 Feb 2001 - Rolled in supposed Borland fixes from John Maddock, but -// not seeing any improvement yet (David Abrahams) -// 06 Feb 2001 - Factored if_true out into boost/detail/select_type.hpp -// (David Abrahams) -// 23 Jan 2001 - Fixed logic of difference_type selection, which was -// completely wack. In the process, added digit_traits<> -// to compute the number of digits in intmax_t even when -// not supplied by numeric_limits<>. (David Abrahams) -// 21 Jan 2001 - Created (David Abrahams) - -#ifndef BOOST_NUMERIC_TRAITS_HPP_DWA20001901 -# define BOOST_NUMERIC_TRAITS_HPP_DWA20001901 - -# include -# include -# include -# include -# include -# include - -namespace boost { namespace detail { - - // Template class is_signed -- determine whether a numeric type is signed - // Requires that T is constructable from the literals -1 and 0. Compile-time - // error results if that requirement is not met (and thus signedness is not - // likely to have meaning for that type). - template - struct is_signed - { -#if defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) - BOOST_STATIC_CONSTANT(bool, value = (Number(-1) < Number(0))); -#else - BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits::is_signed); -#endif - }; - -# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - // digit_traits - compute the number of digits in a built-in integer - // type. Needed for implementations on which numeric_limits is not specialized - // for intmax_t (e.g. VC6). - template struct digit_traits_select; - - // numeric_limits is specialized; just select that version of digits - template <> struct digit_traits_select - { - template struct traits - { - BOOST_STATIC_CONSTANT(int, digits = std::numeric_limits::digits); - }; - }; - - // numeric_limits is not specialized; compute digits from sizeof(T) - template <> struct digit_traits_select - { - template struct traits - { - BOOST_STATIC_CONSTANT(int, digits = ( - sizeof(T) * std::numeric_limits::digits - - (is_signed::value ? 1 : 0)) - ); - }; - }; - - // here's the "usable" template - template struct digit_traits - { - typedef digit_traits_select< - ::std::numeric_limits::is_specialized> selector; - typedef typename selector::template traits traits; - BOOST_STATIC_CONSTANT(int, digits = traits::digits); - }; -#endif - - // Template class integer_traits -- traits of various integer types - // This should probably be rolled into boost::integer_traits one day, but I - // need it to work without - template - struct integer_traits - { -# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - private: - typedef Integer integer_type; - typedef std::numeric_limits x; - public: - typedef typename - if_true<(int(x::is_signed) - && (!int(x::is_bounded) - // digits is the number of no-sign bits - || (int(x::digits) + 1 >= digit_traits::digits)))>::template then< - Integer, - - typename if_true<(int(x::digits) + 1 < digit_traits::digits)>::template then< - signed int, - - typename if_true<(int(x::digits) + 1 < digit_traits::digits)>::template then< - signed long, - - // else - intmax_t - >::type>::type>::type difference_type; -#else - BOOST_STATIC_ASSERT(boost::is_integral::value); - - typedef typename - if_true<(sizeof(Integer) >= sizeof(intmax_t))>::template then< - - typename if_true<(is_signed::value)>::template then< - Integer, - intmax_t - >::type, - - typename if_true<(sizeof(Integer) < sizeof(std::ptrdiff_t))>::template then< - std::ptrdiff_t, - intmax_t - >::type - >::type difference_type; -# endif - }; - - // Right now, only supports integers, but should be expanded. - template - struct numeric_traits - { - typedef typename integer_traits::difference_type difference_type; - }; - - template - typename numeric_traits::difference_type numeric_distance(Number x, Number y) - { - typedef typename numeric_traits::difference_type difference_type; - return difference_type(y) - difference_type(x); - } -}} - -#endif // BOOST_NUMERIC_TRAITS_HPP_DWA20001901 diff --git a/boost/detail/ob_compressed_pair.hpp b/boost/detail/ob_compressed_pair.hpp deleted file mode 100644 index 326e454..0000000 --- a/boost/detail/ob_compressed_pair.hpp +++ /dev/null @@ -1,499 +0,0 @@ -// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000. -// 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). -// -// See http://www.boost.org/libs/utility for most recent version including documentation. -// see libs/utility/compressed_pair.hpp -// -/* Release notes: - 20 Jan 2001: - Fixed obvious bugs (David Abrahams) - 07 Oct 2000: - Added better single argument constructor support. - 03 Oct 2000: - Added VC6 support (JM). - 23rd July 2000: - Additional comments added. (JM) - Jan 2000: - Original version: this version crippled for use with crippled compilers - - John Maddock Jan 2000. -*/ - - -#ifndef BOOST_OB_COMPRESSED_PAIR_HPP -#define BOOST_OB_COMPRESSED_PAIR_HPP - -#include -#ifndef BOOST_OBJECT_TYPE_TRAITS_HPP -#include -#endif -#ifndef BOOST_SAME_TRAITS_HPP -#include -#endif -#ifndef BOOST_CALL_TRAITS_HPP -#include -#endif - -namespace boost -{ -#ifdef BOOST_MSVC6_MEMBER_TEMPLATES -// -// use member templates to emulate -// partial specialisation. Note that due to -// problems with overload resolution with VC6 -// each of the compressed_pair versions that follow -// have one template single-argument constructor -// in place of two specific constructors: -// - -template -class compressed_pair; - -namespace detail{ - -template -struct best_conversion_traits -{ - typedef char one; - typedef char (&two)[2]; - static A a; - static one test(T1); - static two test(T2); - - enum { value = sizeof(test(a)) }; -}; - -template -struct init_one; - -template <> -struct init_one<1> -{ - template - static void init(const A& a, T1* p1, T2*) - { - *p1 = a; - } -}; - -template <> -struct init_one<2> -{ - template - static void init(const A& a, T1*, T2* p2) - { - *p2 = a; - } -}; - - -// T1 != T2, both non-empty -template -class compressed_pair_0 -{ -private: - T1 _first; - T2 _second; -public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_0() : _first(), _second() {} - compressed_pair_0(first_param_type x, second_param_type y) : _first(x), _second(y) {} - template - explicit compressed_pair_0(const A& val) - { - init_one::value>::init(val, &_first, &_second); - } - compressed_pair_0(const ::boost::compressed_pair& x) - : _first(x.first()), _second(x.second()) {} - -#if 0 - compressed_pair_0& operator=(const compressed_pair_0& x) { - cout << "assigning compressed pair 0" << endl; - _first = x._first; - _second = x._second; - cout << "finished assigning compressed pair 0" << endl; - return *this; - } -#endif - - first_reference first() { return _first; } - first_const_reference first() const { return _first; } - - second_reference second() { return _second; } - second_const_reference second() const { return _second; } - - void swap(compressed_pair_0& y) - { - using std::swap; - swap(_first, y._first); - swap(_second, y._second); - } -}; - -// T1 != T2, T2 empty -template -class compressed_pair_1 : T2 -{ -private: - T1 _first; -public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_1() : T2(), _first() {} - compressed_pair_1(first_param_type x, second_param_type y) : T2(y), _first(x) {} - - template - explicit compressed_pair_1(const A& val) - { - init_one::value>::init(val, &_first, static_cast(this)); - } - - compressed_pair_1(const ::boost::compressed_pair& x) - : T2(x.second()), _first(x.first()) {} - - first_reference first() { return _first; } - first_const_reference first() const { return _first; } - - second_reference second() { return *this; } - second_const_reference second() const { return *this; } - - void swap(compressed_pair_1& y) - { - // no need to swap empty base class: - using std::swap; - swap(_first, y._first); - } -}; - -// T1 != T2, T1 empty -template -class compressed_pair_2 : T1 -{ -private: - T2 _second; -public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_2() : T1(), _second() {} - compressed_pair_2(first_param_type x, second_param_type y) : T1(x), _second(y) {} - template - explicit compressed_pair_2(const A& val) - { - init_one::value>::init(val, static_cast(this), &_second); - } - compressed_pair_2(const ::boost::compressed_pair& x) - : T1(x.first()), _second(x.second()) {} - -#if 0 - compressed_pair_2& operator=(const compressed_pair_2& x) { - cout << "assigning compressed pair 2" << endl; - T1::operator=(x); - _second = x._second; - cout << "finished assigning compressed pair 2" << endl; - return *this; - } -#endif - first_reference first() { return *this; } - first_const_reference first() const { return *this; } - - second_reference second() { return _second; } - second_const_reference second() const { return _second; } - - void swap(compressed_pair_2& y) - { - // no need to swap empty base class: - using std::swap; - swap(_second, y._second); - } -}; - -// T1 != T2, both empty -template -class compressed_pair_3 : T1, T2 -{ -public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_3() : T1(), T2() {} - compressed_pair_3(first_param_type x, second_param_type y) : T1(x), T2(y) {} - template - explicit compressed_pair_3(const A& val) - { - init_one::value>::init(val, static_cast(this), static_cast(this)); - } - compressed_pair_3(const ::boost::compressed_pair& x) - : T1(x.first()), T2(x.second()) {} - - first_reference first() { return *this; } - first_const_reference first() const { return *this; } - - second_reference second() { return *this; } - second_const_reference second() const { return *this; } - - void swap(compressed_pair_3& y) - { - // no need to swap empty base classes: - } -}; - -// T1 == T2, and empty -template -class compressed_pair_4 : T1 -{ -public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_4() : T1() {} - compressed_pair_4(first_param_type x, second_param_type y) : T1(x), m_second(y) {} - // only one single argument constructor since T1 == T2 - explicit compressed_pair_4(first_param_type x) : T1(x), m_second(x) {} - compressed_pair_4(const ::boost::compressed_pair& x) - : T1(x.first()), m_second(x.second()) {} - - first_reference first() { return *this; } - first_const_reference first() const { return *this; } - - second_reference second() { return m_second; } - second_const_reference second() const { return m_second; } - - void swap(compressed_pair_4& y) - { - // no need to swap empty base classes: - } -private: - T2 m_second; -}; - -// T1 == T2, not empty -template -class compressed_pair_5 -{ -private: - T1 _first; - T2 _second; -public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair_5() : _first(), _second() {} - compressed_pair_5(first_param_type x, second_param_type y) : _first(x), _second(y) {} - // only one single argument constructor since T1 == T2 - explicit compressed_pair_5(first_param_type x) : _first(x), _second(x) {} - compressed_pair_5(const ::boost::compressed_pair& c) - : _first(c.first()), _second(c.second()) {} - - first_reference first() { return _first; } - first_const_reference first() const { return _first; } - - second_reference second() { return _second; } - second_const_reference second() const { return _second; } - - void swap(compressed_pair_5& y) - { - using std::swap; - swap(_first, y._first); - swap(_second, y._second); - } -}; - -template -struct compressed_pair_chooser -{ - template - struct rebind - { - typedef compressed_pair_0 type; - }; -}; - -template <> -struct compressed_pair_chooser -{ - template - struct rebind - { - typedef compressed_pair_1 type; - }; -}; - -template <> -struct compressed_pair_chooser -{ - template - struct rebind - { - typedef compressed_pair_2 type; - }; -}; - -template <> -struct compressed_pair_chooser -{ - template - struct rebind - { - typedef compressed_pair_3 type; - }; -}; - -template <> -struct compressed_pair_chooser -{ - template - struct rebind - { - typedef compressed_pair_4 type; - }; -}; - -template <> -struct compressed_pair_chooser -{ - template - struct rebind - { - typedef compressed_pair_5 type; - }; -}; - -template -struct compressed_pair_traits -{ -private: - typedef compressed_pair_chooser::value, is_empty::value, is_same::value> chooser; - typedef typename chooser::template rebind bound_type; -public: - typedef typename bound_type::type type; -}; - -} // namespace detail - -template -class compressed_pair : public detail::compressed_pair_traits::type -{ -private: - typedef typename detail::compressed_pair_traits::type base_type; -public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair() : base_type() {} - compressed_pair(first_param_type x, second_param_type y) : base_type(x, y) {} - template - explicit compressed_pair(const A& x) : base_type(x){} - - first_reference first() { return base_type::first(); } - first_const_reference first() const { return base_type::first(); } - - second_reference second() { return base_type::second(); } - second_const_reference second() const { return base_type::second(); } -}; - -template -inline void swap(compressed_pair& x, compressed_pair& y) -{ - x.swap(y); -} - -#else -// no partial specialisation, no member templates: - -template -class compressed_pair -{ -private: - T1 _first; - T2 _second; -public: - typedef T1 first_type; - typedef T2 second_type; - typedef typename call_traits::param_type first_param_type; - typedef typename call_traits::param_type second_param_type; - typedef typename call_traits::reference first_reference; - typedef typename call_traits::reference second_reference; - typedef typename call_traits::const_reference first_const_reference; - typedef typename call_traits::const_reference second_const_reference; - - compressed_pair() : _first(), _second() {} - compressed_pair(first_param_type x, second_param_type y) : _first(x), _second(y) {} - explicit compressed_pair(first_param_type x) : _first(x), _second() {} - // can't define this in case T1 == T2: - // explicit compressed_pair(second_param_type y) : _first(), _second(y) {} - - first_reference first() { return _first; } - first_const_reference first() const { return _first; } - - second_reference second() { return _second; } - second_const_reference second() const { return _second; } - - void swap(compressed_pair& y) - { - using std::swap; - swap(_first, y._first); - swap(_second, y._second); - } -}; - -template -inline void swap(compressed_pair& x, compressed_pair& y) -{ - x.swap(y); -} - -#endif - -} // boost - -#endif // BOOST_OB_COMPRESSED_PAIR_HPP - - - diff --git a/boost/detail/quick_allocator.hpp b/boost/detail/quick_allocator.hpp deleted file mode 100644 index d54b3a7..0000000 --- a/boost/detail/quick_allocator.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED -#define BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// -// detail/quick_allocator.hpp -// -// Copyright (c) 2003 David Abrahams -// Copyright (c) 2003 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt -// - -#include - -#endif // #ifndef BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED diff --git a/boost/detail/reference_content.hpp b/boost/detail/reference_content.hpp deleted file mode 100644 index 36b80d2..0000000 --- a/boost/detail/reference_content.hpp +++ /dev/null @@ -1,120 +0,0 @@ -//----------------------------------------------------------------------------- -// boost detail/reference_content.hpp header file -// See http://www.boost.org for updates, documentation, and revision history. -//----------------------------------------------------------------------------- -// -// Copyright (c) 2003 -// Eric Friedman -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_DETAIL_REFERENCE_CONTENT_HPP -#define BOOST_DETAIL_REFERENCE_CONTENT_HPP - -#include "boost/config.hpp" - -# include "boost/mpl/bool.hpp" -# include "boost/type_traits/has_nothrow_copy.hpp" - -#include "boost/mpl/void.hpp" - -namespace boost { - -namespace detail { - -/////////////////////////////////////////////////////////////////////////////// -// (detail) class template reference_content -// -// Non-Assignable wrapper for references. -// -template -class reference_content -{ -private: // representation - - RefT content_; - -public: // structors - - ~reference_content() - { - } - - reference_content(RefT r) - : content_( r ) - { - } - - reference_content(const reference_content& operand) - : content_( operand.content_ ) - { - } - -private: // non-Assignable - - reference_content& operator=(const reference_content&); - -public: // queries - - RefT get() const - { - return content_; - } - -}; - -/////////////////////////////////////////////////////////////////////////////// -// (detail) metafunction make_reference_content -// -// Wraps with reference_content if specified type is reference. -// - -template struct make_reference_content; - - -template -struct make_reference_content -{ - typedef T type; -}; - -template -struct make_reference_content< T& > -{ - typedef reference_content type; -}; - - -template <> -struct make_reference_content< mpl::void_ > -{ - template - struct apply - : make_reference_content - { - }; - - typedef mpl::void_ type; -}; - -} // namespace detail - -/////////////////////////////////////////////////////////////////////////////// -// reference_content type traits specializations -// - - -template -struct has_nothrow_copy< - ::boost::detail::reference_content< T& > - > - : mpl::true_ -{ -}; - - -} // namespace boost - -#endif // BOOST_DETAIL_REFERENCE_CONTENT_HPP diff --git a/boost/detail/scoped_enum_emulation.hpp b/boost/detail/scoped_enum_emulation.hpp deleted file mode 100644 index 1c7bc23..0000000 --- a/boost/detail/scoped_enum_emulation.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2014 Andrey Semashev - * - * Distributed under the Boost Software License, Version 1.0. (See - * accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ - -#ifndef BOOST_DETAIL_SCOPED_ENUM_EMULATION_HPP -#define BOOST_DETAIL_SCOPED_ENUM_EMULATION_HPP - -// The header file at this path is deprecated; -// use boost/core/scoped_enum.hpp instead. - -#include - -#endif diff --git a/boost/detail/select_type.hpp b/boost/detail/select_type.hpp deleted file mode 100644 index c13946f..0000000 --- a/boost/detail/select_type.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// (C) Copyright David Abrahams 2001. -// Distributed under the 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 for most recent version including documentation. - -// Revision History -// 09 Feb 01 Applied John Maddock's Borland patch Moving -// specialization to unspecialized template (David Abrahams) -// 06 Feb 01 Created (David Abrahams) - -#ifndef SELECT_TYPE_DWA20010206_HPP -# define SELECT_TYPE_DWA20010206_HPP - -namespace boost { namespace detail { - - // Template class if_true -- select among 2 types based on a bool constant expression - // Usage: - // typename if_true<(bool_const_expression)>::template then::type - - // HP aCC cannot deal with missing names for template value parameters - template struct if_true - { - template - struct then { typedef T type; }; - }; - - template <> - struct if_true - { - template - struct then { typedef F type; }; - }; -}} -#endif // SELECT_TYPE_DWA20010206_HPP diff --git a/boost/detail/sp_typeinfo.hpp b/boost/detail/sp_typeinfo.hpp deleted file mode 100644 index 4e4de55..0000000 --- a/boost/detail/sp_typeinfo.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED -#define BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// detail/sp_typeinfo.hpp -// -// Deprecated, please use boost/core/typeinfo.hpp -// -// Copyright 2007 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -namespace boost -{ - -namespace detail -{ - -typedef boost::core::typeinfo sp_typeinfo; - -} // namespace detail - -} // namespace boost - -#define BOOST_SP_TYPEID(T) BOOST_CORE_TYPEID(T) - -#endif // #ifndef BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED diff --git a/boost/detail/templated_streams.hpp b/boost/detail/templated_streams.hpp deleted file mode 100644 index 1fa6ee3..0000000 --- a/boost/detail/templated_streams.hpp +++ /dev/null @@ -1,74 +0,0 @@ -//----------------------------------------------------------------------------- -// boost detail/templated_streams.hpp header file -// See http://www.boost.org for updates, documentation, and revision history. -//----------------------------------------------------------------------------- -// -// Copyright (c) 2003 -// Eric Friedman -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_DETAIL_TEMPLATED_STREAMS_HPP -#define BOOST_DETAIL_TEMPLATED_STREAMS_HPP - -#include "boost/config.hpp" - -/////////////////////////////////////////////////////////////////////////////// -// (detail) BOOST_TEMPLATED_STREAM_* macros -// -// Provides workaround platforms without stream class templates. -// - -#if !defined(BOOST_NO_STD_LOCALE) - -#define BOOST_TEMPLATED_STREAM_TEMPLATE(E,T) \ - template < typename E , typename T > - -#define BOOST_TEMPLATED_STREAM_TEMPLATE_ALLOC(E,T,A) \ - template < typename E , typename T , typename A > - -#define BOOST_TEMPLATED_STREAM_ARGS(E,T) \ - typename E , typename T - -#define BOOST_TEMPLATED_STREAM_ARGS_ALLOC(E,T,A) \ - typename E , typename T , typename A - -#define BOOST_TEMPLATED_STREAM_COMMA , - -#define BOOST_TEMPLATED_STREAM_ELEM(E) E -#define BOOST_TEMPLATED_STREAM_TRAITS(T) T -#define BOOST_TEMPLATED_STREAM_ALLOC(A) A - -#define BOOST_TEMPLATED_STREAM(X,E,T) \ - BOOST_JOIN(std::basic_,X)< E , T > - -#define BOOST_TEMPLATED_STREAM_WITH_ALLOC(X,E,T,A) \ - BOOST_JOIN(std::basic_,X)< E , T , A > - -#else // defined(BOOST_NO_STD_LOCALE) - -#define BOOST_TEMPLATED_STREAM_TEMPLATE(E,T) /**/ - -#define BOOST_TEMPLATED_STREAM_TEMPLATE_ALLOC(E,T,A) /**/ - -#define BOOST_TEMPLATED_STREAM_ARGS(E,T) /**/ - -#define BOOST_TEMPLATED_STREAM_ARGS_ALLOC(E,T,A) /**/ - -#define BOOST_TEMPLATED_STREAM_COMMA /**/ - -#define BOOST_TEMPLATED_STREAM_ELEM(E) char -#define BOOST_TEMPLATED_STREAM_TRAITS(T) std::char_traits -#define BOOST_TEMPLATED_STREAM_ALLOC(A) std::allocator - -#define BOOST_TEMPLATED_STREAM(X,E,T) \ - std::X - -#define BOOST_TEMPLATED_STREAM_WITH_ALLOC(X,E,T,A) \ - std::X - -#endif // BOOST_NO_STD_LOCALE - -#endif // BOOST_DETAIL_TEMPLATED_STREAMS_HPP diff --git a/boost/detail/utf8_codecvt_facet.hpp b/boost/detail/utf8_codecvt_facet.hpp deleted file mode 100644 index 753b339..0000000 --- a/boost/detail/utf8_codecvt_facet.hpp +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu) -// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu). -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_UTF8_CODECVT_FACET_HPP -#define BOOST_UTF8_CODECVT_FACET_HPP - -// MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// utf8_codecvt_facet.hpp - -// This header defines class utf8_codecvt_facet, derived fro -// std::codecvt, which can be used to convert utf8 data in -// files into wchar_t strings in the application. -// -// The header is NOT STANDALONE, and is not to be included by the USER. -// There are at least two libraries which want to use this functionality, and -// we want to avoid code duplication. It would be possible to create utf8 -// library, but: -// - this requires review process first -// - in the case, when linking the a library which uses utf8 -// (say 'program_options'), user should also link to the utf8 library. -// This seems inconvenient, and asking a user to link to an unrevieved -// library is strange. -// Until the above points are fixed, a library which wants to use utf8 must: -// - include this header from one of it's headers or sources -// - include the corresponding .cpp file from one of the sources -// - before including either file, the library must define -// - BOOST_UTF8_BEGIN_NAMESPACE to the namespace declaration that must be used -// - BOOST_UTF8_END_NAMESPACE to the code to close the previous namespace -// - declaration. -// - BOOST_UTF8_DECL -- to the code which must be used for all 'exportable' -// symbols. -// -// For example, program_options library might contain: -// #define BOOST_UTF8_BEGIN_NAMESPACE -// namespace boost { namespace program_options { -// #define BOOST_UTF8_END_NAMESPACE }} -// #define BOOST_UTF8_DECL BOOST_PROGRAM_OPTIONS_DECL -// #include "../../detail/utf8/utf8_codecvt.cpp" -// -// Essentially, each library will have its own copy of utf8 code, in -// different namespaces. - -// Note:(Robert Ramey). I have made the following alterations in the original -// code. -// a) Rendered utf8_codecvt with using templates -// b) Move longer functions outside class definition to prevent inlining -// and make code smaller -// c) added on a derived class to permit translation to/from current -// locale to utf8 - -// See http://www.boost.org for updates, documentation, and revision history. - -// archives stored as text - note these ar templated on the basic -// stream templates to accommodate wide (and other?) kind of characters -// -// note the fact that on libraries without wide characters, ostream is -// is not a specialization of basic_ostream which in fact is not defined -// in such cases. So we can't use basic_ostream but rather -// use two template parameters -// -// utf8_codecvt_facet -// This is an implementation of a std::codecvt facet for translating -// from UTF-8 externally to UCS-4. Note that this is not tied to -// any specific types in order to allow customization on platforms -// where wchar_t is not big enough. -// -// NOTES: The current implementation jumps through some unpleasant hoops in -// order to deal with signed character types. As a std::codecvt_base::result, -// it is necessary for the ExternType to be convertible to unsigned char. -// I chose not to tie the extern_type explicitly to char. But if any combination -// of types other than is used, then std::codecvt must be -// specialized on those types for this to work. - -#include -#include // for mbstate_t -#include // for std::size_t - -#include -#include - -#if defined(BOOST_NO_STDC_NAMESPACE) -namespace std { - using ::mbstate_t; - using ::size_t; -} -#endif - -#if !defined(__MSL_CPP__) && !defined(__LIBCOMO__) - #define BOOST_CODECVT_DO_LENGTH_CONST const -#else - #define BOOST_CODECVT_DO_LENGTH_CONST -#endif - -// maximum lenght of a multibyte string -#define MB_LENGTH_MAX 8 - -BOOST_UTF8_BEGIN_NAMESPACE - -struct BOOST_UTF8_DECL utf8_codecvt_facet : - public std::codecvt -{ -public: - explicit utf8_codecvt_facet(std::size_t no_locale_manage=0) - : std::codecvt(no_locale_manage) - {} -protected: - virtual std::codecvt_base::result do_in( - std::mbstate_t& state, - const char * from, - const char * from_end, - const char * & from_next, - wchar_t * to, - wchar_t * to_end, - wchar_t*& to_next - ) const; - - virtual std::codecvt_base::result do_out( - std::mbstate_t & state, - const wchar_t * from, - const wchar_t * from_end, - const wchar_t* & from_next, - char * to, - char * to_end, - char * & to_next - ) const; - - bool invalid_continuing_octet(unsigned char octet_1) const { - return (octet_1 < 0x80|| 0xbf< octet_1); - } - - bool invalid_leading_octet(unsigned char octet_1) const { - return (0x7f < octet_1 && octet_1 < 0xc0) || - (octet_1 > 0xfd); - } - - // continuing octets = octets except for the leading octet - static unsigned int get_cont_octet_count(unsigned char lead_octet) { - return get_octet_count(lead_octet) - 1; - } - - static unsigned int get_octet_count(unsigned char lead_octet); - - // How many "continuing octets" will be needed for this word - // == total octets - 1. - int get_cont_octet_out_count(wchar_t word) const ; - - virtual bool do_always_noconv() const BOOST_NOEXCEPT_OR_NOTHROW { - return false; - } - - // UTF-8 isn't really stateful since we rewind on partial conversions - virtual std::codecvt_base::result do_unshift( - std::mbstate_t&, - char * from, - char * /*to*/, - char * & next - ) const { - next = from; - return ok; - } - - virtual int do_encoding() const BOOST_NOEXCEPT_OR_NOTHROW { - const int variable_byte_external_encoding=0; - return variable_byte_external_encoding; - } - - // How many char objects can I process to get <= max_limit - // wchar_t objects? - virtual int do_length( - BOOST_CODECVT_DO_LENGTH_CONST std::mbstate_t &, - const char * from, - const char * from_end, - std::size_t max_limit - ) const; - - // Largest possible value do_length(state,from,from_end,1) could return. - virtual int do_max_length() const BOOST_NOEXCEPT_OR_NOTHROW { - return 6; // largest UTF-8 encoding of a UCS-4 character - } -}; - -BOOST_UTF8_END_NAMESPACE - -#endif // BOOST_UTF8_CODECVT_FACET_HPP diff --git a/boost/detail/utf8_codecvt_facet.ipp b/boost/detail/utf8_codecvt_facet.ipp deleted file mode 100644 index 8a13124..0000000 --- a/boost/detail/utf8_codecvt_facet.ipp +++ /dev/null @@ -1,284 +0,0 @@ -/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// utf8_codecvt_facet.ipp - -// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu) -// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu). -// Use, modification and distribution is 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) - -// Please see the comments in to -// learn how this file should be used. - -#include - -#include // for multi-byte converson routines -#include - -#include -#include - -// If we don't have wstring, then Unicode support -// is not available anyway, so we don't need to even -// compiler this file. This also fixes the problem -// with mingw, which can compile this file, but will -// generate link error when building DLL. -#ifndef BOOST_NO_STD_WSTRING - -BOOST_UTF8_BEGIN_NAMESPACE - -/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// implementation for wchar_t - -// Translate incoming UTF-8 into UCS-4 -std::codecvt_base::result utf8_codecvt_facet::do_in( - std::mbstate_t& /*state*/, - const char * from, - const char * from_end, - const char * & from_next, - wchar_t * to, - wchar_t * to_end, - wchar_t * & to_next -) const { - // Basic algorithm: The first octet determines how many - // octets total make up the UCS-4 character. The remaining - // "continuing octets" all begin with "10". To convert, subtract - // the amount that specifies the number of octets from the first - // octet. Subtract 0x80 (1000 0000) from each continuing octet, - // then mash the whole lot together. Note that each continuing - // octet only uses 6 bits as unique values, so only shift by - // multiples of 6 to combine. - while (from != from_end && to != to_end) { - - // Error checking on the first octet - if (invalid_leading_octet(*from)){ - from_next = from; - to_next = to; - return std::codecvt_base::error; - } - - // The first octet is adjusted by a value dependent upon - // the number of "continuing octets" encoding the character - const int cont_octet_count = get_cont_octet_count(*from); - const wchar_t octet1_modifier_table[] = { - 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc - }; - - // The unsigned char conversion is necessary in case char is - // signed (I learned this the hard way) - wchar_t ucs_result = - (unsigned char)(*from++) - octet1_modifier_table[cont_octet_count]; - - // Invariants : - // 1) At the start of the loop, 'i' continuing characters have been - // processed - // 2) *from points to the next continuing character to be processed. - int i = 0; - while(i != cont_octet_count && from != from_end) { - - // Error checking on continuing characters - if (invalid_continuing_octet(*from)) { - from_next = from; - to_next = to; - return std::codecvt_base::error; - } - - ucs_result *= (1 << 6); - - // each continuing character has an extra (10xxxxxx)b attached to - // it that must be removed. - ucs_result += (unsigned char)(*from++) - 0x80; - ++i; - } - - // If the buffer ends with an incomplete unicode character... - if (from == from_end && i != cont_octet_count) { - // rewind "from" to before the current character translation - from_next = from - (i+1); - to_next = to; - return std::codecvt_base::partial; - } - *to++ = ucs_result; - } - from_next = from; - to_next = to; - - // Were we done converting or did we run out of destination space? - if(from == from_end) return std::codecvt_base::ok; - else return std::codecvt_base::partial; -} - -std::codecvt_base::result utf8_codecvt_facet::do_out( - std::mbstate_t& /*state*/, - const wchar_t * from, - const wchar_t * from_end, - const wchar_t * & from_next, - char * to, - char * to_end, - char * & to_next -) const -{ - // RG - consider merging this table with the other one - const wchar_t octet1_modifier_table[] = { - 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc - }; - - wchar_t max_wchar = (std::numeric_limits::max)(); - while (from != from_end && to != to_end) { - - // Check for invalid UCS-4 character - if (*from > max_wchar) { - from_next = from; - to_next = to; - return std::codecvt_base::error; - } - - int cont_octet_count = get_cont_octet_out_count(*from); - - // RG - comment this formula better - int shift_exponent = (cont_octet_count) * 6; - - // Process the first character - *to++ = static_cast(octet1_modifier_table[cont_octet_count] + - (unsigned char)(*from / (1 << shift_exponent))); - - // Process the continuation characters - // Invariants: At the start of the loop: - // 1) 'i' continuing octets have been generated - // 2) '*to' points to the next location to place an octet - // 3) shift_exponent is 6 more than needed for the next octet - int i = 0; - while (i != cont_octet_count && to != to_end) { - shift_exponent -= 6; - *to++ = static_cast(0x80 + ((*from / (1 << shift_exponent)) % (1 << 6))); - ++i; - } - // If we filled up the out buffer before encoding the character - if(to == to_end && i != cont_octet_count) { - from_next = from; - to_next = to - (i+1); - return std::codecvt_base::partial; - } - ++from; - } - from_next = from; - to_next = to; - // Were we done or did we run out of destination space - if(from == from_end) return std::codecvt_base::ok; - else return std::codecvt_base::partial; -} - -// How many char objects can I process to get <= max_limit -// wchar_t objects? -int utf8_codecvt_facet::do_length( - const std::mbstate_t &, - const char * from, - const char * from_end, - std::size_t max_limit -) const -#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) - throw() -#endif -{ - // RG - this code is confusing! I need a better way to express it. - // and test cases. - - // Invariants: - // 1) last_octet_count has the size of the last measured character - // 2) char_count holds the number of characters shown to fit - // within the bounds so far (no greater than max_limit) - // 3) from_next points to the octet 'last_octet_count' before the - // last measured character. - int last_octet_count=0; - std::size_t char_count = 0; - const char* from_next = from; - // Use "<" because the buffer may represent incomplete characters - while (from_next+last_octet_count <= from_end && char_count <= max_limit) { - from_next += last_octet_count; - last_octet_count = (get_octet_count(*from_next)); - ++char_count; - } - return static_cast(from_next-from_end); -} - -unsigned int utf8_codecvt_facet::get_octet_count( - unsigned char lead_octet -){ - // if the 0-bit (MSB) is 0, then 1 character - if (lead_octet <= 0x7f) return 1; - - // Otherwise the count number of consecutive 1 bits starting at MSB -// assert(0xc0 <= lead_octet && lead_octet <= 0xfd); - - if (0xc0 <= lead_octet && lead_octet <= 0xdf) return 2; - else if (0xe0 <= lead_octet && lead_octet <= 0xef) return 3; - else if (0xf0 <= lead_octet && lead_octet <= 0xf7) return 4; - else if (0xf8 <= lead_octet && lead_octet <= 0xfb) return 5; - else return 6; -} -BOOST_UTF8_END_NAMESPACE - -namespace { -template -int get_cont_octet_out_count_impl(wchar_t word){ - if (word < 0x80) { - return 0; - } - if (word < 0x800) { - return 1; - } - return 2; -} - -template<> -int get_cont_octet_out_count_impl<4>(wchar_t word){ - if (word < 0x80) { - return 0; - } - if (word < 0x800) { - return 1; - } - - // Note that the following code will generate warnings on some platforms - // where wchar_t is defined as UCS2. The warnings are superfluous as the - // specialization is never instantitiated with such compilers, but this - // can cause problems if warnings are being treated as errors, so we guard - // against that. Including as we do - // should be enough to get WCHAR_MAX defined. -#if !defined(WCHAR_MAX) -# error WCHAR_MAX not defined! -#endif - // cope with VC++ 7.1 or earlier having invalid WCHAR_MAX -#if defined(_MSC_VER) && _MSC_VER <= 1310 // 7.1 or earlier - return 2; -#elif WCHAR_MAX > 0x10000 - - if (word < 0x10000) { - return 2; - } - if (word < 0x200000) { - return 3; - } - if (word < 0x4000000) { - return 4; - } - return 5; - -#else - return 2; -#endif -} - -} // namespace anonymous - -BOOST_UTF8_BEGIN_NAMESPACE -// How many "continuing octets" will be needed for this word -// == total octets - 1. -int utf8_codecvt_facet::get_cont_octet_out_count( - wchar_t word -) const { - return get_cont_octet_out_count_impl(word); -} -BOOST_UTF8_END_NAMESPACE - -#endif diff --git a/boost/detail/winapi/GetCurrentProcess.hpp b/boost/detail/winapi/GetCurrentProcess.hpp deleted file mode 100644 index 51206bb..0000000 --- a/boost/detail/winapi/GetCurrentProcess.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// GetCurrentProcess.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_GETCURRENTPROCESS_HPP -#define BOOST_DETAIL_WINAPI_GETCURRENTPROCESS_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentProcess; -#else - extern "C" __declspec(dllimport) HANDLE_ WINAPI GetCurrentProcess(); -#endif -} -} -} -#endif // BOOST_DETAIL_WINAPI_GETCURRENTPROCESS_HPP diff --git a/boost/detail/winapi/GetCurrentThread.hpp b/boost/detail/winapi/GetCurrentThread.hpp deleted file mode 100644 index 595b751..0000000 --- a/boost/detail/winapi/GetCurrentThread.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// GetCurrentThread.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_GETCURRENTTHREAD_HPP -#define BOOST_DETAIL_WINAPI_GETCURRENTTHREAD_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { -#if defined( UNDER_CE ) -// Windows CE define GetCurrentThread as an inline function in kfuncs.h -inline HANDLE_ GetCurrentThread() -{ - return ::GetCurrentThread(); -} -#else -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentThread; -#else - extern "C" __declspec(dllimport) HANDLE_ WINAPI GetCurrentThread(); -#endif -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_GETCURRENTTHREAD_HPP diff --git a/boost/detail/winapi/GetLastError.hpp b/boost/detail/winapi/GetLastError.hpp deleted file mode 100644 index 6e9e2d9..0000000 --- a/boost/detail/winapi/GetLastError.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// GetLastError.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_GETLASTERROR_HPP -#define BOOST_DETAIL_WINAPI_GETLASTERROR_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetLastError; -#else - extern "C" __declspec(dllimport) DWORD_ WINAPI - GetLastError(); -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_GETLASTERROR_HPP diff --git a/boost/detail/winapi/GetProcessTimes.hpp b/boost/detail/winapi/GetProcessTimes.hpp deleted file mode 100644 index f2860b0..0000000 --- a/boost/detail/winapi/GetProcessTimes.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// GetProcessTimes.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_GETPROCESSTIMES_HPP -#define BOOST_DETAIL_WINAPI_GETPROCESSTIMES_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { -#if !defined(UNDER_CE) // Windows CE does not define GetProcessTimes -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetProcessTimes; -#else - extern "C" __declspec(dllimport) BOOL_ WINAPI - GetProcessTimes( - HANDLE_ hProcess, - LPFILETIME_ lpCreationTime, - LPFILETIME_ lpExitTime, - LPFILETIME_ lpKernelTime, - LPFILETIME_ lpUserTime - ); -#endif -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_GETPROCESSTIMES_HPP diff --git a/boost/detail/winapi/GetThreadTimes.hpp b/boost/detail/winapi/GetThreadTimes.hpp deleted file mode 100644 index 3428eda..0000000 --- a/boost/detail/winapi/GetThreadTimes.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// GetThreadTimes.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_GETTHREADTIMES_HPP -#define BOOST_DETAIL_WINAPI_GETTHREADTIMES_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetThreadTimes; -#else - extern "C" __declspec(dllimport) BOOL_ WINAPI - GetThreadTimes( - HANDLE_ hThread, - LPFILETIME_ lpCreationTime, - LPFILETIME_ lpExitTime, - LPFILETIME_ lpKernelTime, - LPFILETIME_ lpUserTime - ); -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_GETTHREADTIMES_HPP diff --git a/boost/detail/winapi/LocalFree.hpp b/boost/detail/winapi/LocalFree.hpp deleted file mode 100644 index 697016c..0000000 --- a/boost/detail/winapi/LocalFree.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// LocalFree.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_LOCALFREE_HPP -#define BOOST_DETAIL_WINAPI_LOCALFREE_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - typedef HANDLE_ HLOCAL_; - - using ::LocalFree; -#else - extern "C" typedef HANDLE_ HLOCAL_; - extern "C" __declspec(dllimport) HLOCAL_ WINAPI - LocalFree(HLOCAL_ hMem); -#endif -} -} -} -#endif // BOOST_DETAIL_WINAPI_LOCALFREE_HPP diff --git a/boost/detail/winapi/basic_types.hpp b/boost/detail/winapi/basic_types.hpp deleted file mode 100644 index 09d907b..0000000 --- a/boost/detail/winapi/basic_types.hpp +++ /dev/null @@ -1,134 +0,0 @@ -// basic_types.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_BASIC_TYPES_HPP -#define BOOST_DETAIL_WINAPI_BASIC_TYPES_HPP - -#include -#include -#include - -#if defined( BOOST_USE_WINDOWS_H ) -# include -#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined(__CYGWIN__) -# include -// @FIXME Which condition must be tested -# ifdef UNDER_CE -# ifndef WINAPI -# ifndef _WIN32_WCE_EMULATION -# define WINAPI __cdecl // Note this doesn't match the desktop definition -# else -# define WINAPI __stdcall -# endif -# endif -# else -# ifndef WINAPI -# define WINAPI __stdcall -# endif -# endif -# ifndef NTAPI -# define NTAPI __stdcall -# endif -#else -# error "Win32 functions not available" -#endif - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - typedef ::BOOL BOOL_; - typedef ::BOOLEAN BOOLEAN_; - typedef ::PBOOLEAN PBOOLEAN_; - typedef ::BYTE BYTE_; - typedef ::WORD WORD_; - typedef ::DWORD DWORD_; - typedef ::HANDLE HANDLE_; - typedef ::HMODULE HMODULE_; - typedef ::LONG LONG_; - typedef ::ULONG ULONG_; - typedef ::LONGLONG LONGLONG_; - typedef ::ULONGLONG ULONGLONG_; - typedef ::INT_PTR INT_PTR_; - typedef ::UINT_PTR UINT_PTR_; - typedef ::LONG_PTR LONG_PTR_; - typedef ::ULONG_PTR ULONG_PTR_; - typedef ::LARGE_INTEGER LARGE_INTEGER_; - typedef ::PLARGE_INTEGER PLARGE_INTEGER_; - typedef ::PVOID PVOID_; - typedef ::LPVOID LPVOID_; - typedef ::CHAR CHAR_; - typedef ::LPSTR LPSTR_; - typedef ::LPCSTR LPCSTR_; - typedef ::WCHAR WCHAR_; - typedef ::LPWSTR LPWSTR_; - typedef ::LPCWSTR LPCWSTR_; -#else -extern "C" { - typedef int BOOL_; - typedef unsigned char BYTE_; - typedef BYTE_ BOOLEAN_; - typedef BOOLEAN_* PBOOLEAN_; - typedef unsigned short WORD_; - typedef unsigned long DWORD_; - typedef void* HANDLE_; - typedef void* HMODULE_; - - typedef long LONG_; - typedef unsigned long ULONG_; - - typedef boost::int64_t LONGLONG_; - typedef boost::uint64_t ULONGLONG_; - -// @FIXME Which condition must be tested -# ifdef _WIN64 -#if defined(__CYGWIN__) - typedef long INT_PTR_; - typedef unsigned long UINT_PTR_; - typedef long LONG_PTR_; - typedef unsigned long ULONG_PTR_; -#else - typedef __int64 INT_PTR_; - typedef unsigned __int64 UINT_PTR_; - typedef __int64 LONG_PTR_; - typedef unsigned __int64 ULONG_PTR_; -#endif -# else - typedef int INT_PTR_; - typedef unsigned int UINT_PTR_; - typedef long LONG_PTR_; - typedef unsigned long ULONG_PTR_; -# endif - - typedef struct _LARGE_INTEGER { - LONGLONG_ QuadPart; - } LARGE_INTEGER_; - typedef LARGE_INTEGER_ *PLARGE_INTEGER_; - - typedef void *PVOID_; - typedef void *LPVOID_; - typedef const void *LPCVOID_; - - typedef char CHAR_; - typedef CHAR_ *LPSTR_; - typedef const CHAR_ *LPCSTR_; - - typedef wchar_t WCHAR_; - typedef WCHAR_ *LPWSTR_; - typedef const WCHAR_ *LPCWSTR_; -} -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_BASIC_TYPES_HPP diff --git a/boost/detail/winapi/config.hpp b/boost/detail/winapi/config.hpp deleted file mode 100644 index 2b0cdfb..0000000 --- a/boost/detail/winapi/config.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// config.hpp --------------------------------------------------------------// - -// Copyright 2013 Andrey Semashev - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_CONFIG_HPP_INCLUDED_ -#define BOOST_DETAIL_WINAPI_CONFIG_HPP_INCLUDED_ - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -// These constants reflect _WIN32_WINNT_* macros from sdkddkver.h -// See also: http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745%28v=vs.85%29.aspx#setting_winver_or__win32_winnt -#define BOOST_WINAPI_VERSION_NT4 0x0400 -#define BOOST_WINAPI_VERSION_WIN2K 0x0500 -#define BOOST_WINAPI_VERSION_WINXP 0x0501 -#define BOOST_WINAPI_VERSION_WS03 0x0502 -#define BOOST_WINAPI_VERSION_WIN6 0x0600 -#define BOOST_WINAPI_VERSION_VISTA 0x0600 -#define BOOST_WINAPI_VERSION_WS08 0x0600 -#define BOOST_WINAPI_VERSION_LONGHORN 0x0600 -#define BOOST_WINAPI_VERSION_WIN7 0x0601 -#define BOOST_WINAPI_VERSION_WIN8 0x0602 -#define BOOST_WINAPI_VERSION_WINBLUE 0x0603 - -#if !defined(BOOST_USE_WINAPI_VERSION) -#if defined(_WIN32_WINNT) -#define BOOST_USE_WINAPI_VERSION _WIN32_WINNT -#elif defined(WINVER) -#define BOOST_USE_WINAPI_VERSION WINVER -#else -// By default use Windows XP API -#define BOOST_USE_WINAPI_VERSION BOOST_WINAPI_VERSION_WINXP -#endif -#endif - -#if defined(BOOST_USE_WINDOWS_H) -// We have to define the version macros so that windows.h provides the necessary symbols -#if !defined(_WIN32_WINNT) -#define _WIN32_WINNT BOOST_USE_WINAPI_VERSION -#endif -#if !defined(WINVER) -#define WINVER BOOST_USE_WINAPI_VERSION -#endif -#endif - -#endif // BOOST_DETAIL_WINAPI_CONFIG_HPP_INCLUDED_ diff --git a/boost/detail/winapi/crypt.hpp b/boost/detail/winapi/crypt.hpp deleted file mode 100644 index c9108f2..0000000 --- a/boost/detail/winapi/crypt.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// crypt.hpp --------------------------------------------------------------// - -// Copyright 2014 Antony Polukhin - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_CRYPT_HPP -#define BOOST_DETAIL_WINAPI_CRYPT_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - typedef HCRYPTPROV HCRYPTPROV_; - - using ::CryptEnumProvidersA; - using ::CryptAcquireContextA; - using ::CryptGenRandom; - using ::CryptReleaseContext; - - const DWORD_ PROV_RSA_FULL_ = PROV_RSA_FULL; - - const DWORD_ CRYPT_VERIFYCONTEXT_ = CRYPT_VERIFYCONTEXT; - const DWORD_ CRYPT_NEWKEYSET_ = CRYPT_NEWKEYSET; - const DWORD_ CRYPT_DELETEKEYSET_ = CRYPT_DELETEKEYSET; - const DWORD_ CRYPT_MACHINE_KEYSET_ = CRYPT_MACHINE_KEYSET; - const DWORD_ CRYPT_SILENT_ = CRYPT_SILENT; -#else -extern "C" { - typedef ULONG_PTR_ HCRYPTPROV_; - - __declspec(dllimport) BOOL_ __stdcall - CryptEnumProvidersA( - DWORD_ dwIndex, - DWORD_ *pdwReserved, - DWORD_ dwFlags, - DWORD_ *pdwProvType, - LPSTR_ szProvName, - DWORD_ *pcbProvName - ); - - __declspec(dllimport) BOOL_ __stdcall - CryptAcquireContextA( - HCRYPTPROV_ *phProv, - LPCSTR_ pszContainer, - LPCSTR_ pszProvider, - DWORD_ dwProvType, - DWORD_ dwFlags - ); - - __declspec(dllimport) BOOL_ __stdcall - CryptGenRandom( - HCRYPTPROV_ hProv, - DWORD_ dwLen, - BYTE_ *pbBuffer - ); - - __declspec(dllimport) BOOL_ __stdcall - CryptReleaseContext( - HCRYPTPROV_ hProv, - DWORD_ dwFlags - ); - - const DWORD_ PROV_RSA_FULL_ = 1; - - const DWORD_ CRYPT_VERIFYCONTEXT_ = 0xF0000000; - const DWORD_ CRYPT_NEWKEYSET_ = 8; - const DWORD_ CRYPT_DELETEKEYSET_ = 16; - const DWORD_ CRYPT_MACHINE_KEYSET_ = 32; - const DWORD_ CRYPT_SILENT_ = 64; -} -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_CRYPT_HPP diff --git a/boost/detail/winapi/directory_management.hpp b/boost/detail/winapi/directory_management.hpp deleted file mode 100644 index 19af1ee..0000000 --- a/boost/detail/winapi/directory_management.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// directory_management.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_DIRECTORY_MANAGEMENT_HPP -#define BOOST_DETAIL_WINAPI_DIRECTORY_MANAGEMENT_HPP - -#include -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - using ::CreateDirectory; - using ::CreateDirectoryA; - using ::GetTempPathA; - using ::RemoveDirectoryA; -#else -extern "C" { - __declspec(dllimport) int __stdcall - CreateDirectory(LPCTSTR_, LPSECURITY_ATTRIBUTES_*); - __declspec(dllimport) int __stdcall - CreateDirectoryA(LPCTSTR_, interprocess_security_attributes*); - __declspec(dllimport) int __stdcall - GetTempPathA(unsigned long length, char *buffer); - __declspec(dllimport) int __stdcall - RemoveDirectoryA(LPCTSTR_); -} -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_THREAD_HPP diff --git a/boost/detail/winapi/dll.hpp b/boost/detail/winapi/dll.hpp deleted file mode 100644 index 2ec5a73..0000000 --- a/boost/detail/winapi/dll.hpp +++ /dev/null @@ -1,86 +0,0 @@ -// dll.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_DLL_HPP -#define BOOST_DETAIL_WINAPI_DLL_HPP - -#include -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - typedef ::FARPROC FARPROC_; - typedef ::NEARPROC NEARPROC_; - typedef ::PROC PROC_; - -# ifdef BOOST_NO_ANSI_APIS - using ::LoadLibraryW; - using ::GetModuleHandleW; -# else - using ::LoadLibraryA; - using ::GetModuleHandleA; -# endif - using ::FreeLibrary; - using ::GetProcAddress; -#else -extern "C" { -# ifdef _WIN64 - typedef INT_PTR_ (WINAPI *FARPROC_)(); - typedef INT_PTR_ (WINAPI *NEARPROC_)(); - typedef INT_PTR_ (WINAPI *PROC_)(); -# else - typedef int (WINAPI *FARPROC_)(); - typedef int (WINAPI *NEARPROC_)(); - typedef int (WINAPI *PROC_)(); -# endif // _WIN64 - -# ifdef BOOST_NO_ANSI_APIS - __declspec(dllimport) HMODULE_ WINAPI - LoadLibraryW( - LPCWSTR_ lpFileName - ); - __declspec(dllimport) HMODULE_ WINAPI - GetModuleHandleW( - LPCWSTR_ lpFileName - ); -# else - __declspec(dllimport) HMODULE_ WINAPI - LoadLibraryA( - LPCSTR_ lpFileName - ); - __declspec(dllimport) HMODULE_ WINAPI - GetModuleHandleA( - LPCSTR_ lpFileName - ); -# endif - - __declspec(dllimport) BOOL_ WINAPI - FreeLibrary( - HMODULE_ hModule - ); - __declspec(dllimport) FARPROC_ WINAPI - GetProcAddress( - HMODULE_ hModule, - LPCSTR_ lpProcName - ); -} -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_DLL_HPP diff --git a/boost/detail/winapi/error_handling.hpp b/boost/detail/winapi/error_handling.hpp deleted file mode 100644 index fbe9924..0000000 --- a/boost/detail/winapi/error_handling.hpp +++ /dev/null @@ -1,93 +0,0 @@ -// error_handling.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_ERROR_HANDLING_HPP -#define BOOST_DETAIL_WINAPI_ERROR_HANDLING_HPP - -#include -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { - -#if defined( BOOST_USE_WINDOWS_H ) - using ::FormatMessageA; - using ::FormatMessageW; - - const int FORMAT_MESSAGE_ALLOCATE_BUFFER_= FORMAT_MESSAGE_ALLOCATE_BUFFER; - const int FORMAT_MESSAGE_IGNORE_INSERTS_= FORMAT_MESSAGE_IGNORE_INSERTS; - const int FORMAT_MESSAGE_FROM_STRING_= FORMAT_MESSAGE_FROM_STRING; - const int FORMAT_MESSAGE_FROM_HMODULE_= FORMAT_MESSAGE_FROM_HMODULE; - const int FORMAT_MESSAGE_FROM_SYSTEM_= FORMAT_MESSAGE_FROM_SYSTEM; - const int FORMAT_MESSAGE_ARGUMENT_ARRAY_= FORMAT_MESSAGE_ARGUMENT_ARRAY; - const int FORMAT_MESSAGE_MAX_WIDTH_MASK_= FORMAT_MESSAGE_MAX_WIDTH_MASK; - - const char LANG_NEUTRAL_= LANG_NEUTRAL; - const char LANG_INVARIANT_= LANG_INVARIANT; - - const char SUBLANG_DEFAULT_= SUBLANG_DEFAULT; // user default - inline WORD_ MAKELANGID_(WORD_ p, WORD_ s) { - return MAKELANGID(p,s); - } -#else -extern "C" { - // using ::FormatMessageA; - __declspec(dllimport) - DWORD_ - WINAPI - FormatMessageA( - DWORD_ dwFlags, - LPCVOID_ lpSource, - DWORD_ dwMessageId, - DWORD_ dwLanguageId, - LPSTR_ lpBuffer, - DWORD_ nSize, - va_list *Arguments - ); - - // using ::FormatMessageW; - __declspec(dllimport) - DWORD_ - WINAPI - FormatMessageW( - DWORD_ dwFlags, - LPCVOID_ lpSource, - DWORD_ dwMessageId, - DWORD_ dwLanguageId, - LPWSTR_ lpBuffer, - DWORD_ nSize, - va_list *Arguments - ); - - const int FORMAT_MESSAGE_ALLOCATE_BUFFER_= 0x00000100; - const int FORMAT_MESSAGE_IGNORE_INSERTS_= 0x00000200; - const int FORMAT_MESSAGE_FROM_STRING_= 0x00000400; - const int FORMAT_MESSAGE_FROM_HMODULE_= 0x00000800; - const int FORMAT_MESSAGE_FROM_SYSTEM_= 0x00001000; - const int FORMAT_MESSAGE_ARGUMENT_ARRAY_= 0x00002000; - const int FORMAT_MESSAGE_MAX_WIDTH_MASK_= 0x000000FF; - - const char LANG_NEUTRAL_= 0x00; - const char LANG_INVARIANT_= 0x7f; - - const char SUBLANG_DEFAULT_= 0x01; // user default - inline WORD_ MAKELANGID_(WORD_ p, WORD_ s) { - return ((((WORD_ )(s)) << 10) | (WORD_ )(p)); - } - -} -#endif -} -} -} -#endif // BOOST_DETAIL_WINAPI_ERROR_HANDLING_HPP diff --git a/boost/detail/winapi/file_management.hpp b/boost/detail/winapi/file_management.hpp deleted file mode 100644 index c1d5978..0000000 --- a/boost/detail/winapi/file_management.hpp +++ /dev/null @@ -1,130 +0,0 @@ -// thread.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_FILE_MANAGEMENT_HPP -#define BOOST_DETAIL_WINAPI_FILE_MANAGEMENT_HPP - -#include -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - using ::CreateFileA; - using ::DeleteFileA; - using ::FindFirstFileA; - using ::FindNextFileA; - using ::FindClose; - using ::GetFileSizeEx; - using ::MoveFileExA; - using ::SetFileValidData; -#else -extern "C" { - typedef struct _OVERLAPPED { - ULONG_PTR Internal; - ULONG_PTR InternalHigh; - union { - struct { - DWORD Offset; - DWORD OffsetHigh; - } ; - PVOID Pointer; - } ; - HANDLE hEvent; - } OVERLAPPED, *LPOVERLAPPED; - - - __declspec(dllimport) void * __stdcall - CreateFileA (const char *, unsigned long, unsigned long, struct SECURITY_ATTRIBUTES_*, unsigned long, unsigned long, void *); - __declspec(dllimport) int __stdcall - DeleteFileA (const char *); - __declspec(dllimport) void *__stdcall - FindFirstFileA(const char *lpFileName, win32_find_data_t *lpFindFileData); - __declspec(dllimport) int __stdcall - FindNextFileA(void *hFindFile, win32_find_data_t *lpFindFileData); - __declspec(dllimport) int __stdcall - FindClose(void *hFindFile); - __declspec(dllimport) BOOL __stdcall - GetFileSizeEx( - HANDLE_ hFile, - PLARGE_INTEGER_ lpFileSize - ); - __declspec(dllimport) int __stdcall - MoveFileExA (const char *, const char *, unsigned long); - __declspec(dllimport) BOOL_ __stdcall - SetFileValidData( - HANDLE_ hFile, - LONGLONG_ ValidDataLength - ); - __declspec(dllimport) BOOL_ __stdcall - SetEndOfFile( - HANDLE_ hFile - ); - __declspec(dllimport) BOOL_ __stdcall - SetFilePointerEx( - HANDLE_ hFile, - LARGE_INTEGER_ liDistanceToMove, - PLARGE_INTEGER_ lpNewFilePointer, - DWORD_ dwMoveMethod - ); - __declspec(dllimport) BOOL_ __stdcall - LockFile( - HANDLE_ hFile, - DWORD_ dwFileOffsetLow, - DWORD_ dwFileOffsetHigh, - DWORD_ nNumberOfBytesToLockLow, - DWORD_ nNumberOfBytesToLockHigh - ); - __declspec(dllimport) BOOL_ __stdcall - UnlockFile( - HANDLE_ hFile, - DWORD_ dwFileOffsetLow, - DWORD_ dwFileOffsetHigh, - DWORD_ nNumberOfBytesToUnlockLow, - DWORD_ nNumberOfBytesToUnlockHigh - ); - __declspec(dllimport) BOOL_ __stdcall - LockFileEx( - HANDLE_ hFile, - DWORD_ dwFlags, - DWORD_ dwReserved, - DWORD_ nNumberOfBytesToLockLow, - DWORD_ nNumberOfBytesToLockHigh, - LPOVERLAPPED_ lpOverlapped - ); - __declspec(dllimport) BOOL_ __stdcall - UnlockFileEx( - HANDLE_ hFile, - DWORD_ dwReserved, - DWORD_ nNumberOfBytesToUnlockLow, - DWORD_ nNumberOfBytesToUnlockHigh, - LPOVERLAPPED_ lpOverlapped - ); - __declspec(dllimport) BOOL_ __stdcall - WriteFile( - HANDLE_ hFile, - LPCVOID_ lpBuffer, - DWORD_ nNumberOfBytesToWrite, - LPDWORD_ lpNumberOfBytesWritten, - LPOVERLAPPED_ lpOverlapped - ); -} -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_THREAD_HPP diff --git a/boost/detail/winapi/handles.hpp b/boost/detail/winapi/handles.hpp deleted file mode 100644 index 7108daa..0000000 --- a/boost/detail/winapi/handles.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// memory.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_HANDLES_HPP -#define BOOST_DETAIL_WINAPI_HANDLES_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - using ::CloseHandle; - using ::DuplicateHandle; - - const DWORD_ duplicate_close_source = DUPLICATE_CLOSE_SOURCE; - const DWORD_ duplicate_same_access = DUPLICATE_SAME_ACCESS; - const HANDLE_ invalid_handle_value = INVALID_HANDLE_VALUE; -#else -extern "C" { - __declspec(dllimport) int __stdcall - CloseHandle(void*); - __declspec(dllimport) int __stdcall - DuplicateHandle(void*,void*,void*,void**,unsigned long,int,unsigned long); -} - const DWORD_ duplicate_close_source = 1; - const DWORD_ duplicate_same_access = 2; - const HANDLE_ invalid_handle_value = (HANDLE_)(-1); -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_HANDLES_HPP diff --git a/boost/detail/winapi/memory.hpp b/boost/detail/winapi/memory.hpp deleted file mode 100644 index b5316e0..0000000 --- a/boost/detail/winapi/memory.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// memory.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_MEMORY_HPP -#define BOOST_DETAIL_WINAPI_MEMORY_HPP - -#include -#include -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - using ::CreateFileMappingA; - using ::FlushViewOfFile; - using ::GetProcessHeap; - using ::HeapAlloc; - using ::HeapFree; - using ::MapViewOfFileEx; - using ::OpenFileMappingA; - using ::UnmapViewOfFile; -#else -#undef HeapAlloc -extern "C" { - __declspec(dllimport) void * __stdcall - CreateFileMappingA (void *, SECURITY_ATTRIBUTES_*, unsigned long, unsigned long, unsigned long, const char *); - __declspec(dllimport) int __stdcall - FlushViewOfFile (void *, std::size_t); - __declspec(dllimport) HANDLE_ __stdcall - GetProcessHeap(); - __declspec(dllimport) void* __stdcall - HeapAlloc(HANDLE_,DWORD_,SIZE_T_); - __declspec(dllimport) BOOL_ __stdcall - HeapFree(HANDLE_,DWORD_,LPVOID_); - __declspec(dllimport) void * __stdcall - MapViewOfFileEx (void *, unsigned long, unsigned long, unsigned long, std::size_t, void*); - __declspec(dllimport) void * __stdcall - OpenFileMappingA (unsigned long, int, const char *); - __declspec(dllimport) int __stdcall - UnmapViewOfFile(void *); -} -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_MEMORY_HPP diff --git a/boost/detail/winapi/process.hpp b/boost/detail/winapi/process.hpp deleted file mode 100644 index de287b1..0000000 --- a/boost/detail/winapi/process.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// process.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_PROCESS_HPP -#define BOOST_DETAIL_WINAPI_PROCESS_HPP - -#include -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentProcessId; -#else -# ifndef UNDER_CE -extern "C" { - __declspec(dllimport) DWORD_ WINAPI GetCurrentProcessId(void); -} -# else - using ::GetCurrentProcessId; -# endif -#endif -} -} -} -#endif // BOOST_DETAIL_WINAPI_PROCESS_HPP diff --git a/boost/detail/winapi/security.hpp b/boost/detail/winapi/security.hpp deleted file mode 100644 index 79925c6..0000000 --- a/boost/detail/winapi/security.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// security.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_SECURITY_HPP -#define BOOST_DETAIL_WINAPI_SECURITY_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) -typedef ::SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES_; -typedef ::PSECURITY_ATTRIBUTES PSECURITY_ATTRIBUTES_; -typedef ::LPSECURITY_ATTRIBUTES LPSECURITY_ATTRIBUTES_; - -#else -extern "C" { - struct SECURITY_DESCRIPTOR_; - typedef SECURITY_DESCRIPTOR_* PSECURITY_DESCRIPTOR_; - typedef struct _ACL { - BYTE_ AclRevision; - BYTE_ Sbz1; - WORD_ AclSize; - WORD_ AceCount; - WORD_ Sbz2; - } ACL_, *PACL_; - - typedef struct _SECURITY_ATTRIBUTES { - DWORD_ nLength; - LPVOID_ lpSecurityDescriptor; - BOOL_ bInheritHandle; - } SECURITY_ATTRIBUTES_, *PSECURITY_ATTRIBUTES_, *LPSECURITY_ATTRIBUTES_; - - __declspec(dllimport) BOOL_ __stdcall - InitializeSecurityDescriptor( - PSECURITY_DESCRIPTOR_ pSecurityDescriptor, - DWORD_ dwRevision - ); - __declspec(dllimport) BOOL_ __stdcall - SetSecurityDescriptorDacl( - PSECURITY_DESCRIPTOR_ pSecurityDescriptor, - BOOL_ bDaclPresent, - PACL_ pDacl, - BOOL_ bDaclDefaulted - ); -} -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_SECURITY_HPP diff --git a/boost/detail/winapi/synchronization.hpp b/boost/detail/winapi/synchronization.hpp deleted file mode 100644 index b9497cb..0000000 --- a/boost/detail/winapi/synchronization.hpp +++ /dev/null @@ -1,293 +0,0 @@ -// synchronizaion.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_SYNCHRONIZATION_HPP -#define BOOST_DETAIL_WINAPI_SYNCHRONIZATION_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - typedef ::CRITICAL_SECTION CRITICAL_SECTION_; - typedef ::PAPCFUNC PAPCFUNC_; - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - typedef ::INIT_ONCE INIT_ONCE_; - typedef ::PINIT_ONCE PINIT_ONCE_; - typedef ::LPINIT_ONCE LPINIT_ONCE_; - #define BOOST_DETAIL_WINAPI_INIT_ONCE_STATIC_INIT INIT_ONCE_STATIC_INIT - typedef ::PINIT_ONCE_FN PINIT_ONCE_FN_; - - typedef ::SRWLOCK SRWLOCK_; - typedef ::PSRWLOCK PSRWLOCK_; - #define BOOST_DETAIL_WINAPI_SRWLOCK_INIT SRWLOCK_INIT - - typedef ::CONDITION_VARIABLE CONDITION_VARIABLE_; - typedef ::PCONDITION_VARIABLE PCONDITION_VARIABLE_; - #define BOOST_DETAIL_WINAPI_CONDITION_VARIABLE_INIT CONDITION_VARIABLE_INIT -#endif - - using ::InitializeCriticalSection; -#if BOOST_USE_WINAPI_VERSION >= 0x0403 - using ::InitializeCriticalSectionAndSpinCount; -#endif - using ::EnterCriticalSection; - using ::TryEnterCriticalSection; - using ::LeaveCriticalSection; - using ::DeleteCriticalSection; - -# ifdef BOOST_NO_ANSI_APIS - using ::CreateMutexW; - using ::OpenMutexW; - using ::CreateEventW; - using ::OpenEventW; - using ::CreateSemaphoreW; - using ::OpenSemaphoreW; -# else - using ::CreateMutexA; - using ::OpenMutexA; - using ::CreateEventA; - using ::OpenEventA; - using ::CreateSemaphoreA; - using ::OpenSemaphoreA; -# endif - using ::ReleaseMutex; - using ::ReleaseSemaphore; - using ::SetEvent; - using ::ResetEvent; - using ::WaitForMultipleObjects; - using ::WaitForSingleObject; - using ::QueueUserAPC; - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - using ::InitOnceInitialize; - using ::InitOnceExecuteOnce; - using ::InitOnceBeginInitialize; - using ::InitOnceComplete; - - using ::InitializeSRWLock; - using ::AcquireSRWLockExclusive; - using ::TryAcquireSRWLockExclusive; - using ::ReleaseSRWLockExclusive; - using ::AcquireSRWLockShared; - using ::TryAcquireSRWLockShared; - using ::ReleaseSRWLockShared; - - using ::InitializeConditionVariable; - using ::WakeConditionVariable; - using ::WakeAllConditionVariable; - using ::SleepConditionVariableCS; - using ::SleepConditionVariableSRW; -#endif - - const DWORD_ infinite = INFINITE; - const DWORD_ wait_abandoned = WAIT_ABANDONED; - const DWORD_ wait_object_0 = WAIT_OBJECT_0; - const DWORD_ wait_timeout = WAIT_TIMEOUT; - const DWORD_ wait_failed = WAIT_FAILED; - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - const DWORD_ init_once_async = INIT_ONCE_ASYNC; - const DWORD_ init_once_check_only = INIT_ONCE_CHECK_ONLY; - const DWORD_ init_once_init_failed = INIT_ONCE_INIT_FAILED; - const DWORD_ init_once_ctx_reserved_bits = INIT_ONCE_CTX_RESERVED_BITS; - - const ULONG_ condition_variable_lockmode_shared = CONDITION_VARIABLE_LOCKMODE_SHARED; -#endif - -#else // defined( BOOST_USE_WINDOWS_H ) - -extern "C" { - - typedef struct CRITICAL_SECTION_ - { - struct critical_section_debug * DebugInfo; - long LockCount; - long RecursionCount; - void * OwningThread; - void * LockSemaphore; - #if defined(_WIN64) - unsigned __int64 SpinCount; - #else - unsigned long SpinCount; - #endif - } - *PCRITICAL_SECTION_; - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - typedef union INIT_ONCE_ - { - PVOID_ Ptr; - } - *PINIT_ONCE_, *LPINIT_ONCE_; - #define BOOST_DETAIL_WINAPI_INIT_ONCE_STATIC_INIT {0} - typedef BOOL_ (WINAPI *PINIT_ONCE_FN_)(PINIT_ONCE_ InitOnce, PVOID_ Parameter, PVOID_ *Context); - - typedef struct SRWLOCK_ - { - PVOID_ Ptr; - } - * PSRWLOCK_; - #define BOOST_DETAIL_WINAPI_SRWLOCK_INIT {0} - - typedef struct CONDITION_VARIABLE_ - { - PVOID_ Ptr; - } - * PCONDITION_VARIABLE_; - #define BOOST_DETAIL_WINAPI_CONDITION_VARIABLE_INIT {0} - -#endif - - __declspec(dllimport) void WINAPI - InitializeCriticalSection(PCRITICAL_SECTION_); -#if BOOST_USE_WINAPI_VERSION >= 0x0403 - __declspec(dllimport) BOOL_ WINAPI - InitializeCriticalSectionAndSpinCount(CRITICAL_SECTION_* lpCS, DWORD_ dwSpinCount); -#endif - __declspec(dllimport) void WINAPI - EnterCriticalSection(PCRITICAL_SECTION_); - __declspec(dllimport) BOOL_ WINAPI - TryEnterCriticalSection(PCRITICAL_SECTION_); - __declspec(dllimport) void WINAPI - LeaveCriticalSection(PCRITICAL_SECTION_); - __declspec(dllimport) void WINAPI - DeleteCriticalSection(PCRITICAL_SECTION_); - - struct _SECURITY_ATTRIBUTES; -# ifdef BOOST_NO_ANSI_APIS - __declspec(dllimport) HANDLE_ WINAPI - CreateMutexW(_SECURITY_ATTRIBUTES*, BOOL_, LPCWSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenMutexW(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName); - __declspec(dllimport) HANDLE_ WINAPI - CreateSemaphoreW(_SECURITY_ATTRIBUTES*, LONG_, LONG_, LPCWSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenSemaphoreW(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName); - __declspec(dllimport) HANDLE_ WINAPI - CreateEventW(_SECURITY_ATTRIBUTES*, BOOL_, BOOL_, LPCWSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenEventW(DWORD_, BOOL_, LPCWSTR_); -# else - __declspec(dllimport) HANDLE_ WINAPI - CreateMutexA(_SECURITY_ATTRIBUTES*, BOOL_, LPCSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenMutexA(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName); - __declspec(dllimport) HANDLE_ WINAPI - CreateSemaphoreA(_SECURITY_ATTRIBUTES*, LONG_, LONG_, LPCSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenSemaphoreA(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName); - __declspec(dllimport) HANDLE_ WINAPI - CreateEventA(_SECURITY_ATTRIBUTES*, BOOL_, BOOL_, LPCSTR_); - __declspec(dllimport) HANDLE_ WINAPI - OpenEventA(DWORD_, BOOL_, LPCSTR_); -# endif - __declspec(dllimport) BOOL_ WINAPI - ReleaseMutex(HANDLE_); - __declspec(dllimport) DWORD_ WINAPI - WaitForSingleObject(HANDLE_, DWORD_); - __declspec(dllimport) DWORD_ WINAPI - WaitForMultipleObjects(DWORD_ nCount, - HANDLE_ const * lpHandles, - BOOL_ bWaitAll, - DWORD_ dwMilliseconds); - __declspec(dllimport) BOOL_ WINAPI - ReleaseSemaphore(HANDLE_, LONG_, LONG_*); - __declspec(dllimport) BOOL_ WINAPI - SetEvent(HANDLE_); - __declspec(dllimport) BOOL_ WINAPI - ResetEvent(HANDLE_); - - typedef void (__stdcall *PAPCFUNC_)(ULONG_PTR_); - __declspec(dllimport) DWORD_ WINAPI - QueueUserAPC(PAPCFUNC_, HANDLE_, ULONG_PTR_); - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - __declspec(dllimport) void WINAPI InitOnceInitialize(PINIT_ONCE_); - __declspec(dllimport) BOOL_ WINAPI InitOnceExecuteOnce(PINIT_ONCE_ InitOnce, PINIT_ONCE_FN_ InitFn, PVOID_ Parameter, LPVOID_* Context); - __declspec(dllimport) BOOL_ WINAPI InitOnceBeginInitialize(LPINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, BOOL_* fPending, LPVOID_* lpContext); - __declspec(dllimport) BOOL_ WINAPI InitOnceComplete(LPINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, LPVOID_* lpContext); - - - __declspec(dllimport) void WINAPI InitializeSRWLock(PSRWLOCK_ SRWLock); - __declspec(dllimport) void WINAPI AcquireSRWLockExclusive(PSRWLOCK_ SRWLock); - __declspec(dllimport) BOOLEAN_ WINAPI TryAcquireSRWLockExclusive(PSRWLOCK_ SRWLock); - __declspec(dllimport) void WINAPI ReleaseSRWLockExclusive(PSRWLOCK_ SRWLock); - __declspec(dllimport) void WINAPI AcquireSRWLockShared(PSRWLOCK_ SRWLock); - __declspec(dllimport) BOOLEAN_ WINAPI TryAcquireSRWLockShared(PSRWLOCK_ SRWLock); - __declspec(dllimport) void WINAPI ReleaseSRWLockShared(PSRWLOCK_ SRWLock); - - __declspec(dllimport) void WINAPI InitializeConditionVariable(PCONDITION_VARIABLE_ ConditionVariable); - __declspec(dllimport) void WINAPI WakeConditionVariable(PCONDITION_VARIABLE_ ConditionVariable); - __declspec(dllimport) void WINAPI WakeAllConditionVariable(PCONDITION_VARIABLE_ ConditionVariable); - __declspec(dllimport) BOOL_ WINAPI SleepConditionVariableCS(PCONDITION_VARIABLE_ ConditionVariable, PCRITICAL_SECTION_ CriticalSection, DWORD_ dwMilliseconds); - __declspec(dllimport) BOOL_ WINAPI SleepConditionVariableSRW(PCONDITION_VARIABLE_ ConditionVariable, PSRWLOCK_ SRWLock, DWORD_ dwMilliseconds, ULONG_ Flags); -#endif - -} // extern "C" - -const DWORD_ infinite = (DWORD_)0xFFFFFFFF; -const DWORD_ wait_abandoned = 0x00000080L; -const DWORD_ wait_object_0 = 0x00000000L; -const DWORD_ wait_timeout = 0x00000102L; -const DWORD_ wait_failed = (DWORD_)0xFFFFFFFF; - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 -const DWORD_ init_once_async = 0x00000002UL; -const DWORD_ init_once_check_only = 0x00000001UL; -const DWORD_ init_once_init_failed = 0x00000004UL; -const DWORD_ init_once_ctx_reserved_bits = 2; - -const ULONG_ condition_variable_lockmode_shared = 0x00000001; -#endif - -#endif // defined( BOOST_USE_WINDOWS_H ) - -const DWORD_ max_non_infinite_wait = (DWORD_)0xFFFFFFFE; - -BOOST_FORCEINLINE HANDLE_ create_anonymous_mutex(_SECURITY_ATTRIBUTES* lpAttributes, BOOL_ bInitialOwner) -{ -#ifdef BOOST_NO_ANSI_APIS - return CreateMutexW(lpAttributes, bInitialOwner, 0); -#else - return CreateMutexA(lpAttributes, bInitialOwner, 0); -#endif -} - -BOOST_FORCEINLINE HANDLE_ create_anonymous_semaphore(_SECURITY_ATTRIBUTES* lpAttributes, LONG_ lInitialCount, LONG_ lMaximumCount) -{ -#ifdef BOOST_NO_ANSI_APIS - return CreateSemaphoreW(lpAttributes, lInitialCount, lMaximumCount, 0); -#else - return CreateSemaphoreA(lpAttributes, lInitialCount, lMaximumCount, 0); -#endif -} - -BOOST_FORCEINLINE HANDLE_ create_anonymous_event(_SECURITY_ATTRIBUTES* lpAttributes, BOOL_ bManualReset, BOOL_ bInitialState) -{ -#ifdef BOOST_NO_ANSI_APIS - return CreateEventW(lpAttributes, bManualReset, bInitialState, 0); -#else - return CreateEventA(lpAttributes, bManualReset, bInitialState, 0); -#endif -} - -} -} -} - -#endif // BOOST_DETAIL_WINAPI_SYNCHRONIZATION_HPP diff --git a/boost/detail/winapi/system.hpp b/boost/detail/winapi/system.hpp deleted file mode 100644 index 2c2d82a..0000000 --- a/boost/detail/winapi/system.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// system.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba -// Copyright (c) Microsoft Corporation 2014 - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_SYSTEM_HPP -#define BOOST_DETAIL_WINAPI_SYSTEM_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - typedef ::SYSTEM_INFO SYSTEM_INFO_; -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP -extern "C" __declspec(dllimport) void __stdcall GetSystemInfo (struct system_info *); -# else -extern "C" __declspec(dllimport) void __stdcall GetNativeSystemInfo (struct system_info *); -# endif -#else -extern "C" { - typedef struct _SYSTEM_INFO { - union { - DWORD_ dwOemId; - struct { - WORD_ wProcessorArchitecture; - WORD_ wReserved; - } dummy; - } ; - DWORD_ dwPageSize; - LPVOID_ lpMinimumApplicationAddress; - LPVOID_ lpMaximumApplicationAddress; - DWORD_PTR_ dwActiveProcessorMask; - DWORD_ dwNumberOfProcessors; - DWORD_ dwProcessorType; - DWORD_ dwAllocationGranularity; - WORD_ wProcessorLevel; - WORD_ wProcessorRevision; - } SYSTEM_INFO_; - -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - __declspec(dllimport) void __stdcall - GetSystemInfo (struct system_info *); -# else - __declspec(dllimport) void __stdcall - GetNativeSystemInfo (struct system_info *); -# endif -} -#endif -} -} -} -#endif // BOOST_DETAIL_WINAPI_SYSTEM_HPP diff --git a/boost/detail/winapi/thread.hpp b/boost/detail/winapi/thread.hpp deleted file mode 100644 index ee0dac6..0000000 --- a/boost/detail/winapi/thread.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// thread.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_THREAD_HPP -#define BOOST_DETAIL_WINAPI_THREAD_HPP - -#include -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentThreadId; - using ::SleepEx; - using ::Sleep; - using ::SwitchToThread; -#else -extern "C" { -# ifndef UNDER_CE - __declspec(dllimport) DWORD_ WINAPI GetCurrentThreadId(void); - __declspec(dllimport) DWORD_ WINAPI SleepEx(DWORD_, BOOL_); - __declspec(dllimport) void WINAPI Sleep(DWORD_); - __declspec(dllimport) BOOL_ WINAPI SwitchToThread(void); -#else - using ::GetCurrentThreadId; - using ::SleepEx; - using ::Sleep; - using ::SwitchToThread; -#endif -} -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_THREAD_HPP diff --git a/boost/detail/winapi/thread_pool.hpp b/boost/detail/winapi/thread_pool.hpp deleted file mode 100644 index 57059dc..0000000 --- a/boost/detail/winapi/thread_pool.hpp +++ /dev/null @@ -1,96 +0,0 @@ -// thread_pool.hpp --------------------------------------------------------------// - -// Copyright 2013 Andrey Semashev - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_THREAD_POOL_HPP -#define BOOST_DETAIL_WINAPI_THREAD_POOL_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - -typedef ::WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACKFUNC_; -typedef ::WAITORTIMERCALLBACK WAITORTIMERCALLBACK_; - -using ::RegisterWaitForSingleObject; -using ::UnregisterWait; -using ::UnregisterWaitEx; - -const ULONG_ wt_execute_default = WT_EXECUTEDEFAULT; -const ULONG_ wt_execute_in_io_thread = WT_EXECUTEINIOTHREAD; -const ULONG_ wt_execute_in_ui_thread = WT_EXECUTEINUITHREAD; -const ULONG_ wt_execute_in_wait_thread = WT_EXECUTEINWAITTHREAD; -const ULONG_ wt_execute_only_once = WT_EXECUTEONLYONCE; -const ULONG_ wt_execute_in_timer_thread = WT_EXECUTEINTIMERTHREAD; -const ULONG_ wt_execute_long_function = WT_EXECUTELONGFUNCTION; -const ULONG_ wt_execute_in_persistent_io_thread = WT_EXECUTEINPERSISTENTIOTHREAD; -const ULONG_ wt_execute_in_persistent_thread = WT_EXECUTEINPERSISTENTTHREAD; -const ULONG_ wt_transfer_impersonation = WT_TRANSFER_IMPERSONATION; - -inline ULONG_ wt_set_max_threadpool_threads(ULONG_ flags, ULONG_ limit) -{ - return WT_SET_MAX_THREADPOOL_THREADS(flags, limit); -} - -#else - -extern "C" { - -typedef void (NTAPI* WAITORTIMERCALLBACKFUNC_) (PVOID_, BOOLEAN_); -typedef WAITORTIMERCALLBACKFUNC_ WAITORTIMERCALLBACK_; - -__declspec(dllimport) BOOL_ WINAPI RegisterWaitForSingleObject -( - HANDLE_* phNewWaitObject, - HANDLE_ hObject, - WAITORTIMERCALLBACK_ Callback, - PVOID_ Context, - ULONG_ dwMilliseconds, - ULONG_ dwFlags -); - -__declspec(dllimport) BOOL_ WINAPI UnregisterWait(HANDLE_ WaitHandle); -__declspec(dllimport) BOOL_ WINAPI UnregisterWaitEx(HANDLE_ WaitHandle, HANDLE_ CompletionEvent); - -} // extern "C" - -const ULONG_ wt_execute_default = 0x00000000; -const ULONG_ wt_execute_in_io_thread = 0x00000001; -const ULONG_ wt_execute_in_ui_thread = 0x00000002; -const ULONG_ wt_execute_in_wait_thread = 0x00000004; -const ULONG_ wt_execute_only_once = 0x00000008; -const ULONG_ wt_execute_in_timer_thread = 0x00000020; -const ULONG_ wt_execute_long_function = 0x00000010; -const ULONG_ wt_execute_in_persistent_io_thread = 0x00000040; -const ULONG_ wt_execute_in_persistent_thread = 0x00000080; -const ULONG_ wt_transfer_impersonation = 0x00000100; - -inline ULONG_ wt_set_max_threadpool_threads(ULONG_ flags, ULONG_ limit) -{ - return flags | (limit << 16); -} - -#endif -} -} -} - -#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K - -#endif // BOOST_DETAIL_WINAPI_THREAD_POOL_HPP diff --git a/boost/detail/winapi/time.hpp b/boost/detail/winapi/time.hpp deleted file mode 100644 index 6a6b447..0000000 --- a/boost/detail/winapi/time.hpp +++ /dev/null @@ -1,105 +0,0 @@ -// time.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba -// Copyright (c) Microsoft Corporation 2014 - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_TIME_HPP -#define BOOST_DETAIL_WINAPI_TIME_HPP - -#include -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace detail { -namespace winapi { - -#if defined( BOOST_USE_WINDOWS_H ) - - typedef FILETIME FILETIME_; - typedef PFILETIME PFILETIME_; - typedef LPFILETIME LPFILETIME_; - - typedef SYSTEMTIME SYSTEMTIME_; - typedef SYSTEMTIME* PSYSTEMTIME_; - - #ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime - using ::GetSystemTimeAsFileTime; - #endif - #if BOOST_PLAT_WINDOWS_DESKTOP - using ::FileTimeToLocalFileTime; - #endif - using ::GetSystemTime; - using ::SystemTimeToFileTime; - - #if BOOST_PLAT_WINDOWS_DESKTOP - using ::GetTickCount; - #endif - #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - using ::GetTickCount64; - #endif - -#else - -extern "C" { - typedef struct _FILETIME { - DWORD_ dwLowDateTime; - DWORD_ dwHighDateTime; - } FILETIME_, *PFILETIME_, *LPFILETIME_; - - typedef struct _SYSTEMTIME { - WORD_ wYear; - WORD_ wMonth; - WORD_ wDayOfWeek; - WORD_ wDay; - WORD_ wHour; - WORD_ wMinute; - WORD_ wSecond; - WORD_ wMilliseconds; - } SYSTEMTIME_, *PSYSTEMTIME_; - - #ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime - __declspec(dllimport) void WINAPI - GetSystemTimeAsFileTime(FILETIME_* lpFileTime); - #endif - __declspec(dllimport) int WINAPI - FileTimeToLocalFileTime(const FILETIME_* lpFileTime, - FILETIME_* lpLocalFileTime); - __declspec(dllimport) void WINAPI - GetSystemTime(SYSTEMTIME_* lpSystemTime); - __declspec(dllimport) int WINAPI - SystemTimeToFileTime(const SYSTEMTIME_* lpSystemTime, - FILETIME_* lpFileTime); - #if BOOST_PLAT_WINDOWS_DESKTOP - __declspec(dllimport) DWORD_ WINAPI - GetTickCount(); - #endif - #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 - __declspec(dllimport) ULONGLONG_ WINAPI - GetTickCount64(); - #endif -} - -#endif - -#ifndef BOOST_HAS_GETSYSTEMTIMEASFILETIME -inline void WINAPI GetSystemTimeAsFileTime(FILETIME_* lpFileTime) -{ - SYSTEMTIME_ st; - GetSystemTime(&st); - SystemTimeToFileTime(&st, lpFileTime); -} -#endif - -} -} -} - -#endif // BOOST_DETAIL_WINAPI_TIME_HPP diff --git a/boost/detail/winapi/timers.hpp b/boost/detail/winapi/timers.hpp deleted file mode 100644 index 04c6dfb..0000000 --- a/boost/detail/winapi/timers.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// timers.hpp --------------------------------------------------------------// - -// Copyright 2010 Vicente J. Botet Escriba - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_TIMERS_HPP -#define BOOST_DETAIL_WINAPI_TIMERS_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - using ::QueryPerformanceCounter; - using ::QueryPerformanceFrequency; -#else -extern "C" { - __declspec(dllimport) BOOL_ WINAPI - QueryPerformanceCounter( - LARGE_INTEGER_ *lpPerformanceCount - ); - - __declspec(dllimport) BOOL_ WINAPI - QueryPerformanceFrequency( - LARGE_INTEGER_ *lpFrequency - ); -} -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_TIMERS_HPP diff --git a/boost/detail/winapi/tls.hpp b/boost/detail/winapi/tls.hpp deleted file mode 100644 index d948693..0000000 --- a/boost/detail/winapi/tls.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// tls.hpp --------------------------------------------------------------// - -// Copyright 2013 Andrey Semashev - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_TLS_HPP -#define BOOST_DETAIL_WINAPI_TLS_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - -using ::TlsAlloc; -using ::TlsGetValue; -using ::TlsSetValue; -using ::TlsFree; - -const DWORD_ tls_out_of_indexes = TLS_OUT_OF_INDEXES; - -#else - -extern "C" { -__declspec(dllimport) DWORD_ WINAPI TlsAlloc(void); -__declspec(dllimport) LPVOID_ WINAPI TlsGetValue(DWORD_ dwTlsIndex); -__declspec(dllimport) BOOL_ WINAPI TlsSetValue(DWORD_ dwTlsIndex, LPVOID_ lpTlsValue); -__declspec(dllimport) BOOL_ WINAPI TlsFree(DWORD_ dwTlsIndex); -} - -const DWORD_ tls_out_of_indexes = 0xFFFFFFFF; - -#endif -} -} -} - -#endif // BOOST_DETAIL_WINAPI_TLS_HPP diff --git a/boost/detail/winapi/waitable_timer.hpp b/boost/detail/winapi/waitable_timer.hpp deleted file mode 100644 index 52a7338..0000000 --- a/boost/detail/winapi/waitable_timer.hpp +++ /dev/null @@ -1,110 +0,0 @@ -// waitable_timer.hpp --------------------------------------------------------------// - -// Copyright 2013 Andrey Semashev - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - - -#ifndef BOOST_DETAIL_WINAPI_WAITABLE_TIMER_HPP -#define BOOST_DETAIL_WINAPI_WAITABLE_TIMER_HPP - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - -typedef ::PTIMERAPCROUTINE PTIMERAPCROUTINE_; - -# ifdef BOOST_NO_ANSI_APIS -using ::CreateWaitableTimerW; -using ::OpenWaitableTimerW; -# else -using ::CreateWaitableTimerA; -using ::OpenWaitableTimerA; -# endif -using ::SetWaitableTimer; -using ::CancelWaitableTimer; - -#else - -extern "C" { - -struct _SECURITY_ATTRIBUTES; - -typedef void (WINAPI* PTIMERAPCROUTINE_) -( - LPVOID_ lpArgToCompletionRoutine, - DWORD_ dwTimerLowValue, - DWORD_ dwTimerHighValue -); - -# ifdef BOOST_NO_ANSI_APIS -__declspec(dllimport) HANDLE_ WINAPI CreateWaitableTimerW -( - _SECURITY_ATTRIBUTES* lpTimerAttributes, - BOOL_ bManualReset, - LPCWSTR_ lpTimerName -); - -__declspec(dllimport) HANDLE_ WINAPI OpenWaitableTimerW -( - DWORD_ dwDesiredAccess, - BOOL_ bInheritHandle, - LPCWSTR_ lpTimerName -); -# else -__declspec(dllimport) HANDLE_ WINAPI CreateWaitableTimerA -( - _SECURITY_ATTRIBUTES* lpTimerAttributes, - BOOL_ bManualReset, - LPCSTR_ lpTimerName -); - -__declspec(dllimport) HANDLE_ WINAPI OpenWaitableTimerA -( - DWORD_ dwDesiredAccess, - BOOL_ bInheritHandle, - LPCSTR_ lpTimerName -); -# endif - -__declspec(dllimport) BOOL_ WINAPI SetWaitableTimer -( - HANDLE_ hTimer, - const LARGE_INTEGER_ *lpDueTime, - LONG_ lPeriod, - PTIMERAPCROUTINE_ pfnCompletionRoutine, - LPVOID_ lpArgToCompletionRoutine, - BOOL_ fResume -); - -__declspec(dllimport) BOOL_ WINAPI CancelWaitableTimer(HANDLE_ hTimer); - -} - -#endif - -BOOST_FORCEINLINE HANDLE_ create_anonymous_waitable_timer(_SECURITY_ATTRIBUTES* lpTimerAttributes, BOOL_ bManualReset) -{ -#ifdef BOOST_NO_ANSI_APIS - return CreateWaitableTimerW(lpTimerAttributes, bManualReset, 0); -#else - return CreateWaitableTimerA(lpTimerAttributes, bManualReset, 0); -#endif -} - -} -} -} - -#endif // BOOST_DETAIL_WINAPI_WAITABLE_TIMER_HPP diff --git a/boost/dynamic_bitset.hpp b/boost/dynamic_bitset.hpp deleted file mode 100644 index 29e1038..0000000 --- a/boost/dynamic_bitset.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// ----------------------------------------------------------- -// -// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek -// Copyright (c) 2003-2004, 2008 Gennaro Prota -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// ----------------------------------------------------------- - -#ifndef BOOST_DYNAMIC_BITSET_HPP -#define BOOST_DYNAMIC_BITSET_HPP - -#include "boost/dynamic_bitset/dynamic_bitset.hpp" - -#endif // include guard diff --git a/boost/dynamic_bitset_fwd.hpp b/boost/dynamic_bitset_fwd.hpp deleted file mode 100644 index 7bb6e89..0000000 --- a/boost/dynamic_bitset_fwd.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// ----------------------------------------------------------- -// -// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek -// Copyright (c) 2003-2004 Gennaro Prota -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// ----------------------------------------------------------- - -#ifndef BOOST_DYNAMIC_BITSET_FWD_HPP -#define BOOST_DYNAMIC_BITSET_FWD_HPP - -#include - -namespace boost { - -template > -class dynamic_bitset; - -} - -#endif // include guard diff --git a/boost/enable_shared_from_this.hpp b/boost/enable_shared_from_this.hpp deleted file mode 100644 index b1bb63d..0000000 --- a/boost/enable_shared_from_this.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED -#define BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED - -// -// enable_shared_from_this.hpp -// -// Copyright (c) 2002 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt -// -// http://www.boost.org/libs/smart_ptr/enable_shared_from_this.html -// - -#include - -#endif // #ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED diff --git a/boost/exception_ptr.hpp b/boost/exception_ptr.hpp deleted file mode 100644 index d48cce9..0000000 --- a/boost/exception_ptr.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. - -//Distributed under the Boost Software License, Version 1.0. (See accompanying -//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef UUID_FA5836A2CADA11DC8CD47C8555D89593 -#define UUID_FA5836A2CADA11DC8CD47C8555D89593 - -#include - -#endif diff --git a/boost/filesystem.hpp b/boost/filesystem.hpp deleted file mode 100644 index 1a75302..0000000 --- a/boost/filesystem.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// boost/filesystem.hpp --------------------------------------------------------------// - -// Copyright Beman Dawes 2010 - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - -// Library home page: http://www.boost.org/libs/filesystem - -//--------------------------------------------------------------------------------------// - -#ifndef BOOST_FILESYSTEM_FILESYSTEM_HPP -#define BOOST_FILESYSTEM_FILESYSTEM_HPP - -# include -# include -# include -# include - -#endif // BOOST_FILESYSTEM_FILESYSTEM_HPP diff --git a/boost/flyweight.hpp b/boost/flyweight.hpp deleted file mode 100644 index 852ea8e..0000000 --- a/boost/flyweight.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2006-2008 Joaquin M Lopez Munoz. - * Distributed under the 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/flyweight for library home page. - */ - -#ifndef BOOST_FLYWEIGHT_HPP -#define BOOST_FLYWEIGHT_HPP - -#if defined(_MSC_VER) -#pragma once -#endif - -#include -#include -#include -#include -#include - -#endif diff --git a/boost/foreach.hpp b/boost/foreach.hpp deleted file mode 100644 index ac2e613..0000000 --- a/boost/foreach.hpp +++ /dev/null @@ -1,1121 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// foreach.hpp header file -// -// Copyright 2004 Eric Niebler. -// Distributed under the 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/foreach for documentation -// -// Credits: -// Anson Tsao - for the initial inspiration and several good suggestions. -// Thorsten Ottosen - for Boost.Range, and for suggesting a way to detect -// const-qualified rvalues at compile time on VC7.1+ -// Russell Hind - For help porting to Borland -// Alisdair Meredith - For help porting to Borland -// Stefan Slapeta - For help porting to Intel -// David Jenkins - For help finding a Microsoft Code Analysis bug -// mimomorin@... - For a patch to use rvalue refs on supporting compilers - -#ifndef BOOST_FOREACH - -// MS compatible compilers support #pragma once -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include // for std::pair - -#include -#include - -// Some compilers let us detect even const-qualified rvalues at compile-time -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \ - || defined(BOOST_MSVC) && !defined(_PREFAST_) \ - || (BOOST_WORKAROUND(__GNUC__, == 4) && (__GNUC_MINOR__ <= 5) && !defined(BOOST_INTEL) && \ - !defined(BOOST_CLANG)) \ - || (BOOST_WORKAROUND(__GNUC__, == 3) && (__GNUC_MINOR__ >= 4) && !defined(BOOST_INTEL) && \ - !defined(BOOST_CLANG)) -# define BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION -#else -// Some compilers allow temporaries to be bound to non-const references. -// These compilers make it impossible to for BOOST_FOREACH to detect -// temporaries and avoid reevaluation of the collection expression. -# if BOOST_WORKAROUND(__BORLANDC__, < 0x593) \ - || (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) && defined(_MSC_VER)) \ - || BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) \ - || BOOST_WORKAROUND(__DECCXX_VER, <= 60590042) -# define BOOST_FOREACH_NO_RVALUE_DETECTION -# endif -// Some compilers do not correctly implement the lvalue/rvalue conversion -// rules of the ternary conditional operator. -# if defined(BOOST_FOREACH_NO_RVALUE_DETECTION) \ - || defined(BOOST_NO_SFINAE) \ - || BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \ - || BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(1400)) \ - || (BOOST_WORKAROUND(__GNUC__, == 3) && (__GNUC_MINOR__ <= 3) && defined(__APPLE_CC__)) \ - || BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) \ - || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) \ - || BOOST_WORKAROUND(__SUNPRO_CC, >= 0x5100) \ - || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) -# define BOOST_FOREACH_NO_CONST_RVALUE_DETECTION -# else -# define BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION -# endif -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION -# include -# include -# include -# include -#endif - -namespace boost -{ - -// forward declarations for iterator_range -template -class iterator_range; - -// forward declarations for sub_range -template -class sub_range; - -namespace foreach -{ - /////////////////////////////////////////////////////////////////////////////// - // in_range - // - template - inline std::pair in_range(T begin, T end) - { - return std::make_pair(begin, end); - } - - /////////////////////////////////////////////////////////////////////////////// - // boost::foreach::is_lightweight_proxy - // Specialize this for user-defined collection types if they are inexpensive to copy. - // This tells BOOST_FOREACH it can avoid the rvalue/lvalue detection stuff. - template - struct is_lightweight_proxy - : boost::mpl::false_ - { - }; - - /////////////////////////////////////////////////////////////////////////////// - // boost::foreach::is_noncopyable - // Specialize this for user-defined collection types if they cannot be copied. - // This also tells BOOST_FOREACH to avoid the rvalue/lvalue detection stuff. - template - struct is_noncopyable - #if !defined(BOOST_BROKEN_IS_BASE_AND_DERIVED) && !defined(BOOST_NO_IS_ABSTRACT) - : boost::mpl::or_< - boost::is_abstract - , boost::is_base_and_derived - > - #elif !defined(BOOST_BROKEN_IS_BASE_AND_DERIVED) - : boost::is_base_and_derived - #elif !defined(BOOST_NO_IS_ABSTRACT) - : boost::is_abstract - #else - : boost::mpl::false_ - #endif - { - }; - -} // namespace foreach - -} // namespace boost - -// vc6/7 needs help ordering the following overloads -#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -# define BOOST_FOREACH_TAG_DEFAULT ... -#else -# define BOOST_FOREACH_TAG_DEFAULT boost::foreach::tag -#endif - -/////////////////////////////////////////////////////////////////////////////// -// boost_foreach_is_lightweight_proxy -// Another customization point for the is_lightweight_proxy optimization, -// this one works on legacy compilers. Overload boost_foreach_is_lightweight_proxy -// at the global namespace for your type. -template -inline boost::foreach::is_lightweight_proxy * -boost_foreach_is_lightweight_proxy(T *&, BOOST_FOREACH_TAG_DEFAULT) { return 0; } - -template -inline boost::mpl::true_ * -boost_foreach_is_lightweight_proxy(std::pair *&, boost::foreach::tag) { return 0; } - -template -inline boost::mpl::true_ * -boost_foreach_is_lightweight_proxy(boost::iterator_range *&, boost::foreach::tag) { return 0; } - -template -inline boost::mpl::true_ * -boost_foreach_is_lightweight_proxy(boost::sub_range *&, boost::foreach::tag) { return 0; } - -template -inline boost::mpl::true_ * -boost_foreach_is_lightweight_proxy(T **&, boost::foreach::tag) { return 0; } - -/////////////////////////////////////////////////////////////////////////////// -// boost_foreach_is_noncopyable -// Another customization point for the is_noncopyable trait, -// this one works on legacy compilers. Overload boost_foreach_is_noncopyable -// at the global namespace for your type. -template -inline boost::foreach::is_noncopyable * -boost_foreach_is_noncopyable(T *&, BOOST_FOREACH_TAG_DEFAULT) { return 0; } - -namespace boost -{ - -namespace foreach_detail_ -{ - -/////////////////////////////////////////////////////////////////////////////// -// Define some utilities for assessing the properties of expressions -// -template -inline boost::mpl::and_ *and_(Bool1 *, Bool2 *) { return 0; } - -template -inline boost::mpl::and_ *and_(Bool1 *, Bool2 *, Bool3 *) { return 0; } - -template -inline boost::mpl::or_ *or_(Bool1 *, Bool2 *) { return 0; } - -template -inline boost::mpl::or_ *or_(Bool1 *, Bool2 *, Bool3 *) { return 0; } - -template -inline boost::mpl::not_ *not_(Bool1 *) { return 0; } - -template -inline boost::is_array *is_array_(T const &) { return 0; } - -template -inline boost::is_const *is_const_(T &) { return 0; } - -#ifndef BOOST_FOREACH_NO_RVALUE_DETECTION -template -inline boost::mpl::true_ *is_const_(T const &) { return 0; } -#endif - -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES -template -inline boost::mpl::false_ *is_rvalue_(T &, int) { return 0; } - -template -inline boost::mpl::true_ *is_rvalue_(T const &, ...) { return 0; } -#else -template -inline boost::is_rvalue_reference *is_rvalue_(T &&, int) { return 0; } -#endif - -/////////////////////////////////////////////////////////////////////////////// -// auto_any_t/auto_any -// General utility for putting an object of any type into automatic storage -struct auto_any_base -{ - // auto_any_base must evaluate to false in boolean context so that - // they can be declared in if() statements. - operator bool() const - { - return false; - } -}; - -template -struct auto_any : auto_any_base -{ - explicit auto_any(T const &t) - : item(t) - { - } - - // temporaries of type auto_any will be bound to const auto_any_base - // references, but we still want to be able to mutate the stored - // data, so declare it as mutable. - mutable T item; -}; - -typedef auto_any_base const &auto_any_t; - -template -inline BOOST_DEDUCED_TYPENAME boost::mpl::if_::type &auto_any_cast(auto_any_t a) -{ - return static_cast const &>(a).item; -} - -typedef boost::mpl::true_ const_; - -/////////////////////////////////////////////////////////////////////////////// -// type2type -// -template -struct type2type - : boost::mpl::if_ -{ -}; - -template -struct wrap_cstr -{ - typedef T type; -}; - -template<> -struct wrap_cstr -{ - typedef wrap_cstr type; - typedef char *iterator; - typedef char *const_iterator; -}; - -template<> -struct wrap_cstr -{ - typedef wrap_cstr type; - typedef char const *iterator; - typedef char const *const_iterator; -}; - -template<> -struct wrap_cstr -{ - typedef wrap_cstr type; - typedef wchar_t *iterator; - typedef wchar_t *const_iterator; -}; - -template<> -struct wrap_cstr -{ - typedef wrap_cstr type; - typedef wchar_t const *iterator; - typedef wchar_t const *const_iterator; -}; - -template -struct is_char_array - : mpl::and_< - is_array - , mpl::or_< - is_convertible - , is_convertible - > - > -{}; - -template -struct foreach_iterator -{ - // **** READ THIS IF YOUR COMPILE BREAKS HERE **** - // - // There is an ambiguity about how to iterate over arrays of char and wchar_t. - // Should the last array element be treated as a null terminator to be skipped, or - // is it just like any other element in the array? To fix the problem, you must - // say which behavior you want. - // - // To treat the container as a null-terminated string, merely cast it to a - // char const *, as in BOOST_FOREACH( char ch, (char const *)"hello" ) ... - // - // To treat the container as an array, use boost::as_array() in , - // as in BOOST_FOREACH( char ch, boost::as_array("hello") ) ... - BOOST_MPL_ASSERT_MSG( (!is_char_array::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T&) ); - - // If the type is a pointer to a null terminated string (as opposed - // to an array type), there is no ambiguity. - typedef BOOST_DEDUCED_TYPENAME wrap_cstr::type container; - - typedef BOOST_DEDUCED_TYPENAME boost::mpl::eval_if< - C - , range_const_iterator - , range_mutable_iterator - >::type type; -}; - - -template -struct foreach_reverse_iterator -{ - // **** READ THIS IF YOUR COMPILE BREAKS HERE **** - // - // There is an ambiguity about how to iterate over arrays of char and wchar_t. - // Should the last array element be treated as a null terminator to be skipped, or - // is it just like any other element in the array? To fix the problem, you must - // say which behavior you want. - // - // To treat the container as a null-terminated string, merely cast it to a - // char const *, as in BOOST_FOREACH( char ch, (char const *)"hello" ) ... - // - // To treat the container as an array, use boost::as_array() in , - // as in BOOST_FOREACH( char ch, boost::as_array("hello") ) ... - BOOST_MPL_ASSERT_MSG( (!is_char_array::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T&) ); - - // If the type is a pointer to a null terminated string (as opposed - // to an array type), there is no ambiguity. - typedef BOOST_DEDUCED_TYPENAME wrap_cstr::type container; - - typedef BOOST_DEDUCED_TYPENAME boost::mpl::eval_if< - C - , range_reverse_iterator - , range_reverse_iterator - >::type type; -}; - -template -struct foreach_reference - : iterator_reference::type> -{ -}; - -/////////////////////////////////////////////////////////////////////////////// -// encode_type -// -template -inline type2type *encode_type(T &, boost::mpl::false_ *) { return 0; } - -template -inline type2type *encode_type(T const &, boost::mpl::true_ *) { return 0; } - -/////////////////////////////////////////////////////////////////////////////// -// set_false -// -inline bool set_false(bool &b) -{ - b = false; - return false; -} - -/////////////////////////////////////////////////////////////////////////////// -// to_ptr -// -template -inline T *&to_ptr(T const &) -{ - static T *t = 0; - return t; -} - -// Borland needs a little extra help with arrays -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -template -inline T (*&to_ptr(T (&)[N]))[N] -{ - static T (*t)[N] = 0; - return t; -} - -/////////////////////////////////////////////////////////////////////////////// -// derefof -// -template -inline T &derefof(T *t) -{ - // This is a work-around for a compiler bug in Borland. If T* is a pointer to array type U(*)[N], - // then dereferencing it results in a U* instead of U(&)[N]. The cast forces the issue. - return reinterpret_cast( - *const_cast( - reinterpret_cast(t) - ) - ); -} - -# define BOOST_FOREACH_DEREFOF(T) boost::foreach_detail_::derefof(*T) -#else -# define BOOST_FOREACH_DEREFOF(T) (*T) -#endif - -#if defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION) \ - && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) -/////////////////////////////////////////////////////////////////////////////// -// Rvalue references makes it drop-dead simple to detect at compile time -// whether an expression is an rvalue. -/////////////////////////////////////////////////////////////////////////////// - -# define BOOST_FOREACH_IS_RVALUE(COL) \ - boost::foreach_detail_::is_rvalue_((COL), 0) - -#elif defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION) \ - && defined(BOOST_NO_CXX11_RVALUE_REFERENCES) -/////////////////////////////////////////////////////////////////////////////// -// Detect at compile-time whether an expression yields an rvalue or -// an lvalue. This is rather non-standard, but some popular compilers -// accept it. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// rvalue_probe -// -template -struct rvalue_probe -{ - struct private_type_ {}; - // can't ever return an array by value - typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_< - boost::mpl::or_, boost::is_array >, private_type_, T - >::type value_type; - operator value_type() { return *reinterpret_cast(this); } // never called - operator T &() const { return *reinterpret_cast(const_cast(this)); } // never called -}; - -template -rvalue_probe const make_probe(T const &) -{ - return rvalue_probe(); -} - -# define BOOST_FOREACH_IS_RVALUE(COL) \ - boost::foreach_detail_::and_( \ - boost::foreach_detail_::not_(boost::foreach_detail_::is_array_(COL)) \ - , (true ? 0 : boost::foreach_detail_::is_rvalue_( \ - (true ? boost::foreach_detail_::make_probe(COL) : (COL)), 0))) - -#elif defined(BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION) -/////////////////////////////////////////////////////////////////////////////// -// Detect at run-time whether an expression yields an rvalue -// or an lvalue. This is 100% standard C++, but not all compilers -// accept it. Also, it causes FOREACH to break when used with non- -// copyable collection types. -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// rvalue_probe -// -template -struct rvalue_probe -{ - rvalue_probe(T &t, bool &b) - : value(t) - , is_rvalue(b) - { - } - - struct private_type_ {}; - // can't ever return an array or an abstract type by value - #ifdef BOOST_NO_IS_ABSTRACT - typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_< - boost::is_array, private_type_, T - >::type value_type; - #else - typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_< - boost::mpl::or_, boost::is_array >, private_type_, T - >::type value_type; - #endif - - operator value_type() - { - this->is_rvalue = true; - return this->value; - } - - operator T &() const - { - return this->value; - } - -private: - T &value; - bool &is_rvalue; -}; - -template -rvalue_probe make_probe(T &t, bool &b) { return rvalue_probe(t, b); } - -template -rvalue_probe make_probe(T const &t, bool &b) { return rvalue_probe(t, b); } - -/////////////////////////////////////////////////////////////////////////////// -// simple_variant -// holds either a T or a T const* -template -struct simple_variant -{ - simple_variant(T const *t) - : is_rvalue(false) - { - *static_cast(this->data.address()) = t; - } - - simple_variant(T const &t) - : is_rvalue(true) - { - ::new(this->data.address()) T(t); - } - - simple_variant(simple_variant const &that) - : is_rvalue(that.is_rvalue) - { - if(this->is_rvalue) - ::new(this->data.address()) T(*that.get()); - else - *static_cast(this->data.address()) = that.get(); - } - - ~simple_variant() - { - if(this->is_rvalue) - this->get()->~T(); - } - - T const *get() const - { - if(this->is_rvalue) - return static_cast(this->data.address()); - else - return *static_cast(this->data.address()); - } - -private: - enum size_type { size = sizeof(T) > sizeof(T*) ? sizeof(T) : sizeof(T*) }; - simple_variant &operator =(simple_variant const &); - bool const is_rvalue; - aligned_storage data; -}; - -// If the collection is an array or is noncopyable, it must be an lvalue. -// If the collection is a lightweight proxy, treat it as an rvalue -// BUGBUG what about a noncopyable proxy? -template -inline BOOST_DEDUCED_TYPENAME boost::enable_if, IsProxy>::type * -should_copy_impl(LValue *, IsProxy *, bool *) -{ - return 0; -} - -// Otherwise, we must determine at runtime whether it's an lvalue or rvalue -inline bool * -should_copy_impl(boost::mpl::false_ *, boost::mpl::false_ *, bool *is_rvalue) -{ - return is_rvalue; -} - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// contain -// -template -inline auto_any contain(T const &t, boost::mpl::true_ *) // rvalue -{ - return auto_any(t); -} - -template -inline auto_any contain(T &t, boost::mpl::false_ *) // lvalue -{ - // Cannot seem to get sunpro to handle addressof() with array types. - #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x570)) - return auto_any(&t); - #else - return auto_any(boost::addressof(t)); - #endif -} - -#ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION -template -inline auto_any > -contain(T const &t, bool *rvalue) -{ - return auto_any >(*rvalue ? simple_variant(t) : simple_variant(&t)); -} -#endif - -///////////////////////////////////////////////////////////////////////////// -// begin -// -template -inline auto_any::type> -begin(auto_any_t col, type2type *, boost::mpl::true_ *) // rvalue -{ - return auto_any::type>( - boost::begin(auto_any_cast(col))); -} - -template -inline auto_any::type> -begin(auto_any_t col, type2type *, boost::mpl::false_ *) // lvalue -{ - typedef BOOST_DEDUCED_TYPENAME type2type::type type; - typedef BOOST_DEDUCED_TYPENAME foreach_iterator::type iterator; - return auto_any::type>( - iterator(boost::begin(BOOST_FOREACH_DEREFOF((auto_any_cast(col)))))); -} - -#ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION -template -inline auto_any::type> -begin(auto_any_t col, type2type *, bool *) -{ - return auto_any::type>( - boost::begin(*auto_any_cast, boost::mpl::false_>(col).get())); -} -#endif - -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -template -inline auto_any -begin(auto_any_t col, type2type *, boost::mpl::true_ *) // null-terminated C-style strings -{ - return auto_any(auto_any_cast(col)); -} -#endif - -/////////////////////////////////////////////////////////////////////////////// -// end -// -template -inline auto_any::type> -end(auto_any_t col, type2type *, boost::mpl::true_ *) // rvalue -{ - return auto_any::type>( - boost::end(auto_any_cast(col))); -} - -template -inline auto_any::type> -end(auto_any_t col, type2type *, boost::mpl::false_ *) // lvalue -{ - typedef BOOST_DEDUCED_TYPENAME type2type::type type; - typedef BOOST_DEDUCED_TYPENAME foreach_iterator::type iterator; - return auto_any::type>( - iterator(boost::end(BOOST_FOREACH_DEREFOF((auto_any_cast(col)))))); -} - -#ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION -template -inline auto_any::type> -end(auto_any_t col, type2type *, bool *) -{ - return auto_any::type>( - boost::end(*auto_any_cast, boost::mpl::false_>(col).get())); -} -#endif - -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -template -inline auto_any -end(auto_any_t, type2type *, boost::mpl::true_ *) // null-terminated C-style strings -{ - return auto_any(0); // not used -} -#endif - -/////////////////////////////////////////////////////////////////////////////// -// done -// -template -inline bool done(auto_any_t cur, auto_any_t end, type2type *) -{ - typedef BOOST_DEDUCED_TYPENAME foreach_iterator::type iter_t; - return auto_any_cast(cur) == auto_any_cast(end); -} - -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -template -inline bool done(auto_any_t cur, auto_any_t, type2type *) // null-terminated C-style strings -{ - return ! *auto_any_cast(cur); -} -#endif - -/////////////////////////////////////////////////////////////////////////////// -// next -// -template -inline void next(auto_any_t cur, type2type *) -{ - typedef BOOST_DEDUCED_TYPENAME foreach_iterator::type iter_t; - ++auto_any_cast(cur); -} - -/////////////////////////////////////////////////////////////////////////////// -// deref -// -template -inline BOOST_DEDUCED_TYPENAME foreach_reference::type -deref(auto_any_t cur, type2type *) -{ - typedef BOOST_DEDUCED_TYPENAME foreach_iterator::type iter_t; - return *auto_any_cast(cur); -} - -///////////////////////////////////////////////////////////////////////////// -// rbegin -// -template -inline auto_any::type> -rbegin(auto_any_t col, type2type *, boost::mpl::true_ *) // rvalue -{ - return auto_any::type>( - boost::rbegin(auto_any_cast(col))); -} - -template -inline auto_any::type> -rbegin(auto_any_t col, type2type *, boost::mpl::false_ *) // lvalue -{ - typedef BOOST_DEDUCED_TYPENAME type2type::type type; - typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator::type iterator; - return auto_any::type>( - iterator(boost::rbegin(BOOST_FOREACH_DEREFOF((auto_any_cast(col)))))); -} - -#ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION -template -inline auto_any::type> -rbegin(auto_any_t col, type2type *, bool *) -{ - return auto_any::type>( - boost::rbegin(*auto_any_cast, boost::mpl::false_>(col).get())); -} -#endif - -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -template -inline auto_any > -rbegin(auto_any_t col, type2type *, boost::mpl::true_ *) // null-terminated C-style strings -{ - T *p = auto_any_cast(col); - while(0 != *p) - ++p; - return auto_any >(reverse_iterator(p)); -} -#endif - -/////////////////////////////////////////////////////////////////////////////// -// rend -// -template -inline auto_any::type> -rend(auto_any_t col, type2type *, boost::mpl::true_ *) // rvalue -{ - return auto_any::type>( - boost::rend(auto_any_cast(col))); -} - -template -inline auto_any::type> -rend(auto_any_t col, type2type *, boost::mpl::false_ *) // lvalue -{ - typedef BOOST_DEDUCED_TYPENAME type2type::type type; - typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator::type iterator; - return auto_any::type>( - iterator(boost::rend(BOOST_FOREACH_DEREFOF((auto_any_cast(col)))))); -} - -#ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION -template -inline auto_any::type> -rend(auto_any_t col, type2type *, bool *) -{ - return auto_any::type>( - boost::rend(*auto_any_cast, boost::mpl::false_>(col).get())); -} -#endif - -#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -template -inline auto_any > -rend(auto_any_t col, type2type *, boost::mpl::true_ *) // null-terminated C-style strings -{ - return auto_any >( - reverse_iterator(auto_any_cast(col))); -} -#endif - -/////////////////////////////////////////////////////////////////////////////// -// rdone -// -template -inline bool rdone(auto_any_t cur, auto_any_t end, type2type *) -{ - typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator::type iter_t; - return auto_any_cast(cur) == auto_any_cast(end); -} - -/////////////////////////////////////////////////////////////////////////////// -// rnext -// -template -inline void rnext(auto_any_t cur, type2type *) -{ - typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator::type iter_t; - ++auto_any_cast(cur); -} - -/////////////////////////////////////////////////////////////////////////////// -// rderef -// -template -inline BOOST_DEDUCED_TYPENAME foreach_reference::type -rderef(auto_any_t cur, type2type *) -{ - typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator::type iter_t; - return *auto_any_cast(cur); -} - -} // namespace foreach_detail_ -} // namespace boost - -// Suppress a bogus code analysis warning on vc8+ -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -# define BOOST_FOREACH_SUPPRESS_WARNINGS() __pragma(warning(suppress:6001)) -#else -# define BOOST_FOREACH_SUPPRESS_WARNINGS() -#endif - -/////////////////////////////////////////////////////////////////////////////// -// Define a macro for giving hidden variables a unique name. Not strictly -// needed, but eliminates some warnings on some compilers. -#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) -// With some versions of MSVC, use of __LINE__ to create unique identifiers -// can fail when the Edit-and-Continue debug flag is used. -# define BOOST_FOREACH_ID(x) x -#else -# define BOOST_FOREACH_ID(x) BOOST_PP_CAT(x, __LINE__) -#endif - -// A sneaky way to get the type of the collection without evaluating the expression -#define BOOST_FOREACH_TYPEOF(COL) \ - (true ? 0 : boost::foreach_detail_::encode_type(COL, boost::foreach_detail_::is_const_(COL))) - -// returns true_* if the type is noncopyable -#define BOOST_FOREACH_IS_NONCOPYABLE(COL) \ - boost_foreach_is_noncopyable( \ - boost::foreach_detail_::to_ptr(COL) \ - , boost_foreach_argument_dependent_lookup_hack_value) - -// returns true_* if the type is a lightweight proxy (and is not noncopyable) -#define BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL) \ - boost::foreach_detail_::and_( \ - boost::foreach_detail_::not_(BOOST_FOREACH_IS_NONCOPYABLE(COL)) \ - , boost_foreach_is_lightweight_proxy( \ - boost::foreach_detail_::to_ptr(COL) \ - , boost_foreach_argument_dependent_lookup_hack_value)) - -#if defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION) -/////////////////////////////////////////////////////////////////////////////// -// R-values and const R-values supported here with zero runtime overhead -/////////////////////////////////////////////////////////////////////////////// - -// No variable is needed to track the rvalue-ness of the collection expression -# define BOOST_FOREACH_PREAMBLE() \ - BOOST_FOREACH_SUPPRESS_WARNINGS() - -// Evaluate the collection expression -# define BOOST_FOREACH_EVALUATE(COL) \ - (COL) - -# define BOOST_FOREACH_SHOULD_COPY(COL) \ - (true ? 0 : boost::foreach_detail_::or_( \ - BOOST_FOREACH_IS_RVALUE(COL) \ - , BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL))) - -#elif defined(BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION) -/////////////////////////////////////////////////////////////////////////////// -// R-values and const R-values supported here -/////////////////////////////////////////////////////////////////////////////// - -// Declare a variable to track the rvalue-ness of the collection expression -# define BOOST_FOREACH_PREAMBLE() \ - BOOST_FOREACH_SUPPRESS_WARNINGS() \ - if (bool BOOST_FOREACH_ID(_foreach_is_rvalue) = false) {} else - -// Evaluate the collection expression, and detect if it is an lvalue or and rvalue -# define BOOST_FOREACH_EVALUATE(COL) \ - (true ? boost::foreach_detail_::make_probe((COL), BOOST_FOREACH_ID(_foreach_is_rvalue)) : (COL)) - -// The rvalue/lvalue-ness of the collection expression is determined dynamically, unless -// the type is an array or is noncopyable or is non-const, in which case we know it's an lvalue. -// If the type happens to be a lightweight proxy, always make a copy. -# define BOOST_FOREACH_SHOULD_COPY(COL) \ - (boost::foreach_detail_::should_copy_impl( \ - true ? 0 : boost::foreach_detail_::or_( \ - boost::foreach_detail_::is_array_(COL) \ - , BOOST_FOREACH_IS_NONCOPYABLE(COL) \ - , boost::foreach_detail_::not_(boost::foreach_detail_::is_const_(COL))) \ - , true ? 0 : BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL) \ - , &BOOST_FOREACH_ID(_foreach_is_rvalue))) - -#elif !defined(BOOST_FOREACH_NO_RVALUE_DETECTION) -/////////////////////////////////////////////////////////////////////////////// -// R-values supported here, const R-values NOT supported here -/////////////////////////////////////////////////////////////////////////////// - -// No variable is needed to track the rvalue-ness of the collection expression -# define BOOST_FOREACH_PREAMBLE() \ - BOOST_FOREACH_SUPPRESS_WARNINGS() - -// Evaluate the collection expression -# define BOOST_FOREACH_EVALUATE(COL) \ - (COL) - -// Determine whether the collection expression is an lvalue or an rvalue. -// NOTE: this gets the answer wrong for const rvalues. -# define BOOST_FOREACH_SHOULD_COPY(COL) \ - (true ? 0 : boost::foreach_detail_::or_( \ - boost::foreach_detail_::is_rvalue_((COL), 0) \ - , BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL))) - -#else -/////////////////////////////////////////////////////////////////////////////// -// R-values NOT supported here -/////////////////////////////////////////////////////////////////////////////// - -// No variable is needed to track the rvalue-ness of the collection expression -# define BOOST_FOREACH_PREAMBLE() \ - BOOST_FOREACH_SUPPRESS_WARNINGS() - -// Evaluate the collection expression -# define BOOST_FOREACH_EVALUATE(COL) \ - (COL) - -// Can't use rvalues with BOOST_FOREACH (unless they are lightweight proxies) -# define BOOST_FOREACH_SHOULD_COPY(COL) \ - (true ? 0 : BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL)) - -#endif - -#define BOOST_FOREACH_CONTAIN(COL) \ - boost::foreach_detail_::contain( \ - BOOST_FOREACH_EVALUATE(COL) \ - , BOOST_FOREACH_SHOULD_COPY(COL)) - -#define BOOST_FOREACH_BEGIN(COL) \ - boost::foreach_detail_::begin( \ - BOOST_FOREACH_ID(_foreach_col) \ - , BOOST_FOREACH_TYPEOF(COL) \ - , BOOST_FOREACH_SHOULD_COPY(COL)) - -#define BOOST_FOREACH_END(COL) \ - boost::foreach_detail_::end( \ - BOOST_FOREACH_ID(_foreach_col) \ - , BOOST_FOREACH_TYPEOF(COL) \ - , BOOST_FOREACH_SHOULD_COPY(COL)) - -#define BOOST_FOREACH_DONE(COL) \ - boost::foreach_detail_::done( \ - BOOST_FOREACH_ID(_foreach_cur) \ - , BOOST_FOREACH_ID(_foreach_end) \ - , BOOST_FOREACH_TYPEOF(COL)) - -#define BOOST_FOREACH_NEXT(COL) \ - boost::foreach_detail_::next( \ - BOOST_FOREACH_ID(_foreach_cur) \ - , BOOST_FOREACH_TYPEOF(COL)) - -#define BOOST_FOREACH_DEREF(COL) \ - boost::foreach_detail_::deref( \ - BOOST_FOREACH_ID(_foreach_cur) \ - , BOOST_FOREACH_TYPEOF(COL)) - -#define BOOST_FOREACH_RBEGIN(COL) \ - boost::foreach_detail_::rbegin( \ - BOOST_FOREACH_ID(_foreach_col) \ - , BOOST_FOREACH_TYPEOF(COL) \ - , BOOST_FOREACH_SHOULD_COPY(COL)) - -#define BOOST_FOREACH_REND(COL) \ - boost::foreach_detail_::rend( \ - BOOST_FOREACH_ID(_foreach_col) \ - , BOOST_FOREACH_TYPEOF(COL) \ - , BOOST_FOREACH_SHOULD_COPY(COL)) - -#define BOOST_FOREACH_RDONE(COL) \ - boost::foreach_detail_::rdone( \ - BOOST_FOREACH_ID(_foreach_cur) \ - , BOOST_FOREACH_ID(_foreach_end) \ - , BOOST_FOREACH_TYPEOF(COL)) - -#define BOOST_FOREACH_RNEXT(COL) \ - boost::foreach_detail_::rnext( \ - BOOST_FOREACH_ID(_foreach_cur) \ - , BOOST_FOREACH_TYPEOF(COL)) - -#define BOOST_FOREACH_RDEREF(COL) \ - boost::foreach_detail_::rderef( \ - BOOST_FOREACH_ID(_foreach_cur) \ - , BOOST_FOREACH_TYPEOF(COL)) - -/////////////////////////////////////////////////////////////////////////////// -// BOOST_FOREACH -// -// For iterating over collections. Collections can be -// arrays, null-terminated strings, or STL containers. -// The loop variable can be a value or reference. For -// example: -// -// std::list int_list(/*stuff*/); -// BOOST_FOREACH(int &i, int_list) -// { -// /* -// * loop body goes here. -// * i is a reference to the int in int_list. -// */ -// } -// -// Alternately, you can declare the loop variable first, -// so you can access it after the loop finishes. Obviously, -// if you do it this way, then the loop variable cannot be -// a reference. -// -// int i; -// BOOST_FOREACH(i, int_list) -// { ... } -// -#define BOOST_FOREACH(VAR, COL) \ - BOOST_FOREACH_PREAMBLE() \ - if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_col) = BOOST_FOREACH_CONTAIN(COL)) {} else \ - if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_BEGIN(COL)) {} else \ - if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_END(COL)) {} else \ - for (bool BOOST_FOREACH_ID(_foreach_continue) = true; \ - BOOST_FOREACH_ID(_foreach_continue) && !BOOST_FOREACH_DONE(COL); \ - BOOST_FOREACH_ID(_foreach_continue) ? BOOST_FOREACH_NEXT(COL) : (void)0) \ - if (boost::foreach_detail_::set_false(BOOST_FOREACH_ID(_foreach_continue))) {} else \ - for (VAR = BOOST_FOREACH_DEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true) - -/////////////////////////////////////////////////////////////////////////////// -// BOOST_REVERSE_FOREACH -// -// For iterating over collections in reverse order. In -// all other respects, BOOST_REVERSE_FOREACH is like -// BOOST_FOREACH. -// -#define BOOST_REVERSE_FOREACH(VAR, COL) \ - BOOST_FOREACH_PREAMBLE() \ - if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_col) = BOOST_FOREACH_CONTAIN(COL)) {} else \ - if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_RBEGIN(COL)) {} else \ - if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_REND(COL)) {} else \ - for (bool BOOST_FOREACH_ID(_foreach_continue) = true; \ - BOOST_FOREACH_ID(_foreach_continue) && !BOOST_FOREACH_RDONE(COL); \ - BOOST_FOREACH_ID(_foreach_continue) ? BOOST_FOREACH_RNEXT(COL) : (void)0) \ - if (boost::foreach_detail_::set_false(BOOST_FOREACH_ID(_foreach_continue))) {} else \ - for (VAR = BOOST_FOREACH_RDEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true) - -#endif diff --git a/boost/foreach_fwd.hpp b/boost/foreach_fwd.hpp deleted file mode 100644 index 4e0bb37..0000000 --- a/boost/foreach_fwd.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// foreach.hpp header file -// -// Copyright 2010 Eric Niebler. -// Distributed under the 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/foreach for documentation -// -// Credits: -// Kazutoshi Satoda: for suggesting the need for a _fwd header for foreach's -// customization points. - -#ifndef BOOST_FOREACH_FWD_HPP -#define BOOST_FOREACH_FWD_HPP - -// This must be at global scope, hence the uglified name -enum boost_foreach_argument_dependent_lookup_hack -{ - boost_foreach_argument_dependent_lookup_hack_value -}; - -namespace boost -{ - -namespace foreach -{ - /////////////////////////////////////////////////////////////////////////////// - // boost::foreach::tag - // - typedef boost_foreach_argument_dependent_lookup_hack tag; - - /////////////////////////////////////////////////////////////////////////////// - // boost::foreach::is_lightweight_proxy - // Specialize this for user-defined collection types if they are inexpensive to copy. - // This tells BOOST_FOREACH it can avoid the rvalue/lvalue detection stuff. - template - struct is_lightweight_proxy; - - /////////////////////////////////////////////////////////////////////////////// - // boost::foreach::is_noncopyable - // Specialize this for user-defined collection types if they cannot be copied. - // This also tells BOOST_FOREACH to avoid the rvalue/lvalue detection stuff. - template - struct is_noncopyable; - -} // namespace foreach - -} // namespace boost - -#endif diff --git a/boost/format.hpp b/boost/format.hpp deleted file mode 100644 index 73464a8..0000000 --- a/boost/format.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// ---------------------------------------------------------------------------- -// format.hpp : primary header -// ---------------------------------------------------------------------------- - -// Copyright Samuel Krempp 2003. 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) - -// See http://www.boost.org/libs/format for library home page - - -// ---------------------------------------------------------------------------- - -#ifndef BOOST_FORMAT_HPP -#define BOOST_FORMAT_HPP - -#include -#include -#include -#include - -#ifndef BOOST_NO_STD_LOCALE -#include -#endif - -// *** Compatibility framework -#include - -#ifdef BOOST_NO_LOCALE_ISIDIGIT -#include // we'll use the non-locale 's std::isdigit(int) -#endif - -// **** Forward declarations ---------------------------------- -#include // basic_format, and other frontends -#include // misc forward declarations for internal use - -// **** Auxiliary structs (stream_format_state , and format_item ) -#include - -// **** Format class interface -------------------------------- -#include - -// **** Exceptions ----------------------------------------------- -#include - -// **** Implementation ------------------------------------------- -#include // member functions -#include // class for grouping arguments -#include // argument-feeding functions -#include // format-string parsing (member-)functions - -// **** Implementation of the free functions ---------------------- -#include - - -// *** Undefine 'local' macros : -#include - -#endif // BOOST_FORMAT_HPP diff --git a/boost/function.hpp b/boost/function.hpp deleted file mode 100644 index b72842b..0000000 --- a/boost/function.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Boost.Function library - -// Copyright Douglas Gregor 2001-2003. Use, modification and -// distribution is 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) - -// For more information, see http://www.boost.org/libs/function - -// William Kempf, Jesse Jones and Karl Nelson were all very helpful in the -// design of this library. - -#include // unary_function, binary_function - -#include -#include - -#ifndef BOOST_FUNCTION_MAX_ARGS -# define BOOST_FUNCTION_MAX_ARGS 10 -#endif // BOOST_FUNCTION_MAX_ARGS - -// Include the prologue here so that the use of file-level iteration -// in anything that may be included by function_template.hpp doesn't break -#include - -// Older Visual Age C++ version do not handle the file iteration well -#if BOOST_WORKAROUND(__IBMCPP__, >= 500) && BOOST_WORKAROUND(__IBMCPP__, < 800) -# if BOOST_FUNCTION_MAX_ARGS >= 0 -# include -# endif -# if BOOST_FUNCTION_MAX_ARGS >= 1 -# include -# endif -# if BOOST_FUNCTION_MAX_ARGS >= 2 -# include -# endif -# if BOOST_FUNCTION_MAX_ARGS >= 3 -# include -# endif -# if BOOST_FUNCTION_MAX_ARGS >= 4 -# include -# endif -# if BOOST_FUNCTION_MAX_ARGS >= 5 -# include -# endif -# if BOOST_FUNCTION_MAX_ARGS >= 6 -# include -# endif -# if BOOST_FUNCTION_MAX_ARGS >= 7 -# include -# endif -# if BOOST_FUNCTION_MAX_ARGS >= 8 -# include -# endif -# if BOOST_FUNCTION_MAX_ARGS >= 9 -# include -# endif -# if BOOST_FUNCTION_MAX_ARGS >= 10 -# include -# endif -#else -// What is the '3' for? -# define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_FUNCTION_MAX_ARGS,)) -# include BOOST_PP_ITERATE() -# undef BOOST_PP_ITERATION_PARAMS_1 -#endif diff --git a/boost/function_equal.hpp b/boost/function_equal.hpp deleted file mode 100644 index 2d76c75..0000000 --- a/boost/function_equal.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright Douglas Gregor 2004. -// Copyright 2005 Peter Dimov - -// Use, modification and distribution is 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) - -// For more information, see http://www.boost.org -#ifndef BOOST_FUNCTION_EQUAL_HPP -#define BOOST_FUNCTION_EQUAL_HPP - -namespace boost { - -template - bool function_equal_impl(const F& f, const G& g, long) - { return f == g; } - -// function_equal_impl needs to be unqualified to pick -// user overloads on two-phase compilers - -template - bool function_equal(const F& f, const G& g) - { return function_equal_impl(f, g, 0); } - -} // end namespace boost - -#endif // BOOST_FUNCTION_EQUAL_HPP diff --git a/boost/function_output_iterator.hpp b/boost/function_output_iterator.hpp deleted file mode 100644 index dd8c44d..0000000 --- a/boost/function_output_iterator.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// (C) Copyright Jeremy Siek 2001. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// Revision History: - -// 27 Feb 2001 Jeremy Siek -// Initial checkin. - -#ifndef BOOST_FUNCTION_OUTPUT_ITERATOR_HPP -#define BOOST_FUNCTION_OUTPUT_ITERATOR_HPP - -#include - -namespace boost { -namespace iterators { - - template - class function_output_iterator { - typedef function_output_iterator self; - public: - typedef std::output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - explicit function_output_iterator() {} - - explicit function_output_iterator(const UnaryFunction& f) - : m_f(f) {} - - struct output_proxy { - output_proxy(UnaryFunction& f) : m_f(f) { } - template output_proxy& operator=(const T& value) { - m_f(value); - return *this; - } - UnaryFunction& m_f; - }; - output_proxy operator*() { return output_proxy(m_f); } - self& operator++() { return *this; } - self& operator++(int) { return *this; } - private: - UnaryFunction m_f; - }; - - template - inline function_output_iterator - make_function_output_iterator(const UnaryFunction& f = UnaryFunction()) { - return function_output_iterator(f); - } - -} // namespace iterators - -using iterators::function_output_iterator; -using iterators::make_function_output_iterator; - -} // namespace boost - -#endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP diff --git a/boost/functional.hpp b/boost/functional.hpp deleted file mode 100644 index b618485..0000000 --- a/boost/functional.hpp +++ /dev/null @@ -1,548 +0,0 @@ -// ------------------------------------------------------------------------------ -// Copyright (c) 2000 Cadenza New Zealand Ltd -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// ------------------------------------------------------------------------------ -// Boost functional.hpp header file -// See http://www.boost.org/libs/functional for documentation. -// ------------------------------------------------------------------------------ -// $Id$ -// ------------------------------------------------------------------------------ - -#ifndef BOOST_FUNCTIONAL_HPP -#define BOOST_FUNCTIONAL_HPP - -#include -#include -#include - -namespace boost -{ -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - // -------------------------------------------------------------------------- - // The following traits classes allow us to avoid the need for ptr_fun - // because the types of arguments and the result of a function can be - // deduced. - // - // In addition to the standard types defined in unary_function and - // binary_function, we add - // - // - function_type, the type of the function or function object itself. - // - // - param_type, the type that should be used for passing the function or - // function object as an argument. - // -------------------------------------------------------------------------- - namespace detail - { - template - struct unary_traits_imp; - - template - struct unary_traits_imp - { - typedef Operation function_type; - typedef const function_type & param_type; - typedef typename Operation::result_type result_type; - typedef typename Operation::argument_type argument_type; - }; - - template - struct unary_traits_imp - { - typedef R (*function_type)(A); - typedef R (*param_type)(A); - typedef R result_type; - typedef A argument_type; - }; - - template - struct binary_traits_imp; - - template - struct binary_traits_imp - { - typedef Operation function_type; - typedef const function_type & param_type; - typedef typename Operation::result_type result_type; - typedef typename Operation::first_argument_type first_argument_type; - typedef typename Operation::second_argument_type second_argument_type; - }; - - template - struct binary_traits_imp - { - typedef R (*function_type)(A1,A2); - typedef R (*param_type)(A1,A2); - typedef R result_type; - typedef A1 first_argument_type; - typedef A2 second_argument_type; - }; - } // namespace detail - - template - struct unary_traits - { - typedef typename detail::unary_traits_imp::function_type function_type; - typedef typename detail::unary_traits_imp::param_type param_type; - typedef typename detail::unary_traits_imp::result_type result_type; - typedef typename detail::unary_traits_imp::argument_type argument_type; - }; - - template - struct unary_traits - { - typedef R (*function_type)(A); - typedef R (*param_type)(A); - typedef R result_type; - typedef A argument_type; - }; - - template - struct binary_traits - { - typedef typename detail::binary_traits_imp::function_type function_type; - typedef typename detail::binary_traits_imp::param_type param_type; - typedef typename detail::binary_traits_imp::result_type result_type; - typedef typename detail::binary_traits_imp::first_argument_type first_argument_type; - typedef typename detail::binary_traits_imp::second_argument_type second_argument_type; - }; - - template - struct binary_traits - { - typedef R (*function_type)(A1,A2); - typedef R (*param_type)(A1,A2); - typedef R result_type; - typedef A1 first_argument_type; - typedef A2 second_argument_type; - }; -#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - // -------------------------------------------------------------------------- - // If we have no partial specialisation available, decay to a situation - // that is no worse than in the Standard, i.e., ptr_fun will be required. - // -------------------------------------------------------------------------- - - template - struct unary_traits - { - typedef Operation function_type; - typedef const Operation& param_type; - typedef typename Operation::result_type result_type; - typedef typename Operation::argument_type argument_type; - }; - - template - struct binary_traits - { - typedef Operation function_type; - typedef const Operation & param_type; - typedef typename Operation::result_type result_type; - typedef typename Operation::first_argument_type first_argument_type; - typedef typename Operation::second_argument_type second_argument_type; - }; -#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - - // -------------------------------------------------------------------------- - // unary_negate, not1 - // -------------------------------------------------------------------------- - template - class unary_negate - : public std::unary_function::argument_type,bool> - { - public: - explicit unary_negate(typename unary_traits::param_type x) - : - pred(x) - {} - bool operator()(typename call_traits::argument_type>::param_type x) const - { - return !pred(x); - } - private: - typename unary_traits::function_type pred; - }; - - template - unary_negate not1(const Predicate &pred) - { - // The cast is to placate Borland C++Builder in certain circumstances. - // I don't think it should be necessary. - return unary_negate((typename unary_traits::param_type)pred); - } - - template - unary_negate not1(Predicate &pred) - { - return unary_negate(pred); - } - - // -------------------------------------------------------------------------- - // binary_negate, not2 - // -------------------------------------------------------------------------- - template - class binary_negate - : public std::binary_function::first_argument_type, - typename binary_traits::second_argument_type, - bool> - { - public: - explicit binary_negate(typename binary_traits::param_type x) - : - pred(x) - {} - bool operator()(typename call_traits::first_argument_type>::param_type x, - typename call_traits::second_argument_type>::param_type y) const - { - return !pred(x,y); - } - private: - typename binary_traits::function_type pred; - }; - - template - binary_negate not2(const Predicate &pred) - { - // The cast is to placate Borland C++Builder in certain circumstances. - // I don't think it should be necessary. - return binary_negate((typename binary_traits::param_type)pred); - } - - template - binary_negate not2(Predicate &pred) - { - return binary_negate(pred); - } - - // -------------------------------------------------------------------------- - // binder1st, bind1st - // -------------------------------------------------------------------------- - template - class binder1st - : public std::unary_function::second_argument_type, - typename binary_traits::result_type> - { - public: - binder1st(typename binary_traits::param_type x, - typename call_traits::first_argument_type>::param_type y) - : - op(x), value(y) - {} - - typename binary_traits::result_type - operator()(typename call_traits::second_argument_type>::param_type x) const - { - return op(value, x); - } - - protected: - typename binary_traits::function_type op; - typename binary_traits::first_argument_type value; - }; - - template - inline binder1st bind1st(const Operation &op, - typename call_traits< - typename binary_traits::first_argument_type - >::param_type x) - { - // The cast is to placate Borland C++Builder in certain circumstances. - // I don't think it should be necessary. - return binder1st((typename binary_traits::param_type)op, x); - } - - template - inline binder1st bind1st(Operation &op, - typename call_traits< - typename binary_traits::first_argument_type - >::param_type x) - { - return binder1st(op, x); - } - - // -------------------------------------------------------------------------- - // binder2nd, bind2nd - // -------------------------------------------------------------------------- - template - class binder2nd - : public std::unary_function::first_argument_type, - typename binary_traits::result_type> - { - public: - binder2nd(typename binary_traits::param_type x, - typename call_traits::second_argument_type>::param_type y) - : - op(x), value(y) - {} - - typename binary_traits::result_type - operator()(typename call_traits::first_argument_type>::param_type x) const - { - return op(x, value); - } - - protected: - typename binary_traits::function_type op; - typename binary_traits::second_argument_type value; - }; - - template - inline binder2nd bind2nd(const Operation &op, - typename call_traits< - typename binary_traits::second_argument_type - >::param_type x) - { - // The cast is to placate Borland C++Builder in certain circumstances. - // I don't think it should be necessary. - return binder2nd((typename binary_traits::param_type)op, x); - } - - template - inline binder2nd bind2nd(Operation &op, - typename call_traits< - typename binary_traits::second_argument_type - >::param_type x) - { - return binder2nd(op, x); - } - - // -------------------------------------------------------------------------- - // mem_fun, etc - // -------------------------------------------------------------------------- - template - class mem_fun_t : public std::unary_function - { - public: - explicit mem_fun_t(S (T::*p)()) - : - ptr(p) - {} - S operator()(T* p) const - { - return (p->*ptr)(); - } - private: - S (T::*ptr)(); - }; - - template - class mem_fun1_t : public std::binary_function - { - public: - explicit mem_fun1_t(S (T::*p)(A)) - : - ptr(p) - {} - S operator()(T* p, typename call_traits::param_type x) const - { - return (p->*ptr)(x); - } - private: - S (T::*ptr)(A); - }; - - template - class const_mem_fun_t : public std::unary_function - { - public: - explicit const_mem_fun_t(S (T::*p)() const) - : - ptr(p) - {} - S operator()(const T* p) const - { - return (p->*ptr)(); - } - private: - S (T::*ptr)() const; - }; - - template - class const_mem_fun1_t : public std::binary_function - { - public: - explicit const_mem_fun1_t(S (T::*p)(A) const) - : - ptr(p) - {} - S operator()(const T* p, typename call_traits::param_type x) const - { - return (p->*ptr)(x); - } - private: - S (T::*ptr)(A) const; - }; - - template - inline mem_fun_t mem_fun(S (T::*f)()) - { - return mem_fun_t(f); - } - - template - inline mem_fun1_t mem_fun(S (T::*f)(A)) - { - return mem_fun1_t(f); - } - -#ifndef BOOST_NO_POINTER_TO_MEMBER_CONST - template - inline const_mem_fun_t mem_fun(S (T::*f)() const) - { - return const_mem_fun_t(f); - } - - template - inline const_mem_fun1_t mem_fun(S (T::*f)(A) const) - { - return const_mem_fun1_t(f); - } -#endif // BOOST_NO_POINTER_TO_MEMBER_CONST - - // -------------------------------------------------------------------------- - // mem_fun_ref, etc - // -------------------------------------------------------------------------- - template - class mem_fun_ref_t : public std::unary_function - { - public: - explicit mem_fun_ref_t(S (T::*p)()) - : - ptr(p) - {} - S operator()(T& p) const - { - return (p.*ptr)(); - } - private: - S (T::*ptr)(); - }; - - template - class mem_fun1_ref_t : public std::binary_function - { - public: - explicit mem_fun1_ref_t(S (T::*p)(A)) - : - ptr(p) - {} - S operator()(T& p, typename call_traits::param_type x) const - { - return (p.*ptr)(x); - } - private: - S (T::*ptr)(A); - }; - - template - class const_mem_fun_ref_t : public std::unary_function - { - public: - explicit const_mem_fun_ref_t(S (T::*p)() const) - : - ptr(p) - {} - - S operator()(const T &p) const - { - return (p.*ptr)(); - } - private: - S (T::*ptr)() const; - }; - - template - class const_mem_fun1_ref_t : public std::binary_function - { - public: - explicit const_mem_fun1_ref_t(S (T::*p)(A) const) - : - ptr(p) - {} - - S operator()(const T& p, typename call_traits::param_type x) const - { - return (p.*ptr)(x); - } - private: - S (T::*ptr)(A) const; - }; - - template - inline mem_fun_ref_t mem_fun_ref(S (T::*f)()) - { - return mem_fun_ref_t(f); - } - - template - inline mem_fun1_ref_t mem_fun_ref(S (T::*f)(A)) - { - return mem_fun1_ref_t(f); - } - -#ifndef BOOST_NO_POINTER_TO_MEMBER_CONST - template - inline const_mem_fun_ref_t mem_fun_ref(S (T::*f)() const) - { - return const_mem_fun_ref_t(f); - } - - template - inline const_mem_fun1_ref_t mem_fun_ref(S (T::*f)(A) const) - { - return const_mem_fun1_ref_t(f); - } -#endif // BOOST_NO_POINTER_TO_MEMBER_CONST - - // -------------------------------------------------------------------------- - // ptr_fun - // -------------------------------------------------------------------------- - template - class pointer_to_unary_function : public std::unary_function - { - public: - explicit pointer_to_unary_function(Result (*f)(Arg)) - : - func(f) - {} - - Result operator()(typename call_traits::param_type x) const - { - return func(x); - } - - private: - Result (*func)(Arg); - }; - - template - inline pointer_to_unary_function ptr_fun(Result (*f)(Arg)) - { - return pointer_to_unary_function(f); - } - - template - class pointer_to_binary_function : public std::binary_function - { - public: - explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)) - : - func(f) - {} - - Result operator()(typename call_traits::param_type x, typename call_traits::param_type y) const - { - return func(x,y); - } - - private: - Result (*func)(Arg1, Arg2); - }; - - template - inline pointer_to_binary_function ptr_fun(Result (*f)(Arg1, Arg2)) - { - return pointer_to_binary_function(f); - } -} // namespace boost - -#endif diff --git a/boost/generator_iterator.hpp b/boost/generator_iterator.hpp deleted file mode 100644 index 0fe1569..0000000 --- a/boost/generator_iterator.hpp +++ /dev/null @@ -1,85 +0,0 @@ -// (C) Copyright Jens Maurer 2001. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Revision History: - -// 15 Nov 2001 Jens Maurer -// created. - -// See http://www.boost.org/libs/utility/iterator_adaptors.htm for documentation. - -#ifndef BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP -#define BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP - -#include -#include - -namespace boost { -namespace iterators { - -template -class generator_iterator - : public iterator_facade< - generator_iterator - , typename Generator::result_type - , single_pass_traversal_tag - , typename Generator::result_type const& - > -{ - typedef iterator_facade< - generator_iterator - , typename Generator::result_type - , single_pass_traversal_tag - , typename Generator::result_type const& - > super_t; - - public: - generator_iterator() {} - generator_iterator(Generator* g) : m_g(g), m_value((*m_g)()) {} - - void increment() - { - m_value = (*m_g)(); - } - - const typename Generator::result_type& - dereference() const - { - return m_value; - } - - bool equal(generator_iterator const& y) const - { - return this->m_g == y.m_g && this->m_value == y.m_value; - } - - private: - Generator* m_g; - typename Generator::result_type m_value; -}; - -template -struct generator_iterator_generator -{ - typedef generator_iterator type; -}; - -template -inline generator_iterator -make_generator_iterator(Generator & gen) -{ - typedef generator_iterator result_t; - return result_t(&gen); -} - -} // namespace iterators - -using iterators::generator_iterator; -using iterators::generator_iterator_generator; -using iterators::make_generator_iterator; - -} // namespace boost - -#endif // BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP diff --git a/boost/geometry.hpp b/boost/geometry.hpp deleted file mode 100644 index a4756e7..0000000 --- a/boost/geometry.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) - -// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. - -// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library -// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. - -// Use, modification and distribution is 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) - -#ifndef BOOST_GEOMETRY_HPP -#define BOOST_GEOMETRY_HPP - -#include - -#endif // BOOST_GEOMETRY_HPP diff --git a/boost/get_pointer.hpp b/boost/get_pointer.hpp deleted file mode 100644 index b27b98a..0000000 --- a/boost/get_pointer.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright Peter Dimov and David Abrahams 2002. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#ifndef GET_POINTER_DWA20021219_HPP -#define GET_POINTER_DWA20021219_HPP - -#include - -// In order to avoid circular dependencies with Boost.TR1 -// we make sure that our include of doesn't try to -// pull in the TR1 headers: that's why we use this header -// rather than including directly: -#include // std::auto_ptr - -namespace boost { - -// get_pointer(p) extracts a ->* capable pointer from p - -template T * get_pointer(T * p) -{ - return p; -} - -// get_pointer(shared_ptr const & p) has been moved to shared_ptr.hpp - -template T * get_pointer(std::auto_ptr const& p) -{ - return p.get(); -} - -#if !defined( BOOST_NO_CXX11_SMART_PTR ) - -template T * get_pointer( std::unique_ptr const& p ) -{ - return p.get(); -} - -template T * get_pointer( std::shared_ptr const& p ) -{ - return p.get(); -} - -#endif - -} // namespace boost - -#endif // GET_POINTER_DWA20021219_HPP diff --git a/boost/implicit_cast.hpp b/boost/implicit_cast.hpp deleted file mode 100644 index d82db76..0000000 --- a/boost/implicit_cast.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright David Abrahams 2003. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -#ifndef IMPLICIT_CAST_DWA200356_HPP -# define IMPLICIT_CAST_DWA200356_HPP - -namespace boost { - -namespace detail { - -template struct icast_identity -{ - typedef T type; -}; - -} // namespace detail - -// implementation originally suggested by C. Green in -// http://lists.boost.org/MailArchives/boost/msg00886.php - -// The use of identity creates a non-deduced form, so that the -// explicit template argument must be supplied -template -inline T implicit_cast (typename boost::detail::icast_identity::type x) { - return x; -} - -// incomplete return type now is here -//template -//void implicit_cast (...); - -} // namespace boost - - -#endif // IMPLICIT_CAST_DWA200356_HPP diff --git a/boost/indirect_reference.hpp b/boost/indirect_reference.hpp deleted file mode 100644 index 3279cd0..0000000 --- a/boost/indirect_reference.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef INDIRECT_REFERENCE_DWA200415_HPP -# define INDIRECT_REFERENCE_DWA200415_HPP - -// -// Copyright David Abrahams 2004. Use, modification and distribution is -// 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) -// -// typename indirect_reference

::type provides the type of *p. -// -// http://www.boost.org/libs/iterator/doc/pointee.html -// - -# include -# include -# include -# include -# include - -namespace boost { - -namespace detail -{ - template - struct smart_ptr_reference - { - typedef typename boost::pointee

::type& type; - }; -} - -template -struct indirect_reference - : mpl::eval_if< - detail::is_incrementable

- , iterator_reference

- , detail::smart_ptr_reference

- > -{ -}; - -} // namespace boost - -#endif // INDIRECT_REFERENCE_DWA200415_HPP diff --git a/boost/integer.hpp b/boost/integer.hpp index 35a1e10..9fa0019 100644 --- a/boost/integer.hpp +++ b/boost/integer.hpp @@ -42,15 +42,15 @@ namespace boost // fast integers from least integers // int_fast_t<> works correctly for unsigned too, in spite of the name. template< typename LeastInt > - struct int_fast_t - { - typedef LeastInt fast; + struct int_fast_t + { + typedef LeastInt fast; typedef fast type; }; // imps may specialize namespace detail{ - // convert category to type + // convert category to type template< int Category > struct int_least_helper {}; // default is empty template< int Category > struct uint_least_helper {}; // default is empty @@ -91,7 +91,8 @@ namespace boost template <> struct exact_signed_base_helper { typedef int exact; }; template <> struct exact_unsigned_base_helper { typedef unsigned int exact; }; #endif -#if ULONG_MAX != UINT_MAX +#if ULONG_MAX != UINT_MAX && ( !defined __TI_COMPILER_VERSION__ || \ + ( __TI_COMPILER_VERSION__ >= 7000000 && !defined __TI_40BIT_LONG__ ) ) template <> struct exact_signed_base_helper { typedef long exact; }; template <> struct exact_unsigned_base_helper { typedef unsigned long exact; }; #endif @@ -111,11 +112,11 @@ namespace boost // signed template< int Bits > // bits (including sign) required - struct int_t : public detail::exact_signed_base_helper + struct int_t : public boost::detail::exact_signed_base_helper { BOOST_STATIC_ASSERT_MSG(Bits <= (int)(sizeof(boost::intmax_t) * CHAR_BIT), "No suitable signed integer type with the requested number of bits is available."); - typedef typename detail::int_least_helper + typedef typename boost::detail::int_least_helper < #ifdef BOOST_HAS_LONG_LONG (Bits <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) + @@ -132,13 +133,13 @@ namespace boost // unsigned template< int Bits > // bits required - struct uint_t : public detail::exact_unsigned_base_helper + struct uint_t : public boost::detail::exact_unsigned_base_helper { BOOST_STATIC_ASSERT_MSG(Bits <= (int)(sizeof(boost::uintmax_t) * CHAR_BIT), "No suitable unsigned integer type with the requested number of bits is available."); #if (defined(__BORLANDC__) || defined(__CODEGEAR__)) && defined(BOOST_NO_INTEGRAL_INT64_T) // It's really not clear why this workaround should be needed... shrug I guess! JM - BOOST_STATIC_CONSTANT(int, s = + BOOST_STATIC_CONSTANT(int, s = 6 + (Bits <= ::std::numeric_limits::digits) + (Bits <= ::std::numeric_limits::digits) + @@ -146,8 +147,8 @@ namespace boost (Bits <= ::std::numeric_limits::digits)); typedef typename detail::int_least_helper< ::boost::uint_t::s>::least least; #else - typedef typename detail::uint_least_helper - < + typedef typename boost::detail::uint_least_helper + < #ifdef BOOST_HAS_LONG_LONG (Bits <= (int)(sizeof(boost::long_long_type) * CHAR_BIT)) + #else @@ -166,16 +167,16 @@ namespace boost // integer templates specifying extreme value ----------------------------// // signed -#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG) template< boost::long_long_type MaxValue > // maximum value to require support #else template< long MaxValue > // maximum value to require support #endif - struct int_max_value_t + struct int_max_value_t { - typedef typename detail::int_least_helper + typedef typename boost::detail::int_least_helper < -#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG) (MaxValue <= ::boost::integer_traits::const_max) + #else 1 + @@ -188,16 +189,16 @@ namespace boost typedef typename int_fast_t::type fast; }; -#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG) template< boost::long_long_type MinValue > // minimum value to require support #else template< long MinValue > // minimum value to require support #endif - struct int_min_value_t + struct int_min_value_t { - typedef typename detail::int_least_helper + typedef typename boost::detail::int_least_helper < -#if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) +#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T) && defined(BOOST_HAS_LONG_LONG) (MinValue >= ::boost::integer_traits::const_min) + #else 1 + @@ -216,12 +217,12 @@ namespace boost #else template< unsigned long MaxValue > // minimum value to require support #endif - struct uint_value_t + struct uint_value_t { #if (defined(__BORLANDC__) || defined(__CODEGEAR__)) // It's really not clear why this workaround should be needed... shrug I guess! JM #if defined(BOOST_NO_INTEGRAL_INT64_T) - BOOST_STATIC_CONSTANT(unsigned, which = + BOOST_STATIC_CONSTANT(unsigned, which = 1 + (MaxValue <= ::boost::integer_traits::const_max) + (MaxValue <= ::boost::integer_traits::const_max) + @@ -229,7 +230,7 @@ namespace boost (MaxValue <= ::boost::integer_traits::const_max)); typedef typename detail::int_least_helper< ::boost::uint_value_t::which>::least least; #else // BOOST_NO_INTEGRAL_INT64_T - BOOST_STATIC_CONSTANT(unsigned, which = + BOOST_STATIC_CONSTANT(unsigned, which = 1 + (MaxValue <= ::boost::integer_traits::const_max) + (MaxValue <= ::boost::integer_traits::const_max) + @@ -239,8 +240,8 @@ namespace boost typedef typename detail::uint_least_helper< ::boost::uint_value_t::which>::least least; #endif // BOOST_NO_INTEGRAL_INT64_T #else - typedef typename detail::uint_least_helper - < + typedef typename boost::detail::uint_least_helper + < #if !defined(BOOST_NO_INTEGRAL_INT64_T) && defined(BOOST_HAS_LONG_LONG) (MaxValue <= ::boost::integer_traits::const_max) + #else diff --git a/boost/integer_fwd.hpp b/boost/integer_fwd.hpp index 20eff2b..10577ae 100644 --- a/boost/integer_fwd.hpp +++ b/boost/integer_fwd.hpp @@ -158,6 +158,29 @@ template struct static_unsigned_max; + +// From + +#ifdef BOOST_NO_INTEGRAL_INT64_T + typedef unsigned long static_gcd_type; +#else + typedef boost::uintmax_t static_gcd_type; +#endif + +template < static_gcd_type Value1, static_gcd_type Value2 > + struct static_gcd; +template < static_gcd_type Value1, static_gcd_type Value2 > + struct static_lcm; + + +// From + +template < typename IntegerType > + class gcd_evaluator; +template < typename IntegerType > + class lcm_evaluator; + + } // namespace boost diff --git a/boost/intrusive/any_hook.hpp b/boost/intrusive/any_hook.hpp deleted file mode 100644 index 1b53837..0000000 --- a/boost/intrusive/any_hook.hpp +++ /dev/null @@ -1,336 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2006-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_ANY_HOOK_HPP -#define BOOST_INTRUSIVE_ANY_HOOK_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -//! Helper metafunction to define a \c \c any_base_hook that yields to the same -//! type when the same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_any_base_hook -{ - /// @cond - typedef typename pack_options - < hook_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3 - #else - Options... - #endif - >::type packed_options; - - typedef generic_hook - < any_algorithms - , typename packed_options::tag - , packed_options::link_mode - , AnyBaseHookId - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -//! Derive a class from this hook in order to store objects of that class -//! in an intrusive container. -//! -//! The hook admits the following options: \c tag<>, \c void_pointer<> and -//! \c link_mode<>. -//! -//! \c tag<> defines a tag to identify the node. -//! The same tag value can be used in different classes, but if a class is -//! derived from more than one \c any_base_hook, then each \c any_base_hook needs its -//! unique tag. -//! -//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, \c safe_link). -//! -//! \c void_pointer<> is the pointer type that will be used internally in the hook -//! and the container configured to use this hook. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class any_base_hook - : public make_any_base_hook - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - - #else - - #endif - ::type -{ - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - public: - //! Effects: If link_mode is or \c safe_link - //! initializes the node to an unlinked state. - //! - //! Throws: Nothing. - any_base_hook(); - - //! Effects: If link_mode is or \c safe_link - //! initializes the node to an unlinked state. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing a copy-constructor - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - any_base_hook(const any_base_hook& ); - - //! Effects: Empty function. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing an assignment operator - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - any_base_hook& operator=(const any_base_hook& ); - - //! Effects: If link_mode is \c normal_link, the destructor does - //! nothing (ie. no code is generated). If link_mode is \c safe_link and the - //! object is stored in a container an assertion is raised. - //! - //! Throws: Nothing. - ~any_base_hook(); - - //! Precondition: link_mode must be \c safe_link. - //! - //! Returns: true, if the node belongs to a container, false - //! otherwise. This function can be used to test whether \c container::iterator_to - //! will return a valid iterator. - //! - //! Complexity: Constant - bool is_linked() const; - #endif -}; - -//! Helper metafunction to define a \c \c any_member_hook that yields to the same -//! type when the same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_any_member_hook -{ - /// @cond - typedef typename pack_options - < hook_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3 - #else - Options... - #endif - >::type packed_options; - - typedef generic_hook - < any_algorithms - , member_tag - , packed_options::link_mode - , NoBaseHookId - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -//! Store this hook in a class to be inserted -//! in an intrusive container. -//! -//! The hook admits the following options: \c void_pointer<> and -//! \c link_mode<>. -//! -//! \c link_mode<> will specify the linking mode of the hook (\c normal_link or \c safe_link). -//! -//! \c void_pointer<> is the pointer type that will be used internally in the hook -//! and the container configured to use this hook. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class any_member_hook - : public make_any_member_hook - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - - #else - - #endif - ::type -{ - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - public: - //! Effects: If link_mode is or \c safe_link - //! initializes the node to an unlinked state. - //! - //! Throws: Nothing. - any_member_hook(); - - //! Effects: If link_mode is or \c safe_link - //! initializes the node to an unlinked state. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing a copy-constructor - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - any_member_hook(const any_member_hook& ); - - //! Effects: Empty function. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing an assignment operator - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - any_member_hook& operator=(const any_member_hook& ); - - //! Effects: If link_mode is \c normal_link, the destructor does - //! nothing (ie. no code is generated). If link_mode is \c safe_link and the - //! object is stored in a container an assertion is raised. - //! - //! Throws: Nothing. - ~any_member_hook(); - - //! Precondition: link_mode must be \c safe_link. - //! - //! Returns: true, if the node belongs to a container, false - //! otherwise. This function can be used to test whether \c container::iterator_to - //! will return a valid iterator. - //! - //! Complexity: Constant - bool is_linked() const; - #endif -}; - -/// @cond - -namespace detail{ - -BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(old_proto_value_traits_base_hook, hooktags::is_base_hook) - -//!This option setter specifies that the container -//!must use the specified base hook -template class NodeTraits> -struct any_to_some_hook -{ - typedef typename BasicHook::template pack::proto_value_traits old_proto_value_traits; - - template - struct pack : public Base - { - struct proto_value_traits - { - //proto_value_traits::hooktags::is_base_hook is used by get_value_traits - //to detect base hooks, so mark it in case BasicHook has it. - struct hooktags - { - static const bool is_base_hook = old_proto_value_traits_base_hook_bool_is_true - ::value; - }; - - typedef old_proto_value_traits basic_hook_t; - static const bool is_any_hook = true; - - template - struct node_traits_from_voidptr - { typedef NodeTraits type; }; - }; - }; -}; - -} //namespace detail{ - -/// @endcond - -//!This option setter specifies that -//!any hook should behave as an slist hook -template -struct any_to_slist_hook -/// @cond - : public detail::any_to_some_hook -/// @endcond -{}; - -//!This option setter specifies that -//!any hook should behave as an list hook -template -struct any_to_list_hook -/// @cond - : public detail::any_to_some_hook -/// @endcond -{}; - -//!This option setter specifies that -//!any hook should behave as a set hook -template -struct any_to_set_hook -/// @cond - : public detail::any_to_some_hook -/// @endcond -{}; - -//!This option setter specifies that -//!any hook should behave as an avl_set hook -template -struct any_to_avl_set_hook -/// @cond - : public detail::any_to_some_hook -/// @endcond -{}; - -//!This option setter specifies that any -//!hook should behave as a bs_set hook -template -struct any_to_bs_set_hook -/// @cond - : public detail::any_to_some_hook -/// @endcond -{}; - -//!This option setter specifies that any hook -//!should behave as an unordered set hook -template -struct any_to_unordered_set_hook -/// @cond - : public detail::any_to_some_hook -/// @endcond -{}; - - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_ANY_HOOK_HPP diff --git a/boost/intrusive/avl_set.hpp b/boost/intrusive/avl_set.hpp deleted file mode 100644 index 58d6108..0000000 --- a/boost/intrusive/avl_set.hpp +++ /dev/null @@ -1,950 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_INTRUSIVE_AVL_SET_HPP -#define BOOST_INTRUSIVE_AVL_SET_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -//! The class template avl_set is an intrusive container, that mimics most of -//! the interface of std::set as described in the C++ standard. -//! -//! The template parameter \c T is the type to be managed by the container. -//! The user can specify additional options and if no options are provided -//! default options are used. -//! -//! The container supports the following options: -//! \c base_hook<>/member_hook<>/value_traits<>, -//! \c constant_time_size<>, \c size_type<> and -//! \c compare<>. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -class avl_set_impl -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - : public bstree_impl -#endif -{ - /// @cond - typedef bstree_impl tree_type; - BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_set_impl) - - typedef tree_type implementation_defined; - /// @endcond - - public: - typedef typename implementation_defined::value_type value_type; - typedef typename implementation_defined::value_traits value_traits; - typedef typename implementation_defined::pointer pointer; - typedef typename implementation_defined::const_pointer const_pointer; - typedef typename implementation_defined::reference reference; - typedef typename implementation_defined::const_reference const_reference; - typedef typename implementation_defined::difference_type difference_type; - typedef typename implementation_defined::size_type size_type; - typedef typename implementation_defined::value_compare value_compare; - typedef typename implementation_defined::key_compare key_compare; - typedef typename implementation_defined::iterator iterator; - typedef typename implementation_defined::const_iterator const_iterator; - typedef typename implementation_defined::reverse_iterator reverse_iterator; - typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; - typedef typename implementation_defined::insert_commit_data insert_commit_data; - typedef typename implementation_defined::node_traits node_traits; - typedef typename implementation_defined::node node; - typedef typename implementation_defined::node_ptr node_ptr; - typedef typename implementation_defined::const_node_ptr const_node_ptr; - typedef typename implementation_defined::node_algorithms node_algorithms; - - static const bool constant_time_size = tree_type::constant_time_size; - - public: - - //! @copydoc ::boost::intrusive::avltree::avltree(const value_compare &,const value_traits &) - explicit avl_set_impl( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : tree_type(cmp, v_traits) - {} - - //! @copydoc ::boost::intrusive::avltree::avltree(bool,Iterator,Iterator,const value_compare &,const value_traits &) - template - avl_set_impl( Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : tree_type(true, b, e, cmp, v_traits) - {} - - //! @copydoc ::boost::intrusive::avltree::avltree(avltree &&) - avl_set_impl(BOOST_RV_REF(avl_set_impl) x) - : tree_type(::boost::move(static_cast(x))) - {} - - //! @copydoc ::boost::intrusive::avltree::operator=(avltree &&) - avl_set_impl& operator=(BOOST_RV_REF(avl_set_impl) x) - { return static_cast(tree_type::operator=(::boost::move(static_cast(x)))); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::avltree::~avltree() - ~avl_set_impl(); - - //! @copydoc ::boost::intrusive::avltree::begin() - iterator begin(); - - //! @copydoc ::boost::intrusive::avltree::begin()const - const_iterator begin() const; - - //! @copydoc ::boost::intrusive::avltree::cbegin()const - const_iterator cbegin() const; - - //! @copydoc ::boost::intrusive::avltree::end() - iterator end(); - - //! @copydoc ::boost::intrusive::avltree::end()const - const_iterator end() const; - - //! @copydoc ::boost::intrusive::avltree::cend()const - const_iterator cend() const; - - //! @copydoc ::boost::intrusive::avltree::begin() - reverse_iterator avlegin(); - - //! @copydoc ::boost::intrusive::avltree::begin()const - const_reverse_iterator avlegin() const; - - //! @copydoc ::boost::intrusive::avltree::crbegin()const - const_reverse_iterator crbegin() const; - - //! @copydoc ::boost::intrusive::avltree::rend() - reverse_iterator rend(); - - //! @copydoc ::boost::intrusive::avltree::rend()const - const_reverse_iterator rend() const; - - //! @copydoc ::boost::intrusive::avltree::crend()const - const_reverse_iterator crend() const; - - //! @copydoc ::boost::intrusive::avltree::container_from_end_iterator(iterator) - static avl_set_impl &container_from_end_iterator(iterator end_iterator); - - //! @copydoc ::boost::intrusive::avltree::container_from_end_iterator(const_iterator) - static const avl_set_impl &container_from_end_iterator(const_iterator end_iterator); - - //! @copydoc ::boost::intrusive::avltree::container_from_iterator(iterator) - static avl_set_impl &container_from_iterator(iterator it); - - //! @copydoc ::boost::intrusive::avltree::container_from_iterator(const_iterator) - static const avl_set_impl &container_from_iterator(const_iterator it); - - //! @copydoc ::boost::intrusive::avltree::key_comp()const - key_compare key_comp() const; - - //! @copydoc ::boost::intrusive::avltree::value_comp()const - value_compare value_comp() const; - - //! @copydoc ::boost::intrusive::avltree::empty()const - bool empty() const; - - //! @copydoc ::boost::intrusive::avltree::size()const - size_type size() const; - - //! @copydoc ::boost::intrusive::avltree::swap - void swap(avl_set_impl& other); - - //! @copydoc ::boost::intrusive::avltree::clone_from - template - void clone_from(const avl_set_impl &src, Cloner cloner, Disposer disposer); - - #endif //#ifdef BOOST_iNTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::avltree::insert_unique(reference) - std::pair insert(reference value) - { return tree_type::insert_unique(value); } - - //! @copydoc ::boost::intrusive::avltree::insert_unique(const_iterator,reference) - iterator insert(const_iterator hint, reference value) - { return tree_type::insert_unique(hint, value); } - - //! @copydoc ::boost::intrusive::avltree::insert_unique_check(const KeyType&,KeyValueCompare,insert_commit_data&) - template - std::pair insert_check - (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) - { return tree_type::insert_unique_check(key, key_value_comp, commit_data); } - - //! @copydoc ::boost::intrusive::avltree::insert_unique_check(const_iterator,const KeyType&,KeyValueCompare,insert_commit_data&) - template - std::pair insert_check - (const_iterator hint, const KeyType &key - ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) - { return tree_type::insert_unique_check(hint, key, key_value_comp, commit_data); } - - //! @copydoc ::boost::intrusive::avltree::insert_unique(Iterator,Iterator) - template - void insert(Iterator b, Iterator e) - { tree_type::insert_unique(b, e); } - - //! @copydoc ::boost::intrusive::avltree::insert_unique_commit - iterator insert_commit(reference value, const insert_commit_data &commit_data) - { return tree_type::insert_unique_commit(value, commit_data); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! @copydoc ::boost::intrusive::avltree::insert_before - iterator insert_before(const_iterator pos, reference value); - - //! @copydoc ::boost::intrusive::avltree::push_back - void push_back(reference value); - - //! @copydoc ::boost::intrusive::avltree::push_front - void push_front(reference value); - - //! @copydoc ::boost::intrusive::avltree::erase(const_iterator) - iterator erase(const_iterator i); - - //! @copydoc ::boost::intrusive::avltree::erase(const_iterator,const_iterator) - iterator erase(const_iterator b, const_iterator e); - - //! @copydoc ::boost::intrusive::avltree::erase(const_reference) - size_type erase(const_reference value); - - //! @copydoc ::boost::intrusive::avltree::erase(const KeyType&,KeyValueCompare) - template - size_type erase(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_iterator,Disposer) - template - iterator erase_and_dispose(const_iterator i, Disposer disposer); - - //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_iterator,const_iterator,Disposer) - template - iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer); - - //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_reference, Disposer) - template - size_type erase_and_dispose(const_reference value, Disposer disposer); - - //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer) - template - size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer); - - //! @copydoc ::boost::intrusive::avltree::clear - void clear(); - - //! @copydoc ::boost::intrusive::avltree::clear_and_dispose - template - void clear_and_dispose(Disposer disposer); - - #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::avltree::count(const_reference)const - size_type count(const_reference value) const - { return static_cast(this->tree_type::find(value) != this->tree_type::cend()); } - - //! @copydoc ::boost::intrusive::avltree::count(const KeyType&,KeyValueCompare)const - template - size_type count(const KeyType& key, KeyValueCompare comp) const - { return static_cast(this->tree_type::find(key, comp) != this->tree_type::cend()); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::avltree::lower_bound(const_reference) - iterator lower_bound(const_reference value); - - //! @copydoc ::boost::intrusive::avltree::lower_bound(const KeyType&,KeyValueCompare) - template - iterator lower_bound(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::avltree::lower_bound(const_reference)const - const_iterator lower_bound(const_reference value) const; - - //! @copydoc ::boost::intrusive::avltree::lower_bound(const KeyType&,KeyValueCompare)const - template - const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::avltree::upper_bound(const_reference) - iterator upper_bound(const_reference value); - - //! @copydoc ::boost::intrusive::avltree::upper_bound(const KeyType&,KeyValueCompare) - template - iterator upper_bound(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::avltree::upper_bound(const_reference)const - const_iterator upper_bound(const_reference value) const; - - //! @copydoc ::boost::intrusive::avltree::upper_bound(const KeyType&,KeyValueCompare)const - template - const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::avltree::find(const_reference) - iterator find(const_reference value); - - //! @copydoc ::boost::intrusive::avltree::find(const KeyType&,KeyValueCompare) - template - iterator find(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::avltree::find(const_reference)const - const_iterator find(const_reference value) const; - - //! @copydoc ::boost::intrusive::avltree::find(const KeyType&,KeyValueCompare)const - template - const_iterator find(const KeyType& key, KeyValueCompare comp) const; - - #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::rbtree::equal_range(const_reference) - std::pair equal_range(const_reference value) - { return this->tree_type::lower_bound_range(value); } - - //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyValueCompare) - template - std::pair equal_range(const KeyType& key, KeyValueCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } - - //! @copydoc ::boost::intrusive::rbtree::equal_range(const_reference)const - std::pair - equal_range(const_reference value) const - { return this->tree_type::lower_bound_range(value); } - - //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyValueCompare)const - template - std::pair - equal_range(const KeyType& key, KeyValueCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::avltree::bounded_range(const_reference,const_reference,bool,bool) - std::pair bounded_range - (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed); - - //! @copydoc ::boost::intrusive::avltree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool) - template - std::pair bounded_range - (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed); - - //! @copydoc ::boost::intrusive::avltree::bounded_range(const_reference,const_reference,bool,bool)const - std::pair - bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const; - - //! @copydoc ::boost::intrusive::avltree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const - template - std::pair bounded_range - (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const; - - //! @copydoc ::boost::intrusive::avltree::s_iterator_to(reference) - static iterator s_iterator_to(reference value); - - //! @copydoc ::boost::intrusive::avltree::s_iterator_to(const_reference) - static const_iterator s_iterator_to(const_reference value); - - //! @copydoc ::boost::intrusive::avltree::iterator_to(reference) - iterator iterator_to(reference value); - - //! @copydoc ::boost::intrusive::avltree::iterator_to(const_reference)const - const_iterator iterator_to(const_reference value) const; - - //! @copydoc ::boost::intrusive::avltree::init_node(reference) - static void init_node(reference value); - - //! @copydoc ::boost::intrusive::avltree::unlink_leftmost_without_rebalance - pointer unlink_leftmost_without_rebalance(); - - //! @copydoc ::boost::intrusive::avltree::replace_node - void replace_node(iterator replace_this, reference with_this); - - //! @copydoc ::boost::intrusive::avltree::remove_node - void remove_node(reference value); - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED -}; - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -template -bool operator!= (const avl_set_impl &x, const avl_set_impl &y); - -template -bool operator>(const avl_set_impl &x, const avl_set_impl &y); - -template -bool operator<=(const avl_set_impl &x, const avl_set_impl &y); - -template -bool operator>=(const avl_set_impl &x, const avl_set_impl &y); - -template -void swap(avl_set_impl &x, avl_set_impl &y); - -#endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -//! Helper metafunction to define a \c set that yields to the same type when the -//! same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_avl_set -{ - /// @cond - typedef typename pack_options - < avltree_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3, O4, O5 - #else - Options... - #endif - >::type packed_options; - - typedef typename detail::get_value_traits - ::type value_traits; - typedef typename detail::get_header_holder_type - < value_traits, typename packed_options::header_holder_type >::type header_holder_type; - - typedef avl_set_impl - < value_traits - , typename packed_options::compare - , typename packed_options::size_type - , packed_options::constant_time_size - , header_holder_type - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class avl_set - : public make_avl_set::type -{ - typedef typename make_avl_set - ::type Base; - - BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_set) - public: - typedef typename Base::value_compare value_compare; - typedef typename Base::value_traits value_traits; - typedef typename Base::iterator iterator; - typedef typename Base::const_iterator const_iterator; - - //Assert if passed value traits are compatible with the type - BOOST_STATIC_ASSERT((detail::is_same::value)); - - explicit avl_set( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(cmp, v_traits) - {} - - template - avl_set( Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(b, e, cmp, v_traits) - {} - - avl_set(BOOST_RV_REF(avl_set) x) - : Base(::boost::move(static_cast(x))) - {} - - avl_set& operator=(BOOST_RV_REF(avl_set) x) - { return static_cast(this->Base::operator=(::boost::move(static_cast(x)))); } - - static avl_set &container_from_end_iterator(iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static const avl_set &container_from_end_iterator(const_iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static avl_set &container_from_iterator(iterator it) - { return static_cast(Base::container_from_iterator(it)); } - - static const avl_set &container_from_iterator(const_iterator it) - { return static_cast(Base::container_from_iterator(it)); } -}; - -#endif - -//! The class template avl_multiset is an intrusive container, that mimics most of -//! the interface of std::_multiset as described in the C++ standard. -//! -//! The template parameter \c T is the type to be managed by the container. -//! The user can specify additional options and if no options are provided -//! default options are used. -//! -//! The container supports the following options: -//! \c base_hook<>/member_hook<>/value_traits<>, -//! \c constant_time_size<>, \c size_type<> and -//! \c compare<>. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -class avl_multiset_impl -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - : public bstree_impl -#endif -{ - /// @cond - typedef bstree_impl tree_type; - - BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_multiset_impl) - typedef tree_type implementation_defined; - /// @endcond - - public: - typedef typename implementation_defined::value_type value_type; - typedef typename implementation_defined::value_traits value_traits; - typedef typename implementation_defined::pointer pointer; - typedef typename implementation_defined::const_pointer const_pointer; - typedef typename implementation_defined::reference reference; - typedef typename implementation_defined::const_reference const_reference; - typedef typename implementation_defined::difference_type difference_type; - typedef typename implementation_defined::size_type size_type; - typedef typename implementation_defined::value_compare value_compare; - typedef typename implementation_defined::key_compare key_compare; - typedef typename implementation_defined::iterator iterator; - typedef typename implementation_defined::const_iterator const_iterator; - typedef typename implementation_defined::reverse_iterator reverse_iterator; - typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; - typedef typename implementation_defined::insert_commit_data insert_commit_data; - typedef typename implementation_defined::node_traits node_traits; - typedef typename implementation_defined::node node; - typedef typename implementation_defined::node_ptr node_ptr; - typedef typename implementation_defined::const_node_ptr const_node_ptr; - typedef typename implementation_defined::node_algorithms node_algorithms; - - static const bool constant_time_size = tree_type::constant_time_size; - - public: - //! @copydoc ::boost::intrusive::avltree::avltree(const value_compare &,const value_traits &) - explicit avl_multiset_impl( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : tree_type(cmp, v_traits) - {} - - //! @copydoc ::boost::intrusive::avltree::avltree(bool,Iterator,Iterator,const value_compare &,const value_traits &) - template - avl_multiset_impl( Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : tree_type(false, b, e, cmp, v_traits) - {} - - //! @copydoc ::boost::intrusive::avltree::avltree(avltree &&) - avl_multiset_impl(BOOST_RV_REF(avl_multiset_impl) x) - : tree_type(::boost::move(static_cast(x))) - {} - - //! @copydoc ::boost::intrusive::avltree::operator=(avltree &&) - avl_multiset_impl& operator=(BOOST_RV_REF(avl_multiset_impl) x) - { return static_cast(tree_type::operator=(::boost::move(static_cast(x)))); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! @copydoc ::boost::intrusive::avltree::~avltree() - ~avl_multiset_impl(); - - //! @copydoc ::boost::intrusive::avltree::begin() - iterator begin(); - - //! @copydoc ::boost::intrusive::avltree::begin()const - const_iterator begin() const; - - //! @copydoc ::boost::intrusive::avltree::cbegin()const - const_iterator cbegin() const; - - //! @copydoc ::boost::intrusive::avltree::end() - iterator end(); - - //! @copydoc ::boost::intrusive::avltree::end()const - const_iterator end() const; - - //! @copydoc ::boost::intrusive::avltree::cend()const - const_iterator cend() const; - - //! @copydoc ::boost::intrusive::avltree::rbegin() - reverse_iterator rbegin(); - - //! @copydoc ::boost::intrusive::avltree::rbegin()const - const_reverse_iterator rbegin() const; - - //! @copydoc ::boost::intrusive::avltree::crbegin()const - const_reverse_iterator crbegin() const; - - //! @copydoc ::boost::intrusive::avltree::rend() - reverse_iterator rend(); - - //! @copydoc ::boost::intrusive::avltree::rend()const - const_reverse_iterator rend() const; - - //! @copydoc ::boost::intrusive::avltree::crend()const - const_reverse_iterator crend() const; - - //! @copydoc ::boost::intrusive::avltree::container_from_end_iterator(iterator) - static avl_multiset_impl &container_from_end_iterator(iterator end_iterator); - - //! @copydoc ::boost::intrusive::avltree::container_from_end_iterator(const_iterator) - static const avl_multiset_impl &container_from_end_iterator(const_iterator end_iterator); - - //! @copydoc ::boost::intrusive::avltree::container_from_iterator(iterator) - static avl_multiset_impl &container_from_iterator(iterator it); - - //! @copydoc ::boost::intrusive::avltree::container_from_iterator(const_iterator) - static const avl_multiset_impl &container_from_iterator(const_iterator it); - - //! @copydoc ::boost::intrusive::avltree::key_comp()const - key_compare key_comp() const; - - //! @copydoc ::boost::intrusive::avltree::value_comp()const - value_compare value_comp() const; - - //! @copydoc ::boost::intrusive::avltree::empty()const - bool empty() const; - - //! @copydoc ::boost::intrusive::avltree::size()const - size_type size() const; - - //! @copydoc ::boost::intrusive::avltree::swap - void swap(avl_multiset_impl& other); - - //! @copydoc ::boost::intrusive::avltree::clone_from - template - void clone_from(const avl_multiset_impl &src, Cloner cloner, Disposer disposer); - - #endif //#ifdef BOOST_iNTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::avltree::insert_equal(reference) - iterator insert(reference value) - { return tree_type::insert_equal(value); } - - //! @copydoc ::boost::intrusive::avltree::insert_equal(const_iterator,reference) - iterator insert(const_iterator hint, reference value) - { return tree_type::insert_equal(hint, value); } - - //! @copydoc ::boost::intrusive::avltree::insert_equal(Iterator,Iterator) - template - void insert(Iterator b, Iterator e) - { tree_type::insert_equal(b, e); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! @copydoc ::boost::intrusive::avltree::insert_before - iterator insert_before(const_iterator pos, reference value); - - //! @copydoc ::boost::intrusive::avltree::push_back - void push_back(reference value); - - //! @copydoc ::boost::intrusive::avltree::push_front - void push_front(reference value); - - //! @copydoc ::boost::intrusive::avltree::erase(const_iterator) - iterator erase(const_iterator i); - - //! @copydoc ::boost::intrusive::avltree::erase(const_iterator,const_iterator) - iterator erase(const_iterator b, const_iterator e); - - //! @copydoc ::boost::intrusive::avltree::erase(const_reference) - size_type erase(const_reference value); - - //! @copydoc ::boost::intrusive::avltree::erase(const KeyType&,KeyValueCompare) - template - size_type erase(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_iterator,Disposer) - template - iterator erase_and_dispose(const_iterator i, Disposer disposer); - - //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_iterator,const_iterator,Disposer) - template - iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer); - - //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_reference, Disposer) - template - size_type erase_and_dispose(const_reference value, Disposer disposer); - - //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer) - template - size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer); - - //! @copydoc ::boost::intrusive::avltree::clear - void clear(); - - //! @copydoc ::boost::intrusive::avltree::clear_and_dispose - template - void clear_and_dispose(Disposer disposer); - - //! @copydoc ::boost::intrusive::avltree::count(const_reference)const - size_type count(const_reference value) const; - - //! @copydoc ::boost::intrusive::avltree::count(const KeyType&,KeyValueCompare)const - template - size_type count(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::avltree::lower_bound(const_reference) - iterator lower_bound(const_reference value); - - //! @copydoc ::boost::intrusive::avltree::lower_bound(const KeyType&,KeyValueCompare) - template - iterator lower_bound(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::avltree::lower_bound(const_reference)const - const_iterator lower_bound(const_reference value) const; - - //! @copydoc ::boost::intrusive::avltree::lower_bound(const KeyType&,KeyValueCompare)const - template - const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::avltree::upper_bound(const_reference) - iterator upper_bound(const_reference value); - - //! @copydoc ::boost::intrusive::avltree::upper_bound(const KeyType&,KeyValueCompare) - template - iterator upper_bound(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::avltree::upper_bound(const_reference)const - const_iterator upper_bound(const_reference value) const; - - //! @copydoc ::boost::intrusive::avltree::upper_bound(const KeyType&,KeyValueCompare)const - template - const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::avltree::find(const_reference) - iterator find(const_reference value); - - //! @copydoc ::boost::intrusive::avltree::find(const KeyType&,KeyValueCompare) - template - iterator find(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::avltree::find(const_reference)const - const_iterator find(const_reference value) const; - - //! @copydoc ::boost::intrusive::avltree::find(const KeyType&,KeyValueCompare)const - template - const_iterator find(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::avltree::equal_range(const_reference) - std::pair equal_range(const_reference value); - - //! @copydoc ::boost::intrusive::avltree::equal_range(const KeyType&,KeyValueCompare) - template - std::pair equal_range(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::avltree::equal_range(const_reference)const - std::pair - equal_range(const_reference value) const; - - //! @copydoc ::boost::intrusive::avltree::equal_range(const KeyType&,KeyValueCompare)const - template - std::pair - equal_range(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::avltree::bounded_range(const_reference,const_reference,bool,bool) - std::pair bounded_range - (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed); - - //! @copydoc ::boost::intrusive::avltree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool) - template - std::pair bounded_range - (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed); - - //! @copydoc ::boost::intrusive::avltree::bounded_range(const_reference,const_reference,bool,bool)const - std::pair - bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const; - - //! @copydoc ::boost::intrusive::avltree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const - template - std::pair bounded_range - (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const; - - //! @copydoc ::boost::intrusive::avltree::s_iterator_to(reference) - static iterator s_iterator_to(reference value); - - //! @copydoc ::boost::intrusive::avltree::s_iterator_to(const_reference) - static const_iterator s_iterator_to(const_reference value); - - //! @copydoc ::boost::intrusive::avltree::iterator_to(reference) - iterator iterator_to(reference value); - - //! @copydoc ::boost::intrusive::avltree::iterator_to(const_reference)const - const_iterator iterator_to(const_reference value) const; - - //! @copydoc ::boost::intrusive::avltree::init_node(reference) - static void init_node(reference value); - - //! @copydoc ::boost::intrusive::avltree::unlink_leftmost_without_rebalance - pointer unlink_leftmost_without_rebalance(); - - //! @copydoc ::boost::intrusive::avltree::replace_node - void replace_node(iterator replace_this, reference with_this); - - //! @copydoc ::boost::intrusive::avltree::remove_node - void remove_node(reference value); - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED -}; - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -template -bool operator!= (const avl_multiset_impl &x, const avl_multiset_impl &y); - -template -bool operator>(const avl_multiset_impl &x, const avl_multiset_impl &y); - -template -bool operator<=(const avl_multiset_impl &x, const avl_multiset_impl &y); - -template -bool operator>=(const avl_multiset_impl &x, const avl_multiset_impl &y); - -template -void swap(avl_multiset_impl &x, avl_multiset_impl &y); - -#endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -//! Helper metafunction to define a \c avl_multiset that yields to the same type when the -//! same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_avl_multiset -{ - /// @cond - typedef typename pack_options - < avltree_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3, O4, O5 - #else - Options... - #endif - >::type packed_options; - - typedef typename detail::get_value_traits - ::type value_traits; - typedef typename detail::get_header_holder_type - < value_traits, typename packed_options::header_holder_type >::type header_holder_type; - - typedef avl_multiset_impl - < value_traits - , typename packed_options::compare - , typename packed_options::size_type - , packed_options::constant_time_size - , header_holder_type - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class avl_multiset - : public make_avl_multiset::type -{ - typedef typename make_avl_multiset::type Base; - - BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_multiset) - - public: - typedef typename Base::value_compare value_compare; - typedef typename Base::value_traits value_traits; - typedef typename Base::iterator iterator; - typedef typename Base::const_iterator const_iterator; - - //Assert if passed value traits are compatible with the type - BOOST_STATIC_ASSERT((detail::is_same::value)); - - explicit avl_multiset( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(cmp, v_traits) - {} - - template - avl_multiset( Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(b, e, cmp, v_traits) - {} - - avl_multiset(BOOST_RV_REF(avl_multiset) x) - : Base(::boost::move(static_cast(x))) - {} - - avl_multiset& operator=(BOOST_RV_REF(avl_multiset) x) - { return static_cast(this->Base::operator=(::boost::move(static_cast(x)))); } - - static avl_multiset &container_from_end_iterator(iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static const avl_multiset &container_from_end_iterator(const_iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static avl_multiset &container_from_iterator(iterator it) - { return static_cast(Base::container_from_iterator(it)); } - - static const avl_multiset &container_from_iterator(const_iterator it) - { return static_cast(Base::container_from_iterator(it)); } -}; - -#endif - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_AVL_SET_HPP diff --git a/boost/intrusive/avl_set_hook.hpp b/boost/intrusive/avl_set_hook.hpp deleted file mode 100644 index 6fdc51b..0000000 --- a/boost/intrusive/avl_set_hook.hpp +++ /dev/null @@ -1,291 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_AVL_SET_HOOK_HPP -#define BOOST_INTRUSIVE_AVL_SET_HOOK_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -//! Helper metafunction to define a \c avl_set_base_hook that yields to the same -//! type when the same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_avl_set_base_hook -{ - /// @cond - typedef typename pack_options - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - - #else - - #endif - ::type packed_options; - - typedef generic_hook - < avltree_algorithms > - , typename packed_options::tag - , packed_options::link_mode - , AvlTreeBaseHookId - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -//! Derive a class from avl_set_base_hook in order to store objects in -//! in an avl_set/avl_multiset. avl_set_base_hook holds the data necessary to maintain -//! the avl_set/avl_multiset and provides an appropriate value_traits class for avl_set/avl_multiset. -//! -//! The hook admits the following options: \c tag<>, \c void_pointer<>, -//! \c link_mode<> and \c optimize_size<>. -//! -//! \c tag<> defines a tag to identify the node. -//! The same tag value can be used in different classes, but if a class is -//! derived from more than one \c list_base_hook, then each \c list_base_hook needs its -//! unique tag. -//! -//! \c void_pointer<> is the pointer type that will be used internally in the hook -//! and the container configured to use this hook. -//! -//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, -//! \c auto_unlink or \c safe_link). -//! -//! \c optimize_size<> will tell the hook to optimize the hook for size instead -//! of speed. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class avl_set_base_hook - : public make_avl_set_base_hook - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - - #else - - #endif - ::type -{ - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - public: - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. - //! - //! Throws: Nothing. - avl_set_base_hook(); - - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing a copy-constructor - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - avl_set_base_hook(const avl_set_base_hook& ); - - //! Effects: Empty function. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing an assignment operator - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - avl_set_base_hook& operator=(const avl_set_base_hook& ); - - //! Effects: If link_mode is \c normal_link, the destructor does - //! nothing (ie. no code is generated). If link_mode is \c safe_link and the - //! object is stored in a set an assertion is raised. If link_mode is - //! \c auto_unlink and \c is_linked() is true, the node is unlinked. - //! - //! Throws: Nothing. - ~avl_set_base_hook(); - - //! Effects: Swapping two nodes swaps the position of the elements - //! related to those nodes in one or two containers. That is, if the node - //! this is part of the element e1, the node x is part of the element e2 - //! and both elements are included in the containers s1 and s2, then after - //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 - //! at the position of e1. If one element is not in a container, then - //! after the swap-operation the other element is not in a container. - //! Iterators to e1 and e2 related to those nodes are invalidated. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - void swap_nodes(avl_set_base_hook &other); - - //! Precondition: link_mode must be \c safe_link or \c auto_unlink. - //! - //! Returns: true, if the node belongs to a container, false - //! otherwise. This function can be used to test whether \c set::iterator_to - //! will return a valid iterator. - //! - //! Complexity: Constant - bool is_linked() const; - - //! Effects: Removes the node if it's inserted in a container. - //! This function is only allowed if link_mode is \c auto_unlink. - //! - //! Throws: Nothing. - void unlink(); - #endif -}; - -//! Helper metafunction to define a \c avl_set_member_hook that yields to the same -//! type when the same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_avl_set_member_hook -{ - /// @cond - typedef typename pack_options - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - - #else - - #endif - ::type packed_options; - - typedef generic_hook - < avltree_algorithms > - , member_tag - , packed_options::link_mode - , NoBaseHookId - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -//! Put a public data member avl_set_member_hook in order to store objects of this class in -//! an avl_set/avl_multiset. avl_set_member_hook holds the data necessary for maintaining the -//! avl_set/avl_multiset and provides an appropriate value_traits class for avl_set/avl_multiset. -//! -//! The hook admits the following options: \c void_pointer<>, -//! \c link_mode<> and \c optimize_size<>. -//! -//! \c void_pointer<> is the pointer type that will be used internally in the hook -//! and the container configured to use this hook. -//! -//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, -//! \c auto_unlink or \c safe_link). -//! -//! \c optimize_size<> will tell the hook to optimize the hook for size instead -//! of speed. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class avl_set_member_hook - : public make_avl_set_member_hook - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - - #else - - #endif - ::type -{ - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - public: - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. - //! - //! Throws: Nothing. - avl_set_member_hook(); - - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing a copy-constructor - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - avl_set_member_hook(const avl_set_member_hook& ); - - //! Effects: Empty function. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing an assignment operator - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - avl_set_member_hook& operator=(const avl_set_member_hook& ); - - //! Effects: If link_mode is \c normal_link, the destructor does - //! nothing (ie. no code is generated). If link_mode is \c safe_link and the - //! object is stored in a set an assertion is raised. If link_mode is - //! \c auto_unlink and \c is_linked() is true, the node is unlinked. - //! - //! Throws: Nothing. - ~avl_set_member_hook(); - - //! Effects: Swapping two nodes swaps the position of the elements - //! related to those nodes in one or two containers. That is, if the node - //! this is part of the element e1, the node x is part of the element e2 - //! and both elements are included in the containers s1 and s2, then after - //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 - //! at the position of e1. If one element is not in a container, then - //! after the swap-operation the other element is not in a container. - //! Iterators to e1 and e2 related to those nodes are invalidated. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - void swap_nodes(avl_set_member_hook &other); - - //! Precondition: link_mode must be \c safe_link or \c auto_unlink. - //! - //! Returns: true, if the node belongs to a container, false - //! otherwise. This function can be used to test whether \c set::iterator_to - //! will return a valid iterator. - //! - //! Complexity: Constant - bool is_linked() const; - - //! Effects: Removes the node if it's inserted in a container. - //! This function is only allowed if link_mode is \c auto_unlink. - //! - //! Throws: Nothing. - void unlink(); - #endif -}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_AVL_SET_HOOK_HPP diff --git a/boost/intrusive/avltree.hpp b/boost/intrusive/avltree.hpp deleted file mode 100644 index d2adf24..0000000 --- a/boost/intrusive/avltree.hpp +++ /dev/null @@ -1,549 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_INTRUSIVE_AVLTREE_HPP -#define BOOST_INTRUSIVE_AVLTREE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -/// @cond - -struct default_avltree_hook_applier -{ template struct apply{ typedef typename T::default_avltree_hook type; }; }; - -template<> -struct is_default_hook_tag -{ static const bool value = true; }; - -struct avltree_defaults -{ - typedef default_avltree_hook_applier proto_value_traits; - static const bool constant_time_size = true; - typedef std::size_t size_type; - typedef void compare; - typedef void header_holder_type; -}; - -/// @endcond - -//! The class template avltree is an intrusive AVL tree container, that -//! is used to construct intrusive avl_set and avl_multiset containers. -//! The no-throw guarantee holds only, if the value_compare object -//! doesn't throw. -//! -//! The template parameter \c T is the type to be managed by the container. -//! The user can specify additional options and if no options are provided -//! default options are used. -//! -//! The container supports the following options: -//! \c base_hook<>/member_hook<>/value_traits<>, -//! \c constant_time_size<>, \c size_type<> and -//! \c compare<>. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -class avltree_impl - /// @cond - : public bstree_impl - /// @endcond -{ - public: - typedef ValueTraits value_traits; - /// @cond - typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType - , ConstantTimeSize, AvlTreeAlgorithms - , HeaderHolder> tree_type; - typedef tree_type implementation_defined; - /// @endcond - - typedef typename implementation_defined::pointer pointer; - typedef typename implementation_defined::const_pointer const_pointer; - typedef typename implementation_defined::value_type value_type; - typedef typename implementation_defined::key_type key_type; - typedef typename implementation_defined::reference reference; - typedef typename implementation_defined::const_reference const_reference; - typedef typename implementation_defined::difference_type difference_type; - typedef typename implementation_defined::size_type size_type; - typedef typename implementation_defined::value_compare value_compare; - typedef typename implementation_defined::key_compare key_compare; - typedef typename implementation_defined::iterator iterator; - typedef typename implementation_defined::const_iterator const_iterator; - typedef typename implementation_defined::reverse_iterator reverse_iterator; - typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; - typedef typename implementation_defined::node_traits node_traits; - typedef typename implementation_defined::node node; - typedef typename implementation_defined::node_ptr node_ptr; - typedef typename implementation_defined::const_node_ptr const_node_ptr; - typedef typename implementation_defined::node_algorithms node_algorithms; - - static const bool constant_time_size = implementation_defined::constant_time_size; - /// @cond - private: - - //noncopyable - BOOST_MOVABLE_BUT_NOT_COPYABLE(avltree_impl) - - /// @endcond - - public: - - typedef typename implementation_defined::insert_commit_data insert_commit_data; - - - //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &) - explicit avltree_impl( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : tree_type(cmp, v_traits) - {} - - //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const value_compare &,const value_traits &) - template - avltree_impl( bool unique, Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : tree_type(unique, b, e, cmp, v_traits) - {} - - //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&) - avltree_impl(BOOST_RV_REF(avltree_impl) x) - : tree_type(::boost::move(static_cast(x))) - {} - - //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&) - avltree_impl& operator=(BOOST_RV_REF(avltree_impl) x) - { return static_cast(tree_type::operator=(::boost::move(static_cast(x)))); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::bstree::~bstree() - ~avltree_impl(); - - //! @copydoc ::boost::intrusive::bstree::begin() - iterator begin(); - - //! @copydoc ::boost::intrusive::bstree::begin()const - const_iterator begin() const; - - //! @copydoc ::boost::intrusive::bstree::cbegin()const - const_iterator cbegin() const; - - //! @copydoc ::boost::intrusive::bstree::end() - iterator end(); - - //! @copydoc ::boost::intrusive::bstree::end()const - const_iterator end() const; - - //! @copydoc ::boost::intrusive::bstree::cend()const - const_iterator cend() const; - - //! @copydoc ::boost::intrusive::bstree::rbegin() - reverse_iterator rbegin(); - - //! @copydoc ::boost::intrusive::bstree::rbegin()const - const_reverse_iterator rbegin() const; - - //! @copydoc ::boost::intrusive::bstree::crbegin()const - const_reverse_iterator crbegin() const; - - //! @copydoc ::boost::intrusive::bstree::rend() - reverse_iterator rend(); - - //! @copydoc ::boost::intrusive::bstree::rend()const - const_reverse_iterator rend() const; - - //! @copydoc ::boost::intrusive::bstree::crend()const - const_reverse_iterator crend() const; - - //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator) - static avltree_impl &container_from_end_iterator(iterator end_iterator); - - //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator) - static const avltree_impl &container_from_end_iterator(const_iterator end_iterator); - - //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator) - static avltree_impl &container_from_iterator(iterator it); - - //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator) - static const avltree_impl &container_from_iterator(const_iterator it); - - //! @copydoc ::boost::intrusive::bstree::key_comp()const - key_compare key_comp() const; - - //! @copydoc ::boost::intrusive::bstree::value_comp()const - value_compare value_comp() const; - - //! @copydoc ::boost::intrusive::bstree::empty()const - bool empty() const; - - //! @copydoc ::boost::intrusive::bstree::size()const - size_type size() const; - - //! @copydoc ::boost::intrusive::bstree::swap - void swap(avltree_impl& other); - - //! @copydoc ::boost::intrusive::bstree::clone_from - template - void clone_from(const avltree_impl &src, Cloner cloner, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::insert_equal(reference) - iterator insert_equal(reference value); - - //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference) - iterator insert_equal(const_iterator hint, reference value); - - //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator) - template - void insert_equal(Iterator b, Iterator e); - - //! @copydoc ::boost::intrusive::bstree::insert_unique(reference) - std::pair insert_unique(reference value); - - //! @copydoc ::boost::intrusive::bstree::insert_unique(const_iterator,reference) - iterator insert_unique(const_iterator hint, reference value); - - //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyValueCompare,insert_commit_data&) - template - std::pair insert_unique_check - (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data); - - //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyValueCompare,insert_commit_data&) - template - std::pair insert_unique_check - (const_iterator hint, const KeyType &key - ,KeyValueCompare key_value_comp, insert_commit_data &commit_data); - - //! @copydoc ::boost::intrusive::bstree::insert_unique_commit - iterator insert_unique_commit(reference value, const insert_commit_data &commit_data); - - //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator) - template - void insert_unique(Iterator b, Iterator e); - - //! @copydoc ::boost::intrusive::bstree::insert_before - iterator insert_before(const_iterator pos, reference value); - - //! @copydoc ::boost::intrusive::bstree::push_back - void push_back(reference value); - - //! @copydoc ::boost::intrusive::bstree::push_front - void push_front(reference value); - - //! @copydoc ::boost::intrusive::bstree::erase(const_iterator) - iterator erase(const_iterator i); - - //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator) - iterator erase(const_iterator b, const_iterator e); - - //! @copydoc ::boost::intrusive::bstree::erase(const_reference) - size_type erase(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyValueCompare) - template - size_type erase(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer) - template - iterator erase_and_dispose(const_iterator i, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer) - template - iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_reference, Disposer) - template - size_type erase_and_dispose(const_reference value, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer) - template - size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::clear - void clear(); - - //! @copydoc ::boost::intrusive::bstree::clear_and_dispose - template - void clear_and_dispose(Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::count(const_reference)const - size_type count(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const - template - size_type count(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference) - iterator lower_bound(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare) - template - iterator lower_bound(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const - const_iterator lower_bound(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)const - template - const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference) - iterator upper_bound(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare) - template - iterator upper_bound(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)const - const_iterator upper_bound(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)const - template - const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::find(const_reference) - iterator find(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare) - template - iterator find(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::find(const_reference)const - const_iterator find(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)const - template - const_iterator find(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference) - std::pair equal_range(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare) - template - std::pair equal_range(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)const - std::pair - equal_range(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)const - template - std::pair - equal_range(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool) - std::pair bounded_range - (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed); - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool) - template - std::pair bounded_range - (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed); - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)const - std::pair - bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const; - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const - template - std::pair bounded_range - (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const; - - //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference) - static iterator s_iterator_to(reference value); - - //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference) - static const_iterator s_iterator_to(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::iterator_to(reference) - iterator iterator_to(reference value); - - //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const - const_iterator iterator_to(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::init_node(reference) - static void init_node(reference value); - - //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance - pointer unlink_leftmost_without_rebalance(); - - //! @copydoc ::boost::intrusive::bstree::replace_node - void replace_node(iterator replace_this, reference with_this); - - //! @copydoc ::boost::intrusive::bstree::remove_node - void remove_node(reference value); - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED -}; - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -template -bool operator< (const avltree_impl &x, const avltree_impl &y); - -template -bool operator==(const avltree_impl &x, const avltree_impl &y); - -template -bool operator!= (const avltree_impl &x, const avltree_impl &y); - -template -bool operator>(const avltree_impl &x, const avltree_impl &y); - -template -bool operator<=(const avltree_impl &x, const avltree_impl &y); - -template -bool operator>=(const avltree_impl &x, const avltree_impl &y); - -template -void swap(avltree_impl &x, avltree_impl &y); - -#endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -//! Helper metafunction to define a \c avltree that yields to the same type when the -//! same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_avltree -{ - /// @cond - typedef typename pack_options - < avltree_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3, O4, O5 - #else - Options... - #endif - >::type packed_options; - - typedef typename detail::get_value_traits - ::type value_traits; - typedef typename detail::get_header_holder_type - < value_traits, typename packed_options::header_holder_type >::type header_holder_type; - - typedef avltree_impl - < value_traits - , typename packed_options::compare - , typename packed_options::size_type - , packed_options::constant_time_size - , header_holder_type - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - - -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class avltree - : public make_avltree::type -{ - typedef typename make_avltree - ::type Base; - BOOST_MOVABLE_BUT_NOT_COPYABLE(avltree) - - public: - typedef typename Base::value_compare value_compare; - typedef typename Base::value_traits value_traits; - typedef typename Base::iterator iterator; - typedef typename Base::const_iterator const_iterator; - typedef typename Base::reverse_iterator reverse_iterator; - typedef typename Base::const_reverse_iterator const_reverse_iterator; - - //Assert if passed value traits are compatible with the type - BOOST_STATIC_ASSERT((detail::is_same::value)); - - explicit avltree( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(cmp, v_traits) - {} - - template - avltree( bool unique, Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(unique, b, e, cmp, v_traits) - {} - - avltree(BOOST_RV_REF(avltree) x) - : Base(::boost::move(static_cast(x))) - {} - - avltree& operator=(BOOST_RV_REF(avltree) x) - { return static_cast(this->Base::operator=(::boost::move(static_cast(x)))); } - - static avltree &container_from_end_iterator(iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static const avltree &container_from_end_iterator(const_iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static avltree &container_from_iterator(iterator it) - { return static_cast(Base::container_from_iterator(it)); } - - static const avltree &container_from_iterator(const_iterator it) - { return static_cast(Base::container_from_iterator(it)); } -}; - -#endif - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_AVLTREE_HPP diff --git a/boost/intrusive/avltree_algorithms.hpp b/boost/intrusive/avltree_algorithms.hpp deleted file mode 100644 index e5bcfde..0000000 --- a/boost/intrusive/avltree_algorithms.hpp +++ /dev/null @@ -1,687 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Daniel K. O. 2005. -// (C) Copyright Ion Gaztanaga 2007-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_AVLTREE_ALGORITHMS_HPP -#define BOOST_INTRUSIVE_AVLTREE_ALGORITHMS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include - -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -/// @cond - -template -struct avltree_node_cloner - : private detail::ebo_functor_holder -{ - typedef typename NodeTraits::node_ptr node_ptr; - typedef detail::ebo_functor_holder base_t; - - avltree_node_cloner(F f) - : base_t(f) - {} - - node_ptr operator()(const node_ptr & p) - { - node_ptr n = base_t::get()(p); - NodeTraits::set_balance(n, NodeTraits::get_balance(p)); - return n; - } -}; - -namespace detail { - -template -struct avltree_node_checker - : public bstree_node_checker -{ - typedef bstree_node_checker base_checker_t; - typedef ValueTraits value_traits; - typedef typename value_traits::node_traits node_traits; - typedef typename node_traits::const_node_ptr const_node_ptr; - - struct return_type - : public base_checker_t::return_type - { - return_type() : height(0) {} - int height; - }; - - avltree_node_checker(const NodePtrCompare& comp, ExtraChecker extra_checker) - : base_checker_t(comp, extra_checker) - {} - - void operator () (const const_node_ptr& p, - const return_type& check_return_left, const return_type& check_return_right, - return_type& check_return) - { - const int height_diff = check_return_right.height - check_return_left.height; (void)height_diff; - BOOST_INTRUSIVE_INVARIANT_ASSERT( - (height_diff == -1 && node_traits::get_balance(p) == node_traits::negative()) || - (height_diff == 0 && node_traits::get_balance(p) == node_traits::zero()) || - (height_diff == 1 && node_traits::get_balance(p) == node_traits::positive()) - ); - check_return.height = 1 + - (check_return_left.height > check_return_right.height ? check_return_left.height : check_return_right.height); - base_checker_t::operator()(p, check_return_left, check_return_right, check_return); - } -}; - -} // namespace detail - -/// @endcond - -//! avltree_algorithms is configured with a NodeTraits class, which encapsulates the -//! information about the node to be manipulated. NodeTraits must support the -//! following interface: -//! -//! Typedefs: -//! -//! node: The type of the node that forms the binary search tree -//! -//! node_ptr: A pointer to a node -//! -//! const_node_ptr: A pointer to a const node -//! -//! balance: The type of the balance factor -//! -//! Static functions: -//! -//! static node_ptr get_parent(const_node_ptr n); -//! -//! static void set_parent(node_ptr n, node_ptr parent); -//! -//! static node_ptr get_left(const_node_ptr n); -//! -//! static void set_left(node_ptr n, node_ptr left); -//! -//! static node_ptr get_right(const_node_ptr n); -//! -//! static void set_right(node_ptr n, node_ptr right); -//! -//! static balance get_balance(const_node_ptr n); -//! -//! static void set_balance(node_ptr n, balance b); -//! -//! static balance negative(); -//! -//! static balance zero(); -//! -//! static balance positive(); -template -class avltree_algorithms - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - : public bstree_algorithms - #endif -{ - public: - typedef typename NodeTraits::node node; - typedef NodeTraits node_traits; - typedef typename NodeTraits::node_ptr node_ptr; - typedef typename NodeTraits::const_node_ptr const_node_ptr; - typedef typename NodeTraits::balance balance; - - /// @cond - private: - typedef bstree_algorithms bstree_algo; - - /// @endcond - - public: - //! This type is the information that will be - //! filled by insert_unique_check - typedef typename bstree_algo::insert_commit_data insert_commit_data; - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::bstree_algorithms::get_header(const const_node_ptr&) - static node_ptr get_header(const const_node_ptr & n); - - //! @copydoc ::boost::intrusive::bstree_algorithms::begin_node - static node_ptr begin_node(const const_node_ptr & header); - - //! @copydoc ::boost::intrusive::bstree_algorithms::end_node - static node_ptr end_node(const const_node_ptr & header); - - //! @copydoc ::boost::intrusive::bstree_algorithms::swap_tree - static void swap_tree(const node_ptr & header1, const node_ptr & header2); - - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::bstree_algorithms::swap_nodes(const node_ptr&,const node_ptr&) - static void swap_nodes(const node_ptr & node1, const node_ptr & node2) - { - if(node1 == node2) - return; - - node_ptr header1(bstree_algo::get_header(node1)), header2(bstree_algo::get_header(node2)); - swap_nodes(node1, header1, node2, header2); - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::swap_nodes(const node_ptr&,const node_ptr&,const node_ptr&,const node_ptr&) - static void swap_nodes(const node_ptr & node1, const node_ptr & header1, const node_ptr & node2, const node_ptr & header2) - { - if(node1 == node2) return; - - bstree_algo::swap_nodes(node1, header1, node2, header2); - //Swap balance - balance c = NodeTraits::get_balance(node1); - NodeTraits::set_balance(node1, NodeTraits::get_balance(node2)); - NodeTraits::set_balance(node2, c); - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::replace_node(const node_ptr&,const node_ptr&) - static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & new_node) - { - if(node_to_be_replaced == new_node) - return; - replace_node(node_to_be_replaced, bstree_algo::get_header(node_to_be_replaced), new_node); - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::replace_node(const node_ptr&,const node_ptr&,const node_ptr&) - static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & header, const node_ptr & new_node) - { - bstree_algo::replace_node(node_to_be_replaced, header, new_node); - NodeTraits::set_balance(new_node, NodeTraits::get_balance(node_to_be_replaced)); - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::unlink(const node_ptr&) - static void unlink(const node_ptr & node) - { - node_ptr x = NodeTraits::get_parent(node); - if(x){ - while(!is_header(x)) - x = NodeTraits::get_parent(x); - erase(x, node); - } - } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! @copydoc ::boost::intrusive::bstree_algorithms::unlink_leftmost_without_rebalance - static node_ptr unlink_leftmost_without_rebalance(const node_ptr & header); - - //! @copydoc ::boost::intrusive::bstree_algorithms::unique(const const_node_ptr&) - static bool unique(const const_node_ptr & node); - - //! @copydoc ::boost::intrusive::bstree_algorithms::size(const const_node_ptr&) - static std::size_t size(const const_node_ptr & header); - - //! @copydoc ::boost::intrusive::bstree_algorithms::next_node(const node_ptr&) - static node_ptr next_node(const node_ptr & node); - - //! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(const node_ptr&) - static node_ptr prev_node(const node_ptr & node); - - //! @copydoc ::boost::intrusive::bstree_algorithms::init(const node_ptr&) - static void init(const node_ptr & node); - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! Requires: node must not be part of any tree. - //! - //! Effects: Initializes the header to represent an empty tree. - //! unique(header) == true. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Nodes: If node is inserted in a tree, this function corrupts the tree. - static void init_header(const node_ptr & header) - { - bstree_algo::init_header(header); - NodeTraits::set_balance(header, NodeTraits::zero()); - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::erase(const node_ptr&,const node_ptr&) - static node_ptr erase(const node_ptr & header, const node_ptr & z) - { - typename bstree_algo::data_for_rebalance info; - bstree_algo::erase(header, z, info); - if(info.y != z){ - NodeTraits::set_balance(info.y, NodeTraits::get_balance(z)); - } - //Rebalance avltree - rebalance_after_erasure(header, info.x, info.x_parent); - return z; - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::clone(const const_node_ptr&,const node_ptr&,Cloner,Disposer) - template - static void clone - (const const_node_ptr & source_header, const node_ptr & target_header, Cloner cloner, Disposer disposer) - { - avltree_node_cloner new_cloner(cloner); - bstree_algo::clone(source_header, target_header, new_cloner, disposer); - } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! @copydoc ::boost::intrusive::bstree_algorithms::clear_and_dispose(const node_ptr&,Disposer) - template - static void clear_and_dispose(const node_ptr & header, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree_algorithms::lower_bound(const const_node_ptr&,const KeyType&,KeyNodePtrCompare) - template - static node_ptr lower_bound - (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp); - - //! @copydoc ::boost::intrusive::bstree_algorithms::upper_bound(const const_node_ptr&,const KeyType&,KeyNodePtrCompare) - template - static node_ptr upper_bound - (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp); - - //! @copydoc ::boost::intrusive::bstree_algorithms::find(const const_node_ptr&,const KeyType&,KeyNodePtrCompare) - template - static node_ptr find - (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp); - - //! @copydoc ::boost::intrusive::bstree_algorithms::equal_range(const const_node_ptr&,const KeyType&,KeyNodePtrCompare) - template - static std::pair equal_range - (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp); - - //! @copydoc ::boost::intrusive::bstree_algorithms::bounded_range(const const_node_ptr&,const KeyType&,const KeyType&,KeyNodePtrCompare,bool,bool) - template - static std::pair bounded_range - (const const_node_ptr & header, const KeyType &lower_key, const KeyType &upper_key, KeyNodePtrCompare comp - , bool left_closed, bool right_closed); - - //! @copydoc ::boost::intrusive::bstree_algorithms::count(const const_node_ptr&,const KeyType&,KeyNodePtrCompare) - template - static std::size_t count(const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp); - - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::bstree_algorithms::insert_equal_upper_bound(const node_ptr&,const node_ptr&,NodePtrCompare) - template - static node_ptr insert_equal_upper_bound - (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp) - { - bstree_algo::insert_equal_upper_bound(h, new_node, comp); - rebalance_after_insertion(h, new_node); - return new_node; - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::insert_equal_lower_bound(const node_ptr&,const node_ptr&,NodePtrCompare) - template - static node_ptr insert_equal_lower_bound - (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp) - { - bstree_algo::insert_equal_lower_bound(h, new_node, comp); - rebalance_after_insertion(h, new_node); - return new_node; - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::insert_equal(const node_ptr&,const node_ptr&,const node_ptr&,NodePtrCompare) - template - static node_ptr insert_equal - (const node_ptr & header, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp) - { - bstree_algo::insert_equal(header, hint, new_node, comp); - rebalance_after_insertion(header, new_node); - return new_node; - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::insert_before(const node_ptr&,const node_ptr&,const node_ptr&) - static node_ptr insert_before - (const node_ptr & header, const node_ptr & pos, const node_ptr & new_node) - { - bstree_algo::insert_before(header, pos, new_node); - rebalance_after_insertion(header, new_node); - return new_node; - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::push_back(const node_ptr&,const node_ptr&) - static void push_back(const node_ptr & header, const node_ptr & new_node) - { - bstree_algo::push_back(header, new_node); - rebalance_after_insertion(header, new_node); - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::push_front(const node_ptr&,const node_ptr&) - static void push_front(const node_ptr & header, const node_ptr & new_node) - { - bstree_algo::push_front(header, new_node); - rebalance_after_insertion(header, new_node); - } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! @copydoc ::boost::intrusive::bstree_algorithms::insert_unique_check(const const_node_ptr&,const KeyType&,KeyNodePtrCompare,insert_commit_data&) - template - static std::pair insert_unique_check - (const const_node_ptr & header, const KeyType &key - ,KeyNodePtrCompare comp, insert_commit_data &commit_data); - - //! @copydoc ::boost::intrusive::bstree_algorithms::insert_unique_check(const const_node_ptr&,const node_ptr&,const KeyType&,KeyNodePtrCompare,insert_commit_data&) - template - static std::pair insert_unique_check - (const const_node_ptr & header, const node_ptr &hint, const KeyType &key - ,KeyNodePtrCompare comp, insert_commit_data &commit_data); - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::bstree_algorithms::insert_unique_commit(const node_ptr&,const node_ptr&,const insert_commit_data &) - static void insert_unique_commit - (const node_ptr & header, const node_ptr & new_value, const insert_commit_data &commit_data) - { - bstree_algo::insert_unique_commit(header, new_value, commit_data); - rebalance_after_insertion(header, new_value); - } - - //! @copydoc ::boost::intrusive::bstree_algorithms::is_header - static bool is_header(const const_node_ptr & p) - { return NodeTraits::get_balance(p) == NodeTraits::zero() && bstree_algo::is_header(p); } - - - /// @cond - static bool verify(const node_ptr &header) - { - std::size_t height; - std::size_t count; - return verify_recursion(NodeTraits::get_parent(header), count, height); - } - - private: - - static bool verify_recursion(node_ptr n, std::size_t &count, std::size_t &height) - { - if (!n){ - count = 0; - height = 0; - return true; - } - std::size_t leftcount, rightcount; - std::size_t leftheight, rightheight; - if(!verify_recursion(NodeTraits::get_left (n), leftcount, leftheight) || - !verify_recursion(NodeTraits::get_right(n), rightcount, rightheight) ){ - return false; - } - count = 1u + leftcount + rightcount; - height = 1u + (leftheight > rightheight ? leftheight : rightheight); - - //If equal height, balance must be zero - if(rightheight == leftheight){ - if(NodeTraits::get_balance(n) != NodeTraits::zero()){ - BOOST_ASSERT(0); - return false; - } - } - //If right is taller than left, then the difference must be at least 1 and the balance positive - else if(rightheight > leftheight){ - if(rightheight - leftheight > 1 ){ - BOOST_ASSERT(0); - return false; - } - else if(NodeTraits::get_balance(n) != NodeTraits::positive()){ - BOOST_ASSERT(0); - return false; - } - } - //If left is taller than right, then the difference must be at least 1 and the balance negative - else{ - if(leftheight - rightheight > 1 ){ - BOOST_ASSERT(0); - return false; - } - else if(NodeTraits::get_balance(n) != NodeTraits::negative()){ - BOOST_ASSERT(0); - return false; - } - } - return true; - } - - static void rebalance_after_erasure(const node_ptr & header, node_ptr x, node_ptr x_parent) - { - for ( node_ptr root = NodeTraits::get_parent(header) - ; x != root - ; root = NodeTraits::get_parent(header), x_parent = NodeTraits::get_parent(x)) { - const balance x_parent_balance = NodeTraits::get_balance(x_parent); - //Don't cache x_is_leftchild or similar because x can be null and - //equal to both x_parent_left and x_parent_right - const node_ptr x_parent_left (NodeTraits::get_left(x_parent)); - const node_ptr x_parent_right(NodeTraits::get_right(x_parent)); - - if(x_parent_balance == NodeTraits::zero()){ - NodeTraits::set_balance( x_parent, x == x_parent_right ? NodeTraits::negative() : NodeTraits::positive() ); - break; // the height didn't change, let's stop here - } - else if(x_parent_balance == NodeTraits::negative()){ - if (x == x_parent_left) { ////x is left child or x and sibling are null - NodeTraits::set_balance(x_parent, NodeTraits::zero()); // balanced - x = x_parent; - } - else { - // x is right child (x_parent_left is the left child) - BOOST_INTRUSIVE_INVARIANT_ASSERT(x_parent_left); - if (NodeTraits::get_balance(x_parent_left) == NodeTraits::positive()) { - // x_parent_left MUST have a right child - BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_right(x_parent_left)); - x = avl_rotate_left_right(x_parent, x_parent_left, header); - } - else { - avl_rotate_right(x_parent, x_parent_left, header); - x = x_parent_left; - } - - // if changed from negative to NodeTraits::positive(), no need to check above - if (NodeTraits::get_balance(x) == NodeTraits::positive()){ - break; - } - } - } - else if(x_parent_balance == NodeTraits::positive()){ - if (x == x_parent_right) { //x is right child or x and sibling are null - NodeTraits::set_balance(x_parent, NodeTraits::zero()); // balanced - x = x_parent; - } - else { - // x is left child (x_parent_right is the right child) - BOOST_INTRUSIVE_INVARIANT_ASSERT(x_parent_right); - if (NodeTraits::get_balance(x_parent_right) == NodeTraits::negative()) { - // x_parent_right MUST have then a left child - BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_left(x_parent_right)); - x = avl_rotate_right_left(x_parent, x_parent_right, header); - } - else { - avl_rotate_left(x_parent, x_parent_right, header); - x = x_parent_right; - } - // if changed from NodeTraits::positive() to negative, no need to check above - if (NodeTraits::get_balance(x) == NodeTraits::negative()){ - break; - } - } - } - else{ - BOOST_INTRUSIVE_INVARIANT_ASSERT(false); // never reached - } - } - } - - static void rebalance_after_insertion(const node_ptr & header, node_ptr x) - { - NodeTraits::set_balance(x, NodeTraits::zero()); - // Rebalance. - for(node_ptr root = NodeTraits::get_parent(header); x != root; root = NodeTraits::get_parent(header)){ - node_ptr const x_parent(NodeTraits::get_parent(x)); - node_ptr const x_parent_left(NodeTraits::get_left(x_parent)); - const balance x_parent_balance = NodeTraits::get_balance(x_parent); - const bool x_is_leftchild(x == x_parent_left); - if(x_parent_balance == NodeTraits::zero()){ - // if x is left, parent will have parent->bal_factor = negative - // else, parent->bal_factor = NodeTraits::positive() - NodeTraits::set_balance( x_parent, x_is_leftchild ? NodeTraits::negative() : NodeTraits::positive() ); - x = x_parent; - } - else if(x_parent_balance == NodeTraits::positive()){ - // if x is a left child, parent->bal_factor = zero - if (x_is_leftchild) - NodeTraits::set_balance(x_parent, NodeTraits::zero()); - else{ // x is a right child, needs rebalancing - if (NodeTraits::get_balance(x) == NodeTraits::negative()) - avl_rotate_right_left(x_parent, x, header); - else - avl_rotate_left(x_parent, x, header); - } - break; - } - else if(x_parent_balance == NodeTraits::negative()){ - // if x is a left child, needs rebalancing - if (x_is_leftchild) { - if (NodeTraits::get_balance(x) == NodeTraits::positive()) - avl_rotate_left_right(x_parent, x, header); - else - avl_rotate_right(x_parent, x, header); - } - else - NodeTraits::set_balance(x_parent, NodeTraits::zero()); - break; - } - else{ - BOOST_INTRUSIVE_INVARIANT_ASSERT(false); // never reached - } - } - } - - static void left_right_balancing(const node_ptr & a, const node_ptr & b, const node_ptr & c) - { - // balancing... - const balance c_balance = NodeTraits::get_balance(c); - const balance zero_balance = NodeTraits::zero(); - const balance posi_balance = NodeTraits::positive(); - const balance nega_balance = NodeTraits::negative(); - NodeTraits::set_balance(c, zero_balance); - if(c_balance == nega_balance){ - NodeTraits::set_balance(a, posi_balance); - NodeTraits::set_balance(b, zero_balance); - } - else if(c_balance == zero_balance){ - NodeTraits::set_balance(a, zero_balance); - NodeTraits::set_balance(b, zero_balance); - } - else if(c_balance == posi_balance){ - NodeTraits::set_balance(a, zero_balance); - NodeTraits::set_balance(b, nega_balance); - } - else{ - BOOST_INTRUSIVE_INVARIANT_ASSERT(false); // never reached - } - } - - static node_ptr avl_rotate_left_right(const node_ptr a, const node_ptr a_oldleft, const node_ptr & hdr) - { // [note: 'a_oldleft' is 'b'] - // | | // - // a(-2) c // - // / \ / \ // - // / \ ==> / \ // - // (pos)b [g] b a // - // / \ / \ / \ // - // [d] c [d] e f [g] // - // / \ // - // e f // - const node_ptr c = NodeTraits::get_right(a_oldleft); - bstree_algo::rotate_left_no_parent_fix(a_oldleft, c); - //No need to link c with a [NodeTraits::set_parent(c, a) + NodeTraits::set_left(a, c)] - //as c is not root and another rotation is coming - bstree_algo::rotate_right(a, c, NodeTraits::get_parent(a), hdr); - left_right_balancing(a, a_oldleft, c); - return c; - } - - static node_ptr avl_rotate_right_left(const node_ptr a, const node_ptr a_oldright, const node_ptr & hdr) - { // [note: 'a_oldright' is 'b'] - // | | // - // a(pos) c // - // / \ / \ // - // / \ / \ // - // [d] b(neg) ==> a b // - // / \ / \ / \ // - // c [g] [d] e f [g] // - // / \ // - // e f // - const node_ptr c (NodeTraits::get_left(a_oldright)); - bstree_algo::rotate_right_no_parent_fix(a_oldright, c); - //No need to link c with a [NodeTraits::set_parent(c, a) + NodeTraits::set_right(a, c)] - //as c is not root and another rotation is coming. - bstree_algo::rotate_left(a, c, NodeTraits::get_parent(a), hdr); - left_right_balancing(a_oldright, a, c); - return c; - } - - static void avl_rotate_left(const node_ptr &x, const node_ptr &x_oldright, const node_ptr & hdr) - { - bstree_algo::rotate_left(x, x_oldright, NodeTraits::get_parent(x), hdr); - - // reset the balancing factor - if (NodeTraits::get_balance(x_oldright) == NodeTraits::positive()) { - NodeTraits::set_balance(x, NodeTraits::zero()); - NodeTraits::set_balance(x_oldright, NodeTraits::zero()); - } - else { // this doesn't happen during insertions - NodeTraits::set_balance(x, NodeTraits::positive()); - NodeTraits::set_balance(x_oldright, NodeTraits::negative()); - } - } - - static void avl_rotate_right(const node_ptr &x, const node_ptr &x_oldleft, const node_ptr & hdr) - { - bstree_algo::rotate_right(x, x_oldleft, NodeTraits::get_parent(x), hdr); - - // reset the balancing factor - if (NodeTraits::get_balance(x_oldleft) == NodeTraits::negative()) { - NodeTraits::set_balance(x, NodeTraits::zero()); - NodeTraits::set_balance(x_oldleft, NodeTraits::zero()); - } - else { // this doesn't happen during insertions - NodeTraits::set_balance(x, NodeTraits::negative()); - NodeTraits::set_balance(x_oldleft, NodeTraits::positive()); - } - } - - /// @endcond -}; - -/// @cond - -template -struct get_algo -{ - typedef avltree_algorithms type; -}; - -template -struct get_node_checker -{ - typedef detail::avltree_node_checker type; -}; - -/// @endcond - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_AVLTREE_ALGORITHMS_HPP diff --git a/boost/intrusive/bs_set.hpp b/boost/intrusive/bs_set.hpp deleted file mode 100644 index b87a543..0000000 --- a/boost/intrusive/bs_set.hpp +++ /dev/null @@ -1,948 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2013-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_INTRUSIVE_BS_SET_HPP -#define BOOST_INTRUSIVE_BS_SET_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -//! The class template bs_set is an intrusive container, that mimics most of -//! the interface of std::set as described in the C++ standard. -//! -//! The template parameter \c T is the type to be managed by the container. -//! The user can specify additional options and if no options are provided -//! default options are used. -//! -//! The container supports the following options: -//! \c base_hook<>/member_hook<>/value_traits<>, -//! \c constant_time_size<>, \c size_type<> and -//! \c compare<>. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -class bs_set_impl -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - : public bstree_impl -#endif -{ - /// @cond - typedef bstree_impl tree_type; - BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_set_impl) - - typedef tree_type implementation_defined; - /// @endcond - - public: - typedef typename implementation_defined::value_type value_type; - typedef typename implementation_defined::value_traits value_traits; - typedef typename implementation_defined::pointer pointer; - typedef typename implementation_defined::const_pointer const_pointer; - typedef typename implementation_defined::reference reference; - typedef typename implementation_defined::const_reference const_reference; - typedef typename implementation_defined::difference_type difference_type; - typedef typename implementation_defined::size_type size_type; - typedef typename implementation_defined::value_compare value_compare; - typedef typename implementation_defined::key_compare key_compare; - typedef typename implementation_defined::iterator iterator; - typedef typename implementation_defined::const_iterator const_iterator; - typedef typename implementation_defined::reverse_iterator reverse_iterator; - typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; - typedef typename implementation_defined::insert_commit_data insert_commit_data; - typedef typename implementation_defined::node_traits node_traits; - typedef typename implementation_defined::node node; - typedef typename implementation_defined::node_ptr node_ptr; - typedef typename implementation_defined::const_node_ptr const_node_ptr; - typedef typename implementation_defined::node_algorithms node_algorithms; - - static const bool constant_time_size = tree_type::constant_time_size; - - public: - //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &) - explicit bs_set_impl( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : tree_type(cmp, v_traits) - {} - - //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const value_compare &,const value_traits &) - template - bs_set_impl( Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : tree_type(true, b, e, cmp, v_traits) - {} - - //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&) - bs_set_impl(BOOST_RV_REF(bs_set_impl) x) - : tree_type(::boost::move(static_cast(x))) - {} - - //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&) - bs_set_impl& operator=(BOOST_RV_REF(bs_set_impl) x) - { return static_cast(tree_type::operator=(::boost::move(static_cast(x)))); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! @copydoc ::boost::intrusive::bstree::~bstree() - ~bs_set_impl(); - - //! @copydoc ::boost::intrusive::bstree::begin() - iterator begin(); - - //! @copydoc ::boost::intrusive::bstree::begin()const - const_iterator begin() const; - - //! @copydoc ::boost::intrusive::bstree::cbegin()const - const_iterator cbegin() const; - - //! @copydoc ::boost::intrusive::bstree::end() - iterator end(); - - //! @copydoc ::boost::intrusive::bstree::end()const - const_iterator end() const; - - //! @copydoc ::boost::intrusive::bstree::cend()const - const_iterator cend() const; - - //! @copydoc ::boost::intrusive::bstree::rbegin() - reverse_iterator rbegin(); - - //! @copydoc ::boost::intrusive::bstree::rbegin()const - const_reverse_iterator rbegin() const; - - //! @copydoc ::boost::intrusive::bstree::crbegin()const - const_reverse_iterator crbegin() const; - - //! @copydoc ::boost::intrusive::bstree::rend() - reverse_iterator rend(); - - //! @copydoc ::boost::intrusive::bstree::rend()const - const_reverse_iterator rend() const; - - //! @copydoc ::boost::intrusive::bstree::crend()const - const_reverse_iterator crend() const; - - //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator) - static bs_set_impl &container_from_end_iterator(iterator end_iterator); - - //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator) - static const bs_set_impl &container_from_end_iterator(const_iterator end_iterator); - - //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator) - static bs_set_impl &container_from_iterator(iterator it); - - //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator) - static const bs_set_impl &container_from_iterator(const_iterator it); - - //! @copydoc ::boost::intrusive::bstree::key_comp()const - key_compare key_comp() const; - - //! @copydoc ::boost::intrusive::bstree::value_comp()const - value_compare value_comp() const; - - //! @copydoc ::boost::intrusive::bstree::empty()const - bool empty() const; - - //! @copydoc ::boost::intrusive::bstree::size()const - size_type size() const; - - //! @copydoc ::boost::intrusive::bstree::swap - void swap(bs_set_impl& other); - - //! @copydoc ::boost::intrusive::bstree::clone_from - template - void clone_from(const bs_set_impl &src, Cloner cloner, Disposer disposer); - - #endif //#ifdef BOOST_iNTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::bstree::insert_unique(reference) - std::pair insert(reference value) - { return tree_type::insert_unique(value); } - - //! @copydoc ::boost::intrusive::bstree::insert_unique(const_iterator,reference) - iterator insert(const_iterator hint, reference value) - { return tree_type::insert_unique(hint, value); } - - //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyValueCompare,insert_commit_data&) - template - std::pair insert_check - (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) - { return tree_type::insert_unique_check(key, key_value_comp, commit_data); } - - //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyValueCompare,insert_commit_data&) - template - std::pair insert_check - (const_iterator hint, const KeyType &key - ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) - { return tree_type::insert_unique_check(hint, key, key_value_comp, commit_data); } - - //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator) - template - void insert(Iterator b, Iterator e) - { tree_type::insert_unique(b, e); } - - //! @copydoc ::boost::intrusive::bstree::insert_unique_commit - iterator insert_commit(reference value, const insert_commit_data &commit_data) - { return tree_type::insert_unique_commit(value, commit_data); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! @copydoc ::boost::intrusive::bstree::insert_before - iterator insert_before(const_iterator pos, reference value); - - //! @copydoc ::boost::intrusive::bstree::push_back - void push_back(reference value); - - //! @copydoc ::boost::intrusive::bstree::push_front - void push_front(reference value); - - //! @copydoc ::boost::intrusive::bstree::erase(const_iterator) - iterator erase(const_iterator i); - - //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator) - iterator erase(const_iterator b, const_iterator e); - - //! @copydoc ::boost::intrusive::bstree::erase(const_reference) - size_type erase(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyValueCompare) - template - size_type erase(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer) - template - iterator erase_and_dispose(const_iterator i, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer) - template - iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_reference, Disposer) - template - size_type erase_and_dispose(const_reference value, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer) - template - size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::clear - void clear(); - - //! @copydoc ::boost::intrusive::bstree::clear_and_dispose - template - void clear_and_dispose(Disposer disposer); - - #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::bstree::count(const_reference)const - size_type count(const_reference value) const - { return static_cast(this->tree_type::find(value) == this->tree_type::cend()); } - - //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const - template - size_type count(const KeyType& key, KeyValueCompare comp) const - { return static_cast(this->tree_type::find(key, comp) == this->tree_type::cend()); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference) - iterator lower_bound(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare) - template - iterator lower_bound(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const - const_iterator lower_bound(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)const - template - const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference) - iterator upper_bound(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare) - template - iterator upper_bound(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)const - const_iterator upper_bound(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)const - template - const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::find(const_reference) - iterator find(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare) - template - iterator find(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::find(const_reference)const - const_iterator find(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)const - template - const_iterator find(const KeyType& key, KeyValueCompare comp) const; - - #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::rbtree::equal_range(const_reference) - std::pair equal_range(const_reference value) - { return this->tree_type::lower_bound_range(value); } - - //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyValueCompare) - template - std::pair equal_range(const KeyType& key, KeyValueCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } - - //! @copydoc ::boost::intrusive::rbtree::equal_range(const_reference)const - std::pair - equal_range(const_reference value) const - { return this->tree_type::lower_bound_range(value); } - - //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyValueCompare)const - template - std::pair - equal_range(const KeyType& key, KeyValueCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool) - std::pair bounded_range - (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed); - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool) - template - std::pair bounded_range - (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed); - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)const - std::pair - bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const; - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const - template - std::pair bounded_range - (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const; - - //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference) - static iterator s_iterator_to(reference value); - - //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference) - static const_iterator s_iterator_to(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::iterator_to(reference) - iterator iterator_to(reference value); - - //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const - const_iterator iterator_to(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::init_node(reference) - static void init_node(reference value); - - //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance - pointer unlink_leftmost_without_rebalance(); - - //! @copydoc ::boost::intrusive::bstree::replace_node - void replace_node(iterator replace_this, reference with_this); - - //! @copydoc ::boost::intrusive::bstree::remove_node - void remove_node(reference value); - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED -}; - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -template -bool operator!= (const bs_set_impl &x, const bs_set_impl &y); - -template -bool operator>(const bs_set_impl &x, const bs_set_impl &y); - -template -bool operator<=(const bs_set_impl &x, const bs_set_impl &y); - -template -bool operator>=(const bs_set_impl &x, const bs_set_impl &y); - -template -void swap(bs_set_impl &x, bs_set_impl &y); - -#endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -//! Helper metafunction to define a \c bs_set that yields to the same type when the -//! same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_bs_set -{ - /// @cond - typedef typename pack_options - < bstree_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3, O4, O5 - #else - Options... - #endif - >::type packed_options; - - typedef typename detail::get_value_traits - ::type value_traits; - typedef typename detail::get_header_holder_type - < value_traits, typename packed_options::header_holder_type >::type header_holder_type; - - typedef bs_set_impl - < value_traits - , typename packed_options::compare - , typename packed_options::size_type - , packed_options::constant_time_size - , header_holder_type - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class bs_set - : public make_bs_set::type -{ - typedef typename make_bs_set - ::type Base; - - BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_set) - public: - typedef typename Base::value_compare value_compare; - typedef typename Base::value_traits value_traits; - typedef typename Base::iterator iterator; - typedef typename Base::const_iterator const_iterator; - - //Assert if passed value traits are compatible with the type - BOOST_STATIC_ASSERT((detail::is_same::value)); - - explicit bs_set( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(cmp, v_traits) - {} - - template - bs_set( Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(b, e, cmp, v_traits) - {} - - bs_set(BOOST_RV_REF(bs_set) x) - : Base(::boost::move(static_cast(x))) - {} - - bs_set& operator=(BOOST_RV_REF(bs_set) x) - { return static_cast(this->Base::operator=(::boost::move(static_cast(x)))); } - - static bs_set &container_from_end_iterator(iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static const bs_set &container_from_end_iterator(const_iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static bs_set &container_from_iterator(iterator it) - { return static_cast(Base::container_from_iterator(it)); } - - static const bs_set &container_from_iterator(const_iterator it) - { return static_cast(Base::container_from_iterator(it)); } -}; - -#endif - -//! The class template bs_multiset is an intrusive container, that mimics most of -//! the interface of std::multiset as described in the C++ standard. -//! -//! The template parameter \c T is the type to be managed by the container. -//! The user can specify additional options and if no options are provided -//! default options are used. -//! -//! The container supports the following options: -//! \c base_hook<>/member_hook<>/value_traits<>, -//! \c constant_time_size<>, \c size_type<> and -//! \c compare<>. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -class bs_multiset_impl -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - : public bstree_impl -#endif -{ - /// @cond - typedef bstree_impl tree_type; - - BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_multiset_impl) - typedef tree_type implementation_defined; - /// @endcond - - public: - typedef typename implementation_defined::value_type value_type; - typedef typename implementation_defined::value_traits value_traits; - typedef typename implementation_defined::pointer pointer; - typedef typename implementation_defined::const_pointer const_pointer; - typedef typename implementation_defined::reference reference; - typedef typename implementation_defined::const_reference const_reference; - typedef typename implementation_defined::difference_type difference_type; - typedef typename implementation_defined::size_type size_type; - typedef typename implementation_defined::value_compare value_compare; - typedef typename implementation_defined::key_compare key_compare; - typedef typename implementation_defined::iterator iterator; - typedef typename implementation_defined::const_iterator const_iterator; - typedef typename implementation_defined::reverse_iterator reverse_iterator; - typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator; - typedef typename implementation_defined::insert_commit_data insert_commit_data; - typedef typename implementation_defined::node_traits node_traits; - typedef typename implementation_defined::node node; - typedef typename implementation_defined::node_ptr node_ptr; - typedef typename implementation_defined::const_node_ptr const_node_ptr; - typedef typename implementation_defined::node_algorithms node_algorithms; - - static const bool constant_time_size = tree_type::constant_time_size; - - public: - //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &) - explicit bs_multiset_impl( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : tree_type(cmp, v_traits) - {} - - //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const value_compare &,const value_traits &) - template - bs_multiset_impl( Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : tree_type(false, b, e, cmp, v_traits) - {} - - //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&) - bs_multiset_impl(BOOST_RV_REF(bs_multiset_impl) x) - : tree_type(::boost::move(static_cast(x))) - {} - - //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&) - bs_multiset_impl& operator=(BOOST_RV_REF(bs_multiset_impl) x) - { return static_cast(tree_type::operator=(::boost::move(static_cast(x)))); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! @copydoc ::boost::intrusive::bstree::~bstree() - ~bs_multiset_impl(); - - //! @copydoc ::boost::intrusive::bstree::begin() - iterator begin(); - - //! @copydoc ::boost::intrusive::bstree::begin()const - const_iterator begin() const; - - //! @copydoc ::boost::intrusive::bstree::cbegin()const - const_iterator cbegin() const; - - //! @copydoc ::boost::intrusive::bstree::end() - iterator end(); - - //! @copydoc ::boost::intrusive::bstree::end()const - const_iterator end() const; - - //! @copydoc ::boost::intrusive::bstree::cend()const - const_iterator cend() const; - - //! @copydoc ::boost::intrusive::bstree::rbegin() - reverse_iterator rbegin(); - - //! @copydoc ::boost::intrusive::bstree::rbegin()const - const_reverse_iterator rbegin() const; - - //! @copydoc ::boost::intrusive::bstree::crbegin()const - const_reverse_iterator crbegin() const; - - //! @copydoc ::boost::intrusive::bstree::rend() - reverse_iterator rend(); - - //! @copydoc ::boost::intrusive::bstree::rend()const - const_reverse_iterator rend() const; - - //! @copydoc ::boost::intrusive::bstree::crend()const - const_reverse_iterator crend() const; - - //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator) - static bs_multiset_impl &container_from_end_iterator(iterator end_iterator); - - //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator) - static const bs_multiset_impl &container_from_end_iterator(const_iterator end_iterator); - - //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator) - static bs_multiset_impl &container_from_iterator(iterator it); - - //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator) - static const bs_multiset_impl &container_from_iterator(const_iterator it); - - //! @copydoc ::boost::intrusive::bstree::key_comp()const - key_compare key_comp() const; - - //! @copydoc ::boost::intrusive::bstree::value_comp()const - value_compare value_comp() const; - - //! @copydoc ::boost::intrusive::bstree::empty()const - bool empty() const; - - //! @copydoc ::boost::intrusive::bstree::size()const - size_type size() const; - - //! @copydoc ::boost::intrusive::bstree::swap - void swap(bs_multiset_impl& other); - - //! @copydoc ::boost::intrusive::bstree::clone_from - template - void clone_from(const bs_multiset_impl &src, Cloner cloner, Disposer disposer); - - #endif //#ifdef BOOST_iNTRUSIVE_DOXYGEN_INVOKED - - //! @copydoc ::boost::intrusive::bstree::insert_equal(reference) - iterator insert(reference value) - { return tree_type::insert_equal(value); } - - //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference) - iterator insert(const_iterator hint, reference value) - { return tree_type::insert_equal(hint, value); } - - //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator) - template - void insert(Iterator b, Iterator e) - { tree_type::insert_equal(b, e); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! @copydoc ::boost::intrusive::bstree::insert_before - iterator insert_before(const_iterator pos, reference value); - - //! @copydoc ::boost::intrusive::bstree::push_back - void push_back(reference value); - - //! @copydoc ::boost::intrusive::bstree::push_front - void push_front(reference value); - - //! @copydoc ::boost::intrusive::bstree::erase(const_iterator) - iterator erase(const_iterator i); - - //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator) - iterator erase(const_iterator b, const_iterator e); - - //! @copydoc ::boost::intrusive::bstree::erase(const_reference) - size_type erase(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyValueCompare) - template - size_type erase(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer) - template - iterator erase_and_dispose(const_iterator i, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer) - template - iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_reference, Disposer) - template - size_type erase_and_dispose(const_reference value, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer) - template - size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::clear - void clear(); - - //! @copydoc ::boost::intrusive::bstree::clear_and_dispose - template - void clear_and_dispose(Disposer disposer); - - //! @copydoc ::boost::intrusive::bstree::count(const_reference)const - size_type count(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const - template - size_type count(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference) - iterator lower_bound(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare) - template - iterator lower_bound(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const - const_iterator lower_bound(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)const - template - const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference) - iterator upper_bound(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare) - template - iterator upper_bound(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)const - const_iterator upper_bound(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)const - template - const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::find(const_reference) - iterator find(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare) - template - iterator find(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::find(const_reference)const - const_iterator find(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)const - template - const_iterator find(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference) - std::pair equal_range(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare) - template - std::pair equal_range(const KeyType& key, KeyValueCompare comp); - - //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)const - std::pair - equal_range(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)const - template - std::pair - equal_range(const KeyType& key, KeyValueCompare comp) const; - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool) - std::pair bounded_range - (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed); - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool) - template - std::pair bounded_range - (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed); - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)const - std::pair - bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const; - - //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const - template - std::pair bounded_range - (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const; - - //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference) - static iterator s_iterator_to(reference value); - - //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference) - static const_iterator s_iterator_to(const_reference value); - - //! @copydoc ::boost::intrusive::bstree::iterator_to(reference) - iterator iterator_to(reference value); - - //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const - const_iterator iterator_to(const_reference value) const; - - //! @copydoc ::boost::intrusive::bstree::init_node(reference) - static void init_node(reference value); - - //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance - pointer unlink_leftmost_without_rebalance(); - - //! @copydoc ::boost::intrusive::bstree::replace_node - void replace_node(iterator replace_this, reference with_this); - - //! @copydoc ::boost::intrusive::bstree::remove_node - void remove_node(reference value); - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED -}; - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -template -bool operator!= (const bs_multiset_impl &x, const bs_multiset_impl &y); - -template -bool operator>(const bs_multiset_impl &x, const bs_multiset_impl &y); - -template -bool operator<=(const bs_multiset_impl &x, const bs_multiset_impl &y); - -template -bool operator>=(const bs_multiset_impl &x, const bs_multiset_impl &y); - -template -void swap(bs_multiset_impl &x, bs_multiset_impl &y); - -#endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -//! Helper metafunction to define a \c bs_multiset that yields to the same type when the -//! same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_bs_multiset -{ - /// @cond - typedef typename pack_options - < bstree_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3, O4, O5 - #else - Options... - #endif - >::type packed_options; - - typedef typename detail::get_value_traits - ::type value_traits; - typedef typename detail::get_header_holder_type - < value_traits, typename packed_options::header_holder_type >::type header_holder_type; - - typedef bs_multiset_impl - < value_traits - , typename packed_options::compare - , typename packed_options::size_type - , packed_options::constant_time_size - , header_holder_type - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class bs_multiset - : public make_bs_multiset::type -{ - typedef typename make_bs_multiset::type Base; - - BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_multiset) - - public: - typedef typename Base::value_compare value_compare; - typedef typename Base::value_traits value_traits; - typedef typename Base::iterator iterator; - typedef typename Base::const_iterator const_iterator; - - //Assert if passed value traits are compatible with the type - BOOST_STATIC_ASSERT((detail::is_same::value)); - - explicit bs_multiset( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(cmp, v_traits) - {} - - template - bs_multiset( Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(b, e, cmp, v_traits) - {} - - bs_multiset(BOOST_RV_REF(bs_multiset) x) - : Base(::boost::move(static_cast(x))) - {} - - bs_multiset& operator=(BOOST_RV_REF(bs_multiset) x) - { return static_cast(this->Base::operator=(::boost::move(static_cast(x)))); } - - static bs_multiset &container_from_end_iterator(iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static const bs_multiset &container_from_end_iterator(const_iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static bs_multiset &container_from_iterator(iterator it) - { return static_cast(Base::container_from_iterator(it)); } - - static const bs_multiset &container_from_iterator(const_iterator it) - { return static_cast(Base::container_from_iterator(it)); } -}; - -#endif - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_BS_SET_HPP diff --git a/boost/intrusive/bs_set_hook.hpp b/boost/intrusive/bs_set_hook.hpp deleted file mode 100644 index cb5af30..0000000 --- a/boost/intrusive/bs_set_hook.hpp +++ /dev/null @@ -1,286 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_BS_SET_HOOK_HPP -#define BOOST_INTRUSIVE_BS_SET_HOOK_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -//! Helper metafunction to define a \c bs_set_base_hook that yields to the same -//! type when the same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_bs_set_base_hook -{ - /// @cond - typedef typename pack_options - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - < hook_defaults, O1, O2, O3> - #else - < hook_defaults, Options...> - #endif - ::type packed_options; - - typedef generic_hook - < bstree_algorithms > - , typename packed_options::tag - , packed_options::link_mode - , BsTreeBaseHookId - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -//! Derive a class from bs_set_base_hook in order to store objects in -//! in a bs_set/bs_multiset. bs_set_base_hook holds the data necessary to maintain -//! the bs_set/bs_multiset and provides an appropriate value_traits class for bs_set/bs_multiset. -//! -//! The hook admits the following options: \c tag<>, \c void_pointer<>, -//! \c link_mode<>. -//! -//! \c tag<> defines a tag to identify the node. -//! The same tag value can be used in different classes, but if a class is -//! derived from more than one \c list_base_hook, then each \c list_base_hook needs its -//! unique tag. -//! -//! \c void_pointer<> is the pointer type that will be used internally in the hook -//! and the container configured to use this hook. -//! -//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, -//! \c auto_unlink or \c safe_link). -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class bs_set_base_hook - : public make_bs_set_base_hook - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - - #else - - #endif - ::type - -{ - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - public: - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. - //! - //! Throws: Nothing. - bs_set_base_hook(); - - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing a copy-constructor - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - bs_set_base_hook(const bs_set_base_hook& ); - - //! Effects: Empty function. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing an assignment operator - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - bs_set_base_hook& operator=(const bs_set_base_hook& ); - - //! Effects: If link_mode is \c normal_link, the destructor does - //! nothing (ie. no code is generated). If link_mode is \c safe_link and the - //! object is stored in a set an assertion is raised. If link_mode is - //! \c auto_unlink and \c is_linked() is true, the node is unlinked. - //! - //! Throws: Nothing. - ~bs_set_base_hook(); - - //! Effects: Swapping two nodes swaps the position of the elements - //! related to those nodes in one or two containers. That is, if the node - //! this is part of the element e1, the node x is part of the element e2 - //! and both elements are included in the containers s1 and s2, then after - //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 - //! at the position of e1. If one element is not in a container, then - //! after the swap-operation the other element is not in a container. - //! Iterators to e1 and e2 related to those nodes are invalidated. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - void swap_nodes(bs_set_base_hook &other); - - //! Precondition: link_mode must be \c safe_link or \c auto_unlink. - //! - //! Returns: true, if the node belongs to a container, false - //! otherwise. This function can be used to test whether \c set::iterator_to - //! will return a valid iterator. - //! - //! Complexity: Constant - bool is_linked() const; - - //! Effects: Removes the node if it's inserted in a container. - //! This function is only allowed if link_mode is \c auto_unlink. - //! - //! Throws: Nothing. - void unlink(); - #endif -}; - -//! Helper metafunction to define a \c bs_set_member_hook that yields to the same -//! type when the same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_bs_set_member_hook -{ - /// @cond - typedef typename pack_options - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - < hook_defaults, O1, O2, O3> - #else - < hook_defaults, Options...> - #endif - - ::type packed_options; - - typedef generic_hook - < bstree_algorithms > - , member_tag - , packed_options::link_mode - , NoBaseHookId - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -//! Put a public data member bs_set_member_hook in order to store objects of this class in -//! a bs_set/bs_multiset. bs_set_member_hook holds the data necessary for maintaining the -//! bs_set/bs_multiset and provides an appropriate value_traits class for bs_set/bs_multiset. -//! -//! The hook admits the following options: \c void_pointer<>, \c link_mode<>. -//! -//! \c void_pointer<> is the pointer type that will be used internally in the hook -//! and the container configured to use this hook. -//! -//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, -//! \c auto_unlink or \c safe_link). -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class bs_set_member_hook - : public make_bs_set_member_hook - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - - #else - - #endif - ::type -{ - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - public: - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. - //! - //! Throws: Nothing. - bs_set_member_hook(); - - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing a copy-constructor - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - bs_set_member_hook(const bs_set_member_hook& ); - - //! Effects: Empty function. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing an assignment operator - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - bs_set_member_hook& operator=(const bs_set_member_hook& ); - - //! Effects: If link_mode is \c normal_link, the destructor does - //! nothing (ie. no code is generated). If link_mode is \c safe_link and the - //! object is stored in a set an assertion is raised. If link_mode is - //! \c auto_unlink and \c is_linked() is true, the node is unlinked. - //! - //! Throws: Nothing. - ~bs_set_member_hook(); - - //! Effects: Swapping two nodes swaps the position of the elements - //! related to those nodes in one or two containers. That is, if the node - //! this is part of the element e1, the node x is part of the element e2 - //! and both elements are included in the containers s1 and s2, then after - //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 - //! at the position of e1. If one element is not in a container, then - //! after the swap-operation the other element is not in a container. - //! Iterators to e1 and e2 related to those nodes are invalidated. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - void swap_nodes(bs_set_member_hook &other); - - //! Precondition: link_mode must be \c safe_link or \c auto_unlink. - //! - //! Returns: true, if the node belongs to a container, false - //! otherwise. This function can be used to test whether \c set::iterator_to - //! will return a valid iterator. - //! - //! Complexity: Constant - bool is_linked() const; - - //! Effects: Removes the node if it's inserted in a container. - //! This function is only allowed if link_mode is \c auto_unlink. - //! - //! Throws: Nothing. - void unlink(); - #endif -}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_BS_SET_HOOK_HPP diff --git a/boost/intrusive/bstree.hpp b/boost/intrusive/bstree.hpp deleted file mode 100644 index 44b02bb..0000000 --- a/boost/intrusive/bstree.hpp +++ /dev/null @@ -1,2177 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2013-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_INTRUSIVE_BSTREE_HPP -#define BOOST_INTRUSIVE_BSTREE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include //pair,lexicographical_compare -#include //swap -#include //size_t... -#include //less, equal_to - - -namespace boost { -namespace intrusive { - -/// @cond - -struct default_bstree_hook_applier -{ template struct apply{ typedef typename T::default_bstree_hook type; }; }; - -template<> -struct is_default_hook_tag -{ static const bool value = true; }; - -struct bstree_defaults -{ - typedef default_bstree_hook_applier proto_value_traits; - static const bool constant_time_size = true; - typedef std::size_t size_type; - typedef void compare; - static const bool floating_point = true; //For sgtree - typedef void priority; //For treap - typedef void header_holder_type; -}; - -template -struct bstbase3 -{ - typedef ValueTraits value_traits; - typedef typename value_traits::node_traits node_traits; - typedef typename node_traits::node node_type; - typedef typename get_algo::type node_algorithms; - typedef typename node_traits::node_ptr node_ptr; - typedef typename node_traits::const_node_ptr const_node_ptr; - typedef tree_iterator iterator; - typedef tree_iterator const_iterator; - typedef boost::intrusive::detail::reverse_iterator reverse_iterator; - typedef boost::intrusive::detail::reverse_iterator const_reverse_iterator; - typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::pointer) pointer; - typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::const_pointer) const_pointer; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::element_type) value_type; - typedef BOOST_INTRUSIVE_IMPDEF(value_type) key_type; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::reference) reference; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::reference) const_reference; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::difference_type) difference_type; - typedef HeaderHolder header_holder_type; - - static const bool safemode_or_autounlink = is_safe_autounlink::value; - static const bool stateful_value_traits = detail::is_stateful_value_traits::value; - static const bool has_container_from_iterator = - detail::is_same< header_holder_type, detail::default_header_holder< node_traits > >::value; - - struct holder_t : public ValueTraits - { - explicit holder_t(const ValueTraits &vtraits) - : ValueTraits(vtraits) - {} - header_holder_type root; - } holder; - - static bstbase3 &get_tree_base_from_end_iterator(const const_iterator &end_iterator) - { - BOOST_STATIC_ASSERT(has_container_from_iterator); - node_ptr p = end_iterator.pointed_node(); - header_holder_type* h = header_holder_type::get_holder(p); - holder_t *holder = get_parent_from_member(h, &holder_t::root); - bstbase3 *base = get_parent_from_member (holder, &bstbase3::holder); - return *base; - } - - bstbase3(const ValueTraits &vtraits) - : holder(vtraits) - { - node_algorithms::init_header(this->header_ptr()); - } - - node_ptr header_ptr() - { return holder.root.get_node(); } - - const_node_ptr header_ptr() const - { return holder.root.get_node(); } - - const value_traits &get_value_traits() const - { return this->holder; } - - value_traits &get_value_traits() - { return this->holder; } - - typedef typename boost::intrusive::value_traits_pointers - ::const_value_traits_ptr const_value_traits_ptr; - - const_value_traits_ptr priv_value_traits_ptr() const - { return pointer_traits::pointer_to(this->get_value_traits()); } - - iterator begin() - { return iterator(node_algorithms::begin_node(this->header_ptr()), this->priv_value_traits_ptr()); } - - const_iterator begin() const - { return cbegin(); } - - const_iterator cbegin() const - { return const_iterator(node_algorithms::begin_node(this->header_ptr()), this->priv_value_traits_ptr()); } - - iterator end() - { return iterator(node_algorithms::end_node(this->header_ptr()), this->priv_value_traits_ptr()); } - - const_iterator end() const - { return cend(); } - - const_iterator cend() const - { return const_iterator(node_algorithms::end_node(this->header_ptr()), this->priv_value_traits_ptr()); } - - iterator root() - { return iterator(node_algorithms::root_node(this->header_ptr()), this->priv_value_traits_ptr()); } - - const_iterator root() const - { return croot(); } - - const_iterator croot() const - { return const_iterator(node_algorithms::root_node(this->header_ptr()), this->priv_value_traits_ptr()); } - - reverse_iterator rbegin() - { return reverse_iterator(end()); } - - const_reverse_iterator rbegin() const - { return const_reverse_iterator(end()); } - - const_reverse_iterator crbegin() const - { return const_reverse_iterator(end()); } - - reverse_iterator rend() - { return reverse_iterator(begin()); } - - const_reverse_iterator rend() const - { return const_reverse_iterator(begin()); } - - const_reverse_iterator crend() const - { return const_reverse_iterator(begin()); } - - void replace_node(iterator replace_this, reference with_this) - { - node_algorithms::replace_node( get_value_traits().to_node_ptr(*replace_this) - , this->header_ptr() - , get_value_traits().to_node_ptr(with_this)); - if(safemode_or_autounlink) - node_algorithms::init(replace_this.pointed_node()); - } - - void rebalance() - { node_algorithms::rebalance(this->header_ptr()); } - - iterator rebalance_subtree(iterator root) - { return iterator(node_algorithms::rebalance_subtree(root.pointed_node()), this->priv_value_traits_ptr()); } - - static iterator s_iterator_to(reference value) - { - BOOST_STATIC_ASSERT((!stateful_value_traits)); - return iterator (value_traits::to_node_ptr(value), const_value_traits_ptr()); - } - - static const_iterator s_iterator_to(const_reference value) - { - BOOST_STATIC_ASSERT((!stateful_value_traits)); - return const_iterator (value_traits::to_node_ptr(*pointer_traits::const_cast_from(pointer_traits::pointer_to(value))), const_value_traits_ptr()); - } - - iterator iterator_to(reference value) - { return iterator (this->get_value_traits().to_node_ptr(value), this->priv_value_traits_ptr()); } - - const_iterator iterator_to(const_reference value) const - { return const_iterator (this->get_value_traits().to_node_ptr(*pointer_traits::const_cast_from(pointer_traits::pointer_to(value))), this->priv_value_traits_ptr()); } - - static void init_node(reference value) - { node_algorithms::init(value_traits::to_node_ptr(value)); } - -}; - -template -struct get_less -{ - typedef Less type; -}; - -template -struct get_less -{ - typedef ::std::less type; -}; - -template -struct bstbase2 - //Put the (possibly empty) functor in the first position to get EBO in MSVC - : public detail::ebo_functor_holder::type> - , public bstbase3 -{ - typedef bstbase3 treeheader_t; - typedef typename treeheader_t::value_traits value_traits; - typedef typename treeheader_t::node_algorithms node_algorithms; - typedef typename get_less - < VoidOrKeyComp, typename value_traits::value_type>::type value_compare; - typedef BOOST_INTRUSIVE_IMPDEF(value_compare) key_compare; - typedef typename treeheader_t::iterator iterator; - typedef typename treeheader_t::const_iterator const_iterator; - typedef typename treeheader_t::node_ptr node_ptr; - typedef typename treeheader_t::const_node_ptr const_node_ptr; - - bstbase2(const value_compare &comp, const ValueTraits &vtraits) - : detail::ebo_functor_holder(comp), treeheader_t(vtraits) - {} - - const value_compare &comp() const - { return this->get(); } - - value_compare &comp() - { return this->get(); } - - typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::pointer) pointer; - typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::const_pointer) const_pointer; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::element_type) value_type; - typedef BOOST_INTRUSIVE_IMPDEF(value_type) key_type; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::reference) reference; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::reference) const_reference; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::difference_type) difference_type; - typedef typename node_algorithms::insert_commit_data insert_commit_data; - - value_compare value_comp() const - { return this->comp(); } - - key_compare key_comp() const - { return this->comp(); } - - //lower_bound - iterator lower_bound(const_reference value) - { return this->lower_bound(value, this->comp()); } - - const_iterator lower_bound(const_reference value) const - { return this->lower_bound(value, this->comp()); } - - template - iterator lower_bound(const KeyType &key, KeyValueCompare comp) - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - return iterator(node_algorithms::lower_bound - (this->header_ptr(), key, key_node_comp), this->priv_value_traits_ptr()); - } - - template - const_iterator lower_bound(const KeyType &key, KeyValueCompare comp) const - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - return const_iterator(node_algorithms::lower_bound - (this->header_ptr(), key, key_node_comp), this->priv_value_traits_ptr()); - } - - //upper_bound - iterator upper_bound(const_reference value) - { return this->upper_bound(value, this->comp()); } - - template - iterator upper_bound(const KeyType &key, KeyValueCompare comp) - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - return iterator(node_algorithms::upper_bound - (this->header_ptr(), key, key_node_comp), this->priv_value_traits_ptr()); - } - - const_iterator upper_bound(const_reference value) const - { return this->upper_bound(value, this->comp()); } - - template - const_iterator upper_bound(const KeyType &key, KeyValueCompare comp) const - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - return const_iterator(node_algorithms::upper_bound - (this->header_ptr(), key, key_node_comp), this->priv_value_traits_ptr()); - } - - //find - iterator find(const_reference value) - { return this->find(value, this->comp()); } - - template - iterator find(const KeyType &key, KeyValueCompare comp) - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - return iterator - (node_algorithms::find(this->header_ptr(), key, key_node_comp), this->priv_value_traits_ptr()); - } - - const_iterator find(const_reference value) const - { return this->find(value, this->comp()); } - - template - const_iterator find(const KeyType &key, KeyValueCompare comp) const - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - return const_iterator - (node_algorithms::find(this->header_ptr(), key, key_node_comp), this->priv_value_traits_ptr()); - } - - //equal_range - std::pair equal_range(const_reference value) - { return this->equal_range(value, this->comp()); } - - template - std::pair equal_range(const KeyType &key, KeyValueCompare comp) - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - std::pair ret - (node_algorithms::equal_range(this->header_ptr(), key, key_node_comp)); - return std::pair( iterator(ret.first, this->priv_value_traits_ptr()) - , iterator(ret.second, this->priv_value_traits_ptr())); - } - - std::pair - equal_range(const_reference value) const - { return this->equal_range(value, this->comp()); } - - template - std::pair - equal_range(const KeyType &key, KeyValueCompare comp) const - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - std::pair ret - (node_algorithms::equal_range(this->header_ptr(), key, key_node_comp)); - return std::pair( const_iterator(ret.first, this->priv_value_traits_ptr()) - , const_iterator(ret.second, this->priv_value_traits_ptr())); - } - - //lower_bound_range - std::pair lower_bound_range(const_reference value) - { return this->lower_bound_range(value, this->comp()); } - - template - std::pair lower_bound_range(const KeyType &key, KeyValueCompare comp) - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - std::pair ret - (node_algorithms::lower_bound_range(this->header_ptr(), key, key_node_comp)); - return std::pair( iterator(ret.first, this->priv_value_traits_ptr()) - , iterator(ret.second, this->priv_value_traits_ptr())); - } - - std::pair - lower_bound_range(const_reference value) const - { return this->lower_bound_range(value, this->comp()); } - - template - std::pair - lower_bound_range(const KeyType &key, KeyValueCompare comp) const - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - std::pair ret - (node_algorithms::lower_bound_range(this->header_ptr(), key, key_node_comp)); - return std::pair( const_iterator(ret.first, this->priv_value_traits_ptr()) - , const_iterator(ret.second, this->priv_value_traits_ptr())); - } - - //bounded_range - std::pair bounded_range - (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) - { return this->bounded_range(lower_value, upper_value, this->comp(), left_closed, right_closed); } - - template - std::pair bounded_range - (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - std::pair ret - (node_algorithms::bounded_range - (this->header_ptr(), lower_key, upper_key, key_node_comp, left_closed, right_closed)); - return std::pair( iterator(ret.first, this->priv_value_traits_ptr()) - , iterator(ret.second, this->priv_value_traits_ptr())); - } - - std::pair bounded_range - (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const - { return this->bounded_range(lower_value, upper_value, this->comp(), left_closed, right_closed); } - - template - std::pair bounded_range - (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const - { - detail::key_nodeptr_comp - key_node_comp(comp, &this->get_value_traits()); - std::pair ret - (node_algorithms::bounded_range - (this->header_ptr(), lower_key, upper_key, key_node_comp, left_closed, right_closed)); - return std::pair( const_iterator(ret.first, this->priv_value_traits_ptr()) - , const_iterator(ret.second, this->priv_value_traits_ptr())); - } - - //insert_unique_check - template - std::pair insert_unique_check - (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) - { - detail::key_nodeptr_comp - ocomp(key_value_comp, &this->get_value_traits()); - std::pair ret = - (node_algorithms::insert_unique_check - (this->header_ptr(), key, ocomp, commit_data)); - return std::pair(iterator(ret.first, this->priv_value_traits_ptr()), ret.second); - } - - template - std::pair insert_unique_check - (const_iterator hint, const KeyType &key - ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) - { - detail::key_nodeptr_comp - ocomp(key_value_comp, &this->get_value_traits()); - std::pair ret = - (node_algorithms::insert_unique_check - (this->header_ptr(), hint.pointed_node(), key, ocomp, commit_data)); - return std::pair(iterator(ret.first, this->priv_value_traits_ptr()), ret.second); - } -}; - -//Due to MSVC's EBO implementation, to save space and maintain the ABI, we must put the non-empty size member -//in the first position, but if size is not going to be stored then we'll use an specialization -//that doesn't inherit from size_holder -template -struct bstbase_hack - : public detail::size_holder - , public bstbase2 < ValueTraits, VoidOrKeyComp, AlgoType, HeaderHolder> -{ - typedef bstbase2< ValueTraits, VoidOrKeyComp, AlgoType, HeaderHolder> base_type; - typedef typename base_type::value_compare value_compare; - typedef SizeType size_type; - typedef typename base_type::node_traits node_traits; - typedef typename get_algo - ::type algo_type; - - bstbase_hack(const value_compare & comp, const ValueTraits &vtraits) - : base_type(comp, vtraits) - { - this->sz_traits().set_size(size_type(0)); - } - - typedef detail::size_holder size_traits; - - size_traits &sz_traits() - { return static_cast(*this); } - - const size_traits &sz_traits() const - { return static_cast(*this); } -}; - -//Specialization for ConstantTimeSize == false -template -struct bstbase_hack - : public bstbase2 < ValueTraits, VoidOrKeyComp, AlgoType, HeaderHolder> -{ - typedef bstbase2< ValueTraits, VoidOrKeyComp, AlgoType, HeaderHolder> base_type; - typedef typename base_type::value_compare value_compare; - bstbase_hack(const value_compare & comp, const ValueTraits &vtraits) - : base_type(comp, vtraits) - {} - - typedef detail::size_holder size_traits; - - size_traits &sz_traits() - { return s_size_traits; } - - const size_traits &sz_traits() const - { return s_size_traits; } - - static size_traits s_size_traits; -}; - -template -detail::size_holder bstbase_hack::s_size_traits; - -//This class will -template -struct bstbase - : public bstbase_hack< ValueTraits, VoidOrKeyComp, ConstantTimeSize, SizeType, AlgoType, HeaderHolder> -{ - typedef bstbase_hack< ValueTraits, VoidOrKeyComp, ConstantTimeSize, SizeType, AlgoType, HeaderHolder> base_type; - typedef ValueTraits value_traits; - typedef typename base_type::value_compare value_compare; - typedef value_compare key_compare; - typedef typename base_type::const_reference const_reference; - typedef typename base_type::reference reference; - typedef typename base_type::iterator iterator; - typedef typename base_type::const_iterator const_iterator; - typedef typename base_type::node_traits node_traits; - typedef typename get_algo - ::type node_algorithms; - typedef SizeType size_type; - - bstbase(const value_compare & comp, const ValueTraits &vtraits) - : base_type(comp, vtraits) - {} - - //Detach all inserted nodes. This will add exception safety to bstree_impl - //constructors inserting elements. - ~bstbase() - { - if(is_safe_autounlink::value){ - node_algorithms::clear_and_dispose - ( this->header_ptr() - , detail::node_disposer - (detail::null_disposer(), &this->get_value_traits())); - node_algorithms::init(this->header_ptr()); - } - } -}; - - -/// @endcond - -//! The class template bstree is an unbalanced intrusive binary search tree -//! container. The no-throw guarantee holds only, if the value_compare object -//! doesn't throw. -//! -//! The complexity guarantees only hold if the tree is balanced, logarithmic -//! complexity would increase to linear if the tree is totally unbalanced. -//! -//! The template parameter \c T is the type to be managed by the container. -//! The user can specify additional options and if no options are provided -//! default options are used. -//! -//! The container supports the following options: -//! \c base_hook<>/member_hook<>/value_traits<>, -//! \c constant_time_size<>, \c size_type<> and -//! \c compare<>. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -class bstree_impl - : public bstbase -{ - public: - /// @cond - typedef bstbase data_type; - typedef tree_iterator iterator_type; - typedef tree_iterator const_iterator_type; - /// @endcond - - typedef BOOST_INTRUSIVE_IMPDEF(ValueTraits) value_traits; - typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::pointer) pointer; - typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::const_pointer) const_pointer; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::element_type) value_type; - typedef BOOST_INTRUSIVE_IMPDEF(value_type) key_type; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::reference) reference; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::reference) const_reference; - typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits::difference_type) difference_type; - typedef BOOST_INTRUSIVE_IMPDEF(SizeType) size_type; - typedef BOOST_INTRUSIVE_IMPDEF(typename data_type::value_compare) value_compare; - typedef BOOST_INTRUSIVE_IMPDEF(value_compare) key_compare; - typedef BOOST_INTRUSIVE_IMPDEF(iterator_type) iterator; - typedef BOOST_INTRUSIVE_IMPDEF(const_iterator_type) const_iterator; - typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::detail::reverse_iterator) reverse_iterator; - typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::detail::reverse_iterator) const_reverse_iterator; - typedef BOOST_INTRUSIVE_IMPDEF(typename value_traits::node_traits) node_traits; - typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::node) node; - typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::node_ptr) node_ptr; - typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::const_node_ptr) const_node_ptr; - /// @cond - typedef typename get_algo::type algo_type; - /// @endcond - typedef BOOST_INTRUSIVE_IMPDEF(algo_type) node_algorithms; - - static const bool constant_time_size = ConstantTimeSize; - static const bool stateful_value_traits = detail::is_stateful_value_traits::value; - /// @cond - private: - - //noncopyable - BOOST_MOVABLE_BUT_NOT_COPYABLE(bstree_impl) - - static const bool safemode_or_autounlink = is_safe_autounlink::value; - - //Constant-time size is incompatible with auto-unlink hooks! - BOOST_STATIC_ASSERT(!(constant_time_size && ((int)value_traits::link_mode == (int)auto_unlink))); - - - protected: - - - /// @endcond - - public: - - typedef typename node_algorithms::insert_commit_data insert_commit_data; - - //! Effects: Constructs an empty container. - //! - //! Complexity: Constant. - //! - //! Throws: If value_traits::node_traits::node - //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) - //! or the copy constructor of the value_compare object throws. Basic guarantee. - explicit bstree_impl( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : data_type(cmp, v_traits) - {} - - //! Requires: Dereferencing iterator must yield an lvalue of type value_type. - //! cmp must be a comparison function that induces a strict weak ordering. - //! - //! Effects: Constructs an empty container and inserts elements from - //! [b, e). - //! - //! Complexity: Linear in N if [b, e) is already sorted using - //! comp and otherwise N * log N, where N is the distance between first and last. - //! - //! Throws: If value_traits::node_traits::node - //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) - //! or the copy constructor/operator() of the value_compare object throws. Basic guarantee. - template - bstree_impl( bool unique, Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : data_type(cmp, v_traits) - { - //bstbase releases elements in case of exceptions - if(unique) - this->insert_unique(b, e); - else - this->insert_equal(b, e); - } - - //! Effects: to-do - //! - bstree_impl(BOOST_RV_REF(bstree_impl) x) - : data_type(::boost::move(x.comp()), ::boost::move(x.get_value_traits())) - { - this->swap(x); - } - - //! Effects: to-do - //! - bstree_impl& operator=(BOOST_RV_REF(bstree_impl) x) - { this->swap(x); return *this; } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - //! Effects: Detaches all elements from this. The objects in the set - //! are not deleted (i.e. no destructors are called), but the nodes according to - //! the value_traits template parameter are reinitialized and thus can be reused. - //! - //! Complexity: Linear to elements contained in *this. - //! - //! Throws: Nothing. - ~bstree_impl() - {} - - //! Effects: Returns an iterator pointing to the beginning of the container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - iterator begin(); - - //! Effects: Returns a const_iterator pointing to the beginning of the container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_iterator begin() const; - - //! Effects: Returns a const_iterator pointing to the beginning of the container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_iterator cbegin() const; - - //! Effects: Returns an iterator pointing to the end of the container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - iterator end(); - - //! Effects: Returns a const_iterator pointing to the end of the container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_iterator end() const; - - //! Effects: Returns a const_iterator pointing to the end of the container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_iterator cend() const; - - //! Effects: Returns a reverse_iterator pointing to the beginning of the - //! reversed container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - reverse_iterator rbegin(); - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_reverse_iterator rbegin() const; - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_reverse_iterator crbegin() const; - - //! Effects: Returns a reverse_iterator pointing to the end - //! of the reversed container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - reverse_iterator rend(); - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_reverse_iterator rend() const; - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed container. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_reverse_iterator crend() const; - - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! Precondition: end_iterator must be a valid end iterator - //! of the container. - //! - //! Effects: Returns a const reference to the container associated to the end iterator - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - static bstree_impl &container_from_end_iterator(iterator end_iterator) - { - return static_cast - (data_type::get_tree_base_from_end_iterator(end_iterator)); - } - - //! Precondition: end_iterator must be a valid end const_iterator - //! of the container. - //! - //! Effects: Returns a const reference to the container associated to the iterator - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - static const bstree_impl &container_from_end_iterator(const_iterator end_iterator) - { - return static_cast - (data_type::get_tree_base_from_end_iterator(end_iterator)); - } - - //! Precondition: it must be a valid iterator - //! of the container. - //! - //! Effects: Returns a const reference to the container associated to the iterator - //! - //! Throws: Nothing. - //! - //! Complexity: Logarithmic. - static bstree_impl &container_from_iterator(iterator it) - { return container_from_end_iterator(it.end_iterator_from_it()); } - - //! Precondition: it must be a valid end const_iterator - //! of container. - //! - //! Effects: Returns a const reference to the container associated to the end iterator - //! - //! Throws: Nothing. - //! - //! Complexity: Logarithmic. - static const bstree_impl &container_from_iterator(const_iterator it) - { return container_from_end_iterator(it.end_iterator_from_it()); } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! Effects: Returns the key_compare object used by the container. - //! - //! Complexity: Constant. - //! - //! Throws: If value_compare copy-constructor throws. - key_compare key_comp() const; - - //! Effects: Returns the value_compare object used by the container. - //! - //! Complexity: Constant. - //! - //! Throws: If value_compare copy-constructor throws. - value_compare value_comp() const; - - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! Effects: Returns true if the container is empty. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - bool empty() const - { - if(ConstantTimeSize){ - return !this->data_type::sz_traits().get_size(); - } - else{ - return algo_type::unique(this->header_ptr()); - } - } - - //! Effects: Returns the number of elements stored in the container. - //! - //! Complexity: Linear to elements contained in *this - //! if constant-time size option is disabled. Constant time otherwise. - //! - //! Throws: Nothing. - size_type size() const - { - if(constant_time_size) - return this->sz_traits().get_size(); - else{ - return (size_type)node_algorithms::size(this->header_ptr()); - } - } - - //! Effects: Swaps the contents of two containers. - //! - //! Complexity: Constant. - //! - //! Throws: If the comparison functor's swap call throws. - void swap(bstree_impl& other) - { - //This can throw - using std::swap; - swap(this->comp(), this->comp()); - //These can't throw - node_algorithms::swap_tree(this->header_ptr(), node_ptr(other.header_ptr())); - if(constant_time_size){ - size_type backup = this->sz_traits().get_size(); - this->sz_traits().set_size(other.sz_traits().get_size()); - other.sz_traits().set_size(backup); - } - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! Cloner should yield to nodes equivalent to the original nodes. - //! - //! Effects: Erases all the elements from *this - //! calling Disposer::operator()(pointer), clones all the - //! elements from src calling Cloner::operator()(const_reference ) - //! and inserts them on *this. Copies the predicate from the source container. - //! - //! If cloner throws, all cloned elements are unlinked and disposed - //! calling Disposer::operator()(pointer). - //! - //! Complexity: Linear to erased plus inserted elements. - //! - //! Throws: If cloner throws or predicate copy assignment throws. Basic guarantee. - template - void clone_from(const bstree_impl &src, Cloner cloner, Disposer disposer) - { - this->clear_and_dispose(disposer); - if(!src.empty()){ - detail::exception_disposer - rollback(*this, disposer); - node_algorithms::clone - (const_node_ptr(src.header_ptr()) - ,node_ptr(this->header_ptr()) - ,detail::node_cloner (cloner, &this->get_value_traits()) - ,detail::node_disposer(disposer, &this->get_value_traits())); - this->sz_traits().set_size(src.sz_traits().get_size()); - this->comp() = src.comp(); - rollback.release(); - } - } - - //! Requires: value must be an lvalue - //! - //! Effects: Inserts value into the container before the upper bound. - //! - //! Complexity: Average complexity for insert element is at - //! most logarithmic. - //! - //! Throws: If the internal value_compare ordering function throws. Strong guarantee. - //! - //! Note: Does not affect the validity of iterators and references. - //! No copy-constructors are called. - iterator insert_equal(reference value) - { - detail::key_nodeptr_comp - key_node_comp(this->comp(), &this->get_value_traits()); - node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); - iterator ret(node_algorithms::insert_equal_upper_bound - (this->header_ptr(), to_insert, key_node_comp), this->priv_value_traits_ptr()); - this->sz_traits().increment(); - return ret; - } - - //! Requires: value must be an lvalue, and "hint" must be - //! a valid iterator. - //! - //! Effects: Inserts x into the container, using "hint" as a hint to - //! where it will be inserted. If "hint" is the upper_bound - //! the insertion takes constant time (two comparisons in the worst case) - //! - //! Complexity: Logarithmic in general, but it is amortized - //! constant time if t is inserted immediately before hint. - //! - //! Throws: If the internal value_compare ordering function throws. Strong guarantee. - //! - //! Note: Does not affect the validity of iterators and references. - //! No copy-constructors are called. - iterator insert_equal(const_iterator hint, reference value) - { - detail::key_nodeptr_comp - key_node_comp(this->comp(), &this->get_value_traits()); - node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); - iterator ret(node_algorithms::insert_equal - (this->header_ptr(), hint.pointed_node(), to_insert, key_node_comp), this->priv_value_traits_ptr()); - this->sz_traits().increment(); - return ret; - } - - //! Requires: Dereferencing iterator must yield an lvalue - //! of type value_type. - //! - //! Effects: Inserts a each element of a range into the container - //! before the upper bound of the key of each element. - //! - //! Complexity: Insert range is in general O(N * log(N)), where N is the - //! size of the range. However, it is linear in N if the range is already sorted - //! by value_comp(). - //! - //! Throws: Nothing. - //! - //! Note: Does not affect the validity of iterators and references. - //! No copy-constructors are called. - template - void insert_equal(Iterator b, Iterator e) - { - iterator iend(this->end()); - for (; b != e; ++b) - this->insert_equal(iend, *b); - } - - //! Requires: value must be an lvalue - //! - //! Effects: Inserts value into the container if the value - //! is not already present. - //! - //! Complexity: Average complexity for insert element is at - //! most logarithmic. - //! - //! Throws: Nothing. - //! - //! Note: Does not affect the validity of iterators and references. - //! No copy-constructors are called. - std::pair insert_unique(reference value) - { - insert_commit_data commit_data; - std::pair ret = this->insert_unique_check(value, this->comp(), commit_data); - if(!ret.second) - return ret; - return std::pair (this->insert_unique_commit(value, commit_data), true); - } - - //! Requires: value must be an lvalue, and "hint" must be - //! a valid iterator - //! - //! Effects: Tries to insert x into the container, using "hint" as a hint - //! to where it will be inserted. - //! - //! Complexity: Logarithmic in general, but it is amortized - //! constant time (two comparisons in the worst case) - //! if t is inserted immediately before hint. - //! - //! Throws: Nothing. - //! - //! Note: Does not affect the validity of iterators and references. - //! No copy-constructors are called. - iterator insert_unique(const_iterator hint, reference value) - { - insert_commit_data commit_data; - std::pair ret = this->insert_unique_check(hint, value, this->comp(), commit_data); - if(!ret.second) - return ret.first; - return this->insert_unique_commit(value, commit_data); - } - - //! Requires: Dereferencing iterator must yield an lvalue - //! of type value_type. - //! - //! Effects: Tries to insert each element of a range into the container. - //! - //! Complexity: Insert range is in general O(N * log(N)), where N is the - //! size of the range. However, it is linear in N if the range is already sorted - //! by value_comp(). - //! - //! Throws: Nothing. - //! - //! Note: Does not affect the validity of iterators and references. - //! No copy-constructors are called. - template - void insert_unique(Iterator b, Iterator e) - { - if(this->empty()){ - iterator iend(this->end()); - for (; b != e; ++b) - this->insert_unique(iend, *b); - } - else{ - for (; b != e; ++b) - this->insert_unique(*b); - } - } - - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! Requires: key_value_comp must be a comparison function that induces - //! the same strict weak ordering as value_compare. The difference is that - //! key_value_comp compares an arbitrary key with the contained values. - //! - //! Effects: Checks if a value can be inserted in the container, using - //! a user provided key instead of the value itself. - //! - //! Returns: If there is an equivalent value - //! returns a pair containing an iterator to the already present value - //! and false. If the value can be inserted returns true in the returned - //! pair boolean and fills "commit_data" that is meant to be used with - //! the "insert_commit" function. - //! - //! Complexity: Average complexity is at most logarithmic. - //! - //! Throws: If the key_value_comp ordering function throws. Strong guarantee. - //! - //! Notes: This function is used to improve performance when constructing - //! a value_type is expensive: if there is an equivalent value - //! the constructed object must be discarded. Many times, the part of the - //! node that is used to impose the order is much cheaper to construct - //! than the value_type and this function offers the possibility to use that - //! part to check if the insertion will be successful. - //! - //! If the check is successful, the user can construct the value_type and use - //! "insert_commit" to insert the object in constant-time. This gives a total - //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). - //! - //! "commit_data" remains valid for a subsequent "insert_commit" only if no more - //! objects are inserted or erased from the container. - template - std::pair insert_unique_check - (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data); - - //! Requires: key_value_comp must be a comparison function that induces - //! the same strict weak ordering as value_compare. The difference is that - //! key_value_comp compares an arbitrary key with the contained values. - //! - //! Effects: Checks if a value can be inserted in the container, using - //! a user provided key instead of the value itself, using "hint" - //! as a hint to where it will be inserted. - //! - //! Returns: If there is an equivalent value - //! returns a pair containing an iterator to the already present value - //! and false. If the value can be inserted returns true in the returned - //! pair boolean and fills "commit_data" that is meant to be used with - //! the "insert_commit" function. - //! - //! Complexity: Logarithmic in general, but it's amortized - //! constant time if t is inserted immediately before hint. - //! - //! Throws: If the key_value_comp ordering function throws. Strong guarantee. - //! - //! Notes: This function is used to improve performance when constructing - //! a value_type is expensive: if there is an equivalent value - //! the constructed object must be discarded. Many times, the part of the - //! constructing that is used to impose the order is much cheaper to construct - //! than the value_type and this function offers the possibility to use that key - //! to check if the insertion will be successful. - //! - //! If the check is successful, the user can construct the value_type and use - //! "insert_commit" to insert the object in constant-time. This can give a total - //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)). - //! - //! "commit_data" remains valid for a subsequent "insert_commit" only if no more - //! objects are inserted or erased from the container. - template - std::pair insert_unique_check - (const_iterator hint, const KeyType &key - ,KeyValueCompare key_value_comp, insert_commit_data &commit_data); - - #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - //! Requires: value must be an lvalue of type value_type. commit_data - //! must have been obtained from a previous call to "insert_check". - //! No objects should have been inserted or erased from the container between - //! the "insert_check" that filled "commit_data" and the call to "insert_commit". - //! - //! Effects: Inserts the value in the container using the information obtained - //! from the "commit_data" that a previous "insert_check" filled. - //! - //! Returns: An iterator to the newly inserted object. - //! - //! Complexity: Constant time. - //! - //! Throws: Nothing. - //! - //! Notes: This function has only sense if a "insert_check" has been - //! previously executed to fill "commit_data". No value should be inserted or - //! erased between the "insert_check" and "insert_commit" calls. - iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) - { - node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); - node_algorithms::insert_unique_commit - (this->header_ptr(), to_insert, commit_data); - this->sz_traits().increment(); - return iterator(to_insert, this->priv_value_traits_ptr()); - } - - //! Requires: value must be an lvalue, "pos" must be - //! a valid iterator (or end) and must be the succesor of value - //! once inserted according to the predicate - //! - //! Effects: Inserts x into the container before "pos". - //! - //! Complexity: Constant time. - //! - //! Throws: Nothing. - //! - //! Note: This function does not check preconditions so if "pos" is not - //! the successor of "value" container ordering invariant will be broken. - //! This is a low-level function to be used only for performance reasons - //! by advanced users. - iterator insert_before(const_iterator pos, reference value) - { - node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); - this->sz_traits().increment(); - return iterator(node_algorithms::insert_before - (this->header_ptr(), pos.pointed_node(), to_insert), this->priv_value_traits_ptr()); - } - - //! Requires: value must be an lvalue, and it must be no less - //! than the greatest inserted key - //! - //! Effects: Inserts x into the container in the last position. - //! - //! Complexity: Constant time. - //! - //! Throws: Nothing. - //! - //! Note: This function does not check preconditions so if value is - //! less than the greatest inserted key container ordering invariant will be broken. - //! This function is slightly more efficient than using "insert_before". - //! This is a low-level function to be used only for performance reasons - //! by advanced users. - void push_back(reference value) - { - node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); - this->sz_traits().increment(); - node_algorithms::push_back(this->header_ptr(), to_insert); - } - - //! Requires: value must be an lvalue, and it must be no greater - //! than the minimum inserted key - //! - //! Effects: Inserts x into the container in the first position. - //! - //! Complexity: Constant time. - //! - //! Throws: Nothing. - //! - //! Note: This function does not check preconditions so if value is - //! greater than the minimum inserted key container ordering invariant will be broken. - //! This function is slightly more efficient than using "insert_before". - //! This is a low-level function to be used only for performance reasons - //! by advanced users. - void push_front(reference value) - { - node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); - this->sz_traits().increment(); - node_algorithms::push_front(this->header_ptr(), to_insert); - } - - //! Effects: Erases the element pointed to by pos. - //! - //! Complexity: Average complexity for erase element is constant time. - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - iterator erase(const_iterator i) - { - const_iterator ret(i); - ++ret; - node_ptr to_erase(i.pointed_node()); - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase)); - node_algorithms::erase(this->header_ptr(), to_erase); - this->sz_traits().decrement(); - if(safemode_or_autounlink) - node_algorithms::init(to_erase); - return ret.unconst(); - } - - //! Effects: Erases the range pointed to by b end e. - //! - //! Complexity: Average complexity for erase range is at most - //! O(log(size() + N)), where N is the number of elements in the range. - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - iterator erase(const_iterator b, const_iterator e) - { size_type n; return this->private_erase(b, e, n); } - - //! Effects: Erases all the elements with the given value. - //! - //! Returns: The number of erased elements. - //! - //! Complexity: O(log(size() + N). - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - size_type erase(const_reference value) - { return this->erase(value, this->comp()); } - - //! Effects: Erases all the elements with the given key. - //! according to the comparison functor "comp". - //! - //! Returns: The number of erased elements. - //! - //! Complexity: O(log(size() + N). - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - template - size_type erase(const KeyType& key, KeyValueCompare comp - /// @cond - , typename detail::enable_if_c::value >::type * = 0 - /// @endcond - ) - { - std::pair p = this->equal_range(key, comp); - size_type n; - this->private_erase(p.first, p.second, n); - return n; - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases the element pointed to by pos. - //! Disposer::operator()(pointer) is called for the removed element. - //! - //! Complexity: Average complexity for erase element is constant time. - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators - //! to the erased elements. - template - iterator erase_and_dispose(const_iterator i, Disposer disposer) - { - node_ptr to_erase(i.pointed_node()); - iterator ret(this->erase(i)); - disposer(this->get_value_traits().to_value_ptr(to_erase)); - return ret; - } - - #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - template - iterator erase_and_dispose(iterator i, Disposer disposer) - { return this->erase_and_dispose(const_iterator(i), disposer); } - #endif - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases all the elements with the given value. - //! Disposer::operator()(pointer) is called for the removed elements. - //! - //! Returns: The number of erased elements. - //! - //! Complexity: O(log(size() + N). - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - template - size_type erase_and_dispose(const_reference value, Disposer disposer) - { - std::pair p = this->equal_range(value); - size_type n; - this->private_erase(p.first, p.second, n, disposer); - return n; - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases the range pointed to by b end e. - //! Disposer::operator()(pointer) is called for the removed elements. - //! - //! Complexity: Average complexity for erase range is at most - //! O(log(size() + N)), where N is the number of elements in the range. - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators - //! to the erased elements. - template - iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) - { size_type n; return this->private_erase(b, e, n, disposer); } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases all the elements with the given key. - //! according to the comparison functor "comp". - //! Disposer::operator()(pointer) is called for the removed elements. - //! - //! Returns: The number of erased elements. - //! - //! Complexity: O(log(size() + N). - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators - //! to the erased elements. - template - size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer - /// @cond - , typename detail::enable_if_c::value >::type * = 0 - /// @endcond - ) - { - std::pair p = this->equal_range(key, comp); - size_type n; - this->private_erase(p.first, p.second, n, disposer); - return n; - } - - //! Effects: Erases all of the elements. - //! - //! Complexity: Linear to the number of elements on the container. - //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - void clear() - { - if(safemode_or_autounlink){ - this->clear_and_dispose(detail::null_disposer()); - } - else{ - node_algorithms::init_header(this->header_ptr()); - this->sz_traits().set_size(0); - } - } - - //! Effects: Erases all of the elements calling disposer(p) for - //! each node to be erased. - //! Complexity: Average complexity for is at most O(log(size() + N)), - //! where N is the number of elements in the container. - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. Calls N times to disposer functor. - template - void clear_and_dispose(Disposer disposer) - { - node_algorithms::clear_and_dispose(this->header_ptr() - , detail::node_disposer(disposer, &this->get_value_traits())); - node_algorithms::init_header(this->header_ptr()); - this->sz_traits().set_size(0); - } - - //! Effects: Returns the number of contained elements with the given value - //! - //! Complexity: Logarithmic to the number of elements contained plus lineal - //! to number of objects with the given value. - //! - //! Throws: If `value_compare` throws. - size_type count(const_reference value) const - { return size_type(this->count(value, this->comp())); } - - //! Effects: Returns the number of contained elements with the given key - //! - //! Complexity: Logarithmic to the number of elements contained plus lineal - //! to number of objects with the given key. - //! - //! Throws: If `comp` throws. - template - size_type count(const KeyType &key, KeyValueCompare comp) const - { - std::pair ret = this->equal_range(key, comp); - size_type n = 0; - for(; ret.first != ret.second; ++ret.first){ ++n; } - return n; - } - - #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - - //Add non-const overloads to theoretically const members - //as some algorithms have different behavior when non-const versions are used (like splay trees). - size_type count(const_reference value) - { return size_type(this->count(value, this->comp())); } - - template - size_type count(const KeyType &key, KeyValueCompare comp) - { - std::pair ret = this->equal_range(key, comp); - size_type n = 0; - for(; ret.first != ret.second; ++ret.first){ ++n; } - return n; - } - - #else //defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - - //! Effects: Returns an iterator to the first element whose - //! key is not less than k or end() if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `value_compare` throws. - iterator lower_bound(const_reference value); - - //! Effects: Returns an iterator to the first element whose - //! key is not less than k or end() if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `value_compare` throws. - const_iterator lower_bound(const_reference value) const; - - //! Effects: Returns an iterator to the first element whose - //! key is not less than k or end() if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `comp` throws. - template - iterator lower_bound(const KeyType &key, KeyValueCompare comp); - - //! Effects: Returns a const iterator to the first element whose - //! key is not less than k or end() if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `comp` throws. - template - const_iterator lower_bound(const KeyType &key, KeyValueCompare comp) const; - - //! Effects: Returns an iterator to the first element whose - //! key is greater than k or end() if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `value_compare` throws. - iterator upper_bound(const_reference value); - - //! Effects: Returns an iterator to the first element whose - //! key is greater than k according to comp or end() if that element - //! does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `comp` throws. - template - iterator upper_bound(const KeyType &key, KeyValueCompare comp); - - //! Effects: Returns an iterator to the first element whose - //! key is greater than k or end() if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `value_compare` throws. - const_iterator upper_bound(const_reference value) const; - - //! Effects: Returns an iterator to the first element whose - //! key is greater than k according to comp or end() if that element - //! does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `comp` throws. - template - const_iterator upper_bound(const KeyType &key, KeyValueCompare comp) const; - - //! Effects: Finds an iterator to the first element whose key is - //! k or end() if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `value_compare` throws. - iterator find(const_reference value); - - //! Effects: Finds an iterator to the first element whose key is - //! k or end() if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `comp` throws. - template - iterator find(const KeyType &key, KeyValueCompare comp); - - //! Effects: Finds a const_iterator to the first element whose key is - //! k or end() if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `value_compare` throws. - const_iterator find(const_reference value) const; - - //! Effects: Finds a const_iterator to the first element whose key is - //! k or end() if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `comp` throws. - template - const_iterator find(const KeyType &key, KeyValueCompare comp) const; - - //! Effects: Finds a range containing all elements whose key is k or - //! an empty range that indicates the position where those elements would be - //! if they there is no elements with key k. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `value_compare` throws. - std::pair equal_range(const_reference value); - - //! Effects: Finds a range containing all elements whose key is k or - //! an empty range that indicates the position where those elements would be - //! if they there is no elements with key k. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `comp` throws. - template - std::pair equal_range(const KeyType &key, KeyValueCompare comp); - - //! Effects: Finds a range containing all elements whose key is k or - //! an empty range that indicates the position where those elements would be - //! if they there is no elements with key k. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `value_compare` throws. - std::pair - equal_range(const_reference value) const; - - //! Effects: Finds a range containing all elements whose key is k or - //! an empty range that indicates the position where those elements would be - //! if they there is no elements with key k. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `comp` throws. - template - std::pair - equal_range(const KeyType &key, KeyValueCompare comp) const; - - //! Requires: 'lower_value' must not be greater than 'upper_value'. If - //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false. - //! - //! Effects: Returns an a pair with the following criteria: - //! - //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise - //! - //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `value_compare` throws. - //! - //! Note: This function can be more efficient than calling upper_bound - //! and lower_bound for lower_value and upper_value. - //! - //! Note: Experimental function, the interface might change in future releases. - std::pair bounded_range - (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed); - - //! Requires: KeyValueCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the container. - //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If - //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. - //! - //! Effects: Returns an a pair with the following criteria: - //! - //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise - //! - //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `comp` throws. - //! - //! Note: This function can be more efficient than calling upper_bound - //! and lower_bound for lower_key and upper_key. - //! - //! Note: Experimental function, the interface might change in future releases. - template - std::pair bounded_range - (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed); - - //! Requires: 'lower_value' must not be greater than 'upper_value'. If - //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false. - //! - //! Effects: Returns an a pair with the following criteria: - //! - //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise - //! - //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `value_compare` throws. - //! - //! Note: This function can be more efficient than calling upper_bound - //! and lower_bound for lower_value and upper_value. - //! - //! Note: Experimental function, the interface might change in future releases. - std::pair bounded_range - (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const; - - //! Requires: KeyValueCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the container. - //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If - //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. - //! - //! Effects: Returns an a pair with the following criteria: - //! - //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise - //! - //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise - //! - //! Complexity: Logarithmic. - //! - //! Throws: If `comp` throws. - //! - //! Note: This function can be more efficient than calling upper_bound - //! and lower_bound for lower_key and upper_key. - //! - //! Note: Experimental function, the interface might change in future releases. - template - std::pair bounded_range - (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const; - - //! Requires: value must be an lvalue and shall be in a set of - //! appropriate type. Otherwise the behavior is undefined. - //! - //! Effects: Returns: a valid iterator i belonging to the set - //! that points to the value - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: This static function is available only if the value traits - //! is stateless. - static iterator s_iterator_to(reference value); - - //! Requires: value must be an lvalue and shall be in a set of - //! appropriate type. Otherwise the behavior is undefined. - //! - //! Effects: Returns: a valid const_iterator i belonging to the - //! set that points to the value - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: This static function is available only if the value traits - //! is stateless. - static const_iterator s_iterator_to(const_reference value); - - //! Requires: value must be an lvalue and shall be in a set of - //! appropriate type. Otherwise the behavior is undefined. - //! - //! Effects: Returns: a valid iterator i belonging to the set - //! that points to the value - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - iterator iterator_to(reference value); - - //! Requires: value must be an lvalue and shall be in a set of - //! appropriate type. Otherwise the behavior is undefined. - //! - //! Effects: Returns: a valid const_iterator i belonging to the - //! set that points to the value - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_iterator iterator_to(const_reference value) const; - - //! Requires: value shall not be in a container. - //! - //! Effects: init_node puts the hook of a value in a well-known default - //! state. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant time. - //! - //! Note: This function puts the hook in the well-known default state - //! used by auto_unlink and safe hooks. - static void init_node(reference value); - - #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - - //! Effects: Unlinks the leftmost node from the container. - //! - //! Complexity: Average complexity is constant time. - //! - //! Throws: Nothing. - //! - //! Notes: This function breaks the container and the container can - //! only be used for more unlink_leftmost_without_rebalance calls. - //! This function is normally used to achieve a step by step - //! controlled destruction of the container. - pointer unlink_leftmost_without_rebalance() - { - node_ptr to_be_disposed(node_algorithms::unlink_leftmost_without_rebalance - (this->header_ptr())); - if(!to_be_disposed) - return 0; - this->sz_traits().decrement(); - if(safemode_or_autounlink)//If this is commented does not work with normal_link - node_algorithms::init(to_be_disposed); - return this->get_value_traits().to_value_ptr(to_be_disposed); - } - - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - - //! Requires: replace_this must be a valid iterator of *this - //! and with_this must not be inserted in any container. - //! - //! Effects: Replaces replace_this in its position in the - //! container with with_this. The container does not need to be rebalanced. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: This function will break container ordering invariants if - //! with_this is not equivalent to *replace_this according to the - //! ordering rules. This function is faster than erasing and inserting - //! the node, since no rebalancing or comparison is needed. - void replace_node(iterator replace_this, reference with_this); - - //! Effects: Rebalances the tree. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear. - void rebalance(); - - //! Requires: old_root is a node of a tree. - //! - //! Effects: Rebalances the subtree rooted at old_root. - //! - //! Returns: The new root of the subtree. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the elements in the subtree. - iterator rebalance_subtree(iterator root); - - #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - - //! Effects: removes "value" from the container. - //! - //! Throws: Nothing. - //! - //! Complexity: Logarithmic time. - //! - //! Note: This static function is only usable with non-constant - //! time size containers that have stateless comparison functors. - //! - //! If the user calls - //! this function with a constant time size container or stateful comparison - //! functor a compilation error will be issued. - static void remove_node(reference value) - { - BOOST_STATIC_ASSERT((!constant_time_size)); - node_ptr to_remove(value_traits::to_node_ptr(value)); - node_algorithms::unlink(to_remove); - if(safemode_or_autounlink) - node_algorithms::init(to_remove); - } - - //! Effects: Asserts the integrity of the container with additional checks provided by the user. - //! - //! Complexity: Linear time. - //! - //! Note: The method might not have effect when asserts are turned off (e.g., with NDEBUG). - //! Experimental function, interface might change in future versions. - template - void check(ExtraChecker extra_checker) const - { - typedef detail::key_nodeptr_comp nodeptr_comp_t; - nodeptr_comp_t nodeptr_comp(this->comp(), &this->get_value_traits()); - typedef typename get_node_checker::type node_checker_t; - typename node_checker_t::return_type checker_return; - node_algorithms::check(this->header_ptr(), node_checker_t(nodeptr_comp, extra_checker), checker_return); - if (constant_time_size) - BOOST_INTRUSIVE_INVARIANT_ASSERT(this->sz_traits().get_size() == checker_return.node_count); - } - - //! Effects: Asserts the integrity of the container. - //! - //! Complexity: Linear time. - //! - //! Note: The method has no effect when asserts are turned off (e.g., with NDEBUG). - //! Experimental function, interface might change in future versions. - void check() const - { - check(detail::empty_node_checker()); - } - - /// @cond - private: - template - iterator private_erase(const_iterator b, const_iterator e, size_type &n, Disposer disposer) - { - for(n = 0; b != e; ++n) - this->erase_and_dispose(b++, disposer); - return b.unconst(); - } - - iterator private_erase(const_iterator b, const_iterator e, size_type &n) - { - for(n = 0; b != e; ++n) - this->erase(b++); - return b.unconst(); - } - /// @endcond -}; - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline bool operator< -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const bstree_impl &x, const bstree_impl &y) -#else -( const bstree_impl &x -, const bstree_impl &y) -#endif -{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -bool operator== -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const bstree_impl &x, const bstree_impl &y) -#else -( const bstree_impl &x -, const bstree_impl &y) -#endif -{ - typedef bstree_impl tree_type; - typedef typename tree_type::const_iterator const_iterator; - - if(tree_type::constant_time_size && x.size() != y.size()){ - return false; - } - const_iterator end1 = x.end(); - const_iterator i1 = x.begin(); - const_iterator i2 = y.begin(); - if(tree_type::constant_time_size){ - while (i1 != end1 && *i1 == *i2) { - ++i1; - ++i2; - } - return i1 == end1; - } - else{ - const_iterator end2 = y.end(); - while (i1 != end1 && i2 != end2 && *i1 == *i2) { - ++i1; - ++i2; - } - return i1 == end1 && i2 == end2; - } -} - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline bool operator!= -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const bstree_impl &x, const bstree_impl &y) -#else -( const bstree_impl &x -, const bstree_impl &y) -#endif -{ return !(x == y); } - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline bool operator> -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const bstree_impl &x, const bstree_impl &y) -#else -( const bstree_impl &x -, const bstree_impl &y) -#endif -{ return y < x; } - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline bool operator<= -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const bstree_impl &x, const bstree_impl &y) -#else -( const bstree_impl &x -, const bstree_impl &y) -#endif -{ return !(y < x); } - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline bool operator>= -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const bstree_impl &x, const bstree_impl &y) -#else -( const bstree_impl &x -, const bstree_impl &y) -#endif -{ return !(x < y); } - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline void swap -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(bstree_impl &x, bstree_impl &y) -#else -( bstree_impl &x -, bstree_impl &y) -#endif -{ x.swap(y); } - -//! Helper metafunction to define a \c bstree that yields to the same type when the -//! same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_bstree -{ - /// @cond - typedef typename pack_options - < bstree_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3, O4, O5 - #else - Options... - #endif - >::type packed_options; - - typedef typename detail::get_value_traits - ::type value_traits; - typedef typename detail::get_header_holder_type - < value_traits, typename packed_options::header_holder_type >::type header_holder_type; - - typedef bstree_impl - < value_traits - , typename packed_options::compare - , typename packed_options::size_type - , packed_options::constant_time_size - , BsTreeAlgorithms - , header_holder_type - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - - -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class bstree - : public make_bstree::type -{ - typedef typename make_bstree - ::type Base; - BOOST_MOVABLE_BUT_NOT_COPYABLE(bstree) - - public: - typedef typename Base::value_compare value_compare; - typedef typename Base::value_traits value_traits; - typedef typename Base::iterator iterator; - typedef typename Base::const_iterator const_iterator; - - //Assert if passed value traits are compatible with the type - BOOST_STATIC_ASSERT((detail::is_same::value)); - - bstree( const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(cmp, v_traits) - {} - - template - bstree( bool unique, Iterator b, Iterator e - , const value_compare &cmp = value_compare() - , const value_traits &v_traits = value_traits()) - : Base(unique, b, e, cmp, v_traits) - {} - - bstree(BOOST_RV_REF(bstree) x) - : Base(::boost::move(static_cast(x))) - {} - - bstree& operator=(BOOST_RV_REF(bstree) x) - { return static_cast(this->Base::operator=(::boost::move(static_cast(x)))); } - - static bstree &container_from_end_iterator(iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static const bstree &container_from_end_iterator(const_iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static bstree &container_from_iterator(iterator it) - { return static_cast(Base::container_from_iterator(it)); } - - static const bstree &container_from_iterator(const_iterator it) - { return static_cast(Base::container_from_iterator(it)); } -}; - -#endif -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_BSTREE_HPP diff --git a/boost/intrusive/bstree_algorithms.hpp b/boost/intrusive/bstree_algorithms.hpp deleted file mode 100644 index de5445e..0000000 --- a/boost/intrusive/bstree_algorithms.hpp +++ /dev/null @@ -1,2127 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_BSTREE_ALGORITHMS_HPP -#define BOOST_INTRUSIVE_BSTREE_ALGORITHMS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -/// @cond - -//! This type is the information that will be filled by insert_unique_check -template -struct insert_commit_data_t -{ - insert_commit_data_t() - : link_left(false) - , node() - {} - bool link_left; - NodePtr node; -}; - -template -struct data_for_rebalance_t -{ - NodePtr x; - NodePtr x_parent; - NodePtr y; -}; - -namespace detail { - -template -struct bstree_node_checker - : public ExtraChecker -{ - typedef ExtraChecker base_checker_t; - typedef ValueTraits value_traits; - typedef typename value_traits::node_traits node_traits; - typedef typename node_traits::const_node_ptr const_node_ptr; - - struct return_type - : public base_checker_t::return_type - { - return_type() : min_key_node_ptr(const_node_ptr()), max_key_node_ptr(const_node_ptr()), node_count(0) {} - - const_node_ptr min_key_node_ptr; - const_node_ptr max_key_node_ptr; - size_t node_count; - }; - - bstree_node_checker(const NodePtrCompare& comp, ExtraChecker extra_checker) - : base_checker_t(extra_checker), comp_(comp) - {} - - void operator () (const const_node_ptr& p, - const return_type& check_return_left, const return_type& check_return_right, - return_type& check_return) - { - if (check_return_left.max_key_node_ptr) - BOOST_INTRUSIVE_INVARIANT_ASSERT(!comp_(p, check_return_left.max_key_node_ptr)); - if (check_return_right.min_key_node_ptr) - BOOST_INTRUSIVE_INVARIANT_ASSERT(!comp_(check_return_right.min_key_node_ptr, p)); - check_return.min_key_node_ptr = node_traits::get_left(p)? check_return_left.min_key_node_ptr : p; - check_return.max_key_node_ptr = node_traits::get_right(p)? check_return_right.max_key_node_ptr : p; - check_return.node_count = check_return_left.node_count + check_return_right.node_count + 1; - base_checker_t::operator()(p, check_return_left, check_return_right, check_return); - } - - const NodePtrCompare comp_; -}; - -} // namespace detail - -/// @endcond - - - -//! This is an implementation of a binary search tree. -//! A node in the search tree has references to its children and its parent. This -//! is to allow traversal of the whole tree from a given node making the -//! implementation of iterator a pointer to a node. -//! At the top of the tree a node is used specially. This node's parent pointer -//! is pointing to the root of the tree. Its left pointer points to the -//! leftmost node in the tree and the right pointer to the rightmost one. -//! This node is used to represent the end-iterator. -//! -//! +---------+ -//! header------------------------------>| | -//! | | -//! +----------(left)--------| |--------(right)---------+ -//! | +---------+ | -//! | | | -//! | | (parent) | -//! | | | -//! | | | -//! | +---------+ | -//! root of tree ..|......................> | | | -//! | | D | | -//! | | | | -//! | +-------+---------+-------+ | -//! | | | | -//! | | | | -//! | | | | -//! | | | | -//! | | | | -//! | +---------+ +---------+ | -//! | | | | | | -//! | | B | | F | | -//! | | | | | | -//! | +--+---------+--+ +--+---------+--+ | -//! | | | | | | -//! | | | | | | -//! | | | | | | -//! | +---+-----+ +-----+---+ +---+-----+ +-----+---+ | -//! +-->| | | | | | | |<--+ -//! | A | | C | | E | | G | -//! | | | | | | | | -//! +---------+ +---------+ +---------+ +---------+ -//! -//! bstree_algorithms is configured with a NodeTraits class, which encapsulates the -//! information about the node to be manipulated. NodeTraits must support the -//! following interface: -//! -//! Typedefs: -//! -//! node: The type of the node that forms the binary search tree -//! -//! node_ptr: A pointer to a node -//! -//! const_node_ptr: A pointer to a const node -//! -//! Static functions: -//! -//! static node_ptr get_parent(const_node_ptr n); -//! -//! static void set_parent(node_ptr n, node_ptr parent); -//! -//! static node_ptr get_left(const_node_ptr n); -//! -//! static void set_left(node_ptr n, node_ptr left); -//! -//! static node_ptr get_right(const_node_ptr n); -//! -//! static void set_right(node_ptr n, node_ptr right); -template -class bstree_algorithms -{ - public: - typedef typename NodeTraits::node node; - typedef NodeTraits node_traits; - typedef typename NodeTraits::node_ptr node_ptr; - typedef typename NodeTraits::const_node_ptr const_node_ptr; - typedef insert_commit_data_t insert_commit_data; - typedef data_for_rebalance_t data_for_rebalance; - - /// @cond - - private: - template - struct dispose_subtree_disposer - { - dispose_subtree_disposer(Disposer &disp, const node_ptr & subtree) - : disposer_(&disp), subtree_(subtree) - {} - - void release() - { disposer_ = 0; } - - ~dispose_subtree_disposer() - { - if(disposer_){ - dispose_subtree(subtree_, *disposer_); - } - } - Disposer *disposer_; - const node_ptr subtree_; - }; - - /// @endcond - - public: - //! Requires: 'header' is the header node of a tree. - //! - //! Effects: Returns the first node of the tree, the header if the tree is empty. - //! - //! Complexity: Constant time. - //! - //! Throws: Nothing. - static node_ptr begin_node(const const_node_ptr & header) - { return node_traits::get_left(header); } - - //! Requires: 'header' is the header node of a tree. - //! - //! Effects: Returns the header of the tree. - //! - //! Complexity: Constant time. - //! - //! Throws: Nothing. - static node_ptr end_node(const const_node_ptr & header) - { return detail::uncast(header); } - - //! Requires: 'header' is the header node of a tree. - //! - //! Effects: Returns the root of the tree if any, header otherwise - //! - //! Complexity: Constant time. - //! - //! Throws: Nothing. - static node_ptr root_node(const const_node_ptr & header) - { - node_ptr p = node_traits::get_parent(header); - return p ? p : detail::uncast(header); - } - - //! Requires: 'node' is a node of the tree or a node initialized - //! by init(...) or init_node. - //! - //! Effects: Returns true if the node is initialized by init() or init_node(). - //! - //! Complexity: Constant time. - //! - //! Throws: Nothing. - static bool unique(const const_node_ptr & node) - { return !NodeTraits::get_parent(node); } - - //! Requires: 'node' is a node of the tree or a header node. - //! - //! Effects: Returns the header of the tree. - //! - //! Complexity: Logarithmic. - //! - //! Throws: Nothing. - static node_ptr get_header(const const_node_ptr & node) - { - node_ptr n(detail::uncast(node)); - node_ptr p(NodeTraits::get_parent(node)); - //If p is null, then n is the header of an empty tree - if(p){ - //Non-empty tree, check if n is neither root nor header - node_ptr pp(NodeTraits::get_parent(p)); - //If granparent is not equal to n, then n is neither root nor header, - //the try the fast path - if(n != pp){ - do{ - n = p; - p = pp; - pp = NodeTraits::get_parent(pp); - }while(n != pp); - n = p; - } - //Check if n is root or header when size() > 0 - else if(!is_header(n)){ - n = p; - } - } - return n; - /* - node_ptr h = detail::uncast(node); - node_ptr p = NodeTraits::get_parent(node); - if(p){ - while(!is_header(p)) - p = NodeTraits::get_parent(p); - return p; - } - else{ - return h; - }*/ - } - - //! Requires: node1 and node2 can't be header nodes - //! of two trees. - //! - //! Effects: Swaps two nodes. After the function node1 will be inserted - //! in the position node2 before the function. node2 will be inserted in the - //! position node1 had before the function. - //! - //! Complexity: Logarithmic. - //! - //! Throws: Nothing. - //! - //! Note: This function will break container ordering invariants if - //! node1 and node2 are not equivalent according to the ordering rules. - //! - //!Experimental function - static void swap_nodes(const node_ptr & node1, const node_ptr & node2) - { - if(node1 == node2) - return; - - node_ptr header1(get_header(node1)), header2(get_header(node2)); - swap_nodes(node1, header1, node2, header2); - } - - //! Requires: node1 and node2 can't be header nodes - //! of two trees with header header1 and header2. - //! - //! Effects: Swaps two nodes. After the function node1 will be inserted - //! in the position node2 before the function. node2 will be inserted in the - //! position node1 had before the function. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: This function will break container ordering invariants if - //! node1 and node2 are not equivalent according to the ordering rules. - //! - //!Experimental function - static void swap_nodes(const node_ptr & node1, const node_ptr & header1, const node_ptr & node2, const node_ptr & header2) - { - if(node1 == node2) - return; - - //node1 and node2 must not be header nodes - //BOOST_INTRUSIVE_INVARIANT_ASSERT((header1 != node1 && header2 != node2)); - if(header1 != header2){ - //Update header1 if necessary - if(node1 == NodeTraits::get_left(header1)){ - NodeTraits::set_left(header1, node2); - } - - if(node1 == NodeTraits::get_right(header1)){ - NodeTraits::set_right(header1, node2); - } - - if(node1 == NodeTraits::get_parent(header1)){ - NodeTraits::set_parent(header1, node2); - } - - //Update header2 if necessary - if(node2 == NodeTraits::get_left(header2)){ - NodeTraits::set_left(header2, node1); - } - - if(node2 == NodeTraits::get_right(header2)){ - NodeTraits::set_right(header2, node1); - } - - if(node2 == NodeTraits::get_parent(header2)){ - NodeTraits::set_parent(header2, node1); - } - } - else{ - //If both nodes are from the same tree - //Update header if necessary - if(node1 == NodeTraits::get_left(header1)){ - NodeTraits::set_left(header1, node2); - } - else if(node2 == NodeTraits::get_left(header2)){ - NodeTraits::set_left(header2, node1); - } - - if(node1 == NodeTraits::get_right(header1)){ - NodeTraits::set_right(header1, node2); - } - else if(node2 == NodeTraits::get_right(header2)){ - NodeTraits::set_right(header2, node1); - } - - if(node1 == NodeTraits::get_parent(header1)){ - NodeTraits::set_parent(header1, node2); - } - else if(node2 == NodeTraits::get_parent(header2)){ - NodeTraits::set_parent(header2, node1); - } - - //Adjust data in nodes to be swapped - //so that final link swap works as expected - if(node1 == NodeTraits::get_parent(node2)){ - NodeTraits::set_parent(node2, node2); - - if(node2 == NodeTraits::get_right(node1)){ - NodeTraits::set_right(node1, node1); - } - else{ - NodeTraits::set_left(node1, node1); - } - } - else if(node2 == NodeTraits::get_parent(node1)){ - NodeTraits::set_parent(node1, node1); - - if(node1 == NodeTraits::get_right(node2)){ - NodeTraits::set_right(node2, node2); - } - else{ - NodeTraits::set_left(node2, node2); - } - } - } - - //Now swap all the links - node_ptr temp; - //swap left link - temp = NodeTraits::get_left(node1); - NodeTraits::set_left(node1, NodeTraits::get_left(node2)); - NodeTraits::set_left(node2, temp); - //swap right link - temp = NodeTraits::get_right(node1); - NodeTraits::set_right(node1, NodeTraits::get_right(node2)); - NodeTraits::set_right(node2, temp); - //swap parent link - temp = NodeTraits::get_parent(node1); - NodeTraits::set_parent(node1, NodeTraits::get_parent(node2)); - NodeTraits::set_parent(node2, temp); - - //Now adjust adjacent nodes for newly inserted node 1 - if((temp = NodeTraits::get_left(node1))){ - NodeTraits::set_parent(temp, node1); - } - if((temp = NodeTraits::get_right(node1))){ - NodeTraits::set_parent(temp, node1); - } - if((temp = NodeTraits::get_parent(node1)) && - //The header has been already updated so avoid it - temp != header2){ - if(NodeTraits::get_left(temp) == node2){ - NodeTraits::set_left(temp, node1); - } - if(NodeTraits::get_right(temp) == node2){ - NodeTraits::set_right(temp, node1); - } - } - //Now adjust adjacent nodes for newly inserted node 2 - if((temp = NodeTraits::get_left(node2))){ - NodeTraits::set_parent(temp, node2); - } - if((temp = NodeTraits::get_right(node2))){ - NodeTraits::set_parent(temp, node2); - } - if((temp = NodeTraits::get_parent(node2)) && - //The header has been already updated so avoid it - temp != header1){ - if(NodeTraits::get_left(temp) == node1){ - NodeTraits::set_left(temp, node2); - } - if(NodeTraits::get_right(temp) == node1){ - NodeTraits::set_right(temp, node2); - } - } - } - - //! Requires: node_to_be_replaced must be inserted in a tree - //! and new_node must not be inserted in a tree. - //! - //! Effects: Replaces node_to_be_replaced in its position in the - //! tree with new_node. The tree does not need to be rebalanced - //! - //! Complexity: Logarithmic. - //! - //! Throws: Nothing. - //! - //! Note: This function will break container ordering invariants if - //! new_node is not equivalent to node_to_be_replaced according to the - //! ordering rules. This function is faster than erasing and inserting - //! the node, since no rebalancing and comparison is needed. Experimental function - static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & new_node) - { - if(node_to_be_replaced == new_node) - return; - replace_node(node_to_be_replaced, get_header(node_to_be_replaced), new_node); - } - - //! Requires: node_to_be_replaced must be inserted in a tree - //! with header "header" and new_node must not be inserted in a tree. - //! - //! Effects: Replaces node_to_be_replaced in its position in the - //! tree with new_node. The tree does not need to be rebalanced - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: This function will break container ordering invariants if - //! new_node is not equivalent to node_to_be_replaced according to the - //! ordering rules. This function is faster than erasing and inserting - //! the node, since no rebalancing or comparison is needed. Experimental function - static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & header, const node_ptr & new_node) - { - if(node_to_be_replaced == new_node) - return; - - //Update header if necessary - if(node_to_be_replaced == NodeTraits::get_left(header)){ - NodeTraits::set_left(header, new_node); - } - - if(node_to_be_replaced == NodeTraits::get_right(header)){ - NodeTraits::set_right(header, new_node); - } - - if(node_to_be_replaced == NodeTraits::get_parent(header)){ - NodeTraits::set_parent(header, new_node); - } - - //Now set data from the original node - node_ptr temp; - NodeTraits::set_left(new_node, NodeTraits::get_left(node_to_be_replaced)); - NodeTraits::set_right(new_node, NodeTraits::get_right(node_to_be_replaced)); - NodeTraits::set_parent(new_node, NodeTraits::get_parent(node_to_be_replaced)); - - //Now adjust adjacent nodes for newly inserted node - if((temp = NodeTraits::get_left(new_node))){ - NodeTraits::set_parent(temp, new_node); - } - if((temp = NodeTraits::get_right(new_node))){ - NodeTraits::set_parent(temp, new_node); - } - if((temp = NodeTraits::get_parent(new_node)) && - //The header has been already updated so avoid it - temp != header){ - if(NodeTraits::get_left(temp) == node_to_be_replaced){ - NodeTraits::set_left(temp, new_node); - } - if(NodeTraits::get_right(temp) == node_to_be_replaced){ - NodeTraits::set_right(temp, new_node); - } - } - } - - //! Requires: 'node' is a node from the tree except the header. - //! - //! Effects: Returns the next node of the tree. - //! - //! Complexity: Average constant time. - //! - //! Throws: Nothing. - static node_ptr next_node(const node_ptr & node) - { - node_ptr const n_right(NodeTraits::get_right(node)); - if(n_right){ - return minimum(n_right); - } - else { - node_ptr n(node); - node_ptr p(NodeTraits::get_parent(n)); - while(n == NodeTraits::get_right(p)){ - n = p; - p = NodeTraits::get_parent(p); - } - return NodeTraits::get_right(n) != p ? p : n; - } - } - - //! Requires: 'node' is a node from the tree except the leftmost node. - //! - //! Effects: Returns the previous node of the tree. - //! - //! Complexity: Average constant time. - //! - //! Throws: Nothing. - static node_ptr prev_node(const node_ptr & node) - { - if(is_header(node)){ - return NodeTraits::get_right(node); - //return maximum(NodeTraits::get_parent(node)); - } - else if(NodeTraits::get_left(node)){ - return maximum(NodeTraits::get_left(node)); - } - else { - node_ptr p(node); - node_ptr x = NodeTraits::get_parent(p); - while(p == NodeTraits::get_left(x)){ - p = x; - x = NodeTraits::get_parent(x); - } - return x; - } - } - - //! Requires: 'node' is a node of a tree but not the header. - //! - //! Effects: Returns the minimum node of the subtree starting at p. - //! - //! Complexity: Logarithmic to the size of the subtree. - //! - //! Throws: Nothing. - static node_ptr minimum(node_ptr node) - { - for(node_ptr p_left = NodeTraits::get_left(node) - ;p_left - ;p_left = NodeTraits::get_left(node)){ - node = p_left; - } - return node; - } - - //! Requires: 'node' is a node of a tree but not the header. - //! - //! Effects: Returns the maximum node of the subtree starting at p. - //! - //! Complexity: Logarithmic to the size of the subtree. - //! - //! Throws: Nothing. - static node_ptr maximum(node_ptr node) - { - for(node_ptr p_right = NodeTraits::get_right(node) - ;p_right - ;p_right = NodeTraits::get_right(node)){ - node = p_right; - } - return node; - } - - //! Requires: 'node' must not be part of any tree. - //! - //! Effects: After the function unique(node) == true. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Nodes: If node is inserted in a tree, this function corrupts the tree. - static void init(const node_ptr & node) - { - NodeTraits::set_parent(node, node_ptr()); - NodeTraits::set_left(node, node_ptr()); - NodeTraits::set_right(node, node_ptr()); - }; - - //! Effects: Returns true if node is in the same state as if called init(node) - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - static bool inited(const const_node_ptr & node) - { - return !NodeTraits::get_parent(node) && - !NodeTraits::get_left(node) && - !NodeTraits::get_right(node) ; - }; - - //! Requires: node must not be part of any tree. - //! - //! Effects: Initializes the header to represent an empty tree. - //! unique(header) == true. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Nodes: If node is inserted in a tree, this function corrupts the tree. - static void init_header(const node_ptr & header) - { - NodeTraits::set_parent(header, node_ptr()); - NodeTraits::set_left(header, header); - NodeTraits::set_right(header, header); - } - - //! Requires: "disposer" must be an object function - //! taking a node_ptr parameter and shouldn't throw. - //! - //! Effects: Empties the target tree calling - //! void disposer::operator()(const node_ptr &) for every node of the tree - //! except the header. - //! - //! Complexity: Linear to the number of element of the source tree plus the. - //! number of elements of tree target tree when calling this function. - //! - //! Throws: If cloner functor throws. If this happens target nodes are disposed. - template - static void clear_and_dispose(const node_ptr & header, Disposer disposer) - { - node_ptr source_root = NodeTraits::get_parent(header); - if(!source_root) - return; - dispose_subtree(source_root, disposer); - init_header(header); - } - - //! Requires: header is the header of a tree. - //! - //! Effects: Unlinks the leftmost node from the tree, and - //! updates the header link to the new leftmost node. - //! - //! Complexity: Average complexity is constant time. - //! - //! Throws: Nothing. - //! - //! Notes: This function breaks the tree and the tree can - //! only be used for more unlink_leftmost_without_rebalance calls. - //! This function is normally used to achieve a step by step - //! controlled destruction of the tree. - static node_ptr unlink_leftmost_without_rebalance(const node_ptr & header) - { - node_ptr leftmost = NodeTraits::get_left(header); - if (leftmost == header) - return node_ptr(); - node_ptr leftmost_parent(NodeTraits::get_parent(leftmost)); - node_ptr leftmost_right (NodeTraits::get_right(leftmost)); - bool is_root = leftmost_parent == header; - - if (leftmost_right){ - NodeTraits::set_parent(leftmost_right, leftmost_parent); - NodeTraits::set_left(header, bstree_algorithms::minimum(leftmost_right)); - - if (is_root) - NodeTraits::set_parent(header, leftmost_right); - else - NodeTraits::set_left(NodeTraits::get_parent(header), leftmost_right); - } - else if (is_root){ - NodeTraits::set_parent(header, node_ptr()); - NodeTraits::set_left(header, header); - NodeTraits::set_right(header, header); - } - else{ - NodeTraits::set_left(leftmost_parent, node_ptr()); - NodeTraits::set_left(header, leftmost_parent); - } - return leftmost; - } - - //! Requires: node is a node of the tree but it's not the header. - //! - //! Effects: Returns the number of nodes of the subtree. - //! - //! Complexity: Linear time. - //! - //! Throws: Nothing. - static std::size_t size(const const_node_ptr & header) - { - node_ptr beg(begin_node(header)); - node_ptr end(end_node(header)); - std::size_t i = 0; - for(;beg != end; beg = next_node(beg)) ++i; - return i; - } - - //! Requires: header1 and header2 must be the header nodes - //! of two trees. - //! - //! Effects: Swaps two trees. After the function header1 will contain - //! links to the second tree and header2 will have links to the first tree. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - static void swap_tree(const node_ptr & header1, const node_ptr & header2) - { - if(header1 == header2) - return; - - node_ptr tmp; - - //Parent swap - tmp = NodeTraits::get_parent(header1); - NodeTraits::set_parent(header1, NodeTraits::get_parent(header2)); - NodeTraits::set_parent(header2, tmp); - //Left swap - tmp = NodeTraits::get_left(header1); - NodeTraits::set_left(header1, NodeTraits::get_left(header2)); - NodeTraits::set_left(header2, tmp); - //Right swap - tmp = NodeTraits::get_right(header1); - NodeTraits::set_right(header1, NodeTraits::get_right(header2)); - NodeTraits::set_right(header2, tmp); - - //Now test parent - node_ptr h1_parent(NodeTraits::get_parent(header1)); - if(h1_parent){ - NodeTraits::set_parent(h1_parent, header1); - } - else{ - NodeTraits::set_left(header1, header1); - NodeTraits::set_right(header1, header1); - } - - node_ptr h2_parent(NodeTraits::get_parent(header2)); - if(h2_parent){ - NodeTraits::set_parent(h2_parent, header2); - } - else{ - NodeTraits::set_left(header2, header2); - NodeTraits::set_right(header2, header2); - } - } - - //! Requires: p is a node of a tree. - //! - //! Effects: Returns true if p is the header of the tree. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - static bool is_header(const const_node_ptr & p) - { - node_ptr p_left (NodeTraits::get_left(p)); - node_ptr p_right(NodeTraits::get_right(p)); - if(!NodeTraits::get_parent(p) || //Header condition when empty tree - (p_left && p_right && //Header always has leftmost and rightmost - (p_left == p_right || //Header condition when only node - (NodeTraits::get_parent(p_left) != p || - NodeTraits::get_parent(p_right) != p )) - //When tree size > 1 headers can't be leftmost's - //and rightmost's parent - )){ - return true; - } - return false; - } - - //! Requires: "header" must be the header node of a tree. - //! KeyNodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. - //! - //! Effects: Returns a node_ptr to the first element that is equivalent to - //! "key" according to "comp" or "header" if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If "comp" throws. - template - static node_ptr find - (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) - { - node_ptr end = detail::uncast(header); - node_ptr y = lower_bound(header, key, comp); - return (y == end || comp(key, y)) ? end : y; - } - - //! Requires: "header" must be the header node of a tree. - //! KeyNodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. - //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If - //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. - //! - //! Effects: Returns an a pair with the following criteria: - //! - //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise - //! - //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise - //! - //! Complexity: Logarithmic. - //! - //! Throws: If "comp" throws. - //! - //! Note: This function can be more efficient than calling upper_bound - //! and lower_bound for lower_key and upper_key. - //! - //! Note: Experimental function, the interface might change. - template< class KeyType, class KeyNodePtrCompare> - static std::pair bounded_range - ( const const_node_ptr & header - , const KeyType &lower_key - , const KeyType &upper_key - , KeyNodePtrCompare comp - , bool left_closed - , bool right_closed) - { - node_ptr y = detail::uncast(header); - node_ptr x = NodeTraits::get_parent(header); - - while(x){ - //If x is less than lower_key the target - //range is on the right part - if(comp(x, lower_key)){ - //Check for invalid input range - BOOST_INTRUSIVE_INVARIANT_ASSERT(comp(x, upper_key)); - x = NodeTraits::get_right(x); - } - //If the upper_key is less than x, the target - //range is on the left part - else if(comp(upper_key, x)){ - y = x; - x = NodeTraits::get_left(x); - } - else{ - //x is inside the bounded range( x >= lower_key && x <= upper_key), - //so we must split lower and upper searches - // - //Sanity check: if lower_key and upper_key are equal, then both left_closed and right_closed can't be false - BOOST_INTRUSIVE_INVARIANT_ASSERT(left_closed || right_closed || comp(lower_key, x) || comp(x, upper_key)); - return std::pair( - left_closed - //If left_closed, then comp(x, lower_key) is already the lower_bound - //condition so we save one comparison and go to the next level - //following traditional lower_bound algo - ? lower_bound_loop(NodeTraits::get_left(x), x, lower_key, comp) - //If left-open, comp(x, lower_key) is not the upper_bound algo - //condition so we must recheck current 'x' node with upper_bound algo - : upper_bound_loop(x, y, lower_key, comp) - , - right_closed - //If right_closed, then comp(upper_key, x) is already the upper_bound - //condition so we can save one comparison and go to the next level - //following lower_bound algo - ? upper_bound_loop(NodeTraits::get_right(x), y, upper_key, comp) - //If right-open, comp(upper_key, x) is not the lower_bound algo - //condition so we must recheck current 'x' node with lower_bound algo - : lower_bound_loop(x, y, upper_key, comp) - ); - } - } - return std::pair (y, y); - } - - //! Requires: "header" must be the header node of a tree. - //! KeyNodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. - //! - //! Effects: Returns the number of elements with a key equivalent to "key" - //! according to "comp". - //! - //! Complexity: Logarithmic. - //! - //! Throws: If "comp" throws. - template - static std::size_t count - (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) - { - std::pair ret = equal_range(header, key, comp); - std::size_t n = 0; - while(ret.first != ret.second){ - ++n; - ret.first = next_node(ret.first); - } - return n; - } - - //! Requires: "header" must be the header node of a tree. - //! KeyNodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. - //! - //! Effects: Returns an a pair of node_ptr delimiting a range containing - //! all elements that are equivalent to "key" according to "comp" or an - //! empty range that indicates the position where those elements would be - //! if there are no equivalent elements. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If "comp" throws. - template - static std::pair equal_range - (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) - { - return bounded_range(header, key, key, comp, true, true); - } - - //! Requires: "header" must be the header node of a tree. - //! KeyNodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. - //! - //! Effects: Returns an a pair of node_ptr delimiting a range containing - //! the first element that is equivalent to "key" according to "comp" or an - //! empty range that indicates the position where that element would be - //! if there are no equivalent elements. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If "comp" throws. - template - static std::pair lower_bound_range - (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) - { - node_ptr const lb(lower_bound(header, key, comp)); - std::pair ret_ii(lb, lb); - if(lb != header && !comp(key, lb)){ - ret_ii.second = next_node(ret_ii.second); - } - return ret_ii; - } - - //! Requires: "header" must be the header node of a tree. - //! KeyNodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. - //! - //! Effects: Returns a node_ptr to the first element that is - //! not less than "key" according to "comp" or "header" if that element does - //! not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If "comp" throws. - template - static node_ptr lower_bound - (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) - { - return lower_bound_loop(NodeTraits::get_parent(header), detail::uncast(header), key, comp); - } - - //! Requires: "header" must be the header node of a tree. - //! KeyNodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs. - //! - //! Effects: Returns a node_ptr to the first element that is greater - //! than "key" according to "comp" or "header" if that element does not exist. - //! - //! Complexity: Logarithmic. - //! - //! Throws: If "comp" throws. - template - static node_ptr upper_bound - (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp) - { - return upper_bound_loop(NodeTraits::get_parent(header), detail::uncast(header), key, comp); - } - - //! Requires: "header" must be the header node of a tree. - //! "commit_data" must have been obtained from a previous call to - //! "insert_unique_check". No objects should have been inserted or erased - //! from the set between the "insert_unique_check" that filled "commit_data" - //! and the call to "insert_commit". - //! - //! - //! Effects: Inserts new_node in the set using the information obtained - //! from the "commit_data" that a previous "insert_check" filled. - //! - //! Complexity: Constant time. - //! - //! Throws: Nothing. - //! - //! Notes: This function has only sense if a "insert_unique_check" has been - //! previously executed to fill "commit_data". No value should be inserted or - //! erased between the "insert_check" and "insert_commit" calls. - static void insert_unique_commit - (const node_ptr & header, const node_ptr & new_value, const insert_commit_data &commit_data) - { return insert_commit(header, new_value, commit_data); } - - //! Requires: "header" must be the header node of a tree. - //! KeyNodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. NodePtrCompare compares KeyType with a node_ptr. - //! - //! Effects: Checks if there is an equivalent node to "key" in the - //! tree according to "comp" and obtains the needed information to realize - //! a constant-time node insertion if there is no equivalent node. - //! - //! Returns: If there is an equivalent value - //! returns a pair containing a node_ptr to the already present node - //! and false. If there is not equivalent key can be inserted returns true - //! in the returned pair's boolean and fills "commit_data" that is meant to - //! be used with the "insert_commit" function to achieve a constant-time - //! insertion function. - //! - //! Complexity: Average complexity is at most logarithmic. - //! - //! Throws: If "comp" throws. - //! - //! Notes: This function is used to improve performance when constructing - //! a node is expensive and the user does not want to have two equivalent nodes - //! in the tree: if there is an equivalent value - //! the constructed object must be discarded. Many times, the part of the - //! node that is used to impose the order is much cheaper to construct - //! than the node and this function offers the possibility to use that part - //! to check if the insertion will be successful. - //! - //! If the check is successful, the user can construct the node and use - //! "insert_commit" to insert the node in constant-time. This gives a total - //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). - //! - //! "commit_data" remains valid for a subsequent "insert_unique_commit" only - //! if no more objects are inserted or erased from the set. - template - static std::pair insert_unique_check - (const const_node_ptr & header, const KeyType &key - ,KeyNodePtrCompare comp, insert_commit_data &commit_data - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - , std::size_t *pdepth = 0 - #endif - ) - { - std::size_t depth = 0; - node_ptr h(detail::uncast(header)); - node_ptr y(h); - node_ptr x(NodeTraits::get_parent(y)); - node_ptr prev = node_ptr(); - - //Find the upper bound, cache the previous value and if we should - //store it in the left or right node - bool left_child = true; - while(x){ - ++depth; - y = x; - x = (left_child = comp(key, x)) ? - NodeTraits::get_left(x) : (prev = y, NodeTraits::get_right(x)); - } - - if(pdepth) *pdepth = depth; - - //Since we've found the upper bound there is no other value with the same key if: - // - There is no previous node - // - The previous node is less than the key - const bool not_present = !prev || comp(prev, key); - if(not_present){ - commit_data.link_left = left_child; - commit_data.node = y; - } - return std::pair(prev, not_present); - } - - //! Requires: "header" must be the header node of a tree. - //! KeyNodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. NodePtrCompare compares KeyType with a node_ptr. - //! "hint" is node from the "header"'s tree. - //! - //! Effects: Checks if there is an equivalent node to "key" in the - //! tree according to "comp" using "hint" as a hint to where it should be - //! inserted and obtains the needed information to realize - //! a constant-time node insertion if there is no equivalent node. - //! If "hint" is the upper_bound the function has constant time - //! complexity (two comparisons in the worst case). - //! - //! Returns: If there is an equivalent value - //! returns a pair containing a node_ptr to the already present node - //! and false. If there is not equivalent key can be inserted returns true - //! in the returned pair's boolean and fills "commit_data" that is meant to - //! be used with the "insert_commit" function to achieve a constant-time - //! insertion function. - //! - //! Complexity: Average complexity is at most logarithmic, but it is - //! amortized constant time if new_node should be inserted immediately before "hint". - //! - //! Throws: If "comp" throws. - //! - //! Notes: This function is used to improve performance when constructing - //! a node is expensive and the user does not want to have two equivalent nodes - //! in the tree: if there is an equivalent value - //! the constructed object must be discarded. Many times, the part of the - //! node that is used to impose the order is much cheaper to construct - //! than the node and this function offers the possibility to use that part - //! to check if the insertion will be successful. - //! - //! If the check is successful, the user can construct the node and use - //! "insert_commit" to insert the node in constant-time. This gives a total - //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)). - //! - //! "commit_data" remains valid for a subsequent "insert_unique_commit" only - //! if no more objects are inserted or erased from the set. - template - static std::pair insert_unique_check - (const const_node_ptr & header, const node_ptr &hint, const KeyType &key - ,KeyNodePtrCompare comp, insert_commit_data &commit_data - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - , std::size_t *pdepth = 0 - #endif - ) - { - //hint must be bigger than the key - if(hint == header || comp(key, hint)){ - node_ptr prev(hint); - //Previous value should be less than the key - if(hint == begin_node(header) || comp((prev = prev_node(hint)), key)){ - commit_data.link_left = unique(header) || !NodeTraits::get_left(hint); - commit_data.node = commit_data.link_left ? hint : prev; - if(pdepth){ - *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1; - } - return std::pair(node_ptr(), true); - } - } - //Hint was wrong, use hintless insertion - return insert_unique_check(header, key, comp, commit_data, pdepth); - } - - //! Requires: "header" must be the header node of a tree. - //! NodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. NodePtrCompare compares two node_ptrs. "hint" is node from - //! the "header"'s tree. - //! - //! Effects: Inserts new_node into the tree, using "hint" as a hint to - //! where it will be inserted. If "hint" is the upper_bound - //! the insertion takes constant time (two comparisons in the worst case). - //! - //! Complexity: Logarithmic in general, but it is amortized - //! constant time if new_node is inserted immediately before "hint". - //! - //! Throws: If "comp" throws. - template - static node_ptr insert_equal - (const node_ptr & h, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - , std::size_t *pdepth = 0 - #endif - ) - { - insert_commit_data commit_data; - insert_equal_check(h, hint, new_node, comp, commit_data, pdepth); - insert_commit(h, new_node, commit_data); - return new_node; - } - - //! Requires: "h" must be the header node of a tree. - //! NodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. NodePtrCompare compares two node_ptrs. - //! - //! Effects: Inserts new_node into the tree before the upper bound - //! according to "comp". - //! - //! Complexity: Average complexity for insert element is at - //! most logarithmic. - //! - //! Throws: If "comp" throws. - template - static node_ptr insert_equal_upper_bound - (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - , std::size_t *pdepth = 0 - #endif - ) - { - insert_commit_data commit_data; - insert_equal_upper_bound_check(h, new_node, comp, commit_data, pdepth); - insert_commit(h, new_node, commit_data); - return new_node; - } - - //! Requires: "h" must be the header node of a tree. - //! NodePtrCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the tree. NodePtrCompare compares two node_ptrs. - //! - //! Effects: Inserts new_node into the tree before the lower bound - //! according to "comp". - //! - //! Complexity: Average complexity for insert element is at - //! most logarithmic. - //! - //! Throws: If "comp" throws. - template - static node_ptr insert_equal_lower_bound - (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - , std::size_t *pdepth = 0 - #endif - ) - { - insert_commit_data commit_data; - insert_equal_lower_bound_check(h, new_node, comp, commit_data, pdepth); - insert_commit(h, new_node, commit_data); - return new_node; - } - - //! Requires: "header" must be the header node of a tree. - //! "pos" must be a valid iterator or header (end) node. - //! "pos" must be an iterator pointing to the successor to "new_node" - //! once inserted according to the order of already inserted nodes. This function does not - //! check "pos" and this precondition must be guaranteed by the caller. - //! - //! Effects: Inserts new_node into the tree before "pos". - //! - //! Complexity: Constant-time. - //! - //! Throws: Nothing. - //! - //! Note: If "pos" is not the successor of the newly inserted "new_node" - //! tree invariants might be broken. - static node_ptr insert_before - (const node_ptr & header, const node_ptr & pos, const node_ptr & new_node - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - , std::size_t *pdepth = 0 - #endif - ) - { - insert_commit_data commit_data; - insert_before_check(header, pos, commit_data, pdepth); - insert_commit(header, new_node, commit_data); - return new_node; - } - - //! Requires: "header" must be the header node of a tree. - //! "new_node" must be, according to the used ordering no less than the - //! greatest inserted key. - //! - //! Effects: Inserts new_node into the tree before "pos". - //! - //! Complexity: Constant-time. - //! - //! Throws: Nothing. - //! - //! Note: If "new_node" is less than the greatest inserted key - //! tree invariants are broken. This function is slightly faster than - //! using "insert_before". - static void push_back - (const node_ptr & header, const node_ptr & new_node - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - , std::size_t *pdepth = 0 - #endif - ) - { - insert_commit_data commit_data; - push_back_check(header, commit_data, pdepth); - insert_commit(header, new_node, commit_data); - } - - //! Requires: "header" must be the header node of a tree. - //! "new_node" must be, according to the used ordering, no greater than the - //! lowest inserted key. - //! - //! Effects: Inserts new_node into the tree before "pos". - //! - //! Complexity: Constant-time. - //! - //! Throws: Nothing. - //! - //! Note: If "new_node" is greater than the lowest inserted key - //! tree invariants are broken. This function is slightly faster than - //! using "insert_before". - static void push_front - (const node_ptr & header, const node_ptr & new_node - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - , std::size_t *pdepth = 0 - #endif - ) - { - insert_commit_data commit_data; - push_front_check(header, commit_data, pdepth); - insert_commit(header, new_node, commit_data); - } - - //! Requires: 'node' can't be a header node. - //! - //! Effects: Calculates the depth of a node: the depth of a - //! node is the length (number of edges) of the path from the root - //! to that node. (The root node is at depth 0.) - //! - //! Complexity: Logarithmic to the number of nodes in the tree. - //! - //! Throws: Nothing. - static std::size_t depth(const_node_ptr node) - { - std::size_t depth = 0; - node_ptr p_parent; - while(node != NodeTraits::get_parent(p_parent = NodeTraits::get_parent(node))){ - ++depth; - node = p_parent; - } - return depth; - } - - //! Requires: "cloner" must be a function - //! object taking a node_ptr and returning a new cloned node of it. "disposer" must - //! take a node_ptr and shouldn't throw. - //! - //! Effects: First empties target tree calling - //! void disposer::operator()(const node_ptr &) for every node of the tree - //! except the header. - //! - //! Then, duplicates the entire tree pointed by "source_header" cloning each - //! source node with node_ptr Cloner::operator()(const node_ptr &) to obtain - //! the nodes of the target tree. If "cloner" throws, the cloned target nodes - //! are disposed using void disposer(const node_ptr &). - //! - //! Complexity: Linear to the number of element of the source tree plus the. - //! number of elements of tree target tree when calling this function. - //! - //! Throws: If cloner functor throws. If this happens target nodes are disposed. - template - static void clone - (const const_node_ptr & source_header, const node_ptr & target_header, Cloner cloner, Disposer disposer) - { - if(!unique(target_header)){ - clear_and_dispose(target_header, disposer); - } - - node_ptr leftmost, rightmost; - node_ptr new_root = clone_subtree - (source_header, target_header, cloner, disposer, leftmost, rightmost); - - //Now update header node - NodeTraits::set_parent(target_header, new_root); - NodeTraits::set_left (target_header, leftmost); - NodeTraits::set_right (target_header, rightmost); - } - - //! Requires: header must be the header of a tree, z a node - //! of that tree and z != header. - //! - //! Effects: Erases node "z" from the tree with header "header". - //! - //! Complexity: Amortized constant time. - //! - //! Throws: Nothing. - static void erase(const node_ptr & header, const node_ptr & z) - { - data_for_rebalance ignored; - erase(header, z, ignored); - } - - //! Requires: node is a tree node but not the header. - //! - //! Effects: Unlinks the node and rebalances the tree. - //! - //! Complexity: Average complexity is constant time. - //! - //! Throws: Nothing. - static void unlink(const node_ptr & node) - { - node_ptr x = NodeTraits::get_parent(node); - if(x){ - while(!is_header(x)) - x = NodeTraits::get_parent(x); - erase(x, node); - } - } - - //! Requires: header must be the header of a tree. - //! - //! Effects: Rebalances the tree. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear. - static void rebalance(const node_ptr & header) - { - node_ptr root = NodeTraits::get_parent(header); - if(root){ - rebalance_subtree(root); - } - } - - //! Requires: old_root is a node of a tree. It shall not be null. - //! - //! Effects: Rebalances the subtree rooted at old_root. - //! - //! Returns: The new root of the subtree. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear. - static node_ptr rebalance_subtree(const node_ptr & old_root) - { - //Taken from: - //"Tree rebalancing in optimal time and space" - //Quentin F. Stout and Bette L. Warren - - //To avoid irregularities in the algorithm (old_root can be a - //left or right child or even the root of the tree) just put the - //root as the right child of its parent. Before doing this backup - //information to restore the original relationship after - //the algorithm is applied. - node_ptr super_root = NodeTraits::get_parent(old_root); - BOOST_INTRUSIVE_INVARIANT_ASSERT(super_root); - - //Get root info - node_ptr super_root_right_backup = NodeTraits::get_right(super_root); - bool super_root_is_header = NodeTraits::get_parent(super_root) == old_root; - bool old_root_is_right = is_right_child(old_root); - NodeTraits::set_right(super_root, old_root); - - std::size_t size; - subtree_to_vine(super_root, size); - vine_to_subtree(super_root, size); - node_ptr new_root = NodeTraits::get_right(super_root); - - //Recover root - if(super_root_is_header){ - NodeTraits::set_right(super_root, super_root_right_backup); - NodeTraits::set_parent(super_root, new_root); - } - else if(old_root_is_right){ - NodeTraits::set_right(super_root, new_root); - } - else{ - NodeTraits::set_right(super_root, super_root_right_backup); - NodeTraits::set_left(super_root, new_root); - } - return new_root; - } - - //! Effects: Asserts the integrity of the container with additional checks provided by the user. - //! - //! Requires: header must be the header of a tree. - //! - //! Complexity: Linear time. - //! - //! Note: The method might not have effect when asserts are turned off (e.g., with NDEBUG). - //! Experimental function, interface might change in future versions. - template - static void check(const const_node_ptr& header, Checker checker, typename Checker::return_type& checker_return) - { - const_node_ptr root_node_ptr = NodeTraits::get_parent(header); - if (!root_node_ptr) - { - // check left&right header pointers - BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_left(header) == header); - BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_right(header) == header); - } - else - { - // check parent pointer of root node - BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_parent(root_node_ptr) == header); - // check subtree from root - check_subtree(root_node_ptr, checker, checker_return); - // check left&right header pointers - const_node_ptr p = root_node_ptr; - while (NodeTraits::get_left(p)) { p = NodeTraits::get_left(p); } - BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_left(header) == p); - p = root_node_ptr; - while (NodeTraits::get_right(p)) { p = NodeTraits::get_right(p); } - BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_right(header) == p); - } - } - - protected: - static void erase(const node_ptr & header, const node_ptr & z, data_for_rebalance &info) - { - node_ptr y(z); - node_ptr x; - const node_ptr z_left(NodeTraits::get_left(z)); - const node_ptr z_right(NodeTraits::get_right(z)); - - if(!z_left){ - x = z_right; // x might be null. - } - else if(!z_right){ // z has exactly one non-null child. y == z. - x = z_left; // x is not null. - BOOST_ASSERT(x); - } - else{ //make y != z - // y = find z's successor - y = bstree_algorithms::minimum(z_right); - x = NodeTraits::get_right(y); // x might be null. - } - - node_ptr x_parent; - const node_ptr z_parent(NodeTraits::get_parent(z)); - const bool z_is_leftchild(NodeTraits::get_left(z_parent) == z); - - if(y != z){ //has two children and y is the minimum of z - //y is z's successor and it has a null left child. - //x is the right child of y (it can be null) - //Relink y in place of z and link x with y's old parent - NodeTraits::set_parent(z_left, y); - NodeTraits::set_left(y, z_left); - if(y != z_right){ - //Link y with the right tree of z - NodeTraits::set_right(y, z_right); - NodeTraits::set_parent(z_right, y); - //Link x with y's old parent (y must be a left child) - x_parent = NodeTraits::get_parent(y); - BOOST_ASSERT(NodeTraits::get_left(x_parent) == y); - if(x) - NodeTraits::set_parent(x, x_parent); - //Since y was the successor and not the right child of z, it must be a left child - NodeTraits::set_left(x_parent, x); - } - else{ //y was the right child of y so no need to fix x's position - x_parent = y; - } - NodeTraits::set_parent(y, z_parent); - bstree_algorithms::set_child(header, y, z_parent, z_is_leftchild); - } - else { // z has zero or one child, x is one child (it can be null) - //Just link x to z's parent - x_parent = z_parent; - if(x) - NodeTraits::set_parent(x, z_parent); - bstree_algorithms::set_child(header, x, z_parent, z_is_leftchild); - - //Now update leftmost/rightmost in case z was one of them - if(NodeTraits::get_left(header) == z){ - //z_left must be null because z is the leftmost - BOOST_ASSERT(!z_left); - NodeTraits::set_left(header, !z_right ? - z_parent : // makes leftmost == header if z == root - bstree_algorithms::minimum(z_right)); - } - if(NodeTraits::get_right(header) == z){ - //z_right must be null because z is the rightmost - BOOST_ASSERT(!z_right); - NodeTraits::set_right(header, !z_left ? - z_parent : // makes rightmost == header if z == root - bstree_algorithms::maximum(z_left)); - } - } - - //If z had 0/1 child, y == z and one of its children (and maybe null) - //If z had 2 children, y is the successor of z and x is the right child of y - info.x = x; - info.y = y; - //If z had 0/1 child, x_parent is the new parent of the old right child of y (z's successor) - //If z had 2 children, x_parent is the new parent of y (z_parent) - BOOST_ASSERT(!x || NodeTraits::get_parent(x) == x_parent); - info.x_parent = x_parent; - } - - //! Requires: node is a node of the tree but it's not the header. - //! - //! Effects: Returns the number of nodes of the subtree. - //! - //! Complexity: Linear time. - //! - //! Throws: Nothing. - static std::size_t subtree_size(const const_node_ptr & subtree) - { - std::size_t count = 0; - if (subtree){ - node_ptr n = detail::uncast(subtree); - node_ptr m = NodeTraits::get_left(n); - while(m){ - n = m; - m = NodeTraits::get_left(n); - } - - while(1){ - ++count; - node_ptr n_right(NodeTraits::get_right(n)); - if(n_right){ - n = n_right; - m = NodeTraits::get_left(n); - while(m){ - n = m; - m = NodeTraits::get_left(n); - } - } - else { - do{ - if (n == subtree){ - return count; - } - m = n; - n = NodeTraits::get_parent(n); - }while(NodeTraits::get_left(n) != m); - } - } - } - return count; - } - - //! Requires: p is a node of a tree. - //! - //! Effects: Returns true if p is a left child. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - static bool is_left_child(const node_ptr & p) - { return NodeTraits::get_left(NodeTraits::get_parent(p)) == p; } - - //! Requires: p is a node of a tree. - //! - //! Effects: Returns true if p is a right child. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - static bool is_right_child(const node_ptr & p) - { return NodeTraits::get_right(NodeTraits::get_parent(p)) == p; } - - static void insert_before_check - (const node_ptr &header, const node_ptr & pos - , insert_commit_data &commit_data - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - , std::size_t *pdepth = 0 - #endif - ) - { - node_ptr prev(pos); - if(pos != NodeTraits::get_left(header)) - prev = prev_node(pos); - bool link_left = unique(header) || !NodeTraits::get_left(pos); - commit_data.link_left = link_left; - commit_data.node = link_left ? pos : prev; - if(pdepth){ - *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1; - } - } - - static void push_back_check - (const node_ptr & header, insert_commit_data &commit_data - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - , std::size_t *pdepth = 0 - #endif - ) - { - node_ptr prev(NodeTraits::get_right(header)); - if(pdepth){ - *pdepth = prev == header ? 0 : depth(prev) + 1; - } - commit_data.link_left = false; - commit_data.node = prev; - } - - static void push_front_check - (const node_ptr & header, insert_commit_data &commit_data - #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - , std::size_t *pdepth = 0 - #endif - ) - { - node_ptr pos(NodeTraits::get_left(header)); - if(pdepth){ - *pdepth = pos == header ? 0 : depth(pos) + 1; - } - commit_data.link_left = true; - commit_data.node = pos; - } - - template - static void insert_equal_check - (const node_ptr &header, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp - , insert_commit_data &commit_data - /// @cond - , std::size_t *pdepth = 0 - /// @endcond - ) - { - if(hint == header || !comp(hint, new_node)){ - node_ptr prev(hint); - if(hint == NodeTraits::get_left(header) || - !comp(new_node, (prev = prev_node(hint)))){ - bool link_left = unique(header) || !NodeTraits::get_left(hint); - commit_data.link_left = link_left; - commit_data.node = link_left ? hint : prev; - if(pdepth){ - *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1; - } - } - else{ - insert_equal_upper_bound_check(header, new_node, comp, commit_data, pdepth); - } - } - else{ - insert_equal_lower_bound_check(header, new_node, comp, commit_data, pdepth); - } - } - - template - static void insert_equal_upper_bound_check - (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, insert_commit_data & commit_data, std::size_t *pdepth = 0) - { - std::size_t depth = 0; - node_ptr y(h); - node_ptr x(NodeTraits::get_parent(y)); - - while(x){ - ++depth; - y = x; - x = comp(new_node, x) ? - NodeTraits::get_left(x) : NodeTraits::get_right(x); - } - if(pdepth) *pdepth = depth; - commit_data.link_left = (y == h) || comp(new_node, y); - commit_data.node = y; - } - - template - static void insert_equal_lower_bound_check - (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, insert_commit_data & commit_data, std::size_t *pdepth = 0) - { - std::size_t depth = 0; - node_ptr y(h); - node_ptr x(NodeTraits::get_parent(y)); - - while(x){ - ++depth; - y = x; - x = !comp(x, new_node) ? - NodeTraits::get_left(x) : NodeTraits::get_right(x); - } - if(pdepth) *pdepth = depth; - commit_data.link_left = (y == h) || !comp(y, new_node); - commit_data.node = y; - } - - static void insert_commit - (const node_ptr & header, const node_ptr & new_node, const insert_commit_data &commit_data) - { - //Check if commit_data has not been initialized by a insert_unique_check call. - BOOST_INTRUSIVE_INVARIANT_ASSERT(commit_data.node != node_ptr()); - node_ptr parent_node(commit_data.node); - if(parent_node == header){ - NodeTraits::set_parent(header, new_node); - NodeTraits::set_right(header, new_node); - NodeTraits::set_left(header, new_node); - } - else if(commit_data.link_left){ - NodeTraits::set_left(parent_node, new_node); - if(parent_node == NodeTraits::get_left(header)) - NodeTraits::set_left(header, new_node); - } - else{ - NodeTraits::set_right(parent_node, new_node); - if(parent_node == NodeTraits::get_right(header)) - NodeTraits::set_right(header, new_node); - } - NodeTraits::set_parent(new_node, parent_node); - NodeTraits::set_right(new_node, node_ptr()); - NodeTraits::set_left(new_node, node_ptr()); - } - - //Fix header and own's parent data when replacing x with own, providing own's old data with parent - static void set_child(const node_ptr & header, const node_ptr & new_child, const node_ptr & new_parent, const bool link_left) - { - if(new_parent == header) - NodeTraits::set_parent(header, new_child); - else if(link_left) - NodeTraits::set_left(new_parent, new_child); - else - NodeTraits::set_right(new_parent, new_child); - } - - // rotate p to left (no header and p's parent fixup) - static void rotate_left_no_parent_fix(const node_ptr & p, const node_ptr &p_right) - { - node_ptr p_right_left(NodeTraits::get_left(p_right)); - NodeTraits::set_right(p, p_right_left); - if(p_right_left){ - NodeTraits::set_parent(p_right_left, p); - } - NodeTraits::set_left(p_right, p); - NodeTraits::set_parent(p, p_right); - } - - // rotate p to left (with header and p's parent fixup) - static void rotate_left(const node_ptr & p, const node_ptr & p_right, const node_ptr & p_parent, const node_ptr & header) - { - const bool p_was_left(NodeTraits::get_left(p_parent) == p); - rotate_left_no_parent_fix(p, p_right); - NodeTraits::set_parent(p_right, p_parent); - set_child(header, p_right, p_parent, p_was_left); - } - - // rotate p to right (no header and p's parent fixup) - static void rotate_right_no_parent_fix(const node_ptr & p, const node_ptr &p_left) - { - node_ptr p_left_right(NodeTraits::get_right(p_left)); - NodeTraits::set_left(p, p_left_right); - if(p_left_right){ - NodeTraits::set_parent(p_left_right, p); - } - NodeTraits::set_right(p_left, p); - NodeTraits::set_parent(p, p_left); - } - - // rotate p to right (with header and p's parent fixup) - static void rotate_right(const node_ptr & p, const node_ptr & p_left, const node_ptr & p_parent, const node_ptr & header) - { - const bool p_was_left(NodeTraits::get_left(p_parent) == p); - rotate_right_no_parent_fix(p, p_left); - NodeTraits::set_parent(p_left, p_parent); - set_child(header, p_left, p_parent, p_was_left); - } - - private: - - static void subtree_to_vine(node_ptr vine_tail, std::size_t &size) - { - //Inspired by LibAVL: - //It uses a clever optimization for trees with parent pointers. - //No parent pointer is updated when transforming a tree to a vine as - //most of them will be overriten during compression rotations. - //A final pass must be made after the rebalancing to updated those - //pointers not updated by tree_to_vine + compression calls - std::size_t len = 0; - node_ptr remainder = NodeTraits::get_right(vine_tail); - while(remainder){ - node_ptr tempptr = NodeTraits::get_left(remainder); - if(!tempptr){ //move vine-tail down one - vine_tail = remainder; - remainder = NodeTraits::get_right(remainder); - ++len; - } - else{ //rotate - NodeTraits::set_left(remainder, NodeTraits::get_right(tempptr)); - NodeTraits::set_right(tempptr, remainder); - remainder = tempptr; - NodeTraits::set_right(vine_tail, tempptr); - } - } - size = len; - } - - static void compress_subtree(node_ptr scanner, std::size_t count) - { - while(count--){ //compress "count" spine nodes in the tree with pseudo-root scanner - node_ptr child = NodeTraits::get_right(scanner); - node_ptr child_right = NodeTraits::get_right(child); - NodeTraits::set_right(scanner, child_right); - //Avoid setting the parent of child_right - scanner = child_right; - node_ptr scanner_left = NodeTraits::get_left(scanner); - NodeTraits::set_right(child, scanner_left); - if(scanner_left) - NodeTraits::set_parent(scanner_left, child); - NodeTraits::set_left(scanner, child); - NodeTraits::set_parent(child, scanner); - } - } - - static void vine_to_subtree(const node_ptr & super_root, std::size_t count) - { - const std::size_t one_szt = 1u; - std::size_t leaf_nodes = count + one_szt - std::size_t(one_szt << detail::floor_log2(count + one_szt)); - compress_subtree(super_root, leaf_nodes); //create deepest leaves - std::size_t vine_nodes = count - leaf_nodes; - while(vine_nodes > 1){ - vine_nodes /= 2; - compress_subtree(super_root, vine_nodes); - } - - //Update parents of nodes still in the in the original vine line - //as those have not been updated by subtree_to_vine or compress_subtree - for ( node_ptr q = super_root, p = NodeTraits::get_right(super_root) - ; p - ; q = p, p = NodeTraits::get_right(p)){ - NodeTraits::set_parent(p, q); - } - } - - //! Requires: "n" must be a node inserted in a tree. - //! - //! Effects: Returns a pointer to the header node of the tree. - //! - //! Complexity: Logarithmic. - //! - //! Throws: Nothing. - static node_ptr get_root(const node_ptr & node) - { - BOOST_INTRUSIVE_INVARIANT_ASSERT((!inited(node))); - node_ptr x = NodeTraits::get_parent(node); - if(x){ - while(!is_header(x)){ - x = NodeTraits::get_parent(x); - } - return x; - } - else{ - return node; - } - } - - template - static node_ptr clone_subtree - (const const_node_ptr &source_parent, const node_ptr &target_parent - , Cloner cloner, Disposer disposer - , node_ptr &leftmost_out, node_ptr &rightmost_out - ) - { - node_ptr target_sub_root = target_parent; - node_ptr source_root = NodeTraits::get_parent(source_parent); - if(!source_root){ - leftmost_out = rightmost_out = source_root; - } - else{ - //We'll calculate leftmost and rightmost nodes while iterating - node_ptr current = source_root; - node_ptr insertion_point = target_sub_root = cloner(current); - - //We'll calculate leftmost and rightmost nodes while iterating - node_ptr leftmost = target_sub_root; - node_ptr rightmost = target_sub_root; - - //First set the subroot - NodeTraits::set_left(target_sub_root, node_ptr()); - NodeTraits::set_right(target_sub_root, node_ptr()); - NodeTraits::set_parent(target_sub_root, target_parent); - - dispose_subtree_disposer rollback(disposer, target_sub_root); - while(true) { - //First clone left nodes - if( NodeTraits::get_left(current) && - !NodeTraits::get_left(insertion_point)) { - current = NodeTraits::get_left(current); - node_ptr temp = insertion_point; - //Clone and mark as leaf - insertion_point = cloner(current); - NodeTraits::set_left (insertion_point, node_ptr()); - NodeTraits::set_right (insertion_point, node_ptr()); - //Insert left - NodeTraits::set_parent(insertion_point, temp); - NodeTraits::set_left (temp, insertion_point); - //Update leftmost - if(rightmost == target_sub_root) - leftmost = insertion_point; - } - //Then clone right nodes - else if( NodeTraits::get_right(current) && - !NodeTraits::get_right(insertion_point)){ - current = NodeTraits::get_right(current); - node_ptr temp = insertion_point; - //Clone and mark as leaf - insertion_point = cloner(current); - NodeTraits::set_left (insertion_point, node_ptr()); - NodeTraits::set_right (insertion_point, node_ptr()); - //Insert right - NodeTraits::set_parent(insertion_point, temp); - NodeTraits::set_right (temp, insertion_point); - //Update rightmost - rightmost = insertion_point; - } - //If not, go up - else if(current == source_root){ - break; - } - else{ - //Branch completed, go up searching more nodes to clone - current = NodeTraits::get_parent(current); - insertion_point = NodeTraits::get_parent(insertion_point); - } - } - rollback.release(); - leftmost_out = leftmost; - rightmost_out = rightmost; - } - return target_sub_root; - } - - template - static void dispose_subtree(node_ptr x, Disposer disposer) - { - while (x){ - node_ptr save(NodeTraits::get_left(x)); - if (save) { - // Right rotation - NodeTraits::set_left(x, NodeTraits::get_right(save)); - NodeTraits::set_right(save, x); - } - else { - save = NodeTraits::get_right(x); - init(x); - disposer(x); - } - x = save; - } - } - - template - static node_ptr lower_bound_loop - (node_ptr x, node_ptr y, const KeyType &key, KeyNodePtrCompare comp) - { - while(x){ - if(comp(x, key)){ - x = NodeTraits::get_right(x); - } - else{ - y = x; - x = NodeTraits::get_left(x); - } - } - return y; - } - - template - static node_ptr upper_bound_loop - (node_ptr x, node_ptr y, const KeyType &key, KeyNodePtrCompare comp) - { - while(x){ - if(comp(key, x)){ - y = x; - x = NodeTraits::get_left(x); - } - else{ - x = NodeTraits::get_right(x); - } - } - return y; - } - - template - static void check_subtree(const const_node_ptr& node, Checker checker, typename Checker::return_type& check_return) - { - const_node_ptr left = NodeTraits::get_left(node); - const_node_ptr right = NodeTraits::get_right(node); - typename Checker::return_type check_return_left; - typename Checker::return_type check_return_right; - if (left) - { - BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_parent(left) == node); - check_subtree(left, checker, check_return_left); - } - if (right) - { - BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_parent(right) == node); - check_subtree(right, checker, check_return_right); - } - checker(node, check_return_left, check_return_right, check_return); - } -}; - -/// @cond - -template -struct get_algo -{ - typedef bstree_algorithms type; -}; - -template -struct get_node_checker -{ - typedef detail::bstree_node_checker type; -}; - -/// @endcond - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_BSTREE_ALGORITHMS_HPP diff --git a/boost/intrusive/circular_list_algorithms.hpp b/boost/intrusive/circular_list_algorithms.hpp deleted file mode 100644 index 1e888a1..0000000 --- a/boost/intrusive/circular_list_algorithms.hpp +++ /dev/null @@ -1,507 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_CIRCULAR_LIST_ALGORITHMS_HPP -#define BOOST_INTRUSIVE_CIRCULAR_LIST_ALGORITHMS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -//! circular_list_algorithms provides basic algorithms to manipulate nodes -//! forming a circular doubly linked list. An empty circular list is formed by a node -//! whose pointers point to itself. -//! -//! circular_list_algorithms is configured with a NodeTraits class, which encapsulates the -//! information about the node to be manipulated. NodeTraits must support the -//! following interface: -//! -//! Typedefs: -//! -//! node: The type of the node that forms the circular list -//! -//! node_ptr: A pointer to a node -//! -//! const_node_ptr: A pointer to a const node -//! -//! Static functions: -//! -//! static node_ptr get_previous(const_node_ptr n); -//! -//! static void set_previous(node_ptr n, node_ptr prev); -//! -//! static node_ptr get_next(const_node_ptr n); -//! -//! static void set_next(node_ptr n, node_ptr next); -template -class circular_list_algorithms -{ - public: - typedef typename NodeTraits::node node; - typedef typename NodeTraits::node_ptr node_ptr; - typedef typename NodeTraits::const_node_ptr const_node_ptr; - typedef NodeTraits node_traits; - - //! Effects: Constructs an non-used list element, so that - //! inited(this_node) == true - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void init(const node_ptr &this_node) - { - const node_ptr null_node((node_ptr())); - NodeTraits::set_next(this_node, null_node); - NodeTraits::set_previous(this_node, null_node); - } - - //! Effects: Returns true is "this_node" is in a non-used state - //! as if it was initialized by the "init" function. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static bool inited(const const_node_ptr &this_node) - { return !NodeTraits::get_next(this_node); } - - //! Effects: Constructs an empty list, making this_node the only - //! node of the circular list: - //! NodeTraits::get_next(this_node) == NodeTraits::get_previous(this_node) - //! == this_node. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void init_header(const node_ptr &this_node) - { - NodeTraits::set_next(this_node, this_node); - NodeTraits::set_previous(this_node, this_node); - } - - - //! Requires: this_node must be in a circular list or be an empty circular list. - //! - //! Effects: Returns true is "this_node" is the only node of a circular list: - //! return NodeTraits::get_next(this_node) == this_node - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static bool unique(const const_node_ptr &this_node) - { - node_ptr next = NodeTraits::get_next(this_node); - return !next || next == this_node; - } - - //! Requires: this_node must be in a circular list or be an empty circular list. - //! - //! Effects: Returns the number of nodes in a circular list. If the circular list - //! is empty, returns 1. - //! - //! Complexity: Linear - //! - //! Throws: Nothing. - static std::size_t count(const const_node_ptr &this_node) - { - std::size_t result = 0; - const_node_ptr p = this_node; - do{ - p = NodeTraits::get_next(p); - ++result; - }while (p != this_node); - return result; - } - - //! Requires: this_node must be in a circular list or be an empty circular list. - //! - //! Effects: Unlinks the node from the circular list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static node_ptr unlink(const node_ptr &this_node) - { - node_ptr next(NodeTraits::get_next(this_node)); - node_ptr prev(NodeTraits::get_previous(this_node)); - NodeTraits::set_next(prev, next); - NodeTraits::set_previous(next, prev); - return next; - } - - //! Requires: b and e must be nodes of the same circular list or an empty range. - //! - //! Effects: Unlinks the node [b, e) from the circular list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void unlink(const node_ptr &b, const node_ptr &e) - { - if (b != e) { - node_ptr prevb(NodeTraits::get_previous(b)); - NodeTraits::set_previous(e, prevb); - NodeTraits::set_next(prevb, e); - } - } - - //! Requires: nxt_node must be a node of a circular list. - //! - //! Effects: Links this_node before nxt_node in the circular list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void link_before(const node_ptr &nxt_node, const node_ptr &this_node) - { - node_ptr prev(NodeTraits::get_previous(nxt_node)); - NodeTraits::set_previous(this_node, prev); - NodeTraits::set_next(this_node, nxt_node); - //nxt_node might be an alias for prev->next_ - //so use it before NodeTraits::set_next(prev, ...) - //is called and the reference changes it's value - NodeTraits::set_previous(nxt_node, this_node); - NodeTraits::set_next(prev, this_node); - } - - //! Requires: prev_node must be a node of a circular list. - //! - //! Effects: Links this_node after prev_node in the circular list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void link_after(const node_ptr &prev_node, const node_ptr &this_node) - { - node_ptr next(NodeTraits::get_next(prev_node)); - NodeTraits::set_previous(this_node, prev_node); - NodeTraits::set_next(this_node, next); - //prev_node might be an alias for next->next_ - //so use it before update it before NodeTraits::set_previous(next, ...) - //is called and the reference changes it's value - NodeTraits::set_next(prev_node, this_node); - NodeTraits::set_previous(next, this_node); - } - - //! Requires: this_node and other_node must be nodes inserted - //! in circular lists or be empty circular lists. - //! - //! Effects: Swaps the position of the nodes: this_node is inserted in - //! other_nodes position in the second circular list and the other_node is inserted - //! in this_node's position in the first circular list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. -/* - static void swap_nodes(const node_ptr &this_node, const node_ptr &other_node) - { - - if (other_node == this_node) - return; - bool empty1 = unique(this_node); - bool empty2 = unique(other_node); - - node_ptr next_this(NodeTraits::get_next(this_node)); - node_ptr prev_this(NodeTraits::get_previous(this_node)); - node_ptr next_other(NodeTraits::get_next(other_node)); - node_ptr prev_other(NodeTraits::get_previous(other_node)); - - //Do the swap - NodeTraits::set_next(this_node, next_other); - NodeTraits::set_next(other_node, next_this); - - NodeTraits::set_previous(this_node, prev_other); - NodeTraits::set_previous(other_node, prev_this); - - if (empty2){ - init(this_node); - } - else{ - NodeTraits::set_next(prev_other, this_node); - NodeTraits::set_previous(next_other, this_node); - } - if (empty1){ - init(other_node); - } - else{ - NodeTraits::set_next(prev_this, other_node); - NodeTraits::set_previous(next_this, other_node); - } - } -*/ - - //Watanabe version - private: - static void swap_prev(const node_ptr &this_node, const node_ptr &other_node) - { - node_ptr temp(NodeTraits::get_previous(this_node)); - NodeTraits::set_previous(this_node, NodeTraits::get_previous(other_node)); - NodeTraits::set_previous(other_node, temp); - } - static void swap_next(const node_ptr &this_node, const node_ptr &other_node) - { - node_ptr temp(NodeTraits::get_next(this_node)); - NodeTraits::set_next(this_node, NodeTraits::get_next(other_node)); - NodeTraits::set_next(other_node, temp); - } - - public: - static void swap_nodes(const node_ptr &this_node, const node_ptr &other_node) - { - if (other_node == this_node) - return; - bool this_inited = inited(this_node); - bool other_inited = inited(other_node); - if(this_inited){ - init_header(this_node); - } - if(other_inited){ - init_header(other_node); - } - - node_ptr next_this(NodeTraits::get_next(this_node)); - node_ptr prev_this(NodeTraits::get_previous(this_node)); - node_ptr next_other(NodeTraits::get_next(other_node)); - node_ptr prev_other(NodeTraits::get_previous(other_node)); - //these first two swaps must happen before the other two - swap_prev(next_this, next_other); - swap_next(prev_this, prev_other); - swap_next(this_node, other_node); - swap_prev(this_node, other_node); - - if(this_inited){ - init(other_node); - } - if(other_inited){ - init(this_node); - } - } - - //! Requires: b and e must be nodes of the same circular list or an empty range. - //! and p must be a node of a different circular list or may not be an iterator in - // [b, e). - //! - //! Effects: Removes the nodes from [b, e) range from their circular list and inserts - //! them before p in p's circular list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void transfer(const node_ptr &p, const node_ptr &b, const node_ptr &e) - { - if (b != e) { - node_ptr prev_p(NodeTraits::get_previous(p)); - node_ptr prev_b(NodeTraits::get_previous(b)); - node_ptr prev_e(NodeTraits::get_previous(e)); - NodeTraits::set_next(prev_e, p); - NodeTraits::set_previous(p, prev_e); - NodeTraits::set_next(prev_b, e); - NodeTraits::set_previous(e, prev_b); - NodeTraits::set_next(prev_p, b); - NodeTraits::set_previous(b, prev_p); - } - } - - //! Requires: i must a node of a circular list - //! and p must be a node of a different circular list. - //! - //! Effects: Removes the node i from its circular list and inserts - //! it before p in p's circular list. - //! If p == i or p == NodeTraits::get_next(i), this function is a null operation. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void transfer(const node_ptr &p, const node_ptr &i) - { - node_ptr n(NodeTraits::get_next(i)); - if(n != p && i != p){ - node_ptr prev_p(NodeTraits::get_previous(p)); - node_ptr prev_i(NodeTraits::get_previous(i)); - NodeTraits::set_next(prev_p, i); - NodeTraits::set_previous(i, prev_p); - NodeTraits::set_next(i, p); - NodeTraits::set_previous(p, i); - NodeTraits::set_previous(n, prev_i); - NodeTraits::set_next(prev_i, n); - - } - } - - //! Effects: Reverses the order of elements in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: This function is linear time. - static void reverse(const node_ptr &p) - { - node_ptr f(NodeTraits::get_next(p)); - node_ptr i(NodeTraits::get_next(f)), e(p); - - while(i != e) { - node_ptr n = i; - i = NodeTraits::get_next(i); - transfer(f, n, i); - f = n; - } - } - - //! Effects: Moves the node p n positions towards the end of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of moved positions. - static void move_backwards(const node_ptr &p, std::size_t n) - { - //Null shift, nothing to do - if(!n) return; - node_ptr first = NodeTraits::get_next(p); - //size() == 0 or 1, nothing to do - if(first == NodeTraits::get_previous(p)) return; - unlink(p); - //Now get the new first node - while(n--){ - first = NodeTraits::get_next(first); - } - link_before(first, p); - } - - //! Effects: Moves the node p n positions towards the beginning of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of moved positions. - static void move_forward(const node_ptr &p, std::size_t n) - { - //Null shift, nothing to do - if(!n) return; - node_ptr last = NodeTraits::get_previous(p); - //size() == 0 or 1, nothing to do - if(last == NodeTraits::get_next(p)) return; - - unlink(p); - //Now get the new last node - while(n--){ - last = NodeTraits::get_previous(last); - } - link_after(last, p); - } - - //! Requires: f and l must be in a circular list. - //! - //! Effects: Returns the number of nodes in the range [f, l). - //! - //! Complexity: Linear - //! - //! Throws: Nothing. - static std::size_t distance(const const_node_ptr &f, const const_node_ptr &l) - { - const_node_ptr i(f); - std::size_t result = 0; - while(i != l){ - i = NodeTraits::get_next(i); - ++result; - } - return result; - } - - struct stable_partition_info - { - std::size_t num_1st_partition; - std::size_t num_2nd_partition; - node_ptr beg_2st_partition; - }; - - template - static void stable_partition(node_ptr beg, const node_ptr &end, Pred pred, stable_partition_info &info) - { - node_ptr bcur = node_traits::get_previous(beg); - node_ptr cur = beg; - node_ptr new_f = end; - - std::size_t num1 = 0, num2 = 0; - while(cur != end){ - if(pred(cur)){ - ++num1; - bcur = cur; - cur = node_traits::get_next(cur); - } - else{ - ++num2; - node_ptr last_to_remove = bcur; - new_f = cur; - bcur = cur; - cur = node_traits::get_next(cur); - BOOST_TRY{ - //Main loop - while(cur != end){ - if(pred(cur)){ //Might throw - ++num1; - //Process current node - node_traits::set_next (last_to_remove, cur); - node_traits::set_previous(cur, last_to_remove); - last_to_remove = cur; - node_ptr nxt = node_traits::get_next(cur); - node_traits::set_next (bcur, nxt); - node_traits::set_previous(nxt, bcur); - cur = nxt; - } - else{ - ++num2; - bcur = cur; - cur = node_traits::get_next(cur); - } - } - } - BOOST_CATCH(...){ - node_traits::set_next (last_to_remove, new_f); - node_traits::set_previous(new_f, last_to_remove); - throw; - } - BOOST_CATCH_END - node_traits::set_next(last_to_remove, new_f); - node_traits::set_previous(new_f, last_to_remove); - break; - } - } - info.num_1st_partition = num1; - info.num_2nd_partition = num2; - info.beg_2st_partition = new_f; - } -}; - -/// @cond - -template -struct get_algo -{ - typedef circular_list_algorithms type; -}; - -/// @endcond - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_CIRCULAR_LIST_ALGORITHMS_HPP diff --git a/boost/intrusive/circular_slist_algorithms.hpp b/boost/intrusive/circular_slist_algorithms.hpp deleted file mode 100644 index 3dd561d..0000000 --- a/boost/intrusive/circular_slist_algorithms.hpp +++ /dev/null @@ -1,407 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP -#define BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include - - -namespace boost { -namespace intrusive { - -//! circular_slist_algorithms provides basic algorithms to manipulate nodes -//! forming a circular singly linked list. An empty circular list is formed by a node -//! whose pointer to the next node points to itself. -//! -//! circular_slist_algorithms is configured with a NodeTraits class, which encapsulates the -//! information about the node to be manipulated. NodeTraits must support the -//! following interface: -//! -//! Typedefs: -//! -//! node: The type of the node that forms the circular list -//! -//! node_ptr: A pointer to a node -//! -//! const_node_ptr: A pointer to a const node -//! -//! Static functions: -//! -//! static node_ptr get_next(const_node_ptr n); -//! -//! static void set_next(node_ptr n, node_ptr next); -template -class circular_slist_algorithms - /// @cond - : public detail::common_slist_algorithms - /// @endcond -{ - /// @cond - typedef detail::common_slist_algorithms base_t; - /// @endcond - public: - typedef typename NodeTraits::node node; - typedef typename NodeTraits::node_ptr node_ptr; - typedef typename NodeTraits::const_node_ptr const_node_ptr; - typedef NodeTraits node_traits; - - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - - //! Effects: Constructs an non-used list element, putting the next - //! pointer to null: - //! NodeTraits::get_next(this_node) == node_ptr() - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void init(node_ptr this_node); - - //! Requires: this_node must be in a circular list or be an empty circular list. - //! - //! Effects: Returns true is "this_node" is the only node of a circular list: - //! or it's a not inserted node: - //! return node_ptr() == NodeTraits::get_next(this_node) || NodeTraits::get_next(this_node) == this_node - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static bool unique(const_node_ptr this_node); - - //! Effects: Returns true is "this_node" has the same state as - //! if it was inited using "init(node_ptr)" - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static bool inited(const_node_ptr this_node); - - //! Requires: prev_node must be in a circular list or be an empty circular list. - //! - //! Effects: Unlinks the next node of prev_node from the circular list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void unlink_after(node_ptr prev_node); - - //! Requires: prev_node and last_node must be in a circular list - //! or be an empty circular list. - //! - //! Effects: Unlinks the range (prev_node, last_node) from the circular list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void unlink_after(node_ptr prev_node, node_ptr last_node); - - //! Requires: prev_node must be a node of a circular list. - //! - //! Effects: Links this_node after prev_node in the circular list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void link_after(node_ptr prev_node, node_ptr this_node); - - //! Requires: b and e must be nodes of the same circular list or an empty range. - //! and p must be a node of a different circular list. - //! - //! Effects: Removes the nodes from (b, e] range from their circular list and inserts - //! them after p in p's circular list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void transfer_after(node_ptr p, node_ptr b, node_ptr e); - - #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - - //! Effects: Constructs an empty list, making this_node the only - //! node of the circular list: - //! NodeTraits::get_next(this_node) == this_node. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void init_header(const node_ptr &this_node) - { NodeTraits::set_next(this_node, this_node); } - - //! Requires: this_node and prev_init_node must be in the same circular list. - //! - //! Effects: Returns 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(prev_init_node). - //! - //! Complexity: Linear to the number of elements between prev_init_node and this_node. - //! - //! Throws: Nothing. - static node_ptr get_previous_node(const node_ptr &prev_init_node, const node_ptr &this_node) - { return base_t::get_previous_node(prev_init_node, this_node); } - - //! Requires: this_node must be in a circular list or be an empty circular list. - //! - //! Effects: Returns the previous node of this_node in the circular list. - //! - //! Complexity: Linear to the number of elements in the circular list. - //! - //! Throws: Nothing. - static node_ptr get_previous_node(const node_ptr & this_node) - { return base_t::get_previous_node(this_node, this_node); } - - //! Requires: this_node must be in a circular list or be an empty circular list. - //! - //! Effects: Returns the previous node of the previous node of this_node in the circular list. - //! - //! Complexity: Linear to the number of elements in the circular list. - //! - //! Throws: Nothing. - static node_ptr get_previous_previous_node(const node_ptr & this_node) - { return get_previous_previous_node(this_node, this_node); } - - //! Requires: this_node and p must be in the same circular list. - //! - //! Effects: Returns the previous node of the previous node of this_node in the - //! circular list starting. the search from p. The first node checked - //! for equality is NodeTraits::get_next((NodeTraits::get_next(p)). - //! - //! Complexity: Linear to the number of elements in the circular list. - //! - //! Throws: Nothing. - static node_ptr get_previous_previous_node(node_ptr p, const node_ptr & this_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){ - p = p_next; - p_next = p_next_next; - p_next_next = NodeTraits::get_next(p_next); - } - return p; - } - - //! Requires: this_node must be in a circular list or be an empty circular list. - //! - //! Effects: Returns the number of nodes in a circular list. If the circular list - //! is empty, returns 1. - //! - //! Complexity: Linear - //! - //! Throws: Nothing. - static std::size_t count(const const_node_ptr & this_node) - { - std::size_t result = 0; - const_node_ptr p = this_node; - do{ - p = NodeTraits::get_next(p); - ++result; - } while (p != this_node); - return result; - } - - //! Requires: this_node must be in a circular list, be an empty circular list or be inited. - //! - //! Effects: Unlinks the node from the circular list. - //! - //! Complexity: Linear to the number of elements in the circular list - //! - //! Throws: Nothing. - static void unlink(const node_ptr & this_node) - { - if(NodeTraits::get_next(this_node)) - base_t::unlink_after(get_previous_node(this_node)); - } - - //! Requires: nxt_node must be a node of a circular list. - //! - //! Effects: Links this_node before nxt_node in the circular list. - //! - //! Complexity: Linear to the number of elements in the circular list. - //! - //! Throws: Nothing. - static void link_before (const node_ptr & nxt_node, const node_ptr & this_node) - { base_t::link_after(get_previous_node(nxt_node), this_node); } - - //! Requires: this_node and other_node must be nodes inserted - //! in circular lists or be empty circular lists. - //! - //! Effects: Swaps the position of the nodes: this_node is inserted in - //! other_nodes position in the second circular list and the other_node is inserted - //! in this_node's position in the first circular list. - //! - //! Complexity: Linear to number of elements of both lists - //! - //! Throws: Nothing. - static void swap_nodes(const node_ptr & this_node, const node_ptr & other_node) - { - if (other_node == this_node) - return; - const node_ptr this_next = NodeTraits::get_next(this_node); - const node_ptr other_next = NodeTraits::get_next(other_node); - const bool this_null = !this_next; - const bool other_null = !other_next; - const bool this_empty = this_next == this_node; - const bool other_empty = other_next == other_node; - - if(!(other_null || other_empty)){ - NodeTraits::set_next(this_next == other_node ? other_node : get_previous_node(other_node), this_node ); - } - if(!(this_null | this_empty)){ - NodeTraits::set_next(other_next == this_node ? this_node : get_previous_node(this_node), other_node ); - } - NodeTraits::set_next(this_node, other_empty ? this_node : (other_next == this_node ? other_node : other_next) ); - NodeTraits::set_next(other_node, this_empty ? other_node : (this_next == other_node ? this_node : this_next ) ); - } - - //! Effects: Reverses the order of elements in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: This function is linear to the contained elements. - static void reverse(const node_ptr & p) - { - node_ptr i = NodeTraits::get_next(p), e(p); - for (;;) { - node_ptr nxt(NodeTraits::get_next(i)); - if (nxt == e) - break; - base_t::transfer_after(e, i, nxt); - } - } - - //! Effects: Moves the node p n positions towards the end of the list. - //! - //! Returns: The previous node of p after the function if there has been any movement, - //! Null if n leads to no movement. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements plus the number moved positions. - static node_ptr move_backwards(const node_ptr & p, std::size_t n) - { - //Null shift, nothing to do - if(!n) return node_ptr(); - node_ptr first = NodeTraits::get_next(p); - - //count() == 1 or 2, nothing to do - if(NodeTraits::get_next(first) == p) - return node_ptr(); - - bool end_found = false; - node_ptr new_last = node_ptr(); - - //Now find the new last node according to the shift count. - //If we find p before finding the new last node - //unlink p, shortcut the search now that we know the size of the list - //and continue. - for(std::size_t i = 1; i <= n; ++i){ - new_last = first; - first = NodeTraits::get_next(first); - if(first == p){ - //Shortcut the shift with the modulo of the size of the list - n %= i; - if(!n) - return node_ptr(); - i = 0; - //Unlink p and continue the new first node search - first = NodeTraits::get_next(p); - base_t::unlink_after(new_last); - end_found = true; - } - } - - //If the p has not been found in the previous loop, find it - //starting in the new first node and unlink it - if(!end_found){ - base_t::unlink_after(base_t::get_previous_node(first, p)); - } - - //Now link p after the new last node - base_t::link_after(new_last, p); - return new_last; - } - - //! Effects: Moves the node p n positions towards the beginning of the list. - //! - //! Returns: The previous node of p after the function if there has been any movement, - //! Null if n leads equals to no movement. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements plus the number moved positions. - static node_ptr move_forward(const node_ptr & p, std::size_t n) - { - //Null shift, nothing to do - if(!n) return node_ptr(); - node_ptr first = node_traits::get_next(p); - - //count() == 1 or 2, nothing to do - if(node_traits::get_next(first) == p) return node_ptr(); - - //Iterate until p is found to know where the current last node is. - //If the shift count is less than the size of the list, we can also obtain - //the position of the new last node after the shift. - node_ptr old_last(first), next_to_it, new_last(p); - std::size_t distance = 1; - while(p != (next_to_it = node_traits::get_next(old_last))){ - if(++distance > n) - new_last = node_traits::get_next(new_last); - old_last = next_to_it; - } - //If the shift was bigger or equal than the size, obtain the equivalent - //forward shifts and find the new last node. - if(distance <= n){ - //Now find the equivalent forward shifts. - //Shortcut the shift with the modulo of the size of the list - std::size_t new_before_last_pos = (distance - (n % distance))% distance; - //If the shift is a multiple of the size there is nothing to do - if(!new_before_last_pos) return node_ptr(); - - for( new_last = p - ; new_before_last_pos-- - ; new_last = node_traits::get_next(new_last)){ - //empty - } - } - - //Now unlink p and link it after the new last node - base_t::unlink_after(old_last); - base_t::link_after(new_last, p); - return new_last; - } -}; - -/// @cond - -template -struct get_algo -{ - typedef circular_slist_algorithms type; -}; - -/// @endcond - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP diff --git a/boost/intrusive/derivation_value_traits.hpp b/boost/intrusive/derivation_value_traits.hpp deleted file mode 100644 index 87bc489..0000000 --- a/boost/intrusive/derivation_value_traits.hpp +++ /dev/null @@ -1,77 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2006-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP -#define BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -//!This value traits template is used to create value traits -//!from user defined node traits where value_traits::value_type will -//!derive from node_traits::node - -template -struct derivation_value_traits -{ - public: - typedef NodeTraits node_traits; - typedef T value_type; - typedef typename node_traits::node node; - typedef typename node_traits::node_ptr node_ptr; - typedef typename node_traits::const_node_ptr const_node_ptr; - typedef typename pointer_traits:: - template rebind_pointer::type pointer; - typedef typename pointer_traits:: - template rebind_pointer::type const_pointer; - typedef typename boost::intrusive:: - pointer_traits::reference reference; - typedef typename boost::intrusive:: - pointer_traits::reference const_reference; - static const link_mode_type link_mode = LinkMode; - - static node_ptr to_node_ptr(reference value) - { return node_ptr(&value); } - - static const_node_ptr to_node_ptr(const_reference value) - { return node_ptr(&value); } - - static pointer to_value_ptr(const node_ptr &n) - { - return pointer_traits::pointer_to(static_cast(*n)); - } - - static const_pointer to_value_ptr(const const_node_ptr &n) - { - return pointer_traits::pointer_to(static_cast(*n)); - } -}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP diff --git a/boost/intrusive/detail/algo_type.hpp b/boost/intrusive/detail/algo_type.hpp deleted file mode 100644 index e40cb43..0000000 --- a/boost/intrusive/detail/algo_type.hpp +++ /dev/null @@ -1,46 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_ALGO_TYPE_HPP -#define BOOST_INTRUSIVE_DETAIL_ALGO_TYPE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -namespace boost { -namespace intrusive { - -enum algo_types -{ - CircularListAlgorithms, - CircularSListAlgorithms, - LinearSListAlgorithms, - CommonSListAlgorithms, - BsTreeAlgorithms, - RbTreeAlgorithms, - AvlTreeAlgorithms, - SgTreeAlgorithms, - SplayTreeAlgorithms, - TreapAlgorithms -}; - -template -struct get_algo; - -template -struct get_node_checker; - -} //namespace intrusive -} //namespace boost - -#endif //BOOST_INTRUSIVE_DETAIL_ALGO_TYPE_HPP diff --git a/boost/intrusive/detail/algorithm.hpp b/boost/intrusive/detail/algorithm.hpp new file mode 100644 index 0000000..d2421ff --- /dev/null +++ b/boost/intrusive/detail/algorithm.hpp @@ -0,0 +1,90 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014. +// +// Distributed under the 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/intrusive for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_ALGORITHM_HPP +#define BOOST_INTRUSIVE_DETAIL_ALGORITHM_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +namespace boost { +namespace intrusive { + +struct algo_pred_equal +{ + template + bool operator()(const T &x, const T &y) const + { return x == y; } +}; + +struct algo_pred_less +{ + template + bool operator()(const T &x, const T &y) const + { return x < y; } +}; + +template +bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p) +{ + for (; first1 != last1; ++first1, ++first2) { + if (!p(*first1, *first2)) { + return false; + } + } + return true; +} + +template +bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2) +{ return (algo_equal)(first1, last1, first2, algo_pred_equal()); } + +template +bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinaryPredicate pred) +{ + for (; first1 != last1 && first2 != last2; ++first1, ++first2) + if (!pred(*first1, *first2)) + return false; + return first1 == last1 && first2 == last2; +} + +template +bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) +{ return (algo_equal)(first1, last1, first2, last2, algo_pred_equal()); } + +template + bool algo_lexicographical_compare (InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + BinaryPredicate pred) +{ + while (first1 != last1){ + if (first2 == last2 || *first2 < *first1) return false; + else if (pred(*first1, *first2)) return true; + ++first1; ++first2; + } + return (first2 != last2); +} + +template + bool algo_lexicographical_compare (InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) +{ return (algo_lexicographical_compare)(first1, last1, first2, last2, algo_pred_less()); } + +} //namespace intrusive { +} //namespace boost { + +#endif //#ifndef BOOST_INTRUSIVE_DETAIL_ALGORITHM_HPP diff --git a/boost/intrusive/detail/any_node_and_algorithms.hpp b/boost/intrusive/detail/any_node_and_algorithms.hpp deleted file mode 100644 index 5a0e8c2..0000000 --- a/boost/intrusive/detail/any_node_and_algorithms.hpp +++ /dev/null @@ -1,280 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2006-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_ANY_NODE_HPP -#define BOOST_INTRUSIVE_ANY_NODE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include - -namespace boost { -namespace intrusive { - -template -struct any_node -{ - typedef any_node node; - typedef typename pointer_rebind::type node_ptr; - typedef typename pointer_rebind::type const_node_ptr; - node_ptr node_ptr_1; - node_ptr node_ptr_2; - node_ptr node_ptr_3; - std::size_t size_t_1; -}; - -template -struct any_list_node_traits -{ - typedef any_node node; - typedef typename node::node_ptr node_ptr; - typedef typename node::const_node_ptr const_node_ptr; - - static const node_ptr &get_next(const const_node_ptr & n) - { return n->node_ptr_1; } - - static void set_next(const node_ptr & n, const node_ptr & next) - { n->node_ptr_1 = next; } - - static const node_ptr &get_previous(const const_node_ptr & n) - { return n->node_ptr_2; } - - static void set_previous(const node_ptr & n, const node_ptr & prev) - { n->node_ptr_2 = prev; } -}; - - -template -struct any_slist_node_traits -{ - typedef any_node node; - typedef typename node::node_ptr node_ptr; - typedef typename node::const_node_ptr const_node_ptr; - - static const node_ptr &get_next(const const_node_ptr & n) - { return n->node_ptr_1; } - - static void set_next(const node_ptr & n, const node_ptr & next) - { n->node_ptr_1 = next; } -}; - - -template -struct any_unordered_node_traits - : public any_slist_node_traits -{ - typedef any_slist_node_traits reduced_slist_node_traits; - typedef typename reduced_slist_node_traits::node node; - typedef typename reduced_slist_node_traits::node_ptr node_ptr; - typedef typename reduced_slist_node_traits::const_node_ptr const_node_ptr; - - static const bool store_hash = true; - static const bool optimize_multikey = true; - - static const node_ptr &get_next(const const_node_ptr & n) - { return n->node_ptr_1; } - - static void set_next(const node_ptr & n, const node_ptr & next) - { n->node_ptr_1 = next; } - - static node_ptr get_prev_in_group(const const_node_ptr & n) - { return n->node_ptr_2; } - - static void set_prev_in_group(const node_ptr & n, const node_ptr & prev) - { n->node_ptr_2 = prev; } - - static std::size_t get_hash(const const_node_ptr & n) - { return n->size_t_1; } - - static void set_hash(const node_ptr & n, std::size_t h) - { n->size_t_1 = h; } -}; - - -template -struct any_rbtree_node_traits -{ - typedef any_node node; - typedef typename node::node_ptr node_ptr; - typedef typename node::const_node_ptr const_node_ptr; - - typedef std::size_t color; - - static const node_ptr &get_parent(const const_node_ptr & n) - { return n->node_ptr_1; } - - static void set_parent(const node_ptr & n, const node_ptr & p) - { n->node_ptr_1 = p; } - - static const node_ptr &get_left(const const_node_ptr & n) - { return n->node_ptr_2; } - - static void set_left(const node_ptr & n, const node_ptr & l) - { n->node_ptr_2 = l; } - - static const node_ptr &get_right(const const_node_ptr & n) - { return n->node_ptr_3; } - - static void set_right(const node_ptr & n, const node_ptr & r) - { n->node_ptr_3 = r; } - - static color get_color(const const_node_ptr & n) - { return n->size_t_1; } - - static void set_color(const node_ptr & n, color c) - { n->size_t_1 = c; } - - static color black() - { return 0u; } - - static color red() - { return 1u; } -}; - - -template -struct any_avltree_node_traits -{ - typedef any_node node; - typedef typename node::node_ptr node_ptr; - typedef typename node::const_node_ptr const_node_ptr; - - typedef std::size_t balance; - - static const node_ptr &get_parent(const const_node_ptr & n) - { return n->node_ptr_1; } - - static void set_parent(const node_ptr & n, const node_ptr & p) - { n->node_ptr_1 = p; } - - static const node_ptr &get_left(const const_node_ptr & n) - { return n->node_ptr_2; } - - static void set_left(const node_ptr & n, const node_ptr & l) - { n->node_ptr_2 = l; } - - static const node_ptr &get_right(const const_node_ptr & n) - { return n->node_ptr_3; } - - static void set_right(const node_ptr & n, const node_ptr & r) - { n->node_ptr_3 = r; } - - static balance get_balance(const const_node_ptr & n) - { return n->size_t_1; } - - static void set_balance(const node_ptr & n, balance b) - { n->size_t_1 = b; } - - static balance negative() - { return 0u; } - - static balance zero() - { return 1u; } - - static balance positive() - { return 2u; } -}; - - -template -struct any_tree_node_traits -{ - typedef any_node node; - typedef typename node::node_ptr node_ptr; - typedef typename node::const_node_ptr const_node_ptr; - - static const node_ptr &get_parent(const const_node_ptr & n) - { return n->node_ptr_1; } - - static void set_parent(const node_ptr & n, const node_ptr & p) - { n->node_ptr_1 = p; } - - static const node_ptr &get_left(const const_node_ptr & n) - { return n->node_ptr_2; } - - static void set_left(const node_ptr & n, const node_ptr & l) - { n->node_ptr_2 = l; } - - static const node_ptr &get_right(const const_node_ptr & n) - { return n->node_ptr_3; } - - static void set_right(const node_ptr & n, const node_ptr & r) - { n->node_ptr_3 = r; } -}; - -template -class any_node_traits -{ - public: - typedef any_node node; - typedef typename node::node_ptr node_ptr; - typedef typename node::const_node_ptr const_node_ptr; -}; - -template -class any_algorithms -{ - template - static void function_not_available_for_any_hooks(typename detail::enable_if >::type) - {} - - public: - typedef any_node node; - typedef typename node::node_ptr node_ptr; - typedef typename node::const_node_ptr const_node_ptr; - typedef any_node_traits node_traits; - - //! Requires: node must not be part of any tree. - //! - //! Effects: After the function unique(node) == true. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Nodes: If node is inserted in a tree, this function corrupts the tree. - static void init(const node_ptr & node) - { node->node_ptr_1 = 0; }; - - //! Effects: Returns true if node is in the same state as if called init(node) - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - static bool inited(const const_node_ptr & node) - { return !node->node_ptr_1; }; - - static bool unique(const const_node_ptr & node) - { return 0 == node->node_ptr_1; } - - static void unlink(const node_ptr &) - { - //Auto-unlink hooks and unlink() are not available for any hooks - any_algorithms::template function_not_available_for_any_hooks(); - } - - static void swap_nodes(const node_ptr &, const node_ptr &) - { - //Any nodes have no swap_nodes capability because they don't know - //what algorithm they must use to unlink the node from the container - any_algorithms::template function_not_available_for_any_hooks(); - } -}; - -} //namespace intrusive -} //namespace boost - -#endif //BOOST_INTRUSIVE_ANY_NODE_HPP diff --git a/boost/intrusive/detail/array_initializer.hpp b/boost/intrusive/detail/array_initializer.hpp deleted file mode 100644 index b2072a8..0000000 --- a/boost/intrusive/detail/array_initializer.hpp +++ /dev/null @@ -1,90 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_ARRAY_INITIALIZER_HPP -#define BOOST_INTRUSIVE_DETAIL_ARRAY_INITIALIZER_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include - -namespace boost { -namespace intrusive { -namespace detail { - -//This is not standard, but should work with all compilers -union max_align -{ - char char_; - short short_; - int int_; - long long_; - #ifdef BOOST_HAS_LONG_LONG - long long long_long_; - #endif - float float_; - double double_; - long double long_double_; - void * void_ptr_; -}; - -template -class array_initializer -{ - public: - template - array_initializer(const CommonInitializer &init) - { - char *init_buf = (char*)rawbuf; - std::size_t i = 0; - BOOST_TRY{ - for(; i != N; ++i){ - new(init_buf)T(init); - init_buf += sizeof(T); - } - } - BOOST_CATCH(...){ - while(i--){ - init_buf -= sizeof(T); - ((T*)init_buf)->~T(); - } - BOOST_RETHROW; - } - BOOST_CATCH_END - } - - operator T* () - { return (T*)(rawbuf); } - - operator const T*() const - { return (const T*)(rawbuf); } - - ~array_initializer() - { - char *init_buf = (char*)rawbuf + N*sizeof(T); - for(std::size_t i = 0; i != N; ++i){ - init_buf -= sizeof(T); - ((T*)init_buf)->~T(); - } - } - - private: - detail::max_align rawbuf[(N*sizeof(T)-1)/sizeof(detail::max_align)+1]; -}; - -} //namespace detail{ -} //namespace intrusive{ -} //namespace boost{ - -#endif //BOOST_INTRUSIVE_DETAIL_ARRAY_INITIALIZER_HPP diff --git a/boost/intrusive/detail/assert.hpp b/boost/intrusive/detail/assert.hpp deleted file mode 100644 index d75d225..0000000 --- a/boost/intrusive/detail/assert.hpp +++ /dev/null @@ -1,41 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2006-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_ASSERT_HPP -#define BOOST_INTRUSIVE_DETAIL_ASSERT_HPP - -#if defined(_MSC_VER) -#pragma once -#endif - -#if !defined(BOOST_INTRUSIVE_INVARIANT_ASSERT) - #include - #define BOOST_INTRUSIVE_INVARIANT_ASSERT BOOST_ASSERT -#elif defined(BOOST_INTRUSIVE_INVARIANT_ASSERT_INCLUDE) - #include BOOST_INTRUSIVE_INVARIANT_ASSERT_INCLUDE -#endif - -#if !defined(BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT) - #include - #define BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT BOOST_ASSERT -#elif defined(BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT_INCLUDE) - #include BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT_INCLUDE -#endif - -#if !defined(BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT) - #include - #define BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT BOOST_ASSERT -#elif defined(BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT_INCLUDE) - #include BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT_INCLUDE -#endif - -#endif //BOOST_INTRUSIVE_DETAIL_ASSERT_HPP diff --git a/boost/intrusive/detail/avltree_node.hpp b/boost/intrusive/detail/avltree_node.hpp deleted file mode 100644 index 522806a..0000000 --- a/boost/intrusive/detail/avltree_node.hpp +++ /dev/null @@ -1,188 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_AVLTREE_NODE_HPP -#define BOOST_INTRUSIVE_AVLTREE_NODE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -///////////////////////////////////////////////////////////////////////////// -// // -// Generic node_traits for any pointer type // -// // -///////////////////////////////////////////////////////////////////////////// - -//This is the compact representation: 3 pointers -template -struct compact_avltree_node -{ - typedef typename pointer_rebind >::type node_ptr; - typedef typename pointer_rebind >::type const_node_ptr; - enum balance { negative_t, zero_t, positive_t }; - node_ptr parent_, left_, right_; -}; - -//This is the normal representation: 3 pointers + enum -template -struct avltree_node -{ - typedef typename pointer_rebind >::type node_ptr; - typedef typename pointer_rebind >::type const_node_ptr; - enum balance { negative_t, zero_t, positive_t }; - node_ptr parent_, left_, right_; - balance balance_; -}; - -//This is the default node traits implementation -//using a node with 3 generic pointers plus an enum -template -struct default_avltree_node_traits_impl -{ - typedef avltree_node node; - typedef typename node::node_ptr node_ptr; - typedef typename node::const_node_ptr const_node_ptr; - - typedef typename node::balance balance; - - 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 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 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) - { n->right_ = r; } - - 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; } - - static balance negative() - { return node::negative_t; } - - static balance zero() - { return node::zero_t; } - - static balance positive() - { return node::positive_t; } -}; - -//This is the compact node traits implementation -//using a node with 3 generic pointers -template -struct compact_avltree_node_traits_impl -{ - typedef compact_avltree_node node; - typedef typename node::node_ptr node_ptr; - typedef typename node::const_node_ptr const_node_ptr; - typedef typename node::balance balance; - - typedef pointer_plus_bits ptr_bit; - - static node_ptr get_parent(const 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 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 node_ptr get_right(const const_node_ptr & n) - { return n->right_; } - - static void set_right(const node_ptr & n, const node_ptr & r) - { n->right_ = r; } - - static balance get_balance(const const_node_ptr & n) - { return (balance)ptr_bit::get_bits(n->parent_); } - - static void set_balance(const node_ptr & n, balance b) - { ptr_bit::set_bits(n->parent_, (std::size_t)b); } - - static balance negative() - { return node::negative_t; } - - static balance zero() - { return node::zero_t; } - - static balance positive() - { return node::positive_t; } -}; - -//Dispatches the implementation based on the boolean -template -struct avltree_node_traits_dispatch - : public default_avltree_node_traits_impl -{}; - -template -struct avltree_node_traits_dispatch - : public compact_avltree_node_traits_impl -{}; - -//Inherit from rbtree_node_traits_dispatch depending on the embedding capabilities -template -struct avltree_node_traits - : public avltree_node_traits_dispatch - < VoidPointer - , OptimizeSize && - max_pointer_plus_bits - < VoidPointer - , detail::alignment_of >::value - >::value >= 2u - > -{}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_AVLTREE_NODE_HPP diff --git a/boost/intrusive/detail/common_slist_algorithms.hpp b/boost/intrusive/detail/common_slist_algorithms.hpp deleted file mode 100644 index 4c7f1a1..0000000 --- a/boost/intrusive/detail/common_slist_algorithms.hpp +++ /dev/null @@ -1,194 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_COMMON_SLIST_ALGORITHMS_HPP -#define BOOST_INTRUSIVE_COMMON_SLIST_ALGORITHMS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { -namespace detail { - -template -class common_slist_algorithms -{ - public: - typedef typename NodeTraits::node node; - typedef typename NodeTraits::node_ptr node_ptr; - typedef typename NodeTraits::const_node_ptr const_node_ptr; - typedef NodeTraits node_traits; - - static node_ptr get_previous_node(node_ptr p, const node_ptr & this_node) - { - for( node_ptr p_next - ; this_node != (p_next = NodeTraits::get_next(p)) - ; p = p_next){ - //Logic error: possible use of linear lists with - //operations only permitted with lists - BOOST_INTRUSIVE_INVARIANT_ASSERT(p); - } - return p; - } - - static void init(const node_ptr & this_node) - { NodeTraits::set_next(this_node, node_ptr()); } - - static bool unique(const const_node_ptr & this_node) - { - node_ptr next = NodeTraits::get_next(this_node); - return !next || next == this_node; - } - - static bool inited(const const_node_ptr & this_node) - { return !NodeTraits::get_next(this_node); } - - static void unlink_after(const node_ptr & prev_node) - { - const_node_ptr this_node(NodeTraits::get_next(prev_node)); - NodeTraits::set_next(prev_node, NodeTraits::get_next(this_node)); - } - - static void unlink_after(const node_ptr & prev_node, const node_ptr & last_node) - { NodeTraits::set_next(prev_node, last_node); } - - static void link_after(const node_ptr & prev_node, const node_ptr & this_node) - { - NodeTraits::set_next(this_node, NodeTraits::get_next(prev_node)); - NodeTraits::set_next(prev_node, this_node); - } - - static void incorporate_after(const node_ptr & bp, const node_ptr & b, const node_ptr & be) - { - node_ptr p(NodeTraits::get_next(bp)); - NodeTraits::set_next(bp, b); - NodeTraits::set_next(be, p); - } - - static void transfer_after(const node_ptr & bp, const node_ptr & bb, const node_ptr & be) - { - if (bp != bb && bp != be && bb != be) { - node_ptr next_b = NodeTraits::get_next(bb); - node_ptr next_e = NodeTraits::get_next(be); - node_ptr next_p = NodeTraits::get_next(bp); - NodeTraits::set_next(bb, next_e); - NodeTraits::set_next(be, next_p); - NodeTraits::set_next(bp, next_b); - } - } - - struct stable_partition_info - { - std::size_t num_1st_partition; - std::size_t num_2nd_partition; - node_ptr beg_2st_partition; - node_ptr new_last_node; - }; - - template - static void stable_partition(node_ptr before_beg, const node_ptr &end, Pred pred, stable_partition_info &info) - { - node_ptr bcur = before_beg; - node_ptr cur = node_traits::get_next(bcur); - node_ptr new_f = end; - - std::size_t num1 = 0, num2 = 0; - while(cur != end){ - if(pred(cur)){ - ++num1; - bcur = cur; - cur = node_traits::get_next(cur); - } - else{ - ++num2; - node_ptr last_to_remove = bcur; - new_f = cur; - bcur = cur; - cur = node_traits::get_next(cur); - BOOST_TRY{ - //Main loop - while(cur != end){ - if(pred(cur)){ //Might throw - ++num1; - //Process current node - node_traits::set_next(last_to_remove, cur); - last_to_remove = cur; - node_ptr nxt = node_traits::get_next(cur); - node_traits::set_next(bcur, nxt); - cur = nxt; - } - else{ - ++num2; - bcur = cur; - cur = node_traits::get_next(cur); - } - } - } - BOOST_CATCH(...){ - node_traits::set_next(last_to_remove, new_f); - throw; - } - BOOST_CATCH_END - node_traits::set_next(last_to_remove, new_f); - break; - } - } - info.num_1st_partition = num1; - info.num_2nd_partition = num2; - info.beg_2st_partition = new_f; - info.new_last_node = bcur; - } - - //! Requires: f and l must be in a circular list. - //! - //! Effects: Returns the number of nodes in the range [f, l). - //! - //! Complexity: Linear - //! - //! Throws: Nothing. - static std::size_t distance(const const_node_ptr &f, const const_node_ptr &l) - { - const_node_ptr i(f); - std::size_t result = 0; - while(i != l){ - i = NodeTraits::get_next(i); - ++result; - } - return result; - } -}; - -/// @endcond - -} //namespace detail - -/// @cond - -template -struct get_algo -{ - typedef detail::common_slist_algorithms type; -}; - - -} //namespace intrusive -} //namespace boost - -#endif //BOOST_INTRUSIVE_COMMON_SLIST_ALGORITHMS_HPP diff --git a/boost/intrusive/detail/default_header_holder.hpp b/boost/intrusive/detail/default_header_holder.hpp deleted file mode 100644 index c471691..0000000 --- a/boost/intrusive/detail/default_header_holder.hpp +++ /dev/null @@ -1,65 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP -#define BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -namespace boost { -namespace intrusive { -namespace detail { - -// trivial header node holder -template < typename NodeTraits > -struct default_header_holder : public NodeTraits::node -{ - typedef NodeTraits node_traits; - typedef typename node_traits::node node; - typedef typename node_traits::node_ptr node_ptr; - typedef typename node_traits::const_node_ptr const_node_ptr; - - default_header_holder() : node() {} - - const_node_ptr get_node() const - { return pointer_traits< const_node_ptr >::pointer_to(*static_cast< const node* >(this)); } - - node_ptr get_node() - { return pointer_traits< node_ptr >::pointer_to(*static_cast< node* >(this)); } - - // (unsafe) downcast used to implement container-from-iterator - static default_header_holder* get_holder(const node_ptr &p) - { return static_cast< default_header_holder* >(boost::intrusive::detail::to_raw_pointer(p)); } -}; - -// type function producing the header node holder -template < typename Value_Traits, typename HeaderHolder > -struct get_header_holder_type -{ - typedef HeaderHolder type; -}; -template < typename Value_Traits > -struct get_header_holder_type< Value_Traits, void > -{ - typedef default_header_holder< typename Value_Traits::node_traits > type; -}; - -} //namespace detail -} //namespace intrusive -} //namespace boost - -#endif //BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP diff --git a/boost/intrusive/detail/ebo_functor_holder.hpp b/boost/intrusive/detail/ebo_functor_holder.hpp deleted file mode 100644 index d2e8107..0000000 --- a/boost/intrusive/detail/ebo_functor_holder.hpp +++ /dev/null @@ -1,226 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Joaquin M Lopez Munoz 2006-2013 -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP -#define BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include - -namespace boost { -namespace intrusive { -namespace detail { - -#if defined(BOOST_MSVC) || defined(__BORLANDC_) -#define BOOST_INTRUSIVE_TT_DECL __cdecl -#else -#define BOOST_INTRUSIVE_TT_DECL -#endif - -#if defined(_MSC_EXTENSIONS) && !defined(__BORLAND__) && !defined(_WIN64) && !defined(_M_ARM) && !defined(UNDER_CE) -#define BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS -#endif - -template -struct is_unary_or_binary_function_impl -{ static const bool value = false; }; - -// see boost ticket #4094 -// avoid duplicate definitions of is_unary_or_binary_function_impl -#ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -#else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -#ifndef _MANAGED - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -#endif - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -#endif - -// see boost ticket #4094 -// avoid duplicate definitions of is_unary_or_binary_function_impl -#ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -#else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -#ifndef _MANAGED - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -#endif - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -#endif - -// see boost ticket #4094 -// avoid duplicate definitions of is_unary_or_binary_function_impl -#ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -#else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -#ifndef _MANAGED - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -#endif - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; - -template -struct is_unary_or_binary_function_impl -{ static const bool value = true; }; -#endif - -template -struct is_unary_or_binary_function_impl -{ static const bool value = false; }; - -template -struct is_unary_or_binary_function : is_unary_or_binary_function_impl -{}; - -template -class ebo_functor_holder_impl -{ - public: - ebo_functor_holder_impl() - {} - ebo_functor_holder_impl(const T& t) - : t_(t) - {} - template - ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2) - : t_(arg1, arg2) - {} - - T& get(){return t_;} - const T& get()const{return t_;} - - private: - T t_; -}; - -template -class ebo_functor_holder_impl - : public T -{ - public: - ebo_functor_holder_impl() - {} - ebo_functor_holder_impl(const T& t) - : T(t) - {} - template - ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2) - : T(arg1, arg2) - {} - - T& get(){return *this;} - const T& get()const{return *this;} -}; - -template -class ebo_functor_holder - : public ebo_functor_holder_impl::value> -{ - private: - typedef ebo_functor_holder_impl::value> super; - - public: - ebo_functor_holder(){} - ebo_functor_holder(const T& t) - : super(t) - {} - - template - ebo_functor_holder(const Arg1& arg1, const Arg2& arg2) - : super(arg1, arg2) - {} - - ebo_functor_holder& operator=(const ebo_functor_holder& x) - { - this->get()=x.get(); - return *this; - } -}; - - -} //namespace detail { -} //namespace intrusive { -} //namespace boost { - -#endif //#ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP diff --git a/boost/intrusive/detail/empty_node_checker.hpp b/boost/intrusive/detail/empty_node_checker.hpp deleted file mode 100644 index 33d78a3..0000000 --- a/boost/intrusive/detail/empty_node_checker.hpp +++ /dev/null @@ -1,40 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_EMPTY_NODE_CHECKER_HPP -#define BOOST_INTRUSIVE_DETAIL_EMPTY_NODE_CHECKER_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -namespace boost { -namespace intrusive { -namespace detail { - -template -struct empty_node_checker -{ - typedef ValueTraits value_traits; - typedef typename value_traits::node_traits node_traits; - typedef typename node_traits::const_node_ptr const_node_ptr; - - struct return_type {}; - - void operator () (const const_node_ptr&, const return_type&, const return_type&, return_type&) {} -}; - -} //namespace detail{ -} //namespace intrusive{ -} //namespace boost{ - -#endif //BOOST_INTRUSIVE_DETAIL_EMPTY_NODE_CHECKER_HPP diff --git a/boost/intrusive/detail/equal_to_value.hpp b/boost/intrusive/detail/equal_to_value.hpp deleted file mode 100644 index 3ffd1c2..0000000 --- a/boost/intrusive/detail/equal_to_value.hpp +++ /dev/null @@ -1,44 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_EQUAL_TO_VALUE_HPP -#define BOOST_INTRUSIVE_DETAIL_EQUAL_TO_VALUE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -namespace boost { -namespace intrusive { -namespace detail { - -//This functor compares a stored value -//and the one passed as an argument -template -class equal_to_value -{ - ConstReference t_; - - public: - equal_to_value(ConstReference t) - : t_(t) - {} - - bool operator()(ConstReference t)const - { return t_ == t; } -}; - -} //namespace detail{ -} //namespace intrusive{ -} //namespace boost{ - -#endif //BOOST_INTRUSIVE_DETAIL_EQUAL_TO_VALUE_HPP diff --git a/boost/intrusive/detail/exception_disposer.hpp b/boost/intrusive/detail/exception_disposer.hpp deleted file mode 100644 index 1226f5e..0000000 --- a/boost/intrusive/detail/exception_disposer.hpp +++ /dev/null @@ -1,84 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_EXCEPTION_DISPOSER_HPP -#define BOOST_INTRUSIVE_DETAIL_EXCEPTION_DISPOSER_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -namespace boost { -namespace intrusive { -namespace detail { - -template -class exception_disposer -{ - Container *cont_; - Disposer &disp_; - - exception_disposer(const exception_disposer&); - exception_disposer &operator=(const exception_disposer&); - - public: - exception_disposer(Container &cont, Disposer &disp) - : cont_(&cont), disp_(disp) - {} - - void release() - { cont_ = 0; } - - ~exception_disposer() - { - if(cont_){ - cont_->clear_and_dispose(disp_); - } - } -}; - -template -class exception_array_disposer -{ - Container *cont_; - Disposer &disp_; - SizeType &constructed_; - - exception_array_disposer(const exception_array_disposer&); - exception_array_disposer &operator=(const exception_array_disposer&); - - public: - - exception_array_disposer - (Container &cont, Disposer &disp, SizeType &constructed) - : cont_(&cont), disp_(disp), constructed_(constructed) - {} - - void release() - { cont_ = 0; } - - ~exception_array_disposer() - { - SizeType n = constructed_; - if(cont_){ - while(n--){ - cont_[n].clear_and_dispose(disp_); - } - } - } -}; - -} //namespace detail{ -} //namespace intrusive{ -} //namespace boost{ - -#endif //BOOST_INTRUSIVE_DETAIL_EXCEPTION_DISPOSER_HPP diff --git a/boost/intrusive/detail/function_detector.hpp b/boost/intrusive/detail/function_detector.hpp deleted file mode 100644 index f72865d..0000000 --- a/boost/intrusive/detail/function_detector.hpp +++ /dev/null @@ -1,88 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2009-2013. -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// -// This code was modified from the code posted by Alexandre Courpron in his -// article "Interface Detection" in The Code Project: -// http://www.codeproject.com/KB/architecture/Detector.aspx -/////////////////////////////////////////////////////////////////////////////// -// Copyright 2007 Alexandre Courpron -// -// Permission to use, copy, modify, redistribute and sell this software, -// provided that this copyright notice appears on all copies of the software. -/////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_FUNCTION_DETECTOR_HPP -#define BOOST_INTRUSIVE_DETAIL_FUNCTION_DETECTOR_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -namespace boost { -namespace intrusive { -namespace function_detector { - - typedef char NotFoundType; - struct StaticFunctionType { NotFoundType x [2]; }; - struct NonStaticFunctionType { NotFoundType x [3]; }; - - enum - { NotFound = 0, - StaticFunction = sizeof( StaticFunctionType ) - sizeof( NotFoundType ), - NonStaticFunction = sizeof( NonStaticFunctionType ) - sizeof( NotFoundType ) - }; - -} //namespace boost { -} //namespace intrusive { -} //namespace function_detector { - -#define BOOST_INTRUSIVE_CREATE_FUNCTION_DETECTOR(Identifier, InstantiationKey) \ - namespace boost { \ - namespace intrusive { \ - namespace function_detector { \ - template < class T, \ - class NonStaticType, \ - class NonStaticConstType, \ - class StaticType > \ - class DetectMember_##InstantiationKey_##Identifier { \ - template < NonStaticType > \ - struct TestNonStaticNonConst ; \ - \ - template < NonStaticConstType > \ - struct TestNonStaticConst ; \ - \ - template < StaticType > \ - struct TestStatic ; \ - \ - template \ - static NonStaticFunctionType Test( TestNonStaticNonConst<&U::Identifier>*, int ); \ - \ - template \ - static NonStaticFunctionType Test( TestNonStaticConst<&U::Identifier>*, int ); \ - \ - template \ - static StaticFunctionType Test( TestStatic<&U::Identifier>*, int ); \ - \ - template \ - static NotFoundType Test( ... ); \ - public : \ - static const int check = NotFound + (sizeof(Test(0, 0)) - sizeof(NotFoundType));\ - };\ -}}} //namespace boost::intrusive::function_detector { - -#define BOOST_INTRUSIVE_DETECT_FUNCTION(Class, InstantiationKey, ReturnType, Identifier, Params) \ - ::boost::intrusive::function_detector::DetectMember_##InstantiationKey_##Identifier< Class,\ - ReturnType (Class::*)Params,\ - ReturnType (Class::*)Params const,\ - ReturnType (*)Params \ - >::check - -#endif //@ifndef BOOST_INTRUSIVE_DETAIL_FUNCTION_DETECTOR_HPP diff --git a/boost/intrusive/detail/generic_hook.hpp b/boost/intrusive/detail/generic_hook.hpp deleted file mode 100644 index c5af081..0000000 --- a/boost/intrusive/detail/generic_hook.hpp +++ /dev/null @@ -1,217 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_GENERIC_HOOK_HPP -#define BOOST_INTRUSIVE_GENERIC_HOOK_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -/// @cond - -namespace detail { - -template -struct link_dispatch -{}; - -template -void destructor_impl(Hook &hook, detail::link_dispatch) -{ //If this assertion raises, you might have destroyed an object - //while it was still inserted in a container that is alive. - //If so, remove the object from the container before destroying it. - (void)hook; BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT(!hook.is_linked()); -} - -template -void destructor_impl(Hook &hook, detail::link_dispatch) -{ hook.unlink(); } - -template -void destructor_impl(Hook &, detail::link_dispatch) -{} - -} //namespace detail { - -enum base_hook_type -{ NoBaseHookId -, ListBaseHookId -, SlistBaseHookId -, RbTreeBaseHookId -, HashBaseHookId -, AvlTreeBaseHookId -, BsTreeBaseHookId -, TreapTreeBaseHookId -, AnyBaseHookId -}; - - -template -struct hook_tags_definer{}; - -template -struct hook_tags_definer -{ typedef HookTags default_list_hook; }; - -template -struct hook_tags_definer -{ typedef HookTags default_slist_hook; }; - -template -struct hook_tags_definer -{ typedef HookTags default_rbtree_hook; }; - -template -struct hook_tags_definer -{ typedef HookTags default_hashtable_hook; }; - -template -struct hook_tags_definer -{ typedef HookTags default_avltree_hook; }; - -template -struct hook_tags_definer -{ typedef HookTags default_bstree_hook; }; - -template -struct hook_tags_definer -{ typedef HookTags default_any_hook; }; - -template - < class NodeTraits - , class Tag - , link_mode_type LinkMode - , base_hook_type BaseHookType - > -struct hooktags_impl -{ - static const link_mode_type link_mode = LinkMode; - typedef Tag tag; - typedef NodeTraits node_traits; - static const bool is_base_hook = !detail::is_same::value; - static const bool safemode_or_autounlink = is_safe_autounlink::value; - static const unsigned int type = BaseHookType; -}; - -/// @endcond - -template - < class NodeAlgorithms - , class Tag - , link_mode_type LinkMode - , base_hook_type BaseHookType - > -class generic_hook - /// @cond - //If the hook is a base hook, derive generic hook from node_holder - //so that a unique base class is created to convert from the node - //to the type. This mechanism will be used by bhtraits. - // - //If the hook is a member hook, generic hook will directly derive - //from the hook. - : public detail::if_c - < detail::is_same::value - , typename NodeAlgorithms::node - , node_holder - >::type - //If this is the a default-tagged base hook derive from a class that - //will define an special internal typedef. Containers will be able to detect this - //special typedef and obtain generic_hook's internal types in order to deduce - //value_traits for this hook. - , public hook_tags_definer - < generic_hook - , detail::is_same::value*BaseHookType> - /// @endcond -{ - /// @cond - typedef NodeAlgorithms node_algorithms; - typedef typename node_algorithms::node node; - typedef typename node_algorithms::node_ptr node_ptr; - typedef typename node_algorithms::const_node_ptr const_node_ptr; - - public: - - typedef hooktags_impl - < typename NodeAlgorithms::node_traits - , Tag, LinkMode, BaseHookType> hooktags; - - node_ptr this_ptr() - { return pointer_traits::pointer_to(static_cast(*this)); } - - const_node_ptr this_ptr() const - { return pointer_traits::pointer_to(static_cast(*this)); } - - public: - /// @endcond - - generic_hook() - { - if(hooktags::safemode_or_autounlink){ - node_algorithms::init(this->this_ptr()); - } - } - - generic_hook(const generic_hook& ) - { - if(hooktags::safemode_or_autounlink){ - node_algorithms::init(this->this_ptr()); - } - } - - generic_hook& operator=(const generic_hook& ) - { return *this; } - - ~generic_hook() - { - destructor_impl - (*this, detail::link_dispatch()); - } - - void swap_nodes(generic_hook &other) - { - node_algorithms::swap_nodes - (this->this_ptr(), other.this_ptr()); - } - - bool is_linked() const - { - //is_linked() can be only used in safe-mode or auto-unlink - BOOST_STATIC_ASSERT(( hooktags::safemode_or_autounlink )); - return !node_algorithms::unique(this->this_ptr()); - } - - void unlink() - { - BOOST_STATIC_ASSERT(( (int)hooktags::link_mode == (int)auto_unlink )); - node_ptr n(this->this_ptr()); - if(!node_algorithms::inited(n)){ - node_algorithms::unlink(n); - node_algorithms::init(n); - } - } -}; - -} //namespace intrusive -} //namespace boost - -#endif //BOOST_INTRUSIVE_GENERIC_HOOK_HPP diff --git a/boost/intrusive/detail/get_value_traits.hpp b/boost/intrusive/detail/get_value_traits.hpp deleted file mode 100644 index 6f5a9e3..0000000 --- a/boost/intrusive/detail/get_value_traits.hpp +++ /dev/null @@ -1,218 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_GET_VALUE_TRAITS_HPP -#define BOOST_INTRUSIVE_DETAIL_GET_VALUE_TRAITS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include - -namespace boost { -namespace intrusive { - -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - -template -struct is_default_hook_tag -{ static const bool value = false; }; - -namespace detail{ - -template -struct concrete_hook_base_value_traits -{ - typedef typename BaseHook::hooktags tags; - typedef bhtraits - < T - , typename tags::node_traits - , tags::link_mode - , typename tags::tag - , tags::type> type; -}; - -template -struct concrete_hook_base_value_traits -{ - typedef typename BaseHook::hooktags type; -}; - -template -struct any_hook_base_value_traits -{ - //AnyToSomeHook value_traits derive from a generic_hook - //The generic_hook is configured with any_node_traits - //and AnyToSomeHook::value_traits with the correct - //node traits for the container, so use node_traits - //from AnyToSomeHook_ProtoValueTraits and the rest of - //elements from the hooktags member of the generic_hook - - typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t; - typedef typename pointer_rebind - < typename basic_hook_t::hooktags::node_traits::node_ptr - , void>::type void_pointer; - typedef typename AnyToSomeHook_ProtoValueTraits::template - node_traits_from_voidptr::type node_traits; - - typedef bhtraits - < T - , node_traits - , basic_hook_t::hooktags::link_mode - , typename basic_hook_t::hooktags::tag - , basic_hook_t::hooktags::type - > type; -}; - -template -struct any_hook_base_value_traits -{ - typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t; - typedef typename pointer_rebind - < typename basic_hook_t::hooktags::node_traits::node_ptr - , void>::type void_pointer; - - struct type - { - typedef typename AnyToSomeHook_ProtoValueTraits::template - node_traits_from_voidptr::type node_traits; - }; -}; - -template -struct get_member_value_traits -{ - typedef typename MemberHook::member_value_traits type; -}; - -BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_any_hook, is_any_hook) -BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_base_hook, hooktags::is_base_hook) - -template -struct internal_member_value_traits -{ - template static one test(...); - template static two test(typename U::member_value_traits* = 0); - static const bool value = sizeof(test(0)) == sizeof(two); -}; - -template::value> -struct supposed_value_traits; - -template::value> -struct get_base_value_traits; - -template::value> -struct supposed_base_value_traits; - -template::value> -struct supposed_member_value_traits; - -template::value> -struct any_or_concrete_value_traits; - -//Base any hook -template -struct get_base_value_traits - : any_hook_base_value_traits -{}; - -//Non-any base hook -template -struct get_base_value_traits - : concrete_hook_base_value_traits -{}; - -//...It's a default hook -template -struct supposed_value_traits -{ typedef typename SupposedValueTraits::template apply::type type; }; - -//...Not a default hook -template -struct supposed_value_traits -{ typedef SupposedValueTraits type; }; - -//...It's a base hook -template -struct supposed_base_value_traits - : get_base_value_traits -{}; - -//...Not a base hook, try if it's a member or value_traits -template -struct supposed_base_value_traits - : supposed_member_value_traits -{}; - -//...It's a member hook -template -struct supposed_member_value_traits - : get_member_value_traits -{}; - -//...Not a member hook -template -struct supposed_member_value_traits - : any_or_concrete_value_traits -{}; - -template -struct any_or_concrete_value_traits -{ - //A hook node (non-base, e.g.: member or other value traits - typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t; - typedef typename pointer_rebind - ::type void_pointer; - typedef typename AnyToSomeHook_ProtoValueTraits::template - node_traits_from_voidptr::type any_node_traits; - - struct type : basic_hook_t - { - typedef any_node_traits node_traits; - }; -}; - -template -struct any_or_concrete_value_traits -{ - typedef SupposedValueTraits type; -}; - -//////////////////////////////////////// -// get_value_traits / get_node_traits -//////////////////////////////////////// - -template -struct get_value_traits - : supposed_base_value_traits::type, T> -{}; - -template -struct get_node_traits -{ - typedef typename get_value_traits::type::node_traits type; -}; - -} //namespace detail{ - -#endif //BOOST_INTRUSIVE_DOXYGEN_INVOKED - -} //namespace intrusive { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_INTRUSIVE_DETAIL_GET_VALUE_TRAITS_HPP diff --git a/boost/intrusive/detail/has_member_function_callable_with.hpp b/boost/intrusive/detail/has_member_function_callable_with.hpp index ca96f15..30bef56 100644 --- a/boost/intrusive/detail/has_member_function_callable_with.hpp +++ b/boost/intrusive/detail/has_member_function_callable_with.hpp @@ -1,372 +1,331 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2011-2014. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the 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/intrusive for documentation. +// See http://www.boost.org/libs/container for documentation. // ////////////////////////////////////////////////////////////////////////////// -// sample.h +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_CALLABLE_WITH_HPP +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_CALLABLE_WITH_HPP -#if !defined(BOOST_PP_IS_ITERATING) +//Mark that we don't support 0 arg calls due to compiler ICE in GCC 3.4/4.0/4.1 and +//wrong SFINAE for GCC 4.2/4.3 +#if defined(__GNUC__) && !defined(__clang__) && ((__GNUC__*100 + __GNUC_MINOR__*10) >= 340) && ((__GNUC__*100 + __GNUC_MINOR__*10) <= 430) + #define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED +#elif defined(BOOST_INTEL) && (BOOST_INTEL < 1200 ) + #define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED +#endif +#include +#include +#include - #ifndef BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_DETAILS_INCLUDED - #define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_DETAILS_INCLUDED +namespace boost_intrusive_hmfcw { - #include - #include - #include +typedef char yes_type; +struct no_type{ char dummy[2]; }; +#if defined(BOOST_NO_CXX11_DECLTYPE) - //Mark that we don't support 0 arg calls due to compiler ICE in GCC 3.4/4.0/4.1 and - //wrong SFINAE for GCC 4.2/4.3 - #if defined(__GNUC__) && !defined(__clang__) && ((__GNUC__*100 + __GNUC_MINOR__*10) >= 340) && ((__GNUC__*100 + __GNUC_MINOR__*10) <= 430) - #define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED - #elif defined(BOOST_INTEL) && (BOOST_INTEL < 1200 ) - #define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED - #endif +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - namespace boost_intrusive_has_member_function_callable_with { +template +struct make_dontcare +{ + typedef dont_care type; +}; - struct dont_care - { - dont_care(...); - }; +#endif - template - struct make_dontcare - { - typedef boost_intrusive_has_member_function_callable_with::dont_care type; - }; +struct dont_care +{ + dont_care(...); +}; - struct private_type - { - static private_type p; - private_type const &operator,(int) const; - }; +struct private_type +{ + static private_type p; + private_type const &operator,(int) const; +}; - typedef char yes_type; // sizeof(yes_type) == 1 - struct no_type{ char dummy[2]; }; // sizeof(no_type) == 2 +template +no_type is_private_type(T const &); +yes_type is_private_type(private_type const &); - template - no_type is_private_type(T const &); - yes_type is_private_type(private_type const &); +#endif //#if defined(BOOST_NO_CXX11_DECLTYPE) - } //boost_intrusive_has_member_function_callable_with +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +template struct remove_cv { typedef T type; }; +template struct remove_cv { typedef T type; }; +template struct remove_cv { typedef T type; }; +template struct remove_cv { typedef T type; }; + +#endif + +} //namespace boost_intrusive_hmfcw { + +#endif //BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_CALLABLE_WITH_HPP + +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME + #error "You MUST define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME before including this header!" +#endif + +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN + #error "You MUST define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN before including this header!" +#endif + +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX + #error "You MUST define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX before including this header!" +#endif + +#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX < BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN + #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX value MUST be greater or equal than BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN!" +#endif + +#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX == 0 + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF +#else + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF , +#endif + +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG + #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG not defined!" +#endif + +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END + #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END not defined!" +#endif + +BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE) + //With decltype and variadic templaes, things are pretty easy + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { + template + static decltype(boost::move_detail::declval(). + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(::boost::move_detail::declval()...) + , boost_intrusive_hmfcw::yes_type()) Test(U* f); + template + static boost_intrusive_hmfcw::no_type Test(...); + static const bool value = sizeof(Test((Fun*)0)) == sizeof(boost_intrusive_hmfcw::yes_type); + }; + +#else //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_DECLTYPE) + + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// + // + // has_member_function_callable_with_impl_XXX + // declaration, special case and 0 arg specializaton + // + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_SINGLE_ITERATION - #endif + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// + // + // has_member_function_callable_with_impl_XXX for 1 to N arguments + // + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// - #endif //BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_DETAILS_INCLUDED + //defined(BOOST_NO_CXX11_DECLTYPE) must be true + template + struct FunWrapTmpl : Fun + { + using Fun::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME; + boost_intrusive_hmfcw::private_type BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(DontCares...) const; + }; -#else //!BOOST_PP_IS_ITERATING + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { + typedef FunWrapTmpl::type...> FunWrap; - #ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME - #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME not defined!" - #endif + static bool const value = (sizeof(boost_intrusive_hmfcw::no_type) == + sizeof(boost_intrusive_hmfcw::is_private_type + ( (::boost::move_detail::declval< FunWrap >(). + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(::boost::move_detail::declval()...), 0) ) + ) + ); + }; + #else //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - #ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN - #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN not defined!" - #endif - - #ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END - #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END not defined!" - #endif - - #if BOOST_PP_ITERATION_START() > BOOST_PP_ITERATION_FINISH() - #error "BOOST_PP_ITERATION_START() must be <= BOOST_PP_ITERATION_FINISH()" - #endif - - #if BOOST_PP_ITERATION() == BOOST_PP_ITERATION_START() - - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN + //Preprocessor must be used to generate specializations instead of variadic templates template - class BOOST_PP_CAT(has_member_function_named_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + class BOOST_MOVE_CAT(has_member_function_named_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) { struct BaseMixin { void BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(); }; - struct Base : public ::boost::intrusive::detail::remove_cv::type, public BaseMixin { Base(); }; + struct Base : public boost_intrusive_hmfcw::remove_cv::type, public BaseMixin {}; template class Helper{}; template - static boost_intrusive_has_member_function_callable_with::no_type deduce + static boost_intrusive_hmfcw::no_type deduce (U*, Helper* = 0); - static boost_intrusive_has_member_function_callable_with::yes_type deduce(...); + static boost_intrusive_hmfcw::yes_type deduce(...); public: - static const bool value = - sizeof(boost_intrusive_has_member_function_callable_with::yes_type) == sizeof(deduce((Base*)(0))); + static const bool value = sizeof(boost_intrusive_hmfcw::yes_type) == sizeof(deduce((Base*)0)); }; - #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// + // + // has_member_function_callable_with_impl_XXX specializations + // + ///////////////////////////////////////////////////////// - template - struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME), _impl); - //! + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME); - template - struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME), _impl) - - { - static const bool value = false; - }; - //! + //No BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME member specialization + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + + { + static const bool value = false; + }; - #else //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - template - struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl); - - template - struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) - - { - static const bool value = false; - }; - - #ifdef BOOST_NO_CXX11_DECLTYPE - - //Special case for 0 args - template< class F - , std::size_t N = - sizeof((boost::move_detail::declval(). - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME (), 0))> - struct BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) - { - boost_intrusive_has_member_function_callable_with::yes_type dummy; - BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)(int); - }; - - //For buggy compilers like MSVC 7.1+ ((F*)0)->func() does not - //SFINAE-out the zeroarg_checker_ instantiation but sizeof yields to 0. - template - struct BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) - { - boost_intrusive_has_member_function_callable_with::no_type dummy; - BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)(int); - }; - - #endif //#ifdef BOOST_NO_CXX11_DECLTYPE - - template - struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) - - { - #ifndef BOOST_NO_CXX11_DECLTYPE - template().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME()) > - static boost_intrusive_has_member_function_callable_with::yes_type Test(U*); - #else - template - static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) - Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)*); - #endif - - template - static boost_intrusive_has_member_function_callable_with::no_type Test(...); - - static const bool value = sizeof(Test< Fun >(0)) - == sizeof(boost_intrusive_has_member_function_callable_with::yes_type); - }; - - template - struct BOOST_PP_CAT( BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME), _impl) - - { - - template - struct FunWrapTmpl : Fun - { - FunWrapTmpl(); - using Fun::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME; - - boost_intrusive_has_member_function_callable_with::private_type - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME - ( DontCares...) const; - }; - - typedef FunWrapTmpl::type...> FunWrap; - - static bool const value = (sizeof(boost_intrusive_has_member_function_callable_with::no_type) == - sizeof(boost_intrusive_has_member_function_callable_with::is_private_type - ( (::boost::move_detail::declval< FunWrap >(). - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME - ( ::boost::move_detail::declval()... ), 0) ) - ) - ); - }; - - template - struct BOOST_PP_CAT( has_member_function_callable_with_ - , BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) - : public BOOST_PP_CAT( BOOST_PP_CAT(has_member_function_callable_with_ - , BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) - < Fun - , BOOST_PP_CAT( has_member_function_named_ - , BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME )::value - , Args... > - {}; - - #endif //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END - - #endif //BOOST_PP_ITERATION() == BOOST_PP_ITERATION_START() - - #if BOOST_PP_ITERATION() == 0 - - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN - - #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - #if !defined(_MSC_VER) || (_MSC_VER < 1600) - - #if defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED) + #if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN == 0 + //0 arg specialization when BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME is present + #if !defined(BOOST_NO_CXX11_DECLTYPE) template - struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) - + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) { - //Mark that we don't support 0 arg calls due to compiler ICE in GCC 3.4/4.0/4.1 and - //wrong SFINAE for GCC 4.2/4.3 - static const bool value = true; + template + static decltype(boost::move_detail::declval().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME() + , boost_intrusive_hmfcw::yes_type()) Test(U* f); + + template + static boost_intrusive_hmfcw::no_type Test(...); + static const bool value = sizeof(Test((Fun*)0)) == sizeof(boost_intrusive_hmfcw::yes_type); + }; + + #else //defined(BOOST_NO_CXX11_DECLTYPE) + + #if !defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED) + + template().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(), 0)> + struct BOOST_MOVE_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { boost_intrusive_hmfcw::yes_type dummy[N ? 1 : 2]; }; + + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { + template static BOOST_MOVE_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + Test(BOOST_MOVE_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)*); + template static boost_intrusive_hmfcw::no_type Test(...); + static const bool value = sizeof(Test< Fun >(0)) == sizeof(boost_intrusive_hmfcw::yes_type); }; #else //defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED) - //Special case for 0 args - template< class F - , std::size_t N = - sizeof((boost::move_detail::declval(). - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME (), 0))> - struct BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) - { - boost_intrusive_has_member_function_callable_with::yes_type dummy; - BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)(int); - }; + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + {//GCC [3.4-4.3) gives ICE when instantiating the 0 arg version so it is not supported. + static const bool value = true; + }; - //For buggy compilers like MSVC 7.1+ ((F*)0)->func() does not - //SFINAE-out the zeroarg_checker_ instantiation but sizeof yields to 0. - template - struct BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) - { - boost_intrusive_has_member_function_callable_with::no_type dummy; - BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)(int); - }; + #endif//!defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED) + #endif //!defined(BOOST_NO_CXX11_DECLTYPE) + #endif //#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN == 0 - template - struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) - - { - template - static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) - Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)*); + #if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX > 0 + //1 to N arg specialization when BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME is present + #if defined(BOOST_NO_CXX11_DECLTYPE) + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION(N)\ + template struct BOOST_MOVE_CAT(FunWrap##N, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) : Fun\ + {\ + using Fun::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME;\ + boost_intrusive_hmfcw::private_type BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME\ + (BOOST_MOVE_REPEAT##N(boost_intrusive_hmfcw::dont_care)) const;\ + };\ + \ + template\ + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)\ + {\ + static bool const value = (sizeof(boost_intrusive_hmfcw::no_type) == sizeof(boost_intrusive_hmfcw::is_private_type\ + ( (::boost::move_detail::declval\ + < BOOST_MOVE_CAT(FunWrap##N, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) >().\ + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(BOOST_MOVE_DECLVAL##N), 0) )\ + )\ + );\ + };\ + // + #else + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION(N)\ + template\ + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)\ + \ + {\ + template\ + static decltype(boost::move_detail::declval().\ + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(BOOST_MOVE_DECLVAL##N)\ + , boost_intrusive_hmfcw::yes_type()) Test(U* f);\ + template\ + static boost_intrusive_hmfcw::no_type Test(...);\ + static const bool value = sizeof(Test((Fun*)0)) == sizeof(boost_intrusive_hmfcw::yes_type);\ + };\ + // + #endif + //////////////////////////////////// + // Build and invoke BOOST_MOVE_ITERATE_NTOM macrofunction, note that N has to be at least 1 + //////////////////////////////////// + #if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN == 0 + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN 1 + #else + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN + #endif + BOOST_MOVE_CAT + (BOOST_MOVE_CAT(BOOST_MOVE_CAT(BOOST_MOVE_ITERATE_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN), TO) + ,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX) + (BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION) + #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION + #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN + //////////////////////////////////// + // End of BOOST_MOVE_ITERATE_NTOM + //////////////////////////////////// + #endif //BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX > 0 - template - static boost_intrusive_has_member_function_callable_with::no_type Test(...); + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// + // + // has_member_function_callable_with_FUNC + // + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// - static const bool value = sizeof(Test< Fun >(0)) - == sizeof(boost_intrusive_has_member_function_callable_with::yes_type); - }; - #endif //defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED) + //Otherwise use the preprocessor + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + : public BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + ::value + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF BOOST_MOVE_CAT(BOOST_MOVE_TARG,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX)> + {}; + #endif //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#endif - #else //#if !defined(_MSC_VER) || (_MSC_VER < 1600) - template - struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) - - { - template - static decltype( boost::move_detail::declval().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME() - , boost_intrusive_has_member_function_callable_with::yes_type()) - Test(U*); +BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END - template - static boost_intrusive_has_member_function_callable_with::no_type Test(...); +//Undef local macros +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF - static const bool value = sizeof(Test(0)) - == sizeof(boost_intrusive_has_member_function_callable_with::yes_type); - }; - #endif //#if !defined(_MSC_VER) || (_MSC_VER < 1600) - - #else //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - #endif //#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END - - #else //BOOST_PP_ITERATION() == 0 - - #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN - - template - struct BOOST_PP_CAT( BOOST_PP_CAT(has_member_function_callable_with_ - , BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) - - { - struct FunWrap : Fun - { - FunWrap(); - - using Fun::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME; - boost_intrusive_has_member_function_callable_with::private_type - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME - ( BOOST_PP_ENUM(BOOST_PP_ITERATION() - , BOOST_INTRUSIVE_PP_IDENTITY - , boost_intrusive_has_member_function_callable_with::dont_care)) const; - }; - - static bool const value = - (sizeof(boost_intrusive_has_member_function_callable_with::no_type) == - sizeof(boost_intrusive_has_member_function_callable_with::is_private_type - ( (boost::move_detail::declval(). - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME - ( BOOST_PP_ENUM( BOOST_PP_ITERATION(), BOOST_INTRUSIVE_PP_DECLVAL, _) ), 0 - ) - ) - ) - ); - }; - - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END - #endif //#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - #endif //BOOST_PP_ITERATION() == 0 - - #if BOOST_PP_ITERATION() == BOOST_PP_ITERATION_FINISH() - - #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN - - template - struct BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) - : public BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME), _impl) - ::value - BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION_FINISH(), P) > - {}; - - BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END - - #endif //#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME - #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN - #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END - - #endif //#if BOOST_PP_ITERATION() == BOOST_PP_ITERATION_FINISH() - -#endif //!BOOST_PP_IS_ITERATING +//Undef user defined macros +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END diff --git a/boost/intrusive/detail/hashtable_node.hpp b/boost/intrusive/detail/hashtable_node.hpp deleted file mode 100644 index 6449fa0..0000000 --- a/boost/intrusive/detail/hashtable_node.hpp +++ /dev/null @@ -1,287 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_HASHTABLE_NODE_HPP -#define BOOST_INTRUSIVE_HASHTABLE_NODE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include //make_slist -#include -#include -#include - - -namespace boost { -namespace intrusive { -namespace detail { - -template -struct bucket_impl : public Slist -{ - typedef Slist slist_type; - bucket_impl() - {} - - bucket_impl(const bucket_impl &) - {} - - ~bucket_impl() - { - //This bucket is still being used! - BOOST_INTRUSIVE_INVARIANT_ASSERT(Slist::empty()); - } - - bucket_impl &operator=(const bucket_impl&) - { - //This bucket is still in use! - BOOST_INTRUSIVE_INVARIANT_ASSERT(Slist::empty()); - //Slist::clear(); - return *this; - } -}; - -template -struct bucket_traits_impl -{ - private: - BOOST_COPYABLE_AND_MOVABLE(bucket_traits_impl) - - public: - /// @cond - - typedef typename pointer_traits - ::template rebind_pointer - < bucket_impl >::type bucket_ptr; - typedef Slist slist; - typedef typename Slist::size_type size_type; - /// @endcond - - bucket_traits_impl(bucket_ptr buckets, size_type len) - : buckets_(buckets), buckets_len_(len) - {} - - bucket_traits_impl(const bucket_traits_impl &x) - : buckets_(x.buckets_), buckets_len_(x.buckets_len_) - {} - - bucket_traits_impl(BOOST_RV_REF(bucket_traits_impl) x) - : buckets_(x.buckets_), buckets_len_(x.buckets_len_) - { x.buckets_ = bucket_ptr(); x.buckets_len_ = 0; } - - bucket_traits_impl& operator=(BOOST_RV_REF(bucket_traits_impl) x) - { - buckets_ = x.buckets_; buckets_len_ = x.buckets_len_; - x.buckets_ = bucket_ptr(); x.buckets_len_ = 0; return *this; - } - - bucket_traits_impl& operator=(BOOST_COPY_ASSIGN_REF(bucket_traits_impl) x) - { - buckets_ = x.buckets_; buckets_len_ = x.buckets_len_; return *this; - } - - const bucket_ptr &bucket_begin() const - { return buckets_; } - - size_type bucket_count() const - { return buckets_len_; } - - private: - bucket_ptr buckets_; - size_type buckets_len_; -}; - -template -struct hash_reduced_slist_node_traits -{ - template static detail::one test(...); - template static detail::two test(typename U::reduced_slist_node_traits* = 0); - static const bool value = sizeof(test(0)) == sizeof(detail::two); -}; - -template -struct apply_reduced_slist_node_traits -{ - typedef typename NodeTraits::reduced_slist_node_traits type; -}; - -template -struct reduced_slist_node_traits -{ - typedef typename detail::eval_if_c - < hash_reduced_slist_node_traits::value - , apply_reduced_slist_node_traits - , detail::identity - >::type type; -}; - -template -struct get_slist_impl -{ - typedef trivial_value_traits trivial_traits; - - //Reducing symbol length - struct type : make_slist - < typename NodeTraits::node - , boost::intrusive::value_traits - , boost::intrusive::constant_time_size - , boost::intrusive::size_type - >::type - {}; -}; - -} //namespace detail { - -template -class hashtable_iterator -{ - typedef boost::intrusive::iterator - < std::forward_iterator_tag - , typename BucketValueTraits::value_traits::value_type - , typename pointer_traits::difference_type - , typename detail::add_const_if_c - ::type * - , typename detail::add_const_if_c - ::type & - > iterator_traits; - - typedef typename BucketValueTraits::value_traits value_traits; - typedef typename BucketValueTraits::bucket_traits bucket_traits; - typedef typename value_traits::node_traits node_traits; - typedef typename detail::get_slist_impl - ::type - >::type slist_impl; - typedef typename slist_impl::iterator siterator; - typedef typename slist_impl::const_iterator const_siterator; - typedef detail::bucket_impl bucket_type; - - typedef typename pointer_traits - ::template rebind_pointer - < const BucketValueTraits >::type const_bucketvaltraits_ptr; - typedef typename slist_impl::size_type size_type; - - - static typename node_traits::node_ptr downcast_bucket(typename bucket_type::node_ptr p) - { - return pointer_traits:: - pointer_to(static_cast(*p)); - } - - public: - typedef typename iterator_traits::difference_type difference_type; - typedef typename iterator_traits::value_type value_type; - typedef typename iterator_traits::pointer pointer; - typedef typename iterator_traits::reference reference; - typedef typename iterator_traits::iterator_category iterator_category; - - hashtable_iterator () - : slist_it_() //Value initialization to achieve "null iterators" (N3644) - {} - - explicit hashtable_iterator(siterator ptr, const BucketValueTraits *cont) - : slist_it_ (ptr), traitsptr_ (cont ? pointer_traits::pointer_to(*cont) : const_bucketvaltraits_ptr() ) - {} - - hashtable_iterator(const hashtable_iterator &other) - : slist_it_(other.slist_it()), traitsptr_(other.get_bucket_value_traits()) - {} - - const siterator &slist_it() const - { return slist_it_; } - - hashtable_iterator unconst() const - { return hashtable_iterator(this->slist_it(), this->get_bucket_value_traits()); } - - public: - hashtable_iterator& operator++() - { this->increment(); return *this; } - - hashtable_iterator operator++(int) - { - hashtable_iterator result (*this); - this->increment(); - return result; - } - - friend bool operator== (const hashtable_iterator& i, const hashtable_iterator& i2) - { return i.slist_it_ == i2.slist_it_; } - - friend bool operator!= (const hashtable_iterator& i, const hashtable_iterator& i2) - { return !(i == i2); } - - reference operator*() const - { return *this->operator ->(); } - - pointer operator->() const - { - return boost::intrusive::detail::to_raw_pointer(this->priv_value_traits().to_value_ptr - (downcast_bucket(slist_it_.pointed_node()))); - } - - const const_bucketvaltraits_ptr &get_bucket_value_traits() const - { return traitsptr_; } - - const value_traits &priv_value_traits() const - { return traitsptr_->priv_value_traits(); } - - const bucket_traits &priv_bucket_traits() const - { return traitsptr_->priv_bucket_traits(); } - - private: - void increment() - { - const bucket_traits &rbuck_traits = this->priv_bucket_traits(); - bucket_type* const buckets = boost::intrusive::detail::to_raw_pointer(rbuck_traits.bucket_begin()); - const size_type buckets_len = rbuck_traits.bucket_count(); - - ++slist_it_; - const typename slist_impl::node_ptr n = slist_it_.pointed_node(); - const siterator first_bucket_bbegin = buckets->end(); - if(first_bucket_bbegin.pointed_node() <= n && n <= buckets[buckets_len-1].cend().pointed_node()){ - //If one-past the node is inside the bucket then look for the next non-empty bucket - //1. get the bucket_impl from the iterator - const bucket_type &b = static_cast - (bucket_type::slist_type::container_from_end_iterator(slist_it_)); - - //2. Now just calculate the index b has in the bucket array - size_type n_bucket = static_cast(&b - buckets); - - //3. Iterate until a non-empty bucket is found - do{ - if (++n_bucket >= buckets_len){ //bucket overflow, return end() iterator - slist_it_ = buckets->before_begin(); - return; - } - } - while (buckets[n_bucket].empty()); - slist_it_ = buckets[n_bucket].begin(); - } - else{ - //++slist_it_ yield to a valid object - } - } - - siterator slist_it_; - const_bucketvaltraits_ptr traitsptr_; -}; - -} //namespace intrusive { -} //namespace boost { - -#endif diff --git a/boost/intrusive/detail/hook_traits.hpp b/boost/intrusive/detail/hook_traits.hpp deleted file mode 100644 index c9c115b..0000000 --- a/boost/intrusive/detail/hook_traits.hpp +++ /dev/null @@ -1,182 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2006-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_HOOK_TRAITS_HPP -#define BOOST_INTRUSIVE_DETAIL_HOOK_TRAITS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -template -struct bhtraits_base -{ - public: - typedef NodePtr node_ptr; - typedef typename pointer_traits::element_type node; - typedef node_holder node_holder_type; - typedef T value_type; - typedef typename pointer_traits:: - template rebind_pointer::type const_node_ptr; - typedef typename pointer_traits:: - template rebind_pointer::type pointer; - typedef typename pointer_traits:: - template rebind_pointer::type const_pointer; - //typedef typename pointer_traits::reference reference; - //typedef typename pointer_traits::reference const_reference; - typedef T & reference; - typedef const T & const_reference; - typedef node_holder_type & node_holder_reference; - typedef const node_holder_type & const_node_holder_reference; - typedef node& node_reference; - typedef const node & const_node_reference; - - static pointer to_value_ptr(const node_ptr & n) - { - return pointer_traits::pointer_to - (static_cast(static_cast(*n))); - } - - static const_pointer to_value_ptr(const const_node_ptr & n) - { - return pointer_traits::pointer_to - (static_cast(static_cast(*n))); - } - - static node_ptr to_node_ptr(reference value) - { - return pointer_traits::pointer_to - (static_cast(static_cast(value))); - } - - static const_node_ptr to_node_ptr(const_reference value) - { - return pointer_traits::pointer_to - (static_cast(static_cast(value))); - } -}; - -template -struct bhtraits - : public bhtraits_base -{ - static const link_mode_type link_mode = LinkMode; - typedef NodeTraits node_traits; -}; - - -template -struct mhtraits -{ - public: - typedef Hook hook_type; - typedef typename hook_type::hooktags::node_traits node_traits; - typedef typename node_traits::node node; - typedef T value_type; - typedef typename node_traits::node_ptr node_ptr; - typedef typename node_traits::const_node_ptr const_node_ptr; - typedef typename pointer_traits:: - template rebind_pointer::type pointer; - typedef typename pointer_traits:: - template rebind_pointer::type const_pointer; - typedef T & reference; - typedef const T & const_reference; - typedef node& node_reference; - typedef const node & const_node_reference; - typedef hook_type& hook_reference; - typedef const hook_type & const_hook_reference; - - static const link_mode_type link_mode = Hook::hooktags::link_mode; - - static node_ptr to_node_ptr(reference value) - { - return pointer_traits::pointer_to - (static_cast(static_cast(value.*P))); - } - - static const_node_ptr to_node_ptr(const_reference value) - { - return pointer_traits::pointer_to - (static_cast(static_cast(value.*P))); - } - - static pointer to_value_ptr(const node_ptr & n) - { - return pointer_traits::pointer_to - (*detail::parent_from_member - (static_cast(boost::intrusive::detail::to_raw_pointer(n)), P)); - } - - static const_pointer to_value_ptr(const const_node_ptr & n) - { - return pointer_traits::pointer_to - (*detail::parent_from_member - (static_cast(boost::intrusive::detail::to_raw_pointer(n)), P)); - } -}; - - -template -struct fhtraits -{ - public: - typedef typename Functor::hook_type hook_type; - typedef typename Functor::hook_ptr hook_ptr; - typedef typename Functor::const_hook_ptr const_hook_ptr; - typedef typename hook_type::hooktags::node_traits node_traits; - typedef typename node_traits::node node; - typedef typename Functor::value_type value_type; - typedef typename node_traits::node_ptr node_ptr; - typedef typename node_traits::const_node_ptr const_node_ptr; - typedef typename pointer_traits:: - template rebind_pointer::type pointer; - typedef typename pointer_traits:: - template rebind_pointer::type const_pointer; - typedef value_type & reference; - typedef const value_type & const_reference; - static const link_mode_type link_mode = hook_type::hooktags::link_mode; - - static node_ptr to_node_ptr(reference value) - { return static_cast(boost::intrusive::detail::to_raw_pointer(Functor::to_hook_ptr(value))); } - - static const_node_ptr to_node_ptr(const_reference value) - { return static_cast(boost::intrusive::detail::to_raw_pointer(Functor::to_hook_ptr(value))); } - - static pointer to_value_ptr(const node_ptr & n) - { return Functor::to_value_ptr(to_hook_ptr(n)); } - - static const_pointer to_value_ptr(const const_node_ptr & n) - { return Functor::to_value_ptr(to_hook_ptr(n)); } - - private: - static hook_ptr to_hook_ptr(const node_ptr & n) - { return hook_ptr(&*static_cast(&*n)); } - - static const_hook_ptr to_hook_ptr(const const_node_ptr & n) - { return const_hook_ptr(&*static_cast(&*n)); } -}; - - -} //namespace intrusive -} //namespace boost - -#endif //BOOST_INTRUSIVE_DETAIL_HOOK_TRAITS_HPP diff --git a/boost/intrusive/detail/iiterator.hpp b/boost/intrusive/detail/iiterator.hpp deleted file mode 100644 index 8378ead..0000000 --- a/boost/intrusive/detail/iiterator.hpp +++ /dev/null @@ -1,227 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2006-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_IITERATOR_HPP -#define BOOST_INTRUSIVE_DETAIL_IITERATOR_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include - -#include - - -namespace boost { -namespace intrusive { - -template -struct iterator -{ - typedef Category iterator_category; - typedef T value_type; - typedef Distance difference_type; - typedef Pointer pointer; - typedef Reference reference; -}; - -template -struct iterator_traits -{ - typedef typename Iterator::difference_type difference_type; - typedef typename Iterator::value_type value_type; - typedef typename Iterator::pointer pointer; - typedef typename Iterator::reference reference; - typedef typename Iterator::iterator_category iterator_category; -}; - -template -struct iterator_traits -{ - typedef std::ptrdiff_t difference_type; - typedef T value_type; - typedef T* pointer; - typedef T& reference; - typedef std::random_access_iterator_tag iterator_category; -}; - -template -struct iterator_traits -{ - typedef std::ptrdiff_t difference_type; - typedef T value_type; - typedef const T* pointer; - typedef const T& reference; - typedef std::random_access_iterator_tag iterator_category; -}; - -template -struct value_traits_pointers -{ - typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT - (boost::intrusive::detail:: - , ValueTraits, value_traits_ptr - , typename pointer_traits::template - rebind_pointer::type) value_traits_ptr; - - typedef typename pointer_traits::template - rebind_pointer::type const_value_traits_ptr; -}; - -template -struct iiterator -{ - typedef ValueTraits value_traits; - typedef typename value_traits::node_traits node_traits; - typedef typename node_traits::node node; - typedef typename node_traits::node_ptr node_ptr; - typedef ::boost::intrusive::pointer_traits nodepointer_traits_t; - typedef typename nodepointer_traits_t::template - rebind_pointer::type void_pointer; - typedef typename ValueTraits::value_type value_type; - typedef typename ValueTraits::pointer nonconst_pointer; - typedef typename ValueTraits::const_pointer yesconst_pointer; - typedef typename ::boost::intrusive::pointer_traits - ::reference nonconst_reference; - typedef typename ::boost::intrusive::pointer_traits - ::reference yesconst_reference; - typedef typename nodepointer_traits_t::difference_type difference_type; - typedef typename detail::if_c - ::type pointer; - typedef typename detail::if_c - ::type reference; - typedef iterator - < Category - , value_type - , difference_type - , pointer - , reference - > iterator_traits; - typedef typename value_traits_pointers - ::value_traits_ptr value_traits_ptr; - typedef typename value_traits_pointers - ::const_value_traits_ptr const_value_traits_ptr; - static const bool stateful_value_traits = - detail::is_stateful_value_traits::value; -}; - -template -struct iiterator_members -{ - - iiterator_members() - : nodeptr_()//Value initialization to achieve "null iterators" (N3644) - {} - - iiterator_members(const NodePtr &n_ptr, const StoredPointer &data) - : nodeptr_(n_ptr), ptr_(data) - {} - - StoredPointer get_ptr() const - { return ptr_; } - - NodePtr nodeptr_; - StoredPointer ptr_; -}; - -template -struct iiterator_members -{ - iiterator_members() - : nodeptr_()//Value initialization to achieve "null iterators" (N3644) - {} - - iiterator_members(const NodePtr &n_ptr, const StoredPointer &) - : nodeptr_(n_ptr) - {} - - StoredPointer get_ptr() const - { return StoredPointer(); } - - NodePtr nodeptr_; -}; - -namespace detail { - -template inline -void advance_impl(InputIt& it, Distance n, const std::input_iterator_tag&) -{ - while(n--) - ++it; -} - -template inline -void advance_impl(InputIt& it, Distance n, std::forward_iterator_tag &) -{ - while(n--) - ++it; -} - -template inline -void advance_impl(InputIt& it, Distance n, std::bidirectional_iterator_tag &) -{ - for (; 0 < n; --n) - ++it; - for (; n < 0; ++n) - --it; -} - -template -inline void advance_impl(InputIt& it, Distance n, const std::random_access_iterator_tag &) -{ - it += n; -} - -} //namespace detail - -template -inline void iterator_advance(InputIt& it, Distance n) -{ // increment iterator by offset, arbitrary iterators - boost::intrusive::detail::advance_impl(it, n, boost::intrusive::iterator_traits::iterator_category()); -} - -namespace detail{ - -template -inline void distance_impl(InputIt first, InputIt last, Distance& off, const Category &) -{ - while(first != last){ - ++off; - ++first; - } -} - -template inline -void distance_impl(InputIt first, InputIt last, Distance& off, const std::random_access_iterator_tag&) -{ - off += last - first; -} - -} //namespace detail - -template inline -typename iterator_traits::difference_type iterator_distance(InputIt first, InputIt last) -{ - typename iterator_traits::difference_type off = 0; - boost::intrusive::detail::distance_impl(first, last, off, boost::intrusive::iterator_traits::iterator_category()); - return off; -} - - -} //namespace intrusive -} //namespace boost - -#endif //BOOST_INTRUSIVE_DETAIL_IITERATOR_HPP diff --git a/boost/intrusive/detail/is_stateful_value_traits.hpp b/boost/intrusive/detail/is_stateful_value_traits.hpp deleted file mode 100644 index da2260e..0000000 --- a/boost/intrusive/detail/is_stateful_value_traits.hpp +++ /dev/null @@ -1,77 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2009-2013. -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_IS_STATEFUL_VALUE_TRAITS_HPP -#define BOOST_INTRUSIVE_DETAIL_IS_STATEFUL_VALUE_TRAITS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#if defined(_MSC_VER) && (_MSC_VER <= 1310) - -#include - -namespace boost { -namespace intrusive { -namespace detail { - -template -struct is_stateful_value_traits -{ - static const bool value = !detail::is_empty_class::value; -}; - -}}} - -#else - -#include - -BOOST_INTRUSIVE_CREATE_FUNCTION_DETECTOR(to_node_ptr, boost_intrusive) -BOOST_INTRUSIVE_CREATE_FUNCTION_DETECTOR(to_value_ptr, boost_intrusive) - -namespace boost { -namespace intrusive { -namespace detail { - -template -struct is_stateful_value_traits -{ - typedef typename ValueTraits::node_ptr node_ptr; - typedef typename ValueTraits::pointer pointer; - typedef typename ValueTraits::value_type value_type; - typedef typename ValueTraits::const_node_ptr const_node_ptr; - typedef typename ValueTraits::const_pointer const_pointer; - - typedef ValueTraits value_traits; - - static const bool value = - (boost::intrusive::function_detector::NonStaticFunction == - (BOOST_INTRUSIVE_DETECT_FUNCTION(ValueTraits, boost_intrusive, node_ptr, to_node_ptr, (value_type&) ))) - || - (boost::intrusive::function_detector::NonStaticFunction == - (BOOST_INTRUSIVE_DETECT_FUNCTION(ValueTraits, boost_intrusive, pointer, to_value_ptr, (node_ptr) ))) - || - (boost::intrusive::function_detector::NonStaticFunction == - (BOOST_INTRUSIVE_DETECT_FUNCTION(ValueTraits, boost_intrusive, const_node_ptr, to_node_ptr, (const value_type&) ))) - || - (boost::intrusive::function_detector::NonStaticFunction == - (BOOST_INTRUSIVE_DETECT_FUNCTION(ValueTraits, boost_intrusive, const_pointer, to_value_ptr, (const_node_ptr) ))) - ; -}; - -}}} - -#endif - -#endif //@ifndef BOOST_INTRUSIVE_DETAIL_IS_STATEFUL_VALUE_TRAITS_HPP diff --git a/boost/intrusive/detail/iterator.hpp b/boost/intrusive/detail/iterator.hpp new file mode 100644 index 0000000..9f0fe60 --- /dev/null +++ b/boost/intrusive/detail/iterator.hpp @@ -0,0 +1,155 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014 +// +// Distributed under the 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP +#define BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include +#include +#include +#include + +namespace boost { +namespace intrusive { + +using boost::movelib::iterator_traits; + +//////////////////// +// iterator +//////////////////// +template +struct iterator +{ + typedef Category iterator_category; + typedef T value_type; + typedef Distance difference_type; + typedef Pointer pointer; + typedef Reference reference; +}; + +//////////////////////////////////////// +// iterator_[dis|en]able_if_tag +//////////////////////////////////////// +template +struct iterator_enable_if_tag + : ::boost::move_detail::enable_if_c + < ::boost::move_detail::is_same + < typename boost::intrusive::iterator_traits::iterator_category + , Tag + >::value + , R> +{}; + +template +struct iterator_disable_if_tag + : ::boost::move_detail::enable_if_c + < !::boost::move_detail::is_same + < typename boost::intrusive::iterator_traits::iterator_category + , Tag + >::value + , R> +{}; + +//////////////////////////////////////// +// iterator_[dis|en]able_if_tag_difference_type +//////////////////////////////////////// +template +struct iterator_enable_if_tag_difference_type + : iterator_enable_if_tag::difference_type> +{}; + +template +struct iterator_disable_if_tag_difference_type + : iterator_disable_if_tag::difference_type> +{}; + +//////////////////// +// advance +//////////////////// +template inline +typename iterator_enable_if_tag::type + iterator_advance(InputIt& it, Distance n) +{ + while(n--) + ++it; +} + +template inline +typename iterator_enable_if_tag::type + iterator_advance(InputIt& it, Distance n) +{ + while(n--) + ++it; +} + +template inline +typename iterator_enable_if_tag::type + iterator_advance(InputIt& it, Distance n) +{ + for (; 0 < n; --n) + ++it; + for (; n < 0; ++n) + --it; +} + +template inline +typename iterator_enable_if_tag::type + iterator_advance(InputIt& it, Distance n) +{ + it += n; +} + +//////////////////// +// distance +//////////////////// +template inline +typename iterator_disable_if_tag_difference_type + ::type + iterator_distance(InputIt first, InputIt last) +{ + typename iterator_traits::difference_type off = 0; + while(first != last){ + ++off; + ++first; + } + return off; +} + +template inline +typename iterator_enable_if_tag_difference_type + ::type + iterator_distance(InputIt first, InputIt last) +{ + typename iterator_traits::difference_type off = last - first; + return off; +} + +template +typename iterator_traits::pointer iterator_arrow_result(const I &i) +{ return i.operator->(); } + +template +T * iterator_arrow_result(T *p) +{ return p; } + +} //namespace intrusive +} //namespace boost + +#endif //BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP diff --git a/boost/intrusive/detail/key_nodeptr_comp.hpp b/boost/intrusive/detail/key_nodeptr_comp.hpp deleted file mode 100644 index dfee8b9..0000000 --- a/boost/intrusive/detail/key_nodeptr_comp.hpp +++ /dev/null @@ -1,72 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_KEY_NODEPTR_COMP_HPP -#define BOOST_INTRUSIVE_DETAIL_KEY_NODEPTR_COMP_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -namespace boost { -namespace intrusive { -namespace detail { - -template -struct key_nodeptr_comp - : private ebo_functor_holder -{ - typedef ValueTraits value_traits; - typedef typename value_traits::value_type value_type; - typedef typename value_traits::node_ptr node_ptr; - typedef typename value_traits::const_node_ptr const_node_ptr; - typedef ebo_functor_holder base_t; - - key_nodeptr_comp(KeyValueCompare kcomp, const ValueTraits *traits) - : base_t(kcomp), traits_(traits) - {} - - template - struct is_node_ptr - { - static const bool value = is_same::value || is_same::value; - }; - - template - const value_type & key_forward - (const T &node, typename enable_if_c::value>::type * = 0) const - { return *traits_->to_value_ptr(node); } - - template - const T & key_forward(const T &key, typename enable_if_c::value>::type* = 0) const - { return key; } - - - template - bool operator()(const KeyType &key1, const KeyType2 &key2) const - { return base_t::get()(this->key_forward(key1), this->key_forward(key2)); } - - template - bool operator()(const KeyType &key1) const - { return base_t::get()(this->key_forward(key1)); } - - const ValueTraits *const traits_; -}; - -} //namespace detail{ -} //namespace intrusive{ -} //namespace boost{ - -#endif //BOOST_INTRUSIVE_DETAIL_KEY_NODEPTR_COMP_HPP diff --git a/boost/intrusive/detail/list_iterator.hpp b/boost/intrusive/detail/list_iterator.hpp deleted file mode 100644 index efddfba..0000000 --- a/boost/intrusive/detail/list_iterator.hpp +++ /dev/null @@ -1,129 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_LIST_ITERATOR_HPP -#define BOOST_INTRUSIVE_LIST_ITERATOR_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include - -namespace boost { -namespace intrusive { - -// list_iterator provides some basic functions for a -// node oriented bidirectional iterator: -template -class list_iterator -{ - protected: - typedef iiterator - types_t; - - static const bool stateful_value_traits = types_t::stateful_value_traits; - - typedef ValueTraits value_traits; - typedef typename types_t::node_traits node_traits; - - typedef typename types_t::node node; - typedef typename types_t::node_ptr node_ptr; - typedef typename types_t::const_value_traits_ptr const_value_traits_ptr; - - public: - typedef typename types_t::iterator_traits::difference_type difference_type; - typedef typename types_t::iterator_traits::value_type value_type; - typedef typename types_t::iterator_traits::pointer pointer; - typedef typename types_t::iterator_traits::reference reference; - typedef typename types_t::iterator_traits::iterator_category iterator_category; - - list_iterator() - {} - - explicit list_iterator(const node_ptr & nodeptr, const const_value_traits_ptr &traits_ptr) - : members_(nodeptr, traits_ptr) - {} - - list_iterator(list_iterator const& other) - : members_(other.pointed_node(), other.get_value_traits()) - {} - - const node_ptr &pointed_node() const - { return members_.nodeptr_; } - - list_iterator &operator=(const node_ptr &node) - { members_.nodeptr_ = node; return static_cast(*this); } - - const_value_traits_ptr get_value_traits() const - { return members_.get_ptr(); } - - public: - list_iterator& operator++() - { - node_ptr p = node_traits::get_next(members_.nodeptr_); - members_.nodeptr_ = p; - return static_cast (*this); - } - - list_iterator operator++(int) - { - list_iterator result (*this); - members_.nodeptr_ = node_traits::get_next(members_.nodeptr_); - return result; - } - - list_iterator& operator--() - { - members_.nodeptr_ = node_traits::get_previous(members_.nodeptr_); - return static_cast (*this); - } - - list_iterator operator--(int) - { - list_iterator result (*this); - members_.nodeptr_ = node_traits::get_previous(members_.nodeptr_); - return result; - } - - friend bool operator== (const list_iterator& l, const list_iterator& r) - { return l.pointed_node() == r.pointed_node(); } - - friend bool operator!= (const list_iterator& l, const list_iterator& r) - { return !(l == r); } - - reference operator*() const - { return *operator->(); } - - pointer operator->() const - { return this->operator_arrow(detail::bool_()); } - - list_iterator unconst() const - { return list_iterator(this->pointed_node(), this->get_value_traits()); } - - private: - pointer operator_arrow(detail::false_) const - { return ValueTraits::to_value_ptr(members_.nodeptr_); } - - pointer operator_arrow(detail::true_) const - { return this->get_value_traits()->to_value_ptr(members_.nodeptr_); } - - iiterator_members members_; -}; - -} //namespace intrusive -} //namespace boost - -#endif //BOOST_INTRUSIVE_LIST_ITERATOR_HPP diff --git a/boost/intrusive/detail/list_node.hpp b/boost/intrusive/detail/list_node.hpp deleted file mode 100644 index ba97ece..0000000 --- a/boost/intrusive/detail/list_node.hpp +++ /dev/null @@ -1,67 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_LIST_NODE_HPP -#define BOOST_INTRUSIVE_LIST_NODE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include - -namespace boost { -namespace intrusive { - -// list_node_traits can be used with circular_list_algorithms and supplies -// a list_node holding the pointers needed for a double-linked list -// it is used by list_derived_node and list_member_node - -template -struct list_node -{ - typedef typename pointer_rebind::type node_ptr; - node_ptr next_; - node_ptr prev_; -}; - -template -struct list_node_traits -{ - typedef list_node node; - typedef typename node::node_ptr node_ptr; - typedef typename pointer_rebind::type const_node_ptr; - - 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 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) - { n->next_ = next; } -}; - -} //namespace intrusive -} //namespace boost - -#endif //BOOST_INTRUSIVE_LIST_NODE_HPP diff --git a/boost/intrusive/detail/math.hpp b/boost/intrusive/detail/math.hpp deleted file mode 100644 index f212ae7..0000000 --- a/boost/intrusive/detail/math.hpp +++ /dev/null @@ -1,271 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_MATH_HPP -#define BOOST_INTRUSIVE_DETAIL_MATH_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -namespace boost { -namespace intrusive { -namespace detail { - -/////////////////////////// -// floor_log2 Dispatcher -//////////////////////////// - -#if defined(_MSC_VER) && (_MSC_VER >= 1300) - - }}} //namespace boost::intrusive::detail - - //Use _BitScanReverseXX intrinsics - - #if defined(_M_X64) || defined(_M_AMD64) || defined(_M_IA64) //64 bit target - #define BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT - #endif - - #ifndef __INTRIN_H_ // Avoid including any windows system header - #ifdef __cplusplus - extern "C" { - #endif // __cplusplus - - #if defined(BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT) //64 bit target - unsigned char _BitScanReverse64(unsigned long *index, unsigned __int64 mask); - #pragma intrinsic(_BitScanReverse64) - #else //32 bit target - unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); - #pragma intrinsic(_BitScanReverse) - #endif - - #ifdef __cplusplus - } - #endif // __cplusplus - #endif // __INTRIN_H_ - - #ifdef BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT - #define BOOST_INTRUSIVE_BSR_INTRINSIC _BitScanReverse64 - #undef BOOST_INTRUSIVE_BSR_INTRINSIC_64_BIT - #else - #define BOOST_INTRUSIVE_BSR_INTRINSIC _BitScanReverse - #endif - - namespace boost { - namespace intrusive { - namespace detail { - - inline std::size_t floor_log2 (std::size_t x) - { - unsigned long log2; - BOOST_INTRUSIVE_BSR_INTRINSIC( &log2, (unsigned long)x ); - return log2; - } - - #undef BOOST_INTRUSIVE_BSR_INTRINSIC - -#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) //GCC >=3.4 - - //Compile-time error in case of missing specialization - template - struct builtin_clz_dispatch; - - #if defined(BOOST_HAS_LONG_LONG) - template<> - struct builtin_clz_dispatch - { - static unsigned long long call(unsigned long long n) - { return __builtin_clzll(n); } - }; - #endif - - template<> - struct builtin_clz_dispatch - { - static unsigned long call(unsigned long n) - { return __builtin_clzl(n); } - }; - - template<> - struct builtin_clz_dispatch - { - static unsigned int call(unsigned int n) - { return __builtin_clz(n); } - }; - - inline std::size_t floor_log2(std::size_t n) - { - return sizeof(std::size_t)*CHAR_BIT - std::size_t(1) - builtin_clz_dispatch::call(n); - } - -#else //Portable methods - -//////////////////////////// -// Generic method -//////////////////////////// - - inline std::size_t floor_log2_get_shift(std::size_t n, true_ )//power of two size_t - { return n >> 1; } - - inline std::size_t floor_log2_get_shift(std::size_t n, false_ )//non-power of two size_t - { return (n >> 1) + ((n & 1u) & (n != 1)); } - - template - inline std::size_t floor_log2 (std::size_t x, integer) - { - const std::size_t Bits = N; - const bool Size_t_Bits_Power_2= !(Bits & (Bits-1)); - - std::size_t n = x; - std::size_t log2 = 0; - - std::size_t remaining_bits = Bits; - std::size_t shift = floor_log2_get_shift(remaining_bits, bool_()); - while(shift){ - std::size_t tmp = n >> shift; - if (tmp){ - log2 += shift, n = tmp; - } - shift = floor_log2_get_shift(shift, bool_()); - } - - return log2; - } - - //////////////////////////// - // DeBruijn method - //////////////////////////// - - //Taken from: - //http://stackoverflow.com/questions/11376288/fast-computing-of-log2-for-64-bit-integers - //Thanks to Desmond Hume - - inline std::size_t floor_log2 (std::size_t v, integer) - { - static const int MultiplyDeBruijnBitPosition[32] = - { - 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, - 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 - }; - - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - - return MultiplyDeBruijnBitPosition[(std::size_t)(v * 0x07C4ACDDU) >> 27]; - } - - inline std::size_t floor_log2 (std::size_t v, integer) - { - static const std::size_t MultiplyDeBruijnBitPosition[64] = { - 63, 0, 58, 1, 59, 47, 53, 2, - 60, 39, 48, 27, 54, 33, 42, 3, - 61, 51, 37, 40, 49, 18, 28, 20, - 55, 30, 34, 11, 43, 14, 22, 4, - 62, 57, 46, 52, 38, 26, 32, 41, - 50, 36, 17, 19, 29, 10, 13, 21, - 56, 45, 25, 31, 35, 16, 9, 12, - 44, 24, 15, 8, 23, 7, 6, 5}; - - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - v |= v >> 32; - return MultiplyDeBruijnBitPosition[((std::size_t)((v - (v >> 1))*0x07EDD5E59A4E28C2ULL)) >> 58]; - } - - - inline std::size_t floor_log2 (std::size_t x) - { - const std::size_t Bits = sizeof(std::size_t)*CHAR_BIT; - return floor_log2(x, integer()); - } - -#endif - -//Thanks to Laurent de Soras in -//http://www.flipcode.com/archives/Fast_log_Function.shtml -inline float fast_log2 (float val) -{ - union caster_t - { - unsigned x; - float val; - } caster; - - caster.val = val; - unsigned x = caster.x; - const int log_2 = int((x >> 23) & 255) - 128; - x &= ~(unsigned(255u) << 23u); - x += unsigned(127) << 23u; - caster.x = x; - val = caster.val; - //1+log2(m), m ranging from 1 to 2 - //3rd degree polynomial keeping first derivate continuity. - //For less precision the line can be commented out - val = ((-1.f/3.f) * val + 2.f) * val - (2.f/3.f); - return val + static_cast(log_2); -} - -inline std::size_t ceil_log2 (std::size_t x) -{ - return static_cast((x & (x-1)) != 0) + floor_log2(x); -} - -template -struct numbits_eq -{ - static const bool value = sizeof(SizeType)*CHAR_BIT == N; -}; - -template -struct sqrt2_pow_max; - -template -struct sqrt2_pow_max >::type> -{ - static const SizeType value = 0xb504f334; - static const std::size_t pow = 31; -}; - -#ifndef BOOST_NO_INT64_T - -template -struct sqrt2_pow_max >::type> -{ - static const SizeType value = 0xb504f333f9de6484ull; - static const std::size_t pow = 63; -}; - -#endif //BOOST_NO_INT64_T - -// Returns floor(pow(sqrt(2), x * 2 + 1)). -// Defined for X from 0 up to the number of bits in size_t minus 1. -inline std::size_t sqrt2_pow_2xplus1 (std::size_t x) -{ - const std::size_t value = (std::size_t)sqrt2_pow_max::value; - const std::size_t pow = (std::size_t)sqrt2_pow_max::pow; - return (value >> (pow - x)) + 1; -} - -} //namespace detail -} //namespace intrusive -} //namespace boost - -#endif //BOOST_INTRUSIVE_DETAIL_MATH_HPP diff --git a/boost/intrusive/detail/memory_util.hpp b/boost/intrusive/detail/memory_util.hpp deleted file mode 100644 index 18a5d3e..0000000 --- a/boost/intrusive/detail/memory_util.hpp +++ /dev/null @@ -1,92 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Pablo Halpern 2009. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2011-2014. Distributed under the 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/intrusive for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_ALLOCATOR_MEMORY_UTIL_HPP -#define BOOST_INTRUSIVE_ALLOCATOR_MEMORY_UTIL_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include - -namespace boost { -namespace intrusive { -namespace detail { - -template -inline T* addressof(T& obj) -{ - return static_cast - (static_cast - (const_cast - (&reinterpret_cast(obj)) - ) - ); -} - -template -struct LowPriorityConversion -{ - // Convertible from T with user-defined-conversion rank. - LowPriorityConversion(const T&) { } -}; - -}}} //namespace boost::intrusive::detail - -#include - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME pointer_to -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, )) -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME static_cast_from -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, )) -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME const_cast_from -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, )) -#include BOOST_PP_ITERATE() - -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME dynamic_cast_from -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, )) -#include BOOST_PP_ITERATE() - -namespace boost { -namespace intrusive { -namespace detail { - -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(element_type) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference) -BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(value_traits_ptr) - -} //namespace detail { -} //namespace intrusive { -} //namespace boost { - -#endif // ! defined(BOOST_INTRUSIVE_ALLOCATOR_MEMORY_UTIL_HPP) diff --git a/boost/intrusive/detail/minimal_less_equal_header.hpp b/boost/intrusive/detail/minimal_less_equal_header.hpp new file mode 100644 index 0000000..5e8a19d --- /dev/null +++ b/boost/intrusive/detail/minimal_less_equal_header.hpp @@ -0,0 +1,30 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015 +// +// Distributed under the 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_DETAIL_MINIMAL_LESS_EQUAL_HEADER_HPP +#define BOOST_INTRUSIVE_DETAIL_MINIMAL_LESS_EQUAL_HEADER_HPP +# +#ifndef BOOST_CONFIG_HPP +# include +#endif +# +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif +# +#//Try to avoid including , as it's quite big in C++11 +#if defined(BOOST_GNU_STDLIB) +# include +#else +# include //Fallback +#endif +# +#endif //BOOST_INTRUSIVE_DETAIL_MINIMAL_LESS_EQUAL_HEADER_HPP diff --git a/boost/intrusive/detail/minimal_pair_header.hpp b/boost/intrusive/detail/minimal_pair_header.hpp new file mode 100644 index 0000000..1358a08 --- /dev/null +++ b/boost/intrusive/detail/minimal_pair_header.hpp @@ -0,0 +1,30 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015 +// +// Distributed under the 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_INTRUSIVE_DETAIL_MINIMAL_PAIR_HEADER_HPP +#define BOOST_INTRUSIVE_DETAIL_MINIMAL_PAIR_HEADER_HPP +# +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif +# +#ifndef BOOST_CONFIG_HPP +# include +#endif +# +#//Try to avoid including , as it's quite big in C++11 +#if defined(BOOST_GNU_STDLIB) +# include +#else +# include //Fallback +#endif +# +#endif //BOOST_INTRUSIVE_DETAIL_MINIMAL_PAIR_HEADER_HPP diff --git a/boost/intrusive/detail/mpl.hpp b/boost/intrusive/detail/mpl.hpp index 9b2c9f1..8d227a1 100644 --- a/boost/intrusive/detail/mpl.hpp +++ b/boost/intrusive/detail/mpl.hpp @@ -14,265 +14,57 @@ #ifndef BOOST_INTRUSIVE_DETAIL_MPL_HPP #define BOOST_INTRUSIVE_DETAIL_MPL_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include +#include #include namespace boost { namespace intrusive { namespace detail { - -template -struct is_same -{ - static const bool value = false; -}; - -template -struct is_same -{ - static const bool value = true; -}; - -template -struct add_const -{ typedef const T type; }; - -template -struct remove_const -{ typedef T type; }; - -template -struct remove_const -{ typedef T type; }; - -template -struct remove_cv -{ typedef T type; }; - -template -struct remove_cv -{ typedef T type; }; - -template -struct remove_cv -{ typedef T type; }; - -template -struct remove_cv -{ typedef T type; }; - -template -struct remove_reference -{ - typedef T type; -}; - -template -struct remove_reference -{ - typedef T type; -}; - -template -struct remove_pointer -{ - typedef T type; -}; - -template -struct remove_pointer -{ - typedef T type; -}; - -template -struct add_pointer -{ - typedef T *type; -}; - -typedef char one; -struct two {one _[2];}; - -template< bool C_ > -struct bool_ -{ - static const bool value = C_; -}; - -template< class Integer, Integer Value > -struct integer -{ - static const Integer value = Value; -}; - -typedef bool_ true_; -typedef bool_ false_; - -typedef true_ true_type; -typedef false_ false_type; - -typedef char yes_type; -struct no_type -{ - char padding[8]; -}; - -template -struct enable_if_c { - typedef T type; -}; - -template -struct enable_if_c {}; - -template -struct enable_if : public enable_if_c{}; - -template -struct apply -{ - typedef typename F::template apply::type type; -}; - -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - -template -struct is_convertible -{ - static const bool value = __is_convertible_to(T, U); -}; - -#else - -template -class is_convertible -{ - typedef char true_t; - class false_t { char dummy[2]; }; - //use any_conversion as first parameter since in MSVC - //overaligned types can't go through ellipsis - static false_t dispatch(...); - static true_t dispatch(U); - static typename remove_reference::type &trigger(); - public: - static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t); -}; - -#endif - -template< - bool C - , typename T1 - , typename T2 - > -struct if_c -{ - typedef T1 type; -}; - -template< - typename T1 - , typename T2 - > -struct if_c -{ - typedef T2 type; -}; - -template< - typename C - , typename T1 - , typename T2 - > -struct if_ -{ - typedef typename if_c<0 != C::value, T1, T2>::type type; -}; - -template< - bool C - , typename F1 - , typename F2 - > -struct eval_if_c - : if_c::type -{}; - -template< - typename C - , typename T1 - , typename T2 - > -struct eval_if - : if_::type -{}; - -// identity is an extension: it is not part of the standard. -template -struct identity -{ - typedef T type; -}; - -template -struct add_const_if_c -{ - typedef typename if_c - < Add - , typename add_const::type - , T - >::type type; -}; - - -//boost::alignment_of yields to 10K lines of preprocessed code, so we -//need an alternative -template struct alignment_of; - -template -struct alignment_of_hack -{ - char c; - T t; - alignment_of_hack(); -}; - -template -struct alignment_logic -{ - static const std::size_t value = A < S ? A : S; -}; - -template< typename T > -struct alignment_of -{ - static const std::size_t value = alignment_logic - < sizeof(alignment_of_hack) - sizeof(T) - , sizeof(T) - >::value; -}; - -template -class is_empty_class -{ - template - struct empty_helper_t1 : public T - { - empty_helper_t1(); - int i[256]; - }; - - struct empty_helper_t2 - { int i[256]; }; - - public: - static const bool value = sizeof(empty_helper_t1) == sizeof(empty_helper_t2); -}; + +using boost::move_detail::is_same; +using boost::move_detail::add_const; +using boost::move_detail::remove_const; +using boost::move_detail::remove_cv; +using boost::move_detail::remove_reference; +using boost::move_detail::add_reference; +using boost::move_detail::remove_pointer; +using boost::move_detail::add_pointer; +using boost::move_detail::true_type; +using boost::move_detail::false_type; +using boost::move_detail::enable_if_c; +using boost::move_detail::enable_if; +using boost::move_detail::disable_if_c; +using boost::move_detail::disable_if; +using boost::move_detail::is_convertible; +using boost::move_detail::if_c; +using boost::move_detail::if_; +using boost::move_detail::is_const; +using boost::move_detail::identity; +using boost::move_detail::alignment_of; +using boost::move_detail::is_empty; +using boost::move_detail::addressof; +using boost::move_detail::integral_constant; +using boost::move_detail::enable_if_convertible; +using boost::move_detail::disable_if_convertible; +using boost::move_detail::bool_; +using boost::move_detail::true_; +using boost::move_detail::false_; +using boost::move_detail::yes_type; +using boost::move_detail::no_type; +using boost::move_detail::apply; +using boost::move_detail::eval_if_c; +using boost::move_detail::eval_if; +using boost::move_detail::unvoid_ref; +using boost::move_detail::add_const_if_c; template struct ls_zeros @@ -292,10 +84,6 @@ struct ls_zeros<1> static const std::size_t value = 0; }; -template struct unvoid_ref { typedef T &type; }; -template <> struct unvoid_ref { struct type_impl { }; typedef type_impl & type; }; -template <> struct unvoid_ref { struct type_impl { }; typedef type_impl & type; }; - // Infrastructure for providing a default type for T::TNAME if absent. #define BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(TNAME) \ template \ @@ -315,7 +103,14 @@ template <> struct unvoid_ref { struct type_impl { }; typedef type_i ::boost::intrusive::detail::if_c \ ::type::TNAME type; \ }; \ - \ + // + +#define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \ + typename INSTANTIATION_NS_PREFIX \ + boost_intrusive_default_type_ ## TNAME< T, TIMPL >::type \ +// + +#define BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(TNAME)\ template \ struct boost_intrusive_eval_default_type_ ## TNAME \ { \ @@ -339,11 +134,6 @@ template <> struct unvoid_ref { struct type_impl { }; typedef type_i }; \ // -#define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \ - typename INSTANTIATION_NS_PREFIX \ - boost_intrusive_default_type_ ## TNAME< T, TIMPL >::type \ -// - #define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \ typename INSTANTIATION_NS_PREFIX \ boost_intrusive_eval_default_type_ ## TNAME< T, TIMPL >::type \ @@ -354,8 +144,8 @@ template \ struct TRAITS_PREFIX##_bool\ {\ template\ - struct two_or_three {one _[2 + Add];};\ - template static one test(...);\ + struct two_or_three {yes_type _[2 + Add];};\ + template static yes_type test(...);\ template static two_or_three test (int);\ static const std::size_t value = sizeof(test(0));\ };\ @@ -363,10 +153,50 @@ struct TRAITS_PREFIX##_bool\ template \ struct TRAITS_PREFIX##_bool_is_true\ {\ - static const bool value = TRAITS_PREFIX##_bool::value > sizeof(one)*2;\ + static const bool value = TRAITS_PREFIX##_bool::value > sizeof(yes_type)*2;\ };\ // +#define BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(TRAITS_NAME, FUNC_NAME) \ + template \ + class TRAITS_NAME \ + { \ + private: \ + template struct helper;\ + template \ + static ::boost::intrusive::detail::yes_type test(helper<&T::FUNC_NAME>*); \ + template static ::boost::intrusive::detail::no_type test(...); \ + public: \ + static const bool value = sizeof(test(0)) == sizeof(::boost::intrusive::detail::yes_type); \ + }; \ +// + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED(TRAITS_NAME, FUNC_NAME) \ +template \ +struct TRAITS_NAME \ +{ \ + struct BaseMixin \ + { \ + void FUNC_NAME(); \ + }; \ + struct Base : public Type, public BaseMixin { Base(); }; \ + template class Helper{}; \ + template \ + static ::boost::intrusive::detail::no_type test(U*, Helper* = 0); \ + static ::boost::intrusive::detail::yes_type test(...); \ + static const bool value = sizeof(::boost::intrusive::detail::yes_type) == sizeof(test((Base*)(0))); \ +};\ +// + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED_IGNORE_SIGNATURE(TRAITS_NAME, FUNC_NAME) \ +BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED(TRAITS_NAME##_ignore_signature, FUNC_NAME) \ +\ +template \ +struct TRAITS_NAME \ + : public TRAITS_NAME##_ignore_signature \ +{};\ +// + } //namespace detail } //namespace intrusive } //namespace boost diff --git a/boost/intrusive/detail/node_cloner_disposer.hpp b/boost/intrusive/detail/node_cloner_disposer.hpp deleted file mode 100644 index 2a18100..0000000 --- a/boost/intrusive/detail/node_cloner_disposer.hpp +++ /dev/null @@ -1,109 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_NODE_CLONER_DISPOSER_HPP -#define BOOST_INTRUSIVE_DETAIL_NODE_CLONER_DISPOSER_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include - -namespace boost { -namespace intrusive { -namespace detail { - -template -struct node_cloner - : private ebo_functor_holder -{ - typedef ValueTraits value_traits; - typedef typename value_traits::node_traits node_traits; - typedef typename node_traits::node_ptr node_ptr; - typedef ebo_functor_holder base_t; - typedef typename get_algo< AlgoType - , node_traits>::type node_algorithms; - static const bool safemode_or_autounlink = - is_safe_autounlink::value; - typedef typename value_traits::value_type value_type; - typedef typename value_traits::pointer pointer; - typedef typename node_traits::node node; - typedef typename value_traits::const_node_ptr const_node_ptr; - typedef typename value_traits::reference reference; - typedef typename value_traits::const_reference const_reference; - - node_cloner(F f, const ValueTraits *traits) - : base_t(f), traits_(traits) - {} - - // tree-based containers use this method, which is proxy-reference friendly - node_ptr operator()(const node_ptr & p) - { - const_reference v = *traits_->to_value_ptr(p); - node_ptr n = traits_->to_node_ptr(*base_t::get()(v)); - //Cloned node must be in default mode if the linking mode requires it - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n)); - return n; - } - - // hashtables use this method, which is proxy-reference unfriendly - node_ptr operator()(const node &to_clone) - { - const value_type &v = - *traits_->to_value_ptr - (pointer_traits::pointer_to(to_clone)); - node_ptr n = traits_->to_node_ptr(*base_t::get()(v)); - //Cloned node must be in default mode if the linking mode requires it - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n)); - return n; - } - - const ValueTraits * const traits_; -}; - -template -struct node_disposer - : private ebo_functor_holder -{ - typedef ValueTraits value_traits; - typedef typename value_traits::node_traits node_traits; - typedef typename node_traits::node_ptr node_ptr; - typedef ebo_functor_holder base_t; - typedef typename get_algo< AlgoType - , node_traits>::type node_algorithms; - static const bool safemode_or_autounlink = - is_safe_autounlink::value; - - node_disposer(F f, const ValueTraits *cont) - : base_t(f), traits_(cont) - {} - - void operator()(const node_ptr & p) - { - if(safemode_or_autounlink) - node_algorithms::init(p); - base_t::get()(traits_->to_value_ptr(p)); - } - const ValueTraits * const traits_; -}; - -} //namespace detail{ -} //namespace intrusive{ -} //namespace boost{ - -#endif //BOOST_INTRUSIVE_DETAIL_NODE_CLONER_DISPOSER_HPP diff --git a/boost/intrusive/detail/node_holder.hpp b/boost/intrusive/detail/node_holder.hpp deleted file mode 100644 index 12732a8..0000000 --- a/boost/intrusive/detail/node_holder.hpp +++ /dev/null @@ -1,31 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_NODE_HOLDER_HPP -#define BOOST_INTRUSIVE_DETAIL_NODE_HOLDER_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -namespace boost { -namespace intrusive { - -template -struct node_holder - : public Node -{}; - -} //namespace intrusive{ -} //namespace boost{ - -#endif //BOOST_INTRUSIVE_DETAIL_NODE_HOLDER_HPP diff --git a/boost/intrusive/detail/node_to_value.hpp b/boost/intrusive/detail/node_to_value.hpp deleted file mode 100644 index 6ec3971..0000000 --- a/boost/intrusive/detail/node_to_value.hpp +++ /dev/null @@ -1,126 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_NODE_TO_VALUE_HPP -#define BOOST_INTRUSIVE_DETAIL_NODE_TO_VALUE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include - -namespace boost { -namespace intrusive { -namespace detail { - -template -struct dummy_constptr -{ - typedef typename boost::intrusive::pointer_traits:: - template rebind_pointer::type ConstVoidPtr; - - explicit dummy_constptr(ConstVoidPtr) - {} - - dummy_constptr() - {} - - ConstVoidPtr get_ptr() const - { return ConstVoidPtr(); } -}; - -template -struct constptr -{ - typedef typename boost::intrusive::pointer_traits:: - template rebind_pointer::type ConstVoidPtr; - - constptr() - {} - - explicit constptr(const ConstVoidPtr &ptr) - : const_void_ptr_(ptr) - {} - - const void *get_ptr() const - { return boost::intrusive::detail::to_raw_pointer(const_void_ptr_); } - - ConstVoidPtr const_void_ptr_; -}; - -template -struct select_constptr -{ - typedef typename if_c - < store_ptr - , constptr - , dummy_constptr - >::type type; -}; - - -template -struct node_to_value - : public select_constptr - < typename pointer_traits - ::template rebind_pointer::type - , is_stateful_value_traits::value - >::type -{ - static const bool stateful_value_traits = is_stateful_value_traits::value; - typedef typename select_constptr - < typename pointer_traits - :: - template rebind_pointer::type - , stateful_value_traits >::type Base; - - typedef ValueTraits value_traits; - typedef typename value_traits::value_type value_type; - typedef typename value_traits::node_traits::node node; - typedef typename add_const_if_c - ::type vtype; - typedef typename add_const_if_c - ::type ntype; - typedef typename pointer_traits - :: - template rebind_pointer::type npointer; - typedef typename pointer_traits:: - template rebind_pointer::type const_value_traits_ptr; - - node_to_value(const const_value_traits_ptr &ptr) - : Base(ptr) - {} - - typedef vtype & result_type; - typedef ntype & first_argument_type; - - const_value_traits_ptr get_value_traits() const - { return pointer_traits::static_cast_from(Base::get_ptr()); } - - result_type to_value(first_argument_type arg, false_) const - { return *(value_traits::to_value_ptr(pointer_traits::pointer_to(arg))); } - - result_type to_value(first_argument_type arg, true_) const - { return *(this->get_value_traits()->to_value_ptr(pointer_traits::pointer_to(arg))); } - - result_type operator()(first_argument_type arg) const - { return this->to_value(arg, bool_()); } -}; - -} //namespace detail{ -} //namespace intrusive{ -} //namespace boost{ - -#endif //BOOST_INTRUSIVE_DETAIL_NODE_TO_VALUE_HPP diff --git a/boost/intrusive/detail/parent_from_member.hpp b/boost/intrusive/detail/parent_from_member.hpp deleted file mode 100644 index 3dfe8d6..0000000 --- a/boost/intrusive/detail/parent_from_member.hpp +++ /dev/null @@ -1,120 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP -#define BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#if defined(BOOST_MSVC) || ((defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && defined(BOOST_INTEL)) - #define BOOST_INTRUSIVE_MSVC_ABI_PTR_TO_MEMBER - #include -#endif - -namespace boost { -namespace intrusive { -namespace detail { - -template -inline std::ptrdiff_t offset_from_pointer_to_member(const Member Parent::* ptr_to_member) -{ - //The implementation of a pointer to member is compiler dependent. - #if defined(BOOST_INTRUSIVE_MSVC_ABI_PTR_TO_MEMBER) - - //MSVC compliant compilers use their the first 32 bits as offset (even in 64 bit mode) - union caster_union - { - const Member Parent::* ptr_to_member; - int offset; - } caster; - - //MSVC ABI can use up to 3 int32 to represent pointer to member data - //with virtual base classes, in those cases there is no simple to - //obtain the address of the parent. So static assert to avoid runtime errors - BOOST_STATIC_ASSERT( sizeof(caster) == sizeof(int) ); - - caster.ptr_to_member = ptr_to_member; - return std::ptrdiff_t(caster.offset); - //Additional info on MSVC behaviour for the future. For 2/3 int ptr-to-member - //types dereference seems to be: - // - // vboffset = [compile_time_offset if 2-int ptr2memb] / - // [ptr2memb.i32[2] if 3-int ptr2memb]. - // vbtable = *(this + vboffset); - // adj = vbtable[ptr2memb.i32[1]]; - // var = adj + (this + vboffset) + ptr2memb.i32[0]; - // - //To reverse the operation we need to - // - obtain vboffset (in 2-int ptr2memb implementation only) - // - Go to Parent's vbtable and obtain adjustment at index ptr2memb.i32[1] - // - parent = member - adj - vboffset - ptr2memb.i32[0] - // - //Even accessing to RTTI we might not be able to obtain this information - //so anyone who thinks it's possible, please send a patch. - - //This works with gcc, msvc, ac++, ibmcpp - #elif defined(__GNUC__) || defined(__HP_aCC) || defined(BOOST_INTEL) || \ - defined(__IBMCPP__) || defined(__DECCXX) - const Parent * const parent = 0; - const char *const member = static_cast(static_cast(&(parent->*ptr_to_member))); - return std::ptrdiff_t(member - static_cast(static_cast(parent))); - #else - //This is the traditional C-front approach: __MWERKS__, __DMC__, __SUNPRO_CC - union caster_union - { - const Member Parent::* ptr_to_member; - std::ptrdiff_t offset; - } caster; - caster.ptr_to_member = ptr_to_member; - return caster.offset - 1; - #endif -} - -template -inline Parent *parent_from_member(Member *member, const Member Parent::* ptr_to_member) -{ - return static_cast - ( - static_cast - ( - static_cast(static_cast(member)) - offset_from_pointer_to_member(ptr_to_member) - ) - ); -} - -template -inline const Parent *parent_from_member(const Member *member, const Member Parent::* ptr_to_member) -{ - return static_cast - ( - static_cast - ( - static_cast(static_cast(member)) - offset_from_pointer_to_member(ptr_to_member) - ) - ); -} - -} //namespace detail { -} //namespace intrusive { -} //namespace boost { - -#ifdef BOOST_INTRUSIVE_MSVC_ABI_PTR_TO_MEMBER -#undef BOOST_INTRUSIVE_MSVC_ABI_PTR_TO_MEMBER -#endif - -#include - -#endif //#ifndef BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP diff --git a/boost/intrusive/detail/pointer_element.hpp b/boost/intrusive/detail/pointer_element.hpp index 1c17f41..dd26e3c 100644 --- a/boost/intrusive/detail/pointer_element.hpp +++ b/boost/intrusive/detail/pointer_element.hpp @@ -11,11 +11,17 @@ #ifndef BOOST_INTRUSIVE_DETAIL_POINTER_ELEMENT_HPP #define BOOST_INTRUSIVE_DETAIL_POINTER_ELEMENT_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif +#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP #include +#endif //BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP namespace boost { namespace intrusive { @@ -118,14 +124,6 @@ template struct first_param < TemplateClass > { typedef T type; }; - template < template //10arg - class TemplateClass, class T - , class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9> - struct first_param - < TemplateClass > - { typedef T type; }; - #endif //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template diff --git a/boost/intrusive/detail/preprocessor.hpp b/boost/intrusive/detail/preprocessor.hpp deleted file mode 100644 index cdbc8a1..0000000 --- a/boost/intrusive/detail/preprocessor.hpp +++ /dev/null @@ -1,42 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2008-2014. Distributed under the 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/intrusive for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_PREPROCESSOR_HPP -#define BOOST_INTRUSIVE_DETAIL_PREPROCESSOR_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include -#include - - -#define BOOST_INTRUSIVE_MAX_CONSTRUCTOR_PARAMETERS 10 - -#define BOOST_INTRUSIVE_PP_IDENTITY(z, n, data) data - -#define BOOST_INTRUSIVE_PP_DECLVAL(z, n, data) \ -boost::move_detail::declval< BOOST_PP_CAT(P, n) >() \ -//! - -#define BOOST_INTRUSIVE_PP_TEMPLATE_PARAM_VOID_DEFAULT(z, n, data) \ - BOOST_PP_CAT(class P, n) = void \ -//! - -#include - -#endif //#ifndef BOOST_INTRUSIVE_DETAIL_PREPROCESSOR_HPP diff --git a/boost/intrusive/detail/rbtree_node.hpp b/boost/intrusive/detail/rbtree_node.hpp deleted file mode 100644 index ab50509..0000000 --- a/boost/intrusive/detail/rbtree_node.hpp +++ /dev/null @@ -1,200 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013. -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_RBTREE_NODE_HPP -#define BOOST_INTRUSIVE_RBTREE_NODE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -///////////////////////////////////////////////////////////////////////////// -// // -// Generic node_traits for any pointer type // -// // -///////////////////////////////////////////////////////////////////////////// - -//This is the compact representation: 3 pointers -template -struct compact_rbtree_node -{ - typedef compact_rbtree_node node; - typedef typename pointer_rebind::type node_ptr; - typedef typename pointer_rebind::type const_node_ptr; - enum color { red_t, black_t }; - node_ptr parent_, left_, right_; -}; - -//This is the normal representation: 3 pointers + enum -template -struct rbtree_node -{ - typedef rbtree_node node; - typedef typename pointer_rebind::type node_ptr; - typedef typename pointer_rebind::type const_node_ptr; - - enum color { red_t, black_t }; - node_ptr parent_, left_, right_; - color color_; -}; - -//This is the default node traits implementation -//using a node with 3 generic pointers plus an enum -template -struct default_rbtree_node_traits_impl -{ - typedef rbtree_node node; - typedef typename node::node_ptr node_ptr; - typedef typename node::const_node_ptr const_node_ptr; - - typedef typename node::color color; - - 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 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 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) - { n->right_ = r; } - - 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; } - - static color black() - { return node::black_t; } - - static color red() - { return node::red_t; } -}; - -//This is the compact node traits implementation -//using a node with 3 generic pointers -template -struct compact_rbtree_node_traits_impl -{ - typedef compact_rbtree_node node; - typedef typename node::node_ptr node_ptr; - typedef typename node::const_node_ptr const_node_ptr; - - typedef pointer_plus_bits ptr_bit; - - typedef typename node::color color; - - 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 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 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) - { n->right_ = r; } - - 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); } - - static color black() - { return node::black_t; } - - static color red() - { return node::red_t; } -}; - -//Dispatches the implementation based on the boolean -template -struct rbtree_node_traits_dispatch - : public default_rbtree_node_traits_impl -{}; - -template -struct rbtree_node_traits_dispatch - : public compact_rbtree_node_traits_impl -{}; - -//Inherit from rbtree_node_traits_dispatch depending on the embedding capabilities -template -struct rbtree_node_traits - : public rbtree_node_traits_dispatch - < VoidPointer - , OptimizeSize && - (max_pointer_plus_bits - < VoidPointer - , detail::alignment_of >::value - >::value >= 1) - > -{}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_RBTREE_NODE_HPP diff --git a/boost/intrusive/detail/reverse_iterator.hpp b/boost/intrusive/detail/reverse_iterator.hpp index 9f443ab..552e8f4 100644 --- a/boost/intrusive/detail/reverse_iterator.hpp +++ b/boost/intrusive/detail/reverse_iterator.hpp @@ -10,19 +10,23 @@ // ///////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP -#define BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP +#ifndef BOOST_INTRUSIVE_DETAIL_REVERSE_ITERATOR_HPP +#define BOOST_INTRUSIVE_DETAIL_REVERSE_ITERATOR_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include -#include +#include +#include namespace boost { namespace intrusive { -namespace detail { template class reverse_iterator @@ -46,10 +50,17 @@ class reverse_iterator {} template - reverse_iterator(const reverse_iterator& r) + reverse_iterator( const reverse_iterator& r + , typename boost::intrusive::detail::enable_if_convertible::type* =0 + ) : m_current(r.base()) {} + template + typename boost::intrusive::detail::enable_if_convertible::type + operator=( const reverse_iterator& r) + { m_current = r.base(); return *this; } + It base() const { return m_current; } @@ -57,10 +68,10 @@ class reverse_iterator { It temp(m_current); --temp; return *temp; } pointer operator->() const - { It temp(m_current); --temp; return temp.operator->(); } + { It temp(m_current); --temp; return iterator_arrow_result(temp); } reference operator[](difference_type off) const - { return this->m_current[-off]; } + { return this->m_current[-off - 1]; } reverse_iterator& operator++() { --m_current; return *this; } @@ -106,22 +117,17 @@ class reverse_iterator reverse_iterator& operator+=(difference_type off) { m_current -= off; return *this; } - friend reverse_iterator operator+(const reverse_iterator & l, difference_type off) - { - reverse_iterator tmp(l.m_current); - tmp.m_current -= off; - return tmp; - } + friend reverse_iterator operator+(reverse_iterator l, difference_type off) + { l.m_current -= off; return l; } + + friend reverse_iterator operator+(difference_type off, reverse_iterator r) + { return (r += off); } reverse_iterator& operator-=(difference_type off) { m_current += off; return *this; } - friend reverse_iterator operator-(const reverse_iterator & l, difference_type off) - { - reverse_iterator tmp(l.m_current); - tmp.m_current += off; - return tmp; - } + friend reverse_iterator operator-(reverse_iterator l, difference_type off) + { l.m_current += off; return l; } friend difference_type operator-(const reverse_iterator& l, const reverse_iterator& r) { return r.m_current - l.m_current; } @@ -130,10 +136,9 @@ class reverse_iterator It m_current; // the wrapped iterator }; -} //namespace detail -} //namespace intrusive -} //namespace boost +} //namespace intrusive { +} //namespace boost { #include -#endif //BOOST_INTRUSIVE_DETAIL_ITERATOR_HPP +#endif //BOOST_INTRUSIVE_DETAIL_REVERSE_ITERATOR_HPP diff --git a/boost/intrusive/detail/simple_disposers.hpp b/boost/intrusive/detail/simple_disposers.hpp deleted file mode 100644 index af59772..0000000 --- a/boost/intrusive/detail/simple_disposers.hpp +++ /dev/null @@ -1,46 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_SIMPLE_DISPOSERS_HPP -#define BOOST_INTRUSIVE_DETAIL_SIMPLE_DISPOSERS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -namespace boost { -namespace intrusive { -namespace detail { - -class null_disposer -{ - public: - template - void operator()(Pointer) - {} -}; - -template -class init_disposer -{ - typedef typename NodeAlgorithms::node_ptr node_ptr; - - public: - void operator()(const node_ptr & p) - { NodeAlgorithms::init(p); } -}; - -} //namespace detail{ -} //namespace intrusive{ -} //namespace boost{ - -#endif //BOOST_INTRUSIVE_DETAIL_SIMPLE_DISPOSERS_HPP diff --git a/boost/intrusive/detail/size_holder.hpp b/boost/intrusive/detail/size_holder.hpp deleted file mode 100644 index a733187..0000000 --- a/boost/intrusive/detail/size_holder.hpp +++ /dev/null @@ -1,80 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2014-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_SIZE_HOLDER_HPP -#define BOOST_INTRUSIVE_DETAIL_SIZE_HOLDER_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -namespace boost { -namespace intrusive { -namespace detail { - -template -struct size_holder -{ - static const bool constant_time_size = ConstantSize; - typedef SizeType size_type; - - SizeType get_size() const - { return size_; } - - void set_size(SizeType size) - { size_ = size; } - - void decrement() - { --size_; } - - void increment() - { ++size_; } - - void increase(SizeType n) - { size_ += n; } - - void decrease(SizeType n) - { size_ -= n; } - - SizeType size_; -}; - -template -struct size_holder -{ - static const bool constant_time_size = false; - typedef SizeType size_type; - - size_type get_size() const - { return 0; } - - void set_size(size_type) - {} - - void decrement() - {} - - void increment() - {} - - void increase(SizeType) - {} - - void decrease(SizeType) - {} -}; - -} //namespace detail{ -} //namespace intrusive{ -} //namespace boost{ - -#endif //BOOST_INTRUSIVE_DETAIL_SIZE_HOLDER_HPP diff --git a/boost/intrusive/detail/slist_iterator.hpp b/boost/intrusive/detail/slist_iterator.hpp deleted file mode 100644 index 579c660..0000000 --- a/boost/intrusive/detail/slist_iterator.hpp +++ /dev/null @@ -1,120 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_SLIST_ITERATOR_HPP -#define BOOST_INTRUSIVE_SLIST_ITERATOR_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - - -// slist_iterator provides some basic functions for a -// node oriented bidirectional iterator: -template -class slist_iterator -{ - protected: - typedef iiterator - types_t; - - static const bool stateful_value_traits = types_t::stateful_value_traits; - - typedef ValueTraits value_traits; - typedef typename types_t::node_traits node_traits; - - typedef typename types_t::node node; - typedef typename types_t::node_ptr node_ptr; - typedef typename types_t::const_value_traits_ptr const_value_traits_ptr; - - public: - typedef typename types_t::iterator_traits::difference_type difference_type; - typedef typename types_t::iterator_traits::value_type value_type; - typedef typename types_t::iterator_traits::pointer pointer; - typedef typename types_t::iterator_traits::reference reference; - typedef typename types_t::iterator_traits::iterator_category iterator_category; - - slist_iterator() - {} - - explicit slist_iterator(const node_ptr & nodeptr, const const_value_traits_ptr &traits_ptr) - : members_(nodeptr, traits_ptr) - {} - - slist_iterator(slist_iterator const& other) - : members_(other.pointed_node(), other.get_value_traits()) - {} - - const node_ptr &pointed_node() const - { return members_.nodeptr_; } - - slist_iterator &operator=(const node_ptr &node) - { members_.nodeptr_ = node; return static_cast(*this); } - - const_value_traits_ptr get_value_traits() const - { return members_.get_ptr(); } - - public: - slist_iterator& operator++() - { - members_.nodeptr_ = node_traits::get_next(members_.nodeptr_); - return static_cast (*this); - } - - slist_iterator operator++(int) - { - slist_iterator result (*this); - members_.nodeptr_ = node_traits::get_next(members_.nodeptr_); - return result; - } - - friend bool operator== (const slist_iterator& l, const slist_iterator& r) - { return l.pointed_node() == r.pointed_node(); } - - friend bool operator!= (const slist_iterator& l, const slist_iterator& r) - { return !(l == r); } - - reference operator*() const - { return *operator->(); } - - pointer operator->() const - { return this->operator_arrow(detail::bool_()); } - - slist_iterator unconst() const - { return slist_iterator(this->pointed_node(), this->get_value_traits()); } - - private: - - pointer operator_arrow(detail::false_) const - { return ValueTraits::to_value_ptr(members_.nodeptr_); } - - pointer operator_arrow(detail::true_) const - { return this->get_value_traits()->to_value_ptr(members_.nodeptr_); } - - iiterator_members members_; -}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_SLIST_ITERATOR_HPP diff --git a/boost/intrusive/detail/slist_node.hpp b/boost/intrusive/detail/slist_node.hpp deleted file mode 100644 index 437190e..0000000 --- a/boost/intrusive/detail/slist_node.hpp +++ /dev/null @@ -1,59 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_SLIST_NODE_HPP -#define BOOST_INTRUSIVE_SLIST_NODE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -namespace boost { -namespace intrusive { - -template -struct slist_node -{ - typedef typename pointer_rebind::type node_ptr; - node_ptr next_; -}; - -// slist_node_traits can be used with circular_slist_algorithms and supplies -// a slist_node holding the pointers needed for a singly-linked list -// it is used by slist_base_hook and slist_member_hook -template -struct slist_node_traits -{ - typedef slist_node node; - typedef typename node::node_ptr node_ptr; - typedef typename pointer_rebind::type const_node_ptr; - - 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) - { n->next_ = next; } -}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_SLIST_NODE_HPP diff --git a/boost/intrusive/detail/std_fwd.hpp b/boost/intrusive/detail/std_fwd.hpp index b657c4a..4b5cedb 100644 --- a/boost/intrusive/detail/std_fwd.hpp +++ b/boost/intrusive/detail/std_fwd.hpp @@ -11,7 +11,11 @@ #ifndef BOOST_INTRUSIVE_DETAIL_STD_FWD_HPP #define BOOST_INTRUSIVE_DETAIL_STD_FWD_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -19,12 +23,20 @@ // Standard predeclarations ////////////////////////////////////////////////////////////////////////////// -#if defined(__clang__) && defined(_LIBCPP_VERSION) +#if defined(_LIBCPP_VERSION) #define BOOST_INTRUSIVE_CLANG_INLINE_STD_NS #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wc++11-extensions" + #if defined(__clang__) + #pragma GCC diagnostic ignored "-Wc++11-extensions" + #endif #define BOOST_INTRUSIVE_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD #define BOOST_INTRUSIVE_STD_NS_END _LIBCPP_END_NAMESPACE_STD +#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE_VERSION) //GCC >= 4.6 + #define BOOST_INTRUSIVE_STD_NS_BEG namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + #define BOOST_INTRUSIVE_STD_NS_END _GLIBCXX_END_NAMESPACE_VERSION } // namespace +#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE) //GCC >= 4.2 + #define BOOST_INTRUSIVE_STD_NS_BEG _GLIBCXX_BEGIN_NAMESPACE(std) + #define BOOST_INTRUSIVE_STD_NS_END _GLIBCXX_END_NAMESPACE #else #define BOOST_INTRUSIVE_STD_NS_BEG namespace std{ #define BOOST_INTRUSIVE_STD_NS_END } @@ -51,4 +63,3 @@ BOOST_INTRUSIVE_STD_NS_END #endif //BOOST_INTRUSIVE_CLANG_INLINE_STD_NS #endif //#ifndef BOOST_INTRUSIVE_DETAIL_STD_FWD_HPP - diff --git a/boost/intrusive/detail/to_raw_pointer.hpp b/boost/intrusive/detail/to_raw_pointer.hpp index e7ebff9..387f63f 100644 --- a/boost/intrusive/detail/to_raw_pointer.hpp +++ b/boost/intrusive/detail/to_raw_pointer.hpp @@ -13,7 +13,11 @@ #ifndef BOOST_INTRUSIVE_DETAIL_TO_RAW_POINTER_HPP #define BOOST_INTRUSIVE_DETAIL_TO_RAW_POINTER_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif diff --git a/boost/intrusive/detail/transform_iterator.hpp b/boost/intrusive/detail/transform_iterator.hpp deleted file mode 100644 index 698318b..0000000 --- a/boost/intrusive/detail/transform_iterator.hpp +++ /dev/null @@ -1,176 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_TRANSFORM_ITERATOR_HPP -#define BOOST_INTRUSIVE_DETAIL_TRANSFORM_ITERATOR_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -namespace boost { -namespace intrusive { -namespace detail { - -template -struct operator_arrow_proxy -{ - operator_arrow_proxy(const PseudoReference &px) - : m_value(px) - {} - - PseudoReference* operator->() const { return &m_value; } - // This function is needed for MWCW and BCC, which won't call operator-> - // again automatically per 13.3.1.2 para 8 -// operator T*() const { return &m_value; } - mutable PseudoReference m_value; -}; - -template -struct operator_arrow_proxy -{ - operator_arrow_proxy(T &px) - : m_value(px) - {} - - T* operator->() const { return &m_value; } - // This function is needed for MWCW and BCC, which won't call operator-> - // again automatically per 13.3.1.2 para 8 -// operator T*() const { return &m_value; } - T &m_value; -}; - -template -class transform_iterator - : public boost::intrusive::iterator - < typename Iterator::iterator_category - , typename detail::remove_reference::type - , typename Iterator::difference_type - , operator_arrow_proxy - , typename UnaryFunction::result_type> -{ - public: - explicit transform_iterator(const Iterator &it, const UnaryFunction &f = UnaryFunction()) - : members_(it, f) - {} - - explicit transform_iterator() - : members_() - {} - - Iterator get_it() const - { return members_.m_it; } - - //Constructors - transform_iterator& operator++() - { increment(); return *this; } - - transform_iterator operator++(int) - { - transform_iterator result (*this); - increment(); - return result; - } - - friend bool operator== (const transform_iterator& i, const transform_iterator& i2) - { return i.equal(i2); } - - friend bool operator!= (const transform_iterator& i, const transform_iterator& i2) - { return !(i == i2); } - -/* - friend bool operator> (const transform_iterator& i, const transform_iterator& i2) - { return i2 < i; } - - friend bool operator<= (const transform_iterator& i, const transform_iterator& i2) - { return !(i > i2); } - - friend bool operator>= (const transform_iterator& i, const transform_iterator& i2) - { return !(i < i2); } -*/ - friend typename Iterator::difference_type operator- (const transform_iterator& i, const transform_iterator& i2) - { return i2.distance_to(i); } - - //Arithmetic - transform_iterator& operator+=(typename Iterator::difference_type off) - { this->advance(off); return *this; } - - transform_iterator operator+(typename Iterator::difference_type off) const - { - transform_iterator other(*this); - other.advance(off); - return other; - } - - friend transform_iterator operator+(typename Iterator::difference_type off, const transform_iterator& right) - { return right + off; } - - transform_iterator& operator-=(typename Iterator::difference_type off) - { this->advance(-off); return *this; } - - transform_iterator operator-(typename Iterator::difference_type off) const - { return *this + (-off); } - - typename UnaryFunction::result_type operator*() const - { return dereference(); } - - operator_arrow_proxy - operator->() const - { return operator_arrow_proxy(dereference()); } - - private: - struct members - : UnaryFunction - { - members(const Iterator &it, const UnaryFunction &f) - : UnaryFunction(f), m_it(it) - {} - - members() - {} - - Iterator m_it; - } members_; - - - void increment() - { ++members_.m_it; } - - void decrement() - { --members_.m_it; } - - bool equal(const transform_iterator &other) const - { return members_.m_it == other.members_.m_it; } - - bool less(const transform_iterator &other) const - { return other.members_.m_it < members_.m_it; } - - typename UnaryFunction::result_type dereference() const - { return members_(*members_.m_it); } - - void advance(typename Iterator::difference_type n) - { boost::intrusive::iterator_advance(members_.m_it, n); } - - typename Iterator::difference_type distance_to(const transform_iterator &other)const - { return boost::intrusive::iterator_distance(other.members_.m_it, members_.m_it); } -}; - -} //namespace detail -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_DETAIL_TRANSFORM_ITERATOR_HPP diff --git a/boost/intrusive/detail/tree_iterator.hpp b/boost/intrusive/detail/tree_iterator.hpp deleted file mode 100644 index c3b599d..0000000 --- a/boost/intrusive/detail/tree_iterator.hpp +++ /dev/null @@ -1,141 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_TREE_ITERATOR_HPP -#define BOOST_INTRUSIVE_TREE_ITERATOR_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -///////////////////////////////////////////////////////////////////////////// -// // -// Implementation of the tree iterator // -// // -///////////////////////////////////////////////////////////////////////////// - -// tree_iterator provides some basic functions for a -// node oriented bidirectional iterator: -template -class tree_iterator -{ - protected: - typedef iiterator< ValueTraits, IsConst - , std::bidirectional_iterator_tag> types_t; - - typedef ValueTraits value_traits; - typedef typename types_t::node_traits node_traits; - - typedef typename types_t::node node; - typedef typename types_t::node_ptr node_ptr; - typedef typename types_t::const_value_traits_ptr const_value_traits_ptr; - static const bool stateful_value_traits = types_t::stateful_value_traits; - typedef bstree_algorithms node_algorithms; - - public: - typedef typename types_t::iterator_traits::difference_type difference_type; - typedef typename types_t::iterator_traits::value_type value_type; - typedef typename types_t::iterator_traits::pointer pointer; - typedef typename types_t::iterator_traits::reference reference; - typedef typename types_t::iterator_traits::iterator_category iterator_category; - - tree_iterator() - {} - - explicit tree_iterator(const node_ptr & nodeptr, const const_value_traits_ptr &traits_ptr) - : members_(nodeptr, traits_ptr) - {} - - tree_iterator(tree_iterator const& other) - : members_(other.pointed_node(), other.get_value_traits()) - {} - - const node_ptr &pointed_node() const - { return members_.nodeptr_; } - - tree_iterator &operator=(const node_ptr &nodeptr) - { members_.nodeptr_ = nodeptr; return static_cast(*this); } - - public: - tree_iterator& operator++() - { - members_.nodeptr_ = node_algorithms::next_node(members_.nodeptr_); - return static_cast (*this); - } - - tree_iterator operator++(int) - { - tree_iterator result (*this); - members_.nodeptr_ = node_algorithms::next_node(members_.nodeptr_); - return result; - } - - tree_iterator& operator--() - { - members_.nodeptr_ = node_algorithms::prev_node(members_.nodeptr_); - return static_cast (*this); - } - - tree_iterator operator--(int) - { - tree_iterator result (*this); - members_.nodeptr_ = node_algorithms::prev_node(members_.nodeptr_); - return result; - } - - friend bool operator== (const tree_iterator& l, const tree_iterator& r) - { return l.pointed_node() == r.pointed_node(); } - - friend bool operator!= (const tree_iterator& l, const tree_iterator& r) - { return !(l == r); } - - reference operator*() const - { return *operator->(); } - - pointer operator->() const - { return this->operator_arrow(detail::bool_()); } - - const_value_traits_ptr get_value_traits() const - { return members_.get_ptr(); } - - tree_iterator end_iterator_from_it() const - { - return tree_iterator(node_algorithms::get_header(this->pointed_node()), this->get_value_traits()); - } - - tree_iterator unconst() const - { return tree_iterator(this->pointed_node(), this->get_value_traits()); } - - private: - pointer operator_arrow(detail::false_) const - { return ValueTraits::to_value_ptr(members_.nodeptr_); } - - pointer operator_arrow(detail::true_) const - { return this->get_value_traits()->to_value_ptr(members_.nodeptr_); } - - iiterator_members members_; -}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_TREE_ITERATOR_HPP diff --git a/boost/intrusive/detail/tree_node.hpp b/boost/intrusive/detail/tree_node.hpp deleted file mode 100644 index 653d6fc..0000000 --- a/boost/intrusive/detail/tree_node.hpp +++ /dev/null @@ -1,75 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_TREE_NODE_HPP -#define BOOST_INTRUSIVE_TREE_NODE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -namespace boost { -namespace intrusive { - -template -struct tree_node -{ - typedef typename pointer_rebind::type node_ptr; - - node_ptr parent_, left_, right_; -}; - -template -struct tree_node_traits -{ - typedef tree_node node; - - typedef typename node::node_ptr node_ptr; - typedef typename pointer_rebind::type const_node_ptr; - - 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 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 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) - { n->right_ = r; } -}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_TREE_NODE_HPP diff --git a/boost/intrusive/detail/uncast.hpp b/boost/intrusive/detail/uncast.hpp deleted file mode 100644 index 944b6cd..0000000 --- a/boost/intrusive/detail/uncast.hpp +++ /dev/null @@ -1,51 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2006-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_DETAIL_UNCAST_HPP -#define BOOST_INTRUSIVE_DETAIL_UNCAST_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include - -namespace boost { -namespace intrusive { -namespace detail { - -template -struct uncast_types -{ - typedef typename pointer_traits::element_type element_type; - typedef typename remove_const::type non_const_type; - typedef typename pointer_traits:: - template rebind_pointer::type non_const_pointer; - typedef pointer_traits non_const_traits; -}; - -template -static typename uncast_types::non_const_pointer - uncast(const ConstNodePtr & ptr) -{ - return uncast_types::non_const_traits::const_cast_from(ptr); -} - -} //namespace detail { -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_DETAIL_UTILITIES_HPP diff --git a/boost/intrusive/detail/workaround.hpp b/boost/intrusive/detail/workaround.hpp index ad00691..b73f4ef 100644 --- a/boost/intrusive/detail/workaround.hpp +++ b/boost/intrusive/detail/workaround.hpp @@ -8,10 +8,14 @@ // ////////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_INTRUSIVE_DETAIL_WRKRND_HPP -#define BOOST_INTRUSIVE_DETAIL_WRKRND_HPP +#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP +#define BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP -#if defined(_MSC_VER) +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -26,5 +30,9 @@ //Macros for documentation purposes. For code, expands to the argument #define BOOST_INTRUSIVE_IMPDEF(TYPE) TYPE #define BOOST_INTRUSIVE_SEEDOC(TYPE) TYPE +#define BOOST_INTRUSIVE_DOC1ST(TYPE1, TYPE2) TYPE2 +#define BOOST_INTRUSIVE_I , +#define BOOST_INTRUSIVE_DOCIGN(T1) T1 -#endif //#ifndef BOOST_INTRUSIVE_DETAIL_WRKRND_HPP + +#endif //#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP diff --git a/boost/intrusive/hashtable.hpp b/boost/intrusive/hashtable.hpp deleted file mode 100644 index af73f70..0000000 --- a/boost/intrusive/hashtable.hpp +++ /dev/null @@ -1,3304 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2006-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_INTRUSIVE_HASHTABLE_HPP -#define BOOST_INTRUSIVE_HASHTABLE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -//std C++ -#include //std::equal_to -#include //std::pair -#include //std::swap, std::lower_bound, std::upper_bound -#include //std::size_t -//boost -#include -#include -#include -//General intrusive utilities -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//Implementation utilities -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -/// @cond - -template -struct prime_list_holder -{ - static const std::size_t prime_list[]; - static const std::size_t prime_list_size; -}; - -//We only support LLP64(Win64) or LP64(most Unix) data models -#ifdef _WIN64 //In 64 bit windows sizeof(size_t) == sizeof(unsigned long long) - #define BOOST_INTRUSIVE_PRIME_C(NUMBER) NUMBER##ULL - #define BOOST_INTRUSIVE_64_BIT_SIZE_T 1 -#else //In 32 bit windows and 32/64 bit unixes sizeof(size_t) == sizeof(unsigned long) - #define BOOST_INTRUSIVE_PRIME_C(NUMBER) NUMBER##UL - #define BOOST_INTRUSIVE_64_BIT_SIZE_T (((((ULONG_MAX>>16)>>16)>>16)>>15) != 0) -#endif - -template -const std::size_t prime_list_holder::prime_list[] = { - BOOST_INTRUSIVE_PRIME_C(3), BOOST_INTRUSIVE_PRIME_C(7), - BOOST_INTRUSIVE_PRIME_C(11), BOOST_INTRUSIVE_PRIME_C(17), - BOOST_INTRUSIVE_PRIME_C(29), BOOST_INTRUSIVE_PRIME_C(53), - BOOST_INTRUSIVE_PRIME_C(97), BOOST_INTRUSIVE_PRIME_C(193), - BOOST_INTRUSIVE_PRIME_C(389), BOOST_INTRUSIVE_PRIME_C(769), - BOOST_INTRUSIVE_PRIME_C(1543), BOOST_INTRUSIVE_PRIME_C(3079), - BOOST_INTRUSIVE_PRIME_C(6151), BOOST_INTRUSIVE_PRIME_C(12289), - BOOST_INTRUSIVE_PRIME_C(24593), BOOST_INTRUSIVE_PRIME_C(49157), - BOOST_INTRUSIVE_PRIME_C(98317), BOOST_INTRUSIVE_PRIME_C(196613), - BOOST_INTRUSIVE_PRIME_C(393241), BOOST_INTRUSIVE_PRIME_C(786433), - BOOST_INTRUSIVE_PRIME_C(1572869), BOOST_INTRUSIVE_PRIME_C(3145739), - BOOST_INTRUSIVE_PRIME_C(6291469), BOOST_INTRUSIVE_PRIME_C(12582917), - BOOST_INTRUSIVE_PRIME_C(25165843), BOOST_INTRUSIVE_PRIME_C(50331653), - BOOST_INTRUSIVE_PRIME_C(100663319), BOOST_INTRUSIVE_PRIME_C(201326611), - BOOST_INTRUSIVE_PRIME_C(402653189), BOOST_INTRUSIVE_PRIME_C(805306457), - BOOST_INTRUSIVE_PRIME_C(1610612741), BOOST_INTRUSIVE_PRIME_C(3221225473), -#if BOOST_INTRUSIVE_64_BIT_SIZE_T - //Taken from Boost.MultiIndex code, thanks to Joaquin M Lopez Munoz. - BOOST_INTRUSIVE_PRIME_C(6442450939), BOOST_INTRUSIVE_PRIME_C(12884901893), - BOOST_INTRUSIVE_PRIME_C(25769803751), BOOST_INTRUSIVE_PRIME_C(51539607551), - BOOST_INTRUSIVE_PRIME_C(103079215111), BOOST_INTRUSIVE_PRIME_C(206158430209), - BOOST_INTRUSIVE_PRIME_C(412316860441), BOOST_INTRUSIVE_PRIME_C(824633720831), - BOOST_INTRUSIVE_PRIME_C(1649267441651), BOOST_INTRUSIVE_PRIME_C(3298534883309), - BOOST_INTRUSIVE_PRIME_C(6597069766657), BOOST_INTRUSIVE_PRIME_C(13194139533299), - BOOST_INTRUSIVE_PRIME_C(26388279066623), BOOST_INTRUSIVE_PRIME_C(52776558133303), - BOOST_INTRUSIVE_PRIME_C(105553116266489), BOOST_INTRUSIVE_PRIME_C(211106232532969), - BOOST_INTRUSIVE_PRIME_C(422212465066001), BOOST_INTRUSIVE_PRIME_C(844424930131963), - BOOST_INTRUSIVE_PRIME_C(1688849860263953), BOOST_INTRUSIVE_PRIME_C(3377699720527861), - BOOST_INTRUSIVE_PRIME_C(6755399441055731), BOOST_INTRUSIVE_PRIME_C(13510798882111483), - BOOST_INTRUSIVE_PRIME_C(27021597764222939), BOOST_INTRUSIVE_PRIME_C(54043195528445957), - BOOST_INTRUSIVE_PRIME_C(108086391056891903), BOOST_INTRUSIVE_PRIME_C(216172782113783843), - BOOST_INTRUSIVE_PRIME_C(432345564227567621), BOOST_INTRUSIVE_PRIME_C(864691128455135207), - BOOST_INTRUSIVE_PRIME_C(1729382256910270481), BOOST_INTRUSIVE_PRIME_C(3458764513820540933), - BOOST_INTRUSIVE_PRIME_C(6917529027641081903), BOOST_INTRUSIVE_PRIME_C(13835058055282163729), - BOOST_INTRUSIVE_PRIME_C(18446744073709551557) -#else - BOOST_INTRUSIVE_PRIME_C(4294967291) -#endif - }; - -#undef BOOST_INTRUSIVE_PRIME_C -#undef BOOST_INTRUSIVE_64_BIT_SIZE_T - -template -const std::size_t prime_list_holder::prime_list_size - = sizeof(prime_list)/sizeof(std::size_t); - -struct hash_bool_flags -{ - static const std::size_t unique_keys_pos = 1u; - static const std::size_t constant_time_size_pos = 2u; - static const std::size_t power_2_buckets_pos = 4u; - static const std::size_t cache_begin_pos = 8u; - static const std::size_t compare_hash_pos = 16u; - static const std::size_t incremental_pos = 32u; -}; - -namespace detail { - -template -struct get_slist_impl_from_supposed_value_traits -{ - typedef SupposedValueTraits value_traits; - typedef typename detail::get_node_traits - ::type node_traits; - typedef typename get_slist_impl - ::type - >::type type; -}; - -template -struct unordered_bucket_impl -{ - typedef typename - get_slist_impl_from_supposed_value_traits - ::type slist_impl; - typedef detail::bucket_impl implementation_defined; - typedef implementation_defined type; -}; - -template -struct unordered_bucket_ptr_impl -{ - typedef typename detail::get_node_traits - ::type::node_ptr node_ptr; - typedef typename unordered_bucket_impl - ::type bucket_type; - - typedef typename pointer_traits - ::template rebind_pointer - < bucket_type >::type implementation_defined; - typedef implementation_defined type; -}; - -template -struct store_hash_bool -{ - template - struct two_or_three {one _[2 + Add];}; - template static one test(...); - template static two_or_three test (int); - static const std::size_t value = sizeof(test(0)); -}; - -template -struct store_hash_is_true -{ - static const bool value = store_hash_bool::value > sizeof(one)*2; -}; - -template -struct optimize_multikey_bool -{ - template - struct two_or_three {one _[2 + Add];}; - template static one test(...); - template static two_or_three test (int); - static const std::size_t value = sizeof(test(0)); -}; - -template -struct optimize_multikey_is_true -{ - static const bool value = optimize_multikey_bool::value > sizeof(one)*2; -}; - -struct insert_commit_data_impl -{ - std::size_t hash; -}; - -template -inline typename pointer_traits::template rebind_pointer::type - dcast_bucket_ptr(const SlistNodePtr &p) -{ - typedef typename pointer_traits::template rebind_pointer::type node_ptr; - return pointer_traits::pointer_to(static_cast(*p)); -} - -template -struct group_functions -{ - typedef NodeTraits node_traits; - typedef unordered_group_adapter group_traits; - typedef typename node_traits::node_ptr node_ptr; - typedef typename node_traits::node node; - typedef typename reduced_slist_node_traits - ::type reduced_node_traits; - typedef typename reduced_node_traits::node_ptr slist_node_ptr; - typedef typename reduced_node_traits::node slist_node; - typedef circular_slist_algorithms group_algorithms; - - static slist_node_ptr get_bucket_before_begin - (const slist_node_ptr &bucket_beg, const slist_node_ptr &bucket_end, const node_ptr &p) - { - //First find the last node of p's group. - //This requires checking the first node of the next group or - //the bucket node. - node_ptr prev_node = p; - node_ptr nxt(node_traits::get_next(p)); - while(!(bucket_beg <= nxt && nxt <= bucket_end) && - (group_traits::get_next(nxt) == prev_node)){ - prev_node = nxt; - nxt = node_traits::get_next(nxt); - } - - //If we've reached the bucket node just return it. - if(bucket_beg <= nxt && nxt <= bucket_end){ - return nxt; - } - - //Otherwise, iterate using group links until the bucket node - node_ptr first_node_of_group = nxt; - node_ptr last_node_group = group_traits::get_next(first_node_of_group); - 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 = detail::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); - } - return possible_end; - } - - static node_ptr get_prev_to_first_in_group(const slist_node_ptr &bucket_node, const node_ptr &first_in_group) - { - //Just iterate using group links and obtain the node - //before "first_in_group)" - node_ptr prev_node = detail::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); - nxt = node_traits::get_next(prev_node); - } - return prev_node; - } - - static node_ptr get_first_in_group_of_last_in_group(const node_ptr &last_in_group) - { - //Just iterate using group links and obtain the node - //before "last_in_group" - node_ptr possible_first = group_traits::get_next(last_in_group); - node_ptr possible_first_prev = group_traits::get_next(possible_first); - // The deleted node is at the end of the group, so the - // node in the group pointing to it is at the beginning - // of the group. Find that to change its pointer. - while(possible_first_prev != last_in_group){ - possible_first = possible_first_prev; - possible_first_prev = group_traits::get_next(possible_first); - } - return possible_first; - } - - static void erase_from_group(const slist_node_ptr &end_ptr, const node_ptr &to_erase_ptr, detail::true_) - { - node_ptr nxt_ptr(node_traits::get_next(to_erase_ptr)); - node_ptr prev_in_group_ptr(group_traits::get_next(to_erase_ptr)); - bool last_in_group = (end_ptr == nxt_ptr) || - (group_traits::get_next(nxt_ptr) != to_erase_ptr); - bool is_first_in_group = node_traits::get_next(prev_in_group_ptr) != to_erase_ptr; - - if(is_first_in_group && last_in_group){ - group_algorithms::init(to_erase_ptr); - } - else if(is_first_in_group){ - group_algorithms::unlink_after(nxt_ptr); - } - else if(last_in_group){ - node_ptr first_in_group = - get_first_in_group_of_last_in_group(to_erase_ptr); - group_algorithms::unlink_after(first_in_group); - } - else{ - group_algorithms::unlink_after(nxt_ptr); - } - } - - static void erase_from_group(const slist_node_ptr&, const node_ptr&, detail::false_) - {} - - static node_ptr get_last_in_group(const node_ptr &first_in_group, detail::true_) - { return group_traits::get_next(first_in_group); } - - static node_ptr get_last_in_group(const node_ptr &n, detail::false_) - { return n; } - - static void init_group(const node_ptr &n, true_) - { group_algorithms::init(n); } - - static void init_group(const node_ptr &, false_) - {} - - static void insert_in_group(const node_ptr &first_in_group, const node_ptr &n, true_) - { - if(first_in_group){ - if(group_algorithms::unique(first_in_group)) - group_algorithms::link_after(first_in_group, n); - else{ - group_algorithms::link_after(node_traits::get_next(first_in_group), n); - } - } - else{ - group_algorithms::init_header(n); - } - } - - static slist_node_ptr get_previous_and_next_in_group - ( const slist_node_ptr &i, node_ptr &nxt_in_group - //If first_end_ptr == last_end_ptr, then first_end_ptr is the bucket of i - //Otherwise first_end_ptr is the first bucket and last_end_ptr the last one. - , const slist_node_ptr &first_end_ptr, const slist_node_ptr &last_end_ptr) - { - slist_node_ptr prev; - node_ptr elem(detail::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)); - bool last_in_group = (first_end_ptr <= nxt && nxt <= last_end_ptr) || - (group_traits::get_next(detail::dcast_bucket_ptr(nxt)) != elem); - //It's the first in group if group_previous's next_node is not - //itself, as group list does not link bucket - node_ptr prev_in_group(group_traits::get_next(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(first_end_ptr != last_end_ptr){ - bucket_node = group_functions::get_bucket_before_begin - (first_end_ptr, last_end_ptr, start_pos); - } - else{ - bucket_node = first_end_ptr; - } - prev = group_functions::get_prev_to_first_in_group(bucket_node, elem); - } - else{ - if(last_in_group){ - nxt_in_group = group_functions::get_first_in_group_of_last_in_group(elem); - } - else{ - nxt_in_group = node_traits::get_next(elem); - } - prev = group_traits::get_next(elem); - } - return prev; - } - - static void insert_in_group(const node_ptr&, const node_ptr&, false_) - {} -}; - -template -class incremental_rehash_rollback -{ - private: - typedef BucketType bucket_type; - typedef SplitTraits split_traits; - - incremental_rehash_rollback(); - incremental_rehash_rollback & operator=(const incremental_rehash_rollback &); - incremental_rehash_rollback (const incremental_rehash_rollback &); - - public: - incremental_rehash_rollback - (bucket_type &source_bucket, bucket_type &destiny_bucket, split_traits &split_traits) - : source_bucket_(source_bucket), destiny_bucket_(destiny_bucket) - , split_traits_(split_traits), released_(false) - {} - - void release() - { released_ = true; } - - ~incremental_rehash_rollback() - { - if(!released_){ - //If an exception is thrown, just put all moved nodes back in the old bucket - //and move back the split mark. - destiny_bucket_.splice_after(destiny_bucket_.before_begin(), source_bucket_); - split_traits_.decrement(); - } - } - - private: - bucket_type &source_bucket_; - bucket_type &destiny_bucket_; - split_traits &split_traits_; - bool released_; -}; - -template -struct node_functions -{ - static void store_hash(typename NodeTraits::node_ptr p, std::size_t h, true_) - { return NodeTraits::set_hash(p, h); } - - static void store_hash(typename NodeTraits::node_ptr, std::size_t, false_) - {} -}; - -inline std::size_t hash_to_bucket(std::size_t hash_value, std::size_t bucket_cnt, detail::false_) -{ return hash_value % bucket_cnt; } - -inline std::size_t hash_to_bucket(std::size_t hash_value, std::size_t bucket_cnt, detail::true_) -{ return hash_value & (bucket_cnt - 1); } - -template -inline std::size_t hash_to_bucket_split(std::size_t hash_value, std::size_t bucket_cnt, std::size_t split) -{ - std::size_t bucket_number = detail::hash_to_bucket(hash_value, bucket_cnt, detail::bool_()); - if(Incremental) - if(bucket_number >= split) - bucket_number -= bucket_cnt/2; - return bucket_number; -} - -} //namespace detail { - -//!This metafunction will obtain the type of a bucket -//!from the value_traits or hook option to be used with -//!a hash container. -template -struct unordered_bucket - : public detail::unordered_bucket_impl - ::proto_value_traits - > -{}; - -//!This metafunction will obtain the type of a bucket pointer -//!from the value_traits or hook option to be used with -//!a hash container. -template -struct unordered_bucket_ptr - : public detail::unordered_bucket_ptr_impl - ::proto_value_traits - > -{}; - -//!This metafunction will obtain the type of the default bucket traits -//!(when the user does not specify the bucket_traits<> option) from the -//!value_traits or hook option to be used with -//!a hash container. -template -struct unordered_default_bucket_traits -{ - typedef typename ValueTraitsOrHookOption:: - template pack::proto_value_traits supposed_value_traits; - typedef typename detail:: - get_slist_impl_from_supposed_value_traits - ::type slist_impl; - typedef detail::bucket_traits_impl - implementation_defined; - typedef implementation_defined type; -}; - -struct default_bucket_traits; - -//hashtable default hook traits -struct default_hashtable_hook_applier -{ template struct apply{ typedef typename T::default_hashtable_hook type; }; }; - -template<> -struct is_default_hook_tag -{ static const bool value = true; }; - -struct hashtable_defaults -{ - typedef default_hashtable_hook_applier proto_value_traits; - typedef std::size_t size_type; - typedef void equal; - typedef void hash; - typedef default_bucket_traits bucket_traits; - static const bool constant_time_size = true; - static const bool power_2_buckets = false; - static const bool cache_begin = false; - static const bool compare_hash = false; - static const bool incremental = false; -}; - -template -struct downcast_node_to_value_t - : public detail::node_to_value -{ - typedef detail::node_to_value base_t; - typedef typename base_t::result_type result_type; - typedef ValueTraits value_traits; - typedef typename detail::get_slist_impl - ::type - >::type slist_impl; - typedef typename detail::add_const_if_c - ::type & first_argument_type; - typedef typename detail::add_const_if_c - < typename ValueTraits::node_traits::node - , IsConst>::type & intermediate_argument_type; - typedef typename pointer_traits - :: - template rebind_pointer - ::type const_value_traits_ptr; - - downcast_node_to_value_t(const const_value_traits_ptr &ptr) - : base_t(ptr) - {} - - result_type operator()(first_argument_type arg) const - { return this->base_t::operator()(static_cast(arg)); } -}; - -template -struct node_cast_adaptor - : private detail::ebo_functor_holder -{ - typedef detail::ebo_functor_holder base_t; - - typedef typename pointer_traits::element_type slist_node; - typedef typename pointer_traits::element_type node; - - template - node_cast_adaptor(const ConvertibleToF &c2f, const RealValuTraits *traits) - : base_t(base_t(c2f, traits)) - {} - - typename base_t::node_ptr operator()(const slist_node &to_clone) - { return base_t::operator()(static_cast(to_clone)); } - - void operator()(SlistNodePtr to_clone) - { - base_t::operator()(pointer_traits::pointer_to(static_cast(*to_clone))); - } -}; - -static const std::size_t hashtable_data_bool_flags_mask = - ( hash_bool_flags::cache_begin_pos - | hash_bool_flags::constant_time_size_pos - | hash_bool_flags::incremental_pos - ); - -//bucket_plus_vtraits stores ValueTraits + BucketTraits -//this data is needed by iterators to obtain the -//value from the iterator and detect the bucket -template -struct bucket_plus_vtraits : public ValueTraits -{ - typedef BucketTraits bucket_traits; - typedef ValueTraits value_traits; - - static const bool safemode_or_autounlink = is_safe_autounlink::value; - - typedef typename - detail::get_slist_impl_from_supposed_value_traits - ::type slist_impl; - typedef typename value_traits::node_traits node_traits; - typedef unordered_group_adapter group_traits; - typedef typename slist_impl::iterator siterator; - typedef typename slist_impl::size_type size_type; - typedef detail::bucket_impl bucket_type; - typedef detail::group_functions group_functions_t; - typedef typename slist_impl::node_algorithms node_algorithms; - typedef typename slist_impl::node_ptr slist_node_ptr; - typedef typename node_traits::node_ptr node_ptr; - typedef typename node_traits::node node; - typedef typename value_traits::value_type value_type; - typedef circular_slist_algorithms group_algorithms; - typedef typename pointer_traits - :: - template rebind_pointer - ::type const_value_traits_ptr; - typedef typename pointer_traits - :: - template rebind_pointer - ::type const_bucket_value_traits_ptr; - typedef typename detail::unordered_bucket_ptr_impl - ::type bucket_ptr; - typedef detail::bool_::value> optimize_multikey_t; - - template - bucket_plus_vtraits(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits) - : ValueTraits(val_traits), bucket_traits_(::boost::forward(b_traits)) - {} - - bucket_plus_vtraits & operator =(const bucket_plus_vtraits &x) - { bucket_traits_ = x.bucket_traits_; return *this; } - - const_value_traits_ptr priv_value_traits_ptr() const - { return pointer_traits::pointer_to(this->priv_value_traits()); } - - //bucket_value_traits - // - const bucket_plus_vtraits &get_bucket_value_traits() const - { return *this; } - - bucket_plus_vtraits &get_bucket_value_traits() - { return *this; } - - const_bucket_value_traits_ptr bucket_value_traits_ptr() const - { return pointer_traits::pointer_to(this->get_bucket_value_traits()); } - - //value traits - // - const value_traits &priv_value_traits() const - { return *this; } - - value_traits &priv_value_traits() - { return *this; } - - //bucket_traits - // - const bucket_traits &priv_bucket_traits() const - { return this->bucket_traits_; } - - bucket_traits &priv_bucket_traits() - { return this->bucket_traits_; } - - //bucket operations - bucket_ptr priv_bucket_pointer() const - { return this->priv_bucket_traits().bucket_begin(); } - - typename slist_impl::size_type priv_bucket_count() const - { return this->priv_bucket_traits().bucket_count(); } - - bucket_ptr priv_invalid_bucket() const - { - const bucket_traits &rbt = this->priv_bucket_traits(); - return rbt.bucket_begin() + rbt.bucket_count(); - } - siterator priv_invalid_local_it() const - { return this->priv_bucket_traits().bucket_begin()->before_begin(); } - - static siterator priv_get_last(bucket_type &b, detail::true_) //optimize multikey - { - //First find the last node of p's group. - //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( detail::dcast_bucket_ptr(end_ptr))); - node_ptr last_node_group(possible_end); - - while(end_ptr != possible_end){ - last_node_group = group_traits::get_next(detail::dcast_bucket_ptr(possible_end)); - possible_end = node_traits::get_next(last_node_group); - } - return bucket_type::s_iterator_to(*last_node_group); - } - - static siterator priv_get_last(bucket_type &b, detail::false_) //NOT optimize multikey - { return b.previous(b.end()); } - - static siterator priv_get_previous(bucket_type &b, siterator i, detail::true_) //optimize multikey - { - node_ptr elem(detail::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 - ? *group_functions_t::get_prev_to_first_in_group(b.end().pointed_node(), elem) - : *group_traits::get_next(elem) - ; - return bucket_type::s_iterator_to(n); - } - - static siterator priv_get_previous(bucket_type &b, siterator i, detail::false_) //NOT optimize multikey - { return b.previous(i); } - - static void priv_clear_group_nodes(bucket_type &b, detail::true_) //optimize multikey - { - siterator it(b.begin()), itend(b.end()); - while(it != itend){ - node_ptr to_erase(detail::dcast_bucket_ptr(it.pointed_node())); - ++it; - group_algorithms::init(to_erase); - } - } - - static void priv_clear_group_nodes(bucket_type &, detail::false_) //NOT optimize multikey - {} - - std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::true_) //optimize multikey - { - 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() - , detail::dcast_bucket_ptr(it.pointed_node())); - //Now get the bucket_impl from the iterator - const bucket_type &b = static_cast - (bucket_type::slist_type::container_from_end_iterator(bucket_type::s_iterator_to(*bb))); - //Now just calculate the index b has in the bucket array - return static_cast(&b - &*f); - } - - std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::false_) //NO optimize multikey - { - 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()); - - //The end node is embedded in the singly linked list: - //iterate until we reach it. - while(!(first_ptr <= it.pointed_node() && it.pointed_node() <= last_ptr)){ - ++it; - } - //Now get the bucket_impl from the iterator - const bucket_type &b = static_cast - (bucket_type::container_from_end_iterator(it)); - - //Now just calculate the index b has in the bucket array - return static_cast(&b - &*f); - } - - static std::size_t priv_stored_hash(slist_node_ptr n, detail::true_) //store_hash - { return node_traits::get_hash(detail::dcast_bucket_ptr(n)); } - - static std::size_t priv_stored_hash(slist_node_ptr, detail::false_) //NO store_hash (This should never be called) - { BOOST_INTRUSIVE_INVARIANT_ASSERT(0); return 0; } - - node &priv_value_to_node(value_type &v) - { return *this->priv_value_traits().to_node_ptr(v); } - - const node &priv_value_to_node(const value_type &v) const - { return *this->priv_value_traits().to_node_ptr(v); } - - value_type &priv_value_from_slist_node(slist_node_ptr n) - { return *this->priv_value_traits().to_value_ptr(detail::dcast_bucket_ptr(n)); } - - const value_type &priv_value_from_slist_node(slist_node_ptr n) const - { return *this->priv_value_traits().to_value_ptr(detail::dcast_bucket_ptr(n)); } - - void priv_clear_buckets(const bucket_ptr buckets_ptr, const size_type bucket_cnt) - { - bucket_ptr buckets_it = buckets_ptr; - for(size_type bucket_i = 0; bucket_i != bucket_cnt; ++buckets_it, ++bucket_i){ - if(safemode_or_autounlink){ - bucket_plus_vtraits::priv_clear_group_nodes(*buckets_it, optimize_multikey_t()); - buckets_it->clear_and_dispose(detail::init_disposer()); - } - else{ - buckets_it->clear(); - } - } - } - - bucket_traits bucket_traits_; -}; - -template -struct get_hash -{ - typedef Hash type; -}; - -template -struct get_hash -{ - typedef ::boost::hash type; -}; - -//bucket_hash_t -//Stores bucket_plus_vtraits plust the hash function -template -struct bucket_hash_t - : public detail::ebo_functor_holder - ::value_traits::value_type - >::type - > -{ - typedef typename bucket_plus_vtraits::value_traits value_traits; - typedef typename value_traits::value_type value_type; - typedef typename value_traits::node_traits node_traits; - typedef typename get_hash< VoidOrKeyHash, value_type>::type hasher; - typedef BucketTraits bucket_traits; - typedef bucket_plus_vtraits bucket_plus_vtraits_t; - - template - bucket_hash_t(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h) - : detail::ebo_functor_holder(h), internal(val_traits, ::boost::forward(b_traits)) - {} - - const hasher &priv_hasher() const - { return this->detail::ebo_functor_holder::get(); } - - hasher &priv_hasher() - { return this->detail::ebo_functor_holder::get(); } - - std::size_t priv_stored_or_compute_hash(const value_type &v, detail::true_) const //For store_hash == true - { return node_traits::get_hash(this->internal.priv_value_traits().to_node_ptr(v)); } - - std::size_t priv_stored_or_compute_hash(const value_type &v, detail::false_) const //For store_hash == false - { return this->priv_hasher()(v); } - - bucket_plus_vtraits_t internal; //4 -}; - - -template -struct get_equal_to -{ - typedef EqualTo type; -}; - -template -struct get_equal_to -{ - typedef ::std::equal_to type; -}; - - -//bucket_hash_equal_t -//Stores bucket_hash_t and the equality function when the first -//non-empty bucket shall not be cached. -template -struct bucket_hash_equal_t - : public detail::ebo_functor_holder //equal - ::value_traits::value_type - >::type - > -{ - typedef bucket_hash_t bucket_hash_type; - typedef bucket_plus_vtraits bucket_plus_vtraits_t; - typedef typename bucket_plus_vtraits_t::value_traits value_traits; - typedef typename get_equal_to< VoidOrKeyEqual - , typename value_traits::value_type - >::type value_equal; - typedef typename bucket_hash_type::hasher hasher; - typedef BucketTraits bucket_traits; - typedef typename bucket_plus_vtraits_t::slist_impl slist_impl; - typedef typename slist_impl::size_type size_type; - typedef typename slist_impl::iterator siterator; - typedef detail::bucket_impl bucket_type; - typedef typename detail::unordered_bucket_ptr_impl::type bucket_ptr; - - template - bucket_hash_equal_t(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h, const value_equal &e) - : detail::ebo_functor_holder(e) - , internal(val_traits, ::boost::forward(b_traits), h) - {} - - bucket_ptr priv_get_cache() - { return this->internal.internal.priv_bucket_pointer(); } - - void priv_set_cache(const bucket_ptr &) - {} - - size_type priv_get_cache_bucket_num() - { return 0u; } - - void priv_initialize_cache() - {} - - void priv_swap_cache(bucket_hash_equal_t &) - {} - - siterator priv_begin() const - { - size_type n = 0; - size_type bucket_cnt = this->internal.internal.priv_bucket_count(); - for (n = 0; n < bucket_cnt; ++n){ - bucket_type &b = this->internal.internal.priv_bucket_pointer()[n]; - if(!b.empty()){ - return b.begin(); - } - } - return this->internal.internal.priv_invalid_local_it(); - } - - void priv_insertion_update_cache(size_type) - {} - - void priv_erasure_update_cache_range(size_type, size_type) - {} - - void priv_erasure_update_cache() - {} - - const value_equal &priv_equal() const - { return this->detail::ebo_functor_holder::get(); } - - value_equal &priv_equal() - { return this->detail::ebo_functor_holder::get(); } - - bucket_hash_t internal; //3 -}; - -//bucket_hash_equal_t -//Stores bucket_hash_t and the equality function when the first -//non-empty bucket shall be cached. -template //cache_begin == true version -struct bucket_hash_equal_t - : public detail::ebo_functor_holder //equal - ::value_traits::value_type - >::type - > -{ - typedef bucket_plus_vtraits bucket_plus_vtraits_t; - typedef bucket_hash_t bucket_hash_type; - typedef typename bucket_plus_vtraits - ::value_traits value_traits; - typedef typename get_equal_to - < VoidOrKeyEqual - , typename value_traits::value_type>::type value_equal; - typedef typename bucket_hash_type::hasher hasher; - typedef BucketTraits bucket_traits; - typedef typename bucket_plus_vtraits_t::slist_impl::size_type size_type; - typedef typename bucket_plus_vtraits_t::slist_impl::iterator siterator; - - template - bucket_hash_equal_t(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h, const value_equal &e) - : detail::ebo_functor_holder(e) - , internal(val_traits, ::boost::forward(b_traits), h) - {} - - typedef typename detail::unordered_bucket_ptr_impl - ::type bucket_ptr; - - bucket_ptr &priv_get_cache() - { return cached_begin_; } - - const bucket_ptr &priv_get_cache() const - { return cached_begin_; } - - void priv_set_cache(const bucket_ptr &p) - { cached_begin_ = p; } - - std::size_t priv_get_cache_bucket_num() - { return this->cached_begin_ - this->internal.internal.priv_bucket_pointer(); } - - void priv_initialize_cache() - { this->cached_begin_ = this->internal.internal.priv_invalid_bucket(); } - - void priv_swap_cache(bucket_hash_equal_t &other) - { - std::swap(this->cached_begin_, other.cached_begin_); - } - - siterator priv_begin() const - { - if(this->cached_begin_ == this->internal.internal.priv_invalid_bucket()){ - return this->internal.internal.priv_invalid_local_it(); - } - else{ - return this->cached_begin_->begin(); - } - } - - void priv_insertion_update_cache(size_type insertion_bucket) - { - bucket_ptr p = this->internal.internal.priv_bucket_pointer() + insertion_bucket; - if(p < this->cached_begin_){ - this->cached_begin_ = p; - } - } - - const value_equal &priv_equal() const - { return this->detail::ebo_functor_holder::get(); } - - value_equal &priv_equal() - { return this->detail::ebo_functor_holder::get(); } - - void priv_erasure_update_cache_range(size_type first_bucket_num, size_type last_bucket_num) - { - //If the last bucket is the end, the cache must be updated - //to the last position if all - if(this->priv_get_cache_bucket_num() == first_bucket_num && - this->internal.internal.priv_bucket_pointer()[first_bucket_num].empty() ){ - this->priv_set_cache(this->internal.internal.priv_bucket_pointer() + last_bucket_num); - this->priv_erasure_update_cache(); - } - } - - void priv_erasure_update_cache() - { - if(this->cached_begin_ != this->internal.internal.priv_invalid_bucket()){ - size_type current_n = this->priv_get_cache() - this->internal.internal.priv_bucket_pointer(); - for( const size_type num_buckets = this->internal.internal.priv_bucket_count() - ; current_n < num_buckets - ; ++current_n, ++this->priv_get_cache()){ - if(!this->priv_get_cache()->empty()){ - return; - } - } - this->priv_initialize_cache(); - } - } - - bucket_ptr cached_begin_; - bucket_hash_t internal; //2 -}; - -//hashdata_internal -//Stores bucket_hash_equal_t and split_traits -template -struct hashdata_internal - : public detail::size_holder< 0 != (BoolFlags & hash_bool_flags::incremental_pos), SizeType, int> //split_traits -{ - typedef bucket_hash_equal_t - < VoidOrKeyHash, VoidOrKeyEqual - , ValueTraits, BucketTraits - , 0 != (BoolFlags & hash_bool_flags::cache_begin_pos) - > internal_type; - typedef typename internal_type::value_equal value_equal; - typedef typename internal_type::hasher hasher; - typedef bucket_plus_vtraits bucket_plus_vtraits_t; - typedef typename bucket_plus_vtraits_t::size_type size_type; - typedef typename bucket_plus_vtraits_t::bucket_ptr bucket_ptr; - typedef detail::size_holder - <0 != (BoolFlags & hash_bool_flags::incremental_pos) - , SizeType, int> split_traits; - typedef typename bucket_plus_vtraits_t:: - value_traits::node_traits node_traits; - typedef detail::bool_::value> optimize_multikey_t; - - template - hashdata_internal( const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits - , const hasher & h, const value_equal &e) - : internal(val_traits, ::boost::forward(b_traits), h, e) - {} - - split_traits &priv_split_traits() - { return *this; } - - const split_traits &priv_split_traits() const - { return *this; } - - ~hashdata_internal() - { this->priv_clear_buckets(); } - - void priv_clear_buckets() - { - this->internal.internal.internal.priv_clear_buckets - ( this->internal.priv_get_cache() - , this->internal.internal.internal.priv_bucket_count() - - (this->internal.priv_get_cache() - - this->internal.internal.internal.priv_bucket_pointer())); - } - - void priv_clear_buckets_and_cache() - { - this->priv_clear_buckets(); - this->internal.priv_initialize_cache(); - } - - void priv_initialize_buckets_and_cache() - { - this->internal.internal.internal.priv_clear_buckets - ( this->internal.internal.internal.priv_bucket_pointer() - , this->internal.internal.internal.priv_bucket_count()); - this->internal.priv_initialize_cache(); - } - - internal_type internal; //2 -}; - -//hashtable_data_t -//Stores hashdata_internal and size_traits -template -struct hashtable_data_t - : public detail::size_holder - < 0 != (BoolFlags & hash_bool_flags::constant_time_size_pos), SizeType> //size_traits -{ - typedef detail::size_holder - < 0 != (BoolFlags & hash_bool_flags::constant_time_size_pos) - , SizeType> size_traits; - typedef hashdata_internal - < SizeType - , BoolFlags & (hash_bool_flags::incremental_pos | hash_bool_flags::cache_begin_pos) - , VoidOrKeyHash, VoidOrKeyEqual - , ValueTraits, BucketTraits> internal_type; - typedef ValueTraits value_traits; - typedef typename internal_type::value_equal value_equal; - typedef typename internal_type::hasher hasher; - typedef BucketTraits bucket_traits; - typedef bucket_plus_vtraits - bucket_plus_vtraits_t; - - template - hashtable_data_t( BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h - , const value_equal &e, const value_traits &val_traits) - : internal(val_traits, ::boost::forward(b_traits), h, e) - {} - - internal_type internal; //1 -}; - -/// @endcond - -//! The class template hashtable is an intrusive hash table container, that -//! is used to construct intrusive unordered_set and unordered_multiset containers. The -//! no-throw guarantee holds only, if the VoidOrKeyEqual object and Hasher don't throw. -//! -//! hashtable is a semi-intrusive container: each object to be stored in the -//! container must contain a proper hook, but the container also needs -//! additional auxiliary memory to work: hashtable needs a pointer to an array -//! of type `bucket_type` to be passed in the constructor. This bucket array must -//! have at least the same lifetime as the container. This makes the use of -//! hashtable more complicated than purely intrusive containers. -//! `bucket_type` is default-constructible, copyable and assignable -//! -//! The template parameter \c T is the type to be managed by the container. -//! The user can specify additional options and if no options are provided -//! default options are used. -//! -//! The container supports the following options: -//! \c base_hook<>/member_hook<>/value_traits<>, -//! \c constant_time_size<>, \c size_type<>, \c hash<> and \c equal<> -//! \c bucket_traits<>, power_2_buckets<>, cache_begin<> and incremental<>. -//! -//! hashtable only provides forward iterators but it provides 4 iterator types: -//! iterator and const_iterator to navigate through the whole container and -//! local_iterator and const_local_iterator to navigate through the values -//! stored in a single bucket. Local iterators are faster and smaller. -//! -//! It's not recommended to use non constant-time size hashtables because several -//! key functions, like "empty()", become non-constant time functions. Non -//! constant_time size hashtables are mainly provided to support auto-unlink hooks. -//! -//! hashtables, does not make automatic rehashings nor -//! offers functions related to a load factor. Rehashing can be explicitly requested -//! and the user must provide a new bucket array that will be used from that moment. -//! -//! Since no automatic rehashing is done, iterators are never invalidated when -//! inserting or erasing elements. Iterators are only invalidated when rehashing. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -class hashtable_impl - : private hashtable_data_t - < SizeType - , BoolFlags & hashtable_data_bool_flags_mask - , VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits> -{ - typedef hashtable_data_t - < SizeType - , BoolFlags & hashtable_data_bool_flags_mask - , VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits> data_type; - - public: - typedef ValueTraits value_traits; - - /// @cond - typedef BucketTraits bucket_traits; - - typedef typename detail::get_slist_impl - ::type - >::type slist_impl; - typedef bucket_plus_vtraits bucket_plus_vtraits_t; - typedef typename bucket_plus_vtraits_t::const_value_traits_ptr const_value_traits_ptr; - - - /// @endcond - - typedef typename value_traits::pointer pointer; - typedef typename value_traits::const_pointer const_pointer; - typedef typename value_traits::value_type value_type; - typedef typename pointer_traits::reference reference; - typedef typename pointer_traits::reference const_reference; - typedef typename pointer_traits::difference_type difference_type; - typedef SizeType size_type; - typedef value_type key_type; - typedef typename data_type::value_equal key_equal; - typedef typename data_type::value_equal value_equal; - typedef typename data_type::hasher hasher; - typedef detail::bucket_impl bucket_type; - typedef typename pointer_traits - ::template rebind_pointer - < bucket_type >::type bucket_ptr; - typedef typename pointer_traits - ::template rebind_pointer - < const bucket_type >::type const_bucket_ptr; - typedef typename pointer_traits - ::reference bucket_reference; - typedef typename pointer_traits - ::reference const_bucket_reference; - typedef typename slist_impl::iterator siterator; - typedef typename slist_impl::const_iterator const_siterator; - typedef hashtable_iterator iterator; - typedef hashtable_iterator const_iterator; - typedef typename value_traits::node_traits node_traits; - typedef typename node_traits::node node; - typedef typename pointer_traits - ::template rebind_pointer - < node >::type node_ptr; - typedef typename pointer_traits - ::template rebind_pointer - < const node >::type const_node_ptr; - typedef typename pointer_traits - ::reference node_reference; - typedef typename pointer_traits - ::reference const_node_reference; - typedef typename slist_impl::node_algorithms node_algorithms; - - static const bool stateful_value_traits = detail::is_stateful_value_traits::value; - static const bool store_hash = detail::store_hash_is_true::value; - - static const bool unique_keys = 0 != (BoolFlags & hash_bool_flags::unique_keys_pos); - static const bool constant_time_size = 0 != (BoolFlags & hash_bool_flags::constant_time_size_pos); - static const bool cache_begin = 0 != (BoolFlags & hash_bool_flags::cache_begin_pos); - static const bool compare_hash = 0 != (BoolFlags & hash_bool_flags::compare_hash_pos); - static const bool incremental = 0 != (BoolFlags & hash_bool_flags::incremental_pos); - static const bool power_2_buckets = incremental || (0 != (BoolFlags & hash_bool_flags::power_2_buckets_pos)); - - static const bool optimize_multikey - = detail::optimize_multikey_is_true::value && !unique_keys; - - /// @cond - private: - - //Configuration error: compare_hash<> can't be specified without store_hash<> - //See documentation for more explanations - BOOST_STATIC_ASSERT((!compare_hash || store_hash)); - - typedef typename slist_impl::node_ptr slist_node_ptr; - typedef typename pointer_traits - ::template rebind_pointer - < void >::type void_pointer; - //We'll define group traits, but these won't be instantiated if - //optimize_multikey is not true - typedef unordered_group_adapter group_traits; - typedef circular_slist_algorithms group_algorithms; - typedef detail::bool_ store_hash_t; - typedef detail::bool_ optimize_multikey_t; - typedef detail::bool_ cache_begin_t; - typedef detail::bool_ power_2_buckets_t; - typedef detail::size_holder size_traits; - typedef detail::size_holder split_traits; - typedef detail::group_functions group_functions_t; - typedef detail::node_functions node_functions_t; - - private: - //noncopyable, movable - BOOST_MOVABLE_BUT_NOT_COPYABLE(hashtable_impl) - - static const bool safemode_or_autounlink = is_safe_autounlink::value; - - //Constant-time size is incompatible with auto-unlink hooks! - BOOST_STATIC_ASSERT(!(constant_time_size && ((int)value_traits::link_mode == (int)auto_unlink))); - //Cache begin is incompatible with auto-unlink hooks! - BOOST_STATIC_ASSERT(!(cache_begin && ((int)value_traits::link_mode == (int)auto_unlink))); - - template - node_cast_adaptor< detail::node_disposer - , slist_node_ptr, node_ptr > - make_node_disposer(const Disposer &disposer) const - { - return node_cast_adaptor - < detail::node_disposer - , slist_node_ptr, node_ptr > - (disposer, &this->priv_value_traits()); - } - - /// @endcond - - public: - typedef detail::insert_commit_data_impl insert_commit_data; - - typedef detail::transform_iterator - < typename slist_impl::iterator - , downcast_node_to_value_t - < value_traits - , false> > local_iterator; - - typedef detail::transform_iterator - < typename slist_impl::iterator - , downcast_node_to_value_t - < value_traits - , true> > const_local_iterator; - - public: - - //! Requires: buckets must not be being used by any other resource. - //! - //! Effects: Constructs an empty unordered_set, storing a reference - //! to the bucket array and copies of the key_hasher and equal_func functors. - //! - //! Complexity: Constant. - //! - //! Throws: If value_traits::node_traits::node - //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) - //! or the copy constructor or invocation of hash_func or equal_func throws. - //! - //! Notes: buckets array must be disposed only after - //! *this is disposed. - explicit hashtable_impl ( const bucket_traits &b_traits - , const hasher & hash_func = hasher() - , const key_equal &equal_func = key_equal() - , const value_traits &v_traits = value_traits()) - : data_type(b_traits, hash_func, equal_func, v_traits) - { - this->data_type::internal.priv_initialize_buckets_and_cache(); - this->priv_size_traits().set_size(size_type(0)); - size_type bucket_sz = this->priv_bucket_count(); - BOOST_INTRUSIVE_INVARIANT_ASSERT(bucket_sz != 0); - //Check power of two bucket array if the option is activated - BOOST_INTRUSIVE_INVARIANT_ASSERT - (!power_2_buckets || (0 == (bucket_sz & (bucket_sz-1)))); - this->priv_split_traits().set_size(bucket_sz>>1); - } - - //! Effects: to-do - //! - hashtable_impl(BOOST_RV_REF(hashtable_impl) x) - : data_type( ::boost::move(x.priv_bucket_traits()) - , ::boost::move(x.priv_hasher()) - , ::boost::move(x.priv_equal()) - , ::boost::move(x.priv_value_traits()) - ) - { - this->priv_swap_cache(x); - x.priv_initialize_cache(); - if(constant_time_size){ - this->priv_size_traits().set_size(size_type(0)); - this->priv_size_traits().set_size(x.priv_size_traits().get_size()); - x.priv_size_traits().set_size(size_type(0)); - } - if(incremental){ - this->priv_split_traits().set_size(x.priv_split_traits().get_size()); - x.priv_split_traits().set_size(size_type(0)); - } - } - - //! Effects: to-do - //! - hashtable_impl& operator=(BOOST_RV_REF(hashtable_impl) x) - { this->swap(x); return *this; } - - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - //! Effects: Detaches all elements from this. The objects in the unordered_set - //! are not deleted (i.e. no destructors are called). - //! - //! Complexity: Linear to the number of elements in the unordered_set, if - //! it's a safe-mode or auto-unlink value. Otherwise constant. - //! - //! Throws: Nothing. - ~hashtable_impl(); - #endif - - //! Effects: Returns an iterator pointing to the beginning of the unordered_set. - //! - //! Complexity: Amortized constant time. - //! Worst case (empty unordered_set): O(this->bucket_count()) - //! - //! Throws: Nothing. - iterator begin() - { return iterator(this->priv_begin(), &this->get_bucket_value_traits()); } - - //! Effects: Returns a const_iterator pointing to the beginning - //! of the unordered_set. - //! - //! Complexity: Amortized constant time. - //! Worst case (empty unordered_set): O(this->bucket_count()) - //! - //! Throws: Nothing. - const_iterator begin() const - { return this->cbegin(); } - - //! Effects: Returns a const_iterator pointing to the beginning - //! of the unordered_set. - //! - //! Complexity: Amortized constant time. - //! Worst case (empty unordered_set): O(this->bucket_count()) - //! - //! Throws: Nothing. - const_iterator cbegin() const - { return const_iterator(this->priv_begin(), &this->get_bucket_value_traits()); } - - //! Effects: Returns an iterator pointing to the end of the unordered_set. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - iterator end() - { return iterator(this->priv_invalid_local_it(), 0); } - - //! Effects: Returns a const_iterator pointing to the end of the unordered_set. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_iterator end() const - { return this->cend(); } - - //! Effects: Returns a const_iterator pointing to the end of the unordered_set. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_iterator cend() const - { return const_iterator(this->priv_invalid_local_it(), 0); } - - //! Effects: Returns the hasher object used by the unordered_set. - //! - //! Complexity: Constant. - //! - //! Throws: If hasher copy-constructor throws. - hasher hash_function() const - { return this->priv_hasher(); } - - //! Effects: Returns the key_equal object used by the unordered_set. - //! - //! Complexity: Constant. - //! - //! Throws: If key_equal copy-constructor throws. - key_equal key_eq() const - { return this->priv_equal(); } - - //! Effects: Returns true if the container is empty. - //! - //! Complexity: if constant-time size and cache_begin options are disabled, - //! average constant time (worst case, with empty() == true: O(this->bucket_count()). - //! Otherwise constant. - //! - //! Throws: Nothing. - bool empty() const - { - if(constant_time_size){ - return !this->size(); - } - else if(cache_begin){ - return this->begin() == this->end(); - } - else{ - size_type bucket_cnt = 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_cnt; ++n, ++b){ - if(!b->empty()){ - return false; - } - } - return true; - } - } - - //! Effects: Returns the number of elements stored in the unordered_set. - //! - //! Complexity: Linear to elements contained in *this if - //! constant_time_size is false. Constant-time otherwise. - //! - //! Throws: Nothing. - size_type size() const - { - if(constant_time_size) - return this->priv_size_traits().get_size(); - else{ - size_type len = 0; - size_type bucket_cnt = 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_cnt; ++n, ++b){ - len += b->size(); - } - return len; - } - } - - //! Requires: the hasher and the equality function unqualified swap - //! call should not throw. - //! - //! Effects: Swaps the contents of two unordered_sets. - //! Swaps also the contained bucket array and equality and hasher functors. - //! - //! Complexity: Constant. - //! - //! Throws: If the swap() call for the comparison or hash functors - //! found using ADL throw. Basic guarantee. - void swap(hashtable_impl& other) - { - using std::swap; - //These can throw - swap(this->priv_equal(), other.priv_equal()); - swap(this->priv_hasher(), other.priv_hasher()); - //These can't throw - swap(this->priv_bucket_traits(), other.priv_bucket_traits()); - swap(this->priv_value_traits(), other.priv_value_traits()); - this->priv_swap_cache(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()); - other.priv_size_traits().set_size(backup); - } - if(incremental){ - size_type backup = this->priv_split_traits().get_size(); - this->priv_split_traits().set_size(other.priv_split_traits().get_size()); - other.priv_split_traits().set_size(backup); - } - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw - //! Cloner should yield to nodes that compare equal and produce the same - //! hash than the original node. - //! - //! Effects: Erases all the elements from *this - //! calling Disposer::operator()(pointer), clones all the - //! elements from src calling Cloner::operator()(const_reference ) - //! and inserts them on *this. The hash function and the equality - //! predicate are copied from the source. - //! - //! If store_hash option is true, this method does not use the hash function. - //! - //! If any operation throws, all cloned elements are unlinked and disposed - //! calling Disposer::operator()(pointer). - //! - //! Complexity: Linear to erased plus inserted elements. - //! - //! Throws: If cloner or hasher throw or hash or equality predicate copying - //! throws. Basic guarantee. - template - void clone_from(const hashtable_impl &src, Cloner cloner, Disposer disposer) - { - this->clear_and_dispose(disposer); - if(!constant_time_size || !src.empty()){ - const size_type src_bucket_count = src.bucket_count(); - const size_type dst_bucket_count = this->bucket_count(); - //Check power of two bucket array if the option is activated - BOOST_INTRUSIVE_INVARIANT_ASSERT - (!power_2_buckets || (0 == (src_bucket_count & (src_bucket_count-1)))); - BOOST_INTRUSIVE_INVARIANT_ASSERT - (!power_2_buckets || (0 == (dst_bucket_count & (dst_bucket_count-1)))); - - //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_bucket_pointer(); - const bucket_ptr dst_buckets = this->priv_bucket_pointer(); - size_type constructed; - - typedef node_cast_adaptor< detail::node_disposer - , slist_node_ptr, node_ptr > NodeDisposer; - typedef node_cast_adaptor< detail::node_cloner - , slist_node_ptr, node_ptr > NodeCloner; - NodeDisposer node_disp(disposer, &this->priv_value_traits()); - - detail::exception_array_disposer - rollback(dst_buckets[0], node_disp, constructed); - for( constructed = 0 - ; constructed < dst_bucket_count - ; ++constructed){ - dst_buckets[constructed].clone_from - ( src_buckets[constructed] - , NodeCloner(cloner, &this->priv_value_traits()), node_disp); - } - if(src_bucket_count != dst_bucket_count){ - //Now insert the remaining ones using the modulo trick - for(//"constructed" comes from the previous loop - ; constructed < src_bucket_count - ; ++constructed){ - bucket_type &dst_b = - dst_buckets[detail::hash_to_bucket_split(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 - ; ++b){ - dst_b.push_front(*(NodeCloner(cloner, &this->priv_value_traits())(*b.pointed_node()))); - } - } - } - this->priv_hasher() = src.priv_hasher(); - this->priv_equal() = src.priv_equal(); - rollback.release(); - this->priv_size_traits().set_size(src.priv_size_traits().get_size()); - this->priv_split_traits().set_size(dst_bucket_count); - this->priv_insertion_update_cache(0u); - this->priv_erasure_update_cache(); - } - else if(store_hash){ - //Unlike previous cloning algorithm, this can throw - //if cloner, hasher or comparison functor throw - const_iterator b(src.cbegin()), e(src.cend()); - detail::exception_disposer - rollback(*this, disposer); - for(; b != e; ++b){ - std::size_t hash_value = this->priv_stored_or_compute_hash(*b, store_hash_t());; - this->priv_insert_equal_with_hash(*cloner(*b), hash_value); - } - rollback.release(); - } - else{ - //Unlike previous cloning algorithm, this can throw - //if cloner, hasher or comparison functor throw - const_iterator b(src.cbegin()), e(src.cend()); - detail::exception_disposer - rollback(*this, disposer); - for(; b != e; ++b){ - this->insert_equal(*cloner(*b)); - } - rollback.release(); - } - } - } - - //! Requires: value must be an lvalue - //! - //! Effects: Inserts the value into the unordered_set. - //! - //! Returns: An iterator to the inserted value. - //! - //! Complexity: Average case O(1), worst case O(this->size()). - //! - //! Throws: If the internal hasher or the equality functor throws. Strong guarantee. - //! - //! Note: Does not affect the validity of iterators and references. - //! No copy-constructors are called. - iterator insert_equal(reference value) - { - size_type bucket_num; - std::size_t hash_value; - siterator prev; - siterator it = this->priv_find - (value, this->priv_hasher(), this->priv_equal(), bucket_num, hash_value, prev); - return this->priv_insert_equal_find(value, bucket_num, hash_value, it); - } - - //! Requires: Dereferencing iterator must yield an lvalue - //! of type value_type. - //! - //! Effects: Equivalent to this->insert_equal(t) for each element in [b, e). - //! - //! Complexity: Average case O(N), where N is std::distance(b, e). - //! Worst case O(N*this->size()). - //! - //! Throws: If the internal hasher or the equality functor throws. Basic guarantee. - //! - //! Note: Does not affect the validity of iterators and references. - //! No copy-constructors are called. - template - void insert_equal(Iterator b, Iterator e) - { - for (; b != e; ++b) - this->insert_equal(*b); - } - - //! Requires: value must be an lvalue - //! - //! Effects: Tries to inserts value into the unordered_set. - //! - //! Returns: If the value - //! is not already present inserts it and returns a pair containing the - //! iterator to the new value and true. If there is an equivalent value - //! returns a pair containing an iterator to the already present value - //! and false. - //! - //! Complexity: Average case O(1), worst case O(this->size()). - //! - //! Throws: If the internal hasher or the equality functor throws. Strong guarantee. - //! - //! Note: Does not affect the validity of iterators and references. - //! No copy-constructors are called. - std::pair insert_unique(reference value) - { - insert_commit_data commit_data; - std::pair ret = this->insert_unique_check - (value, this->priv_hasher(), this->priv_equal(), commit_data); - if(!ret.second) - return ret; - return std::pair - (this->insert_unique_commit(value, commit_data), true); - } - - //! Requires: Dereferencing iterator must yield an lvalue - //! of type value_type. - //! - //! Effects: Equivalent to this->insert_unique(t) for each element in [b, e). - //! - //! Complexity: Average case O(N), where N is std::distance(b, e). - //! Worst case O(N*this->size()). - //! - //! Throws: If the internal hasher or the equality functor throws. Basic guarantee. - //! - //! Note: Does not affect the validity of iterators and references. - //! No copy-constructors are called. - template - void insert_unique(Iterator b, Iterator e) - { - for (; b != e; ++b) - this->insert_unique(*b); - } - - //! Requires: "hash_func" must be a hash function that induces - //! the same hash values as the stored hasher. The difference is that - //! "hash_func" hashes the given key instead of the value_type. - //! - //! "equal_func" must be a equality function that induces - //! the same equality as key_equal. The difference is that - //! "equal_func" compares an arbitrary key with the contained values. - //! - //! Effects: Checks if a value can be inserted in the unordered_set, using - //! a user provided key instead of the value itself. - //! - //! Returns: If there is an equivalent value - //! returns a pair containing an iterator to the already present value - //! and false. If the value can be inserted returns true in the returned - //! pair boolean and fills "commit_data" that is meant to be used with - //! the "insert_commit" function. - //! - //! Complexity: Average case O(1), worst case O(this->size()). - //! - //! Throws: If hash_func or equal_func throw. Strong guarantee. - //! - //! Notes: This function is used to improve performance when constructing - //! a value_type is expensive: if there is an equivalent value - //! the constructed object must be discarded. Many times, the part of the - //! node that is used to impose the hash or the equality is much cheaper to - //! construct than the value_type and this function offers the possibility to - //! use that the part to check if the insertion will be successful. - //! - //! If the check is successful, the user can construct the value_type and use - //! "insert_commit" to insert the object in constant-time. - //! - //! "commit_data" remains valid for a subsequent "insert_commit" only if no more - //! objects are inserted or erased from the unordered_set. - //! - //! After a successful rehashing insert_commit_data remains valid. - template - std::pair insert_unique_check - ( const KeyType &key - , KeyHasher hash_func - , KeyValueEqual equal_func - , insert_commit_data &commit_data) - { - size_type bucket_num; - siterator prev; - siterator prev_pos = - this->priv_find(key, hash_func, equal_func, bucket_num, commit_data.hash, prev); - bool success = prev_pos == this->priv_invalid_local_it(); - if(success){ - prev_pos = prev; - } - return std::pair(iterator(prev_pos, &this->get_bucket_value_traits()),success); - } - - //! Requires: value must be an lvalue of type value_type. commit_data - //! must have been obtained from a previous call to "insert_check". - //! No objects should have been inserted or erased from the unordered_set between - //! the "insert_check" that filled "commit_data" and the call to "insert_commit". - //! - //! Effects: Inserts the value in the unordered_set using the information obtained - //! from the "commit_data" that a previous "insert_check" filled. - //! - //! Returns: An iterator to the newly inserted object. - //! - //! Complexity: Constant time. - //! - //! Throws: Nothing. - //! - //! Notes: This function has only sense if a "insert_check" has been - //! previously executed to fill "commit_data". No value should be inserted or - //! erased between the "insert_check" and "insert_commit" calls. - //! - //! 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 = 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::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)); - 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->get_bucket_value_traits()); - } - - //! Effects: Erases the element pointed to by i. - //! - //! Complexity: Average case O(1), worst case O(this->size()). - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased element. No destructors are called. - void erase(const_iterator i) - { this->erase_and_dispose(i, detail::null_disposer()); } - - //! Effects: Erases the range pointed to by b end e. - //! - //! Complexity: Average case O(std::distance(b, e)), - //! worst case O(this->size()). - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - void erase(const_iterator b, const_iterator e) - { this->erase_and_dispose(b, e, detail::null_disposer()); } - - //! Effects: Erases all the elements with the given value. - //! - //! Returns: The number of erased elements. - //! - //! Complexity: Average case O(this->count(value)). - //! Worst case O(this->size()). - //! - //! Throws: If the internal hasher or the equality functor throws. - //! Basic guarantee. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - size_type erase(const_reference value) - { return this->erase(value, this->priv_hasher(), this->priv_equal()); } - - //! Requires: "hash_func" must be a hash function that induces - //! the same hash values as the stored hasher. The difference is that - //! "hash_func" hashes the given key instead of the value_type. - //! - //! "equal_func" must be a equality function that induces - //! the same equality as key_equal. The difference is that - //! "equal_func" compares an arbitrary key with the contained values. - //! - //! Effects: Erases all the elements that have the same hash and - //! compare equal with the given key. - //! - //! Returns: The number of erased elements. - //! - //! Complexity: Average case O(this->count(value)). - //! Worst case O(this->size()). - //! - //! Throws: If hash_func or equal_func throw. Basic guarantee. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - template - size_type erase(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func) - { return this->erase_and_dispose(key, hash_func, equal_func, detail::null_disposer()); } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases the element pointed to by i. - //! Disposer::operator()(pointer) is called for the removed element. - //! - //! Complexity: Average case O(1), worst case O(this->size()). - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators - //! to the erased elements. - template - void erase_and_dispose(const_iterator i, Disposer disposer - /// @cond - , typename detail::enable_if_c::value >::type * = 0 - /// @endcond - ) - { - this->priv_erase(i, disposer, optimize_multikey_t()); - this->priv_size_traits().decrement(); - this->priv_erasure_update_cache(); - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases the range pointed to by b end e. - //! Disposer::operator()(pointer) is called for the removed elements. - //! - //! Complexity: Average case O(std::distance(b, e)), - //! worst case O(this->size()). - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators - //! to the erased elements. - template - void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) - { - if(b != e){ - //Get the bucket number and local iterator for both iterators - siterator first_local_it(b.slist_it()); - size_type first_bucket_num = this->priv_get_bucket_num(first_local_it); - - const bucket_ptr buck_ptr = this->priv_bucket_pointer(); - siterator before_first_local_it - = this->priv_get_previous(buck_ptr[first_bucket_num], first_local_it); - size_type last_bucket_num; - siterator last_local_it; - - //For the end iterator, we will assign the end iterator - //of the last bucket - if(e == this->end()){ - last_bucket_num = this->bucket_count() - 1; - last_local_it = buck_ptr[last_bucket_num].end(); - } - else{ - last_local_it = e.slist_it(); - last_bucket_num = this->priv_get_bucket_num(last_local_it); - } - this->priv_erase_range(before_first_local_it, first_bucket_num, last_local_it, last_bucket_num, disposer); - this->priv_erasure_update_cache_range(first_bucket_num, last_bucket_num); - } - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases all the elements with the given value. - //! Disposer::operator()(pointer) is called for the removed elements. - //! - //! Returns: The number of erased elements. - //! - //! Complexity: Average case O(this->count(value)). - //! Worst case O(this->size()). - //! - //! Throws: If the internal hasher or the equality functor throws. - //! Basic guarantee. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - template - size_type erase_and_dispose(const_reference value, Disposer disposer) - { return this->erase_and_dispose(value, this->priv_hasher(), this->priv_equal(), disposer); } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases all the elements with the given key. - //! according to the comparison functor "equal_func". - //! Disposer::operator()(pointer) is called for the removed elements. - //! - //! Returns: The number of erased elements. - //! - //! Complexity: Average case O(this->count(value)). - //! Worst case O(this->size()). - //! - //! Throws: If hash_func or equal_func throw. Basic guarantee. - //! - //! Note: Invalidates the iterators - //! to the erased elements. - template - size_type erase_and_dispose(const KeyType& key, KeyHasher hash_func - ,KeyValueEqual equal_func, Disposer disposer) - { - size_type bucket_num; - std::size_t h; - siterator prev; - siterator it = this->priv_find(key, hash_func, equal_func, bucket_num, h, prev); - bool success = it != this->priv_invalid_local_it(); - size_type cnt(0); - if(!success){ - return 0; - } - else if(optimize_multikey){ - siterator last = bucket_type::s_iterator_to - (*node_traits::get_next(group_functions_t::get_last_in_group - (detail::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()))); - this->priv_erase_range_impl(bucket_num, prev, last, disposer, cnt); - } - else{ - //If found erase all equal values - bucket_type &b = this->priv_bucket_pointer()[bucket_num]; - for(siterator end_sit = b.end(); it != end_sit; ++cnt, ++it){ - slist_node_ptr n(it.pointed_node()); - 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)){ - break; - } - } - else if(!equal_func(key, v)){ - break; - } - this->priv_size_traits().decrement(); - } - b.erase_after_and_dispose(prev, it, make_node_disposer(disposer)); - } - this->priv_erasure_update_cache(); - return cnt; - } - - //! Effects: Erases all of the elements. - //! - //! Complexity: Linear to the number of elements on the container. - //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - void clear() - { - this->data_type::internal.priv_clear_buckets_and_cache(); - this->priv_size_traits().set_size(size_type(0)); - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases all of the elements. - //! - //! Complexity: Linear to the number of elements on the container. - //! Disposer::operator()(pointer) is called for the removed elements. - //! - //! Throws: Nothing. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. No destructors are called. - template - void clear_and_dispose(Disposer disposer) - { - if(!constant_time_size || !this->empty()){ - size_type num_buckets = this->bucket_count(); - 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)); - } - this->priv_initialize_cache(); - } - - //! Effects: Returns the number of contained elements with the given value - //! - //! Complexity: Average case O(1), worst case O(this->size()). - //! - //! Throws: If the internal hasher or the equality functor throws. - size_type count(const_reference value) const - { return this->count(value, this->priv_hasher(), this->priv_equal()); } - - //! Requires: "hash_func" must be a hash function that induces - //! the same hash values as the stored hasher. The difference is that - //! "hash_func" hashes the given key instead of the value_type. - //! - //! "equal_func" must be a equality function that induces - //! the same equality as key_equal. The difference is that - //! "equal_func" compares an arbitrary key with the contained values. - //! - //! Effects: Returns the number of contained elements with the given key - //! - //! Complexity: Average case O(1), worst case O(this->size()). - //! - //! Throws: If hash_func or equal throw. - template - size_type count(const KeyType &key, const KeyHasher &hash_func, const KeyValueEqual &equal_func) const - { - size_type bucket_n1, bucket_n2, cnt; - this->priv_equal_range(key, hash_func, equal_func, bucket_n1, bucket_n2, cnt); - return cnt; - } - - //! Effects: Finds an iterator to the first element is equal to - //! "value" or end() if that element does not exist. - //! - //! Complexity: Average case O(1), worst case O(this->size()). - //! - //! Throws: If the internal hasher or the equality functor throws. - iterator find(const_reference value) - { return this->find(value, this->priv_hasher(), this->priv_equal()); } - - //! Requires: "hash_func" must be a hash function that induces - //! the same hash values as the stored hasher. The difference is that - //! "hash_func" hashes the given key instead of the value_type. - //! - //! "equal_func" must be a equality function that induces - //! the same equality as key_equal. The difference is that - //! "equal_func" compares an arbitrary key with the contained values. - //! - //! Effects: Finds an iterator to the first element whose key is - //! "key" according to the given hash and equality functor or end() if - //! that element does not exist. - //! - //! Complexity: Average case O(1), worst case O(this->size()). - //! - //! Throws: If hash_func or equal_func throw. - //! - //! Note: This function is used when constructing a value_type - //! is expensive and the value_type can be compared with a cheaper - //! key type. Usually this key is part of the value_type. - template - iterator find(const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) - { - size_type bucket_n; - std::size_t hash; - siterator prev; - siterator local_it = this->priv_find(key, hash_func, equal_func, bucket_n, hash, prev); - return iterator(local_it, &this->get_bucket_value_traits()); - } - - //! Effects: Finds a const_iterator to the first element whose key is - //! "key" or end() if that element does not exist. - //! - //! Complexity: Average case O(1), worst case O(this->size()). - //! - //! Throws: If the internal hasher or the equality functor throws. - const_iterator find(const_reference value) const - { return this->find(value, this->priv_hasher(), this->priv_equal()); } - - //! Requires: "hash_func" must be a hash function that induces - //! the same hash values as the stored hasher. The difference is that - //! "hash_func" hashes the given key instead of the value_type. - //! - //! "equal_func" must be a equality function that induces - //! the same equality as key_equal. The difference is that - //! "equal_func" compares an arbitrary key with the contained values. - //! - //! Effects: Finds an iterator to the first element whose key is - //! "key" according to the given hasher and equality functor or end() if - //! that element does not exist. - //! - //! Complexity: Average case O(1), worst case O(this->size()). - //! - //! Throws: If hash_func or equal_func throw. - //! - //! Note: This function is used when constructing a value_type - //! is expensive and the value_type can be compared with a cheaper - //! key type. Usually this key is part of the value_type. - template - const_iterator find - (const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) const - { - size_type bucket_n; - std::size_t hash_value; - siterator prev; - siterator sit = this->priv_find(key, hash_func, equal_func, bucket_n, hash_value, prev); - return const_iterator(sit, &this->get_bucket_value_traits()); - } - - //! Effects: Returns a range containing all elements with values equivalent - //! to value. Returns std::make_pair(this->end(), this->end()) if no such - //! elements exist. - //! - //! Complexity: Average case O(this->count(value)). Worst case O(this->size()). - //! - //! Throws: If the internal hasher or the equality functor throws. - std::pair equal_range(const_reference value) - { return this->equal_range(value, this->priv_hasher(), this->priv_equal()); } - - //! Requires: "hash_func" must be a hash function that induces - //! the same hash values as the stored hasher. The difference is that - //! "hash_func" hashes the given key instead of the value_type. - //! - //! "equal_func" must be a equality function that induces - //! the same equality as key_equal. The difference is that - //! "equal_func" compares an arbitrary key with the contained values. - //! - //! Effects: Returns a range containing all elements with equivalent - //! keys. Returns std::make_pair(this->end(), this->end()) if no such - //! elements exist. - //! - //! Complexity: Average case O(this->count(key, hash_func, equal_func)). - //! Worst case O(this->size()). - //! - //! Throws: If hash_func or the equal_func throw. - //! - //! Note: This function is used when constructing a value_type - //! is expensive and the value_type can be compared with a cheaper - //! key type. Usually this key is part of the value_type. - template - std::pair equal_range - (const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) - { - size_type bucket_n1, bucket_n2, cnt; - std::pair ret = this->priv_equal_range - (key, hash_func, equal_func, bucket_n1, bucket_n2, cnt); - return std::pair - (iterator(ret.first, &this->get_bucket_value_traits()), iterator(ret.second, &this->get_bucket_value_traits())); - } - - //! Effects: Returns a range containing all elements with values equivalent - //! to value. Returns std::make_pair(this->end(), this->end()) if no such - //! elements exist. - //! - //! Complexity: Average case O(this->count(value)). Worst case O(this->size()). - //! - //! Throws: If the internal hasher or the equality functor throws. - std::pair - equal_range(const_reference value) const - { return this->equal_range(value, this->priv_hasher(), this->priv_equal()); } - - //! Requires: "hash_func" must be a hash function that induces - //! the same hash values as the stored hasher. The difference is that - //! "hash_func" hashes the given key instead of the value_type. - //! - //! "equal_func" must be a equality function that induces - //! the same equality as key_equal. The difference is that - //! "equal_func" compares an arbitrary key with the contained values. - //! - //! Effects: Returns a range containing all elements with equivalent - //! keys. Returns std::make_pair(this->end(), this->end()) if no such - //! elements exist. - //! - //! Complexity: Average case O(this->count(key, hash_func, equal_func)). - //! Worst case O(this->size()). - //! - //! Throws: If the hasher or equal_func throw. - //! - //! Note: This function is used when constructing a value_type - //! is expensive and the value_type can be compared with a cheaper - //! key type. Usually this key is part of the value_type. - template - std::pair equal_range - (const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) const - { - size_type bucket_n1, bucket_n2, cnt; - std::pair ret = - this->priv_equal_range(key, hash_func, equal_func, bucket_n1, bucket_n2, cnt); - return std::pair - ( const_iterator(ret.first, &this->get_bucket_value_traits()) - , const_iterator(ret.second, &this->get_bucket_value_traits())); - } - - //! Requires: value must be an lvalue and shall be in a unordered_set of - //! appropriate type. Otherwise the behavior is undefined. - //! - //! Effects: Returns: a valid iterator belonging to the unordered_set - //! that points to the value - //! - //! Complexity: Constant. - //! - //! Throws: If the internal hash function throws. - iterator iterator_to(reference value) - { - return iterator(bucket_type::s_iterator_to - (this->priv_value_to_node(value)), &this->get_bucket_value_traits()); - } - - //! Requires: value must be an lvalue and shall be in a unordered_set of - //! appropriate type. Otherwise the behavior is undefined. - //! - //! Effects: Returns: a valid const_iterator belonging to the - //! unordered_set that points to the value - //! - //! Complexity: Constant. - //! - //! Throws: If the internal hash function throws. - const_iterator iterator_to(const_reference value) const - { - node_reference r = *pointer_traits::const_cast_from - (pointer_traits::pointer_to(this->priv_value_to_node(value))); - siterator sit = bucket_type::s_iterator_to(r); - return const_iterator(sit, &this->get_bucket_value_traits()); - } - - //! Requires: value must be an lvalue and shall be in a unordered_set of - //! appropriate type. Otherwise the behavior is undefined. - //! - //! Effects: Returns: a valid local_iterator belonging to the unordered_set - //! that points to the value - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: This static function is available only if the value traits - //! is stateless. - static local_iterator s_local_iterator_to(reference value) - { - BOOST_STATIC_ASSERT((!stateful_value_traits)); - siterator sit = bucket_type::s_iterator_to(*value_traits::to_node_ptr(value)); - return local_iterator(sit, const_value_traits_ptr()); - } - - //! Requires: value must be an lvalue and shall be in a unordered_set of - //! appropriate type. Otherwise the behavior is undefined. - //! - //! Effects: Returns: a valid const_local_iterator belonging to - //! the unordered_set that points to the value - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: This static function is available only if the value traits - //! is stateless. - static const_local_iterator s_local_iterator_to(const_reference value) - { - BOOST_STATIC_ASSERT((!stateful_value_traits)); - node_reference r = *pointer_traits::const_cast_from - (value_traits::to_node_ptr(value)); - siterator sit = bucket_type::s_iterator_to(r); - return const_local_iterator(sit, const_value_traits_ptr()); - } - - //! Requires: value must be an lvalue and shall be in a unordered_set of - //! appropriate type. Otherwise the behavior is undefined. - //! - //! Effects: Returns: a valid local_iterator belonging to the unordered_set - //! that points to the value - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - local_iterator local_iterator_to(reference value) - { - siterator sit = bucket_type::s_iterator_to(this->priv_value_to_node(value)); - return local_iterator(sit, this->priv_value_traits_ptr()); - } - - //! Requires: value must be an lvalue and shall be in a unordered_set of - //! appropriate type. Otherwise the behavior is undefined. - //! - //! Effects: Returns: a valid const_local_iterator belonging to - //! the unordered_set that points to the value - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - const_local_iterator local_iterator_to(const_reference value) const - { - node_reference r = *pointer_traits::const_cast_from - (pointer_traits::pointer_to(this->priv_value_to_node(value))); - siterator sit = bucket_type::s_iterator_to(r); - return const_local_iterator(sit, this->priv_value_traits_ptr()); - } - - //! Effects: Returns the number of buckets passed in the constructor - //! or the last rehash function. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - size_type bucket_count() const - { return this->priv_bucket_count(); } - - //! Requires: n is in the range [0, this->bucket_count()). - //! - //! Effects: Returns the number of elements in the nth bucket. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - size_type bucket_size(size_type n) const - { return this->priv_bucket_pointer()[n].size(); } - - //! Effects: Returns the index of the bucket in which elements - //! with keys equivalent to k would be found, if any such element existed. - //! - //! Complexity: Constant. - //! - //! Throws: If the hash functor throws. - //! - //! Note: the return value is in the range [0, this->bucket_count()). - size_type bucket(const key_type& k) const - { return this->bucket(k, this->priv_hasher()); } - - //! Requires: "hash_func" must be a hash function that induces - //! the same hash values as the stored hasher. The difference is that - //! "hash_func" hashes the given key instead of the value_type. - //! - //! Effects: Returns the index of the bucket in which elements - //! with keys equivalent to k would be found, if any such element existed. - //! - //! Complexity: Constant. - //! - //! Throws: If hash_func throws. - //! - //! Note: the return value is in the range [0, this->bucket_count()). - template - size_type bucket(const KeyType& k, const KeyHasher &hash_func) const - { return this->priv_hash_to_bucket(hash_func(k)); } - - //! Effects: Returns the bucket array pointer passed in the constructor - //! or the last rehash function. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - bucket_ptr bucket_pointer() const - { return this->priv_bucket_pointer(); } - - //! Requires: n is in the range [0, this->bucket_count()). - //! - //! Effects: Returns a local_iterator pointing to the beginning - //! of the sequence stored in the bucket n. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: [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_bucket_pointer()[n].begin(), this->priv_value_traits_ptr()); } - - //! Requires: n is in the range [0, this->bucket_count()). - //! - //! Effects: Returns a const_local_iterator pointing to the beginning - //! of the sequence stored in the bucket n. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: [this->begin(n), this->end(n)) is a valid range - //! containing all of the elements in the nth bucket. - const_local_iterator begin(size_type n) const - { return this->cbegin(n); } - - //! Requires: n is in the range [0, this->bucket_count()). - //! - //! Effects: Returns a const_local_iterator pointing to the beginning - //! of the sequence stored in the bucket n. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: [this->begin(n), this->end(n)) is a valid range - //! containing all of the elements in the nth bucket. - const_local_iterator cbegin(size_type n) const - { - bucket_reference br = pointer_traits::const_cast_from(this->priv_bucket_pointer())[n]; - return const_local_iterator(br.begin(), this->priv_value_traits_ptr()); - } - - //! Requires: n is in the range [0, this->bucket_count()). - //! - //! Effects: Returns a local_iterator pointing to the end - //! of the sequence stored in the bucket n. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: [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_bucket_pointer()[n].end(), this->priv_value_traits_ptr()); } - - //! Requires: n is in the range [0, this->bucket_count()). - //! - //! Effects: Returns a const_local_iterator pointing to the end - //! of the sequence stored in the bucket n. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: [this->begin(n), this->end(n)) is a valid range - //! containing all of the elements in the nth bucket. - const_local_iterator end(size_type n) const - { return this->cend(n); } - - //! Requires: n is in the range [0, this->bucket_count()). - //! - //! Effects: Returns a const_local_iterator pointing to the end - //! of the sequence stored in the bucket n. - //! - //! Complexity: Constant. - //! - //! Throws: Nothing. - //! - //! Note: [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 - { - bucket_reference br = pointer_traits::const_cast_from(this->priv_bucket_pointer())[n]; - return const_local_iterator ( br.end(), this->priv_value_traits_ptr()); - } - - //! Requires: 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. - //! - //! Effects: 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_count(). - //! - //! If store_hash option is true, this method does not use the hash function. - //! - //! Complexity: Average case linear in this->size(), worst case quadratic. - //! - //! Throws: If the hasher functor throws. Basic guarantee. - void rehash(const bucket_traits &new_bucket_traits) - { - 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_bucket_count & (new_bucket_count-1u)))); - - 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_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_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. - //If the source and destination buckets are the same, the second rollback function - //is harmless, because all elements have been already unlinked and destroyed - typedef detail::init_disposer NodeDisposer; - NodeDisposer node_disp; - bucket_type & newbuck = new_buckets[0]; - bucket_type & oldbuck = old_buckets[0]; - detail::exception_array_disposer - rollback1(newbuck, node_disp, new_bucket_count); - detail::exception_array_disposer - 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 - this->priv_initialize_cache(); - this->priv_insertion_update_cache(size_type(0u)); - - //Iterate through nodes - for(; n < old_bucket_count; ++n){ - bucket_type &old_bucket = old_buckets[n]; - - if(!fast_shrink){ - siterator before_i(old_bucket.before_begin()); - siterator end_sit(old_bucket.end()); - siterator i(old_bucket.begin()); - for(;i != end_sit; ++i){ - 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 = detail::hash_to_bucket_split(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 - (detail::dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t())); - if(same_buffer && new_n == n){ - before_i = last; - } - else{ - bucket_type &new_b = new_buckets[new_n]; - new_b.splice_after(new_b.before_begin(), old_bucket, before_i, last); - } - i = before_i; - } - } - else{ - const size_type new_n = detail::hash_to_bucket_split(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]; - if(!old_bucket.empty()){ - new_b.splice_after( new_b.before_begin() - , old_bucket - , old_bucket.before_begin() - , hashtable_impl::priv_get_last(old_bucket)); - } - } - } - - this->priv_size_traits().set_size(size_backup); - this->priv_split_traits().set_size(new_bucket_count); - this->priv_bucket_traits() = new_bucket_traits; - this->priv_initialize_cache(); - this->priv_insertion_update_cache(new_first_bucket_num); - rollback1.release(); - rollback2.release(); - } - - //! Requires: - //! - //! Effects: - //! - //! Complexity: - //! - //! Throws: - //! - //! Note: this method is only available if incremental option is activated. - bool incremental_rehash(bool grow = true) - { - //This function is only available for containers with incremental hashing - BOOST_STATIC_ASSERT(( incremental && power_2_buckets )); - const size_type split_idx = this->priv_split_traits().get_size(); - const size_type bucket_cnt = this->priv_bucket_count(); - const bucket_ptr buck_ptr = this->priv_bucket_pointer(); - - if(grow){ - //Test if the split variable can be changed - if(split_idx >= bucket_cnt) - return false; - - const size_type bucket_to_rehash = split_idx - bucket_cnt/2; - bucket_type &old_bucket = buck_ptr[bucket_to_rehash]; - siterator before_i(old_bucket.before_begin()); - const siterator end_sit(old_bucket.end()); - siterator i(old_bucket.begin()); - 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 rollback - ( buck_ptr[split_idx], old_bucket, this->priv_split_traits()); - for(;i != end_sit; ++i){ - 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 = this->priv_hash_to_bucket(hash_value); - siterator last = bucket_type::s_iterator_to - (*group_functions_t::get_last_in_group - (detail::dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t())); - if(new_n == bucket_to_rehash){ - before_i = last; - } - else{ - bucket_type &new_b = buck_ptr[new_n]; - new_b.splice_after(new_b.before_begin(), old_bucket, before_i, last); - } - i = before_i; - } - rollback.release(); - this->priv_erasure_update_cache(); - return true; - } - else{ - //Test if the split variable can be changed - if(split_idx <= bucket_cnt/2) - return false; - const size_type target_bucket_num = split_idx - 1 - bucket_cnt/2; - bucket_type &target_bucket = buck_ptr[target_bucket_num]; - bucket_type &source_bucket = buck_ptr[split_idx-1]; - target_bucket.splice_after(target_bucket.cbefore_begin(), source_bucket); - this->priv_split_traits().decrement(); - this->priv_insertion_update_cache(target_bucket_num); - return true; - } - } - - //! Effects: If new_bucket_traits.bucket_count() is not - //! this->bucket_count()/2 or this->bucket_count()*2, or - //! this->split_bucket() != new_bucket_traits.bucket_count() returns false - //! and does nothing. - //! - //! Otherwise, copy assigns new_bucket_traits to the internal bucket_traits - //! and transfers all the objects from old buckets to the new ones. - //! - //! Complexity: Linear to size(). - //! - //! Throws: Nothing - //! - //! Note: this method is only available if incremental option is activated. - bool incremental_rehash(const bucket_traits &new_bucket_traits) - { - //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_bucket_count(); - if(new_bucket_traits_size/2 != cur_bucket_traits && new_bucket_traits_size != cur_bucket_traits/2){ - return false; - } - - const size_type split_idx = this->split_count(); - - if(new_bucket_traits_size/2 == cur_bucket_traits){ - //Test if the split variable can be changed - if(!(split_idx >= cur_bucket_traits)) - return false; - } - else{ - //Test if the split variable can be changed - if(!(split_idx <= cur_bucket_traits/2)) - return false; - } - - const size_type ini_n = this->priv_get_cache_bucket_num(); - const bucket_ptr old_buckets = this->priv_bucket_pointer(); - this->priv_bucket_traits() = new_bucket_traits; - if(new_bucket_traits.bucket_begin() != old_buckets){ - for(size_type n = ini_n; n < split_idx; ++n){ - bucket_type &new_bucket = new_bucket_traits.bucket_begin()[n]; - bucket_type &old_bucket = old_buckets[n]; - new_bucket.splice_after(new_bucket.cbefore_begin(), old_bucket); - } - //Put cache to safe position - this->priv_initialize_cache(); - this->priv_insertion_update_cache(ini_n); - } - return true; - } - - //! Requires: - //! - //! Effects: - //! - //! Complexity: - //! - //! Throws: - size_type split_count() const - { - //This function is only available if incremental hashing is activated - BOOST_STATIC_ASSERT(( incremental && power_2_buckets )); - return this->priv_split_traits().get_size(); - } - - //! Effects: Returns the nearest new bucket count optimized for - //! the container that is bigger or equal than n. This suggestion can be - //! used to create bucket arrays with a size that will usually improve - //! container's performance. If such value does not exist, the - //! higher possible value is returned. - //! - //! Complexity: Amortized constant time. - //! - //! Throws: Nothing. - static size_type suggested_upper_bucket_count(size_type n) - { - const std::size_t *primes = &prime_list_holder<0>::prime_list[0]; - const std::size_t *primes_end = primes + prime_list_holder<0>::prime_list_size; - std::size_t const* bound = std::lower_bound(primes, primes_end, n); - bound -= (bound == primes_end); - return size_type(*bound); - } - - //! Effects: Returns the nearest new bucket count optimized for - //! the container that is smaller or equal than n. This suggestion can be - //! used to create bucket arrays with a size that will usually improve - //! container's performance. If such value does not exist, the - //! lowest possible value is returned. - //! - //! Complexity: Amortized constant time. - //! - //! Throws: Nothing. - static size_type suggested_lower_bucket_count(size_type n) - { - const std::size_t *primes = &prime_list_holder<0>::prime_list[0]; - const std::size_t *primes_end = primes + prime_list_holder<0>::prime_list_size; - size_type const* bound = std::upper_bound(primes, primes_end, n); - bound -= (bound != primes); - return size_type(*bound); - } - /// @cond - void check() const {} - private: - size_traits &priv_size_traits() - { return static_cast(static_cast(*this)); } - - const size_traits &priv_size_traits() const - { return static_cast(static_cast(*this)); } - - bucket_ptr priv_bucket_pointer() const - { return this->data_type::internal.internal.internal.internal.priv_bucket_pointer(); } - - SizeType priv_bucket_count() const - { return this->data_type::internal.internal.internal.internal.priv_bucket_count(); } - - const bucket_plus_vtraits &get_bucket_value_traits() const - { return this->data_type::internal.internal.internal.internal.get_bucket_value_traits(); } - - bucket_plus_vtraits &get_bucket_value_traits() - { return this->data_type::internal.internal.internal.internal.get_bucket_value_traits(); } - - bucket_traits &priv_bucket_traits() - { return this->data_type::internal.internal.internal.internal.priv_bucket_traits(); } - - const bucket_traits &priv_bucket_traits() const - { return this->data_type::internal.internal.internal.internal.priv_bucket_traits(); } - - value_traits &priv_value_traits() - { return this->data_type::internal.internal.internal.internal.priv_value_traits(); } - - const value_traits &priv_value_traits() const - { return this->data_type::internal.internal.internal.internal.priv_value_traits(); } - - const_value_traits_ptr priv_value_traits_ptr() const - { return this->data_type::internal.internal.internal.internal.priv_value_traits_ptr(); } - - siterator priv_invalid_local_it() const - { return this->data_type::internal.internal.internal.internal.priv_invalid_local_it(); } - - split_traits &priv_split_traits() - { return this->data_type::internal.priv_split_traits(); } - - const split_traits &priv_split_traits() const - { return this->data_type::internal.priv_split_traits(); } - - bucket_ptr priv_get_cache() - { return this->data_type::internal.internal.priv_get_cache(); } - - void priv_initialize_cache() - { return this->data_type::internal.internal.priv_initialize_cache(); } - - siterator priv_begin() const - { return this->data_type::internal.internal.priv_begin(); } - - const value_equal &priv_equal() const - { return this->data_type::internal.internal.priv_equal(); } - - value_equal &priv_equal() - { return this->data_type::internal.internal.priv_equal(); } - - const hasher &priv_hasher() const - { return this->data_type::internal.internal.internal.priv_hasher(); } - - hasher &priv_hasher() - { return this->data_type::internal.internal.internal.priv_hasher(); } - - void priv_swap_cache(hashtable_impl &h) - { this->data_type::internal.internal.priv_swap_cache(h.data_type::internal.internal); } - - node &priv_value_to_node(value_type &v) - { return this->data_type::internal.internal.internal.internal.priv_value_to_node(v); } - - const node &priv_value_to_node(const value_type &v) const - { return this->data_type::internal.internal.internal.internal.priv_value_to_node(v); } - - SizeType priv_get_cache_bucket_num() - { return this->data_type::internal.internal.priv_get_cache_bucket_num(); } - - void priv_insertion_update_cache(SizeType n) - { return this->data_type::internal.internal.priv_insertion_update_cache(n); } - - template - std::size_t priv_stored_or_compute_hash(const value_type &v, detail::bool_ b) const - { return this->data_type::internal.internal.internal.priv_stored_or_compute_hash(v, b); } - - value_type &priv_value_from_slist_node(slist_node_ptr n) - { return this->data_type::internal.internal.internal.internal.priv_value_from_slist_node(n); } - - const value_type &priv_value_from_slist_node(slist_node_ptr n) const - { return this->data_type::internal.internal.internal.internal.priv_value_from_slist_node(n); } - - void priv_erasure_update_cache_range(SizeType first_bucket_num, SizeType last_bucket_num) - { return this->data_type::internal.internal.priv_erasure_update_cache_range(first_bucket_num, last_bucket_num); } - - void priv_erasure_update_cache() - { return this->data_type::internal.internal.priv_erasure_update_cache(); } - - static std::size_t priv_stored_hash(slist_node_ptr n, detail::true_ true_value) - { return bucket_plus_vtraits::priv_stored_hash(n, true_value); } - - static std::size_t priv_stored_hash(slist_node_ptr n, detail::false_ false_value) - { return bucket_plus_vtraits::priv_stored_hash(n, false_value); } - - std::size_t priv_hash_to_bucket(std::size_t hash_value) const - { - return detail::hash_to_bucket_split - (hash_value, this->priv_bucket_traits().bucket_count(), this->priv_split_traits().get_size()); - } - - template - void priv_erase_range_impl - (size_type bucket_num, siterator before_first_it, siterator end_sit, Disposer disposer, size_type &num_erased) - { - const bucket_ptr buckets = this->priv_bucket_pointer(); - bucket_type &b = buckets[bucket_num]; - - if(before_first_it == b.before_begin() && end_sit == b.end()){ - this->priv_erase_range_impl(bucket_num, 1, disposer, num_erased); - } - else{ - num_erased = 0; - siterator to_erase(before_first_it); - ++to_erase; - slist_node_ptr end_ptr = end_sit.pointed_node(); - while(to_erase != end_sit){ - group_functions_t::erase_from_group(end_ptr, detail::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; - } - this->priv_size_traits().set_size(this->priv_size_traits().get_size()-num_erased); - } - } - - template - void priv_erase_range_impl - (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 = 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]; - siterator b_begin(b.before_begin()); - siterator nxt(b_begin); - ++nxt; - siterator end_sit(b.end()); - while(nxt != end_sit){ - group_functions_t::init_group(detail::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(); - ++num_erased; - } - } - } - - template - void priv_erase_range( siterator before_first_it, size_type first_bucket - , siterator last_it, size_type last_bucket - , Disposer disposer) - { - size_type num_erased; - if (first_bucket == last_bucket){ - this->priv_erase_range_impl(first_bucket, before_first_it, last_it, disposer, num_erased); - } - else { - 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)) - 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); - } - } - - std::size_t priv_get_bucket_num(siterator it) - { 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_) //store_hash - { - return this->priv_hash_to_bucket - (this->priv_stored_hash(it.pointed_node(), store_hash_t())); - } - - std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::false_) //NO store_hash - { return this->data_type::internal.internal.internal.internal.priv_get_bucket_num_no_hash_store(it, optimize_multikey_t()); } - - static siterator priv_get_previous(bucket_type &b, siterator i) - { return bucket_plus_vtraits_t::priv_get_previous(b, i, optimize_multikey_t()); } - - static siterator priv_get_last(bucket_type &b) - { return bucket_plus_vtraits_t::priv_get_last(b, optimize_multikey_t()); } - - template - void priv_erase(const_iterator i, Disposer disposer, detail::true_) - { - slist_node_ptr elem(i.slist_it().pointed_node()); - slist_node_ptr f_bucket_end, l_bucket_end; - if(store_hash){ - f_bucket_end = l_bucket_end = - (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_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 - (*group_functions_t::get_previous_and_next_in_group - ( elem, nxt_in_group, f_bucket_end, l_bucket_end) - ); - 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(detail::dcast_bucket_ptr(elem)); - } - - template - void priv_erase(const_iterator i, Disposer disposer, detail::false_) - { - siterator to_erase(i.slist_it()); - 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)); - } - - template - siterator priv_find - ( const KeyType &key, KeyHasher hash_func - , KeyValueEqual equal_func, size_type &bucket_number, std::size_t &h, siterator &previt) const - { - h = hash_func(key); - return this->priv_find_with_hash(key, equal_func, bucket_number, h, previt); - } - - template - 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 = 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 this->priv_invalid_local_it(); - } - - siterator it = previt; - ++it; - - while(it != b.end()){ - 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)){ - return it; - } - } - else if(equal_func(key, v)){ - return it; - } - if(optimize_multikey){ - previt = bucket_type::s_iterator_to - (*group_functions_t::get_last_in_group - (detail::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())); - it = previt; - } - else{ - previt = it; - } - ++it; - } - previt = b.before_begin(); - return this->priv_invalid_local_it(); - } - - iterator priv_insert_equal_with_hash(reference value, std::size_t hash_value) - { - size_type bucket_num; - siterator prev; - siterator it = this->priv_find_with_hash - (value, this->priv_equal(), bucket_num, hash_value, prev); - 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_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::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) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n)); - //Shortcut for optimize_multikey cases - if(optimize_multikey){ - node_ptr first_in_group = found_equal ? - detail::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 - 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->get_bucket_value_traits()); - } - - template - std::pair priv_equal_range - ( const KeyType &key - , KeyHasher hash_func - , KeyValueEqual equal_func - , size_type &bucket_number_first - , size_type &bucket_number_second - , size_type &cnt) const - { - std::size_t h; - cnt = 0; - siterator prev; - //Let's see if the element is present - std::pair to_return - ( 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_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 - (detail::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()))); - - cnt = 0; - for(; it != to_return.second; ++it){ ++cnt; } - if(to_return.second != b.end()){ - bucket_number_second = bucket_number_first; - return to_return; - } - } - else{ - ++cnt; - ++it; - while(it != b.end()){ - 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)){ - to_return.second = it; - bucket_number_second = bucket_number_first; - return to_return; - } - } - else if(!equal_func(key, v)){ - to_return.second = it; - bucket_number_second = bucket_number_first; - return to_return; - } - ++it; - ++cnt; - } - } - } - - //If we reached the end, find the first, non-empty bucket - for(bucket_number_second = bucket_number_first+1 - ; bucket_number_second != this->priv_bucket_count() - ; ++bucket_number_second){ - bucket_type &b = this->priv_bucket_pointer()[bucket_number_second]; - if(!b.empty()){ - to_return.second = b.begin(); - return to_return; - } - } - - //Otherwise, return the end node - to_return.second = this->priv_invalid_local_it(); - return to_return; - } - /// @endcond -}; - -/// @cond -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template < class T - , bool UniqueKeys - , class PackedOptions - > -#else -template -#endif -struct make_bucket_traits -{ - //Real value traits must be calculated from options - typedef typename detail::get_value_traits - ::type value_traits; - - typedef typename PackedOptions::bucket_traits specified_bucket_traits; - - //Real bucket traits must be calculated from options and calculated value_traits - typedef typename detail::get_slist_impl - ::type - >::type slist_impl; - - typedef typename - detail::if_c< detail::is_same - < specified_bucket_traits - , default_bucket_traits - >::value - , detail::bucket_traits_impl - , specified_bucket_traits - >::type type; -}; -/// @endcond - -//! Helper metafunction to define a \c hashtable that yields to the same type when the -//! same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_hashtable -{ - /// @cond - typedef typename pack_options - < hashtable_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3, O4, O5, O6, O7, O8, O9, O10 - #else - Options... - #endif - >::type packed_options; - - typedef typename detail::get_value_traits - ::type value_traits; - - typedef typename make_bucket_traits - ::type bucket_traits; - - typedef hashtable_impl - < value_traits - , typename packed_options::hash - , typename packed_options::equal - , typename packed_options::size_type - , bucket_traits - , (std::size_t(false)*hash_bool_flags::unique_keys_pos) - | (std::size_t(packed_options::constant_time_size)*hash_bool_flags::constant_time_size_pos) - | (std::size_t(packed_options::power_2_buckets)*hash_bool_flags::power_2_buckets_pos) - | (std::size_t(packed_options::cache_begin)*hash_bool_flags::cache_begin_pos) - | (std::size_t(packed_options::compare_hash)*hash_bool_flags::compare_hash_pos) - | (std::size_t(packed_options::incremental)*hash_bool_flags::incremental_pos) - > implementation_defined; - - /// @endcond - typedef implementation_defined type; -}; - -#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -#if defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class hashtable - : public make_hashtable::type -{ - typedef typename make_hashtable::type Base; - BOOST_MOVABLE_BUT_NOT_COPYABLE(hashtable) - - public: - typedef typename Base::value_traits value_traits; - typedef typename Base::iterator iterator; - typedef typename Base::const_iterator const_iterator; - typedef typename Base::bucket_ptr bucket_ptr; - typedef typename Base::size_type size_type; - typedef typename Base::hasher hasher; - typedef typename Base::bucket_traits bucket_traits; - typedef typename Base::key_equal key_equal; - - //Assert if passed value traits are compatible with the type - BOOST_STATIC_ASSERT((detail::is_same::value)); - - explicit hashtable ( const bucket_traits &b_traits - , const hasher & hash_func = hasher() - , const key_equal &equal_func = key_equal() - , const value_traits &v_traits = value_traits()) - : Base(b_traits, hash_func, equal_func, v_traits) - {} - - hashtable(BOOST_RV_REF(hashtable) x) - : Base(::boost::move(static_cast(x))) - {} - - hashtable& operator=(BOOST_RV_REF(hashtable) x) - { return static_cast(this->Base::operator=(::boost::move(static_cast(x)))); } -}; - -#endif - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_HASHTABLE_HPP diff --git a/boost/intrusive/intrusive_fwd.hpp b/boost/intrusive/intrusive_fwd.hpp deleted file mode 100644 index a449816..0000000 --- a/boost/intrusive/intrusive_fwd.hpp +++ /dev/null @@ -1,729 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_FWD_HPP -#define BOOST_INTRUSIVE_FWD_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -//! \file -//! This header file forward declares most Intrusive classes. -//! -//! It forward declares the following containers and hooks: -//! - boost::intrusive::slist / boost::intrusive::slist_base_hook / boost::intrusive::slist_member_hook -//! - boost::intrusive::list / boost::intrusive::list_base_hook / boost::intrusive::list_member_hook -//! - boost::intrusive::bstree / boost::intrusive::bs_set / boost::intrusive::bs_multiset / -//! boost::intrusive::bs_set_base_hook / boost::intrusive::bs_set_member_hook -//! - boost::intrusive::rbtree / boost::intrusive::set / boost::intrusive::multiset / -//! boost::intrusive::set_base_hook / boost::intrusive::set_member_hook -//! - boost::intrusive::avltree / boost::intrusive::avl_set / boost::intrusive::avl_multiset / -//! boost::intrusive::avl_set_base_hook / boost::intrusive::avl_set_member_hook -//! - boost::intrusive::splaytree / boost::intrusive::splay_set / boost::intrusive::splay_multiset -//! - boost::intrusive::sgtree / boost::intrusive::sg_set / boost::intrusive::sg_multiset -//! - boost::intrusive::treap / boost::intrusive::treap_set / boost::intrusive::treap_multiset -//! - boost::intrusive::hashtable / boost::intrusive::unordered_set / boost::intrusive::unordered_multiset / -//! boost::intrusive::unordered_set_base_hook / boost::intrusive::unordered_set_member_hook / -//! - boost::intrusive::any_base_hook / boost::intrusive::any_member_hook -//! -//! It forward declares the following container or hook options: -//! - boost::intrusive::constant_time_size / boost::intrusive::size_type / boost::intrusive::compare / boost::intrusive::equal -//! - boost::intrusive::floating_point / boost::intrusive::priority / boost::intrusive::hash -//! - boost::intrusive::value_traits / boost::intrusive::member_hook / boost::intrusive::function_hook / boost::intrusive::base_hook -//! - boost::intrusive::void_pointer / boost::intrusive::tag / boost::intrusive::link_mode -//! - boost::intrusive::optimize_size / boost::intrusive::linear / boost::intrusive::cache_last -//! - boost::intrusive::bucket_traits / boost::intrusive::store_hash / boost::intrusive::optimize_multikey -//! - boost::intrusive::power_2_buckets / boost::intrusive::cache_begin / boost::intrusive::compare_hash / boost::intrusive::incremental -//! -//! It forward declares the following value traits utilities: -//! - boost::intrusive::value_traits / boost::intrusive::derivation_value_traits / -//! boost::intrusive::trivial_value_traits -//! -//! Finally it forward declares the following general purpose utilities: -//! - boost::intrusive::pointer_plus_bits / boost::intrusive::priority_compare. - -#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -#include -#include -#include - -namespace boost { -namespace intrusive { - -//////////////////////////// -// Node algorithms -//////////////////////////// - -//Algorithms predeclarations -template -class circular_list_algorithms; - -template -class circular_slist_algorithms; - -template -class linear_slist_algorithms; - -template -class bstree_algorithms; - -template -class rbtree_algorithms; - -template -class avltree_algorithms; - -template -class sgtree_algorithms; - -template -class splaytree_algorithms; - -template -class treap_algorithms; - -//////////////////////////// -// Containers -//////////////////////////// - -//slist -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - , class O6 = void - > -#else -template -#endif -class slist; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - > -#else -template -#endif -class slist_base_hook; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - > -#else -template -#endif -class slist_member_hook; - -//list -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - > -#else -template -#endif -class list; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - > -#else -template -#endif -class list_base_hook; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - > -#else -template -#endif -class list_member_hook; - -//rbtree/set/multiset -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class rbtree; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class set; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class multiset; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - > -#else -template -#endif -class set_base_hook; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - > -#else -template -#endif -class set_member_hook; - -//splaytree/splay_set/splay_multiset -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class splaytree; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class splay_set; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class splay_multiset; - -//avltree/avl_set/avl_multiset -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class avltree; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class avl_set; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class avl_multiset; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - > -#else -template -#endif -class avl_set_base_hook; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - > -#else -template -#endif -class avl_set_member_hook; - - -//treap/treap_set/treap_multiset -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class treap; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class treap_set; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class treap_multiset; - -//sgtree/sg_set/sg_multiset -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class sgtree; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class sg_set; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class sg_multiset; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class bstree; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class bs_set; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - > -#else -template -#endif -class bs_multiset; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - > -#else -template -#endif -class bs_set_base_hook; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - > -#else -template -#endif -class bs_set_member_hook; - -//hashtable/unordered_set/unordered_multiset - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - , class O6 = void - , class O7 = void - , class O8 = void - , class O9 = void - , class O10 = void - > -#else -template -#endif -class hashtable; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - , class O6 = void - , class O7 = void - , class O8 = void - , class O9 = void - , class O10 = void - > -#else -template -#endif -class unordered_set; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class T - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - , class O6 = void - , class O7 = void - , class O8 = void - , class O9 = void - , class O10 = void - > -#else -template -#endif -class unordered_multiset; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - > -#else -template -#endif -class unordered_set_base_hook; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - > -#else -template -#endif -class unordered_set_member_hook; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - > -#else -template -#endif -class any_base_hook; - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template - < class O1 = void - , class O2 = void - , class O3 = void - > -#else -template -#endif -class any_member_hook; - -//Options - -template -struct constant_time_size; - -template -struct size_type; - -template -struct compare; - -template -struct floating_point; - -template -struct equal; - -template -struct priority; - -template -struct hash; - -template struct value_traits; - -template< typename Parent - , typename MemberHook - , MemberHook Parent::* PtrToMember> -struct member_hook; - -template -struct function_hook; - -template -struct base_hook; - -template -struct void_pointer; - -template -struct tag; - -template -struct link_mode; - -template struct -optimize_size; - -template -struct linear; - -template -struct cache_last; - -template -struct bucket_traits; - -template -struct store_hash; - -template -struct optimize_multikey; - -template -struct power_2_buckets; - -template -struct cache_begin; - -template -struct compare_hash; - -template -struct incremental; - -//Value traits - -template -struct value_traits; - -template< typename Parent - , typename MemberHook - , MemberHook Parent::* PtrToMember> -struct member_hook; - -template< typename Functor> -struct function_hook; - -template -struct base_hook; - -template -struct derivation_value_traits; - -template -struct trivial_value_traits; - -//Additional utilities - -template -struct max_pointer_plus_bits; - -template -struct max_pointer_plus_bits; - -template -struct pointer_plus_bits; - -template -struct pointer_plus_bits; - -template -struct pointer_traits; - -template -struct pointer_traits; - -} //namespace intrusive { -} //namespace boost { - -#endif //#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - -#endif //#ifndef BOOST_INTRUSIVE_FWD_HPP diff --git a/boost/intrusive/linear_slist_algorithms.hpp b/boost/intrusive/linear_slist_algorithms.hpp deleted file mode 100644 index 31e5594..0000000 --- a/boost/intrusive/linear_slist_algorithms.hpp +++ /dev/null @@ -1,342 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_LINEAR_SLIST_ALGORITHMS_HPP -#define BOOST_INTRUSIVE_LINEAR_SLIST_ALGORITHMS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -//! linear_slist_algorithms provides basic algorithms to manipulate nodes -//! forming a linear singly linked list. -//! -//! linear_slist_algorithms is configured with a NodeTraits class, which encapsulates the -//! information about the node to be manipulated. NodeTraits must support the -//! following interface: -//! -//! Typedefs: -//! -//! node: The type of the node that forms the linear list -//! -//! node_ptr: A pointer to a node -//! -//! const_node_ptr: A pointer to a const node -//! -//! Static functions: -//! -//! static node_ptr get_next(const_node_ptr n); -//! -//! static void set_next(node_ptr n, node_ptr next); -template -class linear_slist_algorithms - /// @cond - : public detail::common_slist_algorithms - /// @endcond -{ - /// @cond - typedef detail::common_slist_algorithms base_t; - /// @endcond - public: - typedef typename NodeTraits::node node; - typedef typename NodeTraits::node_ptr node_ptr; - typedef typename NodeTraits::const_node_ptr const_node_ptr; - typedef NodeTraits node_traits; - - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - - //! Effects: Constructs an non-used list element, putting the next - //! pointer to null: - //! NodeTraits::get_next(this_node) == node_ptr() - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void init(const node_ptr & this_node); - - //! Requires: this_node must be in a circular list or be an empty circular list. - //! - //! Effects: Returns true is "this_node" is the only node of a circular list: - //! or it's a not inserted node: - //! return node_ptr() == NodeTraits::get_next(this_node) || NodeTraits::get_next(this_node) == this_node - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static bool unique(const_node_ptr this_node); - - //! Effects: Returns true is "this_node" has the same state as if - //! it was inited using "init(node_ptr)" - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static bool inited(const_node_ptr this_node); - - //! Requires: prev_node must be in a circular list or be an empty circular list. - //! - //! Effects: Unlinks the next node of prev_node from the circular list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void unlink_after(const node_ptr & prev_node); - - //! Requires: prev_node and last_node must be in a circular list - //! or be an empty circular list. - //! - //! Effects: Unlinks the range (prev_node, last_node) from the linear list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void unlink_after(const node_ptr & prev_node, const node_ptr & last_node); - - //! Requires: prev_node must be a node of a linear list. - //! - //! Effects: Links this_node after prev_node in the linear list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void link_after(const node_ptr & prev_node, const node_ptr & this_node); - - //! Requires: b and e must be nodes of the same linear list or an empty range. - //! and p must be a node of a different linear list. - //! - //! Effects: Removes the nodes from (b, e] range from their linear list and inserts - //! them after p in p's linear list. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void transfer_after(const node_ptr & p, const node_ptr & b, const node_ptr & e); - - #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - - //! Effects: Constructs an empty list, making this_node the only - //! node of the circular list: - //! NodeTraits::get_next(this_node) == this_node. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void init_header(const node_ptr & this_node) - { NodeTraits::set_next(this_node, node_ptr ()); } - - //! Requires: this_node and prev_init_node must be in the same linear list. - //! - //! Effects: Returns the previous node of this_node in the linear list starting. - //! the search from prev_init_node. The first node checked for equality - //! is NodeTraits::get_next(prev_init_node). - //! - //! Complexity: Linear to the number of elements between prev_init_node and this_node. - //! - //! Throws: Nothing. - static node_ptr get_previous_node(const node_ptr & prev_init_node, const node_ptr & this_node) - { return base_t::get_previous_node(prev_init_node, this_node); } - - //! Requires: this_node must be in a linear list or be an empty linear list. - //! - //! Effects: Returns the number of nodes in a linear list. If the linear list - //! is empty, returns 1. - //! - //! Complexity: Linear - //! - //! Throws: Nothing. - static std::size_t count(const const_node_ptr & this_node) - { - std::size_t result = 0; - const_node_ptr p = this_node; - do{ - p = NodeTraits::get_next(p); - ++result; - } while (p); - return result; - } - - //! Requires: this_node and other_node must be nodes inserted - //! in linear lists or be empty linear lists. - //! - //! Effects: Moves all the nodes previously chained after this_node after other_node - //! and vice-versa. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - static void swap_trailing_nodes(const node_ptr & this_node, const node_ptr & other_node) - { - node_ptr this_nxt = NodeTraits::get_next(this_node); - node_ptr other_nxt = NodeTraits::get_next(other_node); - NodeTraits::set_next(this_node, other_nxt); - NodeTraits::set_next(other_node, this_nxt); - } - - //! Effects: Reverses the order of elements in the list. - //! - //! Returns: The new first node of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: This function is linear to the contained elements. - static node_ptr reverse(const node_ptr & p) - { - if(!p) return node_ptr(); - node_ptr i = NodeTraits::get_next(p); - node_ptr first(p); - while(i){ - node_ptr nxti(NodeTraits::get_next(i)); - base_t::unlink_after(p); - NodeTraits::set_next(i, first); - first = i; - i = nxti; - } - return first; - } - - //! Effects: Moves the first n nodes starting at p to the end of the list. - //! - //! Returns: A pair containing the new first and last node of the list or - //! if there has been any movement, a null pair if n leads to no movement. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements plus the number moved positions. - static std::pair move_first_n_backwards(const node_ptr & p, std::size_t n) - { - std::pair ret; - //Null shift, or count() == 0 or 1, nothing to do - if(!n || !p || !NodeTraits::get_next(p)){ - return ret; - } - - node_ptr first = p; - bool end_found = false; - node_ptr new_last = node_ptr(); - node_ptr old_last = node_ptr(); - - //Now find the new last node according to the shift count. - //If we find 0 before finding the new last node - //unlink p, shortcut the search now that we know the size of the list - //and continue. - for(std::size_t i = 1; i <= n; ++i){ - new_last = first; - first = NodeTraits::get_next(first); - if(first == node_ptr()){ - //Shortcut the shift with the modulo of the size of the list - n %= i; - if(!n) return ret; - old_last = new_last; - i = 0; - //Unlink p and continue the new first node search - first = p; - //unlink_after(new_last); - end_found = true; - } - } - - //If the p has not been found in the previous loop, find it - //starting in the new first node and unlink it - if(!end_found){ - old_last = base_t::get_previous_node(first, node_ptr()); - } - - //Now link p after the new last node - NodeTraits::set_next(old_last, p); - NodeTraits::set_next(new_last, node_ptr()); - ret.first = first; - ret.second = new_last; - return ret; - } - - //! Effects: Moves the first n nodes starting at p to the beginning of the list. - //! - //! Returns: A pair containing the new first and last node of the list or - //! if there has been any movement, a null pair if n leads to no movement. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements plus the number moved positions. - static std::pair move_first_n_forward(const node_ptr & p, std::size_t n) - { - std::pair ret; - //Null shift, or count() == 0 or 1, nothing to do - if(!n || !p || !NodeTraits::get_next(p)) - return ret; - - node_ptr first = p; - - //Iterate until p is found to know where the current last node is. - //If the shift count is less than the size of the list, we can also obtain - //the position of the new last node after the shift. - node_ptr old_last(first), next_to_it, new_last(p); - std::size_t distance = 1; - while(!!(next_to_it = node_traits::get_next(old_last))){ - if(distance++ > n) - new_last = node_traits::get_next(new_last); - old_last = next_to_it; - } - //If the shift was bigger or equal than the size, obtain the equivalent - //forward shifts and find the new last node. - if(distance <= n){ - //Now find the equivalent forward shifts. - //Shortcut the shift with the modulo of the size of the list - std::size_t new_before_last_pos = (distance - (n % distance))% distance; - //If the shift is a multiple of the size there is nothing to do - if(!new_before_last_pos) - return ret; - - for( new_last = p - ; --new_before_last_pos - ; new_last = node_traits::get_next(new_last)){ - //empty - } - } - - //Get the first new node - node_ptr new_first(node_traits::get_next(new_last)); - //Now put the old beginning after the old end - NodeTraits::set_next(old_last, p); - NodeTraits::set_next(new_last, node_ptr()); - ret.first = new_first; - ret.second = new_last; - return ret; - } -}; - -/// @cond - -template -struct get_algo -{ - typedef linear_slist_algorithms type; -}; - -/// @endcond - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_LINEAR_SLIST_ALGORITHMS_HPP diff --git a/boost/intrusive/link_mode.hpp b/boost/intrusive/link_mode.hpp deleted file mode 100644 index c7245d9..0000000 --- a/boost/intrusive/link_mode.hpp +++ /dev/null @@ -1,63 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2006-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_LINK_MODE_HPP -#define BOOST_INTRUSIVE_LINK_MODE_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -namespace boost { -namespace intrusive { - -//!This enumeration defines the type of value_traits that can be defined -//!for Boost.Intrusive containers -enum link_mode_type{ - //!If this linking policy is specified in a value_traits class - //!as the link_mode, containers - //!configured with such value_traits won't set the hooks - //!of the erased values to a default state. Containers also won't - //!check that the hooks of the new values are default initialized. - normal_link, - - //!If this linking policy is specified in a value_traits class - //!as the link_mode, containers - //!configured with such value_traits will set the hooks - //!of the erased values to a default state. Containers also will - //!check that the hooks of the new values are default initialized. - safe_link, - - //!Same as "safe_link" but the user type is an auto-unlink - //!type, so the containers with constant-time size features won't be - //!compatible with value_traits configured with this policy. - //!Containers also know that the a value can be silently erased from - //!the container without using any function provided by the containers. - auto_unlink -}; - -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - -template -struct is_safe_autounlink -{ - static const bool value = - (int)link_mode == (int)auto_unlink || - (int)link_mode == (int)safe_link; -}; - -#endif //BOOST_INTRUSIVE_DOXYGEN_INVOKED - -} //namespace intrusive -} //namespace boost - -#endif //BOOST_INTRUSIVE_LINK_MODE_HPP diff --git a/boost/intrusive/list.hpp b/boost/intrusive/list.hpp deleted file mode 100644 index 297267d..0000000 --- a/boost/intrusive/list.hpp +++ /dev/null @@ -1,1556 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_LIST_HPP -#define BOOST_INTRUSIVE_LIST_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -namespace boost { -namespace intrusive { - -/// @cond - -struct default_list_hook_applier -{ template struct apply{ typedef typename T::default_list_hook type; }; }; - -template<> -struct is_default_hook_tag -{ static const bool value = true; }; - -struct list_defaults -{ - typedef default_list_hook_applier proto_value_traits; - static const bool constant_time_size = true; - typedef std::size_t size_type; - typedef void header_holder_type; -}; - -/// @endcond - -//! The class template list is an intrusive container that mimics most of the -//! interface of std::list as described in the C++ standard. -//! -//! The template parameter \c T is the type to be managed by the container. -//! The user can specify additional options and if no options are provided -//! default options are used. -//! -//! The container supports the following options: -//! \c base_hook<>/member_hook<>/value_traits<>, -//! \c constant_time_size<> and \c size_type<>. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -class list_impl -{ - //Public typedefs - public: - typedef ValueTraits value_traits; - typedef typename value_traits::pointer pointer; - typedef typename value_traits::const_pointer const_pointer; - typedef typename pointer_traits::element_type value_type; - typedef typename pointer_traits::reference reference; - typedef typename pointer_traits::reference const_reference; - typedef typename pointer_traits::difference_type difference_type; - typedef SizeType size_type; - typedef list_iterator iterator; - typedef list_iterator const_iterator; - typedef boost::intrusive::detail::reverse_iterator reverse_iterator; - typedef boost::intrusive::detail::reverse_iteratorconst_reverse_iterator; - typedef typename value_traits::node_traits node_traits; - typedef typename node_traits::node node; - typedef typename node_traits::node_ptr node_ptr; - typedef typename node_traits::const_node_ptr const_node_ptr; - typedef circular_list_algorithms node_algorithms; - typedef HeaderHolder header_holder_type; - - static const bool constant_time_size = ConstantTimeSize; - static const bool stateful_value_traits = detail::is_stateful_value_traits::value; - static const bool has_container_from_iterator = - detail::is_same< header_holder_type, detail::default_header_holder< node_traits > >::value; - - /// @cond - - private: - typedef detail::size_holder size_traits; - - //noncopyable - BOOST_MOVABLE_BUT_NOT_COPYABLE(list_impl) - - static const bool safemode_or_autounlink = is_safe_autounlink::value; - - //Constant-time size is incompatible with auto-unlink hooks! - BOOST_STATIC_ASSERT(!(constant_time_size && - ((int)value_traits::link_mode == (int)auto_unlink) - )); - - node_ptr get_root_node() - { return data_.root_plus_size_.m_header.get_node(); } - - const_node_ptr get_root_node() const - { return data_.root_plus_size_.m_header.get_node(); } - - struct root_plus_size : public size_traits - { - header_holder_type m_header; - }; - - struct data_t : public value_traits - { - typedef typename list_impl::value_traits value_traits; - explicit data_t(const value_traits &val_traits) - : value_traits(val_traits) - {} - - root_plus_size root_plus_size_; - } data_; - - size_traits &priv_size_traits() - { return data_.root_plus_size_; } - - const size_traits &priv_size_traits() const - { return data_.root_plus_size_; } - - const value_traits &priv_value_traits() const - { return data_; } - - value_traits &priv_value_traits() - { return data_; } - - typedef typename boost::intrusive::value_traits_pointers - ::const_value_traits_ptr const_value_traits_ptr; - - const_value_traits_ptr priv_value_traits_ptr() const - { return pointer_traits::pointer_to(this->priv_value_traits()); } - - /// @endcond - - public: - - //! Effects: constructs an empty list. - //! - //! Complexity: Constant - //! - //! Throws: If value_traits::node_traits::node - //! constructor throws (this does not happen with predefined Boost.Intrusive hooks). - explicit list_impl(const value_traits &v_traits = value_traits()) - : data_(v_traits) - { - this->priv_size_traits().set_size(size_type(0)); - node_algorithms::init_header(this->get_root_node()); - } - - //! Requires: Dereferencing iterator must yield an lvalue of type value_type. - //! - //! Effects: Constructs a list equal to the range [first,last). - //! - //! Complexity: Linear in std::distance(b, e). No copy constructors are called. - //! - //! Throws: If value_traits::node_traits::node - //! constructor throws (this does not happen with predefined Boost.Intrusive hooks). - template - list_impl(Iterator b, Iterator e, const value_traits &v_traits = value_traits()) - : data_(v_traits) - { - //nothrow, no need to rollback to release elements on exception - this->priv_size_traits().set_size(size_type(0)); - node_algorithms::init_header(this->get_root_node()); - //nothrow, no need to rollback to release elements on exception - this->insert(this->cend(), b, e); - } - - //! Effects: to-do - //! - list_impl(BOOST_RV_REF(list_impl) x) - : data_(::boost::move(x.priv_value_traits())) - { - this->priv_size_traits().set_size(size_type(0)); - node_algorithms::init_header(this->get_root_node()); - //nothrow, no need to rollback to release elements on exception - this->swap(x); - } - - //! Effects: to-do - //! - list_impl& operator=(BOOST_RV_REF(list_impl) x) - { this->swap(x); return *this; } - - //! Effects: If it's not a safe-mode or an auto-unlink value_type - //! the destructor does nothing - //! (ie. no code is generated). Otherwise it detaches all elements from this. - //! In this case the objects in the list are not deleted (i.e. no destructors - //! are called), but the hooks according to the ValueTraits template parameter - //! are set to their default value. - //! - //! Complexity: Linear to the number of elements in the list, if - //! it's a safe-mode or auto-unlink value . Otherwise constant. - ~list_impl() - { - if(is_safe_autounlink::value){ - this->clear(); - node_algorithms::init(this->get_root_node()); - } - } - - //! Requires: value must be an lvalue. - //! - //! Effects: Inserts the value in the back of the list. - //! No copy constructors are called. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: Does not affect the validity of iterators and references. - void push_back(reference value) - { - node_ptr to_insert = priv_value_traits().to_node_ptr(value); - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert)); - node_algorithms::link_before(this->get_root_node(), to_insert); - this->priv_size_traits().increment(); - } - - //! Requires: value must be an lvalue. - //! - //! Effects: Inserts the value in the front of the list. - //! No copy constructors are called. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: Does not affect the validity of iterators and references. - void push_front(reference value) - { - node_ptr to_insert = priv_value_traits().to_node_ptr(value); - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert)); - node_algorithms::link_before(node_traits::get_next(this->get_root_node()), to_insert); - this->priv_size_traits().increment(); - } - - //! Effects: Erases the last element of the list. - //! No destructors are called. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: Invalidates the iterators (but not the references) to the erased element. - void pop_back() - { return this->pop_back_and_dispose(detail::null_disposer()); } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases the last element of the list. - //! No destructors are called. - //! Disposer::operator()(pointer) is called for the removed element. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: Invalidates the iterators to the erased element. - template - void pop_back_and_dispose(Disposer disposer) - { - node_ptr to_erase = node_traits::get_previous(this->get_root_node()); - node_algorithms::unlink(to_erase); - this->priv_size_traits().decrement(); - if(safemode_or_autounlink) - node_algorithms::init(to_erase); - disposer(priv_value_traits().to_value_ptr(to_erase)); - } - - //! Effects: Erases the first element of the list. - //! No destructors are called. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: Invalidates the iterators (but not the references) to the erased element. - void pop_front() - { return this->pop_front_and_dispose(detail::null_disposer()); } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases the first element of the list. - //! No destructors are called. - //! Disposer::operator()(pointer) is called for the removed element. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: Invalidates the iterators to the erased element. - template - void pop_front_and_dispose(Disposer disposer) - { - node_ptr to_erase = node_traits::get_next(this->get_root_node()); - node_algorithms::unlink(to_erase); - this->priv_size_traits().decrement(); - if(safemode_or_autounlink) - node_algorithms::init(to_erase); - disposer(priv_value_traits().to_value_ptr(to_erase)); - } - - //! Effects: Returns a reference to the first element of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference front() - { return *priv_value_traits().to_value_ptr(node_traits::get_next(this->get_root_node())); } - - //! Effects: Returns a const_reference to the first element of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference front() const - { return *priv_value_traits().to_value_ptr(detail::uncast(node_traits::get_next(this->get_root_node()))); } - - //! Effects: Returns a reference to the last element of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reference back() - { return *priv_value_traits().to_value_ptr(node_traits::get_previous(this->get_root_node())); } - - //! Effects: Returns a const_reference to the last element of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reference back() const - { return *priv_value_traits().to_value_ptr(detail::uncast(node_traits::get_previous(this->get_root_node()))); } - - //! Effects: Returns an iterator to the first element contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator begin() - { return iterator(node_traits::get_next(this->get_root_node()), this->priv_value_traits_ptr()); } - - //! Effects: Returns a const_iterator to the first element contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator begin() const - { return this->cbegin(); } - - //! Effects: Returns a const_iterator to the first element contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cbegin() const - { return const_iterator(node_traits::get_next(this->get_root_node()), this->priv_value_traits_ptr()); } - - //! Effects: Returns an iterator to the end of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - iterator end() - { return iterator(this->get_root_node(), this->priv_value_traits_ptr()); } - - //! Effects: Returns a const_iterator to the end of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator end() const - { return this->cend(); } - - //! Effects: Returns a constant iterator to the end of the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_iterator cend() const - { return const_iterator(detail::uncast(this->get_root_node()), this->priv_value_traits_ptr()); } - - //! Effects: Returns a reverse_iterator pointing to the beginning - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rbegin() - { return reverse_iterator(this->end()); } - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rbegin() const - { return this->crbegin(); } - - //! Effects: Returns a const_reverse_iterator pointing to the beginning - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crbegin() const - { return const_reverse_iterator(end()); } - - //! Effects: Returns a reverse_iterator pointing to the end - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - reverse_iterator rend() - { return reverse_iterator(begin()); } - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator rend() const - { return this->crend(); } - - //! Effects: Returns a const_reverse_iterator pointing to the end - //! of the reversed list. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - const_reverse_iterator crend() const - { return const_reverse_iterator(this->begin()); } - - //! Precondition: end_iterator must be a valid end iterator - //! of list. - //! - //! Effects: Returns a const reference to the list associated to the end iterator - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - static list_impl &container_from_end_iterator(iterator end_iterator) - { return list_impl::priv_container_from_end_iterator(end_iterator); } - - //! Precondition: end_iterator must be a valid end const_iterator - //! of list. - //! - //! Effects: Returns a const reference to the list associated to the end iterator - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - static const list_impl &container_from_end_iterator(const_iterator end_iterator) - { return list_impl::priv_container_from_end_iterator(end_iterator); } - - //! Effects: Returns the number of the elements contained in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements contained in the list. - //! if constant-time size option is disabled. Constant time otherwise. - //! - //! Note: Does not affect the validity of iterators and references. - size_type size() const - { - if(constant_time_size) - return this->priv_size_traits().get_size(); - else - return node_algorithms::count(this->get_root_node()) - 1; - } - - //! Effects: Returns true if the list contains no elements. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: Does not affect the validity of iterators and references. - bool empty() const - { return node_algorithms::unique(this->get_root_node()); } - - //! Effects: Swaps the elements of x and *this. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: Does not affect the validity of iterators and references. - void swap(list_impl& other) - { - node_algorithms::swap_nodes(this->get_root_node(), other.get_root_node()); - 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()); - other.priv_size_traits().set_size(backup); - } - } - - //! Effects: Moves backwards all the elements, so that the first - //! element becomes the second, the second becomes the third... - //! the last element becomes the first one. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of shifts. - //! - //! Note: Does not affect the validity of iterators and references. - void shift_backwards(size_type n = 1) - { node_algorithms::move_forward(this->get_root_node(), n); } - - //! Effects: Moves forward all the elements, so that the second - //! element becomes the first, the third becomes the second... - //! the first element becomes the last one. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of shifts. - //! - //! Note: Does not affect the validity of iterators and references. - void shift_forward(size_type n = 1) - { node_algorithms::move_backwards(this->get_root_node(), n); } - - //! Effects: Erases the element pointed by i of the list. - //! No destructors are called. - //! - //! Returns: the first element remaining beyond the removed element, - //! or end() if no such element exists. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: Invalidates the iterators (but not the references) to the - //! erased element. - iterator erase(const_iterator i) - { return this->erase_and_dispose(i, detail::null_disposer()); } - - //! Requires: b and e must be valid iterators to elements in *this. - //! - //! Effects: Erases the element range pointed by b and e - //! No destructors are called. - //! - //! Returns: the first element remaining beyond the removed elements, - //! or end() if no such element exists. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of erased elements if it's a safe-mode - //! or auto-unlink value, or constant-time size is enabled. Constant-time otherwise. - //! - //! Note: Invalidates the iterators (but not the references) to the - //! erased elements. - iterator erase(const_iterator b, const_iterator e) - { - if(safemode_or_autounlink || constant_time_size){ - return this->erase_and_dispose(b, e, detail::null_disposer()); - } - else{ - node_algorithms::unlink(b.pointed_node(), e.pointed_node()); - return e.unconst(); - } - } - - //! Requires: b and e must be valid iterators to elements in *this. - //! n must be std::distance(b, e). - //! - //! Effects: Erases the element range pointed by b and e - //! No destructors are called. - //! - //! Returns: the first element remaining beyond the removed elements, - //! or end() if no such element exists. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of erased elements if it's a safe-mode - //! or auto-unlink value is enabled. Constant-time otherwise. - //! - //! Note: Invalidates the iterators (but not the references) to the - //! erased elements. - iterator erase(const_iterator b, const_iterator e, size_type n) - { - BOOST_INTRUSIVE_INVARIANT_ASSERT(node_algorithms::distance(b.pointed_node(), e.pointed_node()) == n); - if(safemode_or_autounlink || constant_time_size){ - return this->erase_and_dispose(b, e, detail::null_disposer()); - } - else{ - if(constant_time_size){ - this->priv_size_traits().decrease(n); - } - node_algorithms::unlink(b.pointed_node(), e.pointed_node()); - return e.unconst(); - } - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases the element pointed by i of the list. - //! No destructors are called. - //! Disposer::operator()(pointer) is called for the removed element. - //! - //! Returns: the first element remaining beyond the removed element, - //! or end() if no such element exists. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: Invalidates the iterators to the erased element. - template - iterator erase_and_dispose(const_iterator i, Disposer disposer) - { - node_ptr to_erase(i.pointed_node()); - ++i; - node_algorithms::unlink(to_erase); - this->priv_size_traits().decrement(); - if(safemode_or_autounlink) - node_algorithms::init(to_erase); - disposer(this->priv_value_traits().to_value_ptr(to_erase)); - return i.unconst(); - } - - #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - template - iterator erase_and_dispose(iterator i, Disposer disposer) - { return this->erase_and_dispose(const_iterator(i), disposer); } - #endif - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases the element range pointed by b and e - //! No destructors are called. - //! Disposer::operator()(pointer) is called for the removed elements. - //! - //! Returns: the first element remaining beyond the removed elements, - //! or end() if no such element exists. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements erased. - //! - //! Note: Invalidates the iterators to the erased elements. - template - iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) - { - node_ptr bp(b.pointed_node()), ep(e.pointed_node()); - node_algorithms::unlink(bp, ep); - while(bp != ep){ - node_ptr to_erase(bp); - bp = node_traits::get_next(bp); - if(safemode_or_autounlink) - node_algorithms::init(to_erase); - disposer(priv_value_traits().to_value_ptr(to_erase)); - this->priv_size_traits().decrement(); - } - return e.unconst(); - } - - //! Effects: Erases all the elements of the container. - //! No destructors are called. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements of the list. - //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. - //! - //! Note: Invalidates the iterators (but not the references) to the erased elements. - void clear() - { - if(safemode_or_autounlink){ - this->clear_and_dispose(detail::null_disposer()); - } - else{ - node_algorithms::init_header(this->get_root_node()); - this->priv_size_traits().set_size(size_type(0)); - } - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Erases all the elements of the container. - //! No destructors are called. - //! Disposer::operator()(pointer) is called for the removed elements. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements of the list. - //! - //! Note: Invalidates the iterators to the erased elements. - template - void clear_and_dispose(Disposer disposer) - { - const_iterator it(this->begin()), itend(this->end()); - while(it != itend){ - node_ptr to_erase(it.pointed_node()); - ++it; - if(safemode_or_autounlink) - node_algorithms::init(to_erase); - disposer(priv_value_traits().to_value_ptr(to_erase)); - } - node_algorithms::init_header(this->get_root_node()); - this->priv_size_traits().set_size(0); - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! Cloner should yield to nodes equivalent to the original nodes. - //! - //! Effects: Erases all the elements from *this - //! calling Disposer::operator()(pointer), clones all the - //! elements from src calling Cloner::operator()(const_reference ) - //! and inserts them on *this. - //! - //! If cloner throws, all cloned elements are unlinked and disposed - //! calling Disposer::operator()(pointer). - //! - //! Complexity: Linear to erased plus inserted elements. - //! - //! Throws: If cloner throws. Basic guarantee. - template - void clone_from(const list_impl &src, Cloner cloner, Disposer disposer) - { - this->clear_and_dispose(disposer); - detail::exception_disposer - rollback(*this, disposer); - const_iterator b(src.begin()), e(src.end()); - for(; b != e; ++b){ - this->push_back(*cloner(*b)); - } - rollback.release(); - } - - //! Requires: value must be an lvalue and p must be a valid iterator of *this. - //! - //! Effects: Inserts the value before the position pointed by p. - //! - //! Returns: An iterator to the inserted element. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant time. No copy constructors are called. - //! - //! Note: Does not affect the validity of iterators and references. - iterator insert(const_iterator p, reference value) - { - node_ptr to_insert = this->priv_value_traits().to_node_ptr(value); - if(safemode_or_autounlink) - BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert)); - node_algorithms::link_before(p.pointed_node(), to_insert); - this->priv_size_traits().increment(); - return iterator(to_insert, this->priv_value_traits_ptr()); - } - - //! Requires: Dereferencing iterator must yield - //! an lvalue of type value_type and p must be a valid iterator of *this. - //! - //! Effects: Inserts the range pointed by b and e before the position p. - //! No copy constructors are called. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements inserted. - //! - //! Note: Does not affect the validity of iterators and references. - template - void insert(const_iterator p, Iterator b, Iterator e) - { - for (; b != e; ++b) - this->insert(p, *b); - } - - //! Requires: Dereferencing iterator must yield - //! an lvalue of type value_type. - //! - //! Effects: Clears the list and inserts the range pointed by b and e. - //! No destructors or copy constructors are called. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements inserted plus - //! linear to the elements contained in the list if it's a safe-mode - //! or auto-unlink value. - //! Linear to the number of elements inserted in the list otherwise. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. - template - void assign(Iterator b, Iterator e) - { - this->clear(); - this->insert(this->cend(), b, e); - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Requires: Dereferencing iterator must yield - //! an lvalue of type value_type. - //! - //! Effects: Clears the list and inserts the range pointed by b and e. - //! No destructors or copy constructors are called. - //! Disposer::operator()(pointer) is called for the removed elements. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements inserted plus - //! linear to the elements contained in the list. - //! - //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. - template - void dispose_and_assign(Disposer disposer, Iterator b, Iterator e) - { - this->clear_and_dispose(disposer); - this->insert(this->cend(), b, e); - } - - //! Requires: p must be a valid iterator of *this. - //! - //! Effects: Transfers all the elements of list x to this list, before the - //! the element pointed by p. No destructors or copy constructors are called. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: 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, list_impl& x) - { - if(!x.empty()){ - node_algorithms::transfer - (p.pointed_node(), x.begin().pointed_node(), x.end().pointed_node()); - size_traits &thist = this->priv_size_traits(); - size_traits &xt = x.priv_size_traits(); - thist.increase(xt.get_size()); - xt.set_size(size_type(0)); - } - } - - //! Requires: p must be a valid iterator of *this. - //! new_ele must point to an element contained in list x. - //! - //! Effects: Transfers the value pointed by new_ele, from list x to this list, - //! before the element pointed by p. No destructors or copy constructors are called. - //! If p == new_ele or p == ++new_ele, this function is a null operation. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: 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, list_impl&x, const_iterator new_ele) - { - node_algorithms::transfer(p.pointed_node(), new_ele.pointed_node()); - x.priv_size_traits().decrement(); - this->priv_size_traits().increment(); - } - - //! Requires: p must be a valid iterator of *this. - //! f and e must point to elements contained in list x. - //! - //! Effects: Transfers the range pointed by f and e from list x to this list, - //! before the element pointed by p. No destructors or copy constructors are called. - //! - //! Throws: Nothing. - //! - //! Complexity: Linear to the number of elements transferred - //! if constant-time size option is enabled. Constant-time otherwise. - //! - //! Note: 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, list_impl&x, const_iterator f, const_iterator e) - { - if(constant_time_size) - this->splice(p, x, f, e, node_algorithms::distance(f.pointed_node(), e.pointed_node())); - else - this->splice(p, x, f, e, 1);//distance is a dummy value - } - - //! Requires: p must be a valid iterator of *this. - //! f and e must point to elements contained in list x. - //! n == std::distance(f, e) - //! - //! Effects: Transfers the range pointed by f and e from list x to this list, - //! before the element pointed by p. No destructors or copy constructors are called. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant. - //! - //! Note: 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, list_impl&x, const_iterator f, const_iterator e, size_type n) - { - if(n){ - if(constant_time_size){ - BOOST_INTRUSIVE_INVARIANT_ASSERT(n == node_algorithms::distance(f.pointed_node(), e.pointed_node())); - node_algorithms::transfer(p.pointed_node(), f.pointed_node(), e.pointed_node()); - size_traits &thist = this->priv_size_traits(); - size_traits &xt = x.priv_size_traits(); - thist.increase(n); - xt.decrease(n); - } - else{ - node_algorithms::transfer(p.pointed_node(), f.pointed_node(), e.pointed_node()); - } - } - } - - //! Effects: This function sorts the list *this according to std::less. - //! The sort is stable, that is, the relative order of equivalent elements is preserved. - //! - //! Throws: If value_traits::node_traits::node - //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) - //! or std::less throws. Basic guarantee. - //! - //! Notes: Iterators and references are not invalidated. - //! - //! Complexity: The number of comparisons is approximately N log N, where N - //! is the list's size. - void sort() - { this->sort(std::less()); } - - //! Requires: p must be a comparison function that induces a strict weak ordering - //! - //! Effects: This function sorts the list *this according to p. The sort is - //! stable, that is, the relative order of equivalent elements is preserved. - //! - //! Throws: If value_traits::node_traits::node - //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) - //! or the predicate throws. Basic guarantee. - //! - //! Notes: This won't throw if list_base_hook<> or - //! list_member_hook are used. - //! Iterators and references are not invalidated. - //! - //! Complexity: The number of comparisons is approximately N log N, where N - //! is the list's size. - template - void sort(Predicate p) - { - if(node_traits::get_next(this->get_root_node()) - != node_traits::get_previous(this->get_root_node())){ - list_impl carry(this->priv_value_traits()); - detail::array_initializer counter(this->priv_value_traits()); - int fill = 0; - while(!this->empty()){ - carry.splice(carry.cbegin(), *this, this->cbegin()); - int i = 0; - while(i < fill && !counter[i].empty()) { - counter[i].merge(carry, p); - carry.swap(counter[i++]); - } - carry.swap(counter[i]); - if(i == fill) - ++fill; - } - for (int i = 1; i < fill; ++i) - counter[i].merge(counter[i-1], p); - this->swap(counter[fill-1]); - } - } - - //! Effects: This function removes all of x's elements and inserts them - //! in order into *this according to std::less. 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. - //! - //! Throws: If std::less throws. Basic guarantee. - //! - //! Complexity: This function is linear time: it performs at most - //! size() + x.size() - 1 comparisons. - //! - //! Note: Iterators and references are not invalidated - void merge(list_impl& x) - { this->merge(x, std::less()); } - - //! Requires: 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. - //! - //! Effects: 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. - //! - //! Throws: If the predicate throws. Basic guarantee. - //! - //! Complexity: This function is linear time: it performs at most - //! size() + x.size() - 1 comparisons. - //! - //! Note: Iterators and references are not invalidated. - template - void merge(list_impl& x, Predicate p) - { - const_iterator e(this->cend()), ex(x.cend()); - const_iterator b(this->cbegin()); - while(!x.empty()){ - const_iterator ix(x.cbegin()); - while (b != e && !p(*ix, *b)){ - ++b; - } - if(b == e){ - //Now transfer the rest to the end of the container - this->splice(e, x); - break; - } - else{ - size_type n(0); - do{ - ++ix; ++n; - } while(ix != ex && p(*ix, *b)); - this->splice(b, x, x.begin(), ix, n); - } - } - } - - //! Effects: Reverses the order of elements in the list. - //! - //! Throws: Nothing. - //! - //! Complexity: This function is linear time. - //! - //! Note: Iterators and references are not invalidated - void reverse() - { node_algorithms::reverse(this->get_root_node()); } - - //! Effects: Removes all the elements that compare equal to value. - //! No destructors are called. - //! - //! Throws: If std::equal_to throws. Basic guarantee. - //! - //! Complexity: Linear time. It performs exactly size() comparisons for equality. - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - void remove(const_reference value) - { this->remove_if(detail::equal_to_value(value)); } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Removes all the elements that compare equal to value. - //! Disposer::operator()(pointer) is called for every removed element. - //! - //! Throws: If std::equal_to throws. Basic guarantee. - //! - //! Complexity: Linear time. It performs exactly size() comparisons for equality. - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - template - void remove_and_dispose(const_reference value, Disposer disposer) - { this->remove_and_dispose_if(detail::equal_to_value(value), disposer); } - - //! Effects: Removes all the elements for which a specified - //! predicate is satisfied. No destructors are called. - //! - //! Throws: If pred throws. Basic guarantee. - //! - //! Complexity: Linear time. It performs exactly size() calls to the predicate. - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - template - void remove_if(Pred pred) - { - const node_ptr root_node = this->get_root_node(); - typename node_algorithms::stable_partition_info info; - node_algorithms::stable_partition - (node_traits::get_next(root_node), root_node, detail::key_nodeptr_comp(pred, &this->priv_value_traits()), info); - //Invariants preserved by stable_partition so erase can be safely called - //The first element might have changed so calculate it again - this->erase( const_iterator(node_traits::get_next(root_node), this->priv_value_traits_ptr()) - , const_iterator(info.beg_2st_partition, this->priv_value_traits_ptr()) - , info.num_1st_partition); - } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Removes all the elements for which a specified - //! predicate is satisfied. - //! Disposer::operator()(pointer) is called for every removed element. - //! - //! Throws: If pred throws. Basic guarantee. - //! - //! Complexity: Linear time. It performs exactly size() comparisons for equality. - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - template - void remove_and_dispose_if(Pred pred, Disposer disposer) - { - const node_ptr root_node = this->get_root_node(); - typename node_algorithms::stable_partition_info info; - node_algorithms::stable_partition - (node_traits::get_next(root_node), root_node, detail::key_nodeptr_comp(pred, &this->priv_value_traits()), info); - //Invariants preserved by stable_partition so erase can be safely called - //The first element might have changed so calculate it again - this->erase_and_dispose( const_iterator(node_traits::get_next(root_node), this->priv_value_traits_ptr()) - , const_iterator(info.beg_2st_partition, this->priv_value_traits_ptr()) - , disposer); - } - - //! Effects: Removes adjacent duplicate elements or adjacent - //! elements that are equal from the list. No destructors are called. - //! - //! Throws: If std::equal_toComplexity: Linear time (size()-1 comparisons calls to pred()). - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - void unique() - { this->unique_and_dispose(std::equal_to(), detail::null_disposer()); } - - //! Effects: Removes adjacent duplicate elements or adjacent - //! elements that satisfy some binary predicate from the list. - //! No destructors are called. - //! - //! Throws: If pred throws. Basic guarantee. - //! - //! Complexity: Linear time (size()-1 comparisons equality comparisons). - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - template - void unique(BinaryPredicate pred) - { this->unique_and_dispose(pred, detail::null_disposer()); } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Removes adjacent duplicate elements or adjacent - //! elements that are equal from the list. - //! Disposer::operator()(pointer) is called for every removed element. - //! - //! Throws: If std::equal_toComplexity: Linear time (size()-1) comparisons equality comparisons. - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - template - void unique_and_dispose(Disposer disposer) - { this->unique_and_dispose(std::equal_to(), disposer); } - - //! Requires: Disposer::operator()(pointer) shouldn't throw. - //! - //! Effects: Removes adjacent duplicate elements or adjacent - //! elements that satisfy some binary predicate from the list. - //! Disposer::operator()(pointer) is called for every removed element. - //! - //! Throws: If pred throws. Basic guarantee. - //! - //! Complexity: Linear time (size()-1) comparisons equality comparisons. - //! - //! Note: The relative order of elements that are not removed is unchanged, - //! and iterators to elements that are not removed remain valid. - template - void unique_and_dispose(BinaryPredicate pred, Disposer disposer) - { - const_iterator itend(this->cend()); - const_iterator cur(this->cbegin()); - - if(cur != itend){ - const_iterator after(cur); - ++after; - while(after != itend){ - if(pred(*cur, *after)){ - after = this->erase_and_dispose(after, disposer); - } - else{ - cur = after; - ++after; - } - } - } - } - - //! Requires: value must be a reference to a value inserted in a list. - //! - //! Effects: This function returns a const_iterator pointing to the element - //! - //! Throws: Nothing. - //! - //! Complexity: Constant time. - //! - //! Note: Iterators and references are not invalidated. - //! This static function is available only if the value traits - //! is stateless. - static iterator s_iterator_to(reference value) - { - BOOST_STATIC_ASSERT((!stateful_value_traits)); - BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(value_traits::to_node_ptr(value))); - return iterator(value_traits::to_node_ptr(value), const_value_traits_ptr()); - } - - //! Requires: value must be a const reference to a value inserted in a list. - //! - //! Effects: This function returns an iterator pointing to the element. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant time. - //! - //! Note: Iterators and references are not invalidated. - //! This static function is available only if the value traits - //! is stateless. - static const_iterator s_iterator_to(const_reference value) - { - BOOST_STATIC_ASSERT((!stateful_value_traits)); - reference r =*pointer_traits::const_cast_from(pointer_traits::pointer_to(value)); - BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(value_traits::to_node_ptr(r))); - return const_iterator(value_traits::to_node_ptr(r), const_value_traits_ptr()); - } - - //! Requires: value must be a reference to a value inserted in a list. - //! - //! Effects: This function returns a const_iterator pointing to the element - //! - //! Throws: Nothing. - //! - //! Complexity: Constant time. - //! - //! Note: Iterators and references are not invalidated. - iterator iterator_to(reference value) - { - BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(this->priv_value_traits().to_node_ptr(value))); - return iterator(this->priv_value_traits().to_node_ptr(value), this->priv_value_traits_ptr()); - } - - //! Requires: value must be a const reference to a value inserted in a list. - //! - //! Effects: This function returns an iterator pointing to the element. - //! - //! Throws: Nothing. - //! - //! Complexity: Constant time. - //! - //! Note: Iterators and references are not invalidated. - const_iterator iterator_to(const_reference value) const - { - reference r = *pointer_traits::const_cast_from(pointer_traits::pointer_to(value)); - BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(this->priv_value_traits().to_node_ptr(r))); - return const_iterator(this->priv_value_traits().to_node_ptr(r), this->priv_value_traits_ptr()); - } - - //! Effects: Asserts the integrity of the container. - //! - //! Complexity: Linear time. - //! - //! Note: The method has no effect when asserts are turned off (e.g., with NDEBUG). - //! Experimental function, interface might change in future versions. - void check() const - { - const_node_ptr header_ptr = get_root_node(); - // header's next and prev are never null - BOOST_INTRUSIVE_INVARIANT_ASSERT(node_traits::get_next(header_ptr)); - BOOST_INTRUSIVE_INVARIANT_ASSERT(node_traits::get_previous(header_ptr)); - // header's next and prev either both point to header (empty list) or neither does - BOOST_INTRUSIVE_INVARIANT_ASSERT((node_traits::get_next(header_ptr) == header_ptr) - == (node_traits::get_previous(header_ptr) == header_ptr)); - if (node_traits::get_next(header_ptr) == header_ptr) - { - if (constant_time_size) - BOOST_INTRUSIVE_INVARIANT_ASSERT(this->priv_size_traits().get_size() == 0); - return; - } - size_t node_count = 0; - const_node_ptr p = header_ptr; - while (true) - { - const_node_ptr next_p = node_traits::get_next(p); - BOOST_INTRUSIVE_INVARIANT_ASSERT(next_p); - BOOST_INTRUSIVE_INVARIANT_ASSERT(node_traits::get_previous(next_p) == p); - p = next_p; - if (p == header_ptr) break; - ++node_count; - } - if (constant_time_size) - BOOST_INTRUSIVE_INVARIANT_ASSERT(this->priv_size_traits().get_size() == node_count); - } - - /// @cond - - private: - static list_impl &priv_container_from_end_iterator(const const_iterator &end_iterator) - { - BOOST_STATIC_ASSERT((has_container_from_iterator)); - node_ptr p = end_iterator.pointed_node(); - header_holder_type* h = header_holder_type::get_holder(p); - root_plus_size* r = detail::parent_from_member - < root_plus_size, header_holder_type>(h, &root_plus_size::m_header); - data_t *d = detail::parent_from_member - ( r, &data_t::root_plus_size_); - list_impl *s = detail::parent_from_member(d, &list_impl::data_); - return *s; - } - /// @endcond -}; - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline bool operator< -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const list_impl &x, const list_impl &y) -#else -(const list_impl &x, const list_impl &y) -#endif -{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -bool operator== -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const list_impl &x, const list_impl &y) -#else -(const list_impl &x, const list_impl &y) -#endif -{ - typedef list_impl list_type; - typedef typename list_type::const_iterator const_iterator; - const bool C = list_type::constant_time_size; - if(C && x.size() != y.size()){ - return false; - } - const_iterator end1 = x.end(); - - const_iterator i1 = x.begin(); - const_iterator i2 = y.begin(); - if(C){ - while (i1 != end1 && *i1 == *i2) { - ++i1; - ++i2; - } - return i1 == end1; - } - else{ - const_iterator end2 = y.end(); - while (i1 != end1 && i2 != end2 && *i1 == *i2) { - ++i1; - ++i2; - } - return i1 == end1 && i2 == end2; - } -} - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline bool operator!= -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const list_impl &x, const list_impl &y) -#else -(const list_impl &x, const list_impl &y) -#endif -{ return !(x == y); } - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline bool operator> -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const list_impl &x, const list_impl &y) -#else -(const list_impl &x, const list_impl &y) -#endif -{ return y < x; } - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline bool operator<= -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const list_impl &x, const list_impl &y) -#else -(const list_impl &x, const list_impl &y) -#endif -{ return !(y < x); } - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline bool operator>= -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(const list_impl &x, const list_impl &y) -#else -(const list_impl &x, const list_impl &y) -#endif -{ return !(x < y); } - -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -template -#else -template -#endif -inline void swap -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) -(list_impl &x, list_impl &y) -#else -(list_impl &x, list_impl &y) -#endif -{ x.swap(y); } - -//! Helper metafunction to define a \c list that yields to the same type when the -//! same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_list -{ - /// @cond - typedef typename pack_options - < list_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3, O4 - #else - Options... - #endif - >::type packed_options; - - typedef typename detail::get_value_traits - ::type value_traits; - typedef typename detail::get_header_holder_type - < value_traits, typename packed_options::header_holder_type >::type header_holder_type; - - typedef list_impl - < - value_traits, - typename packed_options::size_type, - packed_options::constant_time_size, - header_holder_type - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - - -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class list - : public make_list::type -{ - typedef typename make_list - ::type Base; - //Assert if passed value traits are compatible with the type - BOOST_STATIC_ASSERT((detail::is_same::value)); - BOOST_MOVABLE_BUT_NOT_COPYABLE(list) - - public: - typedef typename Base::value_traits value_traits; - typedef typename Base::iterator iterator; - typedef typename Base::const_iterator const_iterator; - - explicit list(const value_traits &v_traits = value_traits()) - : Base(v_traits) - {} - - template - list(Iterator b, Iterator e, const value_traits &v_traits = value_traits()) - : Base(b, e, v_traits) - {} - - list(BOOST_RV_REF(list) x) - : Base(::boost::move(static_cast(x))) - {} - - list& operator=(BOOST_RV_REF(list) x) - { return static_cast(this->Base::operator=(::boost::move(static_cast(x)))); } - - static list &container_from_end_iterator(iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } - - static const list &container_from_end_iterator(const_iterator end_iterator) - { return static_cast(Base::container_from_end_iterator(end_iterator)); } -}; - -#endif - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_LIST_HPP diff --git a/boost/intrusive/list_hook.hpp b/boost/intrusive/list_hook.hpp deleted file mode 100644 index 1a06a98..0000000 --- a/boost/intrusive/list_hook.hpp +++ /dev/null @@ -1,286 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztanaga 2006-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_LIST_HOOK_HPP -#define BOOST_INTRUSIVE_LIST_HOOK_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -//! Helper metafunction to define a \c \c list_base_hook that yields to the same -//! type when the same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_list_base_hook -{ - /// @cond - typedef typename pack_options - < hook_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3 - #else - Options... - #endif - >::type packed_options; - - typedef generic_hook - < circular_list_algorithms > - , typename packed_options::tag - , packed_options::link_mode - , ListBaseHookId - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -//! Derive a class from this hook in order to store objects of that class -//! in an list. -//! -//! The hook admits the following options: \c tag<>, \c void_pointer<> and -//! \c link_mode<>. -//! -//! \c tag<> defines a tag to identify the node. -//! The same tag value can be used in different classes, but if a class is -//! derived from more than one \c list_base_hook, then each \c list_base_hook needs its -//! unique tag. -//! -//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, -//! \c auto_unlink or \c safe_link). -//! -//! \c void_pointer<> is the pointer type that will be used internally in the hook -//! and the container configured to use this hook. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class list_base_hook - : public make_list_base_hook - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - - #else - - #endif - ::type -{ - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - public: - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. - //! - //! Throws: Nothing. - list_base_hook(); - - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing a copy-constructor - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - list_base_hook(const list_base_hook& ); - - //! Effects: Empty function. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing an assignment operator - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - list_base_hook& operator=(const list_base_hook& ); - - //! Effects: If link_mode is \c normal_link, the destructor does - //! nothing (ie. no code is generated). If link_mode is \c safe_link and the - //! object is stored in an list an assertion is raised. If link_mode is - //! \c auto_unlink and \c is_linked() is true, the node is unlinked. - //! - //! Throws: Nothing. - ~list_base_hook(); - - //! Effects: Swapping two nodes swaps the position of the elements - //! related to those nodes in one or two containers. That is, if the node - //! this is part of the element e1, the node x is part of the element e2 - //! and both elements are included in the containers s1 and s2, then after - //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 - //! at the position of e1. If one element is not in a container, then - //! after the swap-operation the other element is not in a container. - //! Iterators to e1 and e2 related to those nodes are invalidated. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - void swap_nodes(list_base_hook &other); - - //! Precondition: link_mode must be \c safe_link or \c auto_unlink. - //! - //! Returns: true, if the node belongs to a container, false - //! otherwise. This function can be used to test whether \c list::iterator_to - //! will return a valid iterator. - //! - //! Complexity: Constant - bool is_linked() const; - - //! Effects: Removes the node if it's inserted in a container. - //! This function is only allowed if link_mode is \c auto_unlink. - //! - //! Throws: Nothing. - void unlink(); - #endif -}; - -//! Helper metafunction to define a \c \c list_member_hook that yields to the same -//! type when the same options (either explicitly or implicitly) are used. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -struct make_list_member_hook -{ - /// @cond - typedef typename pack_options - < hook_defaults, - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - O1, O2, O3 - #else - Options... - #endif - >::type packed_options; - - typedef generic_hook - < circular_list_algorithms > - , member_tag - , packed_options::link_mode - , NoBaseHookId - > implementation_defined; - /// @endcond - typedef implementation_defined type; -}; - -//! Store this hook in a class to be inserted -//! in an list. -//! -//! The hook admits the following options: \c void_pointer<> and -//! \c link_mode<>. -//! -//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, -//! \c auto_unlink or \c safe_link). -//! -//! \c void_pointer<> is the pointer type that will be used internally in the hook -//! and the container configured to use this hook. -#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) -template -#else -template -#endif -class list_member_hook - : public make_list_member_hook - #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - - #else - - #endif - ::type -{ - #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) - public: - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. - //! - //! Throws: Nothing. - list_member_hook(); - - //! Effects: If link_mode is \c auto_unlink or \c safe_link - //! initializes the node to an unlinked state. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing a copy-constructor - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - list_member_hook(const list_member_hook& ); - - //! Effects: Empty function. The argument is ignored. - //! - //! Throws: Nothing. - //! - //! Rationale: Providing an assignment operator - //! makes classes using the hook STL-compliant without forcing the - //! user to do some additional work. \c swap can be used to emulate - //! move-semantics. - list_member_hook& operator=(const list_member_hook& ); - - //! Effects: If link_mode is \c normal_link, the destructor does - //! nothing (ie. no code is generated). If link_mode is \c safe_link and the - //! object is stored in an list an assertion is raised. If link_mode is - //! \c auto_unlink and \c is_linked() is true, the node is unlinked. - //! - //! Throws: Nothing. - ~list_member_hook(); - - //! Effects: Swapping two nodes swaps the position of the elements - //! related to those nodes in one or two containers. That is, if the node - //! this is part of the element e1, the node x is part of the element e2 - //! and both elements are included in the containers s1 and s2, then after - //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 - //! at the position of e1. If one element is not in a container, then - //! after the swap-operation the other element is not in a container. - //! Iterators to e1 and e2 related to those nodes are invalidated. - //! - //! Complexity: Constant - //! - //! Throws: Nothing. - void swap_nodes(list_member_hook &other); - - //! Precondition: link_mode must be \c safe_link or \c auto_unlink. - //! - //! Returns: true, if the node belongs to a container, false - //! otherwise. This function can be used to test whether \c list::iterator_to - //! will return a valid iterator. - //! - //! Complexity: Constant - bool is_linked() const; - - //! Effects: Removes the node if it's inserted in a container. - //! This function is only allowed if link_mode is \c auto_unlink. - //! - //! Throws: Nothing. - void unlink(); - #endif -}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_LIST_HOOK_HPP diff --git a/boost/intrusive/member_value_traits.hpp b/boost/intrusive/member_value_traits.hpp deleted file mode 100644 index 96c50ee..0000000 --- a/boost/intrusive/member_value_traits.hpp +++ /dev/null @@ -1,84 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2006-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_MEMBER_VALUE_TRAITS_HPP -#define BOOST_INTRUSIVE_MEMBER_VALUE_TRAITS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include -#include -#include - -namespace boost { -namespace intrusive { - -//!This value traits template is used to create value traits -//!from user defined node traits where value_traits::value_type will -//!store a node_traits::node -template< class T, class NodeTraits - , typename NodeTraits::node T::* PtrToMember - , link_mode_type LinkMode - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - = safe_link - #endif -> -struct member_value_traits -{ - public: - typedef NodeTraits node_traits; - typedef T value_type; - typedef typename node_traits::node node; - typedef typename node_traits::node_ptr node_ptr; - typedef typename node_traits::const_node_ptr const_node_ptr; - typedef pointer_traits node_ptr_traits; - typedef typename pointer_traits::template - rebind_pointer::type pointer; - typedef typename pointer_traits::template - rebind_pointer::type const_pointer; - //typedef typename pointer_traits::reference reference; - //typedef typename pointer_traits::reference const_reference; - typedef value_type & reference; - typedef const value_type & const_reference; - static const link_mode_type link_mode = LinkMode; - - static node_ptr to_node_ptr(reference value) - { return pointer_traits::pointer_to(value.*PtrToMember); } - - static const_node_ptr to_node_ptr(const_reference value) - { return pointer_traits::pointer_to(value.*PtrToMember); } - - static pointer to_value_ptr(const node_ptr &n) - { - return pointer_traits::pointer_to(*detail::parent_from_member - (boost::intrusive::detail::to_raw_pointer(n), PtrToMember)); - } - - static const_pointer to_value_ptr(const const_node_ptr &n) - { - return pointer_traits::pointer_to(*detail::parent_from_member - (boost::intrusive::detail::to_raw_pointer(n), PtrToMember)); - - } -}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_MEMBER_VALUE_TRAITS_HPP diff --git a/boost/intrusive/options.hpp b/boost/intrusive/options.hpp deleted file mode 100644 index 9a77750..0000000 --- a/boost/intrusive/options.hpp +++ /dev/null @@ -1,248 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2014 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_OPTIONS_HPP -#define BOOST_INTRUSIVE_OPTIONS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include -#include -#include - -namespace boost { -namespace intrusive { - -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - -struct empty -{}; - -template -struct fhtraits; - -template -struct mhtraits; - -//typedef void default_tag; -struct default_tag; -struct member_tag; - -template -struct is_default_hook_tag; - -#endif //#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - -//!This option setter specifies if the intrusive -//!container stores its size as a member to -//!obtain constant-time size() member. -BOOST_INTRUSIVE_OPTION_CONSTANT(constant_time_size, bool, Enabled, constant_time_size) - -//!This option setter specifies a container header holder type -BOOST_INTRUSIVE_OPTION_TYPE(header_holder_type, HeaderHolder, HeaderHolder, header_holder_type) - -//!This option setter specifies the type that -//!the container will use to store its size. -BOOST_INTRUSIVE_OPTION_TYPE(size_type, SizeType, SizeType, size_type) - -//!This option setter specifies the strict weak ordering -//!comparison functor for the value type -BOOST_INTRUSIVE_OPTION_TYPE(compare, Compare, Compare, compare) - -//!This option setter for scapegoat containers specifies if -//!the intrusive scapegoat container should use a non-variable -//!alpha value that does not need floating-point operations. -//! -//!If activated, the fixed alpha value is 1/sqrt(2). This -//!option also saves some space in the container since -//!the alpha value and some additional data does not need -//!to be stored in the container. -//! -//!If the user only needs an alpha value near 1/sqrt(2), this -//!option also improves performance since avoids logarithm -//!and division operations when rebalancing the tree. -BOOST_INTRUSIVE_OPTION_CONSTANT(floating_point, bool, Enabled, floating_point) - -//!This option setter specifies the equality -//!functor for the value type -BOOST_INTRUSIVE_OPTION_TYPE(equal, Equal, Equal, equal) - -//!This option setter specifies the equality -//!functor for the value type -BOOST_INTRUSIVE_OPTION_TYPE(priority, Priority, Priority, priority) - -//!This option setter specifies the hash -//!functor for the value type -BOOST_INTRUSIVE_OPTION_TYPE(hash, Hash, Hash, hash) - -//!This option setter specifies the relationship between the type -//!to be managed by the container (the value type) and the node to be -//!used in the node algorithms. It also specifies the linking policy. -BOOST_INTRUSIVE_OPTION_TYPE(value_traits, ValueTraits, ValueTraits, proto_value_traits) - -//#define BOOST_INTRUSIVE_COMMA , -//#define BOOST_INTRUSIVE_LESS < -//#define BOOST_INTRUSIVE_MORE > -//BOOST_INTRUSIVE_OPTION_TYPE (member_hook, Parent BOOST_INTRUSIVE_COMMA class MemberHook BOOST_INTRUSIVE_COMMA MemberHook Parent::* PtrToMember , mhtraits BOOST_INTRUSIVE_LESS Parent BOOST_INTRUSIVE_COMMA MemberHook BOOST_INTRUSIVE_COMMA PtrToMember BOOST_INTRUSIVE_MORE , proto_value_traits) -//template< class Parent , class MemberHook , MemberHook Parent::* PtrToMember> -//struct member_hook { -// template struct pack : Base { -// typedef mhtraits < Parent , MemberHook , PtrToMember > proto_value_traits; -// }; -//}; -// -//#undef BOOST_INTRUSIVE_COMMA -//#undef BOOST_INTRUSIVE_LESS -//#undef BOOST_INTRUSIVE_MORE - -//!This option setter specifies the member hook the -//!container must use. -template< typename Parent - , typename MemberHook - , MemberHook Parent::* PtrToMember> -struct member_hook -{ -// @cond -// typedef typename MemberHook::hooktags::node_traits node_traits; -// typedef typename node_traits::node node_type; -// typedef node_type Parent::* Ptr2MemNode; -// typedef mhtraits -// < Parent -// , node_traits -// //This cast is really ugly but necessary to reduce template bloat. -// //Since we control the layout between the hook and the node, and there is -// //always single inheritance, the offset of the node is exactly the offset of -// //the hook. Since the node type is shared between all member hooks, this saves -// //quite a lot of symbol stuff. -// , (Ptr2MemNode)PtrToMember -// , MemberHook::hooktags::link_mode> member_value_traits; - typedef mhtraits member_value_traits; - template - struct pack : Base - { - typedef member_value_traits proto_value_traits; - }; -/// @endcond -}; - -//!This option setter specifies the function object that will -//!be used to convert between values to be inserted in a container -//!and the hook to be used for that purpose. -BOOST_INTRUSIVE_OPTION_TYPE(function_hook, Functor, fhtraits, proto_value_traits) - -//!This option setter specifies that the container -//!must use the specified base hook -BOOST_INTRUSIVE_OPTION_TYPE(base_hook, BaseHook, BaseHook, proto_value_traits) - -//!This option setter specifies the type of -//!a void pointer. This will instruct the hook -//!to use this type of pointer instead of the -//!default one -BOOST_INTRUSIVE_OPTION_TYPE(void_pointer, VoidPointer, VoidPointer, void_pointer) - -//!This option setter specifies the type of -//!the tag of a base hook. A type cannot have two -//!base hooks of the same type, so a tag can be used -//!to differentiate two base hooks with otherwise same type -BOOST_INTRUSIVE_OPTION_TYPE(tag, Tag, Tag, tag) - -//!This option setter specifies the link mode -//!(normal_link, safe_link or auto_unlink) -BOOST_INTRUSIVE_OPTION_CONSTANT(link_mode, link_mode_type, LinkType, link_mode) - -//!This option setter specifies if the hook -//!should be optimized for size instead of for speed. -BOOST_INTRUSIVE_OPTION_CONSTANT(optimize_size, bool, Enabled, optimize_size) - -//!This option setter specifies if the slist container should -//!use a linear implementation instead of a circular one. -BOOST_INTRUSIVE_OPTION_CONSTANT(linear, bool, Enabled, linear) - -//!If true, slist also stores a pointer to the last element of the singly linked list. -//!This allows O(1) swap and splice_after(iterator, slist &) for circular slists and makes -//!possible new functions like push_back(reference) and back(). -BOOST_INTRUSIVE_OPTION_CONSTANT(cache_last, bool, Enabled, cache_last) - -//!This option setter specifies the bucket traits -//!class for unordered associative containers. When this option is specified, -//!instead of using the default bucket traits, a user defined holder will be defined -BOOST_INTRUSIVE_OPTION_TYPE(bucket_traits, BucketTraits, BucketTraits, bucket_traits) - -//!This option setter specifies if the unordered hook -//!should offer room to store the hash value. -//!Storing the hash in the hook will speed up rehashing -//!processes in applications where rehashing is frequent, -//!rehashing might throw or the value is heavy to hash. -BOOST_INTRUSIVE_OPTION_CONSTANT(store_hash, bool, Enabled, store_hash) - -//!This option setter specifies if the unordered hook -//!should offer room to store another link to another node -//!with the same key. -//!Storing this link will speed up lookups and insertions on -//!unordered_multiset containers with a great number of elements -//!with the same key. -BOOST_INTRUSIVE_OPTION_CONSTANT(optimize_multikey, bool, Enabled, optimize_multikey) - -//!This option setter specifies if the bucket array will be always power of two. -//!This allows using masks instead of the default modulo operation to determine -//!the bucket number from the hash value, leading to better performance. -//!In debug mode, if power of two buckets mode is activated, the bucket length -//!will be checked to through assertions to assure the bucket length is power of two. -BOOST_INTRUSIVE_OPTION_CONSTANT(power_2_buckets, bool, Enabled, power_2_buckets) - -//!This option setter specifies if the container will cache a pointer to the first -//!non-empty bucket so that begin() is always constant-time. -//!This is specially helpful when we can have containers with a few elements -//!but with big bucket arrays (that is, hashtables with low load factors). -BOOST_INTRUSIVE_OPTION_CONSTANT(cache_begin, bool, Enabled, cache_begin) - -//!This option setter specifies if the container will compare the hash value -//!before comparing objects. This option can't be specified if store_hash<> -//!is not true. -//!This is specially helpful when we have containers with a high load factor. -//!and the comparison function is much more expensive that comparing already -//!stored hash values. -BOOST_INTRUSIVE_OPTION_CONSTANT(compare_hash, bool, Enabled, compare_hash) - -//!This option setter specifies if the hash container will use incremental -//!hashing. With incremental hashing the cost of hash table expansion is spread -//!out across each hash table insertion operation, as opposed to be incurred all at once. -//!Therefore linear hashing is well suited for interactive applications or real-time -//!appplications where the worst-case insertion time of non-incremental hash containers -//!(rehashing the whole bucket array) is not admisible. -BOOST_INTRUSIVE_OPTION_CONSTANT(incremental, bool, Enabled, incremental) - -/// @cond - -struct hook_defaults -{ - typedef void* void_pointer; - static const link_mode_type link_mode = safe_link; - typedef default_tag tag; - static const bool optimize_size = false; - static const bool store_hash = false; - static const bool linear = false; - static const bool optimize_multikey = false; -}; - -/// @endcond - -} //namespace intrusive { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_INTRUSIVE_OPTIONS_HPP diff --git a/boost/intrusive/pack_options.hpp b/boost/intrusive/pack_options.hpp deleted file mode 100644 index 077b08b..0000000 --- a/boost/intrusive/pack_options.hpp +++ /dev/null @@ -1,374 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2013-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_PACK_OPTIONS_HPP -#define BOOST_INTRUSIVE_PACK_OPTIONS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include - -namespace boost { -namespace intrusive { - -#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - -#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - -template -struct do_pack -{ - //Use "pack" member template to pack options - typedef typename Next::template pack type; -}; - -template -struct do_pack -{ - //Avoid packing "void" to shorten template names - typedef Prev type; -}; - -template - < class DefaultOptions - , class O1 = void - , class O2 = void - , class O3 = void - , class O4 = void - , class O5 = void - , class O6 = void - , class O7 = void - , class O8 = void - , class O9 = void - , class O10 = void - , class O11 = void - > -struct pack_options -{ - // join options - typedef - typename do_pack - < typename do_pack - < typename do_pack - < typename do_pack - < typename do_pack - < typename do_pack - < typename do_pack - < typename do_pack - < typename do_pack - < typename do_pack - < typename do_pack - < DefaultOptions - , O1 - >::type - , O2 - >::type - , O3 - >::type - , O4 - >::type - , O5 - >::type - , O6 - >::type - , O7 - >::type - , O8 - >::type - , O9 - >::type - , O10 - >::type - , O11 - >::type - type; -}; -#else - -//index_tuple -template -struct index_tuple{}; - -//build_number_seq -template > -struct build_number_seq; - -template -struct build_number_seq > - : build_number_seq > -{}; - -template -struct build_number_seq<0, index_tuple > -{ typedef index_tuple type; }; - -template -struct typelist -{}; - -//invert_typelist -template -struct invert_typelist; - -template -struct typelist_element; - -template -struct typelist_element > -{ - typedef typename typelist_element >::type type; -}; - -template -struct typelist_element<0, typelist > -{ - typedef Head type; -}; - -template -typelist >::type...> - inverted_typelist(index_tuple, typelist) -{ - return typelist >::type...>(); -} - -//sizeof_typelist -template -struct sizeof_typelist; - -template -struct sizeof_typelist< typelist > -{ - static const std::size_t value = sizeof...(Types); -}; - -//invert_typelist_impl -template -struct invert_typelist_impl; - - -template -struct invert_typelist_impl< Typelist, index_tuple > -{ - static const std::size_t last_idx = sizeof_typelist::value - 1; - typedef typelist - ::type...> type; -}; - -template -struct invert_typelist_impl< Typelist, index_tuple > -{ - typedef Typelist type; -}; - -template -struct invert_typelist_impl< Typelist, index_tuple<> > -{ - typedef Typelist type; -}; - -//invert_typelist -template -struct invert_typelist; - -template -struct invert_typelist< typelist > -{ - typedef typelist typelist_t; - typedef typename build_number_seq::type indexes_t; - typedef typename invert_typelist_impl::type type; -}; - -//Do pack -template -struct do_pack; - -template<> -struct do_pack >; - -template -struct do_pack > -{ - typedef Prev type; -}; - -template -struct do_pack > -{ - typedef typename Prev::template pack type; -}; - -template -struct do_pack > -{ - typedef typename Prev::template pack - >::type> type; -}; - - -template -struct pack_options -{ - typedef typelist typelist_t; - typedef typename invert_typelist::type inverted_typelist; - typedef typename do_pack::type type; -}; - -#endif //!defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) - -#define BOOST_INTRUSIVE_OPTION_TYPE(OPTION_NAME, TYPE, TYPEDEF_EXPR, TYPEDEF_NAME) \ -template< class TYPE> \ -struct OPTION_NAME \ -{ \ - template \ - struct pack : Base \ - { \ - typedef TYPEDEF_EXPR TYPEDEF_NAME; \ - }; \ -}; \ -// - -#define BOOST_INTRUSIVE_OPTION_CONSTANT(OPTION_NAME, TYPE, VALUE, CONSTANT_NAME) \ -template< TYPE VALUE> \ -struct OPTION_NAME \ -{ \ - template \ - struct pack : Base \ - { \ - static const TYPE CONSTANT_NAME = VALUE; \ - }; \ -}; \ -// - -#else //#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - -//! This class is a utility that takes: -//! - a default options class defining initial static constant -//! and typedefs -//! - several options defined with BOOST_INTRUSIVE_OPTION_CONSTANT and -//! BOOST_INTRUSIVE_OPTION_TYPE -//! -//! and packs them together in a new type that defines all options as -//! member typedefs or static constant values. Given options of form: -//! -//! \code -//! BOOST_INTRUSIVE_OPTION_TYPE(my_pointer, VoidPointer, VoidPointer, my_pointer_type) -//! BOOST_INTRUSIVE_OPTION_CONSTANT(incremental, bool, Enabled, is_incremental) -//! \endcode -//! -//! the following expression -//! -//! \code -//! -//! struct default_options -//! { -//! typedef long int_type; -//! static const int int_constant = -1; -//! }; -//! -//! pack_options< default_options, my_pointer, incremental >::type -//! \endcode -//! -//! will create a type that will contain the following typedefs/constants -//! -//! \code -//! struct unspecified_type -//! { -//! //Default options -//! typedef long int_type; -//! static const int int_constant = -1; -//! -//! //Packed options (will ovewrite any default option) -//! typedef void* my_pointer_type; -//! static const bool is_incremental = true; -//! }; -//! \endcode -//! -//! If an option is specified in the default options argument and later -//! redefined as an option, the last definition will prevail. -template -struct pack_options -{ - typedef unspecified_type type; -}; - -//! Defines an option class of name OPTION_NAME that can be used to specify a type -//! of type TYPE... -//! -//! \code -//! struct OPTION_NAME -//! { /*unspecified_content*/ }; -//! \endcode -//! -//! ...that after being combined with -//! boost::intrusive::pack_options, -//! will typedef TYPE as a typedef of name TYPEDEF_NAME. Example: -//! -//! \code -//! //[includes and namespaces omitted for brevity] -//! -//! //This macro will create the following class: -//! // template -//! // struct my_pointer -//! // { unspecified_content }; -//! BOOST_INTRUSIVE_OPTION_TYPE(my_pointer, VoidPointer, boost::remove_pointer::type, my_pointer_type) -//! -//! struct empty_default{}; -//! -//! typedef pack_options< empty_default, typename my_pointer >::type::my_pointer_type type; -//! -//! BOOST_STATIC_ASSERT(( boost::is_same::value )); -//! -//! \endcode -#define BOOST_INTRUSIVE_OPTION_TYPE(OPTION_NAME, TYPE, TYPEDEF_EXPR, TYPEDEF_NAME) - -//! Defines an option class of name OPTION_NAME that can be used to specify a constant -//! of type TYPE with value VALUE... -//! -//! \code -//! struct OPTION_NAME -//! { /*unspecified_content*/ }; -//! \endcode -//! -//! ...that after being combined with -//! boost::intrusive::pack_options, -//! will contain a CONSTANT_NAME static constant of value VALUE. Example: -//! -//! \code -//! //[includes and namespaces omitted for brevity] -//! -//! //This macro will create the following class: -//! // template -//! // struct incremental -//! // { unspecified_content }; -//! BOOST_INTRUSIVE_OPTION_CONSTANT(incremental, bool, Enabled, is_incremental) -//! -//! struct empty_default{}; -//! -//! const bool is_incremental = pack_options< empty_default, incremental >::type::is_incremental; -//! -//! BOOST_STATIC_ASSERT(( is_incremental == true )); -//! -//! \endcode -#define BOOST_INTRUSIVE_OPTION_CONSTANT(OPTION_NAME, TYPE, VALUE, CONSTANT_NAME) - -#endif //#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED - - -} //namespace intrusive { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_INTRUSIVE_PACK_OPTIONS_HPP diff --git a/boost/intrusive/parent_from_member.hpp b/boost/intrusive/parent_from_member.hpp deleted file mode 100644 index e6be5bc..0000000 --- a/boost/intrusive/parent_from_member.hpp +++ /dev/null @@ -1,48 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2010-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP -#define BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include - -#include - -namespace boost { -namespace intrusive { - -//! Given a pointer to a member and its corresponding pointer to data member, -//! this function returns the pointer of the parent containing that member. -//! Note: this function does not work with pointer to members that rely on -//! virtual inheritance. -template -inline Parent *get_parent_from_member(Member *member, const Member Parent::* ptr_to_member) -{ return ::boost::intrusive::detail::parent_from_member(member, ptr_to_member); } - -//! Given a const pointer to a member and its corresponding const pointer to data member, -//! this function returns the const pointer of the parent containing that member. -//! Note: this function does not work with pointer to members that rely on -//! virtual inheritance. -template -inline const Parent *get_parent_from_member(const Member *member, const Member Parent::* ptr_to_member) -{ return ::boost::intrusive::detail::parent_from_member(member, ptr_to_member); } - -} //namespace intrusive { -} //namespace boost { - -#include - -#endif //#ifndef BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP diff --git a/boost/intrusive/pointer_plus_bits.hpp b/boost/intrusive/pointer_plus_bits.hpp deleted file mode 100644 index 1fcf67a..0000000 --- a/boost/intrusive/pointer_plus_bits.hpp +++ /dev/null @@ -1,94 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Ion Gaztanaga 2007-2013 -// -// Distributed under the 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/intrusive for documentation. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_INTRUSIVE_POINTER_PLUS_BITS_HPP -#define BOOST_INTRUSIVE_POINTER_PLUS_BITS_HPP - -#if defined(_MSC_VER) -# pragma once -#endif - -#include -#include -#include //ls_zeros -#include //BOOST_INTRUSIVE_INVARIANT_ASSERT - -namespace boost { -namespace intrusive { - -//!This trait class is used to know if a pointer -//!can embed extra bits of information if -//!it's going to be used to point to objects -//!with an alignment of "Alignment" bytes. -template -struct max_pointer_plus_bits -{ - static const std::size_t value = 0; -}; - -//!This is a specialization for raw pointers. -//!Raw pointers can embed extra bits in the lower bits -//!if the alignment is multiple of 2pow(NumBits). -template -struct max_pointer_plus_bits -{ - static const std::size_t value = detail::ls_zeros::value; -}; - -//!This is class that is supposed to have static methods -//!to embed extra bits of information in a pointer. -//!This is a declaration and there is no default implementation, -//!because operations to embed the bits change with every pointer type. -//! -//!An implementation that detects that a pointer type whose -//!has_pointer_plus_bits<>::value is non-zero can make use of these -//!operations to embed the bits in the pointer. -template -struct pointer_plus_bits - #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED - {} - #endif -; - -//!This is the specialization to embed extra bits of information -//!in a raw pointer. The extra bits are stored in the lower bits of the pointer. -template -struct pointer_plus_bits -{ - static const std::size_t Mask = ((std::size_t(1u) << NumBits) - 1); - typedef T* pointer; - - static pointer get_pointer(pointer n) - { return pointer(std::size_t(n) & ~Mask); } - - static void set_pointer(pointer &n, pointer p) - { - BOOST_INTRUSIVE_INVARIANT_ASSERT(0 == (std::size_t(p) & Mask)); - n = pointer(std::size_t(p) | (std::size_t(n) & Mask)); - } - - static std::size_t get_bits(pointer n) - { return (std::size_t(n) & Mask); } - - static void set_bits(pointer &n, std::size_t c) - { - BOOST_INTRUSIVE_INVARIANT_ASSERT(c <= Mask); - n = pointer(std::size_t(get_pointer(n)) | c); - } -}; - -} //namespace intrusive -} //namespace boost - -#include - -#endif //BOOST_INTRUSIVE_POINTER_PLUS_BITS_HPP diff --git a/boost/intrusive/pointer_rebind.hpp b/boost/intrusive/pointer_rebind.hpp index 8524913..9592e06 100644 --- a/boost/intrusive/pointer_rebind.hpp +++ b/boost/intrusive/pointer_rebind.hpp @@ -11,11 +11,17 @@ #ifndef BOOST_INTRUSIVE_POINTER_REBIND_HPP #define BOOST_INTRUSIVE_POINTER_REBIND_HPP -#if defined(_MSC_VER) -# pragma once +#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP +#include +#endif //BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP + +#ifndef BOOST_CONFIG_HPP +# include #endif -#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif namespace boost { namespace intrusive { @@ -165,12 +171,6 @@ template