Merge remote-tracking branch 'upstream/master'

This commit is contained in:
2017-09-18 09:49:56 +03:00
commit 8b0d48f478
5143 changed files with 243341 additions and 67650 deletions

1
.gitignore vendored
View File

@ -191,6 +191,7 @@ config-9001.xml
*-preprocessed.xml
core
!core/
vgcore*
*.deb

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "contrib/mariadb-connector-c"]
path = contrib/mariadb-connector-c
url = https://github.com/MariaDB/mariadb-connector-c.git

View File

@ -1,3 +1,41 @@
# ClickHouse release 1.1.54289
## New features:
* `SYSTEM` queries for server administration: `SYSTEM RELOAD DICTIONARY`, `SYSTEM RELOAD DICTIONARIES`, `SYSTEM DROP DNS CACHE`, `SYSTEM SHUTDOWN`, `SYSTEM KILL`.
* Added functions for working with arrays: `concat`, `arraySlice`, `arrayPushBack`, `arrayPushFront`, `arrayPopBack`, `arrayPopFront`.
* Added the `root` and `identity` parameters for the ZooKeeper configuration. This allows you to isolate individual users on the same ZooKeeper cluster.
* Added the aggregate functions `groupBitAnd`, `groupBitOr`, and `groupBitXor` (for compatibility, they can also be accessed with the names `BIT_AND`, `BIT_OR`, and `BIT_XOR`).
* External dictionaries can be loaded from MySQL by specifying a socket in the filesystem.
* External dictionaries can be loaded from MySQL over SSL (the `ssl_cert`, `ssl_key`, and `ssl_ca` parameters).
* Added the `max_network_bandwidth_for_user` setting to restrict the overall bandwidth use for queries per user.
* Support for `DROP TABLE` for temporary tables.
* Support for reading `DateTime` values in Unix timestamp format from the `CSV` and `JSONEachRow` formats.
* Lagging replicas in distributed queries are now excluded by default (the default threshold is 5 minutes).
* FIFO locking is used during ALTER: an ALTER query isn't blocked indefinitely for continuously running queries.
* Option to set `umask` in the config file.
* Improved performance for queries with `DISTINCT`.
## Bug fixes:
* Improved the process for deleting old nodes in ZooKeeper. Previously, old nodes sometimes didn't get deleted if there were very frequent inserts, which caused the server to be slow to shut down, among other things.
* Fixed randomization when choosing hosts for the connection to ZooKeeper.
* Fixed the exclusion of lagging replicas in distributed queries if the replica is localhost.
* Fixed an error where a data part in a `ReplicatedMergeTree` table could be broken after running `ALTER MODIFY` on an element in a `Nested` structure.
* Fixed an error that could cause SELECT queries to "hang".
* Improvements to distributed DDL queries.
* Fixed the query `CREATE TABLE ... AS <materialized view>`.
* Resolved the deadlock in the `ALTER ... CLEAR COLUMN IN PARTITION` query for `Buffer` tables.
* Fixed the invalid default value for `Enum`s (0 instead of the minimum) when using the `JSONEachRow` and `TSKV` formats.
* Resolved the appearance of zombie processes when using a dictionary with an `executable` source.
* Fixed segfault for the HEAD query.
## Improvements to development workflow and ClickHouse build:
* You can use `pbuilder` to build ClickHouse.
* You can use `libc++` instead of `libstdc++` for builds on Linux.
* Added instructions for using static code analysis tools: `Coverity`, `clang-tidy`, and `cppcheck`.
## Please note when upgrading:
* There is now a higher default value for the MergeTree setting `max_bytes_to_merge_at_max_space_in_pool` (the maximum total size of data parts to merge, in bytes): it has increased from 100 GiB to 150 GiB. This might result in large merges running after the server upgrade, which could cause an increased load on the disk subsystem. If the free space available on the server is less than twice the total amount of the merges that are running, this will cause all other merges to stop running, including merges of small data parts. As a result, INSERT requests will fail with the message "Merges are processing significantly slower than inserts." Use the `SELECT * FROM system.merges` request to monitor the situation. You can also check the `DiskSpaceReservedForMerge` metric in the `system.metrics` table, or in Graphite. You don't need to do anything to fix this, since the issue will resolve itself once the large merges finish. If you find this unacceptable, you can restore the previous value for the `max_bytes_to_merge_at_max_space_in_pool` setting (to do this, go to the `<merge_tree>` section in config.xml, set `<max_bytes_to_merge_at_max_space_in_pool>107374182400</max_bytes_to_merge_at_max_space_in_pool>` and restart the server).
# ClickHouse release 1.1.54284
* This is bugfix release for previous 1.1.54282 release. It fixes ZooKeeper nodes leak in `parts/` directory.

View File

@ -1,3 +1,41 @@
# Релиз ClickHouse 1.1.54289
## Новые возможности:
* Запросы `SYSTEM` для административных действий с сервером: `SYSTEM RELOAD DICTIONARY`, `SYSTEM RELOAD DICTIONARIES`, `SYSTEM DROP DNS CACHE`, `SYSTEM SHUTDOWN`, `SYSTEM KILL`.
* Добавлены функции для работы с массивами: `concat`, `arraySlice`, `arrayPushBack`, `arrayPushFront`, `arrayPopBack`, `arrayPopFront`.
* Добавлены параметры `root` и `identity` для конфигурации ZooKeeper. Это позволяет изолировать разных пользователей одного ZooKeeper кластера.
* Добавлены агрегатные функции `groupBitAnd`, `groupBitOr`, `groupBitXor` (для совместимости доступны также под именами `BIT_AND`, `BIT_OR`, `BIT_XOR`).
* Возможность загрузки внешних словарей из MySQL с указанием сокета на файловой системе.
* Возможность загрузки внешних словарей из MySQL через SSL соединение (параметры `ssl_cert`, `ssl_key`, `ssl_ca`).
* Добавлена настройка `max_network_bandwidth_for_user` для ограничения общего потребления сети для всех запросов одного пользователя.
* Поддержка `DROP TABLE` для временных таблиц.
* Поддержка чтения значений типа `DateTime` в формате unix timestamp из форматов `CSV` и `JSONEachRow`.
* Включено по-умолчанию отключение отстающих реплик при распределённых запросах (по-умолчанию порог равен 5 минутам).
* Используются FIFO блокировки при ALTER: выполнение ALTER не будет неограниченно блокироваться при непрерывно выполняющихся запросах.
* Возможность задать `umask` в конфигурационном файле.
* Увеличена производительность запросов с `DISTINCT`.
## Исправления ошибок:
* Более оптимальная процедура удаления старых нод в ZooKeeper. Ранее в случае очень частых вставок, старые ноды могли не успевать удаляться, что приводило, в том числе, к очень долгому завершению сервера.
* Исправлена рандомизация при выборе хостов для соединения с ZooKeeper.
* Исправлено отключение отстающей реплики при распределённых запросах, если реплика является localhost.
* Исправлена ошибка, в связи с которой кусок данных таблицы типа `ReplicatedMergeTree` мог становиться битым после выполнения `ALTER MODIFY` элемента `Nested` структуры.
* Исправлена ошибка приводящая к возможному зависанию SELECT запросов.
* Доработки распределённых DDL запросов.
* Исправлен запрос `CREATE TABLE ... AS <materialized view>`.
* Исправлен дедлок при запросе `ALTER ... CLEAR COLUMN IN PARTITION` для `Buffer` таблиц.
* Исправлено использование неправильного значения по-умолчанию для `Enum`-ов (0 вместо минимального) при использовании форматов `JSONEachRow` и `TSKV`.
* Исправлено появление zombie процессов при работе со словарём с источником `executable`.
* Исправлен segfault при запросе HEAD.
## Улучшения процесса разработки и сборки ClickHouse:
* Возможность сборки с помощью `pbuilder`.
* Возможность сборки с использованием `libc++` вместо `libstdc++` под Linux.
* Добавлены инструкции для использования статических анализаторов кода `Coverity`, `clang-tidy`, `cppcheck`.
## На что обратить внимание при обновлении:
* Увеличено значение по-умолчанию для настройки MergeTree `max_bytes_to_merge_at_max_space_in_pool` (максимальный суммарный размер кусков в байтах для мержа) со 100 GiB до 150 GiB. Это может привести к запуску больших мержей после обновления сервера, что может вызвать повышенную нагрузку на дисковую подсистему. Если же на серверах, где это происходит, количество свободного места менее чем в два раза больше суммарного объёма выполняющихся мержей, то в связи с этим перестанут выполняться какие-либо другие мержи, включая мержи мелких кусков. Это приведёт к тому, что INSERT-ы будут отклоняться с сообщением "Merges are processing significantly slower than inserts". Для наблюдения, используйте запрос `SELECT * FROM system.merges`. Вы также можете смотреть на метрику `DiskSpaceReservedForMerge` в таблице `system.metrics` или в Graphite. Для исправления этой ситуации можно ничего не делать, так как она нормализуется сама после завершения больших мержей. Если же вас это не устраивает, вы можете вернуть настройку `max_bytes_to_merge_at_max_space_in_pool` в старое значение, прописав в config.xml в секции `<merge_tree>` `<max_bytes_to_merge_at_max_space_in_pool>107374182400</max_bytes_to_merge_at_max_space_in_pool>` и перезапустить сервер.
# Релиз ClickHouse 1.1.54284
* Релиз содержит изменения к предыдущему релизу 1.1.54282, которые исправляют утечку записей о кусках в ZooKeeper

View File

@ -27,16 +27,16 @@ endif ()
cmake_policy (SET CMP0014 OLD) # Ignore warning about CMakeLists.txt in each directory
cmake_policy (SET CMP0012 NEW) # Don't dereference TRUE and FALSE
find_program (CCACHE_FOUND ccache)
if (CCACHE_FOUND AND NOT CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache" AND NOT CMAKE_CXX_COMPILER MATCHES "ccache")
set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache")
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK "ccache")
endif ()
# Write compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
include (cmake/find_ccache.cmake)
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "None")
message (STATUS "CMAKE_BUILD_TYPE is not set, set to default = RELWITHDEBINFO")
set (CMAKE_BUILD_TYPE "RELWITHDEBINFO")
endif ()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
message (STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} )
# ASan - build type with address sanitizer
@ -50,6 +50,13 @@ endif ()
if (ARCH_AARCH64 OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
set (ARCH_ARM 1)
endif ()
if (CMAKE_LIBRARY_ARCHITECTURE MATCHES "i386")
set (ARCH_I386 1)
endif ()
if ( ( ARCH_ARM AND NOT ARCH_AARCH64 ) OR ARCH_I386)
set (ARCH_32 1)
message (WARNING "Support 32bit platforms is highly experimental")
endif ()
set (COMMON_WARNING_FLAGS "-Wall") # -Werror is also added inside directories with our own code.
set (CXX_WARNING_FLAGS "-Wnon-virtual-dtor")
@ -64,11 +71,16 @@ if (USE_STATIC_LIBRARIES)
list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
endif ()
option (GLIBC_COMPATIBILITY "Set to TRUE to enable compatibility with older glibc libraries. Note that it is not compatible with ASan." OFF)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
option (USE_INTERNAL_MEMCPY "Use internal implementation of 'memcpy' function instead of provided by libc. Only for x86_64." ON)
if (CMAKE_SYSTEM MATCHES "Linux")
option (GLIBC_COMPATIBILITY "Set to TRUE to enable compatibility with older glibc libraries. Only for x86_64, Linux. Implies USE_INTERNAL_MEMCPY." ON)
endif()
endif ()
if (GLIBC_COMPATIBILITY)
set (GLIBC_COMPATIBILITY_COMPILE_FLAGS "-include ${ClickHouse_SOURCE_DIR}/libs/libcommon/include/common/glibc_compatibility.h")
set (GLIBC_COMPATIBILITY_LINK_FLAGS "-Wl,--wrap=memcpy")
set (USE_INTERNAL_MEMCPY ON)
endif ()
if (CXX11_ABI STREQUAL ENABLE)
@ -79,20 +91,32 @@ else ()
set (CXX11_ABI_FLAGS "")
endif ()
set (COMPILER_FLAGS "${COMPILER_FLAGS} ${CXX11_ABI_FLAGS}")
set (COMPILER_FLAGS "${COMPILER_FLAGS} ${CXX11_ABI_FLAGS}")
option (PIPE "-pipe compiler option [less /tmp usage, more ram usage]" ON)
if (PIPE)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -pipe")
set (COMPILER_FLAGS "${COMPILER_FLAGS} -pipe")
endif ()
include (cmake/test_cpu.cmake)
option (ARCHNATIVE "Enable -march=native compiler flag" OFF)
if (ARCHNATIVE)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -march=native")
set (COMPILER_FLAGS "${COMPILER_FLAGS} -march=native")
endif ()
option (USE_LIBCXX "Use libc++ and libc++abi instead of libstdc++ (only make sense on Linux with Clang)" OFF)
if (USE_LIBCXX)
set (COMPILER_FLAGS "${COMPILER_FLAGS} -pthread") # NOTE: Why this is not the default and why this is needed only with libc++?
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_LIBCPP_DEBUG=1") # More checks in debug build.
endif ()
# Special options for better optimized code with clang
#if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Wno-unused-command-line-argument -mllvm -inline-threshold=10000")
#endif ()
set (CMAKE_BUILD_COLOR_MAKEFILE ON)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS} -std=gnu++1z ${PLATFORM_EXTRA_CXX_FLAG} -fno-omit-frame-pointer ${COMMON_WARNING_FLAGS} ${CXX_WARNING_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS}")
#set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
@ -105,11 +129,16 @@ set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3 -ggdb3 -fno-inline")
if (NOT APPLE AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_SYSTEM MATCHES "FreeBSD"))
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
endif ()
if (NOT APPLE)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GLIBC_COMPATIBILITY_LINK_FLAGS} ${CXX11_ABI_FLAGS}")
if (USE_LIBCXX AND (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
link_libraries (-Wl,-Bstatic -stdlib=libc++ c++ c++abi -Wl,-Bdynamic)
endif ()
endif ()
include (cmake/test_compiler.cmake)
@ -138,6 +167,18 @@ set (CMAKE_C_FLAGS_MSAN "${CMAKE_C_FLAGS_MSAN} ${SAN_FLAGS}
set (CMAKE_CXX_FLAGS_TSAN "${CMAKE_CXX_FLAGS_TSAN} ${SAN_FLAGS} -fsanitize=thread")
set (CMAKE_C_FLAGS_TSAN "${CMAKE_C_FLAGS_TSAN} ${SAN_FLAGS} -fsanitize=thread")
# Using "include-what-you-use" tool.
option (USE_INCLUDE_WHAT_YOU_USE "Use 'include-what-you-use' tool" OFF)
if (USE_INCLUDE_WHAT_YOU_USE)
find_program(IWYU_PATH NAMES include-what-you-use iwyu)
if (NOT IWYU_PATH)
message(FATAL_ERROR "Could not find the program include-what-you-use")
endif()
if (${CMAKE_VERSION} VERSION_LESS "3.3.0")
message(FATAL_ERROR "include-what-you-use requires CMake version at least 3.3.")
endif()
endif ()
# Flags for test coverage
if (TEST_COVERAGE)
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -DIS_DEBUG")
@ -161,12 +202,12 @@ if (UNBUNDLED)
else ()
set(NOT_UNBUNDLED 1)
endif ()
# Using system libs can cause lot of warnings in includes.
if (UNBUNDLED OR NOT (CMAKE_SYSTEM MATCHES "Linux" OR APPLE))
# Using system libs can cause lot of warnings in includes.
if (UNBUNDLED OR NOT (CMAKE_SYSTEM MATCHES "Linux" OR APPLE) OR ARCH_32)
option (NO_WERROR "Disable -Werror compiler option" ON)
endif ()
message (STATUS "Building for: ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_PROCESSOR} ${CMAKE_LIBRARY_ARCHITECTURE} ; USE_STATIC_LIBRARIES=${USE_STATIC_LIBRARIES} MAKE_STATIC_LIBRARIES=${MAKE_STATIC_LIBRARIES} UNBUNDLED=${UNBUNDLED} CCACHE=${CCACHE_FOUND}")
message (STATUS "Building for: ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_PROCESSOR} ${CMAKE_LIBRARY_ARCHITECTURE} ; USE_STATIC_LIBRARIES=${USE_STATIC_LIBRARIES} MAKE_STATIC_LIBRARIES=${MAKE_STATIC_LIBRARIES} UNBUNDLED=${UNBUNDLED} CCACHE=${CCACHE_FOUND} ${CCACHE_VERSION}")
include(GNUInstallDirs)
@ -204,8 +245,8 @@ include (libs/libmysqlxx/cmake/find_mysqlclient.cmake)
include (libs/libdaemon/cmake/find_unwind.cmake)
set (FULL_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}")
set (FULL_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
set (FULL_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
set (FULL_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
message (STATUS "C_FLAGS = ${FULL_C_FLAGS}")
message (STATUS "CXX_FLAGS = ${FULL_CXX_FLAGS}")
message (STATUS "LINK_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}")

View File

@ -3,7 +3,7 @@ option (USE_INTERNAL_BOOST_LIBRARY "Set to FALSE to use system boost library ins
if (NOT USE_INTERNAL_BOOST_LIBRARY)
set (Boost_USE_STATIC_LIBS ${USE_STATIC_LIBRARIES})
set (BOOST_ROOT "/usr/local")
find_package (Boost 1.60 COMPONENTS program_options system filesystem regex thread)
find_package (Boost 1.60 COMPONENTS program_options system filesystem thread)
# incomplete, no include search, who use it?
if (NOT Boost_FOUND)
# # Try to find manually.
@ -24,7 +24,7 @@ if (NOT Boost_SYSTEM_LIBRARY)
set (Boost_PROGRAM_OPTIONS_LIBRARY boost_program_options_internal)
set (Boost_SYSTEM_LIBRARY boost_system_internal)
set (Boost_FILESYSTEM_LIBRARY boost_filesystem_internal)
set (Boost_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/libboost/boost_1_62_0/")
set (Boost_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/libboost/boost_1_65_0/")
endif ()
message (STATUS "Using Boost: ${Boost_INCLUDE_DIRS} : ${Boost_PROGRAM_OPTIONS_LIBRARY},${Boost_SYSTEM_LIBRARY},${Boost_FILESYSTEM_LIBRARY}")

14
cmake/find_ccache.cmake Normal file
View File

@ -0,0 +1,14 @@
find_program (CCACHE_FOUND ccache)
if (CCACHE_FOUND AND NOT CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache" AND NOT CMAKE_CXX_COMPILER MATCHES "ccache")
execute_process(COMMAND ${CCACHE_FOUND} "-V" OUTPUT_VARIABLE CCACHE_VERSION)
string(REGEX REPLACE "ccache version ([0-9\\.]+).*" "\\1" CCACHE_VERSION ${CCACHE_VERSION} )
if (CCACHE_VERSION VERSION_GREATER "3.2.0" OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
#message(STATUS "Using ${CCACHE_FOUND} ${CCACHE_VERSION}")
set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_FOUND})
else ()
message(STATUS "Not using ${CCACHE_FOUND} ${CCACHE_VERSION} bug: https://bugzilla.samba.org/show_bug.cgi?id=8118")
endif ()
endif ()

View File

@ -4,3 +4,4 @@ set(CITYHASH_CONTRIB_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/libcityhash/in
set(COMMON_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/libs/libcommon/include ${ClickHouse_BINARY_DIR}/libs/libcommon/include)
set(DBMS_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/dbms/src ${ClickHouse_BINARY_DIR}/dbms/src)
set(DOUBLE_CONVERSION_CONTRIB_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/libdouble-conversion)
set(PCG_RANDOM_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/libpcg-random/include)

View File

@ -1,31 +1,31 @@
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast")
if (USE_INTERNAL_BOOST_LIBRARY)
add_subdirectory (libboost)
add_subdirectory (libboost)
endif ()
if (USE_INTERNAL_POCO_LIBRARY)
add_subdirectory (libpoco)
add_subdirectory (libpoco)
endif ()
if (USE_INTERNAL_LZ4_LIBRARY)
add_subdirectory (liblz4)
add_subdirectory (liblz4)
endif ()
if (USE_INTERNAL_ZSTD_LIBRARY)
add_subdirectory (libzstd)
add_subdirectory (libzstd)
endif ()
if (USE_INTERNAL_RE2_LIBRARY)
add_subdirectory (libre2)
add_subdirectory (libre2)
endif ()
if (USE_INTERNAL_DOUBLE_CONVERSION_LIBRARY)
add_subdirectory (libdouble-conversion)
add_subdirectory (libdouble-conversion)
endif ()
if (USE_INTERNAL_ZOOKEEPER_LIBRARY)
add_subdirectory (libzookeeper)
add_subdirectory (libzookeeper)
endif ()
if (USE_INTERNAL_CITYHASH_LIBRARY)
@ -45,26 +45,21 @@ if (USE_INTERNAL_BTRIE_LIBRARY)
endif ()
if (USE_INTERNAL_UNWIND_LIBRARY)
add_subdirectory (libunwind)
add_subdirectory (libunwind)
endif ()
if (USE_INTERNAL_ZLIB_LIBRARY)
add_subdirectory (libzlib-ng)
add_subdirectory (libzlib-ng)
endif ()
if (USE_INTERNAL_CCTZ_LIBRARY)
add_subdirectory (libcctz)
add_subdirectory (libcctz)
endif ()
if (ENABLE_LIBTCMALLOC AND USE_INTERNAL_GPERFTOOLS_LIBRARY)
add_subdirectory (libtcmalloc)
add_subdirectory (libtcmalloc)
endif ()
if (NOT ARCH_ARM)
add_subdirectory (libcpuid)
endif ()
if (USE_INTERNAL_MYSQL_LIBRARY)
add_subdirectory (mariadb-connector-c)
target_include_directories (${MYSQLCLIENT_LIBRARIES} BEFORE PUBLIC ${MYSQL_INCLUDE_DIR})
add_subdirectory (libcpuid)
endif ()

View File

@ -2,54 +2,31 @@ add_definitions(-Wno-unused-variable)
add_definitions(-Wno-deprecated-declarations)
add_library(boost_program_options_internal
boost_1_62_0/libs/program_options/src/cmdline.cpp
boost_1_62_0/libs/program_options/src/config_file.cpp
boost_1_62_0/libs/program_options/src/convert.cpp
boost_1_62_0/libs/program_options/src/options_description.cpp
boost_1_62_0/libs/program_options/src/parsers.cpp
boost_1_62_0/libs/program_options/src/positional_options.cpp
boost_1_62_0/libs/program_options/src/split.cpp
boost_1_62_0/libs/program_options/src/utf8_codecvt_facet.cpp
boost_1_62_0/libs/program_options/src/value_semantic.cpp
boost_1_62_0/libs/program_options/src/variables_map.cpp
boost_1_62_0/libs/program_options/src/winmain.cpp)
boost_1_65_0/libs/program_options/src/cmdline.cpp
boost_1_65_0/libs/program_options/src/config_file.cpp
boost_1_65_0/libs/program_options/src/convert.cpp
boost_1_65_0/libs/program_options/src/options_description.cpp
boost_1_65_0/libs/program_options/src/parsers.cpp
boost_1_65_0/libs/program_options/src/positional_options.cpp
boost_1_65_0/libs/program_options/src/split.cpp
boost_1_65_0/libs/program_options/src/utf8_codecvt_facet.cpp
boost_1_65_0/libs/program_options/src/value_semantic.cpp
boost_1_65_0/libs/program_options/src/variables_map.cpp
boost_1_65_0/libs/program_options/src/winmain.cpp)
add_library(boost_filesystem_internal
boost_1_62_0/libs/filesystem/src/codecvt_error_category.cpp
boost_1_62_0/libs/filesystem/src/operations.cpp
boost_1_62_0/libs/filesystem/src/path.cpp
boost_1_62_0/libs/filesystem/src/path_traits.cpp
boost_1_62_0/libs/filesystem/src/portability.cpp
boost_1_62_0/libs/filesystem/src/unique_path.cpp
boost_1_62_0/libs/filesystem/src/utf8_codecvt_facet.cpp
boost_1_62_0/libs/filesystem/src/windows_file_codecvt.cpp)
boost_1_65_0/libs/filesystem/src/codecvt_error_category.cpp
boost_1_65_0/libs/filesystem/src/operations.cpp
boost_1_65_0/libs/filesystem/src/path.cpp
boost_1_65_0/libs/filesystem/src/path_traits.cpp
boost_1_65_0/libs/filesystem/src/portability.cpp
boost_1_65_0/libs/filesystem/src/unique_path.cpp
boost_1_65_0/libs/filesystem/src/utf8_codecvt_facet.cpp
boost_1_65_0/libs/filesystem/src/windows_file_codecvt.cpp)
add_library(boost_system_internal
boost_1_62_0/libs/system/src/error_code.cpp)
add_library(boost_test_internal
boost_1_62_0/libs/test/src/compiler_log_formatter.cpp
boost_1_62_0/libs/test/src/cpp_main.cpp
boost_1_62_0/libs/test/src/debug.cpp
boost_1_62_0/libs/test/src/decorator.cpp
boost_1_62_0/libs/test/src/execution_monitor.cpp
boost_1_62_0/libs/test/src/framework.cpp
boost_1_62_0/libs/test/src/junit_log_formatter.cpp
boost_1_62_0/libs/test/src/plain_report_formatter.cpp
boost_1_62_0/libs/test/src/progress_monitor.cpp
boost_1_62_0/libs/test/src/results_collector.cpp
boost_1_62_0/libs/test/src/results_reporter.cpp
boost_1_62_0/libs/test/src/test_main.cpp
boost_1_62_0/libs/test/src/test_tools.cpp
boost_1_62_0/libs/test/src/test_tree.cpp
boost_1_62_0/libs/test/src/unit_test_log.cpp
boost_1_62_0/libs/test/src/unit_test_main.cpp
boost_1_62_0/libs/test/src/unit_test_monitor.cpp
boost_1_62_0/libs/test/src/unit_test_parameters.cpp
boost_1_62_0/libs/test/src/xml_log_formatter.cpp
boost_1_62_0/libs/test/src/xml_report_formatter.cpp)
boost_1_65_0/libs/system/src/error_code.cpp)
target_include_directories (boost_program_options_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS})
target_include_directories (boost_filesystem_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS})
target_include_directories (boost_system_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS})
target_include_directories (boost_test_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS})

View File

@ -1,27 +0,0 @@
/*
(c) 2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_ALIGN_DOWN_HPP
#define BOOST_ALIGN_ALIGN_DOWN_HPP
#include <boost/align/detail/align_down.hpp>
#include <boost/align/align_down_forward.hpp>
namespace boost {
namespace alignment {
BOOST_CONSTEXPR inline std::size_t align_down(std::size_t value,
std::size_t alignment) BOOST_NOEXCEPT
{
return value & ~(alignment - 1);
}
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,24 +0,0 @@
/*
(c) 2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_ALIGN_DOWN_FORWARD_HPP
#define BOOST_ALIGN_ALIGN_DOWN_FORWARD_HPP
#include <boost/config.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
BOOST_CONSTEXPR std::size_t align_down(std::size_t value,
std::size_t alignment) BOOST_NOEXCEPT;
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,27 +0,0 @@
/*
(c) 2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_ALIGN_UP_HPP
#define BOOST_ALIGN_ALIGN_UP_HPP
#include <boost/align/detail/align_up.hpp>
#include <boost/align/align_up_forward.hpp>
namespace boost {
namespace alignment {
BOOST_CONSTEXPR inline std::size_t align_up(std::size_t value,
std::size_t alignment) BOOST_NOEXCEPT
{
return (value + alignment - 1) & ~(alignment - 1);
}
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,24 +0,0 @@
/*
(c) 2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_ALIGN_UP_FORWARD_HPP
#define BOOST_ALIGN_ALIGN_UP_FORWARD_HPP
#include <boost/config.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
BOOST_CONSTEXPR std::size_t align_up(std::size_t value,
std::size_t alignment) BOOST_NOEXCEPT;
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,20 +0,0 @@
/*
(c) 2014-2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_ALIGNED_DELETE_FORWARD_HPP
#define BOOST_ALIGN_ALIGNED_DELETE_FORWARD_HPP
namespace boost {
namespace alignment {
struct aligned_delete;
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,21 +0,0 @@
/*
(c) 2014 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_ALIGNMENT_OF_FORWARD_HPP
#define BOOST_ALIGN_ALIGNMENT_OF_FORWARD_HPP
namespace boost {
namespace alignment {
template<class T>
struct alignment_of;
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,22 +0,0 @@
/*
(c) 2014 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP
#define BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP
#include <memory>
namespace boost {
namespace alignment {
using std::align;
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,28 +0,0 @@
/*
(c) 2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGN_DOWN_HPP
#define BOOST_ALIGN_DETAIL_ALIGN_DOWN_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/align/align_down_forward.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace alignment {
inline void* align_down(void* ptr, std::size_t alignment) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return (void*)(align_down((std::size_t)ptr, alignment));
}
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,28 +0,0 @@
/*
(c) 2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGN_UP_HPP
#define BOOST_ALIGN_DETAIL_ALIGN_UP_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/align/align_up_forward.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace alignment {
inline void* align_up(void* ptr, std::size_t alignment) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return (void*)(align_up((std::size_t)ptr, alignment));
}
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,17 +0,0 @@
/*
(c) 2015 NumScale SAS
(c) 2015 LRI UMR 8623 CNRS/University Paris Sud XI
(c) 2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_HPP
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n)
#endif

View File

@ -1,18 +0,0 @@
/*
(c) 2015 NumScale SAS
(c) 2015 LRI UMR 8623 CNRS/University Paris Sud XI
(c) 2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_GCC_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_GCC_HPP
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n) \
(p) = (__typeof__(p))(__builtin_assume_aligned((p), (n)))
#endif

View File

@ -1,18 +0,0 @@
/*
(c) 2015 NumScale SAS
(c) 2015 LRI UMR 8623 CNRS/University Paris Sud XI
(c) 2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_INTEL_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_INTEL_HPP
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n) \
__assume_aligned((p), (n))
#endif

View File

@ -1,20 +0,0 @@
/*
(c) 2015 NumScale SAS
(c) 2015 LRI UMR 8623 CNRS/University Paris Sud XI
(c) 2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_MSVC_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_MSVC_HPP
#include <cstddef>
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n) \
__assume(((std::size_t)(p) & ((n) - 1)) == 0)
#endif

View File

@ -1,36 +0,0 @@
/*
(c) 2014 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_DETAIL_IS_ALIGNED_HPP
#define BOOST_ALIGN_DETAIL_IS_ALIGNED_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/align/is_aligned_forward.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace alignment {
inline bool is_aligned(const void* ptr, std::size_t alignment)
BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return is_aligned((std::size_t)ptr, alignment);
}
inline bool is_aligned(std::size_t alignment, const void* ptr)
BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return is_aligned((std::size_t)ptr, alignment);
}
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,29 +0,0 @@
/*
(c) 2014 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_DETAIL_IS_ALIGNMENT_HPP
#define BOOST_ALIGN_DETAIL_IS_ALIGNMENT_HPP
#include <boost/config.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
namespace detail {
BOOST_CONSTEXPR inline bool is_alignment(std::size_t value)
BOOST_NOEXCEPT
{
return (value > 0) && ((value & (value - 1)) == 0);
}
} /* .detail */
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,27 +0,0 @@
/*
(c) 2014 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_IS_ALIGNED_HPP
#define BOOST_ALIGN_IS_ALIGNED_HPP
#include <boost/align/detail/is_aligned.hpp>
#include <boost/align/is_aligned_forward.hpp>
namespace boost {
namespace alignment {
BOOST_CONSTEXPR inline bool is_aligned(std::size_t value,
std::size_t alignment) BOOST_NOEXCEPT
{
return (value & (alignment - 1)) == 0;
}
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,24 +0,0 @@
/*
(c) 2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_IS_ALIGNED_FORWARD_HPP
#define BOOST_ALIGN_IS_ALIGNED_FORWARD_HPP
#include <boost/config.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
BOOST_CONSTEXPR bool is_aligned(std::size_t value,
std::size_t alignment) BOOST_NOEXCEPT;
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,35 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2014-2014.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_CONTAINER_DETAIL_ALGORITHM_HPP
#define BOOST_CONTAINER_DETAIL_ALGORITHM_HPP
#ifndef BOOST_CONFIG_HPP
# include <boost/config.hpp>
#endif
#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/intrusive/detail/algorithm.hpp>
namespace boost {
namespace container {
using boost::intrusive::algo_equal;
using boost::intrusive::algo_lexicographical_compare;
} //namespace container {
} //namespace boost {
#endif //#ifndef BOOST_CONTAINER_DETAIL_ALGORITHM_HPP

View File

@ -1,383 +0,0 @@
/*
template <class Value, unsigned int Options = 0, class Hash = hash<Value>, class Pred = equal_to<Value>,
class Allocator = allocator<Value> >
class hash_set
{
public:
// types
typedef Value key_type;
typedef key_type value_type;
typedef Hash hasher;
typedef Pred key_equal;
typedef Allocator allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
typedef typename allocator_traits<allocator_type>::size_type size_type;
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
typedef /unspecified/ iterator;
typedef /unspecified/ const_iterator;
typedef /unspecified/ local_iterator;
typedef /unspecified/ const_local_iterator;
hash_set()
noexcept(
is_nothrow_default_constructible<hasher>::value &&
is_nothrow_default_constructible<key_equal>::value &&
is_nothrow_default_constructible<allocator_type>::value);
explicit hash_set(size_type n, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
template <class InputIterator>
hash_set(InputIterator f, InputIterator l,
size_type n = 0, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
explicit hash_set(const allocator_type&);
hash_set(const hash_set&);
hash_set(const hash_set&, const Allocator&);
hash_set(hash_set&&)
noexcept(
is_nothrow_move_constructible<hasher>::value &&
is_nothrow_move_constructible<key_equal>::value &&
is_nothrow_move_constructible<allocator_type>::value);
hash_set(hash_set&&, const Allocator&);
hash_set(initializer_list<value_type>, size_type n = 0,
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
~hash_set();
hash_set& operator=(const hash_set&);
hash_set& operator=(hash_set&&)
noexcept(
allocator_type::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value &&
is_nothrow_move_assignable<hasher>::value &&
is_nothrow_move_assignable<key_equal>::value);
hash_set& operator=(initializer_list<value_type>);
allocator_type get_allocator() const noexcept;
bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
iterator begin() noexcept;
iterator end() noexcept;
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
template <class... Args>
pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args);
template <class... Args>
iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args);
pair<iterator, bool> insert(const value_type& obj);
pair<iterator, bool> insert(value_type&& obj);
iterator insert(const_iterator hint, const value_type& obj);
iterator insert(const_iterator hint, value_type&& obj);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
void swap(hash_set&)
noexcept(
(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value) &&
__is_nothrow_swappable<hasher>::value &&
__is_nothrow_swappable<key_equal>::value);
hasher hash_function() const;
key_equal key_eq() const;
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
size_type bucket_count() const noexcept;
size_type max_bucket_count() const noexcept;
size_type bucket_size(size_type n) const;
size_type bucket(const key_type& k) const;
local_iterator begin(size_type n);
local_iterator end(size_type n);
const_local_iterator begin(size_type n) const;
const_local_iterator end(size_type n) const;
const_local_iterator cbegin(size_type n) const;
const_local_iterator cend(size_type n) const;
float load_factor() const noexcept;
float max_load_factor() const noexcept;
void max_load_factor(float z);
void rehash(size_type n);
void reserve(size_type n);
};
template <class Key, class T, unsigned int Options = 0, class Hash = hash<Key>, class Pred = equal_to<Key>,
class Allocator = allocator<pair<const Key, T> > >
class hash_map
{
public:
// types
typedef Key key_type;
typedef T mapped_type;
typedef Hash hasher;
typedef Pred key_equal;
typedef Allocator allocator_type;
typedef pair<const key_type, mapped_type> value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
typedef typename allocator_traits<allocator_type>::size_type size_type;
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
typedef /unspecified/ iterator;
typedef /unspecified/ const_iterator;
typedef /unspecified/ local_iterator;
typedef /unspecified/ const_local_iterator;
hash_map()
noexcept(
is_nothrow_default_constructible<hasher>::value &&
is_nothrow_default_constructible<key_equal>::value &&
is_nothrow_default_constructible<allocator_type>::value);
explicit hash_map(size_type n, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
template <class InputIterator>
hash_map(InputIterator f, InputIterator l,
size_type n = 0, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
explicit hash_map(const allocator_type&);
hash_map(const hash_map&);
hash_map(const hash_map&, const Allocator&);
hash_map(hash_map&&)
noexcept(
is_nothrow_move_constructible<hasher>::value &&
is_nothrow_move_constructible<key_equal>::value &&
is_nothrow_move_constructible<allocator_type>::value);
hash_map(hash_map&&, const Allocator&);
hash_map(initializer_list<value_type>, size_type n = 0,
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
~hash_map();
hash_map& operator=(const hash_map&);
hash_map& operator=(hash_map&&)
noexcept(
allocator_type::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value &&
is_nothrow_move_assignable<hasher>::value &&
is_nothrow_move_assignable<key_equal>::value);
hash_map& operator=(initializer_list<value_type>);
allocator_type get_allocator() const noexcept;
bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
iterator begin() noexcept;
iterator end() noexcept;
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
template <class... Args>
pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args);
template <class... Args>
iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args);
pair<iterator, bool> insert(const value_type& obj);
template <class P>
pair<iterator, bool> insert(P&& obj);
iterator insert(const_iterator hint, const value_type& obj);
template <class P>
iterator insert(const_iterator hint, P&& obj);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
void swap(hash_map&)
noexcept(
(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value) &&
__is_nothrow_swappable<hasher>::value &&
__is_nothrow_swappable<key_equal>::value);
hasher hash_function() const;
key_equal key_eq() const;
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
mapped_type& operator[](const key_type& k);
mapped_type& operator[](key_type&& k);
mapped_type& at(const key_type& k);
const mapped_type& at(const key_type& k) const;
size_type bucket_count() const noexcept;
size_type max_bucket_count() const noexcept;
size_type bucket_size(size_type n) const;
size_type bucket(const key_type& k) const;
local_iterator begin(size_type n);
local_iterator end(size_type n);
const_local_iterator begin(size_type n) const;
const_local_iterator end(size_type n) const;
const_local_iterator cbegin(size_type n) const;
const_local_iterator cend(size_type n) const;
float load_factor() const noexcept;
float max_load_factor() const noexcept;
void max_load_factor(float z);
void rehash(size_type n);
void reserve(size_type n);
};
*/
template <class Key, class Value, class KeyOfValue, unsigned int Options = 0, class Hash = hash<Key>, class Pred = equal_to<Key>,
class Allocator = allocator<Value> >
class hash_table
{
public:
// types
typedef Value key_type;
typedef key_type value_type;
typedef Hash hasher;
typedef Pred key_equal;
typedef Allocator allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
typedef typename allocator_traits<allocator_type>::size_type size_type;
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
typedef /unspecified/ iterator;
typedef /unspecified/ const_iterator;
typedef /unspecified/ local_iterator;
typedef /unspecified/ const_local_iterator;
hash_set()
noexcept(
is_nothrow_default_constructible<hasher>::value &&
is_nothrow_default_constructible<key_equal>::value &&
is_nothrow_default_constructible<allocator_type>::value);
explicit hash_set(size_type n, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
template <class InputIterator>
hash_set(InputIterator f, InputIterator l,
size_type n = 0, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
explicit hash_set(const allocator_type&);
hash_set(const hash_set&);
hash_set(const hash_set&, const Allocator&);
hash_set(hash_set&&)
noexcept(
is_nothrow_move_constructible<hasher>::value &&
is_nothrow_move_constructible<key_equal>::value &&
is_nothrow_move_constructible<allocator_type>::value);
hash_set(hash_set&&, const Allocator&);
hash_set(initializer_list<value_type>, size_type n = 0,
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
~hash_set();
hash_set& operator=(const hash_set&);
hash_set& operator=(hash_set&&)
noexcept(
allocator_type::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value &&
is_nothrow_move_assignable<hasher>::value &&
is_nothrow_move_assignable<key_equal>::value);
hash_set& operator=(initializer_list<value_type>);
allocator_type get_allocator() const noexcept;
bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
iterator begin() noexcept;
iterator end() noexcept;
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
template <class... Args>
pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args);
template <class... Args>
iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args);
pair<iterator, bool> insert(const value_type& obj);
pair<iterator, bool> insert(value_type&& obj);
iterator insert(const_iterator hint, const value_type& obj);
iterator insert(const_iterator hint, value_type&& obj);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
void swap(hash_set&)
noexcept(
(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value) &&
__is_nothrow_swappable<hasher>::value &&
__is_nothrow_swappable<key_equal>::value);
hasher hash_function() const;
key_equal key_eq() const;
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
size_type bucket_count() const noexcept;
size_type max_bucket_count() const noexcept;
size_type bucket_size(size_type n) const;
size_type bucket(const key_type& k) const;
local_iterator begin(size_type n);
local_iterator end(size_type n);
const_local_iterator begin(size_type n) const;
const_local_iterator end(size_type n) const;
const_local_iterator cbegin(size_type n) const;
const_local_iterator cend(size_type n) const;
float load_factor() const noexcept;
float max_load_factor() const noexcept;
void max_load_factor(float z);
void rehash(size_type n);
void reserve(size_type n);
};

View File

@ -1,162 +0,0 @@
// Copyright (C) 2002 Brad King (brad.king@kitware.com)
// Douglas Gregor (gregod@cs.rpi.edu)
//
// Copyright (C) 2002, 2008, 2013 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)
// For more information, see http://www.boost.org
#ifndef BOOST_CORE_ADDRESSOF_HPP
#define BOOST_CORE_ADDRESSOF_HPP
# include <boost/config.hpp>
# include <boost/detail/workaround.hpp>
# include <cstddef>
namespace boost
{
namespace detail
{
template<class T> struct addr_impl_ref
{
T & v_;
BOOST_FORCEINLINE addr_impl_ref( T & v ): v_( v ) {}
BOOST_FORCEINLINE operator T& () const { return v_; }
private:
addr_impl_ref & operator=(const addr_impl_ref &);
};
template<class T> struct addressof_impl
{
static BOOST_FORCEINLINE T * f( T & v, long )
{
return reinterpret_cast<T*>(
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
}
static BOOST_FORCEINLINE T * f( T * v, int )
{
return v;
}
};
#if !defined( BOOST_NO_CXX11_NULLPTR )
#if !defined( BOOST_NO_CXX11_DECLTYPE ) && ( ( defined( __clang__ ) && !defined( _LIBCPP_VERSION ) ) || defined( __INTEL_COMPILER ) )
typedef decltype(nullptr) addr_nullptr_t;
#else
typedef std::nullptr_t addr_nullptr_t;
#endif
template<> struct addressof_impl< addr_nullptr_t >
{
typedef addr_nullptr_t T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
}
};
template<> struct addressof_impl< addr_nullptr_t const >
{
typedef addr_nullptr_t const T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
}
};
template<> struct addressof_impl< addr_nullptr_t volatile >
{
typedef addr_nullptr_t volatile T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
}
};
template<> struct addressof_impl< addr_nullptr_t const volatile >
{
typedef addr_nullptr_t const volatile T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
}
};
#endif
} // namespace detail
template<class T>
BOOST_FORCEINLINE
T * addressof( T & v )
{
#if (defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) ) || (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5120))
return boost::detail::addressof_impl<T>::f( v, 0 );
#else
return boost::detail::addressof_impl<T>::f( boost::detail::addr_impl_ref<T>( v ), 0 );
#endif
}
#if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) )
namespace detail
{
template<class T> struct addressof_addp
{
typedef T * type;
};
} // namespace detail
template< class T, std::size_t N >
BOOST_FORCEINLINE
typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] )
{
return &t;
}
#endif
// Borland doesn't like casting an array reference to a char reference
// but these overloads work around the problem.
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
template<typename T,std::size_t N>
BOOST_FORCEINLINE
T (*addressof(T (&t)[N]))[N]
{
return reinterpret_cast<T(*)[N]>(&t);
}
template<typename T,std::size_t N>
BOOST_FORCEINLINE
const T (*addressof(const T (&t)[N]))[N]
{
return reinterpret_cast<const T(*)[N]>(&t);
}
#endif
} // namespace boost
#endif // BOOST_CORE_ADDRESSOF_HPP

