From d9ec475d945d3035377a0d89ed42e382d8988891 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Thu, 6 Oct 2016 10:33:54 +0900 Subject: Imported Upstream version 1.60.0 Change-Id: Ie709530d6d5841088ceaba025cbe175a4ef43050 Signed-off-by: DongHun Kwak --- boost/align.hpp | 2 +- boost/align/align.hpp | 2 +- boost/align/aligned_alloc.hpp | 2 +- boost/align/aligned_allocator.hpp | 24 +- boost/align/aligned_allocator_adaptor.hpp | 12 +- boost/align/aligned_allocator_adaptor_forward.hpp | 6 +- boost/align/aligned_allocator_forward.hpp | 6 +- boost/align/aligned_delete.hpp | 8 +- boost/align/aligned_delete_forward.hpp | 6 +- boost/align/alignment_of.hpp | 6 +- boost/align/alignment_of_forward.hpp | 6 +- boost/align/assume_aligned.hpp | 4 +- boost/align/detail/address.hpp | 12 +- boost/align/detail/addressof.hpp | 8 +- boost/align/detail/align.hpp | 8 +- boost/align/detail/align_cxx11.hpp | 6 +- boost/align/detail/aligned_alloc.hpp | 6 +- boost/align/detail/aligned_alloc_android.hpp | 6 +- boost/align/detail/aligned_alloc_macos.hpp | 8 +- boost/align/detail/aligned_alloc_msvc.hpp | 6 +- boost/align/detail/aligned_alloc_posix.hpp | 6 +- boost/align/detail/aligned_alloc_sunos.hpp | 6 +- boost/align/detail/alignment_of.hpp | 19 +- boost/align/detail/alignment_of_clang.hpp | 8 +- boost/align/detail/alignment_of_codegear.hpp | 8 +- boost/align/detail/alignment_of_cxx11.hpp | 8 +- boost/align/detail/alignment_of_gcc.hpp | 8 +- boost/align/detail/alignment_of_msvc.hpp | 21 +- boost/align/detail/assume_aligned.hpp | 2 +- boost/align/detail/assume_aligned_clang.hpp | 8 +- boost/align/detail/assume_aligned_gcc.hpp | 2 +- boost/align/detail/assume_aligned_intel.hpp | 2 +- boost/align/detail/assume_aligned_msvc.hpp | 2 +- boost/align/detail/integral_constant.hpp | 22 +- boost/align/detail/is_aligned.hpp | 8 +- boost/align/detail/is_alignment.hpp | 8 +- boost/align/detail/is_alignment_constant.hpp | 8 +- boost/align/detail/max_align.hpp | 17 +- boost/align/detail/max_count_of.hpp | 29 - boost/align/detail/max_objects.hpp | 29 + boost/align/detail/max_size.hpp | 28 + boost/align/detail/min_size.hpp | 8 +- boost/align/detail/offset_object.hpp | 26 - boost/align/detail/remove_traits.hpp | 8 +- boost/align/is_aligned.hpp | 2 +- boost/aligned_storage.hpp | 127 +- boost/archive/archive_exception.hpp | 1 + boost/archive/basic_binary_oprimitive.hpp | 8 +- boost/archive/detail/basic_iarchive.hpp | 6 +- boost/archive/detail/basic_iserializer.hpp | 6 +- boost/archive/detail/basic_oarchive.hpp | 10 +- boost/archive/detail/basic_oserializer.hpp | 6 +- boost/archive/detail/basic_pointer_iserializer.hpp | 6 +- boost/archive/detail/basic_pointer_oserializer.hpp | 6 +- boost/archive/detail/interface_oarchive.hpp | 4 +- boost/archive/detail/iserializer.hpp | 41 +- .../archive/detail/polymorphic_iarchive_route.hpp | 4 +- .../archive/detail/polymorphic_oarchive_route.hpp | 4 +- boost/archive/impl/xml_iarchive_impl.ipp | 52 +- boost/archive/iterators/head_iterator.hpp | 80 - boost/archive/iterators/mb_from_wchar.hpp | 14 +- boost/archive/iterators/wchar_from_mb.hpp | 32 +- boost/archive/polymorphic_iarchive.hpp | 4 +- boost/archive/polymorphic_oarchive.hpp | 4 +- boost/archive/xml_archive_exception.hpp | 2 + boost/asio/basic_serial_port.hpp | 2 +- boost/asio/detail/config.hpp | 39 +- boost/asio/detail/handler_type_requirements.hpp | 14 +- boost/asio/detail/impl/socket_ops.ipp | 12 +- boost/asio/detail/impl/win_event.ipp | 12 +- boost/asio/detail/impl/win_iocp_handle_service.ipp | 2 +- boost/asio/detail/impl/win_mutex.ipp | 5 + boost/asio/detail/impl/win_static_mutex.ipp | 18 + boost/asio/detail/impl/win_thread.ipp | 12 +- boost/asio/detail/local_free_on_block_exit.hpp | 2 + boost/asio/detail/socket_types.hpp | 8 +- boost/asio/detail/thread.hpp | 8 +- boost/asio/detail/win_event.hpp | 4 + boost/asio/detail/win_thread.hpp | 8 +- boost/asio/detail/winapi_thread.hpp | 124 ++ boost/asio/ssl/impl/context.ipp | 16 +- .../ssl/old/detail/openssl_context_service.hpp | 8 + boost/asio/version.hpp | 2 +- boost/assert.hpp | 9 +- boost/atomic/detail/atomic_flag.hpp | 6 +- boost/atomic/detail/atomic_template.hpp | 128 +- boost/atomic/detail/bitwise_cast.hpp | 53 + boost/atomic/detail/caps_gcc_ppc.hpp | 2 +- boost/atomic/detail/casts.hpp | 64 - boost/atomic/detail/config.hpp | 36 + boost/atomic/detail/int_sizes.hpp | 4 +- boost/atomic/detail/operations_fwd.hpp | 3 +- boost/atomic/detail/ops_cas_based.hpp | 40 +- boost/atomic/detail/ops_emulated.hpp | 16 +- boost/atomic/detail/ops_extending_cas_based.hpp | 9 +- boost/atomic/detail/ops_gcc_alpha.hpp | 2 + boost/atomic/detail/ops_gcc_arm.hpp | 2 + boost/atomic/detail/ops_gcc_atomic.hpp | 15 + boost/atomic/detail/ops_gcc_ppc.hpp | 379 ++-- boost/atomic/detail/ops_gcc_sparc.hpp | 27 +- boost/atomic/detail/ops_gcc_sync.hpp | 33 + boost/atomic/detail/ops_gcc_x86.hpp | 4 + boost/atomic/detail/ops_gcc_x86_dcas.hpp | 306 +++- boost/atomic/detail/ops_linux_arm.hpp | 7 +- boost/atomic/detail/ops_msvc_arm.hpp | 4 + boost/atomic/detail/ops_msvc_x86.hpp | 57 +- boost/atomic/detail/ops_windows.hpp | 1 + boost/atomic/detail/platform.hpp | 8 +- boost/atomic/detail/storage_type.hpp | 138 +- boost/bind.hpp | 19 +- boost/bind/arg.hpp | 6 +- boost/bind/bind.hpp | 483 +++-- boost/bind/placeholders.hpp | 65 +- boost/chrono/detail/inlined/mac/chrono.hpp | 54 +- .../detail/inlined/mac/process_cpu_clocks.hpp | 2 +- .../detail/inlined/posix/process_cpu_clocks.hpp | 2 +- boost/chrono/duration.hpp | 3 +- boost/chrono/io/time_point_units.hpp | 15 +- boost/concept_check.hpp | 17 +- boost/config/compiler/clang.hpp | 22 +- boost/config/compiler/gcc.hpp | 20 +- boost/config/compiler/intel.hpp | 6 + boost/config/compiler/sunpro_cc.hpp | 10 +- boost/config/compiler/visualc.hpp | 1 + boost/config/platform/cloudabi.hpp | 18 + boost/config/platform/macos.hpp | 2 +- boost/config/platform/win32.hpp | 8 + boost/config/select_platform_config.hpp | 4 + boost/config/stdlib/dinkumware.hpp | 11 +- boost/config/stdlib/libstdcpp3.hpp | 4 + boost/config/suffix.hpp | 20 +- boost/container/adaptive_pool.hpp | 34 +- boost/container/allocator.hpp | 43 +- boost/container/allocator_traits.hpp | 2 +- boost/container/container_fwd.hpp | 40 +- boost/container/deque.hpp | 91 +- boost/container/detail/adaptive_node_pool.hpp | 1 - boost/container/detail/alloc_lib.h | 122 +- boost/container/detail/alloc_lib_auto_link.hpp | 24 - boost/container/detail/auto_link.hpp | 11 +- boost/container/detail/block_list.hpp | 139 ++ boost/container/detail/block_slist.hpp | 157 ++ boost/container/detail/config_begin.hpp | 1 + boost/container/detail/copy_move_algo.hpp | 8 +- boost/container/detail/dispatch_uses_allocator.hpp | 293 +++ boost/container/detail/dlmalloc.hpp | 103 ++ boost/container/detail/flat_tree.hpp | 30 +- boost/container/detail/mutex.hpp | 4 +- boost/container/detail/pair.hpp | 72 +- boost/container/detail/pool_common_alloc.hpp | 12 +- boost/container/detail/pool_resource.hpp | 191 ++ boost/container/detail/std_fwd.hpp | 30 +- boost/container/detail/tree.hpp | 37 +- boost/container/detail/type_traits.hpp | 2 + .../container/detail/variadic_templates_tools.hpp | 2 +- boost/container/detail/workaround.hpp | 21 +- boost/container/flat_map.hpp | 21 +- boost/container/flat_set.hpp | 6 +- boost/container/list.hpp | 111 +- boost/container/map.hpp | 6 +- boost/container/new_allocator.hpp | 4 + boost/container/node_allocator.hpp | 24 +- boost/container/pmr/deque.hpp | 43 + boost/container/pmr/flat_map.hpp | 63 + boost/container/pmr/flat_set.hpp | 59 + boost/container/pmr/global_resource.hpp | 66 + boost/container/pmr/list.hpp | 43 + boost/container/pmr/map.hpp | 63 + boost/container/pmr/memory_resource.hpp | 101 ++ boost/container/pmr/monotonic_buffer_resource.hpp | 180 ++ boost/container/pmr/polymorphic_allocator.hpp | 166 ++ boost/container/pmr/pool_options.hpp | 52 + boost/container/pmr/resource_adaptor.hpp | 193 ++ boost/container/pmr/set.hpp | 59 + boost/container/pmr/slist.hpp | 43 + boost/container/pmr/small_vector.hpp | 43 + boost/container/pmr/stable_vector.hpp | 43 + boost/container/pmr/string.hpp | 48 + boost/container/pmr/synchronized_pool_resource.hpp | 138 ++ .../container/pmr/unsynchronized_pool_resource.hpp | 194 ++ boost/container/pmr/vector.hpp | 43 + boost/container/scoped_allocator.hpp | 452 +---- boost/container/scoped_allocator_fwd.hpp | 31 +- boost/container/set.hpp | 9 +- boost/container/slist.hpp | 49 +- boost/container/small_vector.hpp | 17 +- boost/container/stable_vector.hpp | 86 +- boost/container/static_vector.hpp | 8 +- boost/container/string.hpp | 176 +- boost/container/uses_allocator.hpp | 169 ++ boost/container/uses_allocator_fwd.hpp | 73 + boost/container/vector.hpp | 284 +-- boost/context/detail/config.hpp | 13 +- boost/context/detail/invoke.hpp | 56 +- boost/context/execution_context.ipp | 470 +++-- boost/context/execution_context_winfib.ipp | 407 +++-- boost/context/fixedsize_stack.hpp | 5 +- boost/context/posix/protected_fixedsize_stack.hpp | 2 +- boost/context/posix/segmented_stack.hpp | 3 + boost/context/stack_context.hpp | 8 + .../context/windows/protected_fixedsize_stack.hpp | 4 +- boost/convert/base.hpp | 47 +- boost/convert/detail/forward.hpp | 1 + boost/convert/detail/range.hpp | 29 +- boost/convert/spirit.hpp | 4 +- boost/convert/stream.hpp | 2 + boost/convert/strtol.hpp | 21 +- boost/core/demangle.hpp | 11 +- boost/core/enable_if.hpp | 9 + boost/coroutine/asymmetric_coroutine.hpp | 288 +-- .../coroutine/detail/symmetric_coroutine_call.hpp | 144 +- .../coroutine/posix/protected_stack_allocator.hpp | 2 +- .../windows/protected_stack_allocator.hpp | 2 +- boost/coroutine2/detail/config.hpp | 12 - boost/coroutine2/detail/pull_control_block.hpp | 33 +- boost/coroutine2/detail/pull_control_block.ipp | 221 ++- boost/coroutine2/detail/pull_coroutine.hpp | 12 +- boost/coroutine2/detail/pull_coroutine.ipp | 15 +- boost/coroutine2/detail/push_control_block.hpp | 17 +- boost/coroutine2/detail/push_control_block.ipp | 212 +-- boost/coroutine2/detail/push_coroutine.ipp | 7 +- boost/coroutine2/fixedsize_stack.hpp | 3 + boost/coroutine2/segmented_stack.hpp | 3 +- boost/cstdint.hpp | 2 +- boost/date_time/date.hpp | 4 +- boost/date_time/gregorian_calendar.ipp | 10 +- boost/date_time/int_adapter.hpp | 4 +- boost/date_time/posix_time/posix_time_duration.hpp | 6 +- boost/date_time/time_system_counted.hpp | 2 +- boost/detail/is_incrementable.hpp | 54 +- boost/detail/winapi/GetCurrentProcess.hpp | 15 +- boost/detail/winapi/GetCurrentThread.hpp | 22 +- boost/detail/winapi/GetLastError.hpp | 14 +- boost/detail/winapi/GetProcessTimes.hpp | 51 +- boost/detail/winapi/GetThreadTimes.hpp | 42 +- boost/detail/winapi/LocalFree.hpp | 33 - boost/detail/winapi/apc.hpp | 47 + boost/detail/winapi/basic_types.hpp | 249 ++- boost/detail/winapi/condition_variable.hpp | 116 ++ boost/detail/winapi/config.hpp | 21 +- boost/detail/winapi/critical_section.hpp | 184 ++ boost/detail/winapi/crypt.hpp | 223 ++- boost/detail/winapi/detail/cast_ptr.hpp | 40 + boost/detail/winapi/directory_management.hpp | 93 +- boost/detail/winapi/dll.hpp | 230 ++- boost/detail/winapi/error_handling.hpp | 161 +- boost/detail/winapi/event.hpp | 183 ++ boost/detail/winapi/file_management.hpp | 471 +++-- boost/detail/winapi/file_mapping.hpp | 170 ++ boost/detail/winapi/handles.hpp | 59 +- boost/detail/winapi/heap_memory.hpp | 72 + boost/detail/winapi/init_once.hpp | 123 ++ boost/detail/winapi/local_memory.hpp | 51 + boost/detail/winapi/memory.hpp | 46 +- boost/detail/winapi/mutex.hpp | 181 ++ boost/detail/winapi/process.hpp | 20 +- boost/detail/winapi/security.hpp | 95 +- boost/detail/winapi/semaphore.hpp | 170 ++ boost/detail/winapi/srw_lock.hpp | 105 ++ boost/detail/winapi/synchronization.hpp | 285 +-- boost/detail/winapi/system.hpp | 81 +- boost/detail/winapi/thread.hpp | 41 +- boost/detail/winapi/thread_pool.hpp | 130 +- boost/detail/winapi/time.hpp | 170 +- boost/detail/winapi/timers.hpp | 42 +- boost/detail/winapi/tls.hpp | 49 +- boost/detail/winapi/wait.hpp | 84 + boost/detail/winapi/waitable_timer.hpp | 148 +- boost/endian/conversion.hpp | 9 +- boost/exception/exception.hpp | 10 + boost/filesystem.hpp | 1 + boost/filesystem/config.hpp | 3 +- boost/filesystem/operations.hpp | 308 +++- boost/filesystem/path.hpp | 115 +- boost/filesystem/string_file.hpp | 43 + boost/flyweight/assoc_container_factory.hpp | 6 +- boost/flyweight/flyweight.hpp | 6 +- boost/flyweight/flyweight_fwd.hpp | 15 +- boost/flyweight/serialize.hpp | 4 +- boost/format/feed_args.hpp | 4 + boost/functional/hash/hash.hpp | 2 +- boost/fusion/algorithm/iteration/accumulate.hpp | 15 +- .../fusion/algorithm/iteration/accumulate_fwd.hpp | 15 +- boost/fusion/algorithm/iteration/detail/fold.hpp | 530 ++---- .../iteration/detail/preprocessed/fold.hpp | 447 ++--- .../iteration/detail/preprocessed/iter_fold.hpp | 447 ++--- .../iteration/detail/preprocessed/reverse_fold.hpp | 447 ++--- .../detail/preprocessed/reverse_iter_fold.hpp | 447 ++--- .../algorithm/iteration/detail/segmented_fold.hpp | 7 +- boost/fusion/algorithm/iteration/fold.hpp | 12 +- boost/fusion/algorithm/iteration/fold_fwd.hpp | 4 +- boost/fusion/algorithm/iteration/iter_fold.hpp | 13 +- boost/fusion/algorithm/iteration/iter_fold_fwd.hpp | 4 +- boost/fusion/algorithm/iteration/reverse_fold.hpp | 12 +- .../algorithm/iteration/reverse_fold_fwd.hpp | 4 +- .../algorithm/iteration/reverse_iter_fold.hpp | 12 +- .../algorithm/iteration/reverse_iter_fold_fwd.hpp | 4 +- boost/fusion/algorithm/transformation/erase.hpp | 1 - boost/fusion/algorithm/transformation/flatten.hpp | 4 +- boost/fusion/algorithm/transformation/insert.hpp | 1 - .../algorithm/transformation/insert_range.hpp | 1 - boost/fusion/container/deque/deque.hpp | 3 +- .../fusion/container/deque/detail/convert_impl.hpp | 9 +- .../container/deque/detail/cpp03/build_deque.hpp | 1 + .../fusion/container/deque/detail/cpp03/deque.hpp | 4 +- .../deque/detail/cpp03/preprocessed/deque10.hpp | 4 +- .../deque/detail/cpp03/preprocessed/deque20.hpp | 4 +- .../deque/detail/cpp03/preprocessed/deque30.hpp | 4 +- .../deque/detail/cpp03/preprocessed/deque40.hpp | 4 +- .../deque/detail/cpp03/preprocessed/deque50.hpp | 4 +- boost/fusion/container/generation/make_set.hpp | 41 +- boost/fusion/container/generation/make_vector.hpp | 61 +- boost/fusion/container/generation/vector_tie.hpp | 29 + boost/fusion/container/set/detail/as_set.hpp | 50 +- boost/fusion/container/set/detail/convert_impl.hpp | 2 +- boost/fusion/container/set/set.hpp | 120 +- boost/fusion/container/set/set_fwd.hpp | 27 + boost/fusion/container/vector.hpp | 19 +- boost/fusion/container/vector/detail/as_vector.hpp | 53 +- boost/fusion/container/vector/detail/at_impl.hpp | 9 +- boost/fusion/container/vector/detail/config.hpp | 36 + .../container/vector/detail/cpp03/limits.hpp | 1 + .../fusion/container/vector/detail/deref_impl.hpp | 6 +- .../container/vector/detail/value_at_impl.hpp | 39 + .../container/vector/detail/value_of_impl.hpp | 6 +- boost/fusion/container/vector/vector.hpp | 322 +++- boost/fusion/container/vector/vector10.hpp | 10 + boost/fusion/container/vector/vector20.hpp | 10 + boost/fusion/container/vector/vector30.hpp | 10 + boost/fusion/container/vector/vector40.hpp | 10 + boost/fusion/container/vector/vector50.hpp | 10 + boost/fusion/container/vector/vector_fwd.hpp | 26 +- boost/fusion/functional/adapter/limits.hpp | 11 +- boost/fusion/functional/invocation/invoke.hpp | 8 +- .../invocation/invoke_function_object.hpp | 10 +- .../functional/invocation/invoke_procedure.hpp | 4 +- boost/fusion/sequence/io/detail/manip.hpp | 3 +- boost/fusion/support/detail/enabler.hpp | 18 - boost/fusion/support/detail/is_same_size.hpp | 29 + boost/fusion/support/detail/result_of.hpp | 53 - boost/fusion/support/segmented_fold_until.hpp | 5 - boost/fusion/tuple/make_tuple.hpp | 31 + boost/fusion/tuple/tuple.hpp | 75 +- boost/fusion/tuple/tuple_fwd.hpp | 26 +- boost/fusion/tuple/tuple_tie.hpp | 19 + boost/fusion/view/detail/strictest_traversal.hpp | 2 +- boost/fusion/view/flatten_view.hpp | 4 +- boost/fusion/view/flatten_view/flatten_view.hpp | 4 +- .../view/flatten_view/flatten_view_iterator.hpp | 4 +- boost/fusion/view/nview/detail/advance_impl.hpp | 9 +- boost/fusion/view/nview/detail/at_impl.hpp | 3 +- boost/fusion/view/nview/detail/begin_impl.hpp | 5 +- .../fusion/view/nview/detail/cpp03/nview_impl.hpp | 5 +- boost/fusion/view/nview/detail/deref_impl.hpp | 6 +- boost/fusion/view/nview/detail/end_impl.hpp | 5 +- boost/fusion/view/nview/detail/next_impl.hpp | 8 +- boost/fusion/view/nview/detail/nview_impl.hpp | 32 + boost/fusion/view/nview/detail/prior_impl.hpp | 8 +- boost/fusion/view/nview/nview.hpp | 8 +- boost/fusion/view/nview/nview_iterator.hpp | 3 +- boost/geometry/algorithms/centroid.hpp | 23 +- .../algorithms/detail/buffer/buffer_inserter.hpp | 23 +- .../detail/buffer/buffered_piece_collection.hpp | 11 +- .../algorithms/detail/buffer/buffered_ring.hpp | 12 +- .../algorithms/detail/disjoint/box_box.hpp | 13 +- .../algorithms/detail/disjoint/point_box.hpp | 13 +- .../algorithms/detail/distance/segment_to_box.hpp | 21 +- .../algorithms/detail/expand_by_epsilon.hpp | 113 ++ .../geometry/algorithms/detail/is_simple/areal.hpp | 12 +- .../algorithms/detail/is_simple/linear.hpp | 5 +- .../algorithms/detail/is_simple/multipoint.hpp | 4 +- boost/geometry/algorithms/detail/is_valid/box.hpp | 17 +- .../detail/is_valid/has_invalid_coordinate.hpp | 151 ++ .../geometry/algorithms/detail/is_valid/linear.hpp | 6 + .../algorithms/detail/is_valid/pointlike.hpp | 13 +- .../algorithms/detail/is_valid/polygon.hpp | 5 + boost/geometry/algorithms/detail/is_valid/ring.hpp | 25 +- .../algorithms/detail/is_valid/segment.hpp | 11 +- .../algorithms/detail/overlay/clip_linestring.hpp | 13 +- .../detail/overlay/enrich_intersection_points.hpp | 32 +- .../detail/overlay/follow_linear_linear.hpp | 21 +- .../algorithms/detail/overlay/get_turn_info.hpp | 26 +- .../detail/overlay/get_turn_info_helpers.hpp | 4 +- .../algorithms/detail/overlay/get_turns.hpp | 6 +- .../detail/overlay/handle_colocations.hpp | 278 +++ .../overlay/inconsistent_turns_exception.hpp | 38 + .../detail/overlay/intersection_box_box.hpp | 22 +- .../detail/overlay/intersection_insert.hpp | 124 +- .../geometry/algorithms/detail/overlay/overlay.hpp | 25 +- .../algorithms/detail/overlay/traversal_info.hpp | 2 +- .../algorithms/detail/overlay/traverse.hpp | 24 + .../algorithms/detail/overlay/turn_info.hpp | 11 +- .../algorithms/detail/point_is_spike_or_equal.hpp | 46 +- .../algorithms/detail/relate/areal_areal.hpp | 38 +- .../algorithms/detail/relate/boundary_checker.hpp | 40 +- .../algorithms/detail/relate/topology_check.hpp | 36 +- boost/geometry/algorithms/detail/relate/turns.hpp | 4 +- .../detail/sections/section_functions.hpp | 5 + .../algorithms/detail/sections/sectionalize.hpp | 21 +- boost/geometry/algorithms/overlaps.hpp | 16 +- boost/geometry/algorithms/touches.hpp | 31 +- .../geometry/algorithms/validity_failure_type.hpp | 5 +- boost/geometry/arithmetic/determinant.hpp | 2 + boost/geometry/core/exception.hpp | 1 + .../geometry/index/detail/is_bounding_geometry.hpp | 35 + boost/geometry/index/detail/is_indexable.hpp | 47 + boost/geometry/index/detail/rtree/node/node.hpp | 40 +- .../index/detail/rtree/node/node_elements.hpp | 17 +- boost/geometry/index/detail/rtree/pack_create.hpp | 24 + boost/geometry/index/detail/rtree/rstar/insert.hpp | 20 +- .../index/detail/rtree/utilities/are_boxes_ok.hpp | 20 +- .../index/detail/rtree/visitors/children_box.hpp | 4 +- .../index/detail/rtree/visitors/insert.hpp | 48 +- .../index/detail/rtree/visitors/remove.hpp | 15 +- boost/geometry/index/indexable.hpp | 27 +- boost/geometry/index/rtree.hpp | 27 +- .../policies/is_valid/failing_reason_policy.hpp | 2 + .../agnostic/simplify_douglas_peucker.hpp | 2 +- boost/geometry/strategies/cartesian/box_in_box.hpp | 29 +- .../geometry/strategies/cartesian/point_in_box.hpp | 11 +- .../spherical/distance_cross_track_point_box.hpp | 2 +- .../strategies/transform/inverse_transformer.hpp | 3 + .../strategies/transform/matrix_transformers.hpp | 3 + boost/geometry/util/has_infinite_coordinate.hpp | 55 + boost/geometry/util/has_nan_coordinate.hpp | 99 + boost/geometry/util/has_non_finite_coordinate.hpp | 55 + boost/geometry/util/math.hpp | 77 +- boost/heap/binomial_heap.hpp | 5 + boost/icl/concept/interval.hpp | 6 +- boost/icl/concept/interval_associator.hpp | 4 +- boost/icl/concept/interval_associator_base.hpp | 4 +- boost/icl/concept/interval_map.hpp | 8 +- boost/icl/detail/concept_check.hpp | 4 +- boost/icl/detail/interval_set_algo.hpp | 10 +- boost/icl/detail/subset_comparer.hpp | 4 +- boost/icl/interval_base_map.hpp | 3 +- boost/icl/map.hpp | 1 - boost/icl/type_traits/has_inverse.hpp | 4 +- boost/icl/type_traits/infinity.hpp | 15 +- boost/icl/type_traits/is_interval_separator.hpp | 2 + boost/icl/type_traits/is_numeric.hpp | 1 - boost/interprocess/containers/pair.hpp | 1 - boost/interprocess/detail/config_begin.hpp | 5 + boost/interprocess/detail/config_end.hpp | 3 + boost/interprocess/detail/os_thread_functions.hpp | 23 +- boost/interprocess/detail/posix_time_types_wrk.hpp | 5 +- boost/interprocess/detail/std_fwd.hpp | 40 +- boost/interprocess/detail/utilities.hpp | 26 +- boost/interprocess/detail/win32_api.hpp | 45 +- boost/interprocess/detail/workaround.hpp | 3 + boost/interprocess/interprocess_fwd.hpp | 13 +- boost/interprocess/mapped_region.hpp | 4 +- boost/interprocess/offset_ptr.hpp | 398 ++--- boost/interprocess/sync/interprocess_mutex.hpp | 2 +- .../sync/interprocess_recursive_mutex.hpp | 2 +- boost/interprocess/sync/interprocess_semaphore.hpp | 2 +- boost/intrusive/avl_set.hpp | 4 +- boost/intrusive/bs_set.hpp | 4 +- boost/intrusive/bstree.hpp | 172 +- boost/intrusive/detail/ebo_functor_holder.hpp | 132 +- .../detail/has_member_function_callable_with.hpp | 13 +- boost/intrusive/detail/key_nodeptr_comp.hpp | 10 +- boost/intrusive/detail/math.hpp | 22 +- boost/intrusive/detail/parent_from_member.hpp | 4 - boost/intrusive/detail/std_fwd.hpp | 30 +- boost/intrusive/detail/tree_iterator.hpp | 21 +- boost/intrusive/detail/tree_value_compare.hpp | 23 +- boost/intrusive/intrusive_fwd.hpp | 14 +- boost/intrusive/pointer_plus_bits.hpp | 14 +- boost/intrusive/pointer_traits.hpp | 14 +- boost/intrusive/rbtree_algorithms.hpp | 4 + boost/intrusive/set.hpp | 4 +- boost/intrusive/sg_set.hpp | 4 +- boost/intrusive/sgtree.hpp | 17 +- boost/intrusive/splay_set.hpp | 4 +- boost/intrusive/treap_set.hpp | 4 +- boost/iterator/zip_iterator.hpp | 425 ++--- boost/lambda/detail/lambda_functors.hpp | 2 +- boost/lexical_cast.hpp | 7 +- boost/lexical_cast/detail/converter_lexical.hpp | 7 +- boost/lexical_cast/try_lexical_convert.hpp | 13 + boost/locale/boundary/boundary_point.hpp | 8 +- boost/locale/boundary/facets.hpp | 4 +- boost/locale/boundary/index.hpp | 16 +- boost/locale/boundary/segment.hpp | 9 +- boost/locale/conversion.hpp | 4 +- boost/locale/encoding.hpp | 4 +- boost/locale/format.hpp | 4 +- boost/locale/generic_codecvt.hpp | 676 +++++++ boost/locale/gnu_gettext.hpp | 4 +- boost/locale/message.hpp | 8 +- boost/locale/utf8_codecvt.hpp | 69 + boost/locale/util.hpp | 15 + boost/lockfree/detail/atomic.hpp | 19 + boost/lockfree/detail/branch_hints.hpp | 38 - boost/lockfree/detail/freelist.hpp | 2 +- boost/lockfree/detail/tagged_ptr_dcas.hpp | 1 - .../lockfree/detail/tagged_ptr_ptrcompression.hpp | 5 +- boost/lockfree/queue.hpp | 8 +- boost/lockfree/spsc_queue.hpp | 8 +- boost/log/attributes/attribute_set.hpp | 13 +- boost/log/attributes/counter.hpp | 166 +- boost/log/detail/adaptive_mutex.hpp | 244 +++ boost/log/detail/code_conversion.hpp | 15 +- boost/log/detail/config.hpp | 31 +- boost/log/detail/is_character_type.hpp | 2 - boost/log/detail/light_rw_mutex.hpp | 49 +- boost/log/detail/setup_config.hpp | 15 +- boost/log/detail/spin_mutex.hpp | 319 ---- boost/log/detail/thread_specific.hpp | 10 +- boost/log/expressions/formatter.hpp | 215 ++- .../log/expressions/formatters/char_decorator.hpp | 26 +- boost/log/sinks/async_frontend.hpp | 72 +- boost/log/sinks/unbounded_fifo_queue.hpp | 11 +- boost/log/sources/record_ostream.hpp | 61 + boost/log/utility/formatting_ostream.hpp | 19 +- .../type_dispatch/dynamic_type_dispatcher.hpp | 2 +- .../type_dispatch/static_type_dispatcher.hpp | 11 +- boost/math/concepts/real_concept.hpp | 29 +- boost/math/concepts/std_real_concept.hpp | 2 +- boost/math/constants/constants.hpp | 14 +- boost/math/cstdfloat/cstdfloat_iostream.hpp | 5 +- boost/math/distributions/bernoulli.hpp | 2 +- boost/math/distributions/binomial.hpp | 2 +- .../distributions/detail/hypergeometric_pdf.hpp | 2 +- .../detail/hypergeometric_quantile.hpp | 46 + boost/math/distributions/exponential.hpp | 4 +- boost/math/distributions/extreme_value.hpp | 4 +- boost/math/distributions/fisher_f.hpp | 4 +- boost/math/distributions/geometric.hpp | 2 +- boost/math/distributions/hypergeometric.hpp | 44 +- boost/math/distributions/inverse_gaussian.hpp | 15 + boost/math/distributions/negative_binomial.hpp | 2 +- boost/math/distributions/non_central_beta.hpp | 6 +- .../math/distributions/non_central_chi_squared.hpp | 58 +- boost/math/distributions/non_central_t.hpp | 4 +- boost/math/distributions/rayleigh.hpp | 2 +- boost/math/distributions/skew_normal.hpp | 18 +- boost/math/distributions/triangular.hpp | 12 +- boost/math/distributions/uniform.hpp | 21 +- boost/math/policies/error_handling.hpp | 124 +- boost/math/policies/policy.hpp | 108 +- boost/math/special_functions.hpp | 2 + boost/math/special_functions/bernoulli.hpp | 2 +- boost/math/special_functions/bessel.hpp | 34 +- boost/math/special_functions/bessel_prime.hpp | 8 +- boost/math/special_functions/beta.hpp | 183 +- .../special_functions/detail/bernoulli_details.hpp | 18 +- .../detail/bessel_derivatives_linear.hpp | 16 +- boost/math/special_functions/detail/bessel_ik.hpp | 6 +- boost/math/special_functions/detail/bessel_jn.hpp | 7 +- .../special_functions/detail/bessel_jy_asym.hpp | 18 + .../detail/bessel_jy_derivatives_series.hpp | 5 +- boost/math/special_functions/detail/bessel_yn.hpp | 34 +- .../math/special_functions/detail/lanczos_sse2.hpp | 2 +- boost/math/special_functions/detail/polygamma.hpp | 8 +- .../detail/t_distribution_inv.hpp | 40 +- boost/math/special_functions/ellint_2.hpp | 13 +- boost/math/special_functions/ellint_d.hpp | 10 +- boost/math/special_functions/fpclassify.hpp | 22 +- boost/math/special_functions/gamma.hpp | 20 +- boost/math/special_functions/math_fwd.hpp | 25 +- .../special_functions/nonfinite_num_facets.hpp | 5 +- boost/math/special_functions/owens_t.hpp | 84 +- boost/math/special_functions/powm1.hpp | 31 +- .../math/special_functions/relative_difference.hpp | 134 ++ boost/math/special_functions/trigamma.hpp | 28 +- boost/math/special_functions/ulp.hpp | 71 + boost/math/special_functions/zeta.hpp | 182 +- boost/math/tools/big_constant.hpp | 6 +- boost/math/tools/config.hpp | 69 +- boost/math/tools/detail/polynomial_horner1_10.hpp | 22 +- boost/math/tools/detail/polynomial_horner1_11.hpp | 24 +- boost/math/tools/detail/polynomial_horner1_12.hpp | 26 +- boost/math/tools/detail/polynomial_horner1_13.hpp | 28 +- boost/math/tools/detail/polynomial_horner1_14.hpp | 30 +- boost/math/tools/detail/polynomial_horner1_15.hpp | 32 +- boost/math/tools/detail/polynomial_horner1_16.hpp | 34 +- boost/math/tools/detail/polynomial_horner1_17.hpp | 36 +- boost/math/tools/detail/polynomial_horner1_18.hpp | 38 +- boost/math/tools/detail/polynomial_horner1_19.hpp | 40 +- boost/math/tools/detail/polynomial_horner1_2.hpp | 6 +- boost/math/tools/detail/polynomial_horner1_20.hpp | 42 +- boost/math/tools/detail/polynomial_horner1_3.hpp | 8 +- boost/math/tools/detail/polynomial_horner1_4.hpp | 10 +- boost/math/tools/detail/polynomial_horner1_5.hpp | 12 +- boost/math/tools/detail/polynomial_horner1_6.hpp | 14 +- boost/math/tools/detail/polynomial_horner1_7.hpp | 16 +- boost/math/tools/detail/polynomial_horner1_8.hpp | 18 +- boost/math/tools/detail/polynomial_horner1_9.hpp | 20 +- boost/math/tools/detail/polynomial_horner2_10.hpp | 22 +- boost/math/tools/detail/polynomial_horner2_11.hpp | 24 +- boost/math/tools/detail/polynomial_horner2_12.hpp | 26 +- boost/math/tools/detail/polynomial_horner2_13.hpp | 28 +- boost/math/tools/detail/polynomial_horner2_14.hpp | 30 +- boost/math/tools/detail/polynomial_horner2_15.hpp | 32 +- boost/math/tools/detail/polynomial_horner2_16.hpp | 34 +- boost/math/tools/detail/polynomial_horner2_17.hpp | 36 +- boost/math/tools/detail/polynomial_horner2_18.hpp | 38 +- boost/math/tools/detail/polynomial_horner2_19.hpp | 40 +- boost/math/tools/detail/polynomial_horner2_2.hpp | 10 +- boost/math/tools/detail/polynomial_horner2_20.hpp | 42 +- boost/math/tools/detail/polynomial_horner2_3.hpp | 10 +- boost/math/tools/detail/polynomial_horner2_4.hpp | 10 +- boost/math/tools/detail/polynomial_horner2_5.hpp | 12 +- boost/math/tools/detail/polynomial_horner2_6.hpp | 14 +- boost/math/tools/detail/polynomial_horner2_7.hpp | 16 +- boost/math/tools/detail/polynomial_horner2_8.hpp | 18 +- boost/math/tools/detail/polynomial_horner2_9.hpp | 20 +- boost/math/tools/detail/polynomial_horner3_10.hpp | 22 +- boost/math/tools/detail/polynomial_horner3_11.hpp | 24 +- boost/math/tools/detail/polynomial_horner3_12.hpp | 26 +- boost/math/tools/detail/polynomial_horner3_13.hpp | 28 +- boost/math/tools/detail/polynomial_horner3_14.hpp | 30 +- boost/math/tools/detail/polynomial_horner3_15.hpp | 32 +- boost/math/tools/detail/polynomial_horner3_16.hpp | 34 +- boost/math/tools/detail/polynomial_horner3_17.hpp | 36 +- boost/math/tools/detail/polynomial_horner3_18.hpp | 38 +- boost/math/tools/detail/polynomial_horner3_19.hpp | 40 +- boost/math/tools/detail/polynomial_horner3_2.hpp | 10 +- boost/math/tools/detail/polynomial_horner3_20.hpp | 42 +- boost/math/tools/detail/polynomial_horner3_3.hpp | 10 +- boost/math/tools/detail/polynomial_horner3_4.hpp | 10 +- boost/math/tools/detail/polynomial_horner3_5.hpp | 12 +- boost/math/tools/detail/polynomial_horner3_6.hpp | 14 +- boost/math/tools/detail/polynomial_horner3_7.hpp | 16 +- boost/math/tools/detail/polynomial_horner3_8.hpp | 18 +- boost/math/tools/detail/polynomial_horner3_9.hpp | 20 +- boost/math/tools/detail/rational_horner1_10.hpp | 22 +- boost/math/tools/detail/rational_horner1_11.hpp | 24 +- boost/math/tools/detail/rational_horner1_12.hpp | 26 +- boost/math/tools/detail/rational_horner1_13.hpp | 28 +- boost/math/tools/detail/rational_horner1_14.hpp | 30 +- boost/math/tools/detail/rational_horner1_15.hpp | 32 +- boost/math/tools/detail/rational_horner1_16.hpp | 34 +- boost/math/tools/detail/rational_horner1_17.hpp | 36 +- boost/math/tools/detail/rational_horner1_18.hpp | 38 +- boost/math/tools/detail/rational_horner1_19.hpp | 40 +- boost/math/tools/detail/rational_horner1_2.hpp | 6 +- boost/math/tools/detail/rational_horner1_20.hpp | 42 +- boost/math/tools/detail/rational_horner1_3.hpp | 8 +- boost/math/tools/detail/rational_horner1_4.hpp | 10 +- boost/math/tools/detail/rational_horner1_5.hpp | 12 +- boost/math/tools/detail/rational_horner1_6.hpp | 14 +- boost/math/tools/detail/rational_horner1_7.hpp | 16 +- boost/math/tools/detail/rational_horner1_8.hpp | 18 +- boost/math/tools/detail/rational_horner1_9.hpp | 20 +- boost/math/tools/detail/rational_horner2_10.hpp | 22 +- boost/math/tools/detail/rational_horner2_11.hpp | 24 +- boost/math/tools/detail/rational_horner2_12.hpp | 26 +- boost/math/tools/detail/rational_horner2_13.hpp | 28 +- boost/math/tools/detail/rational_horner2_14.hpp | 30 +- boost/math/tools/detail/rational_horner2_15.hpp | 32 +- boost/math/tools/detail/rational_horner2_16.hpp | 34 +- boost/math/tools/detail/rational_horner2_17.hpp | 36 +- boost/math/tools/detail/rational_horner2_18.hpp | 38 +- boost/math/tools/detail/rational_horner2_19.hpp | 40 +- boost/math/tools/detail/rational_horner2_2.hpp | 10 +- boost/math/tools/detail/rational_horner2_20.hpp | 42 +- boost/math/tools/detail/rational_horner2_3.hpp | 10 +- boost/math/tools/detail/rational_horner2_4.hpp | 10 +- boost/math/tools/detail/rational_horner2_5.hpp | 12 +- boost/math/tools/detail/rational_horner2_6.hpp | 14 +- boost/math/tools/detail/rational_horner2_7.hpp | 16 +- boost/math/tools/detail/rational_horner2_8.hpp | 18 +- boost/math/tools/detail/rational_horner2_9.hpp | 20 +- boost/math/tools/detail/rational_horner3_10.hpp | 22 +- boost/math/tools/detail/rational_horner3_11.hpp | 24 +- boost/math/tools/detail/rational_horner3_12.hpp | 26 +- boost/math/tools/detail/rational_horner3_13.hpp | 28 +- boost/math/tools/detail/rational_horner3_14.hpp | 30 +- boost/math/tools/detail/rational_horner3_15.hpp | 32 +- boost/math/tools/detail/rational_horner3_16.hpp | 34 +- boost/math/tools/detail/rational_horner3_17.hpp | 36 +- boost/math/tools/detail/rational_horner3_18.hpp | 38 +- boost/math/tools/detail/rational_horner3_19.hpp | 40 +- boost/math/tools/detail/rational_horner3_2.hpp | 10 +- boost/math/tools/detail/rational_horner3_20.hpp | 42 +- boost/math/tools/detail/rational_horner3_3.hpp | 10 +- boost/math/tools/detail/rational_horner3_4.hpp | 10 +- boost/math/tools/detail/rational_horner3_5.hpp | 12 +- boost/math/tools/detail/rational_horner3_6.hpp | 14 +- boost/math/tools/detail/rational_horner3_7.hpp | 16 +- boost/math/tools/detail/rational_horner3_8.hpp | 18 +- boost/math/tools/detail/rational_horner3_9.hpp | 20 +- boost/math/tools/fraction.hpp | 18 +- boost/math/tools/minima.hpp | 2 + boost/math/tools/precision.hpp | 136 +- boost/math/tools/promotion.hpp | 21 +- boost/math/tools/rational.hpp | 32 +- boost/math/tools/real_cast.hpp | 4 +- boost/math/tools/roots.hpp | 451 ++--- boost/math/tools/series.hpp | 16 +- boost/math/tools/toms748_solve.hpp | 6 +- boost/math/tools/traits.hpp | 7 +- boost/math/tools/workaround.hpp | 4 +- boost/math/tr1.hpp | 5 +- boost/move/core.hpp | 4 + boost/move/default_delete.hpp | 6 + boost/move/detail/fwd_macros.hpp | 266 ++- boost/move/detail/iterator_traits.hpp | 18 +- boost/move/detail/meta_utils.hpp | 5 + boost/move/detail/move_helpers.hpp | 322 ++-- boost/move/detail/std_ns_begin.hpp | 30 + boost/move/detail/std_ns_end.hpp | 14 + boost/move/detail/type_traits.hpp | 4 +- boost/move/unique_ptr.hpp | 4 +- boost/move/utility_core.hpp | 2 + boost/mpi/collectives/reduce.hpp | 4 +- boost/mpi/collectives/scan.hpp | 2 +- boost/mpi/detail/forward_skeleton_iarchive.hpp | 4 +- boost/mpi/detail/forward_skeleton_oarchive.hpp | 4 +- boost/mpi/detail/ignore_skeleton_oarchive.hpp | 4 +- boost/mpl/string.hpp | 2 +- boost/multi_index/detail/ord_index_impl.hpp | 2 +- boost/multi_index/global_fun.hpp | 10 +- boost/multi_index/hashed_index.hpp | 2 +- boost/multi_index/identity.hpp | 10 +- boost/multi_index/random_access_index.hpp | 2 +- boost/multi_index/ranked_index.hpp | 6 +- boost/multi_index/sequenced_index.hpp | 2 +- .../concepts/mp_number_archetypes.hpp | 2 +- boost/multiprecision/cpp_bin_float.hpp | 22 +- boost/multiprecision/cpp_int.hpp | 195 +- boost/multiprecision/cpp_int/bitwise.hpp | 9 + boost/multiprecision/cpp_int/divide.hpp | 16 +- boost/multiprecision/cpp_int/import_export.hpp | 200 +++ boost/multiprecision/cpp_int/limits.hpp | 2 +- boost/multiprecision/detail/default_ops.hpp | 4 +- boost/multiprecision/detail/functions/trig.hpp | 12 +- boost/multiprecision/detail/number_base.hpp | 186 +- boost/multiprecision/float128.hpp | 4 +- boost/multiprecision/gmp.hpp | 6 +- boost/multiprecision/miller_rabin.hpp | 2 + boost/multiprecision/mpfi.hpp | 10 +- boost/multiprecision/mpfr.hpp | 52 +- boost/multiprecision/number.hpp | 70 +- boost/multiprecision/random.hpp | 583 +----- boost/multiprecision/tommath.hpp | 2 +- boost/multiprecision/traits/is_byte_container.hpp | 33 + boost/none.hpp | 12 +- boost/none_t.hpp | 18 +- boost/numeric/odeint.hpp | 1 + .../numeric/odeint/algebra/default_operations.hpp | 4 +- boost/numeric/odeint/integrate/check_adapter.hpp | 222 +++ .../odeint/integrate/detail/integrate_adaptive.hpp | 17 +- .../odeint/integrate/detail/integrate_const.hpp | 24 +- .../odeint/integrate/detail/integrate_n_steps.hpp | 18 +- .../odeint/integrate/detail/integrate_times.hpp | 22 +- .../odeint/integrate/integrate_adaptive.hpp | 2 +- boost/numeric/odeint/integrate/integrate_const.hpp | 203 ++- .../numeric/odeint/integrate/integrate_n_steps.hpp | 82 +- boost/numeric/odeint/integrate/integrate_times.hpp | 109 +- .../numeric/odeint/integrate/max_step_checker.hpp | 114 ++ boost/numeric/odeint/stepper/bulirsch_stoer.hpp | 20 +- .../odeint/stepper/bulirsch_stoer_dense_out.hpp | 40 +- .../odeint/stepper/controlled_runge_kutta.hpp | 236 ++- .../odeint/stepper/dense_output_runge_kutta.hpp | 20 +- .../generation_controlled_runge_kutta.hpp | 14 +- .../generation_dense_output_runge_kutta.hpp | 13 +- .../stepper/generation/generation_rosenbrock4.hpp | 7 + .../odeint/stepper/generation/make_controlled.hpp | 22 + .../stepper/generation/make_dense_output.hpp | 22 + .../odeint/stepper/rosenbrock4_controller.hpp | 32 +- .../odeint/stepper/rosenbrock4_dense_output.hpp | 11 +- .../numeric/odeint/util/detail/less_with_sign.hpp | 6 +- boost/numeric/odeint/util/odeint_error.hpp | 77 + boost/numeric/odeint/util/resize.hpp | 2 +- boost/numeric/odeint/util/resizer.hpp | 2 +- boost/numeric/odeint/util/same_size.hpp | 2 +- boost/numeric/odeint/util/unwrap_reference.hpp | 2 +- boost/operators.hpp | 14 +- boost/optional/optional_io.hpp | 4 +- boost/phoenix/config.hpp | 68 +- boost/phoenix/function/adapt_function.hpp | 1 + boost/phoenix/function/function.hpp | 75 + boost/phoenix/function/lazy_list.hpp | 24 +- boost/phoenix/function/lazy_operator.hpp | 175 +- boost/phoenix/function/lazy_reuse.hpp | 58 +- boost/phoenix/function/lazy_signature.hpp | 335 ++++ boost/phoenix/function/lazy_smart.hpp | 153 ++ boost/phoenix/statement/detail/catch_push_back.hpp | 44 +- .../detail/preprocessed/catch_push_back_10.hpp | 324 +++- .../detail/preprocessed/catch_push_back_20.hpp | 692 ++++++- .../detail/preprocessed/catch_push_back_30.hpp | 1052 ++++++++++- .../detail/preprocessed/catch_push_back_40.hpp | 1428 ++++++++++++++- .../detail/preprocessed/catch_push_back_50.hpp | 1886 ++++++++++++++++++-- .../detail/preprocessed/try_catch_eval_10.hpp | 38 +- .../detail/preprocessed/try_catch_eval_20.hpp | 78 +- .../detail/preprocessed/try_catch_eval_30.hpp | 118 +- .../detail/preprocessed/try_catch_eval_40.hpp | 158 +- .../detail/preprocessed/try_catch_eval_50.hpp | 198 +- boost/phoenix/statement/detail/try_catch_eval.hpp | 4 +- boost/phoenix/statement/try_catch.hpp | 182 +- boost/phoenix/stl/algorithm/detail/begin.hpp | 10 +- boost/phoenix/stl/algorithm/detail/end.hpp | 12 +- boost/phoenix/stl/algorithm/detail/has_find.hpp | 5 + .../algorithm/detail/is_unordered_set_or_map.hpp | 144 ++ .../detail/std_unordered_set_or_map_fwd.hpp | 73 + boost/phoenix/stl/algorithm/querying.hpp | 102 +- boost/phoenix/stl/algorithm/transformation.hpp | 58 +- boost/polygon/detail/boolean_op.hpp | 6 - boost/polygon/detail/boolean_op_45.hpp | 4 - boost/polygon/detail/polygon_45_formation.hpp | 17 - boost/polygon/detail/polygon_90_set_view.hpp | 4 +- .../polygon/detail/polygon_arbitrary_formation.hpp | 38 - boost/polygon/detail/polygon_formation.hpp | 374 ++-- boost/polygon/detail/property_merge.hpp | 6 +- boost/polygon/detail/rectangle_formation.hpp | 2 +- boost/polygon/detail/scan_arbitrary.hpp | 2 +- boost/polygon/isotropy.hpp | 24 +- boost/polygon/point_data.hpp | 8 +- boost/polygon/polygon_45_set_data.hpp | 4 +- boost/polygon/polygon_90_set_data.hpp | 6 +- boost/polygon/polygon_set_data.hpp | 6 +- boost/polygon/polygon_traits.hpp | 12 - boost/polygon/segment_data.hpp | 2 +- boost/pool/detail/mutex.hpp | 2 +- boost/predef.h | 1 + boost/predef/detail/_cassert.h | 2 +- boost/predef/detail/_exception.h | 2 +- boost/predef/hardware.h | 16 + boost/predef/hardware/simd.h | 107 ++ boost/predef/hardware/simd/arm.h | 57 + boost/predef/hardware/simd/arm/versions.h | 32 + boost/predef/hardware/simd/ppc.h | 69 + boost/predef/hardware/simd/ppc/versions.h | 51 + boost/predef/hardware/simd/x86.h | 123 ++ boost/predef/hardware/simd/x86/versions.h | 129 ++ boost/predef/hardware/simd/x86_amd.h | 87 + boost/predef/hardware/simd/x86_amd/versions.h | 51 + boost/predef/platform/windows_desktop.h | 2 +- boost/predef/platform/windows_phone.h | 2 +- boost/predef/platform/windows_runtime.h | 2 +- boost/predef/platform/windows_store.h | 2 +- boost/predef/version.h | 2 +- boost/preprocessor/facilities/identity.hpp | 4 + boost/preprocessor/tuple/eat.hpp | 11 +- boost/progress.hpp | 7 +- boost/python/data_members.hpp | 2 +- boost/random.hpp | 5 + boost/random/binomial_distribution.hpp | 2 +- boost/random/chi_squared_distribution.hpp | 6 +- boost/random/detail/auto_link.hpp | 12 +- boost/random/detail/seed_impl.hpp | 18 +- boost/random/detail/signed_unsigned_tools.hpp | 10 +- boost/random/discrete_distribution.hpp | 14 +- boost/random/generate_canonical.hpp | 2 +- boost/random/hyperexponential_distribution.hpp | 883 +++++++++ boost/random/independent_bits.hpp | 29 +- boost/random/piecewise_constant_distribution.hpp | 2 +- boost/random/piecewise_linear_distribution.hpp | 3 +- boost/random/seed_seq.hpp | 16 +- boost/random/shuffle_order.hpp | 2 +- boost/random/subtract_with_carry.hpp | 4 +- boost/random/traits.hpp | 107 ++ boost/random/triangle_distribution.hpp | 2 +- boost/random/uniform_01.hpp | 32 +- boost/random/uniform_int_distribution.hpp | 50 +- boost/random/uniform_real_distribution.hpp | 2 +- boost/random/uniform_smallint.hpp | 32 +- boost/rational.hpp | 54 +- boost/regex/config.hpp | 58 +- boost/regex/icu.hpp | 166 +- boost/regex/mfc.hpp | 4 +- boost/regex/pattern_except.hpp | 4 +- boost/regex/v4/basic_regex.hpp | 31 +- boost/regex/v4/basic_regex_creator.hpp | 42 +- boost/regex/v4/basic_regex_parser.hpp | 212 ++- boost/regex/v4/cpp_regex_traits.hpp | 211 ++- boost/regex/v4/cregex.hpp | 14 +- boost/regex/v4/fileiter.hpp | 18 +- boost/regex/v4/instances.hpp | 21 +- boost/regex/v4/iterator_traits.hpp | 4 +- boost/regex/v4/match_results.hpp | 34 +- boost/regex/v4/mem_block_cache.hpp | 2 +- boost/regex/v4/perl_matcher.hpp | 55 +- boost/regex/v4/perl_matcher_common.hpp | 40 +- boost/regex/v4/perl_matcher_non_recursive.hpp | 219 ++- boost/regex/v4/perl_matcher_recursive.hpp | 126 +- boost/regex/v4/primary_transform.hpp | 4 +- boost/regex/v4/protected_call.hpp | 2 +- boost/regex/v4/regex_format.hpp | 28 +- boost/regex/v4/regex_grep.hpp | 2 +- boost/regex/v4/regex_iterator.hpp | 6 +- boost/regex/v4/regex_match.hpp | 2 +- boost/regex/v4/regex_raw_buffer.hpp | 4 +- boost/regex/v4/regex_replace.hpp | 8 +- boost/regex/v4/regex_search.hpp | 4 +- boost/regex/v4/regex_split.hpp | 8 +- boost/regex/v4/regex_token_iterator.hpp | 6 +- boost/regex/v4/regex_traits.hpp | 16 +- boost/regex/v4/regex_traits_defaults.hpp | 14 +- boost/regex/v4/regex_workaround.hpp | 7 +- boost/regex/v4/states.hpp | 26 +- boost/regex/v4/sub_match.hpp | 143 +- boost/regex/v4/u32regex_iterator.hpp | 4 +- boost/regex/v4/u32regex_token_iterator.hpp | 4 +- boost/regex/v4/w32_regex_traits.hpp | 82 +- .../serialization/archive_input_unordered_map.hpp | 85 + .../serialization/archive_input_unordered_set.hpp | 70 + boost/serialization/boost_unordered_map.hpp | 154 ++ boost/serialization/boost_unordered_set.hpp | 150 ++ boost/serialization/collections_load_imp.hpp | 2 +- boost/serialization/deque.hpp | 2 + boost/serialization/detail/get_data.hpp | 2 - boost/serialization/extended_type_info.hpp | 6 +- boost/serialization/extended_type_info_typeid.hpp | 4 +- boost/serialization/singleton.hpp | 4 +- boost/serialization/static_warning.hpp | 2 +- boost/serialization/unordered_map.hpp | 89 +- boost/serialization/unordered_set.hpp | 74 +- boost/serialization/variant.hpp | 1 - boost/signals2/detail/auto_buffer.hpp | 4 +- boost/signals2/detail/variadic_slot_invoker.hpp | 15 + boost/signals2/postconstructible.hpp | 2 +- boost/smart_ptr/detail/operator_bool.hpp | 3 +- boost/smart_ptr/detail/shared_count.hpp | 10 + boost/smart_ptr/detail/sp_disable_deprecated.hpp | 40 + boost/smart_ptr/detail/sp_interlocked.hpp | 11 + boost/smart_ptr/detail/yield_k.hpp | 9 + boost/smart_ptr/scoped_ptr.hpp | 10 + boost/smart_ptr/shared_ptr.hpp | 10 + boost/sort/spreadsort/detail/float_sort.hpp | 55 +- boost/sort/spreadsort/detail/string_sort.hpp | 2 +- boost/sort/spreadsort/spreadsort.hpp | 35 +- boost/spirit/home/classic/tree/parse_tree.hpp | 1 - boost/spirit/home/karma/directive/duplicate.hpp | 2 +- .../spirit/home/karma/directive/left_alignment.hpp | 4 +- boost/spirit/home/karma/string/lit.hpp | 3 - boost/spirit/home/qi/detail/assign_to.hpp | 11 + boost/spirit/home/qi/detail/attributes.hpp | 2 +- .../home/qi/numeric/detail/numeric_utils.hpp | 31 +- boost/spirit/home/qi/numeric/detail/real_impl.hpp | 8 +- boost/spirit/home/support/attributes.hpp | 5 +- boost/spirit/home/support/char_encoding/ascii.hpp | 29 +- boost/spirit/home/support/detail/endian/endian.hpp | 21 +- boost/spirit/home/support/terminal.hpp | 44 +- boost/spirit/home/x3/char/char_set.hpp | 4 +- boost/static_assert.hpp | 23 +- boost/test/auto_unit_test.hpp | 2 +- boost/test/data/config.hpp | 9 +- boost/test/data/dataset.hpp | 2 +- boost/test/data/for_each_sample.hpp | 71 + boost/test/data/generators.hpp | 2 +- boost/test/data/monomorphic.hpp | 3 +- boost/test/data/monomorphic/array.hpp | 66 +- boost/test/data/monomorphic/collection.hpp | 68 +- boost/test/data/monomorphic/dataset.hpp | 174 -- boost/test/data/monomorphic/fwd.hpp | 201 +-- boost/test/data/monomorphic/generate.hpp | 53 +- boost/test/data/monomorphic/generators.hpp | 2 +- .../test/data/monomorphic/generators/keywords.hpp | 2 +- boost/test/data/monomorphic/generators/random.hpp | 12 +- boost/test/data/monomorphic/generators/xrange.hpp | 39 +- boost/test/data/monomorphic/grid.hpp | 132 +- boost/test/data/monomorphic/initializer_list.hpp | 81 + boost/test/data/monomorphic/join.hpp | 152 +- boost/test/data/monomorphic/singleton.hpp | 84 +- boost/test/data/monomorphic/zip.hpp | 130 +- boost/test/data/size.hpp | 2 +- boost/test/data/test_case.hpp | 22 +- boost/test/data/traits.hpp | 87 + boost/test/debug.hpp | 2 +- boost/test/debug_config.hpp | 2 +- boost/test/detail/config.hpp | 14 +- boost/test/detail/enable_warnings.hpp | 9 +- boost/test/detail/fwd_decl.hpp | 2 +- boost/test/detail/global_typedef.hpp | 15 +- boost/test/detail/log_level.hpp | 2 +- boost/test/detail/pp_variadic.hpp | 2 +- boost/test/detail/suppress_warnings.hpp | 14 +- boost/test/detail/throw_exception.hpp | 39 +- boost/test/detail/workaround.hpp | 2 +- boost/test/execution_monitor.hpp | 14 +- boost/test/floating_point_comparison.hpp | 2 +- boost/test/framework.hpp | 15 +- boost/test/impl/compiler_log_formatter.ipp | 41 +- boost/test/impl/cpp_main.ipp | 8 +- boost/test/impl/debug.ipp | 6 +- boost/test/impl/decorator.ipp | 6 +- boost/test/impl/execution_monitor.ipp | 16 +- boost/test/impl/framework.ipp | 98 +- boost/test/impl/plain_report_formatter.ipp | 14 +- boost/test/impl/progress_monitor.ipp | 30 +- boost/test/impl/results_collector.ipp | 2 +- boost/test/impl/results_reporter.ipp | 31 +- boost/test/impl/test_main.ipp | 2 +- boost/test/impl/test_tools.ipp | 9 +- boost/test/impl/test_tree.ipp | 15 +- boost/test/impl/unit_test_log.ipp | 16 +- boost/test/impl/unit_test_main.ipp | 27 +- boost/test/impl/unit_test_monitor.ipp | 14 +- boost/test/impl/unit_test_parameters.ipp | 1085 +++++------ boost/test/impl/xml_log_formatter.ipp | 45 +- boost/test/impl/xml_report_formatter.ipp | 25 +- boost/test/included/execution_monitor.hpp | 2 +- boost/test/included/prg_exec_monitor.hpp | 2 +- boost/test/included/test_exec_monitor.hpp | 2 +- boost/test/included/unit_test.hpp | 2 +- boost/test/included/unit_test_framework.hpp | 2 +- boost/test/minimal.hpp | 2 +- boost/test/output/compiler_log_formatter.hpp | 7 +- boost/test/output/plain_report_formatter.hpp | 5 +- boost/test/output/xml_log_formatter.hpp | 2 +- boost/test/output/xml_report_formatter.hpp | 2 +- boost/test/output_test_stream.hpp | 2 +- boost/test/parameterized_test.hpp | 2 +- boost/test/predicate_result.hpp | 2 +- boost/test/prg_exec_monitor.hpp | 2 +- boost/test/progress_monitor.hpp | 2 +- boost/test/results_collector.hpp | 2 +- boost/test/results_reporter.hpp | 2 +- boost/test/test_case_template.hpp | 2 +- boost/test/test_exec_monitor.hpp | 2 +- boost/test/test_tools.hpp | 17 +- boost/test/tools/assertion.hpp | 15 +- boost/test/tools/assertion_result.hpp | 2 +- boost/test/tools/collection_comparison_op.hpp | 23 +- boost/test/tools/context.hpp | 2 +- boost/test/tools/cstring_comparison_op.hpp | 2 +- boost/test/tools/detail/bitwise_manip.hpp | 2 +- boost/test/tools/detail/expression_holder.hpp | 2 +- boost/test/tools/detail/fwd.hpp | 2 +- boost/test/tools/detail/indirections.hpp | 2 +- boost/test/tools/detail/it_pair.hpp | 2 +- boost/test/tools/detail/lexicographic_manip.hpp | 2 +- boost/test/tools/detail/per_element_manip.hpp | 2 +- boost/test/tools/detail/print_helper.hpp | 2 +- boost/test/tools/detail/tolerance_manip.hpp | 4 +- boost/test/tools/floating_point_comparison.hpp | 4 +- boost/test/tools/fpc_op.hpp | 16 +- boost/test/tools/fpc_tolerance.hpp | 2 +- boost/test/tools/interface.hpp | 2 +- boost/test/tools/old/impl.hpp | 2 +- boost/test/tools/old/interface.hpp | 26 +- boost/test/tools/output_test_stream.hpp | 2 +- boost/test/tree/auto_registration.hpp | 2 +- boost/test/tree/decorator.hpp | 2 +- boost/test/tree/fixture.hpp | 2 +- boost/test/tree/global_fixture.hpp | 2 +- boost/test/tree/observer.hpp | 4 +- boost/test/tree/test_case_counter.hpp | 2 +- boost/test/tree/test_case_template.hpp | 2 +- boost/test/tree/test_unit.hpp | 10 +- boost/test/tree/traverse.hpp | 2 +- boost/test/tree/visitor.hpp | 2 +- boost/test/unit_test.hpp | 2 +- boost/test/unit_test_log.hpp | 2 +- boost/test/unit_test_log_formatter.hpp | 2 +- boost/test/unit_test_monitor.hpp | 2 +- boost/test/unit_test_parameters.hpp | 142 +- boost/test/unit_test_suite.hpp | 11 +- boost/test/utils/algorithm.hpp | 7 +- boost/test/utils/assign_op.hpp | 2 +- boost/test/utils/basic_cstring/basic_cstring.hpp | 2 +- .../test/utils/basic_cstring/basic_cstring_fwd.hpp | 2 +- boost/test/utils/basic_cstring/bcs_char_traits.hpp | 2 +- boost/test/utils/basic_cstring/compare.hpp | 2 +- boost/test/utils/basic_cstring/io.hpp | 2 +- boost/test/utils/class_properties.hpp | 2 +- boost/test/utils/custom_manip.hpp | 4 +- boost/test/utils/fixed_mapping.hpp | 120 -- boost/test/utils/foreach.hpp | 2 +- boost/test/utils/is_cstring.hpp | 2 +- boost/test/utils/is_forward_iterable.hpp | 130 +- .../test/utils/iterator/ifstream_line_iterator.hpp | 105 -- .../test/utils/iterator/input_iterator_facade.hpp | 7 +- .../test/utils/iterator/istream_line_iterator.hpp | 93 - boost/test/utils/iterator/token_iterator.hpp | 23 +- boost/test/utils/lazy_ostream.hpp | 4 +- boost/test/utils/named_params.hpp | 228 +-- boost/test/utils/nullstream.hpp | 2 +- boost/test/utils/rtti.hpp | 4 +- boost/test/utils/runtime/argument.hpp | 119 +- boost/test/utils/runtime/argument_factory.hpp | 242 +++ boost/test/utils/runtime/cla/argument_factory.hpp | 216 --- boost/test/utils/runtime/cla/argv_traverser.cpp | 16 - boost/test/utils/runtime/cla/argv_traverser.hpp | 133 +- boost/test/utils/runtime/cla/argv_traverser.ipp | 212 --- boost/test/utils/runtime/cla/basic_parameter.hpp | 85 - boost/test/utils/runtime/cla/char_parameter.cpp | 16 - boost/test/utils/runtime/cla/char_parameter.hpp | 100 -- boost/test/utils/runtime/cla/char_parameter.ipp | 57 - .../runtime/cla/detail/argument_value_usage.hpp | 81 - .../test/utils/runtime/cla/dual_name_parameter.cpp | 16 - .../test/utils/runtime/cla/dual_name_parameter.hpp | 98 - .../test/utils/runtime/cla/dual_name_parameter.ipp | 90 - boost/test/utils/runtime/cla/fwd.hpp | 55 - boost/test/utils/runtime/cla/id_policy.cpp | 16 - boost/test/utils/runtime/cla/id_policy.hpp | 147 -- boost/test/utils/runtime/cla/id_policy.ipp | 118 -- .../utils/runtime/cla/iface/argument_factory.hpp | 51 - boost/test/utils/runtime/cla/iface/id_policy.hpp | 73 - boost/test/utils/runtime/cla/modifier.hpp | 69 - boost/test/utils/runtime/cla/named_parameter.cpp | 16 - boost/test/utils/runtime/cla/named_parameter.hpp | 95 - boost/test/utils/runtime/cla/named_parameter.ipp | 129 -- boost/test/utils/runtime/cla/parameter.hpp | 151 -- boost/test/utils/runtime/cla/parser.cpp | 18 - boost/test/utils/runtime/cla/parser.hpp | 515 +++++- boost/test/utils/runtime/cla/parser.ipp | 267 --- .../utils/runtime/cla/positional_parameter.hpp | 91 - boost/test/utils/runtime/cla/typed_parameter.hpp | 70 - boost/test/utils/runtime/cla/validation.cpp | 16 - boost/test/utils/runtime/cla/validation.hpp | 57 - boost/test/utils/runtime/cla/validation.ipp | 61 - boost/test/utils/runtime/cla/value_generator.hpp | 81 - boost/test/utils/runtime/cla/value_handler.hpp | 57 - boost/test/utils/runtime/config.hpp | 162 -- boost/test/utils/runtime/configuration.hpp | 61 - boost/test/utils/runtime/env/environment.cpp | 23 - boost/test/utils/runtime/env/environment.hpp | 171 -- boost/test/utils/runtime/env/environment.ipp | 125 -- boost/test/utils/runtime/env/fetch.hpp | 108 ++ boost/test/utils/runtime/env/fwd.hpp | 61 - boost/test/utils/runtime/env/modifier.hpp | 47 - boost/test/utils/runtime/env/variable.hpp | 223 --- boost/test/utils/runtime/errors.hpp | 195 ++ boost/test/utils/runtime/file/config_file.cpp | 249 --- boost/test/utils/runtime/file/config_file.hpp | 182 -- .../utils/runtime/file/config_file_iterator.cpp | 685 ------- .../utils/runtime/file/config_file_iterator.hpp | 166 -- boost/test/utils/runtime/finalize.hpp | 56 + boost/test/utils/runtime/fwd.hpp | 24 +- .../utils/runtime/interpret_argument_value.hpp | 163 -- boost/test/utils/runtime/modifier.hpp | 101 ++ boost/test/utils/runtime/parameter.hpp | 450 ++++- boost/test/utils/runtime/trace.hpp | 30 - boost/test/utils/runtime/validation.hpp | 85 - boost/test/utils/setcolor.hpp | 13 +- boost/test/utils/string_cast.hpp | 69 + boost/test/utils/trivial_singleton.hpp | 2 +- boost/test/utils/wrap_stringstream.hpp | 2 +- boost/test/utils/xml_printer.hpp | 39 +- boost/thread/concurrent_queues/sync_queue.hpp | 7 + .../thread/concurrent_queues/sync_timed_queue.hpp | 2 +- boost/thread/csbl/devector.hpp | 8 +- boost/thread/detail/invoker.hpp | 36 +- boost/thread/detail/move.hpp | 19 + boost/thread/detail/nullary_function.hpp | 2 +- boost/thread/detail/thread.hpp | 7 +- boost/thread/detail/thread_group.hpp | 3 +- boost/thread/executors/basic_thread_pool.hpp | 31 +- boost/thread/executors/executor.hpp | 5 +- boost/thread/executors/executor_adaptor.hpp | 9 +- boost/thread/executors/generic_executor_ref.hpp | 20 +- boost/thread/executors/loop_executor.hpp | 18 +- boost/thread/executors/serial_executor.hpp | 15 +- boost/thread/executors/serial_executor_cont.hpp | 2 +- boost/thread/executors/thread_executor.hpp | 1 + .../experimental/parallel/v2/task_region.hpp | 2 +- boost/thread/future.hpp | 1379 +++++++------- boost/thread/futures/launch.hpp | 1 + boost/thread/latch.hpp | 3 + boost/thread/poly_lockable.hpp | 4 +- boost/thread/pthread/condition_variable.hpp | 141 +- boost/thread/pthread/condition_variable_fwd.hpp | 170 +- boost/thread/pthread/once_atomic.hpp | 4 +- boost/thread/shared_mutex.hpp | 1 + boost/thread/v2/thread.hpp | 17 +- boost/thread/win32/condition_variable.hpp | 16 +- boost/thread/win32/shared_mutex.hpp | 4 +- boost/thread/win32/thread_data.hpp | 26 +- boost/thread/win32/thread_primitives.hpp | 42 +- boost/timer/timer.hpp | 2 +- boost/type_erasure/binding.hpp | 36 + boost/type_erasure/detail/adapt_to_vtable.hpp | 38 + boost/type_erasure/detail/auto_link.hpp | 38 + boost/type_erasure/detail/check_map.hpp | 2 + boost/type_erasure/detail/dynamic_vtable.hpp | 172 ++ boost/type_erasure/detail/rebind_placeholders.hpp | 1 + boost/type_erasure/detail/storage.hpp | 4 +- boost/type_erasure/dynamic_any_cast.hpp | 234 +++ boost/type_erasure/dynamic_binding.hpp | 46 + boost/type_erasure/is_placeholder.hpp | 7 - boost/type_erasure/iterator.hpp | 7 +- boost/type_erasure/register_binding.hpp | 169 ++ boost/type_traits.hpp | 72 +- boost/type_traits/add_const.hpp | 17 +- boost/type_traits/add_cv.hpp | 9 +- boost/type_traits/add_lvalue_reference.hpp | 15 +- boost/type_traits/add_pointer.hpp | 23 +- boost/type_traits/add_reference.hpp | 41 +- boost/type_traits/add_rvalue_reference.hpp | 10 +- boost/type_traits/add_volatile.hpp | 9 +- boost/type_traits/aligned_storage.hpp | 143 +- boost/type_traits/alignment_of.hpp | 25 +- boost/type_traits/broken_compiler_spec.hpp | 17 +- boost/type_traits/common_type.hpp | 249 ++- boost/type_traits/conditional.hpp | 9 +- boost/type_traits/config.hpp | 61 +- boost/type_traits/copy_cv.hpp | 34 + boost/type_traits/decay.hpp | 25 +- boost/type_traits/declval.hpp | 44 + boost/type_traits/detail/bool_trait_def.hpp | 23 +- .../type_traits/detail/common_arithmetic_type.hpp | 212 +++ boost/type_traits/detail/common_type_imp.hpp | 333 ---- boost/type_traits/detail/common_type_impl.hpp | 107 ++ .../detail/composite_member_pointer_type.hpp | 113 ++ .../type_traits/detail/composite_pointer_type.hpp | 153 ++ boost/type_traits/detail/config.hpp | 72 + boost/type_traits/detail/cv_traits_impl.hpp | 140 -- boost/type_traits/detail/false_result.hpp | 28 - boost/type_traits/detail/has_binary_operator.hpp | 23 +- boost/type_traits/detail/has_postfix_operator.hpp | 23 +- boost/type_traits/detail/has_prefix_operator.hpp | 25 +- boost/type_traits/detail/ice_and.hpp | 7 + boost/type_traits/detail/ice_eq.hpp | 7 + boost/type_traits/detail/ice_not.hpp | 7 + boost/type_traits/detail/ice_or.hpp | 7 + .../type_traits/detail/is_function_ptr_helper.hpp | 18 +- .../type_traits/detail/is_function_ptr_tester.hpp | 17 +- .../type_traits/detail/is_mem_fun_pointer_impl.hpp | 16 +- .../detail/is_mem_fun_pointer_tester.hpp | 18 +- boost/type_traits/detail/mp_defer.hpp | 56 + boost/type_traits/detail/size_t_trait_def.hpp | 51 - boost/type_traits/detail/size_t_trait_undef.hpp | 16 - boost/type_traits/detail/template_arity_spec.hpp | 27 +- boost/type_traits/detail/type_trait_def.hpp | 67 - boost/type_traits/detail/type_trait_undef.hpp | 19 - boost/type_traits/detail/wrap.hpp | 18 - boost/type_traits/extent.hpp | 7 +- boost/type_traits/floating_point_promotion.hpp | 81 +- boost/type_traits/has_bit_and.hpp | 38 +- boost/type_traits/has_bit_and_assign.hpp | 46 +- boost/type_traits/has_bit_or.hpp | 38 +- boost/type_traits/has_bit_or_assign.hpp | 46 +- boost/type_traits/has_bit_xor.hpp | 38 +- boost/type_traits/has_bit_xor_assign.hpp | 46 +- boost/type_traits/has_complement.hpp | 14 +- boost/type_traits/has_dereference.hpp | 10 +- boost/type_traits/has_divides.hpp | 28 +- boost/type_traits/has_divides_assign.hpp | 36 +- boost/type_traits/has_equal_to.hpp | 40 +- boost/type_traits/has_greater.hpp | 40 +- boost/type_traits/has_greater_equal.hpp | 40 +- boost/type_traits/has_left_shift.hpp | 38 +- boost/type_traits/has_left_shift_assign.hpp | 46 +- boost/type_traits/has_less.hpp | 40 +- boost/type_traits/has_less_equal.hpp | 40 +- boost/type_traits/has_logical_and.hpp | 32 +- boost/type_traits/has_logical_or.hpp | 32 +- boost/type_traits/has_minus.hpp | 58 +- boost/type_traits/has_minus_assign.hpp | 58 +- boost/type_traits/has_modulus.hpp | 38 +- boost/type_traits/has_modulus_assign.hpp | 46 +- boost/type_traits/has_multiplies.hpp | 28 +- boost/type_traits/has_multiplies_assign.hpp | 36 +- boost/type_traits/has_new_operator.hpp | 23 +- boost/type_traits/has_not_equal_to.hpp | 40 +- boost/type_traits/has_nothrow_assign.hpp | 75 +- boost/type_traits/has_nothrow_constructor.hpp | 67 +- boost/type_traits/has_nothrow_copy.hpp | 75 +- boost/type_traits/has_nothrow_destructor.hpp | 30 +- boost/type_traits/has_plus.hpp | 46 +- boost/type_traits/has_plus_assign.hpp | 62 +- boost/type_traits/has_post_decrement.hpp | 22 +- boost/type_traits/has_post_increment.hpp | 22 +- boost/type_traits/has_pre_decrement.hpp | 22 +- boost/type_traits/has_pre_increment.hpp | 22 +- boost/type_traits/has_right_shift.hpp | 38 +- boost/type_traits/has_right_shift_assign.hpp | 46 +- boost/type_traits/has_trivial_assign.hpp | 52 +- boost/type_traits/has_trivial_constructor.hpp | 56 +- boost/type_traits/has_trivial_copy.hpp | 82 +- boost/type_traits/has_trivial_destructor.hpp | 43 +- boost/type_traits/has_trivial_move_assign.hpp | 65 +- boost/type_traits/has_trivial_move_constructor.hpp | 70 +- boost/type_traits/has_virtual_destructor.hpp | 9 +- boost/type_traits/integral_constant.hpp | 107 +- boost/type_traits/integral_promotion.hpp | 33 +- boost/type_traits/intrinsics.hpp | 126 +- boost/type_traits/is_abstract.hpp | 12 +- boost/type_traits/is_arithmetic.hpp | 35 +- boost/type_traits/is_array.hpp | 29 +- boost/type_traits/is_assignable.hpp | 76 + boost/type_traits/is_base_and_derived.hpp | 24 +- boost/type_traits/is_base_of.hpp | 26 +- boost/type_traits/is_base_of_tr1.hpp | 23 +- boost/type_traits/is_class.hpp | 49 +- boost/type_traits/is_complex.hpp | 22 +- boost/type_traits/is_compound.hpp | 26 +- boost/type_traits/is_const.hpp | 60 +- boost/type_traits/is_constructible.hpp | 80 + boost/type_traits/is_convertible.hpp | 124 +- boost/type_traits/is_copy_assignable.hpp | 18 +- boost/type_traits/is_copy_constructible.hpp | 222 ++- boost/type_traits/is_default_constructible.hpp | 64 + boost/type_traits/is_destructible.hpp | 60 + boost/type_traits/is_empty.hpp | 38 +- boost/type_traits/is_enum.hpp | 56 +- boost/type_traits/is_final.hpp | 23 +- boost/type_traits/is_float.hpp | 11 +- boost/type_traits/is_floating_point.hpp | 21 +- boost/type_traits/is_function.hpp | 21 +- boost/type_traits/is_fundamental.hpp | 23 +- boost/type_traits/is_integral.hpp | 75 +- boost/type_traits/is_lvalue_reference.hpp | 20 +- boost/type_traits/is_member_function_pointer.hpp | 43 +- boost/type_traits/is_member_object_pointer.hpp | 28 +- boost/type_traits/is_member_pointer.hpp | 34 +- boost/type_traits/is_nothrow_move_assignable.hpp | 77 +- .../type_traits/is_nothrow_move_constructible.hpp | 99 +- boost/type_traits/is_object.hpp | 31 +- boost/type_traits/is_pod.hpp | 49 +- boost/type_traits/is_pointer.hpp | 65 +- boost/type_traits/is_polymorphic.hpp | 19 +- boost/type_traits/is_reference.hpp | 27 +- boost/type_traits/is_rvalue_reference.hpp | 12 +- boost/type_traits/is_same.hpp | 12 +- boost/type_traits/is_scalar.hpp | 34 +- boost/type_traits/is_signed.hpp | 139 +- boost/type_traits/is_stateless.hpp | 31 +- boost/type_traits/is_union.hpp | 38 +- boost/type_traits/is_unsigned.hpp | 142 +- boost/type_traits/is_virtual_base_of.hpp | 24 +- boost/type_traits/is_void.hpp | 26 +- boost/type_traits/is_volatile.hpp | 59 +- boost/type_traits/make_signed.hpp | 90 +- boost/type_traits/make_unsigned.hpp | 89 +- boost/type_traits/promote.hpp | 22 +- boost/type_traits/rank.hpp | 9 +- boost/type_traits/remove_all_extents.hpp | 23 +- boost/type_traits/remove_bounds.hpp | 27 +- boost/type_traits/remove_const.hpp | 62 +- boost/type_traits/remove_cv.hpp | 49 +- boost/type_traits/remove_extent.hpp | 23 +- boost/type_traits/remove_pointer.hpp | 18 +- boost/type_traits/remove_reference.hpp | 15 +- boost/type_traits/remove_volatile.hpp | 57 +- boost/type_traits/transform_traits_spec.hpp | 14 - boost/type_traits/type_identity.hpp | 22 + boost/type_traits/type_with_alignment.hpp | 276 +-- boost/utility/declval.hpp | 33 +- boost/utility/string_ref.hpp | 6 +- boost/uuid/detail/config.hpp | 22 +- boost/uuid/detail/uuid_x86.hpp | 30 +- boost/uuid/seed_rng.hpp | 5 +- boost/variant/detail/bool_trait_def.hpp | 30 - boost/variant/detail/bool_trait_undef.hpp | 21 - boost/variant/variant.hpp | 5 +- boost/version.hpp | 4 +- boost/vmd/array.hpp | 18 + boost/vmd/array/to_seq.hpp | 49 + boost/vmd/array/to_tuple.hpp | 49 + boost/vmd/assert.hpp | 58 + boost/vmd/assert_is_array.hpp | 113 ++ boost/vmd/assert_is_empty.hpp | 105 ++ boost/vmd/assert_is_identifier.hpp | 158 ++ boost/vmd/assert_is_list.hpp | 113 ++ boost/vmd/assert_is_number.hpp | 73 + boost/vmd/assert_is_seq.hpp | 113 ++ boost/vmd/assert_is_tuple.hpp | 73 + boost/vmd/assert_is_type.hpp | 113 ++ boost/vmd/detail/adjust_tuple_type.hpp | 97 + boost/vmd/detail/array.hpp | 189 ++ boost/vmd/detail/assert.hpp | 69 + boost/vmd/detail/data_equal.hpp | 202 +++ boost/vmd/detail/data_equal_common.hpp | 409 +++++ boost/vmd/detail/empty_result.hpp | 12 + boost/vmd/detail/equal.hpp | 562 ++++++ boost/vmd/detail/equal_common.hpp | 153 ++ boost/vmd/detail/equal_type.hpp | 21 + boost/vmd/detail/identifier.hpp | 429 +++++ boost/vmd/detail/identifier_concat.hpp | 21 + boost/vmd/detail/identifier_type.hpp | 118 ++ boost/vmd/detail/idprefix.hpp | 14 + boost/vmd/detail/is_array.hpp | 41 + boost/vmd/detail/is_array_common.hpp | 248 +++ boost/vmd/detail/is_empty.hpp | 61 + boost/vmd/detail/is_empty_array.hpp | 20 + boost/vmd/detail/is_empty_tuple.hpp | 74 + boost/vmd/detail/is_entire.hpp | 23 + boost/vmd/detail/is_identifier.hpp | 96 + boost/vmd/detail/is_list.hpp | 207 +++ boost/vmd/detail/is_number.hpp | 38 + boost/vmd/detail/is_seq.hpp | 27 + boost/vmd/detail/is_tuple.hpp | 20 + boost/vmd/detail/is_type.hpp | 57 + boost/vmd/detail/is_type_type.hpp | 25 + boost/vmd/detail/list.hpp | 212 +++ boost/vmd/detail/match_identifier.hpp | 160 ++ boost/vmd/detail/match_identifier_common.hpp | 37 + boost/vmd/detail/match_single_identifier.hpp | 16 + boost/vmd/detail/modifiers.hpp | 104 ++ boost/vmd/detail/mods.hpp | 707 ++++++++ boost/vmd/detail/nil_registration.hpp | 13 + boost/vmd/detail/not_empty.hpp | 20 + boost/vmd/detail/number_registration.hpp | 784 ++++++++ boost/vmd/detail/only_after.hpp | 37 + boost/vmd/detail/parens.hpp | 54 + boost/vmd/detail/parens_common.hpp | 21 + boost/vmd/detail/parens_split.hpp | 24 + .../vmd/detail/recurse/data_equal/data_equal_1.hpp | 185 ++ .../detail/recurse/data_equal/data_equal_10.hpp | 185 ++ .../detail/recurse/data_equal/data_equal_11.hpp | 185 ++ .../detail/recurse/data_equal/data_equal_12.hpp | 185 ++ .../detail/recurse/data_equal/data_equal_13.hpp | 185 ++ .../detail/recurse/data_equal/data_equal_14.hpp | 185 ++ .../detail/recurse/data_equal/data_equal_15.hpp | 185 ++ .../detail/recurse/data_equal/data_equal_16.hpp | 185 ++ .../vmd/detail/recurse/data_equal/data_equal_2.hpp | 185 ++ .../vmd/detail/recurse/data_equal/data_equal_3.hpp | 185 ++ .../vmd/detail/recurse/data_equal/data_equal_4.hpp | 185 ++ .../vmd/detail/recurse/data_equal/data_equal_5.hpp | 185 ++ .../vmd/detail/recurse/data_equal/data_equal_6.hpp | 185 ++ .../vmd/detail/recurse/data_equal/data_equal_7.hpp | 185 ++ .../vmd/detail/recurse/data_equal/data_equal_8.hpp | 185 ++ .../vmd/detail/recurse/data_equal/data_equal_9.hpp | 185 ++ .../recurse/data_equal/data_equal_headers.hpp | 22 + .../recurse/data_equal/data_equal_specific.hpp | 185 ++ boost/vmd/detail/recurse/equal/equal_1.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_10.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_11.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_12.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_13.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_14.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_15.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_16.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_2.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_3.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_4.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_5.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_6.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_7.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_8.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_9.hpp | 282 +++ boost/vmd/detail/recurse/equal/equal_headers.hpp | 23 + boost/vmd/detail/seq.hpp | 236 +++ boost/vmd/detail/sequence_arity.hpp | 66 + boost/vmd/detail/sequence_common.hpp | 766 ++++++++ boost/vmd/detail/sequence_elem.hpp | 985 ++++++++++ boost/vmd/detail/sequence_enum.hpp | 40 + boost/vmd/detail/sequence_size.hpp | 21 + boost/vmd/detail/sequence_to_array.hpp | 47 + boost/vmd/detail/sequence_to_list.hpp | 47 + boost/vmd/detail/sequence_to_seq.hpp | 45 + boost/vmd/detail/sequence_to_tuple.hpp | 45 + boost/vmd/detail/sequence_type.hpp | 274 +++ boost/vmd/detail/setup.hpp | 41 + boost/vmd/detail/tuple.hpp | 196 ++ boost/vmd/detail/type_registration.hpp | 43 + boost/vmd/detail/variadic_pop_front.hpp | 24 + boost/vmd/elem.hpp | 292 +++ boost/vmd/empty.hpp | 41 + boost/vmd/enum.hpp | 103 ++ boost/vmd/equal.hpp | 89 + boost/vmd/get_type.hpp | 123 ++ boost/vmd/identity.hpp | 76 + boost/vmd/is_array.hpp | 73 + boost/vmd/is_empty.hpp | 95 + boost/vmd/is_empty_array.hpp | 98 + boost/vmd/is_empty_list.hpp | 73 + boost/vmd/is_identifier.hpp | 117 ++ boost/vmd/is_list.hpp | 73 + boost/vmd/is_multi.hpp | 67 + boost/vmd/is_number.hpp | 52 + boost/vmd/is_parens_empty.hpp | 73 + boost/vmd/is_seq.hpp | 71 + boost/vmd/is_tuple.hpp | 45 + boost/vmd/is_type.hpp | 73 + boost/vmd/is_unary.hpp | 67 + boost/vmd/list.hpp | 18 + boost/vmd/list/to_seq.hpp | 49 + boost/vmd/list/to_tuple.hpp | 49 + boost/vmd/not_equal.hpp | 94 + boost/vmd/seq.hpp | 26 + boost/vmd/seq/is_vmd_seq.hpp | 56 + boost/vmd/seq/pop_back.hpp | 51 + boost/vmd/seq/pop_front.hpp | 51 + boost/vmd/seq/push_back.hpp | 53 + boost/vmd/seq/push_front.hpp | 53 + boost/vmd/seq/remove.hpp | 57 + boost/vmd/seq/size.hpp | 52 + boost/vmd/seq/to_array.hpp | 52 + boost/vmd/seq/to_list.hpp | 65 + boost/vmd/seq/to_tuple.hpp | 49 + boost/vmd/size.hpp | 57 + boost/vmd/to_array.hpp | 101 ++ boost/vmd/to_list.hpp | 101 ++ boost/vmd/to_seq.hpp | 101 ++ boost/vmd/to_tuple.hpp | 101 ++ boost/vmd/tuple.hpp | 26 + boost/vmd/tuple/is_vmd_tuple.hpp | 56 + boost/vmd/tuple/pop_back.hpp | 73 + boost/vmd/tuple/pop_front.hpp | 73 + boost/vmd/tuple/push_back.hpp | 53 + boost/vmd/tuple/push_front.hpp | 53 + boost/vmd/tuple/remove.hpp | 84 + boost/vmd/tuple/size.hpp | 52 + boost/vmd/tuple/to_array.hpp | 52 + boost/vmd/tuple/to_list.hpp | 52 + boost/vmd/tuple/to_seq.hpp | 49 + boost/vmd/vmd.hpp | 54 + 1495 files changed, 62382 insertions(+), 25960 deletions(-) delete mode 100644 boost/align/detail/max_count_of.hpp create mode 100644 boost/align/detail/max_objects.hpp create mode 100644 boost/align/detail/max_size.hpp delete mode 100644 boost/align/detail/offset_object.hpp delete mode 100644 boost/archive/iterators/head_iterator.hpp create mode 100644 boost/asio/detail/winapi_thread.hpp create mode 100644 boost/atomic/detail/bitwise_cast.hpp delete mode 100644 boost/atomic/detail/casts.hpp create mode 100644 boost/config/platform/cloudabi.hpp delete mode 100644 boost/container/detail/alloc_lib_auto_link.hpp create mode 100644 boost/container/detail/block_list.hpp create mode 100644 boost/container/detail/block_slist.hpp create mode 100644 boost/container/detail/dispatch_uses_allocator.hpp create mode 100644 boost/container/detail/dlmalloc.hpp create mode 100644 boost/container/detail/pool_resource.hpp create mode 100644 boost/container/pmr/deque.hpp create mode 100644 boost/container/pmr/flat_map.hpp create mode 100644 boost/container/pmr/flat_set.hpp create mode 100644 boost/container/pmr/global_resource.hpp create mode 100644 boost/container/pmr/list.hpp create mode 100644 boost/container/pmr/map.hpp create mode 100644 boost/container/pmr/memory_resource.hpp create mode 100644 boost/container/pmr/monotonic_buffer_resource.hpp create mode 100644 boost/container/pmr/polymorphic_allocator.hpp create mode 100644 boost/container/pmr/pool_options.hpp create mode 100644 boost/container/pmr/resource_adaptor.hpp create mode 100644 boost/container/pmr/set.hpp create mode 100644 boost/container/pmr/slist.hpp create mode 100644 boost/container/pmr/small_vector.hpp create mode 100644 boost/container/pmr/stable_vector.hpp create mode 100644 boost/container/pmr/string.hpp create mode 100644 boost/container/pmr/synchronized_pool_resource.hpp create mode 100644 boost/container/pmr/unsynchronized_pool_resource.hpp create mode 100644 boost/container/pmr/vector.hpp create mode 100644 boost/container/uses_allocator.hpp create mode 100644 boost/container/uses_allocator_fwd.hpp delete mode 100644 boost/detail/winapi/LocalFree.hpp create mode 100644 boost/detail/winapi/apc.hpp create mode 100644 boost/detail/winapi/condition_variable.hpp create mode 100644 boost/detail/winapi/critical_section.hpp create mode 100644 boost/detail/winapi/detail/cast_ptr.hpp create mode 100644 boost/detail/winapi/event.hpp create mode 100644 boost/detail/winapi/file_mapping.hpp create mode 100644 boost/detail/winapi/heap_memory.hpp create mode 100644 boost/detail/winapi/init_once.hpp create mode 100644 boost/detail/winapi/local_memory.hpp create mode 100644 boost/detail/winapi/mutex.hpp create mode 100644 boost/detail/winapi/semaphore.hpp create mode 100644 boost/detail/winapi/srw_lock.hpp create mode 100644 boost/detail/winapi/wait.hpp create mode 100644 boost/filesystem/string_file.hpp create mode 100644 boost/fusion/container/vector/detail/config.hpp delete mode 100644 boost/fusion/support/detail/enabler.hpp create mode 100644 boost/fusion/support/detail/is_same_size.hpp delete mode 100644 boost/fusion/support/detail/result_of.hpp create mode 100644 boost/geometry/algorithms/detail/expand_by_epsilon.hpp create mode 100644 boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp create mode 100644 boost/geometry/algorithms/detail/overlay/handle_colocations.hpp create mode 100644 boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp create mode 100644 boost/geometry/index/detail/is_bounding_geometry.hpp create mode 100644 boost/geometry/index/detail/is_indexable.hpp create mode 100644 boost/geometry/util/has_infinite_coordinate.hpp create mode 100644 boost/geometry/util/has_nan_coordinate.hpp create mode 100644 boost/geometry/util/has_non_finite_coordinate.hpp create mode 100644 boost/locale/generic_codecvt.hpp create mode 100644 boost/locale/utf8_codecvt.hpp delete mode 100644 boost/lockfree/detail/branch_hints.hpp create mode 100644 boost/log/detail/adaptive_mutex.hpp delete mode 100644 boost/log/detail/spin_mutex.hpp create mode 100644 boost/math/special_functions/relative_difference.hpp create mode 100644 boost/math/special_functions/ulp.hpp create mode 100644 boost/move/detail/std_ns_begin.hpp create mode 100644 boost/move/detail/std_ns_end.hpp create mode 100644 boost/multiprecision/cpp_int/import_export.hpp create mode 100644 boost/multiprecision/traits/is_byte_container.hpp create mode 100644 boost/numeric/odeint/integrate/check_adapter.hpp create mode 100644 boost/numeric/odeint/integrate/max_step_checker.hpp create mode 100644 boost/numeric/odeint/util/odeint_error.hpp create mode 100644 boost/phoenix/function/lazy_signature.hpp create mode 100644 boost/phoenix/function/lazy_smart.hpp create mode 100644 boost/phoenix/stl/algorithm/detail/is_unordered_set_or_map.hpp create mode 100644 boost/phoenix/stl/algorithm/detail/std_unordered_set_or_map_fwd.hpp create mode 100644 boost/predef/hardware.h create mode 100644 boost/predef/hardware/simd.h create mode 100644 boost/predef/hardware/simd/arm.h create mode 100644 boost/predef/hardware/simd/arm/versions.h create mode 100644 boost/predef/hardware/simd/ppc.h create mode 100644 boost/predef/hardware/simd/ppc/versions.h create mode 100644 boost/predef/hardware/simd/x86.h create mode 100644 boost/predef/hardware/simd/x86/versions.h create mode 100644 boost/predef/hardware/simd/x86_amd.h create mode 100644 boost/predef/hardware/simd/x86_amd/versions.h create mode 100644 boost/random/hyperexponential_distribution.hpp create mode 100644 boost/random/traits.hpp create mode 100644 boost/serialization/archive_input_unordered_map.hpp create mode 100644 boost/serialization/archive_input_unordered_set.hpp create mode 100644 boost/serialization/boost_unordered_map.hpp create mode 100644 boost/serialization/boost_unordered_set.hpp create mode 100644 boost/smart_ptr/detail/sp_disable_deprecated.hpp create mode 100644 boost/test/data/for_each_sample.hpp delete mode 100644 boost/test/data/monomorphic/dataset.hpp create mode 100644 boost/test/data/monomorphic/initializer_list.hpp create mode 100644 boost/test/data/traits.hpp delete mode 100644 boost/test/utils/fixed_mapping.hpp delete mode 100644 boost/test/utils/iterator/ifstream_line_iterator.hpp delete mode 100644 boost/test/utils/iterator/istream_line_iterator.hpp create mode 100644 boost/test/utils/runtime/argument_factory.hpp delete mode 100644 boost/test/utils/runtime/cla/argument_factory.hpp delete mode 100644 boost/test/utils/runtime/cla/argv_traverser.cpp delete mode 100644 boost/test/utils/runtime/cla/argv_traverser.ipp delete mode 100644 boost/test/utils/runtime/cla/basic_parameter.hpp delete mode 100644 boost/test/utils/runtime/cla/char_parameter.cpp delete mode 100644 boost/test/utils/runtime/cla/char_parameter.hpp delete mode 100644 boost/test/utils/runtime/cla/char_parameter.ipp delete mode 100644 boost/test/utils/runtime/cla/detail/argument_value_usage.hpp delete mode 100644 boost/test/utils/runtime/cla/dual_name_parameter.cpp delete mode 100644 boost/test/utils/runtime/cla/dual_name_parameter.hpp delete mode 100644 boost/test/utils/runtime/cla/dual_name_parameter.ipp delete mode 100644 boost/test/utils/runtime/cla/fwd.hpp delete mode 100644 boost/test/utils/runtime/cla/id_policy.cpp delete mode 100644 boost/test/utils/runtime/cla/id_policy.hpp delete mode 100644 boost/test/utils/runtime/cla/id_policy.ipp delete mode 100644 boost/test/utils/runtime/cla/iface/argument_factory.hpp delete mode 100644 boost/test/utils/runtime/cla/iface/id_policy.hpp delete mode 100644 boost/test/utils/runtime/cla/modifier.hpp delete mode 100644 boost/test/utils/runtime/cla/named_parameter.cpp delete mode 100644 boost/test/utils/runtime/cla/named_parameter.hpp delete mode 100644 boost/test/utils/runtime/cla/named_parameter.ipp delete mode 100644 boost/test/utils/runtime/cla/parameter.hpp delete mode 100644 boost/test/utils/runtime/cla/parser.cpp delete mode 100644 boost/test/utils/runtime/cla/parser.ipp delete mode 100644 boost/test/utils/runtime/cla/positional_parameter.hpp delete mode 100644 boost/test/utils/runtime/cla/typed_parameter.hpp delete mode 100644 boost/test/utils/runtime/cla/validation.cpp delete mode 100644 boost/test/utils/runtime/cla/validation.hpp delete mode 100644 boost/test/utils/runtime/cla/validation.ipp delete mode 100644 boost/test/utils/runtime/cla/value_generator.hpp delete mode 100644 boost/test/utils/runtime/cla/value_handler.hpp delete mode 100644 boost/test/utils/runtime/config.hpp delete mode 100644 boost/test/utils/runtime/configuration.hpp delete mode 100644 boost/test/utils/runtime/env/environment.cpp delete mode 100644 boost/test/utils/runtime/env/environment.hpp delete mode 100644 boost/test/utils/runtime/env/environment.ipp create mode 100644 boost/test/utils/runtime/env/fetch.hpp delete mode 100644 boost/test/utils/runtime/env/fwd.hpp delete mode 100644 boost/test/utils/runtime/env/modifier.hpp delete mode 100644 boost/test/utils/runtime/env/variable.hpp create mode 100644 boost/test/utils/runtime/errors.hpp delete mode 100644 boost/test/utils/runtime/file/config_file.cpp delete mode 100644 boost/test/utils/runtime/file/config_file.hpp delete mode 100644 boost/test/utils/runtime/file/config_file_iterator.cpp delete mode 100644 boost/test/utils/runtime/file/config_file_iterator.hpp create mode 100644 boost/test/utils/runtime/finalize.hpp delete mode 100644 boost/test/utils/runtime/interpret_argument_value.hpp create mode 100644 boost/test/utils/runtime/modifier.hpp delete mode 100644 boost/test/utils/runtime/trace.hpp delete mode 100644 boost/test/utils/runtime/validation.hpp create mode 100644 boost/test/utils/string_cast.hpp create mode 100644 boost/type_erasure/detail/auto_link.hpp create mode 100644 boost/type_erasure/detail/dynamic_vtable.hpp create mode 100644 boost/type_erasure/dynamic_any_cast.hpp create mode 100644 boost/type_erasure/dynamic_binding.hpp create mode 100644 boost/type_erasure/register_binding.hpp mode change 100755 => 100644 boost/type_traits/aligned_storage.hpp create mode 100644 boost/type_traits/copy_cv.hpp mode change 100755 => 100644 boost/type_traits/decay.hpp create mode 100644 boost/type_traits/declval.hpp create mode 100644 boost/type_traits/detail/common_arithmetic_type.hpp delete mode 100644 boost/type_traits/detail/common_type_imp.hpp create mode 100644 boost/type_traits/detail/common_type_impl.hpp create mode 100644 boost/type_traits/detail/composite_member_pointer_type.hpp create mode 100644 boost/type_traits/detail/composite_pointer_type.hpp create mode 100644 boost/type_traits/detail/config.hpp delete mode 100644 boost/type_traits/detail/cv_traits_impl.hpp delete mode 100644 boost/type_traits/detail/false_result.hpp create mode 100644 boost/type_traits/detail/mp_defer.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/type_trait_def.hpp delete mode 100644 boost/type_traits/detail/type_trait_undef.hpp delete mode 100644 boost/type_traits/detail/wrap.hpp create mode 100644 boost/type_traits/is_assignable.hpp create mode 100644 boost/type_traits/is_constructible.hpp create mode 100644 boost/type_traits/is_default_constructible.hpp create mode 100644 boost/type_traits/is_destructible.hpp mode change 100755 => 100644 boost/type_traits/is_floating_point.hpp mode change 100755 => 100644 boost/type_traits/is_member_object_pointer.hpp delete mode 100644 boost/type_traits/transform_traits_spec.hpp create mode 100644 boost/type_traits/type_identity.hpp delete mode 100644 boost/variant/detail/bool_trait_def.hpp delete mode 100644 boost/variant/detail/bool_trait_undef.hpp create mode 100644 boost/vmd/array.hpp create mode 100644 boost/vmd/array/to_seq.hpp create mode 100644 boost/vmd/array/to_tuple.hpp create mode 100644 boost/vmd/assert.hpp create mode 100644 boost/vmd/assert_is_array.hpp create mode 100644 boost/vmd/assert_is_empty.hpp create mode 100644 boost/vmd/assert_is_identifier.hpp create mode 100644 boost/vmd/assert_is_list.hpp create mode 100644 boost/vmd/assert_is_number.hpp create mode 100644 boost/vmd/assert_is_seq.hpp create mode 100644 boost/vmd/assert_is_tuple.hpp create mode 100644 boost/vmd/assert_is_type.hpp create mode 100644 boost/vmd/detail/adjust_tuple_type.hpp create mode 100644 boost/vmd/detail/array.hpp create mode 100644 boost/vmd/detail/assert.hpp create mode 100644 boost/vmd/detail/data_equal.hpp create mode 100644 boost/vmd/detail/data_equal_common.hpp create mode 100644 boost/vmd/detail/empty_result.hpp create mode 100644 boost/vmd/detail/equal.hpp create mode 100644 boost/vmd/detail/equal_common.hpp create mode 100644 boost/vmd/detail/equal_type.hpp create mode 100644 boost/vmd/detail/identifier.hpp create mode 100644 boost/vmd/detail/identifier_concat.hpp create mode 100644 boost/vmd/detail/identifier_type.hpp create mode 100644 boost/vmd/detail/idprefix.hpp create mode 100644 boost/vmd/detail/is_array.hpp create mode 100644 boost/vmd/detail/is_array_common.hpp create mode 100644 boost/vmd/detail/is_empty.hpp create mode 100644 boost/vmd/detail/is_empty_array.hpp create mode 100644 boost/vmd/detail/is_empty_tuple.hpp create mode 100644 boost/vmd/detail/is_entire.hpp create mode 100644 boost/vmd/detail/is_identifier.hpp create mode 100644 boost/vmd/detail/is_list.hpp create mode 100644 boost/vmd/detail/is_number.hpp create mode 100644 boost/vmd/detail/is_seq.hpp create mode 100644 boost/vmd/detail/is_tuple.hpp create mode 100644 boost/vmd/detail/is_type.hpp create mode 100644 boost/vmd/detail/is_type_type.hpp create mode 100644 boost/vmd/detail/list.hpp create mode 100644 boost/vmd/detail/match_identifier.hpp create mode 100644 boost/vmd/detail/match_identifier_common.hpp create mode 100644 boost/vmd/detail/match_single_identifier.hpp create mode 100644 boost/vmd/detail/modifiers.hpp create mode 100644 boost/vmd/detail/mods.hpp create mode 100644 boost/vmd/detail/nil_registration.hpp create mode 100644 boost/vmd/detail/not_empty.hpp create mode 100644 boost/vmd/detail/number_registration.hpp create mode 100644 boost/vmd/detail/only_after.hpp create mode 100644 boost/vmd/detail/parens.hpp create mode 100644 boost/vmd/detail/parens_common.hpp create mode 100644 boost/vmd/detail/parens_split.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_1.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_10.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_11.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_12.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_13.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_14.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_15.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_16.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_2.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_3.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_4.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_5.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_6.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_7.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_8.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_9.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_headers.hpp create mode 100644 boost/vmd/detail/recurse/data_equal/data_equal_specific.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_1.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_10.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_11.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_12.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_13.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_14.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_15.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_16.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_2.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_3.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_4.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_5.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_6.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_7.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_8.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_9.hpp create mode 100644 boost/vmd/detail/recurse/equal/equal_headers.hpp create mode 100644 boost/vmd/detail/seq.hpp create mode 100644 boost/vmd/detail/sequence_arity.hpp create mode 100644 boost/vmd/detail/sequence_common.hpp create mode 100644 boost/vmd/detail/sequence_elem.hpp create mode 100644 boost/vmd/detail/sequence_enum.hpp create mode 100644 boost/vmd/detail/sequence_size.hpp create mode 100644 boost/vmd/detail/sequence_to_array.hpp create mode 100644 boost/vmd/detail/sequence_to_list.hpp create mode 100644 boost/vmd/detail/sequence_to_seq.hpp create mode 100644 boost/vmd/detail/sequence_to_tuple.hpp create mode 100644 boost/vmd/detail/sequence_type.hpp create mode 100644 boost/vmd/detail/setup.hpp create mode 100644 boost/vmd/detail/tuple.hpp create mode 100644 boost/vmd/detail/type_registration.hpp create mode 100644 boost/vmd/detail/variadic_pop_front.hpp create mode 100644 boost/vmd/elem.hpp create mode 100644 boost/vmd/empty.hpp create mode 100644 boost/vmd/enum.hpp create mode 100644 boost/vmd/equal.hpp create mode 100644 boost/vmd/get_type.hpp create mode 100644 boost/vmd/identity.hpp create mode 100644 boost/vmd/is_array.hpp create mode 100644 boost/vmd/is_empty.hpp create mode 100644 boost/vmd/is_empty_array.hpp create mode 100644 boost/vmd/is_empty_list.hpp create mode 100644 boost/vmd/is_identifier.hpp create mode 100644 boost/vmd/is_list.hpp create mode 100644 boost/vmd/is_multi.hpp create mode 100644 boost/vmd/is_number.hpp create mode 100644 boost/vmd/is_parens_empty.hpp create mode 100644 boost/vmd/is_seq.hpp create mode 100644 boost/vmd/is_tuple.hpp create mode 100644 boost/vmd/is_type.hpp create mode 100644 boost/vmd/is_unary.hpp create mode 100644 boost/vmd/list.hpp create mode 100644 boost/vmd/list/to_seq.hpp create mode 100644 boost/vmd/list/to_tuple.hpp create mode 100644 boost/vmd/not_equal.hpp create mode 100644 boost/vmd/seq.hpp create mode 100644 boost/vmd/seq/is_vmd_seq.hpp create mode 100644 boost/vmd/seq/pop_back.hpp create mode 100644 boost/vmd/seq/pop_front.hpp create mode 100644 boost/vmd/seq/push_back.hpp create mode 100644 boost/vmd/seq/push_front.hpp create mode 100644 boost/vmd/seq/remove.hpp create mode 100644 boost/vmd/seq/size.hpp create mode 100644 boost/vmd/seq/to_array.hpp create mode 100644 boost/vmd/seq/to_list.hpp create mode 100644 boost/vmd/seq/to_tuple.hpp create mode 100644 boost/vmd/size.hpp create mode 100644 boost/vmd/to_array.hpp create mode 100644 boost/vmd/to_list.hpp create mode 100644 boost/vmd/to_seq.hpp create mode 100644 boost/vmd/to_tuple.hpp create mode 100644 boost/vmd/tuple.hpp create mode 100644 boost/vmd/tuple/is_vmd_tuple.hpp create mode 100644 boost/vmd/tuple/pop_back.hpp create mode 100644 boost/vmd/tuple/pop_front.hpp create mode 100644 boost/vmd/tuple/push_back.hpp create mode 100644 boost/vmd/tuple/push_front.hpp create mode 100644 boost/vmd/tuple/remove.hpp create mode 100644 boost/vmd/tuple/size.hpp create mode 100644 boost/vmd/tuple/to_array.hpp create mode 100644 boost/vmd/tuple/to_list.hpp create mode 100644 boost/vmd/tuple/to_seq.hpp create mode 100644 boost/vmd/vmd.hpp (limited to 'boost') diff --git a/boost/align.hpp b/boost/align.hpp index 0b3221dffc..ce8f78d343 100644 --- a/boost/align.hpp +++ b/boost/align.hpp @@ -1,6 +1,6 @@ /* (c) 2014-2015 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. diff --git a/boost/align/align.hpp b/boost/align/align.hpp index b95d673bcd..648a65e295 100644 --- a/boost/align/align.hpp +++ b/boost/align/align.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. diff --git a/boost/align/aligned_alloc.hpp b/boost/align/aligned_alloc.hpp index 0e3ba60641..b70f4bc632 100644 --- a/boost/align/aligned_alloc.hpp +++ b/boost/align/aligned_alloc.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. diff --git a/boost/align/aligned_allocator.hpp b/boost/align/aligned_allocator.hpp index a31dfe599f..9655e3dfb2 100644 --- a/boost/align/aligned_allocator.hpp +++ b/boost/align/aligned_allocator.hpp @@ -1,6 +1,6 @@ /* -(c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com +(c) 2014-2015 Glen Joseph Fernandes + Distributed under the Boost Software License, Version 1.0. @@ -17,8 +17,8 @@ http://boost.org/LICENSE_1_0.txt #include #include #include -#include -#include +#include +#include #include #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) @@ -46,7 +46,7 @@ public: private: enum { - min_align = detail::max_align::value>::value }; @@ -57,7 +57,7 @@ public: }; #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) - aligned_allocator() BOOST_NOEXCEPT = default; + aligned_allocator() = default; #else aligned_allocator() BOOST_NOEXCEPT { } @@ -79,18 +79,18 @@ public: pointer allocate(size_type size, const_void_pointer = 0) { void* p = aligned_alloc(min_align, sizeof(T) * size); - if (!p && size > 0) { - boost::throw_exception(std::bad_alloc()); + if (size > 0 && !p) { + ::boost::throw_exception(std::bad_alloc()); } return static_cast(p); } void deallocate(pointer ptr, size_type) { - alignment::aligned_free(ptr); + ::boost::alignment::aligned_free(ptr); } BOOST_CONSTEXPR size_type max_size() const BOOST_NOEXCEPT { - return detail::max_count_of::value; + return detail::max_objects::value; } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) @@ -160,7 +160,7 @@ inline bool operator!=(const aligned_allocator Distributed under the Boost Software License, Version 1.0. @@ -17,6 +17,7 @@ http://boost.org/LICENSE_1_0.txt #include #include #include +#include #include #if !defined(BOOST_NO_CXX11_ALLOCATOR) @@ -74,9 +75,8 @@ public: private: enum { - min_align = detail::max_align::value, - alignment_of::value>::value>::value + min_align = detail::max_size::value>::value }; public: @@ -184,7 +184,7 @@ inline bool operator!=(const aligned_allocator_adaptor Distributed under the Boost Software License, Version 1.0. @@ -17,7 +17,7 @@ namespace alignment { template class aligned_allocator_adaptor; -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/aligned_allocator_forward.hpp b/boost/align/aligned_allocator_forward.hpp index 9a3f3635db..41f917f38c 100644 --- a/boost/align/aligned_allocator_forward.hpp +++ b/boost/align/aligned_allocator_forward.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -17,7 +17,7 @@ namespace alignment { template class aligned_allocator; -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/aligned_delete.hpp b/boost/align/aligned_delete.hpp index 6d8caed302..c8ad64e4da 100644 --- a/boost/align/aligned_delete.hpp +++ b/boost/align/aligned_delete.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -23,12 +23,12 @@ public: BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(ptr->~T())) { if (ptr) { ptr->~T(); - alignment::aligned_free(ptr); + ::boost::alignment::aligned_free(ptr); } } }; -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/aligned_delete_forward.hpp b/boost/align/aligned_delete_forward.hpp index 530e0970d3..375e576cb5 100644 --- a/boost/align/aligned_delete_forward.hpp +++ b/boost/align/aligned_delete_forward.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -14,7 +14,7 @@ namespace alignment { class aligned_delete; -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/alignment_of.hpp b/boost/align/alignment_of.hpp index 06d22a0259..2531ced105 100644 --- a/boost/align/alignment_of.hpp +++ b/boost/align/alignment_of.hpp @@ -1,6 +1,6 @@ /* (c) 2014-2015 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -47,7 +47,7 @@ struct alignment_of type>::type>::type>::type { }; -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/alignment_of_forward.hpp b/boost/align/alignment_of_forward.hpp index 778a9f73b8..7ab227528b 100644 --- a/boost/align/alignment_of_forward.hpp +++ b/boost/align/alignment_of_forward.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -15,7 +15,7 @@ namespace alignment { template struct alignment_of; -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/assume_aligned.hpp b/boost/align/assume_aligned.hpp index 8d730e6d79..8d9f6ccf43 100644 --- a/boost/align/assume_aligned.hpp +++ b/boost/align/assume_aligned.hpp @@ -3,7 +3,7 @@ (c) 2015 LRI UMR 8623 CNRS/University Paris Sud XI (c) 2015 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -16,7 +16,7 @@ http://boost.org/LICENSE_1_0.txt #if defined(BOOST_MSVC) #include -#elif defined(BOOST_CLANG) +#elif defined(BOOST_CLANG) && defined(__has_builtin) #include #elif BOOST_GCC_VERSION >= 40700 #include diff --git a/boost/align/detail/address.hpp b/boost/align/detail/address.hpp index 63be1a95d0..b38e571534 100644 --- a/boost/align/detail/address.hpp +++ b/boost/align/detail/address.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -17,13 +17,13 @@ namespace alignment { namespace detail { #if defined(BOOST_HAS_INTPTR_T) -typedef boost::uintptr_t address_t; +typedef boost::uintptr_t address; #else -typedef std::size_t address_t; +typedef std::size_t address; #endif -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/addressof.hpp b/boost/align/detail/addressof.hpp index 8f0c88204e..50731a70d0 100644 --- a/boost/align/detail/addressof.hpp +++ b/boost/align/detail/addressof.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -27,8 +27,8 @@ using std::addressof; using boost::addressof; #endif -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/align.hpp b/boost/align/detail/align.hpp index 00be6fd6aa..d2404b3e6d 100644 --- a/boost/align/detail/align.hpp +++ b/boost/align/detail/align.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -21,7 +21,7 @@ inline void* align(std::size_t alignment, std::size_t size, void*& ptr, std::size_t& space) { BOOST_ASSERT(detail::is_alignment(alignment)); - std::size_t n = detail::address_t(ptr) & (alignment - 1); + std::size_t n = detail::address(ptr) & (alignment - 1); if (n != 0) { n = alignment - n; } @@ -34,7 +34,7 @@ inline void* align(std::size_t alignment, std::size_t size, return p; } -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/align_cxx11.hpp b/boost/align/detail/align_cxx11.hpp index 80dc7e36a4..a95b84c70f 100644 --- a/boost/align/detail/align_cxx11.hpp +++ b/boost/align/detail/align_cxx11.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -16,7 +16,7 @@ namespace alignment { using std::align; -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/aligned_alloc.hpp b/boost/align/detail/aligned_alloc.hpp index 1852ac15a6..28c0d2938e 100644 --- a/boost/align/detail/aligned_alloc.hpp +++ b/boost/align/detail/aligned_alloc.hpp @@ -1,6 +1,6 @@ /* (c) 2014-2015 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -48,7 +48,7 @@ inline void aligned_free(void* ptr) BOOST_NOEXCEPT } } -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/aligned_alloc_android.hpp b/boost/align/detail/aligned_alloc_android.hpp index d97d67989e..2381d8be9c 100644 --- a/boost/align/detail/aligned_alloc_android.hpp +++ b/boost/align/detail/aligned_alloc_android.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -30,7 +30,7 @@ inline void aligned_free(void* ptr) BOOST_NOEXCEPT ::free(ptr); } -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/aligned_alloc_macos.hpp b/boost/align/detail/aligned_alloc_macos.hpp index 9b6d235133..da3270b084 100644 --- a/boost/align/detail/aligned_alloc_macos.hpp +++ b/boost/align/detail/aligned_alloc_macos.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -22,7 +22,7 @@ inline void* aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT { BOOST_ASSERT(detail::is_alignment(alignment)); - if (!size) { + if (size == 0) { return 0; } if (alignment < sizeof(void*)) { @@ -40,7 +40,7 @@ inline void aligned_free(void* ptr) BOOST_NOEXCEPT ::free(ptr); } -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/aligned_alloc_msvc.hpp b/boost/align/detail/aligned_alloc_msvc.hpp index 1cb7f2a3a1..92f4291893 100644 --- a/boost/align/detail/aligned_alloc_msvc.hpp +++ b/boost/align/detail/aligned_alloc_msvc.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -30,7 +30,7 @@ inline void aligned_free(void* ptr) BOOST_NOEXCEPT ::_aligned_free(ptr); } -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/aligned_alloc_posix.hpp b/boost/align/detail/aligned_alloc_posix.hpp index 3743652cbd..df64d75da3 100644 --- a/boost/align/detail/aligned_alloc_posix.hpp +++ b/boost/align/detail/aligned_alloc_posix.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -37,7 +37,7 @@ inline void aligned_free(void* ptr) BOOST_NOEXCEPT ::free(ptr); } -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/aligned_alloc_sunos.hpp b/boost/align/detail/aligned_alloc_sunos.hpp index c5778cdd75..0114597bad 100644 --- a/boost/align/detail/aligned_alloc_sunos.hpp +++ b/boost/align/detail/aligned_alloc_sunos.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -30,7 +30,7 @@ inline void aligned_free(void* ptr) BOOST_NOEXCEPT ::free(ptr); } -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/alignment_of.hpp b/boost/align/detail/alignment_of.hpp index b1d2d56920..2a630e9784 100644 --- a/boost/align/detail/alignment_of.hpp +++ b/boost/align/detail/alignment_of.hpp @@ -1,6 +1,6 @@ /* -(c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com +(c) 2014-2015 Glen Joseph Fernandes + Distributed under the Boost Software License, Version 1.0. @@ -10,20 +10,25 @@ http://boost.org/LICENSE_1_0.txt #define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_HPP #include -#include namespace boost { namespace alignment { namespace detail { +template +struct alignof_helper { + char value; + T object; +}; + template struct alignment_of : min_size) - sizeof(T)>::type { + sizeof(alignof_helper) - sizeof(T)>::type { }; -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/alignment_of_clang.hpp b/boost/align/detail/alignment_of_clang.hpp index fa96a37d9d..a8e2a349d6 100644 --- a/boost/align/detail/alignment_of_clang.hpp +++ b/boost/align/detail/alignment_of_clang.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -21,8 +21,8 @@ struct alignment_of : integral_constant { }; -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/alignment_of_codegear.hpp b/boost/align/detail/alignment_of_codegear.hpp index e8986cef66..8875e6c424 100644 --- a/boost/align/detail/alignment_of_codegear.hpp +++ b/boost/align/detail/alignment_of_codegear.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -21,8 +21,8 @@ struct alignment_of : integral_constant { }; -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/alignment_of_cxx11.hpp b/boost/align/detail/alignment_of_cxx11.hpp index 0f66098b67..cbe2d9e7a8 100644 --- a/boost/align/detail/alignment_of_cxx11.hpp +++ b/boost/align/detail/alignment_of_cxx11.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -17,8 +17,8 @@ namespace detail { using std::alignment_of; -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/alignment_of_gcc.hpp b/boost/align/detail/alignment_of_gcc.hpp index 615968b477..0812fde8e4 100644 --- a/boost/align/detail/alignment_of_gcc.hpp +++ b/boost/align/detail/alignment_of_gcc.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -21,8 +21,8 @@ struct alignment_of : integral_constant { }; -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/alignment_of_msvc.hpp b/boost/align/detail/alignment_of_msvc.hpp index 87d6ac8e28..df6912f411 100644 --- a/boost/align/detail/alignment_of_msvc.hpp +++ b/boost/align/detail/alignment_of_msvc.hpp @@ -1,6 +1,6 @@ /* -(c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com +(c) 2014-2015 Glen Joseph Fernandes + Distributed under the Boost Software License, Version 1.0. @@ -10,19 +10,26 @@ http://boost.org/LICENSE_1_0.txt #define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_MSVC_HPP #include -#include namespace boost { namespace alignment { namespace detail { +template +struct alignof_helper { + T first; + char value; + T second; +}; + template struct alignment_of - : min_size, object)>::type { + : min_size) - (sizeof(T) << 1)>::type { }; -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/assume_aligned.hpp b/boost/align/detail/assume_aligned.hpp index 0ecefa1dd0..cf77086624 100644 --- a/boost/align/detail/assume_aligned.hpp +++ b/boost/align/detail/assume_aligned.hpp @@ -3,7 +3,7 @@ (c) 2015 LRI UMR 8623 CNRS/University Paris Sud XI (c) 2015 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. diff --git a/boost/align/detail/assume_aligned_clang.hpp b/boost/align/detail/assume_aligned_clang.hpp index d72b4cae86..2ba41c6970 100644 --- a/boost/align/detail/assume_aligned_clang.hpp +++ b/boost/align/detail/assume_aligned_clang.hpp @@ -1,6 +1,6 @@ /* (c) 2015 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -9,11 +9,9 @@ http://boost.org/LICENSE_1_0.txt #ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_CLANG_HPP #define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_CLANG_HPP -#include - -#if defined(__has_builtin) && __has_builtin(__builtin_assume) +#if __has_builtin(__builtin_assume_aligned) #define BOOST_ALIGN_ASSUME_ALIGNED(ptr, alignment) \ -__builtin_assume((uintptr_t(ptr) & ((alignment) - 1)) == 0) +(ptr) = __builtin_assume_aligned((ptr), (alignment)) #else #define BOOST_ALIGN_ASSUME_ALIGNED(ptr, alignment) #endif diff --git a/boost/align/detail/assume_aligned_gcc.hpp b/boost/align/detail/assume_aligned_gcc.hpp index a1e6cb0280..f7a545851c 100644 --- a/boost/align/detail/assume_aligned_gcc.hpp +++ b/boost/align/detail/assume_aligned_gcc.hpp @@ -3,7 +3,7 @@ (c) 2015 LRI UMR 8623 CNRS/University Paris Sud XI (c) 2015 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. diff --git a/boost/align/detail/assume_aligned_intel.hpp b/boost/align/detail/assume_aligned_intel.hpp index aaaf331802..e9ec2dbeb4 100644 --- a/boost/align/detail/assume_aligned_intel.hpp +++ b/boost/align/detail/assume_aligned_intel.hpp @@ -3,7 +3,7 @@ (c) 2015 LRI UMR 8623 CNRS/University Paris Sud XI (c) 2015 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. diff --git a/boost/align/detail/assume_aligned_msvc.hpp b/boost/align/detail/assume_aligned_msvc.hpp index fdad429b08..97c1fb1add 100644 --- a/boost/align/detail/assume_aligned_msvc.hpp +++ b/boost/align/detail/assume_aligned_msvc.hpp @@ -3,7 +3,7 @@ (c) 2015 LRI UMR 8623 CNRS/University Paris Sud XI (c) 2015 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. diff --git a/boost/align/detail/integral_constant.hpp b/boost/align/detail/integral_constant.hpp index 6116fea5f5..3f8bf0a8d9 100644 --- a/boost/align/detail/integral_constant.hpp +++ b/boost/align/detail/integral_constant.hpp @@ -1,6 +1,6 @@ /* -(c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com +(c) 2014-2015 Glen Joseph Fernandes + Distributed under the Boost Software License, Version 1.0. @@ -25,24 +25,18 @@ using std::integral_constant; template struct integral_constant { typedef T value_type; - typedef integral_constant type; + typedef integral_constant type; -#if !defined(BOOST_NO_CXX11_CONSTEXPR) - constexpr operator value_type() const { + BOOST_CONSTEXPR operator value_type() const { return Value; } - static constexpr T value = Value; -#else - enum { - value = Value - }; -#endif + static BOOST_CONSTEXPR_OR_CONST T value = Value; }; #endif -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/is_aligned.hpp b/boost/align/detail/is_aligned.hpp index a861e9f4c8..cb45be3433 100644 --- a/boost/align/detail/is_aligned.hpp +++ b/boost/align/detail/is_aligned.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -22,10 +22,10 @@ inline bool is_aligned(std::size_t alignment, const void* ptr) BOOST_NOEXCEPT { BOOST_ASSERT(detail::is_alignment(alignment)); - return (detail::address_t(ptr) & (alignment - 1)) == 0; + return (detail::address(ptr) & (alignment - 1)) == 0; } -} /* :alignment */ -} /* :boost */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/is_alignment.hpp b/boost/align/detail/is_alignment.hpp index 7ac0bb3d12..12d8df974f 100644 --- a/boost/align/detail/is_alignment.hpp +++ b/boost/align/detail/is_alignment.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -22,8 +22,8 @@ BOOST_CONSTEXPR inline bool is_alignment(std::size_t value) return (value > 0) && ((value & (value - 1)) == 0); } -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/is_alignment_constant.hpp b/boost/align/detail/is_alignment_constant.hpp index 4c703cafc0..2c29343b2d 100644 --- a/boost/align/detail/is_alignment_constant.hpp +++ b/boost/align/detail/is_alignment_constant.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -21,8 +21,8 @@ struct is_alignment_constant : integral_constant 0) && ((N & (N - 1)) == 0)> { }; -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/max_align.hpp b/boost/align/detail/max_align.hpp index 4351a5a2ed..daa0413935 100644 --- a/boost/align/detail/max_align.hpp +++ b/boost/align/detail/max_align.hpp @@ -1,6 +1,6 @@ /* -(c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com +(c) 2014-2015 Glen Joseph Fernandes + Distributed under the Boost Software License, Version 1.0. @@ -9,20 +9,21 @@ http://boost.org/LICENSE_1_0.txt #ifndef BOOST_ALIGN_DETAIL_MAX_ALIGN_HPP #define BOOST_ALIGN_DETAIL_MAX_ALIGN_HPP -#include +#include +#include #include namespace boost { namespace alignment { namespace detail { -template +template struct max_align - : integral_constant B) ? A : B> { + : max_size::value, alignment_of::value>::type { }; -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/max_count_of.hpp b/boost/align/detail/max_count_of.hpp deleted file mode 100644 index e0ae3bce96..0000000000 --- a/boost/align/detail/max_count_of.hpp +++ /dev/null @@ -1,29 +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_DETAIL_MAX_COUNT_OF_HPP -#define BOOST_ALIGN_DETAIL_MAX_COUNT_OF_HPP - -#include -#include - -namespace boost { -namespace alignment { -namespace detail { - -template -struct max_count_of - : integral_constant(0) / sizeof(T)> { -}; - -} /* :detail */ -} /* :alignment */ -} /* :boost */ - -#endif diff --git a/boost/align/detail/max_objects.hpp b/boost/align/detail/max_objects.hpp new file mode 100644 index 0000000000..eb56d6fe66 --- /dev/null +++ b/boost/align/detail/max_objects.hpp @@ -0,0 +1,29 @@ +/* +(c) 2014 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_MAX_OBJECTS_HPP +#define BOOST_ALIGN_DETAIL_MAX_OBJECTS_HPP + +#include +#include + +namespace boost { +namespace alignment { +namespace detail { + +template +struct max_objects + : integral_constant(0) / sizeof(T)> { +}; + +} /* .detail */ +} /* .alignment */ +} /* .boost */ + +#endif diff --git a/boost/align/detail/max_size.hpp b/boost/align/detail/max_size.hpp new file mode 100644 index 0000000000..48fc45e2ee --- /dev/null +++ b/boost/align/detail/max_size.hpp @@ -0,0 +1,28 @@ +/* +(c) 2014-2015 Glen Joseph Fernandes + + +Distributed under the Boost Software +License, Version 1.0. +http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_MAX_SIZE_HPP +#define BOOST_ALIGN_DETAIL_MAX_SIZE_HPP + +#include +#include + +namespace boost { +namespace alignment { +namespace detail { + +template +struct max_size + : integral_constant B) ? A : B> { +}; + +} /* .detail */ +} /* .alignment */ +} /* .boost */ + +#endif diff --git a/boost/align/detail/min_size.hpp b/boost/align/detail/min_size.hpp index 71afe8c686..8ed3e87ab6 100644 --- a/boost/align/detail/min_size.hpp +++ b/boost/align/detail/min_size.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -21,8 +21,8 @@ struct min_size : integral_constant { }; -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/detail/offset_object.hpp b/boost/align/detail/offset_object.hpp deleted file mode 100644 index 2055edfb4a..0000000000 --- a/boost/align/detail/offset_object.hpp +++ /dev/null @@ -1,26 +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_DETAIL_OFFSET_OBJECT_HPP -#define BOOST_ALIGN_DETAIL_OFFSET_OBJECT_HPP - -namespace boost { -namespace alignment { -namespace detail { - -template -struct offset_object { - char offset; - T object; -}; - -} /* :detail */ -} /* :alignment */ -} /* :boost */ - -#endif diff --git a/boost/align/detail/remove_traits.hpp b/boost/align/detail/remove_traits.hpp index f59d6bf9e8..86a98d459a 100644 --- a/boost/align/detail/remove_traits.hpp +++ b/boost/align/detail/remove_traits.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. @@ -85,8 +85,8 @@ struct remove_cv { }; #endif -} /* :detail */ -} /* :alignment */ -} /* :boost */ +} /* .detail */ +} /* .alignment */ +} /* .boost */ #endif diff --git a/boost/align/is_aligned.hpp b/boost/align/is_aligned.hpp index 7473864ca7..5d99847e4a 100644 --- a/boost/align/is_aligned.hpp +++ b/boost/align/is_aligned.hpp @@ -1,6 +1,6 @@ /* (c) 2014 Glen Joseph Fernandes -glenjofe at gmail dot com + Distributed under the Boost Software License, Version 1.0. diff --git a/boost/aligned_storage.hpp b/boost/aligned_storage.hpp index b5455f00b6..f400fa9e75 100644 --- a/boost/aligned_storage.hpp +++ b/boost/aligned_storage.hpp @@ -13,131 +13,6 @@ #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" +#include #endif // BOOST_ALIGNED_STORAGE_HPP diff --git a/boost/archive/archive_exception.hpp b/boost/archive/archive_exception.hpp index 1159d27755..fabcdb5fa7 100644 --- a/boost/archive/archive_exception.hpp +++ b/boost/archive/archive_exception.hpp @@ -87,6 +87,7 @@ public: const char * e1 = NULL, const char * e2 = NULL ) BOOST_NOEXCEPT; + BOOST_ARCHIVE_DECL archive_exception(archive_exception const &) BOOST_NOEXCEPT ; virtual BOOST_ARCHIVE_DECL ~archive_exception() BOOST_NOEXCEPT_OR_NOTHROW ; virtual BOOST_ARCHIVE_DECL const char * what() const BOOST_NOEXCEPT_OR_NOTHROW ; }; diff --git a/boost/archive/basic_binary_oprimitive.hpp b/boost/archive/basic_binary_oprimitive.hpp index 077d705ef1..f2ea6aa3ea 100644 --- a/boost/archive/basic_binary_oprimitive.hpp +++ b/boost/archive/basic_binary_oprimitive.hpp @@ -149,9 +149,7 @@ basic_binary_oprimitive::save_binary( const void *address, std::size_t count ){ - //BOOST_ASSERT( - // static_cast((std::numeric_limits::max)()) >= count - //); + // BOOST_ASSERT(count <= std::size_t(boost::integer_traits::const_max)); // note: if the following assertions fail // a likely cause is that the output stream is set to "text" // mode where by cr characters recieve special treatment. @@ -161,9 +159,7 @@ basic_binary_oprimitive::save_binary( // archive_exception(archive_exception::output_stream_error) // ); // figure number of elements to output - round up - count = ( count + sizeof(Elem) - 1) - / sizeof(Elem); - BOOST_ASSERT(count <= std::size_t(boost::integer_traits::const_max)); + count = ( count + sizeof(Elem) - 1) / sizeof(Elem); std::streamsize scount = m_sb.sputn( static_cast(address), static_cast(count) diff --git a/boost/archive/detail/basic_iarchive.hpp b/boost/archive/detail/basic_iarchive.hpp index befd0c75f2..1f5a8bf63b 100644 --- a/boost/archive/detail/basic_iarchive.hpp +++ b/boost/archive/detail/basic_iarchive.hpp @@ -65,11 +65,7 @@ protected: public: // some msvc versions require that the following function be public // otherwise it should really protected. - // account for bogus gcc warning - #if defined(__GNUC__) - virtual - #endif - BOOST_ARCHIVE_DECL ~basic_iarchive(); + virtual BOOST_ARCHIVE_DECL ~basic_iarchive(); // note: NOT part of the public API. BOOST_ARCHIVE_DECL void next_object_pointer(void *t); BOOST_ARCHIVE_DECL void register_basic_serializer( diff --git a/boost/archive/detail/basic_iserializer.hpp b/boost/archive/detail/basic_iserializer.hpp index 240f0bc06e..0d66674c34 100644 --- a/boost/archive/detail/basic_iserializer.hpp +++ b/boost/archive/detail/basic_iserializer.hpp @@ -51,11 +51,7 @@ protected: explicit BOOST_ARCHIVE_DECL basic_iserializer( const boost::serialization::extended_type_info & type ); - // account for bogus gcc warning - #if defined(__GNUC__) - virtual - #endif - BOOST_ARCHIVE_DECL ~basic_iserializer(); + virtual BOOST_ARCHIVE_DECL ~basic_iserializer(); public: bool serialized_as_pointer() const { return m_bpis != NULL; diff --git a/boost/archive/detail/basic_oarchive.hpp b/boost/archive/detail/basic_oarchive.hpp index 702c5604bc..c379108d58 100644 --- a/boost/archive/detail/basic_oarchive.hpp +++ b/boost/archive/detail/basic_oarchive.hpp @@ -61,14 +61,8 @@ class BOOST_SYMBOL_VISIBLE basic_oarchive : protected: BOOST_ARCHIVE_DECL basic_oarchive(unsigned int flags = 0); BOOST_ARCHIVE_DECL boost::archive::detail::helper_collection & - get_helper_collection(){ - return *this; - } - // account for bogus gcc warning - #if defined(__GNUC__) - virtual - #endif - BOOST_ARCHIVE_DECL ~basic_oarchive(); + get_helper_collection(); + virtual BOOST_ARCHIVE_DECL ~basic_oarchive(); public: // note: NOT part of the public interface BOOST_ARCHIVE_DECL void register_basic_serializer( diff --git a/boost/archive/detail/basic_oserializer.hpp b/boost/archive/detail/basic_oserializer.hpp index 7a710ba6bc..94247e9005 100644 --- a/boost/archive/detail/basic_oserializer.hpp +++ b/boost/archive/detail/basic_oserializer.hpp @@ -52,11 +52,7 @@ protected: explicit BOOST_ARCHIVE_DECL basic_oserializer( const boost::serialization::extended_type_info & type_ ); - // account for bogus gcc warning - #if defined(__GNUC__) - virtual - #endif - BOOST_ARCHIVE_DECL ~basic_oserializer(); + virtual BOOST_ARCHIVE_DECL ~basic_oserializer(); public: bool serialized_as_pointer() const { return m_bpos != NULL; diff --git a/boost/archive/detail/basic_pointer_iserializer.hpp b/boost/archive/detail/basic_pointer_iserializer.hpp index 23b9f906dc..1fc4b14d6e 100644 --- a/boost/archive/detail/basic_pointer_iserializer.hpp +++ b/boost/archive/detail/basic_pointer_iserializer.hpp @@ -46,11 +46,7 @@ protected: explicit BOOST_ARCHIVE_DECL basic_pointer_iserializer( const boost::serialization::extended_type_info & type_ ); - // account for bogus gcc warning - #if defined(__GNUC__) - virtual - #endif - BOOST_ARCHIVE_DECL ~basic_pointer_iserializer(); + virtual BOOST_ARCHIVE_DECL ~basic_pointer_iserializer(); public: virtual void * heap_allocation() const = 0; virtual const basic_iserializer & get_basic_serializer() const = 0; diff --git a/boost/archive/detail/basic_pointer_oserializer.hpp b/boost/archive/detail/basic_pointer_oserializer.hpp index 868e2fa580..1a5d9549ea 100644 --- a/boost/archive/detail/basic_pointer_oserializer.hpp +++ b/boost/archive/detail/basic_pointer_oserializer.hpp @@ -47,11 +47,7 @@ protected: const boost::serialization::extended_type_info & type_ ); public: - // account for bogus gcc warning - #if defined(__GNUC__) - virtual - #endif - BOOST_ARCHIVE_DECL ~basic_pointer_oserializer(); + virtual BOOST_ARCHIVE_DECL ~basic_pointer_oserializer(); virtual const basic_oserializer & get_basic_serializer() const = 0; virtual void save_object_ptr( basic_oarchive & ar, diff --git a/boost/archive/detail/interface_oarchive.hpp b/boost/archive/detail/interface_oarchive.hpp index 187013b6cd..359463ed9d 100644 --- a/boost/archive/detail/interface_oarchive.hpp +++ b/boost/archive/detail/interface_oarchive.hpp @@ -29,7 +29,7 @@ namespace boost { namespace archive { namespace detail { -class BOOST_ARCHIVE_OR_WARCHIVE_DECL basic_pointer_oserializer; +class basic_pointer_oserializer; template class interface_oarchive @@ -75,7 +75,7 @@ public: template Archive & operator&(const T & t){ return * this ->This() << t; - }; + } }; } // namespace detail diff --git a/boost/archive/detail/iserializer.hpp b/boost/archive/detail/iserializer.hpp index d6d3f42f6e..6419e623c8 100644 --- a/boost/archive/detail/iserializer.hpp +++ b/boost/archive/detail/iserializer.hpp @@ -57,10 +57,16 @@ namespace std{ #include #include -#define DONT_USE_HAS_NEW_OPERATOR ( \ - BOOST_WORKAROUND(__IBMCPP__, < 1210) \ - || defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x590) \ -) + +#ifndef BOOST_MSVC + #define DONT_USE_HAS_NEW_OPERATOR ( \ + BOOST_WORKAROUND(__IBMCPP__, < 1210) \ + || defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x590) \ + ) +#else + #define DONT_USE_HAS_NEW_OPERATOR 0 +#endif + #if ! DONT_USE_HAS_NEW_OPERATOR #include #endif @@ -220,20 +226,25 @@ struct heap_allocation { static T * invoke_new() { return static_cast((T::operator new)(sizeof(T))); } + template + static void deleter(void * t, std::size_t s){ + D(t, s); + } + + template + static void deleter(void * t, std::size_t s){ + D(t); + } static void invoke_delete(T * t) { // if compilation fails here, the likely cause that the class // T has a class specific new operator but no class specific - // delete operator which matches the following signature. Fix - // your program to have this. Note that adding operator delete - // with only one parameter doesn't seem correct to me since - // the standard(3.7.4.2) says " - // "If a class T has a member deallocation function named - // 'operator delete' with exactly one parameter, then that function - // is a usual (non-placement) deallocation function" which I take - // to mean that it will call the destructor of type T which we don't - // want to do here. - // Note: reliance upon automatic conversion from T * to void * here - (T::operator delete)(t, sizeof(T)); + // delete operator which matches the following signature. + // note that this solution addresses the issue that two + // possible signatures. But it doesn't address the possibility + // that the class might have class specific new with NO + // class specific delete at all. Patches (compatible with + // C++03) welcome! + deleter(t, sizeof(T)); } }; struct doesnt_have_new_operator { diff --git a/boost/archive/detail/polymorphic_iarchive_route.hpp b/boost/archive/detail/polymorphic_iarchive_route.hpp index 2c57a3f51c..105685ebbd 100644 --- a/boost/archive/detail/polymorphic_iarchive_route.hpp +++ b/boost/archive/detail/polymorphic_iarchive_route.hpp @@ -39,8 +39,8 @@ namespace serialization { namespace archive { namespace detail{ -class BOOST_ARCHIVE_DECL basic_iserializer; -class BOOST_ARCHIVE_DECL basic_pointer_iserializer; +class basic_iserializer; +class basic_pointer_iserializer; #ifdef BOOST_MSVC # pragma warning(push) diff --git a/boost/archive/detail/polymorphic_oarchive_route.hpp b/boost/archive/detail/polymorphic_oarchive_route.hpp index ae750133a8..b23fd6bf39 100644 --- a/boost/archive/detail/polymorphic_oarchive_route.hpp +++ b/boost/archive/detail/polymorphic_oarchive_route.hpp @@ -39,8 +39,8 @@ namespace serialization { namespace archive { namespace detail{ -class BOOST_ARCHIVE_DECL basic_oserializer; -class BOOST_ARCHIVE_DECL basic_pointer_oserializer; +class basic_oserializer; +class basic_pointer_oserializer; #ifdef BOOST_MSVC # pragma warning(push) diff --git a/boost/archive/impl/xml_iarchive_impl.ipp b/boost/archive/impl/xml_iarchive_impl.ipp index 7639ecb3b1..bf94774987 100644 --- a/boost/archive/impl/xml_iarchive_impl.ipp +++ b/boost/archive/impl/xml_iarchive_impl.ipp @@ -18,10 +18,11 @@ namespace std{ #endif #ifndef BOOST_NO_CWCHAR -#include // mbtowc +#include // mbstate_t and mbrtowc #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ - using ::mbtowc; + using ::mbstate_t; + using ::mbrtowc; } // namespace std #endif #endif // BOOST_NO_CWCHAR @@ -64,21 +65,22 @@ xml_iarchive_impl::load(std::wstring &ws){ if(NULL != ws.data()) #endif ws.resize(0); + std::mbstate_t mbs; const char * start = s.data(); const char * end = start + s.size(); while(start < end){ wchar_t wc; - int resultx = std::mbtowc(&wc, start, end - start); - if(0 < resultx){ - start += resultx; - ws += wc; + std::size_t result = std::mbrtowc(&wc, start, end - start, &mbs); + if(result == static_cast(-1)) + boost::serialization::throw_exception( + iterators::dataflow_exception( + iterators::dataflow_exception::invalid_conversion + ) + ); + if(result == static_cast(-2)) continue; - } - boost::serialization::throw_exception( - iterators::dataflow_exception( - iterators::dataflow_exception::invalid_conversion - ) - ); + start += result; + ws += wc; } } #endif // BOOST_NO_STD_WSTRING @@ -91,24 +93,28 @@ xml_iarchive_impl::load(wchar_t * ws){ bool result = gimpl->parse_string(is, s); if(! result) boost::serialization::throw_exception( - xml_archive_exception(xml_archive_exception::xml_archive_parsing_error) + xml_archive_exception( + xml_archive_exception::xml_archive_parsing_error + ) ); + std::mbstate_t mbs; const char * start = s.data(); const char * end = start + s.size(); while(start < end){ wchar_t wc; - int length = std::mbtowc(&wc, start, end - start); - if(0 < length){ - start += length; - *ws++ = wc; + std::size_t length = std::mbrtowc(&wc, start, end - start, &mbs); + if(static_cast(-1) == length) + boost::serialization::throw_exception( + iterators::dataflow_exception( + iterators::dataflow_exception::invalid_conversion + ) + ); + if(static_cast(-2) == length) continue; - } - boost::serialization::throw_exception( - iterators::dataflow_exception( - iterators::dataflow_exception::invalid_conversion - ) - ); + + start += length; + *ws++ = wc; } *ws = L'\0'; } diff --git a/boost/archive/iterators/head_iterator.hpp b/boost/archive/iterators/head_iterator.hpp deleted file mode 100644 index 6ad7d6b32b..0000000000 --- a/boost/archive/iterators/head_iterator.hpp +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP -#define BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP - -// MS compatible compilers support #pragma once -#if defined(_MSC_VER) -# pragma once -#endif - -/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// head_iterator.hpp - -// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . -// 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 http://www.boost.org for updates, documentation, and revision history. - -#include -#include - -namespace boost { -namespace archive { -namespace iterators { - -template -class head_iterator - : public boost::iterator_adaptor< - head_iterator, - Base, - use_default, - single_pass_traversal_tag - > -{ -private: - friend class iterator_core_access; - typedef boost::iterator_adaptor< - head_iterator, - Base, - use_default, - single_pass_traversal_tag - > super_t; - - typedef head_iterator this_t; - typedef super_t::value_type value_type; - typedef super_t::reference reference_type; - - reference_type dereference_impl(){ - if(! m_end){ - while(! m_predicate(* this->base_reference())) - ++ this->base_reference(); - m_end = true; - } - return * this->base_reference(); - } - - reference_type dereference() const { - return const_cast(this)->dereference_impl(); - } - - void increment(){ - ++base_reference(); - } - Predicate m_predicate; - bool m_end; -public: - template - head_iterator(Predicate f, T start) : - super_t(Base(start)), - m_predicate(f), - m_end(false) - {} - -}; - -} // namespace iterators -} // namespace archive -} // namespace boost - -#endif // BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP diff --git a/boost/archive/iterators/mb_from_wchar.hpp b/boost/archive/iterators/mb_from_wchar.hpp index deb798f623..d76eb3e2d2 100644 --- a/boost/archive/iterators/mb_from_wchar.hpp +++ b/boost/archive/iterators/mb_from_wchar.hpp @@ -18,13 +18,14 @@ #include #include // size_t -#include // for wctomb() +#include // for mbstate_t and wcrtomb() #include #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ using ::size_t; - using ::wctomb; + using ::mbstate_t; + using ::wcrtomb; } // namespace std #endif @@ -82,13 +83,10 @@ class mb_from_wchar } void fill(){ + std::mbstate_t mbs; + std::wcrtomb(0, 0, &mbs); wchar_t value = * this->base_reference(); - #if (defined(__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 3) \ - || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION >= 8)))) - m_bend = std::wcrtomb(m_buffer, value,0); - #else - m_bend = std::wctomb(m_buffer, value); - #endif + m_bend = std::wcrtomb(m_buffer, value, &mbs); BOOST_ASSERT(-1 != m_bend); BOOST_ASSERT((std::size_t)m_bend <= sizeof(m_buffer)); BOOST_ASSERT(m_bend > 0); diff --git a/boost/archive/iterators/wchar_from_mb.hpp b/boost/archive/iterators/wchar_from_mb.hpp index ad1d4cbb7d..998a4686b2 100644 --- a/boost/archive/iterators/wchar_from_mb.hpp +++ b/boost/archive/iterators/wchar_from_mb.hpp @@ -19,13 +19,13 @@ #include #include #include // size_t -#include // mblen +#include // mbstate_t and mbrtowc #include #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ - using ::mblen; - using ::mbtowc; + using ::mbstate_t; + using ::mbrtowc; } // namespace std #endif @@ -101,23 +101,17 @@ public: template wchar_t wchar_from_mb::drain(){ - char buffer[9]; - char * bptr = buffer; - char val; - for(std::size_t i = 0; i++ < (unsigned)MB_CUR_MAX;){ - val = * this->base_reference(); - *bptr++ = val; - int result = std::mblen(buffer, i); - if(-1 != result) - break; - ++(this->base_reference()); - } + std::mbstate_t mbs; wchar_t retval; - int result = std::mbtowc(& retval, buffer, MB_CUR_MAX); - if(0 >= result) - boost::serialization::throw_exception(iterators::dataflow_exception( - iterators::dataflow_exception::invalid_conversion - )); + std::size_t result; + do { + char val = *this->base_reference(); + result = std::mbrtowc(&retval, &val, 1, &mbs); + if(result == static_cast(-1)) + boost::serialization::throw_exception(iterators::dataflow_exception( + iterators::dataflow_exception::invalid_conversion + )); + } while (result == static_cast(-2)); return retval; } diff --git a/boost/archive/polymorphic_iarchive.hpp b/boost/archive/polymorphic_iarchive.hpp index 7f19410dd8..d3c59a9f0f 100644 --- a/boost/archive/polymorphic_iarchive.hpp +++ b/boost/archive/polymorphic_iarchive.hpp @@ -43,8 +43,8 @@ namespace serialization { } // namespace serialization namespace archive { namespace detail { - class BOOST_ARCHIVE_DECL basic_iarchive; - class BOOST_ARCHIVE_DECL basic_iarchive; + class basic_iarchive; + class basic_iserializer; } class polymorphic_iarchive; diff --git a/boost/archive/polymorphic_oarchive.hpp b/boost/archive/polymorphic_oarchive.hpp index aa30b2ac3e..edac4edb1e 100644 --- a/boost/archive/polymorphic_oarchive.hpp +++ b/boost/archive/polymorphic_oarchive.hpp @@ -42,8 +42,8 @@ namespace serialization { } // namespace serialization namespace archive { namespace detail { - class BOOST_ARCHIVE_DECL basic_oarchive; - class BOOST_ARCHIVE_DECL basic_oserializer; + class basic_oarchive; + class basic_oserializer; } class polymorphic_oarchive; diff --git a/boost/archive/xml_archive_exception.hpp b/boost/archive/xml_archive_exception.hpp index b07f9a0c33..82c53ef5d3 100644 --- a/boost/archive/xml_archive_exception.hpp +++ b/boost/archive/xml_archive_exception.hpp @@ -45,6 +45,8 @@ public: const char * e1 = NULL, const char * e2 = NULL ); + BOOST_ARCHIVE_DECL xml_archive_exception(xml_archive_exception const &) ; + virtual BOOST_ARCHIVE_DECL ~xml_archive_exception() BOOST_NOEXCEPT_OR_NOTHROW ; }; }// namespace archive diff --git a/boost/asio/basic_serial_port.hpp b/boost/asio/basic_serial_port.hpp index e0f83b0a5b..d318963a12 100644 --- a/boost/asio/basic_serial_port.hpp +++ b/boost/asio/basic_serial_port.hpp @@ -445,7 +445,7 @@ public: * * @param option The option value to be obtained from the serial port. * - * @param ec Set to indicate what error occured, if any. + * @param ec Set to indicate what error occurred, if any. * * @sa GettableSerialPortOption @n * boost::asio::serial_port_base::baud_rate @n diff --git a/boost/asio/detail/config.hpp b/boost/asio/detail/config.hpp index 0f9e52d593..a39d85d600 100644 --- a/boost/asio/detail/config.hpp +++ b/boost/asio/detail/config.hpp @@ -221,8 +221,7 @@ # define BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT noexcept(true) # endif // defined(__GXX_EXPERIMENTAL_CXX0X__) # endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4) -# endif // defined(__GNUC__) -# if defined(BOOST_ASIO_MSVC) +# elif defined(BOOST_ASIO_MSVC) # if (_MSC_VER >= 1900) # define BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT noexcept(true) # endif // (_MSC_VER >= 1900) @@ -515,25 +514,41 @@ # endif // !defined(BOOST_ASIO_DISABLE_STD_MUTEX_AND_CONDVAR) #endif // !defined(BOOST_ASIO_HAS_STD_MUTEX_AND_CONDVAR) -// WinRT target. -#if !defined(BOOST_ASIO_WINDOWS_RUNTIME) -# if defined(__cplusplus_winrt) +// Windows App target. Windows but with a limited API. +#if !defined(BOOST_ASIO_WINDOWS_APP) +# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0603) # include # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) \ && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -# define BOOST_ASIO_WINDOWS_RUNTIME 1 +# define BOOST_ASIO_WINDOWS_APP 1 # endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) // && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -# endif // defined(__cplusplus_winrt) +# endif // defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0603) +#endif // !defined(BOOST_ASIO_WINDOWS_APP) + +// Legacy WinRT target. Windows App is preferred. +#if !defined(BOOST_ASIO_WINDOWS_RUNTIME) +# if !defined(BOOST_ASIO_WINDOWS_APP) +# if defined(__cplusplus_winrt) +# include +# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) \ + && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +# define BOOST_ASIO_WINDOWS_RUNTIME 1 +# endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) + // && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +# endif // defined(__cplusplus_winrt) +# endif // !defined(BOOST_ASIO_WINDOWS_APP) #endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME) -// Windows target. Excludes WinRT. +// Windows target. Excludes WinRT but includes Windows App targets. #if !defined(BOOST_ASIO_WINDOWS) # if !defined(BOOST_ASIO_WINDOWS_RUNTIME) # if defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_WINDOWS) # define BOOST_ASIO_WINDOWS 1 # elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) # define BOOST_ASIO_WINDOWS 1 +# elif defined(BOOST_ASIO_WINDOWS_APP) +# define BOOST_ASIO_WINDOWS 1 # endif // defined(BOOST_ASIO_HAS_BOOST_CONFIG) && defined(BOOST_WINDOWS) # endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME) #endif // !defined(BOOST_ASIO_WINDOWS) @@ -601,11 +616,11 @@ #if !defined(BOOST_ASIO_HAS_IOCP) # if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) # if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400) -# if !defined(UNDER_CE) +# if !defined(UNDER_CE) && !defined(BOOST_ASIO_WINDOWS_APP) # if !defined(BOOST_ASIO_DISABLE_IOCP) # define BOOST_ASIO_HAS_IOCP 1 # endif // !defined(BOOST_ASIO_DISABLE_IOCP) -# endif // !defined(UNDER_CE) +# endif // !defined(UNDER_CE) && !defined(BOOST_ASIO_WINDOWS_APP) # endif // defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400) # endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) #endif // !defined(BOOST_ASIO_HAS_IOCP) @@ -721,9 +736,9 @@ #if !defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE) # if !defined(BOOST_ASIO_DISABLE_WINDOWS_OBJECT_HANDLE) # if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) -# if !defined(UNDER_CE) +# if !defined(UNDER_CE) && !defined(BOOST_ASIO_WINDOWS_APP) # define BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE 1 -# endif // !defined(UNDER_CE) +# endif // !defined(UNDER_CE) && !defined(BOOST_ASIO_WINDOWS_APP) # endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) # endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_OBJECT_HANDLE) #endif // !defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE) diff --git a/boost/asio/detail/handler_type_requirements.hpp b/boost/asio/detail/handler_type_requirements.hpp index a2d3fd1f20..228e93c69f 100644 --- a/boost/asio/detail/handler_type_requirements.hpp +++ b/boost/asio/detail/handler_type_requirements.hpp @@ -53,8 +53,18 @@ # include #endif // defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS) -// Newer gcc needs special treatment to suppress unused typedef warnings. -#if defined(__GNUC__) +// Newer gcc, clang need special treatment to suppress unused typedef warnings. +#if defined(__clang__) +# if defined(__apple_build_version__) +# if (__clang_major__ >= 7) +# define BOOST_ASIO_UNUSED_TYPEDEF __attribute__((__unused__)) +# endif // (__clang_major__ >= 7) +# elif ((__clang_major__ == 3) && (__clang_minor__ >= 6)) \ + || (__clang_major__ > 3) +# define BOOST_ASIO_UNUSED_TYPEDEF __attribute__((__unused__)) +# endif // ((__clang_major__ == 3) && (__clang_minor__ >= 6)) + // || (__clang_major__ > 3) +#elif defined(__GNUC__) # if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4) # define BOOST_ASIO_UNUSED_TYPEDEF __attribute__((__unused__)) # endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4) diff --git a/boost/asio/detail/impl/socket_ops.ipp b/boost/asio/detail/impl/socket_ops.ipp index dc068e0e03..976eaa42db 100644 --- a/boost/asio/detail/impl/socket_ops.ipp +++ b/boost/asio/detail/impl/socket_ops.ipp @@ -1634,7 +1634,8 @@ int getpeername(socket_type s, socket_addr_type* addr, return socket_error_retval; } -#if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) +#if defined(BOOST_ASIO_WINDOWS) && !defined(BOOST_ASIO_WINDOWS_APP) \ + || defined(__CYGWIN__) if (cached) { // Check if socket is still connected. @@ -1655,9 +1656,11 @@ int getpeername(socket_type s, socket_addr_type* addr, ec = boost::system::error_code(); return 0; } -#else // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) +#else // defined(BOOST_ASIO_WINDOWS) && !defined(BOOST_ASIO_WINDOWS_APP) + // || defined(__CYGWIN__) (void)cached; -#endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) +#endif // defined(BOOST_ASIO_WINDOWS) && !defined(BOOST_ASIO_WINDOWS_APP) + // || defined(__CYGWIN__) clear_last_error(); int result = error_wrapper(call_getpeername( @@ -2581,7 +2584,8 @@ inline void gai_strcpy(char* target, const char* source, std::size_t max_size) strcpy_s(target, max_size, source); #else // defined(BOOST_ASIO_HAS_SECURE_RTL) *target = 0; - strncat(target, source, max_size); + if (max_size > 0) + strncat(target, source, max_size - 1); #endif // defined(BOOST_ASIO_HAS_SECURE_RTL) } diff --git a/boost/asio/detail/impl/win_event.ipp b/boost/asio/detail/impl/win_event.ipp index 0fffbce9cd..40f3f641eb 100644 --- a/boost/asio/detail/impl/win_event.ipp +++ b/boost/asio/detail/impl/win_event.ipp @@ -32,7 +32,11 @@ namespace detail { win_event::win_event() : state_(0) { - events_[0] = ::CreateEvent(0, true, false, 0); +#if defined(BOOST_ASIO_WINDOWS_APP) + events_[0] = ::CreateEventExW(0, 0, CREATE_EVENT_MANUAL_RESET, 0); +#else // defined(BOOST_ASIO_WINDOWS_APP) + events_[0] = ::CreateEventW(0, true, false, 0); +#endif // defined(BOOST_ASIO_WINDOWS_APP) if (!events_[0]) { DWORD last_error = ::GetLastError(); @@ -41,7 +45,11 @@ win_event::win_event() boost::asio::detail::throw_error(ec, "event"); } - events_[1] = ::CreateEvent(0, false, false, 0); +#if defined(BOOST_ASIO_WINDOWS_APP) + events_[1] = ::CreateEventExW(0, 0, 0, 0); +#else // defined(BOOST_ASIO_WINDOWS_APP) + events_[1] = ::CreateEventW(0, false, false, 0); +#endif // defined(BOOST_ASIO_WINDOWS_APP) if (!events_[1]) { DWORD last_error = ::GetLastError(); diff --git a/boost/asio/detail/impl/win_iocp_handle_service.ipp b/boost/asio/detail/impl/win_iocp_handle_service.ipp index b0c784e556..24820a55b0 100644 --- a/boost/asio/detail/impl/win_iocp_handle_service.ipp +++ b/boost/asio/detail/impl/win_iocp_handle_service.ipp @@ -40,7 +40,7 @@ public: OffsetHigh = 0; // Create a non-signalled manual-reset event, for GetOverlappedResult. - hEvent = ::CreateEvent(0, TRUE, FALSE, 0); + hEvent = ::CreateEventW(0, TRUE, FALSE, 0); if (hEvent) { // As documented in GetQueuedCompletionStatus, setting the low order diff --git a/boost/asio/detail/impl/win_mutex.ipp b/boost/asio/detail/impl/win_mutex.ipp index 60ce9dd598..be1d1b8111 100644 --- a/boost/asio/detail/impl/win_mutex.ipp +++ b/boost/asio/detail/impl/win_mutex.ipp @@ -44,6 +44,8 @@ int win_mutex::do_init() // we'll just call the Windows API and hope. # if defined(UNDER_CE) ::InitializeCriticalSection(&crit_section_); +# elif defined(BOOST_ASIO_WINDOWS_APP) + ::InitializeCriticalSectionEx(&crit_section_, 0x80000000, 0); # else if (!::InitializeCriticalSectionAndSpinCount(&crit_section_, 0x80000000)) return ::GetLastError(); @@ -54,6 +56,9 @@ int win_mutex::do_init() { # if defined(UNDER_CE) ::InitializeCriticalSection(&crit_section_); +# elif defined(BOOST_ASIO_WINDOWS_APP) + if (!::InitializeCriticalSectionEx(&crit_section_, 0, 0)) + return ::GetLastError(); # else if (!::InitializeCriticalSectionAndSpinCount(&crit_section_, 0x80000000)) return ::GetLastError(); diff --git a/boost/asio/detail/impl/win_static_mutex.ipp b/boost/asio/detail/impl/win_static_mutex.ipp index 02b44b5d37..14a08efd90 100644 --- a/boost/asio/detail/impl/win_static_mutex.ipp +++ b/boost/asio/detail/impl/win_static_mutex.ipp @@ -50,13 +50,23 @@ int win_static_mutex::do_init() mutex_name, 128, L"asio-58CCDC44-6264-4842-90C2-F3C545CB8AA7-%u-%p", static_cast(::GetCurrentProcessId()), this); +#if defined(BOOST_ASIO_WINDOWS_APP) + HANDLE mutex = ::CreateMutexExW(0, mutex_name, CREATE_MUTEX_INITIAL_OWNER, 0); +#else // defined(BOOST_ASIO_WINDOWS_APP) HANDLE mutex = ::CreateMutexW(0, TRUE, mutex_name); +#endif // defined(BOOST_ASIO_WINDOWS_APP) DWORD last_error = ::GetLastError(); if (mutex == 0) return ::GetLastError(); if (last_error == ERROR_ALREADY_EXISTS) + { +#if defined(BOOST_ASIO_WINDOWS_APP) + ::WaitForSingleObjectEx(mutex, INFINITE, false); +#else // defined(BOOST_ASIO_WINDOWS_APP) ::WaitForSingleObject(mutex, INFINITE); +#endif // defined(BOOST_ASIO_WINDOWS_APP) + } if (initialised_) { @@ -84,6 +94,14 @@ int win_static_mutex::do_init() { # if defined(UNDER_CE) ::InitializeCriticalSection(&crit_section_); +# elif defined(BOOST_ASIO_WINDOWS_APP) + if (!::InitializeCriticalSectionEx(&crit_section_, 0, 0)) + { + last_error = ::GetLastError(); + ::ReleaseMutex(mutex); + ::CloseHandle(mutex); + return last_error; + } # else if (!::InitializeCriticalSectionAndSpinCount(&crit_section_, 0x80000000)) { diff --git a/boost/asio/detail/impl/win_thread.ipp b/boost/asio/detail/impl/win_thread.ipp index 727c122e95..5ebd0e68a0 100644 --- a/boost/asio/detail/impl/win_thread.ipp +++ b/boost/asio/detail/impl/win_thread.ipp @@ -17,7 +17,9 @@ #include -#if defined(BOOST_ASIO_WINDOWS) && !defined(UNDER_CE) +#if defined(BOOST_ASIO_WINDOWS) \ + && !defined(BOOST_ASIO_WINDOWS_APP) \ + && !defined(UNDER_CE) #include #include @@ -57,7 +59,7 @@ void win_thread::join() void win_thread::start_thread(func_base* arg, unsigned int stack_size) { ::HANDLE entry_event = 0; - arg->entry_event_ = entry_event = ::CreateEvent(0, true, false, 0); + arg->entry_event_ = entry_event = ::CreateEventW(0, true, false, 0); if (!entry_event) { DWORD last_error = ::GetLastError(); @@ -67,7 +69,7 @@ void win_thread::start_thread(func_base* arg, unsigned int stack_size) boost::asio::detail::throw_error(ec, "thread.entry_event"); } - arg->exit_event_ = exit_event_ = ::CreateEvent(0, true, false, 0); + arg->exit_event_ = exit_event_ = ::CreateEventW(0, true, false, 0); if (!exit_event_) { DWORD last_error = ::GetLastError(); @@ -136,6 +138,8 @@ void __stdcall apc_function(ULONG_PTR) {} #include -#endif // defined(BOOST_ASIO_WINDOWS) && !defined(UNDER_CE) +#endif // defined(BOOST_ASIO_WINDOWS) + // && !defined(BOOST_ASIO_WINDOWS_APP) + // && !defined(UNDER_CE) #endif // BOOST_ASIO_DETAIL_IMPL_WIN_THREAD_IPP diff --git a/boost/asio/detail/local_free_on_block_exit.hpp b/boost/asio/detail/local_free_on_block_exit.hpp index 47b5dafc46..a3b597e836 100644 --- a/boost/asio/detail/local_free_on_block_exit.hpp +++ b/boost/asio/detail/local_free_on_block_exit.hpp @@ -18,6 +18,7 @@ #include #if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) +#if !defined(BOOST_ASIO_WINDOWS_APP) #include #include @@ -54,6 +55,7 @@ private: #include +#endif // !defined(BOOST_ASIO_WINDOWS_APP) #endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) #endif // BOOST_ASIO_DETAIL_LOCAL_FREE_ON_BLOCK_EXIT_HPP diff --git a/boost/asio/detail/socket_types.hpp b/boost/asio/detail/socket_types.hpp index f4be937703..e8c71093a0 100644 --- a/boost/asio/detail/socket_types.hpp +++ b/boost/asio/detail/socket_types.hpp @@ -37,7 +37,9 @@ # endif // defined(WINAPI_FAMILY) # include # include -# include +# if !defined(BOOST_ASIO_WINDOWS_APP) +# include +# endif // !defined(BOOST_ASIO_WINDOWS_APP) # if defined(BOOST_ASIO_WSPIAPI_H_DEFINED) # undef _WSPIAPI_H_ # undef BOOST_ASIO_WSPIAPI_H_DEFINED @@ -47,7 +49,9 @@ # pragma comment(lib, "ws2.lib") # elif defined(_MSC_VER) || defined(__BORLANDC__) # pragma comment(lib, "ws2_32.lib") -# pragma comment(lib, "mswsock.lib") +# if !defined(BOOST_ASIO_WINDOWS_APP) +# pragma comment(lib, "mswsock.lib") +# endif // !defined(BOOST_ASIO_WINDOWS_APP) # endif // defined(_MSC_VER) || defined(__BORLANDC__) # endif // !defined(BOOST_ASIO_NO_DEFAULT_LINKED_LIBS) # include diff --git a/boost/asio/detail/thread.hpp b/boost/asio/detail/thread.hpp index adc5a55708..1076e6452c 100644 --- a/boost/asio/detail/thread.hpp +++ b/boost/asio/detail/thread.hpp @@ -20,8 +20,8 @@ #if !defined(BOOST_ASIO_HAS_THREADS) # include #elif defined(BOOST_ASIO_WINDOWS) -# if defined(UNDER_CE) -# include +# if defined(BOOST_ASIO_WINDOWS_APP) || defined(UNDER_CE) +# include # else # include # endif @@ -40,8 +40,8 @@ namespace detail { #if !defined(BOOST_ASIO_HAS_THREADS) typedef null_thread thread; #elif defined(BOOST_ASIO_WINDOWS) -# if defined(UNDER_CE) -typedef wince_thread thread; +# if defined(BOOST_ASIO_WINDOWS_APP) || defined(UNDER_CE) +typedef winapi_thread thread; # else typedef win_thread thread; # endif diff --git a/boost/asio/detail/win_event.hpp b/boost/asio/detail/win_event.hpp index ff4df5be23..d9aba6cbec 100644 --- a/boost/asio/detail/win_event.hpp +++ b/boost/asio/detail/win_event.hpp @@ -102,7 +102,11 @@ public: { state_ += 2; lock.unlock(); +#if defined(BOOST_ASIO_WINDOWS_APP) + ::WaitForMultipleObjectsEx(2, events_, false, INFINITE, false); +#else // defined(BOOST_ASIO_WINDOWS_APP) ::WaitForMultipleObjects(2, events_, false, INFINITE); +#endif // defined(BOOST_ASIO_WINDOWS_APP) lock.lock(); state_ -= 2; } diff --git a/boost/asio/detail/win_thread.hpp b/boost/asio/detail/win_thread.hpp index e465430031..44bf8da535 100644 --- a/boost/asio/detail/win_thread.hpp +++ b/boost/asio/detail/win_thread.hpp @@ -17,7 +17,9 @@ #include -#if defined(BOOST_ASIO_WINDOWS) && !defined(UNDER_CE) +#if defined(BOOST_ASIO_WINDOWS) \ + && !defined(BOOST_ASIO_WINDOWS_APP) \ + && !defined(UNDER_CE) #include #include @@ -136,6 +138,8 @@ private: # include #endif // defined(BOOST_ASIO_HEADER_ONLY) -#endif // defined(BOOST_ASIO_WINDOWS) && !defined(UNDER_CE) +#endif // defined(BOOST_ASIO_WINDOWS) + // && !defined(BOOST_ASIO_WINDOWS_APP) + // && !defined(UNDER_CE) #endif // BOOST_ASIO_DETAIL_WIN_THREAD_HPP diff --git a/boost/asio/detail/winapi_thread.hpp b/boost/asio/detail/winapi_thread.hpp new file mode 100644 index 0000000000..ce4050b2d1 --- /dev/null +++ b/boost/asio/detail/winapi_thread.hpp @@ -0,0 +1,124 @@ +// +// detail/winapi_thread.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2015 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) +// + +#ifndef BOOST_ASIO_DETAIL_WINAPI_THREAD_HPP +#define BOOST_ASIO_DETAIL_WINAPI_THREAD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include + +#if defined(BOOST_ASIO_WINDOWS) +#if defined(BOOST_ASIO_WINDOWS_APP) || defined(UNDER_CE) + +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace asio { +namespace detail { + +DWORD WINAPI winapi_thread_function(LPVOID arg); + +class winapi_thread + : private noncopyable +{ +public: + // Constructor. + template + winapi_thread(Function f, unsigned int = 0) + { + std::auto_ptr arg(new func(f)); + DWORD thread_id = 0; + thread_ = ::CreateThread(0, 0, winapi_thread_function, + arg.get(), 0, &thread_id); + if (!thread_) + { + DWORD last_error = ::GetLastError(); + boost::system::error_code ec(last_error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "thread"); + } + arg.release(); + } + + // Destructor. + ~winapi_thread() + { + ::CloseHandle(thread_); + } + + // Wait for the thread to exit. + void join() + { +#if defined(BOOST_ASIO_WINDOWS_APP) + ::WaitForSingleObjectEx(thread_, INFINITE, false); +#else // defined(BOOST_ASIO_WINDOWS_APP) + ::WaitForSingleObject(thread_, INFINITE); +#endif // defined(BOOST_ASIO_WINDOWS_APP) + } + +private: + friend DWORD WINAPI winapi_thread_function(LPVOID arg); + + class func_base + { + public: + virtual ~func_base() {} + virtual void run() = 0; + }; + + template + class func + : public func_base + { + public: + func(Function f) + : f_(f) + { + } + + virtual void run() + { + f_(); + } + + private: + Function f_; + }; + + ::HANDLE thread_; +}; + +inline DWORD WINAPI winapi_thread_function(LPVOID arg) +{ + std::auto_ptr func( + static_cast(arg)); + func->run(); + return 0; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include + +#endif // defined(BOOST_ASIO_WINDOWS_APP) || defined(UNDER_CE) +#endif // defined(BOOST_ASIO_WINDOWS) + +#endif // BOOST_ASIO_DETAIL_WINAPI_THREAD_HPP diff --git a/boost/asio/ssl/impl/context.ipp b/boost/asio/ssl/impl/context.ipp index 67191ade20..acb191a706 100644 --- a/boost/asio/ssl/impl/context.ipp +++ b/boost/asio/ssl/impl/context.ipp @@ -89,6 +89,14 @@ context::context(context::method m) handle_ = ::SSL_CTX_new(::SSLv2_server_method()); break; #endif // defined(OPENSSL_NO_SSL2) +#if defined(OPENSSL_NO_SSL3) + case context::sslv3: + case context::sslv3_client: + case context::sslv3_server: + boost::asio::detail::throw_error( + boost::asio::error::invalid_argument, "context"); + break; +#else // defined(OPENSSL_NO_SSL3) case context::sslv3: handle_ = ::SSL_CTX_new(::SSLv3_method()); break; @@ -98,6 +106,7 @@ context::context(context::method m) case context::sslv3_server: handle_ = ::SSL_CTX_new(::SSLv3_server_method()); break; +#endif // defined(OPENSSL_NO_SSL3) case context::tlsv1: handle_ = ::SSL_CTX_new(::TLSv1_method()); break; @@ -557,11 +566,15 @@ boost::system::error_code context::use_certificate_chain( return ec; } +#if (OPENSSL_VERSION_NUMBER >= 0x10002000L) && !defined(LIBRESSL_VERSION_NUMBER) + ::SSL_CTX_clear_chain_certs(handle_); +#else if (handle_->extra_certs) { ::sk_X509_pop_free(handle_->extra_certs, X509_free); handle_->extra_certs = 0; } +#endif // (OPENSSL_VERSION_NUMBER >= 0x10002000L) while (X509* cacert = ::PEM_read_bio_X509(bio.p, 0, handle_->default_passwd_callback, @@ -949,7 +962,8 @@ int context::password_callback_function( strcpy_s(buf, size, passwd.c_str()); #else // defined(BOOST_ASIO_HAS_SECURE_RTL) *buf = '\0'; - strncat(buf, passwd.c_str(), size); + if (size > 0) + strncat(buf, passwd.c_str(), size - 1); #endif // defined(BOOST_ASIO_HAS_SECURE_RTL) return static_cast(strlen(buf)); diff --git a/boost/asio/ssl/old/detail/openssl_context_service.hpp b/boost/asio/ssl/old/detail/openssl_context_service.hpp index 9b45e3585f..61eac6efc5 100644 --- a/boost/asio/ssl/old/detail/openssl_context_service.hpp +++ b/boost/asio/ssl/old/detail/openssl_context_service.hpp @@ -85,6 +85,13 @@ public: impl = ::SSL_CTX_new(::SSLv2_server_method()); break; #endif // defined(OPENSSL_NO_SSL2) +#if defined(OPENSSL_NO_SSL3) + case context_base::sslv3: + case context_base::sslv3_client: + case context_base::sslv3_server: + boost::asio::detail::throw_error(boost::asio::error::invalid_argument); + break; +#else // defined(OPENSSL_NO_SSL3) case context_base::sslv3: impl = ::SSL_CTX_new(::SSLv3_method()); break; @@ -94,6 +101,7 @@ public: case context_base::sslv3_server: impl = ::SSL_CTX_new(::SSLv3_server_method()); break; +#endif // defined(OPENSSL_NO_SSL3) case context_base::tlsv1: impl = ::SSL_CTX_new(::TLSv1_method()); break; diff --git a/boost/asio/version.hpp b/boost/asio/version.hpp index e8eefafb17..8d506405c2 100644 --- a/boost/asio/version.hpp +++ b/boost/asio/version.hpp @@ -18,6 +18,6 @@ // BOOST_ASIO_VERSION % 100 is the sub-minor version // BOOST_ASIO_VERSION / 100 % 1000 is the minor version // BOOST_ASIO_VERSION / 100000 is the major version -#define BOOST_ASIO_VERSION 101006 // 1.10.6 +#define BOOST_ASIO_VERSION 101007 // 1.10.7 #endif // BOOST_ASIO_VERSION_HPP diff --git a/boost/assert.hpp b/boost/assert.hpp index 1713d9bb1d..9650d7a290 100644 --- a/boost/assert.hpp +++ b/boost/assert.hpp @@ -3,10 +3,12 @@ // BOOST_ASSERT_MSG(expr, msg) // BOOST_VERIFY(expr) // BOOST_VERIFY_MSG(expr, msg) +// BOOST_ASSERT_IS_VOID // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. // Copyright (c) 2007, 2014 Peter Dimov // Copyright (c) Beman Dawes 2011 +// Copyright (c) 2015 Ion Gaztanaga // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -24,16 +26,18 @@ // // -// BOOST_ASSERT, BOOST_ASSERT_MSG +// BOOST_ASSERT, BOOST_ASSERT_MSG, BOOST_ASSERT_IS_VOID // #undef BOOST_ASSERT #undef BOOST_ASSERT_MSG +#undef BOOST_ASSERT_IS_VOID #if defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) ) # define BOOST_ASSERT(expr) ((void)0) # define BOOST_ASSERT_MSG(expr, msg) ((void)0) +# define BOOST_ASSERT_IS_VOID #elif defined(BOOST_ENABLE_ASSERT_HANDLER) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && !defined(NDEBUG) ) @@ -55,6 +59,9 @@ namespace boost # define BOOST_ASSERT(expr) assert(expr) # define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg)) +#if defined(NDEBUG) +# define BOOST_ASSERT_IS_VOID +#endif #endif diff --git a/boost/atomic/detail/atomic_flag.hpp b/boost/atomic/detail/atomic_flag.hpp index 6a6667d8eb..7fb44cdb1a 100644 --- a/boost/atomic/detail/atomic_flag.hpp +++ b/boost/atomic/detail/atomic_flag.hpp @@ -42,7 +42,7 @@ struct atomic_flag typedef atomics::detail::operations< 1u, false > operations; typedef operations::storage_type storage_type; - storage_type m_storage; + operations::aligned_storage_type m_storage; BOOST_FORCEINLINE BOOST_CONSTEXPR atomic_flag() BOOST_NOEXCEPT : m_storage(0) { @@ -50,14 +50,14 @@ struct atomic_flag BOOST_FORCEINLINE bool test_and_set(memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return operations::test_and_set(m_storage, order); + return operations::test_and_set(m_storage.value, order); } BOOST_FORCEINLINE void clear(memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { BOOST_ASSERT(order != memory_order_acquire); BOOST_ASSERT(order != memory_order_acq_rel); - operations::clear(m_storage, order); + operations::clear(m_storage.value, order); } BOOST_DELETED_FUNCTION(atomic_flag(atomic_flag const&)) diff --git a/boost/atomic/detail/atomic_template.hpp b/boost/atomic/detail/atomic_template.hpp index bc3922a711..2deaded62f 100644 --- a/boost/atomic/detail/atomic_template.hpp +++ b/boost/atomic/detail/atomic_template.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #ifdef BOOST_HAS_PRAGMA_ONCE @@ -87,7 +87,7 @@ public: typedef typename operations::storage_type storage_type; protected: - storage_type m_storage; + typename operations::aligned_storage_type m_storage; public: BOOST_DEFAULTED_FUNCTION(base_atomic(), {}) @@ -99,7 +99,7 @@ public: BOOST_ASSERT(order != memory_order_acquire); BOOST_ASSERT(order != memory_order_acq_rel); - operations::store(m_storage, static_cast< storage_type >(v), order); + operations::store(m_storage.value, static_cast< storage_type >(v), order); } BOOST_FORCEINLINE value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT @@ -107,22 +107,22 @@ public: BOOST_ASSERT(order != memory_order_release); BOOST_ASSERT(order != memory_order_acq_rel); - return static_cast< value_type >(operations::load(m_storage, order)); + return static_cast< value_type >(operations::load(m_storage.value, order)); } BOOST_FORCEINLINE value_type fetch_add(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return static_cast< value_type >(operations::fetch_add(m_storage, static_cast< storage_type >(v), order)); + return static_cast< value_type >(operations::fetch_add(m_storage.value, static_cast< storage_type >(v), order)); } BOOST_FORCEINLINE value_type fetch_sub(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return static_cast< value_type >(operations::fetch_sub(m_storage, static_cast< storage_type >(v), order)); + return static_cast< value_type >(operations::fetch_sub(m_storage.value, static_cast< storage_type >(v), order)); } BOOST_FORCEINLINE value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return static_cast< value_type >(operations::exchange(m_storage, static_cast< storage_type >(v), order)); + return static_cast< value_type >(operations::exchange(m_storage.value, static_cast< storage_type >(v), order)); } BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order success_order, memory_order failure_order) volatile BOOST_NOEXCEPT @@ -132,7 +132,7 @@ public: BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); storage_type old_value = static_cast< storage_type >(expected); - const bool res = operations::compare_exchange_strong(m_storage, old_value, static_cast< storage_type >(desired), success_order, failure_order); + const bool res = operations::compare_exchange_strong(m_storage.value, old_value, static_cast< storage_type >(desired), success_order, failure_order); expected = static_cast< value_type >(old_value); return res; } @@ -149,7 +149,7 @@ public: BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); storage_type old_value = static_cast< storage_type >(expected); - const bool res = operations::compare_exchange_weak(m_storage, old_value, static_cast< storage_type >(desired), success_order, failure_order); + const bool res = operations::compare_exchange_weak(m_storage.value, old_value, static_cast< storage_type >(desired), success_order, failure_order); expected = static_cast< value_type >(old_value); return res; } @@ -161,22 +161,22 @@ public: BOOST_FORCEINLINE value_type fetch_and(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return static_cast< value_type >(operations::fetch_and(m_storage, static_cast< storage_type >(v), order)); + return static_cast< value_type >(operations::fetch_and(m_storage.value, static_cast< storage_type >(v), order)); } BOOST_FORCEINLINE value_type fetch_or(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return static_cast< value_type >(operations::fetch_or(m_storage, static_cast< storage_type >(v), order)); + return static_cast< value_type >(operations::fetch_or(m_storage.value, static_cast< storage_type >(v), order)); } BOOST_FORCEINLINE value_type fetch_xor(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return static_cast< value_type >(operations::fetch_xor(m_storage, static_cast< storage_type >(v), order)); + return static_cast< value_type >(operations::fetch_xor(m_storage.value, static_cast< storage_type >(v), order)); } BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT { - return operations::is_lock_free(m_storage); + return operations::is_lock_free(m_storage.value); } BOOST_FORCEINLINE value_type operator++(int) volatile BOOST_NOEXCEPT @@ -243,7 +243,7 @@ public: typedef operations::storage_type storage_type; protected: - storage_type m_storage; + operations::aligned_storage_type m_storage; public: BOOST_DEFAULTED_FUNCTION(base_atomic(), {}) @@ -255,7 +255,7 @@ public: BOOST_ASSERT(order != memory_order_acquire); BOOST_ASSERT(order != memory_order_acq_rel); - operations::store(m_storage, static_cast< storage_type >(v), order); + operations::store(m_storage.value, static_cast< storage_type >(v), order); } BOOST_FORCEINLINE value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT @@ -263,12 +263,12 @@ public: BOOST_ASSERT(order != memory_order_release); BOOST_ASSERT(order != memory_order_acq_rel); - return !!operations::load(m_storage, order); + return !!operations::load(m_storage.value, order); } BOOST_FORCEINLINE value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return !!operations::exchange(m_storage, static_cast< storage_type >(v), order); + return !!operations::exchange(m_storage.value, static_cast< storage_type >(v), order); } BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order success_order, memory_order failure_order) volatile BOOST_NOEXCEPT @@ -278,7 +278,7 @@ public: BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); storage_type old_value = static_cast< storage_type >(expected); - const bool res = operations::compare_exchange_strong(m_storage, old_value, static_cast< storage_type >(desired), success_order, failure_order); + const bool res = operations::compare_exchange_strong(m_storage.value, old_value, static_cast< storage_type >(desired), success_order, failure_order); expected = !!old_value; return res; } @@ -295,7 +295,7 @@ public: BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); storage_type old_value = static_cast< storage_type >(expected); - const bool res = operations::compare_exchange_weak(m_storage, old_value, static_cast< storage_type >(desired), success_order, failure_order); + const bool res = operations::compare_exchange_weak(m_storage.value, old_value, static_cast< storage_type >(desired), success_order, failure_order); expected = !!old_value; return res; } @@ -307,7 +307,7 @@ public: BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT { - return operations::is_lock_free(m_storage); + return operations::is_lock_free(m_storage.value); } BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&)) @@ -330,10 +330,10 @@ public: typedef typename operations::storage_type storage_type; protected: - storage_type m_storage; + typename operations::aligned_storage_type m_storage; public: - BOOST_FORCEINLINE explicit base_atomic(value_type const& v = value_type()) BOOST_NOEXCEPT : m_storage(atomics::detail::memcpy_cast< storage_type >(v)) + BOOST_FORCEINLINE explicit base_atomic(value_type const& v = value_type()) BOOST_NOEXCEPT : m_storage(atomics::detail::bitwise_cast< storage_type >(v)) { } @@ -343,7 +343,7 @@ public: BOOST_ASSERT(order != memory_order_acquire); BOOST_ASSERT(order != memory_order_acq_rel); - operations::store(m_storage, atomics::detail::memcpy_cast< storage_type >(v), order); + operations::store(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order); } BOOST_FORCEINLINE value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT @@ -351,12 +351,12 @@ public: BOOST_ASSERT(order != memory_order_release); BOOST_ASSERT(order != memory_order_acq_rel); - return atomics::detail::memcpy_cast< value_type >(operations::load(m_storage, order)); + return atomics::detail::bitwise_cast< value_type >(operations::load(m_storage.value, order)); } BOOST_FORCEINLINE value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return atomics::detail::memcpy_cast< value_type >(operations::exchange(m_storage, atomics::detail::memcpy_cast< storage_type >(v), order)); + return atomics::detail::bitwise_cast< value_type >(operations::exchange(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order)); } BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order success_order, memory_order failure_order) volatile BOOST_NOEXCEPT @@ -365,9 +365,9 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); - storage_type old_value = atomics::detail::memcpy_cast< storage_type >(expected); - const bool res = operations::compare_exchange_strong(m_storage, old_value, atomics::detail::memcpy_cast< storage_type >(desired), success_order, failure_order); - expected = atomics::detail::memcpy_cast< value_type >(old_value); + storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); + const bool res = operations::compare_exchange_strong(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); + expected = atomics::detail::bitwise_cast< value_type >(old_value); return res; } @@ -382,9 +382,9 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); - storage_type old_value = atomics::detail::memcpy_cast< storage_type >(expected); - const bool res = operations::compare_exchange_weak(m_storage, old_value, atomics::detail::memcpy_cast< storage_type >(desired), success_order, failure_order); - expected = atomics::detail::memcpy_cast< value_type >(old_value); + storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); + const bool res = operations::compare_exchange_weak(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); + expected = atomics::detail::bitwise_cast< value_type >(old_value); return res; } @@ -395,7 +395,7 @@ public: BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT { - return operations::is_lock_free(m_storage); + return operations::is_lock_free(m_storage.value); } BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&)) @@ -419,11 +419,11 @@ public: typedef typename operations::storage_type storage_type; protected: - storage_type m_storage; + typename operations::aligned_storage_type m_storage; public: BOOST_DEFAULTED_FUNCTION(base_atomic(), {}) - BOOST_FORCEINLINE explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : m_storage(atomics::detail::union_cast< storage_type >(v)) + BOOST_FORCEINLINE explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : m_storage(atomics::detail::bitwise_cast< storage_type >(v)) { } @@ -433,7 +433,7 @@ public: BOOST_ASSERT(order != memory_order_acquire); BOOST_ASSERT(order != memory_order_acq_rel); - operations::store(m_storage, atomics::detail::union_cast< storage_type >(v), order); + operations::store(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order); } BOOST_FORCEINLINE value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT @@ -441,22 +441,22 @@ public: BOOST_ASSERT(order != memory_order_release); BOOST_ASSERT(order != memory_order_acq_rel); - return atomics::detail::union_cast< value_type >(operations::load(m_storage, order)); + return atomics::detail::bitwise_cast< value_type >(operations::load(m_storage.value, order)); } BOOST_FORCEINLINE value_type fetch_add(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return atomics::detail::union_cast< value_type >(operations::fetch_add(m_storage, static_cast< storage_type >(v * sizeof(T)), order)); + return atomics::detail::bitwise_cast< value_type >(operations::fetch_add(m_storage.value, static_cast< storage_type >(v * sizeof(T)), order)); } BOOST_FORCEINLINE value_type fetch_sub(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return atomics::detail::union_cast< value_type >(operations::fetch_sub(m_storage, static_cast< storage_type >(v * sizeof(T)), order)); + return atomics::detail::bitwise_cast< value_type >(operations::fetch_sub(m_storage.value, static_cast< storage_type >(v * sizeof(T)), order)); } BOOST_FORCEINLINE value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return atomics::detail::union_cast< value_type >(operations::exchange(m_storage, atomics::detail::union_cast< storage_type >(v), order)); + return atomics::detail::bitwise_cast< value_type >(operations::exchange(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order)); } BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order success_order, memory_order failure_order) volatile BOOST_NOEXCEPT @@ -465,9 +465,9 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); - storage_type old_value = atomics::detail::union_cast< storage_type >(expected); - const bool res = operations::compare_exchange_strong(m_storage, old_value, atomics::detail::union_cast< storage_type >(desired), success_order, failure_order); - expected = atomics::detail::union_cast< value_type >(old_value); + storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); + const bool res = operations::compare_exchange_strong(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); + expected = atomics::detail::bitwise_cast< value_type >(old_value); return res; } @@ -482,9 +482,9 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); - storage_type old_value = atomics::detail::union_cast< storage_type >(expected); - const bool res = operations::compare_exchange_weak(m_storage, old_value, atomics::detail::union_cast< storage_type >(desired), success_order, failure_order); - expected = atomics::detail::union_cast< value_type >(old_value); + storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); + const bool res = operations::compare_exchange_weak(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); + expected = atomics::detail::bitwise_cast< value_type >(old_value); return res; } @@ -495,7 +495,7 @@ public: BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT { - return operations::is_lock_free(m_storage); + return operations::is_lock_free(m_storage.value); } BOOST_FORCEINLINE value_type operator++(int) volatile BOOST_NOEXCEPT @@ -549,11 +549,11 @@ public: typedef operations::storage_type storage_type; protected: - storage_type m_storage; + operations::aligned_storage_type m_storage; public: BOOST_DEFAULTED_FUNCTION(base_atomic(), {}) - BOOST_FORCEINLINE explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : m_storage(atomics::detail::union_cast< storage_type >(v)) + BOOST_FORCEINLINE explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : m_storage(atomics::detail::bitwise_cast< storage_type >(v)) { } @@ -563,7 +563,7 @@ public: BOOST_ASSERT(order != memory_order_acquire); BOOST_ASSERT(order != memory_order_acq_rel); - operations::store(m_storage, atomics::detail::union_cast< storage_type >(v), order); + operations::store(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order); } BOOST_FORCEINLINE value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT @@ -571,22 +571,22 @@ public: BOOST_ASSERT(order != memory_order_release); BOOST_ASSERT(order != memory_order_acq_rel); - return atomics::detail::union_cast< value_type >(operations::load(m_storage, order)); + return atomics::detail::bitwise_cast< value_type >(operations::load(m_storage.value, order)); } BOOST_FORCEINLINE value_type fetch_add(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return atomics::detail::union_cast< value_type >(operations::fetch_add(m_storage, static_cast< storage_type >(v), order)); + return atomics::detail::bitwise_cast< value_type >(operations::fetch_add(m_storage.value, static_cast< storage_type >(v), order)); } BOOST_FORCEINLINE value_type fetch_sub(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return atomics::detail::union_cast< value_type >(operations::fetch_sub(m_storage, static_cast< storage_type >(v), order)); + return atomics::detail::bitwise_cast< value_type >(operations::fetch_sub(m_storage.value, static_cast< storage_type >(v), order)); } BOOST_FORCEINLINE value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT { - return atomics::detail::union_cast< value_type >(operations::exchange(m_storage, atomics::detail::union_cast< storage_type >(v), order)); + return atomics::detail::bitwise_cast< value_type >(operations::exchange(m_storage.value, atomics::detail::bitwise_cast< storage_type >(v), order)); } BOOST_FORCEINLINE bool compare_exchange_strong(value_type& expected, value_type desired, memory_order success_order, memory_order failure_order) volatile BOOST_NOEXCEPT @@ -595,9 +595,9 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); - storage_type old_value = atomics::detail::union_cast< storage_type >(expected); - const bool res = operations::compare_exchange_strong(m_storage, old_value, atomics::detail::union_cast< storage_type >(desired), success_order, failure_order); - expected = atomics::detail::union_cast< value_type >(old_value); + storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); + const bool res = operations::compare_exchange_strong(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); + expected = atomics::detail::bitwise_cast< value_type >(old_value); return res; } @@ -612,9 +612,9 @@ public: BOOST_ASSERT(failure_order != memory_order_acq_rel); BOOST_ASSERT(cas_failure_order_must_not_be_stronger_than_success_order(success_order, failure_order)); - storage_type old_value = atomics::detail::union_cast< storage_type >(expected); - const bool res = operations::compare_exchange_weak(m_storage, old_value, atomics::detail::union_cast< storage_type >(desired), success_order, failure_order); - expected = atomics::detail::union_cast< value_type >(old_value); + storage_type old_value = atomics::detail::bitwise_cast< storage_type >(expected); + const bool res = operations::compare_exchange_weak(m_storage.value, old_value, atomics::detail::bitwise_cast< storage_type >(desired), success_order, failure_order); + expected = atomics::detail::bitwise_cast< value_type >(old_value); return res; } @@ -625,7 +625,7 @@ public: BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT { - return operations::is_lock_free(m_storage); + return operations::is_lock_free(m_storage.value); } BOOST_FORCEINLINE value_type operator++(int) volatile BOOST_NOEXCEPT @@ -696,10 +696,10 @@ public: return this->load(); } - BOOST_FORCEINLINE storage_type& storage() BOOST_NOEXCEPT { return this->m_storage; } - BOOST_FORCEINLINE storage_type volatile& storage() volatile BOOST_NOEXCEPT { return this->m_storage; } - BOOST_FORCEINLINE storage_type const& storage() const BOOST_NOEXCEPT { return this->m_storage; } - BOOST_FORCEINLINE storage_type const volatile& storage() const volatile BOOST_NOEXCEPT { return this->m_storage; } + BOOST_FORCEINLINE storage_type& storage() BOOST_NOEXCEPT { return this->m_storage.value; } + BOOST_FORCEINLINE storage_type volatile& storage() volatile BOOST_NOEXCEPT { return this->m_storage.value; } + BOOST_FORCEINLINE storage_type const& storage() const BOOST_NOEXCEPT { return this->m_storage.value; } + BOOST_FORCEINLINE storage_type const volatile& storage() const volatile BOOST_NOEXCEPT { return this->m_storage.value; } BOOST_DELETED_FUNCTION(atomic(atomic const&)) BOOST_DELETED_FUNCTION(atomic& operator= (atomic const&)) diff --git a/boost/atomic/detail/bitwise_cast.hpp b/boost/atomic/detail/bitwise_cast.hpp new file mode 100644 index 0000000000..8654d10b95 --- /dev/null +++ b/boost/atomic/detail/bitwise_cast.hpp @@ -0,0 +1,53 @@ +/* + * Distributed under the 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) 2009 Helge Bahmann + * Copyright (c) 2012 Tim Blechmann + * Copyright (c) 2013 - 2014 Andrey Semashev + */ +/*! + * \file atomic/detail/bitwise_cast.hpp + * + * This header defines \c bitwise_cast used to convert between storage and value types + */ + +#ifndef BOOST_ATOMIC_DETAIL_BITWISE_CAST_HPP_INCLUDED_ +#define BOOST_ATOMIC_DETAIL_BITWISE_CAST_HPP_INCLUDED_ + +#include +#if !defined(BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY) +#include +#endif + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace boost { +namespace atomics { +namespace detail { + +template< typename To, typename From > +BOOST_FORCEINLINE To bitwise_cast(From const& from) BOOST_NOEXCEPT +{ + struct + { + To to; + } + value = {}; + BOOST_ATOMIC_DETAIL_MEMCPY + ( + &reinterpret_cast< char& >(value.to), + &reinterpret_cast< const char& >(from), + (sizeof(From) < sizeof(To) ? sizeof(From) : sizeof(To)) + ); + return value.to; +} + +} // namespace detail +} // namespace atomics +} // namespace boost + +#endif // BOOST_ATOMIC_DETAIL_BITWISE_CAST_HPP_INCLUDED_ diff --git a/boost/atomic/detail/caps_gcc_ppc.hpp b/boost/atomic/detail/caps_gcc_ppc.hpp index 6dbdde826d..ee2346081b 100644 --- a/boost/atomic/detail/caps_gcc_ppc.hpp +++ b/boost/atomic/detail/caps_gcc_ppc.hpp @@ -25,7 +25,7 @@ #define BOOST_ATOMIC_INT8_LOCK_FREE 2 #define BOOST_ATOMIC_INT16_LOCK_FREE 2 #define BOOST_ATOMIC_INT32_LOCK_FREE 2 -#if defined(__powerpc64__) +#if defined(__powerpc64__) || defined(__PPC64__) #define BOOST_ATOMIC_INT64_LOCK_FREE 2 #endif #define BOOST_ATOMIC_POINTER_LOCK_FREE 2 diff --git a/boost/atomic/detail/casts.hpp b/boost/atomic/detail/casts.hpp deleted file mode 100644 index db28bc25ff..0000000000 --- a/boost/atomic/detail/casts.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Distributed under the 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) 2009 Helge Bahmann - * Copyright (c) 2012 Tim Blechmann - * Copyright (c) 2013 - 2014 Andrey Semashev - */ -/*! - * \file atomic/detail/casts.hpp - * - * This header defines \c union_cast and \c memcpy_cast used to convert between storage and value types - */ - -#ifndef BOOST_ATOMIC_DETAIL_CASTS_HPP_INCLUDED_ -#define BOOST_ATOMIC_DETAIL_CASTS_HPP_INCLUDED_ - -#include -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace atomics { -namespace detail { - -template< typename To, typename From > -BOOST_FORCEINLINE To union_cast(From const& from) BOOST_NOEXCEPT -{ - union - { - To as_to; - From as_from; - } - caster = {}; - caster.as_from = from; - return caster.as_to; -} - -template< typename To, typename From > -BOOST_FORCEINLINE To memcpy_cast(From const& from) BOOST_NOEXCEPT -{ - struct - { - To to; - } - value = {}; - std::memcpy - ( - &reinterpret_cast< char& >(value.to), - &reinterpret_cast< const char& >(from), - (sizeof(From) < sizeof(To) ? sizeof(From) : sizeof(To)) - ); - return value.to; -} - -} // namespace detail -} // namespace atomics -} // namespace boost - -#endif // BOOST_ATOMIC_DETAIL_CASTS_HPP_INCLUDED_ diff --git a/boost/atomic/detail/config.hpp b/boost/atomic/detail/config.hpp index 6b0e418693..489281c2b4 100644 --- a/boost/atomic/detail/config.hpp +++ b/boost/atomic/detail/config.hpp @@ -21,6 +21,30 @@ #pragma once #endif +#if defined(__has_builtin) +#if __has_builtin(__builtin_memcpy) +#define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY +#endif +#if __has_builtin(__builtin_memcmp) +#define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCMP +#endif +#elif defined(BOOST_GCC) +#define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY +#define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCMP +#endif + +#if defined(BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY) +#define BOOST_ATOMIC_DETAIL_MEMCPY __builtin_memcpy +#else +#define BOOST_ATOMIC_DETAIL_MEMCPY std::memcpy +#endif + +#if defined(BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCMP) +#define BOOST_ATOMIC_DETAIL_MEMCMP __builtin_memcmp +#else +#define BOOST_ATOMIC_DETAIL_MEMCMP std::memcmp +#endif + #if defined(__CUDACC__) // nvcc does not support alternatives in asm statement constraints #define BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES @@ -36,4 +60,16 @@ #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA #endif +#if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 403) +// This macro indicates we're using older binutils that don't support implied zero displacements for memory opereands, +// making code like this invalid: +// movl 4+(%%edx), %%eax +#define BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS +#endif + +#if defined(__clang__) || (defined(BOOST_GCC) && (BOOST_GCC+0) < 40500) +// This macro indicates that the compiler does not support allocating rax:rdx register pairs ("A") in asm blocks +#define BOOST_ATOMIC_DETAIL_NO_ASM_RAX_RDX_PAIRS +#endif + #endif // BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_ diff --git a/boost/atomic/detail/int_sizes.hpp b/boost/atomic/detail/int_sizes.hpp index d06ed42a11..eada4fff07 100644 --- a/boost/atomic/detail/int_sizes.hpp +++ b/boost/atomic/detail/int_sizes.hpp @@ -117,8 +117,8 @@ #include #include -#if defined(_MSC_VER) && _MSC_VER <= 1310 -// MSVC 7.1 defines WCHAR_MAX to a value not suitable for constant expressions + #if defined(_MSC_VER) && ( _MSC_VER <= 1310 || defined(UNDER_CE) && _MSC_VER <= 1500 ) +// MSVC 7.1 and MSVC 8 (arm) define WCHAR_MAX to a value not suitable for constant expressions #define BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T 2 #elif (WCHAR_MAX + 0) == 0xff || (WCHAR_MAX + 0) == 0x7f #define BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T 1 diff --git a/boost/atomic/detail/operations_fwd.hpp b/boost/atomic/detail/operations_fwd.hpp index 69049e4630..efd4970747 100644 --- a/boost/atomic/detail/operations_fwd.hpp +++ b/boost/atomic/detail/operations_fwd.hpp @@ -14,6 +14,7 @@ #ifndef BOOST_ATOMIC_DETAIL_OPERATIONS_FWD_HPP_INCLUDED_ #define BOOST_ATOMIC_DETAIL_OPERATIONS_FWD_HPP_INCLUDED_ +#include #include #ifdef BOOST_HAS_PRAGMA_ONCE @@ -24,7 +25,7 @@ namespace boost { namespace atomics { namespace detail { -template< unsigned int Size, bool Signed > +template< std::size_t Size, bool Signed > struct operations; } // namespace detail diff --git a/boost/atomic/detail/ops_cas_based.hpp b/boost/atomic/detail/ops_cas_based.hpp index 7f8d288f7f..504cedb70f 100644 --- a/boost/atomic/detail/ops_cas_based.hpp +++ b/boost/atomic/detail/ops_cas_based.hpp @@ -16,6 +16,7 @@ #include #include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once @@ -25,6 +26,21 @@ namespace boost { namespace atomics { namespace detail { +template< typename Base > +struct cas_based_exchange : + public Base +{ + typedef typename Base::storage_type storage_type; + + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + storage_type old_val; + atomics::detail::non_atomic_load(storage, old_val); + while (!Base::compare_exchange_weak(storage, old_val, v, order, memory_order_relaxed)) {} + return old_val; + } +}; + template< typename Base > struct cas_based_operations : public Base @@ -33,49 +49,47 @@ struct cas_based_operations : static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { - storage_type old_val = Base::load(storage, memory_order_relaxed); + storage_type old_val; + atomics::detail::non_atomic_load(storage, old_val); while (!Base::compare_exchange_weak(storage, old_val, old_val + v, order, memory_order_relaxed)) {} return old_val; } static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { - storage_type old_val = Base::load(storage, memory_order_relaxed); + storage_type old_val; + atomics::detail::non_atomic_load(storage, old_val); while (!Base::compare_exchange_weak(storage, old_val, old_val - v, order, memory_order_relaxed)) {} return old_val; } - static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT - { - storage_type old_val = Base::load(storage, memory_order_relaxed); - while (!Base::compare_exchange_weak(storage, old_val, v, order, memory_order_relaxed)) {} - return old_val; - } - static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { - storage_type old_val = Base::load(storage, memory_order_relaxed); + storage_type old_val; + atomics::detail::non_atomic_load(storage, old_val); while (!Base::compare_exchange_weak(storage, old_val, old_val & v, order, memory_order_relaxed)) {} return old_val; } static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { - storage_type old_val = Base::load(storage, memory_order_relaxed); + storage_type old_val; + atomics::detail::non_atomic_load(storage, old_val); while (!Base::compare_exchange_weak(storage, old_val, old_val | v, order, memory_order_relaxed)) {} return old_val; } static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { - storage_type old_val = Base::load(storage, memory_order_relaxed); + storage_type old_val; + atomics::detail::non_atomic_load(storage, old_val); while (!Base::compare_exchange_weak(storage, old_val, old_val ^ v, order, memory_order_relaxed)) {} return old_val; } static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT { - return !!exchange(storage, (storage_type)1, order); + return !!Base::exchange(storage, (storage_type)1, order); } static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT diff --git a/boost/atomic/detail/ops_emulated.hpp b/boost/atomic/detail/ops_emulated.hpp index 597490f2d7..0dc4e6828a 100644 --- a/boost/atomic/detail/ops_emulated.hpp +++ b/boost/atomic/detail/ops_emulated.hpp @@ -14,6 +14,7 @@ #ifndef BOOST_ATOMIC_DETAIL_OPS_EMULATED_HPP_INCLUDED_ #define BOOST_ATOMIC_DETAIL_OPS_EMULATED_HPP_INCLUDED_ +#include #include #include #include @@ -90,7 +91,17 @@ struct emulated_operations static BOOST_FORCEINLINE bool compare_exchange_weak( storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT { - return compare_exchange_strong(storage, expected, desired, success_order, failure_order); + // Note: This function is the exact copy of compare_exchange_strong. The reason we're not just forwarding the call + // is that MSVC-12 ICEs in this case. + storage_type& s = const_cast< storage_type& >(storage); + lockpool::scoped_lock lock(&storage); + storage_type old_val = s; + const bool res = old_val == expected; + if (res) + s = desired; + expected = old_val; + + return res; } static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT @@ -136,10 +147,11 @@ struct emulated_operations } }; -template< unsigned int Size, bool Signed > +template< std::size_t Size, bool Signed > struct operations : public emulated_operations< typename make_storage_type< Size, Signed >::type > { + typedef typename make_storage_type< Size, Signed >::aligned aligned_storage_type; }; } // namespace detail diff --git a/boost/atomic/detail/ops_extending_cas_based.hpp b/boost/atomic/detail/ops_extending_cas_based.hpp index d7f3c5f5de..3f21031f12 100644 --- a/boost/atomic/detail/ops_extending_cas_based.hpp +++ b/boost/atomic/detail/ops_extending_cas_based.hpp @@ -14,6 +14,7 @@ #ifndef BOOST_ATOMIC_DETAIL_OPS_EXTENDING_CAS_BASED_HPP_INCLUDED_ #define BOOST_ATOMIC_DETAIL_OPS_EXTENDING_CAS_BASED_HPP_INCLUDED_ +#include #include #include #include @@ -26,7 +27,7 @@ namespace boost { namespace atomics { namespace detail { -template< typename Base, unsigned int Size, bool Signed > +template< typename Base, std::size_t Size, bool Signed > struct extending_cas_based_operations : public Base { @@ -35,7 +36,8 @@ struct extending_cas_based_operations : static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { - storage_type old_val = Base::load(storage, memory_order_relaxed); + storage_type old_val; + atomics::detail::non_atomic_load(storage, old_val); emulated_storage_type new_val; do { @@ -47,7 +49,8 @@ struct extending_cas_based_operations : static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { - storage_type old_val = Base::load(storage, memory_order_relaxed); + storage_type old_val; + atomics::detail::non_atomic_load(storage, old_val); emulated_storage_type new_val; do { diff --git a/boost/atomic/detail/ops_gcc_alpha.hpp b/boost/atomic/detail/ops_gcc_alpha.hpp index 6978c7f1c4..3c0e258ceb 100644 --- a/boost/atomic/detail/ops_gcc_alpha.hpp +++ b/boost/atomic/detail/ops_gcc_alpha.hpp @@ -88,6 +88,7 @@ struct operations< 4u, Signed > : public gcc_alpha_operations_base { typedef typename make_storage_type< 4u, Signed >::type storage_type; + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { @@ -599,6 +600,7 @@ struct operations< 8u, Signed > : public gcc_alpha_operations_base { typedef typename make_storage_type< 8u, Signed >::type storage_type; + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { diff --git a/boost/atomic/detail/ops_gcc_arm.hpp b/boost/atomic/detail/ops_gcc_arm.hpp index a28da6919d..d2c2f39a2c 100644 --- a/boost/atomic/detail/ops_gcc_arm.hpp +++ b/boost/atomic/detail/ops_gcc_arm.hpp @@ -156,6 +156,7 @@ struct operations< 4u, Signed > : public gcc_arm_operations_base { typedef typename make_storage_type< 4u, Signed >::type storage_type; + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { @@ -677,6 +678,7 @@ struct operations< 8u, Signed > : public gcc_arm_operations_base { typedef typename make_storage_type< 8u, Signed >::type storage_type; + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { diff --git a/boost/atomic/detail/ops_gcc_atomic.hpp b/boost/atomic/detail/ops_gcc_atomic.hpp index 2e4c37bec7..573a695d08 100644 --- a/boost/atomic/detail/ops_gcc_atomic.hpp +++ b/boost/atomic/detail/ops_gcc_atomic.hpp @@ -180,6 +180,7 @@ template< bool Signed > struct operations< 16u, Signed > : public gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type > { + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; }; #endif @@ -208,6 +209,7 @@ template< bool Signed > struct operations< 8u, Signed > : public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 8u, Signed > { + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; }; #else @@ -216,6 +218,7 @@ template< bool Signed > struct operations< 8u, Signed > : public gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type > { + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; }; #endif @@ -236,6 +239,7 @@ template< bool Signed > struct operations< 4u, Signed > : public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 4u, Signed > { + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; }; #else // !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED) @@ -244,6 +248,7 @@ template< bool Signed > struct operations< 4u, Signed > : public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 4u, Signed > { + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; }; #endif // !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED) @@ -254,6 +259,7 @@ template< bool Signed > struct operations< 4u, Signed > : public gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type > { + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; }; #endif @@ -274,6 +280,7 @@ template< bool Signed > struct operations< 2u, Signed > : public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type >, 2u, Signed > { + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; }; #elif !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED) @@ -282,6 +289,7 @@ template< bool Signed > struct operations< 2u, Signed > : public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 2u, Signed > { + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; }; #else @@ -290,6 +298,7 @@ template< bool Signed > struct operations< 2u, Signed > : public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 2u, Signed > { + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; }; #endif @@ -300,6 +309,7 @@ template< bool Signed > struct operations< 2u, Signed > : public gcc_atomic_operations< typename make_storage_type< 2u, Signed >::type > { + typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type; }; #endif @@ -320,6 +330,7 @@ template< bool Signed > struct operations< 1u, Signed > : public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 2u, Signed >::type >, 1u, Signed > { + typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type; }; #elif !defined(BOOST_ATOMIC_DETAIL_INT32_EXTENDED) @@ -328,6 +339,7 @@ template< bool Signed > struct operations< 1u, Signed > : public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type >, 1u, Signed > { + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; }; #elif !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED) @@ -336,6 +348,7 @@ template< bool Signed > struct operations< 1u, Signed > : public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 1u, Signed > { + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; }; #else @@ -344,6 +357,7 @@ template< bool Signed > struct operations< 1u, Signed > : public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 1u, Signed > { + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; }; #endif @@ -354,6 +368,7 @@ template< bool Signed > struct operations< 1u, Signed > : public gcc_atomic_operations< typename make_storage_type< 1u, Signed >::type > { + typedef typename make_storage_type< 1u, Signed >::aligned aligned_storage_type; }; #endif diff --git a/boost/atomic/detail/ops_gcc_ppc.hpp b/boost/atomic/detail/ops_gcc_ppc.hpp index 8698ee8d76..9131791193 100644 --- a/boost/atomic/detail/ops_gcc_ppc.hpp +++ b/boost/atomic/detail/ops_gcc_ppc.hpp @@ -30,6 +30,9 @@ namespace boost { namespace atomics { namespace detail { +// The implementation below uses information from this document: +// http://www.rdrop.com/users/paulmck/scalability/paper/N2745r.2010.02.19a.html + /* Refer to: Motorola: "Programming Environments Manual for 32-Bit Implementations of the PowerPC Architecture", Appendix E: @@ -84,7 +87,7 @@ struct gcc_ppc_operations_base { static BOOST_FORCEINLINE void fence_before(memory_order order) BOOST_NOEXCEPT { -#if defined(__powerpc64__) +#if defined(__powerpc64__) || defined(__PPC64__) if (order == memory_order_seq_cst) __asm__ __volatile__ ("sync" ::: "memory"); else if ((order & memory_order_release) != 0) @@ -100,12 +103,6 @@ struct gcc_ppc_operations_base if ((order & (memory_order_consume | memory_order_acquire)) != 0) __asm__ __volatile__ ("isync" ::: "memory"); } - - static BOOST_FORCEINLINE void fence_after_store(memory_order order) BOOST_NOEXCEPT - { - if (order == memory_order_seq_cst) - __asm__ __volatile__ ("sync" ::: "memory"); - } }; @@ -114,33 +111,47 @@ struct operations< 4u, Signed > : public gcc_ppc_operations_base { typedef typename make_storage_type< 4u, Signed >::type storage_type; + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { fence_before(order); __asm__ __volatile__ ( - "stw %1, %0\n" + "stw %1, %0\n\t" : "+m" (storage) : "r" (v) ); - fence_after_store(order); } static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT { storage_type v; - __asm__ __volatile__ - ( - "lwz %0, %1\n" - "cmpw %0, %0\n" - "bne- 1f\n" - "1:\n" - : "=&r" (v) - : "m" (storage) - : "cr0" - ); - fence_after(order); + if (order == memory_order_seq_cst) + __asm__ __volatile__ ("sync" ::: "memory"); + if ((order & (memory_order_consume | memory_order_acquire)) != 0) + { + __asm__ __volatile__ + ( + "lwz %0, %1\n\t" + "cmpw %0, %0\n\t" + "bne- 1f\n\t" + "1:\n\t" + "isync\n\t" + : "=&r" (v) + : "m" (storage) + : "cr0", "memory" + ); + } + else + { + __asm__ __volatile__ + ( + "lwz %0, %1\n\t" + : "=&r" (v) + : "m" (storage) + ); + } return v; } @@ -150,10 +161,10 @@ struct operations< 4u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y1\n" - "stwcx. %2,%y1\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y1\n\t" + "stwcx. %2,%y1\n\t" + "bne- 1b\n\t" : "=&b" (original), "+Z" (storage) : "b" (v) : "cr0" @@ -169,14 +180,14 @@ struct operations< 4u, Signed > : fence_before(success_order); __asm__ __volatile__ ( - "li %1, 0\n" - "lwarx %0,%y2\n" - "cmpw %0, %3\n" - "bne- 1f\n" - "stwcx. %4,%y2\n" - "bne- 1f\n" - "li %1, 1\n" - "1:" + "li %1, 0\n\t" + "lwarx %0,%y2\n\t" + "cmpw %0, %3\n\t" + "bne- 1f\n\t" + "stwcx. %4,%y2\n\t" + "bne- 1f\n\t" + "li %1, 1\n\t" + "1:\n\t" : "=&b" (expected), "=&b" (success), "+Z" (storage) : "b" (expected), "b" (desired) : "cr0" @@ -195,14 +206,14 @@ struct operations< 4u, Signed > : fence_before(success_order); __asm__ __volatile__ ( - "li %1, 0\n" - "0: lwarx %0,%y2\n" - "cmpw %0, %3\n" - "bne- 1f\n" - "stwcx. %4,%y2\n" - "bne- 0b\n" - "li %1, 1\n" - "1:" + "li %1, 0\n\t" + "0: lwarx %0,%y2\n\t" + "cmpw %0, %3\n\t" + "bne- 1f\n\t" + "stwcx. %4,%y2\n\t" + "bne- 0b\n\t" + "li %1, 1\n\t" + "1:\n\t" : "=&b" (expected), "=&b" (success), "+Z" (storage) : "b" (expected), "b" (desired) : "cr0" @@ -220,11 +231,11 @@ struct operations< 4u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "add %1,%0,%3\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "add %1,%0,%3\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -239,11 +250,11 @@ struct operations< 4u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "sub %1,%0,%3\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "sub %1,%0,%3\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -258,11 +269,11 @@ struct operations< 4u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "and %1,%0,%3\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "and %1,%0,%3\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -277,11 +288,11 @@ struct operations< 4u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "or %1,%0,%3\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "or %1,%0,%3\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -296,11 +307,11 @@ struct operations< 4u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "xor %1,%0,%3\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "xor %1,%0,%3\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -339,12 +350,12 @@ struct operations< 1u, false > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "add %1,%0,%3\n" - "rlwinm %1, %1, 0, 0xff\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "add %1,%0,%3\n\t" + "rlwinm %1, %1, 0, 0xff\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -359,12 +370,12 @@ struct operations< 1u, false > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "sub %1,%0,%3\n" - "rlwinm %1, %1, 0, 0xff\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "sub %1,%0,%3\n\t" + "rlwinm %1, %1, 0, 0xff\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -387,12 +398,12 @@ struct operations< 1u, true > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "add %1,%0,%3\n" - "extsb %1, %1\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "add %1,%0,%3\n\t" + "extsb %1, %1\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -407,12 +418,12 @@ struct operations< 1u, true > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "sub %1,%0,%3\n" - "extsb %1, %1\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "sub %1,%0,%3\n\t" + "extsb %1, %1\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -436,12 +447,12 @@ struct operations< 2u, false > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "add %1,%0,%3\n" - "rlwinm %1, %1, 0, 0xffff\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "add %1,%0,%3\n\t" + "rlwinm %1, %1, 0, 0xffff\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -456,12 +467,12 @@ struct operations< 2u, false > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "sub %1,%0,%3\n" - "rlwinm %1, %1, 0, 0xffff\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "sub %1,%0,%3\n\t" + "rlwinm %1, %1, 0, 0xffff\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -484,12 +495,12 @@ struct operations< 2u, true > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "add %1,%0,%3\n" - "extsh %1, %1\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "add %1,%0,%3\n\t" + "extsh %1, %1\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -504,12 +515,12 @@ struct operations< 2u, true > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "lwarx %0,%y2\n" - "sub %1,%0,%3\n" - "extsh %1, %1\n" - "stwcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "lwarx %0,%y2\n\t" + "sub %1,%0,%3\n\t" + "extsh %1, %1\n\t" + "stwcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -520,40 +531,54 @@ struct operations< 2u, true > : }; -#if defined(__powerpc64__) +#if defined(__powerpc64__) || defined(__PPC64__) template< bool Signed > struct operations< 8u, Signed > : public gcc_ppc_operations_base { typedef typename make_storage_type< 8u, Signed >::type storage_type; + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { fence_before(order); __asm__ __volatile__ ( - "std %1, %0\n" + "std %1, %0\n\t" : "+m" (storage) : "r" (v) ); - fence_after_store(order); } static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT { storage_type v; - __asm__ __volatile__ - ( - "ld %0, %1\n" - "cmpd %0, %0\n" - "bne- 1f\n" - "1:\n" - : "=&b" (v) - : "m" (storage) - : "cr0" - ); - fence_after(order); + if (order == memory_order_seq_cst) + __asm__ __volatile__ ("sync" ::: "memory"); + if ((order & (memory_order_consume | memory_order_acquire)) != 0) + { + __asm__ __volatile__ + ( + "ld %0, %1\n\t" + "cmpd %0, %0\n\t" + "bne- 1f\n\t" + "1:\n\t" + "isync\n\t" + : "=&b" (v) + : "m" (storage) + : "cr0", "memory" + ); + } + else + { + __asm__ __volatile__ + ( + "ld %0, %1\n\t" + : "=&b" (v) + : "m" (storage) + ); + } return v; } @@ -563,10 +588,10 @@ struct operations< 8u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "ldarx %0,%y1\n" - "stdcx. %2,%y1\n" - "bne- 1b\n" + "1:\n\t" + "ldarx %0,%y1\n\t" + "stdcx. %2,%y1\n\t" + "bne- 1b\n\t" : "=&b" (original), "+Z" (storage) : "b" (v) : "cr0" @@ -582,13 +607,13 @@ struct operations< 8u, Signed > : fence_before(success_order); __asm__ __volatile__ ( - "li %1, 0\n" - "ldarx %0,%y2\n" - "cmpd %0, %3\n" - "bne- 1f\n" - "stdcx. %4,%y2\n" - "bne- 1f\n" - "li %1, 1\n" + "li %1, 0\n\t" + "ldarx %0,%y2\n\t" + "cmpd %0, %3\n\t" + "bne- 1f\n\t" + "stdcx. %4,%y2\n\t" + "bne- 1f\n\t" + "li %1, 1\n\t" "1:" : "=&b" (expected), "=&b" (success), "+Z" (storage) : "b" (expected), "b" (desired) @@ -608,14 +633,14 @@ struct operations< 8u, Signed > : fence_before(success_order); __asm__ __volatile__ ( - "li %1, 0\n" - "0: ldarx %0,%y2\n" - "cmpd %0, %3\n" - "bne- 1f\n" - "stdcx. %4,%y2\n" - "bne- 0b\n" - "li %1, 1\n" - "1:" + "li %1, 0\n\t" + "0: ldarx %0,%y2\n\t" + "cmpd %0, %3\n\t" + "bne- 1f\n\t" + "stdcx. %4,%y2\n\t" + "bne- 0b\n\t" + "li %1, 1\n\t" + "1:\n\t" : "=&b" (expected), "=&b" (success), "+Z" (storage) : "b" (expected), "b" (desired) : "cr0" @@ -633,11 +658,11 @@ struct operations< 8u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "ldarx %0,%y2\n" - "add %1,%0,%3\n" - "stdcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "ldarx %0,%y2\n\t" + "add %1,%0,%3\n\t" + "stdcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -652,11 +677,11 @@ struct operations< 8u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "ldarx %0,%y2\n" - "sub %1,%0,%3\n" - "stdcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "ldarx %0,%y2\n\t" + "sub %1,%0,%3\n\t" + "stdcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -671,11 +696,11 @@ struct operations< 8u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "ldarx %0,%y2\n" - "and %1,%0,%3\n" - "stdcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "ldarx %0,%y2\n\t" + "and %1,%0,%3\n\t" + "stdcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -690,11 +715,11 @@ struct operations< 8u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "ldarx %0,%y2\n" - "or %1,%0,%3\n" - "stdcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "ldarx %0,%y2\n\t" + "or %1,%0,%3\n\t" + "stdcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -709,11 +734,11 @@ struct operations< 8u, Signed > : fence_before(order); __asm__ __volatile__ ( - "1:\n" - "ldarx %0,%y2\n" - "xor %1,%0,%3\n" - "stdcx. %1,%y2\n" - "bne- 1b\n" + "1:\n\t" + "ldarx %0,%y2\n\t" + "xor %1,%0,%3\n\t" + "stdcx. %1,%y2\n\t" + "bne- 1b\n\t" : "=&b" (original), "=&b" (tmp), "+Z" (storage) : "b" (v) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC @@ -738,7 +763,7 @@ struct operations< 8u, Signed > : } }; -#endif // defined(__powerpc64__) +#endif // defined(__powerpc64__) || defined(__PPC64__) BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT @@ -747,14 +772,12 @@ BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT { case memory_order_consume: case memory_order_acquire: - __asm__ __volatile__ ("isync" ::: "memory"); - break; case memory_order_release: -#if defined(__powerpc64__) + case memory_order_acq_rel: +#if defined(__powerpc64__) || defined(__PPC64__) __asm__ __volatile__ ("lwsync" ::: "memory"); break; #endif - case memory_order_acq_rel: case memory_order_seq_cst: __asm__ __volatile__ ("sync" ::: "memory"); break; @@ -765,7 +788,11 @@ BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT { if (order != memory_order_relaxed) +#if defined(__ibmxl__) || defined(__IBMCPP__) + __fence(); +#else __asm__ __volatile__ ("" ::: "memory"); +#endif } } // namespace detail diff --git a/boost/atomic/detail/ops_gcc_sparc.hpp b/boost/atomic/detail/ops_gcc_sparc.hpp index ea6df91dc6..020882bbfa 100644 --- a/boost/atomic/detail/ops_gcc_sparc.hpp +++ b/boost/atomic/detail/ops_gcc_sparc.hpp @@ -62,6 +62,7 @@ struct gcc_sparc_cas32 : public gcc_sparc_cas_base { typedef typename make_storage_type< 4u, Signed >::type storage_type; + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { @@ -104,19 +105,6 @@ struct gcc_sparc_cas32 : return compare_exchange_strong(storage, expected, desired, success_order, failure_order); } - static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT - { - return true; - } -}; - -template< bool Signed > -struct operations< 4u, Signed > : - public cas_based_operations< gcc_sparc_cas32< Signed > > -{ - typedef cas_based_operations< gcc_sparc_cas32< Signed > > base_type; - typedef typename base_type::storage_type storage_type; - static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { base_type::fence_before(order); @@ -131,12 +119,18 @@ struct operations< 4u, Signed > : return v; } - static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT { - return !!exchange(storage, (storage_type)1, order); + return true; } }; +template< bool Signed > +struct operations< 4u, Signed > : + public cas_based_operations< gcc_sparc_cas32< Signed > > +{ +}; + template< bool Signed > struct operations< 1u, Signed > : public extending_cas_based_operations< operations< 4u, Signed >, 1u, Signed > @@ -154,6 +148,7 @@ struct gcc_sparc_cas64 : public gcc_sparc_cas_base { typedef typename make_storage_type< 8u, Signed >::type storage_type; + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { @@ -204,7 +199,7 @@ struct gcc_sparc_cas64 : template< bool Signed > struct operations< 8u, Signed > : - public cas_based_operations< gcc_sparc_cas64< Signed > > + public cas_based_operations< cas_based_exchange< gcc_sparc_cas64< Signed > > > { }; diff --git a/boost/atomic/detail/ops_gcc_sync.hpp b/boost/atomic/detail/ops_gcc_sync.hpp index f4fc3331c6..87f2f53029 100644 --- a/boost/atomic/detail/ops_gcc_sync.hpp +++ b/boost/atomic/detail/ops_gcc_sync.hpp @@ -165,6 +165,17 @@ struct operations< 1u, Signed > : public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 16u, Signed >::type >, 1u, Signed > #endif { +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1) + typedef typename make_storage_type< 1u, Signed >::aligned aligned_storage_type; +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) + typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type; +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; +#else + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; +#endif }; #endif @@ -181,6 +192,15 @@ struct operations< 2u, Signed > : public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 16u, Signed >::type >, 2u, Signed > #endif { +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) + typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type; +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; +#else + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; +#endif }; #endif @@ -195,6 +215,13 @@ struct operations< 4u, Signed > : public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 16u, Signed >::type >, 4u, Signed > #endif { +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; +#elif defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; +#else + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; +#endif }; #endif @@ -207,6 +234,11 @@ struct operations< 8u, Signed > : public extending_cas_based_operations< gcc_sync_operations< typename make_storage_type< 16u, Signed >::type >, 8u, Signed > #endif { +#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; +#else + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; +#endif }; #endif @@ -215,6 +247,7 @@ template< bool Signed > struct operations< 16u, Signed > : public gcc_sync_operations< typename make_storage_type< 16u, Signed >::type > { + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; }; #endif diff --git a/boost/atomic/detail/ops_gcc_x86.hpp b/boost/atomic/detail/ops_gcc_x86.hpp index 6e600457aa..f68125c491 100644 --- a/boost/atomic/detail/ops_gcc_x86.hpp +++ b/boost/atomic/detail/ops_gcc_x86.hpp @@ -115,6 +115,7 @@ struct operations< 1u, Signed > : { typedef gcc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 1u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { @@ -201,6 +202,7 @@ struct operations< 2u, Signed > : { typedef gcc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { @@ -287,6 +289,7 @@ struct operations< 4u, Signed > : { typedef gcc_x86_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { @@ -383,6 +386,7 @@ struct operations< 8u, Signed > : { typedef gcc_x86_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { diff --git a/boost/atomic/detail/ops_gcc_x86_dcas.hpp b/boost/atomic/detail/ops_gcc_x86_dcas.hpp index a6109f926c..f7a84f79ce 100644 --- a/boost/atomic/detail/ops_gcc_x86_dcas.hpp +++ b/boost/atomic/detail/ops_gcc_x86_dcas.hpp @@ -36,6 +36,7 @@ template< bool Signed > struct gcc_dcas_x86 { typedef typename make_storage_type< 8u, Signed >::type storage_type; + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { @@ -68,6 +69,37 @@ struct gcc_dcas_x86 } else { +#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) +#if defined(__PIC__) + uint32_t scratch; + __asm__ __volatile__ + ( + "movl %%ebx, %[scratch]\n\t" + "movl %[value_lo], %%ebx\n\t" + "movl %[dest], %%eax\n\t" + "movl 4+%[dest], %%edx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg8b %[dest]\n\t" + "jne 1b\n\t" + "movl %[scratch], %%ebx\n\t" + : [scratch] "=m" (scratch), [dest] "=o" (storage) + : [value_lo] "a" ((uint32_t)v), "c" ((uint32_t)(v >> 32)) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "edx", "memory" + ); +#else // defined(__PIC__) + __asm__ __volatile__ + ( + "movl %[dest], %%eax\n\t" + "movl 4+%[dest], %%edx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg8b %[dest]\n\t" + "jne 1b\n\t" + : [dest] "=o" (storage) + : [value_lo] "b" ((uint32_t)v), "c" ((uint32_t)(v >> 32)) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "eax", "edx", "memory" + ); +#endif // defined(__PIC__) +#else // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) #if defined(__PIC__) uint32_t scratch; __asm__ __volatile__ @@ -79,7 +111,7 @@ struct gcc_dcas_x86 ".align 16\n\t" "1: lock; cmpxchg8b 0(%[dest])\n\t" "jne 1b\n\t" - "movl %[scratch], %%ebx" + "movl %[scratch], %%ebx\n\t" #if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES) : [scratch] "=m,m" (scratch) : [value_lo] "a,a" ((uint32_t)v), "c,c" ((uint32_t)(v >> 32)), [dest] "D,S" (&storage) @@ -89,7 +121,7 @@ struct gcc_dcas_x86 #endif : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "edx", "memory" ); -#else +#else // defined(__PIC__) __asm__ __volatile__ ( "movl 0(%[dest]), %%eax\n\t" @@ -105,7 +137,8 @@ struct gcc_dcas_x86 #endif : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "eax", "edx", "memory" ); -#endif +#endif // defined(__PIC__) +#endif // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) } } @@ -152,7 +185,7 @@ struct gcc_dcas_x86 ( "movl %%ebx, %%eax\n\t" "movl %%ecx, %%edx\n\t" - "lock; cmpxchg8b %[storage]" + "lock; cmpxchg8b %[storage]\n\t" : "=&A" (value) : [storage] "m" (storage) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory" @@ -191,7 +224,7 @@ struct gcc_dcas_x86 "movl %[desired_lo], %%ebx\n\t" "lock; cmpxchg8b %[dest]\n\t" "movl %[scratch], %%ebx\n\t" - "sete %[success]" + "sete %[success]\n\t" #if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES) : "+A,A,A,A,A,A" (expected), [dest] "+m,m,m,m,m,m" (storage), [scratch] "=m,m,m,m,m,m" (scratch), [success] "=q,m,q,m,q,m" (success) : [desired_lo] "S,S,D,D,m,m" ((uint32_t)desired), "c,c,c,c,c,c" ((uint32_t)(desired >> 32)) @@ -207,7 +240,7 @@ struct gcc_dcas_x86 __asm__ __volatile__ ( "lock; cmpxchg8b %[dest]\n\t" - "sete %[success]" + "sete %[success]\n\t" #if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES) : "+A,A" (expected), [dest] "+m,m" (storage), [success] "=q,m" (success) : "b,b" ((uint32_t)desired), "c,c" ((uint32_t)(desired >> 32)) @@ -227,6 +260,97 @@ struct gcc_dcas_x86 return compare_exchange_strong(storage, expected, desired, success_order, failure_order); } + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { +#if defined(__clang__) + // Clang cannot allocate eax:edx register pairs but it has sync intrinsics + storage_type old_val = storage; + while (true) + { + storage_type val = __sync_val_compare_and_swap(&storage, old_val, v); + if (val == old_val) + return val; + old_val = val; + } +#elif !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) +#if defined(__PIC__) + uint32_t scratch; + __asm__ __volatile__ + ( + "movl %%ebx, %[scratch]\n\t" + "movl %%eax, %%ebx\n\t" + "movl %%edx, %%ecx\n\t" + "movl %[dest], %%eax\n\t" + "movl 4+%[dest], %%edx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg8b %[dest]\n\t" + "jne 1b\n\t" + "movl %[scratch], %%ebx\n\t" + : "+A" (v), [scratch] "=m" (scratch), [dest] "+o" (storage) + : + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "ecx", "memory" + ); + return v; +#else // defined(__PIC__) + __asm__ __volatile__ + ( + "movl %[dest], %%eax\n\t" + "movl 4+%[dest], %%edx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg8b %[dest]\n\t" + "jne 1b\n\t" + : "=A" (v), [dest] "+o" (storage) + : "b" ((uint32_t)v), "c" ((uint32_t)(v >> 32)) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory" + ); + return v; +#endif // defined(__PIC__) +#else // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) +#if defined(__PIC__) + uint32_t scratch; + __asm__ __volatile__ + ( + "movl %%ebx, %[scratch]\n\t" + "movl %%eax, %%ebx\n\t" + "movl %%edx, %%ecx\n\t" + "movl 0(%[dest]), %%eax\n\t" + "movl 4(%[dest]), %%edx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg8b 0(%[dest])\n\t" + "jne 1b\n\t" + "movl %[scratch], %%ebx\n\t" +#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES) + : "+A,A" (v), [scratch] "=m,m" (scratch) + : [dest] "D,S" (&storage) +#else + : "+A" (v), [scratch] "=m" (scratch) + : [dest] "D" (&storage) +#endif + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "ecx", "memory" + ); + return v; +#else // defined(__PIC__) + __asm__ __volatile__ + ( + "movl 0(%[dest]), %%eax\n\t" + "movl 4(%[dest]), %%edx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg8b 0(%[dest])\n\t" + "jne 1b\n\t" +#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES) + : "=A,A" (v) + : "b,b" ((uint32_t)v), "c,c" ((uint32_t)(v >> 32)), [dest] "D,S" (&storage) +#else + : "=A" (v) + : "b" ((uint32_t)v), "c" ((uint32_t)(v >> 32)), [dest] "D" (&storage) +#endif + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory" + ); + return v; +#endif // defined(__PIC__) +#endif + } + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT { return true; @@ -241,21 +365,36 @@ template< bool Signed > struct gcc_dcas_x86_64 { typedef typename make_storage_type< 16u, Signed >::type storage_type; + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { uint64_t const* p_value = (uint64_t const*)&v; +#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + __asm__ __volatile__ + ( + "movq %[dest], %%rax\n\t" + "movq 8+%[dest], %%rdx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg16b %[dest]\n\t" + "jne 1b\n\t" + : [dest] "=o" (storage) + : "b" (p_value[0]), "c" (p_value[1]) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "rax", "rdx", "memory" + ); +#else // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) __asm__ __volatile__ ( "movq 0(%[dest]), %%rax\n\t" "movq 8(%[dest]), %%rdx\n\t" ".align 16\n\t" "1: lock; cmpxchg16b 0(%[dest])\n\t" - "jne 1b" + "jne 1b\n\t" : : "b" (p_value[0]), "c" (p_value[1]), [dest] "r" (&storage) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "rax", "rdx", "memory" ); +#endif // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) } static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order) BOOST_NOEXCEPT @@ -264,16 +403,49 @@ struct gcc_dcas_x86_64 // Clang cannot allocate rax:rdx register pairs but it has sync intrinsics storage_type value = storage_type(); return __sync_val_compare_and_swap(&storage, value, value); -#else +#elif defined(BOOST_ATOMIC_DETAIL_NO_ASM_RAX_RDX_PAIRS) + // GCC 4.4 can't allocate rax:rdx register pair either but it also doesn't support 128-bit __sync_val_compare_and_swap storage_type value; // We don't care for comparison result here; the previous value will be stored into value anyway. // Also we don't care for rbx and rcx values, they just have to be equal to rax and rdx before cmpxchg16b. +#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) __asm__ __volatile__ ( "movq %%rbx, %%rax\n\t" "movq %%rcx, %%rdx\n\t" - "lock; cmpxchg16b %[storage]" + "lock; cmpxchg16b %[storage]\n\t" + "movq %%rax, %[value]\n\t" + "movq %%rdx, 8+%[value]\n\t" + : [value] "=o" (value) + : [storage] "m" (storage) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory", "rax", "rdx" + ); +#else // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + __asm__ __volatile__ + ( + "movq %%rbx, %%rax\n\t" + "movq %%rcx, %%rdx\n\t" + "lock; cmpxchg16b %[storage]\n\t" + "movq %%rax, 0(%[value])\n\t" + "movq %%rdx, 8(%[value])\n\t" + : + : [storage] "m" (storage), [value] "r" (&value) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory", "rax", "rdx" + ); +#endif // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + + return value; +#else // defined(BOOST_ATOMIC_DETAIL_NO_ASM_RAX_RDX_PAIRS) + storage_type value; + + // We don't care for comparison result here; the previous value will be stored into value anyway. + // Also we don't care for rbx and rcx values, they just have to be equal to rax and rdx before cmpxchg16b. + __asm__ __volatile__ + ( + "movq %%rbx, %%rax\n\t" + "movq %%rcx, %%rdx\n\t" + "lock; cmpxchg16b %[storage]\n\t" : "=&A" (value) : [storage] "m" (storage) : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory" @@ -291,13 +463,46 @@ struct gcc_dcas_x86_64 storage_type old_expected = expected; expected = __sync_val_compare_and_swap(&storage, old_expected, desired); return expected == old_expected; -#else +#elif defined(BOOST_ATOMIC_DETAIL_NO_ASM_RAX_RDX_PAIRS) + // GCC 4.4 can't allocate rax:rdx register pair either but it also doesn't support 128-bit __sync_val_compare_and_swap + uint64_t const* p_desired = (uint64_t const*)&desired; + bool success; +#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + __asm__ __volatile__ + ( + "movq %[expected], %%rax\n\t" + "movq 8+%[expected], %%rdx\n\t" + "lock; cmpxchg16b %[dest]\n\t" + "sete %[success]\n\t" + "movq %%rax, %[expected]\n\t" + "movq %%rdx, 8+%[expected]\n\t" + : [dest] "+m" (storage), [expected] "+o" (expected), [success] "=q" (success) + : "b" (p_desired[0]), "c" (p_desired[1]) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory", "rax", "rdx" + ); +#else // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + __asm__ __volatile__ + ( + "movq 0(%[expected]), %%rax\n\t" + "movq 8(%[expected]), %%rdx\n\t" + "lock; cmpxchg16b %[dest]\n\t" + "sete %[success]\n\t" + "movq %%rax, 0(%[expected])\n\t" + "movq %%rdx, 8(%[expected])\n\t" + : [dest] "+m" (storage), [success] "=q" (success) + : "b" (p_desired[0]), "c" (p_desired[1]), [expected] "r" (&expected) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory", "rax", "rdx" + ); +#endif // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + + return success; +#else // defined(BOOST_ATOMIC_DETAIL_NO_ASM_RAX_RDX_PAIRS) uint64_t const* p_desired = (uint64_t const*)&desired; bool success; __asm__ __volatile__ ( "lock; cmpxchg16b %[dest]\n\t" - "sete %[success]" + "sete %[success]\n\t" #if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES) : "+A,A" (expected), [dest] "+m,m" (storage), [success] "=q,m" (success) : "b,b" (p_desired[0]), "c,c" (p_desired[1]) @@ -317,6 +522,85 @@ struct gcc_dcas_x86_64 return compare_exchange_strong(storage, expected, desired, success_order, failure_order); } + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { +#if defined(__clang__) + // Clang cannot allocate eax:edx register pairs but it has sync intrinsics + storage_type old_val = storage; + while (true) + { + storage_type val = __sync_val_compare_and_swap(&storage, old_val, v); + if (val == old_val) + return val; + old_val = val; + } +#elif defined(BOOST_ATOMIC_DETAIL_NO_ASM_RAX_RDX_PAIRS) + // GCC 4.4 can't allocate rax:rdx register pair either but it also doesn't support 128-bit __sync_val_compare_and_swap + storage_type old_value; + uint64_t const* p_value = (uint64_t const*)&v; +#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + __asm__ __volatile__ + ( + "movq %[dest], %%rax\n\t" + "movq 8+%[dest], %%rdx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg16b %[dest]\n\t" + "jne 1b\n\t" + "movq %%rax, %[old_value]\n\t" + "movq %%rdx, 8+%[old_value]\n\t" + : [dest] "+o" (storage), [old_value] "=o" (old_value) + : "b" (p_value[0]), "c" (p_value[1]) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory", "rax", "rdx" + ); +#else // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + __asm__ __volatile__ + ( + "movq 0(%[dest]), %%rax\n\t" + "movq 8(%[dest]), %%rdx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg16b 0(%[dest])\n\t" + "jne 1b\n\t" + "movq %%rax, 0(%[old_value])\n\t" + "movq %%rdx, 8(%[old_value])\n\t" + : + : "b" (p_value[0]), "c" (p_value[1]), [dest] "r" (&storage), [old_value] "r" (&old_value) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory", "rax", "rdx" + ); +#endif // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + + return old_value; +#else // defined(BOOST_ATOMIC_DETAIL_NO_ASM_RAX_RDX_PAIRS) + uint64_t const* p_value = (uint64_t const*)&v; +#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + __asm__ __volatile__ + ( + "movq %[dest], %%rax\n\t" + "movq 8+%[dest], %%rdx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg16b %[dest]\n\t" + "jne 1b\n\t" + : "=&A" (v), [dest] "+o" (storage) + : "b" (p_value[0]), "c" (p_value[1]) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory" + ); +#else // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + __asm__ __volatile__ + ( + "movq 0(%[dest]), %%rax\n\t" + "movq 8(%[dest]), %%rdx\n\t" + ".align 16\n\t" + "1: lock; cmpxchg16b 0(%[dest])\n\t" + "jne 1b\n\t" + : "=&A" (v) + : "b" (p_value[0]), "c" (p_value[1]), [dest] "r" (&storage) + : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory" + ); +#endif // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS) + + return v; +#endif + } + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT { return true; diff --git a/boost/atomic/detail/ops_linux_arm.hpp b/boost/atomic/detail/ops_linux_arm.hpp index 25167b1974..41713a35f5 100644 --- a/boost/atomic/detail/ops_linux_arm.hpp +++ b/boost/atomic/detail/ops_linux_arm.hpp @@ -87,6 +87,7 @@ struct linux_arm_cas : public linux_arm_cas_base { typedef typename make_storage_type< 4u, Signed >::type storage_type; + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { @@ -142,19 +143,19 @@ struct linux_arm_cas : template< bool Signed > struct operations< 1u, Signed > : - public extending_cas_based_operations< cas_based_operations< linux_arm_cas< Signed > >, 1u, Signed > + public extending_cas_based_operations< cas_based_operations< cas_based_exchange< linux_arm_cas< Signed > > >, 1u, Signed > { }; template< bool Signed > struct operations< 2u, Signed > : - public extending_cas_based_operations< cas_based_operations< linux_arm_cas< Signed > >, 2u, Signed > + public extending_cas_based_operations< cas_based_operations< cas_based_exchange< linux_arm_cas< Signed > > >, 2u, Signed > { }; template< bool Signed > struct operations< 4u, Signed > : - public cas_based_operations< linux_arm_cas< Signed > > + public cas_based_operations< cas_based_exchange< linux_arm_cas< Signed > > > { }; diff --git a/boost/atomic/detail/ops_msvc_arm.hpp b/boost/atomic/detail/ops_msvc_arm.hpp index 349f7a5ae8..ff953d67e3 100644 --- a/boost/atomic/detail/ops_msvc_arm.hpp +++ b/boost/atomic/detail/ops_msvc_arm.hpp @@ -135,6 +135,7 @@ struct operations< 1u, Signed > : { typedef msvc_arm_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 1u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { @@ -300,6 +301,7 @@ struct operations< 2u, Signed > : { typedef msvc_arm_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { @@ -465,6 +467,7 @@ struct operations< 4u, Signed > : { typedef msvc_arm_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { @@ -630,6 +633,7 @@ struct operations< 8u, Signed > : { typedef msvc_arm_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { diff --git a/boost/atomic/detail/ops_msvc_x86.hpp b/boost/atomic/detail/ops_msvc_x86.hpp index 501d9c622d..589c029864 100644 --- a/boost/atomic/detail/ops_msvc_x86.hpp +++ b/boost/atomic/detail/ops_msvc_x86.hpp @@ -166,6 +166,7 @@ struct operations< 4u, Signed > : { typedef msvc_x86_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { @@ -237,6 +238,7 @@ struct operations< 1u, Signed > : { typedef msvc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 1u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { @@ -281,6 +283,7 @@ struct operations< 1u, Signed > : { typedef msvc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 1u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { @@ -421,6 +424,7 @@ struct operations< 2u, Signed > : { typedef msvc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { @@ -465,6 +469,7 @@ struct operations< 2u, Signed > : { typedef msvc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { @@ -604,6 +609,7 @@ template< bool Signed > struct msvc_dcas_x86 { typedef typename make_storage_type< 8u, Signed >::type storage_type; + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; // Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3A, 8.1.1. Guaranteed Atomic Operations: // @@ -611,10 +617,12 @@ struct msvc_dcas_x86 // * Reading or writing a quadword aligned on a 64-bit boundary // // Luckily, the memory is almost always 8-byte aligned in our case because atomic<> uses 64 bit native types for storage and dynamic memory allocations - // have at least 8 byte alignment. The only unfortunate case is when atomic is placeod on the stack and it is not 8-byte aligned (like on 32 bit Windows). + // have at least 8 byte alignment. The only unfortunate case is when atomic is placed on the stack and it is not 8-byte aligned (like on 32 bit Windows). static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + storage_type volatile* p = &storage; if (((uint32_t)p & 0x00000007) == 0) { @@ -661,10 +669,14 @@ struct msvc_dcas_x86 mov ebx, backup }; } + + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); } static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order) BOOST_NOEXCEPT { + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + storage_type const volatile* p = &storage; storage_type value; @@ -710,18 +722,23 @@ struct msvc_dcas_x86 }; } + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + return value; } static BOOST_FORCEINLINE bool compare_exchange_strong( storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT { + // MSVC-11 in 32-bit mode sometimes generates messed up code without compiler barriers, + // even though the _InterlockedCompareExchange64 intrinsic already provides one. + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + storage_type volatile* p = &storage; #if defined(BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64) const storage_type old_val = (storage_type)BOOST_ATOMIC_INTERLOCKED_COMPARE_EXCHANGE64(p, desired, expected); const bool result = (old_val == expected); expected = old_val; - return result; #else bool result; int backup; @@ -740,8 +757,10 @@ struct msvc_dcas_x86 mov ebx, backup sete result }; - return result; #endif + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + + return result; } static BOOST_FORCEINLINE bool compare_exchange_weak( @@ -750,6 +769,34 @@ struct msvc_dcas_x86 return compare_exchange_strong(storage, expected, desired, success_order, failure_order); } + static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT + { + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + + storage_type volatile* p = &storage; + int backup; + __asm + { + mov backup, ebx + mov edi, p + mov ebx, dword ptr [v] + mov ecx, dword ptr [v + 4] + mov eax, dword ptr [edi] + mov edx, dword ptr [edi + 4] + align 16 + again: + lock cmpxchg8b qword ptr [edi] + jne again + mov ebx, backup + mov dword ptr [v], eax + mov dword ptr [v + 4], edx + }; + + BOOST_ATOMIC_DETAIL_COMPILER_BARRIER(); + + return v; + } + static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT { return true; @@ -770,6 +817,7 @@ struct operations< 8u, Signed > : { typedef msvc_x86_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { @@ -814,6 +862,7 @@ template< bool Signed > struct msvc_dcas_x86_64 { typedef typename make_storage_type< 16u, Signed >::type storage_type; + typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT { @@ -848,7 +897,7 @@ struct msvc_dcas_x86_64 template< bool Signed > struct operations< 16u, Signed > : - public cas_based_operations< msvc_dcas_x86_64< Signed > > + public cas_based_operations< cas_based_exchange< msvc_dcas_x86_64< Signed > > > { }; diff --git a/boost/atomic/detail/ops_windows.hpp b/boost/atomic/detail/ops_windows.hpp index 1b4b04c8bc..191eb84d0a 100644 --- a/boost/atomic/detail/ops_windows.hpp +++ b/boost/atomic/detail/ops_windows.hpp @@ -110,6 +110,7 @@ struct operations< 4u, Signed > : { typedef windows_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type; static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT { diff --git a/boost/atomic/detail/platform.hpp b/boost/atomic/detail/platform.hpp index 76ad4ebb8f..b6c48ef0f9 100644 --- a/boost/atomic/detail/platform.hpp +++ b/boost/atomic/detail/platform.hpp @@ -24,7 +24,13 @@ #if !defined(BOOST_ATOMIC_FORCE_FALLBACK) // Compiler-based backends -#if ((defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 407)) ||\ +#if (defined(__ibmxl__) || defined(__IBMCPP__)) && defined(__PPC__) + +// IBM XL C++ Compiler has to be checked before GCC/Clang as it pretends to be one but does not support __atomic* intrinsics. +// It does support GCC inline assembler though. +#define BOOST_ATOMIC_DETAIL_PLATFORM gcc_ppc + +#elif ((defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 407)) ||\ (defined(BOOST_CLANG) && ((__clang_major__ * 100 + __clang_minor__) >= 302))) &&\ (\ (__GCC_ATOMIC_BOOL_LOCK_FREE + 0) == 2 ||\ diff --git a/boost/atomic/detail/storage_type.hpp b/boost/atomic/detail/storage_type.hpp index a024f1d327..63a7cef581 100644 --- a/boost/atomic/detail/storage_type.hpp +++ b/boost/atomic/detail/storage_type.hpp @@ -16,9 +16,12 @@ #ifndef BOOST_ATOMIC_DETAIL_STORAGE_TYPE_HPP_INCLUDED_ #define BOOST_ATOMIC_DETAIL_STORAGE_TYPE_HPP_INCLUDED_ -#include +#include #include #include +#if !defined(BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCMP) || !defined(BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY) +#include +#endif #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once @@ -28,84 +31,163 @@ namespace boost { namespace atomics { namespace detail { -template< unsigned int Size > +template< typename T > +BOOST_FORCEINLINE void non_atomic_load(T const volatile& from, T& to) BOOST_NOEXCEPT +{ + to = from; +} + +template< std::size_t Size > struct buffer_storage { - unsigned char data[Size]; + BOOST_ALIGNMENT(16) unsigned char data[Size]; BOOST_FORCEINLINE bool operator! () const BOOST_NOEXCEPT { - bool result = true; - for (unsigned int i = 0; i < Size && result; ++i) - { - result &= data[i] == 0; - } - return result; + return (data[0] == 0u && BOOST_ATOMIC_DETAIL_MEMCMP(data, data + 1, Size - 1) == 0); } BOOST_FORCEINLINE bool operator== (buffer_storage const& that) const BOOST_NOEXCEPT { - return std::memcmp(data, that.data, Size) == 0; + return BOOST_ATOMIC_DETAIL_MEMCMP(data, that.data, Size) == 0; } BOOST_FORCEINLINE bool operator!= (buffer_storage const& that) const BOOST_NOEXCEPT { - return std::memcmp(data, that.data, Size) != 0; + return BOOST_ATOMIC_DETAIL_MEMCMP(data, that.data, Size) != 0; } }; -template< unsigned int Size, bool Signed > +template< std::size_t Size > +BOOST_FORCEINLINE void non_atomic_load(buffer_storage< Size > const volatile& from, buffer_storage< Size >& to) BOOST_NOEXCEPT +{ + BOOST_ATOMIC_DETAIL_MEMCPY(to.data, const_cast< unsigned char const* >(from.data), Size); +} + +template< std::size_t Size, bool Signed > struct make_storage_type { typedef buffer_storage< Size > type; + + struct aligned + { + type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type const& v) BOOST_NOEXCEPT : value(v) {} + }; }; template< > struct make_storage_type< 1u, false > { typedef boost::uint8_t type; + + struct aligned + { + type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type v) BOOST_NOEXCEPT : value(v) {} + }; }; template< > struct make_storage_type< 1u, true > { typedef boost::int8_t type; + + struct aligned + { + type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type v) BOOST_NOEXCEPT : value(v) {} + }; }; template< > struct make_storage_type< 2u, false > { typedef boost::uint16_t type; + + struct aligned + { + BOOST_ALIGNMENT(2) type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type v) BOOST_NOEXCEPT : value(v) {} + }; }; template< > struct make_storage_type< 2u, true > { typedef boost::int16_t type; + + struct aligned + { + BOOST_ALIGNMENT(2) type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type v) BOOST_NOEXCEPT : value(v) {} + }; }; template< > struct make_storage_type< 4u, false > { typedef boost::uint32_t type; + + struct aligned + { + BOOST_ALIGNMENT(4) type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type v) BOOST_NOEXCEPT : value(v) {} + }; }; template< > struct make_storage_type< 4u, true > { typedef boost::int32_t type; + + struct aligned + { + BOOST_ALIGNMENT(4) type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type v) BOOST_NOEXCEPT : value(v) {} + }; }; template< > struct make_storage_type< 8u, false > { typedef boost::uint64_t type; + + struct aligned + { + BOOST_ALIGNMENT(8) type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type v) BOOST_NOEXCEPT : value(v) {} + }; }; template< > struct make_storage_type< 8u, true > { typedef boost::int64_t type; + + struct aligned + { + BOOST_ALIGNMENT(8) type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type v) BOOST_NOEXCEPT : value(v) {} + }; }; #if defined(BOOST_HAS_INT128) @@ -114,17 +196,33 @@ template< > struct make_storage_type< 16u, false > { typedef boost::uint128_type type; + + struct aligned + { + BOOST_ALIGNMENT(16) type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type v) BOOST_NOEXCEPT : value(v) {} + }; }; template< > struct make_storage_type< 16u, true > { typedef boost::int128_type type; + + struct aligned + { + BOOST_ALIGNMENT(16) type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type v) BOOST_NOEXCEPT : value(v) {} + }; }; #elif !defined(BOOST_NO_ALIGNMENT) -struct BOOST_ALIGNMENT(16) storage128_t +struct storage128_t { boost::uint64_t data[2]; @@ -143,10 +241,24 @@ BOOST_FORCEINLINE bool operator!= (storage128_t const& left, storage128_t const& return !(left == right); } +BOOST_FORCEINLINE void non_atomic_load(storage128_t const volatile& from, storage128_t& to) BOOST_NOEXCEPT +{ + to.data[0] = from.data[0]; + to.data[1] = from.data[1]; +} + template< bool Signed > struct make_storage_type< 16u, Signed > { typedef storage128_t type; + + struct aligned + { + BOOST_ALIGNMENT(16) type value; + + BOOST_DEFAULTED_FUNCTION(aligned(), {}) + BOOST_FORCEINLINE BOOST_CONSTEXPR explicit aligned(type const& v) BOOST_NOEXCEPT : value(v) {} + }; }; #endif diff --git a/boost/bind.hpp b/boost/bind.hpp index fd3421ea5a..450120c7a7 100644 --- a/boost/bind.hpp +++ b/boost/bind.hpp @@ -10,7 +10,7 @@ // // bind.hpp - binds function objects to arguments // -// Copyright (c) 2009 Peter Dimov +// Copyright (c) 2009, 2015 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -21,4 +21,21 @@ #include +#ifndef BOOST_BIND_NO_PLACEHOLDERS + +#if defined(BOOST_CLANG) +# pragma clang diagnostic push +# if __has_warning("-Wheader-hygiene") +# pragma clang diagnostic ignored "-Wheader-hygiene" +# endif +#endif + +using namespace boost::placeholders; + +#if defined(BOOST_CLANG) +# pragma clang diagnostic pop +#endif + +#endif // #ifndef BOOST_BIND_NO_PLACEHOLDERS + #endif // #ifndef BOOST_BIND_HPP_INCLUDED diff --git a/boost/bind/arg.hpp b/boost/bind/arg.hpp index c879bb408b..a74b8298be 100644 --- a/boost/bind/arg.hpp +++ b/boost/bind/arg.hpp @@ -28,17 +28,17 @@ namespace boost template< int I > struct arg { - arg() + BOOST_CONSTEXPR arg() { } - template< class T > arg( T const & /* t */ ) + template< class T > BOOST_CONSTEXPR arg( T const & /* t */ ) { BOOST_STATIC_ASSERT( I == is_placeholder::value ); } }; -template< int I > bool operator==( arg const &, arg const & ) +template< int I > BOOST_CONSTEXPR bool operator==( arg const &, arg const & ) { return true; } diff --git a/boost/bind/bind.hpp b/boost/bind/bind.hpp index fd05131236..f793551d1a 100644 --- a/boost/bind/bind.hpp +++ b/boost/bind/bind.hpp @@ -32,6 +32,10 @@ #include #include +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) +#include // std::forward +#endif + // Borland-specific bug, visit_each() silently fails to produce code #if defined(__BORLANDC__) @@ -863,14 +867,337 @@ public: #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) -template< class A > struct list_add_cref +template< class A1 > class rrlist1 +{ +private: + + A1 & a1_; // not A1&& because of msvc-10.0 + +public: + + explicit rrlist1( A1 & a1 ): a1_( a1 ) {} + + A1 && operator[] (boost::arg<1>) const { return std::forward( a1_ ); } // not static_cast because of g++ 4.9 + + A1 && operator[] (boost::arg<1> (*) ()) const { return std::forward( a1_ ); } + + template T & operator[] ( _bi::value & v ) const { return v.get(); } + + template T const & operator[] ( _bi::value const & v ) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } +}; + +template< class A1, class A2 > class rrlist2 { - typedef A const & type; +private: + + A1 & a1_; + A2 & a2_; + +public: + + rrlist2( A1 & a1, A2 & a2 ): a1_( a1 ), a2_( a2 ) {} + + A1 && operator[] (boost::arg<1>) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2>) const { return std::forward( a2_ ); } + + A1 && operator[] (boost::arg<1> (*) ()) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2> (*) ()) const { return std::forward( a2_ ); } + + template T & operator[] ( _bi::value & v ) const { return v.get(); } + + template T const & operator[] ( _bi::value const & v ) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } +}; + +template< class A1, class A2, class A3 > class rrlist3 +{ +private: + + A1 & a1_; + A2 & a2_; + A3 & a3_; + +public: + + rrlist3( A1 & a1, A2 & a2, A3 & a3 ): a1_( a1 ), a2_( a2 ), a3_( a3 ) {} + + A1 && operator[] (boost::arg<1>) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2>) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3>) const { return std::forward( a3_ ); } + + A1 && operator[] (boost::arg<1> (*) ()) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2> (*) ()) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3> (*) ()) const { return std::forward( a3_ ); } + + template T & operator[] ( _bi::value & v ) const { return v.get(); } + + template T const & operator[] ( _bi::value const & v ) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } }; -template< class A > struct list_add_cref< A& > +template< class A1, class A2, class A3, class A4 > class rrlist4 { - typedef A & type; +private: + + A1 & a1_; + A2 & a2_; + A3 & a3_; + A4 & a4_; + +public: + + rrlist4( A1 & a1, A2 & a2, A3 & a3, A4 & a4 ): a1_( a1 ), a2_( a2 ), a3_( a3 ), a4_( a4 ) {} + + A1 && operator[] (boost::arg<1>) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2>) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3>) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4>) const { return std::forward( a4_ ); } + + A1 && operator[] (boost::arg<1> (*) ()) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2> (*) ()) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3> (*) ()) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4> (*) ()) const { return std::forward( a4_ ); } + + template T & operator[] ( _bi::value & v ) const { return v.get(); } + + template T const & operator[] ( _bi::value const & v ) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } +}; + +template< class A1, class A2, class A3, class A4, class A5 > class rrlist5 +{ +private: + + A1 & a1_; + A2 & a2_; + A3 & a3_; + A4 & a4_; + A5 & a5_; + +public: + + rrlist5( A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5 ): a1_( a1 ), a2_( a2 ), a3_( a3 ), a4_( a4 ), a5_( a5 ) {} + + A1 && operator[] (boost::arg<1>) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2>) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3>) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4>) const { return std::forward( a4_ ); } + A5 && operator[] (boost::arg<5>) const { return std::forward( a5_ ); } + + A1 && operator[] (boost::arg<1> (*) ()) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2> (*) ()) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3> (*) ()) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4> (*) ()) const { return std::forward( a4_ ); } + A5 && operator[] (boost::arg<5> (*) ()) const { return std::forward( a5_ ); } + + template T & operator[] ( _bi::value & v ) const { return v.get(); } + + template T const & operator[] ( _bi::value const & v ) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } +}; + +template< class A1, class A2, class A3, class A4, class A5, class A6 > class rrlist6 +{ +private: + + A1 & a1_; + A2 & a2_; + A3 & a3_; + A4 & a4_; + A5 & a5_; + A6 & a6_; + +public: + + rrlist6( A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6 ): a1_( a1 ), a2_( a2 ), a3_( a3 ), a4_( a4 ), a5_( a5 ), a6_( a6 ) {} + + A1 && operator[] (boost::arg<1>) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2>) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3>) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4>) const { return std::forward( a4_ ); } + A5 && operator[] (boost::arg<5>) const { return std::forward( a5_ ); } + A6 && operator[] (boost::arg<6>) const { return std::forward( a6_ ); } + + A1 && operator[] (boost::arg<1> (*) ()) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2> (*) ()) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3> (*) ()) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4> (*) ()) const { return std::forward( a4_ ); } + A5 && operator[] (boost::arg<5> (*) ()) const { return std::forward( a5_ ); } + A6 && operator[] (boost::arg<6> (*) ()) const { return std::forward( a6_ ); } + + template T & operator[] ( _bi::value & v ) const { return v.get(); } + + template T const & operator[] ( _bi::value const & v ) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } +}; + +template< class A1, class A2, class A3, class A4, class A5, class A6, class A7 > class rrlist7 +{ +private: + + A1 & a1_; + A2 & a2_; + A3 & a3_; + A4 & a4_; + A5 & a5_; + A6 & a6_; + A7 & a7_; + +public: + + rrlist7( A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7 ): a1_( a1 ), a2_( a2 ), a3_( a3 ), a4_( a4 ), a5_( a5 ), a6_( a6 ), a7_( a7 ) {} + + A1 && operator[] (boost::arg<1>) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2>) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3>) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4>) const { return std::forward( a4_ ); } + A5 && operator[] (boost::arg<5>) const { return std::forward( a5_ ); } + A6 && operator[] (boost::arg<6>) const { return std::forward( a6_ ); } + A7 && operator[] (boost::arg<7>) const { return std::forward( a7_ ); } + + A1 && operator[] (boost::arg<1> (*) ()) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2> (*) ()) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3> (*) ()) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4> (*) ()) const { return std::forward( a4_ ); } + A5 && operator[] (boost::arg<5> (*) ()) const { return std::forward( a5_ ); } + A6 && operator[] (boost::arg<6> (*) ()) const { return std::forward( a6_ ); } + A7 && operator[] (boost::arg<7> (*) ()) const { return std::forward( a7_ ); } + + template T & operator[] ( _bi::value & v ) const { return v.get(); } + + template T const & operator[] ( _bi::value const & v ) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } +}; + +template< class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > class rrlist8 +{ +private: + + A1 & a1_; + A2 & a2_; + A3 & a3_; + A4 & a4_; + A5 & a5_; + A6 & a6_; + A7 & a7_; + A8 & a8_; + +public: + + rrlist8( A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8 ): a1_( a1 ), a2_( a2 ), a3_( a3 ), a4_( a4 ), a5_( a5 ), a6_( a6 ), a7_( a7 ), a8_( a8 ) {} + + A1 && operator[] (boost::arg<1>) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2>) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3>) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4>) const { return std::forward( a4_ ); } + A5 && operator[] (boost::arg<5>) const { return std::forward( a5_ ); } + A6 && operator[] (boost::arg<6>) const { return std::forward( a6_ ); } + A7 && operator[] (boost::arg<7>) const { return std::forward( a7_ ); } + A8 && operator[] (boost::arg<8>) const { return std::forward( a8_ ); } + + A1 && operator[] (boost::arg<1> (*) ()) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2> (*) ()) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3> (*) ()) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4> (*) ()) const { return std::forward( a4_ ); } + A5 && operator[] (boost::arg<5> (*) ()) const { return std::forward( a5_ ); } + A6 && operator[] (boost::arg<6> (*) ()) const { return std::forward( a6_ ); } + A7 && operator[] (boost::arg<7> (*) ()) const { return std::forward( a7_ ); } + A8 && operator[] (boost::arg<8> (*) ()) const { return std::forward( a8_ ); } + + template T & operator[] ( _bi::value & v ) const { return v.get(); } + + template T const & operator[] ( _bi::value const & v ) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } +}; + +template< class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > class rrlist9 +{ +private: + + A1 & a1_; + A2 & a2_; + A3 & a3_; + A4 & a4_; + A5 & a5_; + A6 & a6_; + A7 & a7_; + A8 & a8_; + A9 & a9_; + +public: + + rrlist9( A1 & a1, A2 & a2, A3 & a3, A4 & a4, A5 & a5, A6 & a6, A7 & a7, A8 & a8, A9 & a9 ): a1_( a1 ), a2_( a2 ), a3_( a3 ), a4_( a4 ), a5_( a5 ), a6_( a6 ), a7_( a7 ), a8_( a8 ), a9_( a9 ) {} + + A1 && operator[] (boost::arg<1>) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2>) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3>) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4>) const { return std::forward( a4_ ); } + A5 && operator[] (boost::arg<5>) const { return std::forward( a5_ ); } + A6 && operator[] (boost::arg<6>) const { return std::forward( a6_ ); } + A7 && operator[] (boost::arg<7>) const { return std::forward( a7_ ); } + A8 && operator[] (boost::arg<8>) const { return std::forward( a8_ ); } + A9 && operator[] (boost::arg<9>) const { return std::forward( a9_ ); } + + A1 && operator[] (boost::arg<1> (*) ()) const { return std::forward( a1_ ); } + A2 && operator[] (boost::arg<2> (*) ()) const { return std::forward( a2_ ); } + A3 && operator[] (boost::arg<3> (*) ()) const { return std::forward( a3_ ); } + A4 && operator[] (boost::arg<4> (*) ()) const { return std::forward( a4_ ); } + A5 && operator[] (boost::arg<5> (*) ()) const { return std::forward( a5_ ); } + A6 && operator[] (boost::arg<6> (*) ()) const { return std::forward( a6_ ); } + A7 && operator[] (boost::arg<7> (*) ()) const { return std::forward( a7_ ); } + A8 && operator[] (boost::arg<8> (*) ()) const { return std::forward( a8_ ); } + A9 && operator[] (boost::arg<9> (*) ()) const { return std::forward( a9_ ); } + + template T & operator[] ( _bi::value & v ) const { return v.get(); } + + template T const & operator[] ( _bi::value const & v ) const { return v.get(); } + + template T & operator[] (reference_wrapper const & v) const { return v.get(); } + + template typename result_traits::type operator[] (bind_t & b) const { return b.eval(*this); } + + template typename result_traits::type operator[] (bind_t const & b) const { return b.eval(*this); } }; template class bind_t @@ -903,221 +1230,109 @@ public: template result_type operator()( A1 && a1 ) { - list1< typename list_add_cref::type > a( a1 ); + rrlist1< A1 > a( a1 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1 ) const { - list1< typename list_add_cref::type > a( a1 ); + rrlist1< A1 > a( a1 ); return l_(type(), f_, a, 0); } template result_type operator()( A1 && a1, A2 && a2 ) { - list2< typename list_add_cref::type, typename list_add_cref::type > a( a1, a2 ); + rrlist2< A1, A2 > a( a1, a2 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2 ) const { - list2< typename list_add_cref::type, typename list_add_cref::type > a( a1, a2 ); + rrlist2< A1, A2 > a( a1, a2 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3 ) { - list3< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3 ); - + rrlist3< A1, A2, A3 > a( a1, a2, a3 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3 ) const { - list3< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3 ); - + rrlist3< A1, A2, A3 > a( a1, a2, a3 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4 ) { - list4< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4 ); - + rrlist4< A1, A2, A3, A4 > a( a1, a2, a3, a4 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4 ) const { - list4< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4 ); - + rrlist4< A1, A2, A3, A4 > a( a1, a2, a3, a4 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5 ) { - list5< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4, a5 ); - + rrlist5< A1, A2, A3, A4, A5 > a( a1, a2, a3, a4, a5 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5 ) const { - list5< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4, a5 ); - + rrlist5< A1, A2, A3, A4, A5 > a( a1, a2, a3, a4, a5 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6 ) { - list6< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4, a5, a6 ); - + rrlist6< A1, A2, A3, A4, A5, A6 > a( a1, a2, a3, a4, a5, a6 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6 ) const { - list6< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4, a5, a6 ); - + rrlist6< A1, A2, A3, A4, A5, A6 > a( a1, a2, a3, a4, a5, a6 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7 ) { - list7< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4, a5, a6, a7 ); - + rrlist7< A1, A2, A3, A4, A5, A6, A7 > a( a1, a2, a3, a4, a5, a6, a7 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7 ) const { - list7< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4, a5, a6, a7 ); - + rrlist7< A1, A2, A3, A4, A5, A6, A7 > a( a1, a2, a3, a4, a5, a6, a7 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8 ) { - list8< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4, a5, a6, a7, a8 ); - + rrlist8< A1, A2, A3, A4, A5, A6, A7, A8 > a( a1, a2, a3, a4, a5, a6, a7, a8 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8 ) const { - list8< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4, a5, a6, a7, a8 ); - + rrlist8< A1, A2, A3, A4, A5, A6, A7, A8 > a( a1, a2, a3, a4, a5, a6, a7, a8 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && a9 ) { - list9< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); - + rrlist9< A1, A2, A3, A4, A5, A6, A7, A8, A9 > a( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); return l_( type(), f_, a, 0 ); } template result_type operator()( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && a9 ) const { - list9< - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type, - typename list_add_cref::type - > a( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); - + rrlist9< A1, A2, A3, A4, A5, A6, A7, A8, A9 > a( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); return l_( type(), f_, a, 0 ); } diff --git a/boost/bind/placeholders.hpp b/boost/bind/placeholders.hpp index 3b098b14f8..b819ef4c46 100644 --- a/boost/bind/placeholders.hpp +++ b/boost/bind/placeholders.hpp @@ -11,10 +11,11 @@ // bind/placeholders.hpp - _N definitions // // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// Copyright 2015 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) +// Distributed under the 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. // @@ -22,48 +23,40 @@ #include #include -namespace +namespace boost { -#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ < 4) - -static inline boost::arg<1> _1() { return boost::arg<1>(); } -static inline boost::arg<2> _2() { return boost::arg<2>(); } -static inline boost::arg<3> _3() { return boost::arg<3>(); } -static inline boost::arg<4> _4() { return boost::arg<4>(); } -static inline boost::arg<5> _5() { return boost::arg<5>(); } -static inline boost::arg<6> _6() { return boost::arg<6>(); } -static inline boost::arg<7> _7() { return boost::arg<7>(); } -static inline boost::arg<8> _8() { return boost::arg<8>(); } -static inline boost::arg<9> _9() { return boost::arg<9>(); } +namespace placeholders +{ -#elif defined(BOOST_MSVC) || (defined(__DECCXX_VER) && __DECCXX_VER <= 60590031) || defined(__MWERKS__) || \ - defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 2) +#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ < 4) -static boost::arg<1> _1; -static boost::arg<2> _2; -static boost::arg<3> _3; -static boost::arg<4> _4; -static boost::arg<5> _5; -static boost::arg<6> _6; -static boost::arg<7> _7; -static boost::arg<8> _8; -static boost::arg<9> _9; +inline boost::arg<1> _1() { return boost::arg<1>(); } +inline boost::arg<2> _2() { return boost::arg<2>(); } +inline boost::arg<3> _3() { return boost::arg<3>(); } +inline boost::arg<4> _4() { return boost::arg<4>(); } +inline boost::arg<5> _5() { return boost::arg<5>(); } +inline boost::arg<6> _6() { return boost::arg<6>(); } +inline boost::arg<7> _7() { return boost::arg<7>(); } +inline boost::arg<8> _8() { return boost::arg<8>(); } +inline boost::arg<9> _9() { return boost::arg<9>(); } #else -boost::arg<1> _1; -boost::arg<2> _2; -boost::arg<3> _3; -boost::arg<4> _4; -boost::arg<5> _5; -boost::arg<6> _6; -boost::arg<7> _7; -boost::arg<8> _8; -boost::arg<9> _9; +BOOST_STATIC_CONSTEXPR boost::arg<1> _1; +BOOST_STATIC_CONSTEXPR boost::arg<2> _2; +BOOST_STATIC_CONSTEXPR boost::arg<3> _3; +BOOST_STATIC_CONSTEXPR boost::arg<4> _4; +BOOST_STATIC_CONSTEXPR boost::arg<5> _5; +BOOST_STATIC_CONSTEXPR boost::arg<6> _6; +BOOST_STATIC_CONSTEXPR boost::arg<7> _7; +BOOST_STATIC_CONSTEXPR boost::arg<8> _8; +BOOST_STATIC_CONSTEXPR boost::arg<9> _9; #endif -} // unnamed namespace +} // namespace placeholders + +} // namespace boost #endif // #ifndef BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED diff --git a/boost/chrono/detail/inlined/mac/chrono.hpp b/boost/chrono/detail/inlined/mac/chrono.hpp index bf20ae924b..5c32a8e176 100644 --- a/boost/chrono/detail/inlined/mac/chrono.hpp +++ b/boost/chrono/detail/inlined/mac/chrono.hpp @@ -39,7 +39,7 @@ system_clock::now(system::error_code & ec) { timeval tv; gettimeofday(&tv, 0); - if (!BOOST_CHRONO_IS_THROWS(ec)) + if (!BOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } @@ -88,7 +88,7 @@ BOOST_CHRONO_STATIC steady_clock::rep steady_simplified_ec(system::error_code & ec) { - if (!BOOST_CHRONO_IS_THROWS(ec)) + if (!BOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } @@ -112,9 +112,9 @@ BOOST_CHRONO_STATIC steady_clock::rep steady_full() { - static kern_return_t err; - static const double factor = chrono_detail::compute_steady_factor(err); - if (err != 0) + kern_return_t err; + const double factor = chrono_detail::compute_steady_factor(err); + if (err != 0) { BOOST_ASSERT(0 && "Boost::Chrono - Internal Error"); } @@ -126,25 +126,25 @@ BOOST_CHRONO_STATIC steady_clock::rep steady_full_ec(system::error_code & ec) { - static kern_return_t err; - static const double factor = chrono_detail::compute_steady_factor(err); - if (err != 0) + kern_return_t err; + const double factor = chrono_detail::compute_steady_factor(err); + if (err != 0) { if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( - system::system_error( - err, - BOOST_CHRONO_SYSTEM_CATEGORY, + system::system_error( + err, + BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::steady_clock" )); - } + } else { ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY ); return steady_clock::rep(); } } - if (!BOOST_CHRONO_IS_THROWS(ec)) + if (!BOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } @@ -163,7 +163,7 @@ init_steady_clock(kern_return_t & err) { mach_timebase_info_data_t MachInfo; err = mach_timebase_info(&MachInfo); - if ( err != 0 ) + if ( err != 0 ) { return 0; } @@ -182,12 +182,12 @@ init_steady_clock_ec(kern_return_t & err) { mach_timebase_info_data_t MachInfo; err = mach_timebase_info(&MachInfo); - if ( err != 0 ) + if ( err != 0 ) { return 0; } - if (MachInfo.numer == MachInfo.denom) + if (MachInfo.numer == MachInfo.denom) { return &chrono_detail::steady_simplified_ec; } @@ -199,10 +199,10 @@ init_steady_clock_ec(kern_return_t & err) steady_clock::time_point steady_clock::now() BOOST_NOEXCEPT { - static kern_return_t err; - static chrono_detail::FP fp = chrono_detail::init_steady_clock(err); - if ( err != 0 ) - { + kern_return_t err; + chrono_detail::FP fp = chrono_detail::init_steady_clock(err); + if ( err != 0 ) + { BOOST_ASSERT(0 && "Boost::Chrono - Internal Error"); } return time_point(duration(fp())); @@ -212,16 +212,16 @@ steady_clock::now() BOOST_NOEXCEPT steady_clock::time_point steady_clock::now(system::error_code & ec) { - static kern_return_t err; - static chrono_detail::FP_ec fp = chrono_detail::init_steady_clock_ec(err); - if ( err != 0 ) + kern_return_t err; + chrono_detail::FP_ec fp = chrono_detail::init_steady_clock_ec(err); + if ( err != 0 ) { if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( - system::system_error( - err, - BOOST_CHRONO_SYSTEM_CATEGORY, + system::system_error( + err, + BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::steady_clock" )); } else @@ -230,7 +230,7 @@ steady_clock::now(system::error_code & ec) return time_point(); } } - if (!BOOST_CHRONO_IS_THROWS(ec)) + if (!BOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } diff --git a/boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp b/boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp index 6d09e2cb3a..6e55b0f2ff 100644 --- a/boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp +++ b/boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp @@ -28,7 +28,7 @@ namespace boost inline long tick_factor() // multiplier to convert ticks // to nanoseconds; -1 if unknown { - static long factor = 0; + long factor = 0; if (!factor) { if ((factor = ::sysconf(_SC_CLK_TCK)) <= 0) diff --git a/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp b/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp index 0476f590c9..feecc86792 100644 --- a/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp +++ b/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp @@ -25,7 +25,7 @@ namespace chrono_detail inline nanoseconds::rep tick_factor() // multiplier to convert ticks // to nanoseconds; -1 if unknown { - static long factor = 0; + long factor = 0; if ( !factor ) { if ( (factor = ::sysconf( _SC_CLK_TCK )) <= 0 ) diff --git a/boost/chrono/duration.hpp b/boost/chrono/duration.hpp index a2110bf411..ac4cfb425b 100644 --- a/boost/chrono/duration.hpp +++ b/boost/chrono/duration.hpp @@ -433,7 +433,8 @@ namespace chrono { rep rep_; public: -#if defined BOOST_NO_CXX11_DEFAULTED_FUNCTIONS +#if defined BOOST_NO_CXX11_DEFAULTED_FUNCTIONS || \ + defined BOOST_CHRONO_DURATION_DEFAULTS_TO_ZERO BOOST_FORCEINLINE BOOST_CONSTEXPR duration() : rep_(duration_values::zero()) { } #else diff --git a/boost/chrono/io/time_point_units.hpp b/boost/chrono/io/time_point_units.hpp index 378c112603..7aef8526da 100644 --- a/boost/chrono/io/time_point_units.hpp +++ b/boost/chrono/io/time_point_units.hpp @@ -24,6 +24,16 @@ namespace boost { namespace chrono { + /** + * customization point to the epoch associated to the clock @c Clock + * The default calls @c f.do_get_epoch(Clock()). The user can overload this function. + * @return the string epoch associated to the @c Clock + */ + template + std::basic_string get_epoch_custom(Clock, TPUFacet& f) + { + return f.do_get_epoch(Clock()); + } /** * @c time_point_units facet gives useful information about the time_point pattern, @@ -74,7 +84,7 @@ namespace boost template string_type get_epoch() const { - return do_get_epoch(Clock()); + return get_epoch_custom(Clock(), *this); } protected: @@ -83,6 +93,7 @@ namespace boost */ virtual ~time_point_units() {} + public: /** * @@ -173,7 +184,7 @@ namespace boost return pattern; } - protected: + //protected: /** * @param c a dummy instance of @c system_clock. * @return The epoch string returned by @c clock_string::since(). diff --git a/boost/concept_check.hpp b/boost/concept_check.hpp index 2d6fa32332..25f118b643 100644 --- a/boost/concept_check.hpp +++ b/boost/concept_check.hpp @@ -19,7 +19,7 @@ # include -# include +# include # include # include # include @@ -27,7 +27,6 @@ # include # include # include -# include # include # include @@ -504,11 +503,11 @@ namespace boost : Assignable , EqualityComparable { - typedef typename boost::detail::iterator_traits::value_type value_type; - typedef typename boost::detail::iterator_traits::difference_type difference_type; - typedef typename boost::detail::iterator_traits::reference reference; - typedef typename boost::detail::iterator_traits::pointer pointer; - typedef typename boost::detail::iterator_traits::iterator_category iterator_category; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::difference_type difference_type; + typedef typename std::iterator_traits::reference reference; + typedef typename std::iterator_traits::pointer pointer; + typedef typename std::iterator_traits::iterator_category iterator_category; BOOST_CONCEPT_USAGE(InputIterator) { @@ -617,7 +616,7 @@ namespace boost private: TT a, b; TT i, j; - typename boost::detail::iterator_traits::difference_type n; + typename std::iterator_traits::difference_type n; }; BOOST_concept(Mutable_RandomAccessIterator,(TT)) @@ -630,7 +629,7 @@ namespace boost } private: TT i; - typename boost::detail::iterator_traits::difference_type n; + typename std::iterator_traits::difference_type n; }; //=========================================================================== diff --git a/boost/config/compiler/clang.hpp b/boost/config/compiler/clang.hpp index 47ea65b0a2..5481e5ee62 100644 --- a/boost/config/compiler/clang.hpp +++ b/boost/config/compiler/clang.hpp @@ -23,6 +23,10 @@ #define __has_extension __has_feature #endif +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif + #if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS) # define BOOST_NO_EXCEPTIONS #endif @@ -58,9 +62,11 @@ // even though it defines __SIZEOF_INT128__. // See https://svn.boost.org/trac/boost/ticket/10418 // Only re-enable this for nvcc if you're absolutely sure -// of the circumstances under which it's supported: +// of the circumstances under which it's supported. +// Similarly __SIZEOF_INT128__ is defined when targetting msvc +// compatibility even though the required support functions are absent. // -#if defined(__SIZEOF_INT128__) && !defined(__CUDACC__) +#if defined(__SIZEOF_INT128__) && !defined(__CUDACC__) && !defined(_MSC_VER) # define BOOST_HAS_INT128 #endif @@ -255,13 +261,15 @@ // 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)) +// +// __builtin_unreachable: +#if defined(__has_builtin) && __has_builtin(__builtin_unreachable) +#define BOOST_UNREACHABLE_RETURN(x) __builtin_unreachable(); #endif +// Clang has supported the 'unused' attribute since the first release. +#define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__)) + #ifndef BOOST_COMPILER # define BOOST_COMPILER "Clang version " __clang_version__ #endif diff --git a/boost/config/compiler/gcc.hpp b/boost/config/compiler/gcc.hpp index 41705df039..d9dd59dc5f 100644 --- a/boost/config/compiler/gcc.hpp +++ b/boost/config/compiler/gcc.hpp @@ -143,6 +143,19 @@ #if defined(__SIZEOF_INT128__) && !defined(__CUDACC__) # define BOOST_HAS_INT128 #endif +// +// Recent GCC versions have a __float128 native type, we need to +// include a std lib header to detect this - not ideal, but we'll +// be including later anyway when we select the std lib. +// +#ifdef __cplusplus +#include +#else +#include +#endif +#if defined(_GLIBCXX_USE_FLOAT128) && !defined(__STRICT_ANSI__) +# define BOOST_HAS_FLOAT128 +#endif // C++0x features in 4.3.n and later // @@ -263,7 +276,12 @@ // // Unused attribute: #if __GNUC__ >= 4 -# define BOOST_ATTRIBUTE_UNUSED __attribute__((unused)) +# define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__)) +#endif +// +// __builtin_unreachable: +#if BOOST_GCC_VERSION >= 40800 +#define BOOST_UNREACHABLE_RETURN(x) __builtin_unreachable(); #endif #ifndef BOOST_COMPILER diff --git a/boost/config/compiler/intel.hpp b/boost/config/compiler/intel.hpp index ecfacc5e70..7789b94464 100644 --- a/boost/config/compiler/intel.hpp +++ b/boost/config/compiler/intel.hpp @@ -20,6 +20,9 @@ #include +#undef BOOST_MSVC +#undef BOOST_MSVC_FULL_VER + #if (__INTEL_COMPILER >= 1500) && (_MSC_VER >= 1900) // // These appear to be supported, even though VC++ may not support them: @@ -36,6 +39,9 @@ #include +#undef BOOST_GCC_VERSION +#undef BOOST_GCC_CXX11 + #endif #undef BOOST_COMPILER diff --git a/boost/config/compiler/sunpro_cc.hpp b/boost/config/compiler/sunpro_cc.hpp index 2fd6d3ece0..6017660cbb 100644 --- a/boost/config/compiler/sunpro_cc.hpp +++ b/boost/config/compiler/sunpro_cc.hpp @@ -125,19 +125,15 @@ #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. -// +#if (__SUNPRO_CC < 0x5140) || (__cplusplus < 201103) #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 +#endif + #define BOOST_NO_COMPLETE_VALUE_INITIALIZATION // // C++0x features diff --git a/boost/config/compiler/visualc.hpp b/boost/config/compiler/visualc.hpp index 93908cea50..baaab589ef 100644 --- a/boost/config/compiler/visualc.hpp +++ b/boost/config/compiler/visualc.hpp @@ -55,6 +55,7 @@ # define BOOST_NO_CXX11_EXTERN_TEMPLATE // Variadic macros do not exist for VC7.1 and lower # define BOOST_NO_CXX11_VARIADIC_MACROS +# define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS #endif #if _MSC_VER < 1500 // 140X == VC++ 8.0 diff --git a/boost/config/platform/cloudabi.hpp b/boost/config/platform/cloudabi.hpp new file mode 100644 index 0000000000..bed7b6318d --- /dev/null +++ b/boost/config/platform/cloudabi.hpp @@ -0,0 +1,18 @@ +// Copyright Nuxi, https://nuxi.nl/ 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) + +#define BOOST_PLATFORM "CloudABI" + +#define BOOST_HAS_DIRENT_H +#define BOOST_HAS_STDINT_H +#define BOOST_HAS_UNISTD_H + +#define BOOST_HAS_CLOCK_GETTIME +#define BOOST_HAS_EXPM1 +#define BOOST_HAS_GETTIMEOFDAY +#define BOOST_HAS_LOG1P +#define BOOST_HAS_NANOSLEEP +#define BOOST_HAS_PTHREADS +#define BOOST_HAS_SCHED_YIELD diff --git a/boost/config/platform/macos.hpp b/boost/config/platform/macos.hpp index 6d876b12db..5be4e3b3da 100644 --- a/boost/config/platform/macos.hpp +++ b/boost/config/platform/macos.hpp @@ -47,7 +47,7 @@ # define BOOST_NO_STDC_NAMESPACE # endif -# if (__GNUC__ == 4) +# if (__GNUC__ >= 4) // Both gcc and intel require these. # define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE diff --git a/boost/config/platform/win32.hpp b/boost/config/platform/win32.hpp index 60a29abe83..450158fbaa 100644 --- a/boost/config/platform/win32.hpp +++ b/boost/config/platform/win32.hpp @@ -74,6 +74,14 @@ # define BOOST_HAS_GETSYSTEMTIMEASFILETIME #endif +// +// Windows Runtime +// +#if defined(WINAPI_FAMILY) && \ + (WINAPI_FAMILY == WINAPI_FAMILY_APP || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) +# define BOOST_NO_ANSI_APIS +#endif + #ifndef BOOST_DISABLE_WIN32 // WEK: Added #define BOOST_HAS_FTIME diff --git a/boost/config/select_platform_config.hpp b/boost/config/select_platform_config.hpp index acd1409ebc..62fd818b93 100644 --- a/boost/config/select_platform_config.hpp +++ b/boost/config/select_platform_config.hpp @@ -80,6 +80,10 @@ #elif defined(__VMS) // VMS: # define BOOST_PLATFORM_CONFIG "boost/config/platform/vms.hpp" + +#elif defined(__CloudABI__) +// Nuxi CloudABI: +# define BOOST_PLATFORM_CONFIG "boost/config/platform/cloudabi.hpp" #else # if defined(unix) \ diff --git a/boost/config/stdlib/dinkumware.hpp b/boost/config/stdlib/dinkumware.hpp index 90c45c6c23..af8ddda528 100644 --- a/boost/config/stdlib/dinkumware.hpp +++ b/boost/config/stdlib/dinkumware.hpp @@ -172,10 +172,19 @@ // 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 +#if defined(_CPPLIB_VER) && (_CPPLIB_VER == 650) # define BOOST_NO_CXX11_HDR_CODECVT #endif +#if defined(_CPPLIB_VER) && (_CPPLIB_VER >= 650) +// If _HAS_AUTO_PTR_ETC is defined to 0, std::auto_ptr is not available. +// See https://www.visualstudio.com/en-us/news/vs2015-vs.aspx#C++ +// and http://blogs.msdn.com/b/vcblog/archive/2015/06/19/c-11-14-17-features-in-vs-2015-rtm.aspx +# if defined(_HAS_AUTO_PTR_ETC) && (_HAS_AUTO_PTR_ETC == 0) +# define BOOST_NO_AUTO_PTR +# endif +#endif + #ifdef _CPPLIB_VER # define BOOST_DINKUMWARE_STDLIB _CPPLIB_VER #else diff --git a/boost/config/stdlib/libstdcpp3.hpp b/boost/config/stdlib/libstdcpp3.hpp index 7d27b0cc0c..9718bedcf2 100644 --- a/boost/config/stdlib/libstdcpp3.hpp +++ b/boost/config/stdlib/libstdcpp3.hpp @@ -251,6 +251,10 @@ #define BOOST_NO_CXX11_HDR_FUTURE #define BOOST_NO_CXX11_HDR_FORWARD_LIST #define BOOST_NO_CXX11_HDR_ATOMIC +// shared_ptr is present, but is not convertible to bool +// which causes all kinds of problems especially in Boost.Thread +// but probably elsewhere as well. +#define BOOST_NO_CXX11_SMART_PTR #endif #if (!defined(_GLIBCXX_HAS_GTHREADS) || !defined(_GLIBCXX_USE_C99_STDINT_TR1)) diff --git a/boost/config/suffix.hpp b/boost/config/suffix.hpp index c0ba333918..17bf1020f5 100644 --- a/boost/config/suffix.hpp +++ b/boost/config/suffix.hpp @@ -444,10 +444,12 @@ namespace std { // is defined, in which case it evaluates to return x; Use when you have a return // statement that can never be reached. -#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION -# define BOOST_UNREACHABLE_RETURN(x) return x; -#else -# define BOOST_UNREACHABLE_RETURN(x) +#ifndef BOOST_UNREACHABLE_RETURN +# ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION +# define BOOST_UNREACHABLE_RETURN(x) return x; +# else +# define BOOST_UNREACHABLE_RETURN(x) +# endif #endif // BOOST_DEDUCED_TYPENAME workaround ------------------------------------------// @@ -501,6 +503,16 @@ namespace boost{ # endif } #endif +// same again for __float128: +#if defined(BOOST_HAS_FLOAT128) && defined(__cplusplus) +namespace boost { +# ifdef __GNUC__ + __extension__ typedef __float128 float128_type; +# else + typedef __float128 float128_type; +# endif +} +#endif // BOOST_[APPEND_]EXPLICIT_TEMPLATE_[NON_]TYPE macros --------------------------// diff --git a/boost/container/adaptive_pool.hpp b/boost/container/adaptive_pool.hpp index 59ba37bc93..ac3d86709e 100644 --- a/boost/container/adaptive_pool.hpp +++ b/boost/container/adaptive_pool.hpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include @@ -164,7 +164,7 @@ class adaptive_pool return pointer(static_cast(singleton_t::instance().allocate_node())); } else{ - return static_cast(boost_cont_malloc(count*sizeof(T))); + return static_cast(dlmalloc_malloc(count*sizeof(T))); } } @@ -180,7 +180,7 @@ class adaptive_pool singleton_t::instance().deallocate_node(ptr); } else{ - boost_cont_free(ptr); + dlmalloc_free(ptr); } } @@ -198,7 +198,7 @@ class adaptive_pool //!Returns maximum the number of objects the previously allocated memory //!pointed by p can hold. size_type size(pointer p) const BOOST_NOEXCEPT_OR_NOTHROW - { return boost_cont_size(p); } + { return dlmalloc_size(p); } //!Allocates just one object. Memory allocated with this function //!must be deallocated only with deallocate_one(). @@ -251,17 +251,17 @@ class adaptive_pool void allocate_many(size_type elem_size, std::size_t n_elements, multiallocation_chain &chain) { BOOST_STATIC_ASSERT(( Version > 1 ));/* - boost_cont_memchain ch; + dlmalloc_memchain ch; BOOST_CONTAINER_MEMCHAIN_INIT(&ch); - if(BOOST_UNLIKELY(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch))){ + if(BOOST_UNLIKELY(!dlmalloc_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_UNLIKELY(!boost_cont_multialloc_nodes - (n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast(&chain)))){ + if(BOOST_UNLIKELY(!dlmalloc_multialloc_nodes + (n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast(&chain)))){ boost::container::throw_bad_alloc(); } } @@ -271,29 +271,29 @@ class adaptive_pool void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain) { BOOST_STATIC_ASSERT(( Version > 1 ));/* - boost_cont_memchain ch; + dlmalloc_memchain ch; BOOST_CONTAINER_MEMCHAIN_INIT(&ch); - if(BOOST_UNLIKELY(!boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch))){ + if(BOOST_UNLIKELY(!dlmalloc_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_UNLIKELY(!boost_cont_multialloc_arrays - (n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast(&chain)))){ + if(BOOST_UNLIKELY(!dlmalloc_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_NOEXCEPT_OR_NOTHROW {/* - boost_cont_memchain ch; + dlmalloc_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)); + dlmalloc_multidealloc(&ch);*/ + dlmalloc_multidealloc(reinterpret_cast(&chain)); } //!Deallocates all free blocks of the pool @@ -326,7 +326,7 @@ class adaptive_pool ,size_type &prefer_in_recvd_out_size, pointer &reuse_ptr) { std::size_t const preferred_size = prefer_in_recvd_out_size; - boost_cont_command_ret_t ret = {0 , 0}; + dlmalloc_command_ret_t ret = {0 , 0}; if(BOOST_UNLIKELY(limit_size > this->max_size() || preferred_size > this->max_size())){ return pointer(); } @@ -335,7 +335,7 @@ class adaptive_pool std::size_t r_size; { void* reuse_ptr_void = reuse_ptr; - ret = boost_cont_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr_void); + ret = dlmalloc_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr_void); reuse_ptr = ret.second ? static_cast(reuse_ptr_void) : 0; } prefer_in_recvd_out_size = r_size/sizeof(T); diff --git a/boost/container/allocator.hpp b/boost/container/allocator.hpp index 9f757c73e8..2fb44b73d3 100644 --- a/boost/container/allocator.hpp +++ b/boost/container/allocator.hpp @@ -24,12 +24,14 @@ #include #include #include -#include +#include #include #include #include #include +//!\file + namespace boost { namespace container { @@ -86,21 +88,18 @@ class 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 +template< class T + , unsigned Version BOOST_CONTAINER_DOCONLY(=2) + , unsigned int AllocationDisableMask BOOST_CONTAINER_DOCONLY(=0)> class allocator { typedef unsigned int allocation_type; @@ -186,7 +185,7 @@ class allocator (void)hint; if(count > this->max_size()) boost::container::throw_bad_alloc(); - void *ret = boost_cont_malloc(count*sizeof(T)); + void *ret = dlmalloc_malloc(count*sizeof(T)); if(!ret) boost::container::throw_bad_alloc(); return static_cast(ret); @@ -195,7 +194,7 @@ class allocator //!Deallocates previously allocated memory. //!Never throws void deallocate(pointer ptr, size_type) BOOST_NOEXCEPT_OR_NOTHROW - { boost_cont_free(ptr); } + { dlmalloc_free(ptr); } //!Returns the maximum number of elements that could be allocated. //!Never throws @@ -243,7 +242,7 @@ class allocator size_type size(pointer p) const BOOST_NOEXCEPT_OR_NOTHROW { BOOST_STATIC_ASSERT(( Version > 1 )); - return boost_cont_size(p); + return dlmalloc_size(p); } //!Allocates just one object. Memory allocated with this function @@ -289,16 +288,16 @@ class allocator void allocate_many(size_type elem_size, std::size_t n_elements, multiallocation_chain &chain) { BOOST_STATIC_ASSERT(( Version > 1 ));/* - boost_cont_memchain ch; + dlmalloc_memchain ch; BOOST_CONTAINER_MEMCHAIN_INIT(&ch); - if(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){ + if(!dlmalloc_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))){ + if(!dlmalloc_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast(&chain))){ boost::container::throw_bad_alloc(); } } @@ -309,9 +308,9 @@ class allocator void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain) { BOOST_STATIC_ASSERT(( Version > 1 )); - boost_cont_memchain ch; + dlmalloc_memchain ch; BOOST_CONTAINER_MEMCHAIN_INIT(&ch); - if(!boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){ + if(!dlmalloc_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){ boost::container::throw_bad_alloc(); } chain.incorporate_after(chain.before_begin() @@ -319,7 +318,7 @@ class allocator ,(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))){ + if(!dlmalloc_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast(&chain))){ boost::container::throw_bad_alloc(); }*/ } @@ -330,12 +329,12 @@ class allocator void deallocate_many(multiallocation_chain &chain) BOOST_NOEXCEPT_OR_NOTHROW { BOOST_STATIC_ASSERT(( Version > 1 )); - boost_cont_memchain ch; + dlmalloc_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)); + dlmalloc_multidealloc(&ch); + //dlmalloc_multidealloc(reinterpret_cast(&chain)); } private: @@ -346,7 +345,7 @@ class allocator ,pointer &reuse_ptr) { std::size_t const preferred_size = prefer_in_recvd_out_size; - boost_cont_command_ret_t ret = {0 , 0}; + dlmalloc_command_ret_t ret = {0 , 0}; if((limit_size > this->max_size()) | (preferred_size > this->max_size())){ return pointer(); } @@ -355,7 +354,7 @@ class allocator std::size_t r_size; { void* reuse_ptr_void = reuse_ptr; - ret = boost_cont_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr_void); + ret = dlmalloc_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr_void); reuse_ptr = ret.second ? static_cast(reuse_ptr_void) : 0; } prefer_in_recvd_out_size = r_size/sizeof(T); diff --git a/boost/container/allocator_traits.hpp b/boost/container/allocator_traits.hpp index 2c7900ea72..b515af6180 100644 --- a/boost/container/allocator_traits.hpp +++ b/boost/container/allocator_traits.hpp @@ -445,7 +445,7 @@ struct allocator_traits template static void priv_construct(container_detail::false_type, Allocator &, T *p, const ::boost::container::default_init_t&) - { ::new((void*)p) T; } + { ::new((void*)p, boost_container_new_t()) T; } static bool priv_storage_is_unpropagable(container_detail::true_type, const Allocator &a, pointer p) { return a.storage_is_unpropagable(p); } diff --git a/boost/container/container_fwd.hpp b/boost/container/container_fwd.hpp index a9b421c2b2..e85a6ce952 100644 --- a/boost/container/container_fwd.hpp +++ b/boost/container/container_fwd.hpp @@ -24,6 +24,7 @@ //! - boost::container::vector //! - boost::container::stable_vector //! - boost::container::static_vector +//! - boost::container::small_vector //! - boost::container::slist //! - boost::container::list //! - boost::container::set @@ -38,11 +39,19 @@ //! - boost::container::string //! - boost::container::wstring //! -//! It forward declares the following allocators: +//! Forward declares the following allocators: //! - boost::container::allocator //! - boost::container::node_allocator //! - boost::container::adaptive_pool //! +//! Forward declares the following polymorphic resource classes: +//! - boost::container::pmr::memory_resource +//! - boost::container::pmr::polymorphic_allocator +//! - boost::container::pmr::monotonic_buffer_resource +//! - boost::container::pmr::pool_options +//! - boost::container::pmr::unsynchronized_pool_resource +//! - boost::container::pmr::synchronized_pool_resource +//! //! And finally it defines the following types #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -54,11 +63,18 @@ namespace boost{ namespace intrusive{ +namespace detail{ //Create namespace to avoid compilation errors -}} +}}} namespace boost{ namespace container{ namespace container_detail{ namespace bi = boost::intrusive; + namespace bid = boost::intrusive::detail; +}}} + +namespace boost{ namespace container{ namespace pmr{ + namespace bi = boost::intrusive; + namespace bid = boost::intrusive::detail; }}} #include @@ -210,6 +226,26 @@ template , std::size_t Version = 2> class node_allocator; +namespace pmr { + +class memory_resource; + +template +class polymorphic_allocator; + +class monotonic_buffer_resource; + +struct pool_options; + +template +class resource_adaptor_imp; + +class unsynchronized_pool_resource; + +class synchronized_pool_resource; + +} //namespace pmr { + #else //! Default options for tree-based associative containers diff --git a/boost/container/deque.hpp b/boost/container/deque.hpp index bdfecc1212..f53f34ae98 100644 --- a/boost/container/deque.hpp +++ b/boost/container/deque.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// (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 http://www.boost.org/LICENSE_1_0.txt) // @@ -1140,7 +1140,10 @@ class deque : protected deque_base //! //! Complexity: Constant. reference front() BOOST_NOEXCEPT_OR_NOTHROW - { return *this->members_.m_start; } + { + BOOST_ASSERT(!this->empty()); + return *this->members_.m_start; + } //! Requires: !empty() //! @@ -1151,7 +1154,10 @@ class deque : protected deque_base //! //! Complexity: Constant. const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW - { return *this->members_.m_start; } + { + BOOST_ASSERT(!this->empty()); + return *this->members_.m_start; + } //! Requires: !empty() //! @@ -1162,7 +1168,10 @@ class deque : protected deque_base //! //! Complexity: Constant. reference back() BOOST_NOEXCEPT_OR_NOTHROW - { return *(end()-1); } + { + BOOST_ASSERT(!this->empty()); + return *(end()-1); + } //! Requires: !empty() //! @@ -1173,7 +1182,10 @@ class deque : protected deque_base //! //! Complexity: Constant. const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW - { return *(cend()-1); } + { + BOOST_ASSERT(!this->empty()); + return *(cend()-1); + } //! Requires: size() > n. //! @@ -1184,7 +1196,10 @@ class deque : protected deque_base //! //! Complexity: Constant. reference operator[](size_type n) BOOST_NOEXCEPT_OR_NOTHROW - { return this->members_.m_start[difference_type(n)]; } + { + BOOST_ASSERT(this->size() > n); + return this->members_.m_start[difference_type(n)]; + } //! Requires: size() > n. //! @@ -1195,7 +1210,10 @@ class deque : protected deque_base //! //! Complexity: Constant. const_reference operator[](size_type n) const BOOST_NOEXCEPT_OR_NOTHROW - { return this->members_.m_start[difference_type(n)]; } + { + BOOST_ASSERT(this->size() > n); + return this->members_.m_start[difference_type(n)]; + } //! Requires: size() >= n. //! @@ -1243,7 +1261,10 @@ class deque : protected deque_base //! //! Note: Non-standard extension size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW - { return this->priv_index_of(p); } + { + //Range checked priv_index_of + return this->priv_index_of(p); + } //! Requires: begin() <= p <= end(). //! @@ -1256,7 +1277,10 @@ class deque : protected deque_base //! //! Note: Non-standard extension size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW - { return this->priv_index_of(p); } + { + //Range checked priv_index_of + return this->priv_index_of(p); + } //! Requires: size() > n. //! @@ -1267,7 +1291,10 @@ class deque : protected deque_base //! //! Complexity: Constant. reference at(size_type n) - { this->priv_range_check(n); return (*this)[n]; } + { + this->priv_throw_if_out_of_range(n); + return (*this)[n]; + } //! Requires: size() > n. //! @@ -1278,7 +1305,10 @@ class deque : protected deque_base //! //! Complexity: Constant. const_reference at(size_type n) const - { this->priv_range_check(n); return (*this)[n]; } + { + this->priv_throw_if_out_of_range(n); + return (*this)[n]; + } ////////////////////////////////////////////// // @@ -1344,6 +1374,7 @@ class deque : protected deque_base template iterator emplace(const_iterator p, BOOST_FWD_REF(Args)... args) { + BOOST_ASSERT(this->priv_in_range_or_end(p)); if(p == this->cbegin()){ this->emplace_front(boost::forward(args)...); return this->begin(); @@ -1394,6 +1425,7 @@ class deque : protected deque_base BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N\ iterator emplace(const_iterator p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ {\ + BOOST_ASSERT(this->priv_in_range_or_end(p));\ if(p == this->cbegin()){\ this->emplace_front(BOOST_MOVE_FWD##N);\ return this->begin();\ @@ -1494,6 +1526,7 @@ class deque : protected deque_base //! Complexity: Linear to n. iterator insert(const_iterator pos, size_type n, const value_type& x) { + //Range check of p is done by insert() typedef constant_iterator c_it; return this->insert(pos, c_it(x, n), c_it()); } @@ -1519,6 +1552,7 @@ class deque : protected deque_base #endif ) { + BOOST_ASSERT(this->priv_in_range_or_end(pos)); size_type n = 0; iterator it(pos.unconst()); for(;first != last; ++first, ++n){ @@ -1541,7 +1575,10 @@ class deque : protected deque_base //! //! Complexity: Linear to distance [il.begin(), il.end()). iterator insert(const_iterator pos, std::initializer_list il) - { return insert(pos, il.begin(), il.end()); } + { + //Range check os pos is done in insert() + return insert(pos, il.begin(), il.end()); + } #endif #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) @@ -1556,6 +1593,7 @@ class deque : protected deque_base #endif ) { + BOOST_ASSERT(this->priv_in_range_or_end(p)); container_detail::insert_range_proxy proxy(first); return priv_insert_aux_impl(p, boost::container::iterator_distance(first, last), proxy); } @@ -1568,6 +1606,7 @@ class deque : protected deque_base //! Complexity: Constant time. void pop_front() BOOST_NOEXCEPT_OR_NOTHROW { + BOOST_ASSERT(!this->empty()); if (this->members_.m_start.m_cur != this->members_.m_start.m_last - 1) { allocator_traits_type::destroy ( this->alloc() @@ -1586,6 +1625,7 @@ class deque : protected deque_base //! Complexity: Constant time. void pop_back() BOOST_NOEXCEPT_OR_NOTHROW { + BOOST_ASSERT(!this->empty()); if (this->members_.m_finish.m_cur != this->members_.m_finish.m_first) { --this->members_.m_finish.m_cur; allocator_traits_type::destroy @@ -1607,6 +1647,7 @@ class deque : protected deque_base //! Constant if pos is the first or the last element. iterator erase(const_iterator pos) BOOST_NOEXCEPT_OR_NOTHROW { + BOOST_ASSERT(this->priv_in_range(pos)); iterator next = pos.unconst(); ++next; size_type index = pos - this->members_.m_start; @@ -1631,6 +1672,8 @@ class deque : protected deque_base //! if(pos is near the beginning). iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW { + BOOST_ASSERT(first == last || + (first < last && this->priv_in_range(first) && this->priv_in_range_or_end(last))); if (first == this->members_.m_start && last == this->members_.m_finish) { this->clear(); return this->members_.m_finish; @@ -1764,12 +1807,26 @@ class deque : protected deque_base } } - void priv_range_check(size_type n) const - { if (n >= this->size()) throw_out_of_range("deque::at out of range"); } + void priv_throw_if_out_of_range(size_type n) const + { + if (n >= this->size()) + throw_out_of_range("deque::at out of range"); + } + + bool priv_in_range(const_iterator pos) const + { + return (this->begin() <= pos) && (pos < this->end()); + } + + bool priv_in_range_or_end(const_iterator pos) const + { + return (this->begin() <= pos) && (pos <= this->end()); + } template iterator priv_insert(const_iterator p, BOOST_FWD_REF(U) x) { + BOOST_ASSERT(this->priv_in_range_or_end(p)); if (p == cbegin()){ this->push_front(::boost::forward(x)); return begin(); @@ -1994,8 +2051,7 @@ class deque : protected deque_base } template - typename iterator_enable_if_tag::type - priv_range_initialize(InIt first, InIt last) + void priv_range_initialize(InIt first, InIt last, typename iterator_enable_if_tag::type* =0) { this->priv_initialize_map(0); BOOST_TRY { @@ -2010,8 +2066,7 @@ class deque : protected deque_base } template - typename iterator_disable_if_tag::type - priv_range_initialize(FwdIt first, FwdIt last) + void priv_range_initialize(FwdIt first, FwdIt last, typename iterator_disable_if_tag::type* =0) { size_type n = 0; n = boost::container::iterator_distance(first, last); diff --git a/boost/container/detail/adaptive_node_pool.hpp b/boost/container/detail/adaptive_node_pool.hpp index 4a1f07c4a8..20696100f5 100644 --- a/boost/container/detail/adaptive_node_pool.hpp +++ b/boost/container/detail/adaptive_node_pool.hpp @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/boost/container/detail/alloc_lib.h b/boost/container/detail/alloc_lib.h index 4802d9d814..950ff722a5 100644 --- a/boost/container/detail/alloc_lib.h +++ b/boost/container/detail/alloc_lib.h @@ -15,27 +15,6 @@ #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 @@ -215,14 +194,6 @@ typedef struct boost_cont_memchain_impl }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)) @@ -231,22 +202,6 @@ BOOST_CONTAINER_DECL void* boost_cont_memalign(size_t bytes, size_t alignment); 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; @@ -254,26 +209,6 @@ typedef struct boost_cont_malloc_stats_impl 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 @@ -303,7 +238,50 @@ typedef struct boost_cont_command_ret_impl int second; }boost_cont_command_ret_t; -BOOST_CONTAINER_DECL boost_cont_command_ret_t boost_cont_allocation_command +size_t boost_cont_size(const void *p); + +void* boost_cont_malloc(size_t bytes); + +void boost_cont_free(void* mem); + +void* boost_cont_memalign(size_t bytes, size_t alignment); + +int boost_cont_multialloc_nodes + (size_t n_elements, size_t elem_size, size_t contiguous_elements, boost_cont_memchain *pchain); + +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); + +void boost_cont_multidealloc(boost_cont_memchain *pchain); + +size_t boost_cont_footprint(); + +size_t boost_cont_allocated_memory(); + +size_t boost_cont_chunksize(const void *p); + +int boost_cont_all_deallocated(); + +boost_cont_malloc_stats_t boost_cont_malloc_stats(); + +size_t boost_cont_in_use_memory(); + +int boost_cont_trim(size_t pad); + +int boost_cont_mallopt(int parameter_number, int parameter_value); + +int boost_cont_grow + (void* oldmem, size_t minbytes, size_t maxbytes, size_t *received); + +int boost_cont_shrink + (void* oldmem, size_t minbytes, size_t maxbytes, size_t *received, int do_commit); + +void* boost_cont_alloc + (size_t minbytes, size_t preferred_bytes, size_t *received_bytes); + +int boost_cont_malloc_check(); + +boost_cont_command_ret_t boost_cont_allocation_command ( allocation_type command , size_t sizeof_object , size_t limit_objects @@ -312,7 +290,17 @@ BOOST_CONTAINER_DECL boost_cont_command_ret_t boost_cont_allocation_command , void *reuse_ptr ); -BOOST_CONTAINER_DECL int boost_cont_mallopt(int param_number, int value); +void *boost_cont_sync_create(); + +void boost_cont_sync_destroy(void *sync); + +int boost_cont_sync_lock(void *sync); + +void boost_cont_sync_unlock(void *sync); + +int boost_cont_global_sync_lock(); + +void boost_cont_global_sync_unlock(); #ifdef __cplusplus } //extern "C" { 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 aea99a65c3..0000000000 --- a/boost/container/detail/alloc_lib_auto_link.hpp +++ /dev/null @@ -1,24 +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 - -#ifndef BOOST_CONFIG_HPP -# include -#endif - -#if defined(BOOST_HAS_PRAGMA_ONCE) -# pragma once -#endif - -#include -#include - -#endif //#ifndef BOOST_CONTAINER_DETAIL_BOOST_CONT_EXT_AUTO_LINK_HPP diff --git a/boost/container/detail/auto_link.hpp b/boost/container/detail/auto_link.hpp index da078e8342..264b1ba112 100644 --- a/boost/container/detail/auto_link.hpp +++ b/boost/container/detail/auto_link.hpp @@ -18,6 +18,13 @@ # pragma once #endif +//Define BOOST_CONTAINER_DYNAMIC_LINKING which is independent from BOOST_*_NO_LIB +//and is needed is some tests that need to disable some checks (like operator new replacements) +//that don't work across DLL boundaries +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTAINER_DYN_LINK) +# define BOOST_CONTAINER_DYNAMIC_LINKING +#endif + // // Automatically link to the correct build variant where possible. // @@ -27,12 +34,14 @@ // 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) +#if defined(BOOST_CONTAINER_DYNAMIC_LINKING) # define BOOST_DYN_LINK #endif + // // And include the header that does the work: // diff --git a/boost/container/detail/block_list.hpp b/boost/container/detail/block_list.hpp new file mode 100644 index 0000000000..1a6057cb4a --- /dev/null +++ b/boost/container/detail/block_list.hpp @@ -0,0 +1,139 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_BLOCK_LIST_HEADER +#define BOOST_CONTAINER_DETAIL_BLOCK_LIST_HEADER + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace container { +namespace pmr { + +struct list_node +{ + list_node *next; + list_node *previous; +}; + +struct list_node_traits +{ + typedef list_node node; + typedef list_node* node_ptr; + typedef const list_node* const_node_ptr; + + static node_ptr get_next(const_node_ptr n) + { return n->next; } + + static node_ptr get_previous(const_node_ptr n) + { return n->previous; } + + static void set_next(const node_ptr & n, const node_ptr & next) + { n->next = next; } + + static void set_previous(const node_ptr & n, const node_ptr & previous) + { n->previous = previous; } +}; + +struct block_list_header + : public list_node +{ + std::size_t size; +}; + +typedef bi::circular_list_algorithms list_algo; + + +template +class block_list_base +{ + list_node m_list; + + static const std::size_t MaxAlignMinus1 = memory_resource::max_align-1u; + + public: + + static const std::size_t header_size = std::size_t(sizeof(DerivedFromBlockListHeader) + MaxAlignMinus1) & std::size_t(~MaxAlignMinus1); + + explicit block_list_base() + { list_algo::init_header(&m_list); } + + #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + block_list_base(const block_list_base&) = delete; + block_list_base operator=(const block_list_base&) = delete; + #else + private: + block_list_base (const block_list_base&); + block_list_base operator=(const block_list_base&); + public: + #endif + + ~block_list_base() + {} + + void *allocate(std::size_t size, memory_resource &mr) + { + if((size_t(-1) - header_size) < size) + throw_bad_alloc(); + void *p = mr.allocate(size+header_size); + block_list_header &mb = *::new((void*)p) DerivedFromBlockListHeader; + mb.size = size+header_size; + list_algo::link_after(&m_list, &mb); + return (char *)p + header_size; + } + + void deallocate(void *p, memory_resource &mr) BOOST_NOEXCEPT + { + DerivedFromBlockListHeader *pheader = static_cast + (static_cast((char*)p - header_size)); + list_algo::unlink(pheader); + const std::size_t size = pheader->size; + static_cast(pheader)->~DerivedFromBlockListHeader(); + mr.deallocate(pheader, size, memory_resource::max_align); + } + + void release(memory_resource &mr) BOOST_NOEXCEPT + { + list_node *n = list_algo::node_traits::get_next(&m_list); + while(n != &m_list){ + DerivedFromBlockListHeader &d = static_cast(*n); + n = list_algo::node_traits::get_next(n); + std::size_t size = d.size; + d.~DerivedFromBlockListHeader(); + mr.deallocate(reinterpret_cast(&d), size, memory_resource::max_align); + } + list_algo::init_header(&m_list); + } +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#include + +#endif //BOOST_CONTAINER_DETAIL_BLOCK_LIST_HEADER diff --git a/boost/container/detail/block_slist.hpp b/boost/container/detail/block_slist.hpp new file mode 100644 index 0000000000..278e6414a7 --- /dev/null +++ b/boost/container/detail/block_slist.hpp @@ -0,0 +1,157 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_BLOCK_SLIST_HEADER +#define BOOST_CONTAINER_DETAIL_BLOCK_SLIST_HEADER + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +namespace boost { +namespace container { +namespace pmr { + +struct slist_node +{ + slist_node *next; +}; + +struct slist_node_traits +{ + typedef slist_node node; + typedef slist_node* node_ptr; + typedef const slist_node* const_node_ptr; + + 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; } +}; + +struct block_slist_header + : public slist_node +{ + std::size_t size; +}; + +typedef bi::linear_slist_algorithms slist_algo; + +template +class block_slist_base +{ + slist_node m_slist; + + static const std::size_t MaxAlignMinus1 = memory_resource::max_align-1u; + + public: + + static const std::size_t header_size = std::size_t(sizeof(DerivedFromBlockSlistHeader) + MaxAlignMinus1) & std::size_t(~MaxAlignMinus1); + + explicit block_slist_base() + { slist_algo::init_header(&m_slist); } + + #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + block_slist_base(const block_slist_base&) = delete; + block_slist_base operator=(const block_slist_base&) = delete; + #else + private: + block_slist_base (const block_slist_base&); + block_slist_base operator=(const block_slist_base&); + public: + #endif + + ~block_slist_base() + {} + + void *allocate(std::size_t size, memory_resource &mr) + { + if((size_t(-1) - header_size) < size) + throw_bad_alloc(); + void *p = mr.allocate(size+header_size); + block_slist_header &mb = *::new((void*)p) DerivedFromBlockSlistHeader; + mb.size = size+header_size; + slist_algo::link_after(&m_slist, &mb); + return (char *)p + header_size; + } + + void release(memory_resource &mr) BOOST_NOEXCEPT + { + slist_node *n = slist_algo::node_traits::get_next(&m_slist); + while(n){ + DerivedFromBlockSlistHeader &d = static_cast(*n); + n = slist_algo::node_traits::get_next(n); + std::size_t size = d.block_slist_header::size; + d.~DerivedFromBlockSlistHeader(); + mr.deallocate(reinterpret_cast(&d), size, memory_resource::max_align); + } + slist_algo::init_header(&m_slist); + } +}; + +class block_slist + : public block_slist_base<> +{ + memory_resource &m_upstream_rsrc; + + public: + + explicit block_slist(memory_resource &upstream_rsrc) + : block_slist_base<>(), m_upstream_rsrc(upstream_rsrc) + {} + + #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + block_slist(const block_slist&) = delete; + block_slist operator=(const block_slist&) = delete; + #else + private: + block_slist (const block_slist&); + block_slist operator=(const block_slist&); + public: + #endif + + ~block_slist() + { this->release(); } + + void *allocate(std::size_t size) + { return this->block_slist_base<>::allocate(size, m_upstream_rsrc); } + + void release() BOOST_NOEXCEPT + { return this->block_slist_base<>::release(m_upstream_rsrc); } + + memory_resource& upstream_resource() const BOOST_NOEXCEPT + { return m_upstream_rsrc; } +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#include + +#endif //BOOST_CONTAINER_DETAIL_BLOCK_SLIST_HEADER diff --git a/boost/container/detail/config_begin.hpp b/boost/container/detail/config_begin.hpp index 3f509e320b..7e3e03fa64 100644 --- a/boost/container/detail/config_begin.hpp +++ b/boost/container/detail/config_begin.hpp @@ -25,6 +25,7 @@ #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 : 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #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 diff --git a/boost/container/detail/copy_move_algo.hpp b/boost/container/detail/copy_move_algo.hpp index 23fa730838..f590a8aaf3 100644 --- a/boost/container/detail/copy_move_algo.hpp +++ b/boost/container/detail/copy_move_algo.hpp @@ -252,15 +252,15 @@ struct disable_if_memzero_initializable template struct enable_if_trivially_destructible - : enable_if_c < false/*container_detail::is_trivially_destructible - ::value_type>::value*/ + : enable_if_c < container_detail::is_trivially_destructible + ::value_type>::value , R> {}; template struct disable_if_trivially_destructible - : enable_if_c ::value_type>::value*/ + : enable_if_c ::value_type>::value , R> {}; diff --git a/boost/container/detail/dispatch_uses_allocator.hpp b/boost/container/detail/dispatch_uses_allocator.hpp new file mode 100644 index 0000000000..3000f7cb27 --- /dev/null +++ b/boost/container/detail/dispatch_uses_allocator.hpp @@ -0,0 +1,293 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_DISPATCH_USES_ALLOCATOR_HPP +#define BOOST_CONTAINER_DISPATCH_USES_ALLOCATOR_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif +#include + +#include + +namespace boost { namespace container { + +namespace container_detail { + + +// Check if we can detect is_convertible using advanced SFINAE expressions +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + //! 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 + template + struct is_constructible + { + typedef char yes_type; + struct no_type + { char padding[2]; }; + + template + struct dummy; + + template + static decltype(X(boost::move_detail::declval()...), true_type()) test(int); + + template + static no_type test(...); + + static const bool value = sizeof(test(0)) == sizeof(yes_type); + }; + + template + struct is_constructible_with_allocator_prefix + : is_constructible + {}; + +#else // #if !defined(BOOST_NO_SFINAE_EXPR) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + //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 + struct is_constructible_with_allocator_prefix + : constructible_with_allocator_prefix + {}; + + template + struct is_constructible_with_allocator_suffix + : constructible_with_allocator_suffix + {}; + + #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + template + struct is_constructible_with_allocator_prefix + : constructible_with_allocator_prefix + {}; + + template + 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 ConstructAlloc + , typename ArgAlloc + , typename T + , class ...Args + > +inline typename container_detail::enable_if_and + < void + , container_detail::is_not_pair + , container_detail::not_< uses_allocator > + >::type dispatch_uses_allocator + ( ConstructAlloc & construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p, BOOST_FWD_REF(Args)...args) +{ + (void)arg_alloc; + allocator_traits::construct(construct_alloc, p, ::boost::forward(args)...); +} + +// allocator_arg_t +template < typename ConstructAlloc + , typename ArgAlloc + , typename T + , class ...Args + > +inline typename container_detail::enable_if_and + < void + , container_detail::is_not_pair + , uses_allocator + , is_constructible_with_allocator_prefix + >::type dispatch_uses_allocator + ( ConstructAlloc& construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p, BOOST_FWD_REF(Args) ...args) +{ + allocator_traits::construct + ( construct_alloc, p, allocator_arg + , ::boost::forward(arg_alloc), ::boost::forward(args)...); +} + +// allocator suffix +template < typename ConstructAlloc + , typename ArgAlloc + , typename T + , class ...Args + > +inline typename container_detail::enable_if_and + < void + , container_detail::is_not_pair + , uses_allocator + , container_detail::not_ > + >::type dispatch_uses_allocator + ( ConstructAlloc& construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p, BOOST_FWD_REF(Args)...args) +{ + allocator_traits::construct + (construct_alloc, p, ::boost::forward(args)..., ::boost::forward(arg_alloc)); +} + +#else //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +#define BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE(N) \ + template \ + inline typename container_detail::enable_if_and\ + < void\ + , container_detail::is_not_pair\ + , container_detail::not_ >\ + >::type\ + dispatch_uses_allocator\ + (ConstructAlloc &construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + (void)arg_alloc;\ + allocator_traits::construct(construct_alloc, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + }\ +// +BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE) +#undef BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE + +#define BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE(N) \ + template < typename ConstructAlloc, typename ArgAlloc, typename T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ + inline typename container_detail::enable_if_and\ + < void\ + , container_detail::is_not_pair\ + , uses_allocator\ + , is_constructible_with_allocator_prefix\ + >::type\ + dispatch_uses_allocator\ + (ConstructAlloc& construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + allocator_traits::construct\ + (construct_alloc, p, allocator_arg, ::boost::forward(arg_alloc) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + }\ +// +BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE) +#undef BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE + +#define BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE(N) \ + template < typename ConstructAlloc, typename ArgAlloc, typename T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ + inline typename container_detail::enable_if_and\ + < void\ + , container_detail::is_not_pair\ + , uses_allocator\ + , container_detail::not_ >\ + >::type\ + dispatch_uses_allocator\ + (ConstructAlloc& construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + allocator_traits::construct\ + (construct_alloc, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N, ::boost::forward(arg_alloc));\ + }\ +// +BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE) +#undef BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE + +#endif //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +template < typename ConstructAlloc + , typename ArgAlloc + , typename Pair + > inline +BOOST_CONTAINER_DOC1ST(void, typename container_detail::enable_if >::type) + dispatch_uses_allocator + ( ConstructAlloc & construct_alloc + , ArgAlloc & arg_alloc + , Pair* p) +{ + (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->first)); + BOOST_TRY{ + (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->second)); + } + BOOST_CATCH(...) { + allocator_traits::destroy(construct_alloc, container_detail::addressof(p->first)); + BOOST_RETHROW + } + BOOST_CATCH_END +} + + +template < typename ConstructAlloc + , typename ArgAlloc + , class Pair, class U, class V> +BOOST_CONTAINER_DOC1ST(void, typename container_detail::enable_if >::type) + dispatch_uses_allocator + ( ConstructAlloc & construct_alloc + , ArgAlloc & arg_alloc + , Pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y) +{ + (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->first), ::boost::forward(x)); + BOOST_TRY{ + (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->second), ::boost::forward(y)); + } + BOOST_CATCH(...){ + allocator_traits::destroy(construct_alloc, container_detail::addressof(p->first)); + BOOST_RETHROW + } + BOOST_CATCH_END +} + +template < typename ConstructAlloc + , typename ArgAlloc + , class Pair, class Pair2> +BOOST_CONTAINER_DOC1ST(void, typename container_detail::enable_if< container_detail::is_pair >::type) + dispatch_uses_allocator + (ConstructAlloc & construct_alloc + , ArgAlloc & arg_alloc + , Pair* p, Pair2& x) +{ (dispatch_uses_allocator)(construct_alloc, arg_alloc, p, x.first, x.second); } + +template < typename ConstructAlloc + , typename ArgAlloc + , class Pair, class Pair2> +typename container_detail::enable_if_and + < void + , container_detail::is_pair + , container_detail::not_ > >::type //This is needed for MSVC10 and ambiguous overloads + dispatch_uses_allocator + (ConstructAlloc & construct_alloc + , ArgAlloc & arg_alloc + , Pair* p, BOOST_RV_REF_BEG Pair2 BOOST_RV_REF_END x) +{ (dispatch_uses_allocator)(construct_alloc, arg_alloc, p, ::boost::move(x.first), ::boost::move(x.second)); } + +//template +//void dispatch_uses_allocator( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc +// , pair* p, piecewise_construct_t, tuple x, tuple y); + +} //namespace container_detail + +}} // namespace boost { namespace container { + +#include + +#endif // BOOST_CONTAINER_DISPATCH_USES_ALLOCATOR_HPP diff --git a/boost/container/detail/dlmalloc.hpp b/boost/container/detail/dlmalloc.hpp new file mode 100644 index 0000000000..15086c399f --- /dev/null +++ b/boost/container/detail/dlmalloc.hpp @@ -0,0 +1,103 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_LIB_HPP +#define BOOST_CONTAINER_DETAIL_ALLOC_LIB_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include +#include +#include + +#include + +namespace boost{ +namespace container{ + +typedef boost_cont_command_ret_t dlmalloc_command_ret_t; +typedef boost_cont_memchain dlmalloc_memchain; +typedef boost_cont_memchain_it dlmalloc_memchain_it; +typedef boost_cont_malloc_stats_t dlmalloc_malloc_stats_t; + +BOOST_CONTAINER_DECL size_t dlmalloc_size(const void *p); + +BOOST_CONTAINER_DECL void* dlmalloc_malloc(size_t bytes); + +BOOST_CONTAINER_DECL void dlmalloc_free(void* mem); + +BOOST_CONTAINER_DECL void* dlmalloc_memalign(size_t bytes, size_t alignment); + +BOOST_CONTAINER_DECL int dlmalloc_multialloc_nodes + (size_t n_elements, size_t elem_size, size_t contiguous_elements, boost_cont_memchain *pchain); + +BOOST_CONTAINER_DECL int dlmalloc_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 dlmalloc_multidealloc(boost_cont_memchain *pchain); + +BOOST_CONTAINER_DECL size_t dlmalloc_footprint(); + +BOOST_CONTAINER_DECL size_t dlmalloc_allocated_memory(); + +BOOST_CONTAINER_DECL size_t dlmalloc_chunksize(const void *p); + +BOOST_CONTAINER_DECL int dlmalloc_all_deallocated(); + +BOOST_CONTAINER_DECL boost_cont_malloc_stats_t dlmalloc_malloc_stats(); + +BOOST_CONTAINER_DECL size_t dlmalloc_in_use_memory(); + +BOOST_CONTAINER_DECL int dlmalloc_trim(size_t pad); + +BOOST_CONTAINER_DECL int dlmalloc_mallopt(int parameter_number, int parameter_value); + +BOOST_CONTAINER_DECL int dlmalloc_grow(void* oldmem, size_t minbytes, size_t maxbytes, size_t *received); + +BOOST_CONTAINER_DECL int dlmalloc_shrink(void* oldmem, size_t minbytes, size_t maxbytes, size_t *received, int do_commit); + +BOOST_CONTAINER_DECL void* dlmalloc_alloc(size_t minbytes, size_t preferred_bytes, size_t *received_bytes); + +BOOST_CONTAINER_DECL int dlmalloc_malloc_check(); + +BOOST_CONTAINER_DECL boost_cont_command_ret_t dlmalloc_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 dlmalloc_mallopt(int param_number, int value); + +BOOST_CONTAINER_DECL void *dlmalloc_sync_create(); + +BOOST_CONTAINER_DECL void dlmalloc_sync_destroy(void *sync); + +BOOST_CONTAINER_DECL bool dlmalloc_sync_lock(void *sync); + +BOOST_CONTAINER_DECL void dlmalloc_sync_unlock(void *sync); + +BOOST_CONTAINER_DECL bool dlmalloc_global_sync_lock(); + +BOOST_CONTAINER_DECL void dlmalloc_global_sync_unlock(); + +} //namespace container{ +} //namespace boost{ + +#include + +#endif //BOOST_CONTAINER_DETAIL_ALLOC_LIB_HPP diff --git a/boost/container/detail/flat_tree.hpp b/boost/container/detail/flat_tree.hpp index f27421125f..4c48c8b7d3 100644 --- a/boost/container/detail/flat_tree.hpp +++ b/boost/container/detail/flat_tree.hpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// (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 http://www.boost.org/LICENSE_1_0.txt) // @@ -376,35 +376,39 @@ class flat_tree return i; } - iterator insert_unique(const_iterator pos, const value_type& val) + iterator insert_unique(const_iterator hint, const value_type& val) { + BOOST_ASSERT(this->priv_in_range_or_end(hint)); std::pair ret; insert_commit_data data; - return this->priv_insert_unique_prepare(pos, val, data) + return this->priv_insert_unique_prepare(hint, val, data) ? this->priv_insert_commit(data, val) : iterator(vector_iterator_get_ptr(data.position)); } - iterator insert_unique(const_iterator pos, BOOST_RV_REF(value_type) val) + iterator insert_unique(const_iterator hint, BOOST_RV_REF(value_type) val) { + BOOST_ASSERT(this->priv_in_range_or_end(hint)); std::pair ret; insert_commit_data data; - return this->priv_insert_unique_prepare(pos, val, data) + return this->priv_insert_unique_prepare(hint, val, data) ? this->priv_insert_commit(data, boost::move(val)) : iterator(vector_iterator_get_ptr(data.position)); } - iterator insert_equal(const_iterator pos, const value_type& val) + iterator insert_equal(const_iterator hint, const value_type& val) { + BOOST_ASSERT(this->priv_in_range_or_end(hint)); insert_commit_data data; - this->priv_insert_equal_prepare(pos, val, data); + this->priv_insert_equal_prepare(hint, val, data); return this->priv_insert_commit(data, val); } - iterator insert_equal(const_iterator pos, BOOST_RV_REF(value_type) mval) + iterator insert_equal(const_iterator hint, BOOST_RV_REF(value_type) mval) { + BOOST_ASSERT(this->priv_in_range_or_end(hint)); insert_commit_data data; - this->priv_insert_equal_prepare(pos, mval, data); + this->priv_insert_equal_prepare(hint, mval, data); return this->priv_insert_commit(data, boost::move(mval)); } @@ -524,6 +528,7 @@ class flat_tree template iterator emplace_hint_unique(const_iterator hint, BOOST_FWD_REF(Args)... args) { + //hint checked in insert_unique typename aligned_storage::value>::type v; value_type &val = *static_cast(static_cast(&v)); stored_allocator_type &a = this->get_stored_allocator(); @@ -546,6 +551,7 @@ class flat_tree template iterator emplace_hint_equal(const_iterator hint, BOOST_FWD_REF(Args)... args) { + //hint checked in insert_equal typename aligned_storage::value>::type v; value_type &val = *static_cast(static_cast(&v)); stored_allocator_type &a = this->get_stored_allocator(); @@ -732,6 +738,12 @@ class flat_tree { x.swap(y); } private: + + bool priv_in_range_or_end(const_iterator pos) const + { + return (this->begin() <= pos) && (pos <= this->end()); + } + struct insert_commit_data { const_iterator position; diff --git a/boost/container/detail/mutex.hpp b/boost/container/detail/mutex.hpp index f8efa7fe6b..82e8810d0a 100644 --- a/boost/container/detail/mutex.hpp +++ b/boost/container/detail/mutex.hpp @@ -107,7 +107,7 @@ #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) { + static inline int boost_container_x86_cas_lock(int *sl) { int ret; int val = 1; int cmp = 0; @@ -118,7 +118,7 @@ return ret; } - static FORCEINLINE void boost_container_x86_clear_lock(int* sl) { + static inline void boost_container_x86_clear_lock(int* sl) { assert(*sl != 0); int prev = 0; int ret; diff --git a/boost/container/detail/pair.hpp b/boost/container/detail/pair.hpp index 35e8846caa..17766f35cb 100644 --- a/boost/container/detail/pair.hpp +++ b/boost/container/detail/pair.hpp @@ -27,52 +27,12 @@ #include #include #include -#include +#include #include //swap #include //pair #include -/* -namespace boost{ - -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 { namespace container_detail { @@ -118,36 +78,6 @@ struct is_std_pair< std::pair > struct pair_nat; -struct piecewise_construct_t { }; -static const piecewise_construct_t piecewise_construct = piecewise_construct_t(); - -/* -template -struct pair -{ - template pair(pair&& p); - template - pair(piecewise_construct_t, tuple first_args, - tuple second_args); - - template pair& operator=(const pair& p); - pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); - template pair& operator=(pair&& p); - - void swap(pair& p) noexcept(noexcept(swap(first, p.first)) && - noexcept(swap(second, p.second))); -}; - -template bool operator==(const pair&, const pair&); -template bool operator!=(const pair&, const pair&); -template bool operator< (const pair&, const pair&); -template bool operator> (const pair&, const pair&); -template bool operator>=(const pair&, const pair&); -template bool operator<=(const pair&, const pair&); -*/ - - template struct pair { diff --git a/boost/container/detail/pool_common_alloc.hpp b/boost/container/detail/pool_common_alloc.hpp index 72e9c8d278..3a3c80a78f 100644 --- a/boost/container/detail/pool_common_alloc.hpp +++ b/boost/container/detail/pool_common_alloc.hpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include namespace boost{ @@ -44,15 +44,15 @@ struct fake_segment_manager typedef boost::container::container_detail:: basic_multiallocation_chain multiallocation_chain; static void deallocate(void_pointer p) - { boost_cont_free(p); } + { dlmalloc_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; + dlmalloc_memchain dlchain; BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&dlchain, ptrs.first, ptrs.second, size); - boost_cont_multidealloc(&dlchain); + dlmalloc_multidealloc(&dlchain); } typedef std::ptrdiff_t difference_type; @@ -60,7 +60,7 @@ struct fake_segment_manager static void *allocate_aligned(std::size_t nbytes, std::size_t alignment) { - void *ret = boost_cont_memalign(nbytes, alignment); + void *ret = dlmalloc_memalign(nbytes, alignment); if(!ret) boost::container::throw_bad_alloc(); return ret; @@ -68,7 +68,7 @@ struct fake_segment_manager static void *allocate(std::size_t nbytes) { - void *ret = boost_cont_malloc(nbytes); + void *ret = dlmalloc_malloc(nbytes); if(!ret) boost::container::throw_bad_alloc(); return ret; diff --git a/boost/container/detail/pool_resource.hpp b/boost/container/detail/pool_resource.hpp new file mode 100644 index 0000000000..e5f59f5186 --- /dev/null +++ b/boost/container/detail/pool_resource.hpp @@ -0,0 +1,191 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_POOL_RESOURCE_HPP +#define BOOST_CONTAINER_POOL_RESOURCE_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + +class pool_data_t; + +static const std::size_t pool_options_minimum_max_blocks_per_chunk = 1u; +static const std::size_t pool_options_default_max_blocks_per_chunk = 32u; +static const std::size_t pool_options_minimum_largest_required_pool_block = + memory_resource::max_align > 2*sizeof(void*) ? memory_resource::max_align : 2*sizeof(void*); +static const std::size_t pool_options_default_largest_required_pool_block = + pool_options_minimum_largest_required_pool_block > 4096u + ? pool_options_minimum_largest_required_pool_block : 4096u; + +#endif //BOOST_CONTAINER_DOXYGEN_INVOKED + +class pool_resource +{ + typedef block_list_base<> block_list_base_t; + + pool_options m_options; + memory_resource& m_upstream; + block_list_base_t m_oversized_list; + pool_data_t *m_pool_data; + std::size_t m_pool_count; + + static void priv_limit_option(std::size_t &val, std::size_t min, std::size_t max); + static std::size_t priv_pool_index(std::size_t block_size); + static std::size_t priv_pool_block(std::size_t index); + + void priv_fix_options(); + void priv_init_pools(); + void priv_constructor_body(); + + public: + + //! Requires: `upstream` is the address of a valid memory resource. + //! + //! Effects: Constructs a pool resource object that will obtain memory + //! from upstream whenever the pool resource is unable to satisfy a memory + //! request from its own internal data structures. The resulting object will hold + //! a copy of upstream, but will not own the resource to which upstream points. + //! [ Note: The intention is that calls to upstream->allocate() will be + //! substantially fewer than calls to this->allocate() in most cases. - end note + //! The behavior of the pooling mechanism is tuned according to the value of + //! the opts argument. + //! + //! Throws: Nothing unless upstream->allocate() throws. It is unspecified if + //! or under what conditions this constructor calls upstream->allocate(). + pool_resource(const pool_options& opts, memory_resource* upstream) BOOST_NOEXCEPT; + + //! Effects: Same as + //! `pool_resource(pool_options(), get_default_resource())`. + pool_resource() BOOST_NOEXCEPT; + + //! Effects: Same as + //! `pool_resource(pool_options(), upstream)`. + explicit pool_resource(memory_resource* upstream) BOOST_NOEXCEPT; + + //! Effects: Same as + //! `pool_resource(opts, get_default_resource())`. + explicit pool_resource(const pool_options& opts) BOOST_NOEXCEPT; + + #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + pool_resource(const pool_resource&) = delete; + pool_resource operator=(const pool_resource&) = delete; + #else + private: + pool_resource (const pool_resource&); + pool_resource operator=(const pool_resource&); + public: + #endif + + //! Effects: Calls + //! `this->release()`. + virtual ~pool_resource(); + + //! Effects: Calls Calls `upstream_resource()->deallocate()` as necessary + //! to release all allocated memory. [ Note: memory is released back to + //! `upstream_resource()` even if deallocate has not been called for some + //! of the allocated blocks. - end note ] + void release(); + + //! Returns: The value of the upstream argument provided to the + //! constructor of this object. + memory_resource* upstream_resource() const; + + //! Returns: The options that control the pooling behavior of this resource. + //! The values in the returned struct may differ from those supplied to the pool + //! resource constructor in that values of zero will be replaced with + //! implementation-defined defaults and sizes may be rounded to unspecified granularity. + pool_options options() const; + + public: //public so that [un]synchronized_pool_resource can use them + + //! Returns: A pointer to allocated storage with a size of at least `bytes`. + //! The size and alignment of the allocated memory shall meet the requirements for + //! a class derived from `memory_resource`. + //! + //! Effects: If the pool selected for a block of size bytes is unable to + //! satisfy the memory request from its own internal data structures, it will call + //! `upstream_resource()->allocate()` to obtain more memory. If `bytes` is larger + //! than that which the largest pool can handle, then memory will be allocated + //! using `upstream_resource()->allocate()`. + //! + //! Throws: Nothing unless `upstream_resource()->allocate()` throws. + virtual void* do_allocate(std::size_t bytes, std::size_t alignment); + + //! Effects: Return the memory at p to the pool. It is unspecified if or under + //! what circumstances this operation will result in a call to + //! `upstream_resource()->deallocate()`. + //! + //! Throws: Nothing. + virtual void do_deallocate(void* p, std::size_t bytes, std::size_t alignment); + + //! Returns: + //! `this == dynamic_cast(&other)`. + virtual bool do_is_equal(const memory_resource& other) const BOOST_NOEXCEPT; + + //Non-standard observers + public: + //! Returns: The number of pools that will be used in the pool resource. + //! + //! Note: Non-standard extension. + std::size_t pool_count() const; + + //! Returns: The index of the pool that will be used to serve the allocation of `bytes`. + //! from the pool specified by `pool_index`. Returns `pool_count()` if `bytes` is bigger + //! than `options().largest_required_pool_block` (no pool will be used to serve this). + //! + //! Note: Non-standard extension. + std::size_t pool_index(std::size_t bytes) const; + + //! Requires: `pool_idx < pool_index()` + //! + //! Returns: The number blocks that will be allocated in the next chunk + //! from the pool specified by `pool_idx`. + //! + //! Note: Non-standard extension. + std::size_t pool_next_blocks_per_chunk(std::size_t pool_idx) const; + + //! Requires: `pool_idx < pool_index()` + //! + //! Returns: The number of bytes of the block that the specified `pool_idx` pool manages. + //! + //! Note: Non-standard extension. + std::size_t pool_block(std::size_t pool_idx) const; + + //! Requires: `pool_idx < pool_index()` + //! + //! Returns: The number of blocks that the specified `pool_idx` pool has cached + //! and will be served without calling the upstream_allocator. + //! + //! Note: Non-standard extension. + std::size_t pool_cached_blocks(std::size_t pool_idx) const; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#include + +#endif //BOOST_CONTAINER_POOL_RESOURCE_HPP diff --git a/boost/container/detail/std_fwd.hpp b/boost/container/detail/std_fwd.hpp index 1277df071f..09678123ff 100644 --- a/boost/container/detail/std_fwd.hpp +++ b/boost/container/detail/std_fwd.hpp @@ -23,26 +23,8 @@ // Standard predeclarations ////////////////////////////////////////////////////////////////////////////// -#if defined(_LIBCPP_VERSION) - #define BOOST_CONTAINER_CLANG_INLINE_STD_NS - #pragma GCC diagnostic push - #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 } -#endif - -BOOST_CONTAINER_STD_NS_BEG +#include +BOOST_MOVE_STD_NS_BEG template class allocator; @@ -66,11 +48,9 @@ class insert_iterator; struct allocator_arg_t; -BOOST_CONTAINER_STD_NS_END +struct piecewise_construct_t; -#ifdef BOOST_CONTAINER_CLANG_INLINE_STD_NS - #pragma GCC diagnostic pop - #undef BOOST_CONTAINER_CLANG_INLINE_STD_NS -#endif //BOOST_CONTAINER_CLANG_INLINE_STD_NS +BOOST_MOVE_STD_NS_END +#include #endif //#ifndef BOOST_CONTAINER_DETAIL_STD_FWD_HPP diff --git a/boost/container/detail/tree.hpp b/boost/container/detail/tree.hpp index c90202973a..c2d6b1d17d 100644 --- a/boost/container/detail/tree.hpp +++ b/boost/container/detail/tree.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// (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 http://www.boost.org/LICENSE_1_0.txt) // @@ -413,8 +413,11 @@ struct key_node_compare { return node.get_data(); } template - typename enable_if_c::value, const T &>::type - key_forward(const T &key) const + #if defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN) + const T &key_forward(const T &key, typename enable_if_c::value>::type* =0) const + #else + typename enable_if_c::value, const T &>::type key_forward(const T &key) const + #endif { return key; } template @@ -811,6 +814,7 @@ class tree std::pair insert_unique_check (const_iterator hint, const key_type& key, insert_commit_data &data) { + BOOST_ASSERT((priv_is_linked)(hint)); std::pair ret = this->icont().insert_unique_check(hint.get(), key, KeyNodeCompare(value_comp()), data); return std::pair(iterator(ret.first), ret.second); @@ -861,6 +865,15 @@ class tree private: + bool priv_is_linked(const_iterator const position) const + { + iiterator const cur(position.get()); + return cur == this->icont().end() || + cur == this->icont().root() || + iiterator(cur).go_parent().go_left() == cur || + iiterator(cur).go_parent().go_right() == cur; + } + template void push_back_impl(BOOST_FWD_REF(MovableConvertible) v) { @@ -888,6 +901,7 @@ class tree iterator emplace_unique_hint_impl(const_iterator hint, NodePtr p) { + BOOST_ASSERT((priv_is_linked)(hint)); value_type &v = p->get_data(); insert_commit_data data; std::pair ret = @@ -924,6 +938,7 @@ class tree template iterator emplace_hint_equal(const_iterator hint, BOOST_FWD_REF(Args)... args) { + BOOST_ASSERT((priv_is_linked)(hint)); 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)); @@ -955,6 +970,7 @@ class tree 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)\ {\ + BOOST_ASSERT((priv_is_linked)(hint));\ NodePtr tmp(AllocHolder::create_node(BOOST_MOVE_FWD##N));\ scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc());\ iterator ret(this->icont().insert_equal(hint.get(), *tmp));\ @@ -969,6 +985,7 @@ class tree iterator insert_unique(const_iterator hint, const value_type& v) { + BOOST_ASSERT((priv_is_linked)(hint)); insert_commit_data data; std::pair ret = this->insert_unique_check(hint, KeyOfValue()(v), data); @@ -980,6 +997,7 @@ class tree template iterator insert_unique(const_iterator hint, BOOST_FWD_REF(MovableConvertible) v) { + BOOST_ASSERT((priv_is_linked)(hint)); insert_commit_data data; std::pair ret = this->insert_unique_check(hint, KeyOfValue()(v), data); @@ -1016,6 +1034,7 @@ class tree iterator insert_equal(const_iterator hint, const value_type& v) { + BOOST_ASSERT((priv_is_linked)(hint)); NodePtr tmp(AllocHolder::create_node(v)); scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); iterator ret(this->icont().insert_equal(hint.get(), *tmp)); @@ -1026,6 +1045,7 @@ class tree template iterator insert_equal(const_iterator hint, BOOST_FWD_REF(MovableConvertible) v) { + BOOST_ASSERT((priv_is_linked)(hint)); NodePtr tmp(AllocHolder::create_node(boost::forward(v))); scoped_destroy_deallocator destroy_deallocator(tmp, this->node_alloc()); iterator ret(this->icont().insert_equal(hint.get(), *tmp)); @@ -1041,13 +1061,20 @@ class tree } iterator erase(const_iterator position) - { return iterator(this->icont().erase_and_dispose(position.get(), Destroyer(this->node_alloc()))); } + { + BOOST_ASSERT(position != this->cend() && (priv_is_linked)(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())); } + { + BOOST_ASSERT(first == last || (first != this->cend() && (priv_is_linked)(first))); + BOOST_ASSERT(first == last || (priv_is_linked)(last)); + return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); + } void clear() { AllocHolder::clear(alloc_version()); } diff --git a/boost/container/detail/type_traits.hpp b/boost/container/detail/type_traits.hpp index e02709ac6e..e1453a6594 100644 --- a/boost/container/detail/type_traits.hpp +++ b/boost/container/detail/type_traits.hpp @@ -30,6 +30,8 @@ namespace boost { namespace container { namespace container_detail { +using ::boost::move_detail::enable_if; +using ::boost::move_detail::enable_if_and; using ::boost::move_detail::is_same; using ::boost::move_detail::is_different; using ::boost::move_detail::is_pointer; diff --git a/boost/container/detail/variadic_templates_tools.hpp b/boost/container/detail/variadic_templates_tools.hpp index ec8b8ceef0..d8c8443038 100644 --- a/boost/container/detail/variadic_templates_tools.hpp +++ b/boost/container/detail/variadic_templates_tools.hpp @@ -54,7 +54,7 @@ class tuple // Construct tuple from another tuple. template tuple(const tuple& other) - : m_head(other.head()), inherited(other.tail()) + : inherited(other.tail()), m_head(other.head()) {} template diff --git a/boost/container/detail/workaround.hpp b/boost/container/detail/workaround.hpp index 026e65d6bb..e1f6156964 100644 --- a/boost/container/detail/workaround.hpp +++ b/boost/container/detail/workaround.hpp @@ -19,8 +19,6 @@ # pragma once #endif -#include - #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)\ && !defined(BOOST_INTERPROCESS_DISABLE_VARIADIC_TMPL) #define BOOST_CONTAINER_PERFECT_FORWARDING @@ -59,6 +57,23 @@ #define BOOST_CONTAINER_DOCIGN(T) T #define BOOST_CONTAINER_DOCONLY(T) -#include +/* + 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 BOOST_SYMBOL_EXPORT + #else + # define BOOST_CONTAINER_DECL BOOST_SYMBOL_IMPORT + + #endif /* BOOST_CONTAINER_SOURCE */ +#else + #define BOOST_CONTAINER_DECL +#endif /* DYN_LINK */ #endif //#ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP diff --git a/boost/container/flat_map.hpp b/boost/container/flat_map.hpp index ef0e1cb252..afd5a52d33 100644 --- a/boost/container/flat_map.hpp +++ b/boost/container/flat_map.hpp @@ -593,9 +593,12 @@ class flat_map //! //! Complexity: Logarithmic. mapped_type &operator[](key_type &&k) ; - + #elif defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN) + //in compilers like GCC 3.4, we can't catch temporaries + mapped_type& operator[](const key_type &k) { return this->priv_subscript(k); } + mapped_type& operator[](BOOST_RV_REF(key_type) k) { return this->priv_subscript(::boost::move(k)); } #else - BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript) + BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript) #endif //! @copydoc ::boost::container::flat_set::nth(size_type) @@ -958,7 +961,7 @@ class flat_map //! 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 + //! Complexity: Logarithmic. const_iterator find(const key_type& x) const { return container_detail::force_copy(m_flat_tree.find(x)); } @@ -971,40 +974,40 @@ class flat_map //! 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 + //! Complexity: Logarithmic. iterator lower_bound(const key_type& x) { return container_detail::force_copy(m_flat_tree.lower_bound(x)); } //! 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 + //! Complexity: Logarithmic. const_iterator lower_bound(const key_type& x) const { return container_detail::force_copy(m_flat_tree.lower_bound(x)); } //! 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 + //! Complexity: Logarithmic. iterator upper_bound(const key_type& x) { return container_detail::force_copy(m_flat_tree.upper_bound(x)); } //! 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 + //! Complexity: Logarithmic. const_iterator upper_bound(const key_type& x) const { return container_detail::force_copy(m_flat_tree.upper_bound(x)); } //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). //! - //! Complexity: Logarithmic + //! Complexity: Logarithmic. std::pair equal_range(const key_type& x) { return container_detail::force_copy >(m_flat_tree.lower_bound_range(x)); } //! Effects: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)). //! - //! Complexity: Logarithmic + //! Complexity: Logarithmic. std::pair equal_range(const key_type& x) const { return container_detail::force_copy >(m_flat_tree.lower_bound_range(x)); } diff --git a/boost/container/flat_set.hpp b/boost/container/flat_set.hpp index 8f592798d2..a99e70786a 100644 --- a/boost/container/flat_set.hpp +++ b/boost/container/flat_set.hpp @@ -968,17 +968,17 @@ class flat_multiset : base_t(static_cast(x)) {} - //! @copydoc ::boost::container::flat_set(flat_set &&) + //! @copydoc ::boost::container::flat_set::flat_set(flat_set &&) 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 &) + //! @copydoc ::boost::container::flat_set::flat_set(const flat_set &, const allocator_type &) flat_multiset(const flat_multiset& x, const allocator_type &a) : base_t(static_cast(x), a) {} - //! @copydoc ::boost::container::flat_set(flat_set &&, const allocator_type &) + //! @copydoc ::boost::container::flat_set::flat_set(flat_set &&, const allocator_type &) flat_multiset(BOOST_RV_REF(flat_multiset) x, const allocator_type &a) : base_t(BOOST_MOVE_BASE(base_t, x), a) {} diff --git a/boost/container/list.hpp b/boost/container/list.hpp index 5135eaecee..8236ff7939 100644 --- a/boost/container/list.hpp +++ b/boost/container/list.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// (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 http://www.boost.org/LICENSE_1_0.txt) // @@ -651,7 +651,10 @@ class list //! //! Complexity: Constant. reference front() BOOST_NOEXCEPT_OR_NOTHROW - { return *this->begin(); } + { + BOOST_ASSERT(!this->empty()); + return *this->begin(); + } //! Requires: !empty() //! @@ -662,7 +665,10 @@ class list //! //! Complexity: Constant. const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW - { return *this->begin(); } + { + BOOST_ASSERT(!this->empty()); + return *this->begin(); + } //! Requires: !empty() //! @@ -673,7 +679,10 @@ class list //! //! Complexity: Constant. reference back() BOOST_NOEXCEPT_OR_NOTHROW - { return *(--this->end()); } + { + BOOST_ASSERT(!this->empty()); + return *(--this->end()); + } //! Requires: !empty() //! @@ -684,7 +693,10 @@ class list //! //! Complexity: Constant. const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW - { return *(--this->end()); } + { + BOOST_ASSERT(!this->empty()); + return *(--this->end()); + } ////////////////////////////////////////////// // @@ -724,10 +736,11 @@ class list //! //! Complexity: Constant template - iterator emplace(const_iterator p, BOOST_FWD_REF(Args)... args) + iterator emplace(const_iterator position, BOOST_FWD_REF(Args)... args) { + BOOST_ASSERT((priv_is_linked)(position)); NodePtr pnode(AllocHolder::create_node(boost::forward(args)...)); - return iterator(this->icont().insert(p.get(), *pnode)); + return iterator(this->icont().insert(position.get(), *pnode)); } #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) @@ -742,10 +755,11 @@ class list { this->emplace(this->cbegin() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);}\ \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ - iterator emplace(const_iterator p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + iterator emplace(const_iterator position BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ {\ + BOOST_ASSERT(position == this->cend() || (--(++position) == position) );\ NodePtr pnode (AllocHolder::create_node(BOOST_MOVE_FWD##N));\ - return iterator(this->icont().insert(p.get(), *pnode));\ + return iterator(this->icont().insert(position.get(), *pnode));\ }\ // BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_LIST_EMPLACE_CODE) @@ -828,10 +842,11 @@ class list //! 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) + iterator insert(const_iterator position, size_type n, const T& x) { + //range check is done by insert typedef constant_iterator cvalue_iterator; - return this->insert(p, cvalue_iterator(x, n), cvalue_iterator()); + return this->insert(position, cvalue_iterator(x, n), cvalue_iterator()); } //! Requires: p must be a valid iterator of *this. @@ -856,6 +871,7 @@ class list #endif ) { + BOOST_ASSERT((priv_is_linked)(p)); const typename Icont::iterator ipos(p.get()); iterator ret_it(ipos); if(first != last){ @@ -870,7 +886,7 @@ class list #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) template - iterator insert(const_iterator p, FwdIt first, FwdIt last + iterator insert(const_iterator position, FwdIt first, FwdIt last , typename container_detail::enable_if_c < !container_detail::is_convertible::value && !(container_detail::is_input_iterator::value @@ -879,9 +895,10 @@ class list >::type * = 0 ) { + BOOST_ASSERT((priv_is_linked)(position)); //Optimized allocation and construction - insertion_functor func(this->icont(), p.get()); - iterator before_p(p.get()); + insertion_functor func(this->icont(), position.get()); + iterator before_p(position.get()); --before_p; this->allocate_many_and_construct(first, boost::container::iterator_distance(first, last), func); return ++before_p; @@ -900,7 +917,10 @@ class list //! //! Complexity: Linear to distance [il.begin(), il.end()). iterator insert(const_iterator p, std::initializer_list il) - { return insert(p, il.begin(), il.end()); } + { + //position range check is done by insert() + return insert(p, il.begin(), il.end()); + } #endif //! Effects: Removes the first element from the list. @@ -909,7 +929,10 @@ class list //! //! Complexity: Amortized constant time. void pop_front() BOOST_NOEXCEPT_OR_NOTHROW - { this->erase(this->cbegin()); } + { + BOOST_ASSERT(!this->empty()); + this->erase(this->cbegin()); + } //! Effects: Removes the last element from the list. //! @@ -917,7 +940,11 @@ class list //! //! Complexity: Amortized constant time. void pop_back() BOOST_NOEXCEPT_OR_NOTHROW - { const_iterator tmp = this->cend(); this->erase(--tmp); } + { + BOOST_ASSERT(!this->empty()); + const_iterator tmp = this->cend(); + this->erase(--tmp); + } //! Requires: p must be a valid iterator of *this. //! @@ -927,7 +954,10 @@ class list //! //! Complexity: Amortized constant time. iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW - { return iterator(this->icont().erase_and_dispose(p.get(), Destroyer(this->node_alloc()))); } + { + BOOST_ASSERT(p != this->cend() && (priv_is_linked)(p)); + 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. //! @@ -937,7 +967,11 @@ class list //! //! Complexity: Linear to the distance between first and last. iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW - { return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); } + { + BOOST_ASSERT(first == last || (first != this->cend() && (priv_is_linked)(first))); + BOOST_ASSERT(first == last || (priv_is_linked)(last)); + return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version())); + } //! Effects: Swaps the contents of *this and x. //! @@ -947,7 +981,12 @@ class list void swap(list& x) BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_swap::value || allocator_traits_type::is_always_equal::value) - { AllocHolder::swap(x); } + { + BOOST_ASSERT(allocator_traits_type::propagate_on_container_swap::value || + allocator_traits_type::is_always_equal::value || + this->get_stored_allocator() == x.get_stored_allocator()); + AllocHolder::swap(x); + } //! Effects: Erases all the elements of the list. //! @@ -977,6 +1016,7 @@ class list //! this list. Iterators of this list and all the references are not invalidated. void splice(const_iterator p, list& x) BOOST_NOEXCEPT_OR_NOTHROW { + BOOST_ASSERT((priv_is_linked)(p)); BOOST_ASSERT(this != &x); BOOST_ASSERT(this->node_alloc() == x.node_alloc()); this->icont().splice(p.get(), x.icont()); @@ -995,7 +1035,10 @@ class list //! 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_NOEXCEPT_OR_NOTHROW - { this->splice(p, static_cast(x)); } + { + //Checks done in splice + 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. @@ -1013,7 +1056,7 @@ class list //! list. Iterators of this list and all the references are not invalidated. void splice(const_iterator p, list &x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW { - //BOOST_ASSERT(this != &x); + BOOST_ASSERT((priv_is_linked)(p)); BOOST_ASSERT(this->node_alloc() == x.node_alloc()); this->icont().splice(p.get(), x.icont(), i.get()); } @@ -1033,7 +1076,11 @@ class list //! 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_NOEXCEPT_OR_NOTHROW - { this->splice(p, static_cast(x), i); } + { + BOOST_ASSERT(this != &x); + //Additional checks done in splice() + 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. @@ -1050,6 +1097,9 @@ class list //! 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_NOEXCEPT_OR_NOTHROW { + BOOST_ASSERT((priv_is_linked)(p)); + BOOST_ASSERT(first == last || (first != x.cend() && x.priv_is_linked(first))); + BOOST_ASSERT(first == last || x.priv_is_linked(last)); BOOST_ASSERT(this->node_alloc() == x.node_alloc()); this->icont().splice(p.get(), x.icont(), first.get(), last.get()); } @@ -1068,7 +1118,11 @@ class list //! 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_NOEXCEPT_OR_NOTHROW - { this->splice(p, static_cast(x), first, last); } + { + BOOST_ASSERT(this != &x); + //Additional checks done in splice() + 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. @@ -1318,6 +1372,13 @@ class list #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: + static bool priv_is_linked(const_iterator const position) + { + const_iterator cur(position); + //This list is circular including end nodes + return (--(++cur)) == position && (++(--cur)) == position; + } + bool priv_try_shrink(size_type new_size) { const size_type len = this->size(); @@ -1348,12 +1409,14 @@ class list iterator priv_insert(const_iterator p, const T &x) { + BOOST_ASSERT((priv_is_linked)(p)); 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) { + BOOST_ASSERT((priv_is_linked)(p)); NodePtr tmp = AllocHolder::create_node(boost::move(x)); return iterator(this->icont().insert(p.get(), *tmp)); } diff --git a/boost/container/map.hpp b/boost/container/map.hpp index 4dc6096e1e..8173181221 100644 --- a/boost/container/map.hpp +++ b/boost/container/map.hpp @@ -481,8 +481,12 @@ class map //! //! Complexity: Logarithmic. mapped_type& operator[](key_type &&k); + #elif defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN) + //in compilers like GCC 3.4, we can't catch temporaries + mapped_type& operator[](const key_type &k) { return this->priv_subscript(k); } + mapped_type& operator[](BOOST_RV_REF(key_type) k) { return this->priv_subscript(::boost::move(k)); } #else - BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript) + BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&, this->priv_subscript) #endif //! Returns: A reference to the element whose key is equivalent to x. diff --git a/boost/container/new_allocator.hpp b/boost/container/new_allocator.hpp index 1ac15d8a25..6a1d8c76e3 100644 --- a/boost/container/new_allocator.hpp +++ b/boost/container/new_allocator.hpp @@ -29,6 +29,8 @@ namespace boost { namespace container { +/// @cond + template struct new_allocator_bool { static const bool value = Value; }; @@ -36,6 +38,8 @@ struct new_allocator_bool template class new_allocator; +/// @endcond + //! Specialization of new_allocator for void types template<> class new_allocator diff --git a/boost/container/node_allocator.hpp b/boost/container/node_allocator.hpp index c3d809078f..d92577e741 100644 --- a/boost/container/node_allocator.hpp +++ b/boost/container/node_allocator.hpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include @@ -157,7 +157,7 @@ class node_allocator return pointer(static_cast(singleton_t::instance().allocate_node())); } else{ - void *ret = boost_cont_malloc(count*sizeof(T)); + void *ret = dlmalloc_malloc(count*sizeof(T)); if(BOOST_UNLIKELY(!ret)) boost::container::throw_bad_alloc(); return static_cast(ret); @@ -176,7 +176,7 @@ class node_allocator singleton_t::instance().deallocate_node(ptr); } else{ - boost_cont_free(ptr); + dlmalloc_free(ptr); } } @@ -204,7 +204,7 @@ class node_allocator size_type size(pointer p) const BOOST_NOEXCEPT_OR_NOTHROW { BOOST_STATIC_ASSERT(( Version > 1 )); - return boost_cont_size(p); + return dlmalloc_size(p); } //!Allocates just one object. Memory allocated with this function @@ -259,9 +259,9 @@ class node_allocator void allocate_many(size_type elem_size, std::size_t n_elements, multiallocation_chain &chain) { BOOST_STATIC_ASSERT(( Version > 1 )); - boost_cont_memchain ch; + dlmalloc_memchain ch; BOOST_CONTAINER_MEMCHAIN_INIT(&ch); - if(BOOST_UNLIKELY(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch))){ + if(BOOST_UNLIKELY(!dlmalloc_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch))){ boost::container::throw_bad_alloc(); } chain.incorporate_after( chain.before_begin() @@ -275,8 +275,8 @@ class node_allocator 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); + dlmalloc_memchain ch; + dlmalloc_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch); if(BOOST_UNLIKELY(BOOST_CONTAINER_MEMCHAIN_EMPTY(&ch))){ boost::container::throw_bad_alloc(); } @@ -292,9 +292,9 @@ class node_allocator void *first = &*chain.begin(); void *last = &*chain.last(); size_t num = chain.size(); - boost_cont_memchain ch; + dlmalloc_memchain ch; BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&ch, first, last, num); - boost_cont_multidealloc(&ch); + dlmalloc_multidealloc(&ch); } //!Swaps allocators. Does not throw. If each allocator is placed in a @@ -319,7 +319,7 @@ class node_allocator ,pointer &reuse) { std::size_t const preferred_size = prefer_in_recvd_out_size; - boost_cont_command_ret_t ret = {0 , 0}; + dlmalloc_command_ret_t ret = {0 , 0}; if((limit_size > this->max_size()) | (preferred_size > this->max_size())){ return pointer(); } @@ -328,7 +328,7 @@ class node_allocator std::size_t r_size; { void* reuse_ptr_void = reuse; - ret = boost_cont_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr_void); + ret = dlmalloc_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr_void); reuse = static_cast(reuse_ptr_void); } prefer_in_recvd_out_size = r_size/sizeof(T); diff --git a/boost/container/pmr/deque.hpp b/boost/container/pmr/deque.hpp new file mode 100644 index 0000000000..744758606c --- /dev/null +++ b/boost/container/pmr/deque.hpp @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_DEQUE_HPP +#define BOOST_CONTAINER_PMR_DEQUE_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template +using deque = boost::container::deque>; + +#endif + +template +struct deque_of +{ + typedef boost::container::deque + < T, polymorphic_allocator > type; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_DEQUE_HPP diff --git a/boost/container/pmr/flat_map.hpp b/boost/container/pmr/flat_map.hpp new file mode 100644 index 0000000000..786c190b05 --- /dev/null +++ b/boost/container/pmr/flat_map.hpp @@ -0,0 +1,63 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_FLAT_MAP_HPP +#define BOOST_CONTAINER_PMR_FLAT_MAP_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template + ,class Options = tree_assoc_defaults > +using flat_map = boost::container::flat_map > >; + +template + ,class Options = tree_assoc_defaults > +using flat_multimap = boost::container::flat_multimap > >; + +#endif + +template + ,class Options = tree_assoc_defaults > +struct flat_map_of +{ + typedef boost::container::flat_map > > type; +}; + +template + ,class Options = tree_assoc_defaults > +struct flat_multimap_of +{ + typedef boost::container::flat_multimap > > type; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_FLAT_MAP_HPP diff --git a/boost/container/pmr/flat_set.hpp b/boost/container/pmr/flat_set.hpp new file mode 100644 index 0000000000..5c3ad1e09e --- /dev/null +++ b/boost/container/pmr/flat_set.hpp @@ -0,0 +1,59 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_SET_HPP +#define BOOST_CONTAINER_PMR_SET_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template + ,class Options = tree_assoc_defaults > +using flat_set = boost::container::flat_set >; + +template + ,class Options = tree_assoc_defaults > +using flat_multiset = boost::container::flat_multiset >; + +#endif + +template + ,class Options = tree_assoc_defaults > +struct flat_set_of +{ + typedef boost::container::flat_set > type; +}; + +template + ,class Options = tree_assoc_defaults > +struct flat_multiset_of +{ + typedef boost::container::flat_multiset > type; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_SET_HPP diff --git a/boost/container/pmr/global_resource.hpp b/boost/container/pmr/global_resource.hpp new file mode 100644 index 0000000000..219309b072 --- /dev/null +++ b/boost/container/pmr/global_resource.hpp @@ -0,0 +1,66 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_GLOBAL_RESOURCE_HPP +#define BOOST_CONTAINER_PMR_GLOBAL_RESOURCE_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include +#include + +#include + +namespace boost { +namespace container { +namespace pmr { + +/// @cond +class memory_resource; +/// @endcond + +//! Returns: A pointer to a static-duration object of a type derived from +//! memory_resource that can serve as a resource for allocating memory using +//! global `operator new` and global `operator delete`. The same value is returned every time this function +//! is called. For return value p and memory resource r, p->is_equal(r) returns &r == p. +BOOST_CONTAINER_DECL memory_resource* new_delete_resource() BOOST_NOEXCEPT; + +//! Returns: A pointer to a static-duration object of a type derived from +//! memory_resource for which allocate() always throws bad_alloc and for which +//! deallocate() has no effect. The same value is returned every time this function +//! is called. For return value p and memory resource r, p->is_equal(r) returns &r == p. +BOOST_CONTAINER_DECL memory_resource* null_memory_resource() BOOST_NOEXCEPT; + +//! Effects: If r is non-null, sets the value of the default memory resource +//! pointer to r, otherwise sets the default memory resource pointer to new_delete_resource(). +//! +//! Postconditions: get_default_resource() == r. +//! +//! Returns: The previous value of the default memory resource pointer. +//! +//! Remarks: Calling the set_default_resource and get_default_resource functions shall +//! not incur a data race. A call to the set_default_resource function shall synchronize +//! with subsequent calls to the set_default_resource and get_default_resource functions. +BOOST_CONTAINER_DECL memory_resource* set_default_resource(memory_resource* r) BOOST_NOEXCEPT; + +//! Returns: The current value of the default +//! memory resource pointer. +BOOST_CONTAINER_DECL memory_resource* get_default_resource() BOOST_NOEXCEPT; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#include + +#endif //BOOST_CONTAINER_PMR_GLOBAL_RESOURCE_HPP diff --git a/boost/container/pmr/list.hpp b/boost/container/pmr/list.hpp new file mode 100644 index 0000000000..5967f452be --- /dev/null +++ b/boost/container/pmr/list.hpp @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_LIST_HPP +#define BOOST_CONTAINER_PMR_LIST_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template +using list = boost::container::list>; + +#endif + +template +struct list_of +{ + typedef boost::container::list + < T, polymorphic_allocator > type; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_VECTOR_HPP diff --git a/boost/container/pmr/map.hpp b/boost/container/pmr/map.hpp new file mode 100644 index 0000000000..fdada0e420 --- /dev/null +++ b/boost/container/pmr/map.hpp @@ -0,0 +1,63 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_MAP_HPP +#define BOOST_CONTAINER_PMR_MAP_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template + ,class Options = tree_assoc_defaults > +using map = boost::container::map >, Options>; + +template + ,class Options = tree_assoc_defaults > +using multimap = boost::container::multimap >, Options>; + +#endif + +template + ,class Options = tree_assoc_defaults > +struct map_of +{ + typedef boost::container::map >, Options> type; +}; + +template + ,class Options = tree_assoc_defaults > +struct multimap_of +{ + typedef boost::container::multimap >, Options> type; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_MAP_HPP diff --git a/boost/container/pmr/memory_resource.hpp b/boost/container/pmr/memory_resource.hpp new file mode 100644 index 0000000000..72338a7559 --- /dev/null +++ b/boost/container/pmr/memory_resource.hpp @@ -0,0 +1,101 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_MEMORY_RESOURCE_HPP +#define BOOST_CONTAINER_PMR_MEMORY_RESOURCE_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +//! The memory_resource class is an abstract interface to an +//! unbounded set of classes encapsulating memory resources. +class memory_resource +{ + public: + // For exposition only + static BOOST_CONSTEXPR_OR_CONST std::size_t max_align = + boost::move_detail::alignment_of::value; + + //! Effects: Destroys + //! this memory_resource. + virtual ~memory_resource(){} + + //! Effects: Equivalent to + //! `return do_allocate(bytes, alignment);` + void* allocate(std::size_t bytes, std::size_t alignment = max_align) + { return this->do_allocate(bytes, alignment); } + + //! Effects: Equivalent to + //! `return do_deallocate(bytes, alignment);` + void deallocate(void* p, std::size_t bytes, std::size_t alignment = max_align) + { return this->do_deallocate(p, bytes, alignment); } + + //! Effects: Equivalent to + //! `return return do_is_equal(other);` + bool is_equal(const memory_resource& other) const BOOST_NOEXCEPT + { return this->do_is_equal(other); } + + //! Returns: + //! `&a == &b || a.is_equal(b)`. + friend bool operator==(const memory_resource& a, const memory_resource& b) BOOST_NOEXCEPT + { return &a == &b || a.is_equal(b); } + + //! Returns: + //! !(a == b). + friend bool operator!=(const memory_resource& a, const memory_resource& b) BOOST_NOEXCEPT + { return !(a == b); } + + protected: + //! Requires: Alignment shall be a power of two. + //! + //! Returns: A derived class shall implement this function to return a pointer + //! to allocated storage with a size of at least bytes. The returned storage is + //! aligned to the specified alignment, if such alignment is supported; otherwise + //! it is aligned to max_align. + //! + //! Throws: A derived class implementation shall throw an appropriate exception if + //! it is unable to allocate memory with the requested size and alignment. + virtual void* do_allocate(std::size_t bytes, std::size_t alignment) = 0; + + //! Requires: p shall have been returned from a prior call to + //! `allocate(bytes, alignment)` on a memory resource equal to *this, and the storage + //! at p shall not yet have been deallocated. + //! + //! Effects: A derived class shall implement this function to dispose of allocated storage. + //! + //! Throws: Nothing. + virtual void do_deallocate(void* p, std::size_t bytes, std::size_t alignment) = 0; + + //! Returns: A derived class shall implement this function to return true if memory + //! allocated from this can be deallocated from other and vice-versa; otherwise it shall + //! return false. [Note: The most-derived type of other might not match the type of this. + //! For a derived class, D, a typical implementation of this function will compute + //! `dynamic_cast(&other)` and go no further (i.e., return false) + //! if it returns nullptr. - end note]. + virtual bool do_is_equal(const memory_resource& other) const BOOST_NOEXCEPT = 0; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#include + +#endif //BOOST_CONTAINER_PMR_MEMORY_RESOURCE_HPP diff --git a/boost/container/pmr/monotonic_buffer_resource.hpp b/boost/container/pmr/monotonic_buffer_resource.hpp new file mode 100644 index 0000000000..dfffe87dc3 --- /dev/null +++ b/boost/container/pmr/monotonic_buffer_resource.hpp @@ -0,0 +1,180 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_MONOTONIC_BUFFER_RESOURCE_HPP +#define BOOST_CONTAINER_PMR_MONOTONIC_BUFFER_RESOURCE_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace container { +namespace pmr { + +//! A monotonic_buffer_resource is a special-purpose memory resource intended for +//! very fast memory allocations in situations where memory is used to build up a +//! few objects and then is released all at once when the memory resource object +//! is destroyed. It has the following qualities: +//! +//! - A call to deallocate has no effect, thus the amount of memory consumed +//! increases monotonically until the resource is destroyed. +//! +//! - The program can supply an initial buffer, which the allocator uses to satisfy +//! memory requests. +//! +//! - When the initial buffer (if any) is exhausted, it obtains additional buffers +//! from an upstream memory resource supplied at construction. Each additional +//! buffer is larger than the previous one, following a geometric progression. +//! +//! - It is intended for access from one thread of control at a time. Specifically, +//! calls to allocate and deallocate do not synchronize with one another. +//! +//! - It owns the allocated memory and frees it on destruction, even if deallocate has +//! not been called for some of the allocated blocks. +class BOOST_CONTAINER_DECL monotonic_buffer_resource + : public memory_resource +{ + block_slist m_memory_blocks; + void* m_current_buffer; + std::size_t m_current_buffer_size; + std::size_t m_next_buffer_size; + + /// @cond + void increase_next_buffer(); + void increase_next_buffer_at_least_to(std::size_t minimum_size); + void *allocate_from_current(std::size_t aligner, std::size_t bytes); + /// @endcond + + public: + + //! The number of bytes that will be requested by the default in the first call + //! to the upstream allocator + //! + //! Note: Non-standard extension. + static const std::size_t initial_next_buffer_size = 32u*sizeof(void*); + + //! Requires: `upstream` shall be the address of a valid memory resource or `nullptr` + //! + //! Effects: If `upstream` is not nullptr, sets the internal resource to `upstream`, + //! to get_default_resource() otherwise. + //! Sets the internal `current_buffer` to `nullptr` and the internal `next_buffer_size` to an + //! implementation-defined size. + explicit monotonic_buffer_resource(memory_resource* upstream = 0) BOOST_NOEXCEPT; + + //! Requires: `upstream` shall be the address of a valid memory resource or `nullptr` + //! and `initial_size` shall be greater than zero. + //! + //! Effects: If `upstream` is not nullptr, sets the internal resource to `upstream`, + //! to get_default_resource() otherwise. Sets the internal `current_buffer` to `nullptr` and + //! `next_buffer_size` to at least `initial_size`. + explicit monotonic_buffer_resource(std::size_t initial_size, memory_resource* upstream = 0) BOOST_NOEXCEPT; + + //! Requires: `upstream` shall be the address of a valid memory resource or `nullptr`, + //! `buffer_size` shall be no larger than the number of bytes in buffer. + //! + //! Effects: If `upstream` is not nullptr, sets the internal resource to `upstream`, + //! to get_default_resource() otherwise. Sets the internal `current_buffer` to `buffer`, + //! and `next_buffer_size` to `buffer_size` (but not less than an implementation-defined size), + //! then increases `next_buffer_size` by an implementation-defined growth factor (which need not be integral). + monotonic_buffer_resource(void* buffer, std::size_t buffer_size, memory_resource* upstream = 0) BOOST_NOEXCEPT; + + #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + monotonic_buffer_resource(const monotonic_buffer_resource&) = delete; + monotonic_buffer_resource operator=(const monotonic_buffer_resource&) = delete; + #else + private: + monotonic_buffer_resource (const monotonic_buffer_resource&); + monotonic_buffer_resource operator=(const monotonic_buffer_resource&); + public: + #endif + + //! Effects: Calls + //! `this->release()`. + virtual ~monotonic_buffer_resource(); + + //! Effects: `upstream_resource()->deallocate()` as necessary to release all allocated memory. + //! [Note: memory is released back to `upstream_resource()` even if some blocks that were allocated + //! from this have not been deallocated from this. - end note] + void release() BOOST_NOEXCEPT; + + //! Returns: The value of + //! the internal resource. + memory_resource* upstream_resource() const BOOST_NOEXCEPT; + + //! Returns: + //! The number of bytes of storage available for the specified alignment and + //! the number of bytes wasted due to the requested alignment. + //! + //! Note: Non-standard extension. + std::size_t remaining_storage(std::size_t alignment, std::size_t &wasted_due_to_alignment) const BOOST_NOEXCEPT; + + //! Returns: + //! The number of bytes of storage available for the specified alignment. + //! + //! Note: Non-standard extension. + std::size_t remaining_storage(std::size_t alignment = 1u) const BOOST_NOEXCEPT; + + //! Returns: + //! The number of bytes of storage available for the specified alignment. + //! + //! Note: Non-standard extension. + const void *current_buffer() const BOOST_NOEXCEPT; + + //! Returns: + //! The number of bytes that will be requested for the next buffer once the + //! current one is exhausted. + //! + //! Note: Non-standard extension. + std::size_t next_buffer_size() const BOOST_NOEXCEPT; + + protected: + + //! Returns: A pointer to allocated storage with a size of at least `bytes`. The size + //! and alignment of the allocated memory shall meet the requirements for a class derived + //! from `memory_resource`. + //! + //! Effects: If the unused space in the internal `current_buffer` can fit a block with the specified + //! bytes and alignment, then allocate the return block from the internal `current_buffer`; otherwise sets + //! the internal `current_buffer` to `upstream_resource()->allocate(n, m)`, where `n` is not less than + //! `max(bytes, next_buffer_size)` and `m` is not less than alignment, and increase + //! `next_buffer_size` by an implementation-defined growth factor (which need not be integral), + //! then allocate the return block from the newly-allocated internal `current_buffer`. + //! + //! Throws: Nothing unless `upstream_resource()->allocate()` throws. + virtual void* do_allocate(std::size_t bytes, std::size_t alignment); + + //! Effects: None + //! + //! Throws: Nothing + //! + //! Remarks: Memory used by this resource increases monotonically until its destruction. + virtual void do_deallocate(void* p, std::size_t bytes, std::size_t alignment) BOOST_NOEXCEPT; + + //! Returns: + //! `this == dynamic_cast(&other)`. + virtual bool do_is_equal(const memory_resource& other) const BOOST_NOEXCEPT; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#include + +#endif //BOOST_CONTAINER_PMR_MONOTONIC_BUFFER_RESOURCE_HPP diff --git a/boost/container/pmr/polymorphic_allocator.hpp b/boost/container/pmr/polymorphic_allocator.hpp new file mode 100644 index 0000000000..d189b3a311 --- /dev/null +++ b/boost/container/pmr/polymorphic_allocator.hpp @@ -0,0 +1,166 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_POLYMORPHIC_ALLOCATOR_HPP +#define BOOST_CONTAINER_PMR_POLYMORPHIC_ALLOCATOR_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace container { +namespace pmr { + +//! A specialization of class template `polymorphic_allocator` conforms to the Allocator requirements. +//! Constructed with different memory resources, different instances of the same specialization of +//! `polymorphic_allocator` can exhibit entirely different allocation behavior. This runtime +//! polymorphism allows objects that use polymorphic_allocator to behave as if they used different +//! allocator types at run time even though they use the same static allocator type. +template +class polymorphic_allocator +{ + public: + typedef T value_type; + + //! Effects: Sets m_resource to + //! `get_default_resource()`. + polymorphic_allocator() BOOST_NOEXCEPT + : m_resource(::boost::container::pmr::get_default_resource()) + {} + + //! Requires: r is non-null. + //! + //! Effects: Sets m_resource to r. + //! + //! Throws: Nothing + //! + //! Notes: This constructor provides an implicit conversion from memory_resource*. + //! Non-standard extension: if r is null m_resource is set to get_default_resource(). + polymorphic_allocator(memory_resource* r) + : m_resource(r ? r : ::boost::container::pmr::get_default_resource()) + {} + + //! Effects: Sets m_resource to + //! other.resource(). + polymorphic_allocator(const polymorphic_allocator& other) + : m_resource(other.m_resource) + {} + + //! Effects: Sets m_resource to + //! other.resource(). + template + polymorphic_allocator(const polymorphic_allocator& other) BOOST_NOEXCEPT + : m_resource(other.resource()) + {} + + //! Effects: Sets m_resource to + //! other.resource(). + polymorphic_allocator& operator=(const polymorphic_allocator& other) + { m_resource = other.m_resource; return *this; } + + //! Returns: Equivalent to + //! `static_cast(m_resource->allocate(n * sizeof(T), alignof(T)))`. + T* allocate(size_t n) + { return static_cast(m_resource->allocate(n*sizeof(T), ::boost::move_detail::alignment_of::value)); } + + //! Requires: p was allocated from a memory resource, x, equal to *m_resource, + //! using `x.allocate(n * sizeof(T), alignof(T))`. + //! + //! Effects: Equivalent to m_resource->deallocate(p, n * sizeof(T), alignof(T)). + //! + //! Throws: Nothing. + void deallocate(T* p, size_t n) + { m_resource->deallocate(p, n*sizeof(T), ::boost::move_detail::alignment_of::value); } + + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! Requires: Uses-allocator construction of T with allocator + //! `this->resource()` and constructor arguments `std::forward(args)...` + //! is well-formed. [Note: uses-allocator construction is always well formed for + //! types that do not use allocators. - end note] + //! + //! Effects: Construct a T object at p by uses-allocator construction with allocator + //! `this->resource()` and constructor arguments `std::forward(args)...`. + //! + //! Throws: Nothing unless the constructor for T throws. + template < typename U, class ...Args> + void construct(U* p, BOOST_FWD_REF(Args)...args) + { + new_allocator na; + container_detail::dispatch_uses_allocator + (na, this->resource(), 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_CONTAINER_PMR_POLYMORPHIC_ALLOCATOR_CONSTRUCT_CODE(N) \ + template < typename U BOOST_MOVE_I##N BOOST_MOVE_CLASSQ##N >\ + void construct(U* p BOOST_MOVE_I##N BOOST_MOVE_UREFQ##N)\ + {\ + new_allocator na;\ + container_detail::dispatch_uses_allocator\ + (na, this->resource(), p BOOST_MOVE_I##N BOOST_MOVE_FWDQ##N);\ + }\ + // + BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_PMR_POLYMORPHIC_ALLOCATOR_CONSTRUCT_CODE) + #undef BOOST_CONTAINER_PMR_POLYMORPHIC_ALLOCATOR_CONSTRUCT_CODE + + #endif //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + + //! Effects: + //! p->~U(). + template + void destroy(U* p) + { (void)p; p->~U(); } + + //! Returns: Equivalent to + //! `polymorphic_allocator()`. + polymorphic_allocator select_on_container_copy_construction() const + { return polymorphic_allocator(); } + + //! Returns: + //! m_resource. + memory_resource* resource() const + { return m_resource; } + + private: + memory_resource* m_resource; +}; + +//! Returns: +//! `*a.resource() == *b.resource()`. +template +bool operator==(const polymorphic_allocator& a, const polymorphic_allocator& b) BOOST_NOEXCEPT +{ return *a.resource() == *b.resource(); } + + +//! Returns: +//! `! (a == b)`. +template +bool operator!=(const polymorphic_allocator& a, const polymorphic_allocator& b) BOOST_NOEXCEPT +{ return *a.resource() != *b.resource(); } + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_POLYMORPHIC_ALLOCATOR_HPP diff --git a/boost/container/pmr/pool_options.hpp b/boost/container/pmr/pool_options.hpp new file mode 100644 index 0000000000..e9f72896b1 --- /dev/null +++ b/boost/container/pmr/pool_options.hpp @@ -0,0 +1,52 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_POOL_OPTIONS_HPP +#define BOOST_CONTAINER_PMR_POOL_OPTIONS_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include + +namespace boost { +namespace container { +namespace pmr { + +//! The members of pool_options comprise a set of constructor options for pool resources. +//! The effect of each option on the pool resource behavior is described below: +//! +//! - `std::size_t max_blocks_per_chunk`: The maximum number of blocks that will be allocated +//! at once from the upstream memory resource to replenish a pool. If the value of +//! `max_blocks_per_chunk` is zero or is greater than an implementation-defined limit, +//! that limit is used instead. The implementation may choose to use a smaller value +//! than is specified in this field and may use different values for different pools. +//! +//! - `std::size_t largest_required_pool_block`: The largest allocation size that is required +//! to be fulfilled using the pooling mechanism. Attempts to allocate a single block +//! larger than this threshold will be allocated directly from the upstream memory +//! resource. If largest_required_pool_block is zero or is greater than an +//! implementation-defined limit, that limit is used instead. The implementation may +//! choose a pass-through threshold larger than specified in this field. +struct pool_options +{ + pool_options() + : max_blocks_per_chunk(0u), largest_required_pool_block(0u) + {} + std::size_t max_blocks_per_chunk; + std::size_t largest_required_pool_block; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_POOL_OPTIONS_HPP diff --git a/boost/container/pmr/resource_adaptor.hpp b/boost/container/pmr/resource_adaptor.hpp new file mode 100644 index 0000000000..deece632e8 --- /dev/null +++ b/boost/container/pmr/resource_adaptor.hpp @@ -0,0 +1,193 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_RESOURCE_ADAPTOR_HPP +#define BOOST_CONTAINER_PMR_RESOURCE_ADAPTOR_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include +#include +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +//! An instance of resource_adaptor is an adaptor that wraps a memory_resource interface +//! around Allocator. In order that resource_adaptor> and resource_adaptor> are the same +//! type for any allocator template X and types T and U, resource_adaptor is rendered as +//! an alias to this class template such that Allocator is rebound to a char value type in every +//! specialization of the class template. The requirements on this class template are defined below. +//! In addition to the Allocator requirements, the parameter to resource_adaptor shall meet +//! the following additional requirements: +//! +//! - `typename allocator_traits:: pointer` shall be identical to +//! `typename allocator_traits:: value_type*`. +//! +//! - `typename allocator_traits:: const_pointer` shall be identical to +//! `typename allocator_traits:: value_type const*`. +//! +//! - `typename allocator_traits:: void_pointer` shall be identical to `void*`. +//! +//! - `typename allocator_traits:: const_void_pointer` shall be identical to `void const*`. +template +class resource_adaptor_imp + : public memory_resource + #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + , private ::boost::intrusive::detail::ebo_functor_holder + #endif +{ + #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED + Allocator m_alloc; + #else + BOOST_COPYABLE_AND_MOVABLE(resource_adaptor_imp) + typedef ::boost::intrusive::detail::ebo_functor_holder ebo_alloc_t; + void static_assert_if_not_char_allocator() const + { + //This class can only be used with allocators type char + BOOST_STATIC_ASSERT((container_detail::is_same::value)); + } + #endif + + public: + typedef Allocator allocator_type; + + //! Effects: Default constructs + //! m_alloc. + resource_adaptor_imp() + { this->static_assert_if_not_char_allocator(); } + + //! Effects: Copy constructs + //! m_alloc. + resource_adaptor_imp(const resource_adaptor_imp &other) + : ebo_alloc_t(other.ebo_alloc_t::get()) + {} + + //! Effects: Move constructs + //! m_alloc. + resource_adaptor_imp(BOOST_RV_REF(resource_adaptor_imp) other) + : ebo_alloc_t(::boost::move(other.get())) + {} + + //! Effects: Initializes m_alloc with + //! a2. + explicit resource_adaptor_imp(const Allocator& a2) + : ebo_alloc_t(a2) + { this->static_assert_if_not_char_allocator(); } + + //! Effects: Initializes m_alloc with + //! a2. + explicit resource_adaptor_imp(BOOST_RV_REF(Allocator) a2) + : ebo_alloc_t(::boost::move(a2)) + { this->static_assert_if_not_char_allocator(); } + + //! Effects: Copy assigns + //! m_alloc. + resource_adaptor_imp& operator=(BOOST_COPY_ASSIGN_REF(resource_adaptor_imp) other) + { this->ebo_alloc_t::get() = other.ebo_alloc_t::get(); return *this; } + + //! Effects: Move assigns + //! m_alloc. + resource_adaptor_imp& operator=(BOOST_RV_REF(resource_adaptor_imp) other) + { this->ebo_alloc_t::get() = ::boost::move(other.ebo_alloc_t::get()); return *this; } + + //! Effects: Returns m_alloc. + allocator_type &get_allocator() + { return this->ebo_alloc_t::get(); } + + //! Effects: Returns m_alloc. + const allocator_type &get_allocator() const + { return this->ebo_alloc_t::get(); } + + protected: + //! Returns: Allocated memory obtained by calling m_alloc.allocate. The size and alignment + //! of the allocated memory shall meet the requirements for a class derived from memory_resource. + virtual void* do_allocate(size_t bytes, size_t alignment) + { (void)alignment; return this->ebo_alloc_t::get().allocate(bytes); } + + //! Requires: p was previously allocated using A.allocate, where A == m_alloc, and not + //! subsequently deallocated. + //! + //! Effects: Returns memory to the allocator using m_alloc.deallocate(). + virtual void do_deallocate(void* p, size_t bytes, size_t alignment) + { (void)alignment; this->ebo_alloc_t::get().deallocate((char*)p, bytes); } + + //! Let p be dynamic_cast(&other). + //! + //! Returns: false if p is null, otherwise the value of m_alloc == p->m_alloc. + virtual bool do_is_equal(const memory_resource& other) const BOOST_NOEXCEPT + { + const resource_adaptor_imp* p = dynamic_cast(&other); + return p && p->ebo_alloc_t::get() == this->ebo_alloc_t::get(); + } +}; + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + +//! `resource_adaptor` is rendered as an alias to resource_adaptor_imp class template +//! such that Allocator is rebound to a char value type. +template +using resource_adaptor = resource_adaptor_imp + ::template rebind_alloc >; + +#else + +template +class resource_adaptor + : public resource_adaptor_imp + ::template portable_rebind_alloc::type> +{ + typedef resource_adaptor_imp + ::template portable_rebind_alloc::type> base_t; + + BOOST_COPYABLE_AND_MOVABLE(resource_adaptor) + + public: + resource_adaptor() + : base_t() + {} + + resource_adaptor(const resource_adaptor &other) + : base_t(other) + {} + + resource_adaptor(BOOST_RV_REF(resource_adaptor) other) + : base_t(BOOST_MOVE_BASE(base_t, other)) + {} + + explicit resource_adaptor(const Allocator& a2) + : base_t(a2) + {} + + explicit resource_adaptor(BOOST_RV_REF(Allocator) a2) + : base_t(BOOST_MOVE_BASE(base_t, a2)) + {} + + resource_adaptor& operator=(BOOST_COPY_ASSIGN_REF(resource_adaptor) other) + { return static_cast(this->base_t::operator=(other)); } + + resource_adaptor& operator=(BOOST_RV_REF(resource_adaptor) other) + { return static_cast(this->base_t::operator=(BOOST_MOVE_BASE(base_t, other))); } + + //get_allocator and protected functions are properly inherited +}; + +#endif + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_RESOURCE_ADAPTOR_HPP diff --git a/boost/container/pmr/set.hpp b/boost/container/pmr/set.hpp new file mode 100644 index 0000000000..6f2c3bfb29 --- /dev/null +++ b/boost/container/pmr/set.hpp @@ -0,0 +1,59 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_SET_HPP +#define BOOST_CONTAINER_PMR_SET_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template + ,class Options = tree_assoc_defaults > +using set = boost::container::set, Options>; + +template + ,class Options = tree_assoc_defaults > +using multiset = boost::container::multiset, Options>; + +#endif + +template + ,class Options = tree_assoc_defaults > +struct set_of +{ + typedef boost::container::set, Options> type; +}; + +template + ,class Options = tree_assoc_defaults > +struct multiset_of +{ + typedef boost::container::multiset, Options> type; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_SET_HPP diff --git a/boost/container/pmr/slist.hpp b/boost/container/pmr/slist.hpp new file mode 100644 index 0000000000..4ee76c62ef --- /dev/null +++ b/boost/container/pmr/slist.hpp @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_SLIST_HPP +#define BOOST_CONTAINER_PMR_SLIST_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template +using slist = boost::container::slist>; + +#endif + +template +struct slist_of +{ + typedef boost::container::slist + < T, polymorphic_allocator > type; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_VECTOR_HPP diff --git a/boost/container/pmr/small_vector.hpp b/boost/container/pmr/small_vector.hpp new file mode 100644 index 0000000000..a79d5a075e --- /dev/null +++ b/boost/container/pmr/small_vector.hpp @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_SMALL_VECTOR_HPP +#define BOOST_CONTAINER_PMR_SMALL_VECTOR_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template +using small_vector = boost::container::small_vector>; + +#endif + +template +struct small_vector_of +{ + typedef boost::container::small_vector + < T, N, polymorphic_allocator > type; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_SMALL_VECTOR_HPP diff --git a/boost/container/pmr/stable_vector.hpp b/boost/container/pmr/stable_vector.hpp new file mode 100644 index 0000000000..07a2059d87 --- /dev/null +++ b/boost/container/pmr/stable_vector.hpp @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_STABLE_VECTOR_HPP +#define BOOST_CONTAINER_PMR_STABLE_VECTOR_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template +using stable_vector = boost::container::stable_vector>; + +#endif + +template +struct stable_vector_of +{ + typedef boost::container::stable_vector + < T, polymorphic_allocator > type; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_STABLE_VECTOR_HPP diff --git a/boost/container/pmr/string.hpp b/boost/container/pmr/string.hpp new file mode 100644 index 0000000000..2e879e3054 --- /dev/null +++ b/boost/container/pmr/string.hpp @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_STRING_HPP +#define BOOST_CONTAINER_PMR_STRING_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template > +using basic_string = + boost::container::basic_string >; + +#endif + +template > +struct basic_string_of +{ + typedef boost::container::basic_string + > type; +}; + +typedef basic_string_of::type string; + +typedef basic_string_of::type wstring; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_STRING_HPP diff --git a/boost/container/pmr/synchronized_pool_resource.hpp b/boost/container/pmr/synchronized_pool_resource.hpp new file mode 100644 index 0000000000..e4d4dd54a1 --- /dev/null +++ b/boost/container/pmr/synchronized_pool_resource.hpp @@ -0,0 +1,138 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_SYNCHRONIZED_POOL_RESOURCE_HPP +#define BOOST_CONTAINER_PMR_SYNCHRONIZED_POOL_RESOURCE_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace container { +namespace pmr { + +//! A synchronized_pool_resource is a general-purpose memory resources having +//! the following qualities: +//! +//! - Each resource owns the allocated memory, and frees it on destruction, +//! even if deallocate has not been called for some of the allocated blocks. +//! +//! - A pool resource consists of a collection of pools, serving +//! requests for different block sizes. Each individual pool manages a +//! collection of chunks that are in turn divided into blocks of uniform size, +//! returned via calls to do_allocate. Each call to do_allocate(size, alignment) +//! is dispatched to the pool serving the smallest blocks accommodating at +//! least size bytes. +//! +//! - When a particular pool is exhausted, allocating a block from that pool +//! results in the allocation of an additional chunk of memory from the upstream +//! allocator (supplied at construction), thus replenishing the pool. With +//! each successive replenishment, the chunk size obtained increases +//! geometrically. [ Note: By allocating memory in chunks, the pooling strategy +//! increases the chance that consecutive allocations will be close together +//! in memory. - end note ] +//! +//! - Allocation requests that exceed the largest block size of any pool are +//! fulfilled directly from the upstream allocator. +//! +//! - A pool_options struct may be passed to the pool resource constructors to +//! tune the largest block size and the maximum chunk size. +//! +//! A synchronized_pool_resource may be accessed from multiple threads without +//! external synchronization and may have thread-specific pools to reduce +//! synchronization costs. +class BOOST_CONTAINER_DECL synchronized_pool_resource + : public memory_resource +{ + pool_resource m_pool_resource; + void *m_opaque_sync; + + public: + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::unsynchronized_pool_resource(const pool_options&,memory_resource*) + synchronized_pool_resource(const pool_options& opts, memory_resource* upstream) BOOST_NOEXCEPT; + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::unsynchronized_pool_resource() + synchronized_pool_resource() BOOST_NOEXCEPT; + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::unsynchronized_pool_resource(memory_resource*) + explicit synchronized_pool_resource(memory_resource* upstream) BOOST_NOEXCEPT; + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::unsynchronized_pool_resource(const pool_options&) + explicit synchronized_pool_resource(const pool_options& opts) BOOST_NOEXCEPT; + + #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + synchronized_pool_resource(const synchronized_pool_resource&) = delete; + synchronized_pool_resource operator=(const synchronized_pool_resource&) = delete; + #else + private: + synchronized_pool_resource (const synchronized_pool_resource&); + synchronized_pool_resource operator=(const synchronized_pool_resource&); + public: + #endif + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::~unsynchronized_pool_resource() + virtual ~synchronized_pool_resource(); + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::release() + void release(); + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::upstream_resource()const + memory_resource* upstream_resource() const; + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::options()const + pool_options options() const; + + protected: + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::do_allocate() + virtual void* do_allocate(std::size_t bytes, std::size_t alignment); + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::do_deallocate(void*,std::size_t,std::size_t) + virtual void do_deallocate(void* p, std::size_t bytes, std::size_t alignment); + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::do_is_equal(const memory_resource&)const + virtual bool do_is_equal(const memory_resource& other) const BOOST_NOEXCEPT; + + //Non-standard observers + public: + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::pool_count() + std::size_t pool_count() const; + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::pool_index(std::size_t)const + std::size_t pool_index(std::size_t bytes) const; + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::pool_next_blocks_per_chunk(std::size_t)const + std::size_t pool_next_blocks_per_chunk(std::size_t pool_idx) const; + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::pool_block(std::size_t)const + std::size_t pool_block(std::size_t pool_idx) const; + + //! @copydoc ::boost::container::pmr::unsynchronized_pool_resource::pool_cached_blocks(std::size_t)const + std::size_t pool_cached_blocks(std::size_t pool_idx) const; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#include + +#endif //BOOST_CONTAINER_PMR_SYNCHRONIZED_POOL_RESOURCE_HPP diff --git a/boost/container/pmr/unsynchronized_pool_resource.hpp b/boost/container/pmr/unsynchronized_pool_resource.hpp new file mode 100644 index 0000000000..21d30b1ebc --- /dev/null +++ b/boost/container/pmr/unsynchronized_pool_resource.hpp @@ -0,0 +1,194 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_UNSYNCHRONIZED_POOL_RESOURCE_HPP +#define BOOST_CONTAINER_PMR_UNSYNCHRONIZED_POOL_RESOURCE_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace container { +namespace pmr { + +//! A unsynchronized_pool_resource is a general-purpose memory resources having +//! the following qualities: +//! +//! - Each resource owns the allocated memory, and frees it on destruction, +//! even if deallocate has not been called for some of the allocated blocks. +//! +//! - A pool resource consists of a collection of pools, serving +//! requests for different block sizes. Each individual pool manages a +//! collection of chunks that are in turn divided into blocks of uniform size, +//! returned via calls to do_allocate. Each call to do_allocate(size, alignment) +//! is dispatched to the pool serving the smallest blocks accommodating at +//! least size bytes. +//! +//! - When a particular pool is exhausted, allocating a block from that pool +//! results in the allocation of an additional chunk of memory from the upstream +//! allocator (supplied at construction), thus replenishing the pool. With +//! each successive replenishment, the chunk size obtained increases +//! geometrically. [ Note: By allocating memory in chunks, the pooling strategy +//! increases the chance that consecutive allocations will be close together +//! in memory. - end note ] +//! +//! - Allocation requests that exceed the largest block size of any pool are +//! fulfilled directly from the upstream allocator. +//! +//! - A pool_options struct may be passed to the pool resource constructors to +//! tune the largest block size and the maximum chunk size. +//! +//! An unsynchronized_pool_resource class may not be accessed from multiple threads +//! simultaneously and thus avoids the cost of synchronization entirely in +//! single-threaded applications. +class BOOST_CONTAINER_DECL unsynchronized_pool_resource + : public memory_resource +{ + pool_resource m_resource; + + public: + + //! Requires: `upstream` is the address of a valid memory resource. + //! + //! Effects: Constructs a pool resource object that will obtain memory + //! from upstream whenever the pool resource is unable to satisfy a memory + //! request from its own internal data structures. The resulting object will hold + //! a copy of upstream, but will not own the resource to which upstream points. + //! [ Note: The intention is that calls to upstream->allocate() will be + //! substantially fewer than calls to this->allocate() in most cases. - end note + //! The behavior of the pooling mechanism is tuned according to the value of + //! the opts argument. + //! + //! Throws: Nothing unless upstream->allocate() throws. It is unspecified if + //! or under what conditions this constructor calls upstream->allocate(). + unsynchronized_pool_resource(const pool_options& opts, memory_resource* upstream) BOOST_NOEXCEPT; + + //! Effects: Same as + //! `unsynchronized_pool_resource(pool_options(), get_default_resource())`. + unsynchronized_pool_resource() BOOST_NOEXCEPT; + + //! Effects: Same as + //! `unsynchronized_pool_resource(pool_options(), upstream)`. + explicit unsynchronized_pool_resource(memory_resource* upstream) BOOST_NOEXCEPT; + + //! Effects: Same as + //! `unsynchronized_pool_resource(opts, get_default_resource())`. + explicit unsynchronized_pool_resource(const pool_options& opts) BOOST_NOEXCEPT; + + #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + unsynchronized_pool_resource(const unsynchronized_pool_resource&) = delete; + unsynchronized_pool_resource operator=(const unsynchronized_pool_resource&) = delete; + #else + private: + unsynchronized_pool_resource (const unsynchronized_pool_resource&); + unsynchronized_pool_resource operator=(const unsynchronized_pool_resource&); + public: + #endif + + //! Effects: Calls + //! `this->release()`. + virtual ~unsynchronized_pool_resource(); + + //! Effects: Calls Calls `upstream_resource()->deallocate()` as necessary + //! to release all allocated memory. [ Note: memory is released back to + //! `upstream_resource()` even if deallocate has not been called for some + //! of the allocated blocks. - end note ] + void release(); + + //! Returns: The value of the upstream argument provided to the + //! constructor of this object. + memory_resource* upstream_resource() const; + + //! Returns: The options that control the pooling behavior of this resource. + //! The values in the returned struct may differ from those supplied to the pool + //! resource constructor in that values of zero will be replaced with + //! implementation-defined defaults and sizes may be rounded to unspecified granularity. + pool_options options() const; + + protected: + + //! Returns: A pointer to allocated storage with a size of at least `bytes`. + //! The size and alignment of the allocated memory shall meet the requirements for + //! a class derived from `memory_resource`. + //! + //! Effects: If the pool selected for a block of size bytes is unable to + //! satisfy the memory request from its own internal data structures, it will call + //! `upstream_resource()->allocate()` to obtain more memory. If `bytes` is larger + //! than that which the largest pool can handle, then memory will be allocated + //! using `upstream_resource()->allocate()`. + //! + //! Throws: Nothing unless `upstream_resource()->allocate()` throws. + virtual void* do_allocate(std::size_t bytes, std::size_t alignment); + + //! Effects: Return the memory at p to the pool. It is unspecified if or under + //! what circumstances this operation will result in a call to + //! `upstream_resource()->deallocate()`. + //! + //! Throws: Nothing. + virtual void do_deallocate(void* p, std::size_t bytes, std::size_t alignment); + + //! Returns: + //! `this == dynamic_cast(&other)`. + virtual bool do_is_equal(const memory_resource& other) const BOOST_NOEXCEPT; + + //Non-standard observers + public: + //! Returns: The number of pools that will be used in the pool resource. + //! + //! Note: Non-standard extension. + std::size_t pool_count() const; + + //! Returns: The index of the pool that will be used to serve the allocation of `bytes`. + //! Returns `pool_count()` if `bytes` is bigger + //! than `options().largest_required_pool_block` (no pool will be used to serve this). + //! + //! Note: Non-standard extension. + std::size_t pool_index(std::size_t bytes) const; + + //! Requires: `pool_idx < pool_index()` + //! + //! Returns: The number blocks that will be allocated in the next chunk + //! from the pool specified by `pool_idx`. + //! + //! Note: Non-standard extension. + std::size_t pool_next_blocks_per_chunk(std::size_t pool_idx) const; + + //! Requires: `pool_idx < pool_index()` + //! + //! Returns: The number of bytes of the block that the specified `pool_idx` pool manages. + //! + //! Note: Non-standard extension. + std::size_t pool_block(std::size_t pool_idx) const; + + //! Requires: `pool_idx < pool_index()` + //! + //! Returns: The number of blocks that the specified `pool_idx` pool has cached + //! and will be served without calling the upstream_allocator. + //! + //! Note: Non-standard extension. + std::size_t pool_cached_blocks(std::size_t pool_idx) const; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#include + +#endif //BOOST_CONTAINER_PMR_UNSYNCHRONIZED_POOL_RESOURCE_HPP diff --git a/boost/container/pmr/vector.hpp b/boost/container/pmr/vector.hpp new file mode 100644 index 0000000000..cef6ae5b94 --- /dev/null +++ b/boost/container/pmr/vector.hpp @@ -0,0 +1,43 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_PMR_VECTOR_HPP +#define BOOST_CONTAINER_PMR_VECTOR_HPP + +#if defined (_MSC_VER) +# pragma once +#endif + +#include +#include + +namespace boost { +namespace container { +namespace pmr { + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template +using vector = boost::container::vector>; + +#endif + +template +struct vector_of +{ + typedef boost::container::vector + < T, polymorphic_allocator > type; +}; + +} //namespace pmr { +} //namespace container { +} //namespace boost { + +#endif //BOOST_CONTAINER_PMR_VECTOR_HPP diff --git a/boost/container/scoped_allocator.hpp b/boost/container/scoped_allocator.hpp index 0724f948fb..6a041a653d 100644 --- a/boost/container/scoped_allocator.hpp +++ b/boost/container/scoped_allocator.hpp @@ -18,7 +18,7 @@ #define BOOST_CONTAINER_ALLOCATOR_SCOPED_ALLOCATOR_HPP #if defined (_MSC_VER) -# pragma once +# pragma once #endif #include @@ -26,8 +26,8 @@ #include #include +#include -#include #include #include #include @@ -42,143 +42,6 @@ namespace boost { namespace container { -//! Remark: if a specialization constructible_with_allocator_suffix::value is true, 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 constructible_with_allocator_suffix::value is true, 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 > -//! { static const bool value = true; }; -//! -//! -//! Note: This trait is a workaround inspired by "N2554: The Scoped A 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 -{ static const bool value = false; }; - -//! Remark: if a specialization constructible_with_allocator_prefix::value is true, 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: specialization constructible_with_allocator_prefix::value is true, 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, BOOST_FWD_REF(Args)... args); -//! }; -//! -//! // Specialize trait for class template Y -//! template > -//! struct constructible_with_allocator_prefix > -//! { static const bool value = true; }; -//! -//! -//! -//! 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 -{ static const bool value = false; }; - -#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 Allocator. - private: - typedef char yes_type; - struct no_type{ char dummy[2]; }; - - // Match this function if TypeT::allocator_type exists and is - // implicitly convertible from Allocator - template - static yes_type test(typename U::allocator_type); - - // Match this function if TypeT::allocator_type does not exist or is - // not convertible from Allocator. - template - static no_type test(...); - static Allocator alloc; // Declared but not defined - - public: - static const bool value = sizeof(test(alloc)) == sizeof(yes_type); -}; - -} //namespace container_detail { - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -//! Remark: Automatically detects if T has a nested allocator_type that is convertible from -//! Allocator. Meets the BinaryTypeTrait requirements ([meta.rqmts] 20.4.1). A program may -//! specialize this type to define uses_allocator::value as true for a T of user-defined type if T does not -//! have a nested allocator_type but is nonetheless constructible using the specified Allocator. -//! -//! Result: uses_allocator::value== true if Convertible, -//! false otherwise. -template -struct uses_allocator - : container_detail::uses_allocator_imp -{}; - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED namespace container_detail { @@ -249,198 +112,17 @@ struct outermost_allocator {}; template -typename container_detail::outermost_allocator_imp::type & +typename outermost_allocator::type & get_outermost_allocator(Allocator &a) -{ return container_detail::outermost_allocator_imp::get(a); } +{ return outermost_allocator::get(a); } template -const typename container_detail::outermost_allocator_imp::type & +const typename outermost_allocator::type & get_outermost_allocator(const Allocator &a) -{ return container_detail::outermost_allocator_imp::get(a); } +{ return outermost_allocator::get(a); } namespace container_detail { -// Check if we can detect is_convertible using advanced SFINAE expressions -#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - //! 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 - template - struct is_constructible - { - typedef char yes_type; - struct no_type - { char padding[2]; }; - - template - struct dummy; - - template - static decltype(X(boost::move_detail::declval()...), true_type()) test(int); - - template - static no_type test(...); - - static const bool value = sizeof(test(0)) == sizeof(yes_type); - }; - - template - struct is_constructible_with_allocator_prefix - : is_constructible - {}; - -#else // #if !defined(BOOST_NO_SFINAE_EXPR) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - //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 - struct is_constructible_with_allocator_prefix - : constructible_with_allocator_prefix - {}; - - template - struct is_constructible_with_allocator_suffix - : constructible_with_allocator_suffix - {}; - - #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - template - struct is_constructible_with_allocator_prefix - : constructible_with_allocator_prefix - {}; - - template - 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) - -// allocator_arg_t -template < typename OutermostAlloc - , typename InnerAlloc - , typename T - , class ...Args - > -inline void dispatch_allocator_prefix_suffix - ( 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)...); -} - -// allocator suffix -template < typename OutermostAlloc - , typename InnerAlloc - , typename T - , class ...Args - > -inline void dispatch_allocator_prefix_suffix - ( 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 - ( 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 - ( bool_< is_constructible_with_allocator_prefix::value>() - , outermost_alloc, inner_alloc, p, ::boost::forward(args)...); -} - -template < typename OutermostAlloc - , typename InnerAlloc - , typename T - , class ...Args - > -inline void dispatch_uses_allocator - ( 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_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE(N) \ -template < typename OutermostAlloc, typename InnerAlloc, typename T\ - BOOST_MOVE_I##N BOOST_MOVE_CLASS##N > \ -inline void dispatch_allocator_prefix_suffix\ - (true_type use_alloc_prefix, OutermostAlloc& outermost_alloc,\ - InnerAlloc& inner_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ -{\ - (void)use_alloc_prefix,\ - allocator_traits::construct\ - (outermost_alloc, p, allocator_arg, inner_alloc BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ -}\ -\ -template < typename OutermostAlloc, typename InnerAlloc, typename T\ - BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ -inline void dispatch_allocator_prefix_suffix\ - (false_type use_alloc_prefix, OutermostAlloc& outermost_alloc,\ - InnerAlloc& inner_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ -{\ - (void)use_alloc_prefix;\ - allocator_traits::construct\ - (outermost_alloc, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N, inner_alloc);\ -}\ -\ -template < typename OutermostAlloc, typename InnerAlloc, typename T\ - BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ -inline void dispatch_uses_allocator\ - (true_type uses_allocator, OutermostAlloc& outermost_alloc,\ - InnerAlloc& inner_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ -{\ - (void)uses_allocator;\ - dispatch_allocator_prefix_suffix\ - ( bool_< is_constructible_with_allocator_prefix::value >()\ - , outermost_alloc, inner_alloc, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ -}\ -\ -template < typename OutermostAlloc, typename InnerAlloc, typename T\ - BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ -inline void dispatch_uses_allocator\ - (false_type uses_allocator, OutermostAlloc &outermost_alloc,\ - InnerAlloc &inner_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ -{\ - (void)uses_allocator; (void)inner_alloc;\ - allocator_traits::construct(outermost_alloc, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ -}\ -// -BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE) -#undef BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE - -#endif //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template @@ -923,24 +605,24 @@ class scoped_allocator_adaptor typedef typename outer_traits_type::void_pointer void_pointer; typedef typename outer_traits_type::const_void_pointer const_void_pointer; //! Type: A type with a constant boolean value == true if - //!`allocator_traits::propagate_on_container_copy_assignment::value` is + //!`allocator_traits:: propagate_on_container_copy_assignment::value` is //! true for any Allocator in the set of OuterAlloc and InnerAllocs..., false otherwise. typedef typename base_type:: propagate_on_container_copy_assignment propagate_on_container_copy_assignment; //! Type: A type with a constant boolean value == true if - //!`allocator_traits::propagate_on_container_move_assignment::value` is + //!`allocator_traits:: propagate_on_container_move_assignment::value` is //! true for any Allocator in the set of OuterAlloc and InnerAllocs..., false otherwise. typedef typename base_type:: propagate_on_container_move_assignment propagate_on_container_move_assignment; //! Type: A type with a constant boolean value == true if - //! `allocator_traits::propagate_on_container_swap::value` is + //! `allocator_traits:: propagate_on_container_swap::value` is //! true for any Allocator in the set of OuterAlloc and InnerAllocs..., false otherwise. typedef typename base_type:: propagate_on_container_swap propagate_on_container_swap; //! Type: A type with a constant boolean value == true if - //!`allocator_traits::is_always_equal::value` is + //!`allocator_traits:: is_always_equal::value` is //! true for all Allocator in the set of OuterAlloc and InnerAllocs..., false otherwise. typedef typename base_type:: is_always_equal is_always_equal; @@ -1053,12 +735,12 @@ class scoped_allocator_adaptor #endif //BOOST_CONTAINER_DOXYGEN_INVOKED //! Returns: - //! allocator_traits::max_size(outer_allocator()). + //! allocator_traits:: max_size(outer_allocator()). size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW { return outer_traits_type::max_size(this->outer_allocator()); } //! Effects: - //! calls OUTERMOST_ALLOC_TRAITS(*this)::destroy(OUTERMOST(*this), p). + //! calls OUTERMOST_ALLOC_TRAITS(*this):: destroy(OUTERMOST(*this), p). template void destroy(T* p) BOOST_NOEXCEPT_OR_NOTHROW { @@ -1099,12 +781,12 @@ class scoped_allocator_adaptor //! Effects: //! 1) If uses_allocator::value is false calls - //! OUTERMOST_ALLOC_TRAITS(*this)::construct - //! (OUTERMOST(*this), p, std::forward(args)...). + //! 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, + //! 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 @@ -1112,13 +794,13 @@ class scoped_allocator_adaptor //! 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, + //! 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] + //! constructible_with_allocator_suffix:: value. -end note] //! //! 4) Otherwise, the program is ill-formed. //! @@ -1126,18 +808,11 @@ class scoped_allocator_adaptor //! 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 >::type - #endif - construct(T* p, BOOST_FWD_REF(Args)...args) + void construct(T* p, BOOST_FWD_REF(Args)...args) { container_detail::dispatch_uses_allocator - ( container_detail::bool_::value>() - , get_outermost_allocator(this->outer_allocator()) - , this->inner_allocator() - , p, ::boost::forward(args)...); + ( (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) @@ -1146,12 +821,10 @@ class scoped_allocator_adaptor //overload selection problems when the first parameter is a pair. #define BOOST_CONTAINER_SCOPED_ALLOCATOR_CONSTRUCT_CODE(N) \ template < typename T BOOST_MOVE_I##N BOOST_MOVE_CLASSQ##N >\ - typename container_detail::enable_if< container_detail::is_not_pair >::type\ - construct(T* p BOOST_MOVE_I##N BOOST_MOVE_UREFQ##N)\ + void construct(T* p BOOST_MOVE_I##N BOOST_MOVE_UREFQ##N)\ {\ container_detail::dispatch_uses_allocator\ - ( container_detail::bool_::value>()\ - , get_outermost_allocator(this->outer_allocator())\ + ( (get_outermost_allocator)(this->outer_allocator())\ , this->inner_allocator(), p BOOST_MOVE_I##N BOOST_MOVE_FWDQ##N);\ }\ // @@ -1160,81 +833,7 @@ class scoped_allocator_adaptor #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, ::boost::move(x)); } - - template - void construct( container_detail::pair* p - , BOOST_RV_REF_BEG container_detail::pair BOOST_RV_REF_END x) - { this->construct_pair(p, ::boost::move(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_pair(p, pr.first, pr.second); } - - template - void construct_pair(Pair* p, BOOST_RV_REF(Pair2) pr) - { this->construct_pair(p, ::boost::move(pr.first), ::boost::move(pr.second)); } - - //template - //void construct(pair* p, piecewise_construct_t, tuple x, tuple y); public: //Internal function @@ -1246,6 +845,8 @@ class scoped_allocator_adaptor #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED }; +/// @cond + template struct scoped_allocator_operator_equal { @@ -1278,6 +879,7 @@ struct scoped_allocator_operator_equal { return true; } }; +/// @endcond template inline bool operator==(const scoped_allocator_adaptor& a diff --git a/boost/container/scoped_allocator_fwd.hpp b/boost/container/scoped_allocator_fwd.hpp index 003ed9f7f7..cddf7fad15 100644 --- a/boost/container/scoped_allocator_fwd.hpp +++ b/boost/container/scoped_allocator_fwd.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2015-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) // @@ -13,7 +13,6 @@ //! \file //! This header file forward declares boost::container::scoped_allocator_adaptor -//! and defines the following types: #ifndef BOOST_CONFIG_HPP # include @@ -26,6 +25,7 @@ #include #include #include +#include #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include @@ -59,38 +59,11 @@ namespace boost { namespace container { #endif - template - struct std_allocator_arg_holder - { - static ::std::allocator_arg_t *dummy; - }; - - template - ::std::allocator_arg_t *std_allocator_arg_holder::dummy; #else //BOOST_CONTAINER_DOXYGEN_INVOKED #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 Allocator requirements -typedef const std::allocator_arg_t & allocator_arg_t; - -//! A instance of type allocator_arg_t -//! -static allocator_arg_t allocator_arg = BOOST_CONTAINER_DOC1ST(unspecified, *std_allocator_arg_holder<>::dummy); - -template -struct constructible_with_allocator_suffix; - -template -struct constructible_with_allocator_prefix; - -template -struct uses_allocator; - }} // namespace boost { namespace container { #include diff --git a/boost/container/set.hpp b/boost/container/set.hpp index 79fa1aec66..ca05cac1f7 100644 --- a/boost/container/set.hpp +++ b/boost/container/set.hpp @@ -253,6 +253,9 @@ class set { 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. + //! + //! Complexity: Linear in il.size(). set& operator=(std::initializer_list il) { this->clear(); @@ -851,17 +854,17 @@ class multiset : base_t(static_cast(x)) {} - //! @copydoc ::boost::container::set(set &&) + //! @copydoc ::boost::container::set::set(set &&) multiset(BOOST_RV_REF(multiset) x) : base_t(BOOST_MOVE_BASE(base_t, x)) {} - //! @copydoc ::boost::container::set(const set &, const allocator_type &) + //! @copydoc ::boost::container::set::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 &) + //! @copydoc ::boost::container::set::set(set &&, const allocator_type &) multiset(BOOST_RV_REF(multiset) x, const allocator_type &a) : base_t(BOOST_MOVE_BASE(base_t, x), a) {} diff --git a/boost/container/slist.hpp b/boost/container/slist.hpp index 2b53df132f..8e7aa20030 100644 --- a/boost/container/slist.hpp +++ b/boost/container/slist.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2004-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) // @@ -684,7 +684,10 @@ class slist //! //! Complexity: Constant. reference front() - { return *this->begin(); } + { + BOOST_ASSERT(!this->empty()); + return *this->begin(); + } //! Requires: !empty() //! @@ -695,7 +698,10 @@ class slist //! //! Complexity: Constant. const_reference front() const - { return *this->begin(); } + { + BOOST_ASSERT(!this->empty()); + return *this->begin(); + } ////////////////////////////////////////////// // @@ -897,7 +903,10 @@ class slist //! //! Complexity: Amortized constant time. void pop_front() - { this->icont().pop_front_and_dispose(Destroyer(this->node_alloc())); } + { + BOOST_ASSERT(!this->empty()); + this->icont().pop_front_and_dispose(Destroyer(this->node_alloc())); + } //! Effects: Erases the element after the element pointed by prev_p //! of the list. @@ -939,7 +948,12 @@ class slist void swap(slist& x) BOOST_NOEXCEPT_IF( allocator_traits_type::propagate_on_container_swap::value || allocator_traits_type::is_always_equal::value) - { AllocHolder::swap(x); } + { + BOOST_ASSERT(allocator_traits_type::propagate_on_container_swap::value || + allocator_traits_type::is_always_equal::value || + this->get_stored_allocator() == x.get_stored_allocator()); + AllocHolder::swap(x); + } //! Effects: Erases all the elements of the list. //! @@ -1652,22 +1666,15 @@ struct has_trivial_destructor_after_move > namespace container { -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - }} //namespace boost{ namespace container { +#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + // Specialization of insert_iterator so that insertions will be constant // time rather than linear time. -#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED - -#if defined(__clang__) && defined(_LIBCPP_VERSION) - #define BOOST_CONTAINER_CLANG_INLINE_STD_NS - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wc++11-extensions" -#endif - -BOOST_CONTAINER_STD_NS_BEG +#include +BOOST_CONTAINER_DOC1ST(namespace std {, BOOST_MOVE_STD_NS_BEG) template class insert_iterator > @@ -1700,14 +1707,8 @@ class insert_iterator > insert_iterator& operator++(int){ return *this; } }; -BOOST_CONTAINER_STD_NS_END - -#ifdef BOOST_CONTAINER_CLANG_INLINE_STD_NS - #pragma GCC diagnostic pop - #undef BOOST_CONTAINER_CLANG_INLINE_STD_NS -#endif //BOOST_CONTAINER_CLANG_INLINE_STD_NS - -#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED +BOOST_CONTAINER_DOC1ST( }, BOOST_MOVE_STD_NS_END) +#include #include diff --git a/boost/container/small_vector.hpp b/boost/container/small_vector.hpp index a9f7522205..4dab684764 100644 --- a/boost/container/small_vector.hpp +++ b/boost/container/small_vector.hpp @@ -117,9 +117,9 @@ class small_vector_allocator typedef typename allocator_traits::propagate_on_container_copy_assignment propagate_on_container_copy_assignment; typedef typename allocator_traits::propagate_on_container_move_assignment propagate_on_container_move_assignment; typedef typename allocator_traits::propagate_on_container_swap propagate_on_container_swap; - //! An integral constant with member `::value == false` + //! An integral constant with member `value == false` typedef BOOST_CONTAINER_IMPDEF(container_detail::bool_) is_always_equal; - //! An integral constant with member `::value == true` + //! An integral constant with member `value == true` typedef BOOST_CONTAINER_IMPDEF(container_detail::bool_) is_partially_propagable; BOOST_CONTAINER_DOCIGN(typedef container_detail::version_type version;) @@ -289,20 +289,25 @@ class small_vector_allocator //! This class consists of common code from all small_vector types that don't depend on the //! "N" template parameter. This class is non-copyable and non-destructible, so this class tipically //! used as reference argument to functions that read or write small vectors. Since `small_vector` -//! derives from `small_vector_base`, the conversion to `small_vector_base` is implicit: -//! +//! derives from `small_vector_base`, the conversion to `small_vector_base` is implicit +//!
 //!
 //! //Clients can pass any small_vector.
 //! void read_any_small_vector_of_foo(const small_vector_base &in_parameter);
+//!
 //! void modify_any_small_vector_of_foo(small_vector_base &out_parameter);
-//! 
+//!
 //! void some_function()
 //! {
+//! 
 //!    small_vector myvector;
+//!
 //!    read_any_small_vector_of_foo(myvector);   // Reads myvector
+//!
 //!    modify_any_small_vector_of_foo(myvector); // Modifies myvector
+//! 
 //! }
-//! 
+//! 
//! //! All `boost::container:vector` member functions are inherited. See `vector` documentation for details. //! diff --git a/boost/container/stable_vector.hpp b/boost/container/stable_vector.hpp index 6aca69bde6..a332dbc66c 100644 --- a/boost/container/stable_vector.hpp +++ b/boost/container/stable_vector.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2008-2013. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2008-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) // @@ -1196,7 +1196,10 @@ class stable_vector //! //! Complexity: Constant. reference front() BOOST_NOEXCEPT_OR_NOTHROW - { return static_cast(*this->index.front()).value; } + { + BOOST_ASSERT(!this->empty()); + return static_cast(*this->index.front()).value; + } //! Requires: !empty() //! @@ -1207,7 +1210,10 @@ class stable_vector //! //! Complexity: Constant. const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW - { return static_cast(*this->index.front()).value; } + { + BOOST_ASSERT(!this->empty()); + return static_cast(*this->index.front()).value; + } //! Requires: !empty() //! @@ -1218,7 +1224,10 @@ class stable_vector //! //! Complexity: Constant. reference back() BOOST_NOEXCEPT_OR_NOTHROW - { return static_cast(*this->index[this->size()-1u]).value; } + { + BOOST_ASSERT(!this->empty()); + return static_cast(*this->index[this->size()-1u]).value; + } //! Requires: !empty() //! @@ -1229,7 +1238,10 @@ class stable_vector //! //! Complexity: Constant. const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW - { return static_cast(*this->index[this->size()-1u]).value; } + { + BOOST_ASSERT(!this->empty()); + return static_cast(*this->index[this->size()-1u]).value; + } //! Requires: size() > n. //! @@ -1241,7 +1253,7 @@ class stable_vector //! Complexity: Constant. reference operator[](size_type n) BOOST_NOEXCEPT_OR_NOTHROW { - BOOST_ASSERT(n < this->size()); + BOOST_ASSERT(this->size() > n); return static_cast(*this->index[n]).value; } @@ -1255,7 +1267,7 @@ class stable_vector //! Complexity: Constant. const_reference operator[](size_type n) const BOOST_NOEXCEPT_OR_NOTHROW { - BOOST_ASSERT(n < this->size()); + BOOST_ASSERT(this->size() > n); return static_cast(*this->index[n]).value; } @@ -1386,6 +1398,7 @@ class stable_vector template iterator emplace(const_iterator p, Args && ...args) { + BOOST_ASSERT(this->priv_in_range_or_end(p)); size_type pos_n = p - cbegin(); typedef emplace_functor EmplaceFunctor; typedef emplace_iterator EmplaceIterator; @@ -1410,6 +1423,7 @@ class stable_vector BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ iterator emplace(const_iterator p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ {\ + BOOST_ASSERT(this->priv_in_range_or_end(p));\ typedef emplace_functor##N\ BOOST_MOVE_LT##N BOOST_MOVE_TARG##N BOOST_MOVE_GT##N EmplaceFunctor;\ typedef emplace_iterator EmplaceIterator;\ @@ -1483,6 +1497,7 @@ class stable_vector //! Complexity: Linear to n. iterator insert(const_iterator p, size_type n, const T& t) { + BOOST_ASSERT(this->priv_in_range_or_end(p)); STABLE_VECTOR_CHECK_INVARIANT; typedef constant_iterator cvalue_iterator; return this->insert(p, cvalue_iterator(t, n), cvalue_iterator()); @@ -1499,6 +1514,7 @@ class stable_vector //! Complexity: Linear to distance [il.begin(), il.end()). iterator insert(const_iterator p, std::initializer_list il) { + //Position checks done by insert() STABLE_VECTOR_CHECK_INVARIANT; return insert(p, il.begin(), il.end()); } @@ -1515,17 +1531,19 @@ class stable_vector //! //! Complexity: Linear to distance [first, last). template - #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - typename container_detail::disable_if_or - < iterator - , container_detail::is_convertible - , container_detail::is_not_input_iterator - >::type - #else - iterator - #endif - insert(const_iterator p, InputIterator first, InputIterator last) - { + iterator insert(const_iterator p, InputIterator first, InputIterator last + #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //Put this as argument instead of the return type as old GCC's like 3.4 + //detect this and the next disable_if_or as overloads + , typename container_detail::disable_if_or + < void + , container_detail::is_convertible + , container_detail::is_not_input_iterator + >::type* = 0 + #endif + ) + { + BOOST_ASSERT(this->priv_in_range_or_end(p)); STABLE_VECTOR_CHECK_INVARIANT; const size_type pos_n = p - this->cbegin(); for(; first != last; ++first){ @@ -1543,6 +1561,7 @@ class stable_vector >::type insert(const_iterator p, FwdIt first, FwdIt last) { + BOOST_ASSERT(this->priv_in_range_or_end(p)); const size_type num_new = static_cast(boost::container::iterator_distance(first, last)); const size_type idx = static_cast(p - this->cbegin()); if(num_new){ @@ -1556,12 +1575,12 @@ class stable_vector //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); + const node_ptr n = this->priv_get_from_pool(); + BOOST_ASSERT(!!n); //Put it in the index so rollback can return it in pool if construct_in_place throws - *it_past_newly_constructed = p; + *it_past_newly_constructed = n; //Constructs and fixes up pointers This can throw - this->priv_build_node_from_it(p, it_past_newly_constructed, first); + this->priv_build_node_from_it(n, it_past_newly_constructed, first); ++first; ++it_past_newly_constructed; } @@ -1581,7 +1600,10 @@ class stable_vector //! //! Complexity: Constant time. void pop_back() BOOST_NOEXCEPT_OR_NOTHROW - { this->erase(--this->cend()); } + { + BOOST_ASSERT(!this->empty()); + this->erase(--this->cend()); + } //! Effects: Erases the element at p. //! @@ -1591,6 +1613,7 @@ class stable_vector //! last element. Constant if p is the last element. iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW { + BOOST_ASSERT(this->priv_in_range(p)); STABLE_VECTOR_CHECK_INVARIANT; const size_type d = p - this->cbegin(); index_iterator it = this->index.begin() + d; @@ -1608,6 +1631,8 @@ class stable_vector //! plus linear to the elements between p and the last element. iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW { + BOOST_ASSERT(first == last || + (first < last && this->priv_in_range(first) && this->priv_in_range_or_end(last))); STABLE_VECTOR_CHECK_INVARIANT; const const_iterator cbeg(this->cbegin()); const size_type d1 = static_cast(first - cbeg), @@ -1641,6 +1666,9 @@ class stable_vector BOOST_NOEXCEPT_IF( allocator_traits_type::propagate_on_container_swap::value || allocator_traits_type::is_always_equal::value) { + BOOST_ASSERT(allocator_traits_type::propagate_on_container_swap::value || + allocator_traits_type::is_always_equal::value || + this->get_stored_allocator() == x.get_stored_allocator()); STABLE_VECTOR_CHECK_INVARIANT; container_detail::bool_ flag; container_detail::swap_alloc(this->priv_node_alloc(), x.priv_node_alloc(), flag); @@ -1702,6 +1730,16 @@ class stable_vector #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: + bool priv_in_range(const_iterator pos) const + { + return (this->begin() <= pos) && (pos < this->end()); + } + + bool priv_in_range_or_end(const_iterator pos) const + { + return (this->begin() <= pos) && (pos <= this->end()); + } + size_type priv_index_of(node_ptr p) const { //Check range @@ -1807,12 +1845,14 @@ class stable_vector iterator priv_insert(const_iterator p, const value_type &t) { + BOOST_ASSERT(this->priv_in_range_or_end(p)); 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) { + BOOST_ASSERT(this->priv_in_range_or_end(p)); typedef repeat_iterator repeat_it; typedef boost::move_iterator repeat_move_it; //Just call more general insert(p, size, value) and return iterator diff --git a/boost/container/static_vector.hpp b/boost/container/static_vector.hpp index c36832dfa3..69540dcc7b 100644 --- a/boost/container/static_vector.hpp +++ b/boost/container/static_vector.hpp @@ -48,7 +48,7 @@ class static_storage_allocator {} static_storage_allocator & operator=(const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW - {} + { return *this; } T* internal_storage() const BOOST_NOEXCEPT_OR_NOTHROW { return const_cast(static_cast(static_cast(&storage))); } @@ -645,7 +645,7 @@ public: //! //! @brief Assigns a range [il.begin(), il.end()) of Values to this container. //! - //! @param first std::initializer_list with values used to construct new content of this container. + //! @param il std::initializer_list with values used to construct new content of this container. //! //! @par Throws //! If Value's copy constructor or copy assignment throws, @@ -809,7 +809,7 @@ public: //! //! @brief Returns the index of the element pointed by p. //! - //! @param i The element's index. + //! @param p An iterator to the element. //! //! @return The index of the element pointed by p. //! @@ -824,7 +824,7 @@ public: //! //! @brief Returns the index of the element pointed by p. //! - //! @param i The index of the element pointed by p. + //! @param p A const_iterator to the element. //! //! @return a const_iterator to the i-th element. //! diff --git a/boost/container/string.hpp b/boost/container/string.hpp index 7399223904..33f5f66176 100644 --- a/boost/container/string.hpp +++ b/boost/container/string.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// (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 http://www.boost.org/LICENSE_1_0.txt) // @@ -93,11 +93,11 @@ class basic_string_base : members_() { init(); } - basic_string_base(const allocator_type& a) + explicit basic_string_base(const allocator_type& a) : members_(a) { init(); } - basic_string_base(BOOST_RV_REF(allocator_type) a) + explicit basic_string_base(BOOST_RV_REF(allocator_type) a) : members_(boost::move(a)) { this->init(); } @@ -108,6 +108,13 @@ class basic_string_base this->allocate_initial_block(n); } + explicit basic_string_base(size_type n) + : members_() + { + this->init(); + this->allocate_initial_block(n); + } + ~basic_string_base() { if(!this->is_short()){ @@ -647,10 +654,22 @@ class basic_string } } + //! Effects: Constructs a basic_string with a default-constructed allocator, + //! 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) + : base_t() + { + 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 string. - basic_string(const basic_string& s, size_type pos, size_type n = npos, - const allocator_type& a = allocator_type()) + basic_string(const basic_string& s, size_type pos, size_type n, const allocator_type& a) : base_t(a) { this->priv_terminate_string(); @@ -661,46 +680,93 @@ class basic_string (s.begin() + pos, s.begin() + pos + container_detail::min_value(n, s.size() - pos)); } + //! Effects: Constructs a basic_string taking a default-constructed allocator, + //! and is initialized by a specific number of characters of the s c-string. + basic_string(const CharT* s, size_type n) + : base_t() + { + this->priv_terminate_string(); + this->assign(s, s + n); + } + //! 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()) + basic_string(const CharT* s, size_type n, const allocator_type& a) : base_t(a) { this->priv_terminate_string(); this->assign(s, s + n); } + //! Effects: Constructs a basic_string with a default-constructed allocator, + //! and is initialized by the null-terminated s c-string. + basic_string(const CharT* s) + : base_t() + { + 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 the null-terminated s c-string. - basic_string(const CharT* s, const allocator_type& a = allocator_type()) + basic_string(const CharT* s, const allocator_type& a) : base_t(a) { this->priv_terminate_string(); this->assign(s, s + Traits::length(s)); } + + //! Effects: Constructs a basic_string with a default-constructed allocator, + //! and is initialized by n copies of c. + basic_string(size_type n, CharT c) + : base_t() + { + this->priv_terminate_string(); + this->assign(n, c); + } + //! 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()) + basic_string(size_type n, CharT c, const allocator_type& a) : base_t(a) { this->priv_terminate_string(); this->assign(n, c); } + //! Effects: Constructs a basic_string with a default-constructed allocator, + //! and is initialized by n default-initialized characters. + basic_string(size_type n, default_init_t) + : base_t(n + 1) + { + this->priv_size(n); + this->priv_terminate_string(); + } + //! 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()) + basic_string(size_type n, default_init_t, const allocator_type& a) : base_t(a, n + 1) { this->priv_size(n); this->priv_terminate_string(); } + //! Effects: Constructs a basic_string with a default-constructed allocator, + //! and a range of iterators. + template + basic_string(InputIterator f, InputIterator l) + : base_t() + { + this->priv_terminate_string(); + this->assign(f, l); + } + //! 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()) + basic_string(InputIterator f, InputIterator l, const allocator_type& a) : base_t(a) { this->priv_terminate_string(); @@ -1058,6 +1124,62 @@ class basic_string // ////////////////////////////////////////////// + //! Requires: !empty() + //! + //! Effects: Returns a reference to the first + //! element of the container. + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + reference front() BOOST_NOEXCEPT_OR_NOTHROW + { + BOOST_ASSERT(!this->empty()); + return *this->priv_addr(); + } + + //! Requires: !empty() + //! + //! Effects: Returns a const reference to the first + //! element of the container. + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW + { + BOOST_ASSERT(!this->empty()); + return *this->priv_addr(); + } + + //! Requires: !empty() + //! + //! Effects: Returns a reference to the last + //! element of the container. + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + reference back() BOOST_NOEXCEPT_OR_NOTHROW + { + BOOST_ASSERT(!this->empty()); + return *(this->priv_addr() + (this->size() - 1u) ); + } + + //! Requires: !empty() + //! + //! Effects: Returns a const reference to the last + //! element of the container. + //! + //! Throws: Nothing. + //! + //! Complexity: Constant. + const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW + { + BOOST_ASSERT(!this->empty()); + return *(this->priv_addr() + (this->size() - 1u) ); + } + //! Requires: size() > n. //! //! Effects: Returns a reference to the nth element @@ -1067,7 +1189,10 @@ class basic_string //! //! Complexity: Constant. reference operator[](size_type n) BOOST_NOEXCEPT_OR_NOTHROW - { return *(this->priv_addr() + n); } + { + BOOST_ASSERT(this->size() > n); + return *(this->priv_addr() + n); + } //! Requires: size() > n. //! @@ -1078,7 +1203,10 @@ class basic_string //! //! Complexity: Constant. const_reference operator[](size_type n) const BOOST_NOEXCEPT_OR_NOTHROW - { return *(this->priv_addr() + n); } + { + BOOST_ASSERT(this->size() > n); + return *(this->priv_addr() + n); + } //! Requires: size() > n. //! @@ -1560,6 +1688,18 @@ class basic_string } #endif + //! Effects: Removes the last element from the container. + //! + //! Throws: Nothing. + //! + //! Complexity: Constant time. + void pop_back() BOOST_NOEXCEPT_OR_NOTHROW + { + BOOST_ASSERT(!this->empty()); + iterator p = this->end(); + this->erase(--p); + } + //! Requires: pos <= size() //! //! Effects: Determines the effective length xlen of the string to be removed as the smaller of n and size() - pos. @@ -1621,18 +1761,6 @@ class basic_string return iterator(f); } - //! Requires: !empty() - //! - //! Throws: Nothing - //! - //! Effects: Equivalent to erase(size() - 1, 1). - void pop_back() BOOST_NOEXCEPT_OR_NOTHROW - { - 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. diff --git a/boost/container/uses_allocator.hpp b/boost/container/uses_allocator.hpp new file mode 100644 index 0000000000..2bcc465890 --- /dev/null +++ b/boost/container/uses_allocator.hpp @@ -0,0 +1,169 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (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_USES_ALLOCATOR_HPP +#define BOOST_CONTAINER_USES_ALLOCATOR_HPP + +#include +#include + +namespace boost { +namespace container { + +//! Remark: if a specialization constructible_with_allocator_suffix::value is true, 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 constructible_with_allocator_suffix::value is true, 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 > +//! { static const bool value = true; }; +//! +//! +//! Note: This trait is a workaround inspired by "N2554: The Scoped A 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 +{ static const bool value = false; }; + +//! Remark: if a specialization constructible_with_allocator_prefix::value is true, 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: specialization constructible_with_allocator_prefix::value is true, 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, BOOST_FWD_REF(Args)... args); +//! }; +//! +//! // Specialize trait for class template Y +//! template > +//! struct constructible_with_allocator_prefix > +//! { static const bool value = true; }; +//! +//! +//! +//! 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 +{ static const bool value = false; }; + +#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 Allocator. + private: + typedef char yes_type; + struct no_type{ char dummy[2]; }; + + // Match this function if T::allocator_type exists and is + // implicitly convertible from Allocator + template + static yes_type test(typename U::allocator_type); + + // Match this function if T::allocator_type exists and it's type is `erased_type`. + template + static typename container_detail::enable_if + < container_detail::is_same + , yes_type + >::type test(const V&); + + // Match this function if TypeT::allocator_type does not exist or is + // not convertible from Allocator. + template + static no_type test(...); + static Allocator alloc; // Declared but not defined + + public: + static const bool value = sizeof(test(alloc)) == sizeof(yes_type); +}; + +} //namespace container_detail { + +#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + +//! Remark: Automatically detects whether T has a nested allocator_type that is convertible from +//! Allocator. Meets the BinaryTypeTrait requirements ([meta.rqmts] 20.4.1). A program may +//! specialize this type to define uses_allocator::value as true for a T of user-defined type if T does not +//! have a nested allocator_type but is nonetheless constructible using the specified Allocator where either: +//! the first argument of a constructor has type allocator_arg_t and the second argument has type Alloc or +//! the last argument of a constructor has type Alloc. +//! +//! Result: uses_allocator::value== true if a type T::allocator_type +//! exists and either is_convertible::value != false or T::allocator_type +//! is an alias `erased_type`. False otherwise. +template +struct uses_allocator + : container_detail::uses_allocator_imp +{}; + +}} //namespace boost::container + +#endif //BOOST_CONTAINER_USES_ALLOCATOR_HPP diff --git a/boost/container/uses_allocator_fwd.hpp b/boost/container/uses_allocator_fwd.hpp new file mode 100644 index 0000000000..d8fe67fbfe --- /dev/null +++ b/boost/container/uses_allocator_fwd.hpp @@ -0,0 +1,73 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2015-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_USES_ALLOCATOR_FWD_HPP +#define BOOST_CONTAINER_USES_ALLOCATOR_FWD_HPP + +#include +#include + +//! \file +//! This header forward declares boost::container::constructible_with_allocator_prefix, +//! boost::container::constructible_with_allocator_suffix and +//! boost::container::uses_allocator. Also defines the following types: + +namespace boost { +namespace container { + +#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + + template + struct std_allocator_arg_holder + { + static ::std::allocator_arg_t *dummy; + }; + + template + ::std::allocator_arg_t *std_allocator_arg_holder::dummy; + +typedef const std::allocator_arg_t & allocator_arg_t; + +#else + +//! 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 Allocator requirements +typedef unspecified allocator_arg_t; + +#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + +//! The `erased_type` struct is an empty struct that serves as a placeholder for a type +//! T in situations where the actual type T is determined at runtime. For example, +//! the nested type, `allocator_type`, is an alias for `erased_type` in classes that +//! use type-erased allocators. +struct erased_type {}; + +//! A instance of type +//! allocator_arg_t +static allocator_arg_t allocator_arg = BOOST_CONTAINER_DOC1ST(unspecified, *std_allocator_arg_holder<>::dummy); + +// @cond + +template +struct constructible_with_allocator_suffix; + +template +struct constructible_with_allocator_prefix; + +template +struct uses_allocator; + +// @endcond + +}} // namespace boost { namespace container { + +#endif //BOOST_CONTAINER_USES_ALLOCATOR_HPP diff --git a/boost/container/vector.hpp b/boost/container/vector.hpp index 1cf44c8e27..e3bc1068aa 100644 --- a/boost/container/vector.hpp +++ b/boost/container/vector.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2005-2014. Distributed under the Boost +// (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 http://www.boost.org/LICENSE_1_0.txt) // @@ -216,7 +216,7 @@ 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) + vector_merge_cursor(T *pbeg, T *plast, BiDirValueIt valueit, Comp &cmp) : m_pbeg(pbeg), m_pcur(--plast), m_valueit(valueit), m_cmp(cmp) {} @@ -241,7 +241,7 @@ struct vector_merge_cursor T *const m_pbeg; T *m_pcur; BiDirValueIt m_valueit; - Comp m_cmp; + Comp &m_cmp; }; } //namespace container_detail { @@ -346,18 +346,17 @@ struct vector_alloc_holder 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)); + const bool all_storage_propagable = !allocator_traits_type::is_partially_propagable::value || + !allocator_traits_type::storage_is_unpropagable(from_alloc, p); + return all_storage_propagable && (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)); + const bool all_storage_propagable = !allocator_traits_type::is_partially_propagable::value || + !(allocator_traits_type::storage_is_unpropagable(l_a, l_p) || allocator_traits_type::storage_is_unpropagable(r_a, r_p)); + return all_storage_propagable && (propagate_allocator || allocator_traits_type::equal(l_a, r_a)); } //Constructor, does not throw @@ -646,7 +645,7 @@ struct vector_alloc_holder this->priv_deep_swap(x); } - void swap_resources(vector_alloc_holder &x) BOOST_NOEXCEPT_OR_NOTHROW + void swap_resources(vector_alloc_holder &) BOOST_NOEXCEPT_OR_NOTHROW { //Containers with version 0 allocators can't be moved without moving elements one by one throw_bad_alloc(); } @@ -819,7 +818,7 @@ class vector 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())); + (this->m_holder.alloc(), n, this->priv_raw_begin()); } //! Effects: Constructs a vector that will use a copy of allocator a @@ -838,7 +837,7 @@ class vector 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())); + (this->m_holder.alloc(), n, this->priv_raw_begin()); } //! Effects: Constructs a vector that will use a copy of allocator a @@ -855,7 +854,7 @@ class vector 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())); + (this->m_holder.alloc(), n, this->priv_raw_begin()); } //! Effects: Constructs a vector that will use a copy of allocator a @@ -874,7 +873,7 @@ class vector 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())); + (this->m_holder.alloc(), n, this->priv_raw_begin()); } //! Effects: Constructs a vector @@ -891,7 +890,7 @@ class vector this->num_alloc += n != 0; #endif boost::container::uninitialized_fill_alloc_n - (this->m_holder.alloc(), value, n, container_detail::to_raw_pointer(this->m_holder.start())); + (this->m_holder.alloc(), value, n, this->priv_raw_begin()); } //! Effects: Constructs a vector that will use a copy of allocator a @@ -908,7 +907,7 @@ class vector this->num_alloc += n != 0; #endif boost::container::uninitialized_fill_alloc_n - (this->m_holder.alloc(), value, n, container_detail::to_raw_pointer(this->m_holder.start())); + (this->m_holder.alloc(), value, n, this->priv_raw_begin()); } //! Effects: Constructs a vector @@ -952,8 +951,8 @@ class vector this->num_alloc += x.size() != 0; #endif ::boost::container::uninitialized_copy_alloc_n - ( this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.start()) - , x.size(), container_detail::to_raw_pointer(this->m_holder.start())); + ( this->m_holder.alloc(), x.priv_raw_begin() + , x.size(), this->priv_raw_begin()); } //! Effects: Move constructor. Moves x's resources to *this. @@ -1013,8 +1012,8 @@ class vector this->num_alloc += x.size() != 0; #endif ::boost::container::uninitialized_copy_alloc_n_source - ( this->m_holder.alloc(), container_detail::to_raw_pointer(x.m_holder.start()) - , x.size(), container_detail::to_raw_pointer(this->m_holder.start())); + ( this->m_holder.alloc(), x.priv_raw_begin() + , x.size(), this->priv_raw_begin()); } //! Effects: Move constructor using the specified allocator. @@ -1038,8 +1037,8 @@ class vector 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())); + ( this->m_holder.alloc(), x.priv_raw_begin() + , n, this->priv_raw_begin()); } } @@ -1052,7 +1051,7 @@ class vector ~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); + (this->get_stored_allocator(), this->priv_raw_begin(), this->m_holder.m_size); //vector_alloc_holder deallocates the data } @@ -1098,6 +1097,7 @@ class vector BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value || allocator_traits_type::is_always_equal::value) { + BOOST_ASSERT(&x != this); this->priv_move_assign(boost::move(x)); return *this; } @@ -1177,7 +1177,7 @@ class vector if (first == last){ //There are no more elements in the sequence, erase remaining - T* const end_pos = this->back_raw(); + T* const end_pos = this->priv_raw_end(); const size_type n = static_cast(end_pos - container_detail::iterator_to_raw_pointer(cur)); this->priv_destroy_last_n(n); } @@ -1513,7 +1513,10 @@ class vector //! //! Complexity: Constant. reference front() BOOST_NOEXCEPT_OR_NOTHROW - { return *this->m_holder.start(); } + { + BOOST_ASSERT(!this->empty()); + return *this->m_holder.start(); + } //! Requires: !empty() //! @@ -1524,7 +1527,10 @@ class vector //! //! Complexity: Constant. const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW - { return *this->m_holder.start(); } + { + BOOST_ASSERT(!this->empty()); + return *this->m_holder.start(); + } //! Requires: !empty() //! @@ -1536,7 +1542,7 @@ class vector //! Complexity: Constant. reference back() BOOST_NOEXCEPT_OR_NOTHROW { - BOOST_ASSERT(this->m_holder.m_size > 0); + BOOST_ASSERT(!this->empty()); return this->m_holder.start()[this->m_holder.m_size - 1]; } @@ -1550,7 +1556,7 @@ class vector //! Complexity: Constant. const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW { - BOOST_ASSERT(this->m_holder.m_size > 0); + BOOST_ASSERT(!this->empty()); return this->m_holder.start()[this->m_holder.m_size - 1]; } @@ -1578,7 +1584,8 @@ class vector //! Complexity: Constant. const_reference operator[](size_type n) const BOOST_NOEXCEPT_OR_NOTHROW { - return this->m_holder.start()[n]; + BOOST_ASSERT(this->m_holder.m_size > n); + return this->m_holder.start()[n]; } //! Requires: size() >= n. @@ -1627,7 +1634,10 @@ class vector //! //! Note: Non-standard extension size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW - { return this->priv_index_of(vector_iterator_get_ptr(p)); } + { + //Range check assert done in priv_index_of + return this->priv_index_of(vector_iterator_get_ptr(p)); + } //! Requires: begin() <= p <= end(). //! @@ -1640,7 +1650,10 @@ class vector //! //! 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)); } + { + //Range check assert done in priv_index_of + return this->priv_index_of(vector_iterator_get_ptr(p)); + } //! Requires: size() > n. //! @@ -1651,7 +1664,10 @@ class vector //! //! Complexity: Constant. reference at(size_type n) - { this->priv_check_range(n); return this->m_holder.start()[n]; } + { + this->priv_throw_if_out_of_range(n); + return this->m_holder.start()[n]; + } //! Requires: size() > n. //! @@ -1662,7 +1678,10 @@ class vector //! //! Complexity: Constant. const_reference at(size_type n) const - { this->priv_check_range(n); return this->m_holder.start()[n]; } + { + this->priv_throw_if_out_of_range(n); + return this->m_holder.start()[n]; + } ////////////////////////////////////////////// // @@ -1677,7 +1696,7 @@ class vector //! //! Complexity: Constant. T* data() BOOST_NOEXCEPT_OR_NOTHROW - { return container_detail::to_raw_pointer(this->m_holder.start()); } + { return this->priv_raw_begin(); } //! Returns: A pointer such that [data(),data() + size()) is a valid range. //! For a non-empty vector, data() == &front(). @@ -1686,7 +1705,7 @@ class vector //! //! Complexity: Constant. const T * data() const BOOST_NOEXCEPT_OR_NOTHROW - { return container_detail::to_raw_pointer(this->m_holder.start()); } + { return this->priv_raw_begin(); } ////////////////////////////////////////////// // @@ -1707,7 +1726,7 @@ class vector { 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(), this->back_raw(), ::boost::forward(args)...); + allocator_traits_type::construct(this->m_holder.alloc(), this->priv_raw_end(), ::boost::forward(args)...); ++this->m_holder.m_size; } else{ @@ -1731,7 +1750,7 @@ class vector 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)...); + allocator_traits_type::construct(this->m_holder.alloc(), this->priv_raw_end(), ::boost::forward(args)...); ++this->m_holder.m_size; } return is_room_enough; @@ -1750,6 +1769,7 @@ class vector template iterator emplace(const_iterator position, BOOST_FWD_REF(Args) ...args) { + BOOST_ASSERT(this->priv_in_range_or_end(position)); //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 @@ -1764,7 +1784,7 @@ class vector {\ 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->priv_raw_end() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ ++this->m_holder.m_size;\ }\ else{\ @@ -1780,7 +1800,7 @@ class vector 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->priv_raw_end() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ ++this->m_holder.m_size;\ }\ return is_room_enough;\ @@ -1789,6 +1809,7 @@ class vector 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)\ {\ + BOOST_ASSERT(this->priv_in_range_or_end(pos));\ 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));\ }\ @@ -1854,6 +1875,7 @@ class vector //! Complexity: Linear to n. iterator insert(const_iterator p, size_type n, const T& x) { + BOOST_ASSERT(this->priv_in_range_or_end(p)); container_detail::insert_n_copies_proxy proxy(x); return this->priv_forward_range_insert(vector_iterator_get_ptr(p), n, proxy); } @@ -1879,6 +1901,7 @@ class vector #endif ) { + BOOST_ASSERT(this->priv_in_range_or_end(pos)); const size_type n_pos = pos - this->cbegin(); iterator it(vector_iterator_get_ptr(pos)); for(;first != last; ++first){ @@ -1898,6 +1921,7 @@ class vector >::type * = 0 ) { + BOOST_ASSERT(this->priv_in_range_or_end(pos)); container_detail::insert_range_proxy proxy(first); return this->priv_forward_range_insert(vector_iterator_get_ptr(pos), boost::container::iterator_distance(first, last), proxy); } @@ -1922,6 +1946,7 @@ class vector template iterator insert(const_iterator pos, size_type num, InIt first, InIt last) { + BOOST_ASSERT(this->priv_in_range_or_end(pos)); BOOST_ASSERT(container_detail::is_input_iterator::value || num == static_cast(boost::container::iterator_distance(first, last))); (void)last; @@ -1940,17 +1965,19 @@ class vector //! Complexity: Linear to the range [il.begin(), il.end()). iterator insert(const_iterator position, std::initializer_list il) { + //Assertion done in insert() return this->insert(position, il.begin(), il.end()); } #endif - //! Effects: Removes the last element from the vector. + //! Effects: Removes the last element from the container. //! //! Throws: Nothing. //! //! Complexity: Constant time. void pop_back() BOOST_NOEXCEPT_OR_NOTHROW { + BOOST_ASSERT(!this->empty()); //Destroy last element this->priv_destroy_last(); } @@ -1963,9 +1990,10 @@ class vector //! last element. Constant if pos is the last element. iterator erase(const_iterator position) { + BOOST_ASSERT(this->priv_in_range(position)); 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 beg_ptr = this->priv_raw_begin(); 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); @@ -1980,8 +2008,10 @@ class vector //! plus linear to the elements between pos and the last element. iterator erase(const_iterator first, const_iterator last) { + BOOST_ASSERT(first == last || + (first < last && this->priv_in_range(first) && this->priv_in_range_or_end(last))); if (first != last){ - T* const old_end_ptr = this->back_raw(); + T* const old_end_ptr = this->priv_raw_end(); 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::container::move(last_ptr, old_end_ptr, first_ptr)); @@ -2128,7 +2158,7 @@ class vector { 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()); + T* const begin_ptr = this->priv_raw_begin(); size_type insertions_left = element_count; size_type prev_pos = old_size_pos; size_type old_hole_size = element_count; @@ -2184,48 +2214,55 @@ class vector void priv_merge(UniqueBool, BidirIt first, BidirIt last, Compare comp) { 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 + 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 + if(free_c < n){ + 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 if(!UniqueBool::value && free_c >= n){ + typedef container_detail::vector_merge_cursor inserter_t; + T* const pbeg = this->priv_raw_begin(); + return this->priv_insert_ordered_at(n, inserter_t(pbeg, pbeg + s, last, comp)); + } + else{ //UniqueBool::value == true and free_c >= n + std::size_t remaining = n; + static const std::size_t PosCount = 64u; + size_type positions[PosCount]; + size_type *indexes = 0; + while(remaining){ + //Query for room to store indexes in the remaining buffer 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); + boost::uintptr_t const addr = boost::uintptr_t(this->priv_raw_begin() + s + n); + boost::uintptr_t const capaddr = boost::uintptr_t(this->priv_raw_begin() + c); + boost::uintptr_t const aligned_addr = (addr + szt_align_mask) & ~szt_align_mask; + indexes = reinterpret_cast(aligned_addr); + std::size_t index_capacity = (aligned_addr >= capaddr) ? 0u : (capaddr - addr)/sizeof(size_type); + + //Capacity is constant, we're not going to change it + if(index_capacity < PosCount){ + indexes = positions; + index_capacity = PosCount; + } + if(index_capacity > remaining) + index_capacity = remaining; + BidirIt limit = first; + boost::container::iterator_advance(limit, index_capacity); + this->priv_insert_ordered_range(UniqueBool(), index_capacity, first, limit, indexes, comp); + first = limit; + remaining -= index_capacity; } } - else{ - this->insert(this->cend(), n, first, last); - } + } + else{ + this->insert(this->cend(), n, first, last); } } @@ -2245,7 +2282,7 @@ class vector //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 pbeg = this->priv_raw_begin(); T* const pend = pbeg + s; T* pcur = pbeg; size_type *position = positions; @@ -2284,7 +2321,7 @@ class vector 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()); + T* pbeg = this->priv_raw_begin(); size_type const old_size = this->size(); T* const pend = pbeg + old_size; T* d_first = container_detail::to_raw_pointer(new_storage); @@ -2338,9 +2375,6 @@ class vector 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); @@ -2357,8 +2391,8 @@ class vector this->capacity() < x.size()){ throw_bad_alloc(); } - T* const this_start = container_detail::to_raw_pointer(m_holder.start()); - T* const other_start = container_detail::to_raw_pointer(x.m_holder.start()); + T* const this_start = this->priv_raw_begin(); + T* const other_start = x.priv_raw_begin(); const size_type this_sz = m_holder.m_size; const size_type other_sz = static_cast(x.m_holder.m_size); boost::container::move_assign_range_alloc_n(this->m_holder.alloc(), other_start, other_sz, this_start, this_sz); @@ -2373,7 +2407,7 @@ class vector , container_detail::is_different >::type * = 0) { - //for move constructor, no aliasing (&x != this) is assummed. + //for move assignment, 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(); @@ -2414,8 +2448,8 @@ class vector this->capacity() < x.size()){ throw_bad_alloc(); } - T* const this_start = container_detail::to_raw_pointer(m_holder.start()); - T* const other_start = container_detail::to_raw_pointer(x.m_holder.start()); + T* const this_start = this->priv_raw_begin(); + T* const other_start = x.priv_raw_begin(); const size_type this_sz = m_holder.m_size; const size_type other_sz = static_cast(x.m_holder.m_size); boost::container::copy_assign_range_alloc_n(this->m_holder.alloc(), other_start, other_sz, this_start, this_sz); @@ -2439,8 +2473,7 @@ class vector this->shrink_to_fit(); } container_detail::assign_alloc(this_alloc, x_alloc, flag); - this->assign( container_detail::to_raw_pointer(x.m_holder.start()) - , container_detail::to_raw_pointer(x.m_holder.start() + x.m_holder.m_size)); + this->assign( x.priv_raw_begin(), x.priv_raw_end() ); } template //Template it to avoid it in explicit instantiations @@ -2452,7 +2485,7 @@ class vector { 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)){ + , x.get_stored_allocator(), x.m_holder.start(), propagate_alloc)){ //Just swap internals this->m_holder.swap_resources(x.m_holder); } @@ -2471,6 +2504,8 @@ class vector , 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())) ); + //Destroy remaining elements + big.erase(big.nth(common_elements), big.cend()); } //And now swap the allocator container_detail::swap_alloc(this->m_holder.alloc(), x.m_holder.alloc(), container_detail::bool_()); @@ -2492,7 +2527,7 @@ class vector 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, this->back_raw(), 0, this->priv_dummy_empty_proxy()); + ( container_detail::to_raw_pointer(p), new_cap, this->priv_raw_end(), 0, this->priv_dummy_empty_proxy()); } void priv_reserve_no_capacity(size_type new_cap, version_2) @@ -2514,7 +2549,7 @@ class vector } else{ //If there is no forward expansion, move objects, we will reuse insertion code T * const new_mem = container_detail::to_raw_pointer(ret); - T * const ins_pos = this->back_raw(); + T * const ins_pos = this->priv_raw_end(); if(reuse){ //Backwards (and possibly forward) expansion #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS ++this->num_expand_bwd; @@ -2536,7 +2571,7 @@ class vector { (void)moved; if(!(value_traits::trivial_dctr || (value_traits::trivial_dctr_after_move && moved))){ - value_type* const p = this->back_raw() - 1; + value_type* const p = this->priv_raw_end() - 1; allocator_traits_type::destroy(this->get_stored_allocator(), p); } --this->m_holder.m_size; @@ -2546,7 +2581,7 @@ class vector { BOOST_ASSERT(n <= this->m_holder.m_size); if(!value_traits::trivial_dctr){ - T* const destroy_pos = container_detail::to_raw_pointer(this->m_holder.start()) + (this->m_holder.m_size-n); + T* const destroy_pos = this->priv_raw_begin() + (this->m_holder.m_size-n); boost::container::destroy_alloc_n(this->get_stored_allocator(), destroy_pos, n); } this->m_holder.m_size -= n; @@ -2555,7 +2590,7 @@ class vector template void priv_uninitialized_construct_at_end(InpIt first, InpIt last) { - T* const old_end_pos = this->back_raw(); + T* const old_end_pos = this->priv_raw_end(); 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; } @@ -2563,13 +2598,14 @@ class vector 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); + (this->get_stored_allocator(), this->priv_raw_begin(), this->m_holder.m_size); this->m_holder.m_size = 0; } template iterator priv_insert(const const_iterator &p, BOOST_FWD_REF(U) x) { + BOOST_ASSERT(this->priv_in_range_or_end(p)); return this->priv_forward_range_insert ( vector_iterator_get_ptr(p), 1, container_detail::get_insert_value_proxy(::boost::forward(x))); } @@ -2586,9 +2622,7 @@ class vector 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() - , container_detail::to_raw_pointer(this->m_holder.start() + this->m_holder.m_size) - , ::boost::forward(u) ); + ( this->m_holder.alloc(), this->priv_raw_end(), ::boost::forward(u) ); ++this->m_holder.m_size; } else{ @@ -2645,8 +2679,7 @@ class vector #endif this->priv_forward_range_insert_new_allocation ( container_detail::to_raw_pointer(p), sz - , container_detail::to_raw_pointer(this->m_holder.start()) - , 0, this->priv_dummy_empty_proxy()); + , this->priv_raw_begin(), 0, this->priv_dummy_empty_proxy()); } } } @@ -2693,7 +2726,8 @@ class vector const size_type new_cap = this->m_holder.next_capacity(n); //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)); + 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 @@ -2708,7 +2742,7 @@ class vector { //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()); + const size_type n_pos = raw_pos - this->priv_raw_begin(); //There is not enough memory, allocate a new //buffer or expand the old one. @@ -2764,7 +2798,7 @@ class vector else{ //Expand forward 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()); + const size_type n_pos = raw_pos - this->priv_raw_begin(); this->priv_forward_range_insert_expand_forward(raw_pos, n, insert_range_proxy); return iterator(this->m_holder.start() + n_pos); } @@ -2849,7 +2883,7 @@ class vector BOOST_ASSERT(first_pos <= last_pos); BOOST_ASSERT(last_pos <= limit_pos); // - T* const begin_ptr = container_detail::to_raw_pointer(this->m_holder.start()); + T* const begin_ptr = this->priv_raw_begin(); T* const first_ptr = begin_ptr + first_pos; T* const last_ptr = begin_ptr + last_pos; @@ -2879,10 +2913,16 @@ class vector } private: + T *priv_raw_begin() const + { return container_detail::to_raw_pointer(m_holder.start()); } + + T* priv_raw_end() const + { return this->priv_raw_begin() + this->m_holder.m_size; } + template void priv_forward_range_insert_at_end_expand_forward(const size_type n, InsertionProxy insert_range_proxy) { - T* const old_finish = this->back_raw(); + T* const old_finish = this->priv_raw_end(); insert_range_proxy.uninitialized_copy_n_and_update(this->m_holder.alloc(), old_finish, n); this->m_holder.m_size += n; } @@ -2893,7 +2933,7 @@ class vector //n can't be 0, because there is nothing to do in that case if(BOOST_UNLIKELY(!n)) return; //There is enough memory - T* const old_finish = this->back_raw(); + T* const old_finish = this->priv_raw_end(); const size_type elems_after = old_finish - pos; if (!elems_after){ @@ -2944,10 +2984,10 @@ class vector //Initialize with [begin(), pos) old buffer //the start of the new buffer - T * const old_buffer = container_detail::to_raw_pointer(this->m_holder.start()); + T * const old_buffer = this->priv_raw_begin(); if(old_buffer){ new_finish = ::boost::container::uninitialized_move_alloc - (this->m_holder.alloc(), container_detail::to_raw_pointer(this->m_holder.start()), pos, old_finish = new_finish); + (this->m_holder.alloc(), this->priv_raw_begin(), pos, old_finish = new_finish); new_values_destroyer.increment_size(new_finish - old_finish); } //Initialize new objects, starting from previous point @@ -2981,7 +3021,7 @@ class vector { //n can be zero to just expand capacity //Backup old data - T* const old_start = container_detail::to_raw_pointer(this->m_holder.start()); + T* const old_start = this->priv_raw_begin(); const size_type old_size = this->m_holder.m_size; T* const old_finish = old_start + old_size; @@ -3291,7 +3331,7 @@ class vector } } - void priv_check_range(size_type n) const + void priv_throw_if_out_of_range(size_type n) const { //If n is out of range, throw an out_of_range exception if (n >= this->size()){ @@ -3299,6 +3339,16 @@ class vector } } + bool priv_in_range(const_iterator pos) const + { + return (this->begin() <= pos) && (pos < this->end()); + } + + bool priv_in_range_or_end(const_iterator pos) const + { + return (this->begin() <= pos) && (pos <= this->end()); + } + #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS public: unsigned int num_expand_fwd; diff --git a/boost/context/detail/config.hpp b/boost/context/detail/config.hpp index ea23a5f9db..0d5fa757fa 100644 --- a/boost/context/detail/config.hpp +++ b/boost/context/detail/config.hpp @@ -50,15 +50,16 @@ #endif #if defined(BOOST_USE_SEGMENTED_STACKS) -# if ! ( (defined(__GNUC__) && __GNUC__ > 3 && __GNUC_MINOR__ > 6) || \ - (defined(__clang__) && __clang_major__ > 2 && __clang_minor__ > 3) ) +# if ! ( (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) ) ) || \ + (defined(__clang__) && (__clang_major__ > 2 || ( __clang_major__ == 2 && __clang_minor__ > 3) ) ) ) # error "compiler does not support segmented_stack stacks" # endif # define BOOST_CONTEXT_SEGMENTS 10 #endif #undef BOOST_CONTEXT_NO_EXECUTION_CONTEXT -#if defined(BOOST_NO_CXX11_DECLTYPE) || \ +#if defined(BOOST_NO_CXX11_CONSTEXPR) || \ + defined(BOOST_NO_CXX11_DECLTYPE) || \ defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || \ defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) || \ defined(BOOST_NO_CXX11_HDR_TUPLE) || \ @@ -77,5 +78,11 @@ #if _MSC_VER > 1800 // _MSC_VER == 1800 -> MS Visual Studio 2013 # undef BOOST_CONTEXT_NO_EXECUTION_CONTEXT #endif +// workaround: Xcode clang feature detection +#if ! defined(__cpp_lib_integer_sequence) && __cpp_lib_integer_sequence < 201304 +# if _LIBCPP_STD_VER > 11 +# undef BOOST_CONTEXT_NO_EXECUTION_CONTEXT +# endif +#endif #endif // BOOST_CONTEXT_DETAIL_CONFIG_H diff --git a/boost/context/detail/invoke.hpp b/boost/context/detail/invoke.hpp index aba05d5cfb..f63d22c3ff 100644 --- a/boost/context/detail/invoke.hpp +++ b/boost/context/detail/invoke.hpp @@ -21,22 +21,60 @@ namespace boost { namespace context { namespace detail { -template< typename Fn, typename... Args > +# if _MSC_VER > 1800 +using std::invoke; +# else +template< typename Fn, typename ... Args > +typename std::enable_if< + ( ! std::is_member_pointer< Fn >::value && + ! std::is_function< Fn >::value && + ! std::is_function< typename std::remove_pointer< Fn >::type >::value + ), + typename std::result_of< Fn( Args ... ) >::type +>::type +invoke( Fn & fn, Args && ... args) { + return fn( std::forward< Args >( args) ... ); +} + +template< typename Fn, typename ... Args > typename std::enable_if< - std::is_member_pointer< typename std::decay< Fn >::type >::value, - typename std::result_of< Fn&&( Args && ...) >::type + ( std::is_member_pointer< Fn >::value && + ! std::is_function< Fn >::value && + ! std::is_function< typename std::remove_pointer< Fn >::type >::value + ), + typename std::result_of< Fn( Args ... ) >::type >::type -invoke( Fn && fn, Args && ... args) { - return std::mem_fn( fn)( std::forward< Args >( args) ...); +invoke( Fn & fn, Args && ... args) { + return std::mem_fn( fn)( std::forward< Args >( args) ... ); } template< typename Fn, typename ... Args > typename std::enable_if< - ! std::is_member_pointer< typename std::decay< Fn >::type >::value, - typename std::result_of< Fn&&( Args && ...) >::type + ( std::is_pointer< Fn >::value && + std::is_function< typename std::remove_pointer< Fn >::type >::value + ), + typename std::result_of< Fn( Args ... ) >::type >::type -invoke( Fn && fn, Args && ... args) { - return std::forward< Fn >( fn)( std::forward< Args >( args) ...); +invoke( Fn fn, Args && ... args) { + return fn( std::forward< Args >( args) ... ); +} +# endif + +template< typename Fn, typename Tpl, std::size_t... I > +decltype( auto) do_invoke( Fn && fn, Tpl && tpl, std::index_sequence< I ... >) { + return invoke( fn, + // std::tuple_element<> does not perfect forwarding + std::forward< decltype( std::get< I >( std::declval< typename std::decay< Tpl >::type >() ) ) >( + std::get< I >( std::forward< typename std::decay< Tpl >::type >( tpl) ) ) ... ); +} + + +template< typename Fn, typename Tpl > +decltype( auto) do_invoke( Fn && fn, Tpl && tpl) { + constexpr auto Size = std::tuple_size< typename std::decay< Tpl >::type >::value; + return do_invoke( std::forward< Fn >( fn), + std::forward< Tpl >( tpl), + std::make_index_sequence< Size >{}); } }}} diff --git a/boost/context/execution_context.ipp b/boost/context/execution_context.ipp index 8832d75c20..ec5443297f 100644 --- a/boost/context/execution_context.ipp +++ b/boost/context/execution_context.ipp @@ -12,11 +12,13 @@ #if ! defined(BOOST_CONTEXT_NO_EXECUTION_CONTEXT) # include +# include # include # include # include # include # include +# include # include # include @@ -26,6 +28,7 @@ # include # include +# include # include # include @@ -45,142 +48,148 @@ void __splitstack_setcontext( void * [BOOST_CONTEXT_SEGMENTS]); namespace boost { namespace context { +namespace detail { -struct preallocated { - void * sp; - std::size_t size; - stack_context sctx; +struct activation_record { + typedef boost::intrusive_ptr< activation_record > ptr_t; - preallocated( void * sp_, std::size_t size_, stack_context sctx_) noexcept : - sp( sp_), size( size_), sctx( sctx_) { - } -}; + enum flag_t { + flag_main_ctx = 1 << 1, + flag_preserve_fpu = 1 << 2 + }; -class BOOST_CONTEXT_DECL execution_context { -private: - struct activation_record { - typedef boost::intrusive_ptr< activation_record > ptr_t; - - enum flag_t { - flag_main_ctx = 1 << 1, - flag_preserve_fpu = 1 << 2, - flag_segmented_stack = 1 << 3 - }; - - thread_local static activation_record toplevel_rec; - thread_local static ptr_t current_rec; - - std::size_t use_count; - fcontext_t fctx; - stack_context sctx; - int flags; - - // used for toplevel-context - // (e.g. main context, thread-entry context) - activation_record() noexcept : - use_count( 1), - fctx( nullptr), - sctx(), - flags( flag_main_ctx) { - } - - activation_record( fcontext_t fctx_, stack_context sctx_, bool use_segmented_stack) noexcept : - use_count( 0), - fctx( fctx_), - sctx( sctx_), - flags( use_segmented_stack ? flag_segmented_stack : 0) { - } - - virtual ~activation_record() noexcept = default; - - void resume( bool fpu = false) noexcept { - // store current activation record in local variable - activation_record * from = current_rec.get(); - // store `this` in static, thread local pointer - // `this` will become the active (running) context - // returned by execution_context::current() - current_rec = this; - // set FPU flag - if (fpu) { - from->flags |= flag_preserve_fpu; - this->flags |= flag_preserve_fpu; - } else { - from->flags &= ~flag_preserve_fpu; - this->flags &= ~flag_preserve_fpu; - } + thread_local static ptr_t current_rec; + + std::atomic< std::size_t > use_count; + fcontext_t fctx; + stack_context sctx; + int flags; + + // used for toplevel-context + // (e.g. main context, thread-entry context) + activation_record() noexcept : + use_count( 0), + fctx( nullptr), + sctx(), + flags( flag_main_ctx) { + } + + activation_record( fcontext_t fctx_, stack_context sctx_) noexcept : + use_count( 0), + fctx( fctx_), + sctx( sctx_), + flags( 0) { + } + + virtual ~activation_record() noexcept = default; + + void * resume( void * vp, bool fpu) noexcept { + // store current activation record in local variable + activation_record * from = current_rec.get(); + // store `this` in static, thread local pointer + // `this` will become the active (running) context + // returned by execution_context::current() + current_rec = this; + // set FPU flag + if (fpu) { + from->flags |= flag_preserve_fpu; + this->flags |= flag_preserve_fpu; + } else { + from->flags &= ~flag_preserve_fpu; + this->flags &= ~flag_preserve_fpu; + } # if defined(BOOST_USE_SEGMENTED_STACKS) - if ( 0 != (flags & flag_segmented_stack) ) { - // adjust segmented stack properties - __splitstack_getcontext( from->sctx.segments_ctx); - __splitstack_setcontext( sctx.segments_ctx); - // context switch from parent context to `this`-context - jump_fcontext( & from->fctx, fctx, reinterpret_cast< intptr_t >( this), fpu); - // parent context resumed - // adjust segmented stack properties - __splitstack_setcontext( from->sctx.segments_ctx); - } else { - // context switch from parent context to `this`-context - jump_fcontext( & from->fctx, fctx, reinterpret_cast< intptr_t >( this), fpu); - // parent context resumed - } -# else - // context switch from parent context to `this`-context - jump_fcontext( & from->fctx, fctx, reinterpret_cast< intptr_t >( this), fpu); - // parent context resumed + // adjust segmented stack properties + __splitstack_getcontext( from->sctx.segments_ctx); + __splitstack_setcontext( sctx.segments_ctx); # endif - } + // context switch from parent context to `this`-context + intptr_t ret = jump_fcontext( & from->fctx, fctx, reinterpret_cast< intptr_t >( vp), fpu); + // parent context resumed + return reinterpret_cast< void * >( ret); + } - virtual void deallocate() {} + virtual void deallocate() { + delete this; + } - friend void intrusive_ptr_add_ref( activation_record * ar) { - ++ar->use_count; - } + friend void intrusive_ptr_add_ref( activation_record * ar) { + ++ar->use_count; + } - friend void intrusive_ptr_release( activation_record * ar) { - BOOST_ASSERT( nullptr != ar); + friend void intrusive_ptr_release( activation_record * ar) { + BOOST_ASSERT( nullptr != ar); - if ( 0 == --ar->use_count) { - ar->deallocate(); - } + if ( 0 == --ar->use_count) { + ar->deallocate(); } - }; + } +}; - template< typename Fn, typename StackAlloc > - class capture_record : public activation_record { - private: - StackAlloc salloc_; - Fn fn_; - - static void destroy( capture_record * p) { - StackAlloc salloc( p->salloc_); - stack_context sctx( p->sctx); - // deallocate activation record - p->~capture_record(); - // destroy stack with stack allocator - salloc.deallocate( sctx); - } +struct activation_record_initializer { + activation_record_initializer(); + ~activation_record_initializer(); +}; - public: - explicit capture_record( stack_context sctx, StackAlloc const& salloc, fcontext_t fctx, Fn && fn, bool use_segmented_stack) noexcept : - activation_record( fctx, sctx, use_segmented_stack), - salloc_( salloc), - fn_( std::forward< Fn >( fn) ) { - } +template< typename Fn, typename Tpl, typename StackAlloc > +class capture_record : public activation_record { +private: + StackAlloc salloc_; + Fn fn_; + Tpl tpl_; + activation_record * caller_; + + static void destroy( capture_record * p) { + StackAlloc salloc( p->salloc_); + stack_context sctx( p->sctx); + // deallocate activation record + p->~capture_record(); + // destroy stack with stack allocator + salloc.deallocate( sctx); + } - void deallocate() override final { - destroy( this); - } +public: + explicit capture_record( + stack_context sctx, StackAlloc const& salloc, + fcontext_t fctx, + Fn && fn, Tpl && tpl, + activation_record * caller) noexcept : + activation_record( fctx, sctx), + salloc_( salloc), + fn_( std::forward< Fn >( fn) ), + tpl_( std::forward< Tpl >( tpl) ), + caller_( caller) { + } + + void deallocate() override final { + destroy( this); + } - void run() noexcept { - try { - fn_(); - } catch (...) { - std::terminate(); - } - BOOST_ASSERT( 0 == (flags & flag_main_ctx) ); + void run() noexcept { + try { + void * vp = caller_->resume( caller_, true); + do_invoke( fn_, std::tuple_cat( tpl_, std::tie( vp) ) ); + } catch (...) { + std::terminate(); } - }; + BOOST_ASSERT( 0 == (flags & flag_main_ctx) ); + } +}; + +} + +struct preallocated { + void * sp; + std::size_t size; + stack_context sctx; + preallocated( void * sp_, std::size_t size_, stack_context sctx_) noexcept : + sp( sp_), size( size_), sctx( sctx_) { + } +}; + +class BOOST_CONTEXT_DECL execution_context { +private: // tampoline function // entered if the execution context // is resumed for the first time @@ -195,13 +204,15 @@ private: ar->run(); } - typedef boost::intrusive_ptr< activation_record > ptr_t; + typedef boost::intrusive_ptr< detail::activation_record > ptr_t; ptr_t ptr_; - template< typename StackAlloc, typename Fn > - static activation_record * create_context( StackAlloc salloc, Fn && fn, bool use_segmented_stack) { - typedef capture_record< Fn, StackAlloc > capture_t; + template< typename StackAlloc, typename Fn ,typename Tpl > + static detail::activation_record * create_context( + StackAlloc salloc, + Fn && fn, Tpl && tpl) { + typedef detail::capture_record< Fn, Tpl, StackAlloc > capture_t; stack_context sctx( salloc.allocate() ); // reserve space for control structure @@ -223,13 +234,18 @@ private: // create fast-context fcontext_t fctx = make_fcontext( sp, size, & execution_context::entry_func< capture_t >); BOOST_ASSERT( nullptr != fctx); + // get current activation record + ptr_t curr = execution_context::current().ptr_; // placment new for control structure on fast-context stack - return new ( sp) capture_t( sctx, salloc, fctx, std::forward< Fn >( fn), use_segmented_stack); + return new ( sp) capture_t( + sctx, salloc, fctx, std::forward< Fn >( fn), std::forward< Tpl >( tpl), curr.get() ); } - template< typename StackAlloc, typename Fn > - static activation_record * create_context( preallocated palloc, StackAlloc salloc, Fn && fn, bool use_segmented_stack) { - typedef capture_record< Fn, StackAlloc > capture_t; + template< typename StackAlloc, typename Fn , typename Tpl > + static detail::activation_record * create_context( + preallocated palloc, StackAlloc salloc, + Fn && fn, Tpl && tpl) { + typedef detail::capture_record< Fn, Tpl, StackAlloc > capture_t; // reserve space for control structure #if defined(BOOST_NO_CXX14_CONSTEXPR) || defined(BOOST_NO_CXX11_STD_ALIGN) @@ -250,119 +266,181 @@ private: // create fast-context fcontext_t fctx = make_fcontext( sp, size, & execution_context::entry_func< capture_t >); BOOST_ASSERT( nullptr != fctx); + // get current activation record + ptr_t curr = execution_context::current().ptr_; // placment new for control structure on fast-context stack - return new ( sp) capture_t( palloc.sctx, salloc, fctx, std::forward< Fn >( fn), use_segmented_stack); - } - - template< typename StackAlloc, typename Fn, typename Tpl, std::size_t ... I > - static activation_record * create_capture_record( StackAlloc salloc, - Fn && fn_, Tpl && tpl_, - std::index_sequence< I ... >, - bool use_segmented_stack) { - return create_context( - salloc, - // lambda, executed in new execution context - [fn=std::forward< Fn >( fn_),tpl=std::forward< Tpl >( tpl_)] () mutable -> decltype( auto) { - detail::invoke( fn, - // non-type template parameter pack used to extract the - // parameters (arguments) from the tuple and pass them to fn - // via parameter pack expansion - // std::tuple_element<> does not perfect forwarding - std::forward< decltype( std::get< I >( std::declval< Tpl >() ) ) >( - std::get< I >( std::forward< Tpl >( tpl) ) ) ... ); - }, - use_segmented_stack); - } - - template< typename StackAlloc, typename Fn, typename Tpl, std::size_t ... I > - static activation_record * create_capture_record( preallocated palloc, StackAlloc salloc, - Fn && fn_, Tpl && tpl_, - std::index_sequence< I ... >, - bool use_segmented_stack) { - return create_context( - palloc, salloc, - // lambda, executed in new execution context - [fn=std::forward< Fn >( fn_),tpl=std::forward< Tpl >( tpl_)] () mutable -> decltype( auto) { - detail::invoke( fn, - // non-type template parameter pack used to extract the - // parameters (arguments) from the tuple and pass them to fn - // via parameter pack expansion - // std::tuple_element<> does not perfect forwarding - std::forward< decltype( std::get< I >( std::declval< Tpl >() ) ) >( - std::get< I >( std::forward< Tpl >( tpl) ) ) ... ); - }, - use_segmented_stack); + return new ( sp) capture_t( + palloc.sctx, salloc, fctx, std::forward< Fn >( fn), std::forward< Tpl >( tpl), curr.get() ); } execution_context() : // default constructed with current activation_record - ptr_( activation_record::current_rec) { + ptr_( detail::activation_record::current_rec) { } public: - static execution_context current() noexcept { - return execution_context(); - } + static execution_context current() noexcept; # if defined(BOOST_USE_SEGMENTED_STACKS) template< typename Fn, typename ... Args > - explicit execution_context( segmented_stack salloc, Fn && fn, Args && ... args) : + explicit execution_context( Fn && fn, Args && ... args) : // deferred execution of fn and its arguments // arguments are stored in std::tuple<> // non-type template parameter pack via std::index_sequence_for<> // preserves the number of arguments // used to extract the function arguments from std::tuple<> - ptr_( create_capture_record( salloc, - std::forward< Fn >( fn), - std::make_tuple( std::forward< Args >( args) ... ), - std::index_sequence_for< Args ... >(), true) ) { + ptr_( create_context( segmented_stack(), + std::forward< Fn >( fn), + std::make_tuple( std::forward< Args >( args) ...) ) ) { + ptr_->resume( ptr_.get(), true); } template< typename Fn, typename ... Args > - explicit execution_context( preallocated palloc, segmented_stack salloc, Fn && fn, Args && ... args) : + explicit execution_context( std::allocator_arg_t, segmented_stack salloc, Fn && fn, Args && ... args) : // deferred execution of fn and its arguments // arguments are stored in std::tuple<> // non-type template parameter pack via std::index_sequence_for<> // preserves the number of arguments // used to extract the function arguments from std::tuple<> - ptr_( create_capture_record( palloc, salloc, - std::forward< Fn >( fn), - std::make_tuple( std::forward< Args >( args) ... ), - std::index_sequence_for< Args ... >(), true) ) { + ptr_( create_context( salloc, + std::forward< Fn >( fn), + std::make_tuple( std::forward< Args >( args) ...) ) ) { + ptr_->resume( ptr_.get(), true); + } + + template< typename Fn, typename ... Args > + explicit execution_context( std::allocator_arg_t, preallocated palloc, segmented_stack salloc, Fn && fn, Args && ... args) : + // deferred execution of fn and its arguments + // arguments are stored in std::tuple<> + // non-type template parameter pack via std::index_sequence_for<> + // preserves the number of arguments + // used to extract the function arguments from std::tuple<> + ptr_( create_context( palloc, salloc, + std::forward< Fn >( fn), + std::make_tuple( std::forward< Args >( args) ...) ) ) { + ptr_->resume( ptr_.get(), true); + } +# else + template< typename Fn, typename ... Args > + explicit execution_context( Fn && fn, Args && ... args) : + // deferred execution of fn and its arguments + // arguments are stored in std::tuple<> + // non-type template parameter pack via std::index_sequence_for<> + // preserves the number of arguments + // used to extract the function arguments from std::tuple<> + ptr_( create_context( fixedsize_stack(), + std::forward< Fn >( fn), + std::make_tuple( std::forward< Args >( args) ...) ) ) { + ptr_->resume( ptr_.get(), true); } -# endif template< typename StackAlloc, typename Fn, typename ... Args > - explicit execution_context( StackAlloc salloc, Fn && fn, Args && ... args) : + explicit execution_context( std::allocator_arg_t, StackAlloc salloc, Fn && fn, Args && ... args) : // deferred execution of fn and its arguments // arguments are stored in std::tuple<> // non-type template parameter pack via std::index_sequence_for<> // preserves the number of arguments // used to extract the function arguments from std::tuple<> - ptr_( create_capture_record( salloc, - std::forward< Fn >( fn), - std::make_tuple( std::forward< Args >( args) ... ), - std::index_sequence_for< Args ... >(), false) ) { + ptr_( create_context( salloc, + std::forward< Fn >( fn), + std::make_tuple( std::forward< Args >( args) ...) ) ) { + ptr_->resume( ptr_.get(), true); } template< typename StackAlloc, typename Fn, typename ... Args > - explicit execution_context( preallocated palloc, StackAlloc salloc, Fn && fn, Args && ... args) : + explicit execution_context( std::allocator_arg_t, preallocated palloc, StackAlloc salloc, Fn && fn, Args && ... args) : // deferred execution of fn and its arguments // arguments are stored in std::tuple<> // non-type template parameter pack via std::index_sequence_for<> // preserves the number of arguments // used to extract the function arguments from std::tuple<> - ptr_( create_capture_record( palloc, salloc, - std::forward< Fn >( fn), - std::make_tuple( std::forward< Args >( args) ... ), - std::index_sequence_for< Args ... >(), false) ) { + ptr_( create_context( palloc, salloc, + std::forward< Fn >( fn), + std::make_tuple( std::forward< Args >( args) ...) ) ) { + ptr_->resume( ptr_.get(), true); + } +# endif + + execution_context( execution_context const& other) noexcept : + ptr_( other.ptr_) { } - void operator()( bool preserve_fpu = false) noexcept { - ptr_->resume( preserve_fpu); + execution_context( execution_context && other) noexcept : + ptr_( other.ptr_) { + other.ptr_.reset(); + } + + execution_context & operator=( execution_context const& other) noexcept { + if ( this != & other) { + ptr_ = other.ptr_; + } + return * this; + } + + execution_context & operator=( execution_context && other) noexcept { + if ( this != & other) { + ptr_ = other.ptr_; + other.ptr_.reset(); + } + return * this; + } + + void * operator()( void * vp = nullptr, bool preserve_fpu = false) noexcept { + return ptr_->resume( vp, preserve_fpu); + } + + explicit operator bool() const noexcept { + return nullptr != ptr_.get(); + } + + bool operator!() const noexcept { + return nullptr == ptr_.get(); + } + + bool operator==( execution_context const& other) const noexcept { + return ptr_ == other.ptr_; + } + + bool operator!=( execution_context const& other) const noexcept { + return ptr_ != other.ptr_; + } + + bool operator<( execution_context const& other) const noexcept { + return ptr_ < other.ptr_; + } + + bool operator>( execution_context const& other) const noexcept { + return other.ptr_ < ptr_; + } + + bool operator<=( execution_context const& other) const noexcept { + return ! ( * this > other); + } + + bool operator>=( execution_context const& other) const noexcept { + return ! ( * this < other); + } + + template< typename charT, class traitsT > + friend std::basic_ostream< charT, traitsT > & + operator<<( std::basic_ostream< charT, traitsT > & os, execution_context const& other) { + if ( nullptr != other.ptr_) { + return os << other.ptr_; + } else { + return os << "{not-valid}"; + } + } + + void swap( execution_context & other) noexcept { + ptr_.swap( other.ptr_); } }; +inline +void swap( execution_context & l, execution_context & r) noexcept { + l.swap( r); +} + }} # ifdef BOOST_HAS_ABI_HEADERS diff --git a/boost/context/execution_context_winfib.ipp b/boost/context/execution_context_winfib.ipp index 7b0a92b550..1b106fa245 100644 --- a/boost/context/execution_context_winfib.ipp +++ b/boost/context/execution_context_winfib.ipp @@ -13,6 +13,8 @@ #include +#include +#include #include #include #include @@ -25,6 +27,7 @@ #include #include +#include #include #ifdef BOOST_HAS_ABI_HEADERS @@ -33,132 +36,162 @@ namespace boost { namespace context { +namespace detail { -struct preallocated { - void * sp; - std::size_t size; - stack_context sctx; +struct activation_record { + typedef boost::intrusive_ptr< activation_record > ptr_t; - preallocated( void * sp_, std::size_t size_, stack_context sctx_) noexcept : - sp( sp_), size( size_), sctx( sctx_) { - } -}; + enum flag_t { + flag_main_ctx = 1 << 1, + flag_preserve_fpu = 1 << 2, + flag_segmented_stack = 1 << 3 + }; -class BOOST_CONTEXT_DECL execution_context { -private: - struct activation_record { - typedef boost::intrusive_ptr< activation_record > ptr_t; - - enum flag_t { - flag_main_ctx = 1 << 1, - flag_preserve_fpu = 1 << 2, - flag_segmented_stack = 1 << 3 - }; - - thread_local static activation_record toplevel_rec; - thread_local static ptr_t current_rec; - - std::size_t use_count; - LPVOID fiber; - stack_context sctx; - int flags; - - // used for toplevel-context - // (e.g. main context, thread-entry context) - activation_record() noexcept : - use_count( 1), - fiber( nullptr), - sctx(), - flags( flag_main_ctx) { - } - - activation_record( stack_context sctx_, bool use_segmented_stack) noexcept : - use_count( 0), - fiber( nullptr), - sctx( sctx_), - flags( use_segmented_stack ? flag_segmented_stack : 0) { - } - - virtual ~activation_record() noexcept = default; - - void resume() noexcept { - // store current activation record in local variable - activation_record * from = current_rec.get(); - // store `this` in static, thread local pointer - // `this` will become the active (running) context - // returned by execution_context::current() - current_rec = this; - // context switch from parent context to `this`-context + thread_local static ptr_t current_rec; + + std::atomic< std::size_t > use_count; + LPVOID fiber; + stack_context sctx; + void * data; + int flags; + + // used for toplevel-context + // (e.g. main context, thread-entry context) + activation_record() noexcept : + use_count( 0), + fiber( nullptr), + sctx(), + flags( flag_main_ctx +# if defined(BOOST_USE_SEGMENTED_STACKS) + | flag_segmented_stack +# endif + ) { + } + + activation_record( stack_context sctx_, bool use_segmented_stack) noexcept : + use_count( 0), + fiber( nullptr), + sctx( sctx_), + data( nullptr), + flags( use_segmented_stack ? flag_segmented_stack : 0) { + } + + virtual ~activation_record() noexcept = default; + + void * resume( void * vp, bool fpu) noexcept { + // store current activation record in local variable + activation_record * from = current_rec.get(); + // store `this` in static, thread local pointer + // `this` will become the active (running) context + // returned by execution_context::current() + current_rec = this; + // context switch from parent context to `this`-context #if ( _WIN32_WINNT > 0x0600) - if ( ::IsThreadAFiber() ) { - from->fiber = ::GetCurrentFiber(); - } else { - from->fiber = ::ConvertThreadToFiber( nullptr); - } -#else + if ( ::IsThreadAFiber() ) { + from->fiber = ::GetCurrentFiber(); + } else { from->fiber = ::ConvertThreadToFiber( nullptr); - if ( nullptr == from->fiber) { - DWORD err = ::GetLastError(); - BOOST_ASSERT( ERROR_ALREADY_FIBER == err); - from->fiber = ::GetCurrentFiber(); - BOOST_ASSERT( nullptr != from->fiber); - BOOST_ASSERT( reinterpret_cast< LPVOID >( 0x1E00) != from->fiber); - } -#endif - ::SwitchToFiber( fiber); } +#else + from->fiber = ::ConvertThreadToFiber( nullptr); + if ( nullptr == from->fiber) { + DWORD err = ::GetLastError(); + BOOST_ASSERT( ERROR_ALREADY_FIBER == err); + from->fiber = ::GetCurrentFiber(); + BOOST_ASSERT( nullptr != from->fiber); + BOOST_ASSERT( reinterpret_cast< LPVOID >( 0x1E00) != from->fiber); + } +#endif + // store passed argument (void pointer) + data = vp; + // context switch + ::SwitchToFiber( fiber); + // access the activation-record of the current fiber + activation_record * ar = static_cast< activation_record * >( GetFiberData() ); + return nullptr != ar ? ar->data : nullptr; + } - virtual void deallocate() {} + virtual void deallocate() { + delete this; + } - friend void intrusive_ptr_add_ref( activation_record * ar) { - ++ar->use_count; - } + friend void intrusive_ptr_add_ref( activation_record * ar) { + ++ar->use_count; + } - friend void intrusive_ptr_release( activation_record * ar) { - BOOST_ASSERT( nullptr != ar); + friend void intrusive_ptr_release( activation_record * ar) { + BOOST_ASSERT( nullptr != ar); - if ( 0 == --ar->use_count) { - ar->deallocate(); - } + if ( 0 == --ar->use_count) { + ar->deallocate(); } - }; + } +}; - template< typename Fn, typename StackAlloc > - class capture_record : public activation_record { - private: - StackAlloc salloc_; - Fn fn_; - - static void destroy( capture_record * p) { - StackAlloc salloc( p->salloc_); - stack_context sctx( p->sctx); - // deallocate activation record - p->~capture_record(); - // destroy stack with stack allocator - salloc.deallocate( sctx); - } +struct activation_record_initializer { + activation_record_initializer(); + ~activation_record_initializer(); +}; - public: - explicit capture_record( stack_context sctx, StackAlloc const& salloc, Fn && fn, bool use_segmented_stack) noexcept : - activation_record( sctx, use_segmented_stack), - salloc_( salloc), - fn_( std::forward< Fn >( fn) ) { - } +template< typename Fn, typename Tpl, typename StackAlloc > +class capture_record : public activation_record { +private: + StackAlloc salloc_; + Fn fn_; + Tpl tpl_; + activation_record * caller_; + + static void destroy( capture_record * p) { + StackAlloc salloc( p->salloc_); + stack_context sctx( p->sctx); + // deallocate activation record + p->~capture_record(); + // destroy stack with stack allocator + salloc.deallocate( sctx); + } - void deallocate() override final { - destroy( this); - } +public: + explicit capture_record( + stack_context sctx, StackAlloc const& salloc, + Fn && fn, Tpl && tpl, + activation_record * caller, + bool use_segmented_stack) noexcept : + activation_record( sctx, use_segmented_stack), + salloc_( salloc), + fn_( std::forward< Fn >( fn) ), + tpl_( std::forward< Tpl >( tpl) ), + caller_( caller) { + } - void run() noexcept { - try { - fn_(); - } catch (...) { - std::terminate(); - } - BOOST_ASSERT( 0 == (flags & flag_main_ctx) ); + void deallocate() override final { + destroy( this); + } + + void run() noexcept { + try { + void * vp = caller_->resume( caller_, true); + do_invoke( fn_, std::tuple_cat( tpl_, std::tie( vp) ) ); + } catch (...) { + std::terminate(); } - }; + BOOST_ASSERT( 0 == (flags & flag_main_ctx) ); + } +}; +} + +struct preallocated { + void * sp; + std::size_t size; + stack_context sctx; + + preallocated( void * sp_, std::size_t size_, stack_context sctx_) noexcept : + sp( sp_), size( size_), sctx( sctx_) { + } +}; + +class BOOST_CONTEXT_DECL execution_context { +private: // tampoline function // entered if the execution context // is resumed for the first time @@ -173,23 +206,30 @@ private: ::DeleteFiber( ar->fiber); } - typedef boost::intrusive_ptr< activation_record > ptr_t; + typedef boost::intrusive_ptr< detail::activation_record > ptr_t; ptr_t ptr_; - template< typename StackAlloc, typename Fn > - static activation_record * create_context( StackAlloc salloc, Fn && fn, bool use_segmented_stack) { - typedef capture_record< Fn, StackAlloc > capture_t; + template< typename StackAlloc, typename Fn ,typename Tpl > + static detail::activation_record * create_context( + StackAlloc salloc, + Fn && fn, Tpl && tpl, + bool use_segmented_stack) { + typedef detail::capture_record< Fn, Tpl, StackAlloc > capture_t; // hackish std::size_t fsize = salloc.size_; - salloc.size_ = sizeof( capture_t); + // protected_fixedsize_stack needs at least 2*page-size + salloc.size_ = ( std::max)( sizeof( capture_t), 2 * stack_traits::page_size() ); stack_context sctx( salloc.allocate() ); // reserve space for control structure void * sp = static_cast< char * >( sctx.sp) - sizeof( capture_t); - // placment new for control structure on fast-context stack - capture_t * cr = new ( sp) capture_t( sctx, salloc, std::forward< Fn >( fn), use_segmented_stack); + // get current activation record + ptr_t curr = execution_context::current().ptr_; + // placement new for control structure on fast-context stack + capture_t * cr = new ( sp) capture_t( + sctx, salloc, std::forward< Fn >( fn), std::forward< Tpl >( tpl), curr.get(), use_segmented_stack); // create fiber // use default stacksize cr->fiber = ::CreateFiber( fsize, execution_context::entry_func< capture_t >, cr); @@ -197,18 +237,25 @@ private: return cr; } - template< typename StackAlloc, typename Fn > - static activation_record * create_context( preallocated palloc, StackAlloc salloc, Fn && fn, bool use_segmented_stack) { - typedef capture_record< Fn, StackAlloc > capture_t; + template< typename StackAlloc, typename Fn , typename Tpl > + static detail::activation_record * create_context( + preallocated palloc, StackAlloc salloc, + Fn && fn, Tpl && tpl, + bool use_segmented_stack) { + typedef detail::capture_record< Fn, Tpl, StackAlloc > capture_t; // hackish std::size_t fsize = salloc.size_; - salloc.size_ = sizeof( capture_t); + // protected_fixedsize_stack needs at least 2*page-size + salloc.size_ = ( std::max)( sizeof( capture_t), 2 * stack_traits::page_size() ); // reserve space for control structure void * sp = static_cast< char * >( palloc.sp) - sizeof( capture_t); - // placment new for control structure on fast-context stack - capture_t * cr = new ( sp) capture_t( palloc.sctx, salloc, std::forward< Fn >( fn), use_segmented_stack); + // get current activation record + ptr_t curr = execution_context::current().ptr_; + // placement new for control structure on fast-context stack + capture_t * cr = new ( sp) capture_t( + palloc.sctx, salloc, std::forward< Fn >( fn), std::forward< Tpl >( tpl), curr.get(), use_segmented_stack); // create fiber // use default stacksize cr->fiber = ::CreateFiber( fsize, execution_context::entry_func< capture_t >, cr); @@ -216,84 +263,90 @@ private: return cr; } - template< typename StackAlloc, typename Fn, typename Tpl, std::size_t ... I > - static activation_record * create_capture_record( StackAlloc salloc, - Fn && fn_, Tpl && tpl_, - std::index_sequence< I ... >, - bool use_segmented_stack) { - return create_context( - salloc, - // lambda, executed in new execution context - [fn=std::forward< Fn >( fn_),tpl=std::forward< Tpl >( tpl_)] () mutable -> decltype( auto) { - detail::invoke( fn, - // non-type template parameter pack used to extract the - // parameters (arguments) from the tuple and pass them to fn - // via parameter pack expansion - // std::tuple_element<> does not perfect forwarding - std::forward< decltype( std::get< I >( std::declval< Tpl >() ) ) >( - std::get< I >( std::forward< Tpl >( tpl) ) ) ... ); - }, - use_segmented_stack); - } - - template< typename StackAlloc, typename Fn, typename Tpl, std::size_t ... I > - static activation_record * create_capture_record( preallocated palloc, StackAlloc salloc, - Fn && fn_, Tpl && tpl_, - std::index_sequence< I ... >, - bool use_segmented_stack) { - return create_context( - palloc, salloc, - // lambda, executed in new execution context - [fn=std::forward< Fn >( fn_),tpl=std::forward< Tpl >( tpl_)] () mutable -> decltype( auto) { - detail::invoke( fn, - // non-type template parameter pack used to extract the - // parameters (arguments) from the tuple and pass them to fn - // via parameter pack expansion - // std::tuple_element<> does not perfect forwarding - std::forward< decltype( std::get< I >( std::declval< Tpl >() ) ) >( - std::get< I >( std::forward< Tpl >( tpl) ) ) ... ); - }, - use_segmented_stack); - } - execution_context() : // default constructed with current activation_record - ptr_( activation_record::current_rec) { + ptr_( detail::activation_record::current_rec) { } public: - static execution_context current() noexcept { - return execution_context(); + static execution_context current() noexcept; + + template< typename Fn, typename ... Args > + explicit execution_context( Fn && fn, Args && ... args) : + // deferred execution of fn and its arguments + // arguments are stored in std::tuple<> + // non-type template parameter pack via std::index_sequence_for<> + // preserves the number of arguments + // used to extract the function arguments from std::tuple<> + ptr_( create_context( fixedsize_stack(), + std::forward< Fn >( fn), + std::make_tuple( std::forward< Args >( args) ...), + false) ) { + ptr_->resume( ptr_.get(), true); } template< typename StackAlloc, typename Fn, typename ... Args > - explicit execution_context( StackAlloc salloc, Fn && fn, Args && ... args) : + explicit execution_context( std::allocator_arg_t, StackAlloc salloc, Fn && fn, Args && ... args) : // deferred execution of fn and its arguments // arguments are stored in std::tuple<> // non-type template parameter pack via std::index_sequence_for<> // preserves the number of arguments // used to extract the function arguments from std::tuple<> - ptr_( create_capture_record( salloc, - std::forward< Fn >( fn), - std::make_tuple( std::forward< Args >( args) ... ), - std::index_sequence_for< Args ... >(), false) ) { + ptr_( create_context( salloc, + std::forward< Fn >( fn), + std::make_tuple( std::forward< Args >( args) ...), + false) ) { + ptr_->resume( ptr_.get(), true); } template< typename StackAlloc, typename Fn, typename ... Args > - explicit execution_context( preallocated palloc, StackAlloc salloc, Fn && fn, Args && ... args) : + explicit execution_context( std::allocator_arg_t, preallocated palloc, StackAlloc salloc, Fn && fn, Args && ... args) : // deferred execution of fn and its arguments // arguments are stored in std::tuple<> // non-type template parameter pack via std::index_sequence_for<> // preserves the number of arguments // used to extract the function arguments from std::tuple<> - ptr_( create_capture_record( palloc, salloc, - std::forward< Fn >( fn), - std::make_tuple( std::forward< Args >( args) ... ), - std::index_sequence_for< Args ... >(), false) ) { + ptr_( create_context( palloc, salloc, + std::forward< Fn >( fn), + std::make_tuple( std::forward< Args >( args) ...), + false) ) { + ptr_->resume( ptr_.get(), true); + } + + execution_context( execution_context const& other) noexcept : + ptr_( other.ptr_) { + } + + execution_context( execution_context && other) noexcept : + ptr_( other.ptr_) { + other.ptr_.reset(); + } + + execution_context & operator=( execution_context const& other) noexcept { + if ( this != & other) { + ptr_ = other.ptr_; + } + return * this; + } + + execution_context & operator=( execution_context && other) noexcept { + if ( this != & other) { + ptr_ = other.ptr_; + other.ptr_.reset(); + } + return * this; + } + + explicit operator bool() const noexcept { + return nullptr != ptr_.get(); + } + + bool operator!() const noexcept { + return nullptr == ptr_.get(); } - void operator()( bool preserve_fpu = false) noexcept { - ptr_->resume(); + void * operator()( void * vp = nullptr, bool preserve_fpu = false) noexcept { + return ptr_->resume( vp, preserve_fpu); } }; diff --git a/boost/context/fixedsize_stack.hpp b/boost/context/fixedsize_stack.hpp index ab19609e87..b27d785d08 100644 --- a/boost/context/fixedsize_stack.hpp +++ b/boost/context/fixedsize_stack.hpp @@ -62,7 +62,7 @@ public: void deallocate( stack_context & sctx) { BOOST_ASSERT( sctx.sp); -#if defined(BOOST_USE_WINFIBERS) +#if ! defined(BOOST_USE_WINFIBERS) BOOST_ASSERT( traits_type::minimum_size() <= sctx.size); BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= sctx.size) ); #endif @@ -77,6 +77,9 @@ public: }; typedef basic_fixedsize_stack< stack_traits > fixedsize_stack; +# if ! defined(BOOST_USE_SEGMENTED_STACKS) +typedef fixedsize_stack default_stack; +# endif }} diff --git a/boost/context/posix/protected_fixedsize_stack.hpp b/boost/context/posix/protected_fixedsize_stack.hpp index c7e09439fc..25ce9a6828 100644 --- a/boost/context/posix/protected_fixedsize_stack.hpp +++ b/boost/context/posix/protected_fixedsize_stack.hpp @@ -58,7 +58,7 @@ public: static_cast< float >( size_) / traits_type::page_size() ) ) ); BOOST_ASSERT_MSG( 2 <= pages, "at least two pages must fit into stack (one page is guard-page)"); const std::size_t size__( pages * traits_type::page_size() ); - BOOST_ASSERT( 0 < size_ && 0 < size__); + BOOST_ASSERT( 0 != size_ && 0 != size__); BOOST_ASSERT( size__ <= size_); // conform to POSIX.4 (POSIX.1b-1993, _POSIX_C_SOURCE=199309L) diff --git a/boost/context/posix/segmented_stack.hpp b/boost/context/posix/segmented_stack.hpp index f4a32d7394..93f4210fd4 100644 --- a/boost/context/posix/segmented_stack.hpp +++ b/boost/context/posix/segmented_stack.hpp @@ -71,6 +71,9 @@ public: }; typedef basic_segmented_stack< stack_traits > segmented_stack; +# if defined(BOOST_USE_SEGMENTED_STACKS) +typedef segmented_stack default_stack; +# endif }} diff --git a/boost/context/stack_context.hpp b/boost/context/stack_context.hpp index 48863b3bc8..24a54e5748 100644 --- a/boost/context/stack_context.hpp +++ b/boost/context/stack_context.hpp @@ -31,7 +31,11 @@ struct stack_context { unsigned valgrind_stack_id; #endif +#if defined(BOOST_NO_CXX11_CONSTEXPR) stack_context() : +#else + constexpr stack_context() : +#endif size( 0), sp( 0), segments_ctx() @@ -48,7 +52,11 @@ struct stack_context { unsigned valgrind_stack_id; #endif +#if defined(BOOST_NO_CXX11_CONSTEXPR) stack_context() : +#else + constexpr stack_context() : +#endif size( 0), sp( 0) #if defined(BOOST_USE_VALGRIND) diff --git a/boost/context/windows/protected_fixedsize_stack.hpp b/boost/context/windows/protected_fixedsize_stack.hpp index e6efee62cf..548bcda31f 100644 --- a/boost/context/windows/protected_fixedsize_stack.hpp +++ b/boost/context/windows/protected_fixedsize_stack.hpp @@ -54,7 +54,7 @@ public: static_cast< float >( size_) / traits_type::page_size() ) ) ); BOOST_ASSERT_MSG( 2 <= pages, "at least two pages must fit into stack (one page is guard-page)"); const std::size_t size__( pages * traits_type::page_size() ); - BOOST_ASSERT( 0 < size_ && 0 < size__); + BOOST_ASSERT( 0 != size_ && 0 != size__); BOOST_ASSERT( size__ <= size_); void * vp = ::VirtualAlloc( 0, size__, MEM_COMMIT, PAGE_READWRITE); @@ -78,7 +78,7 @@ public: void deallocate( stack_context & sctx) { BOOST_ASSERT( sctx.sp); -#if defined(BOOST_USE_WINFIBERS) +#if ! defined(BOOST_USE_WINFIBERS) BOOST_ASSERT( traits_type::minimum_size() <= sctx.size); BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= sctx.size) ); #endif diff --git a/boost/convert/base.hpp b/boost/convert/base.hpp index 128c46f3a5..3d446641d2 100644 --- a/boost/convert/base.hpp +++ b/boost/convert/base.hpp @@ -55,25 +55,29 @@ struct boost::cnv::cnvbase } // Basic type to string - BOOST_CNV_TO_STRING ( int_type v, optional& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( uint_type v, optional& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( lint_type v, optional& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING (ulint_type v, optional& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( sint_type v, optional& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING (usint_type v, optional& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( flt_type v, optional& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( dbl_type v, optional& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( ldbl_type v, optional& r) const { to_str_(v, r); } + BOOST_CNV_TO_STRING ( int_type v, optional& r) const { to_str_(v, r); } + BOOST_CNV_TO_STRING ( uint_type v, optional& r) const { to_str_(v, r); } + BOOST_CNV_TO_STRING ( lint_type v, optional& r) const { to_str_(v, r); } + BOOST_CNV_TO_STRING ( llint_type v, optional& r) const { to_str_(v, r); } + BOOST_CNV_TO_STRING ( ulint_type v, optional& r) const { to_str_(v, r); } + BOOST_CNV_TO_STRING (ullint_type v, optional& r) const { to_str_(v, r); } + BOOST_CNV_TO_STRING ( sint_type v, optional& r) const { to_str_(v, r); } + BOOST_CNV_TO_STRING ( usint_type v, optional& r) const { to_str_(v, r); } + BOOST_CNV_TO_STRING ( flt_type v, optional& r) const { to_str_(v, r); } + BOOST_CNV_TO_STRING ( dbl_type v, optional& r) const { to_str_(v, r); } + BOOST_CNV_TO_STRING ( ldbl_type v, optional& r) const { to_str_(v, r); } // String to basic type - BOOST_CNV_STRING_TO (string_type const& s, optional< int_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< uint_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< lint_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< sint_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< flt_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< dbl_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< ldbl_type>& r) const { str_to_(s, r); } + BOOST_CNV_STRING_TO (string_type const& s, optional< int_type>& r) const { str_to_(s, r); } + BOOST_CNV_STRING_TO (string_type const& s, optional< uint_type>& r) const { str_to_(s, r); } + BOOST_CNV_STRING_TO (string_type const& s, optional< lint_type>& r) const { str_to_(s, r); } + BOOST_CNV_STRING_TO (string_type const& s, optional< llint_type>& r) const { str_to_(s, r); } + BOOST_CNV_STRING_TO (string_type const& s, optional< ulint_type>& r) const { str_to_(s, r); } + BOOST_CNV_STRING_TO (string_type const& s, optional& r) const { str_to_(s, r); } + BOOST_CNV_STRING_TO (string_type const& s, optional< sint_type>& r) const { str_to_(s, r); } + BOOST_CNV_STRING_TO (string_type const& s, optional< usint_type>& r) const { str_to_(s, r); } + BOOST_CNV_STRING_TO (string_type const& s, optional< flt_type>& r) const { str_to_(s, r); } + BOOST_CNV_STRING_TO (string_type const& s, optional< dbl_type>& r) const { str_to_(s, r); } + BOOST_CNV_STRING_TO (string_type const& s, optional< ldbl_type>& r) const { str_to_(s, r); } // Formatters // BOOST_CNV_PARAM (locale, std::locale const) { locale_ = arg[ARG:: locale]; return dncast(); } BOOST_CNV_PARAM (base, base::type const) { base_ = arg[ARG:: base]; return dncast(); } @@ -104,8 +108,11 @@ struct boost::cnv::cnvbase { cnv::range range (str); - /**/ if (skipws_) for (; std::isspace(*range.begin()); ++range); - else if (std::isspace(*range.begin())) return; + if (skipws_) + for (; !range.empty() && std::isspace(*range.begin()); ++range); + + if (range.empty()) return; + if (std::isspace(*range.begin())) return; dncast().str_to(range, result_out); } diff --git a/boost/convert/detail/forward.hpp b/boost/convert/detail/forward.hpp index 5548aec3fe..8d86d8c6a1 100644 --- a/boost/convert/detail/forward.hpp +++ b/boost/convert/detail/forward.hpp @@ -11,6 +11,7 @@ # pragma warning(disable: 4996) # pragma warning(disable: 4180) // qualifier applied to function type has no meaning # pragma warning(disable: 4100) // unreferenced formal parameter +# pragma warning(disable: 4146) // unary minus operator applied to unsigned type #if _MSC_VER < 1900 /* MSVC-14 defines real snprintf()... just about time! */ # define snprintf _snprintf diff --git a/boost/convert/detail/range.hpp b/boost/convert/detail/range.hpp index 439fbf48d0..cdfe7b7401 100644 --- a/boost/convert/detail/range.hpp +++ b/boost/convert/detail/range.hpp @@ -50,37 +50,41 @@ namespace boost { namespace cnv typedef typename cnv::iterator::const_type const_iterator; typedef const_iterator sentry_type; - range_base (iterator b, iterator e) : begin_(b), end_(e) {} - iterator begin () { return begin_; } - iterator end () { return end_; } const_iterator begin () const { return begin_; } - const_iterator end () const { return end_; } - sentry_type sentry () const { return end_; } void operator++ () { ++begin_; } - void operator-- () { --end_; } +// void operator-- () { --end_; } protected: + range_base (iterator b, iterator e) : begin_(b), end_(e) {} + iterator begin_; - mutable iterator end_; + iterator mutable end_; }; template struct range >::type> : public range_base { - typedef range this_type; - typedef range_base base_type; + typedef range this_type; + typedef range_base base_type; + typedef typename base_type::iterator iterator; + typedef typename base_type::const_iterator const_iterator; + typedef const_iterator sentry_type; range (T& r) : base_type(r.begin(), r.end()) {} + + iterator end () { return base_type::end_; } + const_iterator end () const { return base_type::end_; } + sentry_type sentry () const { return base_type::end_; } + bool empty () const { return base_type::begin_ == base_type::end_; } }; template struct range >::type> : public range_base { - typedef range this_type; - typedef range_base base_type; - + typedef range this_type; + typedef range_base base_type; typedef typename remove_const::type value_type; typedef T* iterator; typedef value_type const* const_iterator; @@ -96,6 +100,7 @@ namespace boost { namespace cnv const_iterator end () const { return base_type::end_ ? base_type::end_ : (base_type::end_ = base_type::begin_ + size()); } sentry_type sentry () const { return sentry_type(); } std::size_t size () const { return std::char_traits::length(base_type::begin_); } + bool empty () const { return !*base_type::begin_; } }; template struct range : public range diff --git a/boost/convert/spirit.hpp b/boost/convert/spirit.hpp index 5ef69d3c78..34ad811b2b 100644 --- a/boost/convert/spirit.hpp +++ b/boost/convert/spirit.hpp @@ -38,7 +38,7 @@ struct boost::cnv::spirit : public boost::cnv::cnvbase result_out = result; } template - cnv::range + cnv::range to_str(in_type value_in, char_type* beg) const { typedef typename boost::spirit::traits::create_generator::type generator; @@ -46,7 +46,7 @@ struct boost::cnv::spirit : public boost::cnv::cnvbase char_type* end = beg; bool good = boost::spirit::karma::generate(end, generator(), value_in); - return cnv::range(beg, good ? end : beg); + return cnv::range(beg, good ? end : beg); } }; diff --git a/boost/convert/stream.hpp b/boost/convert/stream.hpp index 04f2bccf98..c0f4890b36 100644 --- a/boost/convert/stream.hpp +++ b/boost/convert/stream.hpp @@ -173,6 +173,8 @@ boost::cnv::basic_stream::str_to( boost::cnv::range string_in, boost::optional& result_out) const { + if (string_in.empty ()) return; + istream_type& istream = stream_; buffer_type* oldbuf = istream.rdbuf(); char_type const* beg = &*string_in.begin(); diff --git a/boost/convert/strtol.hpp b/boost/convert/strtol.hpp index bc329c6870..5d10bde5a7 100644 --- a/boost/convert/strtol.hpp +++ b/boost/convert/strtol.hpp @@ -55,15 +55,21 @@ struct boost::cnv::strtol : public boost::cnv::cnvbase template void str_to(cnv::range v, optional< int_type>& r) const { str_to_i (v, r); } template void str_to(cnv::range v, optional< sint_type>& r) const { str_to_i (v, r); } template void str_to(cnv::range v, optional< lint_type>& r) const { str_to_i (v, r); } + template void str_to(cnv::range v, optional< llint_type>& r) const { str_to_i (v, r); } template void str_to(cnv::range v, optional< uint_type>& r) const { str_to_i (v, r); } template void str_to(cnv::range v, optional< usint_type>& r) const { str_to_i (v, r); } template void str_to(cnv::range v, optional< ulint_type>& r) const { str_to_i (v, r); } + template void str_to(cnv::range v, optional& r) const { str_to_i (v, r); } template void str_to(cnv::range v, optional< flt_type>& r) const { str_to_d (v, r); } template void str_to(cnv::range v, optional< dbl_type>& r) const { str_to_d (v, r); } template void str_to(cnv::range v, optional< ldbl_type>& r) const { str_to_d (v, r); } - template cnv::range to_str ( int_type v, char_type* buf) const { return i_to_str(v, buf); } - template cnv::range to_str (lint_type v, char_type* buf) const { return i_to_str(v, buf); } + template cnv::range to_str ( int_type v, char_type* buf) const { return i_to_str(v, buf); } + template cnv::range to_str ( uint_type v, char_type* buf) const { return i_to_str(v, buf); } + template cnv::range to_str ( lint_type v, char_type* buf) const { return i_to_str(v, buf); } + template cnv::range to_str ( ulint_type v, char_type* buf) const { return i_to_str(v, buf); } + template cnv::range to_str ( llint_type v, char_type* buf) const { return i_to_str(v, buf); } + template cnv::range to_str (ullint_type v, char_type* buf) const { return i_to_str(v, buf); } template cnv::range to_str ( dbl_type v, char_type* buf) const; template cnv::range i_to_str (in_type, char_type*) const; @@ -76,13 +82,16 @@ struct boost::cnv::strtol : public boost::cnv::cnvbase template boost::cnv::range -boost::cnv::strtol::i_to_str(Type value, char_type* buf) const +boost::cnv::strtol::i_to_str(Type in_value, char_type* buf) const { // C1. Base=10 optimization improves performance 10% + typedef typename boost::make_unsigned::type unsigned_type; + char_type* beg = buf + bufsize_ / 2; char_type* end = beg; - bool const is_negative = (value < 0) ? (value = -value, true) : false; + bool const is_negative = in_value < 0; + unsigned_type value = static_cast(is_negative ? -in_value : in_value); if (base_ == 10) for (; value; *(--beg) = int(value % 10) + '0', value /= 10); //C1 else for (; value; *(--beg) = get_char(value % base_), value /= base_); @@ -160,7 +169,6 @@ template void boost::cnv::strtol::str_to_i(cnv::range range, boost::optional& result_out) const { - typedef typename boost::make_unsigned::type unsigned_type; typedef cnv::range range_type; typedef typename range_type::iterator iterator; @@ -182,7 +190,7 @@ boost::cnv::strtol::str_to_i(cnv::range range, boost::optional range, optional& result_out) const { typedef cnv::range range_type; - typedef typename range_type::iterator iterator; typedef typename range_type::value_type char_type; char_type const* str = &*range.begin(); // Currently only works with 'char' diff --git a/boost/core/demangle.hpp b/boost/core/demangle.hpp index eebd0ce0f1..44aeb8ded7 100644 --- a/boost/core/demangle.hpp +++ b/boost/core/demangle.hpp @@ -27,8 +27,15 @@ #if defined( BOOST_CORE_HAS_CXXABI_H ) # include -# include -# include +// For some archtectures (mips, mips64, x86, x86_64) cxxabi.h in Android NDK is implemented by gabi++ library +// (https://android.googlesource.com/platform/ndk/+/master/sources/cxx-stl/gabi++/), which does not implement +// abi::__cxa_demangle(). We detect this implementation by checking the include guard here. +# if defined( __GABIXX_CXXABI_H__ ) +# undef BOOST_CORE_HAS_CXXABI_H +# else +# include +# include +# endif #endif namespace boost diff --git a/boost/core/enable_if.hpp b/boost/core/enable_if.hpp index a3302b18a1..5dcef1e035 100644 --- a/boost/core/enable_if.hpp +++ b/boost/core/enable_if.hpp @@ -23,6 +23,11 @@ namespace boost { + template + struct enable_if_has_type + { + typedef R type; + }; template struct enable_if_c { @@ -80,6 +85,10 @@ namespace boost { template struct enable_if_does_not_work_on_this_compiler; + template + struct enable_if_has_type : enable_if_does_not_work_on_this_compiler + { }; + template struct enable_if_c : enable_if_does_not_work_on_this_compiler { }; diff --git a/boost/coroutine/asymmetric_coroutine.hpp b/boost/coroutine/asymmetric_coroutine.hpp index d9369fae38..640896f7c4 100644 --- a/boost/coroutine/asymmetric_coroutine.hpp +++ b/boost/coroutine/asymmetric_coroutine.hpp @@ -467,16 +467,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R >, R, coroutine_fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -494,16 +494,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R >, R, coroutine_fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -521,16 +521,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R >, R, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -548,16 +548,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R >, R, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -575,16 +575,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R >, R, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -602,16 +602,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R >, R, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -629,16 +629,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R >, R, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -656,16 +656,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R >, R, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -927,16 +927,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R & >, R &, coroutine_fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -954,16 +954,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R & >, R &, coroutine_fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -981,16 +981,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R & >, R &, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1008,16 +1008,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R & >, R &, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1035,16 +1035,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R & >, R &, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1062,16 +1062,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R & >, R &, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1089,16 +1089,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R & >, R &, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1116,16 +1116,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< R & >, R &, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1383,16 +1383,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< void >, void, coroutine_fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1410,16 +1410,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< void >, void, coroutine_fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1437,16 +1437,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< void >, void, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1464,16 +1464,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< void >, void, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1491,16 +1491,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< void >, void, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1518,16 +1518,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< void >, void, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1545,16 +1545,16 @@ public: stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< void >, void, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1572,16 +1572,16 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::pull_coroutine_object< push_coroutine< void >, void, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1642,16 +1642,16 @@ push_coroutine< Arg >::push_coroutine( coroutine_fn fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg >, Arg, coroutine_fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1669,16 +1669,16 @@ push_coroutine< Arg >::push_coroutine( coroutine_fn fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg >, Arg, coroutine_fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1695,16 +1695,16 @@ push_coroutine< Arg & >::push_coroutine( coroutine_fn fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg & >, Arg &, coroutine_fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1722,16 +1722,16 @@ push_coroutine< Arg & >::push_coroutine( coroutine_fn fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg & >, Arg &, coroutine_fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1747,16 +1747,16 @@ inline push_coroutine< void >::push_coroutine( coroutine_fn fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< void >, void, coroutine_fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1773,16 +1773,16 @@ push_coroutine< void >::push_coroutine( coroutine_fn fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< void >, void, coroutine_fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1800,16 +1800,16 @@ push_coroutine< Arg >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg >, Arg, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1827,16 +1827,16 @@ push_coroutine< Arg >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg >, Arg, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1854,16 +1854,16 @@ push_coroutine< Arg & >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg & >, Arg &, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1881,16 +1881,16 @@ push_coroutine< Arg & >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg & >, Arg &, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1907,16 +1907,16 @@ push_coroutine< void >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< void >, void, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1933,16 +1933,16 @@ push_coroutine< void >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< void >, void, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1960,16 +1960,16 @@ push_coroutine< Arg >::push_coroutine( Fn fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg >, Arg, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -1987,16 +1987,16 @@ push_coroutine< Arg >::push_coroutine( Fn fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg >, Arg, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -2014,16 +2014,16 @@ push_coroutine< Arg & >::push_coroutine( Fn fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg & >, Arg &, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -2041,16 +2041,16 @@ push_coroutine< Arg & >::push_coroutine( Fn fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg & >, Arg &, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -2067,16 +2067,16 @@ push_coroutine< void >::push_coroutine( Fn fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< void >, void, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -2093,16 +2093,16 @@ push_coroutine< void >::push_coroutine( Fn fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< void >, void, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -2120,16 +2120,16 @@ push_coroutine< Arg >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg >, Arg, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -2147,16 +2147,16 @@ push_coroutine< Arg >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg >, Arg, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -2174,16 +2174,16 @@ push_coroutine< Arg & >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg & >, Arg &, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -2201,16 +2201,16 @@ push_coroutine< Arg & >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< Arg & >, Arg &, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -2227,16 +2227,16 @@ push_coroutine< void >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_allocator stack_alloc; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< void >, void, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); @@ -2253,16 +2253,16 @@ push_coroutine< void >::push_coroutine( BOOST_RV_REF( Fn) fn, stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef detail::push_coroutine_object< pull_coroutine< void >, void, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, detail::preallocated( sp, size, stack_ctx), stack_alloc); diff --git a/boost/coroutine/detail/symmetric_coroutine_call.hpp b/boost/coroutine/detail/symmetric_coroutine_call.hpp index 0b504b8edc..3a9e4e6f9f 100644 --- a/boost/coroutine/detail/symmetric_coroutine_call.hpp +++ b/boost/coroutine/detail/symmetric_coroutine_call.hpp @@ -65,14 +65,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg, coroutine_fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -89,14 +89,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg, coroutine_fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -113,14 +113,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -137,14 +137,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -161,14 +161,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -185,14 +185,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -209,14 +209,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -233,14 +233,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -321,14 +321,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg &, coroutine_fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -345,14 +345,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg &, coroutine_fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -369,14 +369,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg &, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -393,14 +393,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg &, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -417,14 +417,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg &, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -441,14 +441,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg &, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -465,14 +465,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg &, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -489,14 +489,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< Arg &, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -577,14 +577,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< void, coroutine_fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -601,14 +601,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< void, coroutine_fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< coroutine_fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -625,14 +625,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< void, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -649,14 +649,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< void, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( boost::forward< Fn >( fn), attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -673,14 +673,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< void, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -697,14 +697,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< void, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -721,14 +721,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< void, Fn, stack_allocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); @@ -745,14 +745,14 @@ public: stack_context stack_ctx; // allocate the coroutine-stack stack_alloc.allocate( stack_ctx, attrs.size); - BOOST_ASSERT( 0 < stack_ctx.sp); + BOOST_ASSERT( 0 != stack_ctx.sp); // typedef of internal coroutine-type typedef symmetric_coroutine_object< void, Fn, StackAllocator > object_t; // reserve space on top of coroutine-stack for internal coroutine-type std::size_t size = stack_ctx.size - sizeof( object_t); - BOOST_ASSERT( 0 < size); + BOOST_ASSERT( 0 != size); void * sp = static_cast< char * >( stack_ctx.sp) - sizeof( object_t); - BOOST_ASSERT( 0 < sp); + BOOST_ASSERT( 0 != sp); // placement new for internal coroutine impl_ = new ( sp) object_t( fn, attrs, preallocated( sp, size, stack_ctx), stack_alloc); diff --git a/boost/coroutine/posix/protected_stack_allocator.hpp b/boost/coroutine/posix/protected_stack_allocator.hpp index 659de337a1..649248b57d 100644 --- a/boost/coroutine/posix/protected_stack_allocator.hpp +++ b/boost/coroutine/posix/protected_stack_allocator.hpp @@ -53,7 +53,7 @@ struct basic_protected_stack_allocator static_cast< float >( size) / traits_type::page_size() ) ) ); BOOST_ASSERT_MSG( 2 <= pages, "at least two pages must fit into stack (one page is guard-page)"); const std::size_t size_( pages * traits_type::page_size() ); - BOOST_ASSERT( 0 < size && 0 < size_); + BOOST_ASSERT( 0 != size && 0 != size_); BOOST_ASSERT( size_ <= size); // conform to POSIX.4 (POSIX.1b-1993, _POSIX_C_SOURCE=199309L) diff --git a/boost/coroutine/windows/protected_stack_allocator.hpp b/boost/coroutine/windows/protected_stack_allocator.hpp index 293901223b..29e19babb7 100644 --- a/boost/coroutine/windows/protected_stack_allocator.hpp +++ b/boost/coroutine/windows/protected_stack_allocator.hpp @@ -46,7 +46,7 @@ struct basic_protected_stack_allocator static_cast< float >( size) / traits_type::page_size() ) ) ); BOOST_ASSERT_MSG( 2 <= pages, "at least two pages must fit into stack (one page is guard-page)"); const std::size_t size_ = pages * traits_type::page_size(); - BOOST_ASSERT( 0 < size && 0 < size_); + BOOST_ASSERT( 0 != size && 0 != size_); void * limit = ::VirtualAlloc( 0, size_, MEM_COMMIT, PAGE_READWRITE); if ( ! limit) throw std::bad_alloc(); diff --git a/boost/coroutine2/detail/config.hpp b/boost/coroutine2/detail/config.hpp index c439ecc0ea..cfb95846a5 100644 --- a/boost/coroutine2/detail/config.hpp +++ b/boost/coroutine2/detail/config.hpp @@ -36,16 +36,4 @@ # include #endif -#if defined(BOOST_USE_SEGMENTED_STACKS) -# if ! ( (defined(__GNUC__) && __GNUC__ > 3 && __GNUC_MINOR__ > 6) || \ - (defined(__clang__) && __clang_major__ > 2 && __clang_minor__ > 3) ) -# error "compiler does not support segmented_stack stacks" -# endif -# define BOOST_COROUTINES2_SEGMENTS 10 -#endif - -#if defined(BOOST_CONTEXT_NO_EXECUTION_CONTEXT) -# error "execution_context from boost.context not supported" -#endif - #endif // BOOST_COROUTINES2_DETAIL_CONFIG_H diff --git a/boost/coroutine2/detail/pull_control_block.hpp b/boost/coroutine2/detail/pull_control_block.hpp index 1abb34a0db..7009454c88 100644 --- a/boost/coroutine2/detail/pull_control_block.hpp +++ b/boost/coroutine2/detail/pull_control_block.hpp @@ -8,6 +8,7 @@ #define BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP #include +#include #include #include @@ -22,17 +23,18 @@ namespace detail { template< typename T > struct pull_coroutine< T >::control_block { - typename push_coroutine< T >::control_block * other; - boost::context::execution_context caller; - boost::context::execution_context callee; - bool preserve_fpu; - int state; - std::exception_ptr except; + typename push_coroutine< T >::control_block * other; + boost::context::execution_context ctx; + bool preserve_fpu; + int state; + std::exception_ptr except; + bool bvalid; + typename std::aligned_storage< sizeof( T), alignof( T) >::type storage[1]; template< typename StackAllocator, typename Fn > control_block( context::preallocated, StackAllocator, Fn &&, bool); - explicit control_block( typename push_coroutine< T >::control_block *); + explicit control_block( typename push_coroutine< T >::control_block *, boost::context::execution_context const&); ~control_block(); @@ -41,22 +43,26 @@ struct pull_coroutine< T >::control_block { void resume(); + void set( T *); + + T & get(); + bool valid() const noexcept; }; template< typename T > struct pull_coroutine< T & >::control_block { typename push_coroutine< T & >::control_block * other; - boost::context::execution_context caller; - boost::context::execution_context callee; + boost::context::execution_context ctx; bool preserve_fpu; int state; std::exception_ptr except; + T * t; template< typename StackAllocator, typename Fn > control_block( context::preallocated, StackAllocator, Fn &&, bool); - explicit control_block( typename push_coroutine< T & >::control_block *); + explicit control_block( typename push_coroutine< T & >::control_block *, boost::context::execution_context const&); ~control_block(); @@ -65,13 +71,14 @@ struct pull_coroutine< T & >::control_block { void resume(); + T & get(); + bool valid() const noexcept; }; struct pull_coroutine< void >::control_block { push_coroutine< void >::control_block * other; - boost::context::execution_context caller; - boost::context::execution_context callee; + boost::context::execution_context ctx; bool preserve_fpu; int state; std::exception_ptr except; @@ -79,7 +86,7 @@ struct pull_coroutine< void >::control_block { template< typename StackAllocator, typename Fn > control_block( context::preallocated, StackAllocator, Fn &&, bool); - explicit control_block( push_coroutine< void >::control_block *); + explicit control_block( push_coroutine< void >::control_block *, boost::context::execution_context const&); ~control_block(); diff --git a/boost/coroutine2/detail/pull_control_block.ipp b/boost/coroutine2/detail/pull_control_block.ipp index fd806ecb21..536e5e6a94 100644 --- a/boost/coroutine2/detail/pull_control_block.ipp +++ b/boost/coroutine2/detail/pull_control_block.ipp @@ -8,6 +8,7 @@ #define BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_IPP #include +#include #include #include @@ -33,42 +34,46 @@ template< typename StackAllocator, typename Fn > pull_coroutine< T >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, Fn && fn_, bool preserve_fpu_) : other( nullptr), - caller( boost::context::execution_context::current() ), - callee( palloc, salloc, - [=,fn=std::forward< Fn >( fn_)] () mutable -> decltype( auto) { - // create synthesized push_coroutine< T > - typename push_coroutine< T >::control_block synthesized_cb( this); - push_coroutine< T > synthesized( & synthesized_cb); - other = & synthesized_cb; - try { - // call coroutine-fn with synthesized push_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); - } - // set termination flags - state |= static_cast< int >( state_t::complete); - // jump back to caller - caller( preserve_fpu); - BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); - }), + ctx( std::allocator_arg, palloc, salloc, + [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void { + // create synthesized push_coroutine< T > + typename push_coroutine< T >::control_block synthesized_cb( this, ctx); + push_coroutine< T > synthesized( & synthesized_cb); + other = & synthesized_cb; + try { + // call coroutine-fn with synthesized push_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } + // set termination flags + state |= static_cast< int >( state_t::complete); + // jump back to ctx + other->ctx( nullptr, preserve_fpu); + BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); + }), preserve_fpu( preserve_fpu_), state( static_cast< int >( state_t::unwind) ), - except() { - callee( preserve_fpu); + except(), + bvalid( false), + storage() { + // enter coroutine-fn in order to have first value available after ctor (of `*this`) returns + set( reinterpret_cast< T * >( ctx( nullptr, preserve_fpu) ) ); } template< typename T > -pull_coroutine< T >::control_block::control_block( typename push_coroutine< T >::control_block * cb) : +pull_coroutine< T >::control_block::control_block( typename push_coroutine< T >::control_block * cb, + boost::context::execution_context const& ctx_) : other( cb), - caller( other->callee), - callee( other->caller), + ctx( ctx_), preserve_fpu( other->preserve_fpu), state( 0), - except() { + except(), + bvalid( false), + storage() { } template< typename T > @@ -77,14 +82,19 @@ pull_coroutine< T >::control_block::~control_block() { 0 != ( state & static_cast< int >( state_t::unwind) ) ) { // set early-exit flag state |= static_cast< int >( state_t::early_exit); - callee( preserve_fpu); + ctx( nullptr, preserve_fpu); + } + // destroy data if it set + if ( bvalid) { + reinterpret_cast< T const* >( storage)->~T(); } } template< typename T > void pull_coroutine< T >::control_block::resume() { - callee( preserve_fpu); + other->ctx = boost::context::execution_context::current(); + set( reinterpret_cast< T * >( ctx( nullptr, preserve_fpu) ) ); if ( except) { std::rethrow_exception( except); } @@ -94,10 +104,31 @@ pull_coroutine< T >::control_block::resume() { } } +template< typename T > +void +pull_coroutine< T >::control_block::set( T * t) { + // destroy data if it set + if ( bvalid) { + reinterpret_cast< T const* >( storage)->~T(); + } + if ( nullptr != t) { + new ( storage) T( std::move( * t) ); // FIXME: differrentiation between move/copy + bvalid = true; + } else { + bvalid = false; + } +} + +template< typename T > +T & +pull_coroutine< T >::control_block::get() { + return * reinterpret_cast< T * >( storage); +} + template< typename T > bool pull_coroutine< T >::control_block::valid() const noexcept { - return nullptr != other && nullptr != other->t && 0 == ( state & static_cast< int >( state_t::complete) ); + return nullptr != other && 0 == ( state & static_cast< int >( state_t::complete) ) && bvalid; } @@ -108,42 +139,44 @@ template< typename StackAllocator, typename Fn > pull_coroutine< T & >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, Fn && fn_, bool preserve_fpu_) : other( nullptr), - caller( boost::context::execution_context::current() ), - callee( palloc, salloc, - [=,fn=std::forward< Fn >( fn_)] () mutable -> decltype( auto) { - // create synthesized push_coroutine< T > - typename push_coroutine< T & >::control_block synthesized_cb( this); - push_coroutine< T & > synthesized( & synthesized_cb); - other = & synthesized_cb; - try { - // call coroutine-fn with synthesized push_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); - } - // set termination flags - state |= static_cast< int >( state_t::complete); - // jump back to caller - caller( preserve_fpu); - BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); - }), + ctx( std::allocator_arg, palloc, salloc, + [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void { + // create synthesized push_coroutine< T > + typename push_coroutine< T & >::control_block synthesized_cb( this, ctx); + push_coroutine< T & > synthesized( & synthesized_cb); + other = & synthesized_cb; + try { + // call coroutine-fn with synthesized push_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } + // set termination flags + state |= static_cast< int >( state_t::complete); + // jump back to ctx + other->ctx( nullptr, preserve_fpu); + BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); + }), preserve_fpu( preserve_fpu_), state( static_cast< int >( state_t::unwind) ), - except() { - callee( preserve_fpu); + except(), + t( nullptr) { + // enter coroutine-fn in order to have first value available after ctor (of `*this`) returns + t = reinterpret_cast< T * >( ctx( nullptr, preserve_fpu) ); } template< typename T > -pull_coroutine< T & >::control_block::control_block( typename push_coroutine< T & >::control_block * cb) : +pull_coroutine< T & >::control_block::control_block( typename push_coroutine< T & >::control_block * cb, + boost::context::execution_context const& ctx_) : other( cb), - caller( other->callee), - callee( other->caller), + ctx( ctx_), preserve_fpu( other->preserve_fpu), state( 0), - except() { + except(), + t( nullptr) { } template< typename T > @@ -152,14 +185,15 @@ pull_coroutine< T & >::control_block::~control_block() { 0 != ( state & static_cast< int >( state_t::unwind) ) ) { // set early-exit flag state |= static_cast< int >( state_t::early_exit); - callee( preserve_fpu); + ctx( nullptr, preserve_fpu); } } template< typename T > void pull_coroutine< T & >::control_block::resume() { - callee( preserve_fpu); + other->ctx = boost::context::execution_context::current(); + t = reinterpret_cast< T * >( ctx( nullptr, preserve_fpu) ); if ( except) { std::rethrow_exception( except); } @@ -169,10 +203,16 @@ pull_coroutine< T & >::control_block::resume() { } } +template< typename T > +T & +pull_coroutine< T & >::control_block::get() { + return * reinterpret_cast< T * >( t); +} + template< typename T > bool pull_coroutine< T & >::control_block::valid() const noexcept { - return nullptr != other && nullptr != other->t && 0 == ( state & static_cast< int >( state_t::complete) ); + return nullptr != other && 0 == ( state & static_cast< int >( state_t::complete) ) && nullptr != t; } @@ -182,39 +222,39 @@ template< typename StackAllocator, typename Fn > pull_coroutine< void >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, Fn && fn_, bool preserve_fpu_) : other( nullptr), - caller( boost::context::execution_context::current() ), - callee( palloc, salloc, - [=,fn=std::forward< Fn >( fn_)] () mutable -> decltype( auto) { - // create synthesized push_coroutine< T > - typename push_coroutine< void >::control_block synthesized_cb( this); - push_coroutine< void > synthesized( & synthesized_cb); - other = & synthesized_cb; - try { - // call coroutine-fn with synthesized push_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); - } - // set termination flags - state |= static_cast< int >( state_t::complete); - // jump back to caller - caller( preserve_fpu); - BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); - }), + ctx( std::allocator_arg, palloc, salloc, + [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void { + // create synthesized push_coroutine< T > + typename push_coroutine< void >::control_block synthesized_cb( this, ctx); + push_coroutine< void > synthesized( & synthesized_cb); + other = & synthesized_cb; + try { + // call coroutine-fn with synthesized push_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } + // set termination flags + state |= static_cast< int >( state_t::complete); + // jump back to ctx + other->ctx( nullptr, preserve_fpu); + BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); + }), preserve_fpu( preserve_fpu_), state( static_cast< int >( state_t::unwind) ), except() { - callee( preserve_fpu); + // enter coroutine-fn in order to have first value available after ctor returns + ctx( nullptr, preserve_fpu); } inline -pull_coroutine< void >::control_block::control_block( push_coroutine< void >::control_block * cb) : +pull_coroutine< void >::control_block::control_block( push_coroutine< void >::control_block * cb, + boost::context::execution_context const& ctx_) : other( cb), - caller( other->callee), - callee( other->caller), + ctx( ctx_), preserve_fpu( other->preserve_fpu), state( 0), except() { @@ -226,14 +266,15 @@ pull_coroutine< void >::control_block::~control_block() { 0 != ( state & static_cast< int >( state_t::unwind) ) ) { // set early-exit flag state |= static_cast< int >( state_t::early_exit); - callee( preserve_fpu); + ctx( nullptr, preserve_fpu); } } inline void pull_coroutine< void >::control_block::resume() { - callee( preserve_fpu); + other->ctx = boost::context::execution_context::current(); + ctx( nullptr, preserve_fpu); if ( except) { std::rethrow_exception( except); } diff --git a/boost/coroutine2/detail/pull_coroutine.hpp b/boost/coroutine2/detail/pull_coroutine.hpp index ff76bd3aac..c78750442e 100644 --- a/boost/coroutine2/detail/pull_coroutine.hpp +++ b/boost/coroutine2/detail/pull_coroutine.hpp @@ -66,7 +66,7 @@ public: bool operator!() const noexcept; - T get() const noexcept; + T get(); class iterator : public std::iterator< std::input_iterator_tag, typename std::remove_reference< T >::type > { private: @@ -126,11 +126,11 @@ public: iterator operator++( int) = delete; reference_t operator*() const { - return * c_->cb_->other->t; + return c_->cb_->get(); } pointer_t operator->() const { - return c_->cb_->other->t; + return std::addressof( c_->cb_->get() ); } }; @@ -179,7 +179,7 @@ public: bool operator!() const noexcept; - T & get() const noexcept; + T & get(); class iterator : public std::iterator< std::input_iterator_tag, typename std::remove_reference< T >::type > { private: @@ -239,11 +239,11 @@ public: iterator operator++( int) = delete; reference_t operator*() const { - return * c_->cb_->other->t; + return c_->cb_->get(); } pointer_t operator->() const { - return c_->cb_->other->t; + return std::addressof( c_->cb_->get() ); } }; diff --git a/boost/coroutine2/detail/pull_coroutine.ipp b/boost/coroutine2/detail/pull_coroutine.ipp index f59bb3cb5f..2e37ef2a98 100644 --- a/boost/coroutine2/detail/pull_coroutine.ipp +++ b/boost/coroutine2/detail/pull_coroutine.ipp @@ -19,6 +19,7 @@ #include #include +#include #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -44,7 +45,7 @@ pull_coroutine< T >::has_result_() const { template< typename T > template< typename Fn > pull_coroutine< T >::pull_coroutine( Fn && fn, bool preserve_fpu) : - pull_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + pull_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename T > @@ -106,8 +107,8 @@ pull_coroutine< T >::operator!() const noexcept { template< typename T > T -pull_coroutine< T >::get() const noexcept { - return std::move( * cb_->other->t); +pull_coroutine< T >::get() { + return std::move( cb_->get() ); } @@ -127,7 +128,7 @@ pull_coroutine< T & >::has_result_() const { template< typename T > template< typename Fn > pull_coroutine< T & >::pull_coroutine( Fn && fn, bool preserve_fpu) : - pull_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + pull_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename T > @@ -189,8 +190,8 @@ pull_coroutine< T & >::operator!() const noexcept { template< typename T > T & -pull_coroutine< T & >::get() const noexcept { - return * cb_->other->t; +pull_coroutine< T & >::get() { + return cb_->get(); } @@ -203,7 +204,7 @@ pull_coroutine< void >::pull_coroutine( control_block * cb) : template< typename Fn > pull_coroutine< void >::pull_coroutine( Fn && fn, bool preserve_fpu) : - pull_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + pull_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename StackAllocator, typename Fn > diff --git a/boost/coroutine2/detail/push_control_block.hpp b/boost/coroutine2/detail/push_control_block.hpp index e6c86ffd81..03aa9125eb 100644 --- a/boost/coroutine2/detail/push_control_block.hpp +++ b/boost/coroutine2/detail/push_control_block.hpp @@ -23,17 +23,15 @@ namespace detail { template< typename T > struct push_coroutine< T >::control_block { typename pull_coroutine< T >::control_block * other; - boost::context::execution_context caller; - boost::context::execution_context callee; + boost::context::execution_context ctx; bool preserve_fpu; int state; std::exception_ptr except; - T * t; template< typename StackAllocator, typename Fn > control_block( context::preallocated, StackAllocator, Fn &&, bool); - explicit control_block( typename pull_coroutine< T >::control_block *); + explicit control_block( typename pull_coroutine< T >::control_block *, boost::context::execution_context const&); ~control_block(); @@ -50,17 +48,15 @@ struct push_coroutine< T >::control_block { template< typename T > struct push_coroutine< T & >::control_block { typename pull_coroutine< T & >::control_block * other; - boost::context::execution_context caller; - boost::context::execution_context callee; + boost::context::execution_context ctx; bool preserve_fpu; int state; std::exception_ptr except; - T * t; template< typename StackAllocator, typename Fn > control_block( context::preallocated, StackAllocator, Fn &&, bool); - explicit control_block( typename pull_coroutine< T & >::control_block *); + explicit control_block( typename pull_coroutine< T & >::control_block *, boost::context::execution_context const&); ~control_block(); @@ -74,8 +70,7 @@ struct push_coroutine< T & >::control_block { struct push_coroutine< void >::control_block { pull_coroutine< void >::control_block * other; - boost::context::execution_context caller; - boost::context::execution_context callee; + boost::context::execution_context ctx; bool preserve_fpu; int state; std::exception_ptr except; @@ -83,7 +78,7 @@ struct push_coroutine< void >::control_block { template< typename StackAllocator, typename Fn > control_block( context::preallocated, StackAllocator, Fn &&, bool); - explicit control_block( pull_coroutine< void >::control_block *); + explicit control_block( pull_coroutine< void >::control_block *, boost::context::execution_context const&); ~control_block(); diff --git a/boost/coroutine2/detail/push_control_block.ipp b/boost/coroutine2/detail/push_control_block.ipp index ebef5092b5..ce6776f600 100644 --- a/boost/coroutine2/detail/push_control_block.ipp +++ b/boost/coroutine2/detail/push_control_block.ipp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -34,42 +35,46 @@ template< typename StackAllocator, typename Fn > push_coroutine< T >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, Fn && fn_, bool preserve_fpu_) : other( nullptr), - caller( boost::context::execution_context::current() ), - callee( palloc, salloc, - [=,fn=std::forward< Fn >( fn_)] () mutable -> decltype( auto) { - // create synthesized pull_coroutine< T > - typename pull_coroutine< T >::control_block synthesized_cb( this); - pull_coroutine< T > synthesized( & synthesized_cb); - other = & synthesized_cb; - try { - // call coroutine-fn with synthesized pull_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); - } - // set termination flags - state |= static_cast< int >( state_t::complete); - caller( preserve_fpu); - BOOST_ASSERT_MSG( false, "push_coroutine is complete"); - }), + ctx( std::allocator_arg, palloc, salloc, + [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void { + // create synthesized pull_coroutine< T > + typename pull_coroutine< T >::control_block synthesized_cb( this, ctx); + pull_coroutine< T > synthesized( & synthesized_cb); + other = & synthesized_cb; + // jump back to ctor + T * t = reinterpret_cast< T * >( ctx( nullptr, preserve_fpu) ); + // set transferred value + synthesized_cb.set( t); + try { + // call coroutine-fn with synthesized pull_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } + // set termination flags + state |= static_cast< int >( state_t::complete); + // jump back to ctx + other->ctx( nullptr, preserve_fpu); + BOOST_ASSERT_MSG( false, "push_coroutine is complete"); + }), preserve_fpu( preserve_fpu_), state( static_cast< int >( state_t::unwind) ), - except(), - t( nullptr) { + except() { + // enter coroutine-fn in order to get other set + ctx( nullptr, preserve_fpu); } template< typename T > -push_coroutine< T >::control_block::control_block( typename pull_coroutine< T >::control_block * cb) : +push_coroutine< T >::control_block::control_block( typename pull_coroutine< T >::control_block * cb, + boost::context::execution_context const& ctx_) : other( cb), - caller( other->callee), - callee( other->caller), + ctx( ctx_), preserve_fpu( other->preserve_fpu), state( 0), - except(), - t( nullptr) { + except() { } template< typename T > @@ -78,19 +83,16 @@ push_coroutine< T >::control_block::~control_block() { 0 != ( state & static_cast< int >( state_t::unwind) ) ) { // set early-exit flag state |= static_cast< int >( state_t::early_exit); - callee( preserve_fpu); + ctx( nullptr, preserve_fpu); } } template< typename T > void -push_coroutine< T >::control_block::resume( T const& t_) { - // store data on this stack - // pass an pointer (address of tmp) to other context - T tmp( t_); - t = & tmp; - callee( preserve_fpu); - t = nullptr; +push_coroutine< T >::control_block::resume( T const& t) { + other->ctx = boost::context::execution_context::current(); + // pass an pointer to other context + ctx( const_cast< T * >( & t), preserve_fpu); if ( except) { std::rethrow_exception( except); } @@ -102,13 +104,10 @@ push_coroutine< T >::control_block::resume( T const& t_) { template< typename T > void -push_coroutine< T >::control_block::resume( T && t_) { - // store data on this stack - // pass an pointer (address of tmp) to other context - T tmp( std::move( t_) ); - t = & tmp; - callee( preserve_fpu); - t = nullptr; +push_coroutine< T >::control_block::resume( T && t) { + other->ctx = boost::context::execution_context::current(); + // pass an pointer to other context + ctx( std::addressof( t), preserve_fpu); if ( except) { std::rethrow_exception( except); } @@ -132,42 +131,46 @@ template< typename StackAllocator, typename Fn > push_coroutine< T & >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, Fn && fn_, bool preserve_fpu_) : other( nullptr), - caller( boost::context::execution_context::current() ), - callee( palloc, salloc, - [=,fn=std::forward< Fn >( fn_)] () mutable -> decltype( auto) { - // create synthesized pull_coroutine< T > - typename pull_coroutine< T & >::control_block synthesized_cb( this); - pull_coroutine< T & > synthesized( & synthesized_cb); - other = & synthesized_cb; - try { - // call coroutine-fn with synthesized pull_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); - } - // set termination flags - state |= static_cast< int >( state_t::complete); - caller( preserve_fpu); - BOOST_ASSERT_MSG( false, "push_coroutine is complete"); - }), + ctx( std::allocator_arg, palloc, salloc, + [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void { + // create synthesized pull_coroutine< T > + typename pull_coroutine< T & >::control_block synthesized_cb( this, ctx); + pull_coroutine< T & > synthesized( & synthesized_cb); + other = & synthesized_cb; + // jump back to ctor + T * t = reinterpret_cast< T * >( ctx( nullptr, preserve_fpu) ); + // set transferred value + synthesized_cb.t = t; + try { + // call coroutine-fn with synthesized pull_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } + // set termination flags + state |= static_cast< int >( state_t::complete); + // jump back to ctx + other->ctx( nullptr, preserve_fpu); + BOOST_ASSERT_MSG( false, "push_coroutine is complete"); + }), preserve_fpu( preserve_fpu_), state( static_cast< int >( state_t::unwind) ), - except(), - t( nullptr) { + except() { + // enter coroutine-fn in order to get other set + ctx( nullptr, preserve_fpu); } template< typename T > -push_coroutine< T & >::control_block::control_block( typename pull_coroutine< T & >::control_block * cb) : +push_coroutine< T & >::control_block::control_block( typename pull_coroutine< T & >::control_block * cb, + boost::context::execution_context const& ctx_) : other( cb), - caller( other->callee), - callee( other->caller), + ctx( ctx_), preserve_fpu( other->preserve_fpu), state( 0), - except(), - t( nullptr) { + except() { } template< typename T > @@ -176,16 +179,16 @@ push_coroutine< T & >::control_block::~control_block() { 0 != ( state & static_cast< int >( state_t::unwind) ) ) { // set early-exit flag state |= static_cast< int >( state_t::early_exit); - callee( preserve_fpu); + ctx( nullptr, preserve_fpu); } } template< typename T > void -push_coroutine< T & >::control_block::resume( T & t_) { - t = & t_; - callee( preserve_fpu); - t = nullptr; +push_coroutine< T & >::control_block::resume( T & t) { + other->ctx = boost::context::execution_context::current(); + // pass an pointer to other context + ctx( const_cast< typename std::remove_const< T >::type * >( std::addressof( t) ), preserve_fpu); if ( except) { std::rethrow_exception( except); } @@ -207,37 +210,41 @@ push_coroutine< T & >::control_block::valid() const noexcept { template< typename StackAllocator, typename Fn > push_coroutine< void >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, Fn && fn_, bool preserve_fpu_) : other( nullptr), - caller( boost::context::execution_context::current() ), - callee( palloc, salloc, - [=,fn=std::forward< Fn >( fn_)] () mutable -> decltype( auto) { - // create synthesized pull_coroutine< T > - typename pull_coroutine< void >::control_block synthesized_cb( this); - pull_coroutine< void > synthesized( & synthesized_cb); - other = & synthesized_cb; - try { - // call coroutine-fn with synthesized pull_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); - } - // set termination flags - state |= static_cast< int >( state_t::complete); - caller( preserve_fpu); - BOOST_ASSERT_MSG( false, "push_coroutine is complete"); - }), + ctx( std::allocator_arg, palloc, salloc, + [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void { + // create synthesized pull_coroutine< T > + typename pull_coroutine< void >::control_block synthesized_cb( this, ctx); + pull_coroutine< void > synthesized( & synthesized_cb); + other = & synthesized_cb; + // jump back to ctor + ctx( nullptr, preserve_fpu); + try { + // call coroutine-fn with synthesized pull_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } + // set termination flags + state |= static_cast< int >( state_t::complete); + // jump back to ctx + other->ctx( nullptr, preserve_fpu); + BOOST_ASSERT_MSG( false, "push_coroutine is complete"); + }), preserve_fpu( preserve_fpu_), state( static_cast< int >( state_t::unwind) ), except() { + // enter coroutine-fn in order to get other set + ctx( nullptr, preserve_fpu); } inline -push_coroutine< void >::control_block::control_block( pull_coroutine< void >::control_block * cb) : +push_coroutine< void >::control_block::control_block( pull_coroutine< void >::control_block * cb, + boost::context::execution_context const& ctx_) : other( cb), - caller( other->callee), - callee( other->caller), + ctx( ctx_), preserve_fpu( other->preserve_fpu), state( 0), except() { @@ -249,14 +256,15 @@ push_coroutine< void >::control_block::~control_block() { 0 != ( state & static_cast< int >( state_t::unwind) ) ) { // set early-exit flag state |= static_cast< int >( state_t::early_exit); - callee( preserve_fpu); + ctx( nullptr, preserve_fpu); } } inline void push_coroutine< void >::control_block::resume() { - callee( preserve_fpu); + other->ctx = boost::context::execution_context::current(); + ctx( nullptr, preserve_fpu); if ( except) { std::rethrow_exception( except); } diff --git a/boost/coroutine2/detail/push_coroutine.ipp b/boost/coroutine2/detail/push_coroutine.ipp index 4617e73aac..5f4817802a 100644 --- a/boost/coroutine2/detail/push_coroutine.ipp +++ b/boost/coroutine2/detail/push_coroutine.ipp @@ -18,6 +18,7 @@ #include #include +#include #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -37,7 +38,7 @@ push_coroutine< T >::push_coroutine( control_block * cb) : template< typename T > template< typename Fn > push_coroutine< T >::push_coroutine( Fn && fn, bool preserve_fpu) : - push_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + push_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename T > @@ -115,7 +116,7 @@ push_coroutine< T & >::push_coroutine( control_block * cb) : template< typename T > template< typename Fn > push_coroutine< T & >::push_coroutine( Fn && fn, bool preserve_fpu) : - push_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + push_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename T > @@ -185,7 +186,7 @@ push_coroutine< void >::push_coroutine( control_block * cb) : template< typename Fn > push_coroutine< void >::push_coroutine( Fn && fn, bool preserve_fpu) : - push_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + push_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename StackAllocator, typename Fn > diff --git a/boost/coroutine2/fixedsize_stack.hpp b/boost/coroutine2/fixedsize_stack.hpp index 56523ab29a..8aa66fee61 100644 --- a/boost/coroutine2/fixedsize_stack.hpp +++ b/boost/coroutine2/fixedsize_stack.hpp @@ -23,6 +23,9 @@ namespace boost { namespace coroutines2 { typedef boost::context::fixedsize_stack fixedsize_stack; +#if !defined(BOOST_USE_SEGMENTED_STACKS) +typedef boost::context::default_stack default_stack; +#endif }} diff --git a/boost/coroutine2/segmented_stack.hpp b/boost/coroutine2/segmented_stack.hpp index a252ae445f..8443bc3561 100644 --- a/boost/coroutine2/segmented_stack.hpp +++ b/boost/coroutine2/segmented_stack.hpp @@ -24,7 +24,8 @@ namespace coroutines2 { #if defined(BOOST_USE_SEGMENTED_STACKS) # if ! defined(BOOST_WINDOWS) -typedef boost::context::segmented_stack segmented_stack; +typedef boost::context::segmented_stack segmented_stack; +typedef boost::context::default_stack default_stack; # endif #endif diff --git a/boost/cstdint.hpp b/boost/cstdint.hpp index 69888352da..bf7097ec8c 100644 --- a/boost/cstdint.hpp +++ b/boost/cstdint.hpp @@ -69,7 +69,7 @@ # endif -#ifdef __QNX__ +#if defined(__QNX__) && defined(__EXT_QNX) // QNX (Dinkumware stdlib) defines these as non-standard names. // Reflect to the standard names. diff --git a/boost/date_time/date.hpp b/boost/date_time/date.hpp index 2bd936cd5b..b38db220d5 100644 --- a/boost/date_time/date.hpp +++ b/boost/date_time/date.hpp @@ -159,7 +159,7 @@ namespace date_time { { return date_type(date_rep_type(days_) - dd.get_rep()); } - return date_type(date_rep_type(days_) - dd.days()); + return date_type(date_rep_type(days_) - static_cast(dd.days())); } date_type operator-=(const duration_type& dd) { @@ -177,7 +177,7 @@ namespace date_time { { return date_type(date_rep_type(days_) + dd.get_rep()); } - return date_type(date_rep_type(days_) + dd.days()); + return date_type(date_rep_type(days_) + static_cast(dd.days())); } date_type operator+=(const duration_type& dd) { diff --git a/boost/date_time/gregorian_calendar.ipp b/boost/date_time/gregorian_calendar.ipp index 8a58c8844a..7b43ea8512 100644 --- a/boost/date_time/gregorian_calendar.ipp +++ b/boost/date_time/gregorian_calendar.ipp @@ -44,12 +44,12 @@ namespace date_time { unsigned long week = (juliantoday + day - julianbegin + 4)/7; if ((week >= 1) && (week <= 52)) { - return week; + return static_cast(week); } if (week == 53) { if((day==6) ||(day == 5 && is_leap_year(ymd.year))) { - return week; //under these circumstances week == 53. + return static_cast(week); //under these circumstances week == 53. } else { return 1; //monday - wednesday is in week 1 of next year } @@ -60,10 +60,10 @@ namespace date_time { juliantoday = julian_day_number(ymd); day = (julianbegin + 3) % 7; week = (juliantoday + day - julianbegin + 4)/7; - return week; + return static_cast(week); } - return week; //not reachable -- well except if day == 5 and is_leap_year != true + return static_cast(week); //not reachable -- well except if day == 5 and is_leap_year != true } @@ -79,7 +79,7 @@ namespace date_time { unsigned short y = static_cast(ymd.year + 4800 - a); unsigned short m = static_cast(ymd.month + 12*a - 3); unsigned long d = ymd.day + ((153*m + 2)/5) + 365*y + (y/4) - (y/100) + (y/400) - 32045; - return d; + return static_cast(d); } //! Convert a year-month-day into the julian day number diff --git a/boost/date_time/int_adapter.hpp b/boost/date_time/int_adapter.hpp index 81f68f645c..39210864ca 100644 --- a/boost/date_time/int_adapter.hpp +++ b/boost/date_time/int_adapter.hpp @@ -230,7 +230,7 @@ public: return int_adapter::neg_infinity(); } } - return int_adapter(value_ + rhs.as_number()); + return int_adapter(value_ + static_cast(rhs.as_number())); } int_adapter operator+(const int_type rhs) const @@ -279,7 +279,7 @@ public: return int_adapter::pos_infinity(); } } - return int_adapter(value_ - rhs.as_number()); + return int_adapter(value_ - static_cast(rhs.as_number())); } int_adapter operator-(const int_type rhs) const { diff --git a/boost/date_time/posix_time/posix_time_duration.hpp b/boost/date_time/posix_time/posix_time_duration.hpp index 7e15df2302..34380de904 100644 --- a/boost/date_time/posix_time/posix_time_duration.hpp +++ b/boost/date_time/posix_time/posix_time_duration.hpp @@ -21,7 +21,7 @@ namespace posix_time { { public: explicit hours(long h) : - time_duration(h,0,0) + time_duration(static_cast(h),0,0) {} }; @@ -32,7 +32,7 @@ namespace posix_time { { public: explicit minutes(long m) : - time_duration(0,m,0) + time_duration(0,static_cast(m),0) {} }; @@ -43,7 +43,7 @@ namespace posix_time { { public: explicit seconds(long s) : - time_duration(0,0,s) + time_duration(0,0,static_cast(s)) {} }; diff --git a/boost/date_time/time_system_counted.hpp b/boost/date_time/time_system_counted.hpp index e5ed20b8c6..af27aad36e 100644 --- a/boost/date_time/time_system_counted.hpp +++ b/boost/date_time/time_system_counted.hpp @@ -54,7 +54,7 @@ namespace date_time { return date_type(time_count_.as_special()); } else { - typename calendar_type::date_int_type dc = day_count(); + typename calendar_type::date_int_type dc = static_cast(day_count()); //std::cout << "time_rep here:" << dc << std::endl; ymd_type ymd = calendar_type::from_day_number(dc); return date_type(ymd); diff --git a/boost/detail/is_incrementable.hpp b/boost/detail/is_incrementable.hpp index 88ddb14513..5ebf4b7aca 100644 --- a/boost/detail/is_incrementable.hpp +++ b/boost/detail/is_incrementable.hpp @@ -4,16 +4,13 @@ #ifndef IS_INCREMENTABLE_DWA200415_HPP # define IS_INCREMENTABLE_DWA200415_HPP -# include +# include # include # include # include # include -// Must be the last include -# include - -namespace boost { namespace detail { +namespace boost { namespace detail { // is_incrementable metafunction // @@ -27,7 +24,7 @@ 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. @@ -35,7 +32,7 @@ namespace is_incrementable_ // 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 @@ -47,33 +44,33 @@ using namespace is_incrementable_2; namespace is_incrementable_ { - + # else - + tag operator++(any const&); tag operator++(any const&,int); - -# endif + +# endif # if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) # define BOOST_comma(a,b) (a) -# else +# else // In case an operator++ is found that returns void, we'll use ++x,0 - tag operator,(tag,int); + tag operator,(tag,int); # define BOOST_comma(a,b) (a,b) -# endif +# endif # if defined(BOOST_MSVC) # pragma warning(push) # pragma warning(disable:4913) // Warning about operator, -# endif +# endif // two check overloads help us identify which operator++ was picked char (& check_(tag) )[2]; - + template char check_(T const&); - + template struct impl @@ -99,33 +96,28 @@ namespace is_incrementable_ # if defined(BOOST_MSVC) # pragma warning(pop) -# endif +# 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) +template +struct is_incrementable : + public boost::integral_constant::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_::postfix_impl::value) -{ - BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::postfix_impl::value) +template +struct is_postfix_incrementable : + public boost::integral_constant::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 diff --git a/boost/detail/winapi/GetCurrentProcess.hpp b/boost/detail/winapi/GetCurrentProcess.hpp index 51206bb4e8..431b52fa4c 100644 --- a/boost/detail/winapi/GetCurrentProcess.hpp +++ b/boost/detail/winapi/GetCurrentProcess.hpp @@ -1,6 +1,7 @@ // GetCurrentProcess.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,15 +16,19 @@ #pragma once #endif +// Windows CE define GetCurrentProcess as an inline function in kfuncs.h +#if !defined( BOOST_USE_WINDOWS_H ) && !defined( UNDER_CE ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI GetCurrentProcess(BOOST_DETAIL_WINAPI_VOID); +} +#endif + namespace boost { namespace detail { namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentProcess; -#else - extern "C" __declspec(dllimport) HANDLE_ WINAPI GetCurrentProcess(); -#endif +using ::GetCurrentProcess; } } } + #endif // BOOST_DETAIL_WINAPI_GETCURRENTPROCESS_HPP diff --git a/boost/detail/winapi/GetCurrentThread.hpp b/boost/detail/winapi/GetCurrentThread.hpp index 595b751d13..cbcdc97bda 100644 --- a/boost/detail/winapi/GetCurrentThread.hpp +++ b/boost/detail/winapi/GetCurrentThread.hpp @@ -1,6 +1,7 @@ // GetCurrentThread.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,22 +16,17 @@ #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(); +#if !defined( BOOST_USE_WINDOWS_H ) && !defined( UNDER_CE ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI GetCurrentThread(BOOST_DETAIL_WINAPI_VOID); } -#else -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentThread; -#else - extern "C" __declspec(dllimport) HANDLE_ WINAPI GetCurrentThread(); -#endif #endif + +namespace boost { +namespace detail { +namespace winapi { +using ::GetCurrentThread; } } } diff --git a/boost/detail/winapi/GetLastError.hpp b/boost/detail/winapi/GetLastError.hpp index 6e9e2d998a..8874ba853a 100644 --- a/boost/detail/winapi/GetLastError.hpp +++ b/boost/detail/winapi/GetLastError.hpp @@ -1,6 +1,7 @@ // GetLastError.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,15 +16,16 @@ #pragma once #endif +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetLastError(BOOST_DETAIL_WINAPI_VOID); +} +#endif + namespace boost { namespace detail { namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetLastError; -#else - extern "C" __declspec(dllimport) DWORD_ WINAPI - GetLastError(); -#endif +using ::GetLastError; } } } diff --git a/boost/detail/winapi/GetProcessTimes.hpp b/boost/detail/winapi/GetProcessTimes.hpp index f2860b06bd..41b3f0e493 100644 --- a/boost/detail/winapi/GetProcessTimes.hpp +++ b/boost/detail/winapi/GetProcessTimes.hpp @@ -9,31 +9,52 @@ #ifndef BOOST_DETAIL_WINAPI_GETPROCESSTIMES_HPP #define BOOST_DETAIL_WINAPI_GETPROCESSTIMES_HPP -#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif +// Windows CE does not define GetProcessTimes +#if !defined( UNDER_CE ) + +#include +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +GetProcessTimes( + boost::detail::winapi::HANDLE_ hProcess, + ::_FILETIME* lpCreationTime, + ::_FILETIME* lpExitTime, + ::_FILETIME* lpKernelTime, + ::_FILETIME* lpUserTime); +} +#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 + +BOOST_FORCEINLINE BOOL_ GetProcessTimes( + HANDLE_ hProcess, + LPFILETIME_ lpCreationTime, + LPFILETIME_ lpExitTime, + LPFILETIME_ lpKernelTime, + LPFILETIME_ lpUserTime) +{ + return ::GetProcessTimes( + hProcess, + reinterpret_cast< ::_FILETIME* >(lpCreationTime), + reinterpret_cast< ::_FILETIME* >(lpExitTime), + reinterpret_cast< ::_FILETIME* >(lpKernelTime), + reinterpret_cast< ::_FILETIME* >(lpUserTime)); +} + } } } +#endif // !defined( UNDER_CE ) #endif // BOOST_DETAIL_WINAPI_GETPROCESSTIMES_HPP diff --git a/boost/detail/winapi/GetThreadTimes.hpp b/boost/detail/winapi/GetThreadTimes.hpp index 3428edad22..2e1eb8f45c 100644 --- a/boost/detail/winapi/GetThreadTimes.hpp +++ b/boost/detail/winapi/GetThreadTimes.hpp @@ -1,6 +1,7 @@ // GetThreadTimes.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -9,27 +10,44 @@ #ifndef BOOST_DETAIL_WINAPI_GETTHREADTIMES_HPP #define BOOST_DETAIL_WINAPI_GETTHREADTIMES_HPP +#include #include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +GetThreadTimes( + boost::detail::winapi::HANDLE_ hThread, + ::_FILETIME* lpCreationTime, + ::_FILETIME* lpExitTime, + ::_FILETIME* lpKernelTime, + ::_FILETIME* lpUserTime); +} +#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 + +BOOST_FORCEINLINE BOOL_ GetThreadTimes( + HANDLE_ hThread, + LPFILETIME_ lpCreationTime, + LPFILETIME_ lpExitTime, + LPFILETIME_ lpKernelTime, + LPFILETIME_ lpUserTime) +{ + return ::GetThreadTimes( + hThread, + reinterpret_cast< ::_FILETIME* >(lpCreationTime), + reinterpret_cast< ::_FILETIME* >(lpExitTime), + reinterpret_cast< ::_FILETIME* >(lpKernelTime), + reinterpret_cast< ::_FILETIME* >(lpUserTime)); +} + } } } diff --git a/boost/detail/winapi/LocalFree.hpp b/boost/detail/winapi/LocalFree.hpp deleted file mode 100644 index 697016c0c6..0000000000 --- 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/apc.hpp b/boost/detail/winapi/apc.hpp new file mode 100644 index 0000000000..6913045bec --- /dev/null +++ b/boost/detail/winapi/apc.hpp @@ -0,0 +1,47 @@ +// apc.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_APC_HPP +#define BOOST_DETAIL_WINAPI_APC_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 + +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +typedef boost::detail::winapi::VOID_ +(NTAPI *PAPCFUNC)(boost::detail::winapi::ULONG_PTR_ Parameter); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +QueueUserAPC( + PAPCFUNC pfnAPC, + boost::detail::winapi::HANDLE_ hThread, + boost::detail::winapi::ULONG_PTR_ dwData); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { +typedef ::PAPCFUNC PAPCFUNC_; +using ::QueueUserAPC; +} +} +} + +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 + +#endif // BOOST_DETAIL_WINAPI_APC_HPP diff --git a/boost/detail/winapi/basic_types.hpp b/boost/detail/winapi/basic_types.hpp index 09d907bdc2..717e934e42 100644 --- a/boost/detail/winapi/basic_types.hpp +++ b/boost/detail/winapi/basic_types.hpp @@ -1,11 +1,11 @@ // basic_types.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // 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 @@ -13,11 +13,14 @@ #include #include +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + #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 @@ -26,9 +29,14 @@ # define WINAPI __stdcall # endif # endif +// Windows CE defines a few functions as inline functions in kfuncs.h +typedef int BOOL; +typedef unsigned long DWORD; +typedef void* HANDLE; +# include # else # ifndef WINAPI -# define WINAPI __stdcall +# define WINAPI __stdcall # endif # endif # ifndef NTAPI @@ -38,95 +46,178 @@ # error "Win32 functions not available" #endif -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once +#ifndef NO_STRICT +#ifndef STRICT +#define STRICT 1 +#endif +#endif + +#if defined(STRICT) +#define BOOST_DETAIL_WINAPI_DECLARE_HANDLE(x) struct x##__; typedef struct x##__ *x +#else +#define BOOST_DETAIL_WINAPI_DECLARE_HANDLE(x) typedef void* x +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +union _LARGE_INTEGER; +struct _SECURITY_ATTRIBUTES; +BOOST_DETAIL_WINAPI_DECLARE_HANDLE(HINSTANCE); +typedef HINSTANCE HMODULE; +} +#endif + +#if defined(__GNUC__) +#define BOOST_DETAIL_WINAPI_MAY_ALIAS __attribute__ ((__may_alias__)) +#else +#define BOOST_DETAIL_WINAPI_MAY_ALIAS #endif +// MinGW64 gcc 4.8.2 fails to compile function declarations with boost::detail::winapi::VOID_ arguments even though +// the typedef expands to void. In Windows SDK, VOID is a macro which unfolds to void. We use our own macro in such cases. +#define BOOST_DETAIL_WINAPI_VOID void + 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 + +typedef ::BOOL BOOL_; +typedef ::PBOOL PBOOL_; +typedef ::LPBOOL LPBOOL_; +typedef ::BOOLEAN BOOLEAN_; +typedef ::PBOOLEAN PBOOLEAN_; +typedef ::BYTE BYTE_; +typedef ::PBYTE PBYTE_; +typedef ::LPBYTE LPBYTE_; +typedef ::WORD WORD_; +typedef ::PWORD PWORD_; +typedef ::LPWORD LPWORD_; +typedef ::DWORD DWORD_; +typedef ::PDWORD PDWORD_; +typedef ::LPDWORD LPDWORD_; +typedef ::HANDLE HANDLE_; +typedef ::PHANDLE PHANDLE_; +typedef ::INT INT_; +typedef ::PINT PINT_; +typedef ::LPINT LPINT_; +typedef ::UINT UINT_; +typedef ::PUINT PUINT_; +typedef ::LONG LONG_; +typedef ::PLONG PLONG_; +typedef ::LPLONG LPLONG_; +typedef ::ULONG ULONG_; +typedef ::PULONG PULONG_; +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 ::DWORD_PTR DWORD_PTR_; +typedef ::PDWORD_PTR PDWORD_PTR_; +typedef ::SIZE_T SIZE_T_; +typedef ::PSIZE_T PSIZE_T_; +typedef ::SSIZE_T SSIZE_T_; +typedef ::PSSIZE_T PSSIZE_T_; +typedef VOID VOID_; // VOID is a macro +typedef ::PVOID PVOID_; +typedef ::LPVOID LPVOID_; +typedef ::LPCVOID LPCVOID_; +typedef ::CHAR CHAR_; +typedef ::LPSTR LPSTR_; +typedef ::LPCSTR LPCSTR_; +typedef ::WCHAR WCHAR_; +typedef ::LPWSTR LPWSTR_; +typedef ::LPCWSTR LPCWSTR_; + +#else // defined( BOOST_USE_WINDOWS_H ) + +typedef int BOOL_; +typedef BOOL_* PBOOL_; +typedef BOOL_* LPBOOL_; +typedef unsigned char BYTE_; +typedef BYTE_* PBYTE_; +typedef BYTE_* LPBYTE_; +typedef BYTE_ BOOLEAN_; +typedef BOOLEAN_* PBOOLEAN_; +typedef unsigned short WORD_; +typedef WORD_* PWORD_; +typedef WORD_* LPWORD_; +typedef unsigned long DWORD_; +typedef DWORD_* PDWORD_; +typedef DWORD_* LPDWORD_; +typedef void* HANDLE_; +typedef void** PHANDLE_; + +typedef int INT_; +typedef INT_* PINT_; +typedef INT_* LPINT_; +typedef unsigned int UINT_; +typedef UINT_* PUINT_; +typedef long LONG_; +typedef LONG_* PLONG_; +typedef LONG_* LPLONG_; +typedef unsigned long ULONG_; +typedef ULONG_* PULONG_; + +typedef boost::int64_t LONGLONG_; +typedef boost::uint64_t ULONGLONG_; + # 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 +# 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_; +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 ULONG_PTR_ DWORD_PTR_, *PDWORD_PTR_; +typedef ULONG_PTR_ SIZE_T_, *PSIZE_T_; +typedef LONG_PTR_ SSIZE_T_, *PSSIZE_T_; - typedef void *PVOID_; - typedef void *LPVOID_; - typedef const void *LPCVOID_; +typedef void VOID_; +typedef void *PVOID_; +typedef void *LPVOID_; +typedef const void *LPCVOID_; - typedef char CHAR_; - typedef CHAR_ *LPSTR_; - typedef const CHAR_ *LPCSTR_; +typedef char CHAR_; +typedef CHAR_ *LPSTR_; +typedef const CHAR_ *LPCSTR_; + +typedef wchar_t WCHAR_; +typedef WCHAR_ *LPWSTR_; +typedef const WCHAR_ *LPCWSTR_; + +#endif // defined( BOOST_USE_WINDOWS_H ) + +typedef ::HMODULE HMODULE_; + +typedef union BOOST_DETAIL_WINAPI_MAY_ALIAS _LARGE_INTEGER { + struct { + DWORD_ LowPart; + LONG_ HighPart; + } u; + LONGLONG_ QuadPart; +} LARGE_INTEGER_, *PLARGE_INTEGER_; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SECURITY_ATTRIBUTES { + DWORD_ nLength; + LPVOID_ lpSecurityDescriptor; + BOOL_ bInheritHandle; +} SECURITY_ATTRIBUTES_, *PSECURITY_ATTRIBUTES_, *LPSECURITY_ATTRIBUTES_; - typedef wchar_t WCHAR_; - typedef WCHAR_ *LPWSTR_; - typedef const WCHAR_ *LPCWSTR_; -} -#endif } } } diff --git a/boost/detail/winapi/condition_variable.hpp b/boost/detail/winapi/condition_variable.hpp new file mode 100644 index 0000000000..b47a537158 --- /dev/null +++ b/boost/detail/winapi/condition_variable.hpp @@ -0,0 +1,116 @@ +// condition_variable.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_CONDITION_VARIABLE_HPP +#define BOOST_DETAIL_WINAPI_CONDITION_VARIABLE_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _RTL_CONDITION_VARIABLE; +struct _RTL_CRITICAL_SECTION; +struct _RTL_SRWLOCK; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +InitializeConditionVariable(::_RTL_CONDITION_VARIABLE* ConditionVariable); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +WakeConditionVariable(::_RTL_CONDITION_VARIABLE* ConditionVariable); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +WakeAllConditionVariable(::_RTL_CONDITION_VARIABLE* ConditionVariable); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SleepConditionVariableCS( + ::_RTL_CONDITION_VARIABLE* ConditionVariable, + ::_RTL_CRITICAL_SECTION* CriticalSection, + boost::detail::winapi::DWORD_ dwMilliseconds); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SleepConditionVariableSRW( + ::_RTL_CONDITION_VARIABLE* ConditionVariable, + ::_RTL_SRWLOCK* SRWLock, + boost::detail::winapi::DWORD_ dwMilliseconds, + boost::detail::winapi::ULONG_ Flags); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_CONDITION_VARIABLE { + PVOID_ Ptr; +} CONDITION_VARIABLE_, *PCONDITION_VARIABLE_; +struct _RTL_CRITICAL_SECTION; +struct _RTL_SRWLOCK; + +BOOST_FORCEINLINE VOID_ InitializeConditionVariable(PCONDITION_VARIABLE_ ConditionVariable) +{ + ::InitializeConditionVariable(reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable)); +} + +BOOST_FORCEINLINE VOID_ WakeConditionVariable(PCONDITION_VARIABLE_ ConditionVariable) +{ + ::WakeConditionVariable(reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable)); +} + +BOOST_FORCEINLINE VOID_ WakeAllConditionVariable(PCONDITION_VARIABLE_ ConditionVariable) +{ + ::WakeAllConditionVariable(reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable)); +} + +BOOST_FORCEINLINE BOOL_ SleepConditionVariableCS( + PCONDITION_VARIABLE_ ConditionVariable, + _RTL_CRITICAL_SECTION* CriticalSection, + DWORD_ dwMilliseconds) +{ + return ::SleepConditionVariableCS( + reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable), + reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(CriticalSection), + dwMilliseconds); +} + +BOOST_FORCEINLINE BOOL_ SleepConditionVariableSRW( + PCONDITION_VARIABLE_ ConditionVariable, + _RTL_SRWLOCK* SRWLock, + DWORD_ dwMilliseconds, + ULONG_ Flags) +{ + return ::SleepConditionVariableSRW( + reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable), + reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock), + dwMilliseconds, + Flags); +} + +#if defined( BOOST_USE_WINDOWS_H ) +const ULONG_ CONDITION_VARIABLE_LOCKMODE_SHARED_ = CONDITION_VARIABLE_LOCKMODE_SHARED; +#else // defined( BOOST_USE_WINDOWS_H ) +const ULONG_ CONDITION_VARIABLE_LOCKMODE_SHARED_ = 0x00000001; +#endif // defined( BOOST_USE_WINDOWS_H ) + +const ULONG_ condition_variable_lockmode_shared = CONDITION_VARIABLE_LOCKMODE_SHARED_; + +} +} +} + +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#endif // BOOST_DETAIL_WINAPI_CONDITION_VARIABLE_HPP diff --git a/boost/detail/winapi/config.hpp b/boost/detail/winapi/config.hpp index 2b0cdfbada..c67d670dd2 100644 --- a/boost/detail/winapi/config.hpp +++ b/boost/detail/winapi/config.hpp @@ -10,11 +10,24 @@ #define BOOST_DETAIL_WINAPI_CONFIG_HPP_INCLUDED_ #include +#if defined __MINGW32__ +#include <_mingw.h> +#endif #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif +// BOOST_WINAPI_IS_MINGW indicates that the target Windows SDK is provided by MinGW (http://mingw.org/). +// BOOST_WINAPI_IS_MINGW_W64 indicates that the target Windows SDK is provided by MinGW-w64 (http://mingw-w64.org). +#if defined __MINGW32__ +#if defined __MINGW64_VERSION_MAJOR +#define BOOST_WINAPI_IS_MINGW_W64 +#else +#define BOOST_WINAPI_IS_MINGW +#endif +#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 @@ -28,6 +41,8 @@ #define BOOST_WINAPI_VERSION_WIN7 0x0601 #define BOOST_WINAPI_VERSION_WIN8 0x0602 #define BOOST_WINAPI_VERSION_WINBLUE 0x0603 +#define BOOST_WINAPI_VERSION_WINTHRESHOLD 0x0A00 +#define BOOST_WINAPI_VERSION_WIN10 0x0A00 #if !defined(BOOST_USE_WINAPI_VERSION) #if defined(_WIN32_WINNT) @@ -35,8 +50,12 @@ #elif defined(WINVER) #define BOOST_USE_WINAPI_VERSION WINVER #else -// By default use Windows XP API +// By default use Windows Vista API on compilers that support it and XP on the others +#if (defined(_MSC_VER) && _MSC_VER <= 1400) || defined(BOOST_WINAPI_IS_MINGW) #define BOOST_USE_WINAPI_VERSION BOOST_WINAPI_VERSION_WINXP +#else +#define BOOST_USE_WINAPI_VERSION BOOST_WINAPI_VERSION_WIN6 +#endif #endif #endif diff --git a/boost/detail/winapi/critical_section.hpp b/boost/detail/winapi/critical_section.hpp new file mode 100644 index 0000000000..be1d3472c4 --- /dev/null +++ b/boost/detail/winapi/critical_section.hpp @@ -0,0 +1,184 @@ +// critical_section.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_CRITICAL_SECTION_HPP +#define BOOST_DETAIL_WINAPI_CRITICAL_SECTION_HPP + +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) + +extern "C" { +#if !defined( BOOST_WINAPI_IS_MINGW ) +struct _RTL_CRITICAL_SECTION; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +InitializeCriticalSection(::_RTL_CRITICAL_SECTION* lpCriticalSection); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +EnterCriticalSection(::_RTL_CRITICAL_SECTION* lpCriticalSection); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +LeaveCriticalSection(::_RTL_CRITICAL_SECTION* lpCriticalSection); + +#if BOOST_USE_WINAPI_VERSION >= 0x0403 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitializeCriticalSectionAndSpinCount( + ::_RTL_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitializeCriticalSectionEx( + ::_RTL_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount, + boost::detail::winapi::DWORD_ Flags); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +SetCriticalSectionSpinCount( + ::_RTL_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +TryEnterCriticalSection(::_RTL_CRITICAL_SECTION* lpCriticalSection); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +DeleteCriticalSection(::_RTL_CRITICAL_SECTION* lpCriticalSection); + +#else // defined( BOOST_WINAPI_IS_MINGW ) + +// MinGW uses a different name for the structure +struct _CRITICAL_SECTION; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +InitializeCriticalSection(::_CRITICAL_SECTION* lpCriticalSection); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +EnterCriticalSection(::_CRITICAL_SECTION* lpCriticalSection); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +LeaveCriticalSection(::_CRITICAL_SECTION* lpCriticalSection); + +#if BOOST_USE_WINAPI_VERSION >= 0x0403 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitializeCriticalSectionAndSpinCount( + ::_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitializeCriticalSectionEx( + ::_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount, + boost::detail::winapi::DWORD_ Flags); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +SetCriticalSectionSpinCount( + ::_CRITICAL_SECTION* lpCriticalSection, + boost::detail::winapi::DWORD_ dwSpinCount); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +TryEnterCriticalSection(::_CRITICAL_SECTION* lpCriticalSection); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +DeleteCriticalSection(::_CRITICAL_SECTION* lpCriticalSection); + +#endif // defined( BOOST_WINAPI_IS_MINGW ) +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +struct _RTL_CRITICAL_SECTION_DEBUG; + +#pragma pack(push, 8) + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_CRITICAL_SECTION { + _RTL_CRITICAL_SECTION_DEBUG* DebugInfo; + LONG_ LockCount; + LONG_ RecursionCount; + HANDLE_ OwningThread; + HANDLE_ LockSemaphore; + ULONG_PTR_ SpinCount; +} CRITICAL_SECTION_, *PCRITICAL_SECTION_; + +#pragma pack(pop) + +BOOST_FORCEINLINE VOID_ InitializeCriticalSection(CRITICAL_SECTION_* lpCriticalSection) +{ + ::InitializeCriticalSection(winapi::detail::cast_ptr(lpCriticalSection)); +} + +BOOST_FORCEINLINE VOID_ EnterCriticalSection(CRITICAL_SECTION_* lpCriticalSection) +{ + ::EnterCriticalSection(winapi::detail::cast_ptr(lpCriticalSection)); +} + +BOOST_FORCEINLINE VOID_ LeaveCriticalSection(CRITICAL_SECTION_* lpCriticalSection) +{ + ::LeaveCriticalSection(winapi::detail::cast_ptr(lpCriticalSection)); +} + +#if BOOST_USE_WINAPI_VERSION >= 0x0403 +BOOST_FORCEINLINE BOOL_ InitializeCriticalSectionAndSpinCount(CRITICAL_SECTION_* lpCriticalSection, DWORD_ dwSpinCount) +{ + return ::InitializeCriticalSectionAndSpinCount(winapi::detail::cast_ptr(lpCriticalSection), dwSpinCount); +} + +// CRITICAL_SECTION_NO_DEBUG_INFO is defined for WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +const DWORD_ CRITICAL_SECTION_NO_DEBUG_INFO_ = 0x01000000; +const DWORD_ CRITICAL_SECTION_FLAG_NO_DEBUG_INFO_ = CRITICAL_SECTION_NO_DEBUG_INFO_; +const DWORD_ CRITICAL_SECTION_FLAG_DYNAMIC_SPIN_ = 0x02000000; // undocumented +const DWORD_ CRITICAL_SECTION_FLAG_STATIC_INIT_ = 0x04000000; // undocumented + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE BOOL_ InitializeCriticalSectionEx(CRITICAL_SECTION_* lpCriticalSection, DWORD_ dwSpinCount, DWORD_ Flags) +{ + return ::InitializeCriticalSectionEx(winapi::detail::cast_ptr(lpCriticalSection), dwSpinCount, Flags); +} +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +BOOST_FORCEINLINE DWORD_ SetCriticalSectionSpinCount(CRITICAL_SECTION_* lpCriticalSection, DWORD_ dwSpinCount) +{ + return ::SetCriticalSectionSpinCount(winapi::detail::cast_ptr(lpCriticalSection), dwSpinCount); +} +#endif // BOOST_USE_WINAPI_VERSION >= 0x0403 + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 +BOOST_FORCEINLINE BOOL_ TryEnterCriticalSection(CRITICAL_SECTION_* lpCriticalSection) +{ + return ::TryEnterCriticalSection(winapi::detail::cast_ptr(lpCriticalSection)); +} +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 + +BOOST_FORCEINLINE VOID_ DeleteCriticalSection(CRITICAL_SECTION_* lpCriticalSection) +{ + ::DeleteCriticalSection(winapi::detail::cast_ptr(lpCriticalSection)); +} + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_CRITICAL_SECTION_HPP diff --git a/boost/detail/winapi/crypt.hpp b/boost/detail/winapi/crypt.hpp index c9108f29bf..4d2ebedb01 100644 --- a/boost/detail/winapi/crypt.hpp +++ b/boost/detail/winapi/crypt.hpp @@ -1,6 +1,7 @@ // crypt.hpp --------------------------------------------------------------// // Copyright 2014 Antony Polukhin +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -10,77 +11,181 @@ #define BOOST_DETAIL_WINAPI_CRYPT_HPP #include +#include +#if defined( BOOST_USE_WINDOWS_H ) && defined( BOOST_WINAPI_IS_MINGW ) +// MinGW does not include this header as part of windows.h +#include +#endif #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ +#if !defined( BOOST_USE_WINDOWS_H ) +namespace boost { namespace detail { namespace winapi { +typedef ULONG_PTR_ HCRYPTPROV_; +}}} + +// Some versions of MinGW (including the latest ones) contain buggy declarations of CryptEnumProvidersA and CryptEnumProvidersW. +// We cannot detect those broken versions, and we can't include the system header because it's incomplete. +// So below we duplicate the broken declarations here and work around the problem with cast_ptr. These declarations +// will have to be removed when MinGW is fixed. + +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +#if !defined( BOOST_WINAPI_IS_MINGW ) || !defined( UNICODE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptEnumProvidersA( + boost::detail::winapi::DWORD_ dwIndex, + boost::detail::winapi::DWORD_ *pdwReserved, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ *pdwProvType, + boost::detail::winapi::LPSTR_ szProvName, + boost::detail::winapi::DWORD_ *pcbProvName); +#else +// Broken declaration in MinGW +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptEnumProvidersA( + boost::detail::winapi::DWORD_ dwIndex, + boost::detail::winapi::DWORD_ *pdwReserved, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ *pdwProvType, + boost::detail::winapi::LPWSTR_ szProvName, + boost::detail::winapi::DWORD_ *pcbProvName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptAcquireContextA( + boost::detail::winapi::HCRYPTPROV_ *phProv, + boost::detail::winapi::LPCSTR_ pszContainer, + boost::detail::winapi::LPCSTR_ pszProvider, + boost::detail::winapi::DWORD_ dwProvType, + boost::detail::winapi::DWORD_ dwFlags); +#endif // !defined( BOOST_NO_ANSI_APIS ) + +#if !defined( BOOST_WINAPI_IS_MINGW ) || defined( UNICODE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptEnumProvidersW( + boost::detail::winapi::DWORD_ dwIndex, + boost::detail::winapi::DWORD_ *pdwReserved, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ *pdwProvType, + boost::detail::winapi::LPWSTR_ szProvName, + boost::detail::winapi::DWORD_ *pcbProvName); +#else +// Broken declaration in MinGW +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptEnumProvidersW( + boost::detail::winapi::DWORD_ dwIndex, + boost::detail::winapi::DWORD_ *pdwReserved, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ *pdwProvType, + boost::detail::winapi::LPSTR_ szProvName, + boost::detail::winapi::DWORD_ *pcbProvName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptAcquireContextW( + boost::detail::winapi::HCRYPTPROV_ *phProv, + boost::detail::winapi::LPCWSTR_ szContainer, + boost::detail::winapi::LPCWSTR_ szProvider, + boost::detail::winapi::DWORD_ dwProvType, + boost::detail::winapi::DWORD_ dwFlags); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptGenRandom( + boost::detail::winapi::HCRYPTPROV_ hProv, + boost::detail::winapi::DWORD_ dwLen, + boost::detail::winapi::BYTE_ *pbBuffer); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CryptReleaseContext( + boost::detail::winapi::HCRYPTPROV_ hProv, + boost::detail::winapi::DWORD_ dwFlags); +} +#endif // !defined( BOOST_USE_WINDOWS_H ) + +namespace boost { +namespace detail { +namespace winapi { + #if defined( BOOST_USE_WINDOWS_H ) - typedef HCRYPTPROV HCRYPTPROV_; - using ::CryptEnumProvidersA; - using ::CryptAcquireContextA; - using ::CryptGenRandom; - using ::CryptReleaseContext; +typedef ::HCRYPTPROV HCRYPTPROV_; - const DWORD_ PROV_RSA_FULL_ = PROV_RSA_FULL; +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; - 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; + +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 + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::CryptEnumProvidersA; +using ::CryptAcquireContextA; +#endif +using ::CryptEnumProvidersW; +using ::CryptAcquireContextW; +using ::CryptGenRandom; +using ::CryptReleaseContext; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE BOOL_ crypt_enum_providers( + DWORD_ dwIndex, + DWORD_ *pdwReserved, + DWORD_ dwFlags, + DWORD_ *pdwProvType, + LPSTR_ szProvName, + DWORD_ *pcbProvName) +{ + return ::CryptEnumProvidersA(dwIndex, pdwReserved, dwFlags, pdwProvType, winapi::detail::cast_ptr(szProvName), pcbProvName); +} + +BOOST_FORCEINLINE BOOL_ crypt_acquire_context( + HCRYPTPROV_ *phProv, + LPCSTR_ pszContainer, + LPCSTR_ pszProvider, + DWORD_ dwProvType, + DWORD_ dwFlags) +{ + return ::CryptAcquireContextA(phProv, pszContainer, pszProvider, dwProvType, dwFlags); } #endif + +BOOST_FORCEINLINE BOOL_ crypt_enum_providers( + DWORD_ dwIndex, + DWORD_ *pdwReserved, + DWORD_ dwFlags, + DWORD_ *pdwProvType, + LPWSTR_ szProvName, + DWORD_ *pcbProvName) +{ + return ::CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, winapi::detail::cast_ptr(szProvName), pcbProvName); +} + +BOOST_FORCEINLINE BOOL_ crypt_acquire_context( + HCRYPTPROV_ *phProv, + LPCWSTR_ szContainer, + LPCWSTR_ szProvider, + DWORD_ dwProvType, + DWORD_ dwFlags) +{ + return ::CryptAcquireContextW(phProv, szContainer, szProvider, dwProvType, dwFlags); +} + } } } diff --git a/boost/detail/winapi/detail/cast_ptr.hpp b/boost/detail/winapi/detail/cast_ptr.hpp new file mode 100644 index 0000000000..261007ee7a --- /dev/null +++ b/boost/detail/winapi/detail/cast_ptr.hpp @@ -0,0 +1,40 @@ +// cast_ptr.hpp --------------------------------------------------------------// + +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_DETAIL_CAST_PTR_HPP +#define BOOST_DETAIL_WINAPI_DETAIL_CAST_PTR_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace boost { +namespace detail { +namespace winapi { +namespace detail { + +//! This class is used to automatically cast pointers to the type used in the current Windows SDK function declarations +class cast_ptr +{ +private: + const void* m_p; + +public: + explicit BOOST_FORCEINLINE cast_ptr(const void* p) BOOST_NOEXCEPT : m_p(p) {} + template< typename T > + BOOST_FORCEINLINE operator T* () const BOOST_NOEXCEPT { return (T*)m_p; } +}; + +} +} +} +} + +#endif // BOOST_DETAIL_WINAPI_DETAIL_CAST_PTR_HPP diff --git a/boost/detail/winapi/directory_management.hpp b/boost/detail/winapi/directory_management.hpp index 19af1ee4ea..61e406b02e 100644 --- a/boost/detail/winapi/directory_management.hpp +++ b/boost/detail/winapi/directory_management.hpp @@ -1,6 +1,7 @@ // directory_management.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -10,37 +11,83 @@ #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_); +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI + CreateDirectoryA(boost::detail::winapi::LPCSTR_, ::_SECURITY_ATTRIBUTES*); +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI + GetTempPathA(boost::detail::winapi::DWORD_ length, boost::detail::winapi::LPSTR_ buffer); +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI + RemoveDirectoryA(boost::detail::winapi::LPCSTR_); +#endif +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI + CreateDirectoryW(boost::detail::winapi::LPCWSTR_, ::_SECURITY_ATTRIBUTES*); +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI + GetTempPathW(boost::detail::winapi::DWORD_ length, boost::detail::winapi::LPWSTR_ buffer); +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI + RemoveDirectoryW(boost::detail::winapi::LPCWSTR_); } #endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::GetTempPathA; +using ::RemoveDirectoryA; +#endif +using ::GetTempPathW; +using ::RemoveDirectoryW; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE BOOL_ CreateDirectoryA(LPCSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes) +{ + return ::CreateDirectoryA(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes)); +} +#endif + +BOOST_FORCEINLINE BOOL_ CreateDirectoryW(LPCWSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes) +{ + return ::CreateDirectoryW(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes)); +} + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE BOOL_ create_directory(LPCSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes) +{ + return ::CreateDirectoryA(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes)); +} +BOOST_FORCEINLINE DWORD_ get_temp_path(DWORD_ length, LPSTR_ buffer) +{ + return ::GetTempPathA(length, buffer); +} +BOOST_FORCEINLINE BOOL_ remove_directory(LPCSTR_ pPathName) +{ + return ::RemoveDirectoryA(pPathName); +} +#endif + +BOOST_FORCEINLINE BOOL_ create_directory(LPCWSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes) +{ + return ::CreateDirectoryW(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes)); } +BOOST_FORCEINLINE DWORD_ get_temp_path(DWORD_ length, LPWSTR_ buffer) +{ + return ::GetTempPathW(length, buffer); } +BOOST_FORCEINLINE BOOL_ remove_directory(LPCWSTR_ pPathName) +{ + return ::RemoveDirectoryW(pPathName); } -#endif // BOOST_DETAIL_WINAPI_THREAD_HPP +} // namespace winapi +} // namespace detail +} // namespace boost + +#endif // BOOST_DETAIL_WINAPI_DIRECTORY_MANAGEMENT_HPP diff --git a/boost/detail/winapi/dll.hpp b/boost/detail/winapi/dll.hpp index 2ec5a73bc9..5172f33880 100644 --- a/boost/detail/winapi/dll.hpp +++ b/boost/detail/winapi/dll.hpp @@ -1,6 +1,9 @@ // dll.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2014 Renato Tegon Forti, Antony Polukhin +// Copyright 2015 Andrey Semashev +// Copyright 2015 Antony Polukhin // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -10,77 +13,184 @@ #define BOOST_DETAIL_WINAPI_DLL_HPP #include -#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif -namespace boost +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +namespace boost { namespace detail { namespace winapi { +#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 +}}} // namespace boost::detail::winapi + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +LoadLibraryA(boost::detail::winapi::LPCSTR_ lpFileName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +LoadLibraryExA( + boost::detail::winapi::LPCSTR_ lpFileName, + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwFlags +); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +GetModuleHandleA(boost::detail::winapi::LPCSTR_ lpFileName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +GetModuleFileNameA( + boost::detail::winapi::HMODULE_ hModule, + boost::detail::winapi::LPSTR_ lpFilename, + boost::detail::winapi::DWORD_ nSize +); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +LoadLibraryW(boost::detail::winapi::LPCWSTR_ lpFileName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +LoadLibraryExW( + boost::detail::winapi::LPCWSTR_ lpFileName, + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwFlags +); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HMODULE_ WINAPI +GetModuleHandleW(boost::detail::winapi::LPCWSTR_ lpFileName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +GetModuleFileNameW( + boost::detail::winapi::HMODULE_ hModule, + boost::detail::winapi::LPWSTR_ lpFilename, + boost::detail::winapi::DWORD_ nSize +); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FreeLibrary(boost::detail::winapi::HMODULE_ hModule); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::FARPROC_ WINAPI +GetProcAddress(boost::detail::winapi::HMODULE_ hModule, boost::detail::winapi::LPCSTR_ lpProcName); + +struct _MEMORY_BASIC_INFORMATION; + +#if !defined( BOOST_WINAPI_IS_MINGW ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::SIZE_T_ WINAPI +VirtualQuery( + boost::detail::winapi::LPCVOID_ lpAddress, + ::_MEMORY_BASIC_INFORMATION* lpBuffer, + boost::detail::winapi::ULONG_PTR_ dwLength +); +#else // !defined( BOOST_WINAPI_IS_MINGW ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +VirtualQuery( + boost::detail::winapi::LPCVOID_ lpAddress, + ::_MEMORY_BASIC_INFORMATION* lpBuffer, + boost::detail::winapi::DWORD_ dwLength +); +#endif // !defined( BOOST_WINAPI_IS_MINGW ) +} // extern "C" +#endif // #if !defined( BOOST_USE_WINDOWS_H ) + +namespace boost { +namespace detail { +namespace winapi { + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS MEMORY_BASIC_INFORMATION_ { + PVOID_ BaseAddress; + PVOID_ AllocationBase; + DWORD_ AllocationProtect; + SIZE_T_ RegionSize; + DWORD_ State; + DWORD_ Protect; + DWORD_ Type; +} *PMEMORY_BASIC_INFORMATION_; + +#if defined( BOOST_USE_WINDOWS_H ) +typedef ::FARPROC FARPROC_; +typedef ::NEARPROC NEARPROC_; +typedef ::PROC PROC_; + +const DWORD_ DONT_RESOLVE_DLL_REFERENCES_ = DONT_RESOLVE_DLL_REFERENCES; +const DWORD_ LOAD_WITH_ALTERED_SEARCH_PATH_ = LOAD_WITH_ALTERED_SEARCH_PATH; +#else // defined( BOOST_USE_WINDOWS_H ) +const DWORD_ DONT_RESOLVE_DLL_REFERENCES_ = 0x00000001; +const DWORD_ LOAD_WITH_ALTERED_SEARCH_PATH_ = 0x00000008; +#endif // defined( BOOST_USE_WINDOWS_H ) + +// This one is not defined by MinGW +const DWORD_ LOAD_IGNORE_CODE_AUTHZ_LEVEL_ = 0x00000010; + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::LoadLibraryA; +using ::LoadLibraryExA; +using ::GetModuleHandleA; +using ::GetModuleFileNameA; +#endif // !defined( BOOST_NO_ANSI_APIS ) +using ::LoadLibraryW; +using ::LoadLibraryExW; +using ::GetModuleHandleW; +using ::GetModuleFileNameW; +using ::FreeLibrary; +using ::GetProcAddress; + +BOOST_FORCEINLINE SIZE_T_ VirtualQuery(LPCVOID_ lpAddress, MEMORY_BASIC_INFORMATION_* lpBuffer, ULONG_PTR_ dwLength) { -namespace detail + return ::VirtualQuery(lpAddress, reinterpret_cast< ::_MEMORY_BASIC_INFORMATION* >(lpBuffer), dwLength); +} + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HMODULE_ load_library(LPCSTR_ lpFileName) { -namespace winapi + return ::LoadLibraryA(lpFileName); +} + +BOOST_FORCEINLINE HMODULE_ load_library_ex(LPCSTR_ lpFileName, HANDLE_ hFile, DWORD_ dwFlags) { -#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 - ); + return ::LoadLibraryExA(lpFileName, hFile, dwFlags); } -#endif + +BOOST_FORCEINLINE HMODULE_ get_module_handle(LPCSTR_ lpFileName) +{ + return ::GetModuleHandleA(lpFileName); } + +BOOST_FORCEINLINE DWORD_ get_module_file_name(HMODULE_ hModule, LPSTR_ lpFilename, DWORD_ nSize) +{ + return ::GetModuleFileNameA(hModule, lpFilename, nSize); } +#endif // #if !defined( BOOST_NO_ANSI_APIS ) + +BOOST_FORCEINLINE HMODULE_ load_library(LPCWSTR_ lpFileName) +{ + return ::LoadLibraryW(lpFileName); +} + +BOOST_FORCEINLINE HMODULE_ load_library_ex(LPCWSTR_ lpFileName, HANDLE_ hFile, DWORD_ dwFlags) +{ + return ::LoadLibraryExW(lpFileName, hFile, dwFlags); } +BOOST_FORCEINLINE HMODULE_ get_module_handle(LPCWSTR_ lpFileName) +{ + return ::GetModuleHandleW(lpFileName); +} + +BOOST_FORCEINLINE DWORD_ get_module_file_name(HMODULE_ hModule, LPWSTR_ lpFilename, DWORD_ nSize) +{ + return ::GetModuleFileNameW(hModule, lpFilename, nSize); +} + +} // namespace winapi +} // namespace detail +} // namespace boost + #endif // BOOST_DETAIL_WINAPI_DLL_HPP diff --git a/boost/detail/winapi/error_handling.hpp b/boost/detail/winapi/error_handling.hpp index fbe9924b25..cdd759ded5 100644 --- a/boost/detail/winapi/error_handling.hpp +++ b/boost/detail/winapi/error_handling.hpp @@ -1,6 +1,7 @@ // error_handling.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -9,85 +10,119 @@ #ifndef BOOST_DETAIL_WINAPI_ERROR_HANDLING_HPP #define BOOST_DETAIL_WINAPI_ERROR_HANDLING_HPP +#include #include -#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +FormatMessageA( + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::LPCVOID_ lpSource, + boost::detail::winapi::DWORD_ dwMessageId, + boost::detail::winapi::DWORD_ dwLanguageId, + boost::detail::winapi::LPSTR_ lpBuffer, + boost::detail::winapi::DWORD_ nSize, + va_list *Arguments); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +FormatMessageW( + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::LPCVOID_ lpSource, + boost::detail::winapi::DWORD_ dwMessageId, + boost::detail::winapi::DWORD_ dwLanguageId, + boost::detail::winapi::LPWSTR_ lpBuffer, + boost::detail::winapi::DWORD_ nSize, + va_list *Arguments); +} +#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); - } + +const DWORD_ FORMAT_MESSAGE_ALLOCATE_BUFFER_= FORMAT_MESSAGE_ALLOCATE_BUFFER; +const DWORD_ FORMAT_MESSAGE_IGNORE_INSERTS_= FORMAT_MESSAGE_IGNORE_INSERTS; +const DWORD_ FORMAT_MESSAGE_FROM_STRING_= FORMAT_MESSAGE_FROM_STRING; +const DWORD_ FORMAT_MESSAGE_FROM_HMODULE_= FORMAT_MESSAGE_FROM_HMODULE; +const DWORD_ FORMAT_MESSAGE_FROM_SYSTEM_= FORMAT_MESSAGE_FROM_SYSTEM; +const DWORD_ FORMAT_MESSAGE_ARGUMENT_ARRAY_= FORMAT_MESSAGE_ARGUMENT_ARRAY; +const DWORD_ FORMAT_MESSAGE_MAX_WIDTH_MASK_= FORMAT_MESSAGE_MAX_WIDTH_MASK; + +const WORD_ LANG_NEUTRAL_= LANG_NEUTRAL; +const WORD_ LANG_INVARIANT_= LANG_INVARIANT; + +const WORD_ SUBLANG_DEFAULT_= SUBLANG_DEFAULT; // user default + +BOOST_FORCEINLINE 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)); - } +const DWORD_ FORMAT_MESSAGE_ALLOCATE_BUFFER_= 0x00000100; +const DWORD_ FORMAT_MESSAGE_IGNORE_INSERTS_= 0x00000200; +const DWORD_ FORMAT_MESSAGE_FROM_STRING_= 0x00000400; +const DWORD_ FORMAT_MESSAGE_FROM_HMODULE_= 0x00000800; +const DWORD_ FORMAT_MESSAGE_FROM_SYSTEM_= 0x00001000; +const DWORD_ FORMAT_MESSAGE_ARGUMENT_ARRAY_= 0x00002000; +const DWORD_ FORMAT_MESSAGE_MAX_WIDTH_MASK_= 0x000000FF; + +const WORD_ LANG_NEUTRAL_= 0x00; +const WORD_ LANG_INVARIANT_= 0x7f; + +const WORD_ SUBLANG_DEFAULT_= 0x01; // user default + +BOOST_FORCEINLINE WORD_ MAKELANGID_(WORD_ p, WORD_ s) +{ + return ((((WORD_)(s)) << 10) | (WORD_)(p)); +} + +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::FormatMessageA; +#endif +using ::FormatMessageW; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE DWORD_ format_message( + DWORD_ dwFlags, + LPCVOID_ lpSource, + DWORD_ dwMessageId, + DWORD_ dwLanguageId, + LPSTR_ lpBuffer, + DWORD_ nSize, + va_list *Arguments) +{ + return ::FormatMessageA(dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, Arguments); } #endif + +BOOST_FORCEINLINE DWORD_ format_message( + DWORD_ dwFlags, + LPCVOID_ lpSource, + DWORD_ dwMessageId, + DWORD_ dwLanguageId, + LPWSTR_ lpBuffer, + DWORD_ nSize, + va_list *Arguments) +{ + return ::FormatMessageW(dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, Arguments); +} + } } } + #endif // BOOST_DETAIL_WINAPI_ERROR_HANDLING_HPP diff --git a/boost/detail/winapi/event.hpp b/boost/detail/winapi/event.hpp new file mode 100644 index 0000000000..ec2b096103 --- /dev/null +++ b/boost/detail/winapi/event.hpp @@ -0,0 +1,183 @@ +// event.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_EVENT_HPP +#define BOOST_DETAIL_WINAPI_EVENT_HPP + +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +#if !defined( BOOST_PLAT_WINDOWS_RUNTIME_AVALIABLE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateEventA( + ::_SECURITY_ATTRIBUTES* lpEventAttributes, + boost::detail::winapi::BOOL_ bManualReset, + boost::detail::winapi::BOOL_ bInitialState, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateEventExA( + ::_SECURITY_ATTRIBUTES *lpEventAttributes, + boost::detail::winapi::LPCSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenEventA( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateEventW( + ::_SECURITY_ATTRIBUTES* lpEventAttributes, + boost::detail::winapi::BOOL_ bManualReset, + boost::detail::winapi::BOOL_ bInitialState, + boost::detail::winapi::LPCWSTR_ lpName); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateEventExW( + ::_SECURITY_ATTRIBUTES *lpEventAttributes, + boost::detail::winapi::LPCWSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenEventW( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCWSTR_ lpName); + +// Windows CE define SetEvent/ResetEvent as inline functions in kfuncs.h +#if !defined( UNDER_CE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SetEvent(boost::detail::winapi::HANDLE_ hEvent); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +ResetEvent(boost::detail::winapi::HANDLE_ hEvent); +#endif +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::OpenEventA; +#endif +using ::OpenEventW; +using ::SetEvent; +using ::ResetEvent; + +#if defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ EVENT_ALL_ACCESS_ = EVENT_ALL_ACCESS; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ CREATE_EVENT_INITIAL_SET_ = CREATE_EVENT_INITIAL_SET; +const DWORD_ CREATE_EVENT_MANUAL_RESET_ = CREATE_EVENT_MANUAL_RESET; +#endif + +#else // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ EVENT_ALL_ACCESS_ = 0x1F0003; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ CREATE_EVENT_INITIAL_SET_ = 0x00000002; +const DWORD_ CREATE_EVENT_MANUAL_RESET_ = 0x00000001; +#endif + +#endif // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ event_all_access = EVENT_ALL_ACCESS_; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ create_event_initial_set = CREATE_EVENT_INITIAL_SET_; +const DWORD_ create_event_manual_reset = CREATE_EVENT_MANUAL_RESET_; +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateEventA(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + const DWORD_ flags = (bManualReset ? create_event_manual_reset : 0u) | (bInitialState ? create_event_initial_set : 0u); + return ::CreateEventExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, flags, event_all_access); +#else + return ::CreateEventA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), bManualReset, bInitialState, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateEventExA(SECURITY_ATTRIBUTES_* lpEventAttributes, LPCSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess) +{ + return ::CreateEventExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, dwFlags, dwDesiredAccess); +} +#endif +#endif + +BOOST_FORCEINLINE HANDLE_ CreateEventW(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCWSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + const DWORD_ flags = (bManualReset ? create_event_manual_reset : 0u) | (bInitialState ? create_event_initial_set : 0u); + return ::CreateEventExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, flags, event_all_access); +#else + return ::CreateEventW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), bManualReset, bInitialState, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateEventExW(SECURITY_ATTRIBUTES_* lpEventAttributes, LPCWSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess) +{ + return ::CreateEventExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, dwFlags, dwDesiredAccess); +} +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCSTR_ lpName) +{ + return winapi::CreateEventA(lpEventAttributes, bManualReset, bInitialState, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_event(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName) +{ + return ::OpenEventA(dwDesiredAccess, bInheritHandle, lpName); +} +#endif + +BOOST_FORCEINLINE HANDLE_ create_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCWSTR_ lpName) +{ + return winapi::CreateEventW(lpEventAttributes, bManualReset, bInitialState, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_event(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName) +{ + return ::OpenEventW(dwDesiredAccess, bInheritHandle, lpName); +} + +BOOST_FORCEINLINE HANDLE_ create_anonymous_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState) +{ + return winapi::CreateEventW(lpEventAttributes, bManualReset, bInitialState, 0); +} + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_EVENT_HPP diff --git a/boost/detail/winapi/file_management.hpp b/boost/detail/winapi/file_management.hpp index c1d5978ba7..c923d8499e 100644 --- a/boost/detail/winapi/file_management.hpp +++ b/boost/detail/winapi/file_management.hpp @@ -1,6 +1,7 @@ -// thread.hpp --------------------------------------------------------------// +// file_management.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -10,121 +11,381 @@ #define BOOST_DETAIL_WINAPI_FILE_MANAGEMENT_HPP #include -#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif -namespace boost +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _OVERLAPPED; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateFileA( + boost::detail::winapi::LPCSTR_ lpFileName, + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::DWORD_ dwShareMode, + ::_SECURITY_ATTRIBUTES* lpSecurityAttributes, + boost::detail::winapi::DWORD_ dwCreationDisposition, + boost::detail::winapi::DWORD_ dwFlagsAndAttributes, + boost::detail::winapi::HANDLE_ hTemplateFile); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +DeleteFileA(boost::detail::winapi::LPCSTR_ lpFileName); + +struct _WIN32_FIND_DATAA; +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +FindFirstFileA(boost::detail::winapi::LPCSTR_ lpFileName, ::_WIN32_FIND_DATAA* lpFindFileData); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FindNextFileA(boost::detail::winapi::HANDLE_ hFindFile, ::_WIN32_FIND_DATAA* lpFindFileData); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +MoveFileExA( + boost::detail::winapi::LPCSTR_ lpExistingFileName, + boost::detail::winapi::LPCSTR_ lpNewFileName, + boost::detail::winapi::DWORD_ dwFlags); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateFileW( + boost::detail::winapi::LPCWSTR_ lpFileName, + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::DWORD_ dwShareMode, + ::_SECURITY_ATTRIBUTES* lpSecurityAttributes, + boost::detail::winapi::DWORD_ dwCreationDisposition, + boost::detail::winapi::DWORD_ dwFlagsAndAttributes, + boost::detail::winapi::HANDLE_ hTemplateFile); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +DeleteFileW(boost::detail::winapi::LPCWSTR_ lpFileName); + +struct _WIN32_FIND_DATAW; +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +FindFirstFileW(boost::detail::winapi::LPCWSTR_ lpFileName, ::_WIN32_FIND_DATAW* lpFindFileData); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FindNextFileW(boost::detail::winapi::HANDLE_ hFindFile, ::_WIN32_FIND_DATAW* lpFindFileData); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +MoveFileExW( + boost::detail::winapi::LPCWSTR_ lpExistingFileName, + boost::detail::winapi::LPCWSTR_ lpNewFileName, + boost::detail::winapi::DWORD_ dwFlags); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FindClose(boost::detail::winapi::HANDLE_ hFindFile); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +GetFileSizeEx(boost::detail::winapi::HANDLE_ hFile, ::_LARGE_INTEGER* lpFileSize); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SetFileValidData(boost::detail::winapi::HANDLE_ hFile, boost::detail::winapi::LONGLONG_ ValidDataLength); + +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SetEndOfFile(boost::detail::winapi::HANDLE_ hFile); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +LockFile( + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwFileOffsetLow, + boost::detail::winapi::DWORD_ dwFileOffsetHigh, + boost::detail::winapi::DWORD_ nNumberOfBytesToLockLow, + boost::detail::winapi::DWORD_ nNumberOfBytesToLockHigh); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +UnlockFile( + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwFileOffsetLow, + boost::detail::winapi::DWORD_ dwFileOffsetHigh, + boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockLow, + boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockHigh); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +LockFileEx( + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwReserved, + boost::detail::winapi::DWORD_ nNumberOfBytesToLockLow, + boost::detail::winapi::DWORD_ nNumberOfBytesToLockHigh, + ::_OVERLAPPED* lpOverlapped); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +UnlockFileEx( + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::DWORD_ dwReserved, + boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockLow, + boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockHigh, + ::_OVERLAPPED* lpOverlapped); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +WriteFile( + boost::detail::winapi::HANDLE_ hFile, + boost::detail::winapi::LPCVOID_ lpBuffer, + boost::detail::winapi::DWORD_ nNumberOfBytesToWrite, + boost::detail::winapi::LPDWORD_ lpNumberOfBytesWritten, + ::_OVERLAPPED* lpOverlapped); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::DeleteFileA; +using ::MoveFileExA; +#endif + +using ::DeleteFileW; +using ::MoveFileExW; + +using ::FindClose; + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP + +using ::SetFileValidData; + +#endif + +using ::SetEndOfFile; +using ::LockFile; +using ::UnlockFile; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _OVERLAPPED { + ULONG_PTR_ Internal; + ULONG_PTR_ InternalHigh; + union { + struct { + DWORD_ Offset; + DWORD_ OffsetHigh; + }; + PVOID_ Pointer; + }; + HANDLE_ hEvent; +} OVERLAPPED_, *LPOVERLAPPED_; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateFileA( + LPCSTR_ lpFileName, + DWORD_ dwDesiredAccess, + DWORD_ dwShareMode, + SECURITY_ATTRIBUTES_* lpSecurityAttributes, + DWORD_ dwCreationDisposition, + DWORD_ dwFlagsAndAttributes, + HANDLE_ hTemplateFile) { -namespace detail + return ::CreateFileA( + lpFileName, + dwDesiredAccess, + dwShareMode, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes), + dwCreationDisposition, + dwFlagsAndAttributes, + hTemplateFile); +} + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _WIN32_FIND_DATAA { + DWORD_ dwFileAttributes; + FILETIME_ ftCreationTime; + FILETIME_ ftLastAccessTime; + FILETIME_ ftLastWriteTime; + DWORD_ nFileSizeHigh; + DWORD_ nFileSizeLow; + DWORD_ dwReserved0; + DWORD_ dwReserved1; + CHAR_ cFileName[ 260 ]; // MAX_PATH + CHAR_ cAlternateFileName[ 14 ]; +#ifdef _MAC + DWORD_ dwFileType; + DWORD_ dwCreatorType; + WORD_ wFinderFlags; +#endif +} WIN32_FIND_DATAA_, *PWIN32_FIND_DATAA_, *LPWIN32_FIND_DATAA_; + +BOOST_FORCEINLINE HANDLE_ FindFirstFileA(LPCSTR_ lpFileName, WIN32_FIND_DATAA_* lpFindFileData) +{ + return ::FindFirstFileA(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ FindNextFileA(HANDLE_ hFindFile, WIN32_FIND_DATAA_* lpFindFileData) { -namespace winapi + return ::FindNextFileA(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData)); +} +#endif + +BOOST_FORCEINLINE HANDLE_ CreateFileW( + LPCWSTR_ lpFileName, + DWORD_ dwDesiredAccess, + DWORD_ dwShareMode, + SECURITY_ATTRIBUTES_* lpSecurityAttributes, + DWORD_ dwCreationDisposition, + DWORD_ dwFlagsAndAttributes, + HANDLE_ hTemplateFile) { -#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 - ); + return ::CreateFileW( + lpFileName, + dwDesiredAccess, + dwShareMode, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes), + dwCreationDisposition, + dwFlagsAndAttributes, + hTemplateFile); } + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _WIN32_FIND_DATAW { + DWORD_ dwFileAttributes; + FILETIME_ ftCreationTime; + FILETIME_ ftLastAccessTime; + FILETIME_ ftLastWriteTime; + DWORD_ nFileSizeHigh; + DWORD_ nFileSizeLow; + DWORD_ dwReserved0; + DWORD_ dwReserved1; + WCHAR_ cFileName[ 260 ]; // MAX_PATH + WCHAR_ cAlternateFileName[ 14 ]; +#ifdef _MAC + DWORD_ dwFileType; + DWORD_ dwCreatorType; + WORD_ wFinderFlags; #endif +} WIN32_FIND_DATAW_, *PWIN32_FIND_DATAW_, *LPWIN32_FIND_DATAW_; + +BOOST_FORCEINLINE HANDLE_ FindFirstFileW(LPCWSTR_ lpFileName, WIN32_FIND_DATAW_* lpFindFileData) +{ + return ::FindFirstFileW(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ FindNextFileW(HANDLE_ hFindFile, WIN32_FIND_DATAW_* lpFindFileData) +{ + return ::FindNextFileW(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ GetFileSizeEx(HANDLE_ hFile, LARGE_INTEGER_* lpFileSize) +{ + return ::GetFileSizeEx(hFile, reinterpret_cast< ::_LARGE_INTEGER* >(lpFileSize)); +} + +BOOST_FORCEINLINE BOOL_ LockFileEx( + HANDLE_ hFile, + DWORD_ dwFlags, + DWORD_ dwReserved, + DWORD_ nNumberOfBytesToLockLow, + DWORD_ nNumberOfBytesToLockHigh, + OVERLAPPED_* lpOverlapped) +{ + return ::LockFileEx(hFile, dwFlags, dwReserved, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped)); +} + +BOOST_FORCEINLINE BOOL_ UnlockFileEx( + HANDLE_ hFile, + DWORD_ dwReserved, + DWORD_ nNumberOfBytesToUnlockLow, + DWORD_ nNumberOfBytesToUnlockHigh, + OVERLAPPED_* lpOverlapped) +{ + return ::UnlockFileEx(hFile, dwReserved, nNumberOfBytesToUnlockLow, nNumberOfBytesToUnlockHigh, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped)); +} + +BOOST_FORCEINLINE BOOL_ WriteFile( + HANDLE_ hFile, + LPCVOID_ lpBuffer, + DWORD_ nNumberOfBytesToWrite, + LPDWORD_ lpNumberOfBytesWritten, + OVERLAPPED_* lpOverlapped) +{ + return ::WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped)); +}; + + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_file( + LPCSTR_ lpFileName, + DWORD_ dwDesiredAccess, + DWORD_ dwShareMode, + SECURITY_ATTRIBUTES_* lpSecurityAttributes, + DWORD_ dwCreationDisposition, + DWORD_ dwFlagsAndAttributes, + HANDLE_ hTemplateFile) +{ + return ::CreateFileA( + lpFileName, + dwDesiredAccess, + dwShareMode, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes), + dwCreationDisposition, + dwFlagsAndAttributes, + hTemplateFile); +} + +BOOST_FORCEINLINE BOOL_ delete_file(LPCSTR_ lpFileName) +{ + return ::DeleteFileA(lpFileName); +} + +BOOST_FORCEINLINE HANDLE_ find_first_file(LPCSTR_ lpFileName, WIN32_FIND_DATAA_* lpFindFileData) +{ + return ::FindFirstFileA(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ find_next_file(HANDLE_ hFindFile, WIN32_FIND_DATAA_* lpFindFileData) +{ + return ::FindNextFileA(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ move_file(LPCSTR_ lpExistingFileName, LPCSTR_ lpNewFileName, DWORD_ dwFlags) +{ + return ::MoveFileExA(lpExistingFileName, lpNewFileName, dwFlags); +} +#endif + +BOOST_FORCEINLINE HANDLE_ create_file( + LPCWSTR_ lpFileName, + DWORD_ dwDesiredAccess, + DWORD_ dwShareMode, + SECURITY_ATTRIBUTES_* lpSecurityAttributes, + DWORD_ dwCreationDisposition, + DWORD_ dwFlagsAndAttributes, + HANDLE_ hTemplateFile) +{ + return ::CreateFileW( + lpFileName, + dwDesiredAccess, + dwShareMode, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes), + dwCreationDisposition, + dwFlagsAndAttributes, + hTemplateFile); +} + +BOOST_FORCEINLINE BOOL_ delete_file(LPCWSTR_ lpFileName) +{ + return ::DeleteFileW(lpFileName); +} + +BOOST_FORCEINLINE HANDLE_ find_first_file(LPCWSTR_ lpFileName, WIN32_FIND_DATAW_* lpFindFileData) +{ + return ::FindFirstFileW(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ find_next_file(HANDLE_ hFindFile, WIN32_FIND_DATAW_* lpFindFileData) +{ + return ::FindNextFileW(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData)); +} + +BOOST_FORCEINLINE BOOL_ move_file(LPCWSTR_ lpExistingFileName, LPCWSTR_ lpNewFileName, DWORD_ dwFlags) +{ + return ::MoveFileExW(lpExistingFileName, lpNewFileName, dwFlags); +} + } } } -#endif // BOOST_DETAIL_WINAPI_THREAD_HPP +#endif // BOOST_DETAIL_WINAPI_FILE_MANAGEMENT_HPP diff --git a/boost/detail/winapi/file_mapping.hpp b/boost/detail/winapi/file_mapping.hpp new file mode 100644 index 0000000000..f3cf794b41 --- /dev/null +++ b/boost/detail/winapi/file_mapping.hpp @@ -0,0 +1,170 @@ +// file_mapping.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_FILE_MAPPING_HPP +#define BOOST_DETAIL_WINAPI_FILE_MAPPING_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateFileMappingA( + boost::detail::winapi::HANDLE_ hFile, + ::_SECURITY_ATTRIBUTES* lpFileMappingAttributes, + boost::detail::winapi::DWORD_ flProtect, + boost::detail::winapi::DWORD_ dwMaximumSizeHigh, + boost::detail::winapi::DWORD_ dwMaximumSizeLow, + boost::detail::winapi::LPCSTR_ lpName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenFileMappingA( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateFileMappingW( + boost::detail::winapi::HANDLE_ hFile, + ::_SECURITY_ATTRIBUTES* lpFileMappingAttributes, + boost::detail::winapi::DWORD_ flProtect, + boost::detail::winapi::DWORD_ dwMaximumSizeHigh, + boost::detail::winapi::DWORD_ dwMaximumSizeLow, + boost::detail::winapi::LPCWSTR_ lpName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenFileMappingW( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCWSTR_ lpName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::LPVOID_ WINAPI +MapViewOfFileEx( + boost::detail::winapi::HANDLE_ hFileMappingObject, + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::DWORD_ dwFileOffsetHigh, + boost::detail::winapi::DWORD_ dwFileOffsetLow, + boost::detail::winapi::SIZE_T_ dwNumberOfBytesToMap, + boost::detail::winapi::LPVOID_ lpBaseAddress); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FlushViewOfFile( + boost::detail::winapi::LPCVOID_ lpBaseAddress, + boost::detail::winapi::SIZE_T_ dwNumberOfBytesToFlush); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +UnmapViewOfFile(boost::detail::winapi::LPCVOID_ lpBaseAddress); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::OpenFileMappingA; +#endif +using ::OpenFileMappingW; +using ::MapViewOfFileEx; +using ::FlushViewOfFile; +using ::UnmapViewOfFile; + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateFileMappingA( + HANDLE_ hFile, + SECURITY_ATTRIBUTES_* lpFileMappingAttributes, + DWORD_ flProtect, + DWORD_ dwMaximumSizeHigh, + DWORD_ dwMaximumSizeLow, + LPCSTR_ lpName) +{ + return ::CreateFileMappingA( + hFile, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes), + flProtect, + dwMaximumSizeHigh, + dwMaximumSizeLow, + lpName); +} +#endif + +BOOST_FORCEINLINE HANDLE_ CreateFileMappingW( + HANDLE_ hFile, + ::_SECURITY_ATTRIBUTES* lpFileMappingAttributes, + DWORD_ flProtect, + DWORD_ dwMaximumSizeHigh, + DWORD_ dwMaximumSizeLow, + LPCWSTR_ lpName) +{ + return ::CreateFileMappingW( + hFile, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes), + flProtect, + dwMaximumSizeHigh, + dwMaximumSizeLow, + lpName); +} + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_file_mapping( + HANDLE_ hFile, + SECURITY_ATTRIBUTES_* lpFileMappingAttributes, + DWORD_ flProtect, + DWORD_ dwMaximumSizeHigh, + DWORD_ dwMaximumSizeLow, + LPCSTR_ lpName) +{ + return ::CreateFileMappingA( + hFile, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes), + flProtect, + dwMaximumSizeHigh, + dwMaximumSizeLow, + lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_file_mapping(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName) +{ + return ::OpenFileMappingA(dwDesiredAccess, bInheritHandle, lpName); +} +#endif + +BOOST_FORCEINLINE HANDLE_ create_file_mapping( + HANDLE_ hFile, + ::_SECURITY_ATTRIBUTES* lpFileMappingAttributes, + DWORD_ flProtect, + DWORD_ dwMaximumSizeHigh, + DWORD_ dwMaximumSizeLow, + LPCWSTR_ lpName) +{ + return ::CreateFileMappingW( + hFile, + reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes), + flProtect, + dwMaximumSizeHigh, + dwMaximumSizeLow, + lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_file_mapping(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName) +{ + return ::OpenFileMappingW(dwDesiredAccess, bInheritHandle, lpName); +} + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_FILE_MAPPING_HPP diff --git a/boost/detail/winapi/handles.hpp b/boost/detail/winapi/handles.hpp index 7108daa10b..54859f46d9 100644 --- a/boost/detail/winapi/handles.hpp +++ b/boost/detail/winapi/handles.hpp @@ -1,6 +1,7 @@ -// memory.hpp --------------------------------------------------------------// +// handles.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,30 +16,44 @@ #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 +#if !defined( BOOST_USE_WINDOWS_H ) extern "C" { - __declspec(dllimport) int __stdcall - CloseHandle(void*); - __declspec(dllimport) int __stdcall - DuplicateHandle(void*,void*,void*,void**,unsigned long,int,unsigned long); +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CloseHandle(boost::detail::winapi::HANDLE_ handle); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +DuplicateHandle( + boost::detail::winapi::HANDLE_ hSourceProcessHandle, + boost::detail::winapi::HANDLE_ hSourceHandle, + boost::detail::winapi::HANDLE_ hTargetProcessHandle, + boost::detail::winapi::HANDLE_* lpTargetHandle, + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::DWORD_ dwOptions); } - const DWORD_ duplicate_close_source = 1; - const DWORD_ duplicate_same_access = 2; - const HANDLE_ invalid_handle_value = (HANDLE_)(-1); #endif + +namespace boost { +namespace detail { +namespace winapi { + +using ::CloseHandle; +using ::DuplicateHandle; + +#if defined( BOOST_USE_WINDOWS_H ) +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 +const DWORD_ DUPLICATE_CLOSE_SOURCE_ = 1; +const DWORD_ DUPLICATE_SAME_ACCESS_ = 2; +const HANDLE_ INVALID_HANDLE_VALUE_ = (HANDLE_)(-1); +#endif + +const DWORD_ duplicate_close_source = DUPLICATE_CLOSE_SOURCE_; +const DWORD_ duplicate_same_access = DUPLICATE_SAME_ACCESS_; +const HANDLE_ invalid_handle_value = INVALID_HANDLE_VALUE_; + } } } diff --git a/boost/detail/winapi/heap_memory.hpp b/boost/detail/winapi/heap_memory.hpp new file mode 100644 index 0000000000..ae863523e4 --- /dev/null +++ b/boost/detail/winapi/heap_memory.hpp @@ -0,0 +1,72 @@ +// heap_memory.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_HEAP_MEMORY_HPP +#define BOOST_DETAIL_WINAPI_HEAP_MEMORY_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +#undef HeapAlloc +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +GetProcessHeap(BOOST_DETAIL_WINAPI_VOID); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +GetProcessHeaps(boost::detail::winapi::DWORD_ NumberOfHeaps, boost::detail::winapi::PHANDLE_ ProcessHeaps); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +HeapCreate( + boost::detail::winapi::DWORD_ flOptions, + boost::detail::winapi::SIZE_T_ dwInitialSize, + boost::detail::winapi::SIZE_T_ dwMaximumSize); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +HeapDestroy(boost::detail::winapi::HANDLE_ hHeap); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::LPVOID_ WINAPI +HeapAlloc( + boost::detail::winapi::HANDLE_ hHeap, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::SIZE_T_ dwBytes); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::LPVOID_ WINAPI +HeapReAlloc( + boost::detail::winapi::HANDLE_ hHeap, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::LPVOID_ lpMem, + boost::detail::winapi::SIZE_T_ dwBytes); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +HeapFree( + boost::detail::winapi::HANDLE_ hHeap, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::LPVOID_ lpMem); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { +using ::GetProcessHeap; +using ::GetProcessHeaps; +using ::HeapCreate; +using ::HeapDestroy; +using ::HeapAlloc; +using ::HeapReAlloc; +using ::HeapFree; +} +} +} + +#endif // BOOST_DETAIL_WINAPI_HEAP_MEMORY_HPP diff --git a/boost/detail/winapi/init_once.hpp b/boost/detail/winapi/init_once.hpp new file mode 100644 index 0000000000..4c0597961e --- /dev/null +++ b/boost/detail/winapi/init_once.hpp @@ -0,0 +1,123 @@ +// init_once.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_INIT_ONCE_HPP +#define BOOST_DETAIL_WINAPI_INIT_ONCE_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if defined( BOOST_WINAPI_IS_MINGW_W64 ) +struct _RTL_RUN_ONCE; +#else +union _RTL_RUN_ONCE; +#endif + +typedef boost::detail::winapi::BOOL_ +(WINAPI *PINIT_ONCE_FN) ( + ::_RTL_RUN_ONCE* InitOnce, + boost::detail::winapi::PVOID_ Parameter, + boost::detail::winapi::PVOID_ *Context); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +InitOnceInitialize(::_RTL_RUN_ONCE* InitOnce); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitOnceExecuteOnce( + ::_RTL_RUN_ONCE* InitOnce, + ::PINIT_ONCE_FN InitFn, + boost::detail::winapi::PVOID_ Parameter, + boost::detail::winapi::LPVOID_ *Context); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitOnceBeginInitialize( + ::_RTL_RUN_ONCE* lpInitOnce, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::PBOOL_ fPending, + boost::detail::winapi::LPVOID_ *lpContext); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitOnceComplete( + ::_RTL_RUN_ONCE* lpInitOnce, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::LPVOID_ lpContext); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +typedef union BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_RUN_ONCE { + PVOID_ Ptr; +} INIT_ONCE_, *PINIT_ONCE_, *LPINIT_ONCE_; + +extern "C" { +typedef BOOL_ (WINAPI *PINIT_ONCE_FN_) (PINIT_ONCE_ lpInitOnce, PVOID_ Parameter, PVOID_ *Context); +} + +BOOST_FORCEINLINE VOID_ InitOnceInitialize(PINIT_ONCE_ lpInitOnce) +{ + ::InitOnceInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce)); +} + +BOOST_FORCEINLINE BOOL_ InitOnceExecuteOnce(PINIT_ONCE_ lpInitOnce, PINIT_ONCE_FN_ InitFn, PVOID_ Parameter, LPVOID_ *Context) +{ + return ::InitOnceExecuteOnce(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), reinterpret_cast< ::PINIT_ONCE_FN >(InitFn), Parameter, Context); +} + +BOOST_FORCEINLINE BOOL_ InitOnceBeginInitialize(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, PBOOL_ fPending, LPVOID_ *lpContext) +{ + return ::InitOnceBeginInitialize(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, fPending, lpContext); +} + +BOOST_FORCEINLINE BOOL_ InitOnceComplete(PINIT_ONCE_ lpInitOnce, DWORD_ dwFlags, LPVOID_ lpContext) +{ + return ::InitOnceComplete(reinterpret_cast< ::_RTL_RUN_ONCE* >(lpInitOnce), dwFlags, lpContext); +} + +#if defined( BOOST_USE_WINDOWS_H ) + +#define BOOST_DETAIL_WINAPI_INIT_ONCE_STATIC_INIT INIT_ONCE_STATIC_INIT +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; + +#else // defined( BOOST_USE_WINDOWS_H ) + +#define BOOST_DETAIL_WINAPI_INIT_ONCE_STATIC_INIT {0} +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; + +#endif // defined( BOOST_USE_WINDOWS_H ) + +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_; + +} +} +} + +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#endif // BOOST_DETAIL_WINAPI_INIT_ONCE_HPP diff --git a/boost/detail/winapi/local_memory.hpp b/boost/detail/winapi/local_memory.hpp new file mode 100644 index 0000000000..17bc08b1bf --- /dev/null +++ b/boost/detail/winapi/local_memory.hpp @@ -0,0 +1,51 @@ +// local_memory.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_LOCAL_MEMORY_HPP +#define BOOST_DETAIL_WINAPI_LOCAL_MEMORY_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +namespace boost { namespace detail { namespace winapi { +typedef HANDLE_ HLOCAL_; +}}} + +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::HLOCAL_ WINAPI +LocalAlloc( + boost::detail::winapi::UINT_ uFlags, + boost::detail::winapi::SIZE_T_ uBytes); +BOOST_SYMBOL_IMPORT boost::detail::winapi::HLOCAL_ WINAPI +LocalReAlloc( + boost::detail::winapi::HLOCAL_ hMem, + boost::detail::winapi::SIZE_T_ uBytes, + boost::detail::winapi::UINT_ uFlags); +BOOST_SYMBOL_IMPORT boost::detail::winapi::HLOCAL_ WINAPI LocalFree(boost::detail::winapi::HLOCAL_ hMem); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { +#if defined( BOOST_USE_WINDOWS_H ) +typedef ::HLOCAL HLOCAL_; +#endif +using ::LocalAlloc; +using ::LocalReAlloc; +using ::LocalFree; +} +} +} + +#endif // BOOST_DETAIL_WINAPI_LOCAL_MEMORY_HPP diff --git a/boost/detail/winapi/memory.hpp b/boost/detail/winapi/memory.hpp index b5316e09e0..3168e21956 100644 --- a/boost/detail/winapi/memory.hpp +++ b/boost/detail/winapi/memory.hpp @@ -1,6 +1,7 @@ // memory.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -9,52 +10,11 @@ #ifndef BOOST_DETAIL_WINAPI_MEMORY_HPP #define BOOST_DETAIL_WINAPI_MEMORY_HPP -#include -#include -#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/mutex.hpp b/boost/detail/winapi/mutex.hpp new file mode 100644 index 0000000000..8f1975ca5c --- /dev/null +++ b/boost/detail/winapi/mutex.hpp @@ -0,0 +1,181 @@ +// mutex.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_MUTEX_HPP +#define BOOST_DETAIL_WINAPI_MUTEX_HPP + +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +#if !defined( BOOST_PLAT_WINDOWS_RUNTIME_AVALIABLE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexA( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::BOOL_ bInitialOwner, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexExA( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::LPCSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenMutexA( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +#if !defined( BOOST_PLAT_WINDOWS_RUNTIME_AVALIABLE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexW( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::BOOL_ bInitialOwner, + boost::detail::winapi::LPCWSTR_ lpName); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateMutexExW( + ::_SECURITY_ATTRIBUTES* lpMutexAttributes, + boost::detail::winapi::LPCWSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenMutexW( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCWSTR_ lpName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +ReleaseMutex(boost::detail::winapi::HANDLE_ hMutex); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::OpenMutexA; +#endif +using ::OpenMutexW; +using ::ReleaseMutex; + +#if defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ MUTEX_ALL_ACCESS_ = MUTEX_ALL_ACCESS; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ CREATE_MUTEX_INITIAL_OWNER_ = CREATE_MUTEX_INITIAL_OWNER; +#endif + +#else // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ MUTEX_ALL_ACCESS_ = 0x1F0001; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ CREATE_MUTEX_INITIAL_OWNER_ = 0x00000001; +#endif + +#endif // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ mutex_all_access = MUTEX_ALL_ACCESS_; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +const DWORD_ create_mutex_initial_owner = CREATE_MUTEX_INITIAL_OWNER_; +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateMutexA(SECURITY_ATTRIBUTES_* lpMutexAttributes, BOOL_ bInitialOwner, LPCSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + const DWORD_ flags = bInitialOwner ? create_mutex_initial_owner : 0u; + return ::CreateMutexExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, flags, mutex_all_access); +#else + return ::CreateMutexA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), bInitialOwner, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateMutexExA( + SECURITY_ATTRIBUTES_* lpMutexAttributes, + LPCSTR_ lpName, + DWORD_ dwFlags, + DWORD_ dwDesiredAccess) +{ + return ::CreateMutexExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, dwFlags, dwDesiredAccess); +} +#endif +#endif + +BOOST_FORCEINLINE HANDLE_ CreateMutexW(SECURITY_ATTRIBUTES_* lpMutexAttributes, BOOL_ bInitialOwner, LPCWSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + const DWORD_ flags = bInitialOwner ? create_mutex_initial_owner : 0u; + return ::CreateMutexExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, flags, mutex_all_access); +#else + return ::CreateMutexW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), bInitialOwner, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateMutexExW( + SECURITY_ATTRIBUTES_* lpMutexAttributes, + LPCWSTR_ lpName, + DWORD_ dwFlags, + DWORD_ dwDesiredAccess) +{ + return ::CreateMutexExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, dwFlags, dwDesiredAccess); +} +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner, LPCSTR_ lpName) +{ + return winapi::CreateMutexA(lpAttributes, bInitialOwner, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_mutex(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName) +{ + return ::OpenMutexA(dwDesiredAccess, bInheritHandle, lpName); +} +#endif + +BOOST_FORCEINLINE HANDLE_ create_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner, LPCWSTR_ lpName) +{ + return winapi::CreateMutexW(lpAttributes, bInitialOwner, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_mutex(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName) +{ + return ::OpenMutexW(dwDesiredAccess, bInheritHandle, lpName); +} + +BOOST_FORCEINLINE HANDLE_ create_anonymous_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner) +{ + return winapi::CreateMutexW(lpAttributes, bInitialOwner, 0); +} + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_MUTEX_HPP diff --git a/boost/detail/winapi/process.hpp b/boost/detail/winapi/process.hpp index de287b15fc..3c3de56e3e 100644 --- a/boost/detail/winapi/process.hpp +++ b/boost/detail/winapi/process.hpp @@ -16,21 +16,19 @@ #pragma once #endif -namespace boost { -namespace detail { -namespace winapi { -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentProcessId; -#else -# ifndef UNDER_CE +// Windows CE define GetCurrentProcessId as an inline function in kfuncs.h +#if !defined( BOOST_USE_WINDOWS_H ) && !defined( UNDER_CE ) extern "C" { - __declspec(dllimport) DWORD_ WINAPI GetCurrentProcessId(void); +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetCurrentProcessId(BOOST_DETAIL_WINAPI_VOID); } -# else - using ::GetCurrentProcessId; -# endif #endif + +namespace boost { +namespace detail { +namespace winapi { +using ::GetCurrentProcessId; } } } + #endif // BOOST_DETAIL_WINAPI_PROCESS_HPP diff --git a/boost/detail/winapi/security.hpp b/boost/detail/winapi/security.hpp index 79925c6c67..4a6544519f 100644 --- a/boost/detail/winapi/security.hpp +++ b/boost/detail/winapi/security.hpp @@ -1,6 +1,7 @@ // security.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,49 +16,63 @@ #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_; - +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _ACL; +struct _SECURITY_DESCRIPTOR; +#if defined( BOOST_WINAPI_IS_MINGW ) +typedef _SECURITY_DESCRIPTOR *PSECURITY_DESCRIPTOR; #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 - ); +typedef boost::detail::winapi::PVOID_ PSECURITY_DESCRIPTOR; +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +InitializeSecurityDescriptor( + PSECURITY_DESCRIPTOR pSecurityDescriptor, + boost::detail::winapi::DWORD_ dwRevision); +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SetSecurityDescriptorDacl( + PSECURITY_DESCRIPTOR pSecurityDescriptor, + boost::detail::winapi::BOOL_ bDaclPresent, + ::_ACL* pDacl, + boost::detail::winapi::BOOL_ bDaclDefaulted); } #endif + +namespace boost { +namespace detail { +namespace winapi { + +typedef PVOID_ PSID_; +typedef WORD_ SECURITY_DESCRIPTOR_CONTROL_, *PSECURITY_DESCRIPTOR_CONTROL_; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _ACL { + BYTE_ AclRevision; + BYTE_ Sbz1; + WORD_ AclSize; + WORD_ AceCount; + WORD_ Sbz2; +} ACL_, *PACL_; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SECURITY_DESCRIPTOR { + BYTE_ Revision; + BYTE_ Sbz1; + SECURITY_DESCRIPTOR_CONTROL_ Control; + PSID_ Owner; + PSID_ Group; + PACL_ Sacl; + PACL_ Dacl; +} SECURITY_DESCRIPTOR_, *PISECURITY_DESCRIPTOR_; + +typedef ::PSECURITY_DESCRIPTOR PSECURITY_DESCRIPTOR_; + +using ::InitializeSecurityDescriptor; + +BOOST_FORCEINLINE BOOL_ SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR_ pSecurityDescriptor, BOOL_ bDaclPresent, PACL_ pDacl, BOOL_ bDaclDefaulted) +{ + return ::SetSecurityDescriptorDacl(pSecurityDescriptor, bDaclPresent, reinterpret_cast< ::_ACL* >(pDacl), bDaclDefaulted); +} + } } } diff --git a/boost/detail/winapi/semaphore.hpp b/boost/detail/winapi/semaphore.hpp new file mode 100644 index 0000000000..ba71aae20b --- /dev/null +++ b/boost/detail/winapi/semaphore.hpp @@ -0,0 +1,170 @@ +// semaphore.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_SEMAPHORE_HPP +#define BOOST_DETAIL_WINAPI_SEMAPHORE_HPP + +#include +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +#if !defined( BOOST_PLAT_WINDOWS_RUNTIME_AVALIABLE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateSemaphoreA( + ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes, + boost::detail::winapi::LONG_ lInitialCount, + boost::detail::winapi::LONG_ lMaximumCount, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateSemaphoreExA( + ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes, + boost::detail::winapi::LONG_ lInitialCount, + boost::detail::winapi::LONG_ lMaximumCount, + boost::detail::winapi::LPCSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenSemaphoreA( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCSTR_ lpName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateSemaphoreW( + ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes, + boost::detail::winapi::LONG_ lInitialCount, + boost::detail::winapi::LONG_ lMaximumCount, + boost::detail::winapi::LPCWSTR_ lpName); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateSemaphoreExW( + ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes, + boost::detail::winapi::LONG_ lInitialCount, + boost::detail::winapi::LONG_ lMaximumCount, + boost::detail::winapi::LPCWSTR_ lpName, + boost::detail::winapi::DWORD_ dwFlags, + boost::detail::winapi::DWORD_ dwDesiredAccess); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenSemaphoreW( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCWSTR_ lpName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +ReleaseSemaphore( + boost::detail::winapi::HANDLE_ hSemaphore, + boost::detail::winapi::LONG_ lReleaseCount, + boost::detail::winapi::LPLONG_ lpPreviousCount); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +#if !defined( BOOST_NO_ANSI_APIS ) +using ::OpenSemaphoreA; +#endif +using ::OpenSemaphoreW; +using ::ReleaseSemaphore; + +#if defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ SEMAPHORE_ALL_ACCESS_ = SEMAPHORE_ALL_ACCESS; + +#else // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ SEMAPHORE_ALL_ACCESS_ = 0x1F0003; + +#endif // defined( BOOST_USE_WINDOWS_H ) + +const DWORD_ semaphore_all_access = SEMAPHORE_ALL_ACCESS_; + + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateSemaphoreA(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + return ::CreateSemaphoreExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, 0, semaphore_all_access); +#else + return ::CreateSemaphoreA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateSemaphoreExA(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess) +{ + return ::CreateSemaphoreExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, dwFlags, dwDesiredAccess); +} +#endif +#endif + +BOOST_FORCEINLINE HANDLE_ CreateSemaphoreW(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName) +{ +#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + return ::CreateSemaphoreExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, 0, semaphore_all_access); +#else + return ::CreateSemaphoreW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName); +#endif +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_FORCEINLINE HANDLE_ CreateSemaphoreExW(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess) +{ + return ::CreateSemaphoreExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, dwFlags, dwDesiredAccess); +} +#endif + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName) +{ + return winapi::CreateSemaphoreA(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_semaphore(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName) +{ + return ::OpenSemaphoreA(dwDesiredAccess, bInheritHandle, lpName); +} +#endif + +BOOST_FORCEINLINE HANDLE_ create_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName) +{ + return winapi::CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName); +} + +BOOST_FORCEINLINE HANDLE_ open_semaphore(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName) +{ + return ::OpenSemaphoreW(dwDesiredAccess, bInheritHandle, lpName); +} + +BOOST_FORCEINLINE HANDLE_ create_anonymous_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount) +{ + return winapi::CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, 0); +} + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_SEMAPHORE_HPP diff --git a/boost/detail/winapi/srw_lock.hpp b/boost/detail/winapi/srw_lock.hpp new file mode 100644 index 0000000000..c5318f5860 --- /dev/null +++ b/boost/detail/winapi/srw_lock.hpp @@ -0,0 +1,105 @@ +// srw_lock.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_SRW_LOCK_HPP +#define BOOST_DETAIL_WINAPI_SRW_LOCK_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _RTL_SRWLOCK; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +InitializeSRWLock(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +ReleaseSRWLockExclusive(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +ReleaseSRWLockShared(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +AcquireSRWLockExclusive(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +AcquireSRWLockShared(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOLEAN_ WINAPI +TryAcquireSRWLockExclusive(::_RTL_SRWLOCK* SRWLock); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOLEAN_ WINAPI +TryAcquireSRWLockShared(::_RTL_SRWLOCK* SRWLock); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_SRWLOCK { + PVOID_ Ptr; +} SRWLOCK_, *PSRWLOCK_; + +#if defined( BOOST_USE_WINDOWS_H ) +#define BOOST_DETAIL_WINAPI_SRWLOCK_INIT SRWLOCK_INIT +#else +#define BOOST_DETAIL_WINAPI_SRWLOCK_INIT {0} +#endif + +BOOST_FORCEINLINE VOID_ InitializeSRWLock(PSRWLOCK_ SRWLock) +{ + ::InitializeSRWLock(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE VOID_ ReleaseSRWLockExclusive(PSRWLOCK_ SRWLock) +{ + ::ReleaseSRWLockExclusive(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE VOID_ ReleaseSRWLockShared(PSRWLOCK_ SRWLock) +{ + ::ReleaseSRWLockShared(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE VOID_ AcquireSRWLockExclusive(PSRWLOCK_ SRWLock) +{ + ::AcquireSRWLockExclusive(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE VOID_ AcquireSRWLockShared(PSRWLOCK_ SRWLock) +{ + ::AcquireSRWLockShared(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE BOOLEAN_ TryAcquireSRWLockExclusive(PSRWLOCK_ SRWLock) +{ + return ::TryAcquireSRWLockExclusive(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +BOOST_FORCEINLINE BOOLEAN_ TryAcquireSRWLockShared(PSRWLOCK_ SRWLock) +{ + return ::TryAcquireSRWLockShared(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); +} + +} +} +} + +#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 + +#endif // BOOST_DETAIL_WINAPI_SRW_LOCK_HPP diff --git a/boost/detail/winapi/synchronization.hpp b/boost/detail/winapi/synchronization.hpp index b9497cbf7c..d4f8c04cb6 100644 --- a/boost/detail/winapi/synchronization.hpp +++ b/boost/detail/winapi/synchronization.hpp @@ -1,6 +1,7 @@ // synchronizaion.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -10,284 +11,18 @@ #define BOOST_DETAIL_WINAPI_SYNCHRONIZATION_HPP #include +#include +#include +#include +#include +#include +#include +#include +#include +#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 index 2c2d82a8a9..93a5eeb11c 100644 --- a/boost/detail/winapi/system.hpp +++ b/boost/detail/winapi/system.hpp @@ -2,6 +2,7 @@ // Copyright 2010 Vicente J. Botet Escriba // Copyright (c) Microsoft Corporation 2014 +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -16,47 +17,57 @@ #pragma once #endif +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _SYSTEM_INFO; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +GetSystemInfo(::_SYSTEM_INFO* lpSystemInfo); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +GetNativeSystemInfo(::_SYSTEM_INFO* lpSystemInfo); +#endif +} +#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; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _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 -} + WORD_ wProcessorArchitecture; + WORD_ wReserved; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + DWORD_ dwPageSize; + LPVOID_ lpMinimumApplicationAddress; + LPVOID_ lpMaximumApplicationAddress; + DWORD_PTR_ dwActiveProcessorMask; + DWORD_ dwNumberOfProcessors; + DWORD_ dwProcessorType; + DWORD_ dwAllocationGranularity; + WORD_ wProcessorLevel; + WORD_ wProcessorRevision; +} SYSTEM_INFO_, *LPSYSTEM_INFO_; + +BOOST_FORCEINLINE VOID_ GetSystemInfo(LPSYSTEM_INFO_ lpSystemInfo) +{ + ::GetSystemInfo(reinterpret_cast< ::_SYSTEM_INFO* >(lpSystemInfo)); +} + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP +BOOST_FORCEINLINE VOID_ GetNativeSystemInfo(LPSYSTEM_INFO_ lpSystemInfo) +{ + ::GetNativeSystemInfo(reinterpret_cast< ::_SYSTEM_INFO* >(lpSystemInfo)); +} #endif + } } } + #endif // BOOST_DETAIL_WINAPI_SYSTEM_HPP diff --git a/boost/detail/winapi/thread.hpp b/boost/detail/winapi/thread.hpp index ee0dac6242..9367d46bd0 100644 --- a/boost/detail/winapi/thread.hpp +++ b/boost/detail/winapi/thread.hpp @@ -1,6 +1,7 @@ // thread.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -16,32 +17,28 @@ #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) - using ::GetCurrentThreadId; - using ::SleepEx; - using ::Sleep; - using ::SwitchToThread; -#else +#if !defined( BOOST_USE_WINDOWS_H ) 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; +// Windows CE define GetCurrentThreadId as an inline function in kfuncs.h +#if !defined( UNDER_CE ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetCurrentThreadId(BOOST_DETAIL_WINAPI_VOID); #endif +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +SleepEx( + boost::detail::winapi::DWORD_ dwMilliseconds, + boost::detail::winapi::BOOL_ bAlertable); +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI Sleep(boost::detail::winapi::DWORD_ dwMilliseconds); +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI SwitchToThread(BOOST_DETAIL_WINAPI_VOID); } #endif + +namespace boost { +namespace detail { +namespace winapi { +using ::GetCurrentThreadId; +using ::SleepEx; +using ::Sleep; +using ::SwitchToThread; } } } diff --git a/boost/detail/winapi/thread_pool.hpp b/boost/detail/winapi/thread_pool.hpp index 57059dc1b2..f81c545961 100644 --- a/boost/detail/winapi/thread_pool.hpp +++ b/boost/detail/winapi/thread_pool.hpp @@ -9,7 +9,7 @@ #ifndef BOOST_DETAIL_WINAPI_THREAD_POOL_HPP #define BOOST_DETAIL_WINAPI_THREAD_POOL_HPP -#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once @@ -17,13 +17,41 @@ #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN2K -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) +#include + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +typedef boost::detail::winapi::VOID_ (NTAPI *WAITORTIMERCALLBACKFUNC) +(boost::detail::winapi::PVOID_, boost::detail::winapi::BOOLEAN_); +typedef WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACK; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +RegisterWaitForSingleObject( + boost::detail::winapi::PHANDLE_ phNewWaitObject, + boost::detail::winapi::HANDLE_ hObject, + WAITORTIMERCALLBACK Callback, + boost::detail::winapi::PVOID_ Context, + boost::detail::winapi::ULONG_ dwMilliseconds, + boost::detail::winapi::ULONG_ dwFlags); +} +#endif + +// MinGW is buggy - it is missing these function declarations for Win2000 +#if !defined( BOOST_USE_WINDOWS_H ) || (defined(BOOST_WINAPI_IS_MINGW) && BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +UnregisterWait(boost::detail::winapi::HANDLE_ WaitHandle); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +UnregisterWaitEx( + boost::detail::winapi::HANDLE_ WaitHandle, + boost::detail::winapi::HANDLE_ CompletionEvent); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { typedef ::WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACKFUNC_; typedef ::WAITORTIMERCALLBACK WAITORTIMERCALLBACK_; @@ -32,61 +60,63 @@ 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; +#if defined( BOOST_USE_WINDOWS_H ) + +const ULONG_ WT_EXECUTEDEFAULT_ = WT_EXECUTEDEFAULT; +const ULONG_ WT_EXECUTEINIOTHREAD_ = WT_EXECUTEINIOTHREAD; +#if defined( BOOST_WINAPI_IS_MINGW ) +const ULONG_ WT_EXECUTEINUITHREAD_ = 0x00000002; +#else +const ULONG_ WT_EXECUTEINUITHREAD_ = WT_EXECUTEINUITHREAD; +#endif +const ULONG_ WT_EXECUTEINWAITTHREAD_ = WT_EXECUTEINWAITTHREAD; +const ULONG_ WT_EXECUTEONLYONCE_ = WT_EXECUTEONLYONCE; +const ULONG_ WT_EXECUTEINTIMERTHREAD_ = WT_EXECUTEINTIMERTHREAD; +const ULONG_ WT_EXECUTELONGFUNCTION_ = WT_EXECUTELONGFUNCTION; +#if defined( BOOST_WINAPI_IS_MINGW ) +const ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = 0x00000040; +#else +const ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = WT_EXECUTEINPERSISTENTIOTHREAD; +#endif +const ULONG_ WT_EXECUTEINPERSISTENTTHREAD_ = 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" { +#else // defined( BOOST_USE_WINDOWS_H ) -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; +const ULONG_ WT_EXECUTEDEFAULT_ = 0x00000000; +const ULONG_ WT_EXECUTEINIOTHREAD_ = 0x00000001; +const ULONG_ WT_EXECUTEINUITHREAD_ = 0x00000002; +const ULONG_ WT_EXECUTEINWAITTHREAD_ = 0x00000004; +const ULONG_ WT_EXECUTEONLYONCE_ = 0x00000008; +const ULONG_ WT_EXECUTEINTIMERTHREAD_ = 0x00000020; +const ULONG_ WT_EXECUTELONGFUNCTION_ = 0x00000010; +const ULONG_ WT_EXECUTEINPERSISTENTIOTHREAD_ = 0x00000040; +const ULONG_ WT_EXECUTEINPERSISTENTTHREAD_ = 0x00000080; +const ULONG_ WT_TRANSFER_IMPERSONATION_ = 0x00000100; inline ULONG_ wt_set_max_threadpool_threads(ULONG_ flags, ULONG_ limit) { return flags | (limit << 16); } -#endif +#endif // defined( BOOST_USE_WINDOWS_H ) + +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_; + } } } diff --git a/boost/detail/winapi/time.hpp b/boost/detail/winapi/time.hpp index 6a6b447117..0f69f47744 100644 --- a/boost/detail/winapi/time.hpp +++ b/boost/detail/winapi/time.hpp @@ -2,6 +2,7 @@ // Copyright 2010 Vicente J. Botet Escriba // Copyright (c) Microsoft Corporation 2014 +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -11,90 +12,123 @@ #define BOOST_DETAIL_WINAPI_TIME_HPP #include -#include +#include #ifdef BOOST_HAS_PRAGMA_ONCE #pragma once #endif +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +struct _FILETIME; +struct _SYSTEMTIME; + +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +GetSystemTime(::_SYSTEMTIME* lpSystemTime); + +#ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime +BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI +GetSystemTimeAsFileTime(::_FILETIME* lpSystemTimeAsFileTime); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SystemTimeToFileTime( + const ::_SYSTEMTIME* lpSystemTime, + ::_FILETIME* lpFileTime); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FileTimeToSystemTime( + const ::_FILETIME* lpFileTime, + ::_SYSTEMTIME* lpSystemTime); + +#if BOOST_PLAT_WINDOWS_DESKTOP +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +FileTimeToLocalFileTime( + const ::_FILETIME* lpFileTime, + ::_FILETIME* lpLocalFileTime); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +LocalFileTimeToFileTime( + const ::_FILETIME* lpLocalFileTime, + ::_FILETIME* lpFileTime); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +GetTickCount(BOOST_DETAIL_WINAPI_VOID); +#endif + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +BOOST_SYMBOL_IMPORT boost::detail::winapi::ULONGLONG_ WINAPI +GetTickCount64(BOOST_DETAIL_WINAPI_VOID); +#endif +} +#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 +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _FILETIME { + DWORD_ dwLowDateTime; + DWORD_ dwHighDateTime; +} FILETIME_, *PFILETIME_, *LPFILETIME_; + +typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SYSTEMTIME { + WORD_ wYear; + WORD_ wMonth; + WORD_ wDayOfWeek; + WORD_ wDay; + WORD_ wHour; + WORD_ wMinute; + WORD_ wSecond; + WORD_ wMilliseconds; +} SYSTEMTIME_, *PSYSTEMTIME_, *LPSYSTEMTIME_; + +#if BOOST_PLAT_WINDOWS_DESKTOP +using ::GetTickCount; +#endif +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 +using ::GetTickCount64; +#endif +BOOST_FORCEINLINE VOID_ GetSystemTime(LPSYSTEMTIME_ lpSystemTime) +{ + ::GetSystemTime(reinterpret_cast< ::_SYSTEMTIME* >(lpSystemTime)); +} + +#if defined( BOOST_HAS_GETSYSTEMTIMEASFILETIME ) +BOOST_FORCEINLINE VOID_ GetSystemTimeAsFileTime(LPFILETIME_ lpSystemTimeAsFileTime) +{ + ::GetSystemTimeAsFileTime(reinterpret_cast< ::_FILETIME* >(lpSystemTimeAsFileTime)); +} #else +// Windows CE does not define GetSystemTimeAsFileTime +BOOST_FORCEINLINE VOID_ GetSystemTimeAsFileTime(FILETIME_* lpFileTime) +{ + boost::detail::winapi::SYSTEMTIME_ st; + boost::detail::winapi::GetSystemTime(&st); + boost::detail::winapi::SystemTimeToFileTime(&st, lpFileTime); +} +#endif -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 +BOOST_FORCEINLINE BOOL_ SystemTimeToFileTime(const SYSTEMTIME_* lpSystemTime, FILETIME_* lpFileTime) +{ + return ::SystemTimeToFileTime(reinterpret_cast< const ::_SYSTEMTIME* >(lpSystemTime), reinterpret_cast< ::_FILETIME* >(lpFileTime)); } -#endif +BOOST_FORCEINLINE BOOL_ FileTimeToSystemTime(const FILETIME_* lpFileTime, SYSTEMTIME_* lpSystemTime) +{ + return ::FileTimeToSystemTime(reinterpret_cast< const ::_FILETIME* >(lpFileTime), reinterpret_cast< ::_SYSTEMTIME* >(lpSystemTime)); +} + +#if BOOST_PLAT_WINDOWS_DESKTOP +BOOST_FORCEINLINE BOOL_ FileTimeToLocalFileTime(const FILETIME_* lpFileTime, FILETIME_* lpLocalFileTime) +{ + return ::FileTimeToLocalFileTime(reinterpret_cast< const ::_FILETIME* >(lpFileTime), reinterpret_cast< ::_FILETIME* >(lpLocalFileTime)); +} -#ifndef BOOST_HAS_GETSYSTEMTIMEASFILETIME -inline void WINAPI GetSystemTimeAsFileTime(FILETIME_* lpFileTime) +BOOST_FORCEINLINE BOOL_ LocalFileTimeToFileTime(const FILETIME_* lpLocalFileTime, FILETIME_* lpFileTime) { - SYSTEMTIME_ st; - GetSystemTime(&st); - SystemTimeToFileTime(&st, lpFileTime); + return ::LocalFileTimeToFileTime(reinterpret_cast< const ::_FILETIME* >(lpLocalFileTime), reinterpret_cast< ::_FILETIME* >(lpFileTime)); } #endif diff --git a/boost/detail/winapi/timers.hpp b/boost/detail/winapi/timers.hpp index 04c6dfbc41..c3bf826100 100644 --- a/boost/detail/winapi/timers.hpp +++ b/boost/detail/winapi/timers.hpp @@ -1,6 +1,7 @@ // timers.hpp --------------------------------------------------------------// // Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt @@ -15,28 +16,31 @@ #pragma once #endif -namespace boost -{ -namespace detail +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +QueryPerformanceCounter(::_LARGE_INTEGER* lpPerformanceCount); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +QueryPerformanceFrequency(::_LARGE_INTEGER* lpFrequency); +} +#endif + + +namespace boost { +namespace detail { +namespace winapi { + +BOOST_FORCEINLINE BOOL_ QueryPerformanceCounter(LARGE_INTEGER_* lpPerformanceCount) { -namespace winapi + return ::QueryPerformanceCounter(reinterpret_cast< ::_LARGE_INTEGER* >(lpPerformanceCount)); +} + +BOOST_FORCEINLINE BOOL_ QueryPerformanceFrequency(LARGE_INTEGER_* lpFrequency) { -#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 - ); + return ::QueryPerformanceFrequency(reinterpret_cast< ::_LARGE_INTEGER* >(lpFrequency)); } -#endif + } } } diff --git a/boost/detail/winapi/tls.hpp b/boost/detail/winapi/tls.hpp index d948693cc9..bcdd7dc977 100644 --- a/boost/detail/winapi/tls.hpp +++ b/boost/detail/winapi/tls.hpp @@ -15,33 +15,44 @@ #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +#if !defined( UNDER_CE ) +// Windows CE define TlsAlloc and TlsFree as inline functions in kfuncs.h +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +TlsAlloc(BOOST_DETAIL_WINAPI_VOID); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +TlsFree(boost::detail::winapi::DWORD_ dwTlsIndex); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::LPVOID_ WINAPI +TlsGetValue(boost::detail::winapi::DWORD_ dwTlsIndex); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +TlsSetValue( + boost::detail::winapi::DWORD_ dwTlsIndex, + boost::detail::winapi::LPVOID_ lpTlsValue); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { using ::TlsAlloc; +using ::TlsFree; using ::TlsGetValue; using ::TlsSetValue; -using ::TlsFree; - -const DWORD_ tls_out_of_indexes = TLS_OUT_OF_INDEXES; +#if defined( BOOST_USE_WINDOWS_H ) +const DWORD_ TLS_OUT_OF_INDEXES_ = TLS_OUT_OF_INDEXES; #else +const DWORD_ TLS_OUT_OF_INDEXES_ = 0xFFFFFFFF; +#endif -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; +const DWORD_ tls_out_of_indexes = TLS_OUT_OF_INDEXES_; -#endif } } } diff --git a/boost/detail/winapi/wait.hpp b/boost/detail/winapi/wait.hpp new file mode 100644 index 0000000000..bd20d46826 --- /dev/null +++ b/boost/detail/winapi/wait.hpp @@ -0,0 +1,84 @@ +// wait.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba +// Copyright 2015 Andrey Semashev + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +#ifndef BOOST_DETAIL_WINAPI_WAIT_HPP +#define BOOST_DETAIL_WINAPI_WAIT_HPP + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +WaitForSingleObject( + boost::detail::winapi::HANDLE_ hHandle, + boost::detail::winapi::DWORD_ dwMilliseconds); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +WaitForMultipleObjects( + boost::detail::winapi::DWORD_ nCount, + boost::detail::winapi::HANDLE_ const* lpHandles, + boost::detail::winapi::BOOL_ bWaitAll, + boost::detail::winapi::DWORD_ dwMilliseconds); + +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 +BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI +SignalObjectAndWait( + boost::detail::winapi::HANDLE_ hObjectToSignal, + boost::detail::winapi::HANDLE_ hObjectToWaitOn, + boost::detail::winapi::DWORD_ dwMilliseconds, + boost::detail::winapi::BOOL_ bAlertable); +#endif +} +#endif + +namespace boost { +namespace detail { +namespace winapi { + +using ::WaitForMultipleObjects; +using ::WaitForSingleObject; +#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_NT4 +using ::SignalObjectAndWait; +#endif + +#if defined( BOOST_USE_WINDOWS_H ) + +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; + +#else // defined( BOOST_USE_WINDOWS_H ) + +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; + +#endif // defined( BOOST_USE_WINDOWS_H ) + +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_; + +const DWORD_ max_non_infinite_wait = (DWORD_)0xFFFFFFFE; + +} +} +} + +#endif // BOOST_DETAIL_WINAPI_WAIT_HPP diff --git a/boost/detail/winapi/waitable_timer.hpp b/boost/detail/winapi/waitable_timer.hpp index 52a7338a20..842cb040d4 100644 --- a/boost/detail/winapi/waitable_timer.hpp +++ b/boost/detail/winapi/waitable_timer.hpp @@ -15,91 +15,107 @@ #pragma once #endif -namespace boost -{ -namespace detail -{ -namespace winapi -{ -#if defined( BOOST_USE_WINDOWS_H ) +#if !defined( BOOST_USE_WINDOWS_H ) +extern "C" { +typedef boost::detail::winapi::VOID_ +(WINAPI *PTIMERAPCROUTINE)( + boost::detail::winapi::LPVOID_ lpArgToCompletionRoutine, + boost::detail::winapi::DWORD_ dwTimerLowValue, + boost::detail::winapi::DWORD_ dwTimerHighValue); + +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateWaitableTimerA( + ::_SECURITY_ATTRIBUTES* lpTimerAttributes, + boost::detail::winapi::BOOL_ bManualReset, + boost::detail::winapi::LPCSTR_ lpTimerName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenWaitableTimerA( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCSTR_ lpTimerName); +#endif + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +CreateWaitableTimerW( + ::_SECURITY_ATTRIBUTES* lpTimerAttributes, + boost::detail::winapi::BOOL_ bManualReset, + boost::detail::winapi::LPCWSTR_ lpTimerName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI +OpenWaitableTimerW( + boost::detail::winapi::DWORD_ dwDesiredAccess, + boost::detail::winapi::BOOL_ bInheritHandle, + boost::detail::winapi::LPCWSTR_ lpTimerName); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +SetWaitableTimer( + boost::detail::winapi::HANDLE_ hTimer, + const ::_LARGE_INTEGER* lpDueTime, + boost::detail::winapi::LONG_ lPeriod, + PTIMERAPCROUTINE pfnCompletionRoutine, + boost::detail::winapi::LPVOID_ lpArgToCompletionRoutine, + boost::detail::winapi::BOOL_ fResume); + +BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI +CancelWaitableTimer(boost::detail::winapi::HANDLE_ hTimer); +} +#endif + +namespace boost { +namespace detail { +namespace winapi { typedef ::PTIMERAPCROUTINE PTIMERAPCROUTINE_; -# ifdef BOOST_NO_ANSI_APIS -using ::CreateWaitableTimerW; -using ::OpenWaitableTimerW; -# else -using ::CreateWaitableTimerA; +#if !defined( BOOST_NO_ANSI_APIS ) using ::OpenWaitableTimerA; -# endif -using ::SetWaitableTimer; +#endif +using ::OpenWaitableTimerW; using ::CancelWaitableTimer; -#else - -extern "C" { +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ CreateWaitableTimerA(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCSTR_ lpTimerName) +{ + return ::CreateWaitableTimerA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName); +} +#endif -struct _SECURITY_ATTRIBUTES; +BOOST_FORCEINLINE HANDLE_ CreateWaitableTimerW(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCWSTR_ lpTimerName) +{ + return ::CreateWaitableTimerW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName); +} -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 -( +BOOST_FORCEINLINE BOOL_ SetWaitableTimer( HANDLE_ hTimer, - const LARGE_INTEGER_ *lpDueTime, + const LARGE_INTEGER_* lpDueTime, LONG_ lPeriod, PTIMERAPCROUTINE_ pfnCompletionRoutine, LPVOID_ lpArgToCompletionRoutine, - BOOL_ fResume -); - -__declspec(dllimport) BOOL_ WINAPI CancelWaitableTimer(HANDLE_ hTimer); - + BOOL_ fResume) +{ + return ::SetWaitableTimer(hTimer, reinterpret_cast< const ::_LARGE_INTEGER* >(lpDueTime), lPeriod, pfnCompletionRoutine, lpArgToCompletionRoutine, fResume); } +#if !defined( BOOST_NO_ANSI_APIS ) +BOOST_FORCEINLINE HANDLE_ create_waitable_timer(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCSTR_ lpTimerName) +{ + return ::CreateWaitableTimerA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName); +} #endif -BOOST_FORCEINLINE HANDLE_ create_anonymous_waitable_timer(_SECURITY_ATTRIBUTES* lpTimerAttributes, BOOL_ bManualReset) +BOOST_FORCEINLINE HANDLE_ create_waitable_timer(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset, LPCWSTR_ lpTimerName) +{ + return ::CreateWaitableTimerW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, lpTimerName); +} + +BOOST_FORCEINLINE HANDLE_ create_anonymous_waitable_timer(PSECURITY_ATTRIBUTES_ lpTimerAttributes, BOOL_ bManualReset) { #ifdef BOOST_NO_ANSI_APIS - return CreateWaitableTimerW(lpTimerAttributes, bManualReset, 0); + return ::CreateWaitableTimerW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, 0); #else - return CreateWaitableTimerA(lpTimerAttributes, bManualReset, 0); + return ::CreateWaitableTimerA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpTimerAttributes), bManualReset, 0); #endif } diff --git a/boost/endian/conversion.hpp b/boost/endian/conversion.hpp index 1d89596ebf..7c145d9506 100644 --- a/boost/endian/conversion.hpp +++ b/boost/endian/conversion.hpp @@ -23,7 +23,6 @@ namespace boost { namespace endian { -#ifndef BOOST_ENDIAN_ORDER_ENUM_DEFINED BOOST_SCOPED_ENUM_START(order) { big, little, @@ -33,8 +32,6 @@ namespace endian native = little # endif }; BOOST_SCOPED_ENUM_END -# define BOOST_ENDIAN_ORDER_ENUM_DEFINED -#endif //--------------------------------------------------------------------------------------// // // @@ -52,7 +49,11 @@ namespace endian // // //--------------------------------------------------------------------------------------// - // customization for exact-length arithmetic types. See doc/conversion.html/#FAQ + // customization for exact-length arithmetic types. See doc/conversion.html/#FAQ. + // Note: The omission of an overloads for the arithmetic type (typically long, or + // long long) not assigned to one of the exact length typedefs is a deliberate + // design decision. Such overloads would be non-portable and thus error prone. + inline int8_t endian_reverse(int8_t x) BOOST_NOEXCEPT; inline int16_t endian_reverse(int16_t x) BOOST_NOEXCEPT; inline int32_t endian_reverse(int32_t x) BOOST_NOEXCEPT; diff --git a/boost/exception/exception.hpp b/boost/exception/exception.hpp index d762cf827e..1f2bd9c200 100644 --- a/boost/exception/exception.hpp +++ b/boost/exception/exception.hpp @@ -432,6 +432,11 @@ boost { } +#if defined(__GNUC__) +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# pragma GCC visibility push (default) +# endif +#endif template class clone_impl: @@ -473,6 +478,11 @@ boost } }; } +#if defined(__GNUC__) +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# pragma GCC visibility pop +# endif +#endif template inline diff --git a/boost/filesystem.hpp b/boost/filesystem.hpp index 1a753026c8..0122634d36 100644 --- a/boost/filesystem.hpp +++ b/boost/filesystem.hpp @@ -16,5 +16,6 @@ # include # include # include +# include #endif // BOOST_FILESYSTEM_FILESYSTEM_HPP diff --git a/boost/filesystem/config.hpp b/boost/filesystem/config.hpp index ca695f4114..815976959a 100644 --- a/boost/filesystem/config.hpp +++ b/boost/filesystem/config.hpp @@ -27,12 +27,13 @@ #include #include // for BOOST_POSIX_API or BOOST_WINDOWS_API -#include +#include // BOOST_FILESYSTEM_DEPRECATED needed for source compiles -----------------------------// # ifdef BOOST_FILESYSTEM_SOURCE # define BOOST_FILESYSTEM_DEPRECATED +# undef BOOST_FILESYSTEM_NO_DEPRECATED // fixes #9454, src bld fails if NO_DEP defined # endif // throw an exception ----------------------------------------------------------------// diff --git a/boost/filesystem/operations.hpp b/boost/filesystem/operations.hpp index f0e09b9db7..47bc07476b 100644 --- a/boost/filesystem/operations.hpp +++ b/boost/filesystem/operations.hpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -256,41 +255,81 @@ namespace boost class BOOST_FILESYSTEM_DECL file_status { public: - file_status() : m_value(status_error), m_perms(perms_not_known) {} - explicit file_status(file_type v, perms prms = perms_not_known) - : m_value(v), m_perms(prms) {} + file_status() BOOST_NOEXCEPT + : m_value(status_error), m_perms(perms_not_known) {} + explicit file_status(file_type v) BOOST_NOEXCEPT + : m_value(v), m_perms(perms_not_known) {} + file_status(file_type v, perms prms) BOOST_NOEXCEPT + : m_value(v), m_perms(prms) {} + + // As of October 2015 the interaction between noexcept and =default is so troublesome + // for VC++, GCC, and probably other compilers, that =default is not used with noexcept + // functions. GCC is not even consistent for the same release on different platforms. + + file_status(const file_status& rhs) BOOST_NOEXCEPT + : m_value(rhs.m_value), m_perms(rhs.m_perms) {} + file_status& operator=(const file_status& rhs) BOOST_NOEXCEPT + { + m_value = rhs.m_value; + m_perms = rhs.m_perms; + return *this; + } + +# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + file_status(file_status&& rhs) BOOST_NOEXCEPT + { + m_value = std::move(rhs.m_value); + m_perms = std::move(rhs.m_perms); + } + file_status& operator=(file_status&& rhs) BOOST_NOEXCEPT + { + m_value = std::move(rhs.m_value); + m_perms = std::move(rhs.m_perms); + return *this; + } +# endif + // observers - file_type type() const { return m_value; } - perms permissions() const { return m_perms; } + file_type type() const BOOST_NOEXCEPT { return m_value; } + perms permissions() const BOOST_NOEXCEPT { return m_perms; } // modifiers - void type(file_type v) { m_value = v; } - void permissions(perms prms) { m_perms = prms; } + void type(file_type v) BOOST_NOEXCEPT { m_value = v; } + void permissions(perms prms) BOOST_NOEXCEPT { m_perms = prms; } - bool operator==(const file_status& rhs) const { return type() == rhs.type() && - permissions() == rhs.permissions(); } - bool operator!=(const file_status& rhs) const { return !(*this == rhs); } + bool operator==(const file_status& rhs) const BOOST_NOEXCEPT + { return type() == rhs.type() && + permissions() == rhs.permissions(); } + bool operator!=(const file_status& rhs) const BOOST_NOEXCEPT + { return !(*this == rhs); } private: file_type m_value; enum perms m_perms; }; - inline bool type_present(file_status f) { return f.type() != status_error; } - inline bool permissions_present(file_status f) + inline bool type_present(file_status f) BOOST_NOEXCEPT + { return f.type() != status_error; } + inline bool permissions_present(file_status f) BOOST_NOEXCEPT {return f.permissions() != perms_not_known;} - inline bool status_known(file_status f) { return type_present(f) && permissions_present(f); } - inline bool exists(file_status f) { return f.type() != status_error + inline bool status_known(file_status f) BOOST_NOEXCEPT + { return type_present(f) && permissions_present(f); } + inline bool exists(file_status f) BOOST_NOEXCEPT + { return f.type() != status_error && f.type() != file_not_found; } - inline bool is_regular_file(file_status f){ return f.type() == regular_file; } - inline bool is_directory(file_status f) { return f.type() == directory_file; } - inline bool is_symlink(file_status f) { return f.type() == symlink_file; } - inline bool is_other(file_status f) { return exists(f) && !is_regular_file(f) + inline bool is_regular_file(file_status f) BOOST_NOEXCEPT + { return f.type() == regular_file; } + inline bool is_directory(file_status f) BOOST_NOEXCEPT + { return f.type() == directory_file; } + inline bool is_symlink(file_status f) BOOST_NOEXCEPT + { return f.type() == symlink_file; } + inline bool is_other(file_status f) BOOST_NOEXCEPT + { return exists(f) && !is_regular_file(f) && !is_directory(f) && !is_symlink(f); } # ifndef BOOST_FILESYSTEM_NO_DEPRECATED - inline bool is_regular(file_status f) { return f.type() == regular_file; } + inline bool is_regular(file_status f) BOOST_NOEXCEPT { return f.type() == regular_file; } # endif struct space_info @@ -332,7 +371,7 @@ namespace boost void copy_directory(const path& from, const path& to, system::error_code* ec=0); BOOST_FILESYSTEM_DECL void copy_file(const path& from, const path& to, // See ticket #2925 - detail::copy_option option, system::error_code* ec=0); + detail::copy_option option, system::error_code* ec=0); BOOST_FILESYSTEM_DECL void copy_symlink(const path& existing_symlink, const path& new_symlink, system::error_code* ec=0); BOOST_FILESYSTEM_DECL @@ -366,7 +405,8 @@ namespace boost BOOST_FILESYSTEM_DECL path read_symlink(const path& p, system::error_code* ec=0); BOOST_FILESYSTEM_DECL - // For standardization, if the committee doesn't like "remove", consider "eliminate" + path relative(const path& p, const path& base, system::error_code* ec = 0); + BOOST_FILESYSTEM_DECL bool remove(const path& p, system::error_code* ec=0); BOOST_FILESYSTEM_DECL boost::uintmax_t remove_all(const path& p, system::error_code* ec=0); @@ -382,7 +422,9 @@ namespace boost path temp_directory_path(system::error_code* ec=0); BOOST_FILESYSTEM_DECL path unique_path(const path& p, system::error_code* ec=0); - } // namespace detail + BOOST_FILESYSTEM_DECL + path weakly_canonical(const path& p, system::error_code* ec = 0); + } // namespace detail //--------------------------------------------------------------------------------------// // // @@ -482,13 +524,13 @@ namespace boost void copy(const path& from, const path& to) {detail::copy(from, to);} inline - void copy(const path& from, const path& to, system::error_code& ec) + void copy(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT {detail::copy(from, to, &ec);} inline void copy_directory(const path& from, const path& to) {detail::copy_directory(from, to);} inline - void copy_directory(const path& from, const path& to, system::error_code& ec) + void copy_directory(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT {detail::copy_directory(from, to, &ec);} inline void copy_file(const path& from, const path& to, // See ticket #2925 @@ -503,12 +545,12 @@ namespace boost } inline void copy_file(const path& from, const path& to, // See ticket #2925 - BOOST_SCOPED_ENUM(copy_option) option, system::error_code& ec) + BOOST_SCOPED_ENUM(copy_option) option, system::error_code& ec) BOOST_NOEXCEPT { detail::copy_file(from, to, static_cast(option), &ec); } inline - void copy_file(const path& from, const path& to, system::error_code& ec) + void copy_file(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT { detail::copy_file(from, to, detail::fail_if_exists, &ec); } @@ -517,67 +559,68 @@ namespace boost const path& new_symlink) {detail::copy_symlink(existing_symlink, new_symlink);} inline - void copy_symlink(const path& existing_symlink, const path& new_symlink, system::error_code& ec) + void copy_symlink(const path& existing_symlink, const path& new_symlink, + system::error_code& ec) BOOST_NOEXCEPT {detail::copy_symlink(existing_symlink, new_symlink, &ec);} inline bool create_directories(const path& p) {return detail::create_directories(p);} inline - bool create_directories(const path& p, system::error_code& ec) + bool create_directories(const path& p, system::error_code& ec) BOOST_NOEXCEPT {return detail::create_directories(p, &ec);} inline bool create_directory(const path& p) {return detail::create_directory(p);} inline - bool create_directory(const path& p, system::error_code& ec) + bool create_directory(const path& p, system::error_code& ec) BOOST_NOEXCEPT {return detail::create_directory(p, &ec);} inline void create_directory_symlink(const path& to, const path& from) {detail::create_directory_symlink(to, from);} inline - void create_directory_symlink(const path& to, const path& from, system::error_code& ec) + void create_directory_symlink(const path& to, const path& from, system::error_code& ec) BOOST_NOEXCEPT {detail::create_directory_symlink(to, from, &ec);} inline void create_hard_link(const path& to, const path& new_hard_link) {detail::create_hard_link(to, new_hard_link);} inline - void create_hard_link(const path& to, const path& new_hard_link, system::error_code& ec) + void create_hard_link(const path& to, const path& new_hard_link, system::error_code& ec) BOOST_NOEXCEPT {detail::create_hard_link(to, new_hard_link, &ec);} inline void create_symlink(const path& to, const path& new_symlink) {detail::create_symlink(to, new_symlink);} inline - void create_symlink(const path& to, const path& new_symlink, system::error_code& ec) + void create_symlink(const path& to, const path& new_symlink, system::error_code& ec) BOOST_NOEXCEPT {detail::create_symlink(to, new_symlink, &ec);} inline path current_path() {return detail::current_path();} inline - path current_path(system::error_code& ec) {return detail::current_path(&ec);} + path current_path(system::error_code& ec) BOOST_NOEXCEPT {return detail::current_path(&ec);} inline void current_path(const path& p) {detail::current_path(p);} inline - void current_path(const path& p, system::error_code& ec) {detail::current_path(p, &ec);} + void current_path(const path& p, system::error_code& ec) BOOST_NOEXCEPT {detail::current_path(p, &ec);} inline bool equivalent(const path& p1, const path& p2) {return detail::equivalent(p1, p2);} inline - bool equivalent(const path& p1, const path& p2, system::error_code& ec) + bool equivalent(const path& p1, const path& p2, system::error_code& ec) BOOST_NOEXCEPT {return detail::equivalent(p1, p2, &ec);} inline boost::uintmax_t file_size(const path& p) {return detail::file_size(p);} inline - boost::uintmax_t file_size(const path& p, system::error_code& ec) + boost::uintmax_t file_size(const path& p, system::error_code& ec) BOOST_NOEXCEPT {return detail::file_size(p, &ec);} inline boost::uintmax_t hard_link_count(const path& p) {return detail::hard_link_count(p);} inline - boost::uintmax_t hard_link_count(const path& p, system::error_code& ec) + boost::uintmax_t hard_link_count(const path& p, system::error_code& ec) BOOST_NOEXCEPT {return detail::hard_link_count(p, &ec);} inline path initial_path() {return detail::initial_path();} @@ -594,19 +637,20 @@ namespace boost std::time_t last_write_time(const path& p) {return detail::last_write_time(p);} inline - std::time_t last_write_time(const path& p, system::error_code& ec) + std::time_t last_write_time(const path& p, system::error_code& ec) BOOST_NOEXCEPT {return detail::last_write_time(p, &ec);} inline void last_write_time(const path& p, const std::time_t new_time) {detail::last_write_time(p, new_time);} inline - void last_write_time(const path& p, const std::time_t new_time, system::error_code& ec) + void last_write_time(const path& p, const std::time_t new_time, + system::error_code& ec) BOOST_NOEXCEPT {detail::last_write_time(p, new_time, &ec);} inline void permissions(const path& p, perms prms) {detail::permissions(p, prms);} inline - void permissions(const path& p, perms prms, system::error_code& ec) + void permissions(const path& p, perms prms, system::error_code& ec) BOOST_NOEXCEPT {detail::permissions(p, prms, &ec);} inline @@ -620,31 +664,42 @@ namespace boost bool remove(const path& p) {return detail::remove(p);} inline - bool remove(const path& p, system::error_code& ec) {return detail::remove(p, &ec);} + bool remove(const path& p, system::error_code& ec) BOOST_NOEXCEPT + {return detail::remove(p, &ec);} inline boost::uintmax_t remove_all(const path& p) {return detail::remove_all(p);} inline - boost::uintmax_t remove_all(const path& p, system::error_code& ec) + boost::uintmax_t remove_all(const path& p, system::error_code& ec) BOOST_NOEXCEPT {return detail::remove_all(p, &ec);} inline void rename(const path& old_p, const path& new_p) {detail::rename(old_p, new_p);} inline - void rename(const path& old_p, const path& new_p, system::error_code& ec) + void rename(const path& old_p, const path& new_p, system::error_code& ec) BOOST_NOEXCEPT {detail::rename(old_p, new_p, &ec);} inline // name suggested by Scott McMurray void resize_file(const path& p, uintmax_t size) {detail::resize_file(p, size);} inline - void resize_file(const path& p, uintmax_t size, system::error_code& ec) + void resize_file(const path& p, uintmax_t size, system::error_code& ec) BOOST_NOEXCEPT {detail::resize_file(p, size, &ec);} inline + path relative(const path& p, const path& base=current_path()) + {return detail::relative(p, base);} + inline + path relative(const path& p, system::error_code& ec) + {return detail::relative(p, current_path(), &ec);} + inline + path relative(const path& p, const path& base, system::error_code& ec) + {return detail::relative(p, base, &ec);} + inline space_info space(const path& p) {return detail::space(p);} inline - space_info space(const path& p, system::error_code& ec) {return detail::space(p, &ec);} + space_info space(const path& p, system::error_code& ec) BOOST_NOEXCEPT + {return detail::space(p, &ec);} # ifndef BOOST_FILESYSTEM_NO_DEPRECATED inline bool symbolic_link_exists(const path& p) @@ -665,10 +720,16 @@ namespace boost {return detail::temp_directory_path(&ec);} inline path unique_path(const path& p="%%%%-%%%%-%%%%-%%%%") - { return detail::unique_path(p); } + {return detail::unique_path(p);} inline path unique_path(const path& p, system::error_code& ec) - { return detail::unique_path(p, &ec); } + {return detail::unique_path(p, &ec);} + inline + path weakly_canonical(const path& p) {return detail::weakly_canonical(p);} + + inline + path weakly_canonical(const path& p, system::error_code& ec) + {return detail::weakly_canonical(p, &ec);} //--------------------------------------------------------------------------------------// // // @@ -683,14 +744,46 @@ namespace boost class BOOST_FILESYSTEM_DECL directory_entry { public: + typedef boost::filesystem::path::value_type value_type; // enables class path ctor taking directory_entry - // compiler generated copy constructor, copy assignment, and destructor apply - - directory_entry() {} - explicit directory_entry(const boost::filesystem::path& p, - file_status st = file_status(), file_status symlink_st=file_status()) - : m_path(p), m_status(st), m_symlink_status(symlink_st) + directory_entry() BOOST_NOEXCEPT {} + explicit directory_entry(const boost::filesystem::path& p) + : m_path(p), m_status(file_status()), m_symlink_status(file_status()) {} + directory_entry(const boost::filesystem::path& p, + file_status st, file_status symlink_st = file_status()) + : m_path(p), m_status(st), m_symlink_status(symlink_st) {} + + directory_entry(const directory_entry& rhs) + : m_path(rhs.m_path), m_status(rhs.m_status), m_symlink_status(rhs.m_symlink_status){} + + directory_entry& operator=(const directory_entry& rhs) + { + m_path = rhs.m_path; + m_status = rhs.m_status; + m_symlink_status = rhs.m_symlink_status; + return *this; + } + + // As of October 2015 the interaction between noexcept and =default is so troublesome + // for VC++, GCC, and probably other compilers, that =default is not used with noexcept + // functions. GCC is not even consistent for the same release on different platforms. + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + directory_entry(directory_entry&& rhs) BOOST_NOEXCEPT + { + m_path = std::move(rhs.m_path); + m_status = std::move(rhs.m_status); + m_symlink_status = std::move(rhs.m_symlink_status); + } + directory_entry& operator=(directory_entry&& rhs) BOOST_NOEXCEPT + { + m_path = std::move(rhs.m_path); + m_status = std::move(rhs.m_status); + m_symlink_status = std::move(rhs.m_symlink_status); + return *this; + } +#endif void assign(const boost::filesystem::path& p, file_status st = file_status(), file_status symlink_st = file_status()) @@ -711,18 +804,22 @@ public: { replace_filename(p, st, symlink_st); } # endif - const boost::filesystem::path& path() const {return m_path;} - file_status status() const {return m_get_status();} - file_status status(system::error_code& ec) const {return m_get_status(&ec);} - file_status symlink_status() const {return m_get_symlink_status();} - file_status symlink_status(system::error_code& ec) const {return m_get_symlink_status(&ec);} - - bool operator==(const directory_entry& rhs) {return m_path == rhs.m_path;} - bool operator!=(const directory_entry& rhs) {return m_path != rhs.m_path;} - bool operator< (const directory_entry& rhs) {return m_path < rhs.m_path;} - bool operator<=(const directory_entry& rhs) {return m_path <= rhs.m_path;} - bool operator> (const directory_entry& rhs) {return m_path > rhs.m_path;} - bool operator>=(const directory_entry& rhs) {return m_path >= rhs.m_path;} + const boost::filesystem::path& path() const BOOST_NOEXCEPT {return m_path;} + operator const boost::filesystem::path&() const BOOST_NOEXCEPT + {return m_path;} + file_status status() const {return m_get_status();} + file_status status(system::error_code& ec) const BOOST_NOEXCEPT + {return m_get_status(&ec); } + file_status symlink_status() const {return m_get_symlink_status();} + file_status symlink_status(system::error_code& ec) const BOOST_NOEXCEPT + {return m_get_symlink_status(&ec); } + + bool operator==(const directory_entry& rhs) const BOOST_NOEXCEPT {return m_path == rhs.m_path; } + bool operator!=(const directory_entry& rhs) const BOOST_NOEXCEPT {return m_path != rhs.m_path;} + bool operator< (const directory_entry& rhs) const BOOST_NOEXCEPT {return m_path < rhs.m_path;} + bool operator<=(const directory_entry& rhs) const BOOST_NOEXCEPT {return m_path <= rhs.m_path;} + bool operator> (const directory_entry& rhs) const BOOST_NOEXCEPT {return m_path > rhs.m_path;} + bool operator>=(const directory_entry& rhs) const BOOST_NOEXCEPT {return m_path >= rhs.m_path;} private: boost::filesystem::path m_path; @@ -797,7 +894,7 @@ namespace detail { public: - directory_iterator(){} // creates the "end" iterator + directory_iterator() BOOST_NOEXCEPT {} // creates the "end" iterator // iterator_facade derived classes don't seem to like implementations in // separate translation unit dll's, so forward to detail functions @@ -805,13 +902,13 @@ namespace detail : m_imp(new detail::dir_itr_imp) { detail::directory_iterator_construct(*this, p, 0); } - directory_iterator(const path& p, system::error_code& ec) + directory_iterator(const path& p, system::error_code& ec) BOOST_NOEXCEPT : m_imp(new detail::dir_itr_imp) { detail::directory_iterator_construct(*this, p, &ec); } - ~directory_iterator() {} // never throws + ~directory_iterator() {} - directory_iterator& increment(system::error_code& ec) + directory_iterator& increment(system::error_code& ec) BOOST_NOEXCEPT { detail::directory_iterator_increment(*this, &ec); return *this; @@ -852,18 +949,23 @@ namespace detail // auto - thus the top-level const is stripped - so returning const is harmless and // emphasizes begin() is just a pass through. inline - const directory_iterator& begin(const directory_iterator& iter) {return iter;} + const directory_iterator& begin(const directory_iterator& iter) BOOST_NOEXCEPT + {return iter;} inline - directory_iterator end(const directory_iterator&) {return directory_iterator();} + directory_iterator end(const directory_iterator&) BOOST_NOEXCEPT + {return directory_iterator();} // enable directory_iterator BOOST_FOREACH -----------------------------------------// inline - directory_iterator& range_begin(directory_iterator& iter) {return iter;} + directory_iterator& range_begin(directory_iterator& iter) BOOST_NOEXCEPT + {return iter;} inline - directory_iterator range_begin(const directory_iterator& iter) {return iter;} + directory_iterator range_begin(const directory_iterator& iter) BOOST_NOEXCEPT + {return iter;} inline - directory_iterator range_end(const directory_iterator&) {return directory_iterator();} + directory_iterator range_end(const directory_iterator&) BOOST_NOEXCEPT + {return directory_iterator();} } // namespace filesystem // namespace boost template specializations @@ -1041,10 +1143,19 @@ namespace filesystem { public: - recursive_directory_iterator(){} // creates the "end" iterator + recursive_directory_iterator() BOOST_NOEXCEPT {} // creates the "end" iterator + + explicit recursive_directory_iterator(const path& dir_path) // throws if !exists() + : m_imp(new detail::recur_dir_itr_imp) + { + m_imp->m_options = symlink_option::none; + m_imp->m_stack.push(directory_iterator(dir_path)); + if (m_imp->m_stack.top() == directory_iterator()) + { m_imp.reset(); } + } - explicit recursive_directory_iterator(const path& dir_path, - BOOST_SCOPED_ENUM(symlink_option) opt = symlink_option::none) + recursive_directory_iterator(const path& dir_path, + BOOST_SCOPED_ENUM(symlink_option) opt) // throws if !exists() : m_imp(new detail::recur_dir_itr_imp) { m_imp->m_options = opt; @@ -1055,7 +1166,7 @@ namespace filesystem recursive_directory_iterator(const path& dir_path, BOOST_SCOPED_ENUM(symlink_option) opt, - system::error_code & ec) + system::error_code & ec) BOOST_NOEXCEPT : m_imp(new detail::recur_dir_itr_imp) { m_imp->m_options = opt; @@ -1065,7 +1176,7 @@ namespace filesystem } recursive_directory_iterator(const path& dir_path, - system::error_code & ec) + system::error_code & ec) BOOST_NOEXCEPT : m_imp(new detail::recur_dir_itr_imp) { m_imp->m_options = symlink_option::none; @@ -1074,7 +1185,7 @@ namespace filesystem { m_imp.reset (); } } - recursive_directory_iterator& increment(system::error_code& ec) + recursive_directory_iterator& increment(system::error_code& ec) BOOST_NOEXCEPT { BOOST_ASSERT_MSG(m_imp.get(), "increment() on end recursive_directory_iterator"); @@ -1084,23 +1195,27 @@ namespace filesystem return *this; } - int level() const + int depth() const BOOST_NOEXCEPT { BOOST_ASSERT_MSG(m_imp.get(), - "level() on end recursive_directory_iterator"); + "depth() on end recursive_directory_iterator"); return m_imp->m_level; } + + int level() const BOOST_NOEXCEPT { return depth(); } - bool no_push_pending() const + bool recursion_pending() const BOOST_NOEXCEPT { BOOST_ASSERT_MSG(m_imp.get(), "is_no_push_requested() on end recursive_directory_iterator"); return (m_imp->m_options & symlink_option::_detail_no_push) == symlink_option::_detail_no_push; } + + bool no_push_pending() const BOOST_NOEXCEPT { return recursion_pending(); } # ifndef BOOST_FILESYSTEM_NO_DEPRECATED - bool no_push_request() const { return no_push_pending(); } + bool no_push_request() const BOOST_NOEXCEPT { return no_push_pending(); } # endif void pop() @@ -1111,7 +1226,7 @@ namespace filesystem if (m_imp->m_stack.empty()) m_imp.reset(); // done, so make end iterator } - void no_push(bool value=true) + void disable_recursion_pending(bool value=true) BOOST_NOEXCEPT { BOOST_ASSERT_MSG(m_imp.get(), "no_push() on end recursive_directory_iterator"); @@ -1120,6 +1235,8 @@ namespace filesystem else m_imp->m_options &= ~symlink_option::_detail_no_push; } + + void no_push(bool value=true) BOOST_NOEXCEPT { disable_recursion_pending(value); } file_status status() const { @@ -1174,22 +1291,25 @@ namespace filesystem // auto - thus the top-level const is stripped - so returning const is harmless and // emphasizes begin() is just a pass through. inline - const recursive_directory_iterator& begin(const recursive_directory_iterator& iter) - {return iter;} + const recursive_directory_iterator& + begin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT + {return iter;} inline - recursive_directory_iterator end(const recursive_directory_iterator&) + recursive_directory_iterator end(const recursive_directory_iterator&) BOOST_NOEXCEPT {return recursive_directory_iterator();} // enable recursive directory iterator BOOST_FOREACH -------------------------------// inline - recursive_directory_iterator& range_begin(recursive_directory_iterator& iter) - {return iter;} + recursive_directory_iterator& + range_begin(recursive_directory_iterator& iter) BOOST_NOEXCEPT + {return iter;} inline - recursive_directory_iterator range_begin(const recursive_directory_iterator& iter) - {return iter;} + recursive_directory_iterator + range_begin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT + {return iter;} inline - recursive_directory_iterator range_end(const recursive_directory_iterator&) + recursive_directory_iterator range_end(const recursive_directory_iterator&) BOOST_NOEXCEPT {return recursive_directory_iterator();} } // namespace filesystem diff --git a/boost/filesystem/path.hpp b/boost/filesystem/path.hpp index 7ae4d2fd0d..af5bfcc8c2 100644 --- a/boost/filesystem/path.hpp +++ b/boost/filesystem/path.hpp @@ -46,6 +46,7 @@ namespace boost { namespace filesystem { + //------------------------------------------------------------------------------------// // // // class path // @@ -128,8 +129,7 @@ namespace filesystem // ----- constructors ----- - path(){} - + path() BOOST_NOEXCEPT {} path(const path& p) : m_pathname(p.m_pathname) {} template @@ -145,6 +145,16 @@ namespace filesystem path(const string_type& s) : m_pathname(s) {} path(string_type& s) : m_pathname(s) {} + // As of October 2015 the interaction between noexcept and =default is so troublesome + // for VC++, GCC, and probably other compilers, that =default is not used with noexcept + // functions. GCC is not even consistent for the same release on different platforms. + +# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + path(path&& p) BOOST_NOEXCEPT { m_pathname = std::move(p.m_pathname); } + path& operator=(path&& p) BOOST_NOEXCEPT + { m_pathname = std::move(p.m_pathname); return *this; } +# endif + template path(Source const& source, const codecvt_type& cvt) { @@ -351,7 +361,7 @@ namespace filesystem // ----- modifiers ----- - void clear() { m_pathname.clear(); } + void clear() BOOST_NOEXCEPT { m_pathname.clear(); } path& make_preferred() # ifdef BOOST_POSIX_API { return *this; } // POSIX no effect @@ -361,7 +371,7 @@ namespace filesystem path& remove_filename(); path& remove_trailing_separator(); path& replace_extension(const path& new_extension = path()); - void swap(path& rhs) { m_pathname.swap(rhs.m_pathname); } + void swap(path& rhs) BOOST_NOEXCEPT { m_pathname.swap(rhs.m_pathname); } // ----- observers ----- @@ -384,8 +394,9 @@ namespace filesystem // ----- native format observers ----- - const string_type& native() const { return m_pathname; } // Throws: nothing - const value_type* c_str() const { return m_pathname.c_str(); } // Throws: nothing + const string_type& native() const BOOST_NOEXCEPT { return m_pathname; } + const value_type* c_str() const BOOST_NOEXCEPT { return m_pathname.c_str(); } + string_type::size_type size() const BOOST_NOEXCEPT { return m_pathname.size(); } template String string() const; @@ -441,6 +452,21 @@ namespace filesystem // ----- generic format observers ----- + // Experimental generic function returning generic formatted path (i.e. separators + // are forward slashes). Motivation: simpler than a family of generic_*string + // functions. + path generic() const + { +# ifdef BOOST_WINDOWS_API + path tmp; + std::replace_copy(m_pathname.begin(), m_pathname.end(), + std::back_inserter(tmp.m_pathname), L'\\', L'/'); + return tmp; +# else + return path(*this); +# endif + } + template String generic_string() const; @@ -482,7 +508,7 @@ namespace filesystem // ----- query ----- - bool empty() const { return m_pathname.empty(); } // name consistent with std containers + bool empty() const BOOST_NOEXCEPT{ return m_pathname.empty(); } bool has_root_path() const { return has_root_directory() || has_root_name(); } bool has_root_name() const { return !root_name().empty(); } bool has_root_directory() const { return !root_directory().empty(); } @@ -491,6 +517,7 @@ namespace filesystem bool has_filename() const { return !m_pathname.empty(); } bool has_stem() const { return !stem().empty(); } bool has_extension() const { return !extension().empty(); } + bool is_relative() const { return !is_absolute(); } bool is_absolute() const { # ifdef BOOST_WINDOWS_API @@ -499,20 +526,33 @@ namespace filesystem return has_root_directory(); # endif } - bool is_relative() const { return !is_absolute(); } + + // ----- lexical operations ----- + + path lexically_normal() const; + path lexically_relative(const path& base) const; + path lexically_proximate(const path& base) const + { + path tmp(lexically_relative(base)); + return tmp.empty() ? *this : tmp; + } // ----- iterators ----- class iterator; typedef iterator const_iterator; + class reverse_iterator; + typedef reverse_iterator const_reverse_iterator; iterator begin() const; iterator end() const; + reverse_iterator rbegin() const; + reverse_iterator rend() const; // ----- static member functions ----- - static std::locale imbue(const std::locale& loc); - static const codecvt_type& codecvt(); + static std::locale imbue(const std::locale& loc); + static const codecvt_type& codecvt(); // ----- deprecated functions ----- @@ -522,7 +562,11 @@ namespace filesystem # if !defined(BOOST_FILESYSTEM_NO_DEPRECATED) // recently deprecated functions supplied by default - path& normalize() { return m_normalize(); } + path& normalize() { + path tmp(lexically_normal()); + m_pathname.swap(tmp.m_pathname); + return *this; + } path& remove_leaf() { return remove_filename(); } path leaf() const { return filename(); } path branch_path() const { return parent_path(); } @@ -557,6 +601,7 @@ namespace filesystem //--------------------------------------------------------------------------------------// private: + # if defined(_MSC_VER) # pragma warning(push) // Save warning settings # pragma warning(disable : 4251) // disable warning: class 'std::basic_string<_Elem,_Traits,_Ax>' @@ -623,6 +668,7 @@ namespace filesystem private: friend class boost::iterator_core_access; friend class boost::filesystem::path; + friend class boost::filesystem::path::reverse_iterator; friend void m_path_iterator_increment(path::iterator & it); friend void m_path_iterator_decrement(path::iterator & it); @@ -648,6 +694,53 @@ namespace filesystem // m_pos == m_path_ptr->m_pathname.size() }; // path::iterator + //------------------------------------------------------------------------------------// + // class path::reverse_iterator // + //------------------------------------------------------------------------------------// + + class path::reverse_iterator + : public boost::iterator_facade< + path::reverse_iterator, + path const, + boost::bidirectional_traversal_tag > + { + public: + + explicit reverse_iterator(iterator itr) : m_itr(itr) + { + if (itr != itr.m_path_ptr->begin()) + m_element = *--itr; + } + private: + friend class boost::iterator_core_access; + friend class boost::filesystem::path; + + const path& dereference() const { return m_element; } + bool equal(const reverse_iterator& rhs) const { return m_itr == rhs.m_itr; } + void increment() + { + --m_itr; + if (m_itr != m_itr.m_path_ptr->begin()) + { + iterator tmp = m_itr; + m_element = *--tmp; + } + } + void decrement() + { + m_element = *m_itr; + ++m_itr; + } + + iterator m_itr; + path m_element; + + }; // path::reverse_iterator + + inline path::reverse_iterator path::rbegin() const { return reverse_iterator(end()); } + inline path::reverse_iterator path::rend() const { return reverse_iterator(begin()); } + + //------------------------------------------------------------------------------------// // // // non-member functions // diff --git a/boost/filesystem/string_file.hpp b/boost/filesystem/string_file.hpp new file mode 100644 index 0000000000..015f659080 --- /dev/null +++ b/boost/filesystem/string_file.hpp @@ -0,0 +1,43 @@ +// filesystem/string_file.hpp --------------------------------------------------------// + +// Copyright Beman Dawes 2015 + +// 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_STRING_FILE_HPP +#define BOOST_FILESYSTEM_STRING_FILE_HPP + +#include +#include +#include + +namespace boost +{ +namespace filesystem +{ +inline +void save_string_file(const path& p, const std::string& str) +{ + ofstream file; + file.exceptions(std::ofstream::failbit | std::ofstream::badbit); + file.open(p, std::ios_base::binary); + file.write(str.c_str(), str.size()); +} + +inline +void load_string_file(const path& p, std::string& str) +{ + ifstream file; + file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + file.open(p, std::ios_base::binary); + std::size_t sz = static_cast(file_size(p)); + str.resize(sz, '\0'); + file.read(&str[0], sz); +} +} // namespace filesystem +} // namespace boost + +#endif // include guard diff --git a/boost/flyweight/assoc_container_factory.hpp b/boost/flyweight/assoc_container_factory.hpp index 96deee3ee9..9b35b16ab6 100644 --- a/boost/flyweight/assoc_container_factory.hpp +++ b/boost/flyweight/assoc_container_factory.hpp @@ -1,4 +1,4 @@ -/* Copyright 2006-2014 Joaquin M Lopez Munoz. +/* Copyright 2006-2015 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) @@ -27,8 +27,8 @@ #endif namespace boost{namespace flyweights{namespace detail{ -BOOST_FLYWEIGHT_NESTED_XXX_IF_NOT_PLACEHOLDER_EXPRESSION_DEF(iterator); -BOOST_FLYWEIGHT_NESTED_XXX_IF_NOT_PLACEHOLDER_EXPRESSION_DEF(value_type); +BOOST_FLYWEIGHT_NESTED_XXX_IF_NOT_PLACEHOLDER_EXPRESSION_DEF(iterator) +BOOST_FLYWEIGHT_NESTED_XXX_IF_NOT_PLACEHOLDER_EXPRESSION_DEF(value_type) }}} /* namespace boost::flyweights::detail */ /* Factory class using a given associative container. diff --git a/boost/flyweight/flyweight.hpp b/boost/flyweight/flyweight.hpp index 1fb2009fcf..0895850182 100644 --- a/boost/flyweight/flyweight.hpp +++ b/boost/flyweight/flyweight.hpp @@ -1,6 +1,6 @@ /* Flyweight class. * - * Copyright 2006-2014 Joaquin M Lopez Munoz. + * Copyright 2006-2015 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) @@ -445,8 +445,10 @@ BOOST_TEMPLATED_STREAM(istream,ElemType,Traits)& operator>>( namespace std{ template -struct hash > +BOOST_FLYWEIGHT_STD_HASH_STRUCT_KEYWORD +hash > { +public: typedef std::size_t result_type; typedef boost::flyweight< T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)> argument_type; diff --git a/boost/flyweight/flyweight_fwd.hpp b/boost/flyweight/flyweight_fwd.hpp index 81e2aef97d..73fbf678cc 100644 --- a/boost/flyweight/flyweight_fwd.hpp +++ b/boost/flyweight/flyweight_fwd.hpp @@ -1,4 +1,4 @@ -/* Copyright 2006-2014 Joaquin M Lopez Munoz. +/* Copyright 2006-2015 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) @@ -15,6 +15,7 @@ #include /* keep it first to prevent nasty warns in MSVC */ #include +#include #include #include #include @@ -167,9 +168,16 @@ using flyweights::flyweight; #if !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT) #if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) +#if BOOST_WORKAROUND(_CPPLIB_VER,==520) +/* Dinkumware 5.20 defines std::hash as class rather than struct */ +#define BOOST_FLYWEIGHT_STD_HASH_STRUCT_KEYWORD class +#else +#define BOOST_FLYWEIGHT_STD_HASH_STRUCT_KEYWORD struct +#endif + #if !defined(_LIBCPP_VERSION) namespace std{ -template struct hash; +template BOOST_FLYWEIGHT_STD_HASH_STRUCT_KEYWORD hash; } #else /* As discussed in http://lists.boost.org/Archives/boost/2011/02/177218.php */ @@ -179,7 +187,8 @@ template struct hash; namespace std{ template -struct hash >; +BOOST_FLYWEIGHT_STD_HASH_STRUCT_KEYWORD +hash >; } /* namespace std */ #endif /* !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) */ diff --git a/boost/flyweight/serialize.hpp b/boost/flyweight/serialize.hpp index c222670415..73a1f4e45c 100644 --- a/boost/flyweight/serialize.hpp +++ b/boost/flyweight/serialize.hpp @@ -1,4 +1,4 @@ -/* Copyright 2006-2014 Joaquin M Lopez Munoz. +/* Copyright 2006-2015 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) @@ -46,7 +46,7 @@ template< > void save( Archive& ar,const ::boost::flyweights::flyweight& f, - const unsigned int version) + const unsigned int /*version*/) { typedef ::boost::flyweights::flyweight flyweight; typedef ::boost::flyweights::detail::save_helper helper; diff --git a/boost/format/feed_args.hpp b/boost/format/feed_args.hpp index 95bbe5e252..fa45d215d8 100644 --- a/boost/format/feed_args.hpp +++ b/boost/format/feed_args.hpp @@ -172,6 +172,10 @@ namespace detail { typedef typename string_type::size_type size_type; basic_oaltstringstream oss( &buf); + + if(loc_p != NULL) + oss.imbue(*loc_p); + specs.fmtstate_.apply_on(oss, loc_p); // the stream format state can be modified by manipulators in the argument : diff --git a/boost/functional/hash/hash.hpp b/boost/functional/hash/hash.hpp index 3e5ab5bcf9..2fb9f21116 100644 --- a/boost/functional/hash/hash.hpp +++ b/boost/functional/hash/hash.hpp @@ -411,7 +411,7 @@ namespace boost // passed by copy. // // BOOST_HASH_SPECIALIZE_REF - define a specialization for a type which is - // passed by copy. + // passed by const reference. // // These are undefined later. diff --git a/boost/fusion/algorithm/iteration/accumulate.hpp b/boost/fusion/algorithm/iteration/accumulate.hpp index fe7112e323..7d524a15c2 100644 --- a/boost/fusion/algorithm/iteration/accumulate.hpp +++ b/boost/fusion/algorithm/iteration/accumulate.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,8 +11,6 @@ #include #include #include -#include -#include namespace boost { namespace fusion { @@ -27,11 +26,7 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence& seq, State const& state, F f) { return fusion::fold(seq, state, f); @@ -39,11 +34,7 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence const& seq, State const& state, F f) { return fusion::fold(seq, state, f); diff --git a/boost/fusion/algorithm/iteration/accumulate_fwd.hpp b/boost/fusion/algorithm/iteration/accumulate_fwd.hpp index 50c4d39d4e..f00e67f966 100644 --- a/boost/fusion/algorithm/iteration/accumulate_fwd.hpp +++ b/boost/fusion/algorithm/iteration/accumulate_fwd.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2011 Eric Niebler + Copyright (c) 2015 Kohei Takahashi Distributed under the 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,8 +9,6 @@ #define BOOST_FUSION_ACCUMULATE_FWD_HPP_INCLUDED #include -#include -#include namespace boost { namespace fusion { @@ -21,20 +20,12 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence& seq, State const& state, F f); template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence const& seq, State const& state, F f); }} diff --git a/boost/fusion/algorithm/iteration/detail/fold.hpp b/boost/fusion/algorithm/iteration/detail/fold.hpp index 1813bd247a..4c82b80029 100644 --- a/boost/fusion/algorithm/iteration/detail/fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/fold.hpp @@ -2,12 +2,15 @@ Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2006 Dan Marsden Copyright (c) 2009-2010 Christopher Schmidt + Copyright (c) 2015 Kohei Takahashi Distributed under the 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 +#define FUSION_HASH # + #ifdef BOOST_FUSION_REVERSE_FOLD # ifdef BOOST_FUSION_ITER_FOLD # define BOOST_FUSION_FOLD_NAME reverse_iter_fold @@ -41,378 +44,193 @@ # define BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(IT) fusion::deref(IT) #endif +#if (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) +FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, < 1500) +FUSION_HASH define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +FUSION_HASH else +FUSION_HASH define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +FUSION_HASH endif +#else +# if BOOST_WORKAROUND(BOOST_MSVC, < 1500) +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +# else +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +# endif +#endif + namespace boost { namespace fusion { namespace detail { - template - struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state) - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It)) - > + template + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME) {}; - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)< - Result - , N-4 - >::call( - f(state3,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it3)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it3), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it2), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), - f); - } - }; - - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2)); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), - f); - } - }; - - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), - f); - } - }; - - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)); - } - }; - - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME) - { - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type - it1; - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type - it2; - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type - it3; - - typedef typename - BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - typename BOOST_PP_CAT( - BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest3 - , it3 - , F - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - it3 - >::type - , F - , N-4 - >::type - type; - }; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 3 - > + template + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<0,It,State,F + , typename boost::enable_if_has_type::type +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, < 1500) +#endif +#if BOOST_WORKAROUND(BOOST_MSVC, < 1500) || \ + (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) + , true +#endif +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH endif +#endif + > { - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type - it1; - - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - typename BOOST_PP_CAT( - BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest1 - , it1 - , F - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - it1 const - >::type const - , F - >::type - type; + typedef typename State::type type; }; - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 2 - > - : BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const - , F - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type const + template + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)= 1500) +#endif +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1500) || \ + (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) + // Following SFINAE enables to avoid MSVC 9's partial specialization + // ambiguous bug but MSVC 8 don't compile, and moreover MSVC 8 style + // workaround won't work with MSVC 9. + typename boost::disable_if_c::type::type +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +#endif +#else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +#endif +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH endif +#endif + >::type +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, < 1500) +#endif +#if BOOST_WORKAROUND(BOOST_MSVC, < 1500) || \ + (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) + , false +#endif +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH endif +#endif + > + : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + SeqSize-1 + , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type + , boost::result_of< + F( + typename add_reference::type, + BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) + ) + > , F > {}; - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + 0 + , It + , State , F - , 1 - > - : BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const + >::type + BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + SeqSize + , It + , State , F > - {}; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 0 - > - { - typedef StateRef type; - }; - - template - struct BOOST_PP_CAT(result_of_first_unrolled,BOOST_FUSION_FOLD_NAME) - { - typedef typename - BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM( - It0 const) - ) - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - - template - struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME,_impl) + >::type + BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_, It const& it, typename State::type state, F& f) { - typedef typename - BOOST_PP_CAT( - result_of_first_unrolled,BOOST_FUSION_FOLD_NAME)< - StateRef - , BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( - typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type + return BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)< + typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type + , boost::result_of< + F( + typename add_reference::type, + BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) ) - , F - , SeqSize - >::type - type; - - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)< - type - , SeqSize - > - unrolled_impl; - - return unrolled_impl::call( - state, - BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM( - fusion::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION(seq)), - f); - } - }; - - template - struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME,_impl)<0,StateRef,Seq,F> - { - typedef StateRef type; - - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; + > + , F + >( + mpl::int_() + , fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it) + , f(state, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it)) + , f + ); + } + + template::value + , bool = traits::is_segmented::value> + struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) + {}; - template - struct BOOST_PP_CAT(result_of_, BOOST_FUSION_FOLD_NAME) - : BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME,_impl)< + template + struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) + : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( + typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type + ) + , add_reference , F > {}; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME)::type + BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F& f) + { + return BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)< + BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( + typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type + ) + , add_reference + , F + >( + typename result_of::size::type() + , BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM( + fusion::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION(seq) + ) + , state + , f + ); + } } namespace result_of { template struct BOOST_FUSION_FOLD_NAME - : detail::BOOST_PP_CAT(result_of_, BOOST_FUSION_FOLD_NAME)< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) {}; } @@ -425,10 +243,7 @@ namespace boost { namespace fusion >::type BOOST_FUSION_FOLD_NAME(Seq& seq, State const& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template @@ -440,47 +255,40 @@ namespace boost { namespace fusion >::type BOOST_FUSION_FOLD_NAME(Seq const& seq, State const& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::BOOST_FUSION_FOLD_NAME< Seq - , State const + , State , F >::type BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::BOOST_FUSION_FOLD_NAME< Seq const - , State const + , State , F >::type BOOST_FUSION_FOLD_NAME(Seq const& seq, State& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } }} #undef BOOST_FUSION_FOLD_NAME +#undef BOOST_FUSION_FOLD_IMPL_ENABLER #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION #undef BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM #undef BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM #undef BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM +#undef FUSION_HASH diff --git a/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp b/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp index bd3b1dbdac..c23ba16c28 100644 --- a/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp @@ -8,345 +8,138 @@ This is an auto-generated file. Do not edit! ==============================================================================*/ +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +# else +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +# endif namespace boost { namespace fusion { namespace detail { - template - struct fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - typename fusion::result_of::deref::type) - > - {}; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_fold< - Result - , N-4 - >::call( - f(state3,fusion::deref(it3)), - fusion::next(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,fusion::deref(it2)), - fusion::next(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::next(it0), - f); - } - }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,fusion::deref(it2)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::next(it0), - f); - } - }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,fusion::deref(it1)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::next(it0), - f); - } - }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - fusion::deref(it0)); - } - }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_fold - { - typedef typename - fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::next::type - it2; - typedef typename - fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::next::type - it3; - typedef typename - result_of_unrolled_fold< - typename fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::next< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_fold< - StateRef - , It0 - , F - , 3 + template + struct result_of_it_fold + {}; + template + struct result_of_it_fold<0,It,State,F + , typename boost::enable_if_has_type::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , true +# endif + > { - typedef typename - fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - fold_lvalue_state< - typename fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::next< - it1 const - >::type const - , F - >::type - type; + typedef typename State::type type; }; - template - struct result_of_unrolled_fold< - StateRef - , It0 - , F - , 2 - > - : fold_lvalue_state< - typename fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::next< - It0 const - >::type const + template + struct result_of_it_fold= 1500) + + + + typename boost::disable_if_c::type::type +# else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +# endif + >::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , false +# endif + > + : result_of_it_fold< + SeqSize-1 + , typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > , F > {}; - template - struct result_of_unrolled_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_fold< + 0 + , It + , State , F - , 1 - > - : fold_lvalue_state< - StateRef - , It0 const + >::type + it_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrolledfold - { - typedef typename - result_of_unrolled_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - typename fusion::result_of::deref< It0 const>::type - ) - >::type - , typename result_of::next< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct fold_impl - { - typedef typename - result_of_first_unrolledfold< - StateRef - , typename result_of::begin::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::begin(seq), - f); - } - }; - template - struct fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_fold< + typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > + , F + >( + mpl::int_() + , fusion::next(it) + , f(state, fusion::deref(it)) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_fold - : fold_impl< + {}; + template + struct result_of_fold + : result_of_it_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename result_of::begin::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_fold::type + fold(Seq& seq, State& state, F& f) + { + return it_fold< + typename result_of::begin::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::begin(seq) + , state + , f + ); + } } namespace result_of { template struct fold - : detail::result_of_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_fold {}; } template @@ -358,10 +151,7 @@ namespace boost { namespace fusion >::type fold(Seq& seq, State const& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -372,37 +162,28 @@ namespace boost { namespace fusion >::type fold(Seq const& seq, State const& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq - , State const + , State , F >::type fold(Seq& seq, State& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq const - , State const + , State , F >::type fold(Seq const& seq, State& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } }} diff --git a/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp b/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp index 1d294a8722..d49a868568 100644 --- a/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp @@ -7,345 +7,138 @@ This is an auto-generated file. Do not edit! ==============================================================================*/ +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +# else +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +# endif namespace boost { namespace fusion { namespace detail { - template - struct iter_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - It&) - > - {}; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_iter_fold< - Result - , N-4 - >::call( - f(state3,it3), - fusion::next(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,it2), - fusion::next(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::next(it0), - f); - } - }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,it2); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::next(it0), - f); - } - }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,it1); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::next(it0), - f); - } - }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - it0); - } - }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_iter_fold - { - typedef typename - iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::next::type - it2; - typedef typename - iter_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::next::type - it3; - typedef typename - result_of_unrolled_iter_fold< - typename iter_fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::next< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 - , F - , 3 + template + struct result_of_it_iter_fold + {}; + template + struct result_of_it_iter_fold<0,It,State,F + , typename boost::enable_if_has_type::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , true +# endif + > { - typedef typename - iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - iter_fold_lvalue_state< - typename iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::next< - it1 const - >::type const - , F - >::type - type; + typedef typename State::type type; }; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 - , F - , 2 - > - : iter_fold_lvalue_state< - typename iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::next< - It0 const - >::type const + template + struct result_of_it_iter_fold= 1500) + + + + typename boost::disable_if_c::type::type +# else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +# endif + >::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , false +# endif + > + : result_of_it_iter_fold< + SeqSize-1 + , typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > , F > {}; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_iter_fold< + 0 + , It + , State , F - , 1 - > - : iter_fold_lvalue_state< - StateRef - , It0 const + >::type + it_iter_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_iter_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_iter_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrollediter_fold - { - typedef typename - result_of_unrolled_iter_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - It0 const& - ) - >::type - , typename result_of::next< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct iter_fold_impl - { - typedef typename - result_of_first_unrollediter_fold< - StateRef - , typename result_of::begin::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_iter_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::begin(seq), - f); - } - }; - template - struct iter_fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_iter_fold< + typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > + , F + >( + mpl::int_() + , fusion::next(it) + , f(state, it) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_iter_fold - : iter_fold_impl< + {}; + template + struct result_of_iter_fold + : result_of_it_iter_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename result_of::begin::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_iter_fold::type + iter_fold(Seq& seq, State& state, F& f) + { + return it_iter_fold< + typename result_of::begin::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::begin(seq) + , state + , f + ); + } } namespace result_of { template struct iter_fold - : detail::result_of_iter_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_iter_fold {}; } template @@ -357,10 +150,7 @@ namespace boost { namespace fusion >::type iter_fold(Seq& seq, State const& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +161,28 @@ namespace boost { namespace fusion >::type iter_fold(Seq const& seq, State const& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq - , State const + , State , F >::type iter_fold(Seq& seq, State& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq const - , State const + , State , F >::type iter_fold(Seq const& seq, State& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } }} diff --git a/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp b/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp index 947897821a..4b3b3b1e09 100644 --- a/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp @@ -7,345 +7,138 @@ This is an auto-generated file. Do not edit! ==============================================================================*/ +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +# else +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +# endif namespace boost { namespace fusion { namespace detail { - template - struct reverse_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - typename fusion::result_of::deref::type) - > - {}; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_reverse_fold< - Result - , N-4 - >::call( - f(state3,fusion::deref(it3)), - fusion::prior(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,fusion::deref(it2)), - fusion::prior(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,fusion::deref(it2)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,fusion::deref(it1)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - fusion::deref(it0)); - } - }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_reverse_fold - { - typedef typename - reverse_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::prior::type - it2; - typedef typename - reverse_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::prior::type - it3; - typedef typename - result_of_unrolled_reverse_fold< - typename reverse_fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::prior< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 - , F - , 3 + template + struct result_of_it_reverse_fold + {}; + template + struct result_of_it_reverse_fold<0,It,State,F + , typename boost::enable_if_has_type::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , true +# endif + > { - typedef typename - reverse_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_fold_lvalue_state< - typename reverse_fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::prior< - it1 const - >::type const - , F - >::type - type; + typedef typename State::type type; }; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 - , F - , 2 - > - : reverse_fold_lvalue_state< - typename reverse_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::prior< - It0 const - >::type const + template + struct result_of_it_reverse_fold= 1500) + + + + typename boost::disable_if_c::type::type +# else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +# endif + >::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , false +# endif + > + : result_of_it_reverse_fold< + SeqSize-1 + , typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > , F > {}; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_reverse_fold< + 0 + , It + , State , F - , 1 - > - : reverse_fold_lvalue_state< - StateRef - , It0 const + >::type + it_reverse_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_reverse_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_reverse_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrolledreverse_fold - { - typedef typename - result_of_unrolled_reverse_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - typename fusion::result_of::deref< It0 const>::type - ) - >::type - , typename result_of::prior< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct reverse_fold_impl - { - typedef typename - result_of_first_unrolledreverse_fold< - StateRef - , typename fusion::result_of::prior< typename result_of::end::type >::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_reverse_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::prior( fusion::end(seq)), - f); - } - }; - template - struct reverse_fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_reverse_fold< + typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > + , F + >( + mpl::int_() + , fusion::prior(it) + , f(state, fusion::deref(it)) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_reverse_fold - : reverse_fold_impl< + {}; + template + struct result_of_reverse_fold + : result_of_it_reverse_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_reverse_fold::type + reverse_fold(Seq& seq, State& state, F& f) + { + return it_reverse_fold< + typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::prior( fusion::end(seq) ) + , state + , f + ); + } } namespace result_of { template struct reverse_fold - : detail::result_of_reverse_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_reverse_fold {}; } template @@ -357,10 +150,7 @@ namespace boost { namespace fusion >::type reverse_fold(Seq& seq, State const& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +161,28 @@ namespace boost { namespace fusion >::type reverse_fold(Seq const& seq, State const& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq - , State const + , State , F >::type reverse_fold(Seq& seq, State& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq const - , State const + , State , F >::type reverse_fold(Seq const& seq, State& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } }} diff --git a/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp b/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp index bf1edca53d..10bd9c7d3b 100644 --- a/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp @@ -7,345 +7,138 @@ This is an auto-generated file. Do not edit! ==============================================================================*/ +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +# else +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +# endif namespace boost { namespace fusion { namespace detail { - template - struct reverse_iter_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - It&) - > - {}; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_reverse_iter_fold< - Result - , N-4 - >::call( - f(state3,it3), - fusion::prior(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,it2), - fusion::prior(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,it2); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,it1); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - it0); - } - }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_reverse_iter_fold - { - typedef typename - reverse_iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::prior::type - it2; - typedef typename - reverse_iter_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::prior::type - it3; - typedef typename - result_of_unrolled_reverse_iter_fold< - typename reverse_iter_fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::prior< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 - , F - , 3 + template + struct result_of_it_reverse_iter_fold + {}; + template + struct result_of_it_reverse_iter_fold<0,It,State,F + , typename boost::enable_if_has_type::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , true +# endif + > { - typedef typename - reverse_iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_iter_fold_lvalue_state< - typename reverse_iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::prior< - it1 const - >::type const - , F - >::type - type; + typedef typename State::type type; }; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 - , F - , 2 - > - : reverse_iter_fold_lvalue_state< - typename reverse_iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::prior< - It0 const - >::type const + template + struct result_of_it_reverse_iter_fold= 1500) + + + + typename boost::disable_if_c::type::type +# else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +# endif + >::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , false +# endif + > + : result_of_it_reverse_iter_fold< + SeqSize-1 + , typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > , F > {}; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_reverse_iter_fold< + 0 + , It + , State , F - , 1 - > - : reverse_iter_fold_lvalue_state< - StateRef - , It0 const + >::type + it_reverse_iter_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_reverse_iter_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_reverse_iter_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrolledreverse_iter_fold - { - typedef typename - result_of_unrolled_reverse_iter_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - It0 const& - ) - >::type - , typename result_of::prior< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct reverse_iter_fold_impl - { - typedef typename - result_of_first_unrolledreverse_iter_fold< - StateRef - , typename fusion::result_of::prior< typename result_of::end::type >::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_reverse_iter_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::prior( fusion::end(seq)), - f); - } - }; - template - struct reverse_iter_fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_reverse_iter_fold< + typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > + , F + >( + mpl::int_() + , fusion::prior(it) + , f(state, it) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_reverse_iter_fold - : reverse_iter_fold_impl< + {}; + template + struct result_of_reverse_iter_fold + : result_of_it_reverse_iter_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_reverse_iter_fold::type + reverse_iter_fold(Seq& seq, State& state, F& f) + { + return it_reverse_iter_fold< + typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::prior( fusion::end(seq) ) + , state + , f + ); + } } namespace result_of { template struct reverse_iter_fold - : detail::result_of_reverse_iter_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_reverse_iter_fold {}; } template @@ -357,10 +150,7 @@ namespace boost { namespace fusion >::type reverse_iter_fold(Seq& seq, State const& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +161,28 @@ namespace boost { namespace fusion >::type reverse_iter_fold(Seq const& seq, State const& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq - , State const + , State , F >::type reverse_iter_fold(Seq& seq, State& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq const - , State const + , State , F >::type reverse_iter_fold(Seq const& seq, State& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } }} diff --git a/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp b/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp index 4ff679af2e..350bff75b3 100644 --- a/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace boost { namespace fusion { namespace detail { @@ -38,11 +39,11 @@ namespace boost { namespace fusion { namespace detail }; // The default implementation of this lives in detail/fold.hpp - template + template struct result_of_fold; template - struct result_of_fold + struct result_of_fold { typedef typename result_of::segmented_fold_until< @@ -53,7 +54,7 @@ namespace boost { namespace fusion { namespace detail type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type call(State& state, Sequence& seq, Fun fun) + static type call(Sequence& seq, State& state, Fun& fun) { return fusion::segmented_fold_until(seq, state, segmented_fold_fun(fun)); } diff --git a/boost/fusion/algorithm/iteration/fold.hpp b/boost/fusion/algorithm/iteration/fold.hpp index a2a0146ab4..039e01c0c7 100644 --- a/boost/fusion/algorithm/iteration/fold.hpp +++ b/boost/fusion/algorithm/iteration/fold.hpp @@ -2,6 +2,7 @@ Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2007 Dan Marsden Copyright (c) 2009-2010 Christopher Schmidt + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,24 +11,17 @@ #define BOOST_FUSION_ALGORITHM_ITERATION_FOLD_HPP #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_FUSION_DONT_USE_PREPROCESSED_FILES) diff --git a/boost/fusion/algorithm/iteration/fold_fwd.hpp b/boost/fusion/algorithm/iteration/fold_fwd.hpp index f8328e80f9..0dbac7618b 100644 --- a/boost/fusion/algorithm/iteration/fold_fwd.hpp +++ b/boost/fusion/algorithm/iteration/fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq - , State const + , State , F >::type fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq const - , State const + , State , F >::type fold(Seq const& seq, State& state, F f); diff --git a/boost/fusion/algorithm/iteration/iter_fold.hpp b/boost/fusion/algorithm/iteration/iter_fold.hpp index b59a6957bc..cff5b4edf9 100644 --- a/boost/fusion/algorithm/iteration/iter_fold.hpp +++ b/boost/fusion/algorithm/iteration/iter_fold.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2010 Christopher Schmidt Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,20 +14,14 @@ #include #include #include -#include -#include #include #include -#include -#include +#include #include #include -#include #include -#include -#include -#include -#include +#include +#include #include #define BOOST_FUSION_ITER_FOLD diff --git a/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp b/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp index 6c595cf198..1d8543ca5f 100644 --- a/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp +++ b/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq - , State const + , State , F >::type iter_fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq const - , State const + , State , F >::type iter_fold(Seq const& seq, State& state, F f); diff --git a/boost/fusion/algorithm/iteration/reverse_fold.hpp b/boost/fusion/algorithm/iteration/reverse_fold.hpp index dffff79e14..252ad30836 100644 --- a/boost/fusion/algorithm/iteration/reverse_fold.hpp +++ b/boost/fusion/algorithm/iteration/reverse_fold.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2010 Christopher Schmidt Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,24 +11,17 @@ #define BOOST_FUSION_ALGORITHM_ITERATION_REVERSE_FOLD_HPP #include -#include #include #include -#include #include -#include #include #include -#include +#include #include #include #include -#include -#include -#include -#include #include -#include +#include #include #define BOOST_FUSION_REVERSE_FOLD diff --git a/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp b/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp index 42c8ac2163..c5e24b34a9 100644 --- a/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp +++ b/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq - , State const + , State , F >::type reverse_fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq const - , State const + , State , F >::type reverse_fold(Seq const& seq, State& state, F f); diff --git a/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp b/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp index d36861f37b..3276bbde57 100644 --- a/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp +++ b/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2010 Christopher Schmidt Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -9,24 +10,17 @@ #define BOOST_FUSION_ALGORITHM_ITERATION_REVERSE_ITER_FOLD_HPP #include -#include #include #include -#include #include -#include #include #include -#include +#include #include #include #include -#include -#include -#include -#include #include -#include +#include #include #define BOOST_FUSION_REVERSE_FOLD diff --git a/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp b/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp index 21d99deead..76f0186392 100644 --- a/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp +++ b/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq - , State const + , State , F >::type reverse_iter_fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq const - , State const + , State , F >::type reverse_iter_fold(Seq const& seq, State& state, F f); diff --git a/boost/fusion/algorithm/transformation/erase.hpp b/boost/fusion/algorithm/transformation/erase.hpp index 0f3b8a1519..8eebc357bb 100644 --- a/boost/fusion/algorithm/transformation/erase.hpp +++ b/boost/fusion/algorithm/transformation/erase.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/boost/fusion/algorithm/transformation/flatten.hpp b/boost/fusion/algorithm/transformation/flatten.hpp index e3cfa983a5..43ac34dfe6 100644 --- a/boost/fusion/algorithm/transformation/flatten.hpp +++ b/boost/fusion/algorithm/transformation/flatten.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree Distributed under the 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_FUSION_ALGORITHM_FLATTEN_HPP_INCLUDED #define BOOST_FUSION_ALGORITHM_FLATTEN_HPP_INCLUDED diff --git a/boost/fusion/algorithm/transformation/insert.hpp b/boost/fusion/algorithm/transformation/insert.hpp index 44e596537e..c6d5219d69 100644 --- a/boost/fusion/algorithm/transformation/insert.hpp +++ b/boost/fusion/algorithm/transformation/insert.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/boost/fusion/algorithm/transformation/insert_range.hpp b/boost/fusion/algorithm/transformation/insert_range.hpp index 40e64e1f5e..57878309a1 100644 --- a/boost/fusion/algorithm/transformation/insert_range.hpp +++ b/boost/fusion/algorithm/transformation/insert_range.hpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/boost/fusion/container/deque/deque.hpp b/boost/fusion/container/deque/deque.hpp index 96919052e7..dee51befcd 100644 --- a/boost/fusion/container/deque/deque.hpp +++ b/boost/fusion/container/deque/deque.hpp @@ -149,7 +149,8 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit deque(Sequence const& seq - , typename disable_if >::type* /*dummy*/ = 0) + , typename disable_if >::type* /*dummy*/ = 0 + , typename enable_if >::type* /*dummy*/ = 0) : base(base::from_iterator(fusion::begin(seq))) {} diff --git a/boost/fusion/container/deque/detail/convert_impl.hpp b/boost/fusion/container/deque/detail/convert_impl.hpp index ba9b847773..ede0cc48fe 100644 --- a/boost/fusion/container/deque/detail/convert_impl.hpp +++ b/boost/fusion/container/deque/detail/convert_impl.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2005-2012 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,7 +13,7 @@ #include #include #include -#include +#include namespace boost { namespace fusion { @@ -41,7 +42,11 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& seq) { - return gen::call(seq); + return gen::call(fusion::begin(seq) +#if defined(BOOST_FUSION_HAS_VARIADIC_DEQUE) + , fusion::end(seq) +#endif + ); } }; }; diff --git a/boost/fusion/container/deque/detail/cpp03/build_deque.hpp b/boost/fusion/container/deque/detail/cpp03/build_deque.hpp index 99cbe58493..587aa3b06c 100644 --- a/boost/fusion/container/deque/detail/cpp03/build_deque.hpp +++ b/boost/fusion/container/deque/detail/cpp03/build_deque.hpp @@ -22,6 +22,7 @@ namespace boost { namespace fusion { template struct as_deque + : detail::as_deque::value> { typedef typename detail::as_deque::value> diff --git a/boost/fusion/container/deque/detail/cpp03/deque.hpp b/boost/fusion/container/deque/detail/cpp03/deque.hpp index db8a967ab0..a65fa4acbd 100644 --- a/boost/fusion/container/deque/detail/cpp03/deque.hpp +++ b/boost/fusion/container/deque/detail/cpp03/deque.hpp @@ -101,7 +101,9 @@ namespace boost { namespace fusion { template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* /*dummy*/ = 0) + deque(Sequence const& seq + , typename disable_if >::type* /*dummy*/ = 0 + , typename enable_if >::type* /*dummy*/ = 0) : base(base::from_iterator(fusion::begin(seq))) {} diff --git a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp index ae1828a5f7..95cd8c1cba 100644 --- a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp +++ b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp @@ -201,7 +201,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp index 78224634bb..ad06945135 100644 --- a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp +++ b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp @@ -381,7 +381,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp index 8653217bc0..44a5b2b103 100644 --- a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp +++ b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp @@ -561,7 +561,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp index 3bfd488af2..e642288eb7 100644 --- a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp +++ b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp @@ -741,7 +741,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp index 04441da66c..a387708bca 100644 --- a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp +++ b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp @@ -921,7 +921,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/boost/fusion/container/generation/make_set.hpp b/boost/fusion/container/generation/make_set.hpp index 705ec582a8..cd8519e54d 100644 --- a/boost/fusion/container/generation/make_set.hpp +++ b/boost/fusion/container/generation/make_set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,46 @@ #include #include +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct make_set + { + typedef set< + typename detail::as_fusion_element< + typename remove_const< + typename remove_reference::type + >::type + >::type... + > type; + }; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::make_set::type + make_set(T&&... arg) + { + return typename result_of::make_set::type(std::forward(arg)...); + } + }} + + +#endif #endif diff --git a/boost/fusion/container/generation/make_vector.hpp b/boost/fusion/container/generation/make_vector.hpp index 8f0674815e..cd3b992bb5 100644 --- a/boost/fusion/container/generation/make_vector.hpp +++ b/boost/fusion/container/generation/make_vector.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,66 @@ #include #include +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct make_vector + { + // make `make_vector' into `make_vector' + template struct trim_void; + + template + struct trim_void > + { + typedef vector type; + }; + + template + struct trim_void, void_, Tail...> + : trim_void > { }; + + template + struct trim_void, Head, Tail...> + : trim_void, Tail...> { }; + + typedef + typename trim_void< + vector<> + , typename detail::as_fusion_element< + typename remove_const< + typename remove_reference::type + >::type + >::type... + >::type + type; + }; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::make_vector::type + make_vector(T&&... arg) + { + return typename result_of::make_vector::type(std::forward(arg)...); + } + }} + + +#endif #endif diff --git a/boost/fusion/container/generation/vector_tie.hpp b/boost/fusion/container/generation/vector_tie.hpp index 5bb4face4d..5d7cb98bc2 100644 --- a/boost/fusion/container/generation/vector_tie.hpp +++ b/boost/fusion/container/generation/vector_tie.hpp @@ -8,8 +8,37 @@ #define FUSION_VECTOR_TIE_11112014_2302 #include +#include +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct vector_tie + { + typedef vector type; + }; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline vector + vector_tie(T&... arg) + { + return vector(arg...); + } + }} + + +#endif #endif diff --git a/boost/fusion/container/set/detail/as_set.hpp b/boost/fusion/container/set/detail/as_set.hpp index 1eb0d3fe12..9d33325818 100644 --- a/boost/fusion/container/set/detail/as_set.hpp +++ b/boost/fusion/container/set/detail/as_set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,7 +13,55 @@ /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ +BOOST_FUSION_BARRIER_BEGIN + + template ::type> + struct as_set; + + template + struct as_set > + { + template + struct apply + { + typedef set< + typename result_of::value_of< + typename result_of::advance_c::type + >::type... + > type; + }; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static typename apply::type + call(Iterator const& i) + { + typedef apply gen; + typedef typename gen::type result; + return result(*advance_c(i)...); + } + }; + +BOOST_FUSION_BARRIER_END +}}} + +#endif #endif diff --git a/boost/fusion/container/set/detail/convert_impl.hpp b/boost/fusion/container/set/detail/convert_impl.hpp index d9d5dcfcd3..0b4cb22f32 100644 --- a/boost/fusion/container/set/detail/convert_impl.hpp +++ b/boost/fusion/container/set/detail/convert_impl.hpp @@ -29,7 +29,7 @@ namespace boost { namespace fusion template struct apply { - typedef typename detail::as_set::value> gen; + typedef detail::as_set::value> gen; typedef typename gen:: template apply::type>::type type; diff --git a/boost/fusion/container/set/set.hpp b/boost/fusion/container/set/set.hpp index 59f4eafc02..12fd8115d6 100644 --- a/boost/fusion/container/set/set.hpp +++ b/boost/fusion/container/set/set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,8 +13,126 @@ /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct fusion_sequence_tag; + + template <> + struct set<> : sequence_base > + { + struct category : forward_traversal_tag, associative_tag {}; + + typedef set_tag fusion_tag; + typedef fusion_sequence_tag tag; // this gets picked up by MPL + typedef mpl::false_ is_view; + + typedef vector<> storage_type; + + typedef storage_type::size size; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set() + : data() {} + + template + BOOST_FUSION_GPU_ENABLED + set(Sequence const& rhs, + typename enable_if >::type* = 0, + typename enable_if >::type* = 0) + : data(rhs) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set& + operator=(T const& rhs) + { + data = rhs; + return *this; + } + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + storage_type& get_data() { return data; } + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + storage_type const& get_data() const { return data; } + + private: + storage_type data; + }; + + template + struct set : sequence_base > + { + struct category : forward_traversal_tag, associative_tag {}; + + typedef set_tag fusion_tag; + typedef fusion_sequence_tag tag; // this gets picked up by MPL + typedef mpl::false_ is_view; + + typedef vector storage_type; + + typedef typename storage_type::size size; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set() + : data() {} + + template + BOOST_FUSION_GPU_ENABLED + set(Sequence&& rhs, + typename enable_if >::type* = 0, + typename enable_if >::type* = 0) + : data(std::forward(rhs)) {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + set(U&& ...args) + : data(std::forward(args)...) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set& + operator=(U&& rhs) + { + data = std::forward(rhs); + return *this; + } + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + storage_type& get_data() { return data; } + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + storage_type const& get_data() const { return data; } + + private: + storage_type data; + }; + +}} + +#endif #endif diff --git a/boost/fusion/container/set/set_fwd.hpp b/boost/fusion/container/set/set_fwd.hpp index 50d8d1c8bd..7b5d6830a5 100644 --- a/boost/fusion/container/set/set_fwd.hpp +++ b/boost/fusion/container/set/set_fwd.hpp @@ -9,11 +9,38 @@ #include #include +#include + +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) \ + || (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) +# if defined(BOOST_FUSION_HAS_VARIADIC_SET) +# undef BOOST_FUSION_HAS_VARIADIC_SET +# endif +#else +# if !defined(BOOST_FUSION_HAS_VARIADIC_SET) +# define BOOST_FUSION_HAS_VARIADIC_SET +# endif +#endif /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + struct set_tag; + struct set_iterator_tag; + + template + struct set; +}} + +#endif #endif diff --git a/boost/fusion/container/vector.hpp b/boost/fusion/container/vector.hpp index a999c8b023..41c980331e 100644 --- a/boost/fusion/container/vector.hpp +++ b/boost/fusion/container/vector.hpp @@ -8,25 +8,8 @@ #define FUSION_SEQUENCE_CLASS_VECTOR_10022005_0602 #include -#include - -#include -#if (FUSION_MAX_VECTOR_SIZE > 10) -#include -#endif -#if (FUSION_MAX_VECTOR_SIZE > 20) -#include -#endif -#if (FUSION_MAX_VECTOR_SIZE > 30) -#include -#endif -#if (FUSION_MAX_VECTOR_SIZE > 40) -#include -#endif - -#include #include -#include +#include #include #endif diff --git a/boost/fusion/container/vector/detail/as_vector.hpp b/boost/fusion/container/vector/detail/as_vector.hpp index eaaac89638..e2f45b6a04 100644 --- a/boost/fusion/container/vector/detail/as_vector.hpp +++ b/boost/fusion/container/vector/detail/as_vector.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the 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,12 +8,63 @@ #define FUSION_AS_VECTOR_11052014_1801 #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ +BOOST_FUSION_BARRIER_BEGIN + + template + struct as_vector_impl; + + template + struct as_vector_impl > + { + template + struct apply + { + typedef vector< + typename result_of::value_of< + typename result_of::advance_c::type + >::type... + > type; + }; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static typename apply::type + call(Iterator i) + { + typedef typename apply::type result; + return result(*advance_c(i)...); + } + }; + + template + struct as_vector + : as_vector_impl::type> {}; + +BOOST_FUSION_BARRIER_END +}}} + +#endif #endif diff --git a/boost/fusion/container/vector/detail/at_impl.hpp b/boost/fusion/container/vector/detail/at_impl.hpp index cb98dd4a25..a2900d7943 100644 --- a/boost/fusion/container/vector/detail/at_impl.hpp +++ b/boost/fusion/container/vector/detail/at_impl.hpp @@ -9,9 +9,8 @@ #include #include -#include -#include -#include +#include +#include namespace boost { namespace fusion { @@ -28,7 +27,7 @@ namespace boost { namespace fusion template struct apply { - typedef typename mpl::at::type element; + typedef typename value_at_impl::template apply::type element; typedef typename detail::ref_result::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -43,7 +42,7 @@ namespace boost { namespace fusion template struct apply { - typedef typename mpl::at::type element; + typedef typename value_at_impl::template apply::type element; typedef typename detail::cref_result::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED diff --git a/boost/fusion/container/vector/detail/config.hpp b/boost/fusion/container/vector/detail/config.hpp new file mode 100644 index 0000000000..84f4605d2e --- /dev/null +++ b/boost/fusion/container/vector/detail/config.hpp @@ -0,0 +1,36 @@ +/*============================================================================= + Copyright (c) 2014-2015 Kohei Takahashi + + Distributed under the 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 FUSION_VECTOR_CONFIG_11052014_1720 +#define FUSION_VECTOR_CONFIG_11052014_1720 + +#include +#include +#include + +#if (defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \ + || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \ + || defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) \ + || defined(BOOST_NO_CXX11_DECLTYPE)) \ + || (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) +# if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) +# undef BOOST_FUSION_HAS_VARIADIC_VECTOR +# endif +#else +# if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) +# define BOOST_FUSION_HAS_VARIADIC_VECTOR +# endif +#endif + +// Sometimes, MSVC 12 shows compile error with std::size_t of template parameter. +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1800)) +# if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) +# undef BOOST_FUSION_HAS_VARIADIC_VECTOR +# endif +#endif + +#endif + diff --git a/boost/fusion/container/vector/detail/cpp03/limits.hpp b/boost/fusion/container/vector/detail/cpp03/limits.hpp index 6e106144bb..74a05102d2 100644 --- a/boost/fusion/container/vector/detail/cpp03/limits.hpp +++ b/boost/fusion/container/vector/detail/cpp03/limits.hpp @@ -9,6 +9,7 @@ #include #include +#include #if !defined(FUSION_MAX_VECTOR_SIZE) # define FUSION_MAX_VECTOR_SIZE 10 diff --git a/boost/fusion/container/vector/detail/deref_impl.hpp b/boost/fusion/container/vector/detail/deref_impl.hpp index 5186aa1047..c85bb82b3b 100644 --- a/boost/fusion/container/vector/detail/deref_impl.hpp +++ b/boost/fusion/container/vector/detail/deref_impl.hpp @@ -8,8 +8,8 @@ #define FUSION_DEREF_IMPL_05042005_1037 #include -#include #include +#include #include #include @@ -30,9 +30,7 @@ namespace boost { namespace fusion { typedef typename Iterator::vector vector; typedef typename Iterator::index index; - typedef typename mpl::at< - typename vector::types, index>::type - element; + typedef typename value_at_impl::template apply::type element; typedef typename mpl::if_< diff --git a/boost/fusion/container/vector/detail/value_at_impl.hpp b/boost/fusion/container/vector/detail/value_at_impl.hpp index f71ca8486d..6c8c41fb27 100644 --- a/boost/fusion/container/vector/detail/value_at_impl.hpp +++ b/boost/fusion/container/vector/detail/value_at_impl.hpp @@ -9,11 +9,50 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include + +namespace boost { namespace fusion +{ + struct vector_tag; + + namespace vector_detail + { + template + struct vector_data; + } + + namespace extension + { + template + struct value_at_impl; + + template <> + struct value_at_impl + { + template + struct apply + { + typedef typename boost::remove_cv::type seq; + typedef typename mpl::identity(boost::declval()))>::type::type type; + }; + }; + } +}} + +#endif #endif diff --git a/boost/fusion/container/vector/detail/value_of_impl.hpp b/boost/fusion/container/vector/detail/value_of_impl.hpp index 2a8acf912d..d67ab3fcc2 100644 --- a/boost/fusion/container/vector/detail/value_of_impl.hpp +++ b/boost/fusion/container/vector/detail/value_of_impl.hpp @@ -8,7 +8,7 @@ #define FUSION_VALUE_OF_IMPL_05052005_1128 #include -#include +#include namespace boost { namespace fusion { @@ -27,9 +27,7 @@ namespace boost { namespace fusion { typedef typename Iterator::vector vector; typedef typename Iterator::index index; - typedef typename mpl::at< - typename vector::types, index>::type - type; + typedef typename value_at_impl::template apply::type type; }; }; } diff --git a/boost/fusion/container/vector/vector.hpp b/boost/fusion/container/vector/vector.hpp index 2b9f0ce5ca..845a019e6b 100644 --- a/boost/fusion/container/vector/vector.hpp +++ b/boost/fusion/container/vector/vector.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -9,12 +9,332 @@ #include #include +#include #include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct vector_tag; + struct random_access_traversal_tag; + + namespace vector_detail + { + struct each_elem {}; + struct copy_or_move {}; + template struct from_sequence {}; + + template + struct make_indices_from_seq + : detail::make_index_sequence< + fusion::result_of::size::type>::value + > + {}; + + template + struct pure : remove_cv::type> {}; + + template ::value> + struct is_convertible_to_first + : boost::is_convertible::type> + {}; + + template + struct is_convertible_to_first + : mpl::false_ + {}; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline each_elem + dispatch(T const&...) BOOST_NOEXCEPT { return each_elem(); } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline copy_or_move + dispatch(This const&) BOOST_NOEXCEPT { return copy_or_move(); } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline from_sequence< + typename lazy_enable_if_c< + (traits::is_sequence::type>::value && + !is_same::type>::value && + !is_convertible_to_first::value) + , make_indices_from_seq + >::type + > + dispatch(Sequence&&) BOOST_NOEXCEPT + { return from_sequence::type>(); } + + + // forward_at_c allows to access Nth element even if ForwardSequence + // since fusion::at_c requires RandomAccessSequence. + namespace result_of + { + template + struct forward_at_c + : fusion::result_of::deref< + typename fusion::result_of::advance_c< + typename fusion::result_of::begin< + typename remove_reference::type + >::type + , N + >::type + > + {}; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::forward_at_c::type + forward_at_c(Sequence&& seq) + { + typedef typename + result_of::forward_at_c::type + result; + return std::forward(*advance_c(begin(seq))); + } + + // Object proxy since preserve object order + template + struct store + { + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store() + : elem() // value-initialized explicitly + {} + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store(store const& rhs) + : elem(rhs.get()) + {} + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store& + operator=(store const& rhs) + { + elem = rhs.get(); + return *this; + } + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store(store&& rhs) + : elem(static_cast(rhs.get())) + {} + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store& + operator=(store&& rhs) + { + elem = static_cast(rhs.get()); + return *this; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store(U&& rhs + , typename disable_if::type, store> >::type* = 0) + : elem(std::forward(rhs)) + {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + typename disable_if::type, store>, store&>::type + operator=(U&& rhs) + { + elem = std::forward(rhs); + return *this; + } + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + T & get() { return elem; } + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + T const& get() const { return elem; } + + T elem; + }; + + template + struct vector_data; + + template + struct vector_data, T...> + : store... + , sequence_base, T...> > + { + typedef vector_tag fusion_tag; + typedef fusion_sequence_tag tag; // this gets picked up by MPL + typedef mpl::false_ is_view; + typedef random_access_traversal_tag category; + typedef mpl::int_ size; + typedef vector type_sequence; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector_data() + {} + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector_data(copy_or_move, vector_data const& rhs) + : store(static_cast const&>(rhs))... + {} + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector_data(copy_or_move, vector_data&& rhs) + : store(std::forward >(rhs))... + {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + vector_data(from_sequence >, Sequence&& rhs) + : store(forward_at_c(rhs))... + {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + vector_data(each_elem, U&&... var) + : store(std::forward(var))... + {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + void + assign(Sequence&&, detail::index_sequence<>) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + void + assign(Sequence&& seq, detail::index_sequence) + { + at_impl(mpl::int_()) = vector_detail::forward_at_c(seq); + assign(std::forward(seq), detail::index_sequence()); + } + + template + static BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_detail(store* this_) -> decltype(this_->get()) + { + return this_->get(); + } + + template + static BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_detail(store const* this_) -> decltype(this_->get()) + { + return this_->get(); + } + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_impl(J) -> decltype(at_detail(this)) + { + return at_detail(this); + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_impl(J) const -> decltype(at_detail(this)) + { + return at_detail(this); + } + + template + static BOOST_FUSION_GPU_ENABLED + mpl::identity value_at_impl(store*); + }; + + template + struct trim_void_; + + template + struct trim_void_ > + { + typedef vector_data< + typename detail::make_index_sequence::type + , T... + > type; + }; + + template + struct trim_void_, void_, Tail...> + : trim_void_ > {}; + + template + struct trim_void_, Head, Tail...> + : trim_void_, Tail...> {}; + + template + struct trim_void : trim_void_, T...> {}; + } // namespace boost::fusion::vector_detail + + // This class provides backward compatibility: vector. + template + struct vector + : vector_detail::trim_void::type + { + typedef typename vector_detail::trim_void::type base; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector() + {} + + // rvalue-references is required here in order to forward any arguments to + // base: vector(T const&...) doesn't work with trailing void_ and + // vector(U const&...) cannot forward any arguments to base. + template + // XXX: constexpr become error due to pull-request #79, booooo!! + // In the (near) future release, should be fixed. + /* BOOST_CONSTEXPR */ BOOST_FUSION_GPU_ENABLED + vector(U&&... u) + : base(vector_detail::dispatch(std::forward(u)...), std::forward(u)...) + {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector& + operator=(Sequence&& rhs) + { + typedef typename + vector_detail::make_indices_from_seq::type + indices; + base::assign(std::forward(rhs), indices()); + return *this; + } + }; +}} + +#endif #endif diff --git a/boost/fusion/container/vector/vector10.hpp b/boost/fusion/container/vector/vector10.hpp index f152bfe161..65722fe64a 100644 --- a/boost/fusion/container/vector/vector10.hpp +++ b/boost/fusion/container/vector/vector10.hpp @@ -9,11 +9,21 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +#endif #endif diff --git a/boost/fusion/container/vector/vector20.hpp b/boost/fusion/container/vector/vector20.hpp index c5be355df6..c36e50c7d2 100644 --- a/boost/fusion/container/vector/vector20.hpp +++ b/boost/fusion/container/vector/vector20.hpp @@ -9,11 +9,21 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +#endif #endif diff --git a/boost/fusion/container/vector/vector30.hpp b/boost/fusion/container/vector/vector30.hpp index 1a528cb578..e9f891f28b 100644 --- a/boost/fusion/container/vector/vector30.hpp +++ b/boost/fusion/container/vector/vector30.hpp @@ -9,11 +9,21 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +#endif #endif diff --git a/boost/fusion/container/vector/vector40.hpp b/boost/fusion/container/vector/vector40.hpp index 5faa7d595b..4b753a084e 100644 --- a/boost/fusion/container/vector/vector40.hpp +++ b/boost/fusion/container/vector/vector40.hpp @@ -9,11 +9,21 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +#endif #endif diff --git a/boost/fusion/container/vector/vector50.hpp b/boost/fusion/container/vector/vector50.hpp index 7b7e7a8a18..5d8d356313 100644 --- a/boost/fusion/container/vector/vector50.hpp +++ b/boost/fusion/container/vector/vector50.hpp @@ -9,11 +9,21 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +#endif #endif diff --git a/boost/fusion/container/vector/vector_fwd.hpp b/boost/fusion/container/vector/vector_fwd.hpp index b63099ce9d..dcb0a0fc0c 100644 --- a/boost/fusion/container/vector/vector_fwd.hpp +++ b/boost/fusion/container/vector/vector_fwd.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -9,11 +9,35 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +namespace boost { namespace fusion +{ + template + struct vector; + +#define FUSION_VECTOR_N_ALIASES(z, N, d) \ + template \ + using BOOST_PP_CAT(vector, N) = vector; + + BOOST_PP_REPEAT(51, FUSION_VECTOR_N_ALIASES, ~) + +#undef FUSION_VECTOR_N_ALIASES +}} + +#endif #endif diff --git a/boost/fusion/functional/adapter/limits.hpp b/boost/fusion/functional/adapter/limits.hpp index cdcdf8210e..9fb5a2a2cc 100644 --- a/boost/fusion/functional/adapter/limits.hpp +++ b/boost/fusion/functional/adapter/limits.hpp @@ -9,16 +9,21 @@ #if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_LIMITS_HPP_INCLUDED) # define BOOST_FUSION_FUNCTIONAL_ADAPTER_LIMITS_HPP_INCLUDED -# include +# include +# if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) +# include +# endif # if !defined(BOOST_FUSION_UNFUSED_MAX_ARITY) # define BOOST_FUSION_UNFUSED_MAX_ARITY 6 -# elif BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY > FUSION_MAX_VECTOR_SIZE +# elif !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) && \ + (BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY > FUSION_MAX_VECTOR_SIZE) # error "BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY > FUSION_MAX_VECTOR_SIZE" # endif # if !defined(BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY) # define BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY 6 -# elif BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE +# elif !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) && \ + (BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE) # error "BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE" # endif diff --git a/boost/fusion/functional/invocation/invoke.hpp b/boost/fusion/functional/invocation/invoke.hpp index b79ff5b439..09f3ead87f 100644 --- a/boost/fusion/functional/invocation/invoke.hpp +++ b/boost/fusion/functional/invocation/invoke.hpp @@ -39,9 +39,9 @@ #include #include +#include #include -#include #include #include #include @@ -148,7 +148,7 @@ namespace boost { namespace fusion template struct invoke::type, Sequence >::result_type @@ -195,7 +195,7 @@ namespace boost { namespace fusion template struct invoke_impl::type >::type> { @@ -289,7 +289,7 @@ namespace boost { namespace fusion template struct invoke_impl::BOOST_PP_CAT(T, j) typename boost::result_of::type >::type> diff --git a/boost/fusion/functional/invocation/invoke_function_object.hpp b/boost/fusion/functional/invocation/invoke_function_object.hpp index 3ed508dd3d..2a88eaec19 100644 --- a/boost/fusion/functional/invocation/invoke_function_object.hpp +++ b/boost/fusion/functional/invocation/invoke_function_object.hpp @@ -18,14 +18,12 @@ #include #include +#include #include #include -#include - #include -#include #include #include #include @@ -62,7 +60,7 @@ namespace boost { namespace fusion template struct invoke_function_object::type, Sequence >::result_type @@ -110,7 +108,7 @@ namespace boost { namespace fusion template struct invoke_function_object_impl::type >::type> { @@ -151,7 +149,7 @@ namespace boost { namespace fusion template struct invoke_function_object_impl::type >::type> #undef M diff --git a/boost/fusion/functional/invocation/invoke_procedure.hpp b/boost/fusion/functional/invocation/invoke_procedure.hpp index a0fe73a6f3..971ddbfdea 100644 --- a/boost/fusion/functional/invocation/invoke_procedure.hpp +++ b/boost/fusion/functional/invocation/invoke_procedure.hpp @@ -20,6 +20,7 @@ #include #include +#include #include @@ -28,7 +29,6 @@ #include #include -#include #include #include #include @@ -66,7 +66,7 @@ namespace boost { namespace fusion template struct invoke_procedure::type,Sequence >::result_type diff --git a/boost/fusion/sequence/io/detail/manip.hpp b/boost/fusion/sequence/io/detail/manip.hpp index ec8ce304f6..68f7ab4f91 100644 --- a/boost/fusion/sequence/io/detail/manip.hpp +++ b/boost/fusion/sequence/io/detail/manip.hpp @@ -110,8 +110,7 @@ namespace boost { namespace fusion { // read a delimiter string_type const* p = stream_data_t::get(stream); - using namespace std; - ws(stream); + std::ws(stream); if (p) { diff --git a/boost/fusion/support/detail/enabler.hpp b/boost/fusion/support/detail/enabler.hpp deleted file mode 100644 index 48b69f3227..0000000000 --- a/boost/fusion/support/detail/enabler.hpp +++ /dev/null @@ -1,18 +0,0 @@ -/*============================================================================= - Copyright (c) 2015 Kohei Takahashi - - 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 FUSION_DETAIL_ENABLER_02082015_163810 -#define FUSION_DETAIL_ENABLER_02082015_163810 - -namespace boost { namespace fusion { namespace detail -{ - template - struct enabler { typedef T type; }; -}}} - -#endif - diff --git a/boost/fusion/support/detail/is_same_size.hpp b/boost/fusion/support/detail/is_same_size.hpp new file mode 100644 index 0000000000..b1bf7cde41 --- /dev/null +++ b/boost/fusion/support/detail/is_same_size.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2014-2015 Kohei Takahashi + + Distributed under the 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 FUSION_IS_SAME_SIZE_10082015_1156 +#define FUSION_IS_SAME_SIZE_10082015_1156 + +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ + template + struct is_same_size : mpl::false_ {}; + + template + struct is_same_size >::type, + typename enable_if >::type> + : mpl::equal_to, result_of::size > + {}; +}}} + +#endif diff --git a/boost/fusion/support/detail/result_of.hpp b/boost/fusion/support/detail/result_of.hpp deleted file mode 100644 index e53ea9e354..0000000000 --- a/boost/fusion/support/detail/result_of.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2014 Joel de Guzman - - Distributed under the 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(FUSION_RESULT_OF_10272014_0654) -#define FUSION_RESULT_OF_10272014_0654 - -#include -#include - -#if !defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#define BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF -#endif - -#if !defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) -#include -#include -#include -#endif - -namespace boost { namespace fusion { namespace detail -{ - // This is a temporary workaround for result_of before we make fusion fully - // sfinae result_of friendy, which will require some heavy lifting for some - // low level code. So far this is used only in the fold algorithm. This will - // be removed once we overhaul fold. - -#if defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) - - template - struct result_of_with_decltype : boost::tr1_result_of {}; - -#else // defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) - - BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) - BOOST_MPL_HAS_XXX_TEMPLATE_DEF(result) - - template - struct result_of_with_decltype; - - template - struct result_of_with_decltype - : mpl::if_, detail::has_result >, - boost::tr1_result_of, - boost::detail::cpp0x_result_of >::type {}; - -#endif // defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) - -}}} - -#endif diff --git a/boost/fusion/support/segmented_fold_until.hpp b/boost/fusion/support/segmented_fold_until.hpp index 9e6f4a50f6..8fb09ee38d 100644 --- a/boost/fusion/support/segmented_fold_until.hpp +++ b/boost/fusion/support/segmented_fold_until.hpp @@ -11,11 +11,6 @@ #include #include #include -#include -#include -#include -#include -#include namespace boost { namespace fusion { diff --git a/boost/fusion/tuple/make_tuple.hpp b/boost/fusion/tuple/make_tuple.hpp index 0d1277366a..e5cbb3b2ac 100644 --- a/boost/fusion/tuple/make_tuple.hpp +++ b/boost/fusion/tuple/make_tuple.hpp @@ -13,7 +13,38 @@ /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline tuple::type + >::type + >::type...> + make_tuple(T&&... arg) + { + typedef tuple::type + >::type + >::type...> result_type; + return result_type(std::forward(arg)...); + } +}} + +#endif #endif diff --git a/boost/fusion/tuple/tuple.hpp b/boost/fusion/tuple/tuple.hpp index 674c369132..6ee21f56a0 100644 --- a/boost/fusion/tuple/tuple.hpp +++ b/boost/fusion/tuple/tuple.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,7 +13,80 @@ /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + template + struct tuple : vector + { + typedef vector base_type; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple() + : base_type() {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple(tuple const& other) + : base_type(other) {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple(tuple&& other) + : base_type(std::move(other)) {} + + template + /*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED + explicit + tuple(U&&... args) + : base_type(std::forward(args)...) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple& operator=(U&& rhs) + { + base_type::operator=(std::forward(rhs)); + return *this; + } + }; + + template + struct tuple_size : result_of::size {}; + + template + struct tuple_element : result_of::value_at_c {}; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::at_c::type + get(Tuple& tup) + { + return at_c(tup); + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::at_c::type + get(Tuple const& tup) + { + return at_c(tup); + } +}} + +#endif #endif diff --git a/boost/fusion/tuple/tuple_fwd.hpp b/boost/fusion/tuple/tuple_fwd.hpp index 0742023403..b763acd52f 100644 --- a/boost/fusion/tuple/tuple_fwd.hpp +++ b/boost/fusion/tuple/tuple_fwd.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -9,11 +9,35 @@ #include #include +#include + +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) \ + || (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) +# if defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) +# undef BOOST_FUSION_HAS_VARIADIC_TUPLE +# endif +#else +# if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) +# define BOOST_FUSION_HAS_VARIADIC_TUPLE +# endif +#endif /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + template + struct tuple; +}} #endif +#endif diff --git a/boost/fusion/tuple/tuple_tie.hpp b/boost/fusion/tuple/tuple_tie.hpp index 9202807048..a07dc0a43e 100644 --- a/boost/fusion/tuple/tuple_tie.hpp +++ b/boost/fusion/tuple/tuple_tie.hpp @@ -13,7 +13,26 @@ /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include + +namespace boost { namespace fusion +{ + template + BOOST_FUSION_GPU_ENABLED + inline tuple + tie(T&... arg) + { + return tuple(arg...); + } +}} + +#endif #endif diff --git a/boost/fusion/view/detail/strictest_traversal.hpp b/boost/fusion/view/detail/strictest_traversal.hpp index 9ad1f7aa85..4092ea4da6 100644 --- a/boost/fusion/view/detail/strictest_traversal.hpp +++ b/boost/fusion/view/detail/strictest_traversal.hpp @@ -59,7 +59,7 @@ namespace boost { namespace fusion // never called, but needed for decltype-based result_of (C++0x) #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + BOOST_FUSION_GPU_ENABLED typename result::type operator()(StrictestSoFar&&, Next&&) const; #endif diff --git a/boost/fusion/view/flatten_view.hpp b/boost/fusion/view/flatten_view.hpp index dcef08dec7..25428544d6 100644 --- a/boost/fusion/view/flatten_view.hpp +++ b/boost/fusion/view/flatten_view.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree Distributed under the 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_FUSION_SEQUENCE_FLATTEN_VIEW_HPP_INCLUDED #define BOOST_FUSION_SEQUENCE_FLATTEN_VIEW_HPP_INCLUDED diff --git a/boost/fusion/view/flatten_view/flatten_view.hpp b/boost/fusion/view/flatten_view/flatten_view.hpp index 8e40158d1c..401f65dc86 100644 --- a/boost/fusion/view/flatten_view/flatten_view.hpp +++ b/boost/fusion/view/flatten_view/flatten_view.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree Distributed under the 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_FUSION_FLATTEN_VIEW_HPP_INCLUDED #define BOOST_FUSION_FLATTEN_VIEW_HPP_INCLUDED diff --git a/boost/fusion/view/flatten_view/flatten_view_iterator.hpp b/boost/fusion/view/flatten_view/flatten_view_iterator.hpp index 1ecf692822..be115d910b 100644 --- a/boost/fusion/view/flatten_view/flatten_view_iterator.hpp +++ b/boost/fusion/view/flatten_view/flatten_view_iterator.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree Distributed under the 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_FUSION_FLATTEN_VIEW_ITERATOR_HPP_INCLUDED #define BOOST_FUSION_FLATTEN_VIEW_ITERATOR_HPP_INCLUDED diff --git a/boost/fusion/view/nview/detail/advance_impl.hpp b/boost/fusion/view/nview/detail/advance_impl.hpp index 7c74a386bb..c46414337f 100644 --- a/boost/fusion/view/nview/detail/advance_impl.hpp +++ b/boost/fusion/view/nview/detail/advance_impl.hpp @@ -1,7 +1,7 @@ /*============================================================================= Copyright (c) 2009 Hartmut Kaiser - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ @@ -9,7 +9,6 @@ #define BOOST_FUSION_NVIEW_ADVANCE_IMPL_SEP_24_2009_0212PM #include -#include #include namespace boost { namespace fusion @@ -30,11 +29,11 @@ namespace boost { namespace fusion template struct apply { - typedef typename Iterator::first_type::iterator_type iterator_type; + typedef typename Iterator::first_type iterator_type; typedef typename Iterator::sequence_type sequence_type; - typedef nview_iterator::type> type; + typedef nview_iterator::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/boost/fusion/view/nview/detail/at_impl.hpp b/boost/fusion/view/nview/detail/at_impl.hpp index b9f41defcd..9f8c163708 100644 --- a/boost/fusion/view/nview/detail/at_impl.hpp +++ b/boost/fusion/view/nview/detail/at_impl.hpp @@ -10,6 +10,7 @@ #include #include +#include namespace boost { namespace fusion { @@ -29,7 +30,7 @@ namespace boost { namespace fusion typedef typename Sequence::sequence_type sequence_type; typedef typename Sequence::index_type index_type; - typedef typename result_of::at::type index; + typedef typename result_of::value_at::type index; typedef typename result_of::at::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED diff --git a/boost/fusion/view/nview/detail/begin_impl.hpp b/boost/fusion/view/nview/detail/begin_impl.hpp index bab5e221c9..99e6319ea8 100644 --- a/boost/fusion/view/nview/detail/begin_impl.hpp +++ b/boost/fusion/view/nview/detail/begin_impl.hpp @@ -9,7 +9,6 @@ #define BOOST_FUSION_NVIEW_BEGIN_IMPL_SEP_23_2009_1036PM #include -#include #include namespace boost { namespace fusion @@ -32,8 +31,8 @@ namespace boost { namespace fusion { typedef typename Sequence::index_type index_type; - typedef nview_iterator::type> type; + typedef nview_iterator::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& s) diff --git a/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp b/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp index 08c6c9d738..0bcea9bb91 100644 --- a/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp +++ b/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp @@ -17,10 +17,13 @@ #include #include #include +#include +#include +#include #define BOOST_PP_ITERATION_PARAMS_1 \ (3, (1, FUSION_MAX_VECTOR_SIZE, \ - "boost/fusion/view/nview/detail/cpp03/nview_impl.hpp")) \ + "boost/fusion/view/nview/detail/cpp03/nview_impl.hpp")) \ /**/ /////////////////////////////////////////////////////////////////////////////// diff --git a/boost/fusion/view/nview/detail/deref_impl.hpp b/boost/fusion/view/nview/detail/deref_impl.hpp index 85991021b6..57654aa057 100644 --- a/boost/fusion/view/nview/detail/deref_impl.hpp +++ b/boost/fusion/view/nview/detail/deref_impl.hpp @@ -9,8 +9,8 @@ #define BOOST_FUSION_NVIEW_DEREF_IMPL_SEP_24_2009_0818AM #include -#include -#include +#include +#include namespace boost { namespace fusion { @@ -30,7 +30,7 @@ namespace boost { namespace fusion typedef typename Iterator::first_type first_type; typedef typename Iterator::sequence_type sequence_type; - typedef typename result_of::deref::type index; + typedef typename result_of::value_of::type index; typedef typename result_of::at< typename sequence_type::sequence_type, index>::type type; diff --git a/boost/fusion/view/nview/detail/end_impl.hpp b/boost/fusion/view/nview/detail/end_impl.hpp index 0a6efe560d..810aea917a 100644 --- a/boost/fusion/view/nview/detail/end_impl.hpp +++ b/boost/fusion/view/nview/detail/end_impl.hpp @@ -9,7 +9,6 @@ #define BOOST_FUSION_NVIEW_END_IMPL_SEP_24_2009_0140PM #include -#include #include namespace boost { namespace fusion @@ -33,8 +32,8 @@ namespace boost { namespace fusion { typedef typename Sequence::index_type index_type; - typedef nview_iterator::type> type; + typedef nview_iterator::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& s) diff --git a/boost/fusion/view/nview/detail/next_impl.hpp b/boost/fusion/view/nview/detail/next_impl.hpp index 3c30409647..821d9c3768 100644 --- a/boost/fusion/view/nview/detail/next_impl.hpp +++ b/boost/fusion/view/nview/detail/next_impl.hpp @@ -9,7 +9,7 @@ #define BOOST_FUSION_NVIEW_NEXT_IMPL_SEP_24_2009_0116PM #include -#include +#include namespace boost { namespace fusion { @@ -27,13 +27,13 @@ namespace boost { namespace fusion struct next_impl { template - struct apply + struct apply { - typedef typename Iterator::first_type::iterator_type first_type; + typedef typename Iterator::first_type first_type; typedef typename Iterator::sequence_type sequence_type; typedef nview_iterator::type> type; + typename result_of::next::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/boost/fusion/view/nview/detail/nview_impl.hpp b/boost/fusion/view/nview/detail/nview_impl.hpp index 40674e3551..0c75a66afa 100644 --- a/boost/fusion/view/nview/detail/nview_impl.hpp +++ b/boost/fusion/view/nview/detail/nview_impl.hpp @@ -8,11 +8,43 @@ #define BOOST_FUSION_NVIEW_IMPL_17122014_1948 #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct as_nview + { + typedef vector...> index_type; + typedef nview type; + }; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline nview...> > + as_nview(Sequence& s) + { + typedef vector...> index_type; + return nview(s); + } +}} + +#endif #endif diff --git a/boost/fusion/view/nview/detail/prior_impl.hpp b/boost/fusion/view/nview/detail/prior_impl.hpp index 470c5bd323..29b63f5692 100644 --- a/boost/fusion/view/nview/detail/prior_impl.hpp +++ b/boost/fusion/view/nview/detail/prior_impl.hpp @@ -9,7 +9,7 @@ #define BOOST_FUSION_NVIEW_PRIOR_IMPL_SEP_24_2009_0142PM #include -#include +#include namespace boost { namespace fusion { @@ -27,13 +27,13 @@ namespace boost { namespace fusion struct prior_impl { template - struct apply + struct apply { - typedef typename Iterator::first_type::iterator_type first_type; + typedef typename Iterator::first_type first_type; typedef typename Iterator::sequence_type sequence_type; typedef nview_iterator::type> type; + typename result_of::prior::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/boost/fusion/view/nview/nview.hpp b/boost/fusion/view/nview/nview.hpp index 2e257c81de..e5a4be8ab7 100644 --- a/boost/fusion/view/nview/nview.hpp +++ b/boost/fusion/view/nview/nview.hpp @@ -9,19 +9,15 @@ #define BOOST_FUSION_NVIEW_SEP_23_2009_0948PM #include -#include #include -#include -#include -#include #include #include #include -#include #include #include +#include #include #include @@ -99,7 +95,7 @@ namespace boost { namespace fusion typedef mpl::true_ is_view; typedef Indicies index_type; - typedef typename mpl::size::type size; + typedef typename result_of::size::type size; typedef typename mpl::if_< is_const, detail::addconstref, detail::addref diff --git a/boost/fusion/view/nview/nview_iterator.hpp b/boost/fusion/view/nview/nview_iterator.hpp index aeaf4620b8..42e634e521 100644 --- a/boost/fusion/view/nview/nview_iterator.hpp +++ b/boost/fusion/view/nview/nview_iterator.hpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -40,7 +39,7 @@ namespace boost { namespace fusion typedef random_access_traversal_tag category; typedef Sequence sequence_type; - typedef mpl_iterator first_type; + typedef Pos first_type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit nview_iterator(Sequence& in_seq) diff --git a/boost/geometry/algorithms/centroid.hpp b/boost/geometry/algorithms/centroid.hpp index 1b99ab2ef3..8ef017a3f1 100644 --- a/boost/geometry/algorithms/centroid.hpp +++ b/boost/geometry/algorithms/centroid.hpp @@ -220,19 +220,22 @@ struct centroid_range_state iterator_type it = boost::begin(view); iterator_type end = boost::end(view); - typename PointTransformer::result_type - previous_pt = transformer.apply(*it); - - for ( ++it ; it != end ; ++it) + if (it != end) { typename PointTransformer::result_type - pt = transformer.apply(*it); + previous_pt = transformer.apply(*it); - strategy.apply(static_cast(previous_pt), - static_cast(pt), - state); - - previous_pt = pt; + for ( ++it ; it != end ; ++it) + { + typename PointTransformer::result_type + pt = transformer.apply(*it); + + strategy.apply(static_cast(previous_pt), + static_cast(pt), + state); + + previous_pt = pt; + } } } }; diff --git a/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp b/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp index b25bcc7fb5..606726f338 100644 --- a/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp +++ b/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -135,6 +136,7 @@ struct buffer_range RobustPolicy const& ) { output_point_type intersection_point; + geometry::assign_zero(intersection_point); strategy::buffer::join_selector join = get_join_type(penultimate_input, previous_input, input); @@ -392,7 +394,7 @@ inline void buffer_point(Point const& point, Collection& collection, point_strategy.apply(point, distance_strategy, range_out); collection.add_piece(strategy::buffer::buffered_point, range_out, false); collection.set_piece_center(point); - collection.finish_ring(); + collection.finish_ring(strategy::buffer::result_normal); } @@ -680,7 +682,7 @@ struct buffer_inserter distance, side_strategy, join_strategy, end_strategy, robust_policy, first_p1); } - collection.finish_ring(); + collection.finish_ring(code); } if (code == strategy::buffer::result_no_output && n >= 1) { @@ -740,12 +742,7 @@ private: join_strategy, end_strategy, point_strategy, robust_policy); - if (code == strategy::buffer::result_error_numerical) - { - collection.abort_ring(); - return; - } - collection.finish_ring(is_interior); + collection.finish_ring(code, is_interior); } } @@ -805,14 +802,8 @@ public: join_strategy, end_strategy, point_strategy, robust_policy); - if (code == strategy::buffer::result_error_numerical) - { - collection.abort_ring(); - } - else - { - collection.finish_ring(false, geometry::num_interior_rings(polygon) > 0u); - } + collection.finish_ring(code, false, + geometry::num_interior_rings(polygon) > 0u); } apply_interior_rings(interior_rings(polygon), diff --git a/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp b/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp index 545d89cb9b..b580cf5b9b 100644 --- a/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -860,8 +860,15 @@ struct buffered_piece_collection m_robust_policy); } - inline void finish_ring(bool is_interior = false, bool has_interiors = false) + inline void finish_ring(strategy::buffer::result_code code, + bool is_interior = false, bool has_interiors = false) { + if (code == strategy::buffer::result_error_numerical) + { + abort_ring(); + return; + } + if (m_first_piece_index == -1) { return; @@ -1188,7 +1195,7 @@ struct buffered_piece_collection typename cs_tag::type >::type side_strategy_type; - enrich_intersection_points(m_turns, + enrich_intersection_points(m_turns, detail::overlay::operation_union, offsetted_rings, offsetted_rings, m_robust_policy, side_strategy_type()); diff --git a/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp b/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp index 19c91544ac..29a618b923 100644 --- a/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp +++ b/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp @@ -96,36 +96,36 @@ namespace traits template -struct tag > +struct tag > { typedef ring_tag type; }; template -struct point_order > +struct point_order > { static const order_selector value = geometry::point_order::value; }; template -struct closure > +struct closure > { static const closure_selector value = geometry::closure::value; }; template -struct point_type > +struct point_type > { typedef typename geometry::point_type::type type; }; template -struct tag > +struct tag > { - typedef detail::buffer::buffered_ring_collection_tag type; + typedef geometry::detail::buffer::buffered_ring_collection_tag type; }; diff --git a/boost/geometry/algorithms/detail/disjoint/box_box.hpp b/boost/geometry/algorithms/detail/disjoint/box_box.hpp index 84671f257e..6074af982b 100644 --- a/boost/geometry/algorithms/detail/disjoint/box_box.hpp +++ b/boost/geometry/algorithms/detail/disjoint/box_box.hpp @@ -1,12 +1,12 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. -// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013-2014. -// Modifications copyright (c) 2013-2014, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013-2015. +// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -36,7 +36,6 @@ namespace boost { namespace geometry namespace detail { namespace disjoint { - template < typename Box1, typename Box2, diff --git a/boost/geometry/algorithms/detail/disjoint/point_box.hpp b/boost/geometry/algorithms/detail/disjoint/point_box.hpp index 12213db056..73b7b70990 100644 --- a/boost/geometry/algorithms/detail/disjoint/point_box.hpp +++ b/boost/geometry/algorithms/detail/disjoint/point_box.hpp @@ -1,12 +1,12 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. -// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland -// This file was modified by Oracle on 2013-2014. -// Modifications copyright (c) 2013-2014, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013-2015. +// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -29,7 +29,6 @@ #include - namespace boost { namespace geometry { diff --git a/boost/geometry/algorithms/detail/distance/segment_to_box.hpp b/boost/geometry/algorithms/detail/distance/segment_to_box.hpp index 783699ee0a..fa95152476 100644 --- a/boost/geometry/algorithms/detail/distance/segment_to_box.hpp +++ b/boost/geometry/algorithms/detail/distance/segment_to_box.hpp @@ -562,11 +562,12 @@ private: // assert that the segment has non-negative slope BOOST_GEOMETRY_ASSERT( ( math::equals(geometry::get<0>(p0), geometry::get<0>(p1)) - && geometry::get<1>(p0) < geometry::get<1>(p1)) - || - ( geometry::get<0>(p0) < geometry::get<0>(p1) - && geometry::get<1>(p0) <= geometry::get<1>(p1) ) - ); + && geometry::get<1>(p0) < geometry::get<1>(p1)) + || + ( geometry::get<0>(p0) < geometry::get<0>(p1) + && geometry::get<1>(p0) <= geometry::get<1>(p1) ) + || geometry::has_nan_coordinate(p0) + || geometry::has_nan_coordinate(p1)); ReturnType result(0); @@ -617,8 +618,10 @@ private: typedef compare_less_equal greater_equal; // assert that the segment has negative slope - BOOST_GEOMETRY_ASSERT( geometry::get<0>(p0) < geometry::get<0>(p1) - && geometry::get<1>(p0) > geometry::get<1>(p1) ); + BOOST_GEOMETRY_ASSERT( ( geometry::get<0>(p0) < geometry::get<0>(p1) + && geometry::get<1>(p0) > geometry::get<1>(p1) ) + || geometry::has_nan_coordinate(p0) + || geometry::has_nan_coordinate(p1) ); ReturnType result(0); @@ -665,7 +668,9 @@ public: PPStrategy const& pp_strategy, PSStrategy const& ps_strategy) { - BOOST_GEOMETRY_ASSERT( geometry::less()(p0, p1) ); + BOOST_GEOMETRY_ASSERT( geometry::less()(p0, p1) + || geometry::has_nan_coordinate(p0) + || geometry::has_nan_coordinate(p1) ); if (geometry::get<0>(p0) < geometry::get<0>(p1) && geometry::get<1>(p0) > geometry::get<1>(p1)) diff --git a/boost/geometry/algorithms/detail/expand_by_epsilon.hpp b/boost/geometry/algorithms/detail/expand_by_epsilon.hpp new file mode 100644 index 0000000000..7af08ee371 --- /dev/null +++ b/boost/geometry/algorithms/detail/expand_by_epsilon.hpp @@ -0,0 +1,113 @@ +// Boost.Geometry + +// Copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Distributed under the 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_ALGORITHMS_DETAIL_EXPAND_EXPAND_BY_EPSILON_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_EXPAND_BY_EPSILON_HPP + +#include +#include + +#include + +#include +#include +#include + +#include + +#include + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace expand +{ + +template +< + typename Point, + template class PlusOrMinus, + std::size_t I = 0, + std::size_t D = dimension::value, + bool Enable = boost::is_floating_point + < + typename coordinate_type::type + >::value +> +struct corner_by_epsilon +{ + static inline void apply(Point & point) + { + typedef typename coordinate_type::type coord_type; + coord_type const coord = get(point); + coord_type const eps = math::scaled_epsilon(coord); + + set(point, PlusOrMinus()(coord, eps)); + + corner_by_epsilon::apply(point); + } +}; + +template +< + typename Point, + template class PlusOrMinus, + std::size_t I, + std::size_t D +> +struct corner_by_epsilon +{ + static inline void apply(Point const&) {} +}; + +template +< + typename Point, + template class PlusOrMinus, + std::size_t D, + bool Enable +> +struct corner_by_epsilon +{ + static inline void apply(Point const&) {} +}; + +template +< + typename Point, + template class PlusOrMinus, + std::size_t D +> +struct corner_by_epsilon +{ + static inline void apply(Point const&) {} +}; + +} // namespace expand + +template +inline void expand_by_epsilon(Box & box) +{ + typedef detail::indexed_point_view min_type; + min_type min_point(box); + expand::corner_by_epsilon::apply(min_point); + + typedef detail::indexed_point_view max_type; + max_type max_point(box); + expand::corner_by_epsilon::apply(max_point); +} + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_EXPAND_BY_EPSILON_HPP diff --git a/boost/geometry/algorithms/detail/is_simple/areal.hpp b/boost/geometry/algorithms/detail/is_simple/areal.hpp index 623632c44e..a2322e4831 100644 --- a/boost/geometry/algorithms/detail/is_simple/areal.hpp +++ b/boost/geometry/algorithms/detail/is_simple/areal.hpp @@ -40,11 +40,11 @@ struct is_simple_ring static inline bool apply(Ring const& ring) { simplicity_failure_policy policy; - return - !detail::is_valid::has_duplicates - < - Ring, geometry::closure::value - >::apply(ring, policy); + return ! boost::empty(ring) + && ! detail::is_valid::has_duplicates + < + Ring, geometry::closure::value + >::apply(ring, policy); } }; @@ -128,7 +128,7 @@ struct is_simple < typename boost::range_value::type >, - false // do not allow empty multi-polygon + true // allow empty multi-polygon >::apply(boost::begin(multipolygon), boost::end(multipolygon)); } }; diff --git a/boost/geometry/algorithms/detail/is_simple/linear.hpp b/boost/geometry/algorithms/detail/is_simple/linear.hpp index 0f77a49498..16d7b3a803 100644 --- a/boost/geometry/algorithms/detail/is_simple/linear.hpp +++ b/boost/geometry/algorithms/detail/is_simple/linear.hpp @@ -235,7 +235,8 @@ struct is_simple_linestring static inline bool apply(Linestring const& linestring) { simplicity_failure_policy policy; - return ! detail::is_valid::has_duplicates + return ! boost::empty(linestring) + && ! detail::is_valid::has_duplicates < Linestring, closed >::apply(linestring, policy) @@ -263,7 +264,7 @@ struct is_simple_multilinestring typename boost::range_value::type, false // do not compute self-intersections >, - false // do not allow empty multilinestring + true // allow empty multilinestring >::apply(boost::begin(multilinestring), boost::end(multilinestring)) ) diff --git a/boost/geometry/algorithms/detail/is_simple/multipoint.hpp b/boost/geometry/algorithms/detail/is_simple/multipoint.hpp index 71c9e6ba90..f9f43d1cdb 100644 --- a/boost/geometry/algorithms/detail/is_simple/multipoint.hpp +++ b/boost/geometry/algorithms/detail/is_simple/multipoint.hpp @@ -40,9 +40,9 @@ struct is_simple_multipoint { static inline bool apply(MultiPoint const& multipoint) { - if ( boost::size(multipoint) == 0 ) + if (boost::empty(multipoint)) { - return false; + return true; } MultiPoint mp(multipoint); diff --git a/boost/geometry/algorithms/detail/is_valid/box.hpp b/boost/geometry/algorithms/detail/is_valid/box.hpp index e7a67252ba..863ce625fe 100644 --- a/boost/geometry/algorithms/detail/is_valid/box.hpp +++ b/boost/geometry/algorithms/detail/is_valid/box.hpp @@ -20,6 +20,7 @@ #include #include +#include #include @@ -66,6 +67,20 @@ struct has_valid_corners } }; + +template +struct is_valid_box +{ + template + static inline bool apply(Box const& box, VisitPolicy& visitor) + { + return + ! has_invalid_coordinate::apply(box, visitor) + && + has_valid_corners::value>::apply(box, visitor); + } +}; + }} // namespace detail::is_valid #endif // DOXYGEN_NO_DETAIL @@ -85,7 +100,7 @@ namespace dispatch // Reference (for polygon validity): OGC 06-103r4 (6.1.11.1) template struct is_valid - : detail::is_valid::has_valid_corners::value> + : detail::is_valid::is_valid_box {}; diff --git a/boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp b/boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp new file mode 100644 index 0000000000..6e6823d62f --- /dev/null +++ b/boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp @@ -0,0 +1,151 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_INVALID_COORDINATE_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_INVALID_COORDINATE_HPP + +#include + +#include + +#include +#include + +#include + +#include +#include +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace is_valid +{ + +struct always_valid +{ + template + static inline bool apply(Geometry const&, VisitPolicy& visitor) + { + return ! visitor.template apply(); + } +}; + +struct point_has_invalid_coordinate +{ + template + static inline bool apply(Point const& point, VisitPolicy& visitor) + { + boost::ignore_unused(visitor); + + return + geometry::has_non_finite_coordinate(point) + ? + (! visitor.template apply()) + : + (! visitor.template apply()); + } + + template + static inline bool apply(Point const& point) + { + return geometry::has_non_finite_coordinate(point); + } +}; + +struct indexed_has_invalid_coordinate +{ + template + static inline bool apply(Geometry const& geometry, VisitPolicy& visitor) + { + geometry::detail::indexed_point_view p0(geometry); + geometry::detail::indexed_point_view p1(geometry); + + return point_has_invalid_coordinate::apply(p0, visitor) + || point_has_invalid_coordinate::apply(p1, visitor); + } +}; + + +struct range_has_invalid_coordinate +{ + struct point_has_valid_coordinates + { + template + static inline bool apply(Point const& point) + { + return ! point_has_invalid_coordinate::apply(point); + } + }; + + template + static inline bool apply(Geometry const& geometry, VisitPolicy& visitor) + { + boost::ignore_unused(visitor); + + bool const has_valid_coordinates = detail::check_iterator_range + < + point_has_valid_coordinates, + true // do not consider an empty range as problematic + >::apply(geometry::points_begin(geometry), + geometry::points_end(geometry)); + + return has_valid_coordinates + ? + (! visitor.template apply()) + : + (! visitor.template apply()); + } +}; + + +template +< + typename Geometry, + typename Tag = typename tag::type, + bool HasFloatingPointCoordinates = boost::is_floating_point + < + typename coordinate_type::type + >::value +> +struct has_invalid_coordinate + : range_has_invalid_coordinate +{}; + +template +struct has_invalid_coordinate + : always_valid +{}; + +template +struct has_invalid_coordinate + : point_has_invalid_coordinate +{}; + +template +struct has_invalid_coordinate + : indexed_has_invalid_coordinate +{}; + +template +struct has_invalid_coordinate + : indexed_has_invalid_coordinate +{}; + + +}} // namespace detail::is_valid +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_INVALID_COORDINATE_HPP diff --git a/boost/geometry/algorithms/detail/is_valid/linear.hpp b/boost/geometry/algorithms/detail/is_valid/linear.hpp index e30064faf0..a49e077237 100644 --- a/boost/geometry/algorithms/detail/is_valid/linear.hpp +++ b/boost/geometry/algorithms/detail/is_valid/linear.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -46,6 +47,11 @@ struct is_valid_linestring static inline bool apply(Linestring const& linestring, VisitPolicy& visitor) { + if (has_invalid_coordinate::apply(linestring, visitor)) + { + return false; + } + if (boost::size(linestring) < 2) { return visitor.template apply(); diff --git a/boost/geometry/algorithms/detail/is_valid/pointlike.hpp b/boost/geometry/algorithms/detail/is_valid/pointlike.hpp index e51ab74643..51035f7a73 100644 --- a/boost/geometry/algorithms/detail/is_valid/pointlike.hpp +++ b/boost/geometry/algorithms/detail/is_valid/pointlike.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -36,10 +37,13 @@ template struct is_valid { template - static inline bool apply(Point const&, VisitPolicy& visitor) + static inline bool apply(Point const& point, VisitPolicy& visitor) { boost::ignore_unused(visitor); - return visitor.template apply(); + return ! detail::is_valid::has_invalid_coordinate + < + Point + >::apply(point, visitor); } }; @@ -63,7 +67,10 @@ struct is_valid { // we allow empty multi-geometries, so an empty multipoint // is considered valid - return visitor.template apply(); + return ! detail::is_valid::has_invalid_coordinate + < + MultiPoint + >::apply(multipoint, visitor); } else { diff --git a/boost/geometry/algorithms/detail/is_valid/polygon.hpp b/boost/geometry/algorithms/detail/is_valid/polygon.hpp index 6e87273aa1..bbe8e8fc39 100644 --- a/boost/geometry/algorithms/detail/is_valid/polygon.hpp +++ b/boost/geometry/algorithms/detail/is_valid/polygon.hpp @@ -11,6 +11,9 @@ #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_POLYGON_HPP #include +#ifdef BOOST_GEOMETRY_TEST_DEBUG +#include +#endif // BOOST_GEOMETRY_TEST_DEBUG #include #include @@ -327,7 +330,9 @@ protected: g.add_edge(v2, vip); } +#ifdef BOOST_GEOMETRY_TEST_DEBUG debug_print_complement_graph(std::cout, g); +#endif // BOOST_GEOMETRY_TEST_DEBUG if (g.has_cycles()) { diff --git a/boost/geometry/algorithms/detail/is_valid/ring.hpp b/boost/geometry/algorithms/detail/is_valid/ring.hpp index c35e843418..925c03a472 100644 --- a/boost/geometry/algorithms/detail/is_valid/ring.hpp +++ b/boost/geometry/algorithms/detail/is_valid/ring.hpp @@ -30,8 +30,9 @@ #include #include #include -#include #include +#include +#include #include #include @@ -153,17 +154,23 @@ struct is_valid_ring static inline bool apply(Ring const& ring, VisitPolicy& visitor) { // return invalid if any of the following condition holds: - // (a) the ring's size is below the minimal one - // (b) the ring consists of at most two distinct points - // (c) the ring is not topologically closed - // (d) the ring has spikes - // (e) the ring has duplicate points (if AllowDuplicates is false) - // (f) the boundary of the ring has self-intersections - // (g) the order of the points is inconsistent with the defined order + // (a) the ring's point coordinates are not invalid (e.g., NaN) + // (b) the ring's size is below the minimal one + // (c) the ring consists of at most two distinct points + // (d) the ring is not topologically closed + // (e) the ring has spikes + // (f) the ring has duplicate points (if AllowDuplicates is false) + // (g) the boundary of the ring has self-intersections + // (h) the order of the points is inconsistent with the defined order // // Note: no need to check if the area is zero. If this is the // case, then the ring must have at least two spikes, which is - // checked by condition (c). + // checked by condition (d). + + if (has_invalid_coordinate::apply(ring, visitor)) + { + return false; + } closure_selector const closure = geometry::closure::value; typedef typename closeable_view::type view_type; diff --git a/boost/geometry/algorithms/detail/is_valid/segment.hpp b/boost/geometry/algorithms/detail/is_valid/segment.hpp index a93d2bfe9e..f92f73381f 100644 --- a/boost/geometry/algorithms/detail/is_valid/segment.hpp +++ b/boost/geometry/algorithms/detail/is_valid/segment.hpp @@ -19,7 +19,7 @@ #include #include #include - +#include #include @@ -53,7 +53,14 @@ struct is_valid detail::assign_point_from_index<0>(segment, p[0]); detail::assign_point_from_index<1>(segment, p[1]); - if(! geometry::equals(p[0], p[1])) + if (detail::is_valid::has_invalid_coordinate + < + Segment + >::apply(segment, visitor)) + { + return false; + } + else if (! geometry::equals(p[0], p[1])) { return visitor.template apply(); } diff --git a/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp b/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp index b1a25c9f5e..8cb37d6954 100644 --- a/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp +++ b/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp @@ -51,14 +51,14 @@ class liang_barsky private: typedef model::referring_segment segment_type; - template - inline bool check_edge(T const& p, T const& q, T& t1, T& t2) const + template + inline bool check_edge(CoordinateType const& p, CoordinateType const& q, CalcType& t1, CalcType& t2) const { bool visible = true; if(p < 0) { - T const r = q / p; + CalcType const r = static_cast(q) / p; if (r > t2) visible = false; else if (r > t1) @@ -66,7 +66,7 @@ private: } else if(p > 0) { - T const r = q / p; + CalcType const r = static_cast(q) / p; if (r < t1) visible = false; else if (r < t2) @@ -86,9 +86,10 @@ public: inline bool clip_segment(Box const& b, segment_type& s, bool& sp1_clipped, bool& sp2_clipped) const { typedef typename select_coordinate_type::type coordinate_type; + typedef typename select_most_precise::type calc_type; - coordinate_type t1 = 0; - coordinate_type t2 = 1; + calc_type t1 = 0; + calc_type t2 = 1; coordinate_type const dx = get<1, 0>(s) - get<0, 0>(s); coordinate_type const dy = get<1, 1>(s) - get<0, 1>(s); diff --git a/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp b/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp index 3f81c4dca9..bc84286241 100644 --- a/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp +++ b/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp @@ -26,7 +26,9 @@ #include #include +#include #include +#include #include #include #ifdef BOOST_GEOMETRY_DEBUG_ENRICH @@ -466,6 +468,7 @@ inline void create_map(TurnPoints const& turn_points, MappedVector& mapped_vecto template < bool Reverse1, bool Reverse2, + overlay_type OverlayType, typename TurnPoints, typename Geometry1, typename Geometry2, typename RobustPolicy, @@ -490,10 +493,9 @@ inline void enrich_intersection_points(TurnPoints& turn_points, std::vector > mapped_vector_type; - // DISCARD ALL UU - // #76 is the reason that this is necessary... - // With uu, at all points there is the risk that rings are being traversed twice or more. - // Without uu, all rings having only uu will be untouched and gathered by assemble + // Iterate through turns and discard uu + // and check if there are possible colocations + bool check_colocations = false; for (typename boost::range_iterator::type it = boost::begin(turn_points); it != boost::end(turn_points); @@ -501,14 +503,34 @@ inline void enrich_intersection_points(TurnPoints& turn_points, { if (it->both(detail::overlay::operation_union)) { + // Discard (necessary for a.o. #76). With uu, at all points there + // is the risk that rings are being traversed twice or more. + // Without uu, all rings having only uu will be untouched + // and gathered by assemble it->discarded = true; + check_colocations = true; } - if (it->both(detail::overlay::operation_none)) + else if (it->combination(detail::overlay::operation_union, + detail::overlay::operation_blocked)) + { + check_colocations = true; + } + else if (OverlayType == overlay_difference + && it->both(detail::overlay::operation_intersection)) + { + // For difference operation (u/u -> i/i) + check_colocations = true; + } + else if (it->both(detail::overlay::operation_none)) { it->discarded = true; } } + if (check_colocations) + { + detail::overlay::handle_colocations(turn_points); + } // Create a map of vectors of indexed operation-types to be able // to sort intersection points PER RING diff --git a/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp b/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp index b2c3836712..b9e48cdbfc 100644 --- a/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp +++ b/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -35,24 +36,6 @@ namespace boost { namespace geometry { -#if ! defined(BOOST_GEOMETRY_OVERLAY_NO_THROW) -class inconsistent_turns_exception : public geometry::exception -{ -public: - - inline inconsistent_turns_exception() {} - - virtual ~inconsistent_turns_exception() throw() - {} - - virtual char const* what() const throw() - { - return "Boost.Geometry Inconsistent Turns exception"; - } -}; -#endif - - #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace overlay { diff --git a/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp b/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp index 717f0b47a9..ac36c530bf 100644 --- a/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp +++ b/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp @@ -585,8 +585,8 @@ struct collinear : public base_turn_handler typename SidePolicy > static inline void apply( - Point1 const& , Point1 const& , Point1 const& , - Point2 const& , Point2 const& , Point2 const& , + Point1 const& , Point1 const& pj, Point1 const& pk, + Point2 const& , Point2 const& qj, Point2 const& qk, TurnInfo& ti, IntersectionInfo const& info, DirInfo const& dir_info, @@ -623,8 +623,30 @@ struct collinear : public base_turn_handler { ui_else_iu(product == 1, ti); } + + // Calculate remaining distance. If it continues collinearly it is + // measured until the end of the next segment + ti.operations[0].remaining_distance + = side_p == 0 + ? distance_measure(ti.point, pk) + : distance_measure(ti.point, pj); + ti.operations[1].remaining_distance + = side_q == 0 + ? distance_measure(ti.point, qk) + : distance_measure(ti.point, qj); } + template + static inline typename geometry::coordinate_type::type + distance_measure(Point1 const& a, Point2 const& b) + { + // TODO: use comparable distance for point-point instead - but that + // causes currently cycling include problems + typedef typename geometry::coordinate_type::type ctype; + ctype const dx = get<0>(a) - get<0>(b); + ctype const dy = get<1>(b) - get<1>(b); + return dx * dx + dy * dy; + } }; template diff --git a/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp b/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp index e4f8de42e1..ee0a93ae7e 100644 --- a/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp +++ b/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp @@ -23,9 +23,9 @@ namespace detail { namespace overlay { enum turn_position { position_middle, position_front, position_back }; -template +template struct turn_operation_linear - : public turn_operation + : public turn_operation { turn_operation_linear() : position(position_middle) diff --git a/boost/geometry/algorithms/detail/overlay/get_turns.hpp b/boost/geometry/algorithms/detail/overlay/get_turns.hpp index 098c7b5642..b2b97c0337 100644 --- a/boost/geometry/algorithms/detail/overlay/get_turns.hpp +++ b/boost/geometry/algorithms/detail/overlay/get_turns.hpp @@ -802,19 +802,19 @@ template ::type, typename TagBase2 = typename topological_tag_base::type> struct turn_operation_type { - typedef overlay::turn_operation type; + typedef overlay::turn_operation::type, SegmentRatio> type; }; template struct turn_operation_type { - typedef overlay::turn_operation_linear type; + typedef overlay::turn_operation_linear::type, SegmentRatio> type; }; template struct turn_operation_type { - typedef overlay::turn_operation_linear type; + typedef overlay::turn_operation_linear::type, SegmentRatio> type; }; }} // namespace detail::get_turns diff --git a/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp b/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp new file mode 100644 index 0000000000..6f332ddff2 --- /dev/null +++ b/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp @@ -0,0 +1,278 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2015 Barend Gehrels, 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_ALGORITHMS_DETAIL_OVERLAY_HANDLE_COLOCATIONS_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_HANDLE_COLOCATIONS_HPP + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#if defined(BOOST_GEOMETRY_DEBUG_HANDLE_COLOCATIONS) +# include +# include +# include +# define BOOST_GEOMETRY_DEBUG_IDENTIFIER +#endif + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace overlay +{ + +struct turn_operation_index +{ + turn_operation_index(signed_size_type ti = -1, + signed_size_type oi = -1) + : turn_index(ti) + , op_index(oi) + {} + + signed_size_type turn_index; + signed_size_type op_index; // basically only 0,1 +}; + + +template +struct less_by_fraction_and_type +{ + inline less_by_fraction_and_type(TurnPoints const& turn_points) + : m_turns(turn_points) + { + } + + inline bool operator()(turn_operation_index const& left, + turn_operation_index const& right) const + { + typedef typename boost::range_value::type turn_type; + typedef typename turn_type::turn_operation_type turn_operation_type; + + turn_type const& left_turn = m_turns[left.turn_index]; + turn_type const& right_turn = m_turns[right.turn_index]; + turn_operation_type const& left_op + = left_turn.operations[left.op_index]; + + turn_operation_type const& right_op + = right_turn.operations[right.op_index]; + + if (! (left_op.fraction == right_op.fraction)) + { + return left_op.fraction < right_op.fraction; + } + + turn_operation_type const& left_other_op + = left_turn.operations[1 - left.op_index]; + + turn_operation_type const& right_other_op + = right_turn.operations[1 - right.op_index]; + + // Fraction is the same, now sort on ring id, first outer ring, + // then interior rings + return left_other_op.seg_id < right_other_op.seg_id; + } + +private: + TurnPoints const& m_turns; +}; + +template +inline void handle_colocation_cluster(TurnPoints& turn_points, + segment_identifier const& current_ring_seg_id, + OperationVector const& vec) +{ + typedef typename boost::range_value::type turn_type; + typedef typename turn_type::turn_operation_type turn_operation_type; + + std::vector::const_iterator vit = vec.begin(); + + turn_type cluster_turn = turn_points[vit->turn_index]; + turn_operation_type cluster_op + = cluster_turn.operations[vit->op_index]; + segment_identifier cluster_other_id + = cluster_turn.operations[1 - vit->op_index].seg_id; + bool const discard_colocated + = cluster_turn.both(operation_union) + || cluster_turn.combination(operation_blocked, operation_union); + + for (++vit; vit != vec.end(); ++vit) + { + turn_operation_index const& toi = *vit; + turn_type& turn = turn_points[toi.turn_index]; + turn_operation_type const& op = turn.operations[toi.op_index]; + segment_identifier const& other_id + = turn.operations[1 - toi.op_index].seg_id; + + if (cluster_op.fraction == op.fraction) + { + // Two turns of current ring with same source are colocated, + // one is from exterior ring, one from interior ring + bool const colocated_ext_int + = cluster_other_id.multi_index == other_id.multi_index + && cluster_other_id.ring_index == -1 + && other_id.ring_index >= 0; + + // Turn of current interior ring with other interior ring + bool const touch_int_int + = current_ring_seg_id.ring_index >= 0 + && other_id.ring_index >= 0; + + if (discard_colocated && colocated_ext_int) + { + // If the two turns on this same segment are a + // colocation with two different segments on the + // other geometry, of the same polygon but with + // the outer (u/u or u/x) and the inner ring (non u/u), + // that turn with inner ring should be discarded + turn.discarded = true; + turn.colocated = true; + } + else if (cluster_turn.colocated + && touch_int_int + && turn.both(operation_intersection)) + { + // Two holes touch each other at a point where the + // exterior ring also touches + turn.discarded = true; + turn.colocated = true; + } + else if (OverlayType == overlay_difference + && turn.both(operation_intersection) + && colocated_ext_int) + { + // For difference (polygon inside out) we need to + // discard i/i instead, in case of colocations + turn.discarded = true; + turn.colocated = true; + } + } + else + { + // Not on same fraction on this segment + // assign for next potential cluster + cluster_turn = turn; + cluster_op = op; + cluster_other_id = other_id; + } + + } +} + + +// Checks colocated turns and flags combinations of uu/other, possibly a +// combination of a ring touching another geometry's interior ring which is +// tangential to the exterior ring + +// This function can be extended to replace handle_tangencies: at each +// colocation incoming and outgoing vectors should be inspected + +template +inline void handle_colocations(TurnPoints& turn_points) +{ + typedef std::map + < + segment_identifier, + std::vector + > map_type; + + // Create and fill map on segment-identifier Map is sorted on seg_id, + // meaning it is sorted on ring_identifier too. This means that exterior + // rings are handled first. If there is a colocation on the exterior ring, + // that information can be used for the interior ring too + map_type map; + + int index = 0; + for (typename boost::range_iterator::type + it = boost::begin(turn_points); + it != boost::end(turn_points); + ++it, ++index) + { + map[it->operations[0].seg_id].push_back(turn_operation_index(index, 0)); + map[it->operations[1].seg_id].push_back(turn_operation_index(index, 1)); + } + + // Check if there are multiple turns on one or more segments, + // if not then nothing is to be done + bool colocations = 0; + for (typename map_type::const_iterator it = map.begin(); + it != map.end(); + ++it) + { + if (it->second.size() > 1u) + { + colocations = true; + break; + } + } + + if (! colocations) + { + return; + } + + // Sort all vectors, per same segment + less_by_fraction_and_type less(turn_points); + for (typename map_type::iterator it = map.begin(); + it != map.end(); ++it) + { + std::sort(it->second.begin(), it->second.end(), less); + } + + for (typename map_type::const_iterator it = map.begin(); + it != map.end(); ++it) + { + if (it->second.size() > 1) + { + handle_colocation_cluster(turn_points, + it->first, it->second); + } + } + +#if defined(BOOST_GEOMETRY_DEBUG_HANDLE_COLOCATIONS) + std::cout << "*** Colocations " << map.size() << std::endl; + for (typename map_type::const_iterator it = map.begin(); + it != map.end(); ++it) + { + std::cout << it->first << std::endl; + for (std::vector::const_iterator vit + = it->second.begin(); vit != it->second.end(); ++vit) + { + turn_operation_index const& toi = *vit; + std::cout << geometry::wkt(turn_points[toi.turn_index].point) + << std::boolalpha + << " discarded=" << turn_points[toi.turn_index].discarded + << " colocated=" << turn_points[toi.turn_index].colocated + << " " << operation_char(turn_points[toi.turn_index].operations[0].operation) + << " " << turn_points[toi.turn_index].operations[0].seg_id + << " " << turn_points[toi.turn_index].operations[0].fraction + << " // " << operation_char(turn_points[toi.turn_index].operations[1].operation) + << " " << turn_points[toi.turn_index].operations[1].seg_id + << " " << turn_points[toi.turn_index].operations[1].fraction + << std::endl; + } + } +#endif // DEBUG + +} + + +}} // namespace detail::overlay +#endif //DOXYGEN_NO_DETAIL + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_HANDLE_COLOCATIONS_HPP diff --git a/boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp b/boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp new file mode 100644 index 0000000000..1486f94fbd --- /dev/null +++ b/boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp @@ -0,0 +1,38 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INCONSISTENT_TURNS_EXCEPTION_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INCONSISTENT_TURNS_EXCEPTION_HPP + +#if ! defined(BOOST_GEOMETRY_OVERLAY_NO_THROW) +#include + +namespace boost { namespace geometry +{ + +class inconsistent_turns_exception : public geometry::exception +{ +public: + + inline inconsistent_turns_exception() {} + + virtual ~inconsistent_turns_exception() throw() + {} + + virtual char const* what() const throw() + { + return "Boost.Geometry Inconsistent Turns exception"; + } +}; + +}} // boost::geometry + +#endif // BOOST_GEOMETRY_OVERLAY_NO_THROW + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INCONSISTENT_TURNS_EXCEPTION_HPP diff --git a/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp b/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp index dd041b0d7d..c62b7d2834 100644 --- a/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp +++ b/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp @@ -1,6 +1,11 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -39,19 +44,26 @@ struct intersection_box_box { typedef typename coordinate_type::type ct; - ct min1 = get(box1); - ct min2 = get(box2); ct max1 = get(box1); + ct min2 = get(box2); + + if (max1 < min2) + { + return false; + } + ct max2 = get(box2); + ct min1 = get(box1); - if (max1 < min2 || max2 < min1) + if (max2 < min1) { return false; } + // Set dimensions of output coordinate set(box_out, min1 < min2 ? min2 : min1); set(box_out, max1 > max2 ? max2 : max1); - + return intersection_box_box ::apply(box1, box2, robust_policy, box_out, strategy); } diff --git a/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp b/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp index af0731f5a9..59c8f6f1ff 100644 --- a/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp +++ b/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -175,21 +176,115 @@ template struct intersection_of_linestring_with_areal { #if defined(BOOST_GEOMETRY_DEBUG_FOLLOW) - template - static inline void debug_follow(Turn const& turn, Operation op, - int index) + template + static inline void debug_follow(Turn const& turn, Operation op, + int index) + { + std::cout << index + << " at " << op.seg_id + << " meth: " << method_char(turn.method) + << " op: " << operation_char(op.operation) + << " vis: " << visited_char(op.visited) + << " of: " << operation_char(turn.operations[0].operation) + << operation_char(turn.operations[1].operation) + << " " << geometry::wkt(turn.point) + << std::endl; + } + + template + static inline void debug_turn(Turn const& t, bool non_crossing) + { + std::cout << "checking turn @" + << geometry::wkt(t.point) + << "; " << method_char(t.method) + << ":" << operation_char(t.operations[0].operation) + << "/" << operation_char(t.operations[1].operation) + << "; non-crossing? " + << std::boolalpha << non_crossing << std::noboolalpha + << std::endl; + } +#endif + + class is_crossing_turn + { + // return true is the operation is intersection or blocked + template + static inline bool has_op_i_or_b(Turn const& t) { - std::cout << index - << " at " << op.seg_id - << " meth: " << method_char(turn.method) - << " op: " << operation_char(op.operation) - << " vis: " << visited_char(op.visited) - << " of: " << operation_char(turn.operations[0].operation) - << operation_char(turn.operations[1].operation) - << " " << geometry::wkt(turn.point) - << std::endl; + return + t.operations[Index].operation == overlay::operation_intersection + || + t.operations[Index].operation == overlay::operation_blocked; } + + template + static inline bool has_method_crosses(Turn const& t) + { + return t.method == overlay::method_crosses; + } + + template + static inline bool is_cc(Turn const& t) + { + return + (t.method == overlay::method_touch_interior + || + t.method == overlay::method_equal + || + t.method == overlay::method_collinear) + && + t.operations[0].operation == t.operations[1].operation + && + t.operations[0].operation == overlay::operation_continue + ; + } + + template + static inline bool has_i_or_b_ops(Turn const& t) + { + return + (t.method == overlay::method_touch + || + t.method == overlay::method_touch_interior + || + t.method == overlay::method_collinear) + && + t.operations[1].operation != t.operations[0].operation + && + (has_op_i_or_b<0>(t) || has_op_i_or_b<1>(t)); + } + + public: + template + static inline bool apply(Turn const& t) + { + bool const is_crossing + = has_method_crosses(t) || is_cc(t) || has_i_or_b_ops(t); +#if defined(BOOST_GEOMETRY_DEBUG_FOLLOW) + debug_turn(t, ! is_crossing); #endif + return is_crossing; + } + }; + + struct is_non_crossing_turn + { + template + static inline bool apply(Turn const& t) + { + return ! is_crossing_turn::apply(t); + } + }; + + template + static inline bool no_crossing_turns_or_empty(Turns const& turns) + { + return detail::check_iterator_range + < + is_non_crossing_turn, + true // allow an empty turns range + >::apply(boost::begin(turns), boost::end(turns)); + } template < @@ -212,7 +307,8 @@ struct intersection_of_linestring_with_areal LineStringOut, LineString, Areal, - OverlayType + OverlayType, + false // do not remove spikes for linear geometries > follower; typedef typename point_type::type point_type; @@ -231,7 +327,7 @@ struct intersection_of_linestring_with_areal detail::overlay::assign_null_policy >(linestring, areal, robust_policy, turns, policy); - if (turns.empty()) + if (no_crossing_turns_or_empty(turns)) { // No intersection points, it is either completely // inside (interior + borders) diff --git a/boost/geometry/algorithms/detail/overlay/overlay.hpp b/boost/geometry/algorithms/detail/overlay/overlay.hpp index baf9d4777d..6eb0b8864c 100644 --- a/boost/geometry/algorithms/detail/overlay/overlay.hpp +++ b/boost/geometry/algorithms/detail/overlay/overlay.hpp @@ -78,6 +78,11 @@ inline void get_ring_turn_info(TurnInfoMap& turn_info_map, && ! turn_info.both(operation_intersection) ; + if (! both_uu && turn_info.colocated) + { + skip = true; + } + for (typename boost::range_iterator::type op_it = boost::begin(turn_info.operations); op_it != boost::end(turn_info.operations); @@ -105,7 +110,7 @@ inline void get_ring_turn_info(TurnInfoMap& turn_info_map, template < - typename GeometryOut, overlay_type Direction, bool ReverseOut, + typename GeometryOut, overlay_type OverlayType, bool ReverseOut, typename Geometry1, typename Geometry2, typename OutputIterator > @@ -129,8 +134,8 @@ inline OutputIterator return_if_one_input_is_empty(Geometry1 const& geometry1, // Union: return either of them // Intersection: return nothing // Difference: return first of them - if (Direction == overlay_intersection - || (Direction == overlay_difference && geometry::is_empty(geometry1))) + if (OverlayType == overlay_intersection + || (OverlayType == overlay_difference && geometry::is_empty(geometry1))) { return out; } @@ -143,7 +148,7 @@ inline OutputIterator return_if_one_input_is_empty(Geometry1 const& geometry1, std::map empty; std::map all_of_one_of_them; - select_rings(geometry1, geometry2, empty, all_of_one_of_them); + select_rings(geometry1, geometry2, empty, all_of_one_of_them); ring_container_type rings; assign_parents(geometry1, geometry2, rings, all_of_one_of_them); return add_rings(all_of_one_of_them, geometry1, geometry2, rings, out); @@ -155,7 +160,7 @@ template typename Geometry1, typename Geometry2, bool Reverse1, bool Reverse2, bool ReverseOut, typename GeometryOut, - overlay_type Direction + overlay_type OverlayType > struct overlay { @@ -178,7 +183,7 @@ struct overlay { return return_if_one_input_is_empty < - GeometryOut, Direction, ReverseOut + GeometryOut, OverlayType, ReverseOut >(geometry1, geometry2, out); } @@ -211,8 +216,8 @@ std::cout << "get turns" << std::endl; std::cout << "enrich" << std::endl; #endif typename Strategy::side_strategy_type side_strategy; - geometry::enrich_intersection_points(turn_points, - Direction == overlay_union + geometry::enrich_intersection_points(turn_points, + OverlayType == overlay_union ? geometry::detail::overlay::operation_union : geometry::detail::overlay::operation_intersection, geometry1, geometry2, @@ -229,7 +234,7 @@ std::cout << "traverse" << std::endl; traverse::apply ( geometry1, geometry2, - Direction == overlay_union + OverlayType == overlay_union ? geometry::detail::overlay::operation_union : geometry::detail::overlay::operation_intersection, robust_policy, @@ -246,7 +251,7 @@ std::cout << "traverse" << std::endl; // Select all rings which are NOT touched by any intersection point std::map selected_ring_properties; - select_rings(geometry1, geometry2, turn_info_per_ring, + select_rings(geometry1, geometry2, turn_info_per_ring, selected_ring_properties); // Add rings created during traversal diff --git a/boost/geometry/algorithms/detail/overlay/traversal_info.hpp b/boost/geometry/algorithms/detail/overlay/traversal_info.hpp index 6ee32c17c0..8cabfb0d8d 100644 --- a/boost/geometry/algorithms/detail/overlay/traversal_info.hpp +++ b/boost/geometry/algorithms/detail/overlay/traversal_info.hpp @@ -25,7 +25,7 @@ namespace detail { namespace overlay template -struct traversal_turn_operation : public turn_operation +struct traversal_turn_operation : public turn_operation { enrichment_info enriched; visit_info visited; diff --git a/boost/geometry/algorithms/detail/overlay/traverse.hpp b/boost/geometry/algorithms/detail/overlay/traverse.hpp index 803a164711..45e15d13d0 100644 --- a/boost/geometry/algorithms/detail/overlay/traverse.hpp +++ b/boost/geometry/algorithms/detail/overlay/traverse.hpp @@ -174,7 +174,17 @@ inline bool select_next_ip(operation_type operation, { return false; } + bool has_tp = false; + + typedef typename std::iterator_traits + < + Iterator + >::value_type operation_type; + + typename operation_type::comparable_distance_type + max_remaining_distance = 0; + selected = boost::end(turn.operations); for (Iterator it = boost::begin(turn.operations); it != boost::end(turn.operations); @@ -206,10 +216,24 @@ inline bool select_next_ip(operation_type operation, ) ) { + if (it->operation == operation_continue) + { + max_remaining_distance = it->remaining_distance; + } selected = it; debug_traverse(turn, *it, " Candidate"); has_tp = true; } + + if (it->operation == operation_continue && has_tp) + { + if (it->remaining_distance > max_remaining_distance) + { + max_remaining_distance = it->remaining_distance; + selected = it; + debug_traverse(turn, *it, " Candidate override"); + } + } } if (has_tp) diff --git a/boost/geometry/algorithms/detail/overlay/turn_info.hpp b/boost/geometry/algorithms/detail/overlay/turn_info.hpp index 26669a4b1f..1ac77d5796 100644 --- a/boost/geometry/algorithms/detail/overlay/turn_info.hpp +++ b/boost/geometry/algorithms/detail/overlay/turn_info.hpp @@ -12,6 +12,7 @@ #include +#include #include namespace boost { namespace geometry @@ -54,15 +55,19 @@ enum method_type The class is to be included in the turn_info class, either direct or a derived or similar class with more (e.g. enrichment) information. */ -template +template struct turn_operation { operation_type operation; segment_identifier seg_id; SegmentRatio fraction; + typedef typename coordinate_type::type comparable_distance_type; + comparable_distance_type remaining_distance; + inline turn_operation() : operation(operation_none) + , remaining_distance(0) {} }; @@ -80,7 +85,7 @@ template < typename Point, typename SegmentRatio, - typename Operation = turn_operation, + typename Operation = turn_operation, typename Container = boost::array > struct turn_info @@ -93,6 +98,7 @@ struct turn_info method_type method; bool discarded; bool selectable_start; // Can be used as starting-turn in traverse + bool colocated; Container operations; @@ -101,6 +107,7 @@ struct turn_info : method(method_none) , discarded(false) , selectable_start(true) + , colocated(false) {} inline bool both(operation_type type) const diff --git a/boost/geometry/algorithms/detail/point_is_spike_or_equal.hpp b/boost/geometry/algorithms/detail/point_is_spike_or_equal.hpp index 9db1ef8e0c..399c8fbefc 100644 --- a/boost/geometry/algorithms/detail/point_is_spike_or_equal.hpp +++ b/boost/geometry/algorithms/detail/point_is_spike_or_equal.hpp @@ -1,9 +1,14 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2013 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2013 Mateusz Loskot, London, UK. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015 Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -12,8 +17,6 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_POINT_IS_EQUAL_OR_SPIKE_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_POINT_IS_EQUAL_OR_SPIKE_HPP -#include -#include #include #include #include @@ -28,6 +31,17 @@ namespace boost { namespace geometry namespace detail { +template +inline int sign_of_difference(Point1 const& point1, Point2 const& point2) +{ + return + math::equals(geometry::get(point1), geometry::get(point2)) + ? + 0 + : + (geometry::get(point1) > geometry::get(point2) ? 1 : -1); +} + // Checks if a point ("last_point") causes a spike w.r.t. // the specified two other points (segment_a, segment_b) // @@ -35,7 +49,9 @@ namespace detail // a lp b // // Above, lp generates a spike w.r.t. segment(a,b) -// So specify last point first, then (a,b) (this is unordered, so unintuitive) +// So specify last point first, then (a,b) +// The segment's orientation does matter: if lp is to the right of b +// no spike is reported template static inline bool point_is_spike_or_equal(Point1 const& last_point, Point2 const& segment_a, @@ -46,29 +62,21 @@ static inline bool point_is_spike_or_equal(Point1 const& last_point, typename cs_tag::type >::type side_strategy; - typedef Point1 vector_type; - int const side = side_strategy::apply(last_point, segment_a, segment_b); if (side == 0) { // Last point is collinear w.r.t previous segment. // Check if it is equal - vector_type diff1; - conversion::convert_point_to_point(last_point, diff1); - geometry::subtract_point(diff1, segment_b); - int const sgn_x1 = math::sign(geometry::get<0>(diff1)); - int const sgn_y1 = math::sign(geometry::get<1>(diff1)); + int const sgn_x1 = sign_of_difference<0>(last_point, segment_b); + int const sgn_y1 = sign_of_difference<1>(last_point, segment_b); if (sgn_x1 == 0 && sgn_y1 == 0) { return true; } // Check if it moves forward - vector_type diff2; - conversion::convert_point_to_point(segment_b, diff2); - geometry::subtract_point(diff2, segment_a); - int const sgn_x2 = math::sign(geometry::get<0>(diff2)); - int const sgn_y2 = math::sign(geometry::get<1>(diff2)); + int const sgn_x2 = sign_of_difference<0>(segment_b, segment_a); + int const sgn_y2 = sign_of_difference<1>(segment_b, segment_a); return sgn_x1 != sgn_x2 || sgn_y1 != sgn_y2; } diff --git a/boost/geometry/algorithms/detail/relate/areal_areal.hpp b/boost/geometry/algorithms/detail/relate/areal_areal.hpp index cc9c1b67ca..a74954326b 100644 --- a/boost/geometry/algorithms/detail/relate/areal_areal.hpp +++ b/boost/geometry/algorithms/detail/relate/areal_areal.hpp @@ -338,7 +338,7 @@ struct areal_areal template inline void per_turn(Turn const& turn) { - static const std::size_t other_op_id = (OpId + 1) % 2; + //static const std::size_t other_op_id = (OpId + 1) % 2; static const bool transpose_result = OpId != 0; overlay::operation_type const op = turn.operations[OpId].operation; @@ -357,11 +357,14 @@ struct areal_areal else if ( op == overlay::operation_intersection ) { // ignore i/i - if ( turn.operations[other_op_id].operation != overlay::operation_intersection ) + /*if ( turn.operations[other_op_id].operation != overlay::operation_intersection ) { - update(m_result); + // not correct e.g. for G1 touching G2 in a point where a hole is touching the exterior ring + // in this case 2 turns i/... and u/u will be generated for this IP + //update(m_result); + //update(m_result); - } + }*/ update(m_result); } @@ -473,8 +476,11 @@ struct areal_areal // ignore i/i if ( it->operations[other_op_id].operation != overlay::operation_intersection ) { - // already set in interrupt policy + // this was set in the interrupt policy but it was wrong + // also here it's wrong since it may be a fake entry point //update(result); + + // already set in interrupt policy //update(result); m_enter_detected = true; } @@ -523,6 +529,7 @@ struct areal_areal template static inline void update_enter(Result & result) { + update(result); update(result); update(result); } @@ -574,6 +581,7 @@ struct areal_areal , m_flags(0) { // check which relations must be analysed + // NOTE: 1 and 4 could probably be connected if ( ! may_update(m_result) ) { @@ -662,21 +670,12 @@ struct areal_areal if ( it->operations[0].operation == overlay::operation_intersection && it->operations[1].operation == overlay::operation_intersection ) { - // ignore exterior ring - if ( it->operations[OpId].seg_id.ring_index >= 0 ) - { - found_ii = true; - } + found_ii = true; } else if ( it->operations[0].operation == overlay::operation_union && it->operations[1].operation == overlay::operation_union ) { - // ignore if u/u is for holes - //if ( it->operations[OpId].seg_id.ring_index >= 0 - // && it->operations[other_id].seg_id.ring_index >= 0 ) - { - found_uu = true; - } + found_uu = true; } else // ignore { @@ -687,8 +686,11 @@ struct areal_areal // only i/i was generated for this ring if ( found_ii ) { - //update(m_result); - //update(m_result); + update(m_result); + m_flags |= 1; + + //update(m_result); + update(m_result); update(m_result); m_flags |= 4; diff --git a/boost/geometry/algorithms/detail/relate/boundary_checker.hpp b/boost/geometry/algorithms/detail/relate/boundary_checker.hpp index 9de1bacb7d..1a9a5a8fd7 100644 --- a/boost/geometry/algorithms/detail/relate/boundary_checker.hpp +++ b/boost/geometry/algorithms/detail/relate/boundary_checker.hpp @@ -17,6 +17,8 @@ #include +#include + namespace boost { namespace geometry { @@ -90,19 +92,43 @@ public: for ( multi_iterator it = boost::begin(geometry) ; it != boost::end(geometry) ; ++ it ) { + typename boost::range_reference::type + ls = *it; + // empty or point - no boundary - if ( boost::size(*it) < 2 ) + if (boost::size(ls) < 2) + { continue; + } - // linear ring or point - no boundary - if ( equals::equals_point_point(range::front(*it), range::back(*it)) ) - continue; + typedef typename boost::range_reference + < + typename boost::range_value::type const + >::type point_reference; + + point_reference front_pt = range::front(ls); + point_reference back_pt = range::back(ls); - boundary_points.push_back(range::front(*it)); - boundary_points.push_back(range::back(*it)); + // linear ring or point - no boundary + if (! equals::equals_point_point(front_pt, back_pt)) + { + // do not add points containing NaN coordinates + // because they cannot be reasonably compared, e.g. with MSVC + // an assertion failure is reported in std::equal_range() + if (! geometry::has_nan_coordinate(front_pt)) + { + boundary_points.push_back(front_pt); + } + if (! geometry::has_nan_coordinate(back_pt)) + { + boundary_points.push_back(back_pt); + } + } } - std::sort(boundary_points.begin(), boundary_points.end(), geometry::less()); + std::sort(boundary_points.begin(), + boundary_points.end(), + geometry::less()); is_filled = true; } diff --git a/boost/geometry/algorithms/detail/relate/topology_check.hpp b/boost/geometry/algorithms/detail/relate/topology_check.hpp index 98b857a488..caa8a3c22d 100644 --- a/boost/geometry/algorithms/detail/relate/topology_check.hpp +++ b/boost/geometry/algorithms/detail/relate/topology_check.hpp @@ -16,6 +16,8 @@ #include #include +#include + namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL @@ -106,20 +108,42 @@ struct topology_check typedef typename boost::range_iterator::type ls_iterator; for ( ls_iterator it = boost::begin(mls) ; it != boost::end(mls) ; ++it ) { - std::size_t count = boost::size(*it); + typename boost::range_reference::type + ls = *it; + + std::size_t count = boost::size(ls); - if ( count > 0 ) + if (count > 0) { has_interior = true; } - if ( count > 1 ) + if (count > 1) { + typedef typename boost::range_reference + < + typename boost::range_value::type const + >::type point_reference; + + point_reference front_pt = range::front(ls); + point_reference back_pt = range::back(ls); + // don't store boundaries of linear rings, this doesn't change anything - if ( ! equals::equals_point_point(range::front(*it), range::back(*it)) ) + if (! equals::equals_point_point(front_pt, back_pt)) { - endpoints.push_back(range::front(*it)); - endpoints.push_back(range::back(*it)); + // do not add points containing NaN coordinates + // because they cannot be reasonably compared, e.g. with MSVC + // an assertion failure is reported in std::equal_range() + // NOTE: currently ignoring_counter calling std::equal_range() + // is not used anywhere in the code, still it's safer this way + if (! geometry::has_nan_coordinate(front_pt)) + { + endpoints.push_back(front_pt); + } + if (! geometry::has_nan_coordinate(back_pt)) + { + endpoints.push_back(back_pt); + } } } } diff --git a/boost/geometry/algorithms/detail/relate/turns.hpp b/boost/geometry/algorithms/detail/relate/turns.hpp index d54948e1f5..09d74dec3a 100644 --- a/boost/geometry/algorithms/detail/relate/turns.hpp +++ b/boost/geometry/algorithms/detail/relate/turns.hpp @@ -128,8 +128,8 @@ struct get_turns template struct op_to_int { - template - inline int operator()(detail::overlay::turn_operation const& op) const + template + inline int operator()(Operation const& op) const { switch(op.operation) { diff --git a/boost/geometry/algorithms/detail/sections/section_functions.hpp b/boost/geometry/algorithms/detail/sections/section_functions.hpp index ba1cf931b2..7bc5c08046 100644 --- a/boost/geometry/algorithms/detail/sections/section_functions.hpp +++ b/boost/geometry/algorithms/detail/sections/section_functions.hpp @@ -2,6 +2,11 @@ // Copyright (c) 2015 Barend Gehrels, Amsterdam, the Netherlands. +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // 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) diff --git a/boost/geometry/algorithms/detail/sections/sectionalize.hpp b/boost/geometry/algorithms/detail/sections/sectionalize.hpp index 1ced394353..6443965e95 100644 --- a/boost/geometry/algorithms/detail/sections/sectionalize.hpp +++ b/boost/geometry/algorithms/detail/sections/sectionalize.hpp @@ -52,6 +52,8 @@ #include #include +#include + namespace boost { namespace geometry { @@ -599,19 +601,18 @@ inline void enlarge_sections(Sections& sections) // Reason: turns might, rarely, be missed otherwise (case: "buffer_mp1") // Drawback: not really, range is now completely inside the section. Section is a tiny bit too large, // which might cause (a small number) of more comparisons - // TODO: make dimension-agnostic + + // NOTE: above is old comment to the not used code expanding the Boxes by relaxed_epsilon(10) + + // Enlarge sections by scaled epsilon, this should be consistent with math::equals(). + // Points and Segments are equal-compared WRT machine epsilon, but Boxes aren't + // Enlarging Boxes ensures that they correspond to the bound objects, + // Segments in this case, since Sections are collections of Segments. for (typename boost::range_iterator::type it = boost::begin(sections); it != boost::end(sections); ++it) { - typedef typename boost::range_value::type section_type; - typedef typename section_type::box_type box_type; - typedef typename geometry::coordinate_type::type coordinate_type; - coordinate_type const reps = math::relaxed_epsilon(10.0); - geometry::set<0, 0>(it->bounding_box, geometry::get<0, 0>(it->bounding_box) - reps); - geometry::set<0, 1>(it->bounding_box, geometry::get<0, 1>(it->bounding_box) - reps); - geometry::set<1, 0>(it->bounding_box, geometry::get<1, 0>(it->bounding_box) + reps); - geometry::set<1, 1>(it->bounding_box, geometry::get<1, 1>(it->bounding_box) + reps); + detail::expand_by_epsilon(it->bounding_box); } } @@ -802,6 +803,8 @@ inline void sectionalize(Geometry const& geometry, Reverse, DimensionVector >::apply(geometry, robust_policy, sections, ring_id, max_count); + + detail::sectionalize::enlarge_sections(sections); } diff --git a/boost/geometry/algorithms/overlaps.hpp b/boost/geometry/algorithms/overlaps.hpp index 96310d6cb5..9b5abdb2a0 100644 --- a/boost/geometry/algorithms/overlaps.hpp +++ b/boost/geometry/algorithms/overlaps.hpp @@ -1,11 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -14,8 +16,6 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle - #ifndef BOOST_GEOMETRY_ALGORITHMS_OVERLAPS_HPP #define BOOST_GEOMETRY_ALGORITHMS_OVERLAPS_HPP @@ -31,6 +31,7 @@ #include #include + namespace boost { namespace geometry { @@ -83,6 +84,7 @@ struct box_box_loop { one_in_two = false; } + // Same other way round if (min2 < min1 || max2 > max1) { diff --git a/boost/geometry/algorithms/touches.hpp b/boost/geometry/algorithms/touches.hpp index d6f0df3c74..570c54797f 100644 --- a/boost/geometry/algorithms/touches.hpp +++ b/boost/geometry/algorithms/touches.hpp @@ -1,12 +1,14 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013, 2014. -// Modifications copyright (c) 2013, 2014, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014, 2015. +// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -15,8 +17,6 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle - #ifndef BOOST_GEOMETRY_ALGORITHMS_TOUCHES_HPP #define BOOST_GEOMETRY_ALGORITHMS_TOUCHES_HPP @@ -40,6 +40,7 @@ #include #include + namespace boost { namespace geometry { @@ -70,12 +71,12 @@ struct box_box_loop // TODO assert or exception? //BOOST_GEOMETRY_ASSERT(min1 <= max1 && min2 <= max2); - if ( max1 < min2 || max2 < min1 ) + if (max1 < min2 || max2 < min1) { return false; } - if ( max1 == min2 || max2 == min1 ) + if (max1 == min2 || max2 == min1) { touch = true; } @@ -385,6 +386,16 @@ struct touches template struct touches + : detail::relate::relate_impl + < + detail::de9im::static_mask_touches_type, + Areal1, + Areal2 + > +{}; + +template +struct touches : detail::touches::areal_areal {}; diff --git a/boost/geometry/algorithms/validity_failure_type.hpp b/boost/geometry/algorithms/validity_failure_type.hpp index 42de99c585..3fbf8027b4 100644 --- a/boost/geometry/algorithms/validity_failure_type.hpp +++ b/boost/geometry/algorithms/validity_failure_type.hpp @@ -78,7 +78,10 @@ enum validity_failure_type /// The top-right corner of the box is lexicographically smaller /// than its bottom-left corner /// (applies to boxes only) - failure_wrong_corner_order = 50 // for boxes + failure_wrong_corner_order = 50, // for boxes + /// The geometry has at least one point with an invalid coordinate + /// (for example, the coordinate is a NaN) + failure_invalid_coordinate = 60 }; diff --git a/boost/geometry/arithmetic/determinant.hpp b/boost/geometry/arithmetic/determinant.hpp index 14edea7182..a8e46ca9a0 100644 --- a/boost/geometry/arithmetic/determinant.hpp +++ b/boost/geometry/arithmetic/determinant.hpp @@ -18,6 +18,8 @@ #include #include +#include + namespace boost { namespace geometry { diff --git a/boost/geometry/core/exception.hpp b/boost/geometry/core/exception.hpp index 6868ca775a..21abbd577b 100644 --- a/boost/geometry/core/exception.hpp +++ b/boost/geometry/core/exception.hpp @@ -32,6 +32,7 @@ namespace boost { namespace geometry */ class exception : public std::exception { +public: virtual char const* what() const throw() { return "Boost.Geometry exception"; diff --git a/boost/geometry/index/detail/is_bounding_geometry.hpp b/boost/geometry/index/detail/is_bounding_geometry.hpp new file mode 100644 index 0000000000..d14204af71 --- /dev/null +++ b/boost/geometry/index/detail/is_bounding_geometry.hpp @@ -0,0 +1,35 @@ +// Boost.Geometry Index +// +// Copyright (c) 2011-2015 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_GEOMETRY_INDEX_DETAIL_IS_BOUNDING_GEOMETRY_HPP +#define BOOST_GEOMETRY_INDEX_DETAIL_IS_BOUNDING_GEOMETRY_HPP + +#include +#include + +namespace boost { namespace geometry { namespace index { namespace detail { + +template +< + typename Geometry, + typename Tag = typename geometry::tag::type +> +struct is_bounding_geometry +{ + static const bool value = false; +}; + +template +struct is_bounding_geometry +{ + static const bool value = true; +}; + +}}}} // namespave boost::geometry::index::detail + +#endif // BOOST_GEOMETRY_INDEX_DETAIL_IS_BOUNDING_GEOMETRY_HPP diff --git a/boost/geometry/index/detail/is_indexable.hpp b/boost/geometry/index/detail/is_indexable.hpp new file mode 100644 index 0000000000..1e86463a37 --- /dev/null +++ b/boost/geometry/index/detail/is_indexable.hpp @@ -0,0 +1,47 @@ +// Boost.Geometry Index +// +// Copyright (c) 2011-2015 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_GEOMETRY_INDEX_DETAIL_IS_INDEXABLE_HPP +#define BOOST_GEOMETRY_INDEX_DETAIL_IS_INDEXABLE_HPP + +#include +#include + +namespace boost { namespace geometry { namespace index { namespace detail { + +template +< + typename Geometry, + typename Tag = typename geometry::tag::type +> +struct is_indexable +{ + static const bool value = false; +}; + +template +struct is_indexable +{ + static const bool value = true; +}; + +template +struct is_indexable +{ + static const bool value = true; +}; + +template +struct is_indexable +{ + static const bool value = true; +}; + +}}}} // namespave boost::geometry::index::detail + +#endif // BOOST_GEOMETRY_INDEX_DETAIL_IS_INDEXABLE_HPP diff --git a/boost/geometry/index/detail/rtree/node/node.hpp b/boost/geometry/index/detail/rtree/node/node.hpp index b04744c85a..2b270319f6 100644 --- a/boost/geometry/index/detail/rtree/node/node.hpp +++ b/boost/geometry/index/detail/rtree/node/node.hpp @@ -34,6 +34,7 @@ #include #include +#include namespace boost { namespace geometry { namespace index { @@ -45,8 +46,16 @@ template inline Box elements_box(FwdIter first, FwdIter last, Translator const& tr) { Box result; + + // Only here to suppress 'uninitialized local variable used' warning + // until the suggestion below is not implemented + geometry::assign_inverse(result); - BOOST_GEOMETRY_INDEX_ASSERT(first != last, "non-empty range required"); + //BOOST_GEOMETRY_INDEX_ASSERT(first != last, "non-empty range required"); + // NOTE: this is not elegant temporary solution, + // reference to box could be passed as parameter and bool returned + if ( first == last ) + return result; detail::bounds(element_indexable(*first, tr), result); ++first; @@ -57,6 +66,35 @@ inline Box elements_box(FwdIter first, FwdIter last, Translator const& tr) return result; } +// Enlarge bounds of a leaf node WRT epsilon if needed. +// It's because Points and Segments are compared WRT machine epsilon. +// This ensures that leafs bounds correspond to the stored elements. +// NOTE: this is done only if the Indexable is not a Box +// in the future don't do it also for NSphere +template +inline Box values_box(FwdIter first, FwdIter last, Translator const& tr) +{ + typedef typename std::iterator_traits::value_type element_type; + BOOST_MPL_ASSERT_MSG((is_leaf_element::value), + SHOULD_BE_CALLED_ONLY_FOR_LEAF_ELEMENTS, + (element_type)); + + Box result = elements_box(first, last, tr); + +#ifdef BOOST_GEOMETRY_INDEX_EXPERIMENTAL_ENLARGE_BY_EPSILON + if (BOOST_GEOMETRY_CONDITION(( + ! is_bounding_geometry + < + typename indexable_type::type + >::value))) + { + geometry::detail::expand_by_epsilon(result); + } +#endif + + return result; +} + // destroys subtree if the element is internal node's element template struct destroy_element diff --git a/boost/geometry/index/detail/rtree/node/node_elements.hpp b/boost/geometry/index/detail/rtree/node/node_elements.hpp index e3bfb701f8..0e5848987e 100644 --- a/boost/geometry/index/detail/rtree/node/node_elements.hpp +++ b/boost/geometry/index/detail/rtree/node/node_elements.hpp @@ -2,7 +2,7 @@ // // R-tree node elements access // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -12,6 +12,7 @@ #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_ELEMENTS_HPP #include +#include #include #include @@ -36,6 +37,20 @@ struct element_indexable_type< typedef First type; }; +// is leaf element + +template +struct is_leaf_element +{ + static const bool value = true; +}; + +template +struct is_leaf_element< rtree::ptr_pair > +{ + static const bool value = false; +}; + // element's indexable getter template diff --git a/boost/geometry/index/detail/rtree/pack_create.hpp b/boost/geometry/index/detail/rtree/pack_create.hpp index ce07d293db..e56ce076d2 100644 --- a/boost/geometry/index/detail/rtree/pack_create.hpp +++ b/boost/geometry/index/detail/rtree/pack_create.hpp @@ -14,6 +14,8 @@ #include #include +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace pack_utils { @@ -214,6 +216,11 @@ private: } } + void expand_by_epsilon() + { + geometry::detail::expand_by_epsilon(m_box); + } + BoxType const& get() const { BOOST_GEOMETRY_INDEX_ASSERT(m_initialized, "uninitialized envelope accessed"); @@ -264,6 +271,23 @@ private: rtree::elements(l).push_back(*(first->second)); // MAY THROW (A?,C) } +#ifdef BOOST_GEOMETRY_INDEX_EXPERIMENTAL_ENLARGE_BY_EPSILON + // Enlarge bounds of a leaf node. + // It's because Points and Segments are compared WRT machine epsilon + // This ensures that leafs bounds correspond to the stored elements + // NOTE: this is done only if the Indexable is a different kind of Geometry + // than the bounds (only Box for now). Spatial predicates are checked + // the same way for Geometry of the same kind. + if ( BOOST_GEOMETRY_CONDITION(( + ! index::detail::is_bounding_geometry + < + typename indexable_type::type + >::value )) ) + { + elements_box.expand_by_epsilon(); + } +#endif + auto_remover.release(); return internal_element(elements_box.get(), n); } diff --git a/boost/geometry/index/detail/rtree/rstar/insert.hpp b/boost/geometry/index/detail/rtree/rstar/insert.hpp index ce92140872..127290194f 100644 --- a/boost/geometry/index/detail/rtree/rstar/insert.hpp +++ b/boost/geometry/index/detail/rtree/rstar/insert.hpp @@ -2,7 +2,7 @@ // // R-tree R*-tree insert algorithm implementation // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -231,16 +231,28 @@ struct level_insert_base } template - inline void recalculate_aabb_if_necessary(Node &n) const + inline void recalculate_aabb_if_necessary(Node const& n) const { if ( !result_elements.empty() && !base::m_traverse_data.current_is_root() ) { // calulate node's new box - base::m_traverse_data.current_element().first = - elements_box(rtree::elements(n).begin(), rtree::elements(n).end(), base::m_translator); + recalculate_aabb(n); } } + template + inline void recalculate_aabb(Node const& n) const + { + base::m_traverse_data.current_element().first = + elements_box(rtree::elements(n).begin(), rtree::elements(n).end(), base::m_translator); + } + + inline void recalculate_aabb(leaf const& n) const + { + base::m_traverse_data.current_element().first = + values_box(rtree::elements(n).begin(), rtree::elements(n).end(), base::m_translator); + } + size_type result_relative_level; result_elements_type result_elements; }; diff --git a/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp b/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp index d2caa36707..8e0560379b 100644 --- a/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp +++ b/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp @@ -2,7 +2,7 @@ // // R-tree boxes validating visitor implementation // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -60,13 +60,7 @@ public: m_box = box_bckup; m_is_root = is_root_bckup; - Box box_exp; - geometry::convert(elements.front().first, box_exp); - for( typename elements_type::const_iterator it = elements.begin() + 1; - it != elements.end() ; ++it) - { - geometry::expand(box_exp, it->first); - } + Box box_exp = rtree::elements_box(elements.begin(), elements.end(), m_tr); if ( m_exact_match ) result = m_is_root || geometry::equals(box_exp, m_box); @@ -88,15 +82,7 @@ public: return; } - Box box_exp; - geometry::convert( - index::detail::return_ref_or_bounds(m_tr(elements.front())), - box_exp); - for(typename elements_type::const_iterator it = elements.begin() + 1; - it != elements.end() ; ++it) - { - geometry::expand(box_exp, m_tr(*it)); - } + Box box_exp = rtree::values_box(elements.begin(), elements.end(), m_tr); if ( m_exact_match ) result = geometry::equals(box_exp, m_box); diff --git a/boost/geometry/index/detail/rtree/visitors/children_box.hpp b/boost/geometry/index/detail/rtree/visitors/children_box.hpp index 93726063b4..6c1bafd3de 100644 --- a/boost/geometry/index/detail/rtree/visitors/children_box.hpp +++ b/boost/geometry/index/detail/rtree/visitors/children_box.hpp @@ -2,7 +2,7 @@ // // R-tree node children box calculating visitor implementation // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -40,7 +40,7 @@ public: typedef typename rtree::elements_type::type elements_type; elements_type const& elements = rtree::elements(n); - m_result = rtree::elements_box(elements.begin(), elements.end(), m_tr); + m_result = rtree::values_box(elements.begin(), elements.end(), m_tr); } private: diff --git a/boost/geometry/index/detail/rtree/visitors/insert.hpp b/boost/geometry/index/detail/rtree/visitors/insert.hpp index e697c065e1..87d5bbbcca 100644 --- a/boost/geometry/index/detail/rtree/visitors/insert.hpp +++ b/boost/geometry/index/detail/rtree/visitors/insert.hpp @@ -11,6 +11,11 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_INSERT_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_INSERT_HPP +#include + +#include +#include + #include namespace boost { namespace geometry { namespace index { @@ -262,6 +267,29 @@ protected: BOOST_GEOMETRY_INDEX_ASSERT(0 != m_root_node, "there is no root node"); // TODO // assert - check if Box is correct + + // When a value is inserted, during the tree traversal bounds of nodes + // on a path from the root to a leaf must be expanded. So prepare + // a bounding object at the beginning to not do it later for each node. + // NOTE: This is actually only needed because conditionally the bounding + // object may be expanded below. Otherwise the indexable could be + // directly used instead + index::detail::bounds(rtree::element_indexable(m_element, m_translator), m_element_bounds); + +#ifdef BOOST_GEOMETRY_INDEX_EXPERIMENTAL_ENLARGE_BY_EPSILON + // Enlarge it in case if it's not bounding geometry type. + // It's because Points and Segments are compared WRT machine epsilon + // This ensures that leafs bounds correspond to the stored elements + if (BOOST_GEOMETRY_CONDITION(( + boost::is_same::value + && ! index::detail::is_bounding_geometry + < + typename indexable_type::type + >::value )) ) + { + geometry::detail::expand_by_epsilon(m_element_bounds); + } +#endif } template @@ -274,7 +302,8 @@ protected: // expand the node to contain value geometry::expand( rtree::elements(n)[choosen_node_index].first, - rtree::element_indexable(m_element, m_translator)); + m_element_bounds + /*rtree::element_indexable(m_element, m_translator)*/); // next traversing step traverse_apply_visitor(visitor, n, choosen_node_index); // MAY THROW (V, E: alloc, copy, N:alloc) @@ -342,6 +371,22 @@ protected: // for exception safety subtree_destroyer additional_node_ptr(additional_nodes[0].second, m_allocators); +#ifdef BOOST_GEOMETRY_INDEX_EXPERIMENTAL_ENLARGE_BY_EPSILON + // Enlarge bounds of a leaf node. + // It's because Points and Segments are compared WRT machine epsilon + // This ensures that leafs' bounds correspond to the stored elements. + if (BOOST_GEOMETRY_CONDITION(( + boost::is_same::value + && ! index::detail::is_bounding_geometry + < + typename indexable_type::type + >::value ))) + { + geometry::detail::expand_by_epsilon(n_box); + geometry::detail::expand_by_epsilon(additional_nodes[0].first); + } +#endif + // node is not the root - just add the new node if ( !m_traverse_data.current_is_root() ) { @@ -383,6 +428,7 @@ protected: // TODO: awulkiew - implement dispatchable split::apply to enable additional nodes creation Element const& m_element; + Box m_element_bounds; parameters_type const& m_parameters; Translator const& m_translator; size_type const m_relative_level; diff --git a/boost/geometry/index/detail/rtree/visitors/remove.hpp b/boost/geometry/index/detail/rtree/visitors/remove.hpp index 494d5a019e..6326f87db6 100644 --- a/boost/geometry/index/detail/rtree/visitors/remove.hpp +++ b/boost/geometry/index/detail/rtree/visitors/remove.hpp @@ -97,6 +97,9 @@ public: size_type relative_level = m_leafs_level - m_current_level; // move node to the container - store node's relative level as well and return new underflow state + // NOTE: if the min elements number is 1, then after an underflow + // here the child elements count is 0, so it's not required to store this node, + // it could just be destroyed m_is_underflow = store_underflowed_node(elements, underfl_el_it, relative_level); // MAY THROW (E: alloc, copy) } @@ -120,10 +123,16 @@ public: reinsert_removed_nodes_elements(); // MAY THROW (V, E: alloc, copy, N: alloc) // shorten the tree - if ( rtree::elements(n).size() == 1 ) + // NOTE: if the min elements number is 1, then after underflow + // here the number of elements may be equal to 0 + // this can occur only for the last removed element + if ( rtree::elements(n).size() <= 1 ) { node_pointer root_to_destroy = m_root_node; - m_root_node = rtree::elements(n)[0].second; + if ( rtree::elements(n).size() == 0 ) + m_root_node = 0; + else + m_root_node = rtree::elements(n)[0].second; --m_leafs_level; rtree::destroy_node::apply(m_allocators, root_to_destroy); @@ -161,7 +170,7 @@ public: if ( 0 != m_parent ) { rtree::elements(*m_parent)[m_current_child_index].first - = rtree::elements_box(elements.begin(), elements.end(), m_translator); + = rtree::values_box(elements.begin(), elements.end(), m_translator); } } } diff --git a/boost/geometry/index/indexable.hpp b/boost/geometry/index/indexable.hpp index 391b544f37..feaae557af 100644 --- a/boost/geometry/index/indexable.hpp +++ b/boost/geometry/index/indexable.hpp @@ -1,6 +1,6 @@ // Boost.Geometry Index // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -11,30 +11,9 @@ #include -namespace boost { namespace geometry { namespace index { namespace detail { - -template -struct is_indexable_impl { static const bool value = false; }; - -template -struct is_indexable_impl { static const bool value = true; }; - -template -struct is_indexable_impl { static const bool value = true; }; +#include -template -struct is_indexable_impl { static const bool value = true; }; - -template -struct is_indexable -{ - static const bool value = - is_indexable_impl - < - Indexable, - typename geometry::tag::type - >::value; -}; +namespace boost { namespace geometry { namespace index { namespace detail { /*! \brief The function object extracting Indexable from Value. diff --git a/boost/geometry/index/rtree.hpp b/boost/geometry/index/rtree.hpp index 84c4da8a2a..ea7fc74ed3 100644 --- a/boost/geometry/index/rtree.hpp +++ b/boost/geometry/index/rtree.hpp @@ -627,6 +627,9 @@ public: template inline void insert(ConvertibleOrRange const& conv_or_rng) { + if ( !m_members.root ) + this->raw_create(); + typedef boost::mpl::bool_ < boost::is_convertible::value @@ -657,6 +660,9 @@ public: */ inline size_type remove(value_type const& value) { + if ( !m_members.root ) + return 0; + return this->raw_remove(value); } @@ -687,6 +693,10 @@ public: inline size_type remove(Iterator first, Iterator last) { size_type result = 0; + + if ( !m_members.root ) + return result; + for ( ; first != last ; ++first ) result += this->raw_remove(*first); return result; @@ -716,6 +726,9 @@ public: template inline size_type remove(ConvertibleOrRange const& conv_or_rng) { + if ( !m_members.root ) + return 0; + typedef boost::mpl::bool_ < boost::is_convertible::value @@ -1279,6 +1292,9 @@ public: template size_type count(ValueOrIndexable const& vori) const { + if ( !m_members.root ) + return 0; + // the input should be convertible to Value or Indexable type enum { as_val = 0, as_ind, dont_know }; @@ -1570,9 +1586,6 @@ private: inline void insert_dispatch(ValueConvertible const& val_conv, boost::mpl::bool_ const& /*is_convertible*/) { - if ( !m_members.root ) - this->raw_create(); - this->raw_insert(val_conv); } @@ -1592,9 +1605,6 @@ private: PASSED_OBJECT_IS_NOT_CONVERTIBLE_TO_VALUE_NOR_A_RANGE, (Range)); - if ( !m_members.root ) - this->raw_create(); - typedef typename boost::range_const_iterator::type It; for ( It it = boost::const_begin(rng); it != boost::const_end(rng) ; ++it ) this->raw_insert(*it); @@ -1664,6 +1674,8 @@ private: template size_type query_dispatch(Predicates const& predicates, OutIter out_it, boost::mpl::bool_ const& /*is_distance_predicate*/) const { + BOOST_GEOMETRY_INDEX_ASSERT(m_members.root, "The root must exist"); + static const unsigned distance_predicate_index = detail::predicates_find_distance::value; detail::rtree::visitors::distance_query< value_type, @@ -1690,8 +1702,7 @@ private: template size_type raw_count(ValueOrIndexable const& vori) const { - if ( !m_members.root ) - return 0; + BOOST_GEOMETRY_INDEX_ASSERT(m_members.root, "The root must exist"); detail::rtree::visitors::count < diff --git a/boost/geometry/policies/is_valid/failing_reason_policy.hpp b/boost/geometry/policies/is_valid/failing_reason_policy.hpp index d1918adbda..bb28091d98 100644 --- a/boost/geometry/policies/is_valid/failing_reason_policy.hpp +++ b/boost/geometry/policies/is_valid/failing_reason_policy.hpp @@ -54,6 +54,8 @@ inline char const* validity_failure_type_message(validity_failure_type failure) return "Geometry has duplicate (consecutive) points"; case failure_wrong_corner_order: return "Box has corners in wrong order"; + case failure_invalid_coordinate: + return "Geometry has point(s) with invalid coordinate(s)"; default: // to avoid -Wreturn-type warning return ""; } diff --git a/boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp b/boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp index 99e7d9b50f..053723e4cc 100644 --- a/boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp +++ b/boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp @@ -308,7 +308,7 @@ public : namespace traits { template -struct point_type > +struct point_type > { typedef P type; }; diff --git a/boost/geometry/strategies/cartesian/box_in_box.hpp b/boost/geometry/strategies/cartesian/box_in_box.hpp index 9889658a13..56aef9e4df 100644 --- a/boost/geometry/strategies/cartesian/box_in_box.hpp +++ b/boost/geometry/strategies/cartesian/box_in_box.hpp @@ -1,9 +1,14 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -32,10 +37,10 @@ namespace within struct box_within_range { template - static inline bool apply(BoxContainedValue const& bed_min - , BoxContainedValue const& bed_max - , BoxContainingValue const& bing_min - , BoxContainingValue const& bing_max) + static inline bool apply(BoxContainedValue const& bed_min, + BoxContainedValue const& bed_max, + BoxContainingValue const& bing_min, + BoxContainingValue const& bing_max) { return bing_min <= bed_min && bed_max <= bing_max // contained in containing && bed_min < bed_max; // interiors overlap @@ -46,10 +51,10 @@ struct box_within_range struct box_covered_by_range { template - static inline bool apply(BoxContainedValue const& bed_min - , BoxContainedValue const& bed_max - , BoxContainingValue const& bing_min - , BoxContainingValue const& bing_max) + static inline bool apply(BoxContainedValue const& bed_min, + BoxContainedValue const& bed_max, + BoxContainingValue const& bing_min, + BoxContainingValue const& bing_max) { return bed_min >= bing_min && bed_max <= bing_max; } diff --git a/boost/geometry/strategies/cartesian/point_in_box.hpp b/boost/geometry/strategies/cartesian/point_in_box.hpp index 79f094113d..bd2303cbc4 100644 --- a/boost/geometry/strategies/cartesian/point_in_box.hpp +++ b/boost/geometry/strategies/cartesian/point_in_box.hpp @@ -1,8 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. diff --git a/boost/geometry/strategies/spherical/distance_cross_track_point_box.hpp b/boost/geometry/strategies/spherical/distance_cross_track_point_box.hpp index 14c5bd4eda..59be3645f5 100644 --- a/boost/geometry/strategies/spherical/distance_cross_track_point_box.hpp +++ b/boost/geometry/strategies/spherical/distance_cross_track_point_box.hpp @@ -161,7 +161,7 @@ public: } } - // Otherwise determine which αμονγ the two medirian segments of the + // Otherwise determine which among the two medirian segments of the // box the point is closest to, and compute the distance of // the point to this closest segment diff --git a/boost/geometry/strategies/transform/inverse_transformer.hpp b/boost/geometry/strategies/transform/inverse_transformer.hpp index 685cf874b8..e64a46e4a8 100644 --- a/boost/geometry/strategies/transform/inverse_transformer.hpp +++ b/boost/geometry/strategies/transform/inverse_transformer.hpp @@ -16,6 +16,9 @@ // Remove the ublas checking, otherwise the inverse might fail // (while nothing seems to be wrong) +#ifdef BOOST_UBLAS_TYPE_CHECK +#undef BOOST_UBLAS_TYPE_CHECK +#endif #define BOOST_UBLAS_TYPE_CHECK 0 #include diff --git a/boost/geometry/strategies/transform/matrix_transformers.hpp b/boost/geometry/strategies/transform/matrix_transformers.hpp index 699b91b3aa..d891263a7d 100644 --- a/boost/geometry/strategies/transform/matrix_transformers.hpp +++ b/boost/geometry/strategies/transform/matrix_transformers.hpp @@ -24,6 +24,9 @@ // Remove the ublas checking, otherwise the inverse might fail // (while nothing seems to be wrong) +#ifdef BOOST_UBLAS_TYPE_CHECK +#undef BOOST_UBLAS_TYPE_CHECK +#endif #define BOOST_UBLAS_TYPE_CHECK 0 #include diff --git a/boost/geometry/util/has_infinite_coordinate.hpp b/boost/geometry/util/has_infinite_coordinate.hpp new file mode 100644 index 0000000000..3f1d11a3b0 --- /dev/null +++ b/boost/geometry/util/has_infinite_coordinate.hpp @@ -0,0 +1,55 @@ +// Boost.Geometry + +// Copyright (c) 2015 Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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_UTIL_HAS_INFINITE_COORDINATE_HPP +#define BOOST_GEOMETRY_UTIL_HAS_INFINITE_COORDINATE_HPP + +#include + +#include +#include +#include + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +struct isinf +{ + template + static inline bool apply(T const& t) + { + return boost::math::isinf(t); + } +}; + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + +template +bool has_infinite_coordinate(Point const& point) +{ + return detail::has_coordinate_with_property + < + Point, + detail::isinf, + boost::is_floating_point + < + typename coordinate_type::type + >::value + >::apply(point); +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_UTIL_HAS_INFINITE_COORDINATE_HPP diff --git a/boost/geometry/util/has_nan_coordinate.hpp b/boost/geometry/util/has_nan_coordinate.hpp new file mode 100644 index 0000000000..93d7c7f035 --- /dev/null +++ b/boost/geometry/util/has_nan_coordinate.hpp @@ -0,0 +1,99 @@ +// Boost.Geometry + +// Copyright (c) 2015 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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_UTIL_HAS_NAN_COORDINATE_HPP +#define BOOST_GEOMETRY_UTIL_HAS_NAN_COORDINATE_HPP + +#include + +#include + +#include +#include +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +struct isnan +{ + template + static inline bool apply(T const& t) + { + return boost::math::isnan(t); + } +}; + +template +< + typename Point, + typename Predicate, + bool Enable, + std::size_t I = 0, + std::size_t N = geometry::dimension::value +> +struct has_coordinate_with_property +{ + static bool apply(Point const& point) + { + return Predicate::apply(geometry::get(point)) + || has_coordinate_with_property + < + Point, Predicate, Enable, I+1, N + >::apply(point); + } +}; + +template +struct has_coordinate_with_property +{ + static inline bool apply(Point const&) + { + return false; + } +}; + +template +struct has_coordinate_with_property +{ + static bool apply(Point const& ) + { + return false; + } +}; + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + +template +bool has_nan_coordinate(Point const& point) +{ + return detail::has_coordinate_with_property + < + Point, + detail::isnan, + boost::is_floating_point + < + typename coordinate_type::type + >::value + >::apply(point); +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_UTIL_HAS_NAN_COORDINATE_HPP diff --git a/boost/geometry/util/has_non_finite_coordinate.hpp b/boost/geometry/util/has_non_finite_coordinate.hpp new file mode 100644 index 0000000000..50075641ed --- /dev/null +++ b/boost/geometry/util/has_non_finite_coordinate.hpp @@ -0,0 +1,55 @@ +// Boost.Geometry + +// Copyright (c) 2015 Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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_UTIL_HAS_NON_FINITE_COORDINATE_HPP +#define BOOST_GEOMETRY_UTIL_HAS_NON_FINITE_COORDINATE_HPP + +#include + +#include +#include +#include + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +struct is_not_finite +{ + template + static inline bool apply(T const& t) + { + return ! boost::math::isfinite(t); + } +}; + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + +template +bool has_non_finite_coordinate(Point const& point) +{ + return detail::has_coordinate_with_property + < + Point, + detail::is_not_finite, + boost::is_floating_point + < + typename coordinate_type::type + >::value + >::apply(point); +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_UTIL_HAS_NON_FINITE_COORDINATE_HPP diff --git a/boost/geometry/util/math.hpp b/boost/geometry/util/math.hpp index d84b11f480..c193c8f3f1 100644 --- a/boost/geometry/util/math.hpp +++ b/boost/geometry/util/math.hpp @@ -201,11 +201,36 @@ struct smaller { static inline bool apply(Type const& a, Type const& b) { - if (equals::apply(a, b, equals_default_policy())) + if (!(a < b)) // a >= b { return false; } - return a < b; + + return ! equals::apply(b, a, equals_default_policy()); + } +}; + +template ::value> +struct smaller_or_equals +{ + static inline bool apply(Type const& a, Type const& b) + { + return a <= b; + } +}; + +template +struct smaller_or_equals +{ + static inline bool apply(Type const& a, Type const& b) + { + if (a <= b) + { + return true; + } + + return equals::apply(a, b, equals_default_policy()); } }; @@ -407,6 +432,30 @@ struct relaxed_epsilon } }; +// This must be consistent with math::equals. +// By default math::equals() scales the error by epsilon using the greater of +// compared values but here is only one value, though it should work the same way. +// (a-a) <= max(a, a) * EPS -> 0 <= a*EPS +// (a+da-a) <= max(a+da, a) * EPS -> da <= (a+da)*EPS +template ::value> +struct scaled_epsilon +{ + static inline T apply(T const& val) + { + return (std::max)(abs::apply(val), T(1)) + * std::numeric_limits::epsilon(); + } +}; + +template +struct scaled_epsilon +{ + static inline T apply(T const&) + { + return T(0); + } +}; + // ItoF ItoI FtoF template ::is_integer, @@ -460,6 +509,12 @@ inline T relaxed_epsilon(T const& factor) return detail::relaxed_epsilon::apply(factor); } +template +inline T scaled_epsilon(T const& value) +{ + return detail::scaled_epsilon::apply(value); +} + // Maybe replace this by boost equals or boost ublas numeric equals or so @@ -512,6 +567,24 @@ inline bool larger(T1 const& a, T2 const& b) >::apply(b, a); } +template +inline bool smaller_or_equals(T1 const& a, T2 const& b) +{ + return detail::smaller_or_equals + < + typename select_most_precise::type + >::apply(a, b); +} + +template +inline bool larger_or_equals(T1 const& a, T2 const& b) +{ + return detail::smaller_or_equals + < + typename select_most_precise::type + >::apply(b, a); +} + template inline T d2r() diff --git a/boost/heap/binomial_heap.hpp b/boost/heap/binomial_heap.hpp index 7e0760f4a2..01ccf3fc8d 100644 --- a/boost/heap/binomial_heap.hpp +++ b/boost/heap/binomial_heap.hpp @@ -404,8 +404,13 @@ public: binomial_heap children(value_comp(), element->children, sz); if (trees.empty()) { stability_counter_type stability_count = super_t::get_stability_count(); + size_t size = constant_time_size ? size_holder::get_size() + : 0; swap(children); super_t::set_stability_count(stability_count); + + if (constant_time_size) + size_holder::set_size( size ); } else merge_and_clear_nodes(children); diff --git a/boost/icl/concept/interval.hpp b/boost/icl/concept/interval.hpp index e350cc637d..487d424abd 100644 --- a/boost/icl/concept/interval.hpp +++ b/boost/icl/concept/interval.hpp @@ -455,7 +455,7 @@ enable_if< mpl::and_< mpl::or_, is_static_open , typename interval_traits::domain_type>::type last_next(const Type& object) { - typedef typename interval_traits::domain_type domain_type; + //CL typedef typename interval_traits::domain_type domain_type; return upper(object); // NOTE: last_next is implemented to avoid calling pred(object) } // For unsigned integral types this may cause underflow. @@ -1148,6 +1148,8 @@ left_subtract(Type right, const Type& left_minuend) { if(exclusive_less(left_minuend, right)) return right; + else if(upper_less_equal(right, left_minuend)) + return identity_element::value(); return construct(domain_next(upper(left_minuend)), upper(right)); } @@ -1175,7 +1177,7 @@ left_subtract(Type right, const Type& left_minuend) //- right_subtract ------------------------------------------------------------- /** subtract \c right_minuend from the \c left interval on it's right side. - Return the difference: The part of \c left right of \c right_minuend. + Return the difference: The part of \c left left of \c right_minuend. \code left_over = left - right_minuend; //on the right side. [a ... : left diff --git a/boost/icl/concept/interval_associator.hpp b/boost/icl/concept/interval_associator.hpp index 14d522eb3d..5ffbe6256b 100644 --- a/boost/icl/concept/interval_associator.hpp +++ b/boost/icl/concept/interval_associator.hpp @@ -121,7 +121,7 @@ typename enable_if cardinality(const Type& object) { typedef typename Type::size_type size_type; - typedef typename Type::interval_type interval_type; + //CL typedef typename Type::interval_type interval_type; size_type size = identity_element::value(); ICL_const_FORALL(typename Type, it, object) @@ -139,7 +139,7 @@ typename enable_if cardinality(const Type& object) { typedef typename Type::size_type size_type; - typedef typename Type::interval_type interval_type; + //CL typedef typename Type::interval_type interval_type; size_type size = identity_element::value(); size_type interval_size; diff --git a/boost/icl/concept/interval_associator_base.hpp b/boost/icl/concept/interval_associator_base.hpp index 00f187ac3a..f8b56e95cf 100644 --- a/boost/icl/concept/interval_associator_base.hpp +++ b/boost/icl/concept/interval_associator_base.hpp @@ -28,7 +28,7 @@ typename enable_if , typename Type::const_iterator>::type find(const Type& object, const typename domain_type_of::type& key_val) { - typedef typename Type::const_iterator const_iterator; + //CL typedef typename Type::const_iterator const_iterator; typedef typename Type::interval_type interval_type; return object.find(icl::detail::unit_trail(key_val)); } @@ -41,7 +41,7 @@ typename enable_if , typename Type::const_iterator>::type find(const Type& object, const typename domain_type_of::type& key_val) { - typedef typename Type::const_iterator const_iterator; + //CL typedef typename Type::const_iterator const_iterator; typedef typename Type::interval_type interval_type; return object.find(icl::singleton(key_val)); } diff --git a/boost/icl/concept/interval_map.hpp b/boost/icl/concept/interval_map.hpp index ac645b9038..58298d8042 100644 --- a/boost/icl/concept/interval_map.hpp +++ b/boost/icl/concept/interval_map.hpp @@ -306,7 +306,7 @@ typename enable_if, void>::type add_intersection(Type& section, const Type& object, const typename Type::element_type& operand) { - typedef typename Type::segment_type segment_type; + //CL typedef typename Type::segment_type segment_type; object.add_intersection(section, make_segment(operand)); } @@ -346,8 +346,8 @@ typename enable_if >::type add_intersection(Type& section, const Type& object, const MapT& operand) { - typedef typename Type::segment_type segment_type; - typedef typename Type::interval_type interval_type; + //CL typedef typename Type::segment_type segment_type; + //CL typedef typename Type::interval_type interval_type; typedef typename MapT::const_iterator const_iterator; if(operand.empty()) @@ -538,7 +538,7 @@ typename enable_if< mpl::and_< mpl::not_ > flip(Type& object, const OperandT& operand) { typedef typename OperandT::const_iterator const_iterator; - typedef typename Type::codomain_type codomain_type; + //CL typedef typename Type::codomain_type codomain_type; const_iterator common_lwb, common_upb; diff --git a/boost/icl/detail/concept_check.hpp b/boost/icl/detail/concept_check.hpp index e8ebb40553..5a37f5f25c 100644 --- a/boost/icl/detail/concept_check.hpp +++ b/boost/icl/detail/concept_check.hpp @@ -9,8 +9,8 @@ Copyright (c) 2009-2009: Joachim Faulhaber #define BOOST_ICL_CONCEPT_CHECK_HPP_JOFA_090913 #include -#include +#include namespace boost{ namespace icl { @@ -24,7 +24,7 @@ namespace boost{ namespace icl }; }}// namespace boost icl - +#include #endif diff --git a/boost/icl/detail/interval_set_algo.hpp b/boost/icl/detail/interval_set_algo.hpp index 8d557c7da4..1b8216a0a7 100644 --- a/boost/icl/detail/interval_set_algo.hpp +++ b/boost/icl/detail/interval_set_algo.hpp @@ -246,7 +246,7 @@ inline typename Type::iterator join_on_left(Type& object, typename Type::iterator& left_, typename Type::iterator& right_) { - typedef typename Type::interval_type interval_type; + //CL typedef typename Type::interval_type interval_type; // both left and right are in the set and they are neighbours BOOST_ASSERT(exclusive_less(key_value(left_), key_value(right_))); BOOST_ASSERT(joinable(object, left_, right_)); @@ -260,7 +260,7 @@ inline typename Type::iterator join_on_right(Type& object, typename Type::iterator& left_, typename Type::iterator& right_) { - typedef typename Type::interval_type interval_type; + //CL typedef typename Type::interval_type interval_type; // both left and right are in the map and they are neighbours BOOST_ASSERT(exclusive_less(key_value(left_), key_value(right_))); BOOST_ASSERT(joinable(object, left_, right_)); @@ -569,7 +569,7 @@ template typename Type::iterator add(Type& object, const typename Type::value_type& addend) { - typedef typename Type::interval_type interval_type; + //CL typedef typename Type::interval_type interval_type; typedef typename Type::iterator iterator; typedef typename on_style::type on_style_; @@ -590,7 +590,7 @@ typename Type::iterator add(Type& object, typename Type::iterator prior_, const typename Type::value_type& addend) { - typedef typename Type::interval_type interval_type; + //CL typedef typename Type::interval_type interval_type; typedef typename Type::iterator iterator; typedef typename on_style::type on_style_; @@ -614,7 +614,7 @@ void subtract(Type& object, const typename Type::value_type& minuend) { typedef typename Type::iterator iterator; typedef typename Type::interval_type interval_type; - typedef typename Type::value_type value_type; + //CL typedef typename Type::value_type value_type; if(icl::is_empty(minuend)) return; diff --git a/boost/icl/detail/subset_comparer.hpp b/boost/icl/detail/subset_comparer.hpp index 92b780411a..29f25a2240 100644 --- a/boost/icl/detail/subset_comparer.hpp +++ b/boost/icl/detail/subset_comparer.hpp @@ -119,8 +119,8 @@ public: int co_compare(LeftIterT& left, RightIterT& right) { using namespace boost::mpl; - typedef typename codomain_type_of::type LeftCodomainT; - typedef typename codomain_type_of::type RightCodomainT; + //CL typedef typename codomain_type_of::type LeftCodomainT; + //CL typedef typename codomain_type_of::type RightCodomainT; return if_< diff --git a/boost/icl/interval_base_map.hpp b/boost/icl/interval_base_map.hpp index 4de6962bcc..f61990b2d0 100644 --- a/boost/icl/interval_base_map.hpp +++ b/boost/icl/interval_base_map.hpp @@ -10,12 +10,11 @@ Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin #define BOOST_ICL_INTERVAL_BASE_MAP_HPP_JOFA_990223 #include -#include #include #include #include -#include +#include #include #include #include diff --git a/boost/icl/map.hpp b/boost/icl/map.hpp index af021da735..6f3c851098 100644 --- a/boost/icl/map.hpp +++ b/boost/icl/map.hpp @@ -22,7 +22,6 @@ Copyright (c) 2007-2011: Joachim Faulhaber #endif #include -#include #include #include #include diff --git a/boost/icl/type_traits/has_inverse.hpp b/boost/icl/type_traits/has_inverse.hpp index e73d7af594..fb7c612b6a 100644 --- a/boost/icl/type_traits/has_inverse.hpp +++ b/boost/icl/type_traits/has_inverse.hpp @@ -18,8 +18,8 @@ namespace boost{ namespace icl { typedef has_inverse type; BOOST_STATIC_CONSTANT(bool, - value = (type_traits::ice_or::value, - is_floating_point::value>::value)); + value = ( boost::is_signed::value + || is_floating_point::value ) ); }; }} // namespace boost icl diff --git a/boost/icl/type_traits/infinity.hpp b/boost/icl/type_traits/infinity.hpp index 3fe8e4dfcf..25ccb93a71 100644 --- a/boost/icl/type_traits/infinity.hpp +++ b/boost/icl/type_traits/infinity.hpp @@ -10,7 +10,6 @@ Copyright (c) 2010-2011: Joachim Faulhaber #include #include -#include #include #include #include @@ -24,10 +23,9 @@ template struct has_std_infinity { typedef has_std_infinity type; BOOST_STATIC_CONSTANT(bool, - value = (type_traits::ice_and - < is_numeric::value - , std::numeric_limits::has_infinity - >::value) + value = ( is_numeric::value + && std::numeric_limits::has_infinity + ) ); }; @@ -35,10 +33,9 @@ template struct has_max_infinity { typedef has_max_infinity type; BOOST_STATIC_CONSTANT(bool, - value = (type_traits::ice_and - < is_numeric::value - , type_traits::ice_not::has_infinity>::value - >::value) + value = ( is_numeric::value + && ! std::numeric_limits::has_infinity + ) ); }; diff --git a/boost/icl/type_traits/is_interval_separator.hpp b/boost/icl/type_traits/is_interval_separator.hpp index dedd246c6f..dd498269f7 100644 --- a/boost/icl/type_traits/is_interval_separator.hpp +++ b/boost/icl/type_traits/is_interval_separator.hpp @@ -8,6 +8,8 @@ Copyright (c) 2008-2009: Joachim Faulhaber #ifndef BOOST_ICL_TYPE_TRAITS_IS_INTERVAL_SEPARATOR_HPP_JOFA_081004 #define BOOST_ICL_TYPE_TRAITS_IS_INTERVAL_SEPARATOR_HPP_JOFA_081004 +#include + namespace boost{ namespace icl { template struct is_interval_separator diff --git a/boost/icl/type_traits/is_numeric.hpp b/boost/icl/type_traits/is_numeric.hpp index ff7f550744..9ecc3a16b8 100644 --- a/boost/icl/type_traits/is_numeric.hpp +++ b/boost/icl/type_traits/is_numeric.hpp @@ -12,7 +12,6 @@ Copyright (c) 2010-2010: Joachim Faulhaber #include #include #include -#include #include namespace boost{ namespace icl diff --git a/boost/interprocess/containers/pair.hpp b/boost/interprocess/containers/pair.hpp index 62a1453284..a6e11f49d0 100644 --- a/boost/interprocess/containers/pair.hpp +++ b/boost/interprocess/containers/pair.hpp @@ -27,7 +27,6 @@ namespace boost { namespace interprocess { using boost::container::container_detail::pair; -using boost::container::container_detail::piecewise_construct; } //namespace interprocess { } //namespace boost { diff --git a/boost/interprocess/detail/config_begin.hpp b/boost/interprocess/detail/config_begin.hpp index b1cf078e00..d003ccd314 100644 --- a/boost/interprocess/detail/config_begin.hpp +++ b/boost/interprocess/detail/config_begin.hpp @@ -43,3 +43,8 @@ #pragma warning (disable : 4671) // the copy constructor is inaccessible #pragma warning (disable : 4250) // inherits 'x' via dominance #endif + +#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif diff --git a/boost/interprocess/detail/config_end.hpp b/boost/interprocess/detail/config_end.hpp index 28ec407312..55bccd1bf1 100644 --- a/boost/interprocess/detail/config_end.hpp +++ b/boost/interprocess/detail/config_end.hpp @@ -11,3 +11,6 @@ #pragma warning (pop) #endif +#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) +#pragma GCC diagnostic pop +#endif diff --git a/boost/interprocess/detail/os_thread_functions.hpp b/boost/interprocess/detail/os_thread_functions.hpp index 8469862cc9..3ff0a402ba 100644 --- a/boost/interprocess/detail/os_thread_functions.hpp +++ b/boost/interprocess/detail/os_thread_functions.hpp @@ -77,7 +77,19 @@ namespace ipcdetail{ typedef unsigned long OS_process_id_t; typedef unsigned long OS_thread_id_t; -typedef void* OS_thread_t; +struct OS_thread_t +{ + OS_thread_t() + : m_handle() + {} + + + void* handle() const + { return m_handle; } + + void* m_handle; +}; + typedef OS_thread_id_t OS_systemwide_thread_id_t; //process @@ -495,18 +507,21 @@ inline int thread_create( OS_thread_t * thread, unsigned (__stdcall * start_rout void* h = (void*)_beginthreadex( 0, 0, start_routine, arg, 0, 0 ); if( h != 0 ){ - *thread = h; + thread->m_handle = h; return 0; } else{ return 1; } + + thread->m_handle = (void*)_beginthreadex( 0, 0, start_routine, arg, 0, 0 ); + return thread->m_handle != 0; } inline void thread_join( OS_thread_t thread) { - winapi::wait_for_single_object( thread, winapi::infinite_time ); - winapi::close_handle( thread ); + winapi::wait_for_single_object( thread.handle(), winapi::infinite_time ); + winapi::close_handle( thread.handle() ); } #endif diff --git a/boost/interprocess/detail/posix_time_types_wrk.hpp b/boost/interprocess/detail/posix_time_types_wrk.hpp index ba4973028f..5a12d83d76 100644 --- a/boost/interprocess/detail/posix_time_types_wrk.hpp +++ b/boost/interprocess/detail/posix_time_types_wrk.hpp @@ -28,8 +28,9 @@ #endif //#ifndef WIN32_LEAN_AND_MEAN #endif //#ifdef _WIN32 -#include -#include +#include +#include +#include namespace boost { namespace interprocess { diff --git a/boost/interprocess/detail/std_fwd.hpp b/boost/interprocess/detail/std_fwd.hpp index 098e67067c..282771c3e6 100644 --- a/boost/interprocess/detail/std_fwd.hpp +++ b/boost/interprocess/detail/std_fwd.hpp @@ -22,26 +22,8 @@ // Standard predeclarations ////////////////////////////////////////////////////////////////////////////// -#if defined(_LIBCPP_VERSION) - #define BOOST_INTERPROCESS_CLANG_INLINE_STD_NS - #pragma GCC diagnostic push - #if defined(__clang__) - #pragma GCC diagnostic ignored "-Wc++11-extensions" - #endif - #define BOOST_INTERPROCESS_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD - #define BOOST_INTERPROCESS_STD_NS_END _LIBCPP_END_NAMESPACE_STD -#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE_VERSION) //GCC >= 4.6 - #define BOOST_INTERPROCESS_STD_NS_BEG namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION - #define BOOST_INTERPROCESS_STD_NS_END _GLIBCXX_END_NAMESPACE_VERSION } // namespace -#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE) //GCC >= 4.2 - #define BOOST_INTERPROCESS_STD_NS_BEG _GLIBCXX_BEGIN_NAMESPACE(std) - #define BOOST_INTERPROCESS_STD_NS_END _GLIBCXX_END_NAMESPACE -#else - #define BOOST_INTERPROCESS_STD_NS_BEG namespace std{ - #define BOOST_INTERPROCESS_STD_NS_END } -#endif - -BOOST_INTERPROCESS_STD_NS_BEG +#include +BOOST_MOVE_STD_NS_BEG struct input_iterator_tag; struct forward_iterator_tag; @@ -51,17 +33,25 @@ struct random_access_iterator_tag; template struct char_traits; +#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1800) &&defined(BOOST_DINKUMWARE_STDLIB) +#define BOOST_INTERPROCESS_STD_FWD_MSVC_IOS_BUG +// Compiler bug workaround. Previous versions (<= VC11) +// used dummy virtual functions +# pragma vtordisp(push, 2) +#endif + template class basic_ostream; template class basic_istream; -BOOST_INTERPROCESS_STD_NS_END +#ifdef BOOST_INTERPROCESS_STD_FWD_MSVC_IOS_BUG +# pragma vtordisp(pop) +# undef BOOST_INTERPROCESS_STD_FWD_MSVC_IOS_BUG +#endif -#ifdef BOOST_INTERPROCESS_CLANG_INLINE_STD_NS - #pragma GCC diagnostic pop - #undef BOOST_INTERPROCESS_CLANG_INLINE_STD_NS -#endif //BOOST_INTERPROCESS_CLANG_INLINE_STD_NS +BOOST_MOVE_STD_NS_END +#include #endif //#ifndef BOOST_INTERPROCESS_DETAIL_STD_FWD_HPP diff --git a/boost/interprocess/detail/utilities.hpp b/boost/interprocess/detail/utilities.hpp index f1375d7361..7ff3def65b 100644 --- a/boost/interprocess/detail/utilities.hpp +++ b/boost/interprocess/detail/utilities.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace boost { @@ -156,27 +157,28 @@ inline bool size_overflows(SizeType count) } template -class pointer_size_t_caster +class pointer_uintptr_caster; + +template +class pointer_uintptr_caster { public: - BOOST_STATIC_ASSERT(sizeof(std::size_t) == sizeof(void*)); - - explicit pointer_size_t_caster(std::size_t sz) - : m_ptr(reinterpret_cast(sz)) + BOOST_FORCEINLINE explicit pointer_uintptr_caster(uintptr_t sz) + : m_uintptr(sz) {} - explicit pointer_size_t_caster(RawPointer p) - : m_ptr(p) + BOOST_FORCEINLINE explicit pointer_uintptr_caster(const volatile T *p) + : m_uintptr(reinterpret_cast(p)) {} - std::size_t size() const - { return reinterpret_cast(m_ptr); } + BOOST_FORCEINLINE uintptr_t uintptr() const + { return m_uintptr; } - RawPointer pointer() const - { return m_ptr; } + BOOST_FORCEINLINE T* pointer() const + { return reinterpret_cast(m_uintptr); } private: - RawPointer m_ptr; + uintptr_t m_uintptr; }; diff --git a/boost/interprocess/detail/win32_api.hpp b/boost/interprocess/detail/win32_api.hpp index b924341c32..0329b6dbe4 100644 --- a/boost/interprocess/detail/win32_api.hpp +++ b/boost/interprocess/detail/win32_api.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost +// (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 http://www.boost.org/LICENSE_1_0.txt) // @@ -33,8 +33,12 @@ #ifdef BOOST_USE_WINDOWS_H #include -#include -#include + +# if defined(BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME) +# include +# include +# endif + #include #endif @@ -43,8 +47,7 @@ # pragma comment( lib, "Advapi32.lib" ) # pragma comment( lib, "oleaut32.lib" ) # pragma comment( lib, "Ole32.lib" ) -# pragma comment( lib, "Psapi.lib" ) -# pragma comment( lib, "Shell32.lib" ) //SHGetSpecialFolderPathA +# pragma comment( lib, "Shell32.lib" ) //SHGetFolderPath #endif #if defined (BOOST_INTERPROCESS_WINDOWS) @@ -139,22 +142,6 @@ struct wchar_variant #pragma warning (pop) #endif - - - - - - - - - - - - - - - - struct IUnknown_BIPC { public: @@ -648,6 +635,8 @@ typedef int (__stdcall *farproc_t)(); typedef GUID GUID_BIPC; typedef VARIANT wchar_variant; +#if defined(BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME) + typedef IUnknown IUnknown_BIPC; typedef IWbemClassObject IWbemClassObject_BIPC; @@ -660,6 +649,8 @@ typedef IWbemServices IWbemServices_BIPC; typedef IWbemLocator IWbemLocator_BIPC; +#endif + typedef OVERLAPPED interprocess_overlapped; typedef FILETIME interprocess_filetime; @@ -1412,13 +1403,13 @@ inline bool get_file_information_by_handle(void *hnd, interprocess_by_handle_fil { return 0 != GetFileInformationByHandle(hnd, info); } inline long interlocked_increment(long volatile *addr) -{ return BOOST_INTERLOCKED_INCREMENT(addr); } +{ return BOOST_INTERLOCKED_INCREMENT(const_cast(addr)); } inline long interlocked_decrement(long volatile *addr) -{ return BOOST_INTERLOCKED_DECREMENT(addr); } +{ return BOOST_INTERLOCKED_DECREMENT(const_cast(addr)); } inline long interlocked_compare_exchange(long volatile *addr, long val1, long val2) -{ return BOOST_INTERLOCKED_COMPARE_EXCHANGE(addr, val1, val2); } +{ return BOOST_INTERLOCKED_COMPARE_EXCHANGE(const_cast(addr), val1, val2); } inline long interlocked_exchange_add(long volatile* addend, long value) { return BOOST_INTERLOCKED_EXCHANGE_ADD(const_cast(addend), value); } @@ -1964,7 +1955,7 @@ inline void get_shared_documents_folder(std::string &s) (void)err; } } - #else //registry alternative: SHGetSpecialFolderPathA + #else //registry alternative: SHGetFolderPath const int BIPC_CSIDL_COMMON_APPDATA = 0x0023; // All Users\Application Data const int BIPC_CSIDL_FLAG_CREATE = 0x8000; // new for Win2K, or this in to force creation of folder const int BIPC_SHGFP_TYPE_CURRENT = 0; // current value for user, verify it exists @@ -2007,6 +1998,8 @@ inline void get_registry_value(const char *folder, const char *value_key, std::v } } +#if defined(BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME) + struct co_uninitializer { co_uninitializer(bool b_uninitialize) @@ -2147,8 +2140,6 @@ inline bool get_wmi_class_attribute( std::wstring& strValue, const wchar_t *wmi_ return bRet; } -#ifdef BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME - //Obtains the bootup time from WMI LastBootUpTime. //This time seems to change with hibernation and clock synchronization so avoid it. inline bool get_last_bootup_time( std::wstring& strValue ) diff --git a/boost/interprocess/detail/workaround.hpp b/boost/interprocess/detail/workaround.hpp index daf4455be5..d7e86f464d 100644 --- a/boost/interprocess/detail/workaround.hpp +++ b/boost/interprocess/detail/workaround.hpp @@ -187,6 +187,9 @@ //Macros for documentation purposes. For code, expands to the argument #define BOOST_INTERPROCESS_IMPDEF(TYPE) TYPE #define BOOST_INTERPROCESS_SEEDOC(TYPE) TYPE +#define BOOST_INTERPROCESS_DOC1ST(TYPE1, TYPE2) TYPE2 +#define BOOST_INTERPROCESS_I , +#define BOOST_INTERPROCESS_DOCIGN(T1) T1 #include diff --git a/boost/interprocess/interprocess_fwd.hpp b/boost/interprocess/interprocess_fwd.hpp index 14b7c2ba96..882256e934 100644 --- a/boost/interprocess/interprocess_fwd.hpp +++ b/boost/interprocess/interprocess_fwd.hpp @@ -14,6 +14,9 @@ #ifndef BOOST_CONFIG_HPP # include #endif +#ifndef BOOST_CSTDINT_HPP +# include +#endif # #if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once @@ -238,8 +241,16 @@ class cached_adaptive_pool; static const std::size_t offset_type_alignment = 0; +#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) +# ifdef BOOST_HAS_INTPTR_T + using ::boost::uintptr_t; +# else + typedef std::size_t uintptr_t; +# endif +#endif + template < class T, class DifferenceType = std::ptrdiff_t - , class OffsetType = std::size_t, std::size_t Alignment = offset_type_alignment> + , class OffsetType = uintptr_t, std::size_t Alignment = offset_type_alignment> class offset_ptr; ////////////////////////////////////////////////////////////////////////////// diff --git a/boost/interprocess/mapped_region.hpp b/boost/interprocess/mapped_region.hpp index 912b490900..e5eee0bf79 100644 --- a/boost/interprocess/mapped_region.hpp +++ b/boost/interprocess/mapped_region.hpp @@ -523,8 +523,8 @@ inline bool mapped_region::flush(std::size_t mapping_offset, std::size_t numbyte inline bool mapped_region::shrink_by(std::size_t bytes, bool from_back) { - void *shrink_page_start; - std::size_t shrink_page_bytes; + void *shrink_page_start = 0; + std::size_t shrink_page_bytes = 0; if(!this->priv_shrink_param_check(bytes, from_back, shrink_page_start, shrink_page_bytes)){ return false; } diff --git a/boost/interprocess/offset_ptr.hpp b/boost/interprocess/offset_ptr.hpp index dca55668b6..622b3cd6e3 100644 --- a/boost/interprocess/offset_ptr.hpp +++ b/boost/interprocess/offset_ptr.hpp @@ -52,14 +52,17 @@ namespace ipcdetail { template union offset_ptr_internal { + BOOST_STATIC_ASSERT(sizeof(OffsetType) >= sizeof(uintptr_t)); + explicit offset_ptr_internal(OffsetType off) : m_offset(off) {} + OffsetType m_offset; //Distance between this object and pointee address + typename ::boost::container::container_detail::aligned_storage - < sizeof(OffsetType) - , (OffsetAlignment == offset_type_alignment) ? - ::boost::container::container_detail::alignment_of::value : OffsetAlignment + < sizeof(OffsetType)//for offset_type_alignment m_offset will be enough + , (OffsetAlignment == offset_type_alignment) ? 1u : OffsetAlignment >::type alignment_helper; }; @@ -75,138 +78,92 @@ namespace ipcdetail { // offset_ptr_to_raw_pointer // //////////////////////////////////////////////////////////////////////// - #define BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR - #if defined(_MSC_VER) && (_MSC_VER >= 1800) && (defined(_M_AMD64) || defined(_M_X64)) - //Visual 2013 x64 optimizes more than we desire, so disable branchless option - #else - #define BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR - #endif - template - #ifndef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR - BOOST_NOINLINE - #elif defined(NDEBUG) - inline - #endif - void * offset_ptr_to_raw_pointer(const volatile void *this_ptr, std::size_t offset) + #define BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR + BOOST_FORCEINLINE void * offset_ptr_to_raw_pointer(const volatile void *this_ptr, uintptr_t offset) { - typedef pointer_size_t_caster caster_t; + typedef pointer_uintptr_caster caster_t; #ifndef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR if(offset == 1){ return 0; } else{ - const caster_t caster((void*)this_ptr); - return caster_t(caster.size() + offset).pointer(); + return caster_t(caster_t(this_ptr).uintptr() + offset).pointer(); } #else - const caster_t caster((void*)this_ptr); - std::size_t target_offset = caster.size() + offset; - std::size_t mask = -std::size_t(offset != 1); + uintptr_t mask = offset == 1; + --mask; + uintptr_t target_offset = caster_t(this_ptr).uintptr() + offset; target_offset &= mask; return caster_t(target_offset).pointer(); #endif } - #ifdef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR - #undef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_PTR - #endif - #ifdef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR - #undef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR - #endif - //////////////////////////////////////////////////////////////////////// // // offset_ptr_to_offset // //////////////////////////////////////////////////////////////////////// - #define BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF - //Branchless seems slower in x86 #define BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF - - template - #ifndef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF - BOOST_NOINLINE - #elif defined(NDEBUG) - inline - #endif - std::size_t offset_ptr_to_offset(const volatile void *ptr, const volatile void *this_ptr) + BOOST_FORCEINLINE uintptr_t offset_ptr_to_offset(const volatile void *ptr, const volatile void *this_ptr) { - typedef pointer_size_t_caster caster_t; + typedef pointer_uintptr_caster caster_t; #ifndef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF //offset == 1 && ptr != 0 is not legal for this pointer if(!ptr){ return 1; } else{ - const caster_t this_caster((void*)this_ptr); - const caster_t ptr_caster((void*)ptr); - std::size_t offset = ptr_caster.size() - this_caster.size(); + uintptr_t offset = caster_t(ptr).uintptr() - caster_t(this_ptr).uintptr(); BOOST_ASSERT(offset != 1); return offset; } #else - const caster_t this_caster((void*)this_ptr); - const caster_t ptr_caster((void*)ptr); - //std::size_t other = -std::size_t(ptr != 0); - //std::size_t offset = (ptr_caster.size() - this_caster.size()) & other; - //return offset + !other; + //const uintptr_t other = -uintptr_t(ptr != 0); + //const uintptr_t offset = (caster_t(ptr).uintptr() - caster_t(this_ptr).uintptr()) & other; + //return offset + uintptr_t(!other); // - std::size_t offset = (ptr_caster.size() - this_caster.size() - 1) & -std::size_t(ptr != 0); + uintptr_t offset = caster_t(ptr).uintptr() - caster_t(this_ptr).uintptr(); + --offset; + uintptr_t mask = uintptr_t(ptr == 0); + --mask; + offset &= mask; return ++offset; #endif } - #ifdef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF - #undef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF - #endif - #ifdef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF - #undef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF - #endif - //////////////////////////////////////////////////////////////////////// // // offset_ptr_to_offset_from_other // //////////////////////////////////////////////////////////////////////// - #define BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER - //Branchless seems slower in x86 #define BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF_FROM_OTHER - - template - #ifndef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER - BOOST_NOINLINE - #elif defined(NDEBUG) - inline - #endif - std::size_t offset_ptr_to_offset_from_other - (const volatile void *this_ptr, const volatile void *other_ptr, std::size_t other_offset) + BOOST_FORCEINLINE uintptr_t offset_ptr_to_offset_from_other + (const volatile void *this_ptr, const volatile void *other_ptr, uintptr_t other_offset) { - typedef pointer_size_t_caster caster_t; + typedef pointer_uintptr_caster caster_t; #ifndef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF_FROM_OTHER if(other_offset == 1){ return 1; } else{ - const caster_t this_caster((void*)this_ptr); - const caster_t other_caster((void*)other_ptr); - std::size_t offset = other_caster.size() - this_caster.size() + other_offset; + uintptr_t offset = caster_t(other_ptr).uintptr() - caster_t(this_ptr).uintptr() + other_offset; BOOST_ASSERT(offset != 1); return offset; } #else - const caster_t this_caster((void*)this_ptr); - const caster_t other_caster((void*)other_ptr); - return ((other_caster.size() - this_caster.size()) & -std::size_t(other_offset != 1)) + other_offset; + uintptr_t mask = other_offset == 1; + --mask; + uintptr_t offset = caster_t(other_ptr).uintptr() - caster_t(this_ptr).uintptr(); + offset &= mask; + return offset + other_offset; + + //uintptr_t mask = -uintptr_t(other_offset != 1); + //uintptr_t offset = caster_t(other_ptr).uintptr() - caster_t(this_ptr).uintptr(); + //offset &= mask; + //return offset + other_offset; #endif } - #ifdef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER - #undef BOOST_INTERPROCESS_OFFSET_PTR_INLINE_TO_OFF_FROM_OTHER - #endif - #ifdef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF_FROM_OTHER - #undef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF_FROM_OTHER - #endif - //////////////////////////////////////////////////////////////////////// // // Let's assume cast to void and cv cast don't change any target address @@ -216,15 +173,31 @@ namespace ipcdetail { struct offset_ptr_maintains_address { static const bool value = ipcdetail::is_cv_same::value - || ipcdetail::is_cv_same::value; + || ipcdetail::is_cv_same::value + || ipcdetail::is_cv_same::value + ; }; + template + struct enable_if_convertible_equal_address + : enable_if_c< is_convertible::value + && offset_ptr_maintains_address::value + , Ret> + {}; + + template + struct enable_if_convertible_unequal_address + : enable_if_c< is_convertible::value + && !offset_ptr_maintains_address::value + , Ret> + {}; + } //namespace ipcdetail { #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED //!A smart pointer that stores the offset between between the pointer and the //!the object it points. This allows offset allows special properties, since -//!the pointer is independent from the address address of the pointee, if the +//!the pointer is independent from the address of the pointee, if the //!pointer and the pointee are still separated by the same offset. This feature //!converts offset_ptr in a smart pointer that can be placed in shared memory and //!memory mapped files mapped in different addresses in every process. @@ -232,11 +205,17 @@ namespace ipcdetail { //! \tparam PointedType The type of the pointee. //! \tparam DifferenceType A signed integer type that can represent the arithmetic operations on the pointer //! \tparam OffsetType An unsigned integer type that can represent the -//! distance between two pointers reinterpret_cast-ed as unsigned integers. In general this type +//! distance between two pointers reinterpret_cast-ed as unsigned integers. This type //! should be at least of the same size of std::uintptr_t. In some systems it's possible to communicate //! between 32 and 64 bit processes using 64 bit offsets. //! \tparam OffsetAlignment Alignment of the OffsetType stored inside. In some systems might be necessary //! to align it to 64 bits in order to communicate 32 and 64 bit processes using 64 bit offsets. +//! +//!Note: offset_ptr uses implementation defined properties, present in most platforms, for +//!performance reasons: +//! - Assumes that uintptr_t representation of nullptr is (uintptr_t)zero. +//! - Assumes that incrementing a uintptr_t obtained from a pointer is equivalent +//! to incrementing the pointer and then converting it back to uintptr_t. template class offset_ptr { @@ -263,44 +242,42 @@ class offset_ptr //!Default constructor (null pointer). //!Never throws. - offset_ptr() + BOOST_FORCEINLINE offset_ptr() BOOST_NOEXCEPT : internal(1) {} //!Constructor from raw pointer (allows "0" pointer conversion). //!Never throws. - offset_ptr(pointer ptr) - : internal(static_cast(ipcdetail::offset_ptr_to_offset<0>(ptr, this))) + BOOST_FORCEINLINE offset_ptr(pointer ptr) BOOST_NOEXCEPT + : internal(static_cast(ipcdetail::offset_ptr_to_offset(ptr, this))) {} //!Constructor from other pointer. //!Never throws. template - offset_ptr( T *ptr - , typename ipcdetail::enable_if< ipcdetail::is_convertible >::type * = 0) + BOOST_FORCEINLINE offset_ptr( T *ptr + , typename ipcdetail::enable_if< ipcdetail::is_convertible >::type * = 0) BOOST_NOEXCEPT : internal(static_cast - (ipcdetail::offset_ptr_to_offset<0>(static_cast(ptr), this))) + (ipcdetail::offset_ptr_to_offset(static_cast(ptr), this))) {} //!Constructor from other offset_ptr //!Never throws. - offset_ptr(const offset_ptr& ptr) + BOOST_FORCEINLINE offset_ptr(const offset_ptr& ptr) BOOST_NOEXCEPT : internal(static_cast - (ipcdetail::offset_ptr_to_offset_from_other<0>(this, &ptr, ptr.internal.m_offset))) + (ipcdetail::offset_ptr_to_offset_from_other(this, &ptr, ptr.internal.m_offset))) {} //!Constructor from other offset_ptr. If pointers of pointee types are //!convertible, offset_ptrs will be convertibles. Never throws. template - offset_ptr( const offset_ptr &ptr + BOOST_FORCEINLINE offset_ptr( const offset_ptr &ptr #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED - , typename ipcdetail::enable_if_c< ipcdetail::is_convertible::value - && ipcdetail::offset_ptr_maintains_address::value - >::type * = 0 + , typename ipcdetail::enable_if_convertible_equal_address::type* = 0 #endif - ) + ) BOOST_NOEXCEPT : internal(static_cast - (ipcdetail::offset_ptr_to_offset_from_other<0>(this, &ptr, ptr.get_offset()))) + (ipcdetail::offset_ptr_to_offset_from_other(this, &ptr, ptr.get_offset()))) {} #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED @@ -308,12 +285,10 @@ class offset_ptr //!Constructor from other offset_ptr. If pointers of pointee types are //!convertible, offset_ptrs will be convertibles. Never throws. template - offset_ptr( const offset_ptr &ptr - , typename ipcdetail::enable_if_c< ipcdetail::is_convertible::value - && !ipcdetail::offset_ptr_maintains_address::value - >::type * = 0) + BOOST_FORCEINLINE offset_ptr( const offset_ptr &ptr + , typename ipcdetail::enable_if_convertible_unequal_address::type* = 0) BOOST_NOEXCEPT : internal(static_cast - (ipcdetail::offset_ptr_to_offset<0>(static_cast(ptr.get()), this))) + (ipcdetail::offset_ptr_to_offset(static_cast(ptr.get()), this))) {} #endif @@ -321,51 +296,51 @@ class offset_ptr //!Emulates static_cast operator. //!Never throws. template - offset_ptr(const offset_ptr & r, ipcdetail::static_cast_tag) + BOOST_FORCEINLINE offset_ptr(const offset_ptr & r, ipcdetail::static_cast_tag) BOOST_NOEXCEPT : internal(static_cast - (ipcdetail::offset_ptr_to_offset<0>(static_cast(r.get()), this))) + (ipcdetail::offset_ptr_to_offset(static_cast(r.get()), this))) {} //!Emulates const_cast operator. //!Never throws. template - offset_ptr(const offset_ptr & r, ipcdetail::const_cast_tag) + BOOST_FORCEINLINE offset_ptr(const offset_ptr & r, ipcdetail::const_cast_tag) BOOST_NOEXCEPT : internal(static_cast - (ipcdetail::offset_ptr_to_offset<0>(const_cast(r.get()), this))) + (ipcdetail::offset_ptr_to_offset(const_cast(r.get()), this))) {} //!Emulates dynamic_cast operator. //!Never throws. template - offset_ptr(const offset_ptr & r, ipcdetail::dynamic_cast_tag) + BOOST_FORCEINLINE offset_ptr(const offset_ptr & r, ipcdetail::dynamic_cast_tag) BOOST_NOEXCEPT : internal(static_cast - (ipcdetail::offset_ptr_to_offset<0>(dynamic_cast(r.get()), this))) + (ipcdetail::offset_ptr_to_offset(dynamic_cast(r.get()), this))) {} //!Emulates reinterpret_cast operator. //!Never throws. template - offset_ptr(const offset_ptr & r, ipcdetail::reinterpret_cast_tag) + BOOST_FORCEINLINE offset_ptr(const offset_ptr & r, ipcdetail::reinterpret_cast_tag) BOOST_NOEXCEPT : internal(static_cast - (ipcdetail::offset_ptr_to_offset<0>(reinterpret_cast(r.get()), this))) + (ipcdetail::offset_ptr_to_offset(reinterpret_cast(r.get()), this))) {} //!Obtains raw pointer from offset. //!Never throws. - pointer get() const - { return (pointer)ipcdetail::offset_ptr_to_raw_pointer<0>(this, this->internal.m_offset); } + BOOST_FORCEINLINE pointer get() const BOOST_NOEXCEPT + { return (pointer)ipcdetail::offset_ptr_to_raw_pointer(this, this->internal.m_offset); } - offset_type get_offset() const + BOOST_FORCEINLINE offset_type get_offset() const BOOST_NOEXCEPT { return this->internal.m_offset; } //!Pointer-like -> operator. It can return 0 pointer. //!Never throws. - pointer operator->() const + BOOST_FORCEINLINE pointer operator->() const BOOST_NOEXCEPT { return this->get(); } //!Dereferencing operator, if it is a null offset_ptr behavior //! is undefined. Never throws. - reference operator* () const + BOOST_FORCEINLINE reference operator* () const BOOST_NOEXCEPT { pointer p = this->get(); reference r = *p; @@ -374,75 +349,62 @@ class offset_ptr //!Indexing operator. //!Never throws. - reference operator[](difference_type idx) const + BOOST_FORCEINLINE reference operator[](difference_type idx) const BOOST_NOEXCEPT { return this->get()[idx]; } //!Assignment from pointer (saves extra conversion). //!Never throws. - offset_ptr& operator= (pointer from) + BOOST_FORCEINLINE offset_ptr& operator= (pointer from) BOOST_NOEXCEPT { this->internal.m_offset = - static_cast(ipcdetail::offset_ptr_to_offset<0>(from, this)); + static_cast(ipcdetail::offset_ptr_to_offset(from, this)); return *this; } //!Assignment from other offset_ptr. //!Never throws. - offset_ptr& operator= (const offset_ptr & ptr) + BOOST_FORCEINLINE offset_ptr& operator= (const offset_ptr & ptr) BOOST_NOEXCEPT { this->internal.m_offset = - static_cast(ipcdetail::offset_ptr_to_offset_from_other<0>(this, &ptr, ptr.internal.m_offset)); + static_cast(ipcdetail::offset_ptr_to_offset_from_other(this, &ptr, ptr.internal.m_offset)); return *this; } //!Assignment from related offset_ptr. If pointers of pointee types //! are assignable, offset_ptrs will be assignable. Never throws. - template + template BOOST_FORCEINLINE #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED - typename ipcdetail::enable_if_c< ipcdetail::is_convertible::value - && ipcdetail::offset_ptr_maintains_address::value - , offset_ptr&>::type + typename ipcdetail::enable_if_c + < ipcdetail::is_convertible::value, offset_ptr&>::type #else offset_ptr& #endif - operator= (const offset_ptr &ptr) + operator= (const offset_ptr &ptr) BOOST_NOEXCEPT { - this->internal.m_offset = - static_cast(ipcdetail::offset_ptr_to_offset_from_other<0>(this, &ptr, ptr.get_offset())); + this->assign(ptr, ipcdetail::bool_::value>()); return *this; } - #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED - template - typename ipcdetail::enable_if_c::value - && !ipcdetail::offset_ptr_maintains_address::value - , offset_ptr&>::type - operator= (const offset_ptr &ptr) - { - this->internal.m_offset = - static_cast(ipcdetail::offset_ptr_to_offset<0>(static_cast(ptr.get()), this)); - return *this; - } - #endif + public: //!offset_ptr += difference_type. //!Never throws. - offset_ptr &operator+= (difference_type offset) + BOOST_FORCEINLINE offset_ptr &operator+= (difference_type offset) BOOST_NOEXCEPT { this->inc_offset(offset * sizeof (PointedType)); return *this; } //!offset_ptr -= difference_type. //!Never throws. - offset_ptr &operator-= (difference_type offset) + BOOST_FORCEINLINE offset_ptr &operator-= (difference_type offset) BOOST_NOEXCEPT { this->dec_offset(offset * sizeof (PointedType)); return *this; } //!++offset_ptr. //!Never throws. - offset_ptr& operator++ (void) + BOOST_FORCEINLINE offset_ptr& operator++ (void) BOOST_NOEXCEPT { this->inc_offset(sizeof (PointedType)); return *this; } //!offset_ptr++. //!Never throws. - offset_ptr operator++ (int) + BOOST_FORCEINLINE offset_ptr operator++ (int) BOOST_NOEXCEPT { offset_ptr tmp(*this); this->inc_offset(sizeof (PointedType)); @@ -451,12 +413,12 @@ class offset_ptr //!--offset_ptr. //!Never throws. - offset_ptr& operator-- (void) + BOOST_FORCEINLINE offset_ptr& operator-- (void) BOOST_NOEXCEPT { this->dec_offset(sizeof (PointedType)); return *this; } //!offset_ptr--. //!Never throws. - offset_ptr operator-- (int) + BOOST_FORCEINLINE offset_ptr operator-- (int) BOOST_NOEXCEPT { offset_ptr tmp(*this); this->dec_offset(sizeof (PointedType)); @@ -465,12 +427,17 @@ class offset_ptr //!safe bool conversion operator. //!Never throws. - operator unspecified_bool_type() const + #if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) + BOOST_FORCEINLINE operator unspecified_bool_type() const BOOST_NOEXCEPT { return this->internal.m_offset != 1? &self_t::unspecified_bool_type_func : 0; } - + #else + explicit operator bool() const BOOST_NOEXCEPT + { return this->internal.m_offset != 1; } + #endif + //!Not operator. Not needed in theory, but improves portability. //!Never throws - bool operator! () const + BOOST_FORCEINLINE bool operator! () const BOOST_NOEXCEPT { return this->internal.m_offset == 1; } //!Compatibility with pointer_traits @@ -481,92 +448,92 @@ class offset_ptr //!Compatibility with pointer_traits //! - static offset_ptr pointer_to(reference r) + BOOST_FORCEINLINE static offset_ptr pointer_to(reference r) BOOST_NOEXCEPT { return offset_ptr(&r); } //!difference_type + offset_ptr //!operation - friend offset_ptr operator+(difference_type diff, offset_ptr right) + BOOST_FORCEINLINE friend offset_ptr operator+(difference_type diff, offset_ptr right) BOOST_NOEXCEPT { right += diff; return right; } //!offset_ptr + difference_type //!operation - friend offset_ptr operator+(offset_ptr left, difference_type diff) + BOOST_FORCEINLINE friend offset_ptr operator+(offset_ptr left, difference_type diff) BOOST_NOEXCEPT { left += diff; return left; } //!offset_ptr - diff //!operation - friend offset_ptr operator-(offset_ptr left, difference_type diff) + BOOST_FORCEINLINE friend offset_ptr operator-(offset_ptr left, difference_type diff) BOOST_NOEXCEPT { left -= diff; return left; } //!offset_ptr - diff //!operation - friend offset_ptr operator-(difference_type diff, offset_ptr right) + BOOST_FORCEINLINE friend offset_ptr operator-(difference_type diff, offset_ptr right) BOOST_NOEXCEPT { right -= diff; return right; } //!offset_ptr - offset_ptr //!operation - friend difference_type operator-(const offset_ptr &pt, const offset_ptr &pt2) + BOOST_FORCEINLINE friend difference_type operator-(const offset_ptr &pt, const offset_ptr &pt2) BOOST_NOEXCEPT { return difference_type(pt.get()- pt2.get()); } //Comparison - friend bool operator== (const offset_ptr &pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator== (const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1.get() == pt2.get(); } - friend bool operator!= (const offset_ptr &pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator!= (const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1.get() != pt2.get(); } - friend bool operator<(const offset_ptr &pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator<(const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1.get() < pt2.get(); } - friend bool operator<=(const offset_ptr &pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator<=(const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1.get() <= pt2.get(); } - friend bool operator>(const offset_ptr &pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator>(const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1.get() > pt2.get(); } - friend bool operator>=(const offset_ptr &pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator>=(const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1.get() >= pt2.get(); } //Comparison to raw ptr to support literal 0 - friend bool operator== (pointer pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator== (pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1 == pt2.get(); } - friend bool operator!= (pointer pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator!= (pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1 != pt2.get(); } - friend bool operator<(pointer pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator<(pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1 < pt2.get(); } - friend bool operator<=(pointer pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator<=(pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1 <= pt2.get(); } - friend bool operator>(pointer pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator>(pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1 > pt2.get(); } - friend bool operator>=(pointer pt1, const offset_ptr &pt2) + BOOST_FORCEINLINE friend bool operator>=(pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT { return pt1 >= pt2.get(); } //Comparison - friend bool operator== (const offset_ptr &pt1, pointer pt2) + BOOST_FORCEINLINE friend bool operator== (const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT { return pt1.get() == pt2; } - friend bool operator!= (const offset_ptr &pt1, pointer pt2) + BOOST_FORCEINLINE friend bool operator!= (const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT { return pt1.get() != pt2; } - friend bool operator<(const offset_ptr &pt1, pointer pt2) + BOOST_FORCEINLINE friend bool operator<(const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT { return pt1.get() < pt2; } - friend bool operator<=(const offset_ptr &pt1, pointer pt2) + BOOST_FORCEINLINE friend bool operator<=(const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT { return pt1.get() <= pt2; } - friend bool operator>(const offset_ptr &pt1, pointer pt2) + BOOST_FORCEINLINE friend bool operator>(const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT { return pt1.get() > pt2; } - friend bool operator>=(const offset_ptr &pt1, pointer pt2) + BOOST_FORCEINLINE friend bool operator>=(const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT { return pt1.get() >= pt2; } - friend void swap(offset_ptr &left, offset_ptr &right) + BOOST_FORCEINLINE friend void swap(offset_ptr &left, offset_ptr &right) BOOST_NOEXCEPT { pointer ptr = right.get(); right = left; @@ -574,14 +541,36 @@ class offset_ptr } private: + template + BOOST_FORCEINLINE void assign(const offset_ptr &ptr, ipcdetail::bool_) BOOST_NOEXCEPT + { //no need to pointer adjustment + this->internal.m_offset = + static_cast(ipcdetail::offset_ptr_to_offset_from_other(this, &ptr, ptr.get_offset())); + } + + template + BOOST_FORCEINLINE void assign(const offset_ptr &ptr, ipcdetail::bool_) BOOST_NOEXCEPT + { //we must convert to raw before calculating the offset + this->internal.m_offset = + static_cast(ipcdetail::offset_ptr_to_offset(static_cast(ptr.get()), this)); + } + #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) - void inc_offset(DifferenceType bytes) + BOOST_FORCEINLINE void inc_offset(DifferenceType bytes) BOOST_NOEXCEPT { internal.m_offset += bytes; } - void dec_offset(DifferenceType bytes) + BOOST_FORCEINLINE void dec_offset(DifferenceType bytes) BOOST_NOEXCEPT { internal.m_offset -= bytes; } ipcdetail::offset_ptr_internal internal; + + public: + BOOST_FORCEINLINE const OffsetType &priv_offset() const BOOST_NOEXCEPT + { return internal.m_offset; } + + BOOST_FORCEINLINE OffsetType &priv_offset() BOOST_NOEXCEPT + { return internal.m_offset; } + #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED }; @@ -601,8 +590,8 @@ inline std::basic_istream & operator>> //!Simulation of static_cast between pointers. Never throws. template -inline boost::interprocess::offset_ptr - static_pointer_cast(const boost::interprocess::offset_ptr & r) +BOOST_FORCEINLINE boost::interprocess::offset_ptr + static_pointer_cast(const boost::interprocess::offset_ptr & r) BOOST_NOEXCEPT { return boost::interprocess::offset_ptr (r, boost::interprocess::ipcdetail::static_cast_tag()); @@ -610,8 +599,8 @@ inline boost::interprocess::offset_ptr //!Simulation of const_cast between pointers. Never throws. template -inline boost::interprocess::offset_ptr - const_pointer_cast(const boost::interprocess::offset_ptr & r) +BOOST_FORCEINLINE boost::interprocess::offset_ptr + const_pointer_cast(const boost::interprocess::offset_ptr & r) BOOST_NOEXCEPT { return boost::interprocess::offset_ptr (r, boost::interprocess::ipcdetail::const_cast_tag()); @@ -619,8 +608,8 @@ inline boost::interprocess::offset_ptr //!Simulation of dynamic_cast between pointers. Never throws. template -inline boost::interprocess::offset_ptr - dynamic_pointer_cast(const boost::interprocess::offset_ptr & r) +BOOST_FORCEINLINE boost::interprocess::offset_ptr + dynamic_pointer_cast(const boost::interprocess::offset_ptr & r) BOOST_NOEXCEPT { return boost::interprocess::offset_ptr (r, boost::interprocess::ipcdetail::dynamic_cast_tag()); @@ -628,8 +617,8 @@ inline boost::interprocess::offset_ptr //!Simulation of reinterpret_cast between pointers. Never throws. template -inline boost::interprocess::offset_ptr - reinterpret_pointer_cast(const boost::interprocess::offset_ptr & r) +BOOST_FORCEINLINE boost::interprocess::offset_ptr + reinterpret_pointer_cast(const boost::interprocess::offset_ptr & r) BOOST_NOEXCEPT { return boost::interprocess::offset_ptr (r, boost::interprocess::ipcdetail::reinterpret_cast_tag()); @@ -662,7 +651,7 @@ namespace interprocess { //!to_raw_pointer() enables boost::mem_fn to recognize offset_ptr. //!Never throws. template -inline T * to_raw_pointer(boost::interprocess::offset_ptr const & p) +BOOST_FORCEINLINE T * to_raw_pointer(boost::interprocess::offset_ptr const & p) BOOST_NOEXCEPT { return ipcdetail::to_raw_pointer(p); } } //namespace interprocess @@ -699,33 +688,42 @@ template struct pointer_plus_bits, NumBits> { typedef boost::interprocess::offset_ptr pointer; - typedef ::boost::interprocess::pointer_size_t_caster caster_t; //Bits are stored in the lower bits of the pointer except the LSB, //because this bit is used to represent the null pointer. - static const std::size_t Mask = ((std::size_t(1) << NumBits) - 1) << 1u; + static const uintptr_t Mask = ((uintptr_t(1) << uintptr_t(NumBits)) - uintptr_t(1)) << uintptr_t(1); + BOOST_STATIC_ASSERT(0 ==(Mask&1)); - static pointer get_pointer(const pointer &n) + //We must ALWAYS take argument "n" by reference as a copy of a null pointer + //with a bit (e.g. offset == 3) would be incorrectly copied and interpreted as non-null. + + BOOST_FORCEINLINE static pointer get_pointer(const pointer &n) BOOST_NOEXCEPT { - caster_t caster(n.get()); - return pointer(caster_t(caster.size() & ~Mask).pointer()); + pointer p; + O const tmp_off = n.priv_offset() & O(~Mask); + p.priv_offset() = boost::interprocess::ipcdetail::offset_ptr_to_offset_from_other(&p, &n, tmp_off); + return p; } - static void set_pointer(pointer &n, const pointer &p) + BOOST_FORCEINLINE static void set_pointer(pointer &n, const pointer &p) BOOST_NOEXCEPT { - caster_t n_caster(n.get()); - caster_t p_caster(p.get()); - BOOST_ASSERT(0 == (p_caster.size() & Mask)); - n = caster_t(p_caster.size() | (n_caster.size() & Mask)).pointer(); + BOOST_ASSERT(0 == (get_bits)(p)); + O const stored_bits = O(n.priv_offset() & Mask); + n = p; + n.priv_offset() |= stored_bits; } - static std::size_t get_bits(const pointer &n) - { return (caster_t(n.get()).size() & Mask) >> 1u; } + BOOST_FORCEINLINE static std::size_t get_bits(const pointer &n) BOOST_NOEXCEPT + { + return std::size_t((n.priv_offset() & Mask) >> 1u); + } - static void set_bits(pointer &n, std::size_t b) + BOOST_FORCEINLINE static void set_bits(pointer &n, std::size_t const b) BOOST_NOEXCEPT { BOOST_ASSERT(b < (std::size_t(1) << NumBits)); - caster_t n_caster(n.get()); - n = caster_t((n_caster.size() & ~Mask) | (b << 1u)).pointer(); + O tmp = n.priv_offset(); + tmp &= O(~Mask); + tmp |= O(b << 1u); + n.priv_offset() = tmp; } }; diff --git a/boost/interprocess/sync/interprocess_mutex.hpp b/boost/interprocess/sync/interprocess_mutex.hpp index f3d52f9141..8bfc02c15d 100644 --- a/boost/interprocess/sync/interprocess_mutex.hpp +++ b/boost/interprocess/sync/interprocess_mutex.hpp @@ -158,7 +158,7 @@ inline void interprocess_mutex::lock() { #ifdef BOOST_INTERPROCESS_ENABLE_TIMEOUT_WHEN_LOCKING boost::posix_time::ptime wait_time - = boost::posix_time::microsec_clock::universal_time() + = microsec_clock::universal_time() + boost::posix_time::milliseconds(BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS); if (!m_mutex.timed_lock(wait_time)) { diff --git a/boost/interprocess/sync/interprocess_recursive_mutex.hpp b/boost/interprocess/sync/interprocess_recursive_mutex.hpp index 5da0c1f3b7..e382574937 100644 --- a/boost/interprocess/sync/interprocess_recursive_mutex.hpp +++ b/boost/interprocess/sync/interprocess_recursive_mutex.hpp @@ -154,7 +154,7 @@ inline void interprocess_recursive_mutex::lock() { #ifdef BOOST_INTERPROCESS_ENABLE_TIMEOUT_WHEN_LOCKING boost::posix_time::ptime wait_time - = boost::posix_time::microsec_clock::universal_time() + = microsec_clock::universal_time() + boost::posix_time::milliseconds(BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS); if (!mutex.timed_lock(wait_time)){ throw interprocess_exception(timeout_when_locking_error, "Interprocess mutex timeout when locking. Possible deadlock: owner died without unlocking?"); diff --git a/boost/interprocess/sync/interprocess_semaphore.hpp b/boost/interprocess/sync/interprocess_semaphore.hpp index 8ae0c7933f..bb828dfb0e 100644 --- a/boost/interprocess/sync/interprocess_semaphore.hpp +++ b/boost/interprocess/sync/interprocess_semaphore.hpp @@ -122,7 +122,7 @@ inline void interprocess_semaphore::wait() { #ifdef BOOST_INTERPROCESS_ENABLE_TIMEOUT_WHEN_LOCKING boost::posix_time::ptime wait_time - = boost::posix_time::microsec_clock::universal_time() + = microsec_clock::universal_time() + boost::posix_time::milliseconds(BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS); if (!m_sem.timed_wait(wait_time)) { diff --git a/boost/intrusive/avl_set.hpp b/boost/intrusive/avl_set.hpp index c3d8d999ac..5c51e5978d 100644 --- a/boost/intrusive/avl_set.hpp +++ b/boost/intrusive/avl_set.hpp @@ -328,7 +328,7 @@ class avl_set_impl //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyTypeKeyCompare) template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::rbtree::equal_range(const key_type &)const std::pair @@ -339,7 +339,7 @@ class avl_set_impl template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED diff --git a/boost/intrusive/bs_set.hpp b/boost/intrusive/bs_set.hpp index a46ca38a01..2f560f5863 100644 --- a/boost/intrusive/bs_set.hpp +++ b/boost/intrusive/bs_set.hpp @@ -325,7 +325,7 @@ class bs_set_impl //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare) template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &)const std::pair @@ -336,7 +336,7 @@ class bs_set_impl template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED diff --git a/boost/intrusive/bstree.hpp b/boost/intrusive/bstree.hpp index 7a67de6e12..b08c49b5f1 100644 --- a/boost/intrusive/bstree.hpp +++ b/boost/intrusive/bstree.hpp @@ -360,7 +360,11 @@ struct bstbase2 } template - detail::key_nodeptr_comp key_node_comp(KeyTypeKeyCompare comp) const + struct key_node_comp_ret + { typedef detail::key_nodeptr_comp type; }; + + template + typename key_node_comp_ret::type key_node_comp(KeyTypeKeyCompare comp) const { return detail::key_nodeptr_comp(comp, &this->get_value_traits()); } @@ -1245,6 +1249,19 @@ class bstree_impl 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)); + + #if !(defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) )) + //Test insertion position is correct + iterator p(commit_data.node, this->priv_value_traits_ptr()); + if(!commit_data.link_left){ + ++p; + } + //Check if the insertion point is correct to detect wrong + //uses insert_unique_check + BOOST_ASSERT(( p == this->end() || !this->comp()(*p, value) )); + BOOST_ASSERT(( p == this->begin() || !this->comp()(value, *--p) )); + #endif + node_algorithms::insert_unique_commit (this->header_ptr(), to_insert, commit_data); this->sz_traits().increment(); @@ -1368,6 +1385,10 @@ class bstree_impl size_type erase(const key_type &key) { return this->erase(key, this->key_comp()); } + //! Requires: key is a value such that `*this` is partitioned with respect to + //! comp(nk, key) and !comp(key, nk), with comp(nk, key) implying !comp(key, nk), + //! with nk the key_type of a value_type inserted into `*this`. + //! //! Effects: Erases all the elements with the given key. //! according to the comparison functor "comp". //! @@ -1448,6 +1469,10 @@ class bstree_impl iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) { size_type n; return this->private_erase(b, e, n, disposer); } + //! Requires: key is a value such that `*this` is partitioned with respect to + //! comp(nk, key) and !comp(key, nk), with comp(nk, key) implying !comp(key, nk) + //! and nk the key_type of a value_type inserted into `*this`. + //! //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements with the given key. @@ -1520,6 +1545,10 @@ class bstree_impl size_type count(const key_type &key) const { return size_type(this->count(key, this->key_comp())); } + //! Requires: key is a value such that `*this` is partitioned with respect to + //! comp(nk, key) and !comp(key, nk), with comp(nk, key) implying !comp(key, nk), + //! and nk the key_type of a value_type inserted into `*this`. + //! //! Effects: Returns the number of contained elements with the given key //! //! Complexity: Logarithmic to the number of elements contained plus lineal @@ -1569,21 +1598,11 @@ class bstree_impl //! Throws: If `key_compare` throws. const_iterator lower_bound(const key_type &key) 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. + //! @copydoc ::boost::intrusive::bstree::lower_bound(const key_type &) template iterator lower_bound(const KeyType &key, KeyTypeKeyCompare 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. + //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyTypeKeyCompare) template const_iterator lower_bound(const KeyType &key, KeyTypeKeyCompare comp) const; @@ -1595,6 +1614,9 @@ class bstree_impl //! Throws: If `key_compare` throws. iterator upper_bound(const key_type &key); + //! Requires: key is a value such that `*this` is partitioned with respect to + //! !comp(key, nk), with nk the key_type of a value_type inserted into `*this`. + //! //! 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. @@ -1605,21 +1627,10 @@ class bstree_impl template iterator upper_bound(const KeyType &key, KeyTypeKeyCompare 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 `key_compare` throws. + //! @copydoc ::boost::intrusive::bstree::upper_bound(const key_type &) const_iterator upper_bound(const key_type &key) 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. + //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyTypeKeyCompare) template const_iterator upper_bound(const KeyType &key, KeyTypeKeyCompare comp) const; @@ -1631,6 +1642,10 @@ class bstree_impl //! Throws: If `key_compare` throws. iterator find(const key_type &key); + //! Requires: key is a value such that `*this` is partitioned with respect to + //! comp(nk, key) and !comp(key, nk), with comp(nk, key) implying !comp(key, nk), + //! and nk the key_type of a value_type inserted into `*this`. + //! //! Effects: Finds an iterator to the first element whose key is //! k or end() if that element does not exist. //! @@ -1640,20 +1655,10 @@ class bstree_impl template iterator find(const KeyType &key, KeyTypeKeyCompare 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 `key_compare` throws. + //! @copydoc ::boost::intrusive::bstree::find(const key_type &) const_iterator find(const key_type &key) 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. + //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyTypeKeyCompare) template const_iterator find(const KeyType &key, KeyTypeKeyCompare comp) const; @@ -1666,6 +1671,10 @@ class bstree_impl //! Throws: If `key_compare` throws. std::pair equal_range(const key_type &key); + //! Requires: key is a value such that `*this` is partitioned with respect to + //! comp(nk, key) and !comp(key, nk), with comp(nk, key) implying !comp(key, nk), + //! with nk the key_type of a value_type inserted into `*this`. + //! //! 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. @@ -1676,29 +1685,21 @@ class bstree_impl template std::pair equal_range(const KeyType &key, KeyTypeKeyCompare 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 `key_compare` throws. - std::pair - equal_range(const key_type &key) const; + //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &) + std::pair equal_range(const key_type &key) 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. + //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare) template std::pair equal_range(const KeyType &key, KeyTypeKeyCompare comp) const; - //! Requires: 'lower_key' must not be greater than 'upper_key'. If - //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. + //! Requires: + //! `upper_key` shall not precede `lower_key` according to key_compare. + //! [key_comp()(upper_key, lower_key) shall be false] + //! + //! If `lower_key` is equivalent to `upper_key` + //! [!key_comp()(upper_key, lower_key) && !key_comp()(lower_key, upper_key)] then + //! ('left_closed' || 'right_closed') must be false. //! //! Effects: Returns an a pair with the following criteria: //! @@ -1717,11 +1718,19 @@ class bstree_impl std::pair bounded_range (const key_type &lower_key, const key_type &upper_value, bool left_closed, bool right_closed); - //! Requires: KeyTypeKeyCompare 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. + //! Requires: + //! `lower_key` is a value such that `*this` is partitioned with respect to + //! comp(nk, lower_key) if left_closed is true, with respect to !comp(lower_key, nk) otherwise. + //! + //! `upper_key` is a value such that `*this` is partitioned with respect to + //! !comp(upper_key, nk) if right_closed is true, with respect to comp(nk, upper_key) otherwise. + //! + //! `upper_key` shall not precede `lower_key` according to comp + //! [comp(upper_key, lower_key) shall be false] + //! + //! If `lower_key` is equivalent to `upper_key` + //! [!comp(upper_key, lower_key) && !comp(lower_key, upper_key)] then + //! ('left_closed' || 'right_closed') must be false. //! //! Effects: Returns an a pair with the following criteria: //! @@ -1740,47 +1749,12 @@ class bstree_impl template std::pair bounded_range (const KeyType &lower_key, const KeyType &upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed); - - //! Requires: 'lower_key' must not be greater than 'upper_key'. 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 `key_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. + + //! @copydoc ::boost::intrusive::bstree::bounded_range(const key_type &,const key_type &,bool,bool) std::pair bounded_range (const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed) const; - //! Requires: KeyTypeKeyCompare 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. + //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool) template std::pair bounded_range (const KeyType &lower_key, const KeyType &upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const; diff --git a/boost/intrusive/detail/ebo_functor_holder.hpp b/boost/intrusive/detail/ebo_functor_holder.hpp index 27dd093b60..9fec5a32b7 100644 --- a/boost/intrusive/detail/ebo_functor_holder.hpp +++ b/boost/intrusive/detail/ebo_functor_holder.hpp @@ -22,6 +22,8 @@ # pragma once #endif +#include + namespace boost { namespace intrusive { namespace detail { @@ -155,20 +157,63 @@ template struct is_unary_or_binary_function : is_unary_or_binary_function_impl {}; -template -class ebo_functor_holder_impl +template::value> +class ebo_functor_holder { + BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder) + public: - ebo_functor_holder_impl() + typedef T functor_type; + + ebo_functor_holder() + : t_() + {} + + explicit ebo_functor_holder(const T &t) + : t_(t) {} - ebo_functor_holder_impl(const T& t) - : t_(t) + + explicit ebo_functor_holder(BOOST_RV_REF(T) t) + : t_(::boost::move(t)) {} + template - ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2) - : t_(arg1, arg2) + ebo_functor_holder(BOOST_FWD_REF(Arg1) arg1, BOOST_FWD_REF(Arg2) arg2) + : t_(::boost::forward(arg1), ::boost::forward(arg2)) + {} + + ebo_functor_holder(const ebo_functor_holder &x) + : t_(x) + {} + + ebo_functor_holder(BOOST_RV_REF(ebo_functor_holder) x) + : t_(x.t_) {} + ebo_functor_holder& operator=(BOOST_COPY_ASSIGN_REF(ebo_functor_holder) x) + { + this->get() = x.get(); + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(ebo_functor_holder) x) + { + this->get() = ::boost::move(x.get()); + return *this; + } + + ebo_functor_holder& operator=(const T &x) + { + this->get() = x; + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(T) x) + { + this->get() = ::boost::move(x); + return *this; + } + T& get(){return t_;} const T& get()const{return t_;} @@ -177,50 +222,67 @@ class ebo_functor_holder_impl }; template -class ebo_functor_holder_impl +class ebo_functor_holder : public T { + BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder) + public: - ebo_functor_holder_impl() - {} - explicit ebo_functor_holder_impl(const T& t) - : T(t) + typedef T functor_type; + + ebo_functor_holder() + : T() {} - template - ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2) - : T(arg1, arg2) + + explicit ebo_functor_holder(const T &t) + : T(t) {} - T& get(){return *this;} - const T& get()const{return *this;} -}; + explicit ebo_functor_holder(BOOST_RV_REF(T) t) + : T(::boost::move(t)) + {} -template -class ebo_functor_holder - : public ebo_functor_holder_impl::value> -{ - private: - typedef ebo_functor_holder_impl::value> super; + template + ebo_functor_holder(BOOST_FWD_REF(Arg1) arg1, BOOST_FWD_REF(Arg2) arg2) + : T(::boost::forward(arg1), ::boost::forward(arg2)) + {} - public: - typedef T functor_type; - ebo_functor_holder(){} - explicit ebo_functor_holder(const T& t) - : super(t) + ebo_functor_holder(const ebo_functor_holder &x) + : T(static_cast(x)) {} - template - ebo_functor_holder(const Arg1& arg1, const Arg2& arg2) - : super(arg1, arg2) + ebo_functor_holder(BOOST_RV_REF(ebo_functor_holder) x) + : T(BOOST_MOVE_BASE(T, x)) {} - ebo_functor_holder& operator=(const ebo_functor_holder& x) + ebo_functor_holder& operator=(BOOST_COPY_ASSIGN_REF(ebo_functor_holder) x) { - this->get()=x.get(); + const ebo_functor_holder&r = x; + this->get() = x.get(); + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(ebo_functor_holder) x) + { + this->get() = ::boost::move(x.get()); + return *this; + } + + ebo_functor_holder& operator=(const T &x) + { + this->get() = x; + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(T) x) + { + this->get() = ::boost::move(x); return *this; } -}; + T& get(){return *this;} + const T& get()const{return *this;} +}; } //namespace detail { } //namespace intrusive { diff --git a/boost/intrusive/detail/has_member_function_callable_with.hpp b/boost/intrusive/detail/has_member_function_callable_with.hpp index 30bef56c2b..c9a8e7e637 100644 --- a/boost/intrusive/detail/has_member_function_callable_with.hpp +++ b/boost/intrusive/detail/has_member_function_callable_with.hpp @@ -167,7 +167,11 @@ BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG void BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(); }; - struct Base : public boost_intrusive_hmfcw::remove_cv::type, public BaseMixin {}; + struct Base + : public boost_intrusive_hmfcw::remove_cv::type, public BaseMixin + { //Declare the unneeded default constructor as some old compilers wrongly require it with is_convertible + Base(); + }; template class Helper{}; template @@ -244,11 +248,16 @@ BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG #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 + //Declare some unneeded default constructor as some old compilers wrongly require it with is_convertible #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\ + \ + 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_MOVE_CAT(FunWrap##N, 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;\ };\ diff --git a/boost/intrusive/detail/key_nodeptr_comp.hpp b/boost/intrusive/detail/key_nodeptr_comp.hpp index df2b895db9..1a5ec32acc 100644 --- a/boost/intrusive/detail/key_nodeptr_comp.hpp +++ b/boost/intrusive/detail/key_nodeptr_comp.hpp @@ -60,13 +60,15 @@ struct key_nodeptr_comp //key_forward template - typename enable_if, const key_type &>::type - key_forward(const T &node) const + typename enable_if, const key_type &>::type key_forward(const T &node) const { return key_of_value()(*traits_->to_value_ptr(node)); } template - typename disable_if, const T &>::type - const key_forward(const T &key) const + #if defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN) + const T &key_forward (const T &key, typename disable_if >::type* =0) const + #else + typename disable_if, const T &>::type key_forward(const T &key) const + #endif { return key; } //operator() 1 arg diff --git a/boost/intrusive/detail/math.hpp b/boost/intrusive/detail/math.hpp index dfebe2ab42..4901053cb3 100644 --- a/boost/intrusive/detail/math.hpp +++ b/boost/intrusive/detail/math.hpp @@ -23,6 +23,7 @@ #include #include +#include namespace boost { namespace intrusive { @@ -227,9 +228,28 @@ inline float fast_log2 (float val) return val + static_cast(log_2); } +inline bool is_pow2(std::size_t x) +{ return (x & (x-1)) == 0; } + +template +struct static_is_pow2 +{ + static const bool value = (N & (N-1)) == 0; +}; + inline std::size_t ceil_log2 (std::size_t x) { - return static_cast((x & (x-1)) != 0) + floor_log2(x); + return static_cast(!(is_pow2)(x)) + floor_log2(x); +} + +inline std::size_t ceil_pow2 (std::size_t x) +{ + return std::size_t(1u) << (ceil_log2)(x); +} + +inline std::size_t previous_or_equal_pow2(std::size_t x) +{ + return std::size_t(1u) << floor_log2(x); } template diff --git a/boost/intrusive/detail/parent_from_member.hpp b/boost/intrusive/detail/parent_from_member.hpp index 30eba13e16..8701c3f269 100644 --- a/boost/intrusive/detail/parent_from_member.hpp +++ b/boost/intrusive/detail/parent_from_member.hpp @@ -115,10 +115,6 @@ inline const Parent *parent_from_member(const Member *member, const Member Paren } //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/std_fwd.hpp b/boost/intrusive/detail/std_fwd.hpp index 4b5cedbae3..8193ea8ed1 100644 --- a/boost/intrusive/detail/std_fwd.hpp +++ b/boost/intrusive/detail/std_fwd.hpp @@ -23,26 +23,8 @@ // Standard predeclarations ////////////////////////////////////////////////////////////////////////////// -#if defined(_LIBCPP_VERSION) - #define BOOST_INTRUSIVE_CLANG_INLINE_STD_NS - #pragma GCC diagnostic push - #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 } -#endif - -BOOST_INTRUSIVE_STD_NS_BEG +#include +BOOST_MOVE_STD_NS_BEG template struct less; @@ -55,11 +37,7 @@ struct forward_iterator_tag; struct bidirectional_iterator_tag; struct random_access_iterator_tag; -BOOST_INTRUSIVE_STD_NS_END - -#ifdef BOOST_INTRUSIVE_CLANG_INLINE_STD_NS - #pragma GCC diagnostic pop - #undef BOOST_INTRUSIVE_CLANG_INLINE_STD_NS -#endif //BOOST_INTRUSIVE_CLANG_INLINE_STD_NS +BOOST_MOVE_STD_NS_END +#include #endif //#ifndef BOOST_INTRUSIVE_DETAIL_STD_FWD_HPP diff --git a/boost/intrusive/detail/tree_iterator.hpp b/boost/intrusive/detail/tree_iterator.hpp index c2e980d27a..4985c6ce7b 100644 --- a/boost/intrusive/detail/tree_iterator.hpp +++ b/boost/intrusive/detail/tree_iterator.hpp @@ -106,14 +106,23 @@ class tree_iterator return result; } - void go_left() - { members_.nodeptr_ = node_traits::get_left(members_.nodeptr_); } + tree_iterator& go_left() + { + members_.nodeptr_ = node_traits::get_left(members_.nodeptr_); + return static_cast (*this); + } - void go_right() - { members_.nodeptr_ = node_traits::get_right(members_.nodeptr_); } + tree_iterator& go_right() + { + members_.nodeptr_ = node_traits::get_right(members_.nodeptr_); + return static_cast (*this); + } - void go_parent() - { members_.nodeptr_ = node_traits::get_parent(members_.nodeptr_); } + tree_iterator& go_parent() + { + members_.nodeptr_ = node_traits::get_parent(members_.nodeptr_); + return static_cast (*this); + } operator unspecified_bool_type() const { return members_.nodeptr_ ? &tree_iterator::unspecified_bool_type_func : 0; } diff --git a/boost/intrusive/detail/tree_value_compare.hpp b/boost/intrusive/detail/tree_value_compare.hpp index a05741edee..dc554442fe 100644 --- a/boost/intrusive/detail/tree_value_compare.hpp +++ b/boost/intrusive/detail/tree_value_compare.hpp @@ -34,14 +34,25 @@ struct tree_value_compare typedef KeyOfValue key_of_value; typedef Key key_type; + + tree_value_compare() + : base_t() + {} + explicit tree_value_compare(const key_compare &kcomp) : base_t(kcomp) {} - tree_value_compare() - : base_t() + tree_value_compare (const tree_value_compare &x) + : base_t(x.base_t::get()) {} + tree_value_compare &operator=(const tree_value_compare &x) + { this->base_t::get() = x.base_t::get(); return *this; } + + tree_value_compare &operator=(const key_compare &x) + { this->base_t::get() = x; return *this; } + const key_compare &key_comp() const { return static_cast(*this); } @@ -54,13 +65,13 @@ struct tree_value_compare {}; template - typename boost::intrusive::detail::enable_if, const key_type &>::type - key_forward(const U &key) const + const key_type & key_forward + (const U &key, typename boost::intrusive::detail::enable_if >::type* = 0) const { return key; } template - typename boost::intrusive::detail::disable_if, const key_type &>::type - key_forward(const U &key) const + const key_type & key_forward + (const U &key, typename boost::intrusive::detail::disable_if >::type* = 0) const { return KeyOfValue()(key); } template diff --git a/boost/intrusive/intrusive_fwd.hpp b/boost/intrusive/intrusive_fwd.hpp index b6b14c0698..f51276d636 100644 --- a/boost/intrusive/intrusive_fwd.hpp +++ b/boost/intrusive/intrusive_fwd.hpp @@ -16,7 +16,11 @@ #ifndef BOOST_CONFIG_HPP # include #endif - +# +#ifndef BOOST_CSTDINT_HPP +# include +#endif +# #if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -65,6 +69,14 @@ namespace boost { namespace intrusive { +#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) +# ifdef BOOST_HAS_INTPTR_T + using ::boost::uintptr_t; +# else + typedef std::size_t uintptr_t; +# endif +#endif + //////////////////////////// // Node algorithms //////////////////////////// diff --git a/boost/intrusive/pointer_plus_bits.hpp b/boost/intrusive/pointer_plus_bits.hpp index 117aff3c58..6168ea8ea4 100644 --- a/boost/intrusive/pointer_plus_bits.hpp +++ b/boost/intrusive/pointer_plus_bits.hpp @@ -64,25 +64,25 @@ struct pointer_plus_bits template struct pointer_plus_bits { - static const std::size_t Mask = ((std::size_t(1u) << NumBits) - 1); + static const uintptr_t Mask = uintptr_t((uintptr_t(1u) << NumBits) - 1); typedef T* pointer; static pointer get_pointer(pointer n) - { return pointer(std::size_t(n) & ~Mask); } + { return pointer(uintptr_t(n) & uintptr_t(~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)); + BOOST_INTRUSIVE_INVARIANT_ASSERT(0 == (uintptr_t(p) & Mask)); + n = pointer(uintptr_t(p) | (uintptr_t(n) & Mask)); } static std::size_t get_bits(pointer n) - { return (std::size_t(n) & Mask); } + { return std::size_t(uintptr_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); + BOOST_INTRUSIVE_INVARIANT_ASSERT(uintptr_t(c) <= Mask); + n = pointer(uintptr_t((get_pointer)(n)) | uintptr_t(c)); } }; diff --git a/boost/intrusive/pointer_traits.hpp b/boost/intrusive/pointer_traits.hpp index 24843fddc5..731432b01f 100644 --- a/boost/intrusive/pointer_traits.hpp +++ b/boost/intrusive/pointer_traits.hpp @@ -223,7 +223,7 @@ struct pointer_traits template static pointer priv_static_cast_from(boost::intrusive::detail::false_, const UPtr &uptr) - { return pointer_to(*static_cast(to_raw_pointer(uptr))); } + { return uptr ? pointer_to(*static_cast(to_raw_pointer(uptr))) : pointer(); } //priv_const_cast_from template @@ -232,7 +232,7 @@ struct pointer_traits template static pointer priv_const_cast_from(boost::intrusive::detail::false_, const UPtr &uptr) - { return pointer_to(const_cast(*uptr)); } + { return uptr ? pointer_to(const_cast(*uptr)) : pointer(); } //priv_dynamic_cast_from template @@ -241,15 +241,7 @@ struct pointer_traits template static pointer priv_dynamic_cast_from(boost::intrusive::detail::false_, const UPtr &uptr) - { - element_type *p = dynamic_cast(&*uptr); - if(!p){ - return pointer(); - } - else{ - return pointer_to(*p); - } - } + { return uptr ? pointer_to(dynamic_cast(*uptr)) : pointer(); } ///@endcond }; diff --git a/boost/intrusive/rbtree_algorithms.hpp b/boost/intrusive/rbtree_algorithms.hpp index 00d9fe3b18..2a74e1b2cd 100644 --- a/boost/intrusive/rbtree_algorithms.hpp +++ b/boost/intrusive/rbtree_algorithms.hpp @@ -448,6 +448,7 @@ class rbtree_algorithms NodeTraits::set_color(x_parent, NodeTraits::red()); bstree_algo::rotate_left(x_parent, w, NodeTraits::get_parent(x_parent), header); w = NodeTraits::get_right(x_parent); + BOOST_INTRUSIVE_INVARIANT_ASSERT(w); } node_ptr const w_left (NodeTraits::get_left(w)); node_ptr const w_right(NodeTraits::get_right(w)); @@ -463,6 +464,7 @@ class rbtree_algorithms NodeTraits::set_color(w, NodeTraits::red()); bstree_algo::rotate_right(w, w_left, NodeTraits::get_parent(w), header); w = NodeTraits::get_right(x_parent); + BOOST_INTRUSIVE_INVARIANT_ASSERT(w); } NodeTraits::set_color(w, NodeTraits::get_color(x_parent)); NodeTraits::set_color(x_parent, NodeTraits::black()); @@ -481,6 +483,7 @@ class rbtree_algorithms NodeTraits::set_color(x_parent, NodeTraits::red()); bstree_algo::rotate_right(x_parent, w, NodeTraits::get_parent(x_parent), header); w = NodeTraits::get_left(x_parent); + BOOST_INTRUSIVE_INVARIANT_ASSERT(w); } node_ptr const w_left (NodeTraits::get_left(w)); node_ptr const w_right(NodeTraits::get_right(w)); @@ -496,6 +499,7 @@ class rbtree_algorithms NodeTraits::set_color(w, NodeTraits::red()); bstree_algo::rotate_left(w, w_right, NodeTraits::get_parent(w), header); w = NodeTraits::get_left(x_parent); + BOOST_INTRUSIVE_INVARIANT_ASSERT(w); } NodeTraits::set_color(w, NodeTraits::get_color(x_parent)); NodeTraits::set_color(x_parent, NodeTraits::black()); diff --git a/boost/intrusive/set.hpp b/boost/intrusive/set.hpp index ae6a7a0812..f0072eab20 100644 --- a/boost/intrusive/set.hpp +++ b/boost/intrusive/set.hpp @@ -328,7 +328,7 @@ class set_impl //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyTypeKeyCompare) template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::rbtree::equal_range(const key_type &)const std::pair @@ -339,7 +339,7 @@ class set_impl template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED diff --git a/boost/intrusive/sg_set.hpp b/boost/intrusive/sg_set.hpp index 560845e7a2..e6d4e377d3 100644 --- a/boost/intrusive/sg_set.hpp +++ b/boost/intrusive/sg_set.hpp @@ -326,7 +326,7 @@ class sg_set_impl //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyTypeKeyCompare) template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::rbtree::equal_range(const key_type &)const std::pair @@ -337,7 +337,7 @@ class sg_set_impl template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED diff --git a/boost/intrusive/sgtree.hpp b/boost/intrusive/sgtree.hpp index dc84c80462..b4c4cdec1a 100644 --- a/boost/intrusive/sgtree.hpp +++ b/boost/intrusive/sgtree.hpp @@ -826,18 +826,17 @@ class sgtree_impl //! Complexity: Linear to the elements in the subtree. void balance_factor(float new_alpha) { - BOOST_INTRUSIVE_INVARIANT_ASSERT((new_alpha > 0.5f && new_alpha < 1.0f)); - if(new_alpha < 0.5f && new_alpha >= 1.0f) return; - //The alpha factor CAN't be changed if the fixed, floating operation-less //1/sqrt(2) alpha factor option is activated BOOST_STATIC_ASSERT((floating_point)); - float old_alpha = this->get_alpha_traits().get_alpha(); - this->get_alpha_traits().set_alpha(new_alpha); - - if(new_alpha < old_alpha){ - this->max_tree_size_ = this->size(); - this->rebalance(); + BOOST_INTRUSIVE_INVARIANT_ASSERT((new_alpha > 0.5f && new_alpha < 1.0f)); + if(new_alpha >= 0.5f && new_alpha < 1.0f){ + float old_alpha = this->get_alpha_traits().get_alpha(); + this->get_alpha_traits().set_alpha(new_alpha); + if(new_alpha < old_alpha){ + this->max_tree_size_ = this->size(); + this->rebalance(); + } } } diff --git a/boost/intrusive/splay_set.hpp b/boost/intrusive/splay_set.hpp index eea19d7999..3d43215023 100644 --- a/boost/intrusive/splay_set.hpp +++ b/boost/intrusive/splay_set.hpp @@ -333,7 +333,7 @@ class splay_set_impl //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyTypeKeyCompare) template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::rbtree::equal_range(const key_type &)const std::pair @@ -344,7 +344,7 @@ class splay_set_impl template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED diff --git a/boost/intrusive/treap_set.hpp b/boost/intrusive/treap_set.hpp index 188c80fdce..60cf449147 100644 --- a/boost/intrusive/treap_set.hpp +++ b/boost/intrusive/treap_set.hpp @@ -375,7 +375,7 @@ class treap_set_impl //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyTypeKeyCompare) template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::rbtree::equal_range(const key_type &)const std::pair @@ -386,7 +386,7 @@ class treap_set_impl template std::pair equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED diff --git a/boost/iterator/zip_iterator.hpp b/boost/iterator/zip_iterator.hpp index 304f65eb2f..83fa63b2a7 100644 --- a/boost/iterator/zip_iterator.hpp +++ b/boost/iterator/zip_iterator.hpp @@ -1,6 +1,8 @@ -// Copyright David Abrahams and Thomas Becker 2000-2006. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at +// Copyright David Abrahams and Thomas Becker 2000-2006. +// Copyright Kohei Takahashi 2012-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) #ifndef BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_ @@ -12,19 +14,26 @@ #include #include // for enable_if_convertible #include -#include #include -#include +#include // for std::pair +#include // for backward compatibility -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include #include -#include + +#include +#include +#include +#include +#include +#include namespace boost { namespace iterators { @@ -33,24 +42,6 @@ namespace iterators { template class zip_iterator; - // One important design goal of the zip_iterator is to isolate all - // functionality whose implementation relies on the current tuple - // implementation. This goal has been achieved as follows: Inside - // the namespace detail there is a namespace tuple_impl_specific. - // This namespace encapsulates all functionality that is specific - // to the current Boost tuple implementation. More precisely, the - // namespace tuple_impl_specific provides the following tuple - // algorithms and meta-algorithms for the current Boost tuple - // implementation: - // - // tuple_meta_transform - // tuple_meta_accumulate - // tuple_transform - // tuple_for_each - // - // If the tuple implementation changes, all that needs to be - // replaced is the implementation of these four (meta-)algorithms. - namespace detail { @@ -73,313 +64,96 @@ namespace iterators { struct increment_iterator { template - void operator()(Iterator& it) + void operator()(Iterator& it) const { ++it; } }; // struct decrement_iterator { template - void operator()(Iterator& it) + void operator()(Iterator& it) const { --it; } }; // struct dereference_iterator { - template - struct apply + template + struct result; + + template + struct result { typedef typename - boost::detail::iterator_traits::reference - type; + remove_reference::type>::type + iterator; + + typedef typename iterator_reference::type type; }; template - typename apply::type operator()(Iterator const& it) + typename result::type + operator()(Iterator const& it) const { return *it; } }; - - // The namespace tuple_impl_specific provides two meta- - // algorithms and two algorithms for tuples. - // - namespace tuple_impl_specific - { - // Meta-transform algorithm for tuples - // - template - struct tuple_meta_transform; - - template - struct tuple_meta_transform_impl - { - typedef tuples::cons< - typename mpl::apply1< - typename mpl::lambda::type - , typename Tuple::head_type - >::type - , typename tuple_meta_transform< - typename Tuple::tail_type - , UnaryMetaFun - >::type - > type; - }; - - template - struct tuple_meta_transform - : mpl::eval_if< - boost::is_same - , mpl::identity - , tuple_meta_transform_impl - > - { - }; - - // Meta-accumulate algorithm for tuples. Note: The template - // parameter StartType corresponds to the initial value in - // ordinary accumulation. - // - template - struct tuple_meta_accumulate; - - template< - typename Tuple - , class BinaryMetaFun - , typename StartType - > - struct tuple_meta_accumulate_impl - { - typedef typename mpl::apply2< - typename mpl::lambda::type - , typename Tuple::head_type - , typename tuple_meta_accumulate< - typename Tuple::tail_type - , BinaryMetaFun - , StartType - >::type - >::type type; - }; - - template< - typename Tuple - , class BinaryMetaFun - , typename StartType - > - struct tuple_meta_accumulate - : mpl::eval_if< - boost::is_same - , mpl::identity - , tuple_meta_accumulate_impl< - Tuple - , BinaryMetaFun - , StartType - > - > - { - }; - -#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \ - || ( \ - BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, != 0) && defined(_MSC_VER) \ - ) -// Not sure why intel's partial ordering fails in this case, but I'm -// assuming int's an MSVC bug-compatibility feature. - -# define BOOST_TUPLE_ALGO_DISPATCH -# define BOOST_TUPLE_ALGO(algo) algo##_impl -# define BOOST_TUPLE_ALGO_TERMINATOR , int -# define BOOST_TUPLE_ALGO_RECURSE , ... -#else -# define BOOST_TUPLE_ALGO(algo) algo -# define BOOST_TUPLE_ALGO_TERMINATOR -# define BOOST_TUPLE_ALGO_RECURSE -#endif - - // transform algorithm for tuples. The template parameter Fun - // must be a unary functor which is also a unary metafunction - // class that computes its return type based on its argument - // type. For example: - // - // struct to_ptr - // { - // template - // struct apply - // { - // typedef Arg* type; - // } - // - // template - // Arg* operator()(Arg x); - // }; - template - inline tuples::null_type BOOST_TUPLE_ALGO(tuple_transform) - (tuples::null_type const&, Fun BOOST_TUPLE_ALGO_TERMINATOR) - { return tuples::null_type(); } - - template - inline typename tuple_meta_transform< - Tuple - , Fun - >::type - - BOOST_TUPLE_ALGO(tuple_transform)( - const Tuple& t, - Fun f - BOOST_TUPLE_ALGO_RECURSE - ) - { - typedef typename tuple_meta_transform< - BOOST_DEDUCED_TYPENAME Tuple::tail_type - , Fun - >::type transformed_tail_type; - - return tuples::cons< - BOOST_DEDUCED_TYPENAME mpl::apply1< - Fun, BOOST_DEDUCED_TYPENAME Tuple::head_type - >::type - , transformed_tail_type - >( - f(boost::tuples::get<0>(t)), tuple_transform(t.get_tail(), f) - ); - } - -#ifdef BOOST_TUPLE_ALGO_DISPATCH - template - inline typename tuple_meta_transform< - Tuple - , Fun - >::type - - tuple_transform( - const Tuple& t, - Fun f - ) - { - return tuple_transform_impl(t, f, 1); - } -#endif - - // for_each algorithm for tuples. - // - template - inline Fun BOOST_TUPLE_ALGO(tuple_for_each)( - tuples::null_type - , Fun f BOOST_TUPLE_ALGO_TERMINATOR - ) - { return f; } - - - template - inline Fun BOOST_TUPLE_ALGO(tuple_for_each)( - Tuple& t - , Fun f BOOST_TUPLE_ALGO_RECURSE) - { - f( t.get_head() ); - return tuple_for_each(t.get_tail(), f); - } - -#ifdef BOOST_TUPLE_ALGO_DISPATCH - template - inline Fun - tuple_for_each( - Tuple& t, - Fun f - ) - { - return tuple_for_each_impl(t, f, 1); - } -#endif - - // Equality of tuples. NOTE: "==" for tuples currently (7/2003) - // has problems under some compilers, so I just do my own. - // No point in bringing in a bunch of #ifdefs here. This is - // going to go away with the next tuple implementation anyway. - // - inline bool tuple_equal(tuples::null_type, tuples::null_type) - { return true; } - - template - inline bool tuple_equal(Tuple1 const& t1, Tuple2 const& t2) - { - return t1.get_head() == t2.get_head() && - tuple_equal(t1.get_tail(), t2.get_tail()); - } - } - // - // end namespace tuple_impl_specific - - template - struct iterator_reference - { - typedef typename boost::detail::iterator_traits::reference type; - }; - -#ifdef BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT - // Hack because BOOST_MPL_AUX_LAMBDA_SUPPORT doesn't seem to work - // out well. Instantiating the nested apply template also - // requires instantiating iterator_traits on the - // placeholder. Instead we just specialize it as a metafunction - // class. - template<> - struct iterator_reference - { - template - struct apply : iterator_reference {}; - }; -#endif - // Metafunction to obtain the type of the tuple whose element types // are the reference types of an iterator tuple. // template struct tuple_of_references - : tuple_impl_specific::tuple_meta_transform< + : mpl::transform< IteratorTuple, iterator_reference > { }; + // Specialization for std::pair + template + struct tuple_of_references > + { + typedef std::pair< + typename iterator_reference::type + , typename iterator_reference::type + > type; + }; + // Metafunction to obtain the minimal traversal tag in a tuple // of iterators. // template struct minimum_traversal_category_in_iterator_tuple { - typedef typename tuple_impl_specific::tuple_meta_transform< + typedef typename mpl::transform< IteratorTuple , pure_traversal_tag > >::type tuple_of_traversal_tags; - typedef typename tuple_impl_specific::tuple_meta_accumulate< + typedef typename mpl::fold< tuple_of_traversal_tags - , minimum_category<> , random_access_traversal_tag + , minimum_category<> >::type type; }; - // We need to call tuple_meta_accumulate with mpl::and_ as the - // accumulating functor. To this end, we need to wrap it into - // a struct that has exactly two arguments (that is, template - // parameters) and not five, like mpl::and_ does. - // - template - struct and_with_two_args - : mpl::and_ - { - }; - -# ifdef BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT - // Hack because BOOST_MPL_AUX_LAMBDA_SUPPORT doesn't seem to work - // out well. In this case I think it's an MPL bug - template<> - struct and_with_two_args - { - template - struct apply : mpl::and_ - {}; - }; -# endif + template + struct minimum_traversal_category_in_iterator_tuple > + { + typedef typename pure_traversal_tag< + typename iterator_traversal::type + >::type iterator1_traversal; + typedef typename pure_traversal_tag< + typename iterator_traversal::type + >::type iterator2_traversal; + + typedef typename minimum_category< + iterator1_traversal + , typename minimum_category< + iterator2_traversal + , random_access_traversal_tag + >::type + >::type type; + }; /////////////////////////////////////////////////////////////////// // @@ -401,9 +175,9 @@ namespace iterators { typedef reference value_type; // Difference type is the first iterator's difference type - typedef typename boost::detail::iterator_traits< - typename tuples::element<0, IteratorTuple>::type - >::difference_type difference_type; + typedef typename iterator_difference< + typename mpl::at_c::type + >::type difference_type; // Traversal catetgory is the minimum traversal category in the // iterator tuple. @@ -429,6 +203,30 @@ namespace iterators { { typedef int type; }; + + template + struct converter + { + template + static reference call(Seq seq) + { + typedef typename fusion::traits::tag_of::type tag; + return fusion::convert(seq); + } + }; + + template + struct converter > + { + typedef std::pair reference; + template + static reference call(Seq seq) + { + return reference( + fusion::at_c<0>(seq) + , fusion::at_c<1>(seq)); + } + }; } ///////////////////////////////////////////////////////////////////// @@ -484,10 +282,11 @@ namespace iterators { // iterators in the iterator tuple. typename super_t::reference dereference() const { - return detail::tuple_impl_specific::tuple_transform( - get_iterator_tuple(), - detail::dereference_iterator() - ); + typedef typename super_t::reference reference; + typedef detail::converter gen; + return gen::call(fusion::transform( + get_iterator_tuple(), + detail::dereference_iterator())); } // Two zip iterators are equal if all iterators in the iterator @@ -503,39 +302,35 @@ namespace iterators { template bool equal(const zip_iterator& other) const { - return detail::tuple_impl_specific::tuple_equal( - get_iterator_tuple(), - other.get_iterator_tuple() - ); + return fusion::equal_to( + get_iterator_tuple(), + other.get_iterator_tuple()); } // Advancing a zip iterator means to advance all iterators in the // iterator tuple. void advance(typename super_t::difference_type n) { - detail::tuple_impl_specific::tuple_for_each( + fusion::for_each( m_iterator_tuple, - detail::advance_iterator(n) - ); + detail::advance_iterator(n)); } // Incrementing a zip iterator means to increment all iterators in // the iterator tuple. void increment() { - detail::tuple_impl_specific::tuple_for_each( - m_iterator_tuple, - detail::increment_iterator() - ); + fusion::for_each( + m_iterator_tuple, + detail::increment_iterator()); } // Decrementing a zip iterator means to decrement all iterators in // the iterator tuple. void decrement() { - detail::tuple_impl_specific::tuple_for_each( - m_iterator_tuple, - detail::decrement_iterator() - ); + fusion::for_each( + m_iterator_tuple, + detail::decrement_iterator()); } // Distance is calculated using the first iterator in the tuple. @@ -544,8 +339,8 @@ namespace iterators { const zip_iterator& other ) const { - return boost::tuples::get<0>(other.get_iterator_tuple()) - - boost::tuples::get<0>(this->get_iterator_tuple()); + return fusion::at_c<0>(other.get_iterator_tuple()) - + fusion::at_c<0>(this->get_iterator_tuple()); } // Data Members diff --git a/boost/lambda/detail/lambda_functors.hpp b/boost/lambda/detail/lambda_functors.hpp index 9ce29add96..febb6fc828 100644 --- a/boost/lambda/detail/lambda_functors.hpp +++ b/boost/lambda/detail/lambda_functors.hpp @@ -300,7 +300,7 @@ public: namespace boost { -#if !defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_NO_DECLTYPE) +#if !defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_NO_CXX11_DECLTYPE) template struct result_of()> diff --git a/boost/lexical_cast.hpp b/boost/lexical_cast.hpp index a880c0cd9c..dc3d7e3fb7 100644 --- a/boost/lexical_cast.hpp +++ b/boost/lexical_cast.hpp @@ -30,20 +30,19 @@ #include #include #include -#include namespace boost { template inline Target lexical_cast(const Source &arg) { - boost::value_initialized result; + Target result; - if (!boost::conversion::detail::try_lexical_convert(arg, get(result))) { + if (!boost::conversion::detail::try_lexical_convert(arg, result)) { boost::conversion::detail::throw_bad_cast(); } - return get(result); + return result; } template diff --git a/boost/lexical_cast/detail/converter_lexical.hpp b/boost/lexical_cast/detail/converter_lexical.hpp index 6a7878bdbe..fd866d84e5 100644 --- a/boost/lexical_cast/detail/converter_lexical.hpp +++ b/boost/lexical_cast/detail/converter_lexical.hpp @@ -364,7 +364,6 @@ namespace boost { #endif }; -#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION // Helper for floating point types. // -1.23456789e-123456 // ^ sign @@ -380,6 +379,8 @@ namespace boost { Source, BOOST_DEDUCED_TYPENAME boost::enable_if >::type > { + +#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION BOOST_STATIC_ASSERT( std::numeric_limits::max_exponent10 <= 999999L && std::numeric_limits::min_exponent10 >= -999999L @@ -388,8 +389,10 @@ namespace boost { BOOST_STATIC_CONSTANT(std::size_t, value = 5 + lcast_precision::value + 6 ); - }; +#else // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION + BOOST_STATIC_CONSTANT(std::size_t, value = 156); #endif // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION + }; } namespace detail // lexical_cast_stream_traits diff --git a/boost/lexical_cast/try_lexical_convert.hpp b/boost/lexical_cast/try_lexical_convert.hpp index 66270eee76..1881cdf371 100644 --- a/boost/lexical_cast/try_lexical_convert.hpp +++ b/boost/lexical_cast/try_lexical_convert.hpp @@ -23,6 +23,13 @@ # pragma once #endif +#if defined(__clang__) || (defined(__GNUC__) && \ + !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#endif + #include #include #include @@ -195,5 +202,11 @@ namespace boost { } // namespace boost +#if defined(__clang__) || (defined(__GNUC__) && \ + !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) +#pragma GCC diagnostic pop +#endif + #endif // BOOST_LEXICAL_CAST_TRY_LEXICAL_CONVERT_HPP diff --git a/boost/locale/boundary/boundary_point.hpp b/boost/locale/boundary/boundary_point.hpp index 31718f26bc..3c72dba662 100644 --- a/boost/locale/boundary/boundary_point.hpp +++ b/boost/locale/boundary/boundary_point.hpp @@ -156,19 +156,19 @@ namespace boundary { typedef boundary_point sboundary_point; ///< convenience typedef typedef boundary_point wsboundary_point; ///< convenience typedef - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T typedef boundary_point u16sboundary_point;///< convenience typedef #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T typedef boundary_point u32sboundary_point;///< convenience typedef #endif typedef boundary_point cboundary_point; ///< convenience typedef typedef boundary_point wcboundary_point; ///< convenience typedef - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T typedef boundary_point u16cboundary_point; ///< convenience typedef #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T typedef boundary_point u32cboundary_point; ///< convenience typedef #endif diff --git a/boost/locale/boundary/facets.hpp b/boost/locale/boundary/facets.hpp index 086d64158c..26c01e7d0d 100644 --- a/boost/locale/boundary/facets.hpp +++ b/boost/locale/boundary/facets.hpp @@ -152,7 +152,7 @@ namespace boost { #endif }; - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T template<> class BOOST_LOCALE_DECL boundary_indexing : public std::locale::facet { public: @@ -167,7 +167,7 @@ namespace boost { }; #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T template<> class BOOST_LOCALE_DECL boundary_indexing : public std::locale::facet { public: diff --git a/boost/locale/boundary/index.hpp b/boost/locale/boundary/index.hpp index 5948dccafe..8870c9bcfc 100644 --- a/boost/locale/boundary/index.hpp +++ b/boost/locale/boundary/index.hpp @@ -1036,37 +1036,37 @@ namespace boost { typedef segment_index ssegment_index; ///< convenience typedef typedef segment_index wssegment_index; ///< convenience typedef - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T typedef segment_index u16ssegment_index;///< convenience typedef #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T typedef segment_index u32ssegment_index;///< convenience typedef #endif typedef segment_index csegment_index; ///< convenience typedef typedef segment_index wcsegment_index; ///< convenience typedef - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T typedef segment_index u16csegment_index; ///< convenience typedef #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T typedef segment_index u32csegment_index; ///< convenience typedef #endif typedef boundary_point_index sboundary_point_index;///< convenience typedef typedef boundary_point_index wsboundary_point_index;///< convenience typedef - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T typedef boundary_point_index u16sboundary_point_index;///< convenience typedef #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T typedef boundary_point_index u32sboundary_point_index;///< convenience typedef #endif typedef boundary_point_index cboundary_point_index; ///< convenience typedef typedef boundary_point_index wcboundary_point_index; ///< convenience typedef - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T typedef boundary_point_index u16cboundary_point_index;///< convenience typedef #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T typedef boundary_point_index u32cboundary_point_index;///< convenience typedef #endif diff --git a/boost/locale/boundary/segment.hpp b/boost/locale/boundary/segment.hpp index d735d5b79b..516d883d54 100644 --- a/boost/locale/boundary/segment.hpp +++ b/boost/locale/boundary/segment.hpp @@ -27,7 +27,6 @@ namespace boundary { int compare_text(LeftIterator l_begin,LeftIterator l_end,RightIterator r_begin,RightIterator r_end) { typedef LeftIterator left_iterator; - typedef RightIterator right_iterator; typedef typename std::iterator_traits::value_type char_type; typedef std::char_traits traits; while(l_begin!=l_end && r_begin!=r_end) { @@ -436,19 +435,19 @@ namespace boundary { typedef segment ssegment; ///< convenience typedef typedef segment wssegment; ///< convenience typedef - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T typedef segment u16ssegment;///< convenience typedef #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T typedef segment u32ssegment;///< convenience typedef #endif typedef segment csegment; ///< convenience typedef typedef segment wcsegment; ///< convenience typedef - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T typedef segment u16csegment; ///< convenience typedef #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T typedef segment u32csegment; ///< convenience typedef #endif diff --git a/boost/locale/conversion.hpp b/boost/locale/conversion.hpp index 2b274ec53d..36f3a4fd64 100644 --- a/boost/locale/conversion.hpp +++ b/boost/locale/conversion.hpp @@ -102,7 +102,7 @@ namespace boost { #endif }; - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T template<> class BOOST_LOCALE_DECL converter : public converter_base, public std::locale::facet { public: @@ -117,7 +117,7 @@ namespace boost { }; #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T template<> class BOOST_LOCALE_DECL converter : public converter_base, public std::locale::facet { public: diff --git a/boost/locale/encoding.hpp b/boost/locale/encoding.hpp index 24742bf053..5fd9cb745c 100644 --- a/boost/locale/encoding.hpp +++ b/boost/locale/encoding.hpp @@ -212,7 +212,7 @@ namespace boost { template<> BOOST_LOCALE_DECL std::string from_utf(wchar_t const *begin,wchar_t const *end,std::string const &charset,method_type how); - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T template<> BOOST_LOCALE_DECL std::basic_string to_utf(char const *begin,char const *end,std::string const &charset,method_type how); @@ -220,7 +220,7 @@ namespace boost { BOOST_LOCALE_DECL std::string from_utf(char16_t const *begin,char16_t const *end,std::string const &charset,method_type how); #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T template<> BOOST_LOCALE_DECL std::basic_string to_utf(char const *begin,char const *end,std::string const &charset,method_type how); diff --git a/boost/locale/format.hpp b/boost/locale/format.hpp index 043044f6b1..4bf17057d9 100644 --- a/boost/locale/format.hpp +++ b/boost/locale/format.hpp @@ -473,14 +473,14 @@ namespace boost { /// typedef basic_format wformat; - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T /// /// Definition of char16_t based format /// typedef basic_format u16format; #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T /// /// Definition of char32_t based format /// diff --git a/boost/locale/generic_codecvt.hpp b/boost/locale/generic_codecvt.hpp new file mode 100644 index 0000000000..245f96f8ad --- /dev/null +++ b/boost/locale/generic_codecvt.hpp @@ -0,0 +1,676 @@ +// +// Copyright (c) 2015 Artyom Beilis (Tonkikh) +// +// Distributed under the 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_LOCALE_GENERIC_CODECVT_HPP +#define BOOST_LOCALE_GENERIC_CODECVT_HPP + +#include +#include +#include +#include + +namespace boost { +namespace locale { + +#ifndef BOOST_LOCALE_DOXYGEN +// +// Make sure that mbstate can keep 16 bit of UTF-16 sequence +// +BOOST_STATIC_ASSERT(sizeof(std::mbstate_t)>=2); +#endif + +#if defined(_MSC_VER) && _MSC_VER < 1700 +// up to MSVC 11 (2012) do_length is non-standard it counts wide characters instead of narrow and does not change mbstate +#define BOOST_LOCALE_DO_LENGTH_MBSTATE_CONST +#endif + +/// +/// \brief A base class that used to define constants for generic_codecvt +/// +class generic_codecvt_base { +public: + /// + /// Initail state for converting to or from unicode code points, used by initial_state in derived classes + /// + enum initial_convertion_state { + to_unicode_state, ///< The state would be used by to_unicode functions + from_unicode_state ///< The state would be used by from_unicode functions + }; +}; + +/// +/// \brief Geneneric generic codecvt facet, various stateless encodings to UTF-16 and UTF-32 using wchar_t, char32_t and char16_t +/// +/// Implementations should dervide from this class defining itself as CodecvtImpl and provide following members +/// +/// - `state_type` - a type of special object that allows to store intermediate cached data, for example `iconv_t` descriptor +/// - `state_type initial_state(generic_codecvt_base::initial_convertion_state direction) const` - member function that creates initial state +/// - `int max_encoding_length() const` - a maximal length that one Unicode code point is represented, for UTF-8 for example it is 4 from ISO-8859-1 it is 1 +/// - `utf::code_point to_unicode(state_type &state,char const *&begin,char const *end)` - extract first code point from the text in range [begin,end), in case of success begin would point to the next character sequence to be encoded to next code point, in case of incomplete sequence - utf::incomplete shell be returned, and in case of invalid input sequence utf::illegal shell be returned and begin would remain unmodified +/// - `utf::code_point from_unicode(state_type &state,utf::code_point u,char *begin,char const *end)` - convert a unicode code point `u` into a character seqnece at [begin,end). Return the length of the sequence in case of success, utf::incomplete in case of not enough room to encode the code point of utf::illegal in case conversion can not be performed +/// +/// +/// For example implementaion of codecvt for latin1/ISO-8859-1 character set +/// +/// \code +/// +/// template +/// class latin1_codecvt :boost::locale::generic_codecvt > +/// { +/// public: +/// +/// /* Standard codecvt constructor */ +/// latin1_codecvt(size_t refs = 0) : boost::locale::generic_codecvt >(refs) +/// { +/// } +/// +/// /* State is unused but required by generic_codecvt */ +/// struct state_type {}; +/// +/// state_type initial_state(generic_codecvt_base::initial_convertion_state /*unused*/) const +/// { +/// return state_type(); +/// } +/// +/// int max_encoding_length() const +/// { +/// return 1; +/// } +/// +/// boost::locale::utf::code_point to_unicode(state_type &,char const *&begin,char const *end) const +/// { +/// if(begin == end) +/// return boost::locale::utf::incomplete; +/// return *begin++; +/// } +/// +/// boost::locale::utf::code_point from_unicode(state_type &,boost::locale::utf::code_point u,char *begin,char const *end) const +/// { +/// if(u >= 256) +/// return boost::locale::utf::illegal; +/// if(begin == end) +/// return boost::locale::utf::incomplete; +/// *begin = u; +/// return 1; +/// } +/// }; +/// +/// \endcode +/// +/// When external tools used for encoding conversion, the `state_type` is useful to save objects used for conversions. For example, +/// icu::UConverter can be saved in such a state for an efficient use: +/// +/// \code +/// template +/// class icu_codecvt :boost::locale::generic_codecvt > +/// { +/// public: +/// +/// /* Standard codecvt constructor */ +/// icu_codecvt(std::string const &name,refs = 0) : +/// boost::locale::generic_codecvt >(refs) +/// { ... } +/// +/// /* State is unused but required by generic_codecvt */ +/// struct std::unique_ptr state_type; +/// +/// state_type &&initial_state(generic_codecvt_base::initial_convertion_state /*unused*/) const +/// { +/// UErrorCode err = U_ZERO_ERROR; +/// state_type ptr(ucnv_safeClone(converter_,0,0,&err,ucnv_close); +/// return std::move(ptr); +/// } +/// +/// boost::locale::utf::code_point to_unicode(state_type &ptr,char const *&begin,char const *end) const +/// { +/// UErrorCode err = U_ZERO_ERROR; +/// boost::locale::utf::code_point cp = ucnv_getNextUChar(ptr.get(),&begin,end,&err); +/// ... +/// } +/// ... +/// }; +/// \endcode +/// +/// +template +class generic_codecvt; + +/// +/// \brief UTF-16 to/from UTF-8 codecvt facet to use with char16_t or wchar_t on Windows +/// +/// Note in order to fit the requirements of usability by std::wfstream it uses mbstate_t +/// to handle intermediate states in handling of variable length UTF-16 sequences +/// +/// Its member functions implement standard virtual functions of basic codecvt +/// +template +class generic_codecvt : public std::codecvt, public generic_codecvt_base +{ +public: + + typedef CharType uchar; + + generic_codecvt(size_t refs = 0) : + std::codecvt(refs) + { + } + CodecvtImpl const &implementation() const + { + return *static_cast(this); + } + +protected: + + + virtual std::codecvt_base::result do_unshift(std::mbstate_t &s,char *from,char * /*to*/,char *&next) const + { + boost::uint16_t &state = *reinterpret_cast(&s); +#ifdef DEBUG_CODECVT + std::cout << "Entering unshift " << std::hex << state << std::dec << std::endl; +#endif + if(state != 0) + return std::codecvt_base::error; + next=from; + return std::codecvt_base::ok; + } + virtual int do_encoding() const throw() + { + return 0; + } + virtual int do_max_length() const throw() + { + return implementation().max_encoding_length(); + } + virtual bool do_always_noconv() const throw() + { + return false; + } + + virtual int + do_length( std::mbstate_t + #ifdef BOOST_LOCALE_DO_LENGTH_MBSTATE_CONST + const + #endif + &std_state, + char const *from, + char const *from_end, + size_t max) const + { + #ifndef BOOST_LOCALE_DO_LENGTH_MBSTATE_CONST + char const *save_from = from; + boost::uint16_t &state = *reinterpret_cast(&std_state); + #else + size_t save_max = max; + boost::uint16_t state = *reinterpret_cast(&std_state); + #endif + + typedef typename CodecvtImpl::state_type state_type; + state_type cvt_state = implementation().initial_state(generic_codecvt_base::to_unicode_state); + while(max > 0 && from < from_end){ + char const *prev_from = from; + boost::uint32_t ch=implementation().to_unicode(cvt_state,from,from_end); + if(ch==boost::locale::utf::incomplete || ch==boost::locale::utf::illegal) { + from = prev_from; + break; + } + max --; + if(ch > 0xFFFF) { + if(state == 0) { + from = prev_from; + state = 1; + } + else { + state = 0; + } + } + } + #ifndef BOOST_LOCALE_DO_LENGTH_MBSTATE_CONST + return from - save_from; + #else + return save_max - max; + #endif + } + + + virtual std::codecvt_base::result + do_in( std::mbstate_t &std_state, + char const *from, + char const *from_end, + char const *&from_next, + uchar *to, + uchar *to_end, + uchar *&to_next) const + { + std::codecvt_base::result r=std::codecvt_base::ok; + + // mbstate_t is POD type and should be initialized to 0 (i.a. state = stateT()) + // according to standard. We use it to keep a flag 0/1 for surrogate pair writing + // + // if 0 no code above >0xFFFF observed, of 1 a code above 0xFFFF observerd + // and first pair is written, but no input consumed + boost::uint16_t &state = *reinterpret_cast(&std_state); + typedef typename CodecvtImpl::state_type state_type; + state_type cvt_state = implementation().initial_state(generic_codecvt_base::to_unicode_state); + while(to < to_end && from < from_end) + { +#ifdef DEBUG_CODECVT + std::cout << "Entering IN--------------" << std::endl; + std::cout << "State " << std::hex << state <> 10; + boost::uint16_t vl = ch & 0x3FF; + boost::uint16_t w1 = vh + 0xD800; + boost::uint16_t w2 = vl + 0xDC00; + if(state == 0) { + from = from_saved; + *to++ = w1; + state = 1; + } + else { + *to++ = w2; + state = 0; + } + } + } + from_next=from; + to_next=to; + if(r == std::codecvt_base::ok && (from!=from_end || state!=0)) + r = std::codecvt_base::partial; +#ifdef DEBUG_CODECVT + std::cout << "Returning "; + switch(r) { + case std::codecvt_base::ok: + std::cout << "ok" << std::endl; + break; + case std::codecvt_base::partial: + std::cout << "partial" << std::endl; + break; + case std::codecvt_base::error: + std::cout << "error" << std::endl; + break; + default: + std::cout << "other" << std::endl; + break; + } + std::cout << "State " << std::hex << state <=2 in order + // to be able to store first observerd surrogate pair + // + // State: state!=0 - a first surrogate pair was observerd (state = first pair), + // we expect the second one to come and then zero the state + /// + boost::uint16_t &state = *reinterpret_cast(&std_state); + typedef typename CodecvtImpl::state_type state_type; + state_type cvt_state = implementation().initial_state(generic_codecvt_base::from_unicode_state); + while(to < to_end && from < from_end) + { +#ifdef DEBUG_CODECVT + std::cout << "Entering OUT --------------" << std::endl; + std::cout << "State " << std::hex << state < +class generic_codecvt : public std::codecvt, public generic_codecvt_base +{ +public: + typedef CharType uchar; + + generic_codecvt(size_t refs = 0) : + std::codecvt(refs) + { + } + + CodecvtImpl const &implementation() const + { + return *static_cast(this); + } + +protected: + + virtual std::codecvt_base::result do_unshift(std::mbstate_t &/*s*/,char *from,char * /*to*/,char *&next) const + { + next=from; + return std::codecvt_base::ok; + } + virtual int do_encoding() const throw() + { + return 0; + } + virtual int do_max_length() const throw() + { + return implementation().max_encoding_length(); + } + virtual bool do_always_noconv() const throw() + { + return false; + } + + virtual int + do_length( std::mbstate_t + #ifdef BOOST_LOCALE_DO_LENGTH_MBSTATE_CONST + const + #endif + &/*state*/, + char const *from, + char const *from_end, + size_t max) const + { + #ifndef BOOST_LOCALE_DO_LENGTH_MBSTATE_CONST + char const *start_from = from; + #else + size_t save_max = max; + #endif + typedef typename CodecvtImpl::state_type state_type; + state_type cvt_state = implementation().initial_state(generic_codecvt_base::to_unicode_state); + while(max > 0 && from < from_end){ + char const *save_from = from; + boost::uint32_t ch=implementation().to_unicode(cvt_state,from,from_end); + if(ch==boost::locale::utf::incomplete || ch==boost::locale::utf::illegal) { + from = save_from; + break; + } + max--; + } + #ifndef BOOST_LOCALE_DO_LENGTH_MBSTATE_CONST + return from - start_from; + #else + return save_max - max; + #endif + } + + + virtual std::codecvt_base::result + do_in( std::mbstate_t &/*state*/, + char const *from, + char const *from_end, + char const *&from_next, + uchar *to, + uchar *to_end, + uchar *&to_next) const + { + std::codecvt_base::result r=std::codecvt_base::ok; + + // mbstate_t is POD type and should be initialized to 0 (i.a. state = stateT()) + // according to standard. We use it to keep a flag 0/1 for surrogate pair writing + // + // if 0 no code above >0xFFFF observed, of 1 a code above 0xFFFF observerd + // and first pair is written, but no input consumed + typedef typename CodecvtImpl::state_type state_type; + state_type cvt_state = implementation().initial_state(generic_codecvt_base::to_unicode_state); + while(to < to_end && from < from_end) + { +#ifdef DEBUG_CODECVT + std::cout << "Entering IN--------------" << std::endl; + std::cout << "State " << std::hex << state < +class generic_codecvt : public std::codecvt, public generic_codecvt_base +{ +public: + typedef CharType uchar; + + CodecvtImpl const &implementation() const + { + return *static_cast(this); + } + + generic_codecvt(size_t refs = 0) : std::codecvt(refs) + { + } +}; + +} // locale +} // namespace boost + +#endif +/// +// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/boost/locale/gnu_gettext.hpp b/boost/locale/gnu_gettext.hpp index cc8844f3ae..ce2e7f265e 100644 --- a/boost/locale/gnu_gettext.hpp +++ b/boost/locale/gnu_gettext.hpp @@ -142,12 +142,12 @@ namespace gnu_gettext { template<> BOOST_LOCALE_DECL message_format *create_messages_facet(messages_info const &info); - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T template<> BOOST_LOCALE_DECL message_format *create_messages_facet(messages_info const &info); #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T template<> BOOST_LOCALE_DECL message_format *create_messages_facet(messages_info const &info); #endif diff --git a/boost/locale/message.hpp b/boost/locale/message.hpp index 092a2c192c..ec8f99f280 100644 --- a/boost/locale/message.hpp +++ b/boost/locale/message.hpp @@ -496,13 +496,13 @@ namespace boost { /// Convenience typedef for wchar_t /// typedef basic_message wmessage; - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T /// /// Convenience typedef for char16_t /// typedef basic_message u16message; #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T /// /// Convenience typedef for char32_t /// @@ -722,7 +722,7 @@ namespace boost { static std::locale::id id; }; - #ifdef BOOST_HAS_CHAR16_T + #ifdef BOOST_LOCALE_ENABLE_CHAR16_T template<> struct BOOST_LOCALE_DECL base_message_format : public std::locale::facet @@ -735,7 +735,7 @@ namespace boost { #endif - #ifdef BOOST_HAS_CHAR32_T + #ifdef BOOST_LOCALE_ENABLE_CHAR32_T template<> struct BOOST_LOCALE_DECL base_message_format : public std::locale::facet diff --git a/boost/locale/utf8_codecvt.hpp b/boost/locale/utf8_codecvt.hpp new file mode 100644 index 0000000000..a037c3d593 --- /dev/null +++ b/boost/locale/utf8_codecvt.hpp @@ -0,0 +1,69 @@ +// +// Copyright (c) 2015 Artyom Beilis (Tonkikh) +// +// Distributed under the 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_LOCALE_UTF8_CODECVT_HPP +#define BOOST_LOCALE_UTF8_CODECVT_HPP + +#include +#include +#include +#include + +namespace boost { +namespace locale { + +/// +/// \brief Geneneric utf8 codecvt facet, it allows to convert UTF-8 strings to UTF-16 and UTF-32 using wchar_t, char32_t and char16_t +/// +template +class utf8_codecvt : public generic_codecvt > +{ +public: + + struct state_type {}; + + utf8_codecvt(size_t refs = 0) : generic_codecvt >(refs) + { + } + + static int max_encoding_length() + { + return 4; + } + + static state_type initial_state(generic_codecvt_base::initial_convertion_state /* unused */) + { + return state_type(); + } + static utf::code_point to_unicode(state_type &,char const *&begin,char const *end) + { + char const *p=begin; + + utf::code_point c = utf::utf_traits::decode(p,end); + if(c!=utf::illegal && c!=utf::incomplete) + begin = p; + return c; + } + + static utf::code_point from_unicode(state_type &,utf::code_point u,char *begin,char const *end) + { + if(!utf::is_valid_codepoint(u)) + return utf::illegal; + int width; + if((width=utf::utf_traits::width(u)) > end - begin) + return utf::incomplete; + utf::utf_traits::encode(u,begin); + return width; + } +}; + +} // locale +} // namespace boost + +#endif +/// +// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/boost/locale/util.hpp b/boost/locale/util.hpp index 4d8206b528..022a5aad50 100644 --- a/boost/locale/util.hpp +++ b/boost/locale/util.hpp @@ -201,6 +201,21 @@ namespace util { BOOST_LOCALE_DECL std::locale create_codecvt(std::locale const &in,std::auto_ptr cvt,character_facet_type type); + /// + /// Install utf8 codecvt to UTF-16 or UTF-32 into locale \a in and return + /// new locale that is based on \a in and uses new facet. + /// + BOOST_LOCALE_DECL + std::locale create_utf8_codecvt(std::locale const &in,character_facet_type type); + + /// + /// This function installs codecvt that can be used for conversion between single byte + /// character encodings like ISO-8859-1, koi8-r, windows-1255 and Unicode code points, + /// + /// Throws boost::locale::conv::invalid_charset_error if the chacater set is not supported or isn't single byte character + /// set + BOOST_LOCALE_DECL + std::locale create_simple_codecvt(std::locale const &in,std::string const &encoding,character_facet_type type); } // util } // locale } // boost diff --git a/boost/lockfree/detail/atomic.hpp b/boost/lockfree/detail/atomic.hpp index f36ad4b6d5..47dcd8c504 100644 --- a/boost/lockfree/detail/atomic.hpp +++ b/boost/lockfree/detail/atomic.hpp @@ -18,11 +18,30 @@ #undef BOOST_LOCKFREE_NO_HDR_ATOMIC #endif + // GCC supports atomic<> from version 4.8 onwards. #if (BOOST_GCC >= 40800) && (__cplusplus >= 201103L) #undef BOOST_LOCKFREE_NO_HDR_ATOMIC #endif + +// Apple clang is 2 mayor versions ahead, but in fact 1 minor version behind +#ifdef BOOST_CLANG + +#define BOOST_ATOMIC_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) + +#if defined(__apple_build_version__) && (BOOST_ATOMIC_CLANG_VERSION >= 60100) && (__cplusplus >= 201103L) +#undef BOOST_LOCKFREE_NO_HDR_ATOMIC +#endif + +#if !defined(__apple_build_version__) && (BOOST_ATOMIC_CLANG_VERSION >= 30600) && (__cplusplus >= 201103L) +#undef BOOST_LOCKFREE_NO_HDR_ATOMIC +#endif + +#undef BOOST_ATOMIC_CLANG_VERSION + +#endif // BOOST_CLANG + #endif // BOOST_LOCKFREE_FORCE_STD_ATOMIC diff --git a/boost/lockfree/detail/branch_hints.hpp b/boost/lockfree/detail/branch_hints.hpp deleted file mode 100644 index 3a193f8b24..0000000000 --- a/boost/lockfree/detail/branch_hints.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// branch hints -// Copyright (C) 2007, 2008 Tim Blechmann -// -// Distributed under the 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_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED -#define BOOST_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED - -namespace boost { -namespace lockfree { -namespace detail { -/** \brief hint for the branch prediction */ -inline bool likely(bool expr) -{ -#ifdef __GNUC__ - return __builtin_expect(expr, true); -#else - return expr; -#endif - } - -/** \brief hint for the branch prediction */ -inline bool unlikely(bool expr) -{ -#ifdef __GNUC__ - return __builtin_expect(expr, false); -#else - return expr; -#endif -} - -} /* namespace detail */ -} /* namespace lockfree */ -} /* namespace boost */ - -#endif /* BOOST_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED */ diff --git a/boost/lockfree/detail/freelist.hpp b/boost/lockfree/detail/freelist.hpp index b053dce00c..6b84e6c974 100644 --- a/boost/lockfree/detail/freelist.hpp +++ b/boost/lockfree/detail/freelist.hpp @@ -296,7 +296,7 @@ public: tag_t get_next_tag() const { - tag_t next = (get_tag() + 1) & (std::numeric_limits::max)(); + tag_t next = (get_tag() + 1u) & (std::numeric_limits::max)(); return next; } diff --git a/boost/lockfree/detail/tagged_ptr_dcas.hpp b/boost/lockfree/detail/tagged_ptr_dcas.hpp index 8bc68386e6..6cb5a0616b 100644 --- a/boost/lockfree/detail/tagged_ptr_dcas.hpp +++ b/boost/lockfree/detail/tagged_ptr_dcas.hpp @@ -12,7 +12,6 @@ #include /* for std::size_t */ #include -#include namespace boost { namespace lockfree { diff --git a/boost/lockfree/detail/tagged_ptr_ptrcompression.hpp b/boost/lockfree/detail/tagged_ptr_ptrcompression.hpp index e99e6bff6c..15d383018c 100644 --- a/boost/lockfree/detail/tagged_ptr_ptrcompression.hpp +++ b/boost/lockfree/detail/tagged_ptr_ptrcompression.hpp @@ -14,7 +14,6 @@ #include -#include namespace boost { namespace lockfree { @@ -52,7 +51,7 @@ private: return cu.tag[tag_index]; } - static compressed_ptr_t pack_ptr(T * ptr, int tag) + static compressed_ptr_t pack_ptr(T * ptr, tag_t tag) { cast_unit ret; ret.value = compressed_ptr_t(ptr); @@ -132,7 +131,7 @@ public: tag_t get_next_tag() const { - tag_t next = (get_tag() + 1) & (std::numeric_limits::max)(); + tag_t next = (get_tag() + 1u) & (std::numeric_limits::max)(); return next; } diff --git a/boost/lockfree/queue.hpp b/boost/lockfree/queue.hpp index 74001fba9d..4c982c4dd4 100644 --- a/boost/lockfree/queue.hpp +++ b/boost/lockfree/queue.hpp @@ -15,6 +15,7 @@ #include #include #include +#include // for BOOST_LIKELY #include #include @@ -286,8 +287,6 @@ private: template bool do_push(T const & t) { - using detail::likely; - node * n = pool.template construct(t, pool.null_handle()); handle_type node_handle = pool.get_handle(n); @@ -301,7 +300,7 @@ private: node * next_ptr = pool.get_pointer(next); tagged_node_handle tail2 = tail_.load(memory_order_acquire); - if (likely(tail == tail2)) { + if (BOOST_LIKELY(tail == tail2)) { if (next_ptr == 0) { tagged_node_handle new_tail_next(node_handle, next.get_next_tag()); if ( tail_node->next.compare_exchange_weak(next, new_tail_next) ) { @@ -375,7 +374,6 @@ public: template bool pop (U & ret) { - using detail::likely; for (;;) { tagged_node_handle head = head_.load(memory_order_acquire); node * head_ptr = pool.get_pointer(head); @@ -385,7 +383,7 @@ public: node * next_ptr = pool.get_pointer(next); tagged_node_handle head2 = head_.load(memory_order_acquire); - if (likely(head == head2)) { + if (BOOST_LIKELY(head == head2)) { if (pool.get_handle(head) == pool.get_handle(tail)) { if (next_ptr == 0) return false; diff --git a/boost/lockfree/spsc_queue.hpp b/boost/lockfree/spsc_queue.hpp index 3fbbea7a86..b877cde4db 100644 --- a/boost/lockfree/spsc_queue.hpp +++ b/boost/lockfree/spsc_queue.hpp @@ -18,12 +18,12 @@ #include #include #include +#include // for BOOST_LIKELY #include #include #include -#include #include #include #include @@ -62,7 +62,7 @@ protected: static size_t next_index(size_t arg, size_t max_size) { size_t ret = arg + 1; - while (unlikely(ret >= max_size)) + while (BOOST_UNLIKELY(ret >= max_size)) ret -= max_size; return ret; } @@ -709,13 +709,13 @@ public: } template - explicit spsc_queue(typename allocator::template rebind::other const & alloc) + explicit spsc_queue(typename allocator::template rebind::other const &) { // just for API compatibility: we don't actually need an allocator BOOST_STATIC_ASSERT(!runtime_sized); } - explicit spsc_queue(allocator const & alloc) + explicit spsc_queue(allocator const &) { // just for API compatibility: we don't actually need an allocator BOOST_ASSERT(!runtime_sized); diff --git a/boost/log/attributes/attribute_set.hpp b/boost/log/attributes/attribute_set.hpp index c44d03fe52..05fa3aaa96 100644 --- a/boost/log/attributes/attribute_set.hpp +++ b/boost/log/attributes/attribute_set.hpp @@ -60,9 +60,16 @@ public: } //! Conversion operator (would be invoked in case of reading from the container) - operator mapped_type() const BOOST_NOEXCEPT; + BOOST_FORCEINLINE operator mapped_type() const BOOST_NOEXCEPT + { + return read_mapped_value(); + } //! Assignment operator (would be invoked in case of writing to the container) mapped_type& operator= (mapped_type const& val) const; + +private: + //! Reads the referenced mapped value from the container + mapped_type read_mapped_value() const BOOST_NOEXCEPT; }; } // namespace aux @@ -468,8 +475,8 @@ inline void swap(attribute_set& left, attribute_set& right) BOOST_NOEXCEPT namespace aux { -//! Conversion operator (would be invoked in case of reading from the container) -inline attribute_set_reference_proxy::operator mapped_type() const BOOST_NOEXCEPT +//! Reads the referenced mapped value from the container +inline attribute_set_reference_proxy::mapped_type attribute_set_reference_proxy::read_mapped_value() const BOOST_NOEXCEPT { attribute_set::iterator it = m_pContainer->find(m_key); if (it != m_pContainer->end()) diff --git a/boost/log/attributes/counter.hpp b/boost/log/attributes/counter.hpp index 6cd5bd8ce0..b7d9994027 100644 --- a/boost/log/attributes/counter.hpp +++ b/boost/log/attributes/counter.hpp @@ -22,7 +22,8 @@ #include #include #ifndef BOOST_LOG_NO_THREADS -#include +#include +#include #endif // BOOST_LOG_NO_THREADS #include @@ -39,37 +40,50 @@ namespace attributes { /*! * \brief A class of an attribute that counts an integral value * - * This type of attribute acts as a counter, that is, it returns a monotonously + * This attribute acts as a counter - it returns a monotonously * changing value each time requested. The attribute value type can be specified - * as a template parameter. However, the type must be an integral type of size no - * more than sizeof(long). + * as a template parameter. The type must be an integral type. */ template< typename T > class counter : public attribute { - // For now only integral types up to long are supported - BOOST_STATIC_ASSERT_MSG(is_integral< T >::value && sizeof(T) <= sizeof(long), "Boost.Log: Only integral types up to long are supported by counter attribute"); + BOOST_STATIC_ASSERT_MSG(is_integral< T >::value, "Boost.Log: Only integral types are supported by the counter attribute"); public: //! A counter value type typedef T value_type; protected: - //! Base class for factory implementation - class BOOST_LOG_NO_VTABLE BOOST_SYMBOL_VISIBLE impl : + //! Factory implementation + class BOOST_SYMBOL_VISIBLE impl : public attribute::impl { - }; + private: +#ifndef BOOST_LOG_NO_THREADS + boost::atomic< value_type > m_counter; +#else + value_type m_counter; +#endif + const value_type m_step; + + public: + impl(value_type initial, value_type step) BOOST_NOEXCEPT : + m_counter(initial), m_step(step) + { + } - //! Generic factory implementation - class impl_generic; + attribute_value get_value() + { #ifndef BOOST_LOG_NO_THREADS - //! Increment-by-one factory implementation - class impl_inc; - //! Decrement-by-one factory implementation - class impl_dec; + value_type value = m_counter.fetch_add(m_step, boost::memory_order_relaxed); +#else + value_type value = m_counter; + m_counter += m_step; #endif + return make_attribute_value(value); + } + }; public: /*! @@ -77,24 +91,13 @@ public: * * \param initial Initial value of the counter * \param step Changing step of the counter. Each value acquired from the attribute - * will be greater than the previous one to this amount. + * will be greater than the previous one by this amount. */ - explicit counter(value_type initial = (value_type)0, long step = 1) : -#ifndef BOOST_LOG_NO_THREADS - attribute() - { - if (step == 1) - this->set_impl(new impl_inc(initial)); - else if (step == -1) - this->set_impl(new impl_dec(initial)); - else - this->set_impl(new impl_generic(initial, step)); - } -#else - attribute(new impl_generic(initial, step)) + explicit counter(value_type initial = (value_type)0, value_type step = (value_type)1) : + attribute(new impl(initial, step)) { } -#endif + /*! * Constructor for casting support */ @@ -104,109 +107,6 @@ public: } }; -#ifndef BOOST_LOG_NO_THREADS - -template< typename T > -class counter< T >::impl_generic : - public impl -{ -private: - //! Initial value - const value_type m_Initial; - //! Step value - const long m_Step; - //! The counter - boost::detail::atomic_count m_Counter; - -public: - /*! - * Initializing constructor - */ - impl_generic(value_type initial, long step) : m_Initial(initial), m_Step(step), m_Counter(-1) - { - } - - attribute_value get_value() - { - const unsigned long next_counter = static_cast< unsigned long >(++m_Counter); - value_type next = static_cast< value_type >(m_Initial + (next_counter * m_Step)); - return make_attribute_value(next); - } -}; - -template< typename T > -class counter< T >::impl_inc : - public impl -{ -private: - //! The counter - boost::detail::atomic_count m_Counter; - -public: - /*! - * Initializing constructor - */ - explicit impl_inc(value_type initial) : m_Counter(initial - 1) - { - } - - attribute_value get_value() - { - return make_attribute_value(static_cast< value_type >(++m_Counter)); - } -}; - -template< typename T > -class counter< T >::impl_dec : - public impl -{ -private: - //! The counter - boost::detail::atomic_count m_Counter; - -public: - /*! - * Initializing constructor - */ - explicit impl_dec(value_type initial) : m_Counter(initial + 1) - { - } - - attribute_value get_value() - { - return make_attribute_value(static_cast< value_type >(--m_Counter)); - } -}; - -#else // BOOST_LOG_NO_THREADS - -template< typename T > -class counter< T >::impl_generic : - public impl -{ -private: - //! Step value - const long m_Step; - //! The counter - value_type m_Counter; - -public: - /*! - * Initializing constructor - */ - impl_generic(value_type initial, long step) : m_Step(step), m_Counter(initial - step) - { - } - - attribute_value get_value() - { - m_Counter += m_Step; - return make_attribute_value(m_Counter); - } -}; - -#endif // BOOST_LOG_NO_THREADS - } // namespace attributes BOOST_LOG_CLOSE_NAMESPACE // namespace log diff --git a/boost/log/detail/adaptive_mutex.hpp b/boost/log/detail/adaptive_mutex.hpp new file mode 100644 index 0000000000..25e7559e17 --- /dev/null +++ b/boost/log/detail/adaptive_mutex.hpp @@ -0,0 +1,244 @@ +/* + * Copyright Andrey Semashev 2007 - 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) + */ +/*! + * \file adaptive_mutex.hpp + * \author Andrey Semashev + * \date 01.08.2010 + * + * \brief This header is the Boost.Log library implementation, see the library documentation + * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. + */ + +#ifndef BOOST_LOG_DETAIL_ADAPTIVE_MUTEX_HPP_INCLUDED_ +#define BOOST_LOG_DETAIL_ADAPTIVE_MUTEX_HPP_INCLUDED_ + +#include + +#ifdef BOOST_HAS_PRAGMA_ONCE +#pragma once +#endif + +#ifndef BOOST_LOG_NO_THREADS + +#include +#include + +#if defined(BOOST_THREAD_POSIX) // This one can be defined by users, so it should go first +#define BOOST_LOG_ADAPTIVE_MUTEX_USE_PTHREAD +#elif defined(BOOST_WINDOWS) +#define BOOST_LOG_ADAPTIVE_MUTEX_USE_WINAPI +#elif defined(BOOST_HAS_PTHREADS) +#define BOOST_LOG_ADAPTIVE_MUTEX_USE_PTHREAD +#endif + +#if defined(BOOST_LOG_ADAPTIVE_MUTEX_USE_WINAPI) + +#include +#include + +#if defined(__INTEL_COMPILER) || defined(_MSC_VER) +# if defined(_M_IX86) +# define BOOST_LOG_PAUSE_OP __asm { pause } +# elif defined(_M_AMD64) +extern "C" void _mm_pause(void); +# if defined(BOOST_MSVC) +# pragma intrinsic(_mm_pause) +# endif +# define BOOST_LOG_PAUSE_OP _mm_pause() +# endif +# if defined(__INTEL_COMPILER) +# define BOOST_LOG_COMPILER_BARRIER __memory_barrier() +# else +extern "C" void _ReadWriteBarrier(void); +# if defined(BOOST_MSVC) +# pragma intrinsic(_ReadWriteBarrier) +# endif +# define BOOST_LOG_COMPILER_BARRIER _ReadWriteBarrier() +# endif +#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) +# define BOOST_LOG_PAUSE_OP __asm__ __volatile__("pause;") +# define BOOST_LOG_COMPILER_BARRIER __asm__ __volatile__("" : : : "memory") +#endif + +#include + +namespace boost { + +BOOST_LOG_OPEN_NAMESPACE + +namespace aux { + +//! A mutex that performs spinning or thread yielding in case of contention +class adaptive_mutex +{ +private: + enum state + { + initial_pause = 2, + max_pause = 16 + }; + + long m_State; + +public: + adaptive_mutex() : m_State(0) {} + + bool try_lock() + { + return (BOOST_INTERLOCKED_COMPARE_EXCHANGE(&m_State, 1L, 0L) == 0L); + } + + void lock() + { +#if defined(BOOST_LOG_PAUSE_OP) + unsigned int pause_count = initial_pause; +#endif + while (!try_lock()) + { +#if defined(BOOST_LOG_PAUSE_OP) + if (pause_count < max_pause) + { + for (unsigned int i = 0; i < pause_count; ++i) + { + BOOST_LOG_PAUSE_OP; + } + pause_count += pause_count; + } + else + { + // Restart spinning after waking up this thread + pause_count = initial_pause; + SwitchToThread(); + } +#else + SwitchToThread(); +#endif + } + } + + void unlock() + { +#if (defined(_M_IX86) || defined(_M_AMD64)) && defined(BOOST_LOG_COMPILER_BARRIER) + BOOST_LOG_COMPILER_BARRIER; + m_State = 0L; + BOOST_LOG_COMPILER_BARRIER; +#else + BOOST_INTERLOCKED_EXCHANGE(&m_State, 0L); +#endif + } + + // Non-copyable + BOOST_DELETED_FUNCTION(adaptive_mutex(adaptive_mutex const&)) + BOOST_DELETED_FUNCTION(adaptive_mutex& operator= (adaptive_mutex const&)) +}; + +#undef BOOST_LOG_PAUSE_OP +#undef BOOST_LOG_COMPILER_BARRIER + +} // namespace aux + +BOOST_LOG_CLOSE_NAMESPACE // namespace log + +} // namespace boost + +#include + +#elif defined(BOOST_LOG_ADAPTIVE_MUTEX_USE_PTHREAD) + +#include +#include +#include + +#if defined(PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) +#define BOOST_LOG_ADAPTIVE_MUTEX_USE_PTHREAD_MUTEX_ADAPTIVE_NP +#endif + +namespace boost { + +BOOST_LOG_OPEN_NAMESPACE + +namespace aux { + +//! A mutex that performs spinning or thread yielding in case of contention +class adaptive_mutex +{ +private: + pthread_mutex_t m_State; + +public: + adaptive_mutex() + { +#if defined(BOOST_LOG_ADAPTIVE_MUTEX_USE_PTHREAD_MUTEX_ADAPTIVE_NP) + pthread_mutexattr_t attrs; + pthread_mutexattr_init(&attrs); + pthread_mutexattr_settype(&attrs, PTHREAD_MUTEX_ADAPTIVE_NP); + + const int err = pthread_mutex_init(&m_State, &attrs); + pthread_mutexattr_destroy(&attrs); +#else + const int err = pthread_mutex_init(&m_State, NULL); +#endif + if (BOOST_UNLIKELY(err != 0)) + throw_exception< thread_resource_error >(err, "Failed to initialize an adaptive mutex", "adaptive_mutex::adaptive_mutex()", __FILE__, __LINE__); + } + + ~adaptive_mutex() + { + BOOST_VERIFY(pthread_mutex_destroy(&m_State) == 0); + } + + bool try_lock() + { + const int err = pthread_mutex_trylock(&m_State); + if (err == 0) + return true; + if (BOOST_UNLIKELY(err != EBUSY)) + throw_exception< lock_error >(err, "Failed to lock an adaptive mutex", "adaptive_mutex::try_lock()", __FILE__, __LINE__); + return false; + } + + void lock() + { + const int err = pthread_mutex_lock(&m_State); + if (BOOST_UNLIKELY(err != 0)) + throw_exception< lock_error >(err, "Failed to lock an adaptive mutex", "adaptive_mutex::lock()", __FILE__, __LINE__); + } + + void unlock() + { + BOOST_VERIFY(pthread_mutex_unlock(&m_State) == 0); + } + + // Non-copyable + BOOST_DELETED_FUNCTION(adaptive_mutex(adaptive_mutex const&)) + BOOST_DELETED_FUNCTION(adaptive_mutex& operator= (adaptive_mutex const&)) + +private: + template< typename ExceptionT > + static BOOST_NOINLINE BOOST_LOG_NORETURN void throw_exception(int err, const char* descr, const char* func, const char* file, int line) + { +#if !defined(BOOST_EXCEPTION_DISABLE) + boost::exception_detail::throw_exception_(ExceptionT(err, descr), func, file, line); +#else + boost::throw_exception(ExceptionT(err, descr)); +#endif + } +}; + +} // namespace aux + +BOOST_LOG_CLOSE_NAMESPACE // namespace log + +} // namespace boost + +#include + +#endif + +#endif // BOOST_LOG_NO_THREADS + +#endif // BOOST_LOG_DETAIL_ADAPTIVE_MUTEX_HPP_INCLUDED_ diff --git a/boost/log/detail/code_conversion.hpp b/boost/log/detail/code_conversion.hpp index 41c086e109..86cdfd8800 100644 --- a/boost/log/detail/code_conversion.hpp +++ b/boost/log/detail/code_conversion.hpp @@ -34,6 +34,9 @@ BOOST_LOG_OPEN_NAMESPACE namespace aux { +// Implementation note: We have to implement char<->wchar_t conversions even in the absence of the native wchar_t +// type. These conversions are used in sinks, e.g. to convert multibyte strings to wide-character filesystem paths. + //! The function converts one string to the character type of another BOOST_LOG_API void code_convert_impl(const wchar_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale()); //! The function converts one string to the character type of another @@ -111,8 +114,12 @@ inline std::string const& to_narrow(std::string const& str, std::locale const&) inline std::string to_narrow(std::wstring const& str, std::locale const& loc = std::locale()) { std::string res; - aux::code_convert(str, res, loc); + aux::code_convert_impl(str.c_str(), str.size(), res, loc); +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + return static_cast< std::string&& >(res); +#else return res; +#endif } //! The function converts the passed string to the wide-character encoding @@ -131,8 +138,12 @@ inline std::wstring const& to_wide(std::wstring const& str, std::locale const&) inline std::wstring to_wide(std::string const& str, std::locale const& loc = std::locale()) { std::wstring res; - aux::code_convert(str, res, loc); + aux::code_convert_impl(str.c_str(), str.size(), res, loc); +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + return static_cast< std::wstring&& >(res); +#else return res; +#endif } } // namespace aux diff --git a/boost/log/detail/config.hpp b/boost/log/detail/config.hpp index 64b4412383..5ddfd403b6 100644 --- a/boost/log/detail/config.hpp +++ b/boost/log/detail/config.hpp @@ -26,10 +26,15 @@ #include // To bring in libc macros #include +// The library requires dynamic_cast in a few places #if defined(BOOST_NO_RTTI) # error Boost.Log: RTTI is required by the library #endif +#if defined(BOOST_WINDOWS) +#include +#endif + #if defined(_MSC_VER) && _MSC_VER >= 1600 # define BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH #endif @@ -181,13 +186,8 @@ # endif # if defined(BOOST_LOG_DLL) -# if defined(BOOST_SYMBOL_IMPORT) -# define BOOST_LOG_API BOOST_SYMBOL_IMPORT -# elif defined(BOOST_HAS_DECLSPEC) -# define BOOST_LOG_API __declspec(dllimport) -# endif -# endif -# ifndef BOOST_LOG_API +# define BOOST_LOG_API BOOST_SYMBOL_IMPORT +# else # define BOOST_LOG_API # endif // @@ -221,13 +221,8 @@ #else // !defined(BOOST_LOG_BUILDING_THE_LIB) # if defined(BOOST_LOG_DLL) -# if defined(BOOST_SYMBOL_EXPORT) -# define BOOST_LOG_API BOOST_SYMBOL_EXPORT -# elif defined(BOOST_HAS_DECLSPEC) -# define BOOST_LOG_API __declspec(dllexport) -# endif -# endif -# ifndef BOOST_LOG_API +# define BOOST_LOG_API BOOST_SYMBOL_EXPORT +# else # define BOOST_LOG_API BOOST_SYMBOL_VISIBLE # endif @@ -287,11 +282,11 @@ namespace boost { # if defined(BOOST_THREAD_PLATFORM_PTHREAD) # define BOOST_LOG_VERSION_NAMESPACE v2_mt_posix # elif defined(BOOST_THREAD_PLATFORM_WIN32) -# if defined(BOOST_LOG_USE_WINNT6_API) +# if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 # define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt6 # else # define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt5 -# endif // defined(BOOST_LOG_USE_WINNT6_API) +# endif # else # define BOOST_LOG_VERSION_NAMESPACE v2_mt # endif @@ -303,11 +298,11 @@ namespace boost { # if defined(BOOST_THREAD_PLATFORM_PTHREAD) # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_posix # elif defined(BOOST_THREAD_PLATFORM_WIN32) -# if defined(BOOST_LOG_USE_WINNT6_API) +# if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt6 # else # define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt5 -# endif // defined(BOOST_LOG_USE_WINNT6_API) +# endif # else # define BOOST_LOG_VERSION_NAMESPACE v2s_mt # endif diff --git a/boost/log/detail/is_character_type.hpp b/boost/log/detail/is_character_type.hpp index 29f7dccd55..9b5e9ee2c4 100644 --- a/boost/log/detail/is_character_type.hpp +++ b/boost/log/detail/is_character_type.hpp @@ -40,13 +40,11 @@ struct is_character_type< char > static BOOST_CONSTEXPR_OR_CONST bool value = true; }; -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) template< > struct is_character_type< wchar_t > { static BOOST_CONSTEXPR_OR_CONST bool value = true; }; -#endif #if !defined(BOOST_NO_CXX11_CHAR16_T) template< > diff --git a/boost/log/detail/light_rw_mutex.hpp b/boost/log/detail/light_rw_mutex.hpp index 5b064c64b7..1ecf700047 100644 --- a/boost/log/detail/light_rw_mutex.hpp +++ b/boost/log/detail/light_rw_mutex.hpp @@ -28,7 +28,7 @@ #if defined(BOOST_THREAD_POSIX) // This one can be defined by users, so it should go first #define BOOST_LOG_LWRWMUTEX_USE_PTHREAD -#elif defined(BOOST_WINDOWS) && defined(BOOST_LOG_USE_WINNT6_API) +#elif defined(BOOST_WINDOWS) && (BOOST_USE_WINAPI_VERSION+0) >= (BOOST_WINAPI_VERSION_WIN6+0) #define BOOST_LOG_LWRWMUTEX_USE_SRWLOCK #elif defined(BOOST_HAS_PTHREADS) #define BOOST_LOG_LWRWMUTEX_USE_PTHREAD @@ -36,40 +36,7 @@ #if defined(BOOST_LOG_LWRWMUTEX_USE_SRWLOCK) -#if defined(BOOST_USE_WINDOWS_H) - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 // _WIN32_WINNT_LONGHORN -#endif - -#include - -#else // defined(BOOST_USE_WINDOWS_H) - -namespace boost { - -BOOST_LOG_OPEN_NAMESPACE - -namespace aux { - -extern "C" { - -struct SRWLOCK { void* p; }; -__declspec(dllimport) void __stdcall InitializeSRWLock(SRWLOCK*); -__declspec(dllimport) void __stdcall ReleaseSRWLockExclusive(SRWLOCK*); -__declspec(dllimport) void __stdcall ReleaseSRWLockShared(SRWLOCK*); -__declspec(dllimport) void __stdcall AcquireSRWLockExclusive(SRWLOCK*); -__declspec(dllimport) void __stdcall AcquireSRWLockShared(SRWLOCK*); - -} // extern "C" - -} // namespace aux - -BOOST_LOG_CLOSE_NAMESPACE // namespace log - -} // namespace boost - -#endif // BOOST_USE_WINDOWS_H +#include namespace boost { @@ -80,28 +47,28 @@ namespace aux { //! A light read/write mutex that uses WinNT 6 and later APIs class light_rw_mutex { - SRWLOCK m_Mutex; + boost::detail::winapi::SRWLOCK_ m_Mutex; public: light_rw_mutex() { - InitializeSRWLock(&m_Mutex); + boost::detail::winapi::InitializeSRWLock(&m_Mutex); } void lock_shared() { - AcquireSRWLockShared(&m_Mutex); + boost::detail::winapi::AcquireSRWLockShared(&m_Mutex); } void unlock_shared() { - ReleaseSRWLockShared(&m_Mutex); + boost::detail::winapi::ReleaseSRWLockShared(&m_Mutex); } void lock() { - AcquireSRWLockExclusive(&m_Mutex); + boost::detail::winapi::AcquireSRWLockExclusive(&m_Mutex); } void unlock() { - ReleaseSRWLockExclusive(&m_Mutex); + boost::detail::winapi::ReleaseSRWLockExclusive(&m_Mutex); } // Noncopyable diff --git a/boost/log/detail/setup_config.hpp b/boost/log/detail/setup_config.hpp index fec50fba56..8fde5b3e86 100644 --- a/boost/log/detail/setup_config.hpp +++ b/boost/log/detail/setup_config.hpp @@ -30,11 +30,12 @@ # define BOOST_LOG_SETUP_DLL # endif -# if defined(BOOST_HAS_DECLSPEC) && defined(BOOST_LOG_SETUP_DLL) -# define BOOST_LOG_SETUP_API __declspec(dllimport) +# if defined(BOOST_LOG_SETUP_DLL) +# define BOOST_LOG_SETUP_API BOOST_SYMBOL_IMPORT # else # define BOOST_LOG_SETUP_API -# endif // defined(BOOST_HAS_DECLSPEC) +# endif + // // Automatically link to the correct build variant where possible. // @@ -48,12 +49,10 @@ #else // !defined(BOOST_LOG_SETUP_BUILDING_THE_LIB) -# if defined(BOOST_HAS_DECLSPEC) && defined(BOOST_LOG_SETUP_DLL) -# define BOOST_LOG_SETUP_API __declspec(dllexport) -# elif defined(__GNUC__) && __GNUC__ >= 4 && (defined(linux) || defined(__linux) || defined(__linux__)) -# define BOOST_LOG_SETUP_API __attribute__((visibility("default"))) +# if defined(BOOST_LOG_SETUP_DLL) +# define BOOST_LOG_SETUP_API BOOST_SYMBOL_EXPORT # else -# define BOOST_LOG_SETUP_API +# define BOOST_LOG_SETUP_API BOOST_SYMBOL_VISIBLE # endif #endif // !defined(BOOST_LOG_SETUP_BUILDING_THE_LIB) diff --git a/boost/log/detail/spin_mutex.hpp b/boost/log/detail/spin_mutex.hpp deleted file mode 100644 index 866c4af0a6..0000000000 --- a/boost/log/detail/spin_mutex.hpp +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright Andrey Semashev 2007 - 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) - */ -/*! - * \file spin_mutex.hpp - * \author Andrey Semashev - * \date 01.08.2010 - * - * \brief This header is the Boost.Log library implementation, see the library documentation - * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. - */ - -#ifndef BOOST_LOG_DETAIL_SPIN_MUTEX_HPP_INCLUDED_ -#define BOOST_LOG_DETAIL_SPIN_MUTEX_HPP_INCLUDED_ - -#include - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -#ifndef BOOST_LOG_NO_THREADS - -#include -#include - -#if defined(BOOST_THREAD_POSIX) // This one can be defined by users, so it should go first -#define BOOST_LOG_SPIN_MUTEX_USE_PTHREAD -#elif defined(BOOST_WINDOWS) -#define BOOST_LOG_SPIN_MUTEX_USE_WINAPI -#elif defined(BOOST_HAS_PTHREADS) -#define BOOST_LOG_SPIN_MUTEX_USE_PTHREAD -#endif - -#if defined(BOOST_LOG_SPIN_MUTEX_USE_WINAPI) - -#include - -#if defined(BOOST_USE_WINDOWS_H) - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0500 -#endif - -#include - -#else // defined(BOOST_USE_WINDOWS_H) - -namespace boost { - -BOOST_LOG_OPEN_NAMESPACE - -namespace aux { - -extern "C" { - -__declspec(dllimport) int __stdcall SwitchToThread(); - -} // extern "C" - -} // namespace aux - -BOOST_LOG_CLOSE_NAMESPACE // namespace log - -} // namespace boost - -#endif // BOOST_USE_WINDOWS_H - -#if defined(__INTEL_COMPILER) || defined(_MSC_VER) -# if defined(_M_IX86) -# define BOOST_LOG_PAUSE_OP __asm { pause } -# elif defined(_M_AMD64) -extern "C" void _mm_pause(void); -#pragma intrinsic(_mm_pause) -# define BOOST_LOG_PAUSE_OP _mm_pause() -# endif -# if defined(__INTEL_COMPILER) -# define BOOST_LOG_COMPILER_BARRIER __memory_barrier() -# else -extern "C" void _ReadWriteBarrier(void); -#pragma intrinsic(_ReadWriteBarrier) -# define BOOST_LOG_COMPILER_BARRIER _ReadWriteBarrier() -# endif -#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) -# define BOOST_LOG_PAUSE_OP __asm__ __volatile__("pause;") -# define BOOST_LOG_COMPILER_BARRIER __asm__ __volatile__("" : : : "memory") -#endif - -#include - -namespace boost { - -BOOST_LOG_OPEN_NAMESPACE - -namespace aux { - -//! A simple spinning mutex -class spin_mutex -{ -private: - enum state - { - initial_pause = 2, - max_pause = 16 - }; - - long m_State; - -public: - spin_mutex() : m_State(0) {} - - bool try_lock() - { - return (BOOST_INTERLOCKED_COMPARE_EXCHANGE(&m_State, 1L, 0L) == 0L); - } - - void lock() - { -#if defined(BOOST_LOG_PAUSE_OP) - unsigned int pause_count = initial_pause; -#endif - while (!try_lock()) - { -#if defined(BOOST_LOG_PAUSE_OP) - if (pause_count < max_pause) - { - for (unsigned int i = 0; i < pause_count; ++i) - { - BOOST_LOG_PAUSE_OP; - } - pause_count += pause_count; - } - else - { - // Restart spinning after waking up this thread - pause_count = initial_pause; - SwitchToThread(); - } -#else - SwitchToThread(); -#endif - } - } - - void unlock() - { -#if (defined(_M_IX86) || defined(_M_AMD64)) && defined(BOOST_LOG_COMPILER_BARRIER) - BOOST_LOG_COMPILER_BARRIER; - m_State = 0L; - BOOST_LOG_COMPILER_BARRIER; -#else - BOOST_INTERLOCKED_EXCHANGE(&m_State, 0L); -#endif - } - - // Non-copyable - BOOST_DELETED_FUNCTION(spin_mutex(spin_mutex const&)) - BOOST_DELETED_FUNCTION(spin_mutex& operator= (spin_mutex const&)) -}; - -#undef BOOST_LOG_PAUSE_OP -#undef BOOST_LOG_COMPILER_BARRIER - -} // namespace aux - -BOOST_LOG_CLOSE_NAMESPACE // namespace log - -} // namespace boost - -#include - -#elif defined(BOOST_LOG_SPIN_MUTEX_USE_PTHREAD) - -#include -#include -#include - -namespace boost { - -BOOST_LOG_OPEN_NAMESPACE - -namespace aux { - -#if defined(_POSIX_SPIN_LOCKS) && _POSIX_SPIN_LOCKS > 0 - -//! A simple spinning mutex -class spin_mutex -{ -private: - pthread_spinlock_t m_State; - -public: - spin_mutex() - { - const int err = pthread_spin_init(&m_State, PTHREAD_PROCESS_PRIVATE); - if (err != 0) - throw_exception< thread_resource_error >(err, "failed to initialize a spin mutex", "spin_mutex::spin_mutex()", __FILE__, __LINE__); - } - - ~spin_mutex() - { - BOOST_VERIFY(pthread_spin_destroy(&m_State) == 0); - } - - bool try_lock() - { - const int err = pthread_spin_trylock(&m_State); - if (err == 0) - return true; - if (err != EBUSY) - throw_exception< lock_error >(err, "failed to lock a spin mutex", "spin_mutex::try_lock()", __FILE__, __LINE__); - return false; - } - - void lock() - { - const int err = pthread_spin_lock(&m_State); - if (err != 0) - throw_exception< lock_error >(err, "failed to lock a spin mutex", "spin_mutex::lock()", __FILE__, __LINE__); - } - - void unlock() - { - BOOST_VERIFY(pthread_spin_unlock(&m_State) == 0); - } - - // Non-copyable - BOOST_DELETED_FUNCTION(spin_mutex(spin_mutex const&)) - BOOST_DELETED_FUNCTION(spin_mutex& operator= (spin_mutex const&)) - -private: - template< typename ExceptionT > - static BOOST_NOINLINE BOOST_LOG_NORETURN void throw_exception(int err, const char* descr, const char* func, const char* file, int line) - { -#if !defined(BOOST_EXCEPTION_DISABLE) - boost::exception_detail::throw_exception_(ExceptionT(err, descr), func, file, line); -#else - boost::throw_exception(ExceptionT(err, descr)); -#endif - } -}; - -#else // defined(_POSIX_SPIN_LOCKS) - -//! Backup implementation in case if pthreads don't support spin locks -class spin_mutex -{ -private: - pthread_mutex_t m_State; - -public: - spin_mutex() - { - const int err = pthread_mutex_init(&m_State, NULL); - if (err != 0) - throw_exception< thread_resource_error >(err, "failed to initialize a spin mutex", "spin_mutex::spin_mutex()", __FILE__, __LINE__); - } - - ~spin_mutex() - { - BOOST_VERIFY(pthread_mutex_destroy(&m_State) == 0); - } - - bool try_lock() - { - const int err = pthread_mutex_trylock(&m_State); - if (err == 0) - return true; - if (err != EBUSY) - throw_exception< lock_error >(err, "failed to lock a spin mutex", "spin_mutex::try_lock()", __FILE__, __LINE__); - return false; - } - - void lock() - { - const int err = pthread_mutex_lock(&m_State); - if (err != 0) - throw_exception< lock_error >(err, "failed to lock a spin mutex", "spin_mutex::lock()", __FILE__, __LINE__); - } - - void unlock() - { - BOOST_VERIFY(pthread_mutex_unlock(&m_State) == 0); - } - - // Non-copyable - BOOST_DELETED_FUNCTION(spin_mutex(spin_mutex const&)) - BOOST_DELETED_FUNCTION(spin_mutex& operator= (spin_mutex const&)) - -private: - template< typename ExceptionT > - static BOOST_NOINLINE BOOST_LOG_NORETURN void throw_exception(int err, const char* descr, const char* func, const char* file, int line) - { -#if !defined(BOOST_EXCEPTION_DISABLE) - boost::exception_detail::throw_exception_(ExceptionT(err, descr), func, file, line); -#else - boost::throw_exception(ExceptionT(err, descr)); -#endif - } -}; - -#endif // defined(_POSIX_SPIN_LOCKS) - -} // namespace aux - -BOOST_LOG_CLOSE_NAMESPACE // namespace log - -} // namespace boost - -#include - -#endif - -#endif // BOOST_LOG_NO_THREADS - -#endif // BOOST_LOG_DETAIL_SPIN_MUTEX_HPP_INCLUDED_ diff --git a/boost/log/detail/thread_specific.hpp b/boost/log/detail/thread_specific.hpp index 8f5958c886..7e38be5aab 100644 --- a/boost/log/detail/thread_specific.hpp +++ b/boost/log/detail/thread_specific.hpp @@ -38,11 +38,11 @@ namespace aux { class thread_specific_base { private: - union key_storage - { - void* as_pointer; - unsigned int as_dword; - }; +#if defined(BOOST_THREAD_PLATFORM_WIN32) + typedef unsigned long key_storage; +#else + typedef void* key_storage; +#endif key_storage m_Key; diff --git a/boost/log/expressions/formatter.hpp b/boost/log/expressions/formatter.hpp index 09eb57c0d5..5dc6a5b132 100644 --- a/boost/log/expressions/formatter.hpp +++ b/boost/log/expressions/formatter.hpp @@ -15,6 +15,8 @@ #ifndef BOOST_LOG_EXPRESSIONS_FORMATTER_HPP_INCLUDED_ #define BOOST_LOG_EXPRESSIONS_FORMATTER_HPP_INCLUDED_ +#include +#include #include #include #include @@ -53,10 +55,80 @@ class stream_ref : public reference_wrapper< StreamT > { public: + typedef typename StreamT::char_type char_type; + typedef typename StreamT::traits_type traits_type; + typedef typename StreamT::allocator_type allocator_type; + typedef typename StreamT::streambuf_type streambuf_type; + typedef typename StreamT::string_type string_type; + typedef typename StreamT::ostream_type ostream_type; + typedef typename StreamT::pos_type pos_type; + typedef typename StreamT::off_type off_type; + typedef typename StreamT::int_type int_type; + + typedef typename StreamT::failure failure; + typedef typename StreamT::fmtflags fmtflags; + typedef typename StreamT::iostate iostate; + typedef typename StreamT::openmode openmode; + typedef typename StreamT::seekdir seekdir; + typedef typename StreamT::Init Init; + + typedef typename StreamT::event event; + typedef typename StreamT::event_callback event_callback; + + typedef typename StreamT::sentry sentry; + + static BOOST_CONSTEXPR_OR_CONST fmtflags boolalpha = StreamT::boolalpha; + static BOOST_CONSTEXPR_OR_CONST fmtflags dec = StreamT::dec; + static BOOST_CONSTEXPR_OR_CONST fmtflags fixed = StreamT::fixed; + static BOOST_CONSTEXPR_OR_CONST fmtflags hex = StreamT::hex; + static BOOST_CONSTEXPR_OR_CONST fmtflags internal = StreamT::internal; + static BOOST_CONSTEXPR_OR_CONST fmtflags left = StreamT::left; + static BOOST_CONSTEXPR_OR_CONST fmtflags oct = StreamT::oct; + static BOOST_CONSTEXPR_OR_CONST fmtflags right = StreamT::right; + static BOOST_CONSTEXPR_OR_CONST fmtflags scientific = StreamT::scientific; + static BOOST_CONSTEXPR_OR_CONST fmtflags showbase = StreamT::showbase; + static BOOST_CONSTEXPR_OR_CONST fmtflags showpoint = StreamT::showpoint; + static BOOST_CONSTEXPR_OR_CONST fmtflags skipws = StreamT::skipws; + static BOOST_CONSTEXPR_OR_CONST fmtflags unitbuf = StreamT::unitbuf; + static BOOST_CONSTEXPR_OR_CONST fmtflags uppercase = StreamT::uppercase; + static BOOST_CONSTEXPR_OR_CONST fmtflags adjustfield = StreamT::adjustfield; + static BOOST_CONSTEXPR_OR_CONST fmtflags basefield = StreamT::basefield; + static BOOST_CONSTEXPR_OR_CONST fmtflags floatfield = StreamT::floatfield; + + static BOOST_CONSTEXPR_OR_CONST iostate badbit = StreamT::badbit; + static BOOST_CONSTEXPR_OR_CONST iostate eofbit = StreamT::eofbit; + static BOOST_CONSTEXPR_OR_CONST iostate failbit = StreamT::failbit; + static BOOST_CONSTEXPR_OR_CONST iostate goodbit = StreamT::goodbit; + + static BOOST_CONSTEXPR_OR_CONST openmode app = StreamT::app; + static BOOST_CONSTEXPR_OR_CONST openmode ate = StreamT::ate; + static BOOST_CONSTEXPR_OR_CONST openmode binary = StreamT::binary; + static BOOST_CONSTEXPR_OR_CONST openmode in = StreamT::in; + static BOOST_CONSTEXPR_OR_CONST openmode out = StreamT::out; + static BOOST_CONSTEXPR_OR_CONST openmode trunc = StreamT::trunc; + + static BOOST_CONSTEXPR_OR_CONST seekdir beg = StreamT::beg; + static BOOST_CONSTEXPR_OR_CONST seekdir cur = StreamT::cur; + static BOOST_CONSTEXPR_OR_CONST seekdir end = StreamT::end; + + static BOOST_CONSTEXPR_OR_CONST event erase_event = StreamT::erase_event; + static BOOST_CONSTEXPR_OR_CONST event imbue_event = StreamT::imbue_event; + static BOOST_CONSTEXPR_OR_CONST event copyfmt_event = StreamT::copyfmt_event; + + BOOST_FORCEINLINE explicit stream_ref(StreamT& strm) : reference_wrapper< StreamT >(strm) { } +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template< typename T > + BOOST_FORCEINLINE StreamT& operator<< (T&& val) const + { + StreamT& strm = this->get(); + strm << static_cast< T&& >(val); + return strm; + } +#else template< typename T > BOOST_FORCEINLINE StreamT& operator<< (T& val) const { @@ -72,8 +144,149 @@ public: strm << val; return strm; } +#endif + + BOOST_FORCEINLINE void attach(string_type& str) const { this->get().attach(str); } + BOOST_FORCEINLINE void detach() const { this->get().detach(); } + BOOST_FORCEINLINE string_type const& str() const { return this->get().str(); } + BOOST_FORCEINLINE ostream_type& stream() const { return this->get().stream(); } + BOOST_FORCEINLINE fmtflags flags() const { return this->get().flags(); } + BOOST_FORCEINLINE fmtflags flags(fmtflags f) const { return this->get().flags(f); } + BOOST_FORCEINLINE fmtflags setf(fmtflags f) const { return this->get().setf(f); } + BOOST_FORCEINLINE fmtflags setf(fmtflags f, fmtflags mask) const { return this->get().setf(f, mask); } + BOOST_FORCEINLINE void unsetf(fmtflags f) const { this->get().unsetf(f); } + + BOOST_FORCEINLINE std::streamsize precision() const { return this->get().precision(); } + BOOST_FORCEINLINE std::streamsize precision(std::streamsize p) const { return this->get().precision(p); } + + BOOST_FORCEINLINE std::streamsize width() const { return this->get().width(); } + BOOST_FORCEINLINE std::streamsize width(std::streamsize w) const { return this->get().width(w); } + + BOOST_FORCEINLINE std::locale getloc() const { return this->get().getloc(); } + BOOST_FORCEINLINE std::locale imbue(std::locale const& loc) const { return this->get().imbue(loc); } + + static BOOST_FORCEINLINE int xalloc() { return StreamT::xalloc(); } + BOOST_FORCEINLINE long& iword(int index) const { return this->get().iword(index); } + BOOST_FORCEINLINE void*& pword(int index) const { return this->get().pword(index); } + + BOOST_FORCEINLINE void register_callback(event_callback fn, int index) const { this->get().register_callback(fn, index); } + + static BOOST_FORCEINLINE bool sync_with_stdio(bool sync = true) { return StreamT::sync_with_stdio(sync); } + + BOOST_EXPLICIT_OPERATOR_BOOL() + BOOST_FORCEINLINE bool operator! () const { return !this->get(); } + + BOOST_FORCEINLINE iostate rdstate() const { return this->get().rdstate(); } + BOOST_FORCEINLINE void clear(iostate state = goodbit) const { this->get().clear(state); } + BOOST_FORCEINLINE void setstate(iostate state) const { this->get().setstate(state); } + BOOST_FORCEINLINE bool good() const { return this->get().good(); } + BOOST_FORCEINLINE bool eof() const { return this->get().eof(); } + BOOST_FORCEINLINE bool fail() const { return this->get().fail(); } + BOOST_FORCEINLINE bool bad() const { return this->get().bad(); } + + BOOST_FORCEINLINE iostate exceptions() const { return this->get().exceptions(); } + BOOST_FORCEINLINE void exceptions(iostate s) const { this->get().exceptions(s); } + + BOOST_FORCEINLINE ostream_type* tie() const { return this->get().tie(); } + BOOST_FORCEINLINE ostream_type* tie(ostream_type* strm) const { return this->get().tie(strm); } + + BOOST_FORCEINLINE streambuf_type* rdbuf() const { return this->get().rdbuf(); } + + BOOST_FORCEINLINE StreamT& copyfmt(std::basic_ios< char_type, traits_type >& rhs) const { return this->get().copyfmt(rhs); } + BOOST_FORCEINLINE StreamT& copyfmt(StreamT& rhs) const { return this->get().copyfmt(rhs); } + + BOOST_FORCEINLINE char_type fill() const { return this->get().fill(); } + BOOST_FORCEINLINE char_type fill(char_type ch) const { return this->get().fill(ch); } + + BOOST_FORCEINLINE char narrow(char_type ch, char def) const { return this->get().narrow(ch, def); } + BOOST_FORCEINLINE char_type widen(char ch) const { return this->get().widen(ch); } + + BOOST_FORCEINLINE StreamT& flush() const { return this->get().flush(); } + + BOOST_FORCEINLINE pos_type tellp() const { return this->get().tellp(); } + BOOST_FORCEINLINE StreamT& seekp(pos_type pos) const { return this->get().seekp(pos); } + BOOST_FORCEINLINE StreamT& seekp(off_type off, std::ios_base::seekdir dir) const { return this->get().seekp(off, dir); } + + template< typename CharT > + BOOST_FORCEINLINE typename boost::log::aux::enable_if_streamable_char_type< CharT, StreamT& >::type + put(CharT c) const { return this->get().put(c); } + + template< typename CharT > + BOOST_FORCEINLINE typename boost::log::aux::enable_if_streamable_char_type< CharT, StreamT& >::type + write(const CharT* p, std::streamsize size) const { return this->get().write(p, size); } }; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::boolalpha; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::dec; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::fixed; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::hex; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::internal; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::left; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::oct; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::right; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::scientific; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::showbase; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::showpoint; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::skipws; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::unitbuf; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::uppercase; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::adjustfield; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::basefield; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::floatfield; + +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::badbit; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::eofbit; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::failbit; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::goodbit; + +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::app; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::ate; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::binary; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::in; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::out; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::trunc; + +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::seekdir stream_ref< StreamT >::beg; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::seekdir stream_ref< StreamT >::cur; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::seekdir stream_ref< StreamT >::end; + +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::event stream_ref< StreamT >::erase_event; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::event stream_ref< StreamT >::imbue_event; +template< typename StreamT > +BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::event stream_ref< StreamT >::copyfmt_event; + //! Default log record message formatter struct message_formatter { @@ -84,7 +297,7 @@ struct message_formatter } template< typename StreamT > - result_type operator() (record_view const& rec, StreamT& strm) const + BOOST_FORCEINLINE result_type operator() (record_view const& rec, StreamT& strm) const { boost::log::visit< expressions::tag::message::value_type >(m_MessageName, rec, boost::log::bind_output(strm)); } diff --git a/boost/log/expressions/formatters/char_decorator.hpp b/boost/log/expressions/formatters/char_decorator.hpp index 3082febbfb..e3188810ff 100644 --- a/boost/log/expressions/formatters/char_decorator.hpp +++ b/boost/log/expressions/formatters/char_decorator.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -109,10 +110,15 @@ public: * of each pair is the source pattern, and the second one is the corresponding replacement. */ template< typename RangeT > - explicit pattern_replacer(RangeT const& decorations) + explicit pattern_replacer(RangeT const& decorations +#ifndef BOOST_LOG_DOXYGEN_PASS + // This is needed for a workaround against an MSVC-10 and older bug in constructor overload resolution + , typename boost::enable_if_has_type< typename range_const_iterator< RangeT >::type, int >::type = 0 +#endif + ) { typedef typename range_const_iterator< RangeT >::type iterator; - for (iterator it = begin(decorations), end_ = end(decorations); it != end_; ++it) + for (iterator it = boost::begin(decorations), end_ = boost::end(decorations); it != end_; ++it) { string_lengths lens; { @@ -140,8 +146,8 @@ public: { typedef typename range_const_iterator< FromRangeT >::type iterator1; typedef typename range_const_iterator< ToRangeT >::type iterator2; - iterator1 it1 = begin(from), end1 = end(from); - iterator2 it2 = begin(to), end2 = end(to); + iterator1 it1 = boost::begin(from), end1 = boost::end(from); + iterator2 it2 = boost::begin(to), end2 = boost::end(to); for (; it1 != end1 && it2 != end2; ++it1, ++it2) { string_lengths lens; @@ -200,25 +206,21 @@ private: template< typename RangeT > static typename range_const_iterator< RangeT >::type string_begin(RangeT const& r) { - return begin(r); + return boost::begin(r); } static char_type* string_end(char_type* p) { - while (*p) - ++p; - return p; + return p + std::char_traits< char_type >::length(p); } static const char_type* string_end(const char_type* p) { - while (*p) - ++p; - return p; + return p + std::char_traits< char_type >::length(p); } template< typename RangeT > static typename range_const_iterator< RangeT >::type string_end(RangeT const& r) { - return end(r); + return boost::end(r); } }; diff --git a/boost/log/sinks/async_frontend.hpp b/boost/log/sinks/async_frontend.hpp index 7ba8a5a937..c0209bfb2f 100644 --- a/boost/log/sinks/async_frontend.hpp +++ b/boost/log/sinks/async_frontend.hpp @@ -15,6 +15,7 @@ #ifndef BOOST_LOG_SINKS_ASYNC_FRONTEND_HPP_INCLUDED_ #define BOOST_LOG_SINKS_ASYNC_FRONTEND_HPP_INCLUDED_ +#include // std::terminate #include #ifdef BOOST_HAS_PRAGMA_ONCE @@ -27,6 +28,8 @@ #include #include +#include +#include #include #include #include @@ -104,11 +107,11 @@ private: frontend_mutex_type& m_Mutex; condition_variable_any& m_Cond; thread::id& m_ThreadID; - bool volatile& m_StopRequested; + boost::atomic< bool >& m_StopRequested; public: //! Initializing constructor - scoped_thread_id(frontend_mutex_type& mut, condition_variable_any& cond, thread::id& tid, bool volatile& sr) + scoped_thread_id(frontend_mutex_type& mut, condition_variable_any& cond, thread::id& tid, boost::atomic< bool >& sr) : m_Mutex(mut), m_Cond(cond), m_ThreadID(tid), m_StopRequested(sr) { lock_guard< frontend_mutex_type > lock(m_Mutex); @@ -117,7 +120,7 @@ private: m_ThreadID = this_thread::get_id(); } //! Initializing constructor - scoped_thread_id(unique_lock< frontend_mutex_type >& l, condition_variable_any& cond, thread::id& tid, bool volatile& sr) + scoped_thread_id(unique_lock< frontend_mutex_type >& l, condition_variable_any& cond, thread::id& tid, boost::atomic< bool >& sr) : m_Mutex(*l.mutex()), m_Cond(cond), m_ThreadID(tid), m_StopRequested(sr) { unique_lock< frontend_mutex_type > lock(move(l)); @@ -131,7 +134,7 @@ private: try { lock_guard< frontend_mutex_type > lock(m_Mutex); - m_StopRequested = false; + m_StopRequested.store(false, boost::memory_order_release); m_ThreadID = thread::id(); m_Cond.notify_all(); } @@ -140,9 +143,8 @@ private: } } - private: - scoped_thread_id(scoped_thread_id const&); - scoped_thread_id& operator= (scoped_thread_id const&); + BOOST_DELETED_FUNCTION(scoped_thread_id(scoped_thread_id const&)) + BOOST_DELETED_FUNCTION(scoped_thread_id& operator= (scoped_thread_id const&)) }; //! A scope guard that resets a flag on destructor @@ -151,10 +153,10 @@ private: private: frontend_mutex_type& m_Mutex; condition_variable_any& m_Cond; - volatile bool& m_Flag; + boost::atomic< bool >& m_Flag; public: - explicit scoped_flag(frontend_mutex_type& mut, condition_variable_any& cond, volatile bool& f) : + explicit scoped_flag(frontend_mutex_type& mut, condition_variable_any& cond, boost::atomic< bool >& f) : m_Mutex(mut), m_Cond(cond), m_Flag(f) { } @@ -163,7 +165,7 @@ private: try { lock_guard< frontend_mutex_type > lock(m_Mutex); - m_Flag = false; + m_Flag.store(false, boost::memory_order_release); m_Cond.notify_all(); } catch (...) @@ -171,9 +173,8 @@ private: } } - private: - scoped_flag(scoped_flag const&); - scoped_flag& operator= (scoped_flag const&); + BOOST_DELETED_FUNCTION(scoped_flag(scoped_flag const&)) + BOOST_DELETED_FUNCTION(scoped_flag& operator= (scoped_flag const&)) }; public: @@ -209,9 +210,9 @@ private: condition_variable_any m_BlockCond; //! The flag indicates that the feeding loop has to be stopped - volatile bool m_StopRequested; // TODO: make it a real atomic + boost::atomic< bool > m_StopRequested; //! The flag indicates that queue flush has been requested - volatile bool m_FlushRequested; // TODO: make it a real atomic + boost::atomic< bool > m_FlushRequested; public: /*! @@ -259,10 +260,17 @@ public: /*! * Destructor. Implicitly stops the dedicated feeding thread, if one is running. */ - ~asynchronous_sink() + ~asynchronous_sink() BOOST_NOEXCEPT { - boost::this_thread::disable_interruption no_interrupts; - stop(); + try + { + boost::this_thread::disable_interruption no_interrupts; + stop(); + } + catch (...) + { + std::terminate(); + } } /*! @@ -278,11 +286,11 @@ public: */ void consume(record_view const& rec) { - if (m_FlushRequested) + if (BOOST_UNLIKELY(m_FlushRequested.load(boost::memory_order_acquire))) { unique_lock< frontend_mutex_type > lock(base_type::frontend_mutex()); // Wait until flush is done - while (m_FlushRequested) + while (m_FlushRequested.load(boost::memory_order_acquire)) m_BlockCond.wait(lock); } queue_base_type::enqueue(rec); @@ -293,7 +301,7 @@ public: */ bool try_consume(record_view const& rec) { - if (!m_FlushRequested) + if (!m_FlushRequested.load(boost::memory_order_acquire)) { return queue_base_type::try_enqueue(rec); } @@ -319,7 +327,7 @@ public: while (true) { do_feed_records(); - if (!m_StopRequested) + if (!m_StopRequested.load(boost::memory_order_acquire)) { // Block until new record is available record_view rec; @@ -352,14 +360,14 @@ public: { try { - m_StopRequested = true; + m_StopRequested.store(true, boost::memory_order_release); queue_base_type::interrupt_dequeue(); - while (m_StopRequested) + while (m_StopRequested.load(boost::memory_order_acquire)) m_BlockCond.wait(lock); } catch (...) { - m_StopRequested = false; + m_StopRequested.store(false, boost::memory_order_release); throw; } @@ -386,8 +394,6 @@ public: * The method feeds all log records that may have been buffered to the backend and returns. * Unlike \c feed_records, in case of ordering queueing the method also feeds records * that were enqueued during the ordering window, attempting to empty the queue completely. - * - * \pre The sink frontend must be constructed without spawning a dedicated thread */ void flush() { @@ -395,9 +401,9 @@ public: if (m_FeedingThreadID != thread::id() || m_DedicatedFeedingThread.joinable()) { // There is already a thread feeding records, let it do the job - m_FlushRequested = true; + m_FlushRequested.store(true, boost::memory_order_release); queue_base_type::interrupt_dequeue(); - while (!m_StopRequested && m_FlushRequested) + while (!m_StopRequested.load(boost::memory_order_acquire) && m_FlushRequested.load(boost::memory_order_acquire)) m_BlockCond.wait(lock); // The condition may have been signalled when the feeding thread was finishing. @@ -406,7 +412,7 @@ public: return; } - m_FlushRequested = true; + m_FlushRequested.store(true, boost::memory_order_release); // Flush records ourselves. The guard releases the lock. scoped_thread_id guard(lock, m_BlockCond, m_FeedingThreadID, m_StopRequested); @@ -425,11 +431,11 @@ private: //! The record feeding loop void do_feed_records() { - while (!m_StopRequested) + while (!m_StopRequested.load(boost::memory_order_acquire)) { record_view rec; bool dequeued = false; - if (!m_FlushRequested) + if (BOOST_LIKELY(!m_FlushRequested.load(boost::memory_order_acquire))) dequeued = queue_base_type::try_dequeue_ready(rec); else dequeued = queue_base_type::try_dequeue(rec); @@ -440,7 +446,7 @@ private: break; } - if (m_FlushRequested) + if (BOOST_UNLIKELY(m_FlushRequested.load(boost::memory_order_acquire))) { scoped_flag guard(base_type::frontend_mutex(), m_BlockCond, m_FlushRequested); base_type::flush_backend(m_BackendMutex, *m_pBackend); diff --git a/boost/log/sinks/unbounded_fifo_queue.hpp b/boost/log/sinks/unbounded_fifo_queue.hpp index 3cfaa187e1..9fdb44cc3e 100644 --- a/boost/log/sinks/unbounded_fifo_queue.hpp +++ b/boost/log/sinks/unbounded_fifo_queue.hpp @@ -26,6 +26,8 @@ #error Boost.Log: This header content is only supported in multithreaded environment #endif +#include +#include #include #include #include @@ -62,7 +64,7 @@ private: //! Event object to block on boost::log::aux::event m_event; //! Interruption flag - volatile bool m_interruption_requested; // TODO: make it atomic + boost::atomic< bool > m_interruption_requested; protected: //! Default constructor @@ -113,11 +115,8 @@ protected: while (true) { m_event.wait(); - if (m_interruption_requested) - { - m_interruption_requested = false; + if (m_interruption_requested.exchange(false, boost::memory_order_acquire)) return false; - } if (m_queue.try_pop(rec)) return true; } @@ -126,7 +125,7 @@ protected: //! Wakes a thread possibly blocked in the \c dequeue method void interrupt_dequeue() { - m_interruption_requested = true; + m_interruption_requested.store(true, boost::memory_order_release); m_event.set_signalled(); } }; diff --git a/boost/log/sources/record_ostream.hpp b/boost/log/sources/record_ostream.hpp index b3c58e2ab0..c1e80593aa 100644 --- a/boost/log/sources/record_ostream.hpp +++ b/boost/log/sources/record_ostream.hpp @@ -39,6 +39,18 @@ namespace boost { BOOST_LOG_OPEN_NAMESPACE +template< typename CharT > +class basic_record_ostream; + +namespace aux { + +template< typename StreamT, typename R > +struct enable_if_record_ostream {}; +template< typename CharT, typename R > +struct enable_if_record_ostream< basic_record_ostream< CharT >, R > { typedef R type; }; + +} // namespace aux + /*! * \brief Logging record adapter with a streaming capability * @@ -174,6 +186,55 @@ typedef basic_record_ostream< char > record_ostream; //!< Convenience typ typedef basic_record_ostream< wchar_t > wrecord_ostream; //!< Convenience typedef for wide-character logging #endif +// Implementation note: these operators below should be the least attractive for the compiler +// so that user's overloads are chosen, when present. We use function template partial ordering for this purpose. +// We also don't use perfect forwarding for the right hand argument because in ths case the generic overload +// would be more preferred than the typical one written by users: +// +// record_ostream& operator<< (record_ostream& strm, my_type const& arg); +// +// This is because my_type rvalues require adding const to the type, which counts as a conversion that is not required +// if there is a perfect forwarding overload. +template< typename StreamT, typename T > +inline typename boost::log::aux::enable_if_record_ostream< StreamT, StreamT& >::type +operator<< (StreamT& strm, T const& value) +{ + typedef basic_formatting_ostream< typename StreamT::char_type > formatting_ostream_type; + static_cast< formatting_ostream_type& >(strm) << value; + return strm; +} + +template< typename StreamT, typename T > +inline typename boost::log::aux::enable_if_record_ostream< StreamT, StreamT& >::type +operator<< (StreamT& strm, T& value) +{ + typedef basic_formatting_ostream< typename StreamT::char_type > formatting_ostream_type; + static_cast< formatting_ostream_type& >(strm) << value; + return strm; +} + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + +template< typename StreamT, typename T > +inline typename boost::log::aux::enable_if_record_ostream< StreamT, StreamT& >::type +operator<< (StreamT&& strm, T const& value) +{ + typedef basic_formatting_ostream< typename StreamT::char_type > formatting_ostream_type; + static_cast< formatting_ostream_type& >(strm) << value; + return strm; +} + +template< typename StreamT, typename T > +inline typename boost::log::aux::enable_if_record_ostream< StreamT, StreamT& >::type +operator<< (StreamT&& strm, T& value) +{ + typedef basic_formatting_ostream< typename StreamT::char_type > formatting_ostream_type; + static_cast< formatting_ostream_type& >(strm) << value; + return strm; +} + +#endif // !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + namespace aux { //! Internal class that provides formatting streams for record pumps diff --git a/boost/log/utility/formatting_ostream.hpp b/boost/log/utility/formatting_ostream.hpp index 4345206f12..4d57ac4e32 100644 --- a/boost/log/utility/formatting_ostream.hpp +++ b/boost/log/utility/formatting_ostream.hpp @@ -128,6 +128,10 @@ public: { } + // A workaround for Solaris Studio 12.4 compiler, see: https://svn.boost.org/trac/boost/ticket/11545 + BOOST_EXPLICIT_OPERATOR_BOOL() + bool operator! () const { return !static_cast< base_type const& >(*this); } + BOOST_DELETED_FUNCTION(sentry(sentry const&)) BOOST_DELETED_FUNCTION(sentry& operator= (sentry const&)) }; @@ -363,7 +367,7 @@ public: write(const OtherCharT* p, std::streamsize size) { sentry guard(*this); - if (guard) + if (!!guard) { m_stream.flush(); @@ -399,6 +403,8 @@ public: return this->formatted_write(p, static_cast< std::streamsize >(std::char_traits< char >::length(p))); } + // When no native character type is supported, the following overloads are disabled as they have ambiguous meaning. + // Use basic_string_ref, basic_string_view or basic_string to explicitly indicate that the data is a string. #if !defined(BOOST_NO_INTRINSIC_WCHAR_T) basic_formatting_ostream& operator<< (wchar_t c) { @@ -622,7 +628,7 @@ private: basic_formatting_ostream& formatted_write(const char_type* p, std::streamsize size) { sentry guard(*this); - if (guard) + if (!!guard) { m_stream.flush(); @@ -641,7 +647,7 @@ private: basic_formatting_ostream& formatted_write(const OtherCharT* p, std::streamsize size) { sentry guard(*this); - if (guard) + if (!!guard) { m_stream.flush(); @@ -779,6 +785,13 @@ void basic_formatting_ostream< CharT, TraitsT, AllocatorT >::aligned_write(const // Implementation note: these operators below should be the least attractive for the compiler // so that user's overloads are chosen, when present. We use function template partial ordering for this purpose. +// We also don't use perfect forwarding for the right hand argument because in ths case the generic overload +// would be more preferred than the typical one written by users: +// +// formatting_ostream& operator<< (formatting_ostream& strm, my_type const& arg); +// +// This is because my_type rvalues require adding const to the type, which counts as a conversion that is not required +// if there is a perfect forwarding overload. template< typename StreamT, typename T > inline typename boost::log::aux::enable_if_formatting_ostream< StreamT, StreamT& >::type operator<< (StreamT& strm, T const& value) diff --git a/boost/log/utility/type_dispatch/dynamic_type_dispatcher.hpp b/boost/log/utility/type_dispatch/dynamic_type_dispatcher.hpp index d01228a5da..21428ff949 100644 --- a/boost/log/utility/type_dispatch/dynamic_type_dispatcher.hpp +++ b/boost/log/utility/type_dispatch/dynamic_type_dispatcher.hpp @@ -70,7 +70,7 @@ private: trampoline_t as_trampoline; } caster; - caster.as_trampoline = &callback_base::trampoline< VisitorT, T >; + caster.as_trampoline = (trampoline_t)&callback_base::trampoline< VisitorT, T >; this->m_pTrampoline = caster.as_pvoid; } }; diff --git a/boost/log/utility/type_dispatch/static_type_dispatcher.hpp b/boost/log/utility/type_dispatch/static_type_dispatcher.hpp index bae420f7e5..c580213d66 100644 --- a/boost/log/utility/type_dispatch/static_type_dispatcher.hpp +++ b/boost/log/utility/type_dispatch/static_type_dispatcher.hpp @@ -89,7 +89,7 @@ private: trampoline_t as_trampoline; } caster; - caster.as_trampoline = &type_dispatcher::callback_base::trampoline< VisitorT, T >; + caster.as_trampoline = (trampoline_t)&type_dispatcher::callback_base::trampoline< VisitorT, T >; p->second = caster.as_pvoid; } }; @@ -214,10 +214,10 @@ private: protected: //! Initializing constructor - single_type_dispatcher_base(typeindex::type_index type, callback_base const& callback) BOOST_NOEXCEPT : + single_type_dispatcher_base(typeindex::type_index type, callback_base const& cb) BOOST_NOEXCEPT : type_dispatcher(&single_type_dispatcher_base::get_callback), m_type(type), - m_callback(callback) + m_callback(cb) { } @@ -242,11 +242,14 @@ template< typename T > class single_type_dispatcher : public single_type_dispatcher_base { +private: + typedef void (*trampoline_t)(void*, T const&); + public: //! Constructor template< typename VisitorT > explicit single_type_dispatcher(VisitorT& visitor) BOOST_NOEXCEPT : - single_type_dispatcher_base(typeindex::type_id< T >(), callback_base((void*)boost::addressof(visitor), &callback_base::trampoline< VisitorT, T >)) + single_type_dispatcher_base(typeindex::type_id< T >(), callback_base((void*)boost::addressof(visitor), (trampoline_t)&callback_base::trampoline< VisitorT, T >)) { } diff --git a/boost/math/concepts/real_concept.hpp b/boost/math/concepts/real_concept.hpp index 2b105e6c85..3a759955ab 100644 --- a/boost/math/concepts/real_concept.hpp +++ b/boost/math/concepts/real_concept.hpp @@ -215,10 +215,17 @@ inline real_concept floor(real_concept a) { return std::floor(a.value()); } inline real_concept modf(real_concept a, real_concept* ipart) { +#ifdef __MINGW32__ + real_concept_base_type ip; + real_concept_base_type result = boost::math::modf(a.value(), &ip); + *ipart = ip; + return result; +#else real_concept_base_type ip; real_concept_base_type result = std::modf(a.value(), &ip); *ipart = ip; return result; +#endif } inline real_concept frexp(real_concept a, int* expon) { return std::frexp(a.value(), expon); } @@ -368,7 +375,7 @@ inline concepts::real_concept epsilon(BOOST_MATH_EXPLICI } template <> -inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept)) +inline BOOST_MATH_CONSTEXPR int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept)) BOOST_NOEXCEPT { // Assume number of significand bits is same as real_concept_base_type, // unless std::numeric_limits::is_specialized to provide digits. @@ -381,6 +388,26 @@ inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC } } // namespace tools +/* +namespace policies { + namespace detail { + + template + inline concepts::real_concept raise_rounding_error( + const char*, + const char*, + const T& val, + const concepts::real_concept&, + const ::boost::math::policies::rounding_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T) + { + errno = ERANGE; + // This may or may not do the right thing, but the user asked for the error + // to be silent so here we go anyway: + return val > 0 ? boost::math::tools::max_value() : -boost::math::tools::max_value(); + } + + } +}*/ #if defined(__SGI_STL_PORT) || defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) // diff --git a/boost/math/concepts/std_real_concept.hpp b/boost/math/concepts/std_real_concept.hpp index c565ce3773..b297501d98 100644 --- a/boost/math/concepts/std_real_concept.hpp +++ b/boost/math/concepts/std_real_concept.hpp @@ -378,7 +378,7 @@ inline concepts::std_real_concept epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC } template <> -inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept)) +inline BOOST_MATH_CONSTEXPR int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept)) BOOST_NOEXCEPT { // Assume number of significand bits is same as std_real_concept_base_type, // unless std::numeric_limits::is_specialized to provide digits. return digits(); diff --git a/boost/math/constants/constants.hpp b/boost/math/constants/constants.hpp index 59873c60d8..2a28f98f9e 100644 --- a/boost/math/constants/constants.hpp +++ b/boost/math/constants/constants.hpp @@ -158,7 +158,7 @@ namespace boost{ namespace math #endif } template - const char* convert_from_string(const char* p, const mpl::true_&) + BOOST_CONSTEXPR const char* convert_from_string(const char* p, const mpl::true_&) BOOST_NOEXCEPT { return p; } @@ -211,7 +211,7 @@ namespace boost{ namespace math #ifdef BOOST_MATH_USE_FLOAT128 # define BOOST_MATH_FLOAT128_CONSTANT_OVERLOAD(x) \ - static inline BOOST_CONSTEXPR T get(const mpl::int_&)\ + static inline BOOST_CONSTEXPR T get(const mpl::int_&) BOOST_NOEXCEPT\ { return BOOST_JOIN(x, Q); } #else # define BOOST_MATH_FLOAT128_CONSTANT_OVERLOAD(x) @@ -242,11 +242,11 @@ namespace boost{ namespace math constant_initializer::get_from_string >::force_instantiate();\ return get_from_string();\ }\ - static inline BOOST_CONSTEXPR T get(const mpl::int_)\ + static inline BOOST_CONSTEXPR T get(const mpl::int_) BOOST_NOEXCEPT\ { return BOOST_JOIN(x, F); }\ - static inline BOOST_CONSTEXPR T get(const mpl::int_&)\ + static inline BOOST_CONSTEXPR T get(const mpl::int_&) BOOST_NOEXCEPT\ { return x; }\ - static inline BOOST_CONSTEXPR T get(const mpl::int_&)\ + static inline BOOST_CONSTEXPR T get(const mpl::int_&) BOOST_NOEXCEPT\ { return BOOST_JOIN(x, L); }\ BOOST_MATH_FLOAT128_CONSTANT_OVERLOAD(x) \ template static inline const T& get(const mpl::int_&)\ @@ -262,9 +262,9 @@ namespace boost{ namespace math \ \ /* The actual forwarding function: */ \ - template inline BOOST_CONSTEXPR typename detail::constant_return::type name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T) BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(Policy))\ + template inline BOOST_CONSTEXPR typename detail::constant_return::type name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T) BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(Policy)) BOOST_MATH_NOEXCEPT(T)\ { return detail:: BOOST_JOIN(constant_, name)::get(typename construction_traits::type()); }\ - template inline BOOST_CONSTEXPR typename detail::constant_return::type name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\ + template inline BOOST_CONSTEXPR typename detail::constant_return::type name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) BOOST_MATH_NOEXCEPT(T)\ { return name >(); }\ \ \ diff --git a/boost/math/cstdfloat/cstdfloat_iostream.hpp b/boost/math/cstdfloat/cstdfloat_iostream.hpp index ac94fd35f9..9aaf5f32fb 100644 --- a/boost/math/cstdfloat/cstdfloat_iostream.hpp +++ b/boost/math/cstdfloat/cstdfloat_iostream.hpp @@ -97,15 +97,18 @@ char* my_buffer2 = static_cast(0U); +#ifndef BOOST_NO_EXCEPTIONS try { +#endif my_buffer2 = new char[v + 3]; +#ifndef BOOST_NO_EXCEPTIONS } catch(const std::bad_alloc&) { BOOST_THROW_EXCEPTION(std::runtime_error("Formatting of boost::float128_t failed while allocating memory.")); } - +#endif const int v2 = ::quadmath_snprintf(my_buffer2, v + 3, my_format_string, diff --git a/boost/math/distributions/bernoulli.hpp b/boost/math/distributions/bernoulli.hpp index 1355eda229..09b8a0a3e1 100644 --- a/boost/math/distributions/bernoulli.hpp +++ b/boost/math/distributions/bernoulli.hpp @@ -89,7 +89,7 @@ namespace boost template inline bool check_dist_and_prob(const char* function, RealType p, RealType prob, RealType* result, const Policy& /* pol */) { - if(check_dist(function, p, result, Policy(), typename policies::method_error_check::type()) && detail::check_probability(function, prob, result, Policy()) == false) + if((check_dist(function, p, result, Policy(), typename policies::method_error_check::type()) && detail::check_probability(function, prob, result, Policy())) == false) { return false; } diff --git a/boost/math/distributions/binomial.hpp b/boost/math/distributions/binomial.hpp index a48c89c5b9..620bf9b121 100644 --- a/boost/math/distributions/binomial.hpp +++ b/boost/math/distributions/binomial.hpp @@ -155,7 +155,7 @@ namespace boost template inline bool check_dist_and_prob(const char* function, const RealType& N, RealType p, RealType prob, RealType* result, const Policy& pol) { - if(check_dist(function, N, p, result, pol) && detail::check_probability(function, prob, result, pol) == false) + if((check_dist(function, N, p, result, pol) && detail::check_probability(function, prob, result, pol)) == false) return false; return true; } diff --git a/boost/math/distributions/detail/hypergeometric_pdf.hpp b/boost/math/distributions/detail/hypergeometric_pdf.hpp index 1e6a5ca20d..4364266514 100644 --- a/boost/math/distributions/detail/hypergeometric_pdf.hpp +++ b/boost/math/distributions/detail/hypergeometric_pdf.hpp @@ -311,7 +311,7 @@ T hypergeometric_pdf_prime_loop_imp(hypergeometric_pdf_prime_loop_data& data, hy } if(prime_powers) { - T p = integer_power(data.current_prime, prime_powers); + T p = integer_power(static_cast(data.current_prime), prime_powers); if((p > 1) && (tools::max_value() / p < result.value)) { // diff --git a/boost/math/distributions/detail/hypergeometric_quantile.hpp b/boost/math/distributions/detail/hypergeometric_quantile.hpp index a855a4a777..2cdee23c10 100644 --- a/boost/math/distributions/detail/hypergeometric_quantile.hpp +++ b/boost/math/distributions/detail/hypergeometric_quantile.hpp @@ -130,6 +130,29 @@ unsigned hypergeometric_quantile_imp(T p, T q, unsigned r, unsigned n, unsigned unsigned x = base; result = hypergeometric_pdf(x, r, n, N, pol); T diff = result; + if (diff == 0) + { + ++x; + // We want to skip through x values as fast as we can until we start getting non-zero values, + // otherwise we're just making lots of expensive PDF calls: + T log_pdf = boost::math::lgamma(static_cast(n + 1), pol) + + boost::math::lgamma(static_cast(r + 1), pol) + + boost::math::lgamma(static_cast(N - n + 1), pol) + + boost::math::lgamma(static_cast(N - r + 1), pol) + - boost::math::lgamma(static_cast(N + 1), pol) + - boost::math::lgamma(static_cast(x + 1), pol) + - boost::math::lgamma(static_cast(n - x + 1), pol) + - boost::math::lgamma(static_cast(r - x + 1), pol) + - boost::math::lgamma(static_cast(N - n - r + x + 1), pol); + while (log_pdf < tools::log_min_value()) + { + log_pdf += -log(static_cast(x + 1)) + log(static_cast(n - x)) + log(static_cast(r - x)) - log(static_cast(N - n - r + x + 1)); + ++x; + } + // By the time we get here, log_pdf may be fairly inaccurate due to + // roundoff errors, get a fresh PDF calculation before proceding: + diff = hypergeometric_pdf(x, r, n, N, pol); + } while(result < p) { diff = (diff > tools::min_value() * 8) @@ -155,6 +178,29 @@ unsigned hypergeometric_quantile_imp(T p, T q, unsigned r, unsigned n, unsigned unsigned x = lim; result = 0; T diff = hypergeometric_pdf(x, r, n, N, pol); + if (diff == 0) + { + // We want to skip through x values as fast as we can until we start getting non-zero values, + // otherwise we're just making lots of expensive PDF calls: + --x; + T log_pdf = boost::math::lgamma(static_cast(n + 1), pol) + + boost::math::lgamma(static_cast(r + 1), pol) + + boost::math::lgamma(static_cast(N - n + 1), pol) + + boost::math::lgamma(static_cast(N - r + 1), pol) + - boost::math::lgamma(static_cast(N + 1), pol) + - boost::math::lgamma(static_cast(x + 1), pol) + - boost::math::lgamma(static_cast(n - x + 1), pol) + - boost::math::lgamma(static_cast(r - x + 1), pol) + - boost::math::lgamma(static_cast(N - n - r + x + 1), pol); + while (log_pdf < tools::log_min_value()) + { + log_pdf += log(static_cast(x)) - log(static_cast(n - x + 1)) - log(static_cast(r - x + 1)) + log(static_cast(N - n - r + x)); + --x; + } + // By the time we get here, log_pdf may be fairly inaccurate due to + // roundoff errors, get a fresh PDF calculation before proceding: + diff = hypergeometric_pdf(x, r, n, N, pol); + } while(result + diff / 2 < q) { result += diff; diff --git a/boost/math/distributions/exponential.hpp b/boost/math/distributions/exponential.hpp index bfe7e6b4ac..05c49374ed 100644 --- a/boost/math/distributions/exponential.hpp +++ b/boost/math/distributions/exponential.hpp @@ -117,7 +117,7 @@ inline RealType pdf(const exponential_distribution& dist, cons return result; // Workaround for VC11/12 bug: if ((boost::math::isinf)(x)) - return 0; + return 0; result = lambda * exp(-lambda * x); return result; } // pdf @@ -178,7 +178,7 @@ inline RealType cdf(const complemented2_type= tools::max_value()) - return 0; + return 0; result = exp(-c.param * lambda); return result; diff --git a/boost/math/distributions/extreme_value.hpp b/boost/math/distributions/extreme_value.hpp index 4c6b710cbd..cb86de6612 100644 --- a/boost/math/distributions/extreme_value.hpp +++ b/boost/math/distributions/extreme_value.hpp @@ -100,12 +100,12 @@ inline RealType pdf(const extreme_value_distribution& dist, co RealType a = dist.location(); RealType b = dist.scale(); RealType result = 0; - if((boost::math::isinf)(x)) - return 0.0f; if(0 == detail::verify_scale_b(function, b, &result, Policy())) return result; if(0 == detail::check_finite(function, a, &result, Policy())) return result; + if((boost::math::isinf)(x)) + return 0.0f; if(0 == detail::check_x(function, x, &result, Policy())) return result; RealType e = (a - x) / b; diff --git a/boost/math/distributions/fisher_f.hpp b/boost/math/distributions/fisher_f.hpp index 9e259bcc96..798db2fa75 100644 --- a/boost/math/distributions/fisher_f.hpp +++ b/boost/math/distributions/fisher_f.hpp @@ -78,10 +78,10 @@ RealType pdf(const fisher_f_distribution& dist, const RealType // Error check: RealType error_result = 0; static const char* function = "boost::math::pdf(fisher_f_distribution<%1%> const&, %1%)"; - if(false == detail::check_df( + if(false == (detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( - function, df2, &error_result, Policy())) + function, df2, &error_result, Policy()))) return error_result; if((x < 0) || !(boost::math::isfinite)(x)) diff --git a/boost/math/distributions/geometric.hpp b/boost/math/distributions/geometric.hpp index 88947d6c57..6c9713eadd 100644 --- a/boost/math/distributions/geometric.hpp +++ b/boost/math/distributions/geometric.hpp @@ -105,7 +105,7 @@ namespace boost template inline bool check_dist_and_prob(const char* function, RealType p, RealType prob, RealType* result, const Policy& pol) { - if(check_dist(function, p, result, pol) && detail::check_probability(function, prob, result, pol) == false) + if((check_dist(function, p, result, pol) && detail::check_probability(function, prob, result, pol)) == false) { return false; } diff --git a/boost/math/distributions/hypergeometric.hpp b/boost/math/distributions/hypergeometric.hpp index 5d1ebc7388..21449638d9 100644 --- a/boost/math/distributions/hypergeometric.hpp +++ b/boost/math/distributions/hypergeometric.hpp @@ -41,12 +41,12 @@ namespace boost { namespace math { unsigned defective()const { - return m_n; + return m_r; } unsigned sample_count()const { - return m_r; + return m_n; } bool check_params(const char* function, RealType* result)const @@ -84,9 +84,9 @@ namespace boost { namespace math { private: // Data members: - unsigned m_n; // number of "defective" items + unsigned m_n; // number of items picked unsigned m_N; // number of "total" items - unsigned m_r; // number of items picked + unsigned m_r; // number of "defective" items }; // class hypergeometric_distribution @@ -99,8 +99,8 @@ namespace boost { namespace math { # pragma warning(push) # pragma warning(disable:4267) #endif - unsigned r = dist.sample_count(); - unsigned n = dist.defective(); + unsigned r = dist.defective(); + unsigned n = dist.sample_count(); unsigned N = dist.total(); unsigned l = static_cast((std::max)(0, (int)(n + r) - (int)(N))); unsigned u = (std::min)(r, n); @@ -127,7 +127,7 @@ namespace boost { namespace math { return result; return boost::math::detail::hypergeometric_pdf( - x, dist.sample_count(), dist.defective(), dist.total(), Policy()); + x, dist.defective(), dist.sample_count(), dist.total(), Policy()); } template @@ -156,7 +156,7 @@ namespace boost { namespace math { return result; return boost::math::detail::hypergeometric_cdf( - x, dist.sample_count(), dist.defective(), dist.total(), false, Policy()); + x, dist.defective(), dist.sample_count(), dist.total(), false, Policy()); } template @@ -185,7 +185,7 @@ namespace boost { namespace math { return result; return boost::math::detail::hypergeometric_cdf( - c.param, c.dist.sample_count(), c.dist.defective(), c.dist.total(), true, Policy()); + c.param, c.dist.defective(), c.dist.sample_count(), c.dist.total(), true, Policy()); } template @@ -214,7 +214,7 @@ namespace boost { namespace math { if (false == dist.check_params(function, &result)) return result; if(false == detail::check_probability(function, p, &result, Policy())) return result; - return static_cast(detail::hypergeometric_quantile(p, RealType(1 - p), dist.sample_count(), dist.defective(), dist.total(), Policy())); + return static_cast(detail::hypergeometric_quantile(p, RealType(1 - p), dist.defective(), dist.sample_count(), dist.total(), Policy())); } // quantile template @@ -228,30 +228,30 @@ namespace boost { namespace math { if (false == c.dist.check_params(function, &result)) return result; if(false == detail::check_probability(function, c.param, &result, Policy())) return result; - return static_cast(detail::hypergeometric_quantile(RealType(1 - c.param), c.param, c.dist.sample_count(), c.dist.defective(), c.dist.total(), Policy())); + return static_cast(detail::hypergeometric_quantile(RealType(1 - c.param), c.param, c.dist.defective(), c.dist.sample_count(), c.dist.total(), Policy())); } // quantile template inline RealType mean(const hypergeometric_distribution& dist) { - return static_cast(dist.sample_count() * dist.defective()) / dist.total(); + return static_cast(dist.defective() * dist.sample_count()) / dist.total(); } // RealType mean(const hypergeometric_distribution& dist) template inline RealType variance(const hypergeometric_distribution& dist) { - RealType r = static_cast(dist.sample_count()); - RealType n = static_cast(dist.defective()); + RealType r = static_cast(dist.defective()); + RealType n = static_cast(dist.sample_count()); RealType N = static_cast(dist.total()); - return r * (n / N) * (1 - n / N) * (N - r) / (N - 1); + return n * r * (N - r) * (N - n) / (N * N * (N - 1)); } // RealType variance(const hypergeometric_distribution& dist) template inline RealType mode(const hypergeometric_distribution& dist) { BOOST_MATH_STD_USING - RealType r = static_cast(dist.sample_count()); - RealType n = static_cast(dist.defective()); + RealType r = static_cast(dist.defective()); + RealType n = static_cast(dist.sample_count()); RealType N = static_cast(dist.total()); return floor((r + 1) * (n + 1) / (N + 2)); } @@ -260,17 +260,17 @@ namespace boost { namespace math { inline RealType skewness(const hypergeometric_distribution& dist) { BOOST_MATH_STD_USING - RealType r = static_cast(dist.sample_count()); - RealType n = static_cast(dist.defective()); + RealType r = static_cast(dist.defective()); + RealType n = static_cast(dist.sample_count()); RealType N = static_cast(dist.total()); - return (N - 2 * n) * sqrt(N - 1) * (N - 2 * r) / (sqrt(n * r * (N - n) * (N - r)) * (N - 2)); + return (N - 2 * r) * sqrt(N - 1) * (N - 2 * n) / (sqrt(n * r * (N - r) * (N - n)) * (N - 2)); } // RealType skewness(const hypergeometric_distribution& dist) template inline RealType kurtosis_excess(const hypergeometric_distribution& dist) { - RealType r = static_cast(dist.sample_count()); - RealType n = static_cast(dist.defective()); + RealType r = static_cast(dist.defective()); + RealType n = static_cast(dist.sample_count()); RealType N = static_cast(dist.total()); RealType t1 = N * N * (N - 1) / (r * (N - 2) * (N - 3) * (N - r)); RealType t2 = (N * (N + 1) - 6 * N * (N - r)) / (n * (N - n)) diff --git a/boost/math/distributions/inverse_gaussian.hpp b/boost/math/distributions/inverse_gaussian.hpp index eeca12ad48..e3aa4e0650 100644 --- a/boost/math/distributions/inverse_gaussian.hpp +++ b/boost/math/distributions/inverse_gaussian.hpp @@ -82,6 +82,7 @@ public: RealType result; detail::check_scale(function, l_scale, &result, Policy()); detail::check_location(function, l_mean, &result, Policy()); + detail::check_x_gt0(function, l_mean, &result, Policy()); } RealType mean()const @@ -146,6 +147,10 @@ inline RealType pdf(const inverse_gaussian_distribution& dist, { return result; } + if(false == detail::check_x_gt0(function, mean, &result, Policy())) + { + return result; + } if(false == detail::check_positive_x(function, x, &result, Policy())) { return result; @@ -179,6 +184,10 @@ inline RealType cdf(const inverse_gaussian_distribution& dist, { return result; } + if (false == detail::check_x_gt0(function, mean, &result, Policy())) + { + return result; + } if(false == detail::check_positive_x(function, x, &result, Policy())) { return result; @@ -322,6 +331,8 @@ inline RealType quantile(const inverse_gaussian_distribution& return result; if(false == detail::check_location(function, mean, &result, Policy())) return result; + if (false == detail::check_x_gt0(function, mean, &result, Policy())) + return result; if(false == detail::check_probability(function, p, &result, Policy())) return result; if (p == 0) @@ -380,6 +391,8 @@ inline RealType cdf(const complemented2_type inline bool check_dist_and_prob(const char* function, const RealType& r, RealType p, RealType prob, RealType* result, const Policy& pol) { - if(check_dist(function, r, p, result, pol) && detail::check_probability(function, prob, result, pol) == false) + if((check_dist(function, r, p, result, pol) && detail::check_probability(function, prob, result, pol)) == false) { return false; } diff --git a/boost/math/distributions/non_central_beta.hpp b/boost/math/distributions/non_central_beta.hpp index 6e699e509f..aa66ecec0d 100644 --- a/boost/math/distributions/non_central_beta.hpp +++ b/boost/math/distributions/non_central_beta.hpp @@ -515,7 +515,11 @@ namespace boost T non_central_beta_pdf(T a, T b, T lam, T x, T y, const Policy& pol) { BOOST_MATH_STD_USING - using namespace boost::math; + // + // Special cases: + // + if((x == 0) || (y == 0)) + return 0; // // Variables come first: // diff --git a/boost/math/distributions/non_central_chi_squared.hpp b/boost/math/distributions/non_central_chi_squared.hpp index 88933c1956..97f87ed4c0 100644 --- a/boost/math/distributions/non_central_chi_squared.hpp +++ b/boost/math/distributions/non_central_chi_squared.hpp @@ -73,7 +73,7 @@ namespace boost // int k = iround(lambda, pol); // Forwards and backwards Poisson weights: - T poisf = boost::math::gamma_p_derivative(1 + k, lambda, pol); + T poisf = boost::math::gamma_p_derivative(static_cast(1 + k), lambda, pol); T poisb = poisf * k / lambda; // Initial forwards central chi squared term: T gamf = boost::math::gamma_q(del + k, y, pol); @@ -225,7 +225,7 @@ namespace boost // Central chi squared term for backward iteration: T gamkb = gamkf; // Forwards Poisson weight: - T poiskf = gamma_p_derivative(k+1, del, pol); + T poiskf = gamma_p_derivative(static_cast(k+1), del, pol); // Backwards Poisson weight: T poiskb = poiskf; // Forwards gamma function recursion term: @@ -295,7 +295,7 @@ namespace boost T l2 = lambda / 2; T sum = 0; int k = itrunc(l2); - T pois = gamma_p_derivative(k + 1, l2, pol) * gamma_p_derivative(n2 + k, x2); + T pois = gamma_p_derivative(static_cast(k + 1), l2, pol) * gamma_p_derivative(static_cast(n2 + k), x2); if(pois == 0) return 0; T poisb = pois; @@ -334,7 +334,7 @@ namespace boost BOOST_MATH_STD_USING value_type result; if(l == 0) - result = cdf(boost::math::chi_squared_distribution(k), x); + return invert == false ? cdf(boost::math::chi_squared_distribution(k), x) : cdf(complement(boost::math::chi_squared_distribution(k), x)); else if(x > k + l) { // Complement is the smaller of the two: @@ -442,7 +442,7 @@ namespace boost // noncentral chi squared", Biometrika 46: 364. // See also: // "A comparison of approximations to percentiles of the noncentral chi2-distribution", - // Hardeo Sahai and Mario Miguel Ojeda, Revista de Matematica: Teoria y Aplicaciones 2003 10(1–2) : 57–76. + // Hardeo Sahai and Mario Miguel Ojeda, Revista de Matematica: Teoria y Aplicaciones 2003 10(1-2) : 57-76. // Note that the latter reference refers to an approximation of the CDF, when they really mean the quantile. // value_type b = -(l * l) / (k + 3 * l); @@ -693,18 +693,18 @@ namespace boost static RealType find_degrees_of_freedom(RealType lam, RealType x, RealType p) { const char* function = "non_central_chi_squared<%1%>::find_degrees_of_freedom"; - typedef typename policies::evaluation::type value_type; + typedef typename policies::evaluation::type eval_type; typedef typename policies::normalise< Policy, policies::promote_float, policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; - value_type result = detail::find_degrees_of_freedom( - static_cast(lam), - static_cast(x), - static_cast(p), - static_cast(1-p), + eval_type result = detail::find_degrees_of_freedom( + static_cast(lam), + static_cast(x), + static_cast(p), + static_cast(1-p), forwarding_policy()); return policies::checked_narrowing_cast( result, @@ -714,18 +714,18 @@ namespace boost static RealType find_degrees_of_freedom(const complemented3_type& c) { const char* function = "non_central_chi_squared<%1%>::find_degrees_of_freedom"; - typedef typename policies::evaluation::type value_type; + typedef typename policies::evaluation::type eval_type; typedef typename policies::normalise< Policy, policies::promote_float, policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; - value_type result = detail::find_degrees_of_freedom( - static_cast(c.dist), - static_cast(c.param1), - static_cast(1-c.param2), - static_cast(c.param2), + eval_type result = detail::find_degrees_of_freedom( + static_cast(c.dist), + static_cast(c.param1), + static_cast(1-c.param2), + static_cast(c.param2), forwarding_policy()); return policies::checked_narrowing_cast( result, @@ -734,18 +734,18 @@ namespace boost static RealType find_non_centrality(RealType v, RealType x, RealType p) { const char* function = "non_central_chi_squared<%1%>::find_non_centrality"; - typedef typename policies::evaluation::type value_type; + typedef typename policies::evaluation::type eval_type; typedef typename policies::normalise< Policy, policies::promote_float, policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; - value_type result = detail::find_non_centrality( - static_cast(v), - static_cast(x), - static_cast(p), - static_cast(1-p), + eval_type result = detail::find_non_centrality( + static_cast(v), + static_cast(x), + static_cast(p), + static_cast(1-p), forwarding_policy()); return policies::checked_narrowing_cast( result, @@ -755,18 +755,18 @@ namespace boost static RealType find_non_centrality(const complemented3_type& c) { const char* function = "non_central_chi_squared<%1%>::find_non_centrality"; - typedef typename policies::evaluation::type value_type; + typedef typename policies::evaluation::type eval_type; typedef typename policies::normalise< Policy, policies::promote_float, policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; - value_type result = detail::find_non_centrality( - static_cast(c.dist), - static_cast(c.param1), - static_cast(1-c.param2), - static_cast(c.param2), + eval_type result = detail::find_non_centrality( + static_cast(c.dist), + static_cast(c.param1), + static_cast(1-c.param2), + static_cast(c.param2), forwarding_policy()); return policies::checked_narrowing_cast( result, diff --git a/boost/math/distributions/non_central_t.hpp b/boost/math/distributions/non_central_t.hpp index df7a58e575..718453b657 100644 --- a/boost/math/distributions/non_central_t.hpp +++ b/boost/math/distributions/non_central_t.hpp @@ -90,7 +90,7 @@ namespace boost betaf -= xtermf; T term = poisf * betaf; sum += term; - if((fabs(last_term) > fabs(term)) && (fabs(term/sum) < errtol)) + if((fabs(last_term) >= fabs(term)) && (fabs(term/sum) < errtol)) break; last_term = term; ++count; @@ -358,7 +358,7 @@ namespace boost s = boost::math::sign(pzero - q); if(s != boost::math::sign(guess)) { - guess = s; + guess = static_cast(s); } value_type result = detail::generic_quantile( diff --git a/boost/math/distributions/rayleigh.hpp b/boost/math/distributions/rayleigh.hpp index 01f38c0b01..744733a9fa 100644 --- a/boost/math/distributions/rayleigh.hpp +++ b/boost/math/distributions/rayleigh.hpp @@ -182,7 +182,7 @@ inline RealType cdf(const complemented2_type= tools::max_value()) - return 0; + return 0; result = exp(-ea); return result; } // cdf complement diff --git a/boost/math/distributions/skew_normal.hpp b/boost/math/distributions/skew_normal.hpp index 98348e59bb..f348347ede 100644 --- a/boost/math/distributions/skew_normal.hpp +++ b/boost/math/distributions/skew_normal.hpp @@ -122,15 +122,6 @@ namespace boost{ namespace math{ const RealType shape = dist.shape(); static const char* function = "boost::math::pdf(const skew_normal_distribution<%1%>&, %1%)"; - if((boost::math::isinf)(x)) - { - return 0; // pdf + and - infinity is zero. - } - // Below produces MSVC 4127 warnings, so the above used instead. - //if(std::numeric_limits::has_infinity && abs(x) == std::numeric_limits::infinity()) - //{ // pdf + and - infinity is zero. - // return 0; - //} RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) @@ -145,6 +136,15 @@ namespace boost{ namespace math{ { return result; } + if((boost::math::isinf)(x)) + { + return 0; // pdf + and - infinity is zero. + } + // Below produces MSVC 4127 warnings, so the above used instead. + //if(std::numeric_limits::has_infinity && abs(x) == std::numeric_limits::infinity()) + //{ // pdf + and - infinity is zero. + // return 0; + //} if(false == detail::check_x(function, x, &result, Policy())) { return result; diff --git a/boost/math/distributions/triangular.hpp b/boost/math/distributions/triangular.hpp index 78ef0df744..1e49a38faf 100644 --- a/boost/math/distributions/triangular.hpp +++ b/boost/math/distributions/triangular.hpp @@ -8,6 +8,12 @@ #define BOOST_STATS_TRIANGULAR_HPP // http://mathworld.wolfram.com/TriangularDistribution.html +// Note that the 'constructors' defined by Wolfram are difference from those here, +// for example +// N[variance[triangulardistribution{1, +2}, 1.5], 50] computes +// 0.041666666666666666666666666666666666666666666666667 +// TriangularDistribution{1, +2}, 1.5 is the analog of triangular_distribution(1, 1.5, 2) + // http://en.wikipedia.org/wiki/Triangular_distribution #include @@ -449,7 +455,7 @@ namespace boost{ namespace math } RealType lower = dist.lower(); RealType upper = dist.upper(); - if (mode < (upper - lower) / 2) + if (mode >= (upper + lower) / 2) { return lower + sqrt((upper - lower) * (mode - lower)) / constants::root_two(); } @@ -475,7 +481,9 @@ namespace boost{ namespace math return result; } return root_two() * (lower + upper - 2 * mode) * (2 * lower - upper - mode) * (lower - 2 * upper + mode) / - (5 * pow((lower * lower + upper + upper + mode * mode - lower * upper - lower * mode - upper * mode), RealType(3)/RealType(2))); + (5 * pow((lower * lower + upper * upper + mode * mode + - lower * upper - lower * mode - upper * mode), RealType(3)/RealType(2))); + // #11768: Skewness formula for triangular distribution is incorrect - corrected 29 Oct 2015 for release 1.61. } // RealType skewness(const triangular_distribution& dist) template diff --git a/boost/math/distributions/uniform.hpp b/boost/math/distributions/uniform.hpp index a20597a66a..856c144e36 100644 --- a/boost/math/distributions/uniform.hpp +++ b/boost/math/distributions/uniform.hpp @@ -269,15 +269,18 @@ namespace boost{ namespace math return result; } if(false == detail::check_probability("boost::math::quantile(const uniform_distribution<%1%>&, %1%)", q, &result, Policy())) - if(q == 0) - { - return lower; - } - if(q == 1) - { - return upper; - } - return -q * (upper - lower) + upper; + { + return result; + } + if(q == 0) + { + return upper; + } + if(q == 1) + { + return lower; + } + return -q * (upper - lower) + upper; } // RealType quantile(const complemented2_type, RealType>& c) template diff --git a/boost/math/policies/error_handling.hpp b/boost/math/policies/error_handling.hpp index 674759006e..285fbea7c4 100644 --- a/boost/math/policies/error_handling.hpp +++ b/boost/math/policies/error_handling.hpp @@ -157,11 +157,11 @@ inline T raise_domain_error( } template -inline T raise_domain_error( +inline BOOST_MATH_CONSTEXPR T raise_domain_error( const char* , const char* , const T& , - const ::boost::math::policies::domain_error< ::boost::math::policies::ignore_error>&) + const ::boost::math::policies::domain_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: @@ -173,7 +173,7 @@ inline T raise_domain_error( const char* , const char* , const T& , - const ::boost::math::policies::domain_error< ::boost::math::policies::errno_on_error>&) + const ::boost::math::policies::domain_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T) { errno = EDOM; // This may or may not do the right thing, but the user asked for the error @@ -202,21 +202,21 @@ inline T raise_pole_error( } template -inline T raise_pole_error( +inline BOOST_MATH_CONSTEXPR T raise_pole_error( const char* function, const char* message, const T& val, - const ::boost::math::policies::pole_error< ::boost::math::policies::ignore_error>&) + const ::boost::math::policies::pole_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T) { return ::boost::math::policies::detail::raise_domain_error(function, message, val, ::boost::math::policies::domain_error< ::boost::math::policies::ignore_error>()); } template -inline T raise_pole_error( +inline BOOST_MATH_CONSTEXPR T raise_pole_error( const char* function, const char* message, const T& val, - const ::boost::math::policies::pole_error< ::boost::math::policies::errno_on_error>&) + const ::boost::math::policies::pole_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T) { return ::boost::math::policies::detail::raise_domain_error(function, message, val, ::boost::math::policies::domain_error< ::boost::math::policies::errno_on_error>()); } @@ -256,10 +256,10 @@ inline T raise_overflow_error( } template -inline T raise_overflow_error( +inline BOOST_MATH_CONSTEXPR T raise_overflow_error( const char* , const char* , - const ::boost::math::policies::overflow_error< ::boost::math::policies::ignore_error>&) + const ::boost::math::policies::overflow_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: @@ -267,11 +267,11 @@ inline T raise_overflow_error( } template -inline T raise_overflow_error( +inline BOOST_MATH_CONSTEXPR T raise_overflow_error( const char* , const char* , const T&, - const ::boost::math::policies::overflow_error< ::boost::math::policies::ignore_error>&) + const ::boost::math::policies::overflow_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: @@ -282,7 +282,7 @@ template inline T raise_overflow_error( const char* , const char* , - const ::boost::math::policies::overflow_error< ::boost::math::policies::errno_on_error>&) + const ::boost::math::policies::overflow_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T) { errno = ERANGE; // This may or may not do the right thing, but the user asked for the error @@ -295,7 +295,7 @@ inline T raise_overflow_error( const char* , const char* , const T&, - const ::boost::math::policies::overflow_error< ::boost::math::policies::errno_on_error>&) + const ::boost::math::policies::overflow_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T) { errno = ERANGE; // This may or may not do the right thing, but the user asked for the error @@ -342,10 +342,10 @@ inline T raise_underflow_error( } template -inline T raise_underflow_error( +inline BOOST_MATH_CONSTEXPR T raise_underflow_error( const char* , const char* , - const ::boost::math::policies::underflow_error< ::boost::math::policies::ignore_error>&) + const ::boost::math::policies::underflow_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: @@ -356,7 +356,7 @@ template inline T raise_underflow_error( const char* /* function */, const char* /* message */, - const ::boost::math::policies::underflow_error< ::boost::math::policies::errno_on_error>&) + const ::boost::math::policies::underflow_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T) { errno = ERANGE; // This may or may not do the right thing, but the user asked for the error @@ -386,11 +386,11 @@ inline T raise_denorm_error( } template -inline T raise_denorm_error( +inline BOOST_MATH_CONSTEXPR T raise_denorm_error( const char* , const char* , const T& val, - const ::boost::math::policies::denorm_error< ::boost::math::policies::ignore_error>&) + const ::boost::math::policies::denorm_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: @@ -402,7 +402,7 @@ inline T raise_denorm_error( const char* , const char* , const T& val, - const ::boost::math::policies::denorm_error< ::boost::math::policies::errno_on_error>&) + const ::boost::math::policies::denorm_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T) { errno = ERANGE; // This may or may not do the right thing, but the user asked for the error @@ -433,11 +433,11 @@ inline T raise_evaluation_error( } template -inline T raise_evaluation_error( +inline BOOST_MATH_CONSTEXPR T raise_evaluation_error( const char* , const char* , const T& val, - const ::boost::math::policies::evaluation_error< ::boost::math::policies::ignore_error>&) + const ::boost::math::policies::evaluation_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: @@ -449,7 +449,7 @@ inline T raise_evaluation_error( const char* , const char* , const T& val, - const ::boost::math::policies::evaluation_error< ::boost::math::policies::errno_on_error>&) + const ::boost::math::policies::evaluation_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T) { errno = EDOM; // This may or may not do the right thing, but the user asked for the error @@ -481,12 +481,12 @@ inline TargetType raise_rounding_error( } template -inline TargetType raise_rounding_error( +inline BOOST_MATH_CONSTEXPR TargetType raise_rounding_error( const char* , const char* , const T& val, const TargetType&, - const ::boost::math::policies::rounding_error< ::boost::math::policies::ignore_error>&) + const ::boost::math::policies::rounding_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: @@ -500,7 +500,7 @@ inline TargetType raise_rounding_error( const char* , const T& val, const TargetType&, - const ::boost::math::policies::rounding_error< ::boost::math::policies::errno_on_error>&) + const ::boost::math::policies::rounding_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T) { errno = ERANGE; // This may or may not do the right thing, but the user asked for the error @@ -509,6 +509,20 @@ inline TargetType raise_rounding_error( return val > 0 ? (std::numeric_limits::max)() : (std::numeric_limits::is_integer ? (std::numeric_limits::min)() : -(std::numeric_limits::max)()); } +template +inline T raise_rounding_error( + const char* , + const char* , + const T& val, + const T&, + const ::boost::math::policies::rounding_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T) +{ + errno = ERANGE; + // This may or may not do the right thing, but the user asked for the error + // to be silent so here we go anyway: + return val > 0 ? boost::math::tools::max_value() : -boost::math::tools::max_value(); +} + template inline TargetType raise_rounding_error( const char* function, @@ -534,12 +548,12 @@ inline T raise_indeterminate_result_error( } template -inline T raise_indeterminate_result_error( +inline BOOST_MATH_CONSTEXPR T raise_indeterminate_result_error( const char* , const char* , const T& , const R& result, - const ::boost::math::policies::indeterminate_result_error< ::boost::math::policies::ignore_error>&) + const ::boost::math::policies::indeterminate_result_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: @@ -574,7 +588,7 @@ inline T raise_indeterminate_result_error( } // namespace detail template -inline T raise_domain_error(const char* function, const char* message, const T& val, const Policy&) +inline BOOST_MATH_CONSTEXPR T raise_domain_error(const char* function, const char* message, const T& val, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy::value && BOOST_MATH_IS_FLOAT(T)) { typedef typename Policy::domain_error_type policy_type; return detail::raise_domain_error( @@ -583,7 +597,7 @@ inline T raise_domain_error(const char* function, const char* message, const T& } template -inline T raise_pole_error(const char* function, const char* message, const T& val, const Policy&) +inline BOOST_MATH_CONSTEXPR T raise_pole_error(const char* function, const char* message, const T& val, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy::value && BOOST_MATH_IS_FLOAT(T)) { typedef typename Policy::pole_error_type policy_type; return detail::raise_pole_error( @@ -592,7 +606,7 @@ inline T raise_pole_error(const char* function, const char* message, const T& va } template -inline T raise_overflow_error(const char* function, const char* message, const Policy&) +inline BOOST_MATH_CONSTEXPR T raise_overflow_error(const char* function, const char* message, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy::value && BOOST_MATH_IS_FLOAT(T)) { typedef typename Policy::overflow_error_type policy_type; return detail::raise_overflow_error( @@ -601,7 +615,7 @@ inline T raise_overflow_error(const char* function, const char* message, const P } template -inline T raise_overflow_error(const char* function, const char* message, const T& val, const Policy&) +inline BOOST_MATH_CONSTEXPR T raise_overflow_error(const char* function, const char* message, const T& val, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy::value && BOOST_MATH_IS_FLOAT(T)) { typedef typename Policy::overflow_error_type policy_type; return detail::raise_overflow_error( @@ -610,7 +624,7 @@ inline T raise_overflow_error(const char* function, const char* message, const T } template -inline T raise_underflow_error(const char* function, const char* message, const Policy&) +inline BOOST_MATH_CONSTEXPR T raise_underflow_error(const char* function, const char* message, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy::value && BOOST_MATH_IS_FLOAT(T)) { typedef typename Policy::underflow_error_type policy_type; return detail::raise_underflow_error( @@ -619,7 +633,7 @@ inline T raise_underflow_error(const char* function, const char* message, const } template -inline T raise_denorm_error(const char* function, const char* message, const T& val, const Policy&) +inline BOOST_MATH_CONSTEXPR T raise_denorm_error(const char* function, const char* message, const T& val, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy::value && BOOST_MATH_IS_FLOAT(T)) { typedef typename Policy::denorm_error_type policy_type; return detail::raise_denorm_error( @@ -629,7 +643,7 @@ inline T raise_denorm_error(const char* function, const char* message, const T& } template -inline T raise_evaluation_error(const char* function, const char* message, const T& val, const Policy&) +inline BOOST_MATH_CONSTEXPR T raise_evaluation_error(const char* function, const char* message, const T& val, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy::value && BOOST_MATH_IS_FLOAT(T)) { typedef typename Policy::evaluation_error_type policy_type; return detail::raise_evaluation_error( @@ -638,7 +652,7 @@ inline T raise_evaluation_error(const char* function, const char* message, const } template -inline TargetType raise_rounding_error(const char* function, const char* message, const T& val, const TargetType& t, const Policy&) +inline BOOST_MATH_CONSTEXPR TargetType raise_rounding_error(const char* function, const char* message, const T& val, const TargetType& t, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy::value && BOOST_MATH_IS_FLOAT(T)) { typedef typename Policy::rounding_error_type policy_type; return detail::raise_rounding_error( @@ -647,7 +661,7 @@ inline TargetType raise_rounding_error(const char* function, const char* message } template -inline T raise_indeterminate_result_error(const char* function, const char* message, const T& val, const R& result, const Policy&) +inline BOOST_MATH_CONSTEXPR T raise_indeterminate_result_error(const char* function, const char* message, const T& val, const R& result, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy::value && BOOST_MATH_IS_FLOAT(T)) { typedef typename Policy::indeterminate_result_error_type policy_type; return detail::raise_indeterminate_result_error( @@ -662,7 +676,7 @@ namespace detail { template -inline bool check_overflow(T val, R* result, const char* function, const Policy& pol) +inline bool check_overflow(T val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error)) { BOOST_MATH_STD_USING if(fabs(val) > tools::max_value()) @@ -674,7 +688,7 @@ inline bool check_overflow(T val, R* result, const char* function, const Policy& return false; } template -inline bool check_overflow(std::complex val, R* result, const char* function, const Policy& pol) +inline bool check_overflow(std::complex val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error)) { typedef typename R::value_type r_type; r_type re, im; @@ -684,7 +698,7 @@ inline bool check_overflow(std::complex val, R* result, const char* function, return r; } template -inline bool check_underflow(T val, R* result, const char* function, const Policy& pol) +inline bool check_underflow(T val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error)) { if((val != 0) && (static_cast(val) == 0)) { @@ -694,7 +708,7 @@ inline bool check_underflow(T val, R* result, const char* function, const Policy return false; } template -inline bool check_underflow(std::complex val, R* result, const char* function, const Policy& pol) +inline bool check_underflow(std::complex val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error)) { typedef typename R::value_type r_type; r_type re, im; @@ -704,7 +718,7 @@ inline bool check_underflow(std::complex val, R* result, const char* function return r; } template -inline bool check_denorm(T val, R* result, const char* function, const Policy& pol) +inline bool check_denorm(T val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error)) { BOOST_MATH_STD_USING if((fabs(val) < static_cast(tools::min_value())) && (static_cast(val) != 0)) @@ -715,7 +729,7 @@ inline bool check_denorm(T val, R* result, const char* function, const Policy& p return false; } template -inline bool check_denorm(std::complex val, R* result, const char* function, const Policy& pol) +inline bool check_denorm(std::complex val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error)) { typedef typename R::value_type r_type; r_type re, im; @@ -727,22 +741,28 @@ inline bool check_denorm(std::complex val, R* result, const char* function, c // Default instantiations with ignore_error policy. template -inline bool check_overflow(T /* val */, R* /* result */, const char* /* function */, const overflow_error&){ return false; } +inline BOOST_MATH_CONSTEXPR bool check_overflow(T /* val */, R* /* result */, const char* /* function */, const overflow_error&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +{ return false; } template -inline bool check_overflow(std::complex /* val */, R* /* result */, const char* /* function */, const overflow_error&){ return false; } +inline BOOST_MATH_CONSTEXPR bool check_overflow(std::complex /* val */, R* /* result */, const char* /* function */, const overflow_error&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +{ return false; } template -inline bool check_underflow(T /* val */, R* /* result */, const char* /* function */, const underflow_error&){ return false; } +inline BOOST_MATH_CONSTEXPR bool check_underflow(T /* val */, R* /* result */, const char* /* function */, const underflow_error&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +{ return false; } template -inline bool check_underflow(std::complex /* val */, R* /* result */, const char* /* function */, const underflow_error&){ return false; } +inline BOOST_MATH_CONSTEXPR bool check_underflow(std::complex /* val */, R* /* result */, const char* /* function */, const underflow_error&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +{ return false; } template -inline bool check_denorm(T /* val */, R* /* result*/, const char* /* function */, const denorm_error&){ return false; } +inline BOOST_MATH_CONSTEXPR bool check_denorm(T /* val */, R* /* result*/, const char* /* function */, const denorm_error&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +{ return false; } template -inline bool check_denorm(std::complex /* val */, R* /* result*/, const char* /* function */, const denorm_error&){ return false; } +inline BOOST_MATH_CONSTEXPR bool check_denorm(std::complex /* val */, R* /* result*/, const char* /* function */, const denorm_error&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T)) +{ return false; } } // namespace detail template -inline R checked_narrowing_cast(T val, const char* function) +inline R checked_narrowing_cast(T val, const char* function) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && is_noexcept_error_policy::value) { typedef typename Policy::overflow_error_type overflow_type; typedef typename Policy::underflow_error_type underflow_type; @@ -762,7 +782,7 @@ inline R checked_narrowing_cast(T val, const char* function) } template -inline void check_series_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol) +inline void check_series_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && is_noexcept_error_policy::value) { if(max_iter >= policies::get_max_series_iterations()) raise_evaluation_error( @@ -771,7 +791,7 @@ inline void check_series_iterations(const char* function, boost::uintmax_t max_i } template -inline void check_root_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol) +inline void check_root_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && is_noexcept_error_policy::value) { if(max_iter >= policies::get_max_root_iterations()) raise_evaluation_error( @@ -788,7 +808,7 @@ namespace detail{ // that value usually comes from one of the error handlers above: // template -std::pair pair_from_single(const T& val) +std::pair pair_from_single(const T& val) BOOST_MATH_NOEXCEPT(T) { return std::make_pair(val, val); } diff --git a/boost/math/policies/policy.hpp b/boost/math/policies/policy.hpp index 71309fa116..de813fb8aa 100644 --- a/boost/math/policies/policy.hpp +++ b/boost/math/policies/policy.hpp @@ -33,9 +33,9 @@ namespace boost{ namespace math{ namespace tools{ template -int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)); +BOOST_MATH_CONSTEXPR int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_NOEXCEPT; template -T epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)); +BOOST_MATH_CONSTEXPR T epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T); } @@ -44,6 +44,28 @@ namespace policies{ // // Define macros for our default policies, if they're not defined already: // +// Special cases for exceptions disabled first: +// +#ifdef BOOST_NO_EXCEPTIONS +# ifndef BOOST_MATH_DOMAIN_ERROR_POLICY +# define BOOST_MATH_DOMAIN_ERROR_POLICY errno_on_error +# endif +# ifndef BOOST_MATH_POLE_ERROR_POLICY +# define BOOST_MATH_POLE_ERROR_POLICY errno_on_error +# endif +# ifndef BOOST_MATH_OVERFLOW_ERROR_POLICY +# define BOOST_MATH_OVERFLOW_ERROR_POLICY errno_on_error +# endif +# ifndef BOOST_MATH_EVALUATION_ERROR_POLICY +# define BOOST_MATH_EVALUATION_ERROR_POLICY errno_on_error +# endif +# ifndef BOOST_MATH_ROUNDING_ERROR_POLICY +# define BOOST_MATH_ROUNDING_ERROR_POLICY errno_on_error +# endif +#endif +// +// Then the regular cases: +// #ifndef BOOST_MATH_DOMAIN_ERROR_POLICY #define BOOST_MATH_DOMAIN_ERROR_POLICY throw_on_error #endif @@ -622,81 +644,81 @@ struct normalise, typedef policy type; }; -inline policy<> make_policy() +inline BOOST_MATH_CONSTEXPR policy<> make_policy() BOOST_NOEXCEPT { return policy<>(); } template -inline typename normalise, A1>::type make_policy(const A1&) +inline BOOST_MATH_CONSTEXPR typename normalise, A1>::type make_policy(const A1&) BOOST_NOEXCEPT { typedef typename normalise, A1>::type result_type; return result_type(); } template -inline typename normalise, A1, A2>::type make_policy(const A1&, const A2&) +inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2>::type make_policy(const A1&, const A2&) BOOST_NOEXCEPT { typedef typename normalise, A1, A2>::type result_type; return result_type(); } template -inline typename normalise, A1, A2, A3>::type make_policy(const A1&, const A2&, const A3&) +inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3>::type make_policy(const A1&, const A2&, const A3&) BOOST_NOEXCEPT { typedef typename normalise, A1, A2, A3>::type result_type; return result_type(); } template -inline typename normalise, A1, A2, A3, A4>::type make_policy(const A1&, const A2&, const A3&, const A4&) +inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4>::type make_policy(const A1&, const A2&, const A3&, const A4&) BOOST_NOEXCEPT { typedef typename normalise, A1, A2, A3, A4>::type result_type; return result_type(); } template -inline typename normalise, A1, A2, A3, A4, A5>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&) +inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&) BOOST_NOEXCEPT { typedef typename normalise, A1, A2, A3, A4, A5>::type result_type; return result_type(); } template -inline typename normalise, A1, A2, A3, A4, A5, A6>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&) +inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5, A6>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&) BOOST_NOEXCEPT { typedef typename normalise, A1, A2, A3, A4, A5, A6>::type result_type; return result_type(); } template -inline typename normalise, A1, A2, A3, A4, A5, A6, A7>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&) +inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5, A6, A7>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&) BOOST_NOEXCEPT { typedef typename normalise, A1, A2, A3, A4, A5, A6, A7>::type result_type; return result_type(); } template -inline typename normalise, A1, A2, A3, A4, A5, A6, A7, A8>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&) +inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5, A6, A7, A8>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&) BOOST_NOEXCEPT { typedef typename normalise, A1, A2, A3, A4, A5, A6, A7, A8>::type result_type; return result_type(); } template -inline typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&) +inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&) BOOST_NOEXCEPT { typedef typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9>::type result_type; return result_type(); } template -inline typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&, const A10&) +inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&, const A10&) BOOST_NOEXCEPT { typedef typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>::type result_type; return result_type(); } template -inline typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&, const A10&, const A11&) +inline BOOST_MATH_CONSTEXPR typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&, const A10&, const A11&) BOOST_NOEXCEPT { typedef typename normalise, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::type result_type; return result_type(); @@ -825,7 +847,7 @@ struct precision namespace detail{ template -inline int digits_imp(mpl::true_ const&) +inline BOOST_MATH_CONSTEXPR int digits_imp(mpl::true_ const&) BOOST_NOEXCEPT { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); @@ -837,7 +859,7 @@ inline int digits_imp(mpl::true_ const&) } template -inline int digits_imp(mpl::false_ const&) +inline BOOST_MATH_CONSTEXPR int digits_imp(mpl::false_ const&) BOOST_NOEXCEPT { return tools::digits(); } @@ -845,26 +867,26 @@ inline int digits_imp(mpl::false_ const&) } // namespace detail template -inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_NOEXCEPT { typedef mpl::bool_< std::numeric_limits::is_specialized > tag_type; return detail::digits_imp(tag_type()); } template -inline int digits_base10(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR int digits_base10(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_NOEXCEPT { return boost::math::policies::digits() * 301 / 1000L; } template -inline unsigned long get_max_series_iterations() +inline BOOST_MATH_CONSTEXPR unsigned long get_max_series_iterations() BOOST_NOEXCEPT { typedef typename Policy::max_series_iterations_type iter_type; return iter_type::value; } template -inline unsigned long get_max_root_iterations() +inline BOOST_MATH_CONSTEXPR unsigned long get_max_root_iterations() BOOST_NOEXCEPT { typedef typename Policy::max_root_iterations_type iter_type; return iter_type::value; @@ -875,7 +897,7 @@ namespace detail{ template struct series_factor_calc { - static T get() + static T get() BOOST_MATH_NOEXCEPT(T) { return ldexp(T(1.0), 1 - Digits::value); } @@ -884,7 +906,7 @@ struct series_factor_calc template struct series_factor_calc { - static T get() + static BOOST_MATH_CONSTEXPR T get() BOOST_MATH_NOEXCEPT(T) { return boost::math::tools::epsilon(); } @@ -892,23 +914,24 @@ struct series_factor_calc template struct series_factor_calc { - static T get() + BOOST_STATIC_CONSTANT(boost::uintmax_t, v = static_cast(1u) << (Digits::value - 1)); + + static BOOST_MATH_CONSTEXPR T get() BOOST_MATH_NOEXCEPT(T) { - static const boost::uintmax_t v = static_cast(1u) << (Digits::value - 1); return 1 / static_cast(v); } }; template struct series_factor_calc { - static T get() + static BOOST_MATH_CONSTEXPR T get() BOOST_MATH_NOEXCEPT(T) { return boost::math::tools::epsilon(); } }; template -inline T get_epsilon_imp(mpl::true_ const&) +inline BOOST_MATH_CONSTEXPR T get_epsilon_imp(mpl::true_ const&) BOOST_MATH_NOEXCEPT(T) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); @@ -924,7 +947,7 @@ inline T get_epsilon_imp(mpl::true_ const&) } template -inline T get_epsilon_imp(mpl::false_ const&) +inline BOOST_MATH_CONSTEXPR T get_epsilon_imp(mpl::false_ const&) BOOST_MATH_NOEXCEPT(T) { return tools::epsilon(); } @@ -932,7 +955,7 @@ inline T get_epsilon_imp(mpl::false_ const&) } // namespace detail template -inline T get_epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T get_epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T) { typedef mpl::bool_< (std::numeric_limits::is_specialized && (std::numeric_limits::radix == 2)) > tag_type; return detail::get_epsilon_imp(tag_type()); @@ -973,7 +996,7 @@ struct constructor_error_check { typedef typename Policy::domain_error_type domain_error_type; typedef typename mpl::if_c< - (domain_error_type::value == throw_on_error) || (domain_error_type::value == user_error), + (domain_error_type::value == throw_on_error) || (domain_error_type::value == user_error) || (domain_error_type::value == errno_on_error), mpl::true_, mpl::false_>::type type; }; @@ -987,10 +1010,33 @@ struct method_error_check mpl::false_, mpl::true_>::type type; }; +// +// Does the Policy ever throw on error? +// +template +struct is_noexcept_error_policy +{ + typedef typename Policy::domain_error_type t1; + typedef typename Policy::pole_error_type t2; + typedef typename Policy::overflow_error_type t3; + typedef typename Policy::underflow_error_type t4; + typedef typename Policy::denorm_error_type t5; + typedef typename Policy::evaluation_error_type t6; + typedef typename Policy::rounding_error_type t7; + typedef typename Policy::indeterminate_result_error_type t8; + + BOOST_STATIC_CONSTANT(bool, value = + ((t1::value != throw_on_error) && (t1::value != user_error) + && (t2::value != throw_on_error) && (t2::value != user_error) + && (t3::value != throw_on_error) && (t3::value != user_error) + && (t4::value != throw_on_error) && (t4::value != user_error) + && (t5::value != throw_on_error) && (t5::value != user_error) + && (t6::value != throw_on_error) && (t6::value != user_error) + && (t7::value != throw_on_error) && (t7::value != user_error) + && (t8::value != throw_on_error) && (t8::value != user_error))); +}; }}} // namespaces #endif // BOOST_MATH_POLICY_HPP - - diff --git a/boost/math/special_functions.hpp b/boost/math/special_functions.hpp index 52e412ed8b..367701c2a9 100644 --- a/boost/math/special_functions.hpp +++ b/boost/math/special_functions.hpp @@ -67,5 +67,7 @@ #include #include #include +#include +#include #endif // BOOST_MATH_SPECIAL_FUNCTIONS_HPP diff --git a/boost/math/special_functions/bernoulli.hpp b/boost/math/special_functions/bernoulli.hpp index 5f2b7e1422..e5323fbd42 100644 --- a/boost/math/special_functions/bernoulli.hpp +++ b/boost/math/special_functions/bernoulli.hpp @@ -63,7 +63,7 @@ inline T bernoulli_b2n(const int i, const Policy &pol) if(i < 0) return policies::raise_domain_error("boost::math::bernoulli_b2n<%1%>", "Index should be >= 0 but got %1%", T(i), pol); - T result = 0; // The = 0 is just to silence compiler warings :-( + T result = static_cast(0); // The = 0 is just to silence compiler warnings :-( boost::math::detail::bernoulli_number_imp(&result, static_cast(i), 1u, pol, tag_type()); return result; } diff --git a/boost/math/special_functions/bessel.hpp b/boost/math/special_functions/bessel.hpp index eab723d8ba..1b57e0a873 100644 --- a/boost/math/special_functions/bessel.hpp +++ b/boost/math/special_functions/bessel.hpp @@ -302,20 +302,9 @@ inline T cyl_neumann_imp(T v, T x, const bessel_maybe_int_tag&, const Policy& po if(floor(v) == v) { - if(asymptotic_bessel_large_x_limit(v, x)) - { - T r = asymptotic_bessel_y_large_x_2(static_cast(abs(v)), x); - if((v < 0) && (itrunc(v, pol) & 1)) - r = -r; - BOOST_MATH_INSTRUMENT_VARIABLE(r); - return r; - } - else - { - T r = bessel_yn(itrunc(v, pol), x, pol); - BOOST_MATH_INSTRUMENT_VARIABLE(r); - return r; - } + T r = bessel_yn(itrunc(v, pol), x, pol); + BOOST_MATH_INSTRUMENT_VARIABLE(r); + return r; } T r = cyl_neumann_imp(v, x, bessel_no_int_tag(), pol); BOOST_MATH_INSTRUMENT_VARIABLE(r); @@ -325,20 +314,7 @@ inline T cyl_neumann_imp(T v, T x, const bessel_maybe_int_tag&, const Policy& po template inline T cyl_neumann_imp(int v, T x, const bessel_int_tag&, const Policy& pol) { - BOOST_MATH_STD_USING - - BOOST_MATH_INSTRUMENT_VARIABLE(v); - BOOST_MATH_INSTRUMENT_VARIABLE(x); - - if(asymptotic_bessel_large_x_limit(T(v), x)) - { - T r = asymptotic_bessel_y_large_x_2(static_cast(abs(v)), x); - if((v < 0) && (v & 1)) - r = -r; - return r; - } - else - return bessel_yn(v, x, pol); + return bessel_yn(v, x, pol); } template @@ -582,7 +558,7 @@ inline typename detail::bessel_traits::result_type cyl_bessel_i( policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; - return policies::checked_narrowing_cast(detail::cyl_bessel_i_imp(v, static_cast(x), forwarding_policy()), "boost::math::cyl_bessel_i<%1%>(%1%,%1%)"); + return policies::checked_narrowing_cast(detail::cyl_bessel_i_imp(static_cast(v), static_cast(x), forwarding_policy()), "boost::math::cyl_bessel_i<%1%>(%1%,%1%)"); } template diff --git a/boost/math/special_functions/bessel_prime.hpp b/boost/math/special_functions/bessel_prime.hpp index c5f2d58c2b..2a09b2046b 100644 --- a/boost/math/special_functions/bessel_prime.hpp +++ b/boost/math/special_functions/bessel_prime.hpp @@ -237,7 +237,7 @@ inline typename detail::bessel_traits::result_type cyl_bessel_j_ policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; - return policies::checked_narrowing_cast(detail::cyl_bessel_j_prime_imp(v, static_cast(x), forwarding_policy()), "boost::math::cyl_bessel_j_prime<%1%,%1%>(%1%,%1%)"); + return policies::checked_narrowing_cast(detail::cyl_bessel_j_prime_imp(static_cast(v), static_cast(x), forwarding_policy()), "boost::math::cyl_bessel_j_prime<%1%,%1%>(%1%,%1%)"); } template @@ -279,7 +279,7 @@ inline typename detail::bessel_traits::result_type cyl_bessel_i_ policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; - return policies::checked_narrowing_cast(detail::cyl_bessel_i_prime_imp(v, static_cast(x), forwarding_policy()), "boost::math::cyl_bessel_i_prime<%1%>(%1%,%1%)"); + return policies::checked_narrowing_cast(detail::cyl_bessel_i_prime_imp(static_cast(v), static_cast(x), forwarding_policy()), "boost::math::cyl_bessel_i_prime<%1%>(%1%,%1%)"); } template @@ -301,7 +301,7 @@ inline typename detail::bessel_traits::result_type cyl_bessel_k_ policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; - return policies::checked_narrowing_cast(detail::cyl_bessel_k_prime_imp(v, static_cast(x), forwarding_policy()), "boost::math::cyl_bessel_k_prime<%1%,%1%>(%1%,%1%)"); + return policies::checked_narrowing_cast(detail::cyl_bessel_k_prime_imp(static_cast(v), static_cast(x), forwarding_policy()), "boost::math::cyl_bessel_k_prime<%1%,%1%>(%1%,%1%)"); } template @@ -323,7 +323,7 @@ inline typename detail::bessel_traits::result_type cyl_neumann_p policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; - return policies::checked_narrowing_cast(detail::cyl_neumann_prime_imp(v, static_cast(x), forwarding_policy()), "boost::math::cyl_neumann_prime<%1%,%1%>(%1%,%1%)"); + return policies::checked_narrowing_cast(detail::cyl_neumann_prime_imp(static_cast(v), static_cast(x), forwarding_policy()), "boost::math::cyl_neumann_prime<%1%,%1%>(%1%,%1%)"); } template diff --git a/boost/math/special_functions/beta.hpp b/boost/math/special_functions/beta.hpp index 98d8f7fa80..35b114ef15 100644 --- a/boost/math/special_functions/beta.hpp +++ b/boost/math/special_functions/beta.hpp @@ -47,13 +47,19 @@ T beta_imp(T a, T b, const Lanczos&, const Policy& pol) // Special cases: if((c == a) && (b < tools::epsilon())) - return boost::math::tgamma(b, pol); + return 1 / b; else if((c == b) && (a < tools::epsilon())) - return boost::math::tgamma(a, pol); + return 1 / a; if(b == 1) return 1/a; else if(a == 1) return 1/b; + else if(c < tools::epsilon()) + { + result = c / a; + result /= b; + return result; + } /* // @@ -82,11 +88,11 @@ T beta_imp(T a, T b, const Lanczos&, const Policy& pol) std::swap(a, b); // Lanczos calculation: - T agh = a + Lanczos::g() - T(0.5); - T bgh = b + Lanczos::g() - T(0.5); - T cgh = c + Lanczos::g() - T(0.5); - result = Lanczos::lanczos_sum_expG_scaled(a) * Lanczos::lanczos_sum_expG_scaled(b) / Lanczos::lanczos_sum_expG_scaled(c); - T ambh = a - T(0.5) - b; + T agh = static_cast(a + Lanczos::g() - 0.5f); + T bgh = static_cast(b + Lanczos::g() - 0.5f); + T cgh = static_cast(c + Lanczos::g() - 0.5f); + result = Lanczos::lanczos_sum_expG_scaled(a) * (Lanczos::lanczos_sum_expG_scaled(b) / Lanczos::lanczos_sum_expG_scaled(c)); + T ambh = a - 0.5f - b; if((fabs(b * ambh) < (cgh * 100)) && (a > 100)) { // Special case where the base of the power term is close to 1 @@ -199,7 +205,9 @@ T ibeta_power_terms(T a, T y, const Lanczos&, bool normalised, - const Policy& pol) + const Policy& pol, + T prefix = 1, + const char* function = "boost::math::ibeta<%1%>(%1%, %1%, %1%)") { BOOST_MATH_STD_USING @@ -211,14 +219,17 @@ T ibeta_power_terms(T a, T result; - T prefix = 1; T c = a + b; // combine power terms with Lanczos approximation: - T agh = a + Lanczos::g() - T(0.5); - T bgh = b + Lanczos::g() - T(0.5); - T cgh = c + Lanczos::g() - T(0.5); + T agh = static_cast(a + Lanczos::g() - 0.5f); + T bgh = static_cast(b + Lanczos::g() - 0.5f); + T cgh = static_cast(c + Lanczos::g() - 0.5f); result = Lanczos::lanczos_sum_expG_scaled(c) / (Lanczos::lanczos_sum_expG_scaled(a) * Lanczos::lanczos_sum_expG_scaled(b)); + result *= prefix; + // combine with the leftover terms from the Lanczos approximation: + result *= sqrt(bgh / boost::math::constants::e()); + result *= sqrt(agh / cgh); // l1 and l2 are the base of the exponents minus one: T l1 = (x * b - y * agh) / agh; @@ -308,7 +319,15 @@ T ibeta_power_terms(T a, // First base near 1 only: T l = a * boost::math::log1p(l1, pol) + b * log((y * cgh) / bgh); - result *= exp(l); + if((l <= tools::log_min_value()) || (l >= tools::log_max_value())) + { + l += log(result); + if(l >= tools::log_max_value()) + return policies::raise_overflow_error(function, 0, pol); + result = exp(l); + } + else + result *= exp(l); BOOST_MATH_INSTRUMENT_VARIABLE(result); } else @@ -316,7 +335,15 @@ T ibeta_power_terms(T a, // Second base near 1 only: T l = b * boost::math::log1p(l2, pol) + a * log((x * cgh) / agh); - result *= exp(l); + if((l <= tools::log_min_value()) || (l >= tools::log_max_value())) + { + l += log(result); + if(l >= tools::log_max_value()) + return policies::raise_overflow_error(function, 0, pol); + result = exp(l); + } + else + result *= exp(l); BOOST_MATH_INSTRUMENT_VARIABLE(result); } } @@ -337,11 +364,41 @@ T ibeta_power_terms(T a, || (l2 <= tools::log_min_value()) ) { - // Oops, overflow, sidestep: + // Oops, under/overflow, sidestep if we can: if(a < b) - result *= pow(pow(b2, b/a) * b1, a); + { + T p1 = pow(b2, b / a); + T l3 = a * (log(b1) + log(p1)); + if((l3 < tools::log_max_value()) + && (l3 > tools::log_min_value())) + { + result *= pow(p1 * b1, a); + } + else + { + l2 += l1 + log(result); + if(l2 >= tools::log_max_value()) + return policies::raise_overflow_error(function, 0, pol); + result = exp(l2); + } + } else - result *= pow(pow(b1, a/b) * b2, b); + { + T p1 = pow(b1, a / b); + T l3 = (log(p1) + log(b2)) * b; + if((l3 < tools::log_max_value()) + && (l3 > tools::log_min_value())) + { + result *= pow(p1 * b2, b); + } + else + { + l2 += l1 + log(result); + if(l2 >= tools::log_max_value()) + return policies::raise_overflow_error(function, 0, pol); + result = exp(l2); + } + } BOOST_MATH_INSTRUMENT_VARIABLE(result); } else @@ -351,10 +408,6 @@ T ibeta_power_terms(T a, BOOST_MATH_INSTRUMENT_VARIABLE(result); } } - // combine with the leftover terms from the Lanczos approximation: - result *= sqrt(bgh / boost::math::constants::e()); - result *= sqrt(agh / cgh); - result *= prefix; BOOST_MATH_INSTRUMENT_VARIABLE(result); @@ -380,7 +433,9 @@ T ibeta_power_terms(T a, T y, const boost::math::lanczos::undefined_lanczos&, bool normalised, - const Policy& pol) + const Policy& pol, + T prefix = 1, + const char* = "boost::math::ibeta<%1%>(%1%, %1%, %1%)") { BOOST_MATH_STD_USING @@ -411,7 +466,7 @@ T ibeta_power_terms(T a, T b1 = (x * lc) / la; T b2 = (y * lc) / lb; - T e1 = lc - la - lb; + T e1 = -5; // lc - la - lb; T lb1 = a * log(b1); T lb2 = b * log(b2); @@ -423,21 +478,23 @@ T ibeta_power_terms(T a, || (e1 <= tools::log_min_value()) ) { - result = exp(lb1 + lb2 - e1); + result = exp(lb1 + lb2 - e1 + log(prefix)); } else { T p1, p2; - if((fabs(b1 - 1) * a < 10) && (a > 1)) - p1 = exp(a * boost::math::log1p((x * b - y * la) / la, pol)); + p1 = (x * b - y * la) / la; + if(fabs(p1) < 0.5f) + p1 = exp(a * boost::math::log1p(p1, pol)); else p1 = pow(b1, a); - if((fabs(b2 - 1) * b < 10) && (b > 1)) - p2 = exp(b * boost::math::log1p((y * a - x * lb) / lb, pol)); + p2 = (y * a - x * lb) / lb; + if(fabs(p2) < 0.5f) + p2 = exp(b * boost::math::log1p(p2, pol)); else p2 = pow(b2, b); T p3 = exp(e1); - result = p1 * p2 / p3; + result = prefix * p1 * (p2 / p3); } // and combine with the remaining gamma function components: result /= sa * sb / sc; @@ -480,21 +537,43 @@ T ibeta_series(T a, T b, T x, T s0, const Lanczos&, bool normalised, T* p_deriva T c = a + b; // incomplete beta power term, combined with the Lanczos approximation: - T agh = a + Lanczos::g() - T(0.5); - T bgh = b + Lanczos::g() - T(0.5); - T cgh = c + Lanczos::g() - T(0.5); + T agh = static_cast(a + Lanczos::g() - 0.5f); + T bgh = static_cast(b + Lanczos::g() - 0.5f); + T cgh = static_cast(c + Lanczos::g() - 0.5f); result = Lanczos::lanczos_sum_expG_scaled(c) / (Lanczos::lanczos_sum_expG_scaled(a) * Lanczos::lanczos_sum_expG_scaled(b)); - if(a * b < bgh * 10) - result *= exp((b - 0.5f) * boost::math::log1p(a / bgh, pol)); - else - result *= pow(cgh / bgh, b - 0.5f); - result *= pow(x * cgh / agh, a); - result *= sqrt(agh / boost::math::constants::e()); - if(p_derivative) + T l1 = log(cgh / bgh) * (b - 0.5f); + T l2 = log(x * cgh / agh) * a; + // + // Check for over/underflow in the power terms: + // + if((l1 > tools::log_min_value()) + && (l1 < tools::log_max_value()) + && (l2 > tools::log_min_value()) + && (l2 < tools::log_max_value())) { - *p_derivative = result * pow(y, b); - BOOST_ASSERT(*p_derivative >= 0); + if(a * b < bgh * 10) + result *= exp((b - 0.5f) * boost::math::log1p(a / bgh, pol)); + else + result *= pow(cgh / bgh, b - 0.5f); + result *= pow(x * cgh / agh, a); + result *= sqrt(agh / boost::math::constants::e()); + + if(p_derivative) + { + *p_derivative = result * pow(y, b); + BOOST_ASSERT(*p_derivative >= 0); + } + } + else + { + // + // Oh dear, we need logs, and this *will* cancel: + // + result = log(result) + l1 + l2 + (log(agh) - 1) / 2; + if(p_derivative) + *p_derivative = exp(result + b * log(y)); + result = exp(result); } } else @@ -606,7 +685,7 @@ struct ibeta_fraction2_t T denom = (a + 2 * m - 1); aN /= denom * denom; - T bN = m; + T bN = static_cast(m); bN += (m * (b - m) * x) / (a + 2*m - 1); bN += ((a + m) * (a * y - b * x + 1 + m *(2 - x))) / (a + 2*m + 1); @@ -943,12 +1022,12 @@ T ibeta_imp(T a, T b, T x, const Policy& pol, bool inv, bool normalised, T* p_de if(b == 0) return policies::raise_domain_error(function, "The arguments a and b to the incomplete beta function cannot both be zero, with x=%1%.", x, pol); if(b > 0) - return inv ? 0 : 1; + return static_cast(inv ? 0 : 1); } else if(b == 0) { if(a > 0) - return inv ? 1 : 0; + return static_cast(inv ? 1 : 0); } } else @@ -1200,7 +1279,7 @@ T ibeta_imp(T a, T b, T x, const Policy& pol, bool inv, bool normalised, T* p_de if(b < 40) { - if((floor(a) == a) && (floor(b) == b) && (a < (std::numeric_limits::max)() - 100)) + if((floor(a) == a) && (floor(b) == b) && (a < (std::numeric_limits::max)() - 100) && (y != 1)) { // relate to the binomial distribution and use a finite sum: T k = a - 1; @@ -1342,20 +1421,8 @@ T ibeta_derivative_imp(T a, T b, T x, const Policy& pol) // Now the regular cases: // typedef typename lanczos::lanczos::type lanczos_type; - T f1 = ibeta_power_terms(a, b, x, 1 - x, lanczos_type(), true, pol); T y = (1 - x) * x; - - if(f1 == 0) - return 0; - - if((tools::max_value() * y < f1)) - { - // overflow: - return policies::raise_overflow_error(function, 0, pol); - } - - f1 /= y; - + T f1 = ibeta_power_terms(a, b, x, 1 - x, lanczos_type(), true, pol, 1 / y, function); return f1; } // diff --git a/boost/math/special_functions/detail/bernoulli_details.hpp b/boost/math/special_functions/detail/bernoulli_details.hpp index 525c1fccf4..c12a172b60 100644 --- a/boost/math/special_functions/detail/bernoulli_details.hpp +++ b/boost/math/special_functions/detail/bernoulli_details.hpp @@ -202,9 +202,13 @@ struct bernoulli_initializer // initialize our dymanic table: // boost::math::bernoulli_b2n(2, Policy()); +#ifndef BOOST_NO_EXCEPTIONS try{ +#endif boost::math::bernoulli_b2n(max_bernoulli_b2n::value + 1, Policy()); +#ifndef BOOST_NO_EXCEPTIONS } catch(const std::overflow_error&){} +#endif boost::math::tangent_t2n(2, Policy()); } void force_instantiate()const{} @@ -254,7 +258,9 @@ struct fixed_vector : private std::allocator void resize(unsigned n, const T& val) { if(n > m_capacity) - throw std::runtime_error("Exhausted storage for Bernoulli numbers."); + { + BOOST_THROW_EXCEPTION(std::runtime_error("Exhausted storage for Bernoulli numbers.")); + } for(unsigned i = m_used; i < n; ++i) new (m_data + i) T(val); m_used = n; @@ -432,11 +438,11 @@ public: // if(start + n >= bn.size()) { - std::size_t new_size = (std::min)((std::max)((std::max)(start + n, std::size_t(bn.size() + 20)), std::size_t(50)), std::size_t(bn.capacity())); + std::size_t new_size = (std::min)((std::max)((std::max)(std::size_t(start + n), std::size_t(bn.size() + 20)), std::size_t(50)), std::size_t(bn.capacity())); tangent_numbers_series(new_size); } - for(std::size_t i = (std::max)(max_bernoulli_b2n::value + 1, start); i < start + n; ++i) + for(std::size_t i = (std::max)(std::size_t(max_bernoulli_b2n::value + 1), start); i < start + n; ++i) { *out = (i >= m_overflow_limit) ? policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(i), pol) : bn[i]; ++out; @@ -448,11 +454,11 @@ public: boost::detail::lightweight_mutex::scoped_lock l(m_mutex); if(start + n >= bn.size()) { - std::size_t new_size = (std::min)((std::max)((std::max)(start + n, std::size_t(bn.size() + 20)), std::size_t(50)), std::size_t(bn.capacity())); + std::size_t new_size = (std::min)((std::max)((std::max)(std::size_t(start + n), std::size_t(bn.size() + 20)), std::size_t(50)), std::size_t(bn.capacity())); tangent_numbers_series(new_size); } - for(std::size_t i = (std::max)(max_bernoulli_b2n::value + 1, start); i < start + n; ++i) + for(std::size_t i = (std::max)(std::size_t(max_bernoulli_b2n::value + 1), start); i < start + n; ++i) { *out = (i >= m_overflow_limit) ? policies::raise_overflow_error("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(i), pol) : bn[i]; ++out; @@ -473,7 +479,7 @@ public: { if(start + n >= bn.size()) { - std::size_t new_size = (std::min)((std::max)((std::max)(start + n, std::size_t(bn.size() + 20)), std::size_t(50)), std::size_t(bn.capacity())); + std::size_t new_size = (std::min)((std::max)((std::max)(std::size_t(start + n), std::size_t(bn.size() + 20)), std::size_t(50)), std::size_t(bn.capacity())); tangent_numbers_series(new_size); } m_counter.store(static_cast(bn.size()), BOOST_MATH_ATOMIC_NS::memory_order_release); diff --git a/boost/math/special_functions/detail/bessel_derivatives_linear.hpp b/boost/math/special_functions/detail/bessel_derivatives_linear.hpp index 2ee86a03ee..72fddc61c6 100644 --- a/boost/math/special_functions/detail/bessel_derivatives_linear.hpp +++ b/boost/math/special_functions/detail/bessel_derivatives_linear.hpp @@ -37,13 +37,25 @@ inline T sph_bessel_j_derivative_linear(unsigned v, T x, Policy pol) template inline T bessel_i_derivative_linear(T v, T x, Policy pol) { - return (boost::math::detail::cyl_bessel_i_imp(v-1, x, pol) + boost::math::detail::cyl_bessel_i_imp(v+1, x, pol)) / 2; + T result = boost::math::detail::cyl_bessel_i_imp(v - 1, x, pol); + if(result >= tools::max_value()) + return result; // result is infinite + T result2 = boost::math::detail::cyl_bessel_i_imp(v + 1, x, pol); + if(result2 >= tools::max_value() - result) + return result2; // result is infinite + return (result + result2) / 2; } template inline T bessel_k_derivative_linear(T v, T x, Tag tag, Policy pol) { - return (boost::math::detail::cyl_bessel_k_imp(v-1, x, tag, pol) + boost::math::detail::cyl_bessel_k_imp(v+1, x, tag, pol)) / -2; + T result = boost::math::detail::cyl_bessel_k_imp(v - 1, x, tag, pol); + if(result >= tools::max_value()) + return -result; // result is infinite + T result2 = boost::math::detail::cyl_bessel_k_imp(v + 1, x, tag, pol); + if(result2 >= tools::max_value() - result) + return -result2; // result is infinite + return (result + result2) / -2; } template diff --git a/boost/math/special_functions/detail/bessel_ik.hpp b/boost/math/special_functions/detail/bessel_ik.hpp index 10118d9715..aac1781e10 100644 --- a/boost/math/special_functions/detail/bessel_ik.hpp +++ b/boost/math/special_functions/detail/bessel_ik.hpp @@ -374,6 +374,7 @@ int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol) prev = Ku; current = Ku1; T scale = 1; + T scale_sign = 1; for (k = 1; k <= n; k++) // forward recurrence for K { T fact = 2 * (u + k) / x; @@ -381,6 +382,7 @@ int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol) { prev /= current; scale /= current; + scale_sign *= boost::math::sign(current); current = 1; } next = fact * current + prev; @@ -426,7 +428,7 @@ int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol) if(fact == 0) *I = Iv; else if(tools::max_value() * scale < fact) - *I = (org_kind & need_i) ? T(sign(fact) * sign(scale) * policies::raise_overflow_error(function, 0, pol)) : T(0); + *I = (org_kind & need_i) ? T(sign(fact) * scale_sign * policies::raise_overflow_error(function, 0, pol)) : T(0); else *I = Iv + fact / scale; // reflection formula } @@ -435,7 +437,7 @@ int bessel_ik(T v, T x, T* I, T* K, int kind, const Policy& pol) *I = Iv; } if(tools::max_value() * scale < Kv) - *K = (org_kind & need_k) ? T(sign(Kv) * sign(scale) * policies::raise_overflow_error(function, 0, pol)) : T(0); + *K = (org_kind & need_k) ? T(sign(Kv) * scale_sign * policies::raise_overflow_error(function, 0, pol)) : T(0); else *K = Kv / scale; BOOST_MATH_INSTRUMENT_VARIABLE(*I); diff --git a/boost/math/special_functions/detail/bessel_jn.hpp b/boost/math/special_functions/detail/bessel_jn.hpp index 3f15f9cd87..2413630637 100644 --- a/boost/math/special_functions/detail/bessel_jn.hpp +++ b/boost/math/special_functions/detail/bessel_jn.hpp @@ -35,7 +35,7 @@ T bessel_jn(int n, T x, const Policy& pol) // if (n < 0) { - factor = (n & 0x1) ? -1 : 1; // J_{-n}(z) = (-1)^n J_n(z) + factor = static_cast((n & 0x1) ? -1 : 1); // J_{-n}(z) = (-1)^n J_n(z) n = -n; } else @@ -50,6 +50,8 @@ T bessel_jn(int n, T x, const Policy& pol) // // Special cases: // + if(asymptotic_bessel_large_x_limit(T(n), x)) + return factor * asymptotic_bessel_j_large_x_2(T(n), x); if (n == 0) { return factor * bessel_j0(x); @@ -64,9 +66,6 @@ T bessel_jn(int n, T x, const Policy& pol) return static_cast(0); } - if(asymptotic_bessel_large_x_limit(T(n), x)) - return factor * asymptotic_bessel_j_large_x_2(n, x); - BOOST_ASSERT(n > 1); T scale = 1; if (n < abs(x)) // forward recurrence diff --git a/boost/math/special_functions/detail/bessel_jy_asym.hpp b/boost/math/special_functions/detail/bessel_jy_asym.hpp index 81f6238e58..4d7ac485ad 100644 --- a/boost/math/special_functions/detail/bessel_jy_asym.hpp +++ b/boost/math/special_functions/detail/bessel_jy_asym.hpp @@ -119,6 +119,24 @@ inline T asymptotic_bessel_j_large_x_2(T v, T x) return sin_phase * ampl; } +template +inline bool asymptotic_bessel_large_x_limit(int v, const T& x) +{ + BOOST_MATH_STD_USING + // + // Determines if x is large enough compared to v to take the asymptotic + // forms above. From A&S 9.2.28 we require: + // v < x * eps^1/8 + // and from A&S 9.2.29 we require: + // v^12/10 < 1.5 * x * eps^1/10 + // using the former seems to work OK in practice with broadly similar + // error rates either side of the divide for v < 10000. + // At double precision eps^1/8 ~= 0.01. + // + BOOST_ASSERT(v >= 0); + return (v ? v : 1) < x * 0.004f; +} + template inline bool asymptotic_bessel_large_x_limit(const T& v, const T& x) { diff --git a/boost/math/special_functions/detail/bessel_jy_derivatives_series.hpp b/boost/math/special_functions/detail/bessel_jy_derivatives_series.hpp index 0dc68fc73c..5425caf689 100644 --- a/boost/math/special_functions/detail/bessel_jy_derivatives_series.hpp +++ b/boost/math/special_functions/detail/bessel_jy_derivatives_series.hpp @@ -157,7 +157,8 @@ inline T bessel_y_derivative_small_z_series(T v, T x, const Policy& pol) gam = 1; if (boost::math::tools::max_value() * p < gam) { - return -boost::math::policies::raise_overflow_error(function, 0, pol); + // This term will overflow to -INF, when combined with the series below it becomes +INF: + return boost::math::policies::raise_overflow_error(function, 0, pol); } } prefix = -gam / (boost::math::constants::pi() * p); @@ -173,7 +174,7 @@ inline T bessel_y_derivative_small_z_series(T v, T x, const Policy& pol) scale /= (boost::math::tools::max_value() / 4); if (boost::math::tools::log_max_value() < prefix) { - return -boost::math::policies::raise_overflow_error(function, 0, pol); + return boost::math::policies::raise_overflow_error(function, 0, pol); } } prefix = -exp(prefix); diff --git a/boost/math/special_functions/detail/bessel_yn.hpp b/boost/math/special_functions/detail/bessel_yn.hpp index 0509062bbd..62d7377e4f 100644 --- a/boost/math/special_functions/detail/bessel_yn.hpp +++ b/boost/math/special_functions/detail/bessel_yn.hpp @@ -45,14 +45,13 @@ T bessel_yn(int n, T x, const Policy& pol) // if (n < 0) { - factor = (n & 0x1) ? -1 : 1; // Y_{-n}(z) = (-1)^n Y_n(z) + factor = static_cast((n & 0x1) ? -1 : 1); // Y_{-n}(z) = (-1)^n Y_n(z) n = -n; } else { factor = 1; } - if(x < policies::get_epsilon()) { T scale = 1; @@ -61,6 +60,10 @@ T bessel_yn(int n, T x, const Policy& pol) return boost::math::sign(scale) * boost::math::sign(value) * policies::raise_overflow_error(function, 0, pol); value /= scale; } + else if(asymptotic_bessel_large_x_limit(n, x)) + { + value = factor * asymptotic_bessel_y_large_x_2(static_cast(abs(n)), x); + } else if (n == 0) { value = bessel_y0(x, pol); @@ -76,23 +79,28 @@ T bessel_yn(int n, T x, const Policy& pol) int k = 1; BOOST_ASSERT(k < n); policies::check_series_iterations("boost::math::bessel_y_n<%1%>(%1%,%1%)", n, pol); - do + T mult = 2 * k / x; + value = mult * current - prev; + prev = current; + current = value; + ++k; + if((mult > 1) && (fabs(current) > 1)) + { + prev /= current; + factor /= current; + value /= current; + current = 1; + } + while(k < n) { - T fact = 2 * k / x; - if((fact > 1) && ((tools::max_value() - fabs(prev)) / fact < fabs(current))) - { - prev /= current; - factor /= current; - current = 1; - } - value = fact * current - prev; + mult = 2 * k / x; + value = mult * current - prev; prev = current; current = value; ++k; } - while(k < n); if(fabs(tools::max_value() * factor) < fabs(value)) - return sign(value) * sign(value) * policies::raise_overflow_error(function, 0, pol); + return sign(value) * sign(factor) * policies::raise_overflow_error(function, 0, pol); value /= factor; } return value; diff --git a/boost/math/special_functions/detail/lanczos_sse2.hpp b/boost/math/special_functions/detail/lanczos_sse2.hpp index edef3a0412..b2dd7ea292 100644 --- a/boost/math/special_functions/detail/lanczos_sse2.hpp +++ b/boost/math/special_functions/detail/lanczos_sse2.hpp @@ -12,7 +12,7 @@ #include -#if defined(__GNUC__) || defined(__PGI) +#if defined(__GNUC__) || defined(__PGI) || defined(__SUNPRO_CC) #define ALIGN16 __attribute__((__aligned__(16))) #else #define ALIGN16 __declspec(align(16)) diff --git a/boost/math/special_functions/detail/polygamma.hpp b/boost/math/special_functions/detail/polygamma.hpp index 4ef503bf7c..0267bd3ac8 100644 --- a/boost/math/special_functions/detail/polygamma.hpp +++ b/boost/math/special_functions/detail/polygamma.hpp @@ -44,7 +44,7 @@ // x is crazy large, just concentrate on the first part of the expression and use logs: if(n == 1) return 1 / x; T nlx = n * log(x); - if((nlx < tools::log_max_value()) && (n < max_factorial::value)) + if((nlx < tools::log_max_value()) && (n < (int)max_factorial::value)) return ((n & 1) ? 1 : -1) * boost::math::factorial(n - 1) * pow(x, -n); else return ((n & 1) ? 1 : -1) * exp(boost::math::lgamma(T(n), pol) - n * log(x)); @@ -71,13 +71,13 @@ // or the power term underflows, this just gets set to 0 and then we // know that we have to use logs for the initial terms: // - part_term = ((n > boost::math::max_factorial::value) && (T(n) * n > tools::log_max_value())) + part_term = ((n > (int)boost::math::max_factorial::value) && (T(n) * n > tools::log_max_value())) ? T(0) : static_cast(boost::math::factorial(n - 1, pol) * pow(x, -n - 1)); if(part_term == 0) { // Either n is very large, or the power term underflows, // set the initial values of part_term, term and sum via logs: - part_term = boost::math::lgamma(n, pol) - (n + 1) * log(x); + part_term = static_cast(boost::math::lgamma(n, pol) - (n + 1) * log(x)); sum = exp(part_term + log(n + 2 * x) - boost::math::constants::ln_two()); part_term += log(T(n) * (n + 1)) - boost::math::constants::ln_two() - log(x); part_term = exp(part_term); @@ -505,7 +505,7 @@ // would mean setting the limit to ~ 1 / n, // but we can tolerate a small amount of divergence: // - T small_x_limit = std::min(T(T(5) / n), T(0.25f)); + T small_x_limit = (std::min)(T(T(5) / n), T(0.25f)); if(x < small_x_limit) { return polygamma_nearzero(n, x, pol, function); diff --git a/boost/math/special_functions/detail/t_distribution_inv.hpp b/boost/math/special_functions/detail/t_distribution_inv.hpp index 72f6f0c646..e8bd0db28f 100644 --- a/boost/math/special_functions/detail/t_distribution_inv.hpp +++ b/boost/math/special_functions/detail/t_distribution_inv.hpp @@ -56,9 +56,9 @@ T inverse_students_t_hill(T ndf, T u, const Policy& pol) } else { - y = ((1 / (((ndf + 6) / (ndf * y) - 0.089f * d - 0.822f) + y = static_cast(((1 / (((ndf + 6) / (ndf * y) - 0.089f * d - 0.822f) * (ndf + 2) * 3) + 0.5 / (ndf + 4)) * y - 1) - * (ndf + 1) / (ndf + 2) + 1 / y; + * (ndf + 1) / (ndf + 2) + 1 / y); } q = sqrt(ndf * y); @@ -144,41 +144,41 @@ T inverse_students_t_body_series(T df, T u, const Policy& pol) // only on the degrees of freedom (Eq 57 of Shaw): // T in = 1 / df; - c[2] = 0.16666666666666666667 + 0.16666666666666666667 * in; - c[3] = (0.0083333333333333333333 * in + c[2] = static_cast(0.16666666666666666667 + 0.16666666666666666667 * in); + c[3] = static_cast((0.0083333333333333333333 * in + 0.066666666666666666667) * in - + 0.058333333333333333333; - c[4] = ((0.00019841269841269841270 * in + + 0.058333333333333333333); + c[4] = static_cast(((0.00019841269841269841270 * in + 0.0017857142857142857143) * in + 0.026785714285714285714) * in - + 0.025198412698412698413; - c[5] = (((2.7557319223985890653e-6 * in + + 0.025198412698412698413); + c[5] = static_cast((((2.7557319223985890653e-6 * in + 0.00037477954144620811287) * in - 0.0011078042328042328042) * in + 0.010559964726631393298) * in - + 0.012039792768959435626; - c[6] = ((((2.5052108385441718775e-8 * in + + 0.012039792768959435626); + c[6] = static_cast(((((2.5052108385441718775e-8 * in - 0.000062705427288760622094) * in + 0.00059458674042007375341) * in - 0.0016095979637646304313) * in + 0.0061039211560044893378) * in - + 0.0038370059724226390893; - c[7] = (((((1.6059043836821614599e-10 * in + + 0.0038370059724226390893); + c[7] = static_cast((((((1.6059043836821614599e-10 * in + 0.000015401265401265401265) * in - 0.00016376804137220803887) * in + 0.00069084207973096861986) * in - 0.0012579159844784844785) * in + 0.0010898206731540064873) * in - + 0.0032177478835464946576; - c[8] = ((((((7.6471637318198164759e-13 * in + + 0.0032177478835464946576); + c[8] = static_cast(((((((7.6471637318198164759e-13 * in - 3.9851014346715404916e-6) * in + 0.000049255746366361445727) * in - 0.00024947258047043099953) * in + 0.00064513046951456342991) * in - 0.00076245135440323932387) * in + 0.000033530976880017885309) * in - + 0.0017438262298340009980; - c[9] = (((((((2.8114572543455207632e-15 * in + + 0.0017438262298340009980); + c[9] = static_cast((((((((2.8114572543455207632e-15 * in + 1.0914179173496789432e-6) * in - 0.000015303004486655377567) * in + 0.000090867107935219902229) * in @@ -186,8 +186,8 @@ T inverse_students_t_body_series(T df, T u, const Policy& pol) + 0.00051406605788341121363) * in - 0.00036307660358786885787) * in - 0.00031101086326318780412) * in - + 0.00096472747321388644237; - c[10] = ((((((((8.2206352466243297170e-18 * in + + 0.00096472747321388644237); + c[10] = static_cast(((((((((8.2206352466243297170e-18 * in - 3.1239569599829868045e-7) * in + 4.8903045291975346210e-6) * in - 0.000033202652391372058698) * in @@ -196,7 +196,7 @@ T inverse_students_t_body_series(T df, T u, const Policy& pol) + 0.00035764655430568632777) * in - 0.00010230378073700412687) * in - 0.00036942667800009661203) * in - + 0.00054229262813129686486; + + 0.00054229262813129686486); // // The result is then a polynomial in v (see Eq 56 of Shaw): // @@ -285,7 +285,7 @@ T inverse_students_t(T df, T u, T v, const Policy& pol, bool* pexact = 0) // T a = 4 * (u - u * u);//1 - 4 * (u - 0.5f) * (u - 0.5f); T b = boost::math::cbrt(a); - static const T c = 0.85498797333834849467655443627193; + static const T c = static_cast(0.85498797333834849467655443627193L); T p = 6 * (1 + c * (1 / b - 1)); T p0; do{ diff --git a/boost/math/special_functions/ellint_2.hpp b/boost/math/special_functions/ellint_2.hpp index f4f65cc11d..0d160ecdf1 100644 --- a/boost/math/special_functions/ellint_2.hpp +++ b/boost/math/special_functions/ellint_2.hpp @@ -103,17 +103,10 @@ T ellint_e_imp(T phi, T k, const Policy& pol) { return policies::raise_domain_error("boost::math::ellint_2<%1%>(%1%, %1%)", "The parameter k is out of range, got k = %1%", k, pol); } - else if(rphi == 0) + else if(rphi < tools::root_epsilon()) { - result = 0; - } - else if(sinp * sinp < tools::min_value()) - { - T x = cosp * cosp; - T t = k * k * sinp * sinp; - T y = 1 - t; - T z = 1; - result = s * sinp * (ellint_rf_imp(x, y, z, pol) - t * ellint_rd_imp(x, y, z, pol) / 3); + // See http://functions.wolfram.com/EllipticIntegrals/EllipticE2/06/01/03/0001/ + result = s * rphi; } else { diff --git a/boost/math/special_functions/ellint_d.hpp b/boost/math/special_functions/ellint_d.hpp index 5bd065d6e3..bc5a4b2a56 100644 --- a/boost/math/special_functions/ellint_d.hpp +++ b/boost/math/special_functions/ellint_d.hpp @@ -60,7 +60,7 @@ T ellint_d_imp(T phi, T k, const Policy& pol) if(phi >= tools::max_value()) { // Need to handle infinity as a special case: - result = policies::raise_overflow_error("boost::math::ellint_e<%1%>(%1%,%1%)", 0, pol); + result = policies::raise_overflow_error("boost::math::ellint_d<%1%>(%1%,%1%)", 0, pol); } else if(phi > 1 / tools::epsilon()) { @@ -113,15 +113,11 @@ T ellint_d_imp(T k, const Policy& pol) BOOST_MATH_STD_USING using namespace boost::math::tools; - if (abs(k) > 1) + if (abs(k) >= 1) { - return policies::raise_domain_error("boost::math::ellint_e<%1%>(%1%)", + return policies::raise_domain_error("boost::math::ellint_d<%1%>(%1%)", "Got k = %1%, function requires |k| <= 1", k, pol); } - if (abs(k) == 1) - { - return static_cast(1); - } if(fabs(k) <= tools::root_epsilon()) return constants::pi() / 4; diff --git a/boost/math/special_functions/fpclassify.hpp b/boost/math/special_functions/fpclassify.hpp index 8e75fae0f2..0a4e1ac7aa 100644 --- a/boost/math/special_functions/fpclassify.hpp +++ b/boost/math/special_functions/fpclassify.hpp @@ -80,6 +80,9 @@ is used. #if defined(_MSC_VER) || defined(__BORLANDC__) #include #endif +#ifdef BOOST_MATH_USE_FLOAT128 +#include "quadmath.h" +#endif #ifdef BOOST_NO_STDC_NAMESPACE namespace std{ using ::abs; using ::fabs; } @@ -121,7 +124,10 @@ inline bool is_nan_helper(T, const boost::false_type&) { return false; } - +#ifdef BOOST_MATH_USE_FLOAT128 +inline bool is_nan_helper(__float128 f, const boost::true_type&) { return ::isnanq(f); } +inline bool is_nan_helper(__float128 f, const boost::false_type&) { return ::isnanq(f); } +#endif } namespace math{ @@ -513,6 +519,13 @@ inline bool (isinf)(long double x) return detail::isinf_impl(static_cast(x), method()); } #endif +#ifdef BOOST_MATH_USE_FLOAT128 +template<> +inline bool (isinf)(__float128 x) +{ + return ::isinfq(x); +} +#endif //------------------------------------------------------------------------------ @@ -598,6 +611,13 @@ inline bool (isnan)(long double x) return detail::isnan_impl(x, method()); } #endif +#ifdef BOOST_MATH_USE_FLOAT128 +template<> +inline bool (isnan)(__float128 x) +{ + return ::isnanq(x); +} +#endif } // namespace math } // namespace boost diff --git a/boost/math/special_functions/gamma.hpp b/boost/math/special_functions/gamma.hpp index 1db1e4c2d3..3a3191a807 100644 --- a/boost/math/special_functions/gamma.hpp +++ b/boost/math/special_functions/gamma.hpp @@ -162,7 +162,7 @@ T gamma_imp(T z, const Policy& pol, const Lanczos& l) { if (z < 1 / tools::max_value()) result = policies::raise_overflow_error(function, 0, pol); - result *= 1 / z - constants::euler(); + result *= 1 / z - constants::euler(); } else { @@ -238,13 +238,13 @@ T lgamma_imp(T z, const Policy& pol, const Lanczos& l, int* sign = 0) } else if (z < tools::root_epsilon()) { - if (0 == z) - return policies::raise_pole_error(function, "Evaluation of lgamma at %1%.", z, pol); + if (0 == z) + return policies::raise_pole_error(function, "Evaluation of lgamma at %1%.", z, pol); if (fabs(z) < 1 / tools::max_value()) result = -log(fabs(z)); else - result = log(fabs(1 / z - constants::euler())); - if (z < 0) + result = log(fabs(1 / z - constants::euler())); + if (z < 0) sresult = -1; } else if(z < 15) @@ -526,9 +526,9 @@ T lgamma_imp(T z, const Policy& pol, const lanczos::undefined_lanczos&, int* sig if (zz < min_arg_for_recursion) { - // Here we simply take the logarithm of tgamma(). This is somewhat - // inefficient, but simple. The rationale is that the argument here - // is relatively small and overflow is not expected to be likely. + // Here we simply take the logarithm of tgamma(). This is somewhat + // inefficient, but simple. The rationale is that the argument here + // is relatively small and overflow is not expected to be likely. if (z > -tools::root_epsilon()) { // Reflection formula may fail if z is very close to zero, let the series @@ -540,7 +540,7 @@ T lgamma_imp(T z, const Policy& pol, const lanczos::undefined_lanczos&, int* sig } return log_gamma_value; } - else + else { // No issue with spurious overflow in reflection formula, // just fall through to regular code: @@ -1394,7 +1394,7 @@ T tgamma_delta_ratio_imp_lanczos(T z, T delta, const Policy& pol, const Lanczos& return 1 / (z * boost::math::tgamma(z + delta, pol)); } } - T zgh = z + Lanczos::g() - constants::half(); + T zgh = static_cast(z + Lanczos::g() - constants::half()); T result; if(fabs(delta) < 10) { diff --git a/boost/math/special_functions/math_fwd.hpp b/boost/math/special_functions/math_fwd.hpp index 96f60726a6..ca8e58144e 100644 --- a/boost/math/special_functions/math_fwd.hpp +++ b/boost/math/special_functions/math_fwd.hpp @@ -181,19 +181,19 @@ namespace boost template typename tools::promote_args::type legendre_p(int l, T x); - +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1310) template typename boost::enable_if_c::value, typename tools::promote_args::type>::type legendre_p(int l, T x, const Policy& pol); - +#endif template typename tools::promote_args::type legendre_q(unsigned l, T x); - +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1310) template typename boost::enable_if_c::value, typename tools::promote_args::type>::type legendre_q(unsigned l, T x, const Policy& pol); - +#endif template typename tools::promote_args::type legendre_next(unsigned l, unsigned m, T1 x, T2 Pl, T3 Plm1); @@ -607,8 +607,10 @@ namespace boost template struct bessel_traits { - typedef typename tools::promote_args< - T1, T2 + typedef typename mpl::if_< + is_integral, + typename tools::promote_args::type, + typename tools::promote_args::type >::type result_type; typedef typename policies::precision::type precision_type; @@ -994,6 +996,16 @@ namespace boost template typename tools::promote_args::type float_advance(const T& val, int distance); + template + typename tools::promote_args::type ulp(const T& val, const Policy& pol); + template + typename tools::promote_args::type ulp(const T& val); + + template + typename tools::promote_args::type relative_difference(const T&, const U&); + template + typename tools::promote_args::type epsilon_difference(const T&, const U&); + template T unchecked_bernoulli_b2n(const std::size_t n); template @@ -1447,6 +1459,7 @@ template \ template T float_next(const T& a){ return boost::math::float_next(a, Policy()); }\ template T float_prior(const T& a){ return boost::math::float_prior(a, Policy()); }\ template T float_distance(const T& a, const T& b){ return boost::math::float_distance(a, b, Policy()); }\ + template T ulp(const T& a){ return boost::math::ulp(a, Policy()); }\ \ template \ inline typename boost::math::tools::promote_args::type owens_t(RT1 a, RT2 z){ return boost::math::owens_t(a, z, Policy()); }\ diff --git a/boost/math/special_functions/nonfinite_num_facets.hpp b/boost/math/special_functions/nonfinite_num_facets.hpp index 84d3f1070a..cd1eba9320 100644 --- a/boost/math/special_functions/nonfinite_num_facets.hpp +++ b/boost/math/special_functions/nonfinite_num_facets.hpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -103,7 +104,7 @@ namespace boost { case FP_INFINITE: if(flags_ & trap_infinity) { - throw std::ios_base::failure("Infinity"); + BOOST_THROW_EXCEPTION(std::ios_base::failure("Infinity")); } else if((boost::math::signbit)(val)) { // negative infinity. @@ -122,7 +123,7 @@ namespace boost { case FP_NAN: if(flags_ & trap_nan) { - throw std::ios_base::failure("NaN"); + BOOST_THROW_EXCEPTION(std::ios_base::failure("NaN")); } else if((boost::math::signbit)(val)) { // negative so "-nan". diff --git a/boost/math/special_functions/owens_t.hpp b/boost/math/special_functions/owens_t.hpp index 6de93a4887..7fbd8918c0 100644 --- a/boost/math/special_functions/owens_t.hpp +++ b/boost/math/special_functions/owens_t.hpp @@ -61,9 +61,9 @@ namespace boost inline unsigned short owens_t_compute_code(const RealType h, const RealType a) { static const RealType hrange[] = - {0.02, 0.06, 0.09, 0.125, 0.26, 0.4, 0.6, 1.6, 1.7, 2.33, 2.4, 3.36, 3.4, 4.8}; + { 0.02f, 0.06f, 0.09f, 0.125f, 0.26f, 0.4f, 0.6f, 1.6f, 1.7f, 2.33f, 2.4f, 3.36f, 3.4f, 4.8f }; - static const RealType arange[] = {0.025, 0.09, 0.15, 0.36, 0.5, 0.9, 0.99999}; + static const RealType arange[] = { 0.025f, 0.09f, 0.15f, 0.36f, 0.5f, 0.9f, 0.99999f }; /* original select array from paper: 1, 1, 2,13,13,13,13,13,13,13,13,16,16,16, 9 @@ -229,17 +229,17 @@ namespace boost static const RealType c2[] = { - 0.99999999999999987510, - -0.99999999999988796462, 0.99999999998290743652, - -0.99999999896282500134, 0.99999996660459362918, - -0.99999933986272476760, 0.99999125611136965852, - -0.99991777624463387686, 0.99942835555870132569, - -0.99697311720723000295, 0.98751448037275303682, - -0.95915857980572882813, 0.89246305511006708555, - -0.76893425990463999675, 0.58893528468484693250, - -0.38380345160440256652, 0.20317601701045299653, - -0.82813631607004984866E-01, 0.24167984735759576523E-01, - -0.44676566663971825242E-02, 0.39141169402373836468E-03 + static_cast(0.99999999999999987510), + static_cast(-0.99999999999988796462), static_cast(0.99999999998290743652), + static_cast(-0.99999999896282500134), static_cast(0.99999996660459362918), + static_cast(-0.99999933986272476760), static_cast(0.99999125611136965852), + static_cast(-0.99991777624463387686), static_cast(0.99942835555870132569), + static_cast(-0.99697311720723000295), static_cast(0.98751448037275303682), + static_cast(-0.95915857980572882813), static_cast(0.89246305511006708555), + static_cast(-0.76893425990463999675), static_cast(0.58893528468484693250), + static_cast(-0.38380345160440256652), static_cast(0.20317601701045299653), + static_cast(-0.82813631607004984866E-01), static_cast(0.24167984735759576523E-01), + static_cast(-0.44676566663971825242E-02), static_cast(0.39141169402373836468E-03) }; const RealType as = a*a; @@ -402,20 +402,22 @@ namespace boost */ const unsigned short m = 13; - static const RealType pts[] = {0.35082039676451715489E-02, - 0.31279042338030753740E-01, 0.85266826283219451090E-01, - 0.16245071730812277011, 0.25851196049125434828, - 0.36807553840697533536, 0.48501092905604697475, - 0.60277514152618576821, 0.71477884217753226516, - 0.81475510988760098605, 0.89711029755948965867, - 0.95723808085944261843, 0.99178832974629703586}; - static const RealType wts[] = { 0.18831438115323502887E-01, - 0.18567086243977649478E-01, 0.18042093461223385584E-01, - 0.17263829606398753364E-01, 0.16243219975989856730E-01, - 0.14994592034116704829E-01, 0.13535474469662088392E-01, - 0.11886351605820165233E-01, 0.10070377242777431897E-01, - 0.81130545742299586629E-02, 0.60419009528470238773E-02, - 0.38862217010742057883E-02, 0.16793031084546090448E-02}; + static const RealType pts[] = { + static_cast(0.35082039676451715489E-02), + static_cast(0.31279042338030753740E-01), static_cast(0.85266826283219451090E-01), + static_cast(0.16245071730812277011), static_cast(0.25851196049125434828), + static_cast(0.36807553840697533536), static_cast(0.48501092905604697475), + static_cast(0.60277514152618576821), static_cast(0.71477884217753226516), + static_cast(0.81475510988760098605), static_cast(0.89711029755948965867), + static_cast(0.95723808085944261843), static_cast(0.99178832974629703586) }; + static const RealType wts[] = { + static_cast(0.18831438115323502887E-01), + static_cast(0.18567086243977649478E-01), static_cast(0.18042093461223385584E-01), + static_cast(0.17263829606398753364E-01), static_cast(0.16243219975989856730E-01), + static_cast(0.14994592034116704829E-01), static_cast(0.13535474469662088392E-01), + static_cast(0.11886351605820165233E-01), static_cast(0.10070377242777431897E-01), + static_cast(0.81130545742299586629E-02), static_cast(0.60419009528470238773E-02), + static_cast(0.38862217010742057883E-02), static_cast(0.16793031084546090448E-02) }; const RealType as = a*a; const RealType hs = -h*h*boost::math::constants::half(); @@ -575,14 +577,18 @@ namespace boost // when the last accelerated term was small enough... // int n; +#ifndef BOOST_NO_EXCEPTIONS try { +#endif n = itrunc(T(tools::log_max_value() / 6)); +#ifndef BOOST_NO_EXCEPTIONS } catch(...) { n = (std::numeric_limits::max)(); } +#endif n = (std::min)(n, 1500); T d = pow(3 + sqrt(T(8)), n); d = (d + 1 / d) / 2; @@ -689,14 +695,18 @@ namespace boost // when the last accelerated term was small enough... // int n; +#ifndef BOOST_NO_EXCEPTIONS try { +#endif n = itrunc(RealType(tools::log_max_value() / 6)); +#ifndef BOOST_NO_EXCEPTIONS } catch(...) { n = (std::numeric_limits::max)(); } +#endif n = (std::min)(n, 1500); RealType d = pow(3 + sqrt(RealType(8)), n); d = (d + 1 / d) / 2; @@ -858,25 +868,33 @@ namespace boost bool have_t1(false), have_t2(false); if(ah < 3) { +#ifndef BOOST_NO_EXCEPTIONS try { +#endif have_t1 = true; p1 = owens_t_T1_accelerated(h, a, forwarding_policy()); if(p1.second < target_precision) return p1.first; +#ifndef BOOST_NO_EXCEPTIONS } catch(const boost::math::evaluation_error&){} // T1 may fail and throw, that's OK +#endif } if(ah > 1) { +#ifndef BOOST_NO_EXCEPTIONS try { +#endif have_t2 = true; p2 = owens_t_T2_accelerated(h, a, ah, forwarding_policy()); if(p2.second < target_precision) return p2.first; +#ifndef BOOST_NO_EXCEPTIONS } catch(const boost::math::evaluation_error&){} // T2 may fail and throw, that's OK +#endif } // // If we haven't tried T1 yet, do it now - sometimes it succeeds and the number of iterations @@ -884,14 +902,18 @@ namespace boost // if(!have_t1) { +#ifndef BOOST_NO_EXCEPTIONS try { +#endif have_t1 = true; p1 = owens_t_T1_accelerated(h, a, forwarding_policy()); if(p1.second < target_precision) return p1.first; +#ifndef BOOST_NO_EXCEPTIONS } catch(const boost::math::evaluation_error&){} // T1 may fail and throw, that's OK +#endif } // // If we haven't tried T2 yet, do it now - sometimes it succeeds and the number of iterations @@ -899,24 +921,32 @@ namespace boost // if(!have_t2) { +#ifndef BOOST_NO_EXCEPTIONS try { +#endif have_t2 = true; p2 = owens_t_T2_accelerated(h, a, ah, forwarding_policy()); if(p2.second < target_precision) return p2.first; +#ifndef BOOST_NO_EXCEPTIONS } catch(const boost::math::evaluation_error&){} // T2 may fail and throw, that's OK +#endif } // // OK, nothing left to do but try the most expensive option which is T4, // this is often slow to converge, but when it does converge it tends to // be accurate: +#ifndef BOOST_NO_EXCEPTIONS try { +#endif return T4_mp(h, a, pol); +#ifndef BOOST_NO_EXCEPTIONS } catch(const boost::math::evaluation_error&){} // T4 may fail and throw, that's OK +#endif // // Now look back at the results from T1 and T2 and see if either gave better // results than we could get from the 64-bit precision versions. diff --git a/boost/math/special_functions/powm1.hpp b/boost/math/special_functions/powm1.hpp index f3af3d6e59..fe2fce35d8 100644 --- a/boost/math/special_functions/powm1.hpp +++ b/boost/math/special_functions/powm1.hpp @@ -13,23 +13,40 @@ #include #include #include +#include #include namespace boost{ namespace math{ namespace detail{ template -inline T powm1_imp(const T a, const T z, const Policy& pol) +inline T powm1_imp(const T x, const T y, const Policy& pol) { BOOST_MATH_STD_USING + static const char* function = "boost::math::powm1<%1%>(%1%, %1%)"; - if((fabs(a) < 1) || (fabs(z) < 1)) + if (x > 0) { - T p = log(a) * z; - if(fabs(p) < 2) - return boost::math::expm1(p, pol); - // otherwise fall though: + if ((fabs(y * (x - 1)) < 0.5) || (fabs(y) < 0.2)) + { + // We don't have any good/quick approximation for log(x) * y + // so just try it and see: + T l = y * log(x); + if (l < 0.5) + return boost::math::expm1(l); + if (l > boost::math::tools::log_max_value()) + return boost::math::policies::raise_overflow_error(function, 0, pol); + // fall through.... + } } - return pow(a, z) - 1; + else + { + // y had better be an integer: + if (boost::math::trunc(y) != y) + return boost::math::policies::raise_domain_error(function, "For non-integral exponent, expected base > 0 but got %1%", x, pol); + if (boost::math::trunc(y / 2) == y / 2) + return powm1_imp(T(-x), y, pol); + } + return pow(x, y) - 1; } } // detail diff --git a/boost/math/special_functions/relative_difference.hpp b/boost/math/special_functions/relative_difference.hpp new file mode 100644 index 0000000000..544feda61b --- /dev/null +++ b/boost/math/special_functions/relative_difference.hpp @@ -0,0 +1,134 @@ +// (C) Copyright John Maddock 2006, 2015 +// 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_MATH_RELATIVE_ERROR +#define BOOST_MATH_RELATIVE_ERROR + +#include +#include +#include + +namespace boost{ + namespace math{ + + template + typename boost::math::tools::promote_args::type relative_difference(const T& arg_a, const U& arg_b) + { + typedef typename boost::math::tools::promote_args::type result_type; + result_type a = arg_a; + result_type b = arg_b; + BOOST_MATH_STD_USING +#ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS + // + // If math.h has no long double support we can't rely + // on the math functions generating exponents outside + // the range of a double: + // + result_type min_val = (std::max)( + tools::min_value(), + static_cast((std::numeric_limits::min)())); + result_type max_val = (std::min)( + tools::max_value(), + static_cast((std::numeric_limits::max)())); +#else + result_type min_val = tools::min_value(); + result_type max_val = tools::max_value(); +#endif + // Screen out NaN's first, if either value is a NaN then the distance is "infinite": + if((boost::math::isnan)(a) || (boost::math::isnan)(b)) + return max_val; + // Screen out infinites: + if(fabs(b) > max_val) + { + if(fabs(a) > max_val) + return (a < 0) == (b < 0) ? 0 : max_val; // one infinity is as good as another! + else + return max_val; // one infinity and one finite value implies infinite difference + } + else if(fabs(a) > max_val) + return max_val; // one infinity and one finite value implies infinite difference + + // + // If the values have different signs, treat as infinite difference: + // + if(((a < 0) != (b < 0)) && (a != 0) && (b != 0)) + return max_val; + a = fabs(a); + b = fabs(b); + // + // Now deal with zero's, if one value is zero (or denorm) then treat it the same as + // min_val for the purposes of the calculation that follows: + // + if(a < min_val) + a = min_val; + if(b < min_val) + b = min_val; + + return (std::max)(fabs((a - b) / a), fabs((a - b) / b)); + } + +#if defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) + template <> + inline boost::math::tools::promote_args::type relative_difference(const double& arg_a, const double& arg_b) + { + BOOST_MATH_STD_USING + double a = arg_a; + double b = arg_b; + // + // On Mac OS X we evaluate "double" functions at "long double" precision, + // but "long double" actually has a very slightly narrower range than "double"! + // Therefore use the range of "long double" as our limits since results outside + // that range may have been truncated to 0 or INF: + // + double min_val = (std::max)((double)tools::min_value(), tools::min_value()); + double max_val = (std::min)((double)tools::max_value(), tools::max_value()); + + // Screen out NaN's first, if either value is a NaN then the distance is "infinite": + if((boost::math::isnan)(a) || (boost::math::isnan)(b)) + return max_val; + // Screen out infinites: + if(fabs(b) > max_val) + { + if(fabs(a) > max_val) + return 0; // one infinity is as good as another! + else + return max_val; // one infinity and one finite value implies infinite difference + } + else if(fabs(a) > max_val) + return max_val; // one infinity and one finite value implies infinite difference + + // + // If the values have different signs, treat as infinite difference: + // + if(((a < 0) != (b < 0)) && (a != 0) && (b != 0)) + return max_val; + a = fabs(a); + b = fabs(b); + // + // Now deal with zero's, if one value is zero (or denorm) then treat it the same as + // min_val for the purposes of the calculation that follows: + // + if(a < min_val) + a = min_val; + if(b < min_val) + b = min_val; + + return (std::max)(fabs((a - b) / a), fabs((a - b) / b)); + } +#endif + + template + inline typename boost::math::tools::promote_args::type epsilon_difference(const T& arg_a, const U& arg_b) + { + typedef typename boost::math::tools::promote_args::type result_type; + result_type r = relative_difference(arg_a, arg_b); + if(tools::max_value() * boost::math::tools::epsilon() < r) + return tools::max_value(); + return r / boost::math::tools::epsilon(); + } +} // namespace math +} // namespace boost + +#endif diff --git a/boost/math/special_functions/trigamma.hpp b/boost/math/special_functions/trigamma.hpp index 6fccb36a3a..17c9174c78 100644 --- a/boost/math/special_functions/trigamma.hpp +++ b/boost/math/special_functions/trigamma.hpp @@ -69,22 +69,22 @@ T trigamma_prec(T x, const mpl::int_<53>*, const Policy&) // Expected Error Term : -6.895e-018 // Maximum Relative Change in Control Points : 8.497e-004 static const T P_4_inf[] = { - 0.68947581948701249e-17L, - 0.49999999999998975L, - 1.0177274392923795L, - 2.498208511343429L, - 2.1921221359427595L, - 1.5897035272532764L, - 0.40154388356961734L, + static_cast(0.68947581948701249e-17L), + static_cast(0.49999999999998975L), + static_cast(1.0177274392923795L), + static_cast(2.498208511343429L), + static_cast(2.1921221359427595L), + static_cast(1.5897035272532764L), + static_cast(0.40154388356961734L), }; static const T Q_4_inf[] = { - 1.0L, - 1.7021215452463932L, - 4.4290431747556469L, - 2.9745631894384922L, - 2.3013614809773616L, - 0.28360399799075752L, - 0.022892987908906897L, + static_cast(1.0L), + static_cast(1.7021215452463932L), + static_cast(4.4290431747556469L), + static_cast(2.9745631894384922L), + static_cast(2.3013614809773616L), + static_cast(0.28360399799075752L), + static_cast(0.022892987908906897L), }; if(x <= 2) diff --git a/boost/math/special_functions/ulp.hpp b/boost/math/special_functions/ulp.hpp new file mode 100644 index 0000000000..3d78a1c7c2 --- /dev/null +++ b/boost/math/special_functions/ulp.hpp @@ -0,0 +1,71 @@ +// (C) Copyright John Maddock 2015. +// 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_MATH_SPECIAL_ULP_HPP +#define BOOST_MATH_SPECIAL_ULP_HPP + +#ifdef _MSC_VER +#pragma once +#endif + +#include +#include +#include +#include + +namespace boost{ namespace math{ namespace detail{ + +template +T ulp_imp(const T& val, const Policy& pol) +{ + BOOST_MATH_STD_USING + int expon; + static const char* function = "ulp<%1%>(%1%)"; + + int fpclass = (boost::math::fpclassify)(val); + + if(fpclass == (int)FP_NAN) + { + return policies::raise_domain_error( + function, + "Argument must be finite, but got %1%", val, pol); + } + else if((fpclass == (int)FP_INFINITE) || (fabs(val) >= tools::max_value())) + { + return (val < 0 ? -1 : 1) * policies::raise_overflow_error(function, 0, pol); + } + else if(fpclass == FP_ZERO) + return detail::get_smallest_value(); + // + // This code is almost the same as that for float_next, except for negative integers, + // where we preserve the relation ulp(x) == ulp(-x) as does Java: + // + frexp(fabs(val), &expon); + T diff = ldexp(T(1), expon - tools::digits()); + if(diff == 0) + diff = detail::get_smallest_value(); + return diff; +} + +} + +template +inline typename tools::promote_args::type ulp(const T& val, const Policy& pol) +{ + typedef typename tools::promote_args::type result_type; + return detail::ulp_imp(static_cast(val), pol); +} + +template +inline typename tools::promote_args::type ulp(const T& val) +{ + return ulp(val, policies::policy<>()); +} + + +}} // namespaces + +#endif // BOOST_MATH_SPECIAL_ULP_HPP + diff --git a/boost/math/special_functions/zeta.hpp b/boost/math/special_functions/zeta.hpp index 1ba282f4d1..616bb0cccc 100644 --- a/boost/math/special_functions/zeta.hpp +++ b/boost/math/special_functions/zeta.hpp @@ -200,20 +200,20 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&) // Expected Error Term: -2.020e-18 // Max error found at double precision: 3.994987e-17 static const T P[6] = { - 0.24339294433593750202L, - -0.49092470516353571651L, - 0.0557616214776046784287L, - -0.00320912498879085894856L, - 0.000451534528645796438704L, - -0.933241270357061460782e-5L, + static_cast(0.24339294433593750202L), + static_cast(-0.49092470516353571651L), + static_cast(0.0557616214776046784287L), + static_cast(-0.00320912498879085894856L), + static_cast(0.000451534528645796438704L), + static_cast(-0.933241270357061460782e-5L), }; static const T Q[6] = { - 1L, - -0.279960334310344432495L, - 0.0419676223309986037706L, - -0.00413421406552171059003L, - 0.00024978985622317935355L, - -0.101855788418564031874e-4L, + static_cast(1L), + static_cast(-0.279960334310344432495L), + static_cast(0.0419676223309986037706L), + static_cast(-0.00413421406552171059003L), + static_cast(0.00024978985622317935355L), + static_cast(-0.101855788418564031874e-4L), }; result = tools::evaluate_polynomial(P, sc) / tools::evaluate_polynomial(Q, sc); result -= 1.2433929443359375F; @@ -225,20 +225,20 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&) // Maximum Deviation Found: 9.007e-20 // Expected Error Term: 9.007e-20 static const T P[6] = { - 0.577215664901532860516, - 0.243210646940107164097, - 0.0417364673988216497593, - 0.00390252087072843288378, - 0.000249606367151877175456, - 0.110108440976732897969e-4, + static_cast(0.577215664901532860516L), + static_cast(0.243210646940107164097L), + static_cast(0.0417364673988216497593L), + static_cast(0.00390252087072843288378L), + static_cast(0.000249606367151877175456L), + static_cast(0.110108440976732897969e-4L), }; static const T Q[6] = { - 1, - 0.295201277126631761737, - 0.043460910607305495864, - 0.00434930582085826330659, - 0.000255784226140488490982, - 0.10991819782396112081e-4, + static_cast(1.0), + static_cast(0.295201277126631761737L), + static_cast(0.043460910607305495864L), + static_cast(0.00434930582085826330659L), + static_cast(0.000255784226140488490982L), + static_cast(0.10991819782396112081e-4L), }; result = tools::evaluate_polynomial(P, T(-sc)) / tools::evaluate_polynomial(Q, T(-sc)); result += 1 / (-sc); @@ -249,21 +249,21 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&) // Expected Error Term: -5.946e-22 static const float Y = 0.6986598968505859375; static const T P[6] = { - -0.0537258300023595030676, - 0.0445163473292365591906, - 0.0128677673534519952905, - 0.00097541770457391752726, - 0.769875101573654070925e-4, - 0.328032510000383084155e-5, + static_cast(-0.0537258300023595030676L), + static_cast(0.0445163473292365591906L), + static_cast(0.0128677673534519952905L), + static_cast(0.00097541770457391752726L), + static_cast(0.769875101573654070925e-4L), + static_cast(0.328032510000383084155e-5L), }; static const T Q[7] = { - 1, - 0.33383194553034051422, - 0.0487798431291407621462, - 0.00479039708573558490716, - 0.000270776703956336357707, - 0.106951867532057341359e-4, - 0.236276623974978646399e-7, + 1.0f, + static_cast(0.33383194553034051422L), + static_cast(0.0487798431291407621462L), + static_cast(0.00479039708573558490716L), + static_cast(0.000270776703956336357707L), + static_cast(0.106951867532057341359e-4L), + static_cast(0.236276623974978646399e-7L), }; result = tools::evaluate_polynomial(P, T(s - 2)) / tools::evaluate_polynomial(Q, T(s - 2)); result += Y + 1 / (-sc); @@ -275,23 +275,23 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&) // Max error found at double precision: 2.009135e-16 static const T P[6] = { - -2.49710190602259410021, - -2.60013301809475665334, - -0.939260435377109939261, - -0.138448617995741530935, - -0.00701721240549802377623, - -0.229257310594893932383e-4, + static_cast(-2.49710190602259410021L), + static_cast(-2.60013301809475665334L), + static_cast(-0.939260435377109939261L), + static_cast(-0.138448617995741530935L), + static_cast(-0.00701721240549802377623L), + static_cast(-0.229257310594893932383e-4L), }; static const T Q[9] = { - 1, - 0.706039025937745133628, - 0.15739599649558626358, - 0.0106117950976845084417, - -0.36910273311764618902e-4, - 0.493409563927590008943e-5, - -0.234055487025287216506e-6, - 0.718833729365459760664e-8, - -0.1129200113474947419e-9, + 1.0f, + static_cast(0.706039025937745133628L), + static_cast(0.15739599649558626358L), + static_cast(0.0106117950976845084417L), + static_cast(-0.36910273311764618902e-4L), + static_cast(0.493409563927590008943e-5L), + static_cast(-0.234055487025287216506e-6L), + static_cast(0.718833729365459760664e-8L), + static_cast(-0.1129200113474947419e-9L), }; result = tools::evaluate_polynomial(P, T(s - 4)) / tools::evaluate_polynomial(Q, T(s - 4)); result = 1 + exp(result); @@ -302,24 +302,24 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&) // Expected Error Term: 7.117e-16 // Max error found at double precision: 9.387771e-16 static const T P[7] = { - -4.78558028495135619286, - -1.89197364881972536382, - -0.211407134874412820099, - -0.000189204758260076688518, - 0.00115140923889178742086, - 0.639949204213164496988e-4, - 0.139348932445324888343e-5, + static_cast(-4.78558028495135619286L), + static_cast(-1.89197364881972536382L), + static_cast(-0.211407134874412820099L), + static_cast(-0.000189204758260076688518L), + static_cast(0.00115140923889178742086L), + static_cast(0.639949204213164496988e-4L), + static_cast(0.139348932445324888343e-5L), }; static const T Q[9] = { - 1, - 0.244345337378188557777, - 0.00873370754492288653669, - -0.00117592765334434471562, - -0.743743682899933180415e-4, - -0.21750464515767984778e-5, - 0.471001264003076486547e-8, - -0.833378440625385520576e-10, - 0.699841545204845636531e-12, + 1.0f, + static_cast(0.244345337378188557777L), + static_cast(0.00873370754492288653669L), + static_cast(-0.00117592765334434471562L), + static_cast(-0.743743682899933180415e-4L), + static_cast(-0.21750464515767984778e-5L), + static_cast(0.471001264003076486547e-8L), + static_cast(-0.833378440625385520576e-10L), + static_cast(0.699841545204845636531e-12L), }; result = tools::evaluate_polynomial(P, T(s - 7)) / tools::evaluate_polynomial(Q, T(s - 7)); result = 1 + exp(result); @@ -329,24 +329,24 @@ inline T zeta_imp_prec(T s, T sc, const Policy&, const mpl::int_<53>&) // Max error in interpolated form: 1.668e-17 // Max error found at long double precision: 1.669714e-17 static const T P[8] = { - -10.3948950573308896825, - -2.85827219671106697179, - -0.347728266539245787271, - -0.0251156064655346341766, - -0.00119459173416968685689, - -0.382529323507967522614e-4, - -0.785523633796723466968e-6, - -0.821465709095465524192e-8, + static_cast(-10.3948950573308896825L), + static_cast(-2.85827219671106697179L), + static_cast(-0.347728266539245787271L), + static_cast(-0.0251156064655346341766L), + static_cast(-0.00119459173416968685689L), + static_cast(-0.382529323507967522614e-4L), + static_cast(-0.785523633796723466968e-6L), + static_cast(-0.821465709095465524192e-8L), }; static const T Q[10] = { - 1, - 0.208196333572671890965, - 0.0195687657317205033485, - 0.00111079638102485921877, - 0.408507746266039256231e-4, - 0.955561123065693483991e-6, - 0.118507153474022900583e-7, - 0.222609483627352615142e-14, + 1.0f, + static_cast(0.208196333572671890965L), + static_cast(0.0195687657317205033485L), + static_cast(0.00111079638102485921877L), + static_cast(0.408507746266039256231e-4L), + static_cast(0.955561123065693483991e-6L), + static_cast(0.118507153474022900583e-7L), + static_cast(0.222609483627352615142e-14L), }; result = tools::evaluate_polynomial(P, T(s - 15)) / tools::evaluate_polynomial(Q, T(s - 15)); result = 1 + exp(result); @@ -883,14 +883,14 @@ T zeta_imp_odd_integer(int s, const T& sc, const Policy& pol, const mpl::false_& if(!is_init) { is_init = true; - for(int k = 0; k < sizeof(results) / sizeof(results[0]); ++k) + for(unsigned k = 0; k < sizeof(results) / sizeof(results[0]); ++k) { T arg = k * 2 + 3; T c_arg = 1 - arg; results[k] = zeta_polynomial_series(arg, c_arg, pol); } } - int index = (s - 3) / 2; + unsigned index = (s - 3) / 2; return index >= sizeof(results) / sizeof(results[0]) ? zeta_polynomial_series(T(s), sc, pol): results[index]; } @@ -915,8 +915,12 @@ T zeta_imp(T s, T sc, const Policy& pol, const Tag& tag) // if(floor(s) == s) { +#ifndef BOOST_NO_EXCEPTIONS + // Without exceptions we expect itrunc to return INT_MAX on overflow + // and we fall through anyway. try { +#endif int v = itrunc(s); if(v == s) { @@ -925,12 +929,12 @@ T zeta_imp(T s, T sc, const Policy& pol, const Tag& tag) if(((-v) & 1) == 0) return 0; int n = (-v + 1) / 2; - if(n <= boost::math::max_bernoulli_b2n::value) + if(n <= (int)boost::math::max_bernoulli_b2n::value) return T((-v & 1) ? -1 : 1) * boost::math::unchecked_bernoulli_b2n(n) / (1 - v); } else if((v & 1) == 0) { - if(((v / 2) <= boost::math::max_bernoulli_b2n::value) && (v <= boost::math::max_factorial::value)) + if(((v / 2) <= (int)boost::math::max_bernoulli_b2n::value) && (v <= (int)boost::math::max_factorial::value)) return T(((v / 2 - 1) & 1) ? -1 : 1) * ldexp(T(1), v - 1) * pow(constants::pi(), v) * boost::math::unchecked_bernoulli_b2n(v / 2) / boost::math::unchecked_factorial(v); return T(((v / 2 - 1) & 1) ? -1 : 1) * ldexp(T(1), v - 1) * pow(constants::pi(), v) * @@ -939,9 +943,11 @@ T zeta_imp(T s, T sc, const Policy& pol, const Tag& tag) else return zeta_imp_odd_integer(v, sc, pol, mpl::bool_<(Tag::value <= 113) && Tag::value>()); } +#ifndef BOOST_NO_EXCEPTIONS } catch(const boost::math::rounding_error&){} // Just fall through, s is too large to round catch(const std::overflow_error&){} +#endif } if(fabs(s) < tools::root_epsilon()) diff --git a/boost/math/tools/big_constant.hpp b/boost/math/tools/big_constant.hpp index ff136337e1..4386609989 100644 --- a/boost/math/tools/big_constant.hpp +++ b/boost/math/tools/big_constant.hpp @@ -37,12 +37,12 @@ typedef long double largest_float; #endif template -inline BOOST_CONSTEXPR_OR_CONST T make_big_value(largest_float v, const char*, mpl::true_ const&, mpl::false_ const&) +inline BOOST_CONSTEXPR_OR_CONST T make_big_value(largest_float v, const char*, mpl::true_ const&, mpl::false_ const&) BOOST_MATH_NOEXCEPT(T) { return static_cast(v); } template -inline BOOST_CONSTEXPR_OR_CONST T make_big_value(largest_float v, const char*, mpl::true_ const&, mpl::true_ const&) +inline BOOST_CONSTEXPR_OR_CONST T make_big_value(largest_float v, const char*, mpl::true_ const&, mpl::true_ const&) BOOST_MATH_NOEXCEPT(T) { return static_cast(v); } @@ -54,7 +54,7 @@ inline T make_big_value(largest_float, const char* s, mpl::false_ const&, mpl::f } #endif template -inline BOOST_CONSTEXPR const char* make_big_value(largest_float, const char* s, mpl::false_ const&, mpl::true_ const&) +inline BOOST_MATH_CONSTEXPR const char* make_big_value(largest_float, const char* s, mpl::false_ const&, mpl::true_ const&) BOOST_MATH_NOEXCEPT(T) { return s; } diff --git a/boost/math/tools/config.hpp b/boost/math/tools/config.hpp index e88f578db7..ffd0ab43a6 100644 --- a/boost/math/tools/config.hpp +++ b/boost/math/tools/config.hpp @@ -11,6 +11,7 @@ #endif #include +#include #include // for boost::uintmax_t #include #include @@ -183,14 +184,20 @@ // #ifdef BOOST_MSVC # define BOOST_MATH_POLY_METHOD 2 +# define BOOST_MATH_RATIONAL_METHOD 1 #elif defined(BOOST_INTEL) # define BOOST_MATH_POLY_METHOD 2 -# define BOOST_MATH_RATIONAL_METHOD 2 +# define BOOST_MATH_RATIONAL_METHOD 1 #elif defined(__GNUC__) +#if __GNUC__ < 4 # define BOOST_MATH_POLY_METHOD 3 # define BOOST_MATH_RATIONAL_METHOD 3 # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L +#else +# define BOOST_MATH_POLY_METHOD 3 +# define BOOST_MATH_RATIONAL_METHOD 1 +#endif #endif #if defined(BOOST_NO_LONG_LONG) && !defined(BOOST_MATH_INT_TABLE_TYPE) @@ -198,21 +205,55 @@ # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L #endif +// +// constexpr support, early GCC implementations can't cope so disable +// constexpr for them: +// +#if !defined(__clang) && defined(__GNUC__) +#if (__GNUC__ * 100 + __GNUC_MINOR__) < 490 +# define BOOST_MATH_DISABLE_CONSTEXPR +#endif +#endif + +#ifdef BOOST_MATH_DISABLE_CONSTEXPR +# define BOOST_MATH_CONSTEXPR +#else +# define BOOST_MATH_CONSTEXPR BOOST_CONSTEXPR +#endif + +// +// noexcept support: +// +#ifndef BOOST_NO_CXX11_NOEXCEPT +#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS +#include +# define BOOST_MATH_NOEXCEPT(T) noexcept(std::is_floating_point::value) +# define BOOST_MATH_IS_FLOAT(T) (std::is_floating_point::value) +#else +#include +# define BOOST_MATH_NOEXCEPT(T) noexcept(boost::is_floating_point::value) +# define BOOST_MATH_IS_FLOAT(T) (boost::is_floating_point::value) +#endif +#else +# define BOOST_MATH_NOEXCEPT(T) +# define BOOST_MATH_IS_FLOAT(T) false +#endif + // // The maximum order of polynomial that will be evaluated // via an unrolled specialisation: // #ifndef BOOST_MATH_MAX_POLY_ORDER -# define BOOST_MATH_MAX_POLY_ORDER 17 +# define BOOST_MATH_MAX_POLY_ORDER 20 #endif // // Set the method used to evaluate polynomials and rationals: // #ifndef BOOST_MATH_POLY_METHOD -# define BOOST_MATH_POLY_METHOD 1 +# define BOOST_MATH_POLY_METHOD 2 #endif #ifndef BOOST_MATH_RATIONAL_METHOD -# define BOOST_MATH_RATIONAL_METHOD 0 +# define BOOST_MATH_RATIONAL_METHOD 1 #endif // // decide whether to store constants as integers or reals: @@ -224,7 +265,19 @@ # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##SUF #endif // -// Test whether to support __float128: +// Test whether to support __float128, if we don't have quadmath.h then this can't currently work: +// +#ifndef BOOST_MATH_USE_FLOAT128 +#ifdef __has_include +#if ! __has_include("quadmath.h") +#define BOOST_MATH_DISABLE_FLOAT128 +#endif +#elif !defined(BOOST_ARCH_X86) +#define BOOST_MATH_DISABLE_FLOAT128 +#endif +#endif +// +// And then the actual configuration: // #if defined(_GLIBCXX_USE_FLOAT128) && defined(BOOST_GCC) && !defined(__STRICT_ANSI__) \ && !defined(BOOST_MATH_DISABLE_FLOAT128) || defined(BOOST_MATH_USE_FLOAT128) @@ -296,13 +349,13 @@ namespace tools { template -inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c) +inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c) BOOST_MATH_NOEXCEPT(T) { return (std::max)((std::max)(a, b), c); } template -inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d) +inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d) BOOST_MATH_NOEXCEPT(T) { return (std::max)((std::max)(a, b), (std::max)(c, d)); } @@ -310,7 +363,7 @@ inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d) } // namespace tools template -void suppress_unused_variable_warning(const T&) +void suppress_unused_variable_warning(const T&) BOOST_MATH_NOEXCEPT(T) { } diff --git a/boost/math/tools/detail/polynomial_horner1_10.hpp b/boost/math/tools/detail/polynomial_horner1_10.hpp index b13d6a3887..48cf9e39b3 100644 --- a/boost/math/tools/detail/polynomial_horner1_10.hpp +++ b/boost/math/tools/detail/polynomial_horner1_10.hpp @@ -12,67 +12,67 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_11.hpp b/boost/math/tools/detail/polynomial_horner1_11.hpp index f0cf67e959..e52595429e 100644 --- a/boost/math/tools/detail/polynomial_horner1_11.hpp +++ b/boost/math/tools/detail/polynomial_horner1_11.hpp @@ -12,73 +12,73 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_12.hpp b/boost/math/tools/detail/polynomial_horner1_12.hpp index 03b974ceca..10cd178975 100644 --- a/boost/math/tools/detail/polynomial_horner1_12.hpp +++ b/boost/math/tools/detail/polynomial_horner1_12.hpp @@ -12,79 +12,79 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_13.hpp b/boost/math/tools/detail/polynomial_horner1_13.hpp index b947f542c3..90fa9ec43d 100644 --- a/boost/math/tools/detail/polynomial_horner1_13.hpp +++ b/boost/math/tools/detail/polynomial_horner1_13.hpp @@ -12,85 +12,85 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_14.hpp b/boost/math/tools/detail/polynomial_horner1_14.hpp index 8374e38904..389c8063b0 100644 --- a/boost/math/tools/detail/polynomial_horner1_14.hpp +++ b/boost/math/tools/detail/polynomial_horner1_14.hpp @@ -12,91 +12,91 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_15.hpp b/boost/math/tools/detail/polynomial_horner1_15.hpp index ebfa463601..d196a41603 100644 --- a/boost/math/tools/detail/polynomial_horner1_15.hpp +++ b/boost/math/tools/detail/polynomial_horner1_15.hpp @@ -12,97 +12,97 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_16.hpp b/boost/math/tools/detail/polynomial_horner1_16.hpp index 60eb4dc675..fa48c6614c 100644 --- a/boost/math/tools/detail/polynomial_horner1_16.hpp +++ b/boost/math/tools/detail/polynomial_horner1_16.hpp @@ -12,103 +12,103 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((((a[15] * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_17.hpp b/boost/math/tools/detail/polynomial_horner1_17.hpp index 6233f1b07b..4575aeac7b 100644 --- a/boost/math/tools/detail/polynomial_horner1_17.hpp +++ b/boost/math/tools/detail/polynomial_horner1_17.hpp @@ -12,109 +12,109 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((((a[15] * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((((a[16] * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_18.hpp b/boost/math/tools/detail/polynomial_horner1_18.hpp index 2a06def44b..95dd400416 100644 --- a/boost/math/tools/detail/polynomial_horner1_18.hpp +++ b/boost/math/tools/detail/polynomial_horner1_18.hpp @@ -12,115 +12,115 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((((a[15] * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((((a[16] * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((((((a[17] * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_19.hpp b/boost/math/tools/detail/polynomial_horner1_19.hpp index 8f0da8b219..6d73eb8ffc 100644 --- a/boost/math/tools/detail/polynomial_horner1_19.hpp +++ b/boost/math/tools/detail/polynomial_horner1_19.hpp @@ -12,121 +12,121 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((((a[15] * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((((a[16] * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((((((a[17] * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((((((a[18] * x + a[17]) * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_2.hpp b/boost/math/tools/detail/polynomial_horner1_2.hpp index a0b10d5ee5..85640edf67 100644 --- a/boost/math/tools/detail/polynomial_horner1_2.hpp +++ b/boost/math/tools/detail/polynomial_horner1_2.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_20.hpp b/boost/math/tools/detail/polynomial_horner1_20.hpp index d1a886dd76..f8b7f34384 100644 --- a/boost/math/tools/detail/polynomial_horner1_20.hpp +++ b/boost/math/tools/detail/polynomial_horner1_20.hpp @@ -12,127 +12,127 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((((a[15] * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((((a[16] * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((((((a[17] * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((((((((((((a[18] * x + a[17]) * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<20>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<20>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((((((((((((((a[19] * x + a[18]) * x + a[17]) * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_3.hpp b/boost/math/tools/detail/polynomial_horner1_3.hpp index 715a69aee0..c0ad4660e9 100644 --- a/boost/math/tools/detail/polynomial_horner1_3.hpp +++ b/boost/math/tools/detail/polynomial_horner1_3.hpp @@ -12,25 +12,25 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_4.hpp b/boost/math/tools/detail/polynomial_horner1_4.hpp index d74b7a6386..27ad74eb95 100644 --- a/boost/math/tools/detail/polynomial_horner1_4.hpp +++ b/boost/math/tools/detail/polynomial_horner1_4.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_5.hpp b/boost/math/tools/detail/polynomial_horner1_5.hpp index bb66e6c41d..5cfafb4052 100644 --- a/boost/math/tools/detail/polynomial_horner1_5.hpp +++ b/boost/math/tools/detail/polynomial_horner1_5.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_6.hpp b/boost/math/tools/detail/polynomial_horner1_6.hpp index a29c2710e8..f7f4bee480 100644 --- a/boost/math/tools/detail/polynomial_horner1_6.hpp +++ b/boost/math/tools/detail/polynomial_horner1_6.hpp @@ -12,43 +12,43 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_7.hpp b/boost/math/tools/detail/polynomial_horner1_7.hpp index 093ab89b02..c612822fc0 100644 --- a/boost/math/tools/detail/polynomial_horner1_7.hpp +++ b/boost/math/tools/detail/polynomial_horner1_7.hpp @@ -12,49 +12,49 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_8.hpp b/boost/math/tools/detail/polynomial_horner1_8.hpp index a3d329a37b..5d9b453b9d 100644 --- a/boost/math/tools/detail/polynomial_horner1_8.hpp +++ b/boost/math/tools/detail/polynomial_horner1_8.hpp @@ -12,55 +12,55 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner1_9.hpp b/boost/math/tools/detail/polynomial_horner1_9.hpp index e90f578d04..84977fd13b 100644 --- a/boost/math/tools/detail/polynomial_horner1_9.hpp +++ b/boost/math/tools/detail/polynomial_horner1_9.hpp @@ -12,61 +12,61 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner2_10.hpp b/boost/math/tools/detail/polynomial_horner2_10.hpp index 7c4101f465..f10c5d0492 100644 --- a/boost/math/tools/detail/polynomial_horner2_10.hpp +++ b/boost/math/tools/detail/polynomial_horner2_10.hpp @@ -12,72 +12,72 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); diff --git a/boost/math/tools/detail/polynomial_horner2_11.hpp b/boost/math/tools/detail/polynomial_horner2_11.hpp index bebd1e6483..757357addf 100644 --- a/boost/math/tools/detail/polynomial_horner2_11.hpp +++ b/boost/math/tools/detail/polynomial_horner2_11.hpp @@ -12,79 +12,79 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); diff --git a/boost/math/tools/detail/polynomial_horner2_12.hpp b/boost/math/tools/detail/polynomial_horner2_12.hpp index c4da24ac88..e0fc8a9df7 100644 --- a/boost/math/tools/detail/polynomial_horner2_12.hpp +++ b/boost/math/tools/detail/polynomial_horner2_12.hpp @@ -12,86 +12,86 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); diff --git a/boost/math/tools/detail/polynomial_horner2_13.hpp b/boost/math/tools/detail/polynomial_horner2_13.hpp index 5d7dddc5b5..c13a0a7cc2 100644 --- a/boost/math/tools/detail/polynomial_horner2_13.hpp +++ b/boost/math/tools/detail/polynomial_horner2_13.hpp @@ -12,93 +12,93 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); diff --git a/boost/math/tools/detail/polynomial_horner2_14.hpp b/boost/math/tools/detail/polynomial_horner2_14.hpp index 21a5a37903..ccc6e7d8da 100644 --- a/boost/math/tools/detail/polynomial_horner2_14.hpp +++ b/boost/math/tools/detail/polynomial_horner2_14.hpp @@ -12,100 +12,100 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); diff --git a/boost/math/tools/detail/polynomial_horner2_15.hpp b/boost/math/tools/detail/polynomial_horner2_15.hpp index 7b41214466..a409ba7fdb 100644 --- a/boost/math/tools/detail/polynomial_horner2_15.hpp +++ b/boost/math/tools/detail/polynomial_horner2_15.hpp @@ -12,107 +12,107 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); diff --git a/boost/math/tools/detail/polynomial_horner2_16.hpp b/boost/math/tools/detail/polynomial_horner2_16.hpp index aa3763ad65..a69c1a3619 100644 --- a/boost/math/tools/detail/polynomial_horner2_16.hpp +++ b/boost/math/tools/detail/polynomial_horner2_16.hpp @@ -12,114 +12,114 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((((a[15] * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); diff --git a/boost/math/tools/detail/polynomial_horner2_17.hpp b/boost/math/tools/detail/polynomial_horner2_17.hpp index 6ed5566d49..9e7c05d007 100644 --- a/boost/math/tools/detail/polynomial_horner2_17.hpp +++ b/boost/math/tools/detail/polynomial_horner2_17.hpp @@ -12,121 +12,121 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((((a[15] * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((((a[16] * x2 + a[14]) * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((((a[15] * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); diff --git a/boost/math/tools/detail/polynomial_horner2_18.hpp b/boost/math/tools/detail/polynomial_horner2_18.hpp index 02c72b8227..1ea0e052c0 100644 --- a/boost/math/tools/detail/polynomial_horner2_18.hpp +++ b/boost/math/tools/detail/polynomial_horner2_18.hpp @@ -12,128 +12,128 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((((a[15] * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((((a[16] * x2 + a[14]) * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((((a[15] * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((((a[17] * x2 + a[15]) * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((((a[16] * x2 + a[14]) * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); diff --git a/boost/math/tools/detail/polynomial_horner2_19.hpp b/boost/math/tools/detail/polynomial_horner2_19.hpp index 6e36ace904..45c125c871 100644 --- a/boost/math/tools/detail/polynomial_horner2_19.hpp +++ b/boost/math/tools/detail/polynomial_horner2_19.hpp @@ -12,135 +12,135 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((((a[15] * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((((a[16] * x2 + a[14]) * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((((a[15] * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((((a[17] * x2 + a[15]) * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((((a[16] * x2 + a[14]) * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((((a[18] * x2 + a[16]) * x2 + a[14]) * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((((((a[17] * x2 + a[15]) * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); diff --git a/boost/math/tools/detail/polynomial_horner2_2.hpp b/boost/math/tools/detail/polynomial_horner2_2.hpp index e2a4e7faef..20da483c33 100644 --- a/boost/math/tools/detail/polynomial_horner2_2.hpp +++ b/boost/math/tools/detail/polynomial_horner2_2.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner2_20.hpp b/boost/math/tools/detail/polynomial_horner2_20.hpp index e394b6b325..956c6dba4f 100644 --- a/boost/math/tools/detail/polynomial_horner2_20.hpp +++ b/boost/math/tools/detail/polynomial_horner2_20.hpp @@ -12,142 +12,142 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((a[9] * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((a[10] * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((a[11] * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((a[12] * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((((a[13] * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((((a[15] * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((((a[14] * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((((a[16] * x2 + a[14]) * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((((((a[15] * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((((a[17] * x2 + a[15]) * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + (((((((a[16] * x2 + a[14]) * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((((((((a[18] * x2 + a[16]) * x2 + a[14]) * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((((((((a[17] * x2 + a[15]) * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<20>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<20>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((((((((a[19] * x2 + a[17]) * x2 + a[15]) * x2 + a[13]) * x2 + a[11]) * x2 + a[9]) * x2 + a[7]) * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((((((((a[18] * x2 + a[16]) * x2 + a[14]) * x2 + a[12]) * x2 + a[10]) * x2 + a[8]) * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); diff --git a/boost/math/tools/detail/polynomial_horner2_3.hpp b/boost/math/tools/detail/polynomial_horner2_3.hpp index 187b86c1ce..58b290c7c9 100644 --- a/boost/math/tools/detail/polynomial_horner2_3.hpp +++ b/boost/math/tools/detail/polynomial_horner2_3.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner2_4.hpp b/boost/math/tools/detail/polynomial_horner2_4.hpp index 84badc365a..74f969b749 100644 --- a/boost/math/tools/detail/polynomial_horner2_4.hpp +++ b/boost/math/tools/detail/polynomial_horner2_4.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner2_5.hpp b/boost/math/tools/detail/polynomial_horner2_5.hpp index 287b4be08e..134cbc8ef9 100644 --- a/boost/math/tools/detail/polynomial_horner2_5.hpp +++ b/boost/math/tools/detail/polynomial_horner2_5.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); diff --git a/boost/math/tools/detail/polynomial_horner2_6.hpp b/boost/math/tools/detail/polynomial_horner2_6.hpp index 3662d44f93..7cb75d75c8 100644 --- a/boost/math/tools/detail/polynomial_horner2_6.hpp +++ b/boost/math/tools/detail/polynomial_horner2_6.hpp @@ -12,44 +12,44 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); diff --git a/boost/math/tools/detail/polynomial_horner2_7.hpp b/boost/math/tools/detail/polynomial_horner2_7.hpp index 78ed0df54d..327639deb6 100644 --- a/boost/math/tools/detail/polynomial_horner2_7.hpp +++ b/boost/math/tools/detail/polynomial_horner2_7.hpp @@ -12,51 +12,51 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); diff --git a/boost/math/tools/detail/polynomial_horner2_8.hpp b/boost/math/tools/detail/polynomial_horner2_8.hpp index ac8e941180..2145ad6dcd 100644 --- a/boost/math/tools/detail/polynomial_horner2_8.hpp +++ b/boost/math/tools/detail/polynomial_horner2_8.hpp @@ -12,58 +12,58 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); diff --git a/boost/math/tools/detail/polynomial_horner2_9.hpp b/boost/math/tools/detail/polynomial_horner2_9.hpp index e1a3d17eca..08f6336e49 100644 --- a/boost/math/tools/detail/polynomial_horner2_9.hpp +++ b/boost/math/tools/detail/polynomial_horner2_9.hpp @@ -12,65 +12,65 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((a[4] * x2 + a[2]) * x2 + a[0] + (a[3] * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[5] * x2 + a[3]) * x2 + a[1]) * x + (a[4] * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast(((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + ((a[5] * x2 + a[3]) * x2 + a[1]) * x); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x + ((a[6] * x2 + a[4]) * x2 + a[2]) * x2 + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; return static_cast((((a[8] * x2 + a[6]) * x2 + a[4]) * x2 + a[2]) * x2 + a[0] + (((a[7] * x2 + a[5]) * x2 + a[3]) * x2 + a[1]) * x); diff --git a/boost/math/tools/detail/polynomial_horner3_10.hpp b/boost/math/tools/detail/polynomial_horner3_10.hpp index 69736d7118..05ad20cc30 100644 --- a/boost/math/tools/detail/polynomial_horner3_10.hpp +++ b/boost/math/tools/detail/polynomial_horner3_10.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -127,7 +127,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_11.hpp b/boost/math/tools/detail/polynomial_horner3_11.hpp index 273ed535cc..9f8628e750 100644 --- a/boost/math/tools/detail/polynomial_horner3_11.hpp +++ b/boost/math/tools/detail/polynomial_horner3_11.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -127,7 +127,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -150,7 +150,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_12.hpp b/boost/math/tools/detail/polynomial_horner3_12.hpp index 340567400b..ccb3ec4d10 100644 --- a/boost/math/tools/detail/polynomial_horner3_12.hpp +++ b/boost/math/tools/detail/polynomial_horner3_12.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -127,7 +127,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -150,7 +150,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -175,7 +175,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_13.hpp b/boost/math/tools/detail/polynomial_horner3_13.hpp index 849c93e54a..a8cdf2c508 100644 --- a/boost/math/tools/detail/polynomial_horner3_13.hpp +++ b/boost/math/tools/detail/polynomial_horner3_13.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -127,7 +127,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -150,7 +150,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -175,7 +175,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -202,7 +202,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_14.hpp b/boost/math/tools/detail/polynomial_horner3_14.hpp index f5ac1df9d1..5eb4ef1f28 100644 --- a/boost/math/tools/detail/polynomial_horner3_14.hpp +++ b/boost/math/tools/detail/polynomial_horner3_14.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -127,7 +127,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -150,7 +150,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -175,7 +175,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -202,7 +202,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -231,7 +231,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_15.hpp b/boost/math/tools/detail/polynomial_horner3_15.hpp index b57af7e3dc..7e8edcd8aa 100644 --- a/boost/math/tools/detail/polynomial_horner3_15.hpp +++ b/boost/math/tools/detail/polynomial_horner3_15.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -127,7 +127,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -150,7 +150,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -175,7 +175,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -202,7 +202,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -231,7 +231,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -262,7 +262,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_16.hpp b/boost/math/tools/detail/polynomial_horner3_16.hpp index 1fc8560a21..58bea1581f 100644 --- a/boost/math/tools/detail/polynomial_horner3_16.hpp +++ b/boost/math/tools/detail/polynomial_horner3_16.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -127,7 +127,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -150,7 +150,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -175,7 +175,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -202,7 +202,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -231,7 +231,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -262,7 +262,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -295,7 +295,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_17.hpp b/boost/math/tools/detail/polynomial_horner3_17.hpp index 4a0d0aa472..007b8a4918 100644 --- a/boost/math/tools/detail/polynomial_horner3_17.hpp +++ b/boost/math/tools/detail/polynomial_horner3_17.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -127,7 +127,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -150,7 +150,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -175,7 +175,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -202,7 +202,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -231,7 +231,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -262,7 +262,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -295,7 +295,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -330,7 +330,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_18.hpp b/boost/math/tools/detail/polynomial_horner3_18.hpp index 899117d2f9..68935adba1 100644 --- a/boost/math/tools/detail/polynomial_horner3_18.hpp +++ b/boost/math/tools/detail/polynomial_horner3_18.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -127,7 +127,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -150,7 +150,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -175,7 +175,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -202,7 +202,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -231,7 +231,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -262,7 +262,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -295,7 +295,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -330,7 +330,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -367,7 +367,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_19.hpp b/boost/math/tools/detail/polynomial_horner3_19.hpp index 7c4f728419..acffba6b47 100644 --- a/boost/math/tools/detail/polynomial_horner3_19.hpp +++ b/boost/math/tools/detail/polynomial_horner3_19.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -127,7 +127,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -150,7 +150,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -175,7 +175,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -202,7 +202,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -231,7 +231,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -262,7 +262,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -295,7 +295,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -330,7 +330,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -367,7 +367,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -406,7 +406,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_2.hpp b/boost/math/tools/detail/polynomial_horner3_2.hpp index 372630cfd9..6b8d9a71f8 100644 --- a/boost/math/tools/detail/polynomial_horner3_2.hpp +++ b/boost/math/tools/detail/polynomial_horner3_2.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner3_20.hpp b/boost/math/tools/detail/polynomial_horner3_20.hpp index b20e0d5fe1..b3a170c095 100644 --- a/boost/math/tools/detail/polynomial_horner3_20.hpp +++ b/boost/math/tools/detail/polynomial_horner3_20.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -127,7 +127,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -150,7 +150,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -175,7 +175,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -202,7 +202,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -231,7 +231,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -262,7 +262,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -295,7 +295,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -330,7 +330,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -367,7 +367,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -406,7 +406,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -447,7 +447,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<20>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<20>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_3.hpp b/boost/math/tools/detail/polynomial_horner3_3.hpp index cc6b1a9351..05fe88fccc 100644 --- a/boost/math/tools/detail/polynomial_horner3_3.hpp +++ b/boost/math/tools/detail/polynomial_horner3_3.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner3_4.hpp b/boost/math/tools/detail/polynomial_horner3_4.hpp index 74192f0c90..b98d6f678d 100644 --- a/boost/math/tools/detail/polynomial_horner3_4.hpp +++ b/boost/math/tools/detail/polynomial_horner3_4.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } diff --git a/boost/math/tools/detail/polynomial_horner3_5.hpp b/boost/math/tools/detail/polynomial_horner3_5.hpp index 73d1900998..12e639cef3 100644 --- a/boost/math/tools/detail/polynomial_horner3_5.hpp +++ b/boost/math/tools/detail/polynomial_horner3_5.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_6.hpp b/boost/math/tools/detail/polynomial_horner3_6.hpp index da02574866..b645cb5bbc 100644 --- a/boost/math/tools/detail/polynomial_horner3_6.hpp +++ b/boost/math/tools/detail/polynomial_horner3_6.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_7.hpp b/boost/math/tools/detail/polynomial_horner3_7.hpp index d45a622278..3df4b5b4ef 100644 --- a/boost/math/tools/detail/polynomial_horner3_7.hpp +++ b/boost/math/tools/detail/polynomial_horner3_7.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_8.hpp b/boost/math/tools/detail/polynomial_horner3_8.hpp index d0198bf345..9a49d2555e 100644 --- a/boost/math/tools/detail/polynomial_horner3_8.hpp +++ b/boost/math/tools/detail/polynomial_horner3_8.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/polynomial_horner3_9.hpp b/boost/math/tools/detail/polynomial_horner3_9.hpp index b3e0b19970..3507d37604 100644 --- a/boost/math/tools/detail/polynomial_horner3_9.hpp +++ b/boost/math/tools/detail/polynomial_horner3_9.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) +inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) +inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[1] * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[2] * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[3] * x + a[2]) * x + a[1]) * x + a[0]); } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -55,7 +55,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -70,7 +70,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -87,7 +87,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; @@ -106,7 +106,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) } template -inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) +inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { V x2 = x * x; V t[2]; diff --git a/boost/math/tools/detail/rational_horner1_10.hpp b/boost/math/tools/detail/rational_horner1_10.hpp index 919ba6d09f..e670853869 100644 --- a/boost/math/tools/detail/rational_horner1_10.hpp +++ b/boost/math/tools/detail/rational_horner1_10.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -120,7 +120,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((b[9] * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_11.hpp b/boost/math/tools/detail/rational_horner1_11.hpp index e17bfbc723..65e17598ff 100644 --- a/boost/math/tools/detail/rational_horner1_11.hpp +++ b/boost/math/tools/detail/rational_horner1_11.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -120,7 +120,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((b[9] * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -132,7 +132,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((b[10] * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_12.hpp b/boost/math/tools/detail/rational_horner1_12.hpp index 67b430a990..de33af0e07 100644 --- a/boost/math/tools/detail/rational_horner1_12.hpp +++ b/boost/math/tools/detail/rational_horner1_12.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -120,7 +120,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((b[9] * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -132,7 +132,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((b[10] * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -144,7 +144,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((b[11] * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_13.hpp b/boost/math/tools/detail/rational_horner1_13.hpp index 33ae67523c..ed4ac1af8b 100644 --- a/boost/math/tools/detail/rational_horner1_13.hpp +++ b/boost/math/tools/detail/rational_horner1_13.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -120,7 +120,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((b[9] * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -132,7 +132,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((b[10] * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -144,7 +144,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((b[11] * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -156,7 +156,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((b[12] * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_14.hpp b/boost/math/tools/detail/rational_horner1_14.hpp index 0c5f1884c6..a3222f8212 100644 --- a/boost/math/tools/detail/rational_horner1_14.hpp +++ b/boost/math/tools/detail/rational_horner1_14.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -120,7 +120,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((b[9] * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -132,7 +132,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((b[10] * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -144,7 +144,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((b[11] * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -156,7 +156,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((b[12] * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -168,7 +168,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((b[13] * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_15.hpp b/boost/math/tools/detail/rational_horner1_15.hpp index 848190761f..c8cd691573 100644 --- a/boost/math/tools/detail/rational_horner1_15.hpp +++ b/boost/math/tools/detail/rational_horner1_15.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -120,7 +120,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((b[9] * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -132,7 +132,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((b[10] * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -144,7 +144,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((b[11] * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -156,7 +156,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((b[12] * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -168,7 +168,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((b[13] * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((b[14] * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_16.hpp b/boost/math/tools/detail/rational_horner1_16.hpp index e0661f8b3e..8003c82db7 100644 --- a/boost/math/tools/detail/rational_horner1_16.hpp +++ b/boost/math/tools/detail/rational_horner1_16.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -120,7 +120,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((b[9] * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -132,7 +132,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((b[10] * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -144,7 +144,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((b[11] * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -156,7 +156,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((b[12] * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -168,7 +168,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((b[13] * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((b[14] * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -192,7 +192,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((((a[15] * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((((b[15] * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_17.hpp b/boost/math/tools/detail/rational_horner1_17.hpp index f123da4c95..294c3f175d 100644 --- a/boost/math/tools/detail/rational_horner1_17.hpp +++ b/boost/math/tools/detail/rational_horner1_17.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -120,7 +120,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((b[9] * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -132,7 +132,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((b[10] * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -144,7 +144,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((b[11] * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -156,7 +156,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((b[12] * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -168,7 +168,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((b[13] * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((b[14] * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -192,7 +192,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((((a[15] * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((((b[15] * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -204,7 +204,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((((a[16] * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((((b[16] * x + b[15]) * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_18.hpp b/boost/math/tools/detail/rational_horner1_18.hpp index 718ace87fc..1a48bba097 100644 --- a/boost/math/tools/detail/rational_horner1_18.hpp +++ b/boost/math/tools/detail/rational_horner1_18.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -120,7 +120,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((b[9] * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -132,7 +132,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((b[10] * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -144,7 +144,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((b[11] * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -156,7 +156,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((b[12] * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -168,7 +168,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((b[13] * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((b[14] * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -192,7 +192,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((((a[15] * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((((b[15] * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -204,7 +204,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((((a[16] * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((((b[16] * x + b[15]) * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -216,7 +216,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((((((a[17] * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((((((b[17] * x + b[16]) * x + b[15]) * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_19.hpp b/boost/math/tools/detail/rational_horner1_19.hpp index c849ba8c06..12fd75cf1b 100644 --- a/boost/math/tools/detail/rational_horner1_19.hpp +++ b/boost/math/tools/detail/rational_horner1_19.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -120,7 +120,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((b[9] * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -132,7 +132,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((b[10] * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -144,7 +144,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((b[11] * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -156,7 +156,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((b[12] * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -168,7 +168,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((b[13] * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((b[14] * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -192,7 +192,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((((a[15] * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((((b[15] * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -204,7 +204,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((((a[16] * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((((b[16] * x + b[15]) * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -216,7 +216,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((((((a[17] * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((((((b[17] * x + b[16]) * x + b[15]) * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -228,7 +228,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((((((a[18] * x + a[17]) * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((((((b[18] * x + b[17]) * x + b[16]) * x + b[15]) * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_2.hpp b/boost/math/tools/detail/rational_horner1_2.hpp index 87e41ab3f9..c838f2a2cd 100644 --- a/boost/math/tools/detail/rational_horner1_2.hpp +++ b/boost/math/tools/detail/rational_horner1_2.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_20.hpp b/boost/math/tools/detail/rational_horner1_20.hpp index e05eaaa89b..3ee3e966e6 100644 --- a/boost/math/tools/detail/rational_horner1_20.hpp +++ b/boost/math/tools/detail/rational_horner1_20.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -120,7 +120,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((a[9] * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((b[9] * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -132,7 +132,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((a[10] * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((b[10] * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -144,7 +144,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((a[11] * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((b[11] * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -156,7 +156,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((a[12] * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((b[12] * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -168,7 +168,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((a[13] * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((b[13] * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((a[14] * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((b[14] * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -192,7 +192,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((((a[15] * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((((b[15] * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -204,7 +204,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((((a[16] * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((((b[16] * x + b[15]) * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -216,7 +216,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((((((a[17] * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((((((b[17] * x + b[16]) * x + b[15]) * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -228,7 +228,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((((((((((((a[18] * x + a[17]) * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((((((((((((b[18] * x + b[17]) * x + b[16]) * x + b[15]) * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -240,7 +240,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<20>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<20>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((((((((((((((a[19] * x + a[18]) * x + a[17]) * x + a[16]) * x + a[15]) * x + a[14]) * x + a[13]) * x + a[12]) * x + a[11]) * x + a[10]) * x + a[9]) * x + a[8]) * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((((((((((((((b[19] * x + b[18]) * x + b[17]) * x + b[16]) * x + b[15]) * x + b[14]) * x + b[13]) * x + b[12]) * x + b[11]) * x + b[10]) * x + b[9]) * x + b[8]) * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_3.hpp b/boost/math/tools/detail/rational_horner1_3.hpp index ac1b785e93..034ead3f66 100644 --- a/boost/math/tools/detail/rational_horner1_3.hpp +++ b/boost/math/tools/detail/rational_horner1_3.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_4.hpp b/boost/math/tools/detail/rational_horner1_4.hpp index eeced600f4..de2972f4c4 100644 --- a/boost/math/tools/detail/rational_horner1_4.hpp +++ b/boost/math/tools/detail/rational_horner1_4.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_5.hpp b/boost/math/tools/detail/rational_horner1_5.hpp index 0479f66376..a59ff114d1 100644 --- a/boost/math/tools/detail/rational_horner1_5.hpp +++ b/boost/math/tools/detail/rational_horner1_5.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_6.hpp b/boost/math/tools/detail/rational_horner1_6.hpp index db259968ee..c5000c5db4 100644 --- a/boost/math/tools/detail/rational_horner1_6.hpp +++ b/boost/math/tools/detail/rational_horner1_6.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_7.hpp b/boost/math/tools/detail/rational_horner1_7.hpp index b431fe91ef..bc860f3bf7 100644 --- a/boost/math/tools/detail/rational_horner1_7.hpp +++ b/boost/math/tools/detail/rational_horner1_7.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_8.hpp b/boost/math/tools/detail/rational_horner1_8.hpp index 5a04a7a343..69368978b6 100644 --- a/boost/math/tools/detail/rational_horner1_8.hpp +++ b/boost/math/tools/detail/rational_horner1_8.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner1_9.hpp b/boost/math/tools/detail/rational_horner1_9.hpp index 4b5465fc4a..0aafea15fd 100644 --- a/boost/math/tools/detail/rational_horner1_9.hpp +++ b/boost/math/tools/detail/rational_horner1_9.hpp @@ -12,19 +12,19 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); @@ -36,7 +36,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); @@ -48,7 +48,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); @@ -60,7 +60,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((a[4] * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((b[4] * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -72,7 +72,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((a[5] * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((b[5] * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -84,7 +84,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((b[6] * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -96,7 +96,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast((((((((a[7] * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / (((((((b[7] * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); @@ -108,7 +108,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) return static_cast(((((((((a[8] * x + a[7]) * x + a[6]) * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]) / ((((((((b[8] * x + b[7]) * x + b[6]) * x + b[5]) * x + b[4]) * x + b[3]) * x + b[2]) * x + b[1]) * x + b[0])); diff --git a/boost/math/tools/detail/rational_horner2_10.hpp b/boost/math/tools/detail/rational_horner2_10.hpp index e26d2d934f..127777bc2a 100644 --- a/boost/math/tools/detail/rational_horner2_10.hpp +++ b/boost/math/tools/detail/rational_horner2_10.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -122,7 +122,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_11.hpp b/boost/math/tools/detail/rational_horner2_11.hpp index c05e697197..53983ed4ad 100644 --- a/boost/math/tools/detail/rational_horner2_11.hpp +++ b/boost/math/tools/detail/rational_horner2_11.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -122,7 +122,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -138,7 +138,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_12.hpp b/boost/math/tools/detail/rational_horner2_12.hpp index 4ee3734001..4ad0856b06 100644 --- a/boost/math/tools/detail/rational_horner2_12.hpp +++ b/boost/math/tools/detail/rational_horner2_12.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -122,7 +122,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -138,7 +138,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -154,7 +154,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_13.hpp b/boost/math/tools/detail/rational_horner2_13.hpp index 37977a111d..5f9303d0c3 100644 --- a/boost/math/tools/detail/rational_horner2_13.hpp +++ b/boost/math/tools/detail/rational_horner2_13.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -122,7 +122,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -138,7 +138,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -154,7 +154,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -170,7 +170,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_14.hpp b/boost/math/tools/detail/rational_horner2_14.hpp index 78edfbbe1b..dc512f393f 100644 --- a/boost/math/tools/detail/rational_horner2_14.hpp +++ b/boost/math/tools/detail/rational_horner2_14.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -122,7 +122,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -138,7 +138,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -154,7 +154,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -170,7 +170,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -186,7 +186,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_15.hpp b/boost/math/tools/detail/rational_horner2_15.hpp index 3cf4ef56a0..cf084e8be0 100644 --- a/boost/math/tools/detail/rational_horner2_15.hpp +++ b/boost/math/tools/detail/rational_horner2_15.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -122,7 +122,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -138,7 +138,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -154,7 +154,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -170,7 +170,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -186,7 +186,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -202,7 +202,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_16.hpp b/boost/math/tools/detail/rational_horner2_16.hpp index 3936a1ba4b..3d13db2553 100644 --- a/boost/math/tools/detail/rational_horner2_16.hpp +++ b/boost/math/tools/detail/rational_horner2_16.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -122,7 +122,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -138,7 +138,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -154,7 +154,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -170,7 +170,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -186,7 +186,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -202,7 +202,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -218,7 +218,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_17.hpp b/boost/math/tools/detail/rational_horner2_17.hpp index 4d253b9593..3adf4053bd 100644 --- a/boost/math/tools/detail/rational_horner2_17.hpp +++ b/boost/math/tools/detail/rational_horner2_17.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -122,7 +122,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -138,7 +138,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -154,7 +154,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -170,7 +170,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -186,7 +186,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -202,7 +202,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -218,7 +218,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -234,7 +234,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_18.hpp b/boost/math/tools/detail/rational_horner2_18.hpp index 6c213ecfb0..607609fd8e 100644 --- a/boost/math/tools/detail/rational_horner2_18.hpp +++ b/boost/math/tools/detail/rational_horner2_18.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -122,7 +122,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -138,7 +138,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -154,7 +154,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -170,7 +170,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -186,7 +186,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -202,7 +202,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -218,7 +218,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -234,7 +234,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -250,7 +250,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_19.hpp b/boost/math/tools/detail/rational_horner2_19.hpp index 88e0b9ff01..bc324c3be3 100644 --- a/boost/math/tools/detail/rational_horner2_19.hpp +++ b/boost/math/tools/detail/rational_horner2_19.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -122,7 +122,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -138,7 +138,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -154,7 +154,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -170,7 +170,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -186,7 +186,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -202,7 +202,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -218,7 +218,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -234,7 +234,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -250,7 +250,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -266,7 +266,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_2.hpp b/boost/math/tools/detail/rational_horner2_2.hpp index 35b5abb354..95ec0251d5 100644 --- a/boost/math/tools/detail/rational_horner2_2.hpp +++ b/boost/math/tools/detail/rational_horner2_2.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } diff --git a/boost/math/tools/detail/rational_horner2_20.hpp b/boost/math/tools/detail/rational_horner2_20.hpp index dc73fdd58e..cf1211b61f 100644 --- a/boost/math/tools/detail/rational_horner2_20.hpp +++ b/boost/math/tools/detail/rational_horner2_20.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -122,7 +122,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -138,7 +138,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -154,7 +154,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -170,7 +170,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -186,7 +186,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -202,7 +202,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -218,7 +218,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -234,7 +234,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -250,7 +250,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -266,7 +266,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -282,7 +282,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<20>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<20>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_3.hpp b/boost/math/tools/detail/rational_horner2_3.hpp index 8838ac13e6..9ce437b41f 100644 --- a/boost/math/tools/detail/rational_horner2_3.hpp +++ b/boost/math/tools/detail/rational_horner2_3.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } diff --git a/boost/math/tools/detail/rational_horner2_4.hpp b/boost/math/tools/detail/rational_horner2_4.hpp index 5fe5ada83b..00543ede85 100644 --- a/boost/math/tools/detail/rational_horner2_4.hpp +++ b/boost/math/tools/detail/rational_horner2_4.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } diff --git a/boost/math/tools/detail/rational_horner2_5.hpp b/boost/math/tools/detail/rational_horner2_5.hpp index 48b8498bc7..d117b66633 100644 --- a/boost/math/tools/detail/rational_horner2_5.hpp +++ b/boost/math/tools/detail/rational_horner2_5.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_6.hpp b/boost/math/tools/detail/rational_horner2_6.hpp index 83631eaf51..c431d16344 100644 --- a/boost/math/tools/detail/rational_horner2_6.hpp +++ b/boost/math/tools/detail/rational_horner2_6.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_7.hpp b/boost/math/tools/detail/rational_horner2_7.hpp index 3ed86eafcd..2104302472 100644 --- a/boost/math/tools/detail/rational_horner2_7.hpp +++ b/boost/math/tools/detail/rational_horner2_7.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_8.hpp b/boost/math/tools/detail/rational_horner2_8.hpp index f8b36ece4a..fd98289b99 100644 --- a/boost/math/tools/detail/rational_horner2_8.hpp +++ b/boost/math/tools/detail/rational_horner2_8.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner2_9.hpp b/boost/math/tools/detail/rational_horner2_9.hpp index 88cc4e5fcf..1081ab2f8b 100644 --- a/boost/math/tools/detail/rational_horner2_9.hpp +++ b/boost/math/tools/detail/rational_horner2_9.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -58,7 +58,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -74,7 +74,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -90,7 +90,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -106,7 +106,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_10.hpp b/boost/math/tools/detail/rational_horner3_10.hpp index 019ffdacc3..7da05875f3 100644 --- a/boost/math/tools/detail/rational_horner3_10.hpp +++ b/boost/math/tools/detail/rational_horner3_10.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -312,7 +312,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_11.hpp b/boost/math/tools/detail/rational_horner3_11.hpp index 13ce3134ae..df971197a3 100644 --- a/boost/math/tools/detail/rational_horner3_11.hpp +++ b/boost/math/tools/detail/rational_horner3_11.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -312,7 +312,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -390,7 +390,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_12.hpp b/boost/math/tools/detail/rational_horner3_12.hpp index 634140bd0d..668f76684f 100644 --- a/boost/math/tools/detail/rational_horner3_12.hpp +++ b/boost/math/tools/detail/rational_horner3_12.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -312,7 +312,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -390,7 +390,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -476,7 +476,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_13.hpp b/boost/math/tools/detail/rational_horner3_13.hpp index 0b4974a501..b0b4c2ac58 100644 --- a/boost/math/tools/detail/rational_horner3_13.hpp +++ b/boost/math/tools/detail/rational_horner3_13.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -312,7 +312,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -390,7 +390,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -476,7 +476,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -570,7 +570,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_14.hpp b/boost/math/tools/detail/rational_horner3_14.hpp index 63f4e95963..92035ef806 100644 --- a/boost/math/tools/detail/rational_horner3_14.hpp +++ b/boost/math/tools/detail/rational_horner3_14.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -312,7 +312,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -390,7 +390,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -476,7 +476,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -570,7 +570,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -672,7 +672,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_15.hpp b/boost/math/tools/detail/rational_horner3_15.hpp index c13500f130..9536ecd844 100644 --- a/boost/math/tools/detail/rational_horner3_15.hpp +++ b/boost/math/tools/detail/rational_horner3_15.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -312,7 +312,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -390,7 +390,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -476,7 +476,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -570,7 +570,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -672,7 +672,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -782,7 +782,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_16.hpp b/boost/math/tools/detail/rational_horner3_16.hpp index b1c89774f8..7ccf8f6e7a 100644 --- a/boost/math/tools/detail/rational_horner3_16.hpp +++ b/boost/math/tools/detail/rational_horner3_16.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -312,7 +312,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -390,7 +390,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -476,7 +476,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -570,7 +570,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -672,7 +672,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -782,7 +782,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -900,7 +900,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_17.hpp b/boost/math/tools/detail/rational_horner3_17.hpp index 9c3498ec24..1a35c47397 100644 --- a/boost/math/tools/detail/rational_horner3_17.hpp +++ b/boost/math/tools/detail/rational_horner3_17.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -312,7 +312,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -390,7 +390,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -476,7 +476,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -570,7 +570,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -672,7 +672,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -782,7 +782,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -900,7 +900,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -1026,7 +1026,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_18.hpp b/boost/math/tools/detail/rational_horner3_18.hpp index 5401e9f3a2..8a1c16eb2f 100644 --- a/boost/math/tools/detail/rational_horner3_18.hpp +++ b/boost/math/tools/detail/rational_horner3_18.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -312,7 +312,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -390,7 +390,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -476,7 +476,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -570,7 +570,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -672,7 +672,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -782,7 +782,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -900,7 +900,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -1026,7 +1026,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -1160,7 +1160,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_19.hpp b/boost/math/tools/detail/rational_horner3_19.hpp index c111b68f1e..15d16bafc3 100644 --- a/boost/math/tools/detail/rational_horner3_19.hpp +++ b/boost/math/tools/detail/rational_horner3_19.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -312,7 +312,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -390,7 +390,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -476,7 +476,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -570,7 +570,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -672,7 +672,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -782,7 +782,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -900,7 +900,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -1026,7 +1026,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -1160,7 +1160,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -1302,7 +1302,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_2.hpp b/boost/math/tools/detail/rational_horner3_2.hpp index 35b5abb354..95ec0251d5 100644 --- a/boost/math/tools/detail/rational_horner3_2.hpp +++ b/boost/math/tools/detail/rational_horner3_2.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } diff --git a/boost/math/tools/detail/rational_horner3_20.hpp b/boost/math/tools/detail/rational_horner3_20.hpp index 7bee9b110a..78233214d8 100644 --- a/boost/math/tools/detail/rational_horner3_20.hpp +++ b/boost/math/tools/detail/rational_horner3_20.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -312,7 +312,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -390,7 +390,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -476,7 +476,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -570,7 +570,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -672,7 +672,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -782,7 +782,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -900,7 +900,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -1026,7 +1026,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -1160,7 +1160,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -1302,7 +1302,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -1452,7 +1452,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<20>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<20>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_3.hpp b/boost/math/tools/detail/rational_horner3_3.hpp index 8838ac13e6..9ce437b41f 100644 --- a/boost/math/tools/detail/rational_horner3_3.hpp +++ b/boost/math/tools/detail/rational_horner3_3.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } diff --git a/boost/math/tools/detail/rational_horner3_4.hpp b/boost/math/tools/detail/rational_horner3_4.hpp index 5fe5ada83b..00543ede85 100644 --- a/boost/math/tools/detail/rational_horner3_4.hpp +++ b/boost/math/tools/detail/rational_horner3_4.hpp @@ -12,31 +12,31 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } diff --git a/boost/math/tools/detail/rational_horner3_5.hpp b/boost/math/tools/detail/rational_horner3_5.hpp index 23a606855b..35dce45a80 100644 --- a/boost/math/tools/detail/rational_horner3_5.hpp +++ b/boost/math/tools/detail/rational_horner3_5.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_6.hpp b/boost/math/tools/detail/rational_horner3_6.hpp index 186167d614..b9361ba07a 100644 --- a/boost/math/tools/detail/rational_horner3_6.hpp +++ b/boost/math/tools/detail/rational_horner3_6.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_7.hpp b/boost/math/tools/detail/rational_horner3_7.hpp index e08dce62d7..92b00b3a15 100644 --- a/boost/math/tools/detail/rational_horner3_7.hpp +++ b/boost/math/tools/detail/rational_horner3_7.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_8.hpp b/boost/math/tools/detail/rational_horner3_8.hpp index 3ceb717439..197b6c0550 100644 --- a/boost/math/tools/detail/rational_horner3_8.hpp +++ b/boost/math/tools/detail/rational_horner3_8.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/detail/rational_horner3_9.hpp b/boost/math/tools/detail/rational_horner3_9.hpp index 94dab4c0db..5aad957c37 100644 --- a/boost/math/tools/detail/rational_horner3_9.hpp +++ b/boost/math/tools/detail/rational_horner3_9.hpp @@ -12,37 +12,37 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ template -inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) +inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(0); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(a[0]) / static_cast(b[0]); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((a[1] * x + a[0]) / (b[1] * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V) { return static_cast(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V) { return static_cast((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0])); } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -80,7 +80,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -126,7 +126,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -180,7 +180,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { @@ -242,7 +242,7 @@ inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl:: } template -inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) +inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V) { if(x <= 1) { diff --git a/boost/math/tools/fraction.hpp b/boost/math/tools/fraction.hpp index b245ddd2a3..a787c603f3 100644 --- a/boost/math/tools/fraction.hpp +++ b/boost/math/tools/fraction.hpp @@ -33,11 +33,11 @@ namespace detail typedef typename Gen::result_type result_type; typedef typename Gen::result_type value_type; - static result_type a(const value_type&) + static result_type a(const value_type&) BOOST_MATH_NOEXCEPT(value_type) { return 1; } - static result_type b(const value_type& v) + static result_type b(const value_type& v) BOOST_MATH_NOEXCEPT(value_type) { return v; } @@ -49,11 +49,11 @@ namespace detail typedef typename Gen::result_type value_type; typedef typename value_type::first_type result_type; - static result_type a(const value_type& v) + static result_type a(const value_type& v) BOOST_MATH_NOEXCEPT(value_type) { return v.first; } - static result_type b(const value_type& v) + static result_type b(const value_type& v) BOOST_MATH_NOEXCEPT(value_type) { return v.second; } @@ -85,7 +85,8 @@ namespace detail // Note that the first a0 returned by generator Gen is disarded. // template -inline typename detail::fraction_traits::result_type continued_fraction_b(Gen& g, const U& factor, boost::uintmax_t& max_terms) +inline typename detail::fraction_traits::result_type continued_fraction_b(Gen& g, const U& factor, boost::uintmax_t& max_terms) + BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename detail::fraction_traits::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING // ADL of std names @@ -126,6 +127,7 @@ inline typename detail::fraction_traits::result_type continued_fraction_b(G template inline typename detail::fraction_traits::result_type continued_fraction_b(Gen& g, const U& factor) + BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename detail::fraction_traits::result_type) && noexcept(std::declval()())) { boost::uintmax_t max_terms = (std::numeric_limits::max)(); return continued_fraction_b(g, factor, max_terms); @@ -133,6 +135,7 @@ inline typename detail::fraction_traits::result_type continued_fraction_b(G template inline typename detail::fraction_traits::result_type continued_fraction_b(Gen& g, int bits) + BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename detail::fraction_traits::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING // ADL of std names @@ -146,6 +149,7 @@ inline typename detail::fraction_traits::result_type continued_fraction_b(G template inline typename detail::fraction_traits::result_type continued_fraction_b(Gen& g, int bits, boost::uintmax_t& max_terms) + BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename detail::fraction_traits::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING // ADL of std names @@ -172,6 +176,7 @@ inline typename detail::fraction_traits::result_type continued_fraction_b(G // template inline typename detail::fraction_traits::result_type continued_fraction_a(Gen& g, const U& factor, boost::uintmax_t& max_terms) + BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename detail::fraction_traits::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING // ADL of std names @@ -213,6 +218,7 @@ inline typename detail::fraction_traits::result_type continued_fraction_a(G template inline typename detail::fraction_traits::result_type continued_fraction_a(Gen& g, const U& factor) + BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename detail::fraction_traits::result_type) && noexcept(std::declval()())) { boost::uintmax_t max_iter = (std::numeric_limits::max)(); return continued_fraction_a(g, factor, max_iter); @@ -220,6 +226,7 @@ inline typename detail::fraction_traits::result_type continued_fraction_a(G template inline typename detail::fraction_traits::result_type continued_fraction_a(Gen& g, int bits) + BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename detail::fraction_traits::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING // ADL of std names @@ -234,6 +241,7 @@ inline typename detail::fraction_traits::result_type continued_fraction_a(G template inline typename detail::fraction_traits::result_type continued_fraction_a(Gen& g, int bits, boost::uintmax_t& max_terms) + BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename detail::fraction_traits::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING // ADL of std names diff --git a/boost/math/tools/minima.hpp b/boost/math/tools/minima.hpp index 3dc5356f3e..b76dabe3f6 100644 --- a/boost/math/tools/minima.hpp +++ b/boost/math/tools/minima.hpp @@ -21,6 +21,7 @@ namespace boost{ namespace math{ namespace tools{ template std::pair brent_find_minima(F f, T min, T max, int bits, boost::uintmax_t& max_iter) + BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) { BOOST_MATH_STD_USING bits = (std::min)(policies::digits >() / 2, bits); @@ -138,6 +139,7 @@ std::pair brent_find_minima(F f, T min, T max, int bits, boost::uintmax_t& template inline std::pair brent_find_minima(F f, T min, T max, int digits) + BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) { boost::uintmax_t m = (std::numeric_limits::max)(); return brent_find_minima(f, min, max, digits, m); diff --git a/boost/math/tools/precision.hpp b/boost/math/tools/precision.hpp index ed146c458f..9631fc2eb6 100644 --- a/boost/math/tools/precision.hpp +++ b/boost/math/tools/precision.hpp @@ -39,7 +39,7 @@ namespace tools // See Conceptual Requirements for Real Number Types. template -inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) +inline BOOST_MATH_CONSTEXPR int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) BOOST_NOEXCEPT { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); @@ -54,7 +54,7 @@ inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) } template -inline T max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); @@ -66,7 +66,7 @@ inline T max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) // -max_value = -1.79769e+308, max_value = 1.79769e+308. template -inline T min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); @@ -86,13 +86,13 @@ namespace detail{ // For type float first: // template -inline T log_max_value(const mpl::int_<128>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T log_max_value(const mpl::int_<128>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T) { return 88.0f; } template -inline T log_min_value(const mpl::int_<128>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T log_min_value(const mpl::int_<128>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T) { return -87.0f; } @@ -100,13 +100,13 @@ inline T log_min_value(const mpl::int_<128>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE // Now double: // template -inline T log_max_value(const mpl::int_<1024>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T log_max_value(const mpl::int_<1024>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T) { return 709.0; } template -inline T log_min_value(const mpl::int_<1024>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T log_min_value(const mpl::int_<1024>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T) { return -708.0; } @@ -114,13 +114,13 @@ inline T log_min_value(const mpl::int_<1024>& BOOST_MATH_APPEND_EXPLICIT_TEMPLAT // 80 and 128-bit long doubles: // template -inline T log_max_value(const mpl::int_<16384>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T log_max_value(const mpl::int_<16384>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T) { return 11356.0L; } template -inline T log_min_value(const mpl::int_<16384>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T log_min_value(const mpl::int_<16384>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T) { return -11355.0L; } @@ -128,17 +128,12 @@ inline T log_min_value(const mpl::int_<16384>& BOOST_MATH_APPEND_EXPLICIT_TEMPLA template inline T log_max_value(const mpl::int_<0>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) { -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); -#else - BOOST_ASSERT(::std::numeric_limits::is_specialized); -#endif BOOST_MATH_STD_USING #ifdef __SUNPRO_CC - static const T m = (std::numeric_limits::max)(); + static const T m = boost::math::tools::max_value(); static const T val = log(m); #else - static const T val = log((std::numeric_limits::max)()); + static const T val = log(boost::math::tools::max_value()); #endif return val; } @@ -146,30 +141,25 @@ inline T log_max_value(const mpl::int_<0>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_T template inline T log_min_value(const mpl::int_<0>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) { -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); -#else - BOOST_ASSERT(::std::numeric_limits::is_specialized); -#endif BOOST_MATH_STD_USING #ifdef __SUNPRO_CC - static const T m = (std::numeric_limits::min)(); + static const T m = boost::math::tools::min_value(); static const T val = log(m); #else - static const T val = log((std::numeric_limits::min)()); + static const T val = log(boost::math::tools::min_value()); #endif return val; } template -inline T epsilon(const mpl::true_& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T epsilon(const mpl::true_& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T) { return std::numeric_limits::epsilon(); } #if defined(__GNUC__) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106)) template <> -inline long double epsilon(const mpl::true_& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(long double)) +inline BOOST_MATH_CONSTEXPR long double epsilon(const mpl::true_& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(long double)) BOOST_MATH_NOEXCEPT(long double) { // numeric_limits on Darwin (and elsewhere) tells lies here: // the issue is that long double on a few platforms is @@ -195,6 +185,27 @@ inline T epsilon(const mpl::false_& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) return eps; } +template +struct log_limit_traits +{ + typedef typename mpl::if_c< + (std::numeric_limits::radix == 2) && + (std::numeric_limits::max_exponent == 128 + || std::numeric_limits::max_exponent == 1024 + || std::numeric_limits::max_exponent == 16384), + mpl::int_<(std::numeric_limits::max_exponent > INT_MAX ? INT_MAX : static_cast(std::numeric_limits::max_exponent))>, + mpl::int_<0> + >::type tag_type; + BOOST_STATIC_CONSTANT(bool, value = tag_type::value ? true : false); + BOOST_STATIC_ASSERT(::std::numeric_limits::is_specialized || (value == 0)); +}; + +template struct log_limit_noexcept_traits_imp : public log_limit_traits {}; +template struct log_limit_noexcept_traits_imp : public boost::integral_constant {}; + +template +struct log_limit_noexcept_traits : public log_limit_noexcept_traits_imp {}; + } // namespace detail #ifdef BOOST_MSVC @@ -203,19 +214,10 @@ inline T epsilon(const mpl::false_& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) #endif template -inline T log_max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T log_max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_NOEXCEPT_IF(detail::log_limit_noexcept_traits::value) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - typedef typename mpl::if_c< - (std::numeric_limits::radix == 2) && - (std::numeric_limits::max_exponent == 128 - || std::numeric_limits::max_exponent == 1024 - || std::numeric_limits::max_exponent == 16384), - mpl::int_<(std::numeric_limits::max_exponent > INT_MAX ? INT_MAX : static_cast(std::numeric_limits::max_exponent))>, - mpl::int_<0> - >::type tag_type; - BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); - return detail::log_max_value(tag_type()); + return detail::log_max_value(typename detail::log_limit_traits::tag_type()); #else BOOST_ASSERT(::std::numeric_limits::is_specialized); BOOST_MATH_STD_USING @@ -225,20 +227,10 @@ inline T log_max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) } template -inline T log_min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) +inline BOOST_MATH_CONSTEXPR T log_min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_NOEXCEPT_IF(detail::log_limit_noexcept_traits::value) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - typedef typename mpl::if_c< - (std::numeric_limits::radix == 2) && - (std::numeric_limits::max_exponent == 128 - || std::numeric_limits::max_exponent == 1024 - || std::numeric_limits::max_exponent == 16384), - mpl::int_<(std::numeric_limits::max_exponent > INT_MAX ? INT_MAX : static_cast(std::numeric_limits::max_exponent))>, - mpl::int_<0> - >::type tag_type; - - BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); - return detail::log_min_value(tag_type()); + return detail::log_min_value(typename detail::log_limit_traits::tag_type()); #else BOOST_ASSERT(::std::numeric_limits::is_specialized); BOOST_MATH_STD_USING @@ -252,7 +244,7 @@ inline T log_min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) #endif template -inline T epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) +inline BOOST_MATH_CONSTEXPR T epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) BOOST_MATH_NOEXCEPT(T) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS return detail::epsilon(mpl::bool_< ::std::numeric_limits::is_specialized>()); @@ -266,25 +258,25 @@ inline T epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) namespace detail{ template -inline T root_epsilon_imp(const mpl::int_<24>&) +inline BOOST_MATH_CONSTEXPR T root_epsilon_imp(const mpl::int_<24>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(0.00034526698300124390839884978618400831996329879769945L); } template -inline T root_epsilon_imp(const T*, const mpl::int_<53>&) +inline BOOST_MATH_CONSTEXPR T root_epsilon_imp(const T*, const mpl::int_<53>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(0.1490116119384765625e-7L); } template -inline T root_epsilon_imp(const T*, const mpl::int_<64>&) +inline BOOST_MATH_CONSTEXPR T root_epsilon_imp(const T*, const mpl::int_<64>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(0.32927225399135962333569506281281311031656150598474e-9L); } template -inline T root_epsilon_imp(const T*, const mpl::int_<113>&) +inline BOOST_MATH_CONSTEXPR T root_epsilon_imp(const T*, const mpl::int_<113>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(0.1387778780781445675529539585113525390625e-16L); } @@ -298,25 +290,25 @@ inline T root_epsilon_imp(const T*, const Tag&) } template -inline T cbrt_epsilon_imp(const mpl::int_<24>&) +inline BOOST_MATH_CONSTEXPR T cbrt_epsilon_imp(const mpl::int_<24>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(0.0049215666011518482998719164346805794944150447839903L); } template -inline T cbrt_epsilon_imp(const T*, const mpl::int_<53>&) +inline BOOST_MATH_CONSTEXPR T cbrt_epsilon_imp(const T*, const mpl::int_<53>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(6.05545445239333906078989272793696693569753008995e-6L); } template -inline T cbrt_epsilon_imp(const T*, const mpl::int_<64>&) +inline BOOST_MATH_CONSTEXPR T cbrt_epsilon_imp(const T*, const mpl::int_<64>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(4.76837158203125e-7L); } template -inline T cbrt_epsilon_imp(const T*, const mpl::int_<113>&) +inline BOOST_MATH_CONSTEXPR T cbrt_epsilon_imp(const T*, const mpl::int_<113>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(5.7749313854154005630396773604745549542403508090496e-12L); } @@ -330,25 +322,25 @@ inline T cbrt_epsilon_imp(const T*, const Tag&) } template -inline T forth_root_epsilon_imp(const T*, const mpl::int_<24>&) +inline BOOST_MATH_CONSTEXPR T forth_root_epsilon_imp(const T*, const mpl::int_<24>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(0.018581361171917516667460937040007436176452688944747L); } template -inline T forth_root_epsilon_imp(const T*, const mpl::int_<53>&) +inline BOOST_MATH_CONSTEXPR T forth_root_epsilon_imp(const T*, const mpl::int_<53>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(0.0001220703125L); } template -inline T forth_root_epsilon_imp(const T*, const mpl::int_<64>&) +inline BOOST_MATH_CONSTEXPR T forth_root_epsilon_imp(const T*, const mpl::int_<64>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(0.18145860519450699870567321328132261891067079047605e-4L); } template -inline T forth_root_epsilon_imp(const T*, const mpl::int_<113>&) +inline BOOST_MATH_CONSTEXPR T forth_root_epsilon_imp(const T*, const mpl::int_<113>&) BOOST_MATH_NOEXCEPT(T) { return static_cast(0.37252902984619140625e-8L); } @@ -361,27 +353,31 @@ inline T forth_root_epsilon_imp(const T*, const Tag&) return r_eps; } +template +struct root_epsilon_traits +{ + typedef mpl::int_< (::std::numeric_limits::radix == 2) ? std::numeric_limits::digits : 0> tag_type; + BOOST_STATIC_CONSTANT(bool, has_noexcept = (tag_type::value == 113) || (tag_type::value == 64) || (tag_type::value == 53) || (tag_type::value == 24)); +}; + } template -inline T root_epsilon() +inline BOOST_MATH_CONSTEXPR T root_epsilon() BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && detail::root_epsilon_traits::has_noexcept) { - typedef mpl::int_< (::std::numeric_limits::radix == 2) ? std::numeric_limits::digits : 0> tag_type; - return detail::root_epsilon_imp(static_cast(0), tag_type()); + return detail::root_epsilon_imp(static_cast(0), typename detail::root_epsilon_traits::tag_type()); } template -inline T cbrt_epsilon() +inline BOOST_MATH_CONSTEXPR T cbrt_epsilon() BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && detail::root_epsilon_traits::has_noexcept) { - typedef mpl::int_< (::std::numeric_limits::radix == 2) ? std::numeric_limits::digits : 0> tag_type; - return detail::cbrt_epsilon_imp(static_cast(0), tag_type()); + return detail::cbrt_epsilon_imp(static_cast(0), typename detail::root_epsilon_traits::tag_type()); } template -inline T forth_root_epsilon() +inline BOOST_MATH_CONSTEXPR T forth_root_epsilon() BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && detail::root_epsilon_traits::has_noexcept) { - typedef mpl::int_< (::std::numeric_limits::radix == 2) ? std::numeric_limits::digits : 0> tag_type; - return detail::forth_root_epsilon_imp(static_cast(0), tag_type()); + return detail::forth_root_epsilon_imp(static_cast(0), typename detail::root_epsilon_traits::tag_type()); } } // namespace tools diff --git a/boost/math/tools/promotion.hpp b/boost/math/tools/promotion.hpp index b3ad204077..494d7f99e2 100644 --- a/boost/math/tools/promotion.hpp +++ b/boost/math/tools/promotion.hpp @@ -86,13 +86,20 @@ namespace boost typedef typename mpl::if_< typename mpl::and_, is_floating_point >::type, // both T1P and T2P are floating-point? - typename mpl::if_< typename mpl::or_, is_same >::type, // either long double? - long double, // then result type is long double. - typename mpl::if_< typename mpl::or_, is_same >::type, // either double? - double, // result type is double. - float // else result type is float. - >::type - >::type, +#ifdef BOOST_MATH_USE_FLOAT128 + typename mpl::if_< typename mpl::or_, is_same<__float128, T2P> >::type, // either long double? + __float128, +#endif + typename mpl::if_< typename mpl::or_, is_same >::type, // either long double? + long double, // then result type is long double. + typename mpl::if_< typename mpl::or_, is_same >::type, // either double? + double, // result type is double. + float // else result type is float. + >::type +#ifdef BOOST_MATH_USE_FLOAT128 + >::type +#endif + >::type, // else one or the other is a user-defined type: typename mpl::if_< typename mpl::and_ >, ::boost::is_convertible >, T2P, T1P>::type>::type type; }; // promote_arg2 diff --git a/boost/math/tools/rational.hpp b/boost/math/tools/rational.hpp index accffeaf26..d8bd4a73aa 100644 --- a/boost/math/tools/rational.hpp +++ b/boost/math/tools/rational.hpp @@ -168,12 +168,12 @@ namespace boost{ namespace math{ namespace tools{ // Forward declaration to keep two phase lookup happy: // template -U evaluate_polynomial(const T* poly, U const& z, std::size_t count); +U evaluate_polynomial(const T* poly, U const& z, std::size_t count) BOOST_MATH_NOEXCEPT(U); namespace detail{ template -inline V evaluate_polynomial_c_imp(const T* a, const V& val, const Tag*) +inline V evaluate_polynomial_c_imp(const T* a, const V& val, const Tag*) BOOST_MATH_NOEXCEPT(V) { return evaluate_polynomial(a, val, Tag::value); } @@ -186,7 +186,7 @@ inline V evaluate_polynomial_c_imp(const T* a, const V& val, const Tag*) // the loop expanded versions above: // template -inline U evaluate_polynomial(const T* poly, U const& z, std::size_t count) +inline U evaluate_polynomial(const T* poly, U const& z, std::size_t count) BOOST_MATH_NOEXCEPT(U) { BOOST_ASSERT(count > 0); U sum = static_cast(poly[count - 1]); @@ -202,14 +202,14 @@ inline U evaluate_polynomial(const T* poly, U const& z, std::size_t count) // implementations above: // template -inline V evaluate_polynomial(const T(&a)[N], const V& val) +inline V evaluate_polynomial(const T(&a)[N], const V& val) BOOST_MATH_NOEXCEPT(V) { typedef mpl::int_ tag_type; return detail::evaluate_polynomial_c_imp(static_cast(a), val, static_cast(0)); } template -inline V evaluate_polynomial(const boost::array& a, const V& val) +inline V evaluate_polynomial(const boost::array& a, const V& val) BOOST_MATH_NOEXCEPT(V) { typedef mpl::int_ tag_type; return detail::evaluate_polynomial_c_imp(static_cast(a.data()), val, static_cast(0)); @@ -218,19 +218,19 @@ inline V evaluate_polynomial(const boost::array& a, const V& val) // Even polynomials are trivial: just square the argument! // template -inline U evaluate_even_polynomial(const T* poly, U z, std::size_t count) +inline U evaluate_even_polynomial(const T* poly, U z, std::size_t count) BOOST_MATH_NOEXCEPT(U) { return evaluate_polynomial(poly, U(z*z), count); } template -inline V evaluate_even_polynomial(const T(&a)[N], const V& z) +inline V evaluate_even_polynomial(const T(&a)[N], const V& z) BOOST_MATH_NOEXCEPT(V) { return evaluate_polynomial(a, V(z*z)); } template -inline V evaluate_even_polynomial(const boost::array& a, const V& z) +inline V evaluate_even_polynomial(const boost::array& a, const V& z) BOOST_MATH_NOEXCEPT(V) { return evaluate_polynomial(a, V(z*z)); } @@ -238,32 +238,32 @@ inline V evaluate_even_polynomial(const boost::array& a, const V& z) // Odd polynomials come next: // template -inline U evaluate_odd_polynomial(const T* poly, U z, std::size_t count) +inline U evaluate_odd_polynomial(const T* poly, U z, std::size_t count) BOOST_MATH_NOEXCEPT(U) { return poly[0] + z * evaluate_polynomial(poly+1, U(z*z), count-1); } template -inline V evaluate_odd_polynomial(const T(&a)[N], const V& z) +inline V evaluate_odd_polynomial(const T(&a)[N], const V& z) BOOST_MATH_NOEXCEPT(V) { typedef mpl::int_ tag_type; return a[0] + z * detail::evaluate_polynomial_c_imp(static_cast(a) + 1, V(z*z), static_cast(0)); } template -inline V evaluate_odd_polynomial(const boost::array& a, const V& z) +inline V evaluate_odd_polynomial(const boost::array& a, const V& z) BOOST_MATH_NOEXCEPT(V) { typedef mpl::int_ tag_type; return a[0] + z * detail::evaluate_polynomial_c_imp(static_cast(a.data()) + 1, V(z*z), static_cast(0)); } template -V evaluate_rational(const T* num, const U* denom, const V& z_, std::size_t count); +V evaluate_rational(const T* num, const U* denom, const V& z_, std::size_t count) BOOST_MATH_NOEXCEPT(V); namespace detail{ template -inline V evaluate_rational_c_imp(const T* num, const U* denom, const V& z, const Tag*) +inline V evaluate_rational_c_imp(const T* num, const U* denom, const V& z, const Tag*) BOOST_MATH_NOEXCEPT(V) { return boost::math::tools::evaluate_rational(num, denom, z, Tag::value); } @@ -278,7 +278,7 @@ inline V evaluate_rational_c_imp(const T* num, const U* denom, const V& z, const // in our Lanczos code for example. // template -V evaluate_rational(const T* num, const U* denom, const V& z_, std::size_t count) +V evaluate_rational(const T* num, const U* denom, const V& z_, std::size_t count) BOOST_MATH_NOEXCEPT(V) { V z(z_); V s1, s2; @@ -311,13 +311,13 @@ V evaluate_rational(const T* num, const U* denom, const V& z_, std::size_t count } template -inline V evaluate_rational(const T(&a)[N], const U(&b)[N], const V& z) +inline V evaluate_rational(const T(&a)[N], const U(&b)[N], const V& z) BOOST_MATH_NOEXCEPT(V) { return detail::evaluate_rational_c_imp(a, b, z, static_cast*>(0)); } template -inline V evaluate_rational(const boost::array& a, const boost::array& b, const V& z) +inline V evaluate_rational(const boost::array& a, const boost::array& b, const V& z) BOOST_MATH_NOEXCEPT(V) { return detail::evaluate_rational_c_imp(a.data(), b.data(), z, static_cast*>(0)); } diff --git a/boost/math/tools/real_cast.hpp b/boost/math/tools/real_cast.hpp index 9b854e3014..873e60259b 100644 --- a/boost/math/tools/real_cast.hpp +++ b/boost/math/tools/real_cast.hpp @@ -6,6 +6,8 @@ #ifndef BOOST_MATH_TOOLS_REAL_CAST_HPP #define BOOST_MATH_TOOLS_REAL_CAST_HPP +#include + #ifdef _MSC_VER #pragma once #endif @@ -15,7 +17,7 @@ namespace boost{ namespace math namespace tools { template - inline To real_cast(T t) + inline BOOST_MATH_CONSTEXPR To real_cast(T t) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && BOOST_MATH_IS_FLOAT(To)) { return static_cast(t); } diff --git a/boost/math/tools/roots.hpp b/boost/math/tools/roots.hpp index 2442f5c2d1..25300fee38 100644 --- a/boost/math/tools/roots.hpp +++ b/boost/math/tools/roots.hpp @@ -36,9 +36,49 @@ namespace boost{ namespace math{ namespace tools{ namespace detail{ +namespace dummy{ + + template + typename T::value_type get(const T&) BOOST_MATH_NOEXCEPT(T); +} + +template +void unpack_tuple(const Tuple& t, T& a, T& b) BOOST_MATH_NOEXCEPT(T) +{ + using dummy::get; + // Use ADL to find the right overload for get: + a = get<0>(t); + b = get<1>(t); +} template -inline void unpack_0(const Tuple& t, T& val) -{ val = boost::math::get<0>(t); } +void unpack_tuple(const Tuple& t, T& a, T& b, T& c) BOOST_MATH_NOEXCEPT(T) +{ + using dummy::get; + // Use ADL to find the right overload for get: + a = get<0>(t); + b = get<1>(t); + c = get<2>(t); +} + +template +inline void unpack_0(const Tuple& t, T& val) BOOST_MATH_NOEXCEPT(T) +{ + using dummy::get; + // Rely on ADL to find the correct overload of get: + val = get<0>(t); +} + +template +inline void unpack_tuple(const std::pair& p, V& a, V& b) BOOST_MATH_NOEXCEPT(T) +{ + a = p.first; + b = p.second; +} +template +inline void unpack_0(const std::pair& p, V& a) BOOST_MATH_NOEXCEPT(T) +{ + a = p.first; +} template void handle_zero_derivative(F f, @@ -48,7 +88,7 @@ void handle_zero_derivative(F f, T& result, T& guess, const T& min, - const T& max) + const T& max) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) { if(last_f0 == 0) { @@ -94,14 +134,20 @@ void handle_zero_derivative(F f, } // namespace template -std::pair bisect(F f, T min, T max, Tol tol, boost::uintmax_t& max_iter, const Policy& pol) +std::pair bisect(F f, T min, T max, Tol tol, boost::uintmax_t& max_iter, const Policy& pol) BOOST_NOEXCEPT_IF(policies::is_noexcept_error_policy::value && BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) { T fmin = f(min); T fmax = f(max); if(fmin == 0) + { + max_iter = 2; return std::make_pair(min, min); + } if(fmax == 0) + { + max_iter = 2; return std::make_pair(max, max); + } // // Error checking: @@ -168,20 +214,21 @@ std::pair bisect(F f, T min, T max, Tol tol, boost::uintmax_t& max_iter, c } template -inline std::pair bisect(F f, T min, T max, Tol tol, boost::uintmax_t& max_iter) +inline std::pair bisect(F f, T min, T max, Tol tol, boost::uintmax_t& max_iter) BOOST_NOEXCEPT_IF(policies::is_noexcept_error_policy >::value && BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) { return bisect(f, min, max, tol, max_iter, policies::policy<>()); } template -inline std::pair bisect(F f, T min, T max, Tol tol) +inline std::pair bisect(F f, T min, T max, Tol tol) BOOST_NOEXCEPT_IF(policies::is_noexcept_error_policy >::value && BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) { boost::uintmax_t m = (std::numeric_limits::max)(); return bisect(f, min, max, tol, m, policies::policy<>()); } + template -T newton_raphson_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_t& max_iter) +T newton_raphson_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_t& max_iter) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) { BOOST_MATH_STD_USING @@ -189,7 +236,7 @@ T newton_raphson_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_ T result = guess; T factor = static_cast(ldexp(1.0, 1 - digits)); - T delta = 1; + T delta = tools::max_value(); T delta1 = tools::max_value(); T delta2 = tools::max_value(); @@ -199,7 +246,8 @@ T newton_raphson_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_ last_f0 = f0; delta2 = delta1; delta1 = delta; - boost::math::tie(f0, f1) = f(result); + detail::unpack_tuple(f(result), f0, f1); + --count; if(0 == f0) break; if(f1 == 0) @@ -243,7 +291,7 @@ T newton_raphson_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_ max = guess; else min = guess; - }while(--count && (fabs(result * factor) < fabs(delta))); + }while(count && (fabs(result * factor) < fabs(delta))); max_iter -= count; @@ -262,213 +310,208 @@ T newton_raphson_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_ } template -inline T newton_raphson_iterate(F f, T guess, T min, T max, int digits) +inline T newton_raphson_iterate(F f, T guess, T min, T max, int digits) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) { boost::uintmax_t m = (std::numeric_limits::max)(); return newton_raphson_iterate(f, guess, min, max, digits, m); } -template -T halley_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_t& max_iter) -{ - BOOST_MATH_STD_USING +namespace detail{ - T f0(0), f1, f2; - T result = guess; + struct halley_step + { + template + static T step(const T& /*x*/, const T& f0, const T& f1, const T& f2) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T)) + { + using std::fabs; + T denom = 2 * f0; + T num = 2 * f1 - f0 * (f2 / f1); + T delta; - T factor = static_cast(ldexp(1.0, 1 - digits)); - T delta = (std::max)(T(10000000 * guess), T(10000000)); // arbitarily large delta - T last_f0 = 0; - T delta1 = delta; - T delta2 = delta; + BOOST_MATH_INSTRUMENT_VARIABLE(denom); + BOOST_MATH_INSTRUMENT_VARIABLE(num); - bool out_of_bounds_sentry = false; + if((fabs(num) < 1) && (fabs(denom) >= fabs(num) * tools::max_value())) + { + // possible overflow, use Newton step: + delta = f0 / f1; + } + else + delta = denom / num; + return delta; + } + }; + + template + T second_order_root_finder(F f, T guess, T min, T max, int digits, boost::uintmax_t& max_iter) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) + { + BOOST_MATH_STD_USING + + T f0(0), f1, f2; + T result = guess; + + T factor = static_cast(ldexp(1.0, 1 - digits)); + T delta = (std::max)(T(10000000 * guess), T(10000000)); // arbitarily large delta + T last_f0 = 0; + T delta1 = delta; + T delta2 = delta; + + bool out_of_bounds_sentry = false; #ifdef BOOST_MATH_INSTRUMENT - std::cout << "Halley iteration, limit = " << factor << std::endl; + std::cout << "Second order root iteration, limit = " << factor << std::endl; #endif - boost::uintmax_t count(max_iter); + boost::uintmax_t count(max_iter); - do{ - last_f0 = f0; - delta2 = delta1; - delta1 = delta; - boost::math::tie(f0, f1, f2) = f(result); + do{ + last_f0 = f0; + delta2 = delta1; + delta1 = delta; + detail::unpack_tuple(f(result), f0, f1, f2); + --count; - BOOST_MATH_INSTRUMENT_VARIABLE(f0); - BOOST_MATH_INSTRUMENT_VARIABLE(f1); - BOOST_MATH_INSTRUMENT_VARIABLE(f2); - - if(0 == f0) - break; - if(f1 == 0) - { - // Oops zero derivative!!! + BOOST_MATH_INSTRUMENT_VARIABLE(f0); + BOOST_MATH_INSTRUMENT_VARIABLE(f1); + BOOST_MATH_INSTRUMENT_VARIABLE(f2); + + if(0 == f0) + break; + if(f1 == 0) + { + // Oops zero derivative!!! #ifdef BOOST_MATH_INSTRUMENT - std::cout << "Halley iteration, zero derivative found" << std::endl; + std::cout << "Second order root iteration, zero derivative found" << std::endl; #endif - detail::handle_zero_derivative(f, last_f0, f0, delta, result, guess, min, max); - } - else - { - if(f2 != 0) + detail::handle_zero_derivative(f, last_f0, f0, delta, result, guess, min, max); + } + else { - T denom = 2 * f0; - T num = 2 * f1 - f0 * (f2 / f1); - - BOOST_MATH_INSTRUMENT_VARIABLE(denom); - BOOST_MATH_INSTRUMENT_VARIABLE(num); - - if((fabs(num) < 1) && (fabs(denom) >= fabs(num) * tools::max_value())) + if(f2 != 0) { - // possible overflow, use Newton step: - delta = f0 / f1; + delta = Stepper::step(result, f0, f1, f2); + if(delta * f1 / f0 < 0) + { + // Oh dear, we have a problem as Newton and Halley steps + // disagree about which way we should move. Probably + // there is cancelation error in the calculation of the + // Halley step, or else the derivatives are so small + // that their values are basically trash. We will move + // in the direction indicated by a Newton step, but + // by no more than twice the current guess value, otherwise + // we can jump way out of bounds if we're not careful. + // See https://svn.boost.org/trac/boost/ticket/8314. + delta = f0 / f1; + if(fabs(delta) > 2 * fabs(guess)) + delta = (delta < 0 ? -1 : 1) * 2 * fabs(guess); + } } else - delta = denom / num; - if(delta * f1 / f0 < 0) - { - // Oh dear, we have a problem as Newton and Halley steps - // disagree about which way we should move. Probably - // there is cancelation error in the calculation of the - // Halley step, or else the derivatives are so small - // that their values are basically trash. We will move - // in the direction indicated by a Newton step, but - // by no more than twice the current guess value, otherwise - // we can jump way out of bounds if we're not careful. - // See https://svn.boost.org/trac/boost/ticket/8314. delta = f0 / f1; - if(fabs(delta) > 2 * fabs(guess)) - delta = (delta < 0 ? -1 : 1) * 2 * fabs(guess); - } } - else - delta = f0 / f1; - } #ifdef BOOST_MATH_INSTRUMENT - std::cout << "Halley iteration, delta = " << delta << std::endl; + std::cout << "Second order root iteration, delta = " << delta << std::endl; #endif - T convergence = fabs(delta / delta2); - if((convergence > 0.8) && (convergence < 2)) - { - // last two steps haven't converged, try bisection: - delta = (delta > 0) ? (result - min) / 2 : (result - max) / 2; - if(fabs(delta) > result) - delta = sign(delta) * result; // protect against huge jumps! - // reset delta2 so that this branch will *not* be taken on the - // next iteration: - delta2 = delta * 3; - BOOST_MATH_INSTRUMENT_VARIABLE(delta); - } - guess = result; - result -= delta; - BOOST_MATH_INSTRUMENT_VARIABLE(result); - - // check for out of bounds step: - if(result < min) - { - T diff = ((fabs(min) < 1) && (fabs(result) > 1) && (tools::max_value() / fabs(result) < fabs(min))) ? T(1000) : T(result / min); - if(fabs(diff) < 1) - diff = 1 / diff; - if(!out_of_bounds_sentry && (diff > 0) && (diff < 3)) + T convergence = fabs(delta / delta2); + if((convergence > 0.8) && (convergence < 2)) { - // Only a small out of bounds step, lets assume that the result - // is probably approximately at min: - delta = 0.99f * (guess - min); - result = guess - delta; - out_of_bounds_sentry = true; // only take this branch once! + // last two steps haven't converged, try bisection: + delta = (delta > 0) ? (result - min) / 2 : (result - max) / 2; + if(fabs(delta) > result) + delta = sign(delta) * result; // protect against huge jumps! + // reset delta2 so that this branch will *not* be taken on the + // next iteration: + delta2 = delta * 3; + BOOST_MATH_INSTRUMENT_VARIABLE(delta); } - else + guess = result; + result -= delta; + BOOST_MATH_INSTRUMENT_VARIABLE(result); + + // check for out of bounds step: + if(result < min) { - delta = (guess - min) / 2; - result = guess - delta; - if((result == min) || (result == max)) - break; + T diff = ((fabs(min) < 1) && (fabs(result) > 1) && (tools::max_value() / fabs(result) < fabs(min))) ? T(1000) : T(result / min); + if(fabs(diff) < 1) + diff = 1 / diff; + if(!out_of_bounds_sentry && (diff > 0) && (diff < 3)) + { + // Only a small out of bounds step, lets assume that the result + // is probably approximately at min: + delta = 0.99f * (guess - min); + result = guess - delta; + out_of_bounds_sentry = true; // only take this branch once! + } + else + { + delta = (guess - min) / 2; + result = guess - delta; + if((result == min) || (result == max)) + break; + } } - } - else if(result > max) - { - T diff = ((fabs(max) < 1) && (fabs(result) > 1) && (tools::max_value() / fabs(result) < fabs(max))) ? T(1000) : T(result / max); - if(fabs(diff) < 1) - diff = 1 / diff; - if(!out_of_bounds_sentry && (diff > 0) && (diff < 3)) + else if(result > max) { - // Only a small out of bounds step, lets assume that the result - // is probably approximately at min: - delta = 0.99f * (guess - max); - result = guess - delta; - out_of_bounds_sentry = true; // only take this branch once! + T diff = ((fabs(max) < 1) && (fabs(result) > 1) && (tools::max_value() / fabs(result) < fabs(max))) ? T(1000) : T(result / max); + if(fabs(diff) < 1) + diff = 1 / diff; + if(!out_of_bounds_sentry && (diff > 0) && (diff < 3)) + { + // Only a small out of bounds step, lets assume that the result + // is probably approximately at min: + delta = 0.99f * (guess - max); + result = guess - delta; + out_of_bounds_sentry = true; // only take this branch once! + } + else + { + delta = (guess - max) / 2; + result = guess - delta; + if((result == min) || (result == max)) + break; + } } + // update brackets: + if(delta > 0) + max = guess; else - { - delta = (guess - max) / 2; - result = guess - delta; - if((result == min) || (result == max)) - break; - } - } - // update brackets: - if(delta > 0) - max = guess; - else - min = guess; - }while(--count && (fabs(result * factor) < fabs(delta))); + min = guess; + } while(count && (fabs(result * factor) < fabs(delta))); - max_iter -= count; + max_iter -= count; #ifdef BOOST_MATH_INSTRUMENT - std::cout << "Halley iteration, final count = " << max_iter << std::endl; + std::cout << "Second order root iteration, final count = " << max_iter << std::endl; #endif - return result; + return result; + } + } template -inline T halley_iterate(F f, T guess, T min, T max, int digits) +T halley_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_t& max_iter) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) { - boost::uintmax_t m = (std::numeric_limits::max)(); - return halley_iterate(f, guess, min, max, digits, m); + return detail::second_order_root_finder(f, guess, min, max, digits, max_iter); } template -T schroeder_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_t& max_iter) +inline T halley_iterate(F f, T guess, T min, T max, int digits) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) { - BOOST_MATH_STD_USING - - T f0(0), f1, f2, last_f0(0); - T result = guess; - - T factor = static_cast(ldexp(1.0, 1 - digits)); - T delta = 0; - T delta1 = tools::max_value(); - T delta2 = tools::max_value(); - -#ifdef BOOST_MATH_INSTRUMENT - std::cout << "Schroeder iteration, limit = " << factor << std::endl; -#endif + boost::uintmax_t m = (std::numeric_limits::max)(); + return halley_iterate(f, guess, min, max, digits, m); +} - boost::uintmax_t count(max_iter); +namespace detail{ - do{ - last_f0 = f0; - delta2 = delta1; - delta1 = delta; - boost::math::tie(f0, f1, f2) = f(result); - if(0 == f0) - break; - if((f1 == 0) && (f2 == 0)) - { - // Oops zero derivative!!! -#ifdef BOOST_MATH_INSTRUMENT - std::cout << "Halley iteration, zero derivative found" << std::endl; -#endif - detail::handle_zero_derivative(f, last_f0, f0, delta, result, guess, min, max); - } - else + struct schroder_stepper + { + template + static T step(const T& x, const T& f0, const T& f1, const T& f2) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T)) { T ratio = f0 / f1; - if(ratio / result < 0.1) + T delta; + if(ratio / x < 0.1) { delta = ratio + (f2 / (2 * f1)) * ratio * ratio; // check second derivative doesn't over compensate: @@ -477,66 +520,44 @@ T schroeder_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_t& ma } else delta = ratio; // fall back to Newton iteration. + return delta; } - if(fabs(delta * 2) > fabs(delta2)) - { - // last two steps haven't converged, try bisection: - delta = (delta > 0) ? (result - min) / 2 : (result - max) / 2; - } - guess = result; - result -= delta; -#ifdef BOOST_MATH_INSTRUMENT - std::cout << "Halley iteration, delta = " << delta << std::endl; -#endif - if(result <= min) - { - delta = 0.5F * (guess - min); - result = guess - delta; - if((result == min) || (result == max)) - break; - } - else if(result >= max) - { - delta = 0.5F * (guess - max); - result = guess - delta; - if((result == min) || (result == max)) - break; - } - // update brackets: - if(delta > 0) - max = guess; - else - min = guess; - }while(--count && (fabs(result * factor) < fabs(delta))); - - max_iter -= count; + }; -#ifdef BOOST_MATH_INSTRUMENT - std::cout << "Schroeder iteration, final count = " << max_iter << std::endl; +} - static boost::uintmax_t max_count = 0; - if(max_iter > max_count) - { - max_count = max_iter; - std::cout << "Maximum iterations: " << max_iter << std::endl; - } -#endif +template +T schroder_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_t& max_iter) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) +{ + return detail::second_order_root_finder(f, guess, min, max, digits, max_iter); +} - return result; +template +inline T schroder_iterate(F f, T guess, T min, T max, int digits) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) +{ + boost::uintmax_t m = (std::numeric_limits::max)(); + return schroder_iterate(f, guess, min, max, digits, m); +} +// +// These two are the old spelling of this function, retained for backwards compatibity just in case: +// +template +T schroeder_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_t& max_iter) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) +{ + return detail::second_order_root_finder(f, guess, min, max, digits, max_iter); } template -inline T schroeder_iterate(F f, T guess, T min, T max, int digits) +inline T schroeder_iterate(F f, T guess, T min, T max, int digits) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval()(std::declval()))) { boost::uintmax_t m = (std::numeric_limits::max)(); - return schroeder_iterate(f, guess, min, max, digits, m); + return schroder_iterate(f, guess, min, max, digits, m); } + } // namespace tools } // namespace math } // namespace boost #endif // BOOST_MATH_TOOLS_NEWTON_SOLVER_HPP - - diff --git a/boost/math/tools/series.hpp b/boost/math/tools/series.hpp index a32a33fba1..ab01549a2d 100644 --- a/boost/math/tools/series.hpp +++ b/boost/math/tools/series.hpp @@ -21,7 +21,7 @@ namespace boost{ namespace math{ namespace tools{ // Simple series summation come first: // template -inline typename Functor::result_type sum_series(Functor& func, const U& factor, boost::uintmax_t& max_terms, const V& init_value) +inline typename Functor::result_type sum_series(Functor& func, const U& factor, boost::uintmax_t& max_terms, const V& init_value) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename Functor::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING @@ -44,14 +44,14 @@ inline typename Functor::result_type sum_series(Functor& func, const U& factor, } template -inline typename Functor::result_type sum_series(Functor& func, const U& factor, boost::uintmax_t& max_terms) +inline typename Functor::result_type sum_series(Functor& func, const U& factor, boost::uintmax_t& max_terms) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename Functor::result_type) && noexcept(std::declval()())) { typename Functor::result_type init_value = 0; return sum_series(func, factor, max_terms, init_value); } template -inline typename Functor::result_type sum_series(Functor& func, int bits, boost::uintmax_t& max_terms, const U& init_value) +inline typename Functor::result_type sum_series(Functor& func, int bits, boost::uintmax_t& max_terms, const U& init_value) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename Functor::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING typedef typename Functor::result_type result_type; @@ -60,7 +60,7 @@ inline typename Functor::result_type sum_series(Functor& func, int bits, boost:: } template -inline typename Functor::result_type sum_series(Functor& func, int bits) +inline typename Functor::result_type sum_series(Functor& func, int bits) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename Functor::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING typedef typename Functor::result_type result_type; @@ -70,7 +70,7 @@ inline typename Functor::result_type sum_series(Functor& func, int bits) } template -inline typename Functor::result_type sum_series(Functor& func, int bits, boost::uintmax_t& max_terms) +inline typename Functor::result_type sum_series(Functor& func, int bits, boost::uintmax_t& max_terms) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename Functor::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING typedef typename Functor::result_type result_type; @@ -79,7 +79,7 @@ inline typename Functor::result_type sum_series(Functor& func, int bits, boost:: } template -inline typename Functor::result_type sum_series(Functor& func, int bits, const U& init_value) +inline typename Functor::result_type sum_series(Functor& func, int bits, const U& init_value) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename Functor::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING boost::uintmax_t iters = (std::numeric_limits::max)(); @@ -99,7 +99,7 @@ inline typename Functor::result_type sum_series(Functor& func, int bits, const U // in any case the result is still much better than a naive summation. // template -inline typename Functor::result_type kahan_sum_series(Functor& func, int bits) +inline typename Functor::result_type kahan_sum_series(Functor& func, int bits) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename Functor::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING @@ -122,7 +122,7 @@ inline typename Functor::result_type kahan_sum_series(Functor& func, int bits) } template -inline typename Functor::result_type kahan_sum_series(Functor& func, int bits, boost::uintmax_t& max_terms) +inline typename Functor::result_type kahan_sum_series(Functor& func, int bits, boost::uintmax_t& max_terms) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(typename Functor::result_type) && noexcept(std::declval()())) { BOOST_MATH_STD_USING diff --git a/boost/math/tools/toms748_solve.hpp b/boost/math/tools/toms748_solve.hpp index 48737a821a..dca6bf0218 100644 --- a/boost/math/tools/toms748_solve.hpp +++ b/boost/math/tools/toms748_solve.hpp @@ -31,6 +31,10 @@ template class eps_tolerance { public: + eps_tolerance() + { + eps = 4 * tools::epsilon(); + } eps_tolerance(unsigned bits) { BOOST_MATH_STD_USING @@ -108,7 +112,7 @@ void bracket(F f, T& a, T& b, T c, T& fa, T& fb, T& d, T& fd) } else if(c >= b - fabs(b) * tol) { - c = b - fabs(a) * tol; + c = b - fabs(b) * tol; } // // OK, lets invoke f(c): diff --git a/boost/math/tools/traits.hpp b/boost/math/tools/traits.hpp index c49bf19b86..385388a5e3 100644 --- a/boost/math/tools/traits.hpp +++ b/boost/math/tools/traits.hpp @@ -26,8 +26,7 @@ as defined above, and has member functions "scale" and "location". #endif #include -// should be the last #include -#include +#include namespace boost{ namespace math{ namespace tools{ @@ -101,8 +100,8 @@ struct is_scaled_distribution_imp } // namespace detail -BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_distribution,T,::boost::math::tools::detail::is_distribution_imp::value) -BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_scaled_distribution,T,::boost::math::tools::detail::is_scaled_distribution_imp::value) +template struct is_distribution : public boost::integral_constant::value> {}; +template struct is_scaled_distribution : public boost::integral_constant::value> {}; }}} diff --git a/boost/math/tools/workaround.hpp b/boost/math/tools/workaround.hpp index 20106814c7..29ce8b1c04 100644 --- a/boost/math/tools/workaround.hpp +++ b/boost/math/tools/workaround.hpp @@ -19,14 +19,14 @@ namespace boost{ namespace math{ namespace tools{ // std::fmod(1185.0L, 1.5L); // template -inline T fmod_workaround(T a, T b) +inline T fmod_workaround(T a, T b) BOOST_MATH_NOEXCEPT(T) { BOOST_MATH_STD_USING return fmod(a, b); } #if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106)) template <> -inline long double fmod_workaround(long double a, long double b) +inline long double fmod_workaround(long double a, long double b) BOOST_NOEXCEPT { return ::fmodl(a, b); } diff --git a/boost/math/tr1.hpp b/boost/math/tr1.hpp index df8ab0ef47..eae9216d04 100644 --- a/boost/math/tr1.hpp +++ b/boost/math/tr1.hpp @@ -105,7 +105,10 @@ namespace boost{ namespace math{ namespace tr1{ extern "C"{ #endif #if !(defined(BOOST_INTEL) && defined(__APPLE__)) && !(defined(__FLT_EVAL_METHOD__) && !defined(__cplusplus)) -#ifndef FLT_EVAL_METHOD +#if !defined(FLT_EVAL_METHOD) +typedef float float_t; +typedef double double_t; +#elif FLT_EVAL_METHOD == -1 typedef float float_t; typedef double double_t; #elif FLT_EVAL_METHOD == 0 diff --git a/boost/move/core.hpp b/boost/move/core.hpp index 55486e6b45..54aece0b71 100644 --- a/boost/move/core.hpp +++ b/boost/move/core.hpp @@ -27,6 +27,8 @@ #include #include +// @cond + //boost_move_no_copy_constructor_or_assign typedef //used to detect noncopyable types for other Boost libraries. #if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) @@ -49,6 +51,8 @@ // #endif //BOOST_NO_CXX11_DELETED_FUNCTIONS +// @endcond + #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) #include diff --git a/boost/move/default_delete.hpp b/boost/move/default_delete.hpp index afe1b1bb63..1c26ed924b 100644 --- a/boost/move/default_delete.hpp +++ b/boost/move/default_delete.hpp @@ -31,6 +31,7 @@ //! Describes the default deleter (destruction policy) of unique_ptr: default_delete. namespace boost{ +// @cond namespace move_upd { namespace bmupmu = ::boost::move_upmu; @@ -96,6 +97,7 @@ typedef int bool_conversion::* explicit_bool_arg; #endif } //namespace move_upd { +// @endcond namespace movelib { @@ -123,7 +125,11 @@ struct default_delete #endif #if defined(BOOST_MOVE_DOXYGEN_INVOKED) + //! Trivial copy constructor + //! default_delete(const default_delete&) BOOST_NOEXCEPT = default; + //! Trivial assignment + //! default_delete &operator=(const default_delete&) BOOST_NOEXCEPT = default; #else typedef typename bmupmu::remove_extent::type element_type; diff --git a/boost/move/detail/fwd_macros.hpp b/boost/move/detail/fwd_macros.hpp index 8d5ab2e9b9..e091890dc5 100644 --- a/boost/move/detail/fwd_macros.hpp +++ b/boost/move/detail/fwd_macros.hpp @@ -65,7 +65,7 @@ namespace move_detail { //BOOST_MOVE_REPEATN(MACRO) #define BOOST_MOVE_REPEAT0(MACRO) -#define BOOST_MOVE_REPEAT1(MACRO) MACRO +#define BOOST_MOVE_REPEAT1(MACRO) MACRO #define BOOST_MOVE_REPEAT2(MACRO) BOOST_MOVE_REPEAT1(MACRO), MACRO #define BOOST_MOVE_REPEAT3(MACRO) BOOST_MOVE_REPEAT2(MACRO), MACRO #define BOOST_MOVE_REPEAT4(MACRO) BOOST_MOVE_REPEAT3(MACRO), MACRO @@ -77,7 +77,7 @@ namespace move_detail { //BOOST_MOVE_FWDN #define BOOST_MOVE_FWD0 -#define BOOST_MOVE_FWD1 ::boost::forward(p0) +#define BOOST_MOVE_FWD1 ::boost::forward(p0) #define BOOST_MOVE_FWD2 BOOST_MOVE_FWD1, ::boost::forward(p1) #define BOOST_MOVE_FWD3 BOOST_MOVE_FWD2, ::boost::forward(p2) #define BOOST_MOVE_FWD4 BOOST_MOVE_FWD3, ::boost::forward(p3) @@ -89,7 +89,7 @@ namespace move_detail { //BOOST_MOVE_FWDQN #define BOOST_MOVE_FWDQ0 -#define BOOST_MOVE_FWDQ1 ::boost::forward(q0) +#define BOOST_MOVE_FWDQ1 ::boost::forward(q0) #define BOOST_MOVE_FWDQ2 BOOST_MOVE_FWDQ1, ::boost::forward(q1) #define BOOST_MOVE_FWDQ3 BOOST_MOVE_FWDQ2, ::boost::forward(q2) #define BOOST_MOVE_FWDQ4 BOOST_MOVE_FWDQ3, ::boost::forward(q3) @@ -101,7 +101,7 @@ namespace move_detail { //BOOST_MOVE_ARGN #define BOOST_MOVE_ARG0 -#define BOOST_MOVE_ARG1 p0 +#define BOOST_MOVE_ARG1 p0 #define BOOST_MOVE_ARG2 BOOST_MOVE_ARG1, p1 #define BOOST_MOVE_ARG3 BOOST_MOVE_ARG2, p2 #define BOOST_MOVE_ARG4 BOOST_MOVE_ARG3, p3 @@ -111,9 +111,21 @@ namespace move_detail { #define BOOST_MOVE_ARG8 BOOST_MOVE_ARG7, p7 #define BOOST_MOVE_ARG9 BOOST_MOVE_ARG8, p8 +//BOOST_MOVE_ARGQN +#define BOOST_MOVE_ARGQ0 +#define BOOST_MOVE_ARGQ1 q0 +#define BOOST_MOVE_ARGQ2 BOOST_MOVE_ARGQ1, q1 +#define BOOST_MOVE_ARGQ3 BOOST_MOVE_ARGQ2, q2 +#define BOOST_MOVE_ARGQ4 BOOST_MOVE_ARGQ3, q3 +#define BOOST_MOVE_ARGQ5 BOOST_MOVE_ARGQ4, q4 +#define BOOST_MOVE_ARGQ6 BOOST_MOVE_ARGQ5, q5 +#define BOOST_MOVE_ARGQ7 BOOST_MOVE_ARGQ6, q6 +#define BOOST_MOVE_ARGQ8 BOOST_MOVE_ARGQ7, q7 +#define BOOST_MOVE_ARGQ9 BOOST_MOVE_ARGQ8, q8 + //BOOST_MOVE_DECLVALN #define BOOST_MOVE_DECLVAL0 -#define BOOST_MOVE_DECLVAL1 ::boost::move_detail::declval() +#define BOOST_MOVE_DECLVAL1 ::boost::move_detail::declval() #define BOOST_MOVE_DECLVAL2 BOOST_MOVE_DECLVAL1, ::boost::move_detail::declval() #define BOOST_MOVE_DECLVAL3 BOOST_MOVE_DECLVAL2, ::boost::move_detail::declval() #define BOOST_MOVE_DECLVAL4 BOOST_MOVE_DECLVAL3, ::boost::move_detail::declval() @@ -123,19 +135,36 @@ namespace move_detail { #define BOOST_MOVE_DECLVAL8 BOOST_MOVE_DECLVAL7, ::boost::move_detail::declval() #define BOOST_MOVE_DECLVAL9 BOOST_MOVE_DECLVAL8, ::boost::move_detail::declval() +//BOOST_MOVE_DECLVALQN +#define BOOST_MOVE_DECLVALQ0 +#define BOOST_MOVE_DECLVALQ1 ::boost::move_detail::declval() +#define BOOST_MOVE_DECLVALQ2 BOOST_MOVE_DECLVALQ1, ::boost::move_detail::declval() +#define BOOST_MOVE_DECLVALQ3 BOOST_MOVE_DECLVALQ2, ::boost::move_detail::declval() +#define BOOST_MOVE_DECLVALQ4 BOOST_MOVE_DECLVALQ3, ::boost::move_detail::declval() +#define BOOST_MOVE_DECLVALQ5 BOOST_MOVE_DECLVALQ4, ::boost::move_detail::declval() +#define BOOST_MOVE_DECLVALQ6 BOOST_MOVE_DECLVALQ5, ::boost::move_detail::declval() +#define BOOST_MOVE_DECLVALQ7 BOOST_MOVE_DECLVALQ6, ::boost::move_detail::declval() +#define BOOST_MOVE_DECLVALQ8 BOOST_MOVE_DECLVALQ7, ::boost::move_detail::declval() +#define BOOST_MOVE_DECLVALQ9 BOOST_MOVE_DECLVALQ8, ::boost::move_detail::declval() + #ifdef BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG #define BOOST_MOVE_MREF(T) ::boost::move_detail::mref #define BOOST_MOVE_MFWD(N) ::boost::forward(this->m_p##N.get()) + #define BOOST_MOVE_MFWDQ(N) ::boost::forward(this->m_q##N.get()) #else #define BOOST_MOVE_MREF(T) BOOST_FWD_REF(T) #define BOOST_MOVE_MFWD(N) ::boost::forward(this->m_p##N) + #define BOOST_MOVE_MFWDQ(N) ::boost::forward(this->m_q##N) #endif #define BOOST_MOVE_MITFWD(N) *this->m_p##N #define BOOST_MOVE_MINC(N) ++this->m_p##N +#define BOOST_MOVE_MITFWDQ(N) *this->m_q##N +#define BOOST_MOVE_MINCQ(N) ++this->m_q##N + //BOOST_MOVE_MFWDN #define BOOST_MOVE_MFWD0 -#define BOOST_MOVE_MFWD1 BOOST_MOVE_MFWD(0) +#define BOOST_MOVE_MFWD1 BOOST_MOVE_MFWD(0) #define BOOST_MOVE_MFWD2 BOOST_MOVE_MFWD1, BOOST_MOVE_MFWD(1) #define BOOST_MOVE_MFWD3 BOOST_MOVE_MFWD2, BOOST_MOVE_MFWD(2) #define BOOST_MOVE_MFWD4 BOOST_MOVE_MFWD3, BOOST_MOVE_MFWD(3) @@ -145,9 +174,21 @@ namespace move_detail { #define BOOST_MOVE_MFWD8 BOOST_MOVE_MFWD7, BOOST_MOVE_MFWD(7) #define BOOST_MOVE_MFWD9 BOOST_MOVE_MFWD8, BOOST_MOVE_MFWD(8) +//BOOST_MOVE_MFWDN +#define BOOST_MOVE_MFWDQ0 +#define BOOST_MOVE_MFWDQ1 BOOST_MOVE_MFWDQ(0) +#define BOOST_MOVE_MFWDQ2 BOOST_MOVE_MFWDQ1, BOOST_MOVE_MFWDQ(1) +#define BOOST_MOVE_MFWDQ3 BOOST_MOVE_MFWDQ2, BOOST_MOVE_MFWDQ(2) +#define BOOST_MOVE_MFWDQ4 BOOST_MOVE_MFWDQ3, BOOST_MOVE_MFWDQ(3) +#define BOOST_MOVE_MFWDQ5 BOOST_MOVE_MFWDQ4, BOOST_MOVE_MFWDQ(4) +#define BOOST_MOVE_MFWDQ6 BOOST_MOVE_MFWDQ5, BOOST_MOVE_MFWDQ(5) +#define BOOST_MOVE_MFWDQ7 BOOST_MOVE_MFWDQ6, BOOST_MOVE_MFWDQ(6) +#define BOOST_MOVE_MFWDQ8 BOOST_MOVE_MFWDQ7, BOOST_MOVE_MFWDQ(7) +#define BOOST_MOVE_MFWDQ9 BOOST_MOVE_MFWDQ8, BOOST_MOVE_MFWDQ(8) + //BOOST_MOVE_MINCN #define BOOST_MOVE_MINC0 -#define BOOST_MOVE_MINC1 BOOST_MOVE_MINC(0) +#define BOOST_MOVE_MINC1 BOOST_MOVE_MINC(0) #define BOOST_MOVE_MINC2 BOOST_MOVE_MINC1, BOOST_MOVE_MINC(1) #define BOOST_MOVE_MINC3 BOOST_MOVE_MINC2, BOOST_MOVE_MINC(2) #define BOOST_MOVE_MINC4 BOOST_MOVE_MINC3, BOOST_MOVE_MINC(3) @@ -157,9 +198,21 @@ namespace move_detail { #define BOOST_MOVE_MINC8 BOOST_MOVE_MINC7, BOOST_MOVE_MINC(7) #define BOOST_MOVE_MINC9 BOOST_MOVE_MINC8, BOOST_MOVE_MINC(8) +//BOOST_MOVE_MINCQN +#define BOOST_MOVE_MINCQ0 +#define BOOST_MOVE_MINCQ1 BOOST_MOVE_MINCQ(0) +#define BOOST_MOVE_MINCQ2 BOOST_MOVE_MINCQ1, BOOST_MOVE_MINCQ(1) +#define BOOST_MOVE_MINCQ3 BOOST_MOVE_MINCQ2, BOOST_MOVE_MINCQ(2) +#define BOOST_MOVE_MINCQ4 BOOST_MOVE_MINCQ3, BOOST_MOVE_MINCQ(3) +#define BOOST_MOVE_MINCQ5 BOOST_MOVE_MINCQ4, BOOST_MOVE_MINCQ(4) +#define BOOST_MOVE_MINCQ6 BOOST_MOVE_MINCQ5, BOOST_MOVE_MINCQ(5) +#define BOOST_MOVE_MINCQ7 BOOST_MOVE_MINCQ6, BOOST_MOVE_MINCQ(6) +#define BOOST_MOVE_MINCQ8 BOOST_MOVE_MINCQ7, BOOST_MOVE_MINCQ(7) +#define BOOST_MOVE_MINCQ9 BOOST_MOVE_MINCQ8, BOOST_MOVE_MINCQ(8) + //BOOST_MOVE_MITFWDN #define BOOST_MOVE_MITFWD0 -#define BOOST_MOVE_MITFWD1 BOOST_MOVE_MITFWD(0) +#define BOOST_MOVE_MITFWD1 BOOST_MOVE_MITFWD(0) #define BOOST_MOVE_MITFWD2 BOOST_MOVE_MITFWD1, BOOST_MOVE_MITFWD(1) #define BOOST_MOVE_MITFWD3 BOOST_MOVE_MITFWD2, BOOST_MOVE_MITFWD(2) #define BOOST_MOVE_MITFWD4 BOOST_MOVE_MITFWD3, BOOST_MOVE_MITFWD(3) @@ -169,10 +222,21 @@ namespace move_detail { #define BOOST_MOVE_MITFWD8 BOOST_MOVE_MITFWD7, BOOST_MOVE_MITFWD(7) #define BOOST_MOVE_MITFWD9 BOOST_MOVE_MITFWD8, BOOST_MOVE_MITFWD(8) +//BOOST_MOVE_MITFWDQN +#define BOOST_MOVE_MITFWDQ0 +#define BOOST_MOVE_MITFWDQ1 BOOST_MOVE_MITFWDQ(0) +#define BOOST_MOVE_MITFWDQ2 BOOST_MOVE_MITFWDQ1, BOOST_MOVE_MITFWDQ(1) +#define BOOST_MOVE_MITFWDQ3 BOOST_MOVE_MITFWDQ2, BOOST_MOVE_MITFWDQ(2) +#define BOOST_MOVE_MITFWDQ4 BOOST_MOVE_MITFWDQ3, BOOST_MOVE_MITFWDQ(3) +#define BOOST_MOVE_MITFWDQ5 BOOST_MOVE_MITFWDQ4, BOOST_MOVE_MITFWDQ(4) +#define BOOST_MOVE_MITFWDQ6 BOOST_MOVE_MITFWDQ5, BOOST_MOVE_MITFWDQ(5) +#define BOOST_MOVE_MITFWDQ7 BOOST_MOVE_MITFWDQ6, BOOST_MOVE_MITFWDQ(6) +#define BOOST_MOVE_MITFWDQ8 BOOST_MOVE_MITFWDQ7, BOOST_MOVE_MITFWDQ(7) +#define BOOST_MOVE_MITFWDQ9 BOOST_MOVE_MITFWDQ8, BOOST_MOVE_MITFWDQ(8) //BOOST_MOVE_FWD_INITN #define BOOST_MOVE_FWD_INIT0 -#define BOOST_MOVE_FWD_INIT1 m_p0(::boost::forward(p0)) +#define BOOST_MOVE_FWD_INIT1 m_p0(::boost::forward(p0)) #define BOOST_MOVE_FWD_INIT2 BOOST_MOVE_FWD_INIT1, m_p1(::boost::forward(p1)) #define BOOST_MOVE_FWD_INIT3 BOOST_MOVE_FWD_INIT2, m_p2(::boost::forward(p2)) #define BOOST_MOVE_FWD_INIT4 BOOST_MOVE_FWD_INIT3, m_p3(::boost::forward(p3)) @@ -182,9 +246,21 @@ namespace move_detail { #define BOOST_MOVE_FWD_INIT8 BOOST_MOVE_FWD_INIT7, m_p7(::boost::forward(p7)) #define BOOST_MOVE_FWD_INIT9 BOOST_MOVE_FWD_INIT8, m_p8(::boost::forward(p8)) +//BOOST_MOVE_FWD_INITQN +#define BOOST_MOVE_FWD_INITQ0 +#define BOOST_MOVE_FWD_INITQ1 m_q0(::boost::forward(q0)) +#define BOOST_MOVE_FWD_INITQ2 BOOST_MOVE_FWD_INITQ1, m_q1(::boost::forward(q1)) +#define BOOST_MOVE_FWD_INITQ3 BOOST_MOVE_FWD_INITQ2, m_q2(::boost::forward(q2)) +#define BOOST_MOVE_FWD_INITQ4 BOOST_MOVE_FWD_INITQ3, m_q3(::boost::forward(q3)) +#define BOOST_MOVE_FWD_INITQ5 BOOST_MOVE_FWD_INITQ4, m_q4(::boost::forward(q4)) +#define BOOST_MOVE_FWD_INITQ6 BOOST_MOVE_FWD_INITQ5, m_q5(::boost::forward(q5)) +#define BOOST_MOVE_FWD_INITQ7 BOOST_MOVE_FWD_INITQ6, m_q6(::boost::forward(q6)) +#define BOOST_MOVE_FWD_INITQ8 BOOST_MOVE_FWD_INITQ7, m_q7(::boost::forward(q7)) +#define BOOST_MOVE_FWD_INITQ9 BOOST_MOVE_FWD_INITQ8, m_q8(::boost::forward(q8)) + //BOOST_MOVE_VAL_INITN #define BOOST_MOVE_VAL_INIT0 -#define BOOST_MOVE_VAL_INIT1 m_p0(p0) +#define BOOST_MOVE_VAL_INIT1 m_p0(p0) #define BOOST_MOVE_VAL_INIT2 BOOST_MOVE_VAL_INIT1, m_p1(p1) #define BOOST_MOVE_VAL_INIT3 BOOST_MOVE_VAL_INIT2, m_p2(p2) #define BOOST_MOVE_VAL_INIT4 BOOST_MOVE_VAL_INIT3, m_p3(p3) @@ -194,9 +270,21 @@ namespace move_detail { #define BOOST_MOVE_VAL_INIT8 BOOST_MOVE_VAL_INIT7, m_p7(p7) #define BOOST_MOVE_VAL_INIT9 BOOST_MOVE_VAL_INIT8, m_p8(p8) +//BOOST_MOVE_VAL_INITQN +#define BOOST_MOVE_VAL_INITQ0 +#define BOOST_MOVE_VAL_INITQ1 m_q0(q0) +#define BOOST_MOVE_VAL_INITQ2 BOOST_MOVE_VAL_INITQ1, m_q1(q1) +#define BOOST_MOVE_VAL_INITQ3 BOOST_MOVE_VAL_INITQ2, m_q2(q2) +#define BOOST_MOVE_VAL_INITQ4 BOOST_MOVE_VAL_INITQ3, m_q3(q3) +#define BOOST_MOVE_VAL_INITQ5 BOOST_MOVE_VAL_INITQ4, m_q4(q4) +#define BOOST_MOVE_VAL_INITQ6 BOOST_MOVE_VAL_INITQ5, m_q5(q5) +#define BOOST_MOVE_VAL_INITQ7 BOOST_MOVE_VAL_INITQ6, m_q6(q6) +#define BOOST_MOVE_VAL_INITQ8 BOOST_MOVE_VAL_INITQ7, m_q7(q7) +#define BOOST_MOVE_VAL_INITQ9 BOOST_MOVE_VAL_INITQ8, m_q8(q8) + //BOOST_MOVE_UREFN #define BOOST_MOVE_UREF0 -#define BOOST_MOVE_UREF1 BOOST_FWD_REF(P0) p0 +#define BOOST_MOVE_UREF1 BOOST_FWD_REF(P0) p0 #define BOOST_MOVE_UREF2 BOOST_MOVE_UREF1, BOOST_FWD_REF(P1) p1 #define BOOST_MOVE_UREF3 BOOST_MOVE_UREF2, BOOST_FWD_REF(P2) p2 #define BOOST_MOVE_UREF4 BOOST_MOVE_UREF3, BOOST_FWD_REF(P3) p3 @@ -206,9 +294,21 @@ namespace move_detail { #define BOOST_MOVE_UREF8 BOOST_MOVE_UREF7, BOOST_FWD_REF(P7) p7 #define BOOST_MOVE_UREF9 BOOST_MOVE_UREF8, BOOST_FWD_REF(P8) p8 +//BOOST_MOVE_UREFQN +#define BOOST_MOVE_UREFQ0 +#define BOOST_MOVE_UREFQ1 BOOST_FWD_REF(Q0) q0 +#define BOOST_MOVE_UREFQ2 BOOST_MOVE_UREFQ1, BOOST_FWD_REF(Q1) q1 +#define BOOST_MOVE_UREFQ3 BOOST_MOVE_UREFQ2, BOOST_FWD_REF(Q2) q2 +#define BOOST_MOVE_UREFQ4 BOOST_MOVE_UREFQ3, BOOST_FWD_REF(Q3) q3 +#define BOOST_MOVE_UREFQ5 BOOST_MOVE_UREFQ4, BOOST_FWD_REF(Q4) q4 +#define BOOST_MOVE_UREFQ6 BOOST_MOVE_UREFQ5, BOOST_FWD_REF(Q5) q5 +#define BOOST_MOVE_UREFQ7 BOOST_MOVE_UREFQ6, BOOST_FWD_REF(Q6) q6 +#define BOOST_MOVE_UREFQ8 BOOST_MOVE_UREFQ7, BOOST_FWD_REF(Q7) q7 +#define BOOST_MOVE_UREFQ9 BOOST_MOVE_UREFQ8, BOOST_FWD_REF(Q8) q8 + //BOOST_MOVE_VALN #define BOOST_MOVE_VAL0 -#define BOOST_MOVE_VAL1 P0 p0 +#define BOOST_MOVE_VAL1 BOOST_FWD_REF(P0) p0 #define BOOST_MOVE_VAL2 BOOST_MOVE_VAL1, BOOST_FWD_REF(P1) p1 #define BOOST_MOVE_VAL3 BOOST_MOVE_VAL2, BOOST_FWD_REF(P2) p2 #define BOOST_MOVE_VAL4 BOOST_MOVE_VAL3, BOOST_FWD_REF(P3) p3 @@ -218,22 +318,23 @@ namespace move_detail { #define BOOST_MOVE_VAL8 BOOST_MOVE_VAL7, BOOST_FWD_REF(P7) p7 #define BOOST_MOVE_VAL9 BOOST_MOVE_VAL8, BOOST_FWD_REF(P8) p8 -//BOOST_MOVE_UREFQN -#define BOOST_MOVE_UREFQ0 -#define BOOST_MOVE_UREFQ1 BOOST_FWD_REF(Q0) q0 -#define BOOST_MOVE_UREFQ2 BOOST_MOVE_UREFQ1, BOOST_FWD_REF(Q1) q1 -#define BOOST_MOVE_UREFQ3 BOOST_MOVE_UREFQ2, BOOST_FWD_REF(Q2) q2 -#define BOOST_MOVE_UREFQ4 BOOST_MOVE_UREFQ3, BOOST_FWD_REF(Q3) q3 -#define BOOST_MOVE_UREFQ5 BOOST_MOVE_UREFQ4, BOOST_FWD_REF(Q4) q4 -#define BOOST_MOVE_UREFQ6 BOOST_MOVE_UREFQ5, BOOST_FWD_REF(Q5) q5 -#define BOOST_MOVE_UREFQ7 BOOST_MOVE_UREFQ6, BOOST_FWD_REF(Q6) q6 -#define BOOST_MOVE_UREFQ8 BOOST_MOVE_UREFQ7, BOOST_FWD_REF(Q7) q7 -#define BOOST_MOVE_UREFQ9 BOOST_MOVE_UREFQ8, BOOST_FWD_REF(Q8) q8 +//BOOST_MOVE_VALQN +#define BOOST_MOVE_VALQ0 +#define BOOST_MOVE_VALQ1 BOOST_FWD_REF(Q0) q0 +#define BOOST_MOVE_VALQ2 BOOST_MOVE_VALQ1, BOOST_FWD_REF(Q1) q1 +#define BOOST_MOVE_VALQ3 BOOST_MOVE_VALQ2, BOOST_FWD_REF(Q2) q2 +#define BOOST_MOVE_VALQ4 BOOST_MOVE_VALQ3, BOOST_FWD_REF(Q3) q3 +#define BOOST_MOVE_VALQ5 BOOST_MOVE_VALQ4, BOOST_FWD_REF(Q4) q4 +#define BOOST_MOVE_VALQ6 BOOST_MOVE_VALQ5, BOOST_FWD_REF(Q5) q5 +#define BOOST_MOVE_VALQ7 BOOST_MOVE_VALQ6, BOOST_FWD_REF(Q6) q6 +#define BOOST_MOVE_VALQ8 BOOST_MOVE_VALQ7, BOOST_FWD_REF(Q7) q7 +#define BOOST_MOVE_VALQ9 BOOST_MOVE_VALQ8, BOOST_FWD_REF(Q8) q8 + -//BOOST_MOVE_CREFN #define BOOST_MOVE_UNVOIDCREF(T) const typename boost::move_detail::unvoid::type& +//BOOST_MOVE_CREFN #define BOOST_MOVE_CREF0 -#define BOOST_MOVE_CREF1 BOOST_MOVE_UNVOIDCREF(P0) p0 +#define BOOST_MOVE_CREF1 BOOST_MOVE_UNVOIDCREF(P0) p0 #define BOOST_MOVE_CREF2 BOOST_MOVE_CREF1, BOOST_MOVE_UNVOIDCREF(P1) p1 #define BOOST_MOVE_CREF3 BOOST_MOVE_CREF2, BOOST_MOVE_UNVOIDCREF(P2) p2 #define BOOST_MOVE_CREF4 BOOST_MOVE_CREF3, BOOST_MOVE_UNVOIDCREF(P3) p3 @@ -243,9 +344,21 @@ namespace move_detail { #define BOOST_MOVE_CREF8 BOOST_MOVE_CREF7, BOOST_MOVE_UNVOIDCREF(P7) p7 #define BOOST_MOVE_CREF9 BOOST_MOVE_CREF8, BOOST_MOVE_UNVOIDCREF(P8) p8 +//BOOST_MOVE_CREFQN +#define BOOST_MOVE_CREFQ0 +#define BOOST_MOVE_CREFQ1 BOOST_MOVE_UNVOIDCREF(Q0) q0 +#define BOOST_MOVE_CREFQ2 BOOST_MOVE_CREFQ1, BOOST_MOVE_UNVOIDCREF(Q1) q1 +#define BOOST_MOVE_CREFQ3 BOOST_MOVE_CREFQ2, BOOST_MOVE_UNVOIDCREF(Q2) q2 +#define BOOST_MOVE_CREFQ4 BOOST_MOVE_CREFQ3, BOOST_MOVE_UNVOIDCREF(Q3) q3 +#define BOOST_MOVE_CREFQ5 BOOST_MOVE_CREFQ4, BOOST_MOVE_UNVOIDCREF(Q4) q4 +#define BOOST_MOVE_CREFQ6 BOOST_MOVE_CREFQ5, BOOST_MOVE_UNVOIDCREF(Q5) q5 +#define BOOST_MOVE_CREFQ7 BOOST_MOVE_CREFQ6, BOOST_MOVE_UNVOIDCREF(Q6) q6 +#define BOOST_MOVE_CREFQ8 BOOST_MOVE_CREFQ7, BOOST_MOVE_UNVOIDCREF(Q7) q7 +#define BOOST_MOVE_CREFQ9 BOOST_MOVE_CREFQ8, BOOST_MOVE_UNVOIDCREF(Q8) q8 + //BOOST_MOVE_CLASSN #define BOOST_MOVE_CLASS0 -#define BOOST_MOVE_CLASS1 class P0 +#define BOOST_MOVE_CLASS1 class P0 #define BOOST_MOVE_CLASS2 BOOST_MOVE_CLASS1, class P1 #define BOOST_MOVE_CLASS3 BOOST_MOVE_CLASS2, class P2 #define BOOST_MOVE_CLASS4 BOOST_MOVE_CLASS3, class P3 @@ -257,7 +370,7 @@ namespace move_detail { //BOOST_MOVE_CLASSQN #define BOOST_MOVE_CLASSQ0 -#define BOOST_MOVE_CLASSQ1 class Q0 +#define BOOST_MOVE_CLASSQ1 class Q0 #define BOOST_MOVE_CLASSQ2 BOOST_MOVE_CLASSQ1, class Q1 #define BOOST_MOVE_CLASSQ3 BOOST_MOVE_CLASSQ2, class Q2 #define BOOST_MOVE_CLASSQ4 BOOST_MOVE_CLASSQ3, class Q3 @@ -269,7 +382,7 @@ namespace move_detail { //BOOST_MOVE_CLASSDFLTN #define BOOST_MOVE_CLASSDFLT0 -#define BOOST_MOVE_CLASSDFLT1 class P0 = void +#define BOOST_MOVE_CLASSDFLT1 class P0 = void #define BOOST_MOVE_CLASSDFLT2 BOOST_MOVE_CLASSDFLT1, class P1 = void #define BOOST_MOVE_CLASSDFLT3 BOOST_MOVE_CLASSDFLT2, class P2 = void #define BOOST_MOVE_CLASSDFLT4 BOOST_MOVE_CLASSDFLT3, class P3 = void @@ -279,9 +392,21 @@ namespace move_detail { #define BOOST_MOVE_CLASSDFLT8 BOOST_MOVE_CLASSDFLT7, class P7 = void #define BOOST_MOVE_CLASSDFLT9 BOOST_MOVE_CLASSDFLT8, class P8 = void +//BOOST_MOVE_CLASSDFLTQN +#define BOOST_MOVE_CLASSDFLTQ0 +#define BOOST_MOVE_CLASSDFLTQ1 class Q0 = void +#define BOOST_MOVE_CLASSDFLTQ2 BOOST_MOVE_CLASSDFLTQ1, class Q1 = void +#define BOOST_MOVE_CLASSDFLTQ3 BOOST_MOVE_CLASSDFLTQ2, class Q2 = void +#define BOOST_MOVE_CLASSDFLTQ4 BOOST_MOVE_CLASSDFLTQ3, class Q3 = void +#define BOOST_MOVE_CLASSDFLTQ5 BOOST_MOVE_CLASSDFLTQ4, class Q4 = void +#define BOOST_MOVE_CLASSDFLTQ6 BOOST_MOVE_CLASSDFLTQ5, class Q5 = void +#define BOOST_MOVE_CLASSDFLTQ7 BOOST_MOVE_CLASSDFLTQ6, class Q6 = void +#define BOOST_MOVE_CLASSDFLTQ8 BOOST_MOVE_CLASSDFLTQ7, class Q7 = void +#define BOOST_MOVE_CLASSDFLTQ9 BOOST_MOVE_CLASSDFLTQ8, class Q8 = void + //BOOST_MOVE_TARGN #define BOOST_MOVE_TARG0 -#define BOOST_MOVE_TARG1 P0 +#define BOOST_MOVE_TARG1 P0 #define BOOST_MOVE_TARG2 BOOST_MOVE_TARG1, P1 #define BOOST_MOVE_TARG3 BOOST_MOVE_TARG2, P2 #define BOOST_MOVE_TARG4 BOOST_MOVE_TARG3, P3 @@ -291,9 +416,21 @@ namespace move_detail { #define BOOST_MOVE_TARG8 BOOST_MOVE_TARG7, P7 #define BOOST_MOVE_TARG9 BOOST_MOVE_TARG8, P8 +//BOOST_MOVE_TARGQN +#define BOOST_MOVE_TARGQ0 +#define BOOST_MOVE_TARGQ1 Q0 +#define BOOST_MOVE_TARGQ2 BOOST_MOVE_TARGQ1, Q1 +#define BOOST_MOVE_TARGQ3 BOOST_MOVE_TARGQ2, Q2 +#define BOOST_MOVE_TARGQ4 BOOST_MOVE_TARGQ3, Q3 +#define BOOST_MOVE_TARGQ5 BOOST_MOVE_TARGQ4, Q4 +#define BOOST_MOVE_TARGQ6 BOOST_MOVE_TARGQ5, Q5 +#define BOOST_MOVE_TARGQ7 BOOST_MOVE_TARGQ6, Q6 +#define BOOST_MOVE_TARGQ8 BOOST_MOVE_TARGQ7, Q7 +#define BOOST_MOVE_TARGQ9 BOOST_MOVE_TARGQ8, Q8 + //BOOST_MOVE_FWD_TN #define BOOST_MOVE_FWD_T0 -#define BOOST_MOVE_FWD_T1 typename ::boost::move_detail::forward_type::type +#define BOOST_MOVE_FWD_T1 typename ::boost::move_detail::forward_type::type #define BOOST_MOVE_FWD_T2 BOOST_MOVE_FWD_T1, typename ::boost::move_detail::forward_type::type #define BOOST_MOVE_FWD_T3 BOOST_MOVE_FWD_T2, typename ::boost::move_detail::forward_type::type #define BOOST_MOVE_FWD_T4 BOOST_MOVE_FWD_T3, typename ::boost::move_detail::forward_type::type @@ -303,9 +440,21 @@ namespace move_detail { #define BOOST_MOVE_FWD_T8 BOOST_MOVE_FWD_T7, typename ::boost::move_detail::forward_type::type #define BOOST_MOVE_FWD_T9 BOOST_MOVE_FWD_T8, typename ::boost::move_detail::forward_type::type +//BOOST_MOVE_FWD_TQN +#define BOOST_MOVE_FWD_TQ0 +#define BOOST_MOVE_FWD_TQ1 typename ::boost::move_detail::forward_type::type +#define BOOST_MOVE_FWD_TQ2 BOOST_MOVE_FWD_TQ1, typename ::boost::move_detail::forward_type::type +#define BOOST_MOVE_FWD_TQ3 BOOST_MOVE_FWD_TQ2, typename ::boost::move_detail::forward_type::type +#define BOOST_MOVE_FWD_TQ4 BOOST_MOVE_FWD_TQ3, typename ::boost::move_detail::forward_type::type +#define BOOST_MOVE_FWD_TQ5 BOOST_MOVE_FWD_TQ4, typename ::boost::move_detail::forward_type::type +#define BOOST_MOVE_FWD_TQ6 BOOST_MOVE_FWD_TQ5, typename ::boost::move_detail::forward_type::type +#define BOOST_MOVE_FWD_TQ7 BOOST_MOVE_FWD_TQ6, typename ::boost::move_detail::forward_type::type +#define BOOST_MOVE_FWD_TQ8 BOOST_MOVE_FWD_TQ7, typename ::boost::move_detail::forward_type::type +#define BOOST_MOVE_FWD_TQ9 BOOST_MOVE_FWD_TQ8, typename ::boost::move_detail::forward_type::type + //BOOST_MOVE_MREFX #define BOOST_MOVE_MREF0 -#define BOOST_MOVE_MREF1 BOOST_MOVE_MREF(P0) m_p0; +#define BOOST_MOVE_MREF1 BOOST_MOVE_MREF(P0) m_p0; #define BOOST_MOVE_MREF2 BOOST_MOVE_MREF1 BOOST_MOVE_MREF(P1) m_p1; #define BOOST_MOVE_MREF3 BOOST_MOVE_MREF2 BOOST_MOVE_MREF(P2) m_p2; #define BOOST_MOVE_MREF4 BOOST_MOVE_MREF3 BOOST_MOVE_MREF(P3) m_p3; @@ -315,9 +464,21 @@ namespace move_detail { #define BOOST_MOVE_MREF8 BOOST_MOVE_MREF7 BOOST_MOVE_MREF(P7) m_p7; #define BOOST_MOVE_MREF9 BOOST_MOVE_MREF8 BOOST_MOVE_MREF(P8) m_p8; +//BOOST_MOVE_MREFQX +#define BOOST_MOVE_MREFQ0 +#define BOOST_MOVE_MREFQ1 BOOST_MOVE_MREFQ(Q0) m_q0; +#define BOOST_MOVE_MREFQ2 BOOST_MOVE_MREFQ1 BOOST_MOVE_MREFQ(Q1) m_q1; +#define BOOST_MOVE_MREFQ3 BOOST_MOVE_MREFQ2 BOOST_MOVE_MREFQ(Q2) m_q2; +#define BOOST_MOVE_MREFQ4 BOOST_MOVE_MREFQ3 BOOST_MOVE_MREFQ(Q3) m_q3; +#define BOOST_MOVE_MREFQ5 BOOST_MOVE_MREFQ4 BOOST_MOVE_MREFQ(Q4) m_q4; +#define BOOST_MOVE_MREFQ6 BOOST_MOVE_MREFQ5 BOOST_MOVE_MREFQ(Q5) m_q5; +#define BOOST_MOVE_MREFQ7 BOOST_MOVE_MREFQ6 BOOST_MOVE_MREFQ(Q6) m_q6; +#define BOOST_MOVE_MREFQ8 BOOST_MOVE_MREFQ7 BOOST_MOVE_MREFQ(Q7) m_q7; +#define BOOST_MOVE_MREFQ9 BOOST_MOVE_MREFQ8 BOOST_MOVE_MREFQ(Q8) m_q8; + //BOOST_MOVE_MEMBX #define BOOST_MOVE_MEMB0 -#define BOOST_MOVE_MEMB1 P0 m_p0; +#define BOOST_MOVE_MEMB1 P0 m_p0; #define BOOST_MOVE_MEMB2 BOOST_MOVE_MEMB1 P1 m_p1; #define BOOST_MOVE_MEMB3 BOOST_MOVE_MEMB2 P2 m_p2; #define BOOST_MOVE_MEMB4 BOOST_MOVE_MEMB3 P3 m_p3; @@ -327,6 +488,18 @@ namespace move_detail { #define BOOST_MOVE_MEMB8 BOOST_MOVE_MEMB7 P7 m_p7; #define BOOST_MOVE_MEMB9 BOOST_MOVE_MEMB8 P8 m_p8; +//BOOST_MOVE_MEMBQX +#define BOOST_MOVE_MEMBQ0 +#define BOOST_MOVE_MEMBQ1 Q0 m_q0; +#define BOOST_MOVE_MEMBQ2 BOOST_MOVE_MEMBQ1 Q1 m_q1; +#define BOOST_MOVE_MEMBQ3 BOOST_MOVE_MEMBQ2 Q2 m_q2; +#define BOOST_MOVE_MEMBQ4 BOOST_MOVE_MEMBQ3 Q3 m_q3; +#define BOOST_MOVE_MEMBQ5 BOOST_MOVE_MEMBQ4 Q4 m_q4; +#define BOOST_MOVE_MEMBQ6 BOOST_MOVE_MEMBQ5 Q5 m_q5; +#define BOOST_MOVE_MEMBQ7 BOOST_MOVE_MEMBQ6 Q6 m_q6; +#define BOOST_MOVE_MEMBQ8 BOOST_MOVE_MEMBQ7 Q7 m_q7; +#define BOOST_MOVE_MEMBQ9 BOOST_MOVE_MEMBQ8 Q8 m_q8; + //BOOST_MOVE_TMPL_LTN #define BOOST_MOVE_TMPL_LT0 #define BOOST_MOVE_TMPL_LT1 template< @@ -412,7 +585,7 @@ namespace move_detail { #define BOOST_MOVE_COLON9 BOOST_MOVE_COLON1 //BOOST_MOVE_ITERATE_2TON -#define BOOST_MOVE_ITERATE_2TO2(MACROFUNC) MACROFUNC(2) +#define BOOST_MOVE_ITERATE_2TO2(MACROFUNC) MACROFUNC(2) #define BOOST_MOVE_ITERATE_2TO3(MACROFUNC) BOOST_MOVE_ITERATE_2TO2(MACROFUNC) MACROFUNC(3) #define BOOST_MOVE_ITERATE_2TO4(MACROFUNC) BOOST_MOVE_ITERATE_2TO3(MACROFUNC) MACROFUNC(4) #define BOOST_MOVE_ITERATE_2TO5(MACROFUNC) BOOST_MOVE_ITERATE_2TO4(MACROFUNC) MACROFUNC(5) @@ -422,7 +595,7 @@ namespace move_detail { #define BOOST_MOVE_ITERATE_2TO9(MACROFUNC) BOOST_MOVE_ITERATE_2TO8(MACROFUNC) MACROFUNC(9) //BOOST_MOVE_ITERATE_1TON -#define BOOST_MOVE_ITERATE_1TO1(MACROFUNC) MACROFUNC(1) +#define BOOST_MOVE_ITERATE_1TO1(MACROFUNC) MACROFUNC(1) #define BOOST_MOVE_ITERATE_1TO2(MACROFUNC) BOOST_MOVE_ITERATE_1TO1(MACROFUNC) MACROFUNC(2) #define BOOST_MOVE_ITERATE_1TO3(MACROFUNC) BOOST_MOVE_ITERATE_1TO2(MACROFUNC) MACROFUNC(3) #define BOOST_MOVE_ITERATE_1TO4(MACROFUNC) BOOST_MOVE_ITERATE_1TO3(MACROFUNC) MACROFUNC(4) @@ -433,7 +606,7 @@ namespace move_detail { #define BOOST_MOVE_ITERATE_1TO9(MACROFUNC) BOOST_MOVE_ITERATE_1TO8(MACROFUNC) MACROFUNC(9) //BOOST_MOVE_ITERATE_0TON -#define BOOST_MOVE_ITERATE_0TO0(MACROFUNC) MACROFUNC(0) +#define BOOST_MOVE_ITERATE_0TO0(MACROFUNC) MACROFUNC(0) #define BOOST_MOVE_ITERATE_0TO1(MACROFUNC) BOOST_MOVE_ITERATE_0TO0(MACROFUNC) MACROFUNC(1) #define BOOST_MOVE_ITERATE_0TO2(MACROFUNC) BOOST_MOVE_ITERATE_0TO1(MACROFUNC) MACROFUNC(2) #define BOOST_MOVE_ITERATE_0TO3(MACROFUNC) BOOST_MOVE_ITERATE_0TO2(MACROFUNC) MACROFUNC(3) @@ -456,6 +629,29 @@ namespace move_detail { #define BOOST_MOVE_ITERATE_8TO8(MACROFUNC) MACROFUNC(8) #define BOOST_MOVE_ITERATE_9TO9(MACROFUNC) MACROFUNC(9) +//BOOST_MOVE_ITER2D_0TO9 +#define BOOST_MOVE_ITER2DLOW_0TO0(MACROFUNC2D, M) MACROFUNC2D(M, 0) +#define BOOST_MOVE_ITER2DLOW_0TO1(MACROFUNC2D, M) BOOST_MOVE_ITER2DLOW_0TO0(MACROFUNC2D, M) MACROFUNC2D(M, 1) +#define BOOST_MOVE_ITER2DLOW_0TO2(MACROFUNC2D, M) BOOST_MOVE_ITER2DLOW_0TO1(MACROFUNC2D, M) MACROFUNC2D(M, 2) +#define BOOST_MOVE_ITER2DLOW_0TO3(MACROFUNC2D, M) BOOST_MOVE_ITER2DLOW_0TO2(MACROFUNC2D, M) MACROFUNC2D(M, 3) +#define BOOST_MOVE_ITER2DLOW_0TO4(MACROFUNC2D, M) BOOST_MOVE_ITER2DLOW_0TO3(MACROFUNC2D, M) MACROFUNC2D(M, 4) +#define BOOST_MOVE_ITER2DLOW_0TO5(MACROFUNC2D, M) BOOST_MOVE_ITER2DLOW_0TO4(MACROFUNC2D, M) MACROFUNC2D(M, 5) +#define BOOST_MOVE_ITER2DLOW_0TO6(MACROFUNC2D, M) BOOST_MOVE_ITER2DLOW_0TO5(MACROFUNC2D, M) MACROFUNC2D(M, 6) +#define BOOST_MOVE_ITER2DLOW_0TO7(MACROFUNC2D, M) BOOST_MOVE_ITER2DLOW_0TO6(MACROFUNC2D, M) MACROFUNC2D(M, 7) +#define BOOST_MOVE_ITER2DLOW_0TO8(MACROFUNC2D, M) BOOST_MOVE_ITER2DLOW_0TO7(MACROFUNC2D, M) MACROFUNC2D(M, 8) +#define BOOST_MOVE_ITER2DLOW_0TO9(MACROFUNC2D, M) BOOST_MOVE_ITER2DLOW_0TO8(MACROFUNC2D, M) MACROFUNC2D(M, 9) +// +#define BOOST_MOVE_ITER2D_0TO0(MACROFUNC2D) BOOST_MOVE_ITER2DLOW_0TO9(MACROFUNC2D, 0) +#define BOOST_MOVE_ITER2D_0TO1(MACROFUNC2D) BOOST_MOVE_ITER2D_0TO0(MACROFUNC2D) BOOST_MOVE_ITER2DLOW_0TO9(MACROFUNC2D, 1) +#define BOOST_MOVE_ITER2D_0TO2(MACROFUNC2D) BOOST_MOVE_ITER2D_0TO1(MACROFUNC2D) BOOST_MOVE_ITER2DLOW_0TO9(MACROFUNC2D, 2) +#define BOOST_MOVE_ITER2D_0TO3(MACROFUNC2D) BOOST_MOVE_ITER2D_0TO2(MACROFUNC2D) BOOST_MOVE_ITER2DLOW_0TO9(MACROFUNC2D, 3) +#define BOOST_MOVE_ITER2D_0TO4(MACROFUNC2D) BOOST_MOVE_ITER2D_0TO3(MACROFUNC2D) BOOST_MOVE_ITER2DLOW_0TO9(MACROFUNC2D, 4) +#define BOOST_MOVE_ITER2D_0TO5(MACROFUNC2D) BOOST_MOVE_ITER2D_0TO4(MACROFUNC2D) BOOST_MOVE_ITER2DLOW_0TO9(MACROFUNC2D, 5) +#define BOOST_MOVE_ITER2D_0TO6(MACROFUNC2D) BOOST_MOVE_ITER2D_0TO5(MACROFUNC2D) BOOST_MOVE_ITER2DLOW_0TO9(MACROFUNC2D, 6) +#define BOOST_MOVE_ITER2D_0TO7(MACROFUNC2D) BOOST_MOVE_ITER2D_0TO6(MACROFUNC2D) BOOST_MOVE_ITER2DLOW_0TO9(MACROFUNC2D, 7) +#define BOOST_MOVE_ITER2D_0TO8(MACROFUNC2D) BOOST_MOVE_ITER2D_0TO7(MACROFUNC2D) BOOST_MOVE_ITER2DLOW_0TO9(MACROFUNC2D, 8) +#define BOOST_MOVE_ITER2D_0TO9(MACROFUNC2D) BOOST_MOVE_ITER2D_0TO8(MACROFUNC2D) BOOST_MOVE_ITER2DLOW_0TO9(MACROFUNC2D, 9) + //BOOST_MOVE_CAT #define BOOST_MOVE_CAT(a, b) BOOST_MOVE_CAT_I(a, b) #define BOOST_MOVE_CAT_I(a, b) a ## b diff --git a/boost/move/detail/iterator_traits.hpp b/boost/move/detail/iterator_traits.hpp index 2c5dc3eaeb..a75ee03827 100644 --- a/boost/move/detail/iterator_traits.hpp +++ b/boost/move/detail/iterator_traits.hpp @@ -24,17 +24,7 @@ #include -#if defined(__clang__) && defined(_LIBCPP_VERSION) - #define BOOST_MOVE_CLANG_INLINE_STD_NS - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wc++11-extensions" - #define BOOST_MOVE_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD - #define BOOST_MOVE_STD_NS_END _LIBCPP_END_NAMESPACE_STD -#else - #define BOOST_MOVE_STD_NS_BEG namespace std{ - #define BOOST_MOVE_STD_NS_END } -#endif - +#include BOOST_MOVE_STD_NS_BEG struct input_iterator_tag; @@ -44,11 +34,7 @@ struct random_access_iterator_tag; struct output_iterator_tag; BOOST_MOVE_STD_NS_END - -#ifdef BOOST_MOVE_CLANG_INLINE_STD_NS - #pragma GCC diagnostic pop - #undef BOOST_MOVE_CLANG_INLINE_STD_NS -#endif //BOOST_MOVE_CLANG_INLINE_STD_NS +#include namespace boost{ namespace movelib{ diff --git a/boost/move/detail/meta_utils.hpp b/boost/move/detail/meta_utils.hpp index a8a61dbd7b..323c13af10 100644 --- a/boost/move/detail/meta_utils.hpp +++ b/boost/move/detail/meta_utils.hpp @@ -332,6 +332,11 @@ struct eval_if : if_::type {}; + +#if defined(BOOST_GCC) && (BOOST_GCC <= 40000) +#define BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN +#endif + template struct enable_if_convertible : enable_if< is_convertible, R> diff --git a/boost/move/detail/move_helpers.hpp b/boost/move/detail/move_helpers.hpp index e3b8883159..7b62e26994 100644 --- a/boost/move/detail/move_helpers.hpp +++ b/boost/move/detail/move_helpers.hpp @@ -26,9 +26,9 @@ #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #define BOOST_MOVE_CATCH_CONST(U) \ - typename ::boost::move_detail::if_< ::boost::move_detail::is_class_or_union, BOOST_CATCH_CONST_RLVALUE(U), const U &>::type + typename ::boost::move_detail::if_< ::boost::move_detail::is_class, BOOST_CATCH_CONST_RLVALUE(U), const U &>::type #define BOOST_MOVE_CATCH_RVALUE(U)\ - typename ::boost::move_detail::if_< ::boost::move_detail::is_class_or_union, BOOST_RV_REF(U), ::boost::move_detail::nat>::type + typename ::boost::move_detail::if_< ::boost::move_detail::is_class, BOOST_RV_REF(U), ::boost::move_detail::nat>::type #define BOOST_MOVE_CATCH_FWD(U) BOOST_FWD_REF(U) #else #define BOOST_MOVE_CATCH_CONST(U) const U & @@ -36,142 +36,216 @@ #define BOOST_MOVE_CATCH_FWD(U) U && #endif -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES -#define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ - RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\ - { return FWD_FUNCTION(static_cast(x)); }\ -\ - RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ - { return FWD_FUNCTION(::boost::move(x)); }\ -\ - RETURN_VALUE PUB_FUNCTION(TYPE &x)\ - { return FWD_FUNCTION(const_cast(x)); }\ -\ - template\ - typename ::boost::move_detail::enable_if_and\ - < RETURN_VALUE \ - , ::boost::move_detail::is_same\ - , ::boost::move_detail::is_class_or_union\ - , ::boost::has_move_emulation_disabled\ - >::type\ - PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ - { return FWD_FUNCTION(u); }\ -\ - template\ - typename ::boost::move_detail::disable_if_or\ - < RETURN_VALUE \ - , ::boost::move_detail::is_same \ - , ::boost::move_detail::and_ \ - < ::boost::move_detail::is_rv \ - , ::boost::move_detail::is_class_or_union \ - > \ - >::type\ - PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ - {\ - TYPE t(u);\ - return FWD_FUNCTION(::boost::move(t));\ - }\ +//////////////////////////////////////// +// +// BOOST_MOVE_CONVERSION_AWARE_CATCH // +//////////////////////////////////////// +#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES + #define BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(static_cast(x)); }\ + \ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(::boost::move(x)); }\ + \ + RETURN_VALUE PUB_FUNCTION(TYPE &x)\ + { return FWD_FUNCTION(const_cast(x)); }\ + // + #if defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN) + #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ + BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ + \ + template\ + RETURN_VALUE PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u,\ + typename ::boost::move_detail::enable_if_and\ + < ::boost::move_detail::nat \ + , ::boost::move_detail::is_same\ + , ::boost::move_detail::is_class\ + , ::boost::has_move_emulation_disabled\ + >::type* = 0)\ + { return FWD_FUNCTION(u); }\ + \ + template\ + RETURN_VALUE PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u,\ + typename ::boost::move_detail::disable_if_or\ + < ::boost::move_detail::nat \ + , ::boost::move_detail::is_same \ + , ::boost::move_detail::and_ \ + < ::boost::move_detail::is_rv \ + , ::boost::move_detail::is_class \ + > \ + >::type* = 0)\ + {\ + TYPE t(u);\ + return FWD_FUNCTION(::boost::move(t));\ + }\ + // + #else + #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ + BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ + \ + template\ + typename ::boost::move_detail::enable_if_and\ + < RETURN_VALUE \ + , ::boost::move_detail::is_same\ + , ::boost::move_detail::is_class\ + , ::boost::has_move_emulation_disabled\ + >::type\ + PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ + { return FWD_FUNCTION(u); }\ + \ + template\ + typename ::boost::move_detail::disable_if_or\ + < RETURN_VALUE \ + , ::boost::move_detail::is_same \ + , ::boost::move_detail::and_ \ + < ::boost::move_detail::is_rv \ + , ::boost::move_detail::is_class \ + > \ + >::type\ + PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ + {\ + TYPE t(u);\ + return FWD_FUNCTION(::boost::move(t));\ + }\ + // + #endif #elif (defined(_MSC_VER) && (_MSC_VER == 1600)) -#define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ - RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\ - { return FWD_FUNCTION(static_cast(x)); }\ -\ - RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ - { return FWD_FUNCTION(::boost::move(x)); }\ -\ - template\ - typename ::boost::move_detail::enable_if_c\ - < !::boost::move_detail::is_same::value\ - , RETURN_VALUE >::type\ - PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ - {\ - TYPE t(u);\ - return FWD_FUNCTION(::boost::move(t));\ - }\ + #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(static_cast(x)); }\ + \ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(::boost::move(x)); }\ + \ + template\ + typename ::boost::move_detail::enable_if_c\ + < !::boost::move_detail::is_same::value\ + , RETURN_VALUE >::type\ + PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\ + {\ + TYPE t(u);\ + return FWD_FUNCTION(::boost::move(t));\ + }\ + // + +#else //BOOST_NO_CXX11_RVALUE_REFERENCES + + #define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(static_cast(x)); }\ + \ + RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(::boost::move(x)); }\ + // + +#endif //BOOST_NO_CXX11_RVALUE_REFERENCES + +//////////////////////////////////////// // - -#else - -#define BOOST_MOVE_CONVERSION_AWARE_CATCH(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION)\ - RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\ - { return FWD_FUNCTION(static_cast(x)); }\ -\ - RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ - { return FWD_FUNCTION(::boost::move(x)); }\ +// BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG // - -#endif - +//////////////////////////////////////// #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - -#define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ - RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\ - { return FWD_FUNCTION(arg1, static_cast(x)); }\ -\ - RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ - { return FWD_FUNCTION(arg1, ::boost::move(x)); }\ -\ - RETURN_VALUE PUB_FUNCTION(ARG1 arg1, TYPE &x)\ - { return FWD_FUNCTION(arg1, const_cast(x)); }\ -\ - template\ - typename ::boost::move_detail::enable_if_and\ - < RETURN_VALUE \ - , ::boost::move_detail::is_same\ - , ::boost::has_move_emulation_disabled\ - >::type\ - PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ - { return FWD_FUNCTION(arg1, u); }\ -\ - template\ - typename ::boost::move_detail::disable_if_or\ - < RETURN_VALUE \ - , ::boost::move_detail::is_rv\ - , ::boost::move_detail::is_same\ - , ::boost::move_detail::is_convertible\ - >::type\ - PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ - {\ - TYPE t(u);\ - return FWD_FUNCTION(arg1, ::boost::move(t));\ - }\ -// + #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(arg1, static_cast(x)); }\ + \ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(arg1, ::boost::move(x)); }\ + \ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, TYPE &x)\ + { return FWD_FUNCTION(arg1, const_cast(x)); }\ + // + #if defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN) + #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ + BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ + \ + template\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u,\ + typename ::boost::move_detail::enable_if_and\ + < ::boost::move_detail::nat \ + , ::boost::move_detail::is_same\ + , ::boost::has_move_emulation_disabled\ + >::type* = 0)\ + { return FWD_FUNCTION(arg1, u); }\ + \ + template\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u,\ + typename ::boost::move_detail::disable_if_or\ + < void \ + , ::boost::move_detail::is_rv\ + , ::boost::move_detail::is_same\ + , ::boost::move_detail::is_convertible\ + >::type* = 0)\ + {\ + TYPE t(u);\ + return FWD_FUNCTION(arg1, ::boost::move(t));\ + }\ + // + #else + #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ + BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG_COMMON(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ + \ + template\ + typename ::boost::move_detail::enable_if_and\ + < RETURN_VALUE \ + , ::boost::move_detail::is_same\ + , ::boost::has_move_emulation_disabled\ + >::type\ + PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ + { return FWD_FUNCTION(arg1, u); }\ + \ + template\ + typename ::boost::move_detail::disable_if_or\ + < RETURN_VALUE \ + , ::boost::move_detail::is_rv\ + , ::boost::move_detail::is_same\ + , ::boost::move_detail::is_convertible\ + >::type\ + PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ + {\ + TYPE t(u);\ + return FWD_FUNCTION(arg1, ::boost::move(t));\ + }\ + // + #endif #elif (defined(_MSC_VER) && (_MSC_VER == 1600)) -#define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ - RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\ - { return FWD_FUNCTION(arg1, static_cast(x)); }\ -\ - RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ - { return FWD_FUNCTION(arg1, ::boost::move(x)); }\ -\ - template\ - typename ::boost::move_detail::disable_if_or\ - < RETURN_VALUE \ - , ::boost::move_detail::is_same \ - , ::boost::move_detail::is_convertible \ - >::type\ - PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ - {\ - TYPE t(u);\ - return FWD_FUNCTION(arg1, ::boost::move(t));\ - }\ -// + #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(arg1, static_cast(x)); }\ + \ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(arg1, ::boost::move(x)); }\ + \ + template\ + typename ::boost::move_detail::disable_if_or\ + < RETURN_VALUE \ + , ::boost::move_detail::is_same \ + , ::boost::move_detail::is_convertible \ + >::type\ + PUB_FUNCTION(ARG1 arg1, const BOOST_MOVE_TEMPL_PARAM &u)\ + {\ + TYPE t(u);\ + return FWD_FUNCTION(arg1, ::boost::move(t));\ + }\ + // #else -#define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ - RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\ - { return FWD_FUNCTION(arg1, static_cast(x)); }\ -\ - RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ - { return FWD_FUNCTION(arg1, ::boost::move(x)); }\ -// + #define BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(PUB_FUNCTION, TYPE, RETURN_VALUE, FWD_FUNCTION, ARG1, UNLESS_CONVERTIBLE_TO)\ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_CONST(TYPE) x)\ + { return FWD_FUNCTION(arg1, static_cast(x)); }\ + \ + RETURN_VALUE PUB_FUNCTION(ARG1 arg1, BOOST_MOVE_CATCH_RVALUE(TYPE) x) \ + { return FWD_FUNCTION(arg1, ::boost::move(x)); }\ + // #endif diff --git a/boost/move/detail/std_ns_begin.hpp b/boost/move/detail/std_ns_begin.hpp new file mode 100644 index 0000000000..a768e61a15 --- /dev/null +++ b/boost/move/detail/std_ns_begin.hpp @@ -0,0 +1,30 @@ +#////////////////////////////////////////////////////////////////////////////// +#// +#// (C) Copyright Ion Gaztanaga 2015-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/move for documentation. +#// +#////////////////////////////////////////////////////////////////////////////// +# +#if defined(_LIBCPP_VERSION) + #if defined(__clang__) + #define BOOST_MOVE_STD_NS_GCC_DIAGNOSTIC_PUSH + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wc++11-extensions" + #endif + #define BOOST_MOVE_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD + #define BOOST_MOVE_STD_NS_END _LIBCPP_END_NAMESPACE_STD +#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE_VERSION) //GCC >= 4.6 + #define BOOST_MOVE_STD_NS_BEG namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + #define BOOST_MOVE_STD_NS_END _GLIBCXX_END_NAMESPACE_VERSION } // namespace +#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE) //GCC >= 4.2 + #define BOOST_MOVE_STD_NS_BEG _GLIBCXX_BEGIN_NAMESPACE(std) + #define BOOST_MOVE_STD_NS_END _GLIBCXX_END_NAMESPACE +#else + #define BOOST_MOVE_STD_NS_BEG namespace std{ + #define BOOST_MOVE_STD_NS_END } +#endif + diff --git a/boost/move/detail/std_ns_end.hpp b/boost/move/detail/std_ns_end.hpp new file mode 100644 index 0000000000..097505995b --- /dev/null +++ b/boost/move/detail/std_ns_end.hpp @@ -0,0 +1,14 @@ +#////////////////////////////////////////////////////////////////////////////// +#// +#// (C) Copyright Ion Gaztanaga 2015-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/move for documentation. +#// +#////////////////////////////////////////////////////////////////////////////// +#ifdef BOOST_MOVE_STD_NS_GCC_DIAGNOSTIC_PUSH + #pragma GCC diagnostic pop + #undef BOOST_MOVE_STD_NS_GCC_DIAGNOSTIC_PUSH +#endif //BOOST_MOVE_STD_NS_GCC_DIAGNOSTIC_PUSH diff --git a/boost/move/detail/type_traits.hpp b/boost/move/detail/type_traits.hpp index ab79fb128b..816fdca7b2 100644 --- a/boost/move/detail/type_traits.hpp +++ b/boost/move/detail/type_traits.hpp @@ -480,7 +480,7 @@ template struct remove_all_extents { typedef typename remove_all_extents::type type; }; -template +template struct remove_all_extents { typedef typename remove_all_extents::type type;}; @@ -1003,7 +1003,7 @@ BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x1000) #else //BOOST_NO_ALIGNMENT -template +template union aligned_union { T aligner; diff --git a/boost/move/unique_ptr.hpp b/boost/move/unique_ptr.hpp index bcf4faeea0..5b067436af 100644 --- a/boost/move/unique_ptr.hpp +++ b/boost/move/unique_ptr.hpp @@ -38,7 +38,7 @@ //! specially in C++03 compilers: //! - operator < uses pointer operator < instead of std::less. //! This avoids dependencies on std::common_type and std::less -//! (/ headers. In C++03 this avoid pulling Boost.Typeof and other +//! (/ headers). In C++03 this avoid pulling Boost.Typeof and other //! cascading dependencies. As in all Boost platforms operator < on raw pointers and //! other smart pointers provides strict weak ordering in practice this should not be a problem for users. //! - assignable from literal 0 for compilers without nullptr @@ -46,6 +46,7 @@ //! cv-less T and cv-less U are the same type and T is more CV qualified than U. namespace boost{ +// @cond namespace move_upd { //////////////////////////////////////////// @@ -301,6 +302,7 @@ struct enable_up_moveconv_constr {}; } //namespace move_upd { +// @endcond namespace movelib { diff --git a/boost/move/utility_core.hpp b/boost/move/utility_core.hpp index 89e4f07f8b..7fd1ea1443 100644 --- a/boost/move/utility_core.hpp +++ b/boost/move/utility_core.hpp @@ -265,6 +265,8 @@ #if defined(BOOST_MOVE_DOXYGEN_INVOKED) + //! Effects: Calls `boost::move` if `input_reference` is not a lvalue reference. + //! Otherwise returns the reference template output_reference move_if_not_lvalue_reference(input_reference) noexcept; #elif defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) diff --git a/boost/mpi/collectives/reduce.hpp b/boost/mpi/collectives/reduce.hpp index 4a94d71c12..1e2722ee6d 100644 --- a/boost/mpi/collectives/reduce.hpp +++ b/boost/mpi/collectives/reduce.hpp @@ -46,7 +46,7 @@ namespace detail { template void reduce_impl(const communicator& comm, const T* in_values, int n, - T* out_values, Op op, int root, mpl::true_ /*is_mpi_op*/, + T* out_values, Op /*op*/, int root, mpl::true_ /*is_mpi_op*/, mpl::true_/*is_mpi_datatype*/) { BOOST_MPI_CHECK_RESULT(MPI_Reduce, @@ -59,7 +59,7 @@ namespace detail { // datatype and operation, so we'll use MPI_Reduce directly. template void - reduce_impl(const communicator& comm, const T* in_values, int n, Op op, + reduce_impl(const communicator& comm, const T* in_values, int n, Op /*op*/, int root, mpl::true_ /*is_mpi_op*/, mpl::true_/*is_mpi_datatype*/) { BOOST_MPI_CHECK_RESULT(MPI_Reduce, diff --git a/boost/mpi/collectives/scan.hpp b/boost/mpi/collectives/scan.hpp index 4cba4a83cb..9264838ae8 100644 --- a/boost/mpi/collectives/scan.hpp +++ b/boost/mpi/collectives/scan.hpp @@ -47,7 +47,7 @@ namespace detail { template void scan_impl(const communicator& comm, const T* in_values, int n, T* out_values, - Op op, mpl::true_ /*is_mpi_op*/, mpl::true_ /*is_mpi_datatype*/) + Op /*op*/, mpl::true_ /*is_mpi_op*/, mpl::true_ /*is_mpi_datatype*/) { BOOST_MPI_CHECK_RESULT(MPI_Scan, (const_cast(in_values), out_values, n, diff --git a/boost/mpi/detail/forward_skeleton_iarchive.hpp b/boost/mpi/detail/forward_skeleton_iarchive.hpp index c4b9e0f2a8..0dfcaf9748 100644 --- a/boost/mpi/detail/forward_skeleton_iarchive.hpp +++ b/boost/mpi/detail/forward_skeleton_iarchive.hpp @@ -61,10 +61,10 @@ BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::tracking_type) BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::class_name_type) BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(serialization::collection_size_type) - void load_override(std::string & s , int) + void load_override(std::string & s) { serialization::collection_size_type length(s.size()); - load_override(length,0); + load_override(length); s.resize(length); } diff --git a/boost/mpi/detail/forward_skeleton_oarchive.hpp b/boost/mpi/detail/forward_skeleton_oarchive.hpp index 4b0e057266..1a170b4ab7 100644 --- a/boost/mpi/detail/forward_skeleton_oarchive.hpp +++ b/boost/mpi/detail/forward_skeleton_oarchive.hpp @@ -61,9 +61,9 @@ BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::tracking_type) BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::class_name_type) BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(serialization::collection_size_type) - void save_override(std::string const & t , int) + void save_override(std::string const & t) { - save_override(serialization::collection_size_type(t.size()),0); + save_override(serialization::collection_size_type(t.size())); } diff --git a/boost/mpi/detail/ignore_skeleton_oarchive.hpp b/boost/mpi/detail/ignore_skeleton_oarchive.hpp index 29248f993d..f9285a25d3 100644 --- a/boost/mpi/detail/ignore_skeleton_oarchive.hpp +++ b/boost/mpi/detail/ignore_skeleton_oarchive.hpp @@ -58,10 +58,10 @@ BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(archive::class_name_type) BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(serialization::collection_size_type) BOOST_ARCHIVE_IGNORE_IMPLEMENTATION(serialization::item_version_type) - void save_override(std::string const & s, int) + void save_override(std::string const & s) { if (s.size()) - save_override(serialization::make_array(s.data(),s.size()),0); + save_override(serialization::make_array(s.data(),s.size())); } #undef BOOST_ARCHIVE_IGNORE_IMPLEMENTATION diff --git a/boost/mpl/string.hpp b/boost/mpl/string.hpp index 345918f902..e7898562df 100644 --- a/boost/mpl/string.hpp +++ b/boost/mpl/string.hpp @@ -59,7 +59,7 @@ namespace boost { namespace mpl #define BOOST_MPL_MULTICHAR_LENGTH(c) \ (std::size_t)((c0xffffff)+(c>0xffff)+(c>0xff)+1)) - #if defined(BOOST_ENDIAN_LITTLE_BYTE) && defined(__SUNPRO_CC) + #if BOOST_ENDIAN_LITTLE_BYTE && defined(__SUNPRO_CC) #define BOOST_MPL_MULTICHAR_AT(c,i) \ (char)(0xff&((unsigned)(c)>>(8*(std::size_t)(i)))) diff --git a/boost/multi_index/detail/ord_index_impl.hpp b/boost/multi_index/detail/ord_index_impl.hpp index 8ebaccb2cf..040cb98963 100644 --- a/boost/multi_index/detail/ord_index_impl.hpp +++ b/boost/multi_index/detail/ord_index_impl.hpp @@ -1556,7 +1556,7 @@ template< inline boost::mpl::true_* boost_foreach_is_noncopyable( boost::multi_index::detail::ordered_index< KeyFromValue,Compare,SuperMeta,TagList,Category,AugmentPolicy>*&, - boost::foreach::tag) + boost_foreach_argument_dependent_lookup_hack) { return 0; } diff --git a/boost/multi_index/global_fun.hpp b/boost/multi_index/global_fun.hpp index 3ae2afdafc..2c13769100 100644 --- a/boost/multi_index/global_fun.hpp +++ b/boost/multi_index/global_fun.hpp @@ -14,6 +14,7 @@ #endif #include /* keep it first to prevent nasty warns in MSVC */ +#include #include #include #include @@ -80,7 +81,14 @@ struct const_ref_global_fun_base Type operator()( const reference_wrapper< typename remove_const< - typename remove_reference::type>::type>& x)const + typename remove_reference::type>::type>& x + +#if BOOST_WORKAROUND(BOOST_MSVC,==1310) +/* http://lists.boost.org/Archives/boost/2015/10/226135.php */ + ,int=0 +#endif + + )const { return operator()(x.get()); } diff --git a/boost/multi_index/hashed_index.hpp b/boost/multi_index/hashed_index.hpp index 436fecf771..352d0c13f1 100644 --- a/boost/multi_index/hashed_index.hpp +++ b/boost/multi_index/hashed_index.hpp @@ -1714,7 +1714,7 @@ template< inline boost::mpl::true_* boost_foreach_is_noncopyable( boost::multi_index::detail::hashed_index< KeyFromValue,Hash,Pred,SuperMeta,TagList,Category>*&, - boost::foreach::tag) + boost_foreach_argument_dependent_lookup_hack) { return 0; } diff --git a/boost/multi_index/identity.hpp b/boost/multi_index/identity.hpp index 370deb928b..6c832ce156 100644 --- a/boost/multi_index/identity.hpp +++ b/boost/multi_index/identity.hpp @@ -14,6 +14,7 @@ #endif #include +#include #include #include #include @@ -71,7 +72,14 @@ struct const_identity_base } Type& operator()( - const reference_wrapper::type>& x)const + const reference_wrapper::type>& x + +#if BOOST_WORKAROUND(BOOST_MSVC,==1310) +/* http://lists.boost.org/Archives/boost/2015/10/226135.php */ + ,int=0 +#endif + + )const { return x.get(); } diff --git a/boost/multi_index/random_access_index.hpp b/boost/multi_index/random_access_index.hpp index 5a628fb75a..fe1884ddd3 100644 --- a/boost/multi_index/random_access_index.hpp +++ b/boost/multi_index/random_access_index.hpp @@ -1156,7 +1156,7 @@ struct random_access template inline boost::mpl::true_* boost_foreach_is_noncopyable( boost::multi_index::detail::random_access_index*&, - boost::foreach::tag) + boost_foreach_argument_dependent_lookup_hack) { return 0; } diff --git a/boost/multi_index/ranked_index.hpp b/boost/multi_index/ranked_index.hpp index a5da5242ca..4fd4d32c75 100644 --- a/boost/multi_index/ranked_index.hpp +++ b/boost/multi_index/ranked_index.hpp @@ -270,7 +270,7 @@ struct rank_policy typedef ranked_index type; }; - /* algorihmic stuff */ + /* algorithmic stuff */ template static void add(Pointer x,Pointer root) @@ -302,13 +302,13 @@ struct rank_policy { y->size=x->size; x->size=ranked_node_size(x->left())+ranked_node_size(x->right())+1; - }; + } template static void rotate_right(Pointer x,Pointer y) /* in: x==y->right() */ { rotate_left(x,y); - }; + } #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING) /* invariant stuff */ diff --git a/boost/multi_index/sequenced_index.hpp b/boost/multi_index/sequenced_index.hpp index ce96bb5f9a..424eebc376 100644 --- a/boost/multi_index/sequenced_index.hpp +++ b/boost/multi_index/sequenced_index.hpp @@ -1051,7 +1051,7 @@ struct sequenced template inline boost::mpl::true_* boost_foreach_is_noncopyable( boost::multi_index::detail::sequenced_index*&, - boost::foreach::tag) + boost_foreach_argument_dependent_lookup_hack) { return 0; } diff --git a/boost/multiprecision/concepts/mp_number_archetypes.hpp b/boost/multiprecision/concepts/mp_number_archetypes.hpp index 5d5d841710..9a5f15962b 100644 --- a/boost/multiprecision/concepts/mp_number_archetypes.hpp +++ b/boost/multiprecision/concepts/mp_number_archetypes.hpp @@ -89,7 +89,7 @@ struct number_backend_float_architype if(digits) ss.precision(digits); else - ss.precision(std::numeric_limits::digits10 + 2); + ss.precision(std::numeric_limits::digits10 + 3); boost::intmax_t i = m_value; boost::uintmax_t u = m_value; if(!(f & std::ios_base::scientific) && m_value == i) diff --git a/boost/multiprecision/cpp_bin_float.hpp b/boost/multiprecision/cpp_bin_float.hpp index 4c00799843..bdf6a6308b 100644 --- a/boost/multiprecision/cpp_bin_float.hpp +++ b/boost/multiprecision/cpp_bin_float.hpp @@ -43,7 +43,7 @@ public: typedef typename rep_type::signed_types signed_types; typedef typename rep_type::unsigned_types unsigned_types; - typedef boost::mpl::list float_types; + typedef boost::mpl::list float_types; typedef Exponent exponent_type; static const exponent_type max_exponent_limit = boost::integer_traits::const_max - 2 * static_cast(bit_count); @@ -104,6 +104,18 @@ public: this->assign_float(f); } + template + explicit cpp_bin_float(const Float& f, + typename boost::enable_if_c< + (number_category::value == number_kind_floating_point) + && (std::numeric_limits::digits > (int)bit_count) + && (std::numeric_limits::radix == 2) + >::type const* = 0) + : m_data(), m_exponent(0), m_sign(false) + { + this->assign_float(f); + } + cpp_bin_float& operator=(const cpp_bin_float &o) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval() = std::declval())) { m_data = o.m_data; @@ -125,7 +137,7 @@ public: template typename boost::enable_if_c< (number_category::value == number_kind_floating_point) - && (std::numeric_limits::digits <= (int)bit_count) + //&& (std::numeric_limits::digits <= (int)bit_count) && (std::numeric_limits::radix == 2), cpp_bin_float&>::type operator=(const Float& f) { return assign_float(f); @@ -193,7 +205,7 @@ public: template typename boost::enable_if_c< (number_category::value == number_kind_floating_point) - && !is_floating_point::value + && !boost::is_floating_point::value /*&& (std::numeric_limits >::radix == 2)*/, cpp_bin_float&>::type assign_float(Float f) { @@ -1405,6 +1417,8 @@ namespace detail{ template struct is_explicitly_convertible, backends::cpp_bin_float > : public mpl::true_ {}; +template +struct is_explicitly_convertible > : public boost::is_floating_point {}; } #endif @@ -1478,7 +1492,7 @@ public: BOOST_STATIC_CONSTEXPR int digits = boost::multiprecision::cpp_bin_float::bit_count; BOOST_STATIC_CONSTEXPR int digits10 = (digits - 1) * 301 / 1000; // Is this really correct??? - BOOST_STATIC_CONSTEXPR int max_digits10 = (digits * 301 / 1000) + 2; + BOOST_STATIC_CONSTEXPR int max_digits10 = (digits * 301 / 1000) + 3; BOOST_STATIC_CONSTEXPR bool is_signed = true; BOOST_STATIC_CONSTEXPR bool is_integer = false; BOOST_STATIC_CONSTEXPR bool is_exact = false; diff --git a/boost/multiprecision/cpp_int.hpp b/boost/multiprecision/cpp_int.hpp index d451567bb9..60ad87676c 100644 --- a/boost/multiprecision/cpp_int.hpp +++ b/boost/multiprecision/cpp_int.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -38,9 +39,20 @@ namespace backends{ #pragma warning(disable:4127 4351 4293 4996 4307 4702 6285) #endif -template >::type > +template >::type > struct cpp_int_backend; +} // namespace backends + +namespace detail { + + template + struct is_byte_container > : public boost::false_type {}; + +} // namespace detail + +namespace backends{ + template struct cpp_int_base; // @@ -944,7 +956,7 @@ public: if(b) negate(); } - BOOST_MP_FORCEINLINE void resize(unsigned new_size, unsigned min_size) + BOOST_MP_FORCEINLINE void resize(unsigned, unsigned min_size) { detail::verify_new_size(2, min_size, checked_type()); } @@ -1270,7 +1282,7 @@ private: } public: template - BOOST_MP_FORCEINLINE cpp_int_backend& operator = (Arithmetic val) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval().do_assign_arithmetic(std::declval(), trivial_tag()))) + BOOST_MP_FORCEINLINE typename boost::enable_if_c::value, cpp_int_backend&>::type operator = (Arithmetic val) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval().do_assign_arithmetic(std::declval(), trivial_tag()))) { do_assign_arithmetic(val, trivial_tag()); return *this; @@ -1355,43 +1367,97 @@ private: n -= 1; } } + // + // Exception guarentee: create the result in stack variable "result" + // then do a swap at the end. In the event of a throw, *this will + // be left unchanged. + // + cpp_int_backend result; if(n) { - if(radix == 8 || radix == 16) + if(radix == 16) { - unsigned shift = radix == 8 ? 3 : 4; - unsigned block_count = base_type::limb_bits / shift; - unsigned block_shift = shift * block_count; - limb_type val, block; + while(*s == '0') ++s; + std::size_t bitcount = 4 * std::strlen(s); + limb_type val; + std::size_t limb, shift; + if(bitcount > 4) + bitcount -= 4; + else + bitcount = 0; + std::size_t newsize = bitcount / (sizeof(limb_type) * CHAR_BIT) + 1; + result.resize(static_cast(newsize), static_cast(newsize)); // will throw if this is a checked integer that cannot be resized + std::memset(result.limbs(), 0, result.size() * sizeof(limb_type)); while(*s) { - block = 0; - for(unsigned i = 0; (i < block_count); ++i) + if(*s >= '0' && *s <= '9') + val = *s - '0'; + else if(*s >= 'a' && *s <= 'f') + val = 10 + *s - 'a'; + else if(*s >= 'A' && *s <= 'F') + val = 10 + *s - 'A'; + else { - if(*s >= '0' && *s <= '9') - val = *s - '0'; - else if(*s >= 'a' && *s <= 'f') - val = 10 + *s - 'a'; - else if(*s >= 'A' && *s <= 'F') - val = 10 + *s - 'A'; - else - val = base_type::max_limb_value; - if(val >= radix) - { - BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected content found while parsing character string.")); - } - block <<= shift; - block |= val; - if(!*++s) + BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected content found while parsing character string.")); + } + limb = bitcount / (sizeof(limb_type) * CHAR_BIT); + shift = bitcount % (sizeof(limb_type) * CHAR_BIT); + val <<= shift; + if(result.size() > limb) + { + result.limbs()[limb] |= val; + } + ++s; + bitcount -= 4; + } + result.normalize(); + } + else if(radix == 8) + { + while(*s == '0') ++s; + std::size_t bitcount = 3 * std::strlen(s); + limb_type val; + std::size_t limb, shift; + if(bitcount > 3) + bitcount -= 3; + else + bitcount = 0; + std::size_t newsize = bitcount / (sizeof(limb_type) * CHAR_BIT) + 1; + result.resize(static_cast(newsize), static_cast(newsize)); // will throw if this is a checked integer that cannot be resized + std::memset(result.limbs(), 0, result.size() * sizeof(limb_type)); + while(*s) + { + if(*s >= '0' && *s <= '7') + val = *s - '0'; + else + { + BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected content found while parsing character string.")); + } + limb = bitcount / (sizeof(limb_type) * CHAR_BIT); + shift = bitcount % (sizeof(limb_type) * CHAR_BIT); + if(result.size() > limb) + { + result.limbs()[limb] |= (val << shift); + if(shift > sizeof(limb_type) * CHAR_BIT - 3) { - // final shift is different: - block_shift = (i + 1) * shift; - break; + // Deal with the bits in val that overflow into the next limb: + val >>= (sizeof(limb_type) * CHAR_BIT - shift); + if(val) + { + // If this is the most-significant-limb, we may need to allocate an extra one for the overflow: + if(limb + 1 == newsize) + result.resize(static_cast(newsize + 1), static_cast(newsize + 1)); + if(result.size() > limb + 1) + { + result.limbs()[limb + 1] |= val; + } + } } } - eval_left_shift(*this, block_shift); - this->limbs()[0] |= block; + ++s; + bitcount -= 3; } + result.normalize(); } else { @@ -1416,13 +1482,14 @@ private: break; } } - eval_multiply(*this, block_mult); - eval_add(*this, block); + eval_multiply(result, block_mult); + eval_add(result, block); } } } if(isneg) - this->negate(); + result.negate(); + result.swap(*this); } public: cpp_int_backend& operator = (const char* s) @@ -1638,6 +1705,67 @@ public: { return do_get_string(f, trivial_tag()); } +private: + template + void construct_from_container(const Container& c, const mpl::false_&) + { + // + // We assume that c is a sequence of (unsigned) bytes with the most significant byte first: + // + unsigned newsize = static_cast(c.size() / sizeof(limb_type)); + if(c.size() % sizeof(limb_type)) + { + ++newsize; + } + if(newsize) + { + this->resize(newsize, newsize); // May throw + std::memset(this->limbs(), 0, this->size()); + typename Container::const_iterator i(c.begin()), j(c.end()); + unsigned byte_location = static_cast(c.size() - 1); + while(i != j) + { + unsigned limb = byte_location / sizeof(limb_type); + unsigned shift = (byte_location % sizeof(limb_type)) * CHAR_BIT; + if(this->size() > limb) + this->limbs()[limb] |= static_cast(static_cast(*i)) << shift; + ++i; + --byte_location; + } + } + } + template + void construct_from_container(const Container& c, const mpl::true_&) + { + // + // We assume that c is a sequence of (unsigned) bytes with the most significant byte first: + // + typedef typename base_type::local_limb_type local_limb_type; + *this->limbs() = 0; + if(c.size()) + { + typename Container::const_iterator i(c.begin()), j(c.end()); + unsigned byte_location = static_cast(c.size() - 1); + while(i != j) + { + unsigned limb = byte_location / sizeof(local_limb_type); + unsigned shift = (byte_location % sizeof(local_limb_type)) * CHAR_BIT; + if(limb == 0) + this->limbs()[0] |= static_cast(static_cast(*i)) << shift; + ++i; + --byte_location; + } + } + } +public: + template + cpp_int_backend(const Container& c, typename boost::enable_if_c::value>::type const* = 0) + { + // + // We assume that c is a sequence of (unsigned) bytes with the most significant byte first: + // + construct_from_container(c, trivial_tag()); + } template int compare_imp(const cpp_int_backend& o, const mpl::false_&, const mpl::false_&)const BOOST_NOEXCEPT { @@ -1811,5 +1939,6 @@ struct is_explicitly_convertible #endif #include +#include #endif diff --git a/boost/multiprecision/cpp_int/bitwise.hpp b/boost/multiprecision/cpp_int/bitwise.hpp index a39e2590cb..dd6ba9d191 100644 --- a/boost/multiprecision/cpp_int/bitwise.hpp +++ b/boost/multiprecision/cpp_int/bitwise.hpp @@ -8,6 +8,11 @@ #ifndef BOOST_MP_CPP_INT_BIT_HPP #define BOOST_MP_CPP_INT_BIT_HPP +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4319) +#endif + namespace boost{ namespace multiprecision{ namespace backends{ template @@ -653,4 +658,8 @@ inline typename enable_if_c< }}} // namespaces +#ifdef _MSC_VER +#pragma warning(pop) +#endif + #endif diff --git a/boost/multiprecision/cpp_int/divide.hpp b/boost/multiprecision/cpp_int/divide.hpp index c94bc71498..5fe6ce6ad8 100644 --- a/boost/multiprecision/cpp_int/divide.hpp +++ b/boost/multiprecision/cpp_int/divide.hpp @@ -242,7 +242,21 @@ void divide_unsigned_helper( // Update r in a way that won't actually produce a negative result // in case the argument types are unsigned: // - if(r.compare(t) > 0) + if(truncated_t && carry) + { + // We need to calculate 2^n + t - r + // where n is the number of bits in this type. + // Simplest way is to get 2^n - r by complementing + // r, then add t to it. Note that we can't call eval_complement + // in case this is a signed checked type: + for(unsigned i = 0; i <= r_order; ++i) + r.limbs()[i] = ~prem[i]; + r.normalize(); + eval_increment(r); + eval_add(r, t); + r_neg = !r_neg; + } + else if(r.compare(t) > 0) { eval_subtract(r, t); } diff --git a/boost/multiprecision/cpp_int/import_export.hpp b/boost/multiprecision/cpp_int/import_export.hpp new file mode 100644 index 0000000000..f2f15f6421 --- /dev/null +++ b/boost/multiprecision/cpp_int/import_export.hpp @@ -0,0 +1,200 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ + +#ifndef BOOST_MP_CPP_INT_IMPORT_EXPORT_HPP +#define BOOST_MP_CPP_INT_IMPORT_EXPORT_HPP + + +namespace boost { + namespace multiprecision { + + namespace detail { + + template + void assign_bits(Backend& val, Unsigned bits, unsigned bit_location, unsigned chunk_bits, const mpl::false_& tag) + { + unsigned limb = bit_location / (sizeof(limb_type) * CHAR_BIT); + unsigned shift = bit_location % (sizeof(limb_type) * CHAR_BIT); + + limb_type mask = chunk_bits >= sizeof(limb_type) * CHAR_BIT ? ~static_cast(0u) : (static_cast(1u) << chunk_bits) - 1; + + limb_type value = (static_cast(bits) & mask) << shift; + if(value) + { + if(val.size() == limb) + { + val.resize(limb + 1, limb + 1); + if(val.size() > limb) + val.limbs()[limb] = value; + } + else if(val.size() > limb) + val.limbs()[limb] |= value; + } + if(chunk_bits > sizeof(limb_type) * CHAR_BIT - shift) + { + shift = sizeof(limb_type) * CHAR_BIT - shift; + chunk_bits -= shift; + bit_location += shift; + bits >>= shift; + if(bits) + assign_bits(val, bits, bit_location, chunk_bits, tag); + } + } + template + void assign_bits(Backend& val, Unsigned bits, unsigned bit_location, unsigned chunk_bits, const mpl::true_&) + { + typedef typename Backend::local_limb_type local_limb_type; + // + // Check for possible overflow, this may trigger an exception, or have no effect + // depending on whether this is a checked integer or not: + // + if((bit_location >= sizeof(local_limb_type) * CHAR_BIT) && bits) + val.resize(2, 2); + else + { + local_limb_type mask = chunk_bits >= sizeof(local_limb_type) * CHAR_BIT ? ~static_cast(0u) : (static_cast(1u) << chunk_bits) - 1; + local_limb_type value = (static_cast(bits) & mask) << bit_location; + *val.limbs() |= value; + // + // Check for overflow bits: + // + bit_location = sizeof(local_limb_type) * CHAR_BIT - bit_location; + bits >>= bit_location; + if(bits) + val.resize(2, 2); // May throw! + } + } + + template + inline void resize_to_bit_size(cpp_int_backend& newval, unsigned bits, const mpl::false_&) + { + unsigned limb_count = static_cast(bits / (sizeof(limb_type) * CHAR_BIT)); + if(bits % (sizeof(limb_type) * CHAR_BIT)) + ++limb_count; + static const unsigned max_limbs = MaxBits ? MaxBits / (CHAR_BIT * sizeof(limb_type)) + ((MaxBits % (CHAR_BIT * sizeof(limb_type))) ? 1 : 0) : (std::numeric_limits::max)(); + if(limb_count > max_limbs) + limb_count = max_limbs; + newval.resize(limb_count, limb_count); + std::memset(newval.limbs(), 0, newval.size() * sizeof(limb_type)); + } + template + inline void resize_to_bit_size(cpp_int_backend& newval, unsigned, const mpl::true_&) + { + *newval.limbs() = 0; + } + + } + + + template + number, ExpressionTemplates>& + import_bits( + number, ExpressionTemplates>& val, Iterator i, Iterator j, unsigned chunk_size = 0, bool msv_first = true) + { + typename number, ExpressionTemplates>::backend_type newval; + + typedef typename std::iterator_traits::value_type value_type; + typedef typename boost::make_unsigned::type unsigned_value_type; + typedef typename std::iterator_traits::difference_type difference_type; + typedef typename boost::make_unsigned::type size_type; + typedef typename cpp_int_backend::trivial_tag tag_type; + + if(!chunk_size) + chunk_size = std::numeric_limits::digits; + + size_type limbs = std::distance(i, j); + size_type bits = limbs * chunk_size; + + detail::resize_to_bit_size(newval, static_cast(bits), tag_type()); + + difference_type bit_location = msv_first ? bits - chunk_size : 0; + difference_type bit_location_change = msv_first ? -static_cast(chunk_size) : chunk_size; + + while(i != j) + { + detail::assign_bits(newval, static_cast(*i), static_cast(bit_location), chunk_size, tag_type()); + ++i; + bit_location += bit_location_change; + } + + newval.normalize(); + + val.backend().swap(newval); + return val; + } + + + namespace detail { + + template + boost::uintmax_t extract_bits(const Backend& val, unsigned location, unsigned count, const mpl::false_& tag) + { + unsigned limb = location / (sizeof(limb_type) * CHAR_BIT); + unsigned shift = location % (sizeof(limb_type) * CHAR_BIT); + boost::uintmax_t result = 0; + boost::uintmax_t mask = count == std::numeric_limits::digits ? ~static_cast(0) : (static_cast(1u) << count) - 1; + if(count > (sizeof(limb_type) * CHAR_BIT - shift)) + { + result = extract_bits(val, location + sizeof(limb_type) * CHAR_BIT - shift, count - sizeof(limb_type) * CHAR_BIT + shift, tag); + result <<= sizeof(limb_type) * CHAR_BIT - shift; + } + if(limb < val.size()) + result |= (val.limbs()[limb] >> shift) & mask; + return result; + } + + template + inline boost::uintmax_t extract_bits(const Backend& val, unsigned location, unsigned count, const mpl::true_&) + { + boost::uintmax_t result = *val.limbs(); + boost::uintmax_t mask = count == std::numeric_limits::digits ? ~static_cast(0) : (static_cast(1u) << count) - 1; + return (result >> location) & mask; + } + } + + template + OutputIterator export_bits( + const number, ExpressionTemplates>& val, OutputIterator out, unsigned chunk_size, bool msv_first = true) + { +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4244) +#endif + typedef typename cpp_int_backend::trivial_tag tag_type; + if(!val) + { + *out = 0; + ++out; + return out; + } + unsigned bitcount = msb(val) + 1; + unsigned chunks = bitcount / chunk_size; + if(bitcount % chunk_size) + ++chunks; + + int bit_location = msv_first ? bitcount - chunk_size : 0; + int bit_step = msv_first ? -static_cast(chunk_size) : chunk_size; + while(bit_location % bit_step) ++bit_location; + + do + { + *out = detail::extract_bits(val.backend(), bit_location, chunk_size, tag_type()); + ++out; + bit_location += bit_step; + } while((bit_location >= 0) && (bit_location < (int)bitcount)); + + return out; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + } + + } +} + + + +#endif // BOOST_MP_CPP_INT_IMPORT_EXPORT_HPP + diff --git a/boost/multiprecision/cpp_int/limits.hpp b/boost/multiprecision/cpp_int/limits.hpp index 6088cb1105..36a38d5a3b 100644 --- a/boost/multiprecision/cpp_int/limits.hpp +++ b/boost/multiprecision/cpp_int/limits.hpp @@ -131,7 +131,7 @@ public: static number_type lowest() { return (min)(); } BOOST_STATIC_CONSTEXPR int digits = boost::multiprecision::backends::max_precision::value == UINT_MAX ? INT_MAX : boost::multiprecision::backends::max_precision::value; BOOST_STATIC_CONSTEXPR int digits10 = (digits > INT_MAX / 301) ? (digits / 1000) * 301L : (digits * 301) / 1000; - BOOST_STATIC_CONSTEXPR int max_digits10 = digits10 + 2; + BOOST_STATIC_CONSTEXPR int max_digits10 = digits10 + 3; BOOST_STATIC_CONSTEXPR bool is_signed = boost::multiprecision::is_signed_number::value; BOOST_STATIC_CONSTEXPR bool is_integer = true; BOOST_STATIC_CONSTEXPR bool is_exact = true; diff --git a/boost/multiprecision/detail/default_ops.hpp b/boost/multiprecision/detail/default_ops.hpp index 01fbe181df..f76addb350 100644 --- a/boost/multiprecision/detail/default_ops.hpp +++ b/boost/multiprecision/detail/default_ops.hpp @@ -801,7 +801,7 @@ struct terminal { terminal(const R& v) : value(v){} terminal(){} - terminal& operator = (R val) { value = val; } + terminal& operator = (R val) { value = val; return *this; } R value; operator R()const { return value; } }; @@ -930,7 +930,7 @@ inline void eval_fmod(T& result, const T& a, const T& b) } T n; eval_divide(result, a, b); - if(eval_get_sign(a) < 0) + if(eval_get_sign(result) < 0) eval_ceil(n, result); else eval_floor(n, result); diff --git a/boost/multiprecision/detail/functions/trig.hpp b/boost/multiprecision/detail/functions/trig.hpp index 5d4e2639c2..be2a9deb77 100644 --- a/boost/multiprecision/detail/functions/trig.hpp +++ b/boost/multiprecision/detail/functions/trig.hpp @@ -486,14 +486,18 @@ void eval_asin(T& result, const T& x) result.negate(); return; } - +#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS + typedef typename boost::multiprecision::detail::canonical::type guess_type; +#else + typedef fp_type guess_type; +#endif // Get initial estimate using standard math function asin. - double dd; + guess_type dd; eval_convert_to(&dd, xx); - result = fp_type(std::asin(dd)); + result = (guess_type)(std::asin(dd)); - unsigned current_digits = std::numeric_limits::digits - 5; + unsigned current_digits = std::numeric_limits::digits - 5; unsigned target_precision = boost::multiprecision::detail::digits2 >::value; // Newton-Raphson iteration diff --git a/boost/multiprecision/detail/number_base.hpp b/boost/multiprecision/detail/number_base.hpp index d725779091..6e18763b5c 100644 --- a/boost/multiprecision/detail/number_base.hpp +++ b/boost/multiprecision/detail/number_base.hpp @@ -135,6 +135,10 @@ struct bits_of : sizeof(T) * CHAR_BIT - (is_signed::value ? 1 : 0); }; +#if defined(_GLIBCXX_USE_FLOAT128) && defined(BOOST_GCC) && !defined(__STRICT_ANSI__) +template<> struct bits_of<__float128> { static const unsigned value = 113; }; +#endif + template struct has_enough_bits { @@ -177,7 +181,8 @@ struct canonical_imp > typename Backend::signed_types, pred_type >::type iter_type; - typedef typename mpl::deref::type type; + typedef typename mpl::end::type end_type; + typedef typename mpl::eval_if, mpl::identity, mpl::deref >::type type; }; template struct canonical_imp > @@ -187,7 +192,8 @@ struct canonical_imp > typename Backend::unsigned_types, pred_type >::type iter_type; - typedef typename mpl::deref::type type; + typedef typename mpl::end::type end_type; + typedef typename mpl::eval_if, mpl::identity, mpl::deref >::type type; }; template struct canonical_imp > @@ -197,7 +203,8 @@ struct canonical_imp > typename Backend::float_types, pred_type >::type iter_type; - typedef typename mpl::deref::type type; + typedef typename mpl::end::type end_type; + typedef typename mpl::eval_if, mpl::identity, mpl::deref >::type type; }; template struct canonical_imp > @@ -372,11 +379,36 @@ struct expression static const unsigned depth = left_type::depth + 1; #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS - explicit operator bool()const +# if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7)) || (defined(BOOST_INTEL) && (BOOST_INTEL <= 1500)) + // + // Horrible workaround for gcc-4.6.x which always prefers the template + // operator bool() rather than the non-template operator when converting to + // an arithmetic type: + // + template , int>::type = 0> + explicit operator T ()const + { + result_type r(*this); + return static_cast(r); + } + template ::value || is_void::value || is_number::value, int>::type = 0> + explicit operator T ()const + { + return static_cast(static_cast(*this)); + } +# else + template ::value, int>::type = 0> + explicit operator T()const + { + return static_cast(static_cast(*this)); + } + BOOST_MP_FORCEINLINE explicit operator bool()const { result_type r(*this); return static_cast(r); } + explicit operator void()const {} +# endif #else operator unmentionable_type()const { @@ -385,6 +417,13 @@ struct expression } #endif + template + T convert_to() + { + result_type r(*this); + return r.template convert_to(); + } + private: typename expression_storage::type arg; expression& operator=(const expression&); @@ -404,10 +443,36 @@ struct expression static const unsigned depth = 0; #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS - explicit operator bool()const +# if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7)) || (defined(BOOST_INTEL) && (BOOST_INTEL <= 1500)) + // + // Horrible workaround for gcc-4.6.x which always prefers the template + // operator bool() rather than the non-template operator when converting to + // an arithmetic type: + // + template , int>::type = 0> + explicit operator T ()const + { + result_type r(*this); + return static_cast(r); +} + template ::value || is_void::value || is_number::value, int>::type = 0> + explicit operator T ()const { - return static_cast(arg); + return static_cast(static_cast(*this)); } +# else + template ::value, int>::type = 0> + explicit operator T()const + { + return static_cast(static_cast(*this)); + } + BOOST_MP_FORCEINLINE explicit operator bool()const + { + result_type r(*this); + return static_cast(r); + } + explicit operator void()const {} +# endif #else operator unmentionable_type()const { @@ -415,6 +480,13 @@ struct expression } #endif + template + T convert_to() + { + result_type r(*this); + return r.template convert_to(); + } + private: typename expression_storage::type arg; expression& operator=(const expression&); @@ -439,11 +511,36 @@ struct expression const Arg2& right_ref()const BOOST_NOEXCEPT { return arg2; } #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS - explicit operator bool()const +# if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7)) || (defined(BOOST_INTEL) && (BOOST_INTEL <= 1500)) + // + // Horrible workaround for gcc-4.6.x which always prefers the template + // operator bool() rather than the non-template operator when converting to + // an arithmetic type: + // + template , int>::type = 0> + explicit operator T ()const { result_type r(*this); return static_cast(r); +} + template ::value || is_void::value || is_number::value, int>::type = 0> + explicit operator T ()const + { + return static_cast(static_cast(*this)); } +# else + template ::value, int>::type = 0> + explicit operator T()const + { + return static_cast(static_cast(*this)); + } + BOOST_MP_FORCEINLINE explicit operator bool()const + { + result_type r(*this); + return static_cast(r); + } + explicit operator void()const {} +# endif #else operator unmentionable_type()const { @@ -451,6 +548,13 @@ struct expression return r ? &unmentionable::proc : 0; } #endif + template + T convert_to() + { + result_type r(*this); + return r.template convert_to(); + } + static const unsigned left_depth = left_type::depth + 1; static const unsigned right_depth = right_type::depth + 1; static const unsigned depth = left_depth > right_depth ? left_depth : right_depth; @@ -486,11 +590,36 @@ struct expression const Arg3& right_ref()const BOOST_NOEXCEPT { return arg3; } #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS - explicit operator bool()const +# if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7)) || (defined(BOOST_INTEL) && (BOOST_INTEL <= 1500)) + // + // Horrible workaround for gcc-4.6.x which always prefers the template + // operator bool() rather than the non-template operator when converting to + // an arithmetic type: + // + template , int>::type = 0> + explicit operator T ()const { result_type r(*this); return static_cast(r); +} + template ::value || is_void::value || is_number::value, int>::type = 0> + explicit operator T ()const + { + return static_cast(static_cast(*this)); + } +# else + template ::value, int>::type = 0> + explicit operator T()const + { + return static_cast(static_cast(*this)); } + BOOST_MP_FORCEINLINE explicit operator bool()const + { + result_type r(*this); + return static_cast(r); + } + explicit operator void()const {} +# endif #else operator unmentionable_type()const { @@ -498,6 +627,13 @@ struct expression return r ? &unmentionable::proc : 0; } #endif + template + T convert_to() + { + result_type r(*this); + return r.template convert_to(); + } + static const unsigned left_depth = left_type::depth + 1; static const unsigned middle_depth = middle_type::depth + 1; static const unsigned right_depth = right_type::depth + 1; @@ -542,11 +678,36 @@ struct expression const Arg4& right_ref()const BOOST_NOEXCEPT { return arg4; } #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS - explicit operator bool()const +# if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7)) || (defined(BOOST_INTEL) && (BOOST_INTEL <= 1500)) + // + // Horrible workaround for gcc-4.6.x which always prefers the template + // operator bool() rather than the non-template operator when converting to + // an arithmetic type: + // + template , int>::type = 0> + explicit operator T ()const + { + result_type r(*this); + return static_cast(r); +} + template ::value || is_void::value || is_number::value, int>::type = 0> + explicit operator T ()const + { + return static_cast(static_cast(*this)); + } +# else + template ::value, int>::type = 0> + explicit operator T()const + { + return static_cast(static_cast(*this)); + } + BOOST_MP_FORCEINLINE explicit operator bool()const { result_type r(*this); return static_cast(r); } + explicit operator void()const {} +# endif #else operator unmentionable_type()const { @@ -554,6 +715,13 @@ struct expression return r ? &unmentionable::proc : 0; } #endif + template + T convert_to() + { + result_type r(*this); + return r.template convert_to(); + } + static const unsigned left_depth = left_type::depth + 1; static const unsigned left_middle_depth = left_middle_type::depth + 1; static const unsigned right_middle_depth = right_middle_type::depth + 1; diff --git a/boost/multiprecision/float128.hpp b/boost/multiprecision/float128.hpp index cd70fa009b..4341672393 100644 --- a/boost/multiprecision/float128.hpp +++ b/boost/multiprecision/float128.hpp @@ -144,10 +144,10 @@ public: return *this; } template - BOOST_CONSTEXPR float128_backend(const T& i, const typename enable_if_c::value>::type* = 0) BOOST_NOEXCEPT + BOOST_CONSTEXPR float128_backend(const T& i, const typename enable_if_c::value>::type* = 0) BOOST_NOEXCEPT_IF(noexcept(std::declval() = std::declval())) : m_value(i) {} template - typename enable_if_c::value || is_convertible::value, float128_backend&>::type operator = (const T& i) BOOST_NOEXCEPT + typename enable_if_c::value || is_convertible::value, float128_backend&>::type operator = (const T& i) BOOST_NOEXCEPT_IF(noexcept(std::declval() = std::declval())) { m_value = i; return *this; diff --git a/boost/multiprecision/gmp.hpp b/boost/multiprecision/gmp.hpp index 6351f7ea48..f7d4e90961 100644 --- a/boost/multiprecision/gmp.hpp +++ b/boost/multiprecision/gmp.hpp @@ -2296,7 +2296,7 @@ public: BOOST_STATIC_CONSTEXPR int digits = static_cast((Digits10 * 1000L) / 301L + ((Digits10 * 1000L) % 301L ? 2 : 1)); BOOST_STATIC_CONSTEXPR int digits10 = Digits10; // Have to allow for a possible extra limb inside the gmp data structure: - BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 2 + ((GMP_LIMB_BITS * 301L) / 1000L); + BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 3 + ((GMP_LIMB_BITS * 301L) / 1000L); BOOST_STATIC_CONSTEXPR bool is_signed = true; BOOST_STATIC_CONSTEXPR bool is_integer = false; BOOST_STATIC_CONSTEXPR bool is_exact = false; @@ -2522,7 +2522,7 @@ public: static number_type lowest() { return (min)(); } BOOST_STATIC_CONSTEXPR int digits = INT_MAX; BOOST_STATIC_CONSTEXPR int digits10 = (INT_MAX / 1000) * 301L; - BOOST_STATIC_CONSTEXPR int max_digits10 = digits10 + 2; + BOOST_STATIC_CONSTEXPR int max_digits10 = digits10 + 3; BOOST_STATIC_CONSTEXPR bool is_signed = true; BOOST_STATIC_CONSTEXPR bool is_integer = true; BOOST_STATIC_CONSTEXPR bool is_exact = true; @@ -2621,7 +2621,7 @@ public: // Digits are unbounded, use zero for now: BOOST_STATIC_CONSTEXPR int digits = INT_MAX; BOOST_STATIC_CONSTEXPR int digits10 = (INT_MAX / 1000) * 301L; - BOOST_STATIC_CONSTEXPR int max_digits10 = digits10 + 2; + BOOST_STATIC_CONSTEXPR int max_digits10 = digits10 + 3; BOOST_STATIC_CONSTEXPR bool is_signed = true; BOOST_STATIC_CONSTEXPR bool is_integer = false; BOOST_STATIC_CONSTEXPR bool is_exact = true; diff --git a/boost/multiprecision/miller_rabin.hpp b/boost/multiprecision/miller_rabin.hpp index d62f103fb7..96dac04df5 100644 --- a/boost/multiprecision/miller_rabin.hpp +++ b/boost/multiprecision/miller_rabin.hpp @@ -144,6 +144,8 @@ typename enable_if_c::value == number_kind_integer, bool>::ty #endif typedef I number_type; + if (n == 2) + return true; // Trivial special case. if(bit_test(n, 0) == 0) return false; // n is even if(n <= 227) diff --git a/boost/multiprecision/mpfi.hpp b/boost/multiprecision/mpfi.hpp index 8d13981ceb..66a23cab70 100644 --- a/boost/multiprecision/mpfi.hpp +++ b/boost/multiprecision/mpfi.hpp @@ -125,7 +125,7 @@ struct mpfi_float_imp { if(m_data[0].left._mpfr_d == 0) mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision())); - boost::ulong_long_type mask = (((1uLL << (std::numeric_limits::digits - 1) - 1) << 1) | 1u); + boost::ulong_long_type mask = ((((1uLL << (std::numeric_limits::digits - 1)) - 1) << 1) | 1u); unsigned shift = 0; mpfi_t t; mpfi_init2(t, (std::max)(static_cast(std::numeric_limits::digits), static_cast(multiprecision::detail::digits10_2_2(digits10)))); @@ -1145,11 +1145,17 @@ namespace tools{ template <> inline int digits() +#ifdef BOOST_MATH_NOEXCEPT + BOOST_NOEXCEPT +#endif { return boost::multiprecision::backends::detail::get_default_precision(); } template <> inline int digits, boost::multiprecision::et_off> >() +#ifdef BOOST_MATH_NOEXCEPT + BOOST_NOEXCEPT +#endif { return boost::multiprecision::backends::detail::get_default_precision(); } @@ -1309,7 +1315,7 @@ public: BOOST_STATIC_CONSTEXPR int digits = static_cast((Digits10 * 1000L) / 301L + ((Digits10 * 1000L) % 301 ? 2 : 1)); BOOST_STATIC_CONSTEXPR int digits10 = Digits10; // Is this really correct??? - BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 2; + BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 3; BOOST_STATIC_CONSTEXPR bool is_signed = true; BOOST_STATIC_CONSTEXPR bool is_integer = false; BOOST_STATIC_CONSTEXPR bool is_exact = false; diff --git a/boost/multiprecision/mpfr.hpp b/boost/multiprecision/mpfr.hpp index dcf0044cdd..fde558be79 100644 --- a/boost/multiprecision/mpfr.hpp +++ b/boost/multiprecision/mpfr.hpp @@ -131,7 +131,7 @@ struct mpfr_float_imp { if(m_data[0]._mpfr_d == 0) mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision())); - boost::ulong_long_type mask = (((1uLL << (std::numeric_limits::digits - 1) - 1) << 1) | 1uLL); + boost::ulong_long_type mask = ((((1uLL << (std::numeric_limits::digits - 1)) - 1) << 1) | 1uLL); unsigned shift = 0; mpfr_t t; mpfr_init2(t, (std::max)(static_cast(std::numeric_limits::digits), static_cast(multiprecision::detail::digits10_2_2(digits10)))); @@ -419,7 +419,7 @@ struct mpfr_float_imp #else mpfr_float_imp& operator = (boost::ulong_long_type i) { - boost::ulong_long_type mask = (((1uLL << (std::numeric_limits::digits - 1) - 1) << 1) | 1uL); + boost::ulong_long_type mask = ((((1uLL << (std::numeric_limits::digits - 1)) - 1) << 1) | 1uL); unsigned shift = 0; mpfr_t t; mp_limb_t t_limbs[limb_count]; @@ -1455,15 +1455,61 @@ namespace tools{ template <> inline int digits() +#ifdef BOOST_MATH_NOEXCEPT + BOOST_NOEXCEPT +#endif { return boost::multiprecision::backends::detail::get_default_precision(); } template <> inline int digits, boost::multiprecision::et_off> >() +#ifdef BOOST_MATH_NOEXCEPT + BOOST_NOEXCEPT +#endif { return boost::multiprecision::backends::detail::get_default_precision(); } +template <> +inline boost::multiprecision::mpfr_float + max_value() +{ + boost::multiprecision::mpfr_float result(0.5); + mpfr_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax(), GMP_RNDN); + BOOST_ASSERT(mpfr_number_p(result.backend().data())); + return result; +} + +template <> +inline boost::multiprecision::mpfr_float + min_value() +{ + boost::multiprecision::mpfr_float result(0.5); + mpfr_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin(), GMP_RNDN); + BOOST_ASSERT(mpfr_number_p(result.backend().data())); + return result; +} + +template <> +inline boost::multiprecision::number, boost::multiprecision::et_off> + max_value, boost::multiprecision::et_off> >() +{ + boost::multiprecision::number, boost::multiprecision::et_off> result(0.5); + mpfr_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax(), GMP_RNDN); + BOOST_ASSERT(mpfr_number_p(result.backend().data())); + return result; +} + +template <> +inline boost::multiprecision::number, boost::multiprecision::et_off> + min_value, boost::multiprecision::et_off> >() +{ + boost::multiprecision::number, boost::multiprecision::et_off> result(0.5); + mpfr_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin(), GMP_RNDN); + BOOST_ASSERT(mpfr_number_p(result.backend().data())); + return result; +} + } // namespace tools namespace constants{ namespace detail{ @@ -1618,7 +1664,7 @@ public: BOOST_STATIC_CONSTEXPR int digits = static_cast((Digits10 * 1000L) / 301L + ((Digits10 * 1000L) % 301 ? 2 : 1)); BOOST_STATIC_CONSTEXPR int digits10 = Digits10; // Is this really correct??? - BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 2; + BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 3; BOOST_STATIC_CONSTEXPR bool is_signed = true; BOOST_STATIC_CONSTEXPR bool is_integer = false; BOOST_STATIC_CONSTEXPR bool is_exact = false; diff --git a/boost/multiprecision/number.hpp b/boost/multiprecision/number.hpp index 92242847de..9d8b64b20e 100644 --- a/boost/multiprecision/number.hpp +++ b/boost/multiprecision/number.hpp @@ -24,6 +24,7 @@ #include #include // stream operators #include // EOF +#include // isspace namespace boost{ namespace multiprecision{ @@ -1706,6 +1707,48 @@ inline std::ostream& operator << (std::ostream& os, const expressionsgetc(); + + for(;; c = is.rdbuf()->snextc()) + if(std::istream::traits_type::eq_int_type(std::istream::traits_type::eof(), c)) + { // end of file: + state |= std::ios_base::eofbit; + break; + } + else if(permitted_chars.find_first_of(std::istream::traits_type::to_char_type(c)) == std::string::npos) + { + // Invalid numeric character, stop reading: + is.rdbuf()->sputbackc(static_cast(c)); + break; + } + else + { + result.append(1, std::istream::traits_type::to_char_type(c)); + } + } + + if(!result.size()) + state |= std::ios_base::failbit; + is.setstate(state); + return result; +} } // namespace detail @@ -1715,12 +1758,27 @@ inline std::istream& operator >> (std::istream& is, number> s; - if(hex_format && (number_category::value == number_kind_integer) && ((s[0] != '0') || (s[1] != 'x'))) - s.insert(s.find_first_not_of("+-"), "0x"); - if(oct_format && (number_category::value == number_kind_integer) && (s[0] != '0')) - s.insert(s.find_first_not_of("+-"), "0"); - r.assign(s); + switch(boost::multiprecision::number_category >::value) + { + case boost::multiprecision::number_kind_integer: + s = detail::read_string_while(is, "+-0xX123456789"); + break; + case boost::multiprecision::number_kind_floating_point: + s = detail::read_string_while(is, "+-eE.0123456789infINFnanNANinfinityINFINITY"); + break; + default: + is >> s; + } + if(s.size()) + { + if(hex_format && (number_category::value == number_kind_integer) && ((s[0] != '0') || (s[1] != 'x'))) + s.insert(s.find_first_not_of("+-"), "0x"); + if(oct_format && (number_category::value == number_kind_integer) && (s[0] != '0')) + s.insert(s.find_first_not_of("+-"), "0"); + r.assign(s); + } + else if(!is.fail()) + is.setstate(std::istream::failbit); return is; } diff --git a/boost/multiprecision/random.hpp b/boost/multiprecision/random.hpp index def97f0582..c6b7d34e03 100644 --- a/boost/multiprecision/random.hpp +++ b/boost/multiprecision/random.hpp @@ -8,590 +8,11 @@ #ifndef BOOST_MP_RANDOM_HPP #define BOOST_MP_RANDOM_HPP -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable:4127) +#if defined(__GNUC__) || defined(_MSC_VER) +# pragma message("NOTE: Use of this header (boost/multiprecision/random.hpp) is deprecated: please use the random number library headers directly.") #endif -#include - -namespace boost{ namespace random{ namespace detail{ -// -// This is a horrible hack: this declaration has to appear before the definition of -// uniform_int_distribution, otherwise it won't be used... -// Need to find a better solution, like make Boost.Random safe to use with -// UDT's and depricate/remove this header altogether. -// -template -boost::multiprecision::number - generate_uniform_int(Engine& eng, const boost::multiprecision::number& min_value, const boost::multiprecision::number& max_value); - -}}} #include -#include - -namespace boost{ -namespace random{ -namespace detail{ - -template -struct subtract, true> -{ - typedef boost::multiprecision::number result_type; - result_type operator()(result_type const& x, result_type const& y) { return x - y; } -}; - -} - -template -class independent_bits_engine > -{ -public: - typedef Engine base_type; - typedef boost::multiprecision::number result_type; - - static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () - { return 0; } - // This is the only function we modify compared to the primary template: - static result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () - { - // This expression allows for the possibility that w == std::numeric_limits::digits: - return (((result_type(1) << (w - 1)) - 1) << 1) + 1; - } - - independent_bits_engine() { } - - BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(independent_bits_engine, - result_type, seed_arg) - { - _base.seed(seed_arg); - } - - BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(independent_bits_engine, - SeedSeq, seq) - { _base.seed(seq); } - - independent_bits_engine(const base_type& base_arg) : _base(base_arg) {} - - template - independent_bits_engine(It& first, It last) : _base(first, last) { } - - void seed() { _base.seed(); } - - BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(independent_bits_engine, - result_type, seed_arg) - { _base.seed(seed_arg); } - - BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(independent_bits_engine, - SeedSeq, seq) - { _base.seed(seq); } - - template void seed(It& first, It last) - { _base.seed(first, last); } - - result_type operator()() - { - // While it may seem wasteful to recalculate this - // every time, both msvc and gcc can propagate - // constants, resolving this at compile time. - base_unsigned range = - detail::subtract()((_base.max)(), (_base.min)()); - std::size_t m = - (range == (std::numeric_limits::max)()) ? - std::numeric_limits::digits : - detail::integer_log2(range + 1); - std::size_t n = (w + m - 1) / m; - std::size_t w0, n0; - base_unsigned y0, y1; - base_unsigned y0_mask, y1_mask; - calc_params(n, range, w0, n0, y0, y1, y0_mask, y1_mask); - if(base_unsigned(range - y0 + 1) > y0 / n) { - // increment n and try again. - ++n; - calc_params(n, range, w0, n0, y0, y1, y0_mask, y1_mask); - } - - BOOST_ASSERT(n0*w0 + (n - n0)*(w0 + 1) == w); - - result_type S = 0; - for(std::size_t k = 0; k < n0; ++k) { - base_unsigned u; - do { - u = detail::subtract()(_base(), (_base.min)()); - } while(u > base_unsigned(y0 - 1)); - S = (S << w0) + (u & y0_mask); - } - for(std::size_t k = 0; k < (n - n0); ++k) { - base_unsigned u; - do { - u = detail::subtract()(_base(), (_base.min)()); - } while(u > base_unsigned(y1 - 1)); - S = (S << (w0 + 1)) + (u & y1_mask); - } - return S; - } - - /** Fills a range with random values */ - template - void generate(Iter first, Iter last) - { detail::generate_from_int(*this, first, last); } - - /** Advances the state of the generator by @c z. */ - void discard(boost::uintmax_t z) - { - for(boost::uintmax_t i = 0; i < z; ++i) { - (*this)(); - } - } - - const base_type& base() const { return _base; } - - /** - * Writes the textual representation if the generator to a @c std::ostream. - * The textual representation of the engine is the textual representation - * of the base engine. - */ - BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, independent_bits_engine, r) - { - os << r._base; - return os; - } - - /** - * Reads the state of an @c independent_bits_engine from a - * @c std::istream. - */ - BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, independent_bits_engine, r) - { - is >> r._base; - return is; - } - - /** - * Returns: true iff the two @c independent_bits_engines will - * produce the same sequence of values. - */ - BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(independent_bits_engine, x, y) - { return x._base == y._base; } - /** - * Returns: true iff the two @c independent_bits_engines will - * produce different sequences of values. - */ - BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(independent_bits_engine) - -private: - - /// \cond show_private - typedef typename base_type::result_type base_result; - typedef typename make_unsigned::type base_unsigned; - - void calc_params( - std::size_t n, base_unsigned range, - std::size_t& w0, std::size_t& n0, - base_unsigned& y0, base_unsigned& y1, - base_unsigned& y0_mask, base_unsigned& y1_mask) - { - BOOST_ASSERT(w >= n); - w0 = w/n; - n0 = n - w % n; - y0_mask = (base_unsigned(2) << (w0 - 1)) - 1; - y1_mask = (y0_mask << 1) | 1; - y0 = (range + 1) & ~y0_mask; - y1 = (range + 1) & ~y1_mask; - BOOST_ASSERT(y0 != 0 || base_unsigned(range + 1) == 0); - } - /// \endcond - - Engine _base; -}; - -template -class uniform_smallint > -{ -public: - typedef boost::multiprecision::number input_type; - typedef boost::multiprecision::number result_type; - - class param_type - { - public: - - typedef uniform_smallint distribution_type; - - /** constructs the parameters of a @c uniform_smallint distribution. */ - param_type(result_type const& min_arg = 0, result_type const& max_arg = 9) - : _min(min_arg), _max(max_arg) - { - BOOST_ASSERT(_min <= _max); - } - - /** Returns the minimum value. */ - result_type a() const { return _min; } - /** Returns the maximum value. */ - result_type b() const { return _max; } - - - /** Writes the parameters to a @c std::ostream. */ - BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, param_type, parm) - { - os << parm._min << " " << parm._max; - return os; - } - - /** Reads the parameters from a @c std::istream. */ - BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, param_type, parm) - { - is >> parm._min >> std::ws >> parm._max; - return is; - } - - /** Returns true if the two sets of parameters are equal. */ - BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(param_type, lhs, rhs) - { return lhs._min == rhs._min && lhs._max == rhs._max; } - - /** Returns true if the two sets of parameters are different. */ - BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type) - - private: - result_type _min; - result_type _max; - }; - - /** - * Constructs a @c uniform_smallint. @c min and @c max are the - * lower and upper bounds of the output range, respectively. - */ - explicit uniform_smallint(result_type const& min_arg = 0, result_type const& max_arg = 9) - : _min(min_arg), _max(max_arg) {} - - /** - * Constructs a @c uniform_smallint from its parameters. - */ - explicit uniform_smallint(const param_type& parm) - : _min(parm.a()), _max(parm.b()) {} - - /** Returns the minimum value of the distribution. */ - result_type a() const { return _min; } - /** Returns the maximum value of the distribution. */ - result_type b() const { return _max; } - /** Returns the minimum value of the distribution. */ - result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _min; } - /** Returns the maximum value of the distribution. */ - result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _max; } - - /** Returns the parameters of the distribution. */ - param_type param() const { return param_type(_min, _max); } - /** Sets the parameters of the distribution. */ - void param(const param_type& parm) - { - _min = parm.a(); - _max = parm.b(); - } - - /** - * Effects: Subsequent uses of the distribution do not depend - * on values produced by any engine prior to invoking reset. - */ - void reset() { } - - /** Returns a value uniformly distributed in the range [min(), max()]. */ - template - result_type operator()(Engine& eng) const - { - typedef typename Engine::result_type base_result; - return generate(eng, boost::is_integral()); - } - - /** Returns a value uniformly distributed in the range [param.a(), param.b()]. */ - template - result_type operator()(Engine& eng, const param_type& parm) const - { return uniform_smallint(parm)(eng); } - - /** Writes the distribution to a @c std::ostream. */ - BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, uniform_smallint, ud) - { - os << ud._min << " " << ud._max; - return os; - } - - /** Reads the distribution from a @c std::istream. */ - BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, uniform_smallint, ud) - { - is >> ud._min >> std::ws >> ud._max; - return is; - } - - /** - * Returns true if the two distributions will produce identical - * sequences of values given equal generators. - */ - BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(uniform_smallint, lhs, rhs) - { return lhs._min == rhs._min && lhs._max == rhs._max; } - - /** - * Returns true if the two distributions may produce different - * sequences of values given equal generators. - */ - BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(uniform_smallint) - -private: - - // \cond show_private - template - result_type generate(Engine& eng, boost::mpl::true_) const - { - // equivalent to (eng() - eng.min()) % (_max - _min + 1) + _min, - // but guarantees no overflow. - typedef typename Engine::result_type base_result; - typedef typename boost::make_unsigned::type base_unsigned; - typedef result_type range_type; - range_type range = random::detail::subtract()(_max, _min); - base_unsigned base_range = - random::detail::subtract()((eng.max)(), (eng.min)()); - base_unsigned val = - random::detail::subtract()(eng(), (eng.min)()); - if(range >= base_range) { - return boost::random::detail::add()( - static_cast(val), _min); - } else { - base_unsigned modulus = static_cast(range) + 1; - return boost::random::detail::add()( - static_cast(val % modulus), _min); - } - } - - template - result_type generate(Engine& eng, boost::mpl::false_) const - { - typedef typename Engine::result_type base_result; - typedef result_type range_type; - range_type range = random::detail::subtract()(_max, _min); - base_result val = boost::uniform_01()(eng); - // what is the worst that can possibly happen here? - // base_result may not be able to represent all the values in [0, range] - // exactly. If this happens, it will cause round off error and we - // won't be able to produce all the values in the range. We don't - // care about this because the user has already told us not to by - // using uniform_smallint. However, we do need to be careful - // to clamp the result, or floating point rounding can produce - // an out of range result. - range_type offset = static_cast(val * (range + 1)); - if(offset > range) return _max; - return boost::random::detail::add()(offset , _min); - } - // \endcond - - result_type _min; - result_type _max; -}; - - -namespace detail{ - -template -struct select_uniform_01 > -{ - template - struct apply - { - typedef new_uniform_01 > type; - }; -}; - -template -boost::multiprecision::number - generate_uniform_int( - Engine& eng, const boost::multiprecision::number& min_value, const boost::multiprecision::number& max_value, - boost::mpl::true_ /** is_integral */) -{ - typedef boost::multiprecision::number result_type; - // Since we're using big-numbers, use the result type for all internal calculations: - typedef result_type range_type; - typedef result_type base_result; - typedef result_type base_unsigned; - const range_type range = random::detail::subtract()(max_value, min_value); - const base_result bmin = (eng.min)(); - const base_unsigned brange = - random::detail::subtract()((eng.max)(), (eng.min)()); - - if(range == 0) { - return min_value; - } else if(brange == range) { - // this will probably never happen in real life - // basically nothing to do; just take care we don't overflow / underflow - base_unsigned v = random::detail::subtract()(eng(), bmin); - return random::detail::add()(v, min_value); - } else if(brange < range) { - // use rejection method to handle things like 0..3 --> 0..4 - for(;;) { - // concatenate several invocations of the base RNG - // take extra care to avoid overflows - - // limit == floor((range+1)/(brange+1)) - // Therefore limit*(brange+1) <= range+1 - range_type limit; - if(std::numeric_limits::is_bounded && (range == (std::numeric_limits::max)())) { - limit = range/(range_type(brange)+1); - if(range % (range_type(brange)+1) == range_type(brange)) - ++limit; - } else { - limit = (range+1)/(range_type(brange)+1); - } - - // We consider "result" as expressed to base (brange+1): - // For every power of (brange+1), we determine a random factor - range_type result = range_type(0); - range_type mult = range_type(1); - - // loop invariants: - // result < mult - // mult <= range - while(mult <= limit) { - // Postcondition: result <= range, thus no overflow - // - // limit*(brange+1)<=range+1 def. of limit (1) - // eng()-bmin<=brange eng() post. (2) - // and mult<=limit. loop condition (3) - // Therefore mult*(eng()-bmin+1)<=range+1 by (1),(2),(3) (4) - // Therefore mult*(eng()-bmin)+mult<=range+1 rearranging (4) (5) - // result(random::detail::subtract()(eng(), bmin) * mult); - - // equivalent to (mult * (brange+1)) == range+1, but avoids overflow. - if(mult * range_type(brange) == range - mult + 1) { - // The destination range is an integer power of - // the generator's range. - return(result); - } - - // Postcondition: mult <= range - // - // limit*(brange+1)<=range+1 def. of limit (1) - // mult<=limit loop condition (2) - // Therefore mult*(brange+1)<=range+1 by (1), (2) (3) - // mult*(brange+1)!=range+1 preceding if (4) - // Therefore mult*(brange+1) limit loop condition (1) - // Suppose range/mult >= brange+1 Assumption (2) - // range >= mult*(brange+1) by (2) (3) - // range+1 > mult*(brange+1) by (3) (4) - // range+1 > (limit+1)*(brange+1) by (1), (4) (5) - // (range+1)/(brange+1) > limit+1 by (5) (6) - // limit < floor((range+1)/(brange+1)) by (6) (7) - // limit==floor((range+1)/(brange+1)) def. of limit (8) - // not (2) reductio (9) - // - // loop postcondition: (range/mult)*mult+(mult-1) >= range - // - // (range/mult)*mult + range%mult == range identity (1) - // range%mult < mult def. of % (2) - // (range/mult)*mult+mult > range by (1), (2) (3) - // (range/mult)*mult+(mult-1) >= range by (3) (4) - // - // Note that the maximum value of result at this point is (mult-1), - // so after this final step, we generate numbers that can be - // at least as large as range. We have to really careful to avoid - // overflow in this final addition and in the rejection. Anything - // that overflows is larger than range and can thus be rejected. - - // range/mult < brange+1 -> no endless loop - range_type result_increment = - generate_uniform_int( - eng, - static_cast(0), - static_cast(range/mult), - boost::mpl::true_()); - if(std::numeric_limits::is_bounded && ((std::numeric_limits::max)() / mult < result_increment)) { - // The multiplication would overflow. Reject immediately. - continue; - } - result_increment *= mult; - // unsigned integers are guaranteed to wrap on overflow. - result += result_increment; - if(result < result_increment) { - // The addition overflowed. Reject. - continue; - } - if(result > range) { - // Too big. Reject. - continue; - } - return random::detail::add()(result, min_value); - } - } else { // brange > range - range_type bucket_size; - // it's safe to add 1 to range, as long as we cast it first, - // because we know that it is less than brange. However, - // we do need to be careful not to cause overflow by adding 1 - // to brange. - if(std::numeric_limits::is_bounded && (brange == (std::numeric_limits::max)())) { - bucket_size = brange / (range+1); - if(brange % (range+1) == range) { - ++bucket_size; - } - } else { - bucket_size = (brange+1) / (range+1); - } - for(;;) { - range_type result = - random::detail::subtract()(eng(), bmin); - result /= bucket_size; - // result and range are non-negative, and result is possibly larger - // than range, so the cast is safe - if(result <= range) - return result + min_value; - } - } -} - -template -inline boost::multiprecision::number - generate_uniform_int(Engine& eng, const boost::multiprecision::number& min_value, const boost::multiprecision::number& max_value) -{ - typedef typename Engine::result_type base_result; - typedef typename mpl::or_, mpl::bool_::value == boost::multiprecision::number_kind_integer> >::type tag_type; - return generate_uniform_int(eng, min_value, max_value, - tag_type()); -} - -template -inline boost::multiprecision::number generate_uniform_real(Engine& eng, const boost::multiprecision::number& min_value, const boost::multiprecision::number& max_value) -{ - if(max_value / 2 - min_value / 2 > (std::numeric_limits >::max)() / 2) - return 2 * generate_uniform_real(eng, boost::multiprecision::number(min_value / 2), boost::multiprecision::number(max_value / 2)); - typedef typename Engine::result_type base_result; - return generate_uniform_real(eng, min_value, max_value, - boost::is_integral()); -} - -} // detail - - -}} // namespaces - -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif #endif diff --git a/boost/multiprecision/tommath.hpp b/boost/multiprecision/tommath.hpp index 9c373443c6..346e5395b4 100644 --- a/boost/multiprecision/tommath.hpp +++ b/boost/multiprecision/tommath.hpp @@ -679,7 +679,7 @@ public: static number_type lowest() { return (min)(); } BOOST_STATIC_CONSTEXPR int digits = INT_MAX; BOOST_STATIC_CONSTEXPR int digits10 = (INT_MAX / 1000) * 301L; - BOOST_STATIC_CONSTEXPR int max_digits10 = digits10 + 2; + BOOST_STATIC_CONSTEXPR int max_digits10 = digits10 + 3; BOOST_STATIC_CONSTEXPR bool is_signed = true; BOOST_STATIC_CONSTEXPR bool is_integer = true; BOOST_STATIC_CONSTEXPR bool is_exact = true; diff --git a/boost/multiprecision/traits/is_byte_container.hpp b/boost/multiprecision/traits/is_byte_container.hpp new file mode 100644 index 0000000000..1efda2930e --- /dev/null +++ b/boost/multiprecision/traits/is_byte_container.hpp @@ -0,0 +1,33 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the 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_IS_BYTE_CONTAINER_HPP +#define BOOST_IS_BYTE_CONTAINER_HPP + +#include +#include + +namespace boost{ namespace multiprecision{ namespace detail{ + + BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_member_value_type, value_type, false); + BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_member_const_iterator, const_iterator, false); + + template + struct is_byte_container_imp + { + static const bool value = boost::is_integral::value && (sizeof(typename C::value_type) == 1); + }; + + template + struct is_byte_container_imp : public boost::false_type {}; + + template + struct is_byte_container : public is_byte_container_imp::value && has_member_const_iterator::value> {}; + + +}}} // namespaces + +#endif // BOOST_IS_BYTE_CONTAINER_HPP + diff --git a/boost/none.hpp b/boost/none.hpp index 87a6c707ce..db744e58ac 100644 --- a/boost/none.hpp +++ b/boost/none.hpp @@ -22,8 +22,10 @@ namespace boost { #ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE + none_t const none = (static_cast(0)) ; -#else + +#elif defined BOOST_OPTIONAL_USE_SINGLETON_DEFINITION_OF_NONE namespace detail { namespace optional_detail { @@ -45,9 +47,13 @@ namespace { const none_t& none = detail::optional_detail::none_instance::instance; } -#endif +#else + +const none_t none ((none_t::init_tag())); + +#endif // older definitions } // namespace boost -#endif +#endif // header guard diff --git a/boost/none_t.hpp b/boost/none_t.hpp index 13ce455b16..608cb0c354 100644 --- a/boost/none_t.hpp +++ b/boost/none_t.hpp @@ -16,13 +16,25 @@ namespace boost { #ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE + namespace detail { struct none_helper{}; } typedef int detail::none_helper::*none_t ; -#else + +#elif defined BOOST_OPTIONAL_USE_SINGLETON_DEFINITION_OF_NONE + class none_t {}; -#endif + +#else + +struct none_t +{ + struct init_tag{}; + explicit none_t(init_tag){} // to prevent default constructor +}; + +#endif // old implementation workarounds } // namespace boost -#endif +#endif // header guard diff --git a/boost/numeric/odeint.hpp b/boost/numeric/odeint.hpp index 1cb8be94f4..e0100899ca 100644 --- a/boost/numeric/odeint.hpp +++ b/boost/numeric/odeint.hpp @@ -71,6 +71,7 @@ #include #include +#include #include diff --git a/boost/numeric/odeint/algebra/default_operations.hpp b/boost/numeric/odeint/algebra/default_operations.hpp index b10944fa19..56139083cc 100644 --- a/boost/numeric/odeint/algebra/default_operations.hpp +++ b/boost/numeric/odeint/algebra/default_operations.hpp @@ -529,7 +529,7 @@ struct default_operations { } template< class Res , class T1 , class T2 , class T3 , class T4 > - Res operator()( Res r , const T1 &x_old , const T2 &x , const T3 &dxdt_old , const T4 &x_err ) + Res operator()( Res r , const T1 &x_old , const T2 &/*x*/ , const T3 &dxdt_old , const T4 &x_err ) { BOOST_USING_STD_MAX(); using std::abs; @@ -574,7 +574,7 @@ struct default_operations { } template< class Res , class T1 , class T2 , class T3 , class T4 > - Res operator()( Res r , const T1 &x_old , const T2 &x , const T3 &dxdt_old , const T4 &x_err ) + Res operator()( Res r , const T1 &x_old , const T2 &/*x*/ , const T3 &dxdt_old , const T4 &x_err ) { using std::abs; Res tmp = abs( get_unit_value( x_err ) ) / diff --git a/boost/numeric/odeint/integrate/check_adapter.hpp b/boost/numeric/odeint/integrate/check_adapter.hpp new file mode 100644 index 0000000000..3d3ebd6c88 --- /dev/null +++ b/boost/numeric/odeint/integrate/check_adapter.hpp @@ -0,0 +1,222 @@ +/* + [auto_generated] + boost/numeric/odeint/integrate/check_adapter.hpp + + [begin_description] + Adapters to add checking facility to stepper and observer + [end_description] + + Copyright 2015 Mario Mulansky + + Distributed under the 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_NUMERIC_ODEINT_INTEGRATE_CHECK_ADAPTER_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_INTEGRATE_CHECK_ADAPTER_HPP_INCLUDED + +#include +#include + + +namespace boost { +namespace numeric { +namespace odeint { + +template::type> +class checked_stepper; + + +/** + * \brief Adapter to combine basic stepper and checker. + */ +template +class checked_stepper +{ + +public: + typedef Stepper stepper_type; + typedef Checker checker_type; + // forward stepper typedefs + typedef typename stepper_type::state_type state_type; + typedef typename stepper_type::value_type value_type; + typedef typename stepper_type::deriv_type deriv_type; + typedef typename stepper_type::time_type time_type; + +private: + stepper_type &m_stepper; + checker_type &m_checker; + +public: + /** + * \brief Construct the checked_stepper. + */ + checked_stepper(stepper_type &stepper, checker_type &checker) + : m_stepper(stepper), m_checker(checker) { } + + /** + * \brief forward of the do_step method + */ + template + void do_step(System system, StateInOut &state, const time_type t, const time_type dt) + { + // do the step + m_stepper.do_step(system, state, t, dt); + // call the checker + m_checker(); + } +}; + + +/** + * \brief Adapter to combine controlled stepper and checker. + */ +template +class checked_stepper +{ + +public: + typedef ControlledStepper stepper_type; + typedef Checker checker_type; + // forward stepper typedefs + typedef typename stepper_type::state_type state_type; + typedef typename stepper_type::value_type value_type; + typedef typename stepper_type::deriv_type deriv_type; + typedef typename stepper_type::time_type time_type; + +private: + stepper_type &m_stepper; + checker_type &m_checker; + +public: + /** + * \brief Construct the checked_stepper. + */ + checked_stepper(stepper_type &stepper, checker_type &checker) + : m_stepper(stepper), m_checker(checker) { } + + /** + * \brief forward of the do_step method + */ + template< class System , class StateInOut > + controlled_step_result try_step( System system , StateInOut &state , time_type &t , time_type &dt ) + { + // do the step + if( m_stepper.try_step(system, state, t, dt) == success ) + { + // call the checker if step was successful + m_checker(); + return success; + } else + { + // step failed -> return fail + return fail; + } + } +}; + + +/** + * \brief Adapter to combine dense out stepper and checker. + */ +template +class checked_stepper +{ + +public: + typedef DenseOutStepper stepper_type; + typedef Checker checker_type; + // forward stepper typedefs + typedef typename stepper_type::state_type state_type; + typedef typename stepper_type::value_type value_type; + typedef typename stepper_type::deriv_type deriv_type; + typedef typename stepper_type::time_type time_type; + +private: + stepper_type &m_stepper; + checker_type &m_checker; + +public: + /** + * \brief Construct the checked_stepper. + */ + checked_stepper(stepper_type &stepper, checker_type &checker) + : m_stepper(stepper), m_checker(checker) { } + + + template< class System > + std::pair< time_type , time_type > do_step( System system ) + { + m_checker(); + return m_stepper.do_step(system); + } + + /* provide the remaining dense out stepper interface */ + template< class StateType > + void initialize( const StateType &x0 , time_type t0 , time_type dt0 ) + { m_stepper.initialize(x0, t0, dt0); } + + + template< class StateOut > + void calc_state( time_type t , StateOut &x ) const + { m_stepper.calc_state(t, x); } + + template< class StateOut > + void calc_state( time_type t , const StateOut &x ) const + { m_stepper.calc_state(t, x); } + + const state_type& current_state( void ) const + { return m_stepper.current_state(); } + + time_type current_time( void ) const + { return m_stepper.current_time(); } + + const state_type& previous_state( void ) const + { return m_stepper.previous_state(); } + + time_type previous_time( void ) const + { return m_stepper.previous_time(); } + + time_type current_time_step( void ) const + { return m_stepper.current_time_step(); } + +}; + + +/** + * \brief Adapter to combine observer and checker. + */ +template +class checked_observer +{ +public: + typedef Observer observer_type; + typedef Checker checker_type; + +private: + observer_type &m_observer; + checker_type &m_checker; + +public: + checked_observer(observer_type &observer, checker_type &checker) + : m_observer(observer), m_checker(checker) + {} + + template< class State , class Time > + void operator()(const State& state, Time t) const + { + // call the observer + m_observer(state, t); + // reset the checker + m_checker.reset(); + } +}; + + +} // namespace odeint +} // namespace numeric +} // namespace boost + +#endif \ No newline at end of file diff --git a/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp b/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp index 743e57709c..7516d44087 100644 --- a/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp +++ b/boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp @@ -7,7 +7,7 @@ [end_description] Copyright 2011-2013 Karsten Ahnert - Copyright 2011-2012 Mario Mulansky + Copyright 2011-2015 Mario Mulansky Copyright 2012 Christoph Koke Distributed under the Boost Software License, Version 1.0. @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -41,7 +42,7 @@ namespace odeint { namespace detail { // forward declaration -template< class Stepper , class System , class State , class Time , class Observer> +template< class Stepper , class System , class State , class Time , class Observer > size_t integrate_const( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , @@ -74,7 +75,7 @@ size_t integrate_adaptive( /* - * classical integrate adaptive + * integrate adaptive for controlled stepper */ template< class Stepper , class System , class State , class Time , class Observer > size_t integrate_adaptive( @@ -86,8 +87,7 @@ size_t integrate_adaptive( typename odeint::unwrap_reference< Observer >::type &obs = observer; typename odeint::unwrap_reference< Stepper >::type &st = stepper; - const size_t max_attempts = 1000; - const char *error_string = "Integrate adaptive : Maximal number of iterations reached. A step size could not be found."; + failed_step_checker fail_checker; // to throw a runtime_error if step size adjustment fails size_t count = 0; while( less_with_sign( start_time , end_time , dt ) ) { @@ -97,15 +97,14 @@ size_t integrate_adaptive( dt = end_time - start_time; } - size_t trials = 0; controlled_step_result res; do { res = st.try_step( system , start_state , start_time , dt ); - ++trials; + fail_checker(); // check number of failed steps } - while( ( res == fail ) && ( trials < max_attempts ) ); - if( trials == max_attempts ) BOOST_THROW_EXCEPTION( std::overflow_error( error_string ) ); + while( res == fail ); + fail_checker.reset(); // if we reach here, the step was successful -> reset fail checker ++count; } diff --git a/boost/numeric/odeint/integrate/detail/integrate_const.hpp b/boost/numeric/odeint/integrate/detail/integrate_const.hpp index 312564ff16..7a86b32fa6 100644 --- a/boost/numeric/odeint/integrate/detail/integrate_const.hpp +++ b/boost/numeric/odeint/integrate/detail/integrate_const.hpp @@ -6,7 +6,7 @@ integrate const implementation [end_description] - Copyright 2012 Mario Mulansky + Copyright 2012-2015 Mario Mulansky Copyright 2012 Christoph Koke Copyright 2012 Karsten Ahnert @@ -43,12 +43,13 @@ template< class Stepper , class System , class State , class Time , class Observ size_t integrate_const( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , - Observer observer , stepper_tag + Observer observer , stepper_tag ) { + typename odeint::unwrap_reference< Observer >::type &obs = observer; typename odeint::unwrap_reference< Stepper >::type &st = stepper; - + Time time = start_time; int step = 0; // cast time+dt explicitely in case of expression templates (e.g. multiprecision) @@ -72,11 +73,11 @@ template< class Stepper , class System , class State , class Time , class Observ size_t integrate_const( Stepper stepper , System system , State &start_state , Time start_time , Time end_time , Time dt , - Observer observer , controlled_stepper_tag + Observer observer , controlled_stepper_tag ) { typename odeint::unwrap_reference< Observer >::type &obs = observer; - + Time time = start_time; const Time time_step = dt; int real_steps = 0; @@ -85,8 +86,10 @@ size_t integrate_const( while( less_eq_with_sign( static_cast