View File

@ -1,171 +0,0 @@
#ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP
#define BOOST_CORE_LIGHTWEIGHT_TEST_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
//
// boost/core/lightweight_test.hpp - lightweight test library
//
// Copyright (c) 2002, 2009, 2014 Peter Dimov
// Copyright (2) Beman Dawes 2010, 2011
// Copyright (3) Ion Gaztanaga 2013
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/assert.hpp>
#include <boost/current_function.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <iostream>
// IDE's like Visual Studio perform better if output goes to std::cout or
// some other stream, so allow user to configure output stream:
#ifndef BOOST_LIGHTWEIGHT_TEST_OSTREAM
# define BOOST_LIGHTWEIGHT_TEST_OSTREAM std::cerr
#endif
namespace boost
{
namespace detail
{
struct report_errors_reminder
{
bool called_report_errors_function;
report_errors_reminder() : called_report_errors_function(false) {}
~report_errors_reminder()
{
BOOST_ASSERT(called_report_errors_function); // verify report_errors() was called
}
};
inline report_errors_reminder& report_errors_remind()
{
static report_errors_reminder r;
return r;
}
inline int & test_errors()
{
static int x = 0;
report_errors_remind();
return x;
}
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr << "' failed in function '"
<< function << "'" << std::endl;
++test_errors();
}
inline void error_impl(char const * msg, char const * file, int line, char const * function)
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): " << msg << " in function '"
<< function << "'" << std::endl;
++test_errors();
}
inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function)
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): Exception '" << excep << "' not thrown in function '"
<< function << "'" << std::endl;
++test_errors();
}
template<class T, class U> inline void test_eq_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
{
if( t == u )
{
report_errors_remind();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
<< "' failed in function '" << function << "': "
<< "'" << t << "' != '" << u << "'" << std::endl;
++test_errors();
}
}
template<class T, class U> inline void test_ne_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
{
if( t != u )
{
report_errors_remind();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " != " << expr2
<< "' failed in function '" << function << "': "
<< "'" << t << "' == '" << u << "'" << std::endl;
++test_errors();
}
}
} // namespace detail
inline int report_errors()
{
boost::detail::report_errors_remind().called_report_errors_function = true;
int errors = boost::detail::test_errors();
if( errors == 0 )
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< "No errors detected." << std::endl;
return 0;
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< errors << " error" << (errors == 1? "": "s") << " detected." << std::endl;
return 1;
}
}
} // namespace boost
#define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#ifndef BOOST_NO_EXCEPTIONS
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
try { \
EXPR; \
::boost::detail::throw_failed_impl \
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
catch(EXCEP const&) { \
} \
catch(...) { \
::boost::detail::throw_failed_impl \
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
//
#else
#define BOOST_TEST_THROWS( EXPR, EXCEP )
#endif
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP

View File

@ -1,46 +0,0 @@
//Copyright (c) 2006-2013 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef UUID_9011016A11A711E3B46CD9FA6088709B
#define UUID_9011016A11A711E3B46CD9FA6088709B
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma GCC system_header
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(push,1)
#endif
#include <boost/exception/info.hpp>
#include <boost/exception/get_error_info.hpp>
namespace
boost
{
//Here we're using the boost::error_info machinery to store the info in the exception
//object. Within the context of N3757, this is strictly an implementation detail.
template <class Tag>
inline
void
exception::
set( typename Tag::type const & v )
{
exception_detail::set_info(*this,error_info<Tag,typename Tag::type>(v));
}
template <class Tag>
inline
typename Tag::type const *
exception::
get() const
{
return get_error_info<error_info<Tag,typename Tag::type> >(*this);
}
}
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(pop)
#endif
#endif

View File

@ -1,460 +0,0 @@
// Boost common_factor_rt.hpp header file ----------------------------------//
// (C) Copyright Daryle Walker and Paul Moore 2001-2002. Permission to copy,
// use, modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided "as is"
// without express or implied warranty, and with no claim as to its suitability
// for any purpose.
// boostinspect:nolicense (don't complain about the lack of a Boost license)
// (Paul Moore hasn't been in contact for years, so there's no way to change the
// license.)
// See http://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_INTEGER_COMMON_FACTOR_RT_HPP
#define BOOST_INTEGER_COMMON_FACTOR_RT_HPP
#include <boost/integer_fwd.hpp> // self include
#include <boost/config.hpp> // for BOOST_NESTED_TEMPLATE, etc.
#include <boost/limits.hpp> // for std::numeric_limits
#include <climits> // for CHAR_MIN
#include <boost/detail/workaround.hpp>
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4127 4244) // Conditional expression is constant
#endif
namespace boost
{
namespace integer
{
// Forward declarations for function templates -----------------------------//
template < typename IntegerType >
IntegerType gcd( IntegerType const &a, IntegerType const &b );
template < typename IntegerType >
IntegerType lcm( IntegerType const &a, IntegerType const &b );
// Greatest common divisor evaluator class declaration ---------------------//
template < typename IntegerType >
class gcd_evaluator
{
public:
// Types
typedef IntegerType result_type, first_argument_type, second_argument_type;
// Function object interface
result_type operator ()( first_argument_type const &a,
second_argument_type const &b ) const;
}; // boost::integer::gcd_evaluator
// Least common multiple evaluator class declaration -----------------------//
template < typename IntegerType >
class lcm_evaluator
{
public:
// Types
typedef IntegerType result_type, first_argument_type, second_argument_type;
// Function object interface
result_type operator ()( first_argument_type const &a,
second_argument_type const &b ) const;
}; // boost::integer::lcm_evaluator
// Implementation details --------------------------------------------------//
namespace detail
{
// Greatest common divisor for rings (including unsigned integers)
template < typename RingType >
RingType
gcd_euclidean
(
RingType a,
RingType b
)
{
// Avoid repeated construction
#ifndef __BORLANDC__
RingType const zero = static_cast<RingType>( 0 );
#else
RingType zero = static_cast<RingType>( 0 );
#endif
// Reduce by GCD-remainder property [GCD(a,b) == GCD(b,a MOD b)]
while ( true )
{
if ( a == zero )
return b;
b %= a;
if ( b == zero )
return a;
a %= b;
}
}
// Greatest common divisor for (signed) integers
template < typename IntegerType >
inline
IntegerType
gcd_integer
(
IntegerType const & a,
IntegerType const & b
)
{
// Avoid repeated construction
IntegerType const zero = static_cast<IntegerType>( 0 );
IntegerType const result = gcd_euclidean( a, b );
return ( result < zero ) ? static_cast<IntegerType>(-result) : result;
}
// Greatest common divisor for unsigned binary integers
template < typename BuiltInUnsigned >
BuiltInUnsigned
gcd_binary
(
BuiltInUnsigned u,
BuiltInUnsigned v
)
{
if ( u && v )
{
// Shift out common factors of 2
unsigned shifts = 0;
while ( !(u & 1u) && !(v & 1u) )
{
++shifts;
u >>= 1;
v >>= 1;
}
// Start with the still-even one, if any
BuiltInUnsigned r[] = { u, v };
unsigned which = static_cast<bool>( u & 1u );
// Whittle down the values via their differences
do
{
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
while ( !(r[ which ] & 1u) )
{
r[ which ] = (r[which] >> 1);
}
#else
// Remove factors of two from the even one
while ( !(r[ which ] & 1u) )
{
r[ which ] >>= 1;
}
#endif
// Replace the larger of the two with their difference
if ( r[!which] > r[which] )
{
which ^= 1u;
}
r[ which ] -= r[ !which ];
}
while ( r[which] );
// Shift-in the common factor of 2 to the residues' GCD
return r[ !which ] << shifts;
}
else
{
// At least one input is zero, return the other
// (adding since zero is the additive identity)
// or zero if both are zero.
return u + v;
}
}
// Least common multiple for rings (including unsigned integers)
template < typename RingType >
inline
RingType
lcm_euclidean
(
RingType const & a,
RingType const & b
)
{
RingType const zero = static_cast<RingType>( 0 );
RingType const temp = gcd_euclidean( a, b );
return ( temp != zero ) ? ( a / temp * b ) : zero;
}
// Least common multiple for (signed) integers
template < typename IntegerType >
inline
IntegerType
lcm_integer
(
IntegerType const & a,
IntegerType const & b
)
{
// Avoid repeated construction
IntegerType const zero = static_cast<IntegerType>( 0 );
IntegerType const result = lcm_euclidean( a, b );
return ( result < zero ) ? static_cast<IntegerType>(-result) : result;
}
// Function objects to find the best way of computing GCD or LCM
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
template < typename T, bool IsSpecialized, bool IsSigned >
struct gcd_optimal_evaluator_helper_t
{
T operator ()( T const &a, T const &b )
{
return gcd_euclidean( a, b );
}
};
template < typename T >
struct gcd_optimal_evaluator_helper_t< T, true, true >
{
T operator ()( T const &a, T const &b )
{
return gcd_integer( a, b );
}
};
template < typename T >
struct gcd_optimal_evaluator
{
T operator ()( T const &a, T const &b )
{
typedef ::std::numeric_limits<T> limits_type;
typedef gcd_optimal_evaluator_helper_t<T,
limits_type::is_specialized, limits_type::is_signed> helper_type;
helper_type solver;
return solver( a, b );
}
};
#else // BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
template < typename T >
struct gcd_optimal_evaluator
{
T operator ()( T const &a, T const &b )
{
return gcd_integer( a, b );
}
};
#endif
// Specialize for the built-in integers
#define BOOST_PRIVATE_GCD_UF( Ut ) \
template < > struct gcd_optimal_evaluator<Ut> \
{ Ut operator ()( Ut a, Ut b ) const { return gcd_binary( a, b ); } }
BOOST_PRIVATE_GCD_UF( unsigned char );
BOOST_PRIVATE_GCD_UF( unsigned short );
BOOST_PRIVATE_GCD_UF( unsigned );
BOOST_PRIVATE_GCD_UF( unsigned long );
#ifdef BOOST_HAS_LONG_LONG
BOOST_PRIVATE_GCD_UF( boost::ulong_long_type );
#elif defined(BOOST_HAS_MS_INT64)
BOOST_PRIVATE_GCD_UF( unsigned __int64 );
#endif
#if CHAR_MIN == 0
BOOST_PRIVATE_GCD_UF( char ); // char is unsigned
#endif
#undef BOOST_PRIVATE_GCD_UF
#define BOOST_PRIVATE_GCD_SF( St, Ut ) \
template < > struct gcd_optimal_evaluator<St> \
{ St operator ()( St a, St b ) const { Ut const a_abs = \
static_cast<Ut>( a < 0 ? -a : +a ), b_abs = static_cast<Ut>( \
b < 0 ? -b : +b ); return static_cast<St>( \
gcd_optimal_evaluator<Ut>()(a_abs, b_abs) ); } }
BOOST_PRIVATE_GCD_SF( signed char, unsigned char );
BOOST_PRIVATE_GCD_SF( short, unsigned short );
BOOST_PRIVATE_GCD_SF( int, unsigned );
BOOST_PRIVATE_GCD_SF( long, unsigned long );
#if CHAR_MIN < 0
BOOST_PRIVATE_GCD_SF( char, unsigned char ); // char is signed
#endif
#ifdef BOOST_HAS_LONG_LONG
BOOST_PRIVATE_GCD_SF( boost::long_long_type, boost::ulong_long_type );
#elif defined(BOOST_HAS_MS_INT64)
BOOST_PRIVATE_GCD_SF( __int64, unsigned __int64 );
#endif
#undef BOOST_PRIVATE_GCD_SF
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
template < typename T, bool IsSpecialized, bool IsSigned >
struct lcm_optimal_evaluator_helper_t
{
T operator ()( T const &a, T const &b )
{
return lcm_euclidean( a, b );
}
};
template < typename T >
struct lcm_optimal_evaluator_helper_t< T, true, true >
{
T operator ()( T const &a, T const &b )
{
return lcm_integer( a, b );
}
};
template < typename T >
struct lcm_optimal_evaluator
{
T operator ()( T const &a, T const &b )
{
typedef ::std::numeric_limits<T> limits_type;
typedef lcm_optimal_evaluator_helper_t<T,
limits_type::is_specialized, limits_type::is_signed> helper_type;
helper_type solver;
return solver( a, b );
}
};
#else // BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
template < typename T >
struct lcm_optimal_evaluator
{
T operator ()( T const &a, T const &b )
{
return lcm_integer( a, b );
}
};
#endif
// Functions to find the GCD or LCM in the best way
template < typename T >
inline
T
gcd_optimal
(
T const & a,
T const & b
)
{
gcd_optimal_evaluator<T> solver;
return solver( a, b );
}
template < typename T >
inline
T
lcm_optimal
(
T const & a,
T const & b
)
{
lcm_optimal_evaluator<T> solver;
return solver( a, b );
}
} // namespace detail
// Greatest common divisor evaluator member function definition ------------//
template < typename IntegerType >
inline
typename gcd_evaluator<IntegerType>::result_type
gcd_evaluator<IntegerType>::operator ()
(
first_argument_type const & a,
second_argument_type const & b
) const
{
return detail::gcd_optimal( a, b );
}
// Least common multiple evaluator member function definition --------------//
template < typename IntegerType >
inline
typename lcm_evaluator<IntegerType>::result_type
lcm_evaluator<IntegerType>::operator ()
(
first_argument_type const & a,
second_argument_type const & b
) const
{
return detail::lcm_optimal( a, b );
}
// Greatest common divisor and least common multiple function definitions --//
template < typename IntegerType >
inline
IntegerType
gcd
(
IntegerType const & a,
IntegerType const & b
)
{
gcd_evaluator<IntegerType> solver;
return solver( a, b );
}
template < typename IntegerType >
inline
IntegerType
lcm
(
IntegerType const & a,
IntegerType const & b
)
{
lcm_evaluator<IntegerType> solver;
return solver( a, b );
}
} // namespace integer
} // namespace boost
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#endif // BOOST_INTEGER_COMMON_FACTOR_RT_HPP

View File

@ -1,47 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2014-2014
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/intrusive for documentation.
//
/////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_INTRUSIVE_DETAIL_TO_RAW_POINTER_HPP
#define BOOST_INTRUSIVE_DETAIL_TO_RAW_POINTER_HPP
#ifndef BOOST_CONFIG_HPP
# include <boost/config.hpp>
#endif
#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/detail/workaround.hpp>
#include <boost/intrusive/detail/pointer_element.hpp>
namespace boost {
namespace intrusive {
namespace detail {
template <class T>
BOOST_INTRUSIVE_FORCEINLINE T* to_raw_pointer(T* p)
{ return p; }
template <class Pointer>
BOOST_INTRUSIVE_FORCEINLINE typename boost::intrusive::pointer_element<Pointer>::type*
to_raw_pointer(const Pointer &p)
{ return boost::intrusive::detail::to_raw_pointer(p.operator->()); }
} //namespace detail
} //namespace intrusive
} //namespace boost
#include <boost/intrusive/detail/config_end.hpp>
#endif //BOOST_INTRUSIVE_DETAIL_UTILITIES_HPP

View File

@ -1,97 +0,0 @@
// Boost common_factor_ct.hpp header file ----------------------------------//
// (C) Copyright Daryle Walker and Stephen Cleary 2001-2002.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_MATH_COMMON_FACTOR_CT_HPP
#define BOOST_MATH_COMMON_FACTOR_CT_HPP
#include <boost/math_fwd.hpp> // self include
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
#include <boost/mpl/integral_c.hpp>
namespace boost
{
namespace math
{
// Implementation details --------------------------------------------------//
namespace detail
{
// Build GCD with Euclid's recursive algorithm
template < static_gcd_type Value1, static_gcd_type Value2 >
struct static_gcd_helper_t
{
private:
BOOST_STATIC_CONSTANT( static_gcd_type, new_value1 = Value2 );
BOOST_STATIC_CONSTANT( static_gcd_type, new_value2 = Value1 % Value2 );
#ifndef __BORLANDC__
#define BOOST_DETAIL_GCD_HELPER_VAL(Value) static_cast<static_gcd_type>(Value)
#else
typedef static_gcd_helper_t self_type;
#define BOOST_DETAIL_GCD_HELPER_VAL(Value) (self_type:: Value )
#endif
typedef static_gcd_helper_t< BOOST_DETAIL_GCD_HELPER_VAL(new_value1),
BOOST_DETAIL_GCD_HELPER_VAL(new_value2) > next_step_type;
#undef BOOST_DETAIL_GCD_HELPER_VAL
public:
BOOST_STATIC_CONSTANT( static_gcd_type, value = next_step_type::value );
};
// Non-recursive case
template < static_gcd_type Value1 >
struct static_gcd_helper_t< Value1, 0UL >
{
BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 );
};
// Build the LCM from the GCD
template < static_gcd_type Value1, static_gcd_type Value2 >
struct static_lcm_helper_t
{
typedef static_gcd_helper_t<Value1, Value2> gcd_type;
BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 / gcd_type::value
* Value2 );
};
// Special case for zero-GCD values
template < >
struct static_lcm_helper_t< 0UL, 0UL >
{
BOOST_STATIC_CONSTANT( static_gcd_type, value = 0UL );
};
} // namespace detail
// Compile-time greatest common divisor evaluator class declaration --------//
template < static_gcd_type Value1, static_gcd_type Value2 >
struct static_gcd : public mpl::integral_c<static_gcd_type, (detail::static_gcd_helper_t<Value1, Value2>::value) >
{
}; // boost::math::static_gcd
// Compile-time least common multiple evaluator class declaration ----------//
template < static_gcd_type Value1, static_gcd_type Value2 >
struct static_lcm : public mpl::integral_c<static_gcd_type, (detail::static_lcm_helper_t<Value1, Value2>::value) >
{
}; // boost::math::static_lcm
} // namespace math
} // namespace boost
#endif // BOOST_MATH_COMMON_FACTOR_CT_HPP

View File

@ -1,428 +0,0 @@
// (C) Copyright Jeremy William Murphy 2016.
// 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_COMMON_FACTOR_RT_HPP
#define BOOST_MATH_COMMON_FACTOR_RT_HPP
#include <boost/assert.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/type_traits.hpp>
#include <boost/config.hpp> // for BOOST_NESTED_TEMPLATE, etc.
#include <boost/limits.hpp> // for std::numeric_limits
#include <climits> // for CHAR_MIN
#include <boost/detail/workaround.hpp>
#include <iterator>
#include <algorithm>
#include <limits>
#if (defined(BOOST_MSVC) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
#include <intrin.h>
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4127 4244) // Conditional expression is constant
#endif
namespace boost {
namespace math {
template <class T, bool a = is_unsigned<T>::value || (std::numeric_limits<T>::is_specialized && !std::numeric_limits<T>::is_signed)>
struct gcd_traits_abs_defaults
{
inline static const T& abs(const T& val) { return val; }
};
template <class T>
struct gcd_traits_abs_defaults<T, false>
{
inline static T abs(const T& val)
{
using std::abs;
return abs(val);
}
};
template <class T>
struct gcd_traits_defaults : public gcd_traits_abs_defaults<T>
{
BOOST_FORCEINLINE static unsigned make_odd(T& val)
{
unsigned r = 0;
while(!(val & 1u))
{
val >>= 1;
++r;
}
return r;
}
inline static bool less(const T& a, const T& b)
{
return a < b;
}
enum method_type
{
method_euclid = 0,
method_binary = 1,
method_mixed = 2,
};
static const method_type method =
boost::has_right_shift_assign<T>::value && boost::has_left_shift_assign<T>::value && boost::has_less<T>::value && boost::has_modulus<T>::value
? method_mixed :
boost::has_right_shift_assign<T>::value && boost::has_left_shift_assign<T>::value && boost::has_less<T>::value
? method_binary : method_euclid;
};
//
// Default gcd_traits just inherits from defaults:
//
template <class T>
struct gcd_traits : public gcd_traits_defaults<T> {};
//
// Special handling for polynomials:
//
namespace tools {
template <class T>
class polynomial;
}
template <class T>
struct gcd_traits<boost::math::tools::polynomial<T> > : public gcd_traits_defaults<T>
{
static const boost::math::tools::polynomial<T>& abs(const boost::math::tools::polynomial<T>& val) { return val; }
};
//
// Some platforms have fast bitscan operations, that allow us to implement
// make_odd much more efficiently:
//
#if (defined(BOOST_MSVC) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
#pragma intrinsic(_BitScanForward,)
template <>
struct gcd_traits<unsigned long> : public gcd_traits_defaults<unsigned long>
{
BOOST_FORCEINLINE static unsigned find_lsb(unsigned long val)
{
unsigned long result;
_BitScanForward(&result, val);
return result;
}
BOOST_FORCEINLINE static unsigned make_odd(unsigned long& val)
{
unsigned result = find_lsb(val);
val >>= result;
return result;
}
};
#ifdef _M_X64
#pragma intrinsic(_BitScanForward64)
template <>
struct gcd_traits<unsigned __int64> : public gcd_traits_defaults<unsigned __int64>
{
BOOST_FORCEINLINE static unsigned find_lsb(unsigned __int64 mask)
{
unsigned long result;
_BitScanForward64(&result, mask);
return result;
}
BOOST_FORCEINLINE static unsigned make_odd(unsigned __int64& val)
{
unsigned result = find_lsb(val);
val >>= result;
return result;
}
};
#endif
//
// Other integer type are trivial adaptations of the above,
// this works for signed types too, as by the time these functions
// are called, all values are > 0.
//
template <> struct gcd_traits<long> : public gcd_traits_defaults<long>
{ BOOST_FORCEINLINE static unsigned make_odd(long& val){ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<unsigned int> : public gcd_traits_defaults<unsigned int>
{ BOOST_FORCEINLINE static unsigned make_odd(unsigned int& val){ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<int> : public gcd_traits_defaults<int>
{ BOOST_FORCEINLINE static unsigned make_odd(int& val){ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<unsigned short> : public gcd_traits_defaults<unsigned short>
{ BOOST_FORCEINLINE static unsigned make_odd(unsigned short& val){ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<short> : public gcd_traits_defaults<short>
{ BOOST_FORCEINLINE static unsigned make_odd(short& val){ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<unsigned char> : public gcd_traits_defaults<unsigned char>
{ BOOST_FORCEINLINE static unsigned make_odd(unsigned char& val){ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<signed char> : public gcd_traits_defaults<signed char>
{ BOOST_FORCEINLINE static signed make_odd(signed char& val){ signed result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<char> : public gcd_traits_defaults<char>
{ BOOST_FORCEINLINE static unsigned make_odd(char& val){ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
template <> struct gcd_traits<wchar_t> : public gcd_traits_defaults<wchar_t>
{ BOOST_FORCEINLINE static unsigned make_odd(wchar_t& val){ unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; } };
#ifdef _M_X64
template <> struct gcd_traits<__int64> : public gcd_traits_defaults<__int64>
{ BOOST_FORCEINLINE static unsigned make_odd(__int64& val){ unsigned result = gcd_traits<unsigned __int64>::find_lsb(val); val >>= result; return result; } };
#endif
#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__))
template <>
struct gcd_traits<unsigned> : public gcd_traits_defaults<unsigned>
{
BOOST_FORCEINLINE static unsigned find_lsb(unsigned mask)
{
return __builtin_ctz(mask);
}
BOOST_FORCEINLINE static unsigned make_odd(unsigned& val)
{
unsigned result = find_lsb(val);
val >>= result;
return result;
}
};
template <>
struct gcd_traits<unsigned long> : public gcd_traits_defaults<unsigned long>
{
BOOST_FORCEINLINE static unsigned find_lsb(unsigned long mask)
{
return __builtin_ctzl(mask);
}
BOOST_FORCEINLINE static unsigned make_odd(unsigned long& val)
{
unsigned result = find_lsb(val);
val >>= result;
return result;
}
};
template <>
struct gcd_traits<boost::ulong_long_type> : public gcd_traits_defaults<boost::ulong_long_type>
{
BOOST_FORCEINLINE static unsigned find_lsb(boost::ulong_long_type mask)
{
return __builtin_ctzll(mask);
}
BOOST_FORCEINLINE static unsigned make_odd(boost::ulong_long_type& val)
{
unsigned result = find_lsb(val);
val >>= result;
return result;
}
};
//
// Other integer type are trivial adaptations of the above,
// this works for signed types too, as by the time these functions
// are called, all values are > 0.
//
template <> struct gcd_traits<boost::long_long_type> : public gcd_traits_defaults<boost::long_long_type>
{
BOOST_FORCEINLINE static unsigned make_odd(boost::long_long_type& val) { unsigned result = gcd_traits<boost::ulong_long_type>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<long> : public gcd_traits_defaults<long>
{
BOOST_FORCEINLINE static unsigned make_odd(long& val) { unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<int> : public gcd_traits_defaults<int>
{
BOOST_FORCEINLINE static unsigned make_odd(int& val) { unsigned result = gcd_traits<unsigned long>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<unsigned short> : public gcd_traits_defaults<unsigned short>
{
BOOST_FORCEINLINE static unsigned make_odd(unsigned short& val) { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<short> : public gcd_traits_defaults<short>
{
BOOST_FORCEINLINE static unsigned make_odd(short& val) { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<unsigned char> : public gcd_traits_defaults<unsigned char>
{
BOOST_FORCEINLINE static unsigned make_odd(unsigned char& val) { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<signed char> : public gcd_traits_defaults<signed char>
{
BOOST_FORCEINLINE static signed make_odd(signed char& val) { signed result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<char> : public gcd_traits_defaults<char>
{
BOOST_FORCEINLINE static unsigned make_odd(char& val) { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
template <> struct gcd_traits<wchar_t> : public gcd_traits_defaults<wchar_t>
{
BOOST_FORCEINLINE static unsigned make_odd(wchar_t& val) { unsigned result = gcd_traits<unsigned>::find_lsb(val); val >>= result; return result; }
};
#endif
namespace detail
{
//
// The Mixed Binary Euclid Algorithm
// Sidi Mohamed Sedjelmaci
// Electronic Notes in Discrete Mathematics 35 (2009) 169176
//
template <class T>
T mixed_binary_gcd(T u, T v)
{
using std::swap;
if(gcd_traits<T>::less(u, v))
swap(u, v);
unsigned shifts = 0;
if(!u)
return v;
if(!v)
return u;
shifts = std::min(gcd_traits<T>::make_odd(u), gcd_traits<T>::make_odd(v));
while(gcd_traits<T>::less(1, v))
{
u %= v;
v -= u;
if(!u)
return v << shifts;
if(!v)
return u << shifts;
gcd_traits<T>::make_odd(u);
gcd_traits<T>::make_odd(v);
if(gcd_traits<T>::less(u, v))
swap(u, v);
}
return (v == 1 ? v : u) << shifts;
}
/** Stein gcd (aka 'binary gcd')
*
* From Mathematics to Generic Programming, Alexander Stepanov, Daniel Rose
*/
template <typename SteinDomain>
SteinDomain Stein_gcd(SteinDomain m, SteinDomain n)
{
using std::swap;
BOOST_ASSERT(m >= 0);
BOOST_ASSERT(n >= 0);
if (m == SteinDomain(0))
return n;
if (n == SteinDomain(0))
return m;
// m > 0 && n > 0
int d_m = gcd_traits<SteinDomain>::make_odd(m);
int d_n = gcd_traits<SteinDomain>::make_odd(n);
// odd(m) && odd(n)
while (m != n)
{
if (n > m)
swap(n, m);
m -= n;
gcd_traits<SteinDomain>::make_odd(m);
}
// m == n
m <<= std::min(d_m, d_n);
return m;
}
/** Euclidean algorithm
*
* From Mathematics to Generic Programming, Alexander Stepanov, Daniel Rose
*
*/
template <typename EuclideanDomain>
inline EuclideanDomain Euclid_gcd(EuclideanDomain a, EuclideanDomain b)
{
using std::swap;
while (b != EuclideanDomain(0))
{
a %= b;
swap(a, b);
}
return a;
}
template <typename T>
inline BOOST_DEDUCED_TYPENAME enable_if_c<gcd_traits<T>::method == gcd_traits<T>::method_mixed, T>::type
optimal_gcd_select(T const &a, T const &b)
{
return detail::mixed_binary_gcd(a, b);
}
template <typename T>
inline BOOST_DEDUCED_TYPENAME enable_if_c<gcd_traits<T>::method == gcd_traits<T>::method_binary, T>::type
optimal_gcd_select(T const &a, T const &b)
{
return detail::Stein_gcd(a, b);
}
template <typename T>
inline BOOST_DEDUCED_TYPENAME enable_if_c<gcd_traits<T>::method == gcd_traits<T>::method_euclid, T>::type
optimal_gcd_select(T const &a, T const &b)
{
return detail::Euclid_gcd(a, b);
}
template <class T>
inline T lcm_imp(const T& a, const T& b)
{
T temp = boost::math::detail::optimal_gcd_select(a, b);
#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40500)
return (temp != T(0)) ? T(a / temp * b) : T(0);
#else
return temp ? T(a / temp * b) : T(0);
#endif
}
} // namespace detail
template <typename Integer>
inline Integer gcd(Integer const &a, Integer const &b)
{
return detail::optimal_gcd_select(static_cast<Integer>(gcd_traits<Integer>::abs(a)), static_cast<Integer>(gcd_traits<Integer>::abs(b)));
}
template <typename Integer>
inline Integer lcm(Integer const &a, Integer const &b)
{
return detail::lcm_imp(static_cast<Integer>(gcd_traits<Integer>::abs(a)), static_cast<Integer>(gcd_traits<Integer>::abs(b)));
}
/**
* Knuth, The Art of Computer Programming: Volume 2, Third edition, 1998
* Chapter 4.5.2, Algorithm C: Greatest common divisor of n integers.
*
* Knuth counts down from n to zero but we naturally go from first to last.
* We also return the termination position because it might be useful to know.
*
* Partly by quirk, partly by design, this algorithm is defined for n = 1,
* because the gcd of {x} is x. It is not defined for n = 0.
*
* @tparam I Input iterator.
* @return The gcd of the range and the iterator position at termination.
*/
template <typename I>
std::pair<typename std::iterator_traits<I>::value_type, I>
gcd_range(I first, I last)
{
BOOST_ASSERT(first != last);
typedef typename std::iterator_traits<I>::value_type T;
T d = *first++;
while (d != T(1) && first != last)
{
d = gcd(d, *first);
first++;
}
return std::make_pair(d, first);
}
} // namespace math
} // namespace boost
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#endif // BOOST_MATH_COMMON_FACTOR_RT_HPP

View File

@ -1,129 +0,0 @@
// Copyright (c) 2006 Xiaogang Zhang
// 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_BESSEL_I0_HPP
#define BOOST_MATH_BESSEL_I0_HPP
#ifdef _MSC_VER
#pragma once
#endif
#include <boost/math/tools/rational.hpp>
#include <boost/math/tools/big_constant.hpp>
#include <boost/assert.hpp>
// Modified Bessel function of the first kind of order zero
// minimax rational approximations on intervals, see
// Blair and Edwards, Chalk River Report AECL-4928, 1974
namespace boost { namespace math { namespace detail{
template <typename T>
T bessel_i0(T x);
template <class T>
struct bessel_i0_initializer
{
struct init
{
init()
{
do_init();
}
static void do_init()
{
bessel_i0(T(1));
}
void force_instantiate()const{}
};
static const init initializer;
static void force_instantiate()
{
initializer.force_instantiate();
}
};
template <class T>
const typename bessel_i0_initializer<T>::init bessel_i0_initializer<T>::initializer;
template <typename T>
T bessel_i0(T x)
{
bessel_i0_initializer<T>::force_instantiate();
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.2335582639474375249e+15)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -5.5050369673018427753e+14)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.2940087627407749166e+13)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -8.4925101247114157499e+11)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.1912746104985237192e+10)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.0313066708737980747e+08)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -5.9545626019847898221e+05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.4125195876041896775e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -7.0935347449210549190e+00)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.5453977791786851041e-02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.5172644670688975051e-05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.0517226450451067446e-08)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.6843448573468483278e-11)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.5982226675653184646e-14)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -5.2487866627945699800e-18)),
};
static const T Q1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.2335582639474375245e+15)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 7.8858692566751002988e+12)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.2207067397808979846e+10)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0377081058062166144e+07)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -4.8527560179962773045e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0)),
};
static const T P2[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.2210262233306573296e-04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.3067392038106924055e-02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -4.4700805721174453923e-01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.5674518371240761397e+00)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.3517945679239481621e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.1611322818701131207e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -9.6090021968656180000e+00)),
};
static const T Q2[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -5.5194330231005480228e-04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.2547697594819615062e-02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.1151759188741312645e+00)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.3982595353892851542e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -6.0228002066743340583e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 8.5539563258012929600e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.1446690275135491500e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0)),
};
T value, factor, r;
BOOST_MATH_STD_USING
using namespace boost::math::tools;
BOOST_ASSERT(x >= 0); // negative x is handled before we get here
if (x == 0)
{
return static_cast<T>(1);
}
if (x <= 15) // x in (0, 15]
{
T y = x * x;
value = evaluate_polynomial(P1, y) / evaluate_polynomial(Q1, y);
}
else // x in (15, \infty)
{
T y = 1 / x - T(1) / 15;
r = evaluate_polynomial(P2, y) / evaluate_polynomial(Q2, y);
factor = exp(x) / sqrt(x);
value = factor * r;
}
return value;
}
}}} // namespaces
#endif // BOOST_MATH_BESSEL_I0_HPP

View File

@ -1,133 +0,0 @@
// Copyright (c) 2006 Xiaogang Zhang
// 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_BESSEL_I1_HPP
#define BOOST_MATH_BESSEL_I1_HPP
#ifdef _MSC_VER
#pragma once
#endif
#include <boost/math/tools/rational.hpp>
#include <boost/math/tools/big_constant.hpp>
#include <boost/assert.hpp>
// Modified Bessel function of the first kind of order one
// minimax rational approximations on intervals, see
// Blair and Edwards, Chalk River Report AECL-4928, 1974
namespace boost { namespace math { namespace detail{
template <typename T>
T bessel_i1(T x);
template <class T>
struct bessel_i1_initializer
{
struct init
{
init()
{
do_init();
}
static void do_init()
{
bessel_i1(T(1));
}
void force_instantiate()const{}
};
static const init initializer;
static void force_instantiate()
{
initializer.force_instantiate();
}
};
template <class T>
const typename bessel_i1_initializer<T>::init bessel_i1_initializer<T>::initializer;
template <typename T>
T bessel_i1(T x)
{
bessel_i1_initializer<T>::force_instantiate();
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.4577180278143463643e+15)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.7732037840791591320e+14)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -6.9876779648010090070e+12)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.3357437682275493024e+11)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.4828267606612366099e+09)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.0588550724769347106e+07)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -5.1894091982308017540e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.8225946631657315931e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -4.7207090827310162436e-01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -9.1746443287817501309e-04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.3466829827635152875e-06)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.4831904935994647675e-09)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.1928788903603238754e-12)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -6.5245515583151902910e-16)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.9705291802535139930e-19)),
};
static const T Q1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.9154360556286927285e+15)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 9.7887501377547640438e+12)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.4386907088588283434e+10)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.1594225856856884006e+07)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -5.1326864679904189920e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0)),
};
static const T P2[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.4582087408985668208e-05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -8.9359825138577646443e-04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.9204895411257790122e-02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.4198728018058047439e-01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.3960118277609544334e+00)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.9746376087200685843e+00)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 8.5591872901933459000e-01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -6.0437159056137599999e-02)),
};
static const T Q2[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.7510433111922824643e-05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.2835624489492512649e-03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 7.4212010813186530069e-02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -8.5017476463217924408e-01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.2593714889036996297e+00)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.8806586721556593450e+00)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0)),
};
T value, factor, r, w;
BOOST_MATH_STD_USING
using namespace boost::math::tools;
BOOST_ASSERT(x >= 0); // negative x is handled before we get here
w = abs(x);
if (x == 0)
{
return static_cast<T>(0);
}
if (w <= 15) // w in (0, 15]
{
T y = x * x;
r = evaluate_polynomial(P1, y) / evaluate_polynomial(Q1, y);
factor = w;
value = factor * r;
}
else // w in (15, \infty)
{
T y = 1 / w - T(1) / 15;
r = evaluate_polynomial(P2, y) / evaluate_polynomial(Q2, y);
factor = exp(w) / sqrt(w);
value = factor * r;
}
return value;
}
}}} // namespaces
#endif // BOOST_MATH_BESSEL_I1_HPP

View File

@ -1,158 +0,0 @@
// Copyright (c) 2006 Xiaogang Zhang
// 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_BESSEL_K0_HPP
#define BOOST_MATH_BESSEL_K0_HPP
#ifdef _MSC_VER
#pragma once
#pragma warning(push)
#pragma warning(disable:4702) // Unreachable code (release mode only warning)
#endif
#include <boost/math/tools/rational.hpp>
#include <boost/math/tools/big_constant.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/assert.hpp>
// Modified Bessel function of the second kind of order zero
// minimax rational approximations on intervals, see
// Russon and Blair, Chalk River Report AECL-3461, 1969
namespace boost { namespace math { namespace detail{
template <typename T, typename Policy>
T bessel_k0(T x, const Policy&);
template <class T, class Policy>
struct bessel_k0_initializer
{
struct init
{
init()
{
do_init();
}
static void do_init()
{
bessel_k0(T(1), Policy());
}
void force_instantiate()const{}
};
static const init initializer;
static void force_instantiate()
{
initializer.force_instantiate();
}
};
template <class T, class Policy>
const typename bessel_k0_initializer<T, Policy>::init bessel_k0_initializer<T, Policy>::initializer;
template <typename T, typename Policy>
T bessel_k0(T x, const Policy& pol)
{
BOOST_MATH_INSTRUMENT_CODE(x);
bessel_k0_initializer<T, Policy>::force_instantiate();
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.4708152720399552679e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.9169059852270512312e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.6850901201934832188e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.1999463724910714109e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.3166052564989571850e-01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.8599221412826100000e-04))
};
static const T Q1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.1312714303849120380e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.4994418972832303646e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0))
};
static const T P2[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.6128136304458193998e+06)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.7333769444840079748e+05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.7984434409411765813e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.9501657892958843865e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.6414452837299064100e+00))
};
static const T Q2[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.6128136304458193998e+06)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.9865713163054025489e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.5064972445877992730e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0))
};
static const T P3[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.1600249425076035558e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.3444738764199315021e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.8321525870183537725e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 7.1557062783764037541e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.5097646353289914539e+05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.7398867902565686251e+05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0577068948034021957e+05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.1075408980684392399e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.6832589957340267940e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.1394980557384778174e+02))
};
static const T Q3[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 9.2556599177304839811e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.8821890840982713696e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.4847228371802360957e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.8824616785857027752e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.2689839587977598727e+05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.5144644673520157801e+05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 9.7418829762268075784e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.1474655750295278825e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.4329628889746408858e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.0013443064949242491e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0))
};
T value, factor, r, r1, r2;
BOOST_MATH_STD_USING
using namespace boost::math::tools;
static const char* function = "boost::math::bessel_k0<%1%>(%1%,%1%)";
if (x < 0)
{
return policies::raise_domain_error<T>(function,
"Got x = %1%, but argument x must be non-negative, complex number result not supported", x, pol);
}
if (x == 0)
{
return policies::raise_overflow_error<T>(function, 0, pol);
}
if (x <= 1) // x in (0, 1]
{
T y = x * x;
r1 = evaluate_polynomial(P1, y) / evaluate_polynomial(Q1, y);
r2 = evaluate_polynomial(P2, y) / evaluate_polynomial(Q2, y);
factor = log(x);
value = r1 - factor * r2;
}
else // x in (1, \infty)
{
T y = 1 / x;
r = evaluate_polynomial(P3, y) / evaluate_polynomial(Q3, y);
factor = exp(-x) / sqrt(x);
value = factor * r;
BOOST_MATH_INSTRUMENT_CODE("y = " << y);
BOOST_MATH_INSTRUMENT_CODE("r = " << r);
BOOST_MATH_INSTRUMENT_CODE("factor = " << factor);
BOOST_MATH_INSTRUMENT_CODE("value = " << value);
}
return value;
}
}}} // namespaces
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif // BOOST_MATH_BESSEL_K0_HPP

View File

@ -1,154 +0,0 @@
// Copyright (c) 2006 Xiaogang Zhang
// 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_BESSEL_K1_HPP
#define BOOST_MATH_BESSEL_K1_HPP
#ifdef _MSC_VER
#pragma once
#pragma warning(push)
#pragma warning(disable:4702) // Unreachable code (release mode only warning)
#endif
#include <boost/math/tools/rational.hpp>
#include <boost/math/tools/big_constant.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/assert.hpp>
// Modified Bessel function of the second kind of order one
// minimax rational approximations on intervals, see
// Russon and Blair, Chalk River Report AECL-3461, 1969
namespace boost { namespace math { namespace detail{
template <typename T, typename Policy>
T bessel_k1(T x, const Policy&);
template <class T, class Policy>
struct bessel_k1_initializer
{
struct init
{
init()
{
do_init();
}
static void do_init()
{
bessel_k1(T(1), Policy());
}
void force_instantiate()const{}
};
static const init initializer;
static void force_instantiate()
{
initializer.force_instantiate();
}
};
template <class T, class Policy>
const typename bessel_k1_initializer<T, Policy>::init bessel_k1_initializer<T, Policy>::initializer;
template <typename T, typename Policy>
T bessel_k1(T x, const Policy& pol)
{
bessel_k1_initializer<T, Policy>::force_instantiate();
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.2149374878243304548e+06)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 7.1938920065420586101e+05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.7733324035147015630e+05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 7.1885382604084798576e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 9.9991373567429309922e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.8127070456878442310e-01))
};
static const T Q1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.2149374878243304548e+06)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.7264298672067697862e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.8143915754538725829e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0))
};
static const T P2[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 0.0)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.3531161492785421328e+06)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.4758069205414222471e+05)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -4.5051623763436087023e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -5.3103913335180275253e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.2795590826955002390e-01))
};
static const T Q2[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.7062322985570842656e+06)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.3117653211351080007e+04)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.0507151578787595807e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0))
};
static const T P3[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.2196792496874548962e+00)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.4137176114230414036e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.4122953486801312910e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.3319486433183221990e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.8590657697910288226e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.4540675585544584407e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.3123742209168871550e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 8.1094256146537402173e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.3182609918569941308e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 7.5584584631176030810e+00)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 6.4257745859173138767e-02))
};
static const T Q3[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.7710478032601086579e+00)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.4552228452758912848e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.5951223655579051357e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 9.6929165726802648634e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.9448440788918006154e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.1181000487171943810e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.2082692316002348638e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.3031020088765390854e+02)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.6001069306861518855e+01)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0))
};
T value, factor, r, r1, r2;
BOOST_MATH_STD_USING
using namespace boost::math::tools;
static const char* function = "boost::math::bessel_k1<%1%>(%1%,%1%)";
if (x < 0)
{
return policies::raise_domain_error<T>(function,
"Got x = %1%, but argument x must be non-negative, complex number result not supported.", x, pol);
}
if (x == 0)
{
return policies::raise_overflow_error<T>(function, 0, pol);
}
if (x <= 1) // x in (0, 1]
{
T y = x * x;
r1 = evaluate_polynomial(P1, y) / evaluate_polynomial(Q1, y);
r2 = evaluate_polynomial(P2, y) / evaluate_polynomial(Q2, y);
factor = log(x);
value = (r1 + factor * r2) / x;
}
else // x in (1, \infty)
{
T y = 1 / x;
r = evaluate_polynomial(P3, y) / evaluate_polynomial(Q3, y);
factor = exp(-x) / sqrt(x);
value = factor * r;
}
return value;
}
}}} // namespaces
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif // BOOST_MATH_BESSEL_K1_HPP

View File

@ -1,81 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2015-2016.
// Distributed under the 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.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_MOVE_ALGO_BASIC_OP
#define BOOST_MOVE_ALGO_BASIC_OP
#ifndef BOOST_CONFIG_HPP
# include <boost/config.hpp>
#endif
#
#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/move/utility_core.hpp>
#include <boost/move/adl_move_swap.hpp>
#include <boost/move/detail/iterator_traits.hpp>
namespace boost {
namespace movelib {
struct forward_t{};
struct backward_t{};
struct three_way_t{};
struct move_op
{
template <class SourceIt, class DestinationIt>
void operator()(SourceIt source, DestinationIt dest)
{ *dest = ::boost::move(*source); }
template <class SourceIt, class DestinationIt>
DestinationIt operator()(forward_t, SourceIt first, SourceIt last, DestinationIt dest_begin)
{ return ::boost::move(first, last, dest_begin); }
template <class SourceIt, class DestinationIt>
DestinationIt operator()(backward_t, SourceIt first, SourceIt last, DestinationIt dest_last)
{ return ::boost::move_backward(first, last, dest_last); }
template <class SourceIt, class DestinationIt1, class DestinationIt2>
void operator()(three_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it)
{
*dest2it = boost::move(*dest1it);
*dest1it = boost::move(*srcit);
}
};
struct swap_op
{
template <class SourceIt, class DestinationIt>
void operator()(SourceIt source, DestinationIt dest)
{ boost::adl_move_swap(*dest, *source); }
template <class SourceIt, class DestinationIt>
DestinationIt operator()(forward_t, SourceIt first, SourceIt last, DestinationIt dest_begin)
{ return boost::adl_move_swap_ranges(first, last, dest_begin); }
template <class SourceIt, class DestinationIt>
DestinationIt operator()(backward_t, SourceIt first, SourceIt last, DestinationIt dest_begin)
{ return boost::adl_move_swap_ranges_backward(first, last, dest_begin); }
template <class SourceIt, class DestinationIt1, class DestinationIt2>
void operator()(three_way_t, SourceIt srcit, DestinationIt1 dest1it, DestinationIt2 dest2it)
{
typename ::boost::movelib::iterator_traits<SourceIt>::value_type tmp(boost::move(*dest2it));
*dest2it = boost::move(*dest1it);
*dest1it = boost::move(*srcit);
*srcit = boost::move(tmp);
}
};
}} //namespace boost::movelib
#endif //BOOST_MOVE_ALGO_BASIC_OP

View File

@ -1,120 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2015-2016.
// Distributed under the 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.
//
//////////////////////////////////////////////////////////////////////////////
//! \file
#ifndef BOOST_MOVE_ALGO_BUFFERLESS_MERGE_SORT_HPP
#define BOOST_MOVE_ALGO_BUFFERLESS_MERGE_SORT_HPP
#ifndef BOOST_CONFIG_HPP
# include <boost/config.hpp>
#endif
#
#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/move/detail/config_begin.hpp>
#include <boost/move/detail/workaround.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/move/adl_move_swap.hpp>
#include <boost/move/algo/move.hpp>
#include <boost/move/algo/detail/merge.hpp>
#include <boost/move/detail/iterator_traits.hpp>
#include <boost/move/algo/detail/insertion_sort.hpp>
#include <cassert>
namespace boost {
namespace movelib {
// @cond
namespace detail_bufferless_mergesort {
static const std::size_t UnbufferedMergeSortInsertionSortThreshold = 16;
//A in-placed version based on:
//Jyrki Katajainen, Tomi Pasanen, Jukka Teuhola.
//``Practical in-place mergesort''. Nordic Journal of Computing, 1996.
template<class RandIt, class Compare>
void bufferless_merge_sort(RandIt first, RandIt last, Compare comp);
template<class RandIt, class Compare>
void swap_sort(RandIt const first, RandIt const last, RandIt const buffer_first, RandIt const buffer_last, Compare comp, bool buffer_at_right)
{
typedef typename iterator_traits<RandIt>::size_type size_type;
if (size_type(last - first) > UnbufferedMergeSortInsertionSortThreshold) {
RandIt m = first + (last - first) / 2;
bufferless_merge_sort(first, m, comp);
bufferless_merge_sort(m, last, comp);
if(buffer_at_right){
//Use antistable to minimize movements (if equal, move first half elements
//to maximize the chance last half elements are already in place.
boost::movelib::swap_merge_right(first, m, last, buffer_last, boost::movelib::antistable<Compare>(comp));
}
else{
boost::movelib::swap_merge_left(buffer_first, first, m, last, comp);
}
}
else
boost::movelib::insertion_sort_swap(first, last, buffer_first, comp);
}
template<class RandIt, class Compare>
void bufferless_merge_sort(RandIt const first, RandIt const last, Compare comp)
{
typedef typename iterator_traits<RandIt>::size_type size_type;
size_type len = size_type(last - first);
if (len > size_type(UnbufferedMergeSortInsertionSortThreshold)) {
len /= 2;
RandIt h = last - len; //ceil(half)
RandIt f = h - len; //ceil(first)
swap_sort(f, h, h, last, comp, true); //[h, last) contains sorted elements
//Divide unsorted first half in two
len = size_type(h - first);
while (len > size_type(UnbufferedMergeSortInsertionSortThreshold)) {
len /= 2;
RandIt n = h; //new end
h = n - len; //ceil(half')
f = h - len; //ceil(first')
swap_sort(h, n, f, h, comp, false); // the first half of the previous working area [f, h)
//contains sorted elements: working area in the middle [h, n)
//Now merge small (left) sorted with big (right) sorted (buffer is between them)
swap_merge_with_right_placed(f, h, h, n, last, comp);
}
boost::movelib::insertion_sort(first, h, comp);
boost::movelib::merge_bufferless(first, h, last, comp);
}
else{
boost::movelib::insertion_sort(first, last, comp);
}
}
} //namespace detail_bufferless_mergesort {
// @endcond
//Unstable bufferless merge sort
template<class RandIt, class Compare>
void bufferless_merge_sort(RandIt first, RandIt last, Compare comp)
{
detail_bufferless_mergesort::bufferless_merge_sort(first, last, comp);
}
}} //namespace boost::movelib
#include <boost/move/detail/config_end.hpp>
#endif //#ifndef BOOST_MOVE_ALGO_BUFFERLESS_MERGE_SORT_HPP

View File

@ -1,165 +0,0 @@
// Boost next_prior.hpp header file ---------------------------------------//
// (C) Copyright Dave Abrahams and Daniel Walker 1999-2003. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/utility for documentation.
// Revision History
// 13 Dec 2003 Added next(x, n) and prior(x, n) (Daniel Walker)
#ifndef BOOST_NEXT_PRIOR_HPP_INCLUDED
#define BOOST_NEXT_PRIOR_HPP_INCLUDED
#include <iterator>
#if defined(_MSC_VER) && _MSC_VER <= 1310
#include <boost/mpl/and.hpp>
#include <boost/type_traits/is_integral.hpp>
#endif
#include <boost/type_traits/is_unsigned.hpp>
#include <boost/type_traits/integral_promotion.hpp>
#include <boost/type_traits/make_signed.hpp>
#include <boost/type_traits/has_plus.hpp>
#include <boost/type_traits/has_plus_assign.hpp>
#include <boost/type_traits/has_minus.hpp>
#include <boost/type_traits/has_minus_assign.hpp>
namespace boost {
// Helper functions for classes like bidirectional iterators not supporting
// operator+ and operator-
//
// Usage:
// const std::list<T>::iterator p = get_some_iterator();
// const std::list<T>::iterator prev = boost::prior(p);
// const std::list<T>::iterator next = boost::next(prev, 2);
// Contributed by Dave Abrahams
namespace next_prior_detail {
template< typename T, typename Distance, bool HasPlus = has_plus< T, Distance >::value >
struct next_impl2
{
static T call(T x, Distance n)
{
std::advance(x, n);
return x;
}
};
template< typename T, typename Distance >
struct next_impl2< T, Distance, true >
{
static T call(T x, Distance n)
{
return x + n;
}
};
template< typename T, typename Distance, bool HasPlusAssign = has_plus_assign< T, Distance >::value >
struct next_impl1 :
public next_impl2< T, Distance >
{
};
template< typename T, typename Distance >
struct next_impl1< T, Distance, true >
{
static T call(T x, Distance n)
{
x += n;
return x;
}
};
template<
typename T,
typename Distance,
typename PromotedDistance = typename integral_promotion< Distance >::type,
#if !defined(_MSC_VER) || _MSC_VER > 1310
bool IsUInt = is_unsigned< PromotedDistance >::value
#else
// MSVC 7.1 has problems with applying is_unsigned to non-integral types
bool IsUInt = mpl::and_< is_integral< PromotedDistance >, is_unsigned< PromotedDistance > >::value
#endif
>
struct prior_impl3
{
static T call(T x, Distance n)
{
std::advance(x, -n);
return x;
}
};
template< typename T, typename Distance, typename PromotedDistance >
struct prior_impl3< T, Distance, PromotedDistance, true >
{
static T call(T x, Distance n)
{
typedef typename make_signed< PromotedDistance >::type signed_distance;
std::advance(x, -static_cast< signed_distance >(static_cast< PromotedDistance >(n)));
return x;
}
};
template< typename T, typename Distance, bool HasMinus = has_minus< T, Distance >::value >
struct prior_impl2 :
public prior_impl3< T, Distance >
{
};
template< typename T, typename Distance >
struct prior_impl2< T, Distance, true >
{
static T call(T x, Distance n)
{
return x - n;
}
};
template< typename T, typename Distance, bool HasMinusAssign = has_minus_assign< T, Distance >::value >
struct prior_impl1 :
public prior_impl2< T, Distance >
{
};
template< typename T, typename Distance >
struct prior_impl1< T, Distance, true >
{
static T call(T x, Distance n)
{
x -= n;
return x;
}
};
} // namespace next_prior_detail
template <class T>
inline T next(T x) { return ++x; }
template <class T, class Distance>
inline T next(T x, Distance n)
{
return next_prior_detail::next_impl1< T, Distance >::call(x, n);
}
template <class T>
inline T prior(T x) { return --x; }
template <class T, class Distance>
inline T prior(T x, Distance n)
{
return next_prior_detail::prior_impl1< T, Distance >::call(x, n);
}
} // namespace boost
#endif // BOOST_NEXT_PRIOR_HPP_INCLUDED

View File

@ -1,18 +0,0 @@
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
//
// 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/libs/optional for documentation.
//
// You are welcome to contact the author at:
// fernando_cacciola@hotmail.com
//
#ifndef BOOST_OPTIONAL_FLC_19NOV2002_HPP
#define BOOST_OPTIONAL_FLC_19NOV2002_HPP
#include "boost/optional/optional.hpp"
#endif

View File

@ -1,99 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_CLONE_ALLOCATOR_HPP
#define BOOST_PTR_CONTAINER_CLONE_ALLOCATOR_HPP
#include <boost/assert.hpp>
#include <boost/checked_delete.hpp>
#include <typeinfo>
namespace boost
{
/////////////////////////////////////////////////////////////////////////
// Clonable concept
/////////////////////////////////////////////////////////////////////////
template< class T >
inline T* new_clone( const T& r )
{
//
// @remark: if you get a compile-error here,
// it is most likely because you did not
// define new_clone( const T& ) in the namespace
// of T.
//
T* res = new T( r );
BOOST_ASSERT( typeid(r) == typeid(*res) &&
"Default new_clone() sliced object!" );
return res;
}
template< class T >
inline T* new_clone( const T* r )
{
return r ? new_clone( *r ) : 0;
}
//
// @remark: to make new_clone() work
// with scope_ptr/shared_ptr ect.
// simply overload for those types
// in the appropriate namespace.
//
template< class T >
inline void delete_clone( const T* r )
{
checked_delete( r );
}
/////////////////////////////////////////////////////////////////////////
// CloneAllocator concept
/////////////////////////////////////////////////////////////////////////
struct heap_clone_allocator
{
template< class U >
static U* allocate_clone( const U& r )
{
return new_clone( r );
}
template< class U >
static void deallocate_clone( const U* r )
{
delete_clone( r );
}
};
struct view_clone_allocator
{
template< class U >
static U* allocate_clone( const U& r )
{
return const_cast<U*>(&r);
}
template< class U >
static void deallocate_clone( const U* /*r*/ )
{
// do nothing
}
};
} // namespace 'boost'
#endif

View File

@ -1,411 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_ASSOCIATIVE_PTR_CONTAINER_HPP
#define BOOST_PTR_CONTAINER_DETAIL_ASSOCIATIVE_PTR_CONTAINER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/detail/reversible_ptr_container.hpp>
namespace boost
{
namespace ptr_container_detail
{
template
<
class Config,
class CloneAllocator
>
class associative_ptr_container :
public reversible_ptr_container<Config,CloneAllocator>
{
typedef reversible_ptr_container<Config,CloneAllocator>
base_type;
typedef BOOST_DEDUCED_TYPENAME base_type::scoped_deleter
scoped_deleter;
typedef BOOST_DEDUCED_TYPENAME Config::container_type
container_type;
public: // typedefs
typedef BOOST_DEDUCED_TYPENAME Config::key_type
key_type;
typedef BOOST_DEDUCED_TYPENAME Config::key_compare
key_compare;
typedef BOOST_DEDUCED_TYPENAME Config::value_compare
value_compare;
typedef BOOST_DEDUCED_TYPENAME Config::hasher
hasher;
typedef BOOST_DEDUCED_TYPENAME Config::key_equal
key_equal;
typedef BOOST_DEDUCED_TYPENAME Config::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME Config::const_iterator
const_iterator;
typedef BOOST_DEDUCED_TYPENAME Config::local_iterator
local_iterator;
typedef BOOST_DEDUCED_TYPENAME Config::const_local_iterator
const_local_iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef BOOST_DEDUCED_TYPENAME base_type::reference
reference;
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
const_reference;
public: // foundation
associative_ptr_container()
{ }
template< class SizeType >
associative_ptr_container( SizeType n, unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Compare, class Allocator >
associative_ptr_container( const Compare& comp,
const Allocator& a )
: base_type( comp, a, container_type() )
{ }
template< class Hash, class Pred, class Allocator >
associative_ptr_container( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator, class Compare, class Allocator >
associative_ptr_container( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator& a )
: base_type( first, last, comp, a, container_type() )
{ }
template< class InputIterator, class Hash, class Pred, class Allocator >
associative_ptr_container( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( first, last, hash, pred, a )
{ }
template< class PtrContainer >
explicit associative_ptr_container( std::auto_ptr<PtrContainer> r )
: base_type( r )
{ }
associative_ptr_container( const associative_ptr_container& r )
: base_type( r.begin(), r.end(), container_type() )
{ }
template< class C, class V >
associative_ptr_container( const associative_ptr_container<C,V>& r )
: base_type( r.begin(), r.end(), container_type() )
{ }
template< class PtrContainer >
associative_ptr_container& operator=( std::auto_ptr<PtrContainer> r ) // nothrow
{
base_type::operator=( r );
return *this;
}
associative_ptr_container& operator=( associative_ptr_container r ) // strong
{
this->swap( r );
return *this;
}
public: // associative container interface
key_compare key_comp() const
{
return this->base().key_comp();
}
value_compare value_comp() const
{
return this->base().value_comp();
}
iterator erase( iterator before ) // nothrow
{
BOOST_ASSERT( !this->empty() );
BOOST_ASSERT( before != this->end() );
this->remove( before ); // nothrow
iterator res( before ); // nothrow
++res; // nothrow
this->base().erase( before.base() ); // nothrow
return res; // nothrow
}
size_type erase( const key_type& x ) // nothrow
{
iterator i( this->base().find( x ) );
// nothrow
if( i == this->end() ) // nothrow
return 0u; // nothrow
this->remove( i ); // nothrow
return this->base().erase( x ); // nothrow
}
iterator erase( iterator first,
iterator last ) // nothrow
{
iterator res( last ); // nothrow
if( res != this->end() )
++res; // nothrow
this->remove( first, last ); // nothrow
this->base().erase( first.base(), last.base() ); // nothrow
return res; // nothrow
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_convertible<Range&,key_type&>,
iterator >::type
erase( const Range& r )
{
return erase( boost::begin(r), boost::end(r) );
}
#endif
protected:
template< class AssociatePtrCont >
void multi_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator object,
AssociatePtrCont& from ) // strong
{
BOOST_ASSERT( (void*)&from != (void*)this );
BOOST_ASSERT( !from.empty() && "Cannot transfer from empty container" );
this->base().insert( *object.base() ); // strong
from.base().erase( object.base() ); // nothrow
}
template< class AssociatePtrCont >
size_type multi_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator first,
BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator last,
AssociatePtrCont& from ) // basic
{
BOOST_ASSERT( (void*)&from != (void*)this );
size_type res = 0;
for( ; first != last; )
{
BOOST_ASSERT( first != from.end() );
this->base().insert( *first.base() ); // strong
BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator
to_delete( first );
++first;
from.base().erase( to_delete.base() ); // nothrow
++res;
}
return res;
}
template< class AssociatePtrCont >
bool single_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator object,
AssociatePtrCont& from ) // strong
{
BOOST_ASSERT( (void*)&from != (void*)this );
BOOST_ASSERT( !from.empty() && "Cannot transfer from empty container" );
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool> p =
this->base().insert( *object.base() ); // strong
if( p.second )
from.base().erase( object.base() ); // nothrow
return p.second;
}
template< class AssociatePtrCont >
size_type single_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator first,
BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator last,
AssociatePtrCont& from ) // basic
{
BOOST_ASSERT( (void*)&from != (void*)this );
size_type res = 0;
for( ; first != last; )
{
BOOST_ASSERT( first != from.end() );
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool> p =
this->base().insert( *first.base() ); // strong
BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator
to_delete( first );
++first;
if( p.second )
{
from.base().erase( to_delete.base() ); // nothrow
++res;
}
}
return res;
}
reference front()
{
BOOST_ASSERT( !this->empty() );
BOOST_ASSERT( *this->begin().base() != 0 );
return *this->begin();
}
const_reference front() const
{
return const_cast<associative_ptr_container*>(this)->front();
}
reference back()
{
BOOST_ASSERT( !this->empty() );
BOOST_ASSERT( *(--this->end()).base() != 0 );
return *--this->end();
}
const_reference back() const
{
return const_cast<associative_ptr_container*>(this)->back();
}
protected: // unordered interface
hasher hash_function() const
{
return this->base().hash_function();
}
key_equal key_eq() const
{
return this->base().key_eq();
}
size_type bucket_count() const
{
return this->base().bucket_count();
}
size_type max_bucket_count() const
{
return this->base().max_bucket_count();
}
size_type bucket_size( size_type n ) const
{
return this->base().bucket_size( n );
}
float load_factor() const
{
return this->base().load_factor();
}
float max_load_factor() const
{
return this->base().max_load_factor();
}
void max_load_factor( float factor )
{
return this->base().max_load_factor( factor );
}
void rehash( size_type n )
{
this->base().rehash( n );
}
public:
#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(70190006))
iterator begin()
{
return base_type::begin();
}
const_iterator begin() const
{
return base_type::begin();
}
iterator end()
{
return base_type::end();
}
const_iterator end() const
{
return base_type::end();
}
const_iterator cbegin() const
{
return base_type::cbegin();
}
const_iterator cend() const
{
return base_type::cend();
}
#else
using base_type::begin;
using base_type::end;
using base_type::cbegin;
using base_type::cend;
#endif
protected:
local_iterator begin( size_type n )
{
return local_iterator( this->base().begin( n ) );
}
const_local_iterator begin( size_type n ) const
{
return const_local_iterator( this->base().begin( n ) );
}
local_iterator end( size_type n )
{
return local_iterator( this->base().end( n ) );
}
const_local_iterator end( size_type n ) const
{
return const_local_iterator( this->base().end( n ) );
}
const_local_iterator cbegin( size_type n ) const
{
return const_local_iterator( this->base().cbegin( n ) );
}
const_local_iterator cend( size_type n )
{
return const_local_iterator( this->base().cend( n ) );
}
}; // class 'associative_ptr_container'
} // namespace 'ptr_container_detail'
} // namespace 'boost'
#endif

View File

@ -1,69 +0,0 @@
// (C) Copyright Jonathan Turkanis 2004-2005.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
// Contains the definition of move_ptrs::default_deleter, the default
// Deleter template argument to move_ptr. Uses a technique of Daniel
// Wallin to capture the type of a pointer at the time the deleter
// is constructed, so that move_ptrs can delete objects of incomplete
// type by default.
#ifndef BOOST_MOVE_PTR_DEFAULT_DELETER_HPP_INCLUDED
#define BOOST_MOVE_PTR_DEFAULT_DELETER_HPP_INCLUDED
#include <boost/checked_delete.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/remove_bounds.hpp>
namespace boost { namespace ptr_container_detail { namespace move_ptrs {
namespace ptr_container_detail {
template<typename T>
struct deleter_base {
typedef void (*deleter)(T*);
deleter_base(deleter d) { delete_ = d; }
void operator() (T* t) const { delete_(t); }
static deleter delete_;
};
template<class T>
typename deleter_base<T>::deleter
deleter_base<T>::delete_;
template<typename T>
struct scalar_deleter : deleter_base<T> {
typedef deleter_base<T> base;
scalar_deleter() : base(do_delete) { }
static void do_delete(T* t) { checked_delete(t); }
};
template<typename T>
struct array_deleter
: deleter_base<typename remove_bounds<T>::type>
{
typedef typename remove_bounds<T>::type element_type;
typedef deleter_base<element_type> base;
array_deleter() : base(do_delete) { }
static void do_delete(element_type* t) { checked_array_delete(t); }
};
} // End namespace ptr_container_detail.
template<typename T>
struct default_deleter
: mpl::if_<
is_array<T>,
ptr_container_detail::array_deleter<T>,
ptr_container_detail::scalar_deleter<T>
>::type
{
default_deleter() { }
template<typename TT>
default_deleter(default_deleter<TT> tt) { }
};
} } } // End namespaces ptr_container_detail, move_ptrs, boost.
#endif // #ifndef BOOST_MOVE_PTR_DEFAULT_DELETER_HPP_INCLUDED

View File

@ -1,73 +0,0 @@
// (C) Copyright Thorsten Ottosen 2005
// (C) Copyright Howard Hinnant 2004
// (C) Copyright Jonathan Turkanis 2004
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
//
// Contains type traits machinery for incomplete arrays. MPL compatibility
// is included for completeness, but is not necessary for the current
// application.
//
#ifndef BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED
#define BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED
#include <boost/config.hpp> // BOOST_STATIC_CONSTANT.
#include <boost/mpl/aux_/lambda_support.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_bounds.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace ptr_container_detail { namespace move_ptrs {
// From Howard Hinnant.
template<typename T, typename U>
struct is_array_convertible {
typedef typename remove_bounds<T>::type t_element;
typedef typename remove_bounds<U>::type u_element;
typedef typename remove_cv<t_element>::type t_base;
typedef typename remove_cv<u_element>::type u_base;
typedef typename
mpl::and_<
is_array<T>,
is_array<U>,
is_same<t_base, u_base>,
is_convertible<t_element*, u_element*>
>::type type;
BOOST_STATIC_CONSTANT(bool, value = type::value);
BOOST_MPL_AUX_LAMBDA_SUPPORT(2, is_array_convertible, (T, U))
};
template<typename T, typename U>
struct is_smart_ptr_convertible
: mpl::if_<
is_array<T>,
is_array_convertible<T, U>,
is_convertible<T*, U*>
>::type
{ };
#ifndef BOOST_NO_SFINAE
template<typename Src, typename Tgt, typename T = void>
struct enable_if_convertible
: enable_if<
is_smart_ptr_convertible<Src, Tgt>,
T
>
{ };
#else
template<typename Src, typename Tgt, class T >
struct enable_if_convertible : mpl::identity<T> { };
#endif
} } } // End namespaces ptr_container_detail, move_ptrs, boost.
#endif // #ifndef BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED

View File

@ -1,132 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_MAP_ITERATOR_HPP
#define BOOST_PTR_CONTAINER_MAP_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/config.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/utility/compare_pointees.hpp>
#include <utility>
#if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable:4512) // Assignment operator could not be generated.
#endif
namespace boost
{
namespace ptr_container_detail
{
template< class F, class S >
struct ref_pair
{
typedef F first_type;
typedef S second_type;
const F& first;
S second;
template< class F2, class S2 >
ref_pair( const std::pair<F2,S2>& p )
: first(p.first), second(static_cast<S>(p.second))
{ }
template< class RP >
ref_pair( const RP* rp )
: first(rp->first), second(rp->second)
{ }
const ref_pair* const operator->() const
{
return this;
}
friend inline bool operator==( ref_pair l, ref_pair r )
{
return l.first == r.first &&
boost::equal_pointees( l.second, r.second );
}
friend inline bool operator!=( ref_pair l, ref_pair r )
{
return !( l == r );
}
friend inline bool operator<( ref_pair l, ref_pair r )
{
if( l.first == r.first )
return boost::less_pointees( l.second, r.second );
else
return l.first < r.first;
}
friend inline bool operator>( ref_pair l, ref_pair r )
{
return r < l;
}
friend inline bool operator<=( ref_pair l, ref_pair r )
{
return !(r < l);
}
friend inline bool operator>=( ref_pair l, ref_pair r )
{
return !(l < r);
}
};
}
template<
class I, // base iterator
class F, // first type, key type
class S // second type, mapped type
>
class ptr_map_iterator :
public boost::iterator_adaptor< ptr_map_iterator<I,F,S>, I,
ptr_container_detail::ref_pair<F,S>,
use_default,
ptr_container_detail::ref_pair<F,S> >
{
typedef boost::iterator_adaptor< ptr_map_iterator<I,F,S>, I,
ptr_container_detail::ref_pair<F,S>,
use_default,
ptr_container_detail::ref_pair<F,S> >
base_type;
public:
ptr_map_iterator() : base_type()
{ }
explicit ptr_map_iterator( const I& i ) : base_type(i)
{ }
template< class I2, class F2, class S2 >
ptr_map_iterator( const ptr_map_iterator<I2,F2,S2>& r )
: base_type(r.base())
{ }
}; // class 'ptr_map_iterator'
}
#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif
#endif

View File

@ -1,66 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_META_FUNCTIONS
#define BOOST_PTR_CONTAINER_DETAIL_META_FUNCTIONS
#include <boost/mpl/identity.hpp>
#include <boost/mpl/eval_if.hpp>
namespace boost
{
namespace ptr_container_detail
{
template< class T >
struct select_value_compare
{
typedef typename T::value_compare type;
};
template< class T >
struct select_key_compare
{
typedef typename T::key_compare type;
};
template< class T >
struct select_hasher
{
typedef typename T::hasher type;
};
template< class T >
struct select_key_equal
{
typedef typename T::key_equal type;
};
template< class T >
struct select_iterator
{
typedef typename T::iterator type;
};
template< class T >
struct select_local_iterator
{
typedef typename T::local_iterator type;
};
template< class T >
struct select_const_local_iterator
{
typedef typename T::const_local_iterator type;
};
}
}
#endif

View File

@ -1,44 +0,0 @@
// (C) Copyright Daniel Wallin 2004.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
// Contains the definitions of the class template move_source and the function
// template move, which together make move pointers moveable.
#ifndef BOOST_MOVE_HPP_INCLUDED
#define BOOST_MOVE_HPP_INCLUDED
namespace boost { namespace ptr_container_detail {
namespace move_ptrs {
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:4512)
#endif
template<typename Ptr>
class move_source {
public:
move_source(Ptr& ptr) : ptr_(ptr) {}
Ptr& ptr() const { return ptr_; }
private:
Ptr& ptr_;
move_source(const Ptr&);
};
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
} // End namespace move_ptrs.
template<typename T>
move_ptrs::move_source<T> move(T& x)
{ return move_ptrs::move_source<T>(x); }
} // namespace 'ptr_container_detail'
} // End namespace boost.
#endif // #ifndef BOOST_MOVE_HPP_INCLUDED

View File

@ -1,752 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_REVERSIBLE_PTR_CONTAINER_HPP
#define BOOST_PTR_CONTAINER_DETAIL_REVERSIBLE_PTR_CONTAINER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/detail/throw_exception.hpp>
#include <boost/ptr_container/detail/scoped_deleter.hpp>
#include <boost/ptr_container/detail/static_move_ptr.hpp>
#include <boost/ptr_container/exception.hpp>
#include <boost/ptr_container/clone_allocator.hpp>
#include <boost/ptr_container/nullable.hpp>
#ifdef BOOST_NO_SFINAE
#else
#include <boost/range/functions.hpp>
#endif
#include <boost/config.hpp>
#include <boost/iterator/reverse_iterator.hpp>
#include <boost/range/iterator.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <typeinfo>
#include <memory>
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:4127)
#endif
namespace boost
{
namespace ptr_container_detail
{
template< class CloneAllocator >
struct clone_deleter
{
template< class T >
void operator()( const T* p ) const
{
CloneAllocator::deallocate_clone( p );
}
};
template< class T >
struct is_pointer_or_integral
{
BOOST_STATIC_CONSTANT(bool, value = is_pointer<T>::value || is_integral<T>::value );
};
struct is_pointer_or_integral_tag {};
struct is_range_tag {};
struct sequence_tag {};
struct fixed_length_sequence_tag : sequence_tag {};
struct associative_container_tag {};
struct ordered_associative_container_tag : associative_container_tag {};
struct unordered_associative_container_tag : associative_container_tag {};
template
<
class Config,
class CloneAllocator
>
class reversible_ptr_container
{
private:
BOOST_STATIC_CONSTANT( bool, allow_null = Config::allow_null );
typedef BOOST_DEDUCED_TYPENAME Config::value_type Ty_;
template< bool allow_null_values >
struct null_clone_allocator
{
template< class Iter >
static Ty_* allocate_clone_from_iterator( Iter i )
{
return allocate_clone( Config::get_const_pointer( i ) );
}
static Ty_* allocate_clone( const Ty_* x )
{
if( allow_null_values )
{
if( x == 0 )
return 0;
}
else
{
BOOST_ASSERT( x != 0 && "Cannot insert clone of null!" );
}
Ty_* res = CloneAllocator::allocate_clone( *x );
BOOST_ASSERT( typeid(*res) == typeid(*x) &&
"CloneAllocator::allocate_clone() does not clone the "
"object properly. Check that new_clone() is implemented"
" correctly" );
return res;
}
static void deallocate_clone( const Ty_* x )
{
if( allow_null_values )
{
if( x == 0 )
return;
}
CloneAllocator::deallocate_clone( x );
}
};
typedef BOOST_DEDUCED_TYPENAME Config::void_container_type Cont;
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
typedef null_clone_allocator<reversible_ptr_container::allow_null>
null_cloner_type;
#else
typedef null_clone_allocator<allow_null> null_cloner_type;
#endif
typedef clone_deleter<null_cloner_type> Deleter;
Cont c_;
public:
Cont& base() { return c_; }
protected: // having this public could break encapsulation
const Cont& base() const { return c_; }
public: // typedefs
typedef Ty_* value_type;
typedef Ty_* pointer;
typedef Ty_& reference;
typedef const Ty_& const_reference;
typedef BOOST_DEDUCED_TYPENAME Config::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME Config::const_iterator
const_iterator;
typedef boost::reverse_iterator< iterator >
reverse_iterator;
typedef boost::reverse_iterator< const_iterator >
const_reverse_iterator;
typedef BOOST_DEDUCED_TYPENAME Cont::difference_type
difference_type;
typedef BOOST_DEDUCED_TYPENAME Cont::size_type
size_type;
typedef BOOST_DEDUCED_TYPENAME Config::allocator_type
allocator_type;
typedef CloneAllocator clone_allocator_type;
typedef ptr_container_detail::static_move_ptr<Ty_,Deleter>
auto_type;
protected:
typedef ptr_container_detail::scoped_deleter<Ty_,null_cloner_type>
scoped_deleter;
typedef BOOST_DEDUCED_TYPENAME Cont::iterator
ptr_iterator;
typedef BOOST_DEDUCED_TYPENAME Cont::const_iterator
ptr_const_iterator;
private:
template< class InputIterator >
void copy( InputIterator first, InputIterator last )
{
std::copy( first, last, begin() );
}
void copy( const reversible_ptr_container& r )
{
copy( r.begin(), r.end() );
}
void copy_clones_and_release( scoped_deleter& sd ) // nothrow
{
BOOST_ASSERT( size_type( std::distance( sd.begin(), sd.end() ) ) == c_.size() );
std::copy( sd.begin(), sd.end(), c_.begin() );
sd.release();
}
template< class ForwardIterator >
void clone_assign( ForwardIterator first,
ForwardIterator last ) // strong
{
BOOST_ASSERT( first != last );
scoped_deleter sd( first, last ); // strong
copy_clones_and_release( sd ); // nothrow
}
template< class ForwardIterator >
void clone_back_insert( ForwardIterator first,
ForwardIterator last )
{
BOOST_ASSERT( first != last );
scoped_deleter sd( first, last );
insert_clones_and_release( sd, end() );
}
void remove_all()
{
remove( begin(), end() );
}
protected:
void insert_clones_and_release( scoped_deleter& sd,
iterator where ) // strong
{
//
// 'c_.insert' always provides the strong guarantee for T* elements
// since a copy constructor of a pointer cannot throw
//
c_.insert( where.base(),
sd.begin(), sd.end() );
sd.release();
}
void insert_clones_and_release( scoped_deleter& sd ) // strong
{
c_.insert( sd.begin(), sd.end() );
sd.release();
}
template< class U >
void remove( U* ptr )
{
null_policy_deallocate_clone( ptr );
}
template< class I >
void remove( I i )
{
null_policy_deallocate_clone( Config::get_const_pointer(i) );
}
template< class I >
void remove( I first, I last )
{
for( ; first != last; ++first )
remove( first );
}
static void enforce_null_policy( const Ty_* x, const char* msg )
{
if( !allow_null )
{
BOOST_PTR_CONTAINER_THROW_EXCEPTION( 0 == x && "null not allowed",
bad_pointer, msg );
}
}
static Ty_* null_policy_allocate_clone( const Ty_* x )
{
return null_cloner_type::allocate_clone( x );
}
static void null_policy_deallocate_clone( const Ty_* x )
{
null_cloner_type::deallocate_clone( x );
}
private:
template< class ForwardIterator >
ForwardIterator advance( ForwardIterator begin, size_type n )
{
ForwardIterator iter = begin;
std::advance( iter, n );
return iter;
}
template< class I >
void constructor_impl( I first, I last, std::input_iterator_tag ) // basic
{
while( first != last )
{
insert( end(), null_cloner_type::allocate_clone_from_iterator(first) );
++first;
}
}
template< class I >
void constructor_impl( I first, I last, std::forward_iterator_tag ) // strong
{
if( first == last )
return;
clone_back_insert( first, last );
}
template< class I >
void associative_constructor_impl( I first, I last ) // strong
{
if( first == last )
return;
scoped_deleter sd( first, last );
insert_clones_and_release( sd );
}
public: // foundation! should be protected!
reversible_ptr_container()
{ }
template< class SizeType >
reversible_ptr_container( SizeType n, unordered_associative_container_tag )
: c_( n )
{ }
template< class SizeType >
reversible_ptr_container( SizeType n, fixed_length_sequence_tag )
: c_( n )
{ }
template< class SizeType >
reversible_ptr_container( SizeType n, const allocator_type& a,
fixed_length_sequence_tag )
: c_( n, a )
{ }
explicit reversible_ptr_container( const allocator_type& a )
: c_( a )
{ }
template< class PtrContainer >
explicit reversible_ptr_container( std::auto_ptr<PtrContainer> clone )
{
swap( *clone );
}
reversible_ptr_container( const reversible_ptr_container& r )
{
constructor_impl( r.begin(), r.end(), std::forward_iterator_tag() );
}
template< class C, class V >
reversible_ptr_container( const reversible_ptr_container<C,V>& r )
{
constructor_impl( r.begin(), r.end(), std::forward_iterator_tag() );
}
template< class PtrContainer >
reversible_ptr_container& operator=( std::auto_ptr<PtrContainer> clone ) // nothrow
{
swap( *clone );
return *this;
}
reversible_ptr_container& operator=( reversible_ptr_container r ) // strong
{
swap( r );
return *this;
}
// overhead: null-initilization of container pointer (very cheap compared to cloning)
// overhead: 1 heap allocation (very cheap compared to cloning)
template< class InputIterator >
reversible_ptr_container( InputIterator first,
InputIterator last,
const allocator_type& a = allocator_type() ) // basic, strong
: c_( a )
{
constructor_impl( first, last,
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
#else
BOOST_DEDUCED_TYPENAME
#endif
iterator_category<InputIterator>::type() );
}
template< class Compare >
reversible_ptr_container( const Compare& comp,
const allocator_type& a )
: c_( comp, a ) {}
template< class ForwardIterator >
reversible_ptr_container( ForwardIterator first,
ForwardIterator last,
fixed_length_sequence_tag )
: c_( std::distance(first,last) )
{
constructor_impl( first, last,
std::forward_iterator_tag() );
}
template< class SizeType, class InputIterator >
reversible_ptr_container( SizeType n,
InputIterator first,
InputIterator last,
fixed_length_sequence_tag )
: c_( n )
{
constructor_impl( first, last,
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
#else
BOOST_DEDUCED_TYPENAME
#endif
iterator_category<InputIterator>::type() );
}
template< class Compare >
reversible_ptr_container( const Compare& comp,
const allocator_type& a,
associative_container_tag )
: c_( comp, a )
{ }
template< class InputIterator >
reversible_ptr_container( InputIterator first,
InputIterator last,
associative_container_tag )
{
associative_constructor_impl( first, last );
}
template< class InputIterator, class Compare >
reversible_ptr_container( InputIterator first,
InputIterator last,
const Compare& comp,
const allocator_type& a,
associative_container_tag )
: c_( comp, a )
{
associative_constructor_impl( first, last );
}
explicit reversible_ptr_container( size_type n )
: c_( n ) {}
template< class Hash, class Pred >
reversible_ptr_container( const Hash& h,
const Pred& pred,
const allocator_type& a )
: c_( h, pred, a ) {}
template< class InputIterator, class Hash, class Pred >
reversible_ptr_container( InputIterator first,
InputIterator last,
const Hash& h,
const Pred& pred,
const allocator_type& a )
: c_( h, pred, a )
{
associative_constructor_impl( first, last );
}
public:
~reversible_ptr_container()
{
remove_all();
}
public:
allocator_type get_allocator() const
{
return c_.get_allocator();
}
public: // container requirements
iterator begin()
{ return iterator( c_.begin() ); }
const_iterator begin() const
{ return const_iterator( c_.begin() ); }
iterator end()
{ return iterator( c_.end() ); }
const_iterator end() const
{ return const_iterator( c_.end() ); }
reverse_iterator rbegin()
{ return reverse_iterator( this->end() ); }
const_reverse_iterator rbegin() const
{ return const_reverse_iterator( this->end() ); }
reverse_iterator rend()
{ return reverse_iterator( this->begin() ); }
const_reverse_iterator rend() const
{ return const_reverse_iterator( this->begin() ); }
const_iterator cbegin() const
{ return const_iterator( c_.begin() ); }
const_iterator cend() const
{ return const_iterator( c_.end() ); }
const_reverse_iterator crbegin() const
{ return const_reverse_iterator( this->end() ); }
const_reverse_iterator crend() const
{ return const_reverse_iterator( this->begin() ); }
void swap( reversible_ptr_container& r ) // nothrow
{
c_.swap( r.c_ );
}
size_type size() const // nothrow
{
return c_.size();
}
size_type max_size() const // nothrow
{
return c_.max_size();
}
bool empty() const // nothrow
{
return c_.empty();
}
public: // optional container requirements
bool operator==( const reversible_ptr_container& r ) const // nothrow
{
if( size() != r.size() )
return false;
else
return std::equal( begin(), end(), r.begin() );
}
bool operator!=( const reversible_ptr_container& r ) const // nothrow
{
return !(*this == r);
}
bool operator<( const reversible_ptr_container& r ) const // nothrow
{
return std::lexicographical_compare( begin(), end(), r.begin(), r.end() );
}
bool operator<=( const reversible_ptr_container& r ) const // nothrow
{
return !(r < *this);
}
bool operator>( const reversible_ptr_container& r ) const // nothrow
{
return r < *this;
}
bool operator>=( const reversible_ptr_container& r ) const // nothrow
{
return !(*this < r);
}
public: // modifiers
iterator insert( iterator before, Ty_* x )
{
enforce_null_policy( x, "Null pointer in 'insert()'" );
auto_type ptr( x ); // nothrow
iterator res( c_.insert( before.base(), x ) ); // strong, commit
ptr.release(); // nothrow
return res;
}
template< class U >
iterator insert( iterator before, std::auto_ptr<U> x )
{
return insert( before, x.release() );
}
iterator erase( iterator x ) // nothrow
{
BOOST_ASSERT( !empty() );
BOOST_ASSERT( x != end() );
remove( x );
return iterator( c_.erase( x.base() ) );
}
iterator erase( iterator first, iterator last ) // nothrow
{
remove( first, last );
return iterator( c_.erase( first.base(),
last.base() ) );
}
template< class Range >
iterator erase( const Range& r )
{
return erase( boost::begin(r), boost::end(r) );
}
void clear()
{
remove_all();
c_.clear();
}
public: // access interface
auto_type release( iterator where )
{
BOOST_ASSERT( where != end() );
BOOST_PTR_CONTAINER_THROW_EXCEPTION( empty(), bad_ptr_container_operation,
"'release()' on empty container" );
auto_type ptr( Config::get_pointer( where ) ); // nothrow
c_.erase( where.base() ); // nothrow
return boost::ptr_container_detail::move( ptr );
}
auto_type replace( iterator where, Ty_* x ) // strong
{
BOOST_ASSERT( where != end() );
enforce_null_policy( x, "Null pointer in 'replace()'" );
auto_type ptr( x );
BOOST_PTR_CONTAINER_THROW_EXCEPTION( empty(), bad_ptr_container_operation,
"'replace()' on empty container" );
auto_type old( Config::get_pointer( where ) ); // nothrow
const_cast<void*&>(*where.base()) = ptr.release();
return boost::ptr_container_detail::move( old );
}
template< class U >
auto_type replace( iterator where, std::auto_ptr<U> x )
{
return replace( where, x.release() );
}
auto_type replace( size_type idx, Ty_* x ) // strong
{
enforce_null_policy( x, "Null pointer in 'replace()'" );
auto_type ptr( x );
BOOST_PTR_CONTAINER_THROW_EXCEPTION( idx >= size(), bad_index,
"'replace()' out of bounds" );
auto_type old( static_cast<Ty_*>( c_[idx] ) ); // nothrow
c_[idx] = ptr.release(); // nothrow, commit
return boost::ptr_container_detail::move( old );
}
template< class U >
auto_type replace( size_type idx, std::auto_ptr<U> x )
{
return replace( idx, x.release() );
}
}; // 'reversible_ptr_container'
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
#define BOOST_PTR_CONTAINER_DEFINE_RELEASE( base_type ) \
typename base_type::auto_type \
release( typename base_type::iterator i ) \
{ \
return boost::ptr_container_detail::move(base_type::release(i)); \
}
#else
#define BOOST_PTR_CONTAINER_DEFINE_RELEASE( base_type ) \
using base_type::release;
#endif
//
// two-phase lookup of template functions
// is buggy on most compilers, so we use a macro instead
//
#define BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( PC, base_type, this_type ) \
explicit PC( std::auto_ptr<this_type> r ) \
: base_type ( r ) { } \
\
PC& operator=( std::auto_ptr<this_type> r ) \
{ \
base_type::operator=( r ); \
return *this; \
} \
\
std::auto_ptr<this_type> release() \
{ \
std::auto_ptr<this_type> ptr( new this_type );\
this->swap( *ptr ); \
return ptr; \
} \
BOOST_PTR_CONTAINER_DEFINE_RELEASE( base_type ) \
\
std::auto_ptr<this_type> clone() const \
{ \
return std::auto_ptr<this_type>( new this_type( this->begin(), this->end() ) ); \
}
#define BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( PC, base_type ) \
\
template< class U > \
PC( const PC<U>& r ) : base_type( r ) { } \
\
PC& operator=( PC r ) \
{ \
this->swap( r ); \
return *this; \
} \
#define BOOST_PTR_CONTAINER_DEFINE_CONSTRUCTORS( PC, base_type ) \
typedef BOOST_DEDUCED_TYPENAME base_type::iterator iterator; \
typedef BOOST_DEDUCED_TYPENAME base_type::size_type size_type; \
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference const_reference; \
typedef BOOST_DEDUCED_TYPENAME base_type::allocator_type allocator_type; \
PC() {} \
explicit PC( const allocator_type& a ) : base_type(a) {} \
template< class InputIterator > \
PC( InputIterator first, InputIterator last ) : base_type( first, last ) {} \
template< class InputIterator > \
PC( InputIterator first, InputIterator last, \
const allocator_type& a ) : base_type( first, last, a ) {}
#define BOOST_PTR_CONTAINER_DEFINE_NON_INHERITED_MEMBERS( PC, base_type, this_type ) \
BOOST_PTR_CONTAINER_DEFINE_CONSTRUCTORS( PC, base_type ) \
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( PC, base_type, this_type )
#define BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( PC, base_type, this_type ) \
BOOST_PTR_CONTAINER_DEFINE_NON_INHERITED_MEMBERS( PC, base_type, this_type ) \
BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( PC, base_type )
} // namespace 'ptr_container_detail'
//
// @remark: expose movability of internal move-pointer
//
namespace ptr_container
{
using ptr_container_detail::move;
}
} // namespace 'boost'
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
#endif

View File

@ -1,121 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_SCOPED_DELETER_HPP
#define BOOST_PTR_CONTAINER_SCOPED_DELETER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <iterator>
#include <cstddef>
#include <boost/scoped_array.hpp>
namespace boost
{
namespace ptr_container_detail
{
template< class T, class CloneAllocator >
class scoped_deleter
{
typedef std::size_t size_type;
scoped_array<T*> ptrs_;
size_type stored_;
bool released_;
public:
scoped_deleter( T** a, size_type size )
: ptrs_( a ), stored_( size ), released_( false )
{
BOOST_ASSERT( a );
}
scoped_deleter( size_type size )
: ptrs_( new T*[size] ), stored_( 0 ),
released_( false )
{
BOOST_ASSERT( size > 0 );
}
scoped_deleter( size_type n, const T& x ) // strong
: ptrs_( new T*[n] ), stored_(0),
released_( false )
{
for( size_type i = 0; i != n; i++ )
add( CloneAllocator::allocate_clone( &x ) );
BOOST_ASSERT( stored_ > 0 );
}
template< class InputIterator >
scoped_deleter ( InputIterator first, InputIterator last ) // strong
: ptrs_( new T*[ std::distance(first,last) ] ),
stored_(0),
released_( false )
{
for( ; first != last; ++first )
add( CloneAllocator::allocate_clone_from_iterator( first ) );
BOOST_ASSERT( stored_ > 0 );
}
~scoped_deleter()
{
if ( !released_ )
{
for( size_type i = 0u; i != stored_; ++i )
CloneAllocator::deallocate_clone( ptrs_[i] );
}
}
void add( T* t )
{
BOOST_ASSERT( ptrs_.get() != 0 );
ptrs_[stored_] = t;
++stored_;
}
void release()
{
released_ = true;
}
T** begin()
{
BOOST_ASSERT( ptrs_.get() != 0 );
return &ptrs_[0];
}
T** end()
{
BOOST_ASSERT( ptrs_.get() != 0 );
return &ptrs_[stored_];
}
}; // class 'scoped_deleter'
}
}
#endif

View File

@ -1,87 +0,0 @@
// Copyright Sebastian Ramacher, 2007.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_PTR_MAP_ADAPTER_HPP
#define BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_PTR_MAP_ADAPTER_HPP
#include <boost/ptr_container/ptr_map_adapter.hpp>
#include <boost/ptr_container/detail/serialize_xml_names.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/nvp.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class VoidPtrMap, class CloneAllocator, bool Ordered>
void save(Archive& ar, const ptr_container_detail::ptr_map_adapter_base<T, VoidPtrMap, CloneAllocator,Ordered>& c, unsigned int /*version*/)
{
typedef ptr_container_detail::ptr_map_adapter_base<T, VoidPtrMap, CloneAllocator,Ordered> container;
typedef BOOST_DEDUCED_TYPENAME container::const_iterator const_iterator;
ar << boost::serialization::make_nvp( ptr_container_detail::count(),
ptr_container_detail::serialize_as_const(c.size()) );
const_iterator i = c.begin(), e = c.end();
for(; i != e; ++i)
{
ar << boost::serialization::make_nvp( ptr_container_detail::first(), i->first );
ar << boost::serialization::make_nvp( ptr_container_detail::second(),
ptr_container_detail::serialize_as_const(i->second) );
}
}
template<class Archive, class T, class VoidPtrMap, class CloneAllocator, bool Ordered>
void load(Archive& ar, ptr_map_adapter<T, VoidPtrMap, CloneAllocator,Ordered>& c, unsigned int /*version*/)
{
typedef ptr_map_adapter<T, VoidPtrMap, CloneAllocator,Ordered> container;
typedef BOOST_DEDUCED_TYPENAME container::key_type key_type;
typedef BOOST_DEDUCED_TYPENAME container::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME container::iterator iterator;
c.clear();
size_type n;
ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
for(size_type i = 0u; i != n; ++i)
{
key_type key;
T* value;
ar >> boost::serialization::make_nvp( ptr_container_detail::first(), key );
ar >> boost::serialization::make_nvp( ptr_container_detail::second(), value );
std::pair<iterator, bool> p = c.insert(key, value);
ar.reset_object_address(&p.first->first, &key);
}
}
template<class Archive, class T, class VoidPtrMap, class CloneAllocator, bool Ordered>
void load(Archive& ar, ptr_multimap_adapter<T, VoidPtrMap, CloneAllocator,Ordered>& c, unsigned int /*version*/)
{
typedef ptr_multimap_adapter<T, VoidPtrMap, CloneAllocator,Ordered> container;
typedef BOOST_DEDUCED_TYPENAME container::key_type key_type;
typedef BOOST_DEDUCED_TYPENAME container::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME container::iterator iterator;
c.clear();
size_type n;
ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
for(size_type i = 0u; i != n; ++i)
{
key_type key;
T* value;
ar >> boost::serialization::make_nvp( ptr_container_detail::first(), key );
ar >> boost::serialization::make_nvp( ptr_container_detail::second(), value );
iterator p = c.insert(key, value);
ar.reset_object_address(&p->first, &key);
}
}
} // namespace serialization
} // namespace boost
#endif

View File

@ -1,86 +0,0 @@
// Copyright Sebastian Ramacher, 2007.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_REVERSIBLE_PTR_CONTAINER_HPP
#define BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_REVERSIBLE_PTR_CONTAINER_HPP
#include <boost/ptr_container/detail/reversible_ptr_container.hpp>
#include <boost/ptr_container/detail/serialize_xml_names.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/nvp.hpp>
namespace boost
{
namespace ptr_container_detail
{
template<class Archive, class Config, class CloneAllocator>
void save_helper(Archive& ar, const ptr_container_detail::reversible_ptr_container<Config, CloneAllocator>& c)
{
typedef ptr_container_detail::reversible_ptr_container<Config, CloneAllocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::const_iterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME container_type::value_type value_type;
const_iterator i = c.begin(), e = c.end();
for(; i != e; ++i)
ar << boost::serialization::make_nvp( ptr_container_detail::item(),
ptr_container_detail::serialize_as_const(static_cast<value_type>(*i.base())));
}
template<class Archive, class Config, class CloneAllocator>
void load_helper(Archive& ar, ptr_container_detail::reversible_ptr_container<Config, CloneAllocator>& c,
BOOST_DEDUCED_TYPENAME ptr_container_detail::reversible_ptr_container<Config, CloneAllocator>::size_type n)
{
typedef ptr_container_detail::reversible_ptr_container<Config, CloneAllocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME container_type::value_type value_type;
//
// Called after an appropriate reserve on c.
//
c.clear();
for(size_type i = 0u; i != n; ++i)
{
//
// Remark: pointers are not tracked,
// so we need not call ar.reset_object_address(v, u)
//
value_type ptr;
ar >> boost::serialization::make_nvp( ptr_container_detail::item(), ptr );
c.insert(c.end(), ptr);
}
}
} // namespace ptr_container_detail
namespace serialization
{
template<class Archive, class Config, class CloneAllocator>
void save(Archive& ar, const ptr_container_detail::reversible_ptr_container<Config, CloneAllocator>& c, unsigned int /*version*/)
{
ar << boost::serialization::make_nvp( ptr_container_detail::count(),
ptr_container_detail::serialize_as_const(c.size()) );
ptr_container_detail::save_helper(ar, c);
}
template<class Archive, class Config, class CloneAllocator>
void load(Archive& ar, ptr_container_detail::reversible_ptr_container<Config, CloneAllocator>& c, unsigned int /*version*/)
{
typedef ptr_container_detail::reversible_ptr_container<Config, CloneAllocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
size_type n;
ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
ptr_container_detail::load_helper(ar, c, n);
}
} // namespace serialization
} // namespace boost
#endif

View File

@ -1,32 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2007. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_XML_NAMES
#define BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_XML_NAMES
namespace boost
{
namespace ptr_container_detail
{
inline const char* count() { return "count"; }
inline const char* item() { return "item"; }
inline const char* first() { return "first"; }
inline const char* second() { return "second"; }
template<class T>
inline T const& serialize_as_const(T const& r)
{
return r;
}
}
}
#endif

View File

@ -1,211 +0,0 @@
// (C) Copyright Thorsten Ottosen 2005.
// (C) Copyright Jonathan Turkanis 2004.
// (C) Copyright Daniel Wallin 2004.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
// Implementation of the move_ptr from the "Move Proposal"
// (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1377.htm)
// enhanced to support custom deleters and safe boolean conversions.
//
// The implementation is based on an implementation by Daniel Wallin, at
// "http://aspn.activestate.com/ASPN/Mail/Message/Attachments/boost/
// 400DC271.1060903@student.umu.se/move_ptr.hpp". The current was adapted
// by Jonathan Turkanis to incorporating ideas of Howard Hinnant and
// Rani Sharoni.
#ifndef BOOST_STATIC_MOVE_PTR_HPP_INCLUDED
#define BOOST_STATIC_MOVE_PTR_HPP_INCLUDED
#include <boost/config.hpp> // Member template friends, put size_t in std.
#include <cstddef> // size_t
#include <boost/compressed_pair.hpp>
#include <boost/ptr_container/detail/default_deleter.hpp>
#include <boost/ptr_container/detail/is_convertible.hpp>
#include <boost/ptr_container/detail/move.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_array.hpp>
#if defined(BOOST_MSVC)
#pragma warning(push)
#pragma warning(disable:4521) // Multiple copy constuctors.
#endif
namespace boost { namespace ptr_container_detail {
template< typename T,
typename Deleter =
move_ptrs::default_deleter<T> >
class static_move_ptr
{
public:
typedef typename remove_bounds<T>::type element_type;
typedef Deleter deleter_type;
private:
struct safe_bool_helper { int x; };
typedef int safe_bool_helper::* safe_bool;
typedef boost::compressed_pair<element_type*, Deleter> impl_type;
public:
typedef typename impl_type::second_reference deleter_reference;
typedef typename impl_type::second_const_reference deleter_const_reference;
// Constructors
static_move_ptr() : impl_(0) { }
static_move_ptr(const static_move_ptr& p)
: impl_(p.get(), p.get_deleter())
{
const_cast<static_move_ptr&>(p).release();
}
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
static_move_ptr( const move_ptrs::move_source<static_move_ptr<T,Deleter> >& src )
#else
static_move_ptr( const move_ptrs::move_source<static_move_ptr>& src )
#endif
: impl_(src.ptr().get(), src.ptr().get_deleter())
{
src.ptr().release();
}
template<typename TT>
explicit static_move_ptr(TT* tt)
: impl_(tt, Deleter())
{ }
// Destructor
~static_move_ptr() { if (ptr()) get_deleter()(ptr()); }
// Assignment
static_move_ptr& operator=(static_move_ptr rhs)
{
rhs.swap(*this);
return *this;
}
// Smart pointer interface
element_type* get() const { return ptr(); }
element_type& operator*()
{
/*BOOST_STATIC_ASSERT(!is_array);*/ return *ptr();
}
const element_type& operator*() const
{
/*BOOST_STATIC_ASSERT(!is_array);*/ return *ptr();
}
element_type* operator->()
{
/*BOOST_STATIC_ASSERT(!is_array);*/ return ptr();
}
const element_type* operator->() const
{
/*BOOST_STATIC_ASSERT(!is_array);*/ return ptr();
}
element_type* release()
{
element_type* result = ptr();
ptr() = 0;
return result;
}
void reset()
{
if (ptr()) get_deleter()(ptr());
ptr() = 0;
}
template<typename TT>
void reset(TT* tt)
{
static_move_ptr(tt).swap(*this);
}
template<typename TT, typename DD>
void reset(TT* tt, DD dd)
{
static_move_ptr(tt, dd).swap(*this);
}
operator safe_bool() const { return ptr() ? &safe_bool_helper::x : 0; }
void swap(static_move_ptr& p) { impl_.swap(p.impl_); }
deleter_reference get_deleter() { return impl_.second(); }
deleter_const_reference get_deleter() const { return impl_.second(); }
private:
template<typename TT, typename DD>
void check(const static_move_ptr<TT, DD>& ptr)
{
typedef move_ptrs::is_smart_ptr_convertible<TT, T> convertible;
BOOST_STATIC_ASSERT(convertible::value);
}
#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || defined(BOOST_NO_SFINAE)
// give up on this behavior
#else
template<typename Ptr> struct cant_move_from_const;
template<typename TT, typename DD>
struct cant_move_from_const< const static_move_ptr<TT, DD> > {
typedef typename static_move_ptr<TT, DD>::error type;
};
template<typename Ptr>
static_move_ptr(Ptr&, typename cant_move_from_const<Ptr>::type = 0);
public:
static_move_ptr(static_move_ptr&);
private:
template<typename TT, typename DD>
static_move_ptr( static_move_ptr<TT, DD>&,
typename
move_ptrs::enable_if_convertible<
TT, T, static_move_ptr&
>::type::type* = 0 );
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING || BOOST_NO_SFINAE
//#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
// template<typename TT, typename DD>
// friend class static_move_ptr;
//#else
public:
//#endif
typename impl_type::first_reference
ptr() { return impl_.first(); }
typename impl_type::first_const_reference
ptr() const { return impl_.first(); }
impl_type impl_;
};
} // namespace ptr_container_detail
} // End namespace boost.
#if defined(BOOST_MSVC)
#pragma warning(pop) // #pragma warning(disable:4251)
#endif
#endif // #ifndef BOOST_STATIC_MOVE_PTR_HPP_INCLUDED

View File

@ -1,33 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2006. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_THROW_EXCEPTION
#define BOOST_PTR_CONTAINER_DETAIL_THROW_EXCEPTION
#include <boost/assert.hpp>
#include <boost/config.hpp>
#ifdef BOOST_NO_EXCEPTIONS
#define BOOST_PTR_CONTAINER_NO_EXCEPTIONS
#endif
#ifdef BOOST_PTR_CONTAINER_NO_EXCEPTIONS
#define BOOST_PTR_CONTAINER_THROW_EXCEPTION( If, Ex, Msg ) BOOST_ASSERT( !(If) && Msg )
#else
#define BOOST_PTR_CONTAINER_THROW_EXCEPTION( If, Ex, Msg ) if( (If) ) throw Ex ( Msg )
#endif // BOOST_PTR_CONTAINER_NO_EXCEPTIONS
#endif

View File

@ -1,229 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_VOID_PTR_ITERATOR_HPP
#define BOOST_PTR_CONTAINER_DETAIL_VOID_PTR_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/config.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/type_traits/remove_const.hpp>
namespace boost
{
template
<
class VoidIter,
class T
>
class void_ptr_iterator
{
public:
typedef BOOST_DEDUCED_TYPENAME boost::remove_const<T>::type
value_type;
typedef T& reference;
typedef T* pointer;
typedef BOOST_DEDUCED_TYPENAME iterator_difference<VoidIter>::type
difference_type;
typedef BOOST_DEDUCED_TYPENAME iterator_category<VoidIter>::type
iterator_category;
private:
VoidIter iter_;
public:
void_ptr_iterator() : iter_()
{ }
void_ptr_iterator( VoidIter r ) : iter_(r)
{ }
//
// Remark: passing by value breaks vc7.1
//
template< class MutableIterator, class MutableT >
void_ptr_iterator( const void_ptr_iterator<MutableIterator,MutableT>& r )
#ifdef BOOST_NO_SFINAE
: iter_( VoidIter(const_cast<void**>(&*r.base())) )
#else
: iter_(r.base())
#endif
{ }
T& operator*() const
{
return *static_cast<T*>( *iter_ );
}
T* operator->() const
{
return static_cast<T*>( *iter_ );
}
void_ptr_iterator& operator++()
{
++iter_;
return *this;
}
void_ptr_iterator operator++(int)
{
void_ptr_iterator res = *this;
++iter_;
return res;
}
void_ptr_iterator& operator--()
{
--iter_;
return *this;
}
void_ptr_iterator operator--(int)
{
void_ptr_iterator res = *this;
--iter_;
return res;
}
void_ptr_iterator& operator+=( difference_type n )
{
iter_ += n;
return *this;
}
void_ptr_iterator& operator-=( difference_type n )
{
iter_ -= n;
return *this;
}
T& operator[]( difference_type n ) const
{
return *static_cast<T*>( *(iter_ + n) );
}
VoidIter base() const
{
return iter_;
}
}; // class 'void_ptr_iterator'
template< class VoidIter, class T >
inline void_ptr_iterator<VoidIter,T>
operator+( void_ptr_iterator<VoidIter,T> l,
BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n )
{
l += n;
return l;
}
template< class VoidIter, class T >
inline void_ptr_iterator<VoidIter,T>
operator+( BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n,
void_ptr_iterator<VoidIter,T> r )
{
r += n;
return r;
}
template< class VoidIter, class T >
inline void_ptr_iterator<VoidIter,T>
operator-( void_ptr_iterator<VoidIter,T> l,
BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n )
{
l -= n;
return l;
}
template< class VoidIter, class T >
inline void_ptr_iterator<VoidIter,T>
operator-( BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type n,
void_ptr_iterator<VoidIter,T> r )
{
r -= n;
return r;
}
template< class VoidIter, class T, class VoidIterU, class U >
inline BOOST_DEDUCED_TYPENAME void_ptr_iterator<VoidIter,T>::difference_type
operator-( void_ptr_iterator<VoidIter,T> l,
void_ptr_iterator<VoidIterU,U> r )
{
return l.base() - r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator==( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() == r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator!=( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() != r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator<( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() < r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator<=( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() <= r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator>( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() > r.base();
}
template< class VoidIterT, class T, class VoidIterU, class U >
inline bool operator>=( const void_ptr_iterator<VoidIterT,T>& l,
const void_ptr_iterator<VoidIterU,U>& r )
{
return l.base() >= r.base();
}
}
#endif

View File

@ -1,58 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_EXCEPTION_HPP
#define BOOST_PTR_CONTAINER_EXCEPTION_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <exception>
namespace boost
{
class bad_ptr_container_operation : public std::exception
{
const char* what_;
public:
bad_ptr_container_operation( const char* what ) : what_( what )
{ }
virtual const char* what() const throw()
{
return what_;
}
};
class bad_index : public bad_ptr_container_operation
{
public:
bad_index( const char* what ) : bad_ptr_container_operation( what )
{ }
};
class bad_pointer : public bad_ptr_container_operation
{
public:
bad_pointer() : bad_ptr_container_operation( "Null pointer not allowed in a pointer container!" )
{ }
bad_pointer( const char* text ) : bad_ptr_container_operation( text )
{ }
};
}
#endif

View File

@ -1,151 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2007. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_INDIRECT_FUN_HPP
#define BOOST_PTR_CONTAINER_INDIRECT_FUN_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma once
#endif
#include <boost/config.hpp>
#ifdef BOOST_NO_SFINAE
#else
#include <boost/utility/result_of.hpp>
#include <boost/pointee.hpp>
#endif // BOOST_NO_SFINAE
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_void.hpp>
#include <functional>
namespace boost
{
namespace ptr_container_detail
{
template <typename Type, typename Dummy>
struct make_lazy
{
typedef typename Type::type type;
};
}
template
<
class Fun
#ifdef BOOST_NO_SFINAE
, class Result = bool
#endif
>
class indirect_fun
{
Fun fun;
public:
indirect_fun() : fun(Fun())
{ }
indirect_fun( Fun f ) : fun(f)
{ }
template< class T >
#ifdef BOOST_NO_SFINAE
Result
#else
typename boost::result_of< const Fun( typename pointee<T>::type& ) >::type
#endif
operator()( const T& r ) const
{
return fun( *r );
}
template< class T, class U >
#ifdef BOOST_NO_SFINAE
Result
#else
typename boost::result_of< const Fun( typename pointee<T>::type&,
typename pointee<U>::type& ) >::type
#endif
operator()( const T& r, const U& r2 ) const
{
return fun( *r, *r2 );
}
};
template< class Fun >
inline indirect_fun<Fun> make_indirect_fun( Fun f )
{
return indirect_fun<Fun>( f );
}
template
<
class Fun,
class Arg1,
class Arg2 = Arg1
#ifdef BOOST_NO_SFINAE
, class Result = bool
#endif
>
class void_ptr_indirect_fun
{
Fun fun;
public:
void_ptr_indirect_fun() : fun(Fun())
{ }
void_ptr_indirect_fun( Fun f ) : fun(f)
{ }
template< class Void >
#ifdef BOOST_NO_SFINAE
Result
#else
typename ptr_container_detail::make_lazy<
boost::result_of<const Fun(const Arg1&)>, Void>::type
#endif
operator()( const Void* r ) const
{
BOOST_STATIC_ASSERT(boost::is_void<Void>::value);
BOOST_ASSERT( r != 0 );
return fun( * static_cast<const Arg1*>( r ) );
}
template< class Void >
#ifdef BOOST_NO_SFINAE
Result
#else
typename ptr_container_detail::make_lazy<
boost::result_of<const Fun(const Arg1&, const Arg2&)>, Void>::type
#endif
operator()( const Void* l, const Void* r ) const
{
BOOST_STATIC_ASSERT(boost::is_void<Void>::value);
BOOST_ASSERT( l != 0 && r != 0 );
return fun( * static_cast<const Arg1*>( l ), * static_cast<const Arg2*>( r ) );
}
};
template< class Arg, class Fun >
inline void_ptr_indirect_fun<Fun,Arg> make_void_ptr_indirect_fun( Fun f )
{
return void_ptr_indirect_fun<Fun,Arg>( f );
}
} // namespace 'boost'
#endif

View File

@ -1,73 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_INDIRECT_CONTAINER_NULLABLE_HPP
#define BOOST_INDIRECT_CONTAINER_NULLABLE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/config.hpp>
namespace boost
{
template< class T >
struct nullable
{
typedef T type;
};
namespace ptr_container_detail
{
template< class T >
type_traits::yes_type is_nullable( const nullable<T>* );
type_traits::no_type is_nullable( ... );
}
template< class T >
struct is_nullable
{
private:
BOOST_STATIC_CONSTANT( T*, var );
public:
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:6334)
#endif
BOOST_STATIC_CONSTANT(bool, value = sizeof( ptr_container_detail::is_nullable( var ) )
== sizeof( type_traits::yes_type ) );
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
};
template< class T >
struct remove_nullable
{
typedef BOOST_DEDUCED_TYPENAME mpl::eval_if< is_nullable<T>,
T,
mpl::identity<T> >::type
type;
};
}
#endif

View File

@ -1,234 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_ARRAY_HPP
#define BOOST_PTR_CONTAINER_PTR_ARRAY_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/array.hpp>
#include <boost/static_assert.hpp>
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
namespace boost
{
namespace ptr_container_detail
{
template
<
class T,
size_t N,
class Allocator = int // dummy
>
class ptr_array_impl : public boost::array<T,N>
{
public:
typedef Allocator allocator_type;
ptr_array_impl( Allocator /*a*/ = Allocator() )
{
this->assign( 0 );
}
ptr_array_impl( size_t, T*, Allocator /*a*/ = Allocator() )
{
this->assign( 0 );
}
};
}
template
<
class T,
size_t N,
class CloneAllocator = heap_clone_allocator
>
class ptr_array : public
ptr_sequence_adapter< T,
ptr_container_detail::ptr_array_impl<void*,N>,
CloneAllocator >
{
private:
typedef ptr_sequence_adapter< T,
ptr_container_detail::ptr_array_impl<void*,N>,
CloneAllocator >
base_class;
typedef BOOST_DEDUCED_TYPENAME remove_nullable<T>::type U;
typedef ptr_array<T,N,CloneAllocator>
this_type;
public:
typedef std::size_t size_type;
typedef U* value_type;
typedef U* pointer;
typedef U& reference;
typedef const U& const_reference;
typedef BOOST_DEDUCED_TYPENAME base_class::auto_type
auto_type;
public: // constructors
ptr_array() : base_class()
{ }
ptr_array( const ptr_array& r )
{
size_t i = 0;
for( ; i != N; ++i )
this->base()[i] = this->null_policy_allocate_clone(
static_cast<const T*>( &r[i] ) );
}
template< class U >
ptr_array( const ptr_array<U,N>& r )
{
size_t i = 0;
for( ; i != N; ++i )
this->base()[i] = this->null_policy_allocate_clone(
static_cast<const T*>( &r[i] ) );
}
explicit ptr_array( std::auto_ptr<this_type> r )
: base_class( r ) { }
ptr_array& operator=( ptr_array r )
{
this->swap( r );
return *this;
}
ptr_array& operator=( std::auto_ptr<this_type> r )
{
base_class::operator=(r);
return *this;
}
std::auto_ptr<this_type> release()
{
std::auto_ptr<this_type> ptr( new this_type );
this->swap( *ptr );
return ptr;
}
std::auto_ptr<this_type> clone() const
{
std::auto_ptr<this_type> pa( new this_type );
for( size_t i = 0; i != N; ++i )
{
if( ! is_null(i) )
pa->replace( i, this->null_policy_allocate_clone( &(*this)[i] ) );
}
return pa;
}
private: // hide some members
using base_class::insert;
using base_class::erase;
using base_class::push_back;
using base_class::push_front;
using base_class::pop_front;
using base_class::pop_back;
using base_class::transfer;
using base_class::get_allocator;
public: // compile-time interface
template< size_t idx >
auto_type replace( U* r ) // strong
{
BOOST_STATIC_ASSERT( idx < N );
this->enforce_null_policy( r, "Null pointer in 'ptr_array::replace()'" );
auto_type res( static_cast<U*>( this->base()[idx] ) ); // nothrow
this->base()[idx] = r; // nothrow
return boost::ptr_container::move(res); // nothrow
}
template< size_t idx, class V >
auto_type replace( std::auto_ptr<V> r )
{
return replace<idx>( r.release() );
}
auto_type replace( size_t idx, U* r ) // strong
{
this->enforce_null_policy( r, "Null pointer in 'ptr_array::replace()'" );
auto_type ptr( r );
BOOST_PTR_CONTAINER_THROW_EXCEPTION( idx >= N, bad_index,
"'replace()' aout of bounds" );
auto_type res( static_cast<U*>( this->base()[idx] ) ); // nothrow
this->base()[idx] = ptr.release(); // nothrow
return boost::ptr_container::move(res); // nothrow
}
template< class V >
auto_type replace( size_t idx, std::auto_ptr<V> r )
{
return replace( idx, r.release() );
}
using base_class::at;
template< size_t idx >
T& at()
{
BOOST_STATIC_ASSERT( idx < N );
return (*this)[idx];
}
template< size_t idx >
const T& at() const
{
BOOST_STATIC_ASSERT( idx < N );
return (*this)[idx];
}
bool is_null( size_t idx ) const
{
return base_class::is_null(idx);
}
template< size_t idx >
bool is_null() const
{
BOOST_STATIC_ASSERT( idx < N );
return this->base()[idx] == 0;
}
};
//////////////////////////////////////////////////////////////////////////////
// clonability
template< typename T, size_t size, typename CA >
inline ptr_array<T,size,CA>* new_clone( const ptr_array<T,size,CA>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename T, size_t size, typename CA >
inline void swap( ptr_array<T,size,CA>& l, ptr_array<T,size,CA>& r )
{
l.swap(r);
}
}
#endif

View File

@ -1,531 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_CIRCULAR_BUFFER_HPP
#define BOOST_PTR_CONTAINER_PTR_CIRCULAR_BUFFER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/circular_buffer.hpp>
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
namespace boost
{
template
<
class T,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_circular_buffer : public
ptr_sequence_adapter< T,
boost::circular_buffer<void*,Allocator>,
CloneAllocator >
{
typedef ptr_sequence_adapter< T,
boost::circular_buffer<void*,Allocator>,
CloneAllocator >
base_type;
typedef boost::circular_buffer<void*,Allocator> circular_buffer_type;
typedef ptr_circular_buffer<T,CloneAllocator,Allocator> this_type;
public: // typedefs
typedef typename base_type::value_type value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef typename base_type::size_type size_type;
typedef typename base_type::allocator_type allocator_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::auto_type auto_type;
typedef std::pair<pointer,size_type> array_range;
typedef std::pair<const_pointer,size_type> const_array_range;
typedef typename circular_buffer_type::capacity_type capacity_type;
public: // constructors
ptr_circular_buffer()
{ }
explicit ptr_circular_buffer( capacity_type n )
: base_type( n, ptr_container_detail::fixed_length_sequence_tag() )
{ }
ptr_circular_buffer( capacity_type n,
const allocator_type& alloc )
: base_type( n, alloc, ptr_container_detail::fixed_length_sequence_tag() )
{ }
template< class ForwardIterator >
ptr_circular_buffer( ForwardIterator first, ForwardIterator last )
: base_type( first, last, ptr_container_detail::fixed_length_sequence_tag() )
{ }
template< class InputIterator >
ptr_circular_buffer( capacity_type n, InputIterator first, InputIterator last )
: base_type( n, first, last, ptr_container_detail::fixed_length_sequence_tag() )
{ }
ptr_circular_buffer( const ptr_circular_buffer& r )
: base_type( r.size(), r.begin(), r.end(),
ptr_container_detail::fixed_length_sequence_tag() )
{ }
template< class U >
ptr_circular_buffer( const ptr_circular_buffer<U>& r )
: base_type( r.size(), r.begin(), r.end(),
ptr_container_detail::fixed_length_sequence_tag() )
{ }
ptr_circular_buffer& operator=( ptr_circular_buffer r )
{
this->swap( r );
return *this;
}
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_circular_buffer,
base_type, this_type )
public: // allocators
allocator_type& get_allocator()
{
return this->base().get_allocator();
}
allocator_type get_allocator() const
{
return this->base().get_allocator();
}
public: // circular buffer functions
array_range array_one() // nothrow
{
typename circular_buffer_type::array_range r = this->base().array_one();
return array_range( reinterpret_cast<pointer>(r.first), r.second );
}
const_array_range array_one() const // nothrow
{
typename circular_buffer_type::const_array_range r = this->base().array_one();
return const_array_range( reinterpret_cast<const_pointer>(r.first), r.second );
}
array_range array_two() // nothrow
{
typename circular_buffer_type::array_range r = this->base().array_two();
return array_range( reinterpret_cast<pointer>(r.first), r.second );
}
const_array_range array_two() const // nothrow
{
typename circular_buffer_type::const_array_range r = this->base().array_two();
return const_array_range( reinterpret_cast<const_pointer>(r.first), r.second );
}
pointer linearize() // nothrow
{
return reinterpret_cast<pointer>(this->base().linearize());
}
bool full() const // nothrow
{
return this->base().full();
}
size_type reserve() const // nothrow
{
return this->base().reserve();
}
void reserve( size_type n ) // strong
{
if( capacity() < n )
set_capacity( n );
}
capacity_type capacity() const // nothrow
{
return this->base().capacity();
}
void set_capacity( capacity_type new_capacity ) // strong
{
if( this->size() > new_capacity )
{
this->erase( this->begin() + new_capacity, this->end() );
}
this->base().set_capacity( new_capacity );
}
void rset_capacity( capacity_type new_capacity ) // strong
{
if( this->size() > new_capacity )
{
this->erase( this->begin(),
this->begin() + (this->size()-new_capacity) );
}
this->base().rset_capacity( new_capacity );
}
void resize( size_type size ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( boost::next( this->begin(), size ), this->end() );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_back( new BOOST_DEDUCED_TYPENAME
boost::remove_pointer<value_type>::type() );
}
BOOST_ASSERT( this->size() == size );
}
void resize( size_type size, value_type to_clone ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( boost::next( this->begin(), size ), this->end() );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_back( this->null_policy_allocate_clone( to_clone ) );
}
BOOST_ASSERT( this->size() == size );
}
void rresize( size_type size ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( this->begin(),
boost::next( this->begin(), old_size - size ) );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_front( new BOOST_DEDUCED_TYPENAME
boost::remove_pointer<value_type>::type() );
}
BOOST_ASSERT( this->size() == size );
}
void rresize( size_type size, value_type to_clone ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( this->begin(),
boost::next( this->begin(), old_size - size ) );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_front( this->null_policy_allocate_clone( to_clone ) );
}
BOOST_ASSERT( this->size() == size );
}
template< class InputIterator >
void assign( InputIterator first, InputIterator last ) // strong
{
ptr_circular_buffer temp( first, last );
this->swap( temp );
}
template< class Range >
void assign( const Range& r ) // strong
{
assign( boost::begin(r), boost::end(r ) );
}
void assign( size_type n, value_type to_clone ) // strong
{
ptr_circular_buffer temp( n );
for( size_type i = 0u; i != n; ++i )
temp.push_back( this->null_policy_allocate_clone( to_clone ) );
this->swap( temp );
}
void assign( capacity_type capacity, size_type n,
value_type to_clone ) // basic
{
this->assign( (std::min)(n,capacity), to_clone );
}
template< class InputIterator >
void assign( capacity_type capacity,
InputIterator first, InputIterator last ) // basic
{
this->assign( first, last );
this->set_capacity( capacity );
}
void push_back( value_type ptr ) // nothrow
{
BOOST_ASSERT( capacity() > 0 );
this->enforce_null_policy( ptr, "Null pointer in 'push_back()'" );
auto_type old_ptr;
if( full() )
old_ptr.reset( &*this->begin() );
this->base().push_back( ptr );
}
template< class U >
void push_back( std::auto_ptr<U> ptr ) // nothrow
{
push_back( ptr.release() );
}
void push_front( value_type ptr ) // nothrow
{
BOOST_ASSERT( capacity() > 0 );
this->enforce_null_policy( ptr, "Null pointer in 'push_front()'" );
auto_type old_ptr;
if( full() )
old_ptr.reset( &*(--this->end()) );
this->base().push_front( ptr );
}
template< class U >
void push_front( std::auto_ptr<U> ptr ) // nothrow
{
push_front( ptr.release() );
}
iterator insert( iterator pos, value_type ptr ) // nothrow
{
BOOST_ASSERT( capacity() > 0 );
this->enforce_null_policy( ptr, "Null pointer in 'insert()'" );
auto_type new_ptr( ptr );
iterator b = this->begin();
if( full() && pos == b )
return b;
auto_type old_ptr;
if( full() )
old_ptr.reset( &*this->begin() );
new_ptr.release();
return this->base().insert( pos.base(), ptr );
}
template< class U >
iterator insert( iterator pos, std::auto_ptr<U> ptr ) // nothrow
{
return insert( pos, ptr.release() );
}
template< class InputIterator >
void insert( iterator pos, InputIterator first, InputIterator last ) // basic
{
for( ; first != last; ++first, ++pos )
pos = insert( pos, this->null_policy_allocate_clone( &*first ) );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME
boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
insert( iterator before, const Range& r )
{
insert( before, boost::begin(r), boost::end(r) );
}
#endif
iterator rinsert( iterator pos, value_type ptr ) // nothrow
{
BOOST_ASSERT( capacity() > 0 );
this->enforce_null_policy( ptr, "Null pointer in 'rinsert()'" );
auto_type new_ptr( ptr );
iterator b = this->end();
if (full() && pos == b)
return b;
auto_type old_ptr;
if( full() )
old_ptr.reset( &this->back() );
new_ptr.release();
return this->base().rinsert( pos.base(), ptr );
}
template< class U >
iterator rinsert( iterator pos, std::auto_ptr<U> ptr ) // nothrow
{
return rinsert( pos, ptr.release() );
}
template< class InputIterator >
void rinsert( iterator pos, InputIterator first, InputIterator last ) // basic
{
for( ; first != last; ++first, ++pos )
pos = rinsert( pos, this->null_policy_allocate_clone( &*first ) );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME
boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
rinsert( iterator before, const Range& r )
{
rinsert( before, boost::begin(r), boost::end(r) );
}
#endif
iterator rerase( iterator pos ) // nothrow
{
BOOST_ASSERT( !this->empty() );
BOOST_ASSERT( pos != this->end() );
this->remove( pos );
return iterator( this->base().rerase( pos.base() ) );
}
iterator rerase( iterator first, iterator last ) // nothrow
{
this->remove( first, last );
return iterator( this->base().rerase( first.base(),
last.base() ) );
}
template< class Range >
iterator rerase( const Range& r ) // nothrow
{
return rerase( boost::begin(r), boost::end(r) );
}
void rotate( const_iterator new_begin ) // nothrow
{
this->base().rotate( new_begin.base() );
}
public: // transfer
template< class PtrSeqAdapter >
void transfer( iterator before,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator last,
PtrSeqAdapter& from ) // nothrow
{
BOOST_ASSERT( (void*)&from != (void*)this );
if( from.empty() )
return;
for( BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator begin = first;
begin != last; ++begin, ++before )
before = insert( before, &*begin ); // nothrow
from.base().erase( first.base(), last.base() ); // nothrow
}
template< class PtrSeqAdapter >
void transfer( iterator before,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator object,
PtrSeqAdapter& from ) // nothrow
{
BOOST_ASSERT( (void*)&from != (void*)this );
if( from.empty() )
return;
insert( before, &*object ); // nothrow
from.base().erase( object.base() ); // nothrow
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrSeqAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator > >::type
transfer( iterator before, const Range& r, PtrSeqAdapter& from ) // nothrow
{
transfer( before, boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrSeqAdapter >
void transfer( iterator before, PtrSeqAdapter& from ) // nothrow
{
transfer( before, from.begin(), from.end(), from );
}
public: // C-array support
void transfer( iterator before, value_type* from,
size_type size, bool delete_from = true ) // nothrow
{
BOOST_ASSERT( from != 0 );
if( delete_from )
{
BOOST_DEDUCED_TYPENAME base_type::scoped_deleter
deleter( from, size ); // nothrow
for( size_type i = 0u; i != size; ++i, ++before )
before = insert( before, *(from+i) ); // nothrow
deleter.release(); // nothrow
}
else
{
for( size_type i = 0u; i != size; ++i, ++before )
before = insert( before, *(from+i) ); // nothrow
}
}
value_type* c_array() // nothrow
{
if( this->empty() )
return 0;
this->linearize();
T** res = reinterpret_cast<T**>( &this->begin().base()[0] );
return res;
}
};
//////////////////////////////////////////////////////////////////////////////
// clonability
template< typename T, typename CA, typename A >
inline ptr_circular_buffer<T,CA,A>* new_clone( const ptr_circular_buffer<T,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename T, typename CA, typename A >
inline void swap( ptr_circular_buffer<T,CA,A>& l, ptr_circular_buffer<T,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@ -1,31 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_HPP
#define BOOST_PTR_CONTAINER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/ptr_array.hpp>
#include <boost/ptr_container/ptr_deque.hpp>
#include <boost/ptr_container/ptr_list.hpp>
#include <boost/ptr_container/ptr_map.hpp>
#include <boost/ptr_container/ptr_set.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/ptr_container/ptr_unordered_map.hpp>
#include <boost/ptr_container/ptr_unordered_set.hpp>
#include <boost/ptr_container/ptr_circular_buffer.hpp>
#include <boost/ptr_container/ptr_inserter.hpp>
#endif

View File

@ -1,69 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_DEQUE_HPP
#define BOOST_PTR_CONTAINER_PTR_DEQUE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <deque>
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
namespace boost
{
template
<
class T,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_deque : public
ptr_sequence_adapter< T,
std::deque<void*,Allocator>,
CloneAllocator >
{
typedef ptr_sequence_adapter< T,
std::deque<void*,Allocator>,
CloneAllocator >
base_class;
typedef ptr_deque<T,CloneAllocator,Allocator> this_type;
public:
BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( ptr_deque,
base_class,
this_type )
};
//////////////////////////////////////////////////////////////////////////////
// clonability
template< typename T, typename CA, typename A >
inline ptr_deque<T,CA,A>* new_clone( const ptr_deque<T,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename T, typename CA, typename A >
inline void swap( ptr_deque<T,CA,A>& l, ptr_deque<T,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@ -1,258 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_INSERTER_HPP
#define BOOST_PTR_CONTAINER_PTR_INSERTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <iterator>
#include <memory>
namespace boost
{
namespace ptr_container
{
template< class PtrContainer >
class ptr_back_insert_iterator;
template< class PtrContainer >
class ptr_front_insert_iterator;
template< class PtrContainer >
class ptr_insert_iterator;
template< class PtrContainer >
ptr_back_insert_iterator<PtrContainer>
ptr_back_inserter( PtrContainer& cont );
template< class PtrContainer >
ptr_front_insert_iterator<PtrContainer>
ptr_front_inserter( PtrContainer& cont );
template< class PtrContainer >
ptr_insert_iterator<PtrContainer>
ptr_inserter( PtrContainer& cont, typename PtrContainer::iterator before );
//////////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////////
template< class PtrContainer >
class ptr_back_insert_iterator :
public std::iterator<std::output_iterator_tag,void,void,void,void>
{
public:
typedef PtrContainer container_type;
public:
explicit ptr_back_insert_iterator( PtrContainer& cont )
: container(&cont)
{ }
ptr_back_insert_iterator&
operator=( typename PtrContainer::value_type r )
{
typename PtrContainer::value_type obj = 0;
if( r != 0 )
obj = container_type::clone_allocator_type::allocate_clone(*r);
container->push_back( obj );
return *this;
}
template< class T >
ptr_back_insert_iterator&
operator=( std::auto_ptr<T> r )
{
container->push_back( r );
return *this;
}
ptr_back_insert_iterator&
operator=( typename PtrContainer::const_reference r )
{
container->push_back( container_type::clone_allocator_type::
allocate_clone(r) );
return *this;
}
ptr_back_insert_iterator& operator*()
{
return *this;
}
ptr_back_insert_iterator& operator++()
{
return *this;
}
ptr_back_insert_iterator operator++(int)
{
return *this;
}
protected:
PtrContainer* container;
};
template< class PtrContainer >
class ptr_front_insert_iterator :
public std::iterator<std::output_iterator_tag,void,void,void,void>
{
public:
typedef PtrContainer container_type;
public:
explicit ptr_front_insert_iterator( PtrContainer& cont )
: container(&cont)
{ }
ptr_front_insert_iterator&
operator=( typename PtrContainer::value_type r )
{
typename PtrContainer::value_type obj = 0;
if( r != 0 )
obj = container_type::clone_allocator_type::allocate_clone(*r);
container->push_front( obj );
return *this;
}
template< class T >
ptr_front_insert_iterator&
operator=( std::auto_ptr<T> r )
{
container->push_front( r );
return *this;
}
ptr_front_insert_iterator&
operator=( typename PtrContainer::const_reference r )
{
container->push_front( container_type::clone_allocator_type::
allocate_clone(r) );
return *this;
}
ptr_front_insert_iterator& operator*()
{
return *this;
}
ptr_front_insert_iterator& operator++()
{
return *this;
}
ptr_front_insert_iterator operator++(int)
{
return *this;
}
protected:
PtrContainer* container;
};
template< class PtrContainer >
class ptr_insert_iterator :
public std::iterator<std::output_iterator_tag,void,void,void,void>
{
public:
typedef PtrContainer container_type;
public:
ptr_insert_iterator( PtrContainer& cont,
typename PtrContainer::iterator before )
: container(&cont), iter(before)
{ }
ptr_insert_iterator&
operator=( typename PtrContainer::value_type r )
{
typename PtrContainer::value_type obj = 0;
if( r != 0 )
obj = container_type::clone_allocator_type::allocate_clone(*r);
iter = container->insert( iter, obj );
return *this;
}
template< class T >
ptr_insert_iterator&
operator=( std::auto_ptr<T> r )
{
iter = container->insert( iter, r );
return *this;
}
ptr_insert_iterator&
operator=( typename PtrContainer::const_reference r )
{
iter = container->insert( iter, container_type::clone_allocator_type::
allocate_clone(r) );
return *this;
}
ptr_insert_iterator& operator*()
{
return *this;
}
ptr_insert_iterator& operator++()
{
return *this;
}
ptr_insert_iterator operator++(int)
{
return *this;
}
protected:
PtrContainer* container;
typename PtrContainer::iterator iter;
};
template< class PtrContainer >
inline ptr_back_insert_iterator<PtrContainer>
ptr_back_inserter( PtrContainer& cont )
{
return ptr_back_insert_iterator<PtrContainer>( cont );
}
template< class PtrContainer >
inline ptr_front_insert_iterator<PtrContainer>
ptr_front_inserter( PtrContainer& cont )
{
return ptr_front_insert_iterator<PtrContainer>( cont );
}
template< class PtrContainer >
inline ptr_insert_iterator<PtrContainer>
ptr_inserter( PtrContainer& cont,
typename PtrContainer::iterator before )
{
return ptr_insert_iterator<PtrContainer>( cont, before );
}
} // namespace 'ptr_container'
} // namespace 'boost'
#endif

View File

@ -1,110 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_LIST_HPP
#define BOOST_PTR_CONTAINER_PTR_LIST_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
#include <list>
namespace boost
{
template
<
class T,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_list : public
ptr_sequence_adapter< T,
std::list<void*,Allocator>,
CloneAllocator >
{
typedef ptr_sequence_adapter< T,
std::list<void*,Allocator>,
CloneAllocator >
base_class;
typedef ptr_list<T,CloneAllocator,Allocator> this_type;
public:
BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( ptr_list,
base_class,
this_type )
typedef BOOST_DEDUCED_TYPENAME base_class::value_type value_type;
public:
using base_class::merge;
void merge( ptr_list& x )
{
merge( x, std::less<T>() );
}
template< typename Compare >
void merge( ptr_list& x, Compare comp )
{
this->base().merge( x.base(), void_ptr_indirect_fun<Compare,T>( comp ) ); }
void sort()
{
sort( std::less<T>() );
};
template< typename Compare >
void sort( Compare comp )
{
this->base().sort( void_ptr_indirect_fun<Compare,T>( comp ) );
}
template< class Pred >
void erase_if( iterator first, iterator last, Pred pred )
{
base_class::erase_if( first, last, pred );
}
template< class Pred >
void erase_if( Pred pred )
{
this->base().remove_if( BOOST_DEDUCED_TYPENAME base_class::
BOOST_NESTED_TEMPLATE void_ptr_delete_if<Pred,value_type>
(pred) );
}
}; // class 'ptr_list'
//////////////////////////////////////////////////////////////////////////////
// clonability
template< typename T, typename CA, typename A >
inline ptr_list<T,CA,A>* new_clone( const ptr_list<T,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename T, typename CA, typename A >
inline void swap( ptr_list<T,CA,A>& l, ptr_list<T,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@ -1,165 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_MAP_HPP
#define BOOST_PTR_CONTAINER_PTR_MAP_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <map>
#include <boost/ptr_container/ptr_map_adapter.hpp>
namespace boost
{
template
<
class Key,
class T,
class Compare = std::less<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator< std::pair<const Key,void*> >
>
class ptr_map :
public ptr_map_adapter<T,std::map<Key,void*,
Compare,Allocator>,CloneAllocator>
{
typedef ptr_map_adapter<T,std::map<Key,void*,
Compare,Allocator>,CloneAllocator>
base_type;
typedef ptr_map<Key,T,Compare,CloneAllocator,Allocator> this_type;
public:
ptr_map()
{ }
explicit ptr_map( const Compare& comp,
const Allocator& a = Allocator() )
: base_type( comp, a ) { }
template< class InputIterator >
ptr_map( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< class InputIterator >
ptr_map( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator& a = Allocator() )
: base_type( first, last, comp, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_map, base_type,
this_type )
template< class U >
ptr_map( const ptr_map<Key,U>& r ) : base_type( r )
{ }
ptr_map& operator=( ptr_map r )
{
this->swap( r );
return *this;
}
};
template
<
class Key,
class T,
class Compare = std::less<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator< std::pair<const Key,void*> >
>
class ptr_multimap :
public ptr_multimap_adapter<T,std::multimap<Key,void*,
Compare,Allocator>,CloneAllocator>
{
typedef ptr_multimap_adapter<T,std::multimap<Key,void*,
Compare,Allocator>,CloneAllocator>
base_type;
typedef ptr_multimap<Key,T,Compare,CloneAllocator,Allocator> this_type;
public:
ptr_multimap()
{ }
explicit ptr_multimap( const Compare& comp,
const Allocator& a = Allocator() )
: base_type( comp, a ) { }
template< class InputIterator >
ptr_multimap( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< class InputIterator >
ptr_multimap( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator& a = Allocator() )
: base_type( first, last, comp, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multimap,
base_type,
this_type )
template< class U >
ptr_multimap( const ptr_multimap<Key,U>& r ) : base_type( r )
{ }
ptr_multimap& operator=( ptr_multimap r )
{
this->swap( r );
return *this;
}
};
//////////////////////////////////////////////////////////////////////////////
// clonability
template< class K, class T, class C, class CA, class A >
inline ptr_map<K,T,C,CA,A>* new_clone( const ptr_map<K,T,C,CA,A>& r )
{
return r.clone().release();
}
template< class K, class T, class C, class CA, class A >
inline ptr_multimap<K,T,C,CA,A>* new_clone( const ptr_multimap<K,T,C,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename K, typename T, typename C, typename CA, typename A >
inline void swap( ptr_map<K,T,C,CA,A>& l, ptr_map<K,T,C,CA,A>& r )
{
l.swap(r);
}
template< typename K, typename T, typename C, typename CA, typename A >
inline void swap( ptr_multimap<K,T,C,CA,A>& l, ptr_multimap<K,T,C,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@ -1,874 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_DETAIL_PTR_MAP_ADAPTER_HPP
#define BOOST_PTR_CONTAINER_DETAIL_PTR_MAP_ADAPTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/detail/map_iterator.hpp>
#include <boost/ptr_container/detail/associative_ptr_container.hpp>
#include <boost/ptr_container/detail/meta_functions.hpp>
#include <boost/static_assert.hpp>
#include <boost/range/iterator_range.hpp>
namespace boost
{
namespace ptr_container_detail
{
template
<
class T,
class VoidPtrMap,
bool Ordered
>
struct map_config
{
typedef BOOST_DEDUCED_TYPENAME remove_nullable<T>::type
U;
typedef VoidPtrMap
void_container_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::allocator_type
allocator_type;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_value_compare<VoidPtrMap>,
mpl::identity<void> >::type
value_compare;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_key_compare<VoidPtrMap>,
mpl::identity<void> >::type
key_compare;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
mpl::identity<void>,
select_hasher<VoidPtrMap> >::type
hasher;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
mpl::identity<void>,
select_key_equal<VoidPtrMap> >::type
key_equal;
typedef BOOST_DEDUCED_TYPENAME
mpl::if_c<Ordered,
ptr_container_detail::ordered_associative_container_tag,
ptr_container_detail::unordered_associative_container_tag>::type
container_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::key_type
key_type;
typedef U value_type;
typedef ptr_map_iterator< BOOST_DEDUCED_TYPENAME VoidPtrMap::iterator, key_type, U* const >
iterator;
typedef ptr_map_iterator< BOOST_DEDUCED_TYPENAME VoidPtrMap::const_iterator, key_type, const U* const>
const_iterator;
typedef ptr_map_iterator<
BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_iterator<VoidPtrMap>,
select_local_iterator<VoidPtrMap> >::type,
key_type, U* const >
local_iterator;
typedef ptr_map_iterator<
BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_iterator<VoidPtrMap>,
select_const_local_iterator<VoidPtrMap> >::type,
key_type, const U* const >
const_local_iterator;
template< class Iter >
static U* get_pointer( Iter i )
{
return i->second;
}
template< class Iter >
static const U* get_const_pointer( Iter i )
{
return i->second;
}
BOOST_STATIC_CONSTANT( bool, allow_null = boost::is_nullable<T>::value );
};
template
<
class T,
class VoidPtrMap,
class CloneAllocator,
bool Ordered
>
class ptr_map_adapter_base :
public ptr_container_detail::associative_ptr_container< map_config<T,VoidPtrMap,Ordered>,
CloneAllocator >
{
typedef ptr_container_detail::associative_ptr_container< map_config<T,VoidPtrMap,Ordered>,
CloneAllocator >
base_type;
typedef map_config<T,VoidPtrMap,Ordered> config;
typedef ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator,Ordered> this_type;
public:
typedef BOOST_DEDUCED_TYPENAME base_type::allocator_type
allocator_type;
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
const_iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef BOOST_DEDUCED_TYPENAME base_type::key_type
key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
typedef BOOST_DEDUCED_TYPENAME base_type::value_type
mapped_type;
typedef BOOST_DEDUCED_TYPENAME base_type::reference
mapped_reference;
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
const_mapped_reference;
typedef BOOST_DEDUCED_TYPENAME iterator_value<iterator>::type
value_type;
typedef value_type
reference;
typedef BOOST_DEDUCED_TYPENAME iterator_value<const_iterator>::type
const_reference;
typedef value_type
pointer;
typedef const_reference
const_pointer;
private:
const_mapped_reference lookup( const key_type& key ) const
{
const_iterator i = this->find( key );
if( i != this->end() )
return *i->second;
else
BOOST_PTR_CONTAINER_THROW_EXCEPTION( true, bad_ptr_container_operation,
"'ptr_map/multimap::at()' could"
" not find key" );
}
struct eraser // scope guard
{
bool released_;
VoidPtrMap* m_;
const key_type& key_;
eraser( VoidPtrMap* m, const key_type& key )
: released_(false), m_(m), key_(key)
{}
~eraser()
{
if( !released_ )
m_->erase(key_);
}
void release() { released_ = true; }
private:
eraser& operator=(const eraser&);
};
mapped_reference insert_lookup( const key_type& key )
{
void*& ref = this->base()[key];
if( ref )
{
return *static_cast<mapped_type>(ref);
}
else
{
eraser e(&this->base(),key); // nothrow
mapped_type res = new T(); // strong
ref = res; // nothrow
e.release(); // nothrow
return *res;
}
}
public:
ptr_map_adapter_base()
{ }
template< class SizeType >
explicit ptr_map_adapter_base( SizeType n,
ptr_container_detail::unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Compare, class Allocator >
ptr_map_adapter_base( const Compare& comp,
const Allocator& a )
: base_type( comp, a )
{ }
template< class Hash, class Pred, class Allocator >
ptr_map_adapter_base( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator >
ptr_map_adapter_base( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< class InputIterator, class Comp >
ptr_map_adapter_base( InputIterator first, InputIterator last,
const Comp& comp,
const allocator_type& a = allocator_type() )
: base_type( first, last, comp, a )
{ }
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_map_adapter_base( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( first, last, hash, pred, a )
{ }
template< class PtrContainer >
explicit ptr_map_adapter_base( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
template< typename PtrContainer >
ptr_map_adapter_base& operator=( std::auto_ptr<PtrContainer> clone )
{
base_type::operator=( clone );
return *this;
}
iterator find( const key_type& x )
{
return iterator( this->base().find( x ) );
}
const_iterator find( const key_type& x ) const
{
return const_iterator( this->base().find( x ) );
}
size_type count( const key_type& x ) const
{
return this->base().count( x );
}
iterator lower_bound( const key_type& x )
{
return iterator( this->base().lower_bound( x ) );
}
const_iterator lower_bound( const key_type& x ) const
{
return const_iterator( this->base().lower_bound( x ) );
}
iterator upper_bound( const key_type& x )
{
return iterator( this->base().upper_bound( x ) );
}
const_iterator upper_bound( const key_type& x ) const
{
return const_iterator( this->base().upper_bound( x ) );
}
iterator_range<iterator> equal_range( const key_type& x )
{
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator>
p = this->base().equal_range( x );
return make_iterator_range( iterator( p.first ), iterator( p.second ) );
}
iterator_range<const_iterator> equal_range( const key_type& x ) const
{
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator,
BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator>
p = this->base().equal_range( x );
return make_iterator_range( const_iterator( p.first ),
const_iterator( p.second ) );
}
mapped_reference at( const key_type& key )
{
return const_cast<mapped_reference>( lookup( key ) );
}
const_mapped_reference at( const key_type& key ) const
{
return lookup( key );
}
mapped_reference operator[]( const key_type& key )
{
return insert_lookup( key );
}
auto_type replace( iterator where, mapped_type x ) // strong
{
BOOST_ASSERT( where != this->end() );
this->enforce_null_policy( x, "Null pointer in 'replace()'" );
auto_type ptr( x );
BOOST_PTR_CONTAINER_THROW_EXCEPTION( this->empty(),
bad_ptr_container_operation,
"'replace()' on empty container" );
auto_type old( where->second ); // nothrow
where.base()->second = ptr.release(); // nothrow, commit
return boost::ptr_container::move( old );
}
template< class U >
auto_type replace( iterator where, std::auto_ptr<U> x )
{
return replace( where, x.release() );
}
protected:
size_type bucket( const key_type& key ) const
{
return this->base().bucket( key );
}
};
} // ptr_container_detail
/////////////////////////////////////////////////////////////////////////
// ptr_map_adapter
/////////////////////////////////////////////////////////////////////////
template
<
class T,
class VoidPtrMap,
class CloneAllocator = heap_clone_allocator,
bool Ordered = true
>
class ptr_map_adapter :
public ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator,Ordered>
{
typedef ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator,Ordered>
base_type;
public:
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
const_iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef BOOST_DEDUCED_TYPENAME base_type::key_type
key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
const_reference;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMap::allocator_type
allocator_type;
typedef BOOST_DEDUCED_TYPENAME base_type::mapped_type
mapped_type;
private:
void safe_insert( const key_type& key, auto_type ptr ) // strong
{
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool>
res =
this->base().insert( std::make_pair( key, ptr.get() ) ); // strong, commit
if( res.second ) // nothrow
ptr.release(); // nothrow
}
template< class II >
void map_basic_clone_and_insert( II first, II last )
{
while( first != last )
{
if( this->find( first->first ) == this->end() )
{
const_reference p = *first.base(); // nothrow
auto_type ptr( this->null_policy_allocate_clone( p.second ) );
// strong
this->safe_insert( p.first,
boost::ptr_container::move( ptr ) );
// strong, commit
}
++first;
}
}
public:
ptr_map_adapter( )
{ }
template< class Comp >
explicit ptr_map_adapter( const Comp& comp,
const allocator_type& a )
: base_type( comp, a ) { }
template< class Hash, class Pred, class Allocator >
ptr_map_adapter( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator >
ptr_map_adapter( InputIterator first, InputIterator last )
{
map_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Comp >
ptr_map_adapter( InputIterator first, InputIterator last,
const Comp& comp,
const allocator_type& a = allocator_type() )
: base_type( comp, a )
{
map_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_map_adapter( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{
map_basic_clone_and_insert( first, last );
}
ptr_map_adapter( const ptr_map_adapter& r )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
template< class Key, class U, class CA, bool b >
ptr_map_adapter( const ptr_map_adapter<Key,U,CA,b>& r )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
template< class U >
ptr_map_adapter( std::auto_ptr<U> r ) : base_type( r )
{ }
ptr_map_adapter& operator=( ptr_map_adapter r )
{
this->swap( r );
return *this;
}
template< class U >
ptr_map_adapter& operator=( std::auto_ptr<U> r )
{
base_type::operator=( r );
return *this;
}
using base_type::release;
template< typename InputIterator >
void insert( InputIterator first, InputIterator last ) // basic
{
map_basic_clone_and_insert( first, last );
}
template< class Range >
void insert( const Range& r )
{
insert( boost::begin(r), boost::end(r) );
}
private:
std::pair<iterator,bool> insert_impl( const key_type& key, mapped_type x ) // strong
{
this->enforce_null_policy( x, "Null pointer in ptr_map_adapter::insert()" );
auto_type ptr( x ); // nothrow
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool>
res = this->base().insert( std::make_pair( key, x ) ); // strong, commit
if( res.second ) // nothrow
ptr.release(); // nothrow
return std::make_pair( iterator( res.first ), res.second ); // nothrow
}
iterator insert_impl( iterator before, const key_type& key, mapped_type x ) // strong
{
this->enforce_null_policy( x,
"Null pointer in 'ptr_map_adapter::insert()'" );
auto_type ptr( x ); // nothrow
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
res = this->base().insert( before.base(), std::make_pair( key, x ) );
// strong, commit
ptr.release(); // notrow
return iterator( res );
}
public:
std::pair<iterator,bool> insert( key_type& key, mapped_type x )
{
return insert_impl( key, x );
}
template< class U >
std::pair<iterator,bool> insert( const key_type& key, std::auto_ptr<U> x )
{
return insert_impl( key, x.release() );
}
template< class F, class S >
iterator insert( iterator before, ptr_container_detail::ref_pair<F,S> p ) // strong
{
this->enforce_null_policy( p.second,
"Null pointer in 'ptr_map_adapter::insert()'" );
auto_type ptr( this->null_policy_allocate_clone( p.second ) );
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
result = this->base().insert( before.base(),
std::make_pair(p.first,ptr.get()) ); // strong
if( ptr.get() == result->second )
ptr.release();
return iterator( result );
}
iterator insert( iterator before, key_type& key, mapped_type x ) // strong
{
return insert_impl( before, key, x );
}
template< class U >
iterator insert( iterator before, const key_type& key, std::auto_ptr<U> x ) // strong
{
return insert_impl( before, key, x.release() );
}
template< class PtrMapAdapter >
bool transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator object,
PtrMapAdapter& from ) // strong
{
return this->single_transfer( object, from );
}
template< class PtrMapAdapter >
size_type transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator last,
PtrMapAdapter& from ) // basic
{
return this->single_transfer( first, last, from );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrMapAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator >,
size_type >::type
transfer( const Range& r, PtrMapAdapter& from ) // basic
{
return transfer( boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrMapAdapter >
size_type transfer( PtrMapAdapter& from ) // basic
{
return transfer( from.begin(), from.end(), from );
}
};
/////////////////////////////////////////////////////////////////////////
// ptr_multimap_adapter
/////////////////////////////////////////////////////////////////////////
template
<
class T,
class VoidPtrMultiMap,
class CloneAllocator = heap_clone_allocator,
bool Ordered = true
>
class ptr_multimap_adapter :
public ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMultiMap,CloneAllocator,Ordered>
{
typedef ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMultiMap,CloneAllocator,Ordered>
base_type;
public: // typedefs
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
const_iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef BOOST_DEDUCED_TYPENAME base_type::key_type
key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
const_reference;
typedef BOOST_DEDUCED_TYPENAME base_type::mapped_type
mapped_type;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMultiMap::allocator_type
allocator_type;
private:
void safe_insert( const key_type& key, auto_type ptr ) // strong
{
this->base().insert(
std::make_pair( key, ptr.get() ) ); // strong, commit
ptr.release(); // nothrow
}
template< typename II >
void map_basic_clone_and_insert( II first, II last )
{
while( first != last )
{
const_reference pair = *first.base(); // nothrow
auto_type ptr( this->null_policy_allocate_clone( pair.second ) );
// strong
safe_insert( pair.first,
boost::ptr_container::move( ptr ) );
// strong, commit
++first;
}
}
public:
ptr_multimap_adapter()
{ }
template< class SizeType >
ptr_multimap_adapter( SizeType n,
ptr_container_detail::unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Comp >
explicit ptr_multimap_adapter( const Comp& comp,
const allocator_type& a )
: base_type( comp, a ) { }
template< class Hash, class Pred, class Allocator >
ptr_multimap_adapter( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator >
ptr_multimap_adapter( InputIterator first, InputIterator last )
{
map_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Comp >
ptr_multimap_adapter( InputIterator first, InputIterator last,
const Comp& comp,
const allocator_type& a )
: base_type( comp, a )
{
map_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_multimap_adapter( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{
map_basic_clone_and_insert( first, last );
}
ptr_multimap_adapter( const ptr_multimap_adapter& r )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
template< class Key, class U, class CA, bool b >
ptr_multimap_adapter( const ptr_multimap_adapter<Key,U,CA,b>& r )
{
map_basic_clone_and_insert( r.begin(), r.end() );
}
template< class U >
explicit ptr_multimap_adapter( std::auto_ptr<U> r ) : base_type( r )
{ }
ptr_multimap_adapter& operator=( ptr_multimap_adapter r )
{
this->swap( r );
return *this;
}
template< class U >
ptr_multimap_adapter& operator=( std::auto_ptr<U> r )
{
base_type::operator=( r );
return *this;
}
using base_type::release;
private:
iterator insert_impl( const key_type& key, mapped_type x ) // strong
{
this->enforce_null_policy( x,
"Null pointer in 'ptr_multimap_adapter::insert()'" );
auto_type ptr( x ); // nothrow
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
res = this->base().insert( std::make_pair( key, x ) );
// strong, commit
ptr.release(); // notrow
return iterator( res );
}
iterator insert_impl( iterator before, const key_type& key, mapped_type x ) // strong
{
this->enforce_null_policy( x,
"Null pointer in 'ptr_multimap_adapter::insert()'" );
auto_type ptr( x ); // nothrow
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
res = this->base().insert( before.base(),
std::make_pair( key, x ) );
// strong, commit
ptr.release(); // notrow
return iterator( res );
}
public:
template< typename InputIterator >
void insert( InputIterator first, InputIterator last ) // basic
{
map_basic_clone_and_insert( first, last );
}
template< class Range >
void insert( const Range& r )
{
insert( boost::begin(r), boost::end(r) );
}
iterator insert( key_type& key, mapped_type x ) // strong
{
return insert_impl( key, x );
}
template< class U >
iterator insert( const key_type& key, std::auto_ptr<U> x )
{
return insert_impl( key, x.release() );
}
template< class F, class S >
iterator insert( iterator before, ptr_container_detail::ref_pair<F,S> p ) // strong
{
this->enforce_null_policy( p.second,
"Null pointer in 'ptr_multimap_adapter::insert()'" );
iterator res = insert_impl( before, p.first,
this->null_policy_allocate_clone( p.second ) );
return res;
}
iterator insert( iterator before, key_type& key, mapped_type x ) // strong
{
return insert_impl( before, key, x );
}
template< class U >
iterator insert( iterator before, const key_type& key, std::auto_ptr<U> x ) // strong
{
return insert_impl( before, key, x.release() );
}
template< class PtrMapAdapter >
void transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator object,
PtrMapAdapter& from ) // strong
{
this->multi_transfer( object, from );
}
template< class PtrMapAdapter >
size_type transfer( BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator last,
PtrMapAdapter& from ) // basic
{
return this->multi_transfer( first, last, from );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrMapAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrMapAdapter::iterator >,
size_type >::type
transfer( const Range& r, PtrMapAdapter& from ) // basic
{
return transfer( boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrMapAdapter >
void transfer( PtrMapAdapter& from ) // basic
{
transfer( from.begin(), from.end(), from );
BOOST_ASSERT( from.empty() );
}
};
template< class I, class F, class S >
inline bool is_null( const ptr_map_iterator<I,F,S>& i )
{
return i->second == 0;
}
} // namespace 'boost'
#endif

View File

@ -1,775 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_SEQUENCE_ADAPTER_HPP
#define BOOST_PTR_CONTAINER_PTR_SEQUENCE_ADAPTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/detail/reversible_ptr_container.hpp>
#include <boost/ptr_container/indirect_fun.hpp>
#include <boost/ptr_container/detail/void_ptr_iterator.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost
{
namespace ptr_container_detail
{
template
<
class T,
class VoidPtrSeq
>
struct sequence_config
{
typedef BOOST_DEDUCED_TYPENAME remove_nullable<T>::type
U;
typedef VoidPtrSeq
void_container_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrSeq::allocator_type
allocator_type;
typedef U value_type;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME VoidPtrSeq::iterator, U >
iterator;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME VoidPtrSeq::const_iterator, const U >
const_iterator;
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
template< class Iter >
static U* get_pointer( Iter i )
{
return static_cast<U*>( *i.base() );
}
#else
template< class Iter >
static U* get_pointer( void_ptr_iterator<Iter,U> i )
{
return static_cast<U*>( *i.base() );
}
template< class Iter >
static U* get_pointer( Iter i )
{
return &*i;
}
#endif
#if defined(BOOST_NO_SFINAE) && !BOOST_WORKAROUND(__MWERKS__, <= 0x3003)
template< class Iter >
static const U* get_const_pointer( Iter i )
{
return static_cast<const U*>( *i.base() );
}
#else // BOOST_NO_SFINAE
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003)
template< class Iter >
static const U* get_const_pointer( void_ptr_iterator<Iter,U> i )
{
return static_cast<const U*>( *i.base() );
}
#else // BOOST_WORKAROUND
template< class Iter >
static const U* get_const_pointer( void_ptr_iterator<Iter,const U> i )
{
return static_cast<const U*>( *i.base() );
}
#endif // BOOST_WORKAROUND
template< class Iter >
static const U* get_const_pointer( Iter i )
{
return &*i;
}
#endif // BOOST_NO_SFINAE
BOOST_STATIC_CONSTANT(bool, allow_null = boost::is_nullable<T>::value );
};
} // ptr_container_detail
template< class Iterator, class T >
inline bool is_null( void_ptr_iterator<Iterator,T> i )
{
return *i.base() == 0;
}
template
<
class T,
class VoidPtrSeq,
class CloneAllocator = heap_clone_allocator
>
class ptr_sequence_adapter : public
ptr_container_detail::reversible_ptr_container< ptr_container_detail::sequence_config<T,VoidPtrSeq>,
CloneAllocator >
{
typedef ptr_container_detail::reversible_ptr_container< ptr_container_detail::sequence_config<T,VoidPtrSeq>,
CloneAllocator >
base_type;
typedef ptr_sequence_adapter<T,VoidPtrSeq,CloneAllocator>
this_type;
protected:
typedef BOOST_DEDUCED_TYPENAME base_type::scoped_deleter scoped_deleter;
public:
typedef BOOST_DEDUCED_TYPENAME base_type::value_type value_type;
typedef BOOST_DEDUCED_TYPENAME base_type::reference reference;
typedef BOOST_DEDUCED_TYPENAME base_type::const_reference
const_reference;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type auto_type;
typedef BOOST_DEDUCED_TYPENAME base_type::clone_allocator_type
clone_allocator_type;
typedef BOOST_DEDUCED_TYPENAME base_type::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME base_type::allocator_type
allocator_type;
ptr_sequence_adapter()
{ }
template< class Allocator >
explicit ptr_sequence_adapter( const Allocator& a )
: base_type( a )
{ }
template< class SizeType >
ptr_sequence_adapter( SizeType n,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( n, tag )
{ }
template< class SizeType, class Allocator >
ptr_sequence_adapter( SizeType n, const Allocator& a,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( n, a, tag )
{ }
template< class InputIterator >
ptr_sequence_adapter( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< class InputIterator, class Allocator >
ptr_sequence_adapter( InputIterator first, InputIterator last,
const Allocator& a )
: base_type( first, last, a )
{ }
template< class ForwardIterator >
ptr_sequence_adapter( ForwardIterator first,
ForwardIterator last,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( first, last, tag )
{ }
template< class SizeType, class ForwardIterator >
ptr_sequence_adapter( SizeType n,
ForwardIterator first,
ForwardIterator last,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( n, first, last, tag )
{ }
ptr_sequence_adapter( const ptr_sequence_adapter& r )
: base_type( r )
{ }
template< class U >
ptr_sequence_adapter( const ptr_sequence_adapter<U,VoidPtrSeq,CloneAllocator>& r )
: base_type( r )
{ }
ptr_sequence_adapter( const ptr_sequence_adapter& r,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( r, tag )
{ }
template< class U >
ptr_sequence_adapter( const ptr_sequence_adapter<U,VoidPtrSeq,CloneAllocator>& r,
ptr_container_detail::fixed_length_sequence_tag tag )
: base_type( r, tag )
{ }
template< class PtrContainer >
explicit ptr_sequence_adapter( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
ptr_sequence_adapter& operator=( const ptr_sequence_adapter r )
{
this->swap( r );
return *this;
}
template< class PtrContainer >
ptr_sequence_adapter& operator=( std::auto_ptr<PtrContainer> clone )
{
base_type::operator=( clone );
return *this;
}
/////////////////////////////////////////////////////////////
// modifiers
/////////////////////////////////////////////////////////////
void push_back( value_type x ) // strong
{
this->enforce_null_policy( x, "Null pointer in 'push_back()'" );
auto_type ptr( x ); // notrow
this->base().push_back( x ); // strong, commit
ptr.release(); // nothrow
}
template< class U >
void push_back( std::auto_ptr<U> x )
{
push_back( x.release() );
}
void push_front( value_type x )
{
this->enforce_null_policy( x, "Null pointer in 'push_front()'" );
auto_type ptr( x ); // nothrow
this->base().push_front( x ); // strong, commit
ptr.release(); // nothrow
}
template< class U >
void push_front( std::auto_ptr<U> x )
{
push_front( x.release() );
}
auto_type pop_back()
{
BOOST_ASSERT( !this->empty() &&
"'pop_back()' on empty container" );
auto_type ptr( static_cast<value_type>( this->base().back() ) );
// nothrow
this->base().pop_back(); // nothrow
return ptr_container_detail::move( ptr ); // nothrow
}
auto_type pop_front()
{
BOOST_ASSERT( !this->empty() &&
"'pop_front()' on empty container" );
auto_type ptr( static_cast<value_type>( this->base().front() ) );
// nothrow
this->base().pop_front(); // nothrow
return ptr_container_detail::move( ptr );
}
reference front()
{
BOOST_ASSERT( !this->empty() &&
"accessing 'front()' on empty container" );
BOOST_ASSERT( !::boost::is_null( this->begin() ) );
return *this->begin();
}
const_reference front() const
{
return const_cast<ptr_sequence_adapter*>(this)->front();
}
reference back()
{
BOOST_ASSERT( !this->empty() &&
"accessing 'back()' on empty container" );
BOOST_ASSERT( !::boost::is_null( --this->end() ) );
return *--this->end();
}
const_reference back() const
{
return const_cast<ptr_sequence_adapter*>(this)->back();
}
public: // deque/vector inerface
reference operator[]( size_type n ) // nothrow
{
BOOST_ASSERT( n < this->size() );
BOOST_ASSERT( !this->is_null( n ) );
return *static_cast<value_type>( this->base()[n] );
}
const_reference operator[]( size_type n ) const // nothrow
{
BOOST_ASSERT( n < this->size() );
BOOST_ASSERT( !this->is_null( n ) );
return *static_cast<value_type>( this->base()[n] );
}
reference at( size_type n )
{
BOOST_PTR_CONTAINER_THROW_EXCEPTION( n >= this->size(), bad_index,
"'at()' out of bounds" );
BOOST_ASSERT( !this->is_null( n ) );
return (*this)[n];
}
const_reference at( size_type n ) const
{
BOOST_PTR_CONTAINER_THROW_EXCEPTION( n >= this->size(), bad_index,
"'at()' out of bounds" );
BOOST_ASSERT( !this->is_null( n ) );
return (*this)[n];
}
public: // vector interface
size_type capacity() const
{
return this->base().capacity();
}
void reserve( size_type n )
{
this->base().reserve( n );
}
void reverse()
{
this->base().reverse();
}
public: // assign, insert, transfer
// overhead: 1 heap allocation (very cheap compared to cloning)
template< class InputIterator >
void assign( InputIterator first, InputIterator last ) // strong
{
base_type temp( first, last );
this->swap( temp );
}
template< class Range >
void assign( const Range& r ) // strong
{
assign( boost::begin(r), boost::end(r ) );
}
private:
template< class I >
void insert_impl( iterator before, I first, I last, std::input_iterator_tag ) // strong
{
ptr_sequence_adapter temp(first,last); // strong
transfer( before, temp ); // strong, commit
}
template< class I >
void insert_impl( iterator before, I first, I last, std::forward_iterator_tag ) // strong
{
if( first == last )
return;
scoped_deleter sd( first, last ); // strong
this->insert_clones_and_release( sd, before ); // strong, commit
}
public:
using base_type::insert;
template< class InputIterator >
void insert( iterator before, InputIterator first, InputIterator last ) // strong
{
insert_impl( before, first, last, BOOST_DEDUCED_TYPENAME
iterator_category<InputIterator>::type() );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME
boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
insert( iterator before, const Range& r )
{
insert( before, boost::begin(r), boost::end(r) );
}
#endif
template< class PtrSeqAdapter >
void transfer( iterator before,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator last,
PtrSeqAdapter& from ) // strong
{
BOOST_ASSERT( (void*)&from != (void*)this );
if( from.empty() )
return;
this->base().
insert( before.base(), first.base(), last.base() ); // strong
from.base().erase( first.base(), last.base() ); // nothrow
}
template< class PtrSeqAdapter >
void transfer( iterator before,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator object,
PtrSeqAdapter& from ) // strong
{
BOOST_ASSERT( (void*)&from != (void*)this );
if( from.empty() )
return;
this->base().insert( before.base(), *object.base() ); // strong
from.base().erase( object.base() ); // nothrow
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrSeqAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrSeqAdapter::iterator > >::type
transfer( iterator before, const Range& r, PtrSeqAdapter& from ) // strong
{
transfer( before, boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrSeqAdapter >
void transfer( iterator before, PtrSeqAdapter& from ) // strong
{
BOOST_ASSERT( (void*)&from != (void*)this );
if( from.empty() )
return;
this->base().
insert( before.base(),
from.begin().base(), from.end().base() ); // strong
from.base().clear(); // nothrow
}
public: // C-array support
void transfer( iterator before, value_type* from,
size_type size, bool delete_from = true ) // strong
{
BOOST_ASSERT( from != 0 );
if( delete_from )
{
BOOST_DEDUCED_TYPENAME base_type::scoped_deleter
deleter( from, size ); // nothrow
this->base().insert( before.base(), from, from + size ); // strong
deleter.release(); // nothrow
}
else
{
this->base().insert( before.base(), from, from + size ); // strong
}
}
value_type* c_array() // nothrow
{
if( this->empty() )
return 0;
T** res = reinterpret_cast<T**>( &this->begin().base()[0] );
return res;
}
public: // null functions
bool is_null( size_type idx ) const
{
BOOST_ASSERT( idx < this->size() );
return this->base()[idx] == 0;
}
public: // resize
void resize( size_type size ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( boost::next( this->begin(), size ), this->end() );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_back( new BOOST_DEDUCED_TYPENAME
boost::remove_pointer<value_type>::type() );
}
BOOST_ASSERT( this->size() == size );
}
void resize( size_type size, value_type to_clone ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( boost::next( this->begin(), size ), this->end() );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_back( this->null_policy_allocate_clone( to_clone ) );
}
BOOST_ASSERT( this->size() == size );
}
void rresize( size_type size ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( this->begin(),
boost::next( this->begin(), old_size - size ) );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_front( new BOOST_DEDUCED_TYPENAME
boost::remove_pointer<value_type>::type() );
}
BOOST_ASSERT( this->size() == size );
}
void rresize( size_type size, value_type to_clone ) // basic
{
size_type old_size = this->size();
if( old_size > size )
{
this->erase( this->begin(),
boost::next( this->begin(), old_size - size ) );
}
else if( size > old_size )
{
for( ; old_size != size; ++old_size )
this->push_front( this->null_policy_allocate_clone( to_clone ) );
}
BOOST_ASSERT( this->size() == size );
}
public: // algorithms
void sort( iterator first, iterator last )
{
sort( first, last, std::less<T>() );
}
void sort()
{
sort( this->begin(), this->end() );
}
template< class Compare >
void sort( iterator first, iterator last, Compare comp )
{
BOOST_ASSERT( first <= last && "out of range sort()" );
BOOST_ASSERT( this->begin() <= first && "out of range sort()" );
BOOST_ASSERT( last <= this->end() && "out of range sort()" );
// some static assert on the arguments of the comparison
std::sort( first.base(), last.base(),
void_ptr_indirect_fun<Compare,T>(comp) );
}
template< class Compare >
void sort( Compare comp )
{
sort( this->begin(), this->end(), comp );
}
void unique( iterator first, iterator last )
{
unique( first, last, std::equal_to<T>() );
}
void unique()
{
unique( this->begin(), this->end() );
}
private:
struct is_not_zero_ptr
{
template< class U >
bool operator()( const U* r ) const
{
return r != 0;
}
};
protected:
template< class Fun, class Arg1 >
class void_ptr_delete_if
{
Fun fun;
public:
void_ptr_delete_if() : fun(Fun())
{ }
void_ptr_delete_if( Fun f ) : fun(f)
{ }
bool operator()( void* r ) const
{
BOOST_ASSERT( r != 0 );
Arg1 arg1 = static_cast<Arg1>(r);
if( fun( *arg1 ) )
{
clone_allocator_type::deallocate_clone( arg1 );
return true;
}
return false;
}
};
private:
void compact_and_erase_nulls( iterator first, iterator last ) // nothrow
{
typename base_type::ptr_iterator p = std::stable_partition(
first.base(),
last.base(),
is_not_zero_ptr() );
this->base().erase( p, this->end().base() );
}
void range_check_impl( iterator first, iterator last,
std::bidirectional_iterator_tag )
{ /* do nothing */ }
void range_check_impl( iterator first, iterator last,
std::random_access_iterator_tag )
{
BOOST_ASSERT( first <= last && "out of range unique()/erase_if()" );
BOOST_ASSERT( this->begin() <= first && "out of range unique()/erase_if()" );
BOOST_ASSERT( last <= this->end() && "out of range unique()/erase_if)(" );
}
void range_check( iterator first, iterator last )
{
range_check_impl( first, last,
BOOST_DEDUCED_TYPENAME iterator_category<iterator>::type() );
}
public:
template< class Compare >
void unique( iterator first, iterator last, Compare comp )
{
range_check(first,last);
iterator prev = first;
iterator next = first;
++next;
for( ; next != last; ++next )
{
BOOST_ASSERT( !::boost::is_null(prev) );
BOOST_ASSERT( !::boost::is_null(next) );
if( comp( *prev, *next ) )
{
this->remove( next ); // delete object
*next.base() = 0; // mark pointer as deleted
}
else
{
prev = next;
}
// ++next
}
compact_and_erase_nulls( first, last );
}
template< class Compare >
void unique( Compare comp )
{
unique( this->begin(), this->end(), comp );
}
template< class Pred >
void erase_if( iterator first, iterator last, Pred pred )
{
range_check(first,last);
this->base().erase( std::remove_if( first.base(), last.base(),
void_ptr_delete_if<Pred,value_type>(pred) ),
last.base() );
}
template< class Pred >
void erase_if( Pred pred )
{
erase_if( this->begin(), this->end(), pred );
}
void merge( iterator first, iterator last,
ptr_sequence_adapter& from )
{
merge( first, last, from, std::less<T>() );
}
template< class BinPred >
void merge( iterator first, iterator last,
ptr_sequence_adapter& from, BinPred pred )
{
void_ptr_indirect_fun<BinPred,T> bin_pred(pred);
size_type current_size = this->size();
this->transfer( this->end(), first, last, from );
typename base_type::ptr_iterator middle = this->begin().base();
std::advance(middle,current_size);
std::inplace_merge( this->begin().base(),
middle,
this->end().base(),
bin_pred );
}
void merge( ptr_sequence_adapter& r )
{
merge( r, std::less<T>() );
BOOST_ASSERT( r.empty() );
}
template< class BinPred >
void merge( ptr_sequence_adapter& r, BinPred pred )
{
merge( r.begin(), r.end(), r, pred );
BOOST_ASSERT( r.empty() );
}
};
} // namespace 'boost'
#endif

View File

@ -1,155 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_SET_HPP
#define BOOST_PTR_CONTAINER_PTR_SET_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/indirect_fun.hpp>
#include <boost/ptr_container/ptr_set_adapter.hpp>
#include <set>
namespace boost
{
template
<
class Key,
class Compare = std::less<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_set :
public ptr_set_adapter< Key,
std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
CloneAllocator, true >
{
typedef ptr_set_adapter< Key, std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
CloneAllocator, true >
base_type;
typedef ptr_set<Key,Compare,CloneAllocator,Allocator> this_type;
public:
ptr_set()
{ }
explicit ptr_set( const Compare& comp,
const Allocator& a = Allocator() )
: base_type( comp, a )
{ }
template< typename InputIterator >
ptr_set( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_set( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator& a = Allocator() )
: base_type( first, last, comp, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_set,
base_type,
this_type )
BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_set, base_type )
};
template
<
class Key,
class Compare = std::less<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_multiset :
public ptr_multiset_adapter< Key,
std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
CloneAllocator, true >
{
typedef ptr_multiset_adapter< Key,
std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
CloneAllocator, true >
base_type;
typedef ptr_multiset<Key,Compare,CloneAllocator,Allocator> this_type;
public:
ptr_multiset()
{ }
explicit ptr_multiset( const Compare& comp,
const Allocator& a = Allocator() )
: base_type( comp, a )
{ }
template< typename InputIterator >
ptr_multiset( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_multiset( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator& a = Allocator() )
: base_type( first, last, comp, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multiset,
base_type,
this_type )
BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_multiset,
base_type )
};
/////////////////////////////////////////////////////////////////////////
// clonability
template< typename K, typename C, typename CA, typename A >
inline ptr_set<K,C,CA,A>* new_clone( const ptr_set<K,C,CA,A>& r )
{
return r.clone().release();
}
template< typename K, typename C, typename CA, typename A >
inline ptr_multiset<K,C,CA,A>* new_clone( const ptr_multiset<K,C,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename K, typename C, typename CA, typename A >
inline void swap( ptr_set<K,C,CA,A>& l, ptr_set<K,C,CA,A>& r )
{
l.swap(r);
}
template< typename K, typename C, typename CA, typename A >
inline void swap( ptr_multiset<K,C,CA,A>& l, ptr_multiset<K,C,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@ -1,692 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_SET_ADAPTER_HPP
#define BOOST_PTR_CONTAINER_PTR_SET_ADAPTER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/detail/associative_ptr_container.hpp>
#include <boost/ptr_container/detail/meta_functions.hpp>
#include <boost/ptr_container/detail/void_ptr_iterator.hpp>
#include <boost/range/iterator_range.hpp>
namespace boost
{
namespace ptr_container_detail
{
template
<
class Key,
class VoidPtrSet,
bool Ordered
>
struct set_config
{
typedef VoidPtrSet
void_container_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrSet::allocator_type
allocator_type;
typedef Key value_type;
typedef value_type
key_type;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_value_compare<VoidPtrSet>,
mpl::identity<void> >::type
value_compare;
typedef value_compare
key_compare;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
mpl::identity<void>,
select_hasher<VoidPtrSet> >::type
hasher;
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
mpl::identity<void>,
select_key_equal<VoidPtrSet> >::type
key_equal;
typedef BOOST_DEDUCED_TYPENAME
mpl::if_c<Ordered,
ordered_associative_container_tag,
unordered_associative_container_tag>::type
container_type;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME VoidPtrSet::iterator, Key >
iterator;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME VoidPtrSet::const_iterator, const Key >
const_iterator;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_iterator<VoidPtrSet>,
select_local_iterator<VoidPtrSet> >::type,
Key >
local_iterator;
typedef void_ptr_iterator<
BOOST_DEDUCED_TYPENAME
mpl::eval_if_c<Ordered,
select_iterator<VoidPtrSet>,
select_const_local_iterator<VoidPtrSet> >::type,
const Key >
const_local_iterator;
template< class Iter >
static Key* get_pointer( Iter i )
{
return static_cast<Key*>( *i.base() );
}
template< class Iter >
static const Key* get_const_pointer( Iter i )
{
return static_cast<const Key*>( *i.base() );
}
BOOST_STATIC_CONSTANT(bool, allow_null = false );
};
template
<
class Key,
class VoidPtrSet,
class CloneAllocator = heap_clone_allocator,
bool Ordered = true
>
class ptr_set_adapter_base
: public ptr_container_detail::associative_ptr_container< set_config<Key,VoidPtrSet,Ordered>,
CloneAllocator >
{
typedef ptr_container_detail::associative_ptr_container< set_config<Key,VoidPtrSet,Ordered>,
CloneAllocator >
base_type;
public:
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
const_iterator;
typedef Key key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
public:
ptr_set_adapter_base()
{ }
template< class SizeType >
ptr_set_adapter_base( SizeType n,
ptr_container_detail::unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Compare, class Allocator >
ptr_set_adapter_base( const Compare& comp,
const Allocator& a )
: base_type( comp, a )
{ }
template< class Hash, class Pred, class Allocator >
ptr_set_adapter_base( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator, class Compare, class Allocator >
ptr_set_adapter_base( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator& a )
: base_type( first, last, comp, a )
{ }
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_set_adapter_base( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( first, last, hash, pred, a )
{ }
template< class U, class Set, class CA, bool b >
ptr_set_adapter_base( const ptr_set_adapter_base<U,Set,CA,b>& r )
: base_type( r )
{ }
ptr_set_adapter_base( const ptr_set_adapter_base& r )
: base_type( r )
{ }
template< class PtrContainer >
explicit ptr_set_adapter_base( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
ptr_set_adapter_base& operator=( ptr_set_adapter_base r )
{
this->swap( r );
return *this;
}
template< typename PtrContainer >
ptr_set_adapter_base& operator=( std::auto_ptr<PtrContainer> clone )
{
base_type::operator=( clone );
return *this;
}
using base_type::erase;
size_type erase( const key_type& x ) // nothrow
{
key_type* key = const_cast<key_type*>(&x);
iterator i( this->base().find( key ) );
if( i == this->end() ) // nothrow
return 0u; // nothrow
key = static_cast<key_type*>(*i.base()); // nothrow
size_type res = this->base().erase( key ); // nothrow
this->remove( key ); // nothrow
return res;
}
iterator find( const key_type& x )
{
return iterator( this->base().
find( const_cast<key_type*>(&x) ) );
}
const_iterator find( const key_type& x ) const
{
return const_iterator( this->base().
find( const_cast<key_type*>(&x) ) );
}
size_type count( const key_type& x ) const
{
return this->base().count( const_cast<key_type*>(&x) );
}
iterator lower_bound( const key_type& x )
{
return iterator( this->base().
lower_bound( const_cast<key_type*>(&x) ) );
}
const_iterator lower_bound( const key_type& x ) const
{
return const_iterator( this->base().
lower_bound( const_cast<key_type*>(&x) ) );
}
iterator upper_bound( const key_type& x )
{
return iterator( this->base().
upper_bound( const_cast<key_type*>(&x) ) );
}
const_iterator upper_bound( const key_type& x ) const
{
return const_iterator( this->base().
upper_bound( const_cast<key_type*>(&x) ) );
}
iterator_range<iterator> equal_range( const key_type& x )
{
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator>
p = this->base().
equal_range( const_cast<key_type*>(&x) );
return make_iterator_range( iterator( p.first ),
iterator( p.second ) );
}
iterator_range<const_iterator> equal_range( const key_type& x ) const
{
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator,
BOOST_DEDUCED_TYPENAME base_type::ptr_const_iterator>
p = this->base().
equal_range( const_cast<key_type*>(&x) );
return make_iterator_range( const_iterator( p.first ),
const_iterator( p.second ) );
}
protected:
size_type bucket( const key_type& key ) const
{
return this->base().bucket( const_cast<key_type*>(&key) );
}
};
} // ptr_container_detail
/////////////////////////////////////////////////////////////////////////
// ptr_set_adapter
/////////////////////////////////////////////////////////////////////////
template
<
class Key,
class VoidPtrSet,
class CloneAllocator = heap_clone_allocator,
bool Ordered = true
>
class ptr_set_adapter :
public ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrSet,CloneAllocator,Ordered>
{
typedef ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrSet,CloneAllocator,Ordered>
base_type;
public: // typedefs
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::const_iterator
const_iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef Key key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrSet::allocator_type
allocator_type;
private:
template< typename II >
void set_basic_clone_and_insert( II first, II last ) // basic
{
while( first != last )
{
if( this->find( *first ) == this->end() )
insert( CloneAllocator::allocate_clone( *first ) ); // strong, commit
++first;
}
}
public:
ptr_set_adapter()
{ }
template< class SizeType >
ptr_set_adapter( SizeType n,
ptr_container_detail::unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Comp >
explicit ptr_set_adapter( const Comp& comp,
const allocator_type& a )
: base_type( comp, a )
{
BOOST_ASSERT( this->empty() );
}
template< class Hash, class Pred, class Allocator >
ptr_set_adapter( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator >
ptr_set_adapter( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< class InputIterator, class Compare, class Allocator >
ptr_set_adapter( InputIterator first, InputIterator last,
const Compare& comp,
const Allocator a = Allocator() )
: base_type( comp, a )
{
BOOST_ASSERT( this->empty() );
set_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_set_adapter( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( first, last, hash, pred, a )
{ }
explicit ptr_set_adapter( const ptr_set_adapter& r )
: base_type( r )
{ }
template< class U, class Set, class CA, bool b >
explicit ptr_set_adapter( const ptr_set_adapter<U,Set,CA,b>& r )
: base_type( r )
{ }
template< class PtrContainer >
explicit ptr_set_adapter( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
template< class U, class Set, class CA, bool b >
ptr_set_adapter& operator=( const ptr_set_adapter<U,Set,CA,b>& r )
{
base_type::operator=( r );
return *this;
}
template< class T >
void operator=( std::auto_ptr<T> r )
{
base_type::operator=( r );
}
std::pair<iterator,bool> insert( key_type* x ) // strong
{
this->enforce_null_policy( x, "Null pointer in 'ptr_set::insert()'" );
auto_type ptr( x );
std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool>
res = this->base().insert( x );
if( res.second )
ptr.release();
return std::make_pair( iterator( res.first ), res.second );
}
template< class U >
std::pair<iterator,bool> insert( std::auto_ptr<U> x )
{
return insert( x.release() );
}
iterator insert( iterator where, key_type* x ) // strong
{
this->enforce_null_policy( x, "Null pointer in 'ptr_set::insert()'" );
auto_type ptr( x );
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
res = this->base().insert( where.base(), x );
if( *res == x )
ptr.release();
return iterator( res);
}
template< class U >
iterator insert( iterator where, std::auto_ptr<U> x )
{
return insert( where, x.release() );
}
template< typename InputIterator >
void insert( InputIterator first, InputIterator last ) // basic
{
set_basic_clone_and_insert( first, last );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME
boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
insert( const Range& r )
{
insert( boost::begin(r), boost::end(r) );
}
#endif
template< class PtrSetAdapter >
bool transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator object,
PtrSetAdapter& from ) // strong
{
return this->single_transfer( object, from );
}
template< class PtrSetAdapter >
size_type
transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator last,
PtrSetAdapter& from ) // basic
{
return this->single_transfer( first, last, from );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrSetAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator >,
size_type >::type
transfer( const Range& r, PtrSetAdapter& from ) // basic
{
return transfer( boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrSetAdapter >
size_type transfer( PtrSetAdapter& from ) // basic
{
return transfer( from.begin(), from.end(), from );
}
};
/////////////////////////////////////////////////////////////////////////
// ptr_multiset_adapter
/////////////////////////////////////////////////////////////////////////
template
<
class Key,
class VoidPtrMultiSet,
class CloneAllocator = heap_clone_allocator,
bool Ordered = true
>
class ptr_multiset_adapter :
public ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrMultiSet,CloneAllocator,Ordered>
{
typedef ptr_container_detail::ptr_set_adapter_base<Key,VoidPtrMultiSet,CloneAllocator,Ordered> base_type;
public: // typedefs
typedef BOOST_DEDUCED_TYPENAME base_type::iterator
iterator;
typedef BOOST_DEDUCED_TYPENAME base_type::size_type
size_type;
typedef Key key_type;
typedef BOOST_DEDUCED_TYPENAME base_type::auto_type
auto_type;
typedef BOOST_DEDUCED_TYPENAME VoidPtrMultiSet::allocator_type
allocator_type;
private:
template< typename II >
void set_basic_clone_and_insert( II first, II last ) // basic
{
while( first != last )
{
insert( CloneAllocator::allocate_clone( *first ) ); // strong, commit
++first;
}
}
public:
ptr_multiset_adapter()
{ }
template< class SizeType >
ptr_multiset_adapter( SizeType n,
ptr_container_detail::unordered_associative_container_tag tag )
: base_type( n, tag )
{ }
template< class Comp >
explicit ptr_multiset_adapter( const Comp& comp,
const allocator_type& a )
: base_type( comp, a )
{ }
template< class Hash, class Pred, class Allocator >
ptr_multiset_adapter( const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( hash, pred, a )
{ }
template< class InputIterator >
ptr_multiset_adapter( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< class InputIterator, class Comp >
ptr_multiset_adapter( InputIterator first, InputIterator last,
const Comp& comp,
const allocator_type& a = allocator_type() )
: base_type( comp, a )
{
set_basic_clone_and_insert( first, last );
}
template< class InputIterator, class Hash, class Pred, class Allocator >
ptr_multiset_adapter( InputIterator first, InputIterator last,
const Hash& hash,
const Pred& pred,
const Allocator& a )
: base_type( first, last, hash, pred, a )
{ }
template< class U, class Set, class CA, bool b >
explicit ptr_multiset_adapter( const ptr_multiset_adapter<U,Set,CA,b>& r )
: base_type( r )
{ }
template< class PtrContainer >
explicit ptr_multiset_adapter( std::auto_ptr<PtrContainer> clone )
: base_type( clone )
{ }
template< class U, class Set, class CA, bool b >
ptr_multiset_adapter& operator=( const ptr_multiset_adapter<U,Set,CA,b>& r )
{
base_type::operator=( r );
return *this;
}
template< class T >
void operator=( std::auto_ptr<T> r )
{
base_type::operator=( r );
}
iterator insert( iterator before, key_type* x ) // strong
{
return base_type::insert( before, x );
}
template< class U >
iterator insert( iterator before, std::auto_ptr<U> x )
{
return insert( before, x.release() );
}
iterator insert( key_type* x ) // strong
{
this->enforce_null_policy( x, "Null pointer in 'ptr_multiset::insert()'" );
auto_type ptr( x );
BOOST_DEDUCED_TYPENAME base_type::ptr_iterator
res = this->base().insert( x );
ptr.release();
return iterator( res );
}
template< class U >
iterator insert( std::auto_ptr<U> x )
{
return insert( x.release() );
}
template< typename InputIterator >
void insert( InputIterator first, InputIterator last ) // basic
{
set_basic_clone_and_insert( first, last );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class Range >
BOOST_DEDUCED_TYPENAME
boost::disable_if< ptr_container_detail::is_pointer_or_integral<Range> >::type
insert( const Range& r )
{
insert( boost::begin(r), boost::end(r) );
}
#endif
template< class PtrSetAdapter >
void transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator object,
PtrSetAdapter& from ) // strong
{
this->multi_transfer( object, from );
}
template< class PtrSetAdapter >
size_type transfer( BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator first,
BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator last,
PtrSetAdapter& from ) // basic
{
return this->multi_transfer( first, last, from );
}
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
#else
template< class PtrSetAdapter, class Range >
BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range,
BOOST_DEDUCED_TYPENAME PtrSetAdapter::iterator >, size_type >::type
transfer( const Range& r, PtrSetAdapter& from ) // basic
{
return transfer( boost::begin(r), boost::end(r), from );
}
#endif
template< class PtrSetAdapter >
void transfer( PtrSetAdapter& from ) // basic
{
transfer( from.begin(), from.end(), from );
BOOST_ASSERT( from.empty() );
}
};
} // namespace 'boost'
#endif

View File

@ -1,248 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_UNORDERED_MAP_HPP
#define BOOST_PTR_CONTAINER_PTR_UNORDERED_MAP_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/unordered_map.hpp>
#include <boost/ptr_container/ptr_map_adapter.hpp>
namespace boost
{
template
<
class Key,
class T,
class Hash = boost::hash<Key>,
class Pred = std::equal_to<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator< std::pair<const Key,void*> >
>
class ptr_unordered_map :
public ptr_map_adapter<T,boost::unordered_map<Key,void*,Hash,Pred,Allocator>,
CloneAllocator,false>
{
typedef ptr_map_adapter<T,boost::unordered_map<Key,void*,Hash,Pred,Allocator>,
CloneAllocator,false>
base_type;
typedef ptr_unordered_map<Key,T,Hash,Pred,CloneAllocator,Allocator> this_type;
public:
typedef typename base_type::size_type size_type;
private:
using base_type::lower_bound;
using base_type::upper_bound;
using base_type::rbegin;
using base_type::rend;
using base_type::crbegin;
using base_type::crend;
using base_type::key_comp;
using base_type::value_comp;
using base_type::front;
using base_type::back;
public:
using base_type::begin;
using base_type::end;
using base_type::cbegin;
using base_type::cend;
using base_type::bucket_count;
using base_type::max_bucket_count;
using base_type::bucket_size;
using base_type::bucket;
using base_type::load_factor;
using base_type::max_load_factor;
using base_type::rehash;
using base_type::key_eq;
using base_type::hash_function;
public:
ptr_unordered_map()
{ }
explicit ptr_unordered_map( size_type n )
: base_type( n, ptr_container_detail::unordered_associative_container_tag() )
{ }
ptr_unordered_map( size_type n,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( n, comp, pred, a )
{ }
template< typename InputIterator >
ptr_unordered_map( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_unordered_map( InputIterator first, InputIterator last,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( first, last, comp, pred, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_map,
base_type,
this_type )
template< class U >
ptr_unordered_map( const ptr_unordered_map<Key,U>& r ) : base_type( r )
{ }
ptr_unordered_map& operator=( ptr_unordered_map r )
{
this->swap( r );
return *this;
}
};
template
<
class Key,
class T,
class Hash = boost::hash<Key>,
class Pred = std::equal_to<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator< std::pair<const Key,void*> >
>
class ptr_unordered_multimap :
public ptr_multimap_adapter<T,boost::unordered_multimap<Key,void*,Hash,Pred,Allocator>,
CloneAllocator,false>
{
typedef ptr_multimap_adapter<T,boost::unordered_multimap<Key,void*,Hash,Pred,Allocator>,
CloneAllocator,false>
base_type;
typedef ptr_unordered_multimap<Key,T,Hash,Pred,CloneAllocator,Allocator> this_type;
public:
typedef typename base_type::size_type size_type;
private:
using base_type::lower_bound;
using base_type::upper_bound;
using base_type::rbegin;
using base_type::rend;
using base_type::crbegin;
using base_type::crend;
using base_type::key_comp;
using base_type::value_comp;
using base_type::front;
using base_type::back;
public:
using base_type::begin;
using base_type::end;
using base_type::cbegin;
using base_type::cend;
using base_type::bucket_count;
using base_type::max_bucket_count;
using base_type::bucket_size;
using base_type::bucket;
using base_type::load_factor;
using base_type::max_load_factor;
using base_type::rehash;
using base_type::key_eq;
using base_type::hash_function;
public:
ptr_unordered_multimap()
{ }
explicit ptr_unordered_multimap( size_type n )
: base_type( n, ptr_container_detail::unordered_associative_container_tag() )
{ }
ptr_unordered_multimap( size_type n,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( n, comp, pred, a )
{ }
template< typename InputIterator >
ptr_unordered_multimap( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_unordered_multimap( InputIterator first, InputIterator last,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( first, last, comp, pred, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multimap,
base_type,
this_type )
template< class U >
ptr_unordered_multimap( const ptr_unordered_multimap<Key,U>& r ) : base_type( r )
{ }
ptr_unordered_multimap& operator=( ptr_unordered_multimap r )
{
this->swap( r );
return *this;
}
};
//////////////////////////////////////////////////////////////////////////////
// clonability
template< class K, class T, class H, class P, class CA, class A >
inline ptr_unordered_map<K,T,H,P,CA,A>*
new_clone( const ptr_unordered_map<K,T,H,P,CA,A>& r )
{
return r.clone().release();
}
template< class K, class T, class H, class P, class CA, class A >
inline ptr_unordered_multimap<K,T,H,P,CA,A>*
new_clone( const ptr_unordered_multimap<K,T,H,P,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< class K, class T, class H, class P, class CA, class A >
inline void swap( ptr_unordered_map<K,T,H,P,CA,A>& l,
ptr_unordered_map<K,T,H,P,CA,A>& r )
{
l.swap(r);
}
template< class K, class T, class H, class P, class CA, class A >
inline void swap( ptr_unordered_multimap<K,T,H,P,CA,A>& l,
ptr_unordered_multimap<K,T,H,P,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@ -1,240 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_UNORDERED_SET_HPP
#define BOOST_PTR_CONTAINER_PTR_UNORDERED_SET_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/ptr_container/indirect_fun.hpp>
#include <boost/ptr_container/ptr_set_adapter.hpp>
#include <boost/unordered_set.hpp>
namespace boost
{
template
<
class Key,
class Hash = boost::hash<Key>,
class Pred = std::equal_to<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_unordered_set :
public ptr_set_adapter< Key,
boost::unordered_set<void*,void_ptr_indirect_fun<Hash,Key>,
void_ptr_indirect_fun<Pred,Key>,Allocator>,
CloneAllocator, false >
{
typedef ptr_set_adapter< Key,
boost::unordered_set<void*,void_ptr_indirect_fun<Hash,Key>,
void_ptr_indirect_fun<Pred,Key>,Allocator>,
CloneAllocator, false >
base_type;
typedef ptr_unordered_set<Key,Hash,Pred,CloneAllocator,Allocator> this_type;
public:
typedef typename base_type::size_type size_type;
private:
using base_type::lower_bound;
using base_type::upper_bound;
using base_type::rbegin;
using base_type::rend;
using base_type::crbegin;
using base_type::crend;
using base_type::key_comp;
using base_type::value_comp;
using base_type::front;
using base_type::back;
public:
using base_type::begin;
using base_type::end;
using base_type::cbegin;
using base_type::cend;
using base_type::bucket_count;
using base_type::max_bucket_count;
using base_type::bucket_size;
using base_type::bucket;
using base_type::load_factor;
using base_type::max_load_factor;
using base_type::rehash;
using base_type::key_eq;
using base_type::hash_function;
public:
ptr_unordered_set()
{}
explicit ptr_unordered_set( size_type n )
: base_type( n, ptr_container_detail::unordered_associative_container_tag() )
{ }
ptr_unordered_set( size_type n,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( n, comp, pred, a )
{ }
template< typename InputIterator >
ptr_unordered_set( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_unordered_set( InputIterator first, InputIterator last,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( first, last, comp, pred, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_set,
base_type,
this_type )
BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_set,
base_type )
};
template
<
class Key,
class Hash = boost::hash<Key>,
class Pred = std::equal_to<Key>,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_unordered_multiset :
public ptr_multiset_adapter< Key,
boost::unordered_multiset<void*,void_ptr_indirect_fun<Hash,Key>,
void_ptr_indirect_fun<Pred,Key>,Allocator>,
CloneAllocator, false >
{
typedef ptr_multiset_adapter< Key,
boost::unordered_multiset<void*,void_ptr_indirect_fun<Hash,Key>,
void_ptr_indirect_fun<Pred,Key>,Allocator>,
CloneAllocator, false >
base_type;
typedef ptr_unordered_multiset<Key,Hash,Pred,CloneAllocator,Allocator> this_type;
public:
typedef typename base_type::size_type size_type;
private:
using base_type::lower_bound;
using base_type::upper_bound;
using base_type::rbegin;
using base_type::rend;
using base_type::crbegin;
using base_type::crend;
using base_type::key_comp;
using base_type::value_comp;
using base_type::front;
using base_type::back;
public:
using base_type::begin;
using base_type::end;
using base_type::cbegin;
using base_type::cend;
using base_type::bucket_count;
using base_type::max_bucket_count;
using base_type::bucket_size;
using base_type::bucket;
using base_type::load_factor;
using base_type::max_load_factor;
using base_type::rehash;
using base_type::key_eq;
using base_type::hash_function;
public:
ptr_unordered_multiset()
{ }
explicit ptr_unordered_multiset( size_type n )
: base_type( n, ptr_container_detail::unordered_associative_container_tag() )
{ }
ptr_unordered_multiset( size_type n,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( n, comp, pred, a )
{ }
template< typename InputIterator >
ptr_unordered_multiset( InputIterator first, InputIterator last )
: base_type( first, last )
{ }
template< typename InputIterator >
ptr_unordered_multiset( InputIterator first, InputIterator last,
const Hash& comp,
const Pred& pred = Pred(),
const Allocator& a = Allocator() )
: base_type( first, last, comp, pred, a )
{ }
BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multiset,
base_type,
this_type )
BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_multiset,
base_type )
};
/////////////////////////////////////////////////////////////////////////
// clonability
template< typename K, typename H, typename P, typename CA, typename A >
inline ptr_unordered_set<K,H,P,CA,A>*
new_clone( const ptr_unordered_set<K,H,P,CA,A>& r )
{
return r.clone().release();
}
template< typename K, typename H, typename P, typename CA, typename A >
inline ptr_unordered_multiset<K,H,P,CA,A>*
new_clone( const ptr_unordered_multiset<K,H,P,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename K, typename H, typename P, typename CA, typename A >
inline void swap( ptr_unordered_set<K,H,P,CA,A>& l,
ptr_unordered_set<K,H,P,CA,A>& r )
{
l.swap(r);
}
template< typename K, typename H, typename P, typename CA, typename A >
inline void swap( ptr_unordered_multiset<K,H,P,CA,A>& l,
ptr_unordered_multiset<K,H,P,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@ -1,77 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2003-2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_PTR_VECTOR_HPP
#define BOOST_PTR_CONTAINER_PTR_VECTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <vector>
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
namespace boost
{
template
<
class T,
class CloneAllocator = heap_clone_allocator,
class Allocator = std::allocator<void*>
>
class ptr_vector : public
ptr_sequence_adapter< T,
std::vector<void*,Allocator>,
CloneAllocator >
{
typedef ptr_sequence_adapter< T,
std::vector<void*,Allocator>,
CloneAllocator >
base_class;
typedef ptr_vector<T,CloneAllocator,Allocator> this_type;
public:
BOOST_PTR_CONTAINER_DEFINE_SEQEUENCE_MEMBERS( ptr_vector,
base_class,
this_type )
explicit ptr_vector( size_type n,
const allocator_type& alloc = allocator_type() )
: base_class(alloc)
{
this->base().reserve( n );
}
};
//////////////////////////////////////////////////////////////////////////////
// clonability
template< typename T, typename CA, typename A >
inline ptr_vector<T,CA,A>* new_clone( const ptr_vector<T,CA,A>& r )
{
return r.clone().release();
}
/////////////////////////////////////////////////////////////////////////
// swap
template< typename T, typename CA, typename A >
inline void swap( ptr_vector<T,CA,A>& l, ptr_vector<T,CA,A>& r )
{
l.swap(r);
}
}
#endif

View File

@ -1,47 +0,0 @@
// Copyright Sebastian Ramacher, 2007.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_ARRAY_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_ARRAY_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_array.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, std::size_t N, class CloneAllocator>
void save(Archive& ar, const ptr_array<T, N, CloneAllocator>& c, unsigned int /*version*/)
{
ptr_container_detail::save_helper(ar, c);
}
template<class Archive, class T, std::size_t N, class CloneAllocator>
void load(Archive& ar, ptr_array<T, N, CloneAllocator>& c, unsigned int /*version*/)
{
typedef ptr_array<T, N, CloneAllocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
for(size_type i = 0u; i != N; ++i)
{
T* p;
ar >> boost::serialization::make_nvp( ptr_container_detail::item(), p );
c.replace(i, p);
}
}
template<class Archive, class T, std::size_t N, class CloneAllocator>
void serialize(Archive& ar, ptr_array<T, N, CloneAllocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@ -1,46 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_CIRCULAR_BUFFER_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_CIRCULAR_BUFFER_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_circular_buffer.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class CloneAllocator, class Allocator>
void load(Archive& ar, ptr_circular_buffer<T, CloneAllocator, Allocator>& c, unsigned int version)
{
typedef ptr_circular_buffer<T, CloneAllocator, Allocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
size_type n;
ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
c.reserve(n);
ptr_container_detail::load_helper(ar, c, n);
}
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_circular_buffer<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@ -1,19 +0,0 @@
// Copyright Sebastian Ramacher, 2007.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_HPP
#include <boost/ptr_container/serialize_ptr_array.hpp>
#include <boost/ptr_container/serialize_ptr_deque.hpp>
#include <boost/ptr_container/serialize_ptr_list.hpp>
#include <boost/ptr_container/serialize_ptr_map.hpp>
#include <boost/ptr_container/serialize_ptr_set.hpp>
#include <boost/ptr_container/serialize_ptr_vector.hpp>
#include <boost/ptr_container/serialize_ptr_unordered_set.hpp>
#include <boost/ptr_container/serialize_ptr_unordered_map.hpp>
#include <boost/ptr_container/serialize_ptr_circular_buffer.hpp>
#endif

View File

@ -1,27 +0,0 @@
// Copyright Sebastian Ramacher, 2007.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_DEQUE_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_DEQUE_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_deque.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_deque<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@ -1,27 +0,0 @@
// Copyright Sebastian Ramacher, 2007.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_LIST_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_LIST_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_list.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_list<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@ -1,33 +0,0 @@
// Copyright Sebastian Ramacher, 2007.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_MAP_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_MAP_HPP
#include <boost/ptr_container/detail/serialize_ptr_map_adapter.hpp>
#include <boost/ptr_container/ptr_map.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class Key, class T, class Compare, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_map<Key, T, Compare, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
template<class Archive, class Key, class T, class Compare, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_multimap<Key, T, Compare, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@ -1,33 +0,0 @@
// Copyright Sebastian Ramacher, 2007.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_SET_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_SET_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_set.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_set<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_multiset<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@ -1,39 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_UNORDERED_PTR_MAP_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_UNORDERED_PTR_MAP_HPP
#include <boost/ptr_container/detail/serialize_ptr_map_adapter.hpp>
#include <boost/ptr_container/ptr_unordered_map.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class Key, class T, class Hash, class Pred, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_unordered_map<Key, T, Hash, Pred, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
template<class Archive, class Key, class T, class Hash, class Pred, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_unordered_multimap<Key, T, Hash, Pred, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@ -1,39 +0,0 @@
//
// Boost.Pointer Container
//
// Copyright Thorsten Ottosen 2008. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/ptr_container/
//
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_UNORDERED_SET_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_UNORDERED_SET_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_unordered_set.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class Hash, class Pred, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_unordered_set<T, Hash, Pred, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
template<class Archive, class T, class Hash, class Pred, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_unordered_multiset<T, Hash, Pred, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@ -1,40 +0,0 @@
// Copyright Sebastian Ramacher, 2007.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_VECTOR_HPP
#define BOOST_PTR_CONTAINER_SERIALIZE_PTR_VECTOR_HPP
#include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
namespace boost
{
namespace serialization
{
template<class Archive, class T, class CloneAllocator, class Allocator>
void load(Archive& ar, ptr_vector<T, CloneAllocator, Allocator>& c, unsigned int /*version*/)
{
typedef ptr_vector<T, CloneAllocator, Allocator> container_type;
typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
size_type n;
ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
c.reserve(n);
ptr_container_detail::load_helper(ar, c, n);
}
template<class Archive, class T, class CloneAllocator, class Allocator>
void serialize(Archive& ar, ptr_vector<T, CloneAllocator, Allocator>& c, const unsigned int version)
{
split_free(ar, c, version);
}
} // namespace serialization
} // namespace boost
#endif

View File

@ -1,91 +0,0 @@
/* boost random.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org/libs/random for documentation.
*
* $Id$
*
* Revision history
* 2000-02-18 portability fixes (thanks to Beman Dawes)
* 2000-02-21 shuffle_output, inversive_congruential_schrage,
* generator_iterator, uniform_smallint
* 2000-02-23 generic modulus arithmetic helper, removed *_schrage classes,
* implemented Streamable and EqualityComparable concepts for
* generators, added Bernoulli distribution and Box-Muller
* transform
* 2000-03-01 cauchy, lognormal, triangle distributions; fixed
* uniform_smallint; renamed gaussian to normal distribution
* 2000-03-05 implemented iterator syntax for distribution functions
* 2000-04-21 removed some optimizations for better BCC/MSVC compatibility
* 2000-05-10 adapted to BCC and MSVC
* 2000-06-13 incorporated review results
* 2000-07-06 moved basic templates from namespace detail to random
* 2000-09-23 warning removals and int64 fixes (Ed Brey)
* 2000-09-24 added lagged_fibonacci generator (Matthias Troyer)
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_HPP
#define BOOST_RANDOM_HPP
// generators
#include <boost/random/additive_combine.hpp>
#include <boost/random/discard_block.hpp>
#include <boost/random/independent_bits.hpp>
#include <boost/random/inversive_congruential.hpp>
#include <boost/random/lagged_fibonacci.hpp>
#include <boost/random/linear_congruential.hpp>
#include <boost/random/linear_feedback_shift.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/ranlux.hpp>
#include <boost/random/shuffle_order.hpp>
#include <boost/random/shuffle_output.hpp>
#include <boost/random/subtract_with_carry.hpp>
#include <boost/random/taus88.hpp>
#include <boost/random/xor_combine.hpp>
// misc
#include <boost/random/generate_canonical.hpp>
#include <boost/random/seed_seq.hpp>
#include <boost/random/random_number_generator.hpp>
#include <boost/random/variate_generator.hpp>
// distributions
#include <boost/random/bernoulli_distribution.hpp>
#include <boost/random/beta_distribution.hpp>
#include <boost/random/binomial_distribution.hpp>
#include <boost/random/cauchy_distribution.hpp>
#include <boost/random/chi_squared_distribution.hpp>
#include <boost/random/discrete_distribution.hpp>
#include <boost/random/exponential_distribution.hpp>
#include <boost/random/extreme_value_distribution.hpp>
#include <boost/random/fisher_f_distribution.hpp>
#include <boost/random/gamma_distribution.hpp>
#include <boost/random/geometric_distribution.hpp>
#include <boost/random/hyperexponential_distribution.hpp>
#include <boost/random/laplace_distribution.hpp>
#include <boost/random/lognormal_distribution.hpp>
#include <boost/random/negative_binomial_distribution.hpp>
#include <boost/random/non_central_chi_squared_distribution.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/piecewise_constant_distribution.hpp>
#include <boost/random/piecewise_linear_distribution.hpp>
#include <boost/random/poisson_distribution.hpp>
#include <boost/random/student_t_distribution.hpp>
#include <boost/random/triangle_distribution.hpp>
#include <boost/random/uniform_01.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <boost/random/uniform_on_sphere.hpp>
#include <boost/random/uniform_real.hpp>
#include <boost/random/uniform_real_distribution.hpp>
#include <boost/random/uniform_smallint.hpp>
#include <boost/random/weibull_distribution.hpp>
#include <boost/random/generate_canonical.hpp>
#endif // BOOST_RANDOM_HPP

View File

@ -1,283 +0,0 @@
/* boost random/additive_combine.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_ADDITIVE_COMBINE_HPP
#define BOOST_RANDOM_ADDITIVE_COMBINE_HPP
#include <istream>
#include <iosfwd>
#include <algorithm> // for std::min and std::max
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/operators.hpp>
#include <boost/random/detail/seed.hpp>
#include <boost/random/linear_congruential.hpp>
namespace boost {
namespace random {
/**
* An instantiation of class template @c additive_combine_engine models a
* \pseudo_random_number_generator. It combines two multiplicative
* \linear_congruential_engine number generators, i.e. those with @c c = 0.
* It is described in
*
* @blockquote
* "Efficient and Portable Combined Random Number Generators", Pierre L'Ecuyer,
* Communications of the ACM, Vol. 31, No. 6, June 1988, pp. 742-749, 774
* @endblockquote
*
* The template parameters MLCG1 and MLCG2 shall denote two different
* \linear_congruential_engine number generators, each with c = 0. Each
* invocation returns a random number
* X(n) := (MLCG1(n) - MLCG2(n)) mod (m1 - 1),
* where m1 denotes the modulus of MLCG1.
*/
template<class MLCG1, class MLCG2>
class additive_combine_engine
{
public:
typedef MLCG1 first_base;
typedef MLCG2 second_base;
typedef typename MLCG1::result_type result_type;
// Required by old Boost.Random concept
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
/**
* Returns the smallest value that the generator can produce
*/
static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION ()
{ return 1; }
/**
* Returns the largest value that the generator can produce
*/
static result_type max BOOST_PREVENT_MACRO_SUBSTITUTION ()
{ return MLCG1::modulus-1; }
/**
* Constructs an @c additive_combine_engine using the
* default constructors of the two base generators.
*/
additive_combine_engine() : _mlcg1(), _mlcg2() { }
/**
* Constructs an @c additive_combine_engine, using seed as
* the constructor argument for both base generators.
*/
BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(additive_combine_engine,
result_type, seed_arg)
{
_mlcg1.seed(seed_arg);
_mlcg2.seed(seed_arg);
}
/**
* Constructs an @c additive_combine_engine, using seq as
* the constructor argument for both base generators.
*
* @xmlwarning
* The semantics of this function are liable to change.
* A @c seed_seq is designed to generate all the seeds
* in one shot, but this seeds the two base engines
* independantly and probably ends up giving the same
* sequence to both.
* @endxmlwarning
*/
BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(additive_combine_engine,
SeedSeq, seq)
{
_mlcg1.seed(seq);
_mlcg2.seed(seq);
}
/**
* Constructs an @c additive_combine_engine, using
* @c seed1 and @c seed2 as the constructor argument to
* the first and second base generators, respectively.
*/
additive_combine_engine(typename MLCG1::result_type seed1,
typename MLCG2::result_type seed2)
: _mlcg1(seed1), _mlcg2(seed2) { }
/**
* Contructs an @c additive_combine_engine with
* values from the range defined by the input iterators first
* and last. first will be modified to point to the element
* after the last one used.
*
* Throws: @c std::invalid_argument if the input range is too small.
*
* Exception Safety: Basic
*/
template<class It> additive_combine_engine(It& first, It last)
: _mlcg1(first, last), _mlcg2(first, last) { }
/**
* Seeds an @c additive_combine_engine using the default
* seeds of the two base generators.
*/
void seed()
{
_mlcg1.seed();
_mlcg2.seed();
}
/**
* Seeds an @c additive_combine_engine, using @c seed as the
* seed for both base generators.
*/
BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(additive_combine_engine,
result_type, seed_arg)
{
_mlcg1.seed(seed_arg);
_mlcg2.seed(seed_arg);
}
/**
* Seeds an @c additive_combine_engine, using @c seq to
* seed both base generators.
*
* See the warning on the corresponding constructor.
*/
BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(additive_combine_engine,
SeedSeq, seq)
{
_mlcg1.seed(seq);
_mlcg2.seed(seq);
}
/**
* Seeds an @c additive_combine generator, using @c seed1 and @c seed2 as
* the seeds to the first and second base generators, respectively.
*/
void seed(typename MLCG1::result_type seed1,
typename MLCG2::result_type seed2)
{
_mlcg1.seed(seed1);
_mlcg2.seed(seed2);
}
/**
* Seeds an @c additive_combine_engine with
* values from the range defined by the input iterators first
* and last. first will be modified to point to the element
* after the last one used.
*
* Throws: @c std::invalid_argument if the input range is too small.
*
* Exception Safety: Basic
*/
template<class It> void seed(It& first, It last)
{
_mlcg1.seed(first, last);
_mlcg2.seed(first, last);
}
/** Returns the next value of the generator. */
result_type operator()() {
result_type val1 = _mlcg1();
result_type val2 = _mlcg2();
if(val2 < val1) return val1 - val2;
else return val1 - val2 + MLCG1::modulus - 1;
}
/** Fills a range with random values */
template<class Iter>
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)
{
_mlcg1.discard(z);
_mlcg2.discard(z);
}
/**
* Writes the state of an @c additive_combine_engine to a @c
* std::ostream. The textual representation of an @c
* additive_combine_engine is the textual representation of
* the first base generator followed by the textual representation
* of the second base generator.
*/
BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, additive_combine_engine, r)
{ os << r._mlcg1 << ' ' << r._mlcg2; return os; }
/**
* Reads the state of an @c additive_combine_engine from a
* @c std::istream.
*/
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, additive_combine_engine, r)
{ is >> r._mlcg1 >> std::ws >> r._mlcg2; return is; }
/**
* Returns: true iff the two @c additive_combine_engines will
* produce the same sequence of values.
*/
BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(additive_combine_engine, x, y)
{ return x._mlcg1 == y._mlcg1 && x._mlcg2 == y._mlcg2; }
/**
* Returns: true iff the two @c additive_combine_engines will
* produce different sequences of values.
*/
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(additive_combine_engine)
private:
MLCG1 _mlcg1;
MLCG2 _mlcg2;
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
template<class MLCG1, class MLCG2>
const bool additive_combine_engine<MLCG1, MLCG2>::has_fixed_range;
#endif
/// \cond show_deprecated
/** Provided for backwards compatibility. */
template<class MLCG1, class MLCG2, typename MLCG1::result_type val = 0>
class additive_combine : public additive_combine_engine<MLCG1, MLCG2>
{
typedef additive_combine_engine<MLCG1, MLCG2> base_t;
public:
typedef typename base_t::result_type result_type;
additive_combine() {}
template<class T>
additive_combine(T& arg) : base_t(arg) {}
template<class T>
additive_combine(const T& arg) : base_t(arg) {}
template<class It>
additive_combine(It& first, It last) : base_t(first, last) {}
};
/// \endcond
/**
* The specialization \ecuyer1988 was suggested in
*
* @blockquote
* "Efficient and Portable Combined Random Number Generators", Pierre L'Ecuyer,
* Communications of the ACM, Vol. 31, No. 6, June 1988, pp. 742-749, 774
* @endblockquote
*/
typedef additive_combine_engine<
linear_congruential_engine<uint32_t, 40014, 0, 2147483563>,
linear_congruential_engine<uint32_t, 40692, 0, 2147483399>
> ecuyer1988;
} // namespace random
using random::ecuyer1988;
} // namespace boost
#endif // BOOST_RANDOM_ADDITIVE_COMBINE_HPP

View File

@ -1,197 +0,0 @@
/* boost random/bernoulli_distribution.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Copyright Steven Watanabe 2011
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_BERNOULLI_DISTRIBUTION_HPP
#define BOOST_RANDOM_BERNOULLI_DISTRIBUTION_HPP
#include <iosfwd>
#include <boost/assert.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/operators.hpp>
namespace boost {
namespace random {
/**
* Instantiations of class template \bernoulli_distribution model a
* \random_distribution. Such a random distribution produces bool values
* distributed with probabilities P(true) = p and P(false) = 1-p. p is
* the parameter of the distribution.
*/
template<class RealType = double>
class bernoulli_distribution
{
public:
// In principle, this could work with both integer and floating-point
// types. Generating floating-point random numbers in the first
// place is probably more expensive, so use integer as input.
typedef int input_type;
typedef bool result_type;
class param_type
{
public:
typedef bernoulli_distribution distribution_type;
/**
* Constructs the parameters of the distribution.
*
* Requires: 0 <= p <= 1
*/
explicit param_type(RealType p_arg = RealType(0.5))
: _p(p_arg)
{
BOOST_ASSERT(_p >= 0);
BOOST_ASSERT(_p <= 1);
}
/** Returns the p parameter of the distribution. */
RealType p() const { return _p; }
/** Writes the parameters to a std::ostream. */
BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, param_type, parm)
{
os << parm._p;
return os;
}
/** Reads the parameters from a std::istream. */
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, param_type, parm)
{
is >> parm._p;
return is;
}
/** Returns true if the two sets of parameters are equal. */
BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(param_type, lhs, rhs)
{ return lhs._p == rhs._p; }
/** Returns true if the two sets of parameters are different. */
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type)
private:
RealType _p;
};
/**
* Constructs a \bernoulli_distribution object.
* p is the parameter of the distribution.
*
* Requires: 0 <= p <= 1
*/
explicit bernoulli_distribution(const RealType& p_arg = RealType(0.5))
: _p(p_arg)
{
BOOST_ASSERT(_p >= 0);
BOOST_ASSERT(_p <= 1);
}
/**
* Constructs \bernoulli_distribution from its parameters
*/
explicit bernoulli_distribution(const param_type& parm)
: _p(parm.p()) {}
// compiler-generated copy ctor and assignment operator are fine
/**
* Returns: The "p" parameter of the distribution.
*/
RealType p() const { return _p; }
/** Returns the smallest value that the distribution can produce. */
bool min BOOST_PREVENT_MACRO_SUBSTITUTION () const
{ return false; }
/** Returns the largest value that the distribution can produce. */
bool max BOOST_PREVENT_MACRO_SUBSTITUTION () const
{ return true; }
/** Returns the parameters of the distribution. */
param_type param() const { return param_type(_p); }
/** Sets the parameters of the distribution. */
void param(const param_type& parm) { _p = parm.p(); }
/**
* Effects: Subsequent uses of the distribution do not depend
* on values produced by any engine prior to invoking reset.
*/
void reset() { }
/**
* Returns: a random variate distributed according to the
* \bernoulli_distribution.
*/
template<class Engine>
bool operator()(Engine& eng) const
{
if(_p == RealType(0))
return false;
else
return RealType(eng() - (eng.min)()) <= _p * RealType((eng.max)()-(eng.min)());
}
/**
* Returns: a random variate distributed according to the
* \bernoulli_distribution with parameters specified by param.
*/
template<class Engine>
bool operator()(Engine& eng, const param_type& parm) const
{
return bernoulli_distribution(parm)(eng);
}
/**
* Writes the parameters of the distribution to a @c std::ostream.
*/
BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, bernoulli_distribution, bd)
{
os << bd._p;
return os;
}
/**
* Reads the parameters of the distribution from a @c std::istream.
*/
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, bernoulli_distribution, bd)
{
is >> bd._p;
return is;
}
/**
* Returns true iff the two distributions will produce identical
* sequences of values given equal generators.
*/
BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(bernoulli_distribution, lhs, rhs)
{ return lhs._p == rhs._p; }
/**
* Returns true iff the two distributions will produce different
* sequences of values given equal generators.
*/
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(bernoulli_distribution)
private:
RealType _p;
};
} // namespace random
using random::bernoulli_distribution;
} // namespace boost
#endif // BOOST_RANDOM_BERNOULLI_DISTRIBUTION_HPP

View File

@ -1,184 +0,0 @@
/* boost random/beta_distribution.hpp header file
*
* Copyright Steven Watanabe 2014
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*/
#ifndef BOOST_RANDOM_BETA_DISTRIBUTION_HPP
#define BOOST_RANDOM_BETA_DISTRIBUTION_HPP
#include <cassert>
#include <istream>
#include <iosfwd>
#include <boost/random/detail/operators.hpp>
#include <boost/random/gamma_distribution.hpp>
namespace boost {
namespace random {
/**
* The beta distribution is a real-valued distribution which produces
* values in the range [0, 1]. It has two parameters, alpha and beta.
*
* It has \f$\displaystyle p(x) = \frac{x^{\alpha-1}(1-x)^{\beta-1}}{B(\alpha, \beta)}\f$.
*/
template<class RealType = double>
class beta_distribution {
public:
typedef RealType result_type;
typedef RealType input_type;
class param_type {
public:
typedef beta_distribution distribution_type;
/**
* Constructs a @c param_type from the "alpha" and "beta" parameters
* of the distribution.
*
* Requires: alpha > 0, beta > 0
*/
explicit param_type(RealType alpha_arg = RealType(1.0),
RealType beta_arg = RealType(1.0))
: _alpha(alpha_arg), _beta(beta_arg)
{
assert(alpha_arg > 0);
assert(beta_arg > 0);
}
/** Returns the "alpha" parameter of the distribtuion. */
RealType alpha() const { return _alpha; }
/** Returns the "beta" parameter of the distribution. */
RealType beta() const { return _beta; }
/** Writes a @c param_type to a @c std::ostream. */
BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, param_type, parm)
{ os << parm._alpha << ' ' << parm._beta; return os; }
/** Reads a @c param_type from a @c std::istream. */
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, param_type, parm)
{ is >> parm._alpha >> std::ws >> parm._beta; return is; }
/** Returns true if the two sets of parameters are the same. */
BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(param_type, lhs, rhs)
{ return lhs._alpha == rhs._alpha && lhs._beta == rhs._beta; }
/** Returns true if the two sets of parameters are the different. */
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type)
private:
RealType _alpha;
RealType _beta;
};
/**
* Constructs an @c beta_distribution from its "alpha" and "beta" parameters.
*
* Requires: alpha > 0, beta > 0
*/
explicit beta_distribution(RealType alpha_arg = RealType(1.0),
RealType beta_arg = RealType(1.0))
: _alpha(alpha_arg), _beta(beta_arg)
{
assert(alpha_arg > 0);
assert(beta_arg > 0);
}
/** Constructs an @c beta_distribution from its parameters. */
explicit beta_distribution(const param_type& parm)
: _alpha(parm.alpha()), _beta(parm.beta())
{}
/**
* Returns a random variate distributed according to the
* beta distribution.
*/
template<class URNG>
RealType operator()(URNG& urng) const
{
RealType a = gamma_distribution<RealType>(_alpha, RealType(1.0))(urng);
RealType b = gamma_distribution<RealType>(_beta, RealType(1.0))(urng);
return a / (a + b);
}
/**
* Returns a random variate distributed accordint to the beta
* distribution with parameters specified by @c param.
*/
template<class URNG>
RealType operator()(URNG& urng, const param_type& parm) const
{
return beta_distribution(parm)(urng);
}
/** Returns the "alpha" parameter of the distribution. */
RealType alpha() const { return _alpha; }
/** Returns the "beta" parameter of the distribution. */
RealType beta() const { return _beta; }
/** Returns the smallest value that the distribution can produce. */
RealType min BOOST_PREVENT_MACRO_SUBSTITUTION () const
{ return RealType(0.0); }
/** Returns the largest value that the distribution can produce. */
RealType max BOOST_PREVENT_MACRO_SUBSTITUTION () const
{ return RealType(1.0); }
/** Returns the parameters of the distribution. */
param_type param() const { return param_type(_alpha, _beta); }
/** Sets the parameters of the distribution. */
void param(const param_type& parm)
{
_alpha = parm.alpha();
_beta = parm.beta();
}
/**
* Effects: Subsequent uses of the distribution do not depend
* on values produced by any engine prior to invoking reset.
*/
void reset() { }
/** Writes an @c beta_distribution to a @c std::ostream. */
BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, beta_distribution, wd)
{
os << wd.param();
return os;
}
/** Reads an @c beta_distribution from a @c std::istream. */
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, beta_distribution, wd)
{
param_type parm;
if(is >> parm) {
wd.param(parm);
}
return is;
}
/**
* Returns true if the two instances of @c beta_distribution will
* return identical sequences of values given equal generators.
*/
BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(beta_distribution, lhs, rhs)
{ return lhs._alpha == rhs._alpha && lhs._beta == rhs._beta; }
/**
* Returns true if the two instances of @c beta_distribution will
* return different sequences of values given equal generators.
*/
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(beta_distribution)
private:
RealType _alpha;
RealType _beta;
};
} // namespace random
} // namespace boost
#endif // BOOST_RANDOM_BETA_DISTRIBUTION_HPP

View File

@ -1,434 +0,0 @@
/* boost random/binomial_distribution.hpp header file
*
* Copyright Steven Watanabe 2010
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*/
#ifndef BOOST_RANDOM_BINOMIAL_DISTRIBUTION_HPP_INCLUDED
#define BOOST_RANDOM_BINOMIAL_DISTRIBUTION_HPP_INCLUDED
#include <boost/config/no_tr1/cmath.hpp>
#include <cstdlib>
#include <iosfwd>
#include <boost/random/detail/config.hpp>
#include <boost/random/uniform_01.hpp>
#include <boost/random/detail/disable_warnings.hpp>
namespace boost {
namespace random {
namespace detail {
template<class RealType>
struct binomial_table {
static const RealType table[10];
};
template<class RealType>
const RealType binomial_table<RealType>::table[10] = {
0.08106146679532726,
0.04134069595540929,
0.02767792568499834,
0.02079067210376509,
0.01664469118982119,
0.01387612882307075,
0.01189670994589177,
0.01041126526197209,
0.009255462182712733,
0.008330563433362871
};
}
/**
* The binomial distribution is an integer valued distribution with
* two parameters, @c t and @c p. The values of the distribution
* are within the range [0,t].
*
* The distribution function is
* \f$\displaystyle P(k) = {t \choose k}p^k(1-p)^{t-k}\f$.
*
* The algorithm used is the BTRD algorithm described in
*
* @blockquote
* "The generation of binomial random variates", Wolfgang Hormann,
* Journal of Statistical Computation and Simulation, Volume 46,
* Issue 1 & 2 April 1993 , pages 101 - 110
* @endblockquote
*/
template<class IntType = int, class RealType = double>
class binomial_distribution {
public:
typedef IntType result_type;
typedef RealType input_type;
class param_type {
public:
typedef binomial_distribution distribution_type;
/**
* Construct a param_type object. @c t and @c p
* are the parameters of the distribution.
*
* Requires: t >=0 && 0 <= p <= 1
*/
explicit param_type(IntType t_arg = 1, RealType p_arg = RealType (0.5))
: _t(t_arg), _p(p_arg)
{}
/** Returns the @c t parameter of the distribution. */
IntType t() const { return _t; }
/** Returns the @c p parameter of the distribution. */
RealType p() const { return _p; }
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
/** Writes the parameters of the distribution to a @c std::ostream. */
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os,
const param_type& parm)
{
os << parm._p << " " << parm._t;
return os;
}
/** Reads the parameters of the distribution from a @c std::istream. */
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, param_type& parm)
{
is >> parm._p >> std::ws >> parm._t;
return is;
}
#endif
/** Returns true if the parameters have the same values. */
friend bool operator==(const param_type& lhs, const param_type& rhs)
{
return lhs._t == rhs._t && lhs._p == rhs._p;
}
/** Returns true if the parameters have different values. */
friend bool operator!=(const param_type& lhs, const param_type& rhs)
{
return !(lhs == rhs);
}
private:
IntType _t;
RealType _p;
};
/**
* Construct a @c binomial_distribution object. @c t and @c p
* are the parameters of the distribution.
*
* Requires: t >=0 && 0 <= p <= 1
*/
explicit binomial_distribution(IntType t_arg = 1,
RealType p_arg = RealType(0.5))
: _t(t_arg), _p(p_arg)
{
init();
}
/**
* Construct an @c binomial_distribution object from the
* parameters.
*/
explicit binomial_distribution(const param_type& parm)
: _t(parm.t()), _p(parm.p())
{
init();
}
/**
* Returns a random variate distributed according to the
* binomial distribution.
*/
template<class URNG>
IntType operator()(URNG& urng) const
{
if(use_inversion()) {
if(0.5 < _p) {
return _t - invert(_t, 1-_p, urng);
} else {
return invert(_t, _p, urng);
}
} else if(0.5 < _p) {
return _t - generate(urng);
} else {
return generate(urng);
}
}
/**
* Returns a random variate distributed according to the
* binomial distribution with parameters specified by @c param.
*/
template<class URNG>
IntType operator()(URNG& urng, const param_type& parm) const
{
return binomial_distribution(parm)(urng);
}
/** Returns the @c t parameter of the distribution. */
IntType t() const { return _t; }
/** Returns the @c p parameter of the distribution. */
RealType p() const { return _p; }
/** Returns the smallest value that the distribution can produce. */
IntType min BOOST_PREVENT_MACRO_SUBSTITUTION() const { return 0; }
/** Returns the largest value that the distribution can produce. */
IntType max BOOST_PREVENT_MACRO_SUBSTITUTION() const { return _t; }
/** Returns the parameters of the distribution. */
param_type param() const { return param_type(_t, _p); }
/** Sets parameters of the distribution. */
void param(const param_type& parm)
{
_t = parm.t();
_p = parm.p();
init();
}
/**
* Effects: Subsequent uses of the distribution do not depend
* on values produced by any engine prior to invoking reset.
*/
void reset() { }
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
/** Writes the parameters of the distribution to a @c std::ostream. */
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os,
const binomial_distribution& bd)
{
os << bd.param();
return os;
}
/** Reads the parameters of the distribution from a @c std::istream. */
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, binomial_distribution& bd)
{
bd.read(is);
return is;
}
#endif
/** Returns true if the two distributions will produce the same
sequence of values, given equal generators. */
friend bool operator==(const binomial_distribution& lhs,
const binomial_distribution& rhs)
{
return lhs._t == rhs._t && lhs._p == rhs._p;
}
/** Returns true if the two distributions could produce different
sequences of values, given equal generators. */
friend bool operator!=(const binomial_distribution& lhs,
const binomial_distribution& rhs)
{
return !(lhs == rhs);
}
private:
/// @cond show_private
template<class CharT, class Traits>
void read(std::basic_istream<CharT, Traits>& is) {
param_type parm;
if(is >> parm) {
param(parm);
}
}
bool use_inversion() const
{
// BTRD is safe when np >= 10
return m < 11;
}
// computes the correction factor for the Stirling approximation
// for log(k!)
static RealType fc(IntType k)
{
if(k < 10) return detail::binomial_table<RealType>::table[k];
else {
RealType ikp1 = RealType(1) / (k + 1);
return (RealType(1)/12
- (RealType(1)/360
- (RealType(1)/1260)*(ikp1*ikp1))*(ikp1*ikp1))*ikp1;
}
}
void init()
{
using std::sqrt;
using std::pow;
RealType p = (0.5 < _p)? (1 - _p) : _p;
IntType t = _t;
m = static_cast<IntType>((t+1)*p);
if(use_inversion()) {
q_n = pow((1 - p), static_cast<RealType>(t));
} else {
btrd.r = p/(1-p);
btrd.nr = (t+1)*btrd.r;
btrd.npq = t*p*(1-p);
RealType sqrt_npq = sqrt(btrd.npq);
btrd.b = 1.15 + 2.53 * sqrt_npq;
btrd.a = -0.0873 + 0.0248*btrd.b + 0.01*p;
btrd.c = t*p + 0.5;
btrd.alpha = (2.83 + 5.1/btrd.b) * sqrt_npq;
btrd.v_r = 0.92 - 4.2/btrd.b;
btrd.u_rv_r = 0.86*btrd.v_r;
}
}
template<class URNG>
result_type generate(URNG& urng) const
{
using std::floor;
using std::abs;
using std::log;
while(true) {
RealType u;
RealType v = uniform_01<RealType>()(urng);
if(v <= btrd.u_rv_r) {
u = v/btrd.v_r - 0.43;
return static_cast<IntType>(floor(
(2*btrd.a/(0.5 - abs(u)) + btrd.b)*u + btrd.c));
}
if(v >= btrd.v_r) {
u = uniform_01<RealType>()(urng) - 0.5;
} else {
u = v/btrd.v_r - 0.93;
u = ((u < 0)? -0.5 : 0.5) - u;
v = uniform_01<RealType>()(urng) * btrd.v_r;
}
RealType us = 0.5 - abs(u);
IntType k = static_cast<IntType>(floor((2*btrd.a/us + btrd.b)*u + btrd.c));
if(k < 0 || k > _t) continue;
v = v*btrd.alpha/(btrd.a/(us*us) + btrd.b);
RealType km = abs(k - m);
if(km <= 15) {
RealType f = 1;
if(m < k) {
IntType i = m;
do {
++i;
f = f*(btrd.nr/i - btrd.r);
} while(i != k);
} else if(m > k) {
IntType i = k;
do {
++i;
v = v*(btrd.nr/i - btrd.r);
} while(i != m);
}
if(v <= f) return k;
else continue;
} else {
// final acceptance/rejection
v = log(v);
RealType rho =
(km/btrd.npq)*(((km/3. + 0.625)*km + 1./6)/btrd.npq + 0.5);
RealType t = -km*km/(2*btrd.npq);
if(v < t - rho) return k;
if(v > t + rho) continue;
IntType nm = _t - m + 1;
RealType h = (m + 0.5)*log((m + 1)/(btrd.r*nm))
+ fc(m) + fc(_t - m);
IntType nk = _t - k + 1;
if(v <= h + (_t+1)*log(static_cast<RealType>(nm)/nk)
+ (k + 0.5)*log(nk*btrd.r/(k+1))
- fc(k)
- fc(_t - k))
{
return k;
} else {
continue;
}
}
}
}
template<class URNG>
IntType invert(IntType t, RealType p, URNG& urng) const
{
RealType q = 1 - p;
RealType s = p / q;
RealType a = (t + 1) * s;
RealType r = q_n;
RealType u = uniform_01<RealType>()(urng);
IntType x = 0;
while(u > r) {
u = u - r;
++x;
RealType r1 = ((a/x) - s) * r;
// If r gets too small then the round-off error
// becomes a problem. At this point, p(i) is
// decreasing exponentially, so if we just call
// it 0, it's close enough. Note that the
// minimum value of q_n is about 1e-7, so we
// may need to be a little careful to make sure that
// we don't terminate the first time through the loop
// for float. (Hence the test that r is decreasing)
if(r1 < std::numeric_limits<RealType>::epsilon() && r1 < r) {
break;
}
r = r1;
}
return x;
}
// parameters
IntType _t;
RealType _p;
// common data
IntType m;
union {
// for btrd
struct {
RealType r;
RealType nr;
RealType npq;
RealType b;
RealType a;
RealType c;
RealType alpha;
RealType v_r;
RealType u_rv_r;
} btrd;
// for inversion
RealType q_n;
};
/// @endcond
};
}
// backwards compatibility
using random::binomial_distribution;
}
#include <boost/random/detail/enable_warnings.hpp>
#endif

View File

@ -1,214 +0,0 @@
/* boost random/cauchy_distribution.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_CAUCHY_DISTRIBUTION_HPP
#define BOOST_RANDOM_CAUCHY_DISTRIBUTION_HPP
#include <boost/config/no_tr1/cmath.hpp>
#include <iosfwd>
#include <istream>
#include <boost/limits.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/operators.hpp>
#include <boost/random/uniform_01.hpp>
namespace boost {
namespace random {
// Cauchy distribution:
/**
* The cauchy distribution is a continuous distribution with two
* parameters, median and sigma.
*
* It has \f$\displaystyle p(x) = \frac{\sigma}{\pi(\sigma^2 + (x-m)^2)}\f$
*/
template<class RealType = double>
class cauchy_distribution
{
public:
typedef RealType input_type;
typedef RealType result_type;
class param_type
{
public:
typedef cauchy_distribution distribution_type;
/** Constructs the parameters of the cauchy distribution. */
explicit param_type(RealType median_arg = RealType(0.0),
RealType sigma_arg = RealType(1.0))
: _median(median_arg), _sigma(sigma_arg) {}
// backwards compatibility for Boost.Random
/** Returns the median of the distribution. */
RealType median() const { return _median; }
/** Returns the sigma parameter of the distribution. */
RealType sigma() const { return _sigma; }
// The new names in C++0x.
/** Returns the median of the distribution. */
RealType a() const { return _median; }
/** Returns the sigma parameter of the distribution. */
RealType b() const { return _sigma; }
/** Writes the parameters to a std::ostream. */
BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, param_type, parm)
{
os << parm._median << " " << parm._sigma;
return os;
}
/** Reads the parameters from a std::istream. */
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, param_type, parm)
{
is >> parm._median >> std::ws >> parm._sigma;
return is;
}
/** Returns true if the two sets of parameters are equal. */
BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(param_type, lhs, rhs)
{ return lhs._median == rhs._median && lhs._sigma == rhs._sigma; }
/** Returns true if the two sets of parameters are different. */
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type)
private:
RealType _median;
RealType _sigma;
};
/**
* Constructs a \cauchy_distribution with the paramters @c median
* and @c sigma.
*/
explicit cauchy_distribution(RealType median_arg = RealType(0.0),
RealType sigma_arg = RealType(1.0))
: _median(median_arg), _sigma(sigma_arg) { }
/**
* Constructs a \cauchy_distribution from it's parameters.
*/
explicit cauchy_distribution(const param_type& parm)
: _median(parm.median()), _sigma(parm.sigma()) { }
// compiler-generated copy ctor and assignment operator are fine
// backwards compatibility for Boost.Random
/** Returns: the "median" parameter of the distribution */
RealType median() const { return _median; }
/** Returns: the "sigma" parameter of the distribution */
RealType sigma() const { return _sigma; }
// The new names in C++0x
/** Returns: the "median" parameter of the distribution */
RealType a() const { return _median; }
/** Returns: the "sigma" parameter of the distribution */
RealType b() const { return _sigma; }
/** Returns the smallest value that the distribution can produce. */
RealType min BOOST_PREVENT_MACRO_SUBSTITUTION () const
{ return -(std::numeric_limits<RealType>::infinity)(); }
/** Returns the largest value that the distribution can produce. */
RealType max BOOST_PREVENT_MACRO_SUBSTITUTION () const
{ return (std::numeric_limits<RealType>::infinity)(); }
param_type param() const { return param_type(_median, _sigma); }
void param(const param_type& parm)
{
_median = parm.median();
_sigma = parm.sigma();
}
/**
* Effects: Subsequent uses of the distribution do not depend
* on values produced by any engine prior to invoking reset.
*/
void reset() { }
/**
* Returns: A random variate distributed according to the
* cauchy distribution.
*/
template<class Engine>
result_type operator()(Engine& eng)
{
// Can we have a boost::mathconst please?
const result_type pi = result_type(3.14159265358979323846);
using std::tan;
RealType val = uniform_01<RealType>()(eng)-result_type(0.5);
return _median + _sigma * tan(pi*val);
}
/**
* Returns: A random variate distributed according to the
* cauchy distribution with parameters specified by param.
*/
template<class Engine>
result_type operator()(Engine& eng, const param_type& parm)
{
return cauchy_distribution(parm)(eng);
}
/**
* Writes the distribution to a @c std::ostream.
*/
BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, cauchy_distribution, cd)
{
os << cd._median << " " << cd._sigma;
return os;
}
/**
* Reads the distribution from a @c std::istream.
*/
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, cauchy_distribution, cd)
{
is >> cd._median >> std::ws >> cd._sigma;
return is;
}
/**
* Returns true if the two distributions will produce
* identical sequences of values, given equal generators.
*/
BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(cauchy_distribution, lhs, rhs)
{ return lhs._median == rhs._median && lhs._sigma == rhs._sigma; }
/**
* Returns true if the two distributions may produce
* different sequences of values, given equal generators.
*/
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(cauchy_distribution)
private:
RealType _median;
RealType _sigma;
};
} // namespace random
using random::cauchy_distribution;
} // namespace boost
#endif // BOOST_RANDOM_CAUCHY_DISTRIBUTION_HPP

View File

@ -1,209 +0,0 @@
/* boost random/chi_squared_distribution.hpp header file
*
* Copyright Steven Watanabe 2011
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*/
#ifndef BOOST_RANDOM_CHI_SQUARED_DISTRIBUTION_HPP_INCLUDED
#define BOOST_RANDOM_CHI_SQUARED_DISTRIBUTION_HPP_INCLUDED
#include <iosfwd>
#include <boost/limits.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/gamma_distribution.hpp>
namespace boost {
namespace random {
/**
* The chi squared distribution is a real valued distribution with
* one parameter, @c n. The distribution produces values > 0.
*
* The distribution function is
* \f$\displaystyle P(x) = \frac{x^{(n/2)-1}e^{-x/2}}{\Gamma(n/2)2^{n/2}}\f$.
*/
template<class RealType = double>
class chi_squared_distribution {
public:
typedef RealType result_type;
typedef RealType input_type;
class param_type {
public:
typedef chi_squared_distribution distribution_type;
/**
* Construct a param_type object. @c n
* is the parameter of the distribution.
*
* Requires: t >=0 && 0 <= p <= 1
*/
explicit param_type(RealType n_arg = RealType(1))
: _n(n_arg)
{}
/** Returns the @c n parameter of the distribution. */
RealType n() const { return _n; }
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
/** Writes the parameters of the distribution to a @c std::ostream. */
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os,
const param_type& parm)
{
os << parm._n;
return os;
}
/** Reads the parameters of the distribution from a @c std::istream. */
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, param_type& parm)
{
is >> parm._n;
return is;
}
#endif
/** Returns true if the parameters have the same values. */
friend bool operator==(const param_type& lhs, const param_type& rhs)
{
return lhs._n == rhs._n;
}
/** Returns true if the parameters have different values. */
friend bool operator!=(const param_type& lhs, const param_type& rhs)
{
return !(lhs == rhs);
}
private:
RealType _n;
};
/**
* Construct a @c chi_squared_distribution object. @c n
* is the parameter of the distribution.
*
* Requires: t >=0 && 0 <= p <= 1
*/
explicit chi_squared_distribution(RealType n_arg = RealType(1))
: _impl(static_cast<RealType>(n_arg / 2))
{
}
/**
* Construct an @c chi_squared_distribution object from the
* parameters.
*/
explicit chi_squared_distribution(const param_type& parm)
: _impl(static_cast<RealType>(parm.n() / 2))
{
}
/**
* Returns a random variate distributed according to the
* chi squared distribution.
*/
template<class URNG>
RealType operator()(URNG& urng)
{
return 2 * _impl(urng);
}
/**
* Returns a random variate distributed according to the
* chi squared distribution with parameters specified by @c param.
*/
template<class URNG>
RealType operator()(URNG& urng, const param_type& parm) const
{
return chi_squared_distribution(parm)(urng);
}
/** Returns the @c n parameter of the distribution. */
RealType n() const { return 2 * _impl.alpha(); }
/** Returns the smallest value that the distribution can produce. */
RealType min BOOST_PREVENT_MACRO_SUBSTITUTION() const { return 0; }
/** Returns the largest value that the distribution can produce. */
RealType max BOOST_PREVENT_MACRO_SUBSTITUTION() const
{ return (std::numeric_limits<RealType>::infinity)(); }
/** Returns the parameters of the distribution. */
param_type param() const { return param_type(n()); }
/** Sets parameters of the distribution. */
void param(const param_type& parm)
{
typedef gamma_distribution<RealType> impl_type;
typename impl_type::param_type impl_parm(static_cast<RealType>(parm.n() / 2));
_impl.param(impl_parm);
}
/**
* Effects: Subsequent uses of the distribution do not depend
* on values produced by any engine prior to invoking reset.
*/
void reset() { _impl.reset(); }
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
/** Writes the parameters of the distribution to a @c std::ostream. */
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os,
const chi_squared_distribution& c2d)
{
os << c2d.param();
return os;
}
/** Reads the parameters of the distribution from a @c std::istream. */
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is,
chi_squared_distribution& c2d)
{
c2d.read(is);
return is;
}
#endif
/** Returns true if the two distributions will produce the same
sequence of values, given equal generators. */
friend bool operator==(const chi_squared_distribution& lhs,
const chi_squared_distribution& rhs)
{
return lhs._impl == rhs._impl;
}
/** Returns true if the two distributions could produce different
sequences of values, given equal generators. */
friend bool operator!=(const chi_squared_distribution& lhs,
const chi_squared_distribution& rhs)
{
return !(lhs == rhs);
}
private:
/// @cond show_private
template<class CharT, class Traits>
void read(std::basic_istream<CharT, Traits>& is) {
param_type parm;
if(is >> parm) {
param(parm);
}
}
gamma_distribution<RealType> _impl;
/// @endcond
};
}
}
#endif

View File

@ -1,40 +0,0 @@
/* boost random auto_link.hpp header file
*
* Copyright Steven Watanabe 2010
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* $Id$
*/
#ifndef BOOST_RANDOM_DETAIL_AUTO_LINK_HPP
#define BOOST_RANDOM_DETAIL_AUTO_LINK_HPP
#include <boost/config.hpp>
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_RANDOM_DYN_LINK)
#if defined(BOOST_RANDOM_SOURCE)
#define BOOST_RANDOM_DECL BOOST_SYMBOL_EXPORT
#else
#define BOOST_RANDOM_DECL BOOST_SYMBOL_IMPORT
#endif
#endif
#ifndef BOOST_RANDOM_DECL
#define BOOST_RANDOM_DECL
#endif
#if !defined(BOOST_RANDOM_NO_LIB) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_RANDOM_SOURCE)
#define BOOST_LIB_NAME boost_random
#if defined(BOOST_RANDOM_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
#define BOOST_DYN_LINK
#endif
#include <boost/config/auto_link.hpp>
#endif
#endif

View File

@ -1,18 +0,0 @@
/* boost random/detail/config.hpp header file
*
* Copyright Steven Watanabe 2009
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*/
#include <boost/config.hpp>
#if (defined(BOOST_NO_OPERATORS_IN_NAMESPACE) || defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)) \
&& !defined(BOOST_MSVC)
#define BOOST_RANDOM_NO_STREAM_OPERATORS
#endif

View File

@ -1,216 +0,0 @@
/* boost random/detail/const_mod.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*
* Revision history
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_CONST_MOD_HPP
#define BOOST_RANDOM_CONST_MOD_HPP
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/integer_traits.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <boost/random/detail/large_arithmetic.hpp>
#include <boost/random/detail/disable_warnings.hpp>
namespace boost {
namespace random {
template<class IntType, IntType m>
class const_mod
{
public:
static IntType apply(IntType x)
{
if(((unsigned_m() - 1) & unsigned_m()) == 0)
return (unsigned_type(x)) & (unsigned_m() - 1);
else {
IntType suppress_warnings = (m == 0);
BOOST_ASSERT(suppress_warnings == 0);
return x % (m + suppress_warnings);
}
}
static IntType add(IntType x, IntType c)
{
if(((unsigned_m() - 1) & unsigned_m()) == 0)
return (unsigned_type(x) + unsigned_type(c)) & (unsigned_m() - 1);
else if(c == 0)
return x;
else if(x < m - c)
return x + c;
else
return x - (m - c);
}
static IntType mult(IntType a, IntType x)
{
if(((unsigned_m() - 1) & unsigned_m()) == 0)
return unsigned_type(a) * unsigned_type(x) & (unsigned_m() - 1);
else if(a == 0)
return 0;
else if(a == 1)
return x;
else if(m <= traits::const_max/a) // i.e. a*m <= max
return mult_small(a, x);
else if(traits::is_signed && (m%a < m/a))
return mult_schrage(a, x);
else
return mult_general(a, x);
}
static IntType mult_add(IntType a, IntType x, IntType c)
{
if(((unsigned_m() - 1) & unsigned_m()) == 0)
return (unsigned_type(a) * unsigned_type(x) + unsigned_type(c)) & (unsigned_m() - 1);
else if(a == 0)
return c;
else if(m <= (traits::const_max-c)/a) { // i.e. a*m+c <= max
IntType suppress_warnings = (m == 0);
BOOST_ASSERT(suppress_warnings == 0);
return (a*x+c) % (m + suppress_warnings);
} else
return add(mult(a, x), c);
}
static IntType pow(IntType a, boost::uintmax_t exponent)
{
IntType result = 1;
while(exponent != 0) {
if(exponent % 2 == 1) {
result = mult(result, a);
}
a = mult(a, a);
exponent /= 2;
}
return result;
}
static IntType invert(IntType x)
{ return x == 0 ? 0 : (m == 0? invert_euclidian0(x) : invert_euclidian(x)); }
private:
typedef integer_traits<IntType> traits;
typedef typename make_unsigned<IntType>::type unsigned_type;
const_mod(); // don't instantiate
static IntType mult_small(IntType a, IntType x)
{
IntType suppress_warnings = (m == 0);
BOOST_ASSERT(suppress_warnings == 0);
return a*x % (m + suppress_warnings);
}
static IntType mult_schrage(IntType a, IntType value)
{
const IntType q = m / a;
const IntType r = m % a;
BOOST_ASSERT(r < q); // check that overflow cannot happen
return sub(a*(value%q), r*(value/q));
}
static IntType mult_general(IntType a, IntType b)
{
IntType suppress_warnings = (m == 0);
BOOST_ASSERT(suppress_warnings == 0);
IntType modulus = m + suppress_warnings;
BOOST_ASSERT(modulus == m);
if(::boost::uintmax_t(modulus) <=
(::std::numeric_limits< ::boost::uintmax_t>::max)() / modulus)
{
return static_cast<IntType>(boost::uintmax_t(a) * b % modulus);
} else {
return static_cast<IntType>(detail::mulmod(a, b, modulus));
}
}
static IntType sub(IntType a, IntType b)
{
if(a < b)
return m - (b - a);
else
return a - b;
}
static unsigned_type unsigned_m()
{
if(m == 0) {
return unsigned_type((std::numeric_limits<IntType>::max)()) + 1;
} else {
return unsigned_type(m);
}
}
// invert c in the finite field (mod m) (m must be prime)
static IntType invert_euclidian(IntType c)
{
// we are interested in the gcd factor for c, because this is our inverse
BOOST_ASSERT(c > 0);
IntType l1 = 0;
IntType l2 = 1;
IntType n = c;
IntType p = m;
for(;;) {
IntType q = p / n;
l1 += q * l2;
p -= q * n;
if(p == 0)
return l2;
IntType q2 = n / p;
l2 += q2 * l1;
n -= q2 * p;
if(n == 0)
return m - l1;
}
}
// invert c in the finite field (mod m) (c must be relatively prime to m)
static IntType invert_euclidian0(IntType c)
{
// we are interested in the gcd factor for c, because this is our inverse
BOOST_ASSERT(c > 0);
if(c == 1) return 1;
IntType l1 = 0;
IntType l2 = 1;
IntType n = c;
IntType p = m;
IntType max = (std::numeric_limits<IntType>::max)();
IntType q = max / n;
BOOST_ASSERT(max % n != n - 1 && "c must be relatively prime to m.");
l1 += q * l2;
p = max - q * n + 1;
for(;;) {
if(p == 0)
return l2;
IntType q2 = n / p;
l2 += q2 * l1;
n -= q2 * p;
if(n == 0)
return m - l1;
q = p / n;
l1 += q * l2;
p -= q * n;
}
}
};
} // namespace random
} // namespace boost
#include <boost/random/detail/enable_warnings.hpp>
#endif // BOOST_RANDOM_CONST_MOD_HPP

View File

@ -1,29 +0,0 @@
/* boost random/detail/disable_warnings.hpp header file
*
* Copyright Steven Watanabe 2009
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*
*/
// No #include guard. This header is intended to be included multiple times.
#include <boost/config.hpp>
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4512)
#pragma warning(disable:4127)
#pragma warning(disable:4724)
#pragma warning(disable:4800) // 'int' : forcing value to bool 'true' or 'false' (performance warning)
#endif
#if defined(BOOST_GCC) && BOOST_GCC >= 40600
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlogical-op"
#endif

View File

@ -1,22 +0,0 @@
/* boost random/detail/enable_warnings.hpp header file
*
* Copyright Steven Watanabe 2009
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*
*/
// No #include guard. This header is intended to be included multiple times.
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#if defined(BOOST_GCC) && BOOST_GCC >= 40600
#pragma GCC diagnostic pop
#endif

View File

@ -1,36 +0,0 @@
/* boost random/detail/generator_bits.hpp header file
*
* Copyright Steven Watanabe 2011
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*
*/
#ifndef BOOST_RANDOM_DETAIL_GENERATOR_BITS_HPP
#define BOOST_RANDOM_DETAIL_GENERATOR_BITS_HPP
#include <boost/limits.hpp>
namespace boost {
namespace random {
namespace detail {
// This is a temporary measure that retains backwards
// compatibility.
template<class URNG>
struct generator_bits {
static std::size_t value() {
return std::numeric_limits<typename URNG::result_type>::digits;
}
};
} // namespace detail
} // namespace random
} // namespace boost
#endif // BOOST_RANDOM_DETAIL_GENERATOR_BITS_HPP

View File

@ -1,40 +0,0 @@
/* boost random/mersenne_twister.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Copyright Steven Watanabe 2010
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*
*/
#ifndef BOOST_RANDOM_DETAIL_GENERATOR_SEED_SEQ_HPP_INCLUDED
#define BOOST_RANDOM_DETAIL_GENERATOR_SEED_SEQ_HPP_INCLUDED
namespace boost {
namespace random {
namespace detail {
template<class Generator>
class generator_seed_seq {
public:
generator_seed_seq(Generator& g) : gen(&g) {}
template<class It>
void generate(It first, It last) {
for(; first != last; ++first) {
*first = (*gen)();
}
}
private:
Generator* gen;
};
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More