Compare commits

...

1573 Commits

Author SHA1 Message Date
59b5b17e81 Add support for different sync instructions for CodeWarrior PPC (#95)
* Use msync or se_isync as appropriate for CodeWarrior PPC

* Un-obsolete sp_counted_base_cw_ppc

* Remove untested VLE_ON branch

* Use the supported compiler intrinsic __sync(); instead of msync asm

* Revert "Use the supported compiler intrinsic __sync(); instead of msync asm"

This reverts commit 9b92ea28f0.
2022-06-22 18:41:00 +03:00
f2ab3b21f0 Merge pull request #90 from fanquake/use_core_checked_delete
refactor: use boost/core/checked_delete.hpp over boost/checked_delete.hpp
2022-05-20 03:45:08 +03:00
e04196b6a1 Update ci.yml 2022-05-20 01:35:15 +03:00
95eaa2d7c3 Update shared_ptr move constructors to improve codegen 2022-05-19 22:20:50 +03:00
2e31d0d633 Add ubuntu-22.04 to posix-cmake-test in ci.yml 2022-05-19 21:09:26 +03:00
b8cb132ab4 Update ci.yml 2022-05-19 20:15:52 +03:00
f4d7116241 refactor: use core/checked_delete.hpp over checked_delete.hpp
boost/checked_delete.hpp has been deprecated.
2022-04-03 16:49:10 +01:00
f2cc84a23c Correct example in documentation 2021-12-17 01:36:17 -05:00
f12a33813d Remove msvc-14.2 (in GHA); use clang-win from 2019 2021-12-17 02:49:45 +02:00
cfde4f7407 Correct spelling in changelog 2021-12-16 11:47:55 -05:00
b8d340b495 Update changelog 2021-12-16 11:29:54 -05:00
6716193d9c Add get_allocator_pointer 2021-12-16 11:26:11 -05:00
8f40bff2f6 Remove cxxstd=2a from clang-8 2021-10-29 00:48:48 +03:00
1ef8f4e72d Remove 16.04 from ci.yml 2021-10-28 23:31:51 +03:00
f651a49d96 Enable syntax hightlighting 2021-10-28 23:16:09 +03:00
598314b8e1 Add msvc-14.3 to ci.yml 2021-10-28 23:15:44 +03:00
72221d1da0 Update ci.yml 2021-06-08 18:59:28 +03:00
2cbeb5b185 Update ci.yml 2021-06-08 18:32:47 +03:00
67e657c228 Build CMake tests in .travis.yml 2021-06-08 08:18:47 +03:00
eba3cf92e7 Disable failing tests on 4.4 in addition to 4.4.7 2021-06-08 05:58:06 +03:00
8340a13539 Merge branch 'feature/move-up-deleter' into feature/move-only-deleter 2021-05-11 18:03:35 +03:00
098d0f4ce3 Disable sp_unique_ptr_test2 on msvc-10.0 2021-05-11 15:54:21 +03:00
fec5fb97c8 Enable move-only deleters in the nullptr_t constructors 2021-05-11 02:15:27 +03:00
b52d7548b3 Enable move-only deleters in the allocator constructor 2021-05-11 02:05:28 +03:00
594c7485a5 Enable move-only deleters 2021-05-11 01:59:01 +03:00
d751041fb9 Add more test cases to sp_unique_ptr_test2 2021-05-11 01:33:48 +03:00
d41546ddce Move the unique_ptr deleter instead of copying it 2021-05-11 01:20:02 +03:00
f3424e74e8 Update .github/workflows 2021-04-19 18:53:52 +03:00
0eee7efd54 Update .github/workflows 2021-04-19 18:18:38 +03:00
dc2a127369 Update .travis.yml 2021-01-26 12:53:36 +02:00
42575a0e51 Add "cxxstd" json field 2021-01-21 12:04:23 -05:00
64b2eac868 Add .github/workflows 2021-01-20 00:41:39 +02:00
856ed108e8 Update maintainer e-mail 2020-12-12 01:05:17 +02:00
678a544d27 Add cxxstd=latest to msvc-14.2 2020-11-14 21:42:09 +02:00
f1b06df6f4 Use address-model=32 for msvc-9.0,10.0,11.0 2020-11-14 21:37:15 +02:00
620620df3d Merge branch 'develop' 2020-06-19 19:17:05 +03:00
0bd61c1089 Remove boost_install call from CMakeLists.txt 2020-06-17 19:36:01 +03:00
d1295a9974 Remove boost_install call from CMakeLists.txt 2020-06-11 17:19:17 +03:00
6e8c15c02f Fix typo, trailing whitespace 2020-06-10 21:59:48 +03:00
7c0dcd338a Refactor yield_k.hpp 2020-06-10 18:58:08 +03:00
8d79ceaf8a Revert using a relaxed load before test_and_set; not necessary, and slower, with a proper yielding strategy as opposed to just pause-spinning 2020-06-10 18:20:33 +03:00
d35cf29b99 Revert "Use a relaxed load before XCHG to not lock cache line on contention (AMD spinlock recommendation per <https://probablydance.com/2019/12/30/measuring-mutexes-spinlocks-and-how-bad-the-linux-scheduler-really-is/>)"
This reverts commit 8afe162910.
2020-06-10 18:18:35 +03:00
72ca834ae8 Change yield_k to not use sp_thread_yield; using sp_thread_sleep is always strictly superior, at least on Windows 2020-06-07 21:24:21 +03:00
8afe162910 Use a relaxed load before XCHG to not lock cache line on contention (AMD spinlock recommendation per <https://probablydance.com/2019/12/30/measuring-mutexes-spinlocks-and-how-bad-the-linux-scheduler-really-is/>) 2020-06-07 21:07:35 +03:00
5d31c1c443 Refactor yield_k.hpp 2020-06-07 20:40:41 +03:00
3db4ad9a15 Use a relaxed load before test_and_set to not lock cache line on contention (AMD spinlock recommendation per <https://probablydance.com/2019/12/30/measuring-mutexes-spinlocks-and-how-bad-the-linux-scheduler-really-is/>) 2020-06-07 17:59:55 +03:00
d0655ab145 Add atomic_count_gcc_atomic.hpp 2020-06-07 06:29:14 +03:00
7c01e640f7 Use int_least32_t in atomic_count_sync; prefer it to atomic_count_gcc_x86; mark latter obsolete 2020-06-07 06:05:17 +03:00
00db1e02c6 Add spinlock_gcc_atomic.hpp 2020-06-07 05:00:03 +03:00
914b93430a Change spinlock_sync.hpp to use a single byte 2020-06-07 04:10:49 +03:00
15ffd7852b Remove Clang C11 implementation; no longer used 2020-06-07 02:05:55 +03:00
c66c4f5ed1 Mark platform-specific implementations as obsolete 2020-06-07 02:04:42 +03:00
7e9d8c39a3 Add sp_has_gcc_intrinsics.hpp, sp_counted_base_gcc_atomic.hpp 2020-06-06 20:43:08 +03:00
a0d08b17e0 Fix include guards 2020-06-06 17:13:56 +03:00
108a86cdbd Rename sp_has_sync.hpp to sp_has_sync_intrinsics.hpp 2020-06-06 17:11:28 +03:00
d08bdc86e5 Remove unused files 2020-06-06 16:59:36 +03:00
f8dcf5f6f4 Use BOOST_SMT_PAUSE starting from the first iteration 2020-06-06 16:54:57 +03:00
d38f64ded9 Update documentation 2020-06-06 00:35:12 +03:00
b66fe51566 Avoid g++ 4.4 conflict between hash() and boost::hash 2020-06-06 00:15:58 +03:00
1b5568d585 Add sp_unordered_test 2020-06-05 18:54:44 +03:00
fad0c20263 Add owner_hash 2020-06-05 18:45:00 +03:00
1c61e54b13 Update documentation 2020-06-05 18:12:59 +03:00
a0fc1e6daa Add wp_unordered_test 2020-06-04 20:52:17 +03:00
5dd84ea389 Add .owner_hash_value to shared/weak_ptr, hash_value, std::hash/equal_to specializations for weak_ptr 2020-06-04 20:40:57 +03:00
bc677e9098 Do not require boost::hash in the std::hash specializations 2020-06-03 17:38:03 +03:00
688cfed63e Add Boost::bind to CMake test dependencies 2020-06-03 07:38:07 +03:00
c63dc266b9 Update submodule libs/bind on Travis/Appveyor 2020-06-02 21:51:00 +03:00
6c181a0707 When BOOST_SP_REPORT_IMPLEMENTATION is defined, report what platform-specific atomic implementation is used 2020-06-02 20:51:38 +03:00
4047290b85 Add multithreaded tests 2020-06-02 18:58:45 +03:00
dc6c76d7e9 Move lightweight_thread.hpp to smart_ptr/detail 2020-06-02 17:55:15 +03:00
5a18ffdc56 Add std::hash specializations for shared_ptr, local_shared_ptr, intrusive_ptr 2020-06-02 05:59:23 +03:00
09fdd5ebfd Add FreeBSD to Travis 2020-06-01 18:18:57 +03:00
911874e139 Add gcc-10 to Travis 2020-06-01 18:18:12 +03:00
c7c0eacb74 Add initializers to eq and lt 2020-06-01 15:08:53 +03:00
9ed9f43ca8 Document owner_less, owner_equal_to 2020-06-01 03:53:21 +03:00
0ddf990869 Add noexcept to owner_less, owner_equal_to 2020-06-01 03:44:41 +03:00
a08a5f3d41 Update introduction 2020-06-01 03:26:02 +03:00
77c2d4cad7 Add owner_less_test2 2020-06-01 03:13:42 +03:00
fd612dc114 Add owner_equal_to 2020-06-01 03:05:34 +03:00
e67ebef9a7 Update changelog 2020-06-01 02:01:10 +03:00
6f5b9c7b37 Document local_shared_ptr::owner_equals 2020-06-01 01:59:40 +03:00
91f3aa0386 Add local_shared_ptr::owner_equals 2020-06-01 01:35:25 +03:00
686a354f21 Add lsp_owner_before_test 2020-06-01 01:16:46 +03:00
efceb04665 Asciidoctor 2 fixes 2020-06-01 01:02:09 +03:00
ca57860ae2 Update footer 2020-06-01 00:41:25 +03:00
9dcd05f918 Document owner_equals 2020-06-01 00:40:02 +03:00
4b724ab3f8 Add mixed shared_count/weak_count operator== overloads to avoid refcount manipulation 2020-05-31 22:07:36 +03:00
58915ca2fe Add owner_equals 2020-05-31 21:41:06 +03:00
62b0e5cdf4 Add mixed shared_count/weak_count operator< overloads to avoid refcount manipulation 2020-05-31 21:12:12 +03:00
951ff783b5 Add sp_owner_before_test 2020-05-31 20:33:24 +03:00
6421394e70 Fix msvc-8.0 failures 2020-05-31 20:14:25 +03:00
121312cc22 Use allocator access utilities 2020-05-21 23:14:23 -04:00
1e5df9d551 Merge pull request #79 from EugeneZelenko/use-boost-override
Fix Clang-tidy modernize-use-override warnings.
2020-05-19 01:58:20 +03:00
496127ab99 Merge pull request #77 from eldiener/develop
Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74
2020-05-19 01:57:37 +03:00
2af343a2cb Fix Clang-tidy modernize-use-override warnings. 2020-05-12 18:01:55 -07:00
c6b3700ef1 Merge branch 'develop' of https://github.com/boostorg/smart_ptr into cppbuilder 2020-05-06 11:32:12 -04:00
2a93d30e73 Change conditions to be the same. 2020-05-06 11:31:57 -04:00
02cc561248 Only use warnings-as-errors on msvc, gcc, clang 2020-04-28 05:05:57 +03:00
066b398114 Disable -Wc11-extensions in sp_counted_base_clang.hpp 2020-04-27 00:50:15 +03:00
9c43c69c14 Add sp_pedantic_test 2020-04-26 19:57:05 +03:00
eb8998cd91 Add Clang 10 to Travis 2020-04-26 18:27:35 +03:00
df06c324a7 Merge branch 'develop' of https://github.com/boostorg/smart_ptr into cppbuilder 2020-04-19 02:49:06 -04:00
0ddfab493c Do not enable -Wsuggest-override in C++03 mode 2020-04-14 07:12:35 +03:00
a2732e207a Add BOOST_OVERRIDE to sp_counted_impl.hpp 2020-04-14 00:55:52 +03:00
5be7523ebe Merge branch 'develop' into feature/suggest-override 2020-04-14 00:45:24 +03:00
2320dafc03 Add BOOST_OVERRIDE to bad_weak_ptr.hpp and local_counted_base.hpp 2020-04-14 00:42:57 +03:00
7ab4093f46 Use shared_ptr and make_shared in sp_override_test 2020-04-14 00:32:25 +03:00
296c203135 Rename sp_warning_test to sp_override_test 2020-04-14 00:15:32 +03:00
2dd35e5fbc Mark functions with BOOST_OVERRIDE 2020-04-13 15:34:13 -04:00
977544feda Add sp_warning_test 2020-04-08 21:25:36 +03:00
54b5498208 Manually convince clang-cl to fail shared_from_fail and weak_from_fail 2020-04-02 04:01:21 +03:00
da81452f1f Make shared_from_this and weak_from_this private in enable_shared_from. Fixes #75. 2020-04-02 02:16:59 +03:00
7b9a969215 Add deduction guides to shared_ptr and weak_ptr. Fixes #73. 2020-04-02 00:28:02 +03:00
cd562eb053 Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers. 2020-03-26 17:17:22 -04:00
91cd83e5bf Correct make_unique_noinit example 2020-02-13 21:36:58 -05:00
2fdb8c4b0a Fix Travis issues; remove unnecessary jobs 2020-01-14 19:16:05 +02:00
e806b53433 Update Travis 2020-01-14 17:04:51 +02:00
e0c7bd9a7e Don't build tests when installing; link to Threads::Threads in tests because of lw_thread_test.cpp 2020-01-10 00:54:01 +02:00
766ab05a12 Update submodule libs/preprocessor on Travis (needed by CMake tests) 2020-01-09 15:53:38 +02:00
05cbefd28e Update submodule tools/cmake on Travis 2020-01-09 01:41:15 +02:00
bfbdf4f45f Add CMake install support, tests 2020-01-08 05:08:37 +02:00
169c0cd52a Remove lwm_nop.hpp; add lwm_std_mutex.hpp 2020-01-08 03:57:13 +02:00
7d70691a16 Remove Windows Runtime workaround from yield_k.hpp; it's no longer relevant, Sleep is available 2020-01-08 03:09:11 +02:00
90c27d7cfa Remove Windows Runtime workaround from lwm_win32_cs.hpp; it's no longer relevant, InitializeCriticalSection is available 2020-01-08 02:55:14 +02:00
43d1fe12c5 Include lightweight_test from core and workaround from config 2020-01-01 08:31:25 -05:00
a2749dddb4 Disable 32 bit clang-win to avoid mspdbcore.dll errors 2019-12-05 15:49:48 +02:00
a71e62146c Add VS2019 to Appveyor; separate clang-win into its own job 2019-11-24 00:05:38 +02:00
274ec17836 Even more documentation corrections 2019-09-15 02:06:23 -04:00
a7341070f1 More documentation corrections 2019-09-03 11:53:42 -04:00
a6323354cd Update constraints and synopsis in documentation 2019-09-02 22:10:09 -04:00
f788448101 Document alloc_deleter 2019-08-30 12:52:50 -04:00
283f2d2a11 Simplify synopsis using alias template 2019-08-30 12:04:09 -04:00
034f94617d Workaround for VC10 unique_ptr operator-> 2019-08-30 12:03:36 -04:00
6a5f67b3a2 Disable tests on VC10 which lacks conforming unique_ptr 2019-08-30 10:50:56 -04:00
dcd3c8ef80 In test cases, include allocate_unique first 2019-08-30 08:17:54 -04:00
bb2a453ff6 Add additional test cases 2019-08-30 08:16:11 -04:00
e56eec70ca Call to_address in the scalar destroy case too 2019-08-30 07:39:02 -04:00
60c26acab8 Implement allocate_unique 2019-08-30 00:31:28 -04:00
00f6b5dcb0 Split gcc 8/9 Travis jobs (again) due to log size 2019-08-29 13:20:36 +03:00
6195ae1eb0 Disable -Wdelete-non-virtual-dtor 2019-08-29 12:27:51 +03:00
30291c406a Update .travis.yml 2019-08-29 01:01:52 +03:00
610f19f247 Merge pull request #69 from CJBussey/feature/fix_warning_implicit_conversion
atomic_count_std_atomic: static_cast v to std::int_least32_t
2019-06-23 04:21:52 -07:00
876d40a9ab atomic_count_std_atomic: static_cast v to std::int_least32_t
* fix implicit conversion warning
2019-06-18 11:44:17 +02:00
e4d642c46a Revert Travis to Trusty 2019-05-30 02:42:39 +03:00
3dffa64f58 Bind allocator to element type, not scalar type 2019-05-15 07:33:04 -04:00
af92bd89ef allocation_ptr will be modified, renamed, and moved to detail 2019-05-05 22:21:22 -04:00
4742143605 Support allocation_ptr of const and volatile types 2019-05-04 09:43:11 -04:00
872bf10347 Move construct and destroy from Smart_Ptr to Core 2019-05-03 17:39:25 -04:00
c0ae9b3728 Implement allocation_ptr 2019-05-02 19:26:29 -04:00
1298c2e8e5 Include sp_noexcept.hpp in sp_construct.hpp 2019-05-02 18:00:53 -04:00
d593061b15 Move construct and destroy utilities to common header 2019-05-02 09:48:45 -04:00
5072045f12 Use boost::noinit_adapt free function 2019-04-29 00:37:55 -04:00
442e179920 Simplify implementation in terms of noinit_adaptor 2019-04-28 22:42:37 -04:00
9544a8cb91 Add revision history for 1.65 2019-04-24 17:21:37 +03:00
5823d6bcc9 Document enable_shared_from 2019-04-24 05:16:03 +03:00
f56e609757 Fix mistake in weak_from_this_test 2019-04-24 04:57:37 +03:00
8df63a3d0e Add tests for enable_shared_from 2019-04-24 04:50:59 +03:00
4b6cb1223b Add boost/smart_ptr/enable_shared_from.hpp 2019-04-24 04:50:30 +03:00
719e819570 Under g++ 4.4, <memory> doesn't compile with rtti=off 2019-04-22 15:57:56 +03:00
a571b3a250 Only include core/typeinfo.hpp when needed 2019-04-22 06:07:36 +03:00
f17c5e8e3b Add a few no_rtti tests 2019-04-22 05:43:08 +03:00
e306b30dcf Use a private detail/sp_typeinfo header instead of the deprecated Core one 2019-04-22 05:25:07 +03:00
b6b49ef591 Split g++ 8 Travis job, because log length 2019-04-22 02:19:27 +03:00
2122c7753c Avoid memcpy over a spinlock, because g++ 8 warns 2019-04-22 02:17:28 +03:00
7c76fb385d Add clang-win to Appveyor 2019-04-22 00:59:38 +03:00
372fac679b Remove _internal_aliasing_assign 2019-04-21 23:13:06 +03:00
e3adcaed1e Add revision history 2019-04-21 23:00:24 +03:00
016e682af6 Document weak_ptr aliasing constructors and empty 2019-04-21 22:52:44 +03:00
78e095d761 Disable tests that don't compile on msvc-8.0 2019-04-21 22:50:24 +03:00
eb8a91cb46 Add tests for the weak_ptr aliasing constructors 2019-04-21 22:44:09 +03:00
513cd15378 Add aliasing constructors to weak_ptr. Closes #67. 2019-04-21 22:43:04 +03:00
7bfa6a1f3d Fix typo 2019-04-21 21:33:55 +03:00
8120bb44cb Add rvalue pointer casts (closes #66) 2019-04-21 00:47:36 +03:00
18974ea2db Add cast tests to intrusive_ptr_test 2019-04-20 18:54:13 +03:00
2a4aca403a Merge branch 'develop' into feature/intrusive-ptr-tests 2019-04-20 18:15:31 +03:00
4d0d81477c Update msvc workarounds for 14.2 2019-04-20 18:15:05 +03:00
1725e26f70 Add assignment tests to intrusive_ptr_test 2019-04-20 18:02:11 +03:00
47fffaf11c Switch Appveyor to 2015 image 2019-04-14 18:24:21 +03:00
7f0323a347 Merge branch 'develop' of https://github.com/boostorg/smart_ptr into develop 2019-03-25 19:25:44 +02:00
6d8ea0f0c4 Remove project-id from doc/Jamfile 2019-03-25 19:25:33 +02:00
d10299159a More asciidoctor changes
Reinstate the none/blank trick, but remove the blank line after it in local_shared_ptr.adoc that causes the problem. Also use that trick in place of the nested DLs which don't work with Asciidoctor 2
2019-03-24 23:41:08 -04:00
adcab0e313 Update asciidoc to work with Asciidoctor 2.0 2019-03-24 20:28:17 -04:00
4fbb9ff076 Merge branch 'develop' 2019-03-02 21:08:43 +02:00
8ccb36dfcf Use traits from TypeTraits 2019-02-22 19:36:32 -05:00
fde2e91443 Use traits from TypeTraits 2019-02-22 19:01:55 -05:00
aa1341a6a2 Add BOOST_SP_NOEXCEPT to sp_counted_base_nt.hpp 2019-01-28 21:24:09 +02:00
053779f3ee Add BOOST_SP_NOEXCEPT to sp_counted_base_clang.hpp 2019-01-28 20:52:28 +02:00
51d8167fbf Add more BOOST_SP_NOEXCEPT 2019-01-28 18:46:39 +02:00
5f95fe9848 Fix .travis.yml 2019-01-06 04:37:59 +02:00
599d0bbba9 Add test/cmake_subdir_test 2019-01-05 19:43:22 +02:00
f769217ca8 Update CMakeLists.txt 2019-01-04 19:40:30 +02:00
5d5d28a92e [CMake] Generate cmake target that other libraries can use
... to express their dependency on this library and retrieve any
configuration information such as the include directory and
transitive dependencies.
2019-01-02 22:32:38 +01:00
85fd341402 Merge pull request #59 from Kojoley/patch-1
Do not include the whole Predef for a single macro
2018-12-29 02:24:02 +02:00
eac6411867 Do not include the whole Predef for a single macro 2018-12-28 03:03:02 +03:00
97ef7970e8 Remove VARIANT from .travis.yml 2018-12-23 16:44:03 +02:00
4baa21dd5e Add libstdc++-5 for clang 7-ubsan 2018-12-23 08:17:32 +02:00
d0a89a81f0 More g++ warning suppression 2018-12-23 06:21:55 +02:00
ab2b977e4a Update clang-5 ubsan to clang-7 2018-12-23 05:19:07 +02:00
f380d4466c Avoid some g++ warnings in shared_ptr_test 2018-12-23 05:06:24 +02:00
2932ca4203 Change sp_counted_base_nt/_pt to use boost::int_least32_t instead of long (which may be 64 bit) 2018-12-23 01:54:36 +02:00
660d26c2c3 Change 03/11 to 98/0x for gcc 4.4 2018-12-23 00:08:32 +02:00
a095084492 Improve abi_test 2018-12-23 00:06:13 +02:00
a314765b94 Test variant=debug,release on Travis 2018-12-22 23:52:07 +02:00
02eba55685 Add abi_test 2018-12-22 22:56:20 +02:00
9c2c991291 Update .yml files 2018-12-18 21:53:58 +02:00
2e57ddb953 Update documentation of intrusive_ptr (document move ops, fix op<) 2018-11-25 17:54:51 +02:00
f6c3508aee Add make_local_shared_const_test 2018-11-10 21:04:22 +02:00
b7cca00408 Add make_shared_const_test 2018-11-10 20:44:00 +02:00
7e50abb9ec Merge pull request #55 from Romain-Geissler-1A/noexcept
Use BOOST_NOEXCEPT_OR_NOTHROW in public headers to prepare for C++20.
2018-11-10 19:32:01 +02:00
e7360779b0 Add g++ 8, clang 6.0, 7 to Travis 2018-11-10 18:35:29 +02:00
456da93897 Use BOOST_NOEXCEPT_OR_NOTHROW in public headers to prepare for C++20. 2018-11-09 14:55:34 +00:00
04f0847af4 Add --depth 1 to Appveyor 2018-09-21 20:53:27 +03:00
29a08cdff6 Use BOOST_SYMBOL_VISIBLE with local_counted_base and children 2018-09-19 13:50:13 -04:00
6d3af760f6 Generously dispense BOOST_SYMBOL_VISIBLE 2018-09-18 03:18:23 +03:00
a9f39d2b94 Test make_shared/allocate_shared in dll_test too 2018-09-17 22:04:27 +03:00
4e2f236116 Add dll_test (to check for visibility issues) 2018-09-17 21:50:47 +03:00
4eb53db537 Use intrin.h under clang-cl 2018-08-12 01:26:59 +03:00
a2b6ba85f3 Simplify exception safety in array construct utilities 2018-08-01 08:45:10 -04:00
e37cd4154f Work around ld: unrecognized option '--push-state--no-as-needed' 2018-05-10 16:16:08 +03:00
8563fc5c4e Add tests that include <windows.h> 2018-03-11 23:00:50 +02:00
67fab5c9ec Clang x64 warns that __stdcall is ignored, so don't use it there 2018-03-08 06:53:28 +02:00
f16fbdce26 Fix sp_interlocked on Cygwin 64 2018-03-08 05:15:49 +02:00
c3b3835a58 Mingw doesn't have _RTL_CRITICAL_SECTION 2018-03-08 03:34:00 +02:00
d1600b8abc Do not define pthread_* in lightweight_thread.hpp; mingw-w64 includes pthread.h in the standard library headers 2018-03-08 01:19:44 +02:00
5885763287 Remove clang from Appveyor; doesn't really work. 2018-03-08 00:39:15 +02:00
9bb12692b3 Only test C++14 with clang on Appveyor 2018-03-07 21:23:01 +02:00
773ef80f5d Add mingw configurations; move LLVM clang in its own VS2017 job 2018-03-07 20:06:04 +02:00
704de2bd67 Add Cygwin to Appveyor 2018-03-07 18:27:45 +02:00
1caa233faa Add address-model=32,64 to Appveyor 2018-03-07 17:37:28 +02:00
605d4a2789 Merge pull request #49 from joaquintides/patch-1
fixed AppVeyor link
2018-03-05 16:28:17 +02:00
6ab9b93088 fixed AppVeyor link 2018-03-05 15:13:18 +01:00
4129bb6a5c Use unique_ptr instead of auto_ptr when available 2018-02-19 06:16:11 +02:00
3b64e5ecb3 Add lw_thread_test 2018-02-19 02:02:31 +02:00
4025698fe8 Change atomic operations to take an arbitrary MemoryOrder type, to fix test breakage caused by transition to scoped enum in Boost.Atomic, tracking C++20 2018-02-07 17:45:07 +02:00
2d7ab197a7 Remove variant=debug,release from Travis; too weak, too slow 2018-01-24 15:16:32 +02:00
5877b08490 Disable spinlock_pool_test on msvc-9.0/release as well 2018-01-23 21:49:30 +02:00
ffe5b46f75 Silence MS warning about strcpy 2018-01-23 21:45:59 +02:00
4abc74fe28 Disable spinlock_pool_test on msvc-8.0/release 2018-01-23 19:05:44 +02:00
12a646c607 Update .travis.yml, appveyor.yml 2018-01-23 19:02:35 +02:00
937a3e0e93 Remove tabs 2018-01-23 06:29:17 +02:00
258fa75a7e Add -fsanitize=undefined to Travis 2018-01-20 02:20:35 +02:00
93d0d69f5e Add clang-3.3, 3.4 to Travis 2018-01-19 19:43:30 +02:00
f173f9c0fb Remove -fno-deduce-init-list from make_shared_arrays_test, allocate_shared_arrays_test; seems no longer needed 2018-01-18 14:36:58 +02:00
6a5942f55f Fix make_unique_value_test line 2018-01-18 14:35:15 +02:00
293a4ee009 Use full gcc-4.4.7 version 2018-01-18 14:34:06 +02:00
8e3aa3a565 make_unique_value_test: add -fno-deduce-init-list for gcc-4.6 2018-01-18 00:13:00 +02:00
78bebd5166 Disable auto_ptr_lv_fail on g++ 4.4 (known failure) 2018-01-17 21:17:19 +02:00
a47cf35b0f Disable atomic_sp_constexpr_test on libc++ 5.0 as well 2018-01-17 19:17:17 +02:00
8d0afb670f atomic_sp_constexpr_test: add pragma messages when skipped 2018-01-17 16:46:54 +02:00
77a35856c6 Add g++ 4.4, 4.6 to Travis 2018-01-16 18:50:09 +02:00
693109361e Add missing cxxstd=03 to libc++ Travis job 2018-01-16 16:13:41 +02:00
6735806863 Add clang++-libc++ to Travis 2018-01-16 16:09:13 +02:00
b0dc300154 Merge pull request #47 from wzssyqa/mips-r6-no-set-mips2
disable .set mips2 for mips release r6
2018-01-03 07:18:59 +02:00
adc998469a Add container_hash to Travis and Appveyor 2018-01-03 02:59:19 +02:00
4252ed31de disable .set mips2 for mips release r6
MIPS r6 changed the encoding for `ll' instruction,
if we `.set mips2', it will generate the old encoding for `ll'.

So here we disable it for r6.
2017-12-31 14:14:11 +08:00
279372a784 Merge branch 'develop' 2017-12-18 17:26:13 +02:00
b77b7cfd62 Fix intrusive_ptr converting constructor doc issue #46 2017-11-28 20:13:32 +02:00
2553a71b79 Fix intrusive_ptr converting constructor doc issue #46 2017-11-28 20:09:52 +02:00
5dfcd2a6e4 Rename parameters to cope with gcc 4.8 -Wshadow 2017-11-27 23:47:13 -05:00
6f30b395e4 Add -j 3 to Travis 2017-11-06 05:29:33 +02:00
014318a1ba Reduce Appveyor jobs 2017-11-06 02:34:46 +02:00
d2c8eea08d Add VS2017 /std:c++17 to Appveyor 2017-11-06 01:49:20 +02:00
4e0d47302b Merge pull request #45 from glywk/contribution
Fix make_unique header filename documentation
2017-11-02 21:46:41 -04:00
765840cd71 Fix make_unique header filename documentation 2017-11-02 23:07:16 +01:00
cb4a878fa8 Merge pull request #44 from glenfe/develop
sp_array_construct condition for trivial should include has_trivial_destructor
2017-11-02 13:02:05 -04:00
57a585ed46 sp_array_construct condition for trivial should include has_trivial_destructor 2017-11-02 11:53:41 -04:00
949338ff18 Add test that verifies no temporaries are created by array make_shared 2017-11-02 17:45:17 +02:00
50fbbe91d8 Re-add libstdc++-4.9-dev to clang 3.5, 3.8, 3.9 2017-10-25 00:30:48 +03:00
e88227b506 Update .travis.yml 2017-10-24 20:20:15 +03:00
410f2ce8d4 Remove redundant local asciidoctor tool spec. 2017-10-22 07:56:41 -05:00
4e2e758f58 Merge pull request #42 from grafikrobot/patch-1
Guard against redef of asciidoctor in common b2.
2017-10-19 03:02:10 +03:00
9cb8ee086f Guard against redef of asciidoctor in common b2. 2017-10-18 18:43:56 -05:00
a054a570c1 Add quick test target 2017-09-04 15:45:07 +03:00
219dc523ec Install libstdc++-4.9 for clang 3.5, 3.8, 3.9 in .travis.yml 2017-09-01 23:19:03 +03:00
5da882293d Merge branch 'develop' 2017-09-01 16:15:33 +03:00
868a870a59 Fix lightweight_mutex w/ BOOST_USE_WINDOWS_H 2017-09-01 13:25:19 +03:00
10c6233029 Merge branch 'develop' 2017-08-29 00:44:14 +03:00
bcfe1be681 Merge pull request #40 from BenjaminW3/topic-fix-nvcc
fix compilation for nvcc+clang
2017-08-28 10:51:22 +03:00
966786e7f9 fix compilation for nvcc+clang
nvcc seems to use the host compiler for preprocessing the source for the device and host compilation.
When compiling the host code with the host compiler (clang), `__builtin_assume` is detected correctly and is also available during compilation.
When compiling the device code with nvcc, this builtin function is not available.
2017-08-28 08:12:48 +02:00
087471a232 Bump msvc version checks from <= 1910 to < 1920 2017-08-23 09:16:35 +03:00
06bd43d5b5 Merge branch 'develop' 2017-07-13 16:36:43 +03:00
1758d44e4c Add basic synopsis and description for make_local_shared 2017-07-08 08:50:59 -04:00
1c13ec0888 Remove wrong doc link from meta/libraries.json 2017-07-07 17:58:49 +03:00
cc7eb56f51 Fixed broken link in techniques.adoc 2017-07-07 14:14:54 +03:00
eb64ae8daa Untabify pointer_cast_test2 2017-07-07 00:59:01 +03:00
a3c8c2125a Use has_trivial_assign in construction utilities 2017-07-04 13:45:56 -04:00
3aa419463c Simplify lsp state types 2017-07-01 10:00:47 -04:00
e4ba116d7e Minor refactoring in allocate_shared implementations 2017-06-29 22:33:43 -04:00
864a0c80dd Conditionally compile allocate_local_shared tests 2017-06-29 13:33:14 -04:00
be736e5088 Implement allocate_local_shared for arrays
Also fix the local_shared_ptr constructor to use element_type
2017-06-29 13:05:03 -04:00
48294c483f Use new shared_count constructors in allocate_shared 2017-06-29 09:24:02 -04:00
13e73d6a78 Do not use UINT_MAX to avoid -Wmicrosoft-enum-value from Clang 2017-06-27 16:23:18 +03:00
20a517cc3d Clang/C2 doesn't have _mm_pause 2017-06-27 15:41:56 +03:00
65d412c840 Execute bootstrap in subshell on Appveyor to preserve TOOLSET 2017-06-22 17:34:20 +03:00
d031d4719f Check use counts in make_local_shared tests 2017-06-22 15:39:46 +03:00
c1979bcaf5 Check use counts in make_shared tests 2017-06-22 15:31:50 +03:00
0adb1fb212 Add shared_count constructor taking sp_counted_base* 2017-06-22 15:24:49 +03:00
7410cb1733 Update history.adoc. 2017-06-21 20:25:37 +03:00
2d087d0003 Do not use A::destroy in allocate_shared_noinit 2017-06-21 13:44:17 +03:00
ca7a01a593 Add more tests. Update Jamfile to new style. 2017-06-21 04:07:17 +03:00
314a6634d4 Merge branch 'feature/local_shared_ptr' into develop 2017-06-21 03:33:00 +03:00
6cbc1e6775 Update allocate_shared array unit tests
Tests that do not always use allocator bound for element_type.
2017-06-20 20:06:59 -04:00
81e1cfe301 Merge branch 'develop' into feature/local_shared_ptr 2017-06-21 03:04:16 +03:00
eb8aa36854 Merge branch 'develop' of https://github.com/boostorg/smart_ptr into develop 2017-06-21 03:03:21 +03:00
e210c5728d Add local_shared_ptr.adoc 2017-06-21 03:02:48 +03:00
4046186a2d Use BOOST_NOEXCEPT_OR_NOTHROW for get_deleter
throw() optimizes better there with older versions of GCC in C++98.
2017-06-20 19:27:58 -04:00
01b73a8bfa Merge branch 'develop' into feature/local_shared_ptr 2017-06-21 02:07:27 +03:00
c85abde6b0 Update shared_ptr.adoc 2017-06-21 02:06:16 +03:00
e9523962ae Update .travis.yml 2017-06-21 01:20:11 +03:00
4e5d067ba8 Add local_sp_fn_test 2017-06-20 22:26:07 +03:00
827206ec57 Merge branch 'develop' into feature/local_shared_ptr 2017-06-20 22:07:53 +03:00
0cdad6421d Add shared_ptr_fn_test 2017-06-20 22:07:12 +03:00
f7f7e0183d Merge branch 'feature/local_get_deleter' into feature/local_shared_ptr 2017-06-20 21:38:44 +03:00
f901988e57 Store shared_count in local_counted_base, not shared_ptr 2017-06-20 21:38:03 +03:00
22d150a1a9 Merge branch 'feature/local_get_deleter' into feature/local_shared_ptr 2017-06-20 20:39:04 +03:00
fb17bf685e Add more tests; fix errors 2017-06-20 20:38:26 +03:00
052ebd1946 Merge branch 'develop' into feature/local_get_deleter 2017-06-20 19:35:23 +03:00
028bb2cee8 Fix get_deleter in allocate_shared_array.hpp 2017-06-20 19:33:39 +03:00
9fe6885078 Add more get_deleter tests 2017-06-20 19:18:30 +03:00
6e5a382b6b Start work on get_deleter for local_shared_ptr 2017-06-20 19:01:16 +03:00
87272703c2 Add get_deleter test with an incomplete class 2017-06-20 17:47:59 +03:00
1c097b5764 Add get_deleter test with an incomplete class 2017-06-20 17:47:17 +03:00
014181e1f9 Merge branch 'develop' into feature/local_shared_ptr 2017-06-20 06:25:56 +03:00
0b9547ddad Disable atomic_sp_constexpr_test on libc++ 2017-06-20 06:25:27 +03:00
b104d85d95 Fix use of allocator_traits 2017-06-20 05:36:47 +03:00
e92d79c0a6 Add 14/1z to clang 3.5, 3.6, 3.7 2017-06-20 04:31:35 +03:00
2b5869882a Optimize make_local_shared to use a single allocation 2017-06-20 04:27:45 +03:00
1f86907a3d Add more tests 2017-06-20 02:00:19 +03:00
685b40cc1b Merge branch 'develop' into feature/local_shared_ptr 2017-06-20 01:49:04 +03:00
dcfb8489c6 Fix mistakes in atomic_sp_constexpr_test 2017-06-20 01:48:28 +03:00
6218c52c1a Add make_local_shared 2017-06-20 01:42:45 +03:00
c2b6e96cd7 Merge branch 'develop' into feature/local_shared_ptr 2017-06-19 20:39:29 +03:00
b062d84d36 Update history.adoc 2017-06-19 20:38:51 +03:00
68fb786d4d Add more tests 2017-06-19 17:36:13 +03:00
f7275b7f45 Add more tests 2017-06-19 02:30:54 +03:00
edf02ab0f9 Add more tests 2017-06-19 01:05:01 +03:00
5b316e6e90 Update specification of atomic_shared_ptr 2017-06-18 15:34:57 +03:00
7ed8583a9c Document shared_ptr atomic access functions 2017-06-18 15:24:00 +03:00
6474847481 Make atomic_shared_ptr's default constructor constexpr 2017-06-18 07:56:42 +03:00
75003f734f Merge branch 'feature/constexpr' into develop 2017-06-18 07:11:49 +03:00
79e6fcdd61 Remove comment; C++11 does not guarantee this static init 2017-06-18 05:00:42 +03:00
4341446e04 #ifdef constexpr tests on msvc and clang c++11 2017-06-18 04:21:22 +03:00
9c18322e85 Fix appveyor.yml again 2017-06-18 03:55:48 +03:00
49095c3236 Fix appveyor.yml 2017-06-18 03:36:49 +03:00
fff61ab5d6 Add clang 3.5 to ravis 2017-06-18 03:35:12 +03:00
aef27128f2 Add feature branch testing, matrix to Appveyor 2017-06-18 03:32:32 +03:00
c1d72af0a4 Add g++ 7, clang++ 4 to Travis 2017-06-18 03:11:59 +03:00
0e78e219f5 Make default constructors constexpr 2017-06-18 02:43:20 +03:00
2e469dd7f3 Fix .travis.yml 2017-06-18 02:20:00 +03:00
d9296befa8 Fix branch regexp in .travis.yml 2017-06-18 00:47:58 +03:00
f321ce404f Enable Travis on feature branches 2017-06-18 00:08:05 +03:00
67d897a533 Add a spinlock to atomic_shared_ptr 2017-06-17 23:37:18 +03:00
e462f17c2d Merge branch 'feature/local_shared_ptr' into develop 2017-06-17 21:26:13 +03:00
b8390aeffb Add more tests 2017-06-17 21:24:07 +03:00
9dafc01024 Merge branch 'develop' into feature/local_shared_ptr 2017-06-17 01:36:17 +03:00
7d51c868eb Add more tests 2017-06-17 01:34:58 +03:00
0b0b7af05b Fix intrusive_ref_counter.adoc 2017-06-16 18:18:25 -04:00
7bd389c95e Merge branch 'develop' into feature/local_shared_ptr 2017-06-17 00:15:39 +03:00
1cae5c5696 Fix documentation links in headers 2017-06-17 00:13:21 +03:00
369fdbe38d Merge branch 'develop' into feature/local_shared_ptr 2017-06-16 20:20:54 +03:00
43b37d4f28 Merge branch 'feature/atomic_shared_ptr' into develop 2017-06-16 20:20:17 +03:00
a048cfb56d Minor fixes to atomic_shared_ptr.hpp 2017-06-16 20:19:37 +03:00
070a3a9f1a Add atomic_shared_ptr.adoc 2017-06-16 20:15:23 +03:00
d03ef3db5c Merge branch 'develop' into feature/local_shared_ptr 2017-06-16 19:42:45 +03:00
6d97c2b89e Remove javascript that tried to integrate the Boost banner, as it didn't work 2017-06-16 19:32:35 +03:00
7484d4da41 Merge branch 'develop' into feature/local_shared_ptr 2017-06-16 18:40:01 +03:00
2964ed2379 Merge branch 'feature/atomic_shared_ptr' into develop 2017-06-16 18:36:10 +03:00
a7668291d2 Add atomic_shared_ptr 2017-06-16 18:26:17 +03:00
ffc48e63d8 Merge branch 'develop' into feature/local_shared_ptr 2017-06-16 17:18:33 +03:00
bcc9e50a54 Merge branch 'feature/asciidoc' into develop 2017-06-16 17:17:47 +03:00
8812114601 Fix line wrapping in pdf 2017-06-15 21:34:53 +03:00
5b817ba04d Fix synopses 2017-06-15 21:23:06 +03:00
6db55f7dfd Add _add_ref and _release overload documentation 2017-06-15 11:43:40 -04:00
61de342adc Add deprecated shared_array documentation 2017-06-15 08:16:50 -04:00
7f760526ab Add intrusive_ref_counter documentation 2017-06-15 02:09:06 -04:00
478a819cb5 Add generic pointer casts documentation 2017-06-15 01:36:59 -04:00
902ca6fdf3 Remove 'see below' in documentation 2017-06-14 20:40:11 -04:00
074882976f Slightly better looking comments in documentation 2017-06-14 11:28:41 -04:00
c1820b4a27 Various documentation fixes 2017-06-14 10:29:24 -04:00
8096b7d324 Add make_unique documentation 2017-06-14 08:24:31 -04:00
bdcab9df47 Add examples to make_shared documentation 2017-06-14 01:41:49 -04:00
8f99919102 Update make_shared documentation 2017-06-14 00:18:29 -04:00
27898b0823 Constrain conversions to shared_ptr/weak_ptr 2017-06-13 20:57:12 +03:00
47ee1e09e9 Use single allocation in deleter and allocator constructors 2017-06-13 18:29:18 +03:00
4dda1b5fbb Add lsp_array_* tests 2017-06-13 18:03:01 +03:00
585de501da Embed local_counted_base in the deleter in the pointer case 2017-06-13 17:27:06 +03:00
420626d6d9 Add weak_ptr.adoc 2017-06-13 06:34:16 +03:00
ab99c8f7aa Reflect unique_ptr constructor change 2017-06-13 05:56:19 +03:00
0eb6ad145d Merge branch 'develop' into feature/asciidoc 2017-06-13 05:51:51 +03:00
1d314c5668 Make null unique_ptr convert to empty shared_ptr 2017-06-13 05:50:40 +03:00
5b7d3c08ab Small fix to enable_shared_from_this.adoc 2017-06-13 02:51:02 +03:00
f770e53989 More history 2017-06-13 02:22:51 +03:00
c4d07defcd Add .gitignore 2017-06-13 01:46:50 +03:00
65e616c90b Add a history item for the N1450 formal proposal 2017-06-13 01:45:18 +03:00
f90b418460 Add enable_shared_from_this.adoc 2017-06-13 01:34:31 +03:00
bd2474e7f3 Add shared_ptr.adoc 2017-06-12 20:06:12 +03:00
a88d8b5b29 Add pointer_to_other.adoc 2017-06-12 18:20:54 +03:00
213c00aed7 Merge branch 'develop' into feature/asciidoc 2017-06-12 18:07:46 +03:00
52d976fde2 Use BOOST_SP_NOEXCEPT, BOOST_SP_NOEXCEPT_WITH_ASSERT 2017-06-12 18:06:54 +03:00
a6031ff8e2 Add scoped_array.adoc 2017-06-12 16:53:57 +03:00
239fe204de Merge branch 'develop' into feature/asciidoc 2017-06-12 15:54:44 +03:00
e75fa9329b Remove noexcept on ~local_counted_base for g++ 4.7 2017-06-12 15:53:16 +03:00
3b16e1cc3e Add intrusive_ptr.adoc 2017-06-12 05:17:34 +03:00
392b3c76f0 Add techniques.adoc 2017-06-12 04:06:27 +03:00
dea4e8129d Complete scoped_ptr.adoc 2017-06-12 03:12:03 +03:00
0dfb4dad0f Start rewriting documentation in asciidoc 2017-06-12 01:58:08 +03:00
aec76051f8 Merge branch 'feature/local_shared_ptr' into develop 2017-06-12 00:52:33 +03:00
8f2e6d04de Add more tests 2017-06-12 00:19:07 +03:00
8d9c4df71a Add more tests 2017-06-11 20:35:51 +03:00
b18f68324f Add more tests 2017-06-05 16:38:41 +03:00
aeadd6aeff Initial commit of local_shared_ptr 2017-06-04 21:24:20 +03:00
3c47079f4d Merge branch 'develop' 2017-06-04 19:08:05 +03:00
ca9cb71e86 Merge pull request #39 from Teemperor/ReencodeAsUtf8
Reencoded a few headers that used Windows-1252 with UTF-8.
2017-06-02 23:08:35 +03:00
ba98b8c33f Reencoded a few headers that used Windows-1252 with UTF-8.
Nearly every header in the boost codebase is UTF-8, but here there
are a few headers which are using Windows-1252, which makes it impossible
for some tools to parse those files. This patch just reencodes them
with UTF-8 like the rest of the codebase. I checked that the name of the
author is still correct after this change.

No functional change intended.
2017-06-02 14:51:53 +02:00
3160cbb2e3 Merge branch 'master' of https://github.com/boostorg/smart_ptr 2017-06-01 03:28:39 +03:00
bfa3752ad7 Merge branch 'develop' 2017-06-01 03:28:21 +03:00
e9010baaf5 Merge branch 'Belcourt-develop' into develop 2017-05-27 03:02:32 +03:00
b530ffcae5 Remove redundant check; add coment; include config.hpp 2017-05-27 03:01:34 +03:00
7f42d987e7 Protect clang pragmas with BOOST_CLANG macro. 2017-05-26 12:33:59 -06:00
469015992a Merge branch 'develop' 2017-05-02 08:57:13 -04:00
33b18c7da0 Reformat (line wrap at 80 characters) 2017-05-02 08:12:25 -04:00
596adfc69a Merge branch 'develop' 2017-05-01 13:50:49 +03:00
e99e722fa5 Add alternative sp_array_construct for trivially destructible case 2017-04-30 19:20:57 -04:00
7ef8fa4a19 Fix lwm_win32_cs.hpp for Clang 2017-04-24 19:53:24 +03:00
9081dc5573 Add lwm_win32_cs_test 2017-04-24 19:52:57 +03:00
0043228495 Add clang-3.9/linux, c++1z/osx to Travis 2017-04-24 19:52:37 +03:00
6bdd3fde65 Add alternative sp_array_construct for trivially destructible case 2017-04-23 01:42:15 -04:00
3568e093bb Fix lwm_win32_cs.hpp for Clang 2017-04-16 21:38:29 +03:00
acb29ad6f3 Add lwm_win32_cs_test 2017-04-16 21:02:07 +03:00
d2c1ed0ed5 Add clang-3.9/linux, c++1z/osx to Travis 2017-04-16 00:18:24 +03:00
0085752a56 Merge branch 'develop' 2017-03-13 19:19:40 -04:00
d7ad42724d Revert Appveyor changes. 2017-03-13 19:42:39 +02:00
83d3f07b0d Fourth try to obtain bootstrap.log from Appveyor 2017-03-13 19:02:57 +02:00
994f39f9b0 Third try to obtain bootstrap.log from Appveyor 2017-03-13 18:47:38 +02:00
f45dd4d955 Second try to obtain bootstrap.log from Appveyor 2017-03-13 18:36:52 +02:00
b4abcdb016 Try to obtain bootstrap.log from Appveyor 2017-03-13 18:29:04 +02:00
25cf644f60 Merge pull request #37 from glenfe/develop
Add examples back to documentation
2017-03-13 11:22:06 -04:00
71ef7850ab Add examples back to documentation 2017-03-13 10:59:58 -04:00
40c0ddcbd6 Merge pull request #36 from boostorg/develop
Merge documentation changes
2017-03-10 13:32:44 -05:00
687d31b7c8 Update documentation in make_unique.html 2017-03-10 11:55:06 -05:00
fac6fbe3cf Update documentation in make_shared_array.html 2017-03-10 10:21:21 -05:00
d3b9ee7d24 Merge branch 'develop' 2017-03-06 08:59:03 -05:00
650537da60 Update unit tests for make_unique 2017-03-06 08:36:57 -05:00
324347b9ec Update unit tests for shared array functions 2017-03-06 01:18:16 -05:00
79e675c727 Merge branch 'develop' 2017-03-05 22:09:34 -05:00
6ef791c715 Rename identifiers in allocate and deallocate 2017-03-05 22:07:58 -05:00
15ed558a29 Further simplify alignment logic in allocate 2017-03-05 21:39:22 -05:00
106ada7770 Remove unnecessary helper function 2017-03-05 19:13:26 -05:00
9f70f6619f Do not rely on size of type_with_alignment 2017-03-05 19:10:56 -05:00
494c0cd2c0 Merge branch 'develop' 2017-03-04 23:43:49 -05:00
8c058dfeee Use BOOST_NOEXCEPT_OR_NOTHROW over BOOST_NOEXCEPT 2017-03-04 23:36:24 -05:00
0807efa91a Merge branch 'develop' 2017-03-04 01:09:35 -05:00
bea0fc4a37 Update make_shared_array documentation 2017-03-04 01:07:43 -05:00
3f21bac34f Merge pull request #35 from boostorg/develop
Merge develop
2017-03-03 13:23:35 -05:00
7beb91fd0e Merge branch 'glenfe-allocate_shared' into develop 2017-03-02 06:06:35 +02:00
d1bb87d34e Remove the now unnecessary allocate hint parameter 2017-03-01 13:15:23 -05:00
7570340d70 Add test for allocator construct usage 2017-03-01 13:03:14 -05:00
b42acf77b3 Only use allocator construct/destroy for value_type, not shared_count 2017-03-01 06:18:06 -05:00
1f9c63c34f Fix MSVC parsing problem in allocate_shared_array 2017-03-01 12:08:17 +02:00
f8524c42a8 Add test for a MSVC parsing problem in make_shared 2017-03-01 12:02:30 +02:00
52fbf70879 Special case aligning up sizes and change integral constant style 2017-02-28 19:23:02 -05:00
fb59cd574e Copy rebind allocator before impl destruct 2017-02-28 07:21:49 -05:00
c749052162 Merge pull request #33 from glenfe/allocate_shared_array
Revise make_shared and allocate_shared for arrays
2017-02-28 04:26:20 -05:00
970e88897c Revise make_shared and allocate_shared for arrays 2017-02-28 03:47:09 -05:00
609de5d711 Merge branch 'develop' 2017-02-25 19:30:08 +02:00
d641b9c436 Merge pull request #32 from pgroke-dt/z_OS_XL_C++_support
don't define BOOST_SP_HAS_SYNC for z/OS XL C/C++ compiler
2017-02-25 13:38:33 +02:00
3bb4e4d2df don't define BOOST_SP_HAS_SYNC for z/OS XL C/C++ compiler 2017-02-25 05:44:04 +01:00
5ab9a77d50 Merge branch 'develop'
Conflicts:
	.travis.yml
2017-02-16 15:37:26 +02:00
b80ffbeb3d Remove tools/inspect from appveyor.yml 2017-02-16 15:35:53 +02:00
5f8c2a7ee0 Remove tools/inspect from .travis.yml 2017-02-16 15:34:51 +02:00
94634cb853 Only install necessary packages in .travis.yml to speed it up 2017-02-07 01:50:59 +02:00
17a07a228e Add platform matrix to .travis.yml 2017-02-06 21:32:51 +02:00
d4bc4c9733 Add platform matrix to .travis.yml 2017-02-06 16:51:33 +02:00
1d7f6b9bfd Merge pull request #31 from gongminmin/ClangC2
Fix compiling problems under ClangC2.
2017-02-06 15:26:24 +02:00
d718d21d6b Fix compiling problems under ClangC2. 2017-02-05 15:51:42 -08:00
39b14fa0d6 Merge branch 'develop' 2017-01-01 04:10:26 +02:00
19147212a9 Merge pull request #29 from cdglove/rvalue_casts
Add rvalue versions of static_pointer_cast, const_pointer_cast, dynamic_pointer_cast, reinterpret_pointer_cast.
2016-12-12 05:45:17 +02:00
53928bcc12 Merge pull request #30 from cdglove/reinterpret_pointer_cast_test
Add explicit tests for reinterpret_pointer_cast
2016-12-12 05:42:29 +02:00
9e568dad6e Add explicit tests for reinterpret_pointer_cast. Based on existing pointer_cast tests in shared_ptr_test.cpp 2016-12-11 22:18:57 -05:00
ebd1788f2c Add test for rvalue reinterpret_pointer_cast. 2016-12-11 21:18:18 -05:00
3e2ac10e94 Add rvalue versions of static_pointer_cast, const_pointer_cast, dynamic_pointer_cast, reinterpret_pointer_cast.
Aligns with proposed addition to std:: here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0390r0.htm
2016-12-11 15:38:34 -05:00
61075bb9df Move extra files to extras/ as the src/ and test/ directories are scanned for dependencies 2016-11-10 15:04:21 +02:00
3e61a63f60 Use throw() in place of noexcept on msvc-11.0,12.0 for the standard nothrow traits 2016-11-08 18:42:51 +02:00
a7fbb0a841 Do not use components removed in C++17 (auto_ptr, binary_function) 2016-11-06 15:35:46 +02:00
1e9e2ed6aa Merge branch 'develop' 2016-09-30 16:06:15 +03:00
bdc19dee01 Merge branch 'feature/unique_ptr_casts' into develop 2016-09-10 21:09:05 +03:00
3aa720714d Update documentation. 2016-09-10 20:57:35 +03:00
94a04e57fb Merge branch 'develop' into feature/unique_ptr_casts 2016-09-10 20:28:14 +03:00
776b33ec09 Merge pull request #26 from muggenhor/make_shared-constructor-forwarding
Add test for make_shared's move-emulation support
2016-09-10 20:27:12 +03:00
5595622c3e Relax dynamic_cast check; rephrase const_cast test to be more MSVC-friendly. 2016-09-10 20:18:37 +03:00
2ae3e4ba44 Remove static_pointer_cast restriction; test dynamic cross cast. 2016-09-10 20:07:47 +03:00
b5498d944e Add test for make_shared's move-emulation support
This tests the functionality added with PR boostorg/smart_ptr#24.

Specifically this tests that passing moveable-only types to
constructors is possible through make_shared. Note that real rvalue's
still cannot be passed that way on C++03 unfortunately because there's
no generic way of accomplishing that with current move emulation.
2016-09-10 18:38:37 +02:00
8fac3c9f2f Add one more dynamic_cast test, fold back _test3 into test2. 2016-09-10 19:15:47 +03:00
a14515a364 Add negative pointer cast tests. 2016-09-10 18:43:22 +03:00
190c06e25d Add tests for unique_ptr casts. 2016-09-10 17:55:14 +03:00
62a8a9d6cc Merge branch 'karo/unique_ptr_casts' of https://github.com/koraa/smart_ptr into feature/unique_ptr_casts 2016-09-10 14:48:26 +03:00
48401806f4 Merge branch 'make_shared-constructor-forwarding' of https://github.com/muggenhor/boost-smart_ptr into develop 2016-09-10 14:24:52 +03:00
02de302774 Merge branch 'suppress-weak-vtables-warning' of https://github.com/Kojoley/smart_ptr into develop 2016-09-10 13:55:20 +03:00
80597b379e Copy repo instead of doing a checkout, for pull requests. 2016-09-10 13:47:05 +03:00
840e9fc96e Apply MIPS16 patch from ticket #12418 2016-09-02 20:13:15 +03:00
70367e848e Suppress weak vtables warnings 2016-08-31 17:32:09 +03:00
e8daeaee1c Enable Travis notifications on success 2016-08-28 22:37:10 +03:00
3b9ae9fd5f Switch from msvc-12.0 to msvc-14.0 on Appveyor 2016-08-28 22:01:59 +03:00
20fedcff2c Use <atomic> by default when BOOST_NO_CXX11_HDR_ATOMIC is not defined 2016-08-28 21:28:21 +03:00
de38a735ea boost::make_shared: use Constructor Forwarding on C++03
Use Boost.Move's move emulation and documented Constructor Forwarding
technique to provide (partial) constructor forwarding on compilers that
don't support r-value references.

This allows constructing types taking movable-but-not-copyable types as
constructor arguments. Additionally it's generally more efficient for
movable-and-copyable types, but that's just a nice-to-have.
2016-07-25 15:02:57 +02:00
ce52fb1045 pointer_casts with move semantics for unique_ptr 2016-06-06 16:08:26 +02:00
6b787f1cec Add overloads for std::shared_ptr to pointer casts 2016-06-06 14:51:44 +02:00
2185c4f005 Fix a documentation typo 2016-06-05 23:32:45 +02:00
6d5f554baa Reuse code for plain and shared in ptr cast tests 2016-06-05 23:32:45 +02:00
f3279d24b4 Merge branch 'develop' 2016-05-21 22:45:34 +03:00
c87b6e8af8 Add .travis.yml 2016-05-21 22:07:23 +03:00
aaded4f85c Merge branch 'develop' 2016-05-21 20:48:54 +03:00
eb1a002e34 Create README.md 2016-05-21 19:34:15 +03:00
3304a56101 Merge branch 'develop' 2016-05-21 18:55:46 +03:00
181f38682f Add appveyor.yml. 2016-05-21 18:23:41 +03:00
5b1a8412c3 Merge branch 'develop' 2016-05-21 01:11:22 +03:00
e52905cf3c Add intrusive_ptr converting move assignment. 2016-05-17 18:43:41 +03:00
b7f99ceba6 Update intrusive_ptr_move_test with converting move construction. 2016-05-17 18:36:50 +03:00
a7ade6f062 Remove unnecessary #ifdef 2016-05-17 18:34:18 +03:00
097d2e9bf9 Merge branch 'intrusive_ptr_move' of https://github.com/jtwang83/smart_ptr into develop 2016-05-17 18:29:29 +03:00
d44a78d671 Merge branch 'develop' 2016-05-17 18:10:45 +03:00
582eb63cb3 Merge pull request #18 from joachim-faulhaber/smart_ptr_patches_1_59_0
Warning fixes: Conversion and unused parameter warnings
2016-05-17 18:07:32 +03:00
181b449a57 Merge branch 'develop' 2016-05-17 18:01:36 +03:00
da8de3e95b Merge pull request #19 from Lastique/patch-4
Make the default  intrusive_ptr constructor constexpr
2016-05-17 17:59:10 +03:00
6c27833099 Merge branch 'develop' 2016-05-17 17:46:15 +03:00
83e6e00456 Merge branch 'develop' 2016-04-13 08:01:21 -04:00
522f6c1869 Add more aliasing move test cases, add alias move reset 2016-04-13 14:31:43 +03:00
cd8de9d4a6 Merge branch 'move-alias' of https://github.com/uecasm/smart_ptr into develop 2016-04-13 13:29:50 +03:00
e26542272d Use remove_reference in make_unique implementation 2016-02-19 08:14:02 -05:00
e13beef5df Fix formatting in headers and tests 2016-02-19 08:13:54 -05:00
8298952a12 Update unit tests for make_shared/allocate_shared for arrays
Before pending refactor of make_shared and allocate_shared for arrays.
2016-02-19 08:13:41 -05:00
821925c536 Refactor make_unique implementations
Before the pending refactor of make_shared/allocate_shared for arrays.
2016-02-19 08:13:27 -05:00
427124543b Use remove_reference in make_unique implementation 2016-02-19 08:09:25 -05:00
46f00ea993 Fix hash support for shared_ptr<T[]>, <T[N]> 2016-02-08 20:47:52 +02:00
4473bf8ec2 Fix hash support for shared_ptr<T[]>, <T[N]> 2015-12-15 19:13:20 +02:00
7a7ac4512e Fix formatting in headers and tests 2015-11-11 01:26:15 -05:00
38b6334e36 Update unit tests for make_shared/allocate_shared for arrays
Before pending refactor of make_shared and allocate_shared for arrays.
2015-11-09 22:35:34 -05:00
7af503d3bb Refactor make_unique implementations
Before the pending refactor of make_shared/allocate_shared for arrays.
2015-11-08 11:02:06 -05:00
4db7219c32 Merge branch 'develop' 2015-10-27 20:12:16 +02:00
3f17244225 Removed the intrin.h-related part
Removed the commented part as the comment clearly says that VC9 has problems when intrin.h is included.
2015-10-18 19:44:17 +02:00
ca93749614 Support MSVC-7.1/ intrin.h available >= MSVC-8.0
-> MSVC 7.1 has no intrin.h and needs to use "#pragma intrinsic".
-> intrin.h available since Visual 2005
2015-10-18 12:51:13 +02:00
05d5a4e9a0 Added shared_ptr aliasing move constructor.
Signed-off-by: Gavin Lambert <github@mirality.co.nz>
2015-10-12 18:19:22 +13:00
970a179ac2 Make the default constructor constexpr 2015-10-05 18:24:52 +03:00
a06123eb87 Merge branch 'develop' 2015-09-28 15:51:01 +03:00
fd543d3292 Warning fixes: Conversion and unused parameter warnings 2015-09-24 14:53:40 +02:00
df90496583 Disable deprecation warnings on g++/clang 2015-09-10 23:45:47 +03:00
20ead68473 Merge branch 'develop' 2015-08-18 21:09:05 +03:00
79cde147c9 Merge pull request #17 from jzmaddock/patch-1
Disable explicit operator bool on Oracle C++
2015-08-18 20:54:50 +03:00
abbe975e8f Disable explicit operator bool on Oracle C++
Although Oracle supports this syntax, advanced usage such as:

if(my_shared_ptr && x)

Fail.  Attempts to wokaround by adding additional operator overloads have so far failed.
2015-08-18 18:14:50 +01:00
8ba0730686 Merge pull request #16 from eldiener/sleep_fix_2
Change to Sleep declaration for clang on Windows to match Windows imp…
2015-07-23 01:52:03 +03:00
686efe100b Updated Sleep declaration only includes _mingw.h when needed. 2015-07-22 18:23:43 -04:00
acb880d8c2 Change to Sleep declaration for clang on Windows to match Windows implementation being used 2015-07-22 06:51:49 -04:00
1712b87cb6 Added __declspec(dllimport) for Sleep using clang on Windows. 2015-07-21 15:41:35 -04:00
f8943703f8 Merge branch 'develop' 2015-06-06 01:40:42 +03:00
a42dda0af4 Apply fix for errata 754327 for ARM Cortex-A9 suggested in ticket #11362 2015-06-06 01:40:01 +03:00
9b9b6d3ca6 Merge branch 'develop' 2015-05-12 20:13:50 +03:00
d875a68ceb Add constructor/assignment taking boost::movelib::unique_ptr 2015-05-04 01:06:42 +03:00
8cb2c56556 Merge branch 'develop' 2015-03-20 15:04:59 +02:00
290fe82a43 Merge pull request #14 from Bjoe/changes
Fix bug ticket 11131
2015-03-20 03:02:09 +02:00
94824c807f Add missing std:: namespace 2015-03-20 00:23:58 +01:00
334654de06 intrusive_ptr: add converting ctor for intrusive_ptr<U> with move semantics. Analagous to
template <class U> intrusive_ptr(intrusive_ptr<U> const&)
2015-03-15 20:17:55 -04:00
0ab0e6eecc Merge branch 'develop' 2015-03-02 16:11:06 +02:00
effc9f73d6 Merge pull request #12 from Theodor/size_t_fix_11066
Add <cstddef> include. fixes #11066
2015-03-02 15:53:36 +02:00
99762e7dde Add <cstddef> include. fixes #11066 2015-03-01 23:14:28 +04:00
add539142b Merge branch 'develop' 2015-01-28 13:03:43 +02:00
e067fd2cfd Fix comment. 2015-01-28 13:03:23 +02:00
212528860a Merge branch 'develop' 2015-01-28 12:52:40 +02:00
711c36958a Add an additional weak_from_raw test. 2015-01-28 12:52:10 +02:00
7104e7dc7e Add weak_from_this. 2015-01-25 20:10:57 +02:00
254bda34b7 Merge branch 'develop' 2015-01-25 18:26:07 +02:00
3fd53ced83 Make shared_from_raw and weak_from_raw return consistent values in a constructor, regardless of order, as suggested by Gavin Lambert in #8. 2015-01-22 20:47:01 +02:00
75de3dbcf1 Add clang-specific sp_counted_base. 2015-01-22 05:13:27 +02:00
7faec4265b Fix conflicts with the I macro in <complex.h>. 2015-01-21 19:55:42 +02:00
c81d0806e4 Merge branch 'develop' 2015-01-16 20:53:48 +02:00
a74329794c Fix ambiguous 'detail' errors under msvc-8.0. 2015-01-16 20:53:27 +02:00
71756350d9 Merge branch 'develop' 2015-01-15 22:00:17 +02:00
f65c57d9d2 Fix explicit instantiation regression 2014-11-12 19:04:29 +02:00
b1fc261fe6 Merge branch 'develop' 2014-08-21 23:48:32 +03:00
aedcf3ccda Merge pull request #11 from danieljames/metadata
Create metadata file.
2014-08-21 13:21:23 +03:00
a1a5999a38 Add metadata file. 2014-08-18 15:10:40 +01:00
8afd3bee69 Merge branch 'develop' 2014-08-10 21:24:41 +03:00
2a56c73924 Add weak_from_raw_test2.cpp. 2014-08-09 13:50:38 +03:00
720ce12a25 Add shared_from_raw_test6.cpp. 2014-08-09 13:42:51 +03:00
2be09db523 Merge branch 'develop' 2014-08-09 13:16:34 +03:00
de10be8560 Fix sp_nullptr_test for compilers that don't define std::nullptr_t. 2014-08-09 12:28:28 +03:00
7b71068b52 Extend nullptr_t workaround to Intel C++. 2014-08-09 00:26:00 +03:00
6b562cb5b1 Rename enable_shared_from_raw_test.cpp to weak_from_raw_test.cpp. 2014-08-08 21:28:15 +03:00
3d2c230623 Rename esft_constructor_test.cpp to shared_from_raw_test5.cpp. 2014-08-08 21:24:20 +03:00
553c7994ba Avoid potential conflict between AIX's and Lambda's var.
In ../boost/lambda/detail/lambda_functor_base.hpp there is variable called var that conflicts with an AIX system variable. The entire file (sched.h) does not need to be included only the one function it uses (sched_yield).
2014-08-08 16:03:40 +03:00
280aadfcdb Fix compilation problems with clang
Apparently, clang presents itself as gcc 4.2 even though it supports the final version of rvalue references. Restrict the workaround to gcc only.
2014-08-08 16:03:13 +03:00
59ac922a1c Revert "Revert "Fix warnings on gcc 4.4""
This reverts commit d28b0d07fc.
2014-08-08 16:02:08 +03:00
8de3e84021 Fix shared_from_raw_test4 failures. 2014-08-06 21:28:03 +03:00
bd4f9c239a Add shared_from_raw tests. 2014-08-06 21:07:52 +03:00
528195233b Merge branch 'aix_fix' of https://github.com/ibmsoe/smart_ptr into develop 2014-07-30 17:51:32 +03:00
8c49f5a637 Avoid potential conflict between AIX's and Lambda's var.
In ../boost/lambda/detail/lambda_functor_base.hpp there is variable called var that conflicts with an AIX system variable. The entire file (sched.h) does not need to be included only the one function it uses (sched_yield).
2014-07-30 09:23:21 -05:00
0bab2cc658 Rename member because _CRTDBG_MAP_ALLOC in VS does not allow it
_CRTDBG_MAP_ALLOC has issues with member functions named "free".
2014-07-25 23:44:34 -07:00
88f0a98d71 Rename member because _CRTDBG_MAP_ALLOC in VS does not allow it
_CRTDBG_MAP_ALLOC has issues with member functions named "free".
2014-07-25 20:33:29 -07:00
96d82e0275 Merge pull request #6 from Lastique/patch-3
Fix compilation problems with clang
2014-07-16 16:31:22 +03:00
40387ef654 Fix compilation problems with clang
Apparently, clang presents itself as gcc 4.2 even though it supports the final version of rvalue references. Restrict the workaround to gcc only.
2014-07-16 16:43:35 +04:00
d28b0d07fc Revert "Fix warnings on gcc 4.4"
This reverts commit b1beb11a45.
2014-07-16 15:24:17 +03:00
1c83d65701 Merge branch 'develop' 2014-07-15 13:06:44 +03:00
1d41a328f7 Merge pull request #5 from Lastique/patch-2
Fix warnings on gcc 4.4
2014-07-15 12:30:54 +03:00
b1beb11a45 Fix warnings on gcc 4.4
Added a special version of sp_forward for an outdated version of rvalue references supported by gcc 4.4. The compiler would create a temporary and return an rvalue reference to it in the original code. This resulted in warnings about 'returning reference to temporary'.

The added version is similar to std::forward on that compiler, except it doesn't prohibit template argument deduction (which is in line with the original sp_forward).
2014-07-14 22:33:16 +04:00
bf3e9cc7af -Wshadow fixes. 2014-07-12 20:35:14 +03:00
506239bef5 Merge branch 'develop' 2014-06-11 22:30:00 +03:00
d6841e6d71 Remove trailing whitespace. 2014-06-11 22:29:15 +03:00
56ae9f86c1 Merge pull request #4 from stgates/winrt
[winrt support] Replacing banned APIs Sleep and InitializeCriticalSection
2014-06-11 22:12:25 +03:00
1a74757cfa Adding missing include for boost\predef.h. 2014-06-11 11:44:25 -07:00
07e222217b Updating to use BOOST_PLAT_WINDOWS_RUNTIME based on review feedback. 2014-06-11 11:33:03 -07:00
71c9165119 Replacing banned APIs Sleep and InitializeCriticalSection for Windows store and phone. 2014-06-10 22:07:51 -07:00
f32669400c Remove headers moved into core. 2014-06-03 20:25:38 +03:00
b550e028f5 Move boost/memory_order.hpp to Boost.Atomic 2014-05-20 23:33:03 +03:00
ed2eaddc5d Check BOOST_NO_CXX11_RVALUE_REFERENCES in tests that use std::unique_ptr. 2014-05-15 18:51:27 +03:00
d523c3423e Use Boost.Align for alignment 2014-05-04 08:20:37 -07:00
1968d17d2f Use add_rvalue_reference in make_unique overload 2014-03-12 20:27:36 -07:00
e1e99c5ba3 Merge pull request #3 from Lastique/patch-1
Fix warnings about struct/class mismatch
2014-03-08 10:36:20 -08:00
d586469d60 Fix warnings about struct/class mismatch
ms_allocator_state template was declared as class but its specializations were as structs. This caused Clang 3.2 warnings. The commit changes ms_allocator_state declaration to struct to fix that.
2014-03-08 18:31:31 +03:00
fbb851097f Disable the std::atomic spinlock implementation on Clang 2014-03-01 02:14:56 +02:00
75add10b1d Simplify ms_allocator and as_allocator design 2014-02-28 10:19:50 -08:00
71b2f87e35 Merge branch 'develop' 2014-02-26 15:10:01 +02:00
c759321782 Remove interlocked.hpp, was left behind by the merge 2014-02-26 14:57:59 +02:00
3e625c07e8 Switch to sp_interlocked.hpp 2014-02-25 01:32:19 +02:00
7ff1c65494 Merge branch 'develop' 2014-02-24 20:34:18 +02:00
75cab39801 Drop the BOOST_NO_CXX11_STD_ALIGN-undefined path
Until the merge of Boost.Config develop to master
2014-02-24 08:35:59 -08:00
38cb523713 Derive empty base optimization from rebound allocator 2014-02-18 00:16:57 -08:00
5f1d4eae4f Factor out alignment code into sp_align 2014-02-16 12:15:29 -08:00
adc0cdddff Make as_allocator::deallocate consistent 2014-02-14 18:31:52 -08:00
dcfa031de7 Do not include sp_interlocked.hpp when not on Windows 2014-02-13 12:51:23 +02:00
8c9e8b5556 Further simplification of ms_allocator 2014-02-12 22:15:15 -08:00
d9333e5375 Simplify array_allocator; update documentation 2014-02-12 19:34:56 -08:00
3d279e6c6d Save additional sizeof(void*) bytes for arrays 2014-02-12 13:52:58 -08:00
c003fba3a0 Renamed, cleaned up interlocked.hpp; added test 2014-02-12 20:48:35 +02:00
0c29e86728 Add spinlock_std_atomic.hpp 2014-02-12 20:20:56 +02:00
016af907bd Make sp_counted_impl_ specialization more generic 2014-02-12 08:46:59 -08:00
0337743c8c Revert "Remove obsolete MSVC check from pragma guard"
This reverts commit b7ee788845.
2014-02-12 16:57:45 +02:00
208bfd78f9 Move interlocked.hpp to smart_ptr/detail 2014-02-12 16:42:24 +02:00
2c32bf91b7 Add BOOST_USE_INTRIN_H support; remove #pragma intrinsic, not needed and not supported on Intel.
[SVN r85994]
2014-02-12 16:41:23 +02:00
b7ee788845 Remove obsolete MSVC check from pragma guard
git grep -h -B1 "^#\s*pragma once" | grep -v pragma | sort | uniq

is now clean.

[SVN r85952]
2014-02-12 16:41:22 +02:00
a56378ee35 Enabled #pragma once for all compilers that support it, not only MSVC.
[SVN r85866]
2014-02-12 16:41:22 +02:00
443302306e Fixed compilation problems with MinGW-w64.
[SVN r85865]
2014-02-12 16:41:21 +02:00
f5402a937e Fix the _WIN32_WCE >= 0x600 case.
[SVN r80935]
2014-02-12 16:41:21 +02:00
fe04bea979 Fix: intrin.h is available in msvc-9.0 (_MSC_VER 1500)
[SVN r80626]
2014-02-12 16:41:21 +02:00
8fbb5e9e7f Thread: Try again to fix 5431
[SVN r80127]
2014-02-12 16:41:20 +02:00
0401afc106 Thread: Rollback last modification as it breaks regression test VeecoFTC/msvc-9.0~wm5~stlport5.2
[SVN r80067]
2014-02-12 16:41:20 +02:00
b69ca7aaa5 Thread: Try to fix 5431
[SVN r80042]
2014-02-12 16:41:19 +02:00
dffbf7c931 Use <intrin.h> for VS2010+. Refs #4678.
[SVN r75396]
2014-02-12 16:41:19 +02:00
5dabdf635c Applied patch from issue #4849
[SVN r70383]
2014-02-12 16:41:19 +02:00
3dbde36076 Applied patch from issue #3377
[SVN r62509]
2014-02-12 16:41:18 +02:00
97a9aac5f0 Fix interlocked.hpp to compile under /clr:pure. Refs #3378.
[SVN r57958]
2014-02-12 16:41:17 +02:00
bd5b684fd3 Move smart_ptr into boost/smart_ptr/*.hpp (refs #2239).
[SVN r51509]
2014-02-12 16:41:17 +02:00
6ede4ec4c6 Factored out boost/detail/lightweight_thread.hpp.
[SVN r44638]
2014-02-12 16:41:16 +02:00
aab1328e06 spinlock_nt.hpp added, Cygwin fixes.
[SVN r44055]
2014-02-12 16:41:16 +02:00
451c71c1bd Added changes from David Deakins to enable compilation on Windows CE
[SVN r40679]
2014-02-12 16:41:16 +02:00
6341b8802a Windows CE patch by Michael Fink
[SVN r33986]
2014-02-12 16:41:15 +02:00
e274885fd2 Win32 implementation of boost::timed_mutex
[SVN r33272]
2014-02-12 16:41:15 +02:00
82fe5f5095 Fixed a couple of syntax errors (reported by Juergen Hunold)
[SVN r31946]
2014-02-12 16:41:14 +02:00
8c50214e3f Fixed bug #1370716, static shared_ptr instances not working w/ quick_allocator
[SVN r31931]
2014-02-12 16:41:14 +02:00
21198d07fd Moved BOOST_INTERLOCKED_READ stuff into its own header
[SVN r31098]
2014-02-12 16:41:14 +02:00
b4c8cf3958 Removed :: qualification on _Interlocked functions
[SVN r31097]
2014-02-12 16:41:13 +02:00
77aeaee7a7 Added BOOST_INTERLOCKED_EXCHANGE_POINTER in all branches of the #if
[SVN r31012]
2014-02-12 16:41:13 +02:00
677a0777d2 Added InterlockedExchangePointer
[SVN r31010]
2014-02-12 16:41:12 +02:00
7c7250379b InterlockedCompareExchangePointer is only intrinsic on 64 bit platforms, otherwise it's just a synonym for InterlockedCompareExchange
[SVN r30951]
2014-02-12 16:41:12 +02:00
142eb95986 Added interlocked compare/exchange for pointers, and interlocked_read for values and pointers
[SVN r30941]
2014-02-12 16:41:11 +02:00
d9f24f882e New version of call_once for win32
[SVN r30847]
2014-02-12 16:41:11 +02:00
0fd3947e19 <intrin.h> appears broken.
[SVN r27737]
2014-02-12 16:41:10 +02:00
43bc30e576 Split sp_counted_base into no threads (nt), win32 lock-free (w32) and pthreads (pt)
[SVN r27729]
2014-02-12 16:41:10 +02:00
e0ec2a0aaa Converted to Boost Software License, Version 1.0
[SVN r24055]
2014-02-12 16:41:10 +02:00
5320981cbb _MSC_VER use clarified.
[SVN r20992]
2014-02-12 16:41:09 +02:00
d676bac36a -Wundef fixes.
[SVN r18788]
2014-02-12 16:41:09 +02:00
ec1c6ed414 Fixes for Comeau with Borland as backend.
[SVN r17588]
2014-02-12 16:41:08 +02:00
ce36b11fd5 Made the default page size 512 (g++ 2.96 on Red Hat 7.2 dislikes 496.)
[SVN r17272]
2014-02-12 16:41:08 +02:00
eee70bdcab Added BOOST_QA_PAGE_SIZE.
[SVN r17270]
2014-02-12 16:41:07 +02:00
97eed20d9b Quick_allocator updates.
[SVN r17267]
2014-02-12 16:41:07 +02:00
6b6b63ef37 Dave's quick_allocator added, #define BOOST_SP_USE_QUICK_ALLOCATOR to make shared_ptr use it.
[SVN r17087]
2014-02-12 16:41:07 +02:00
1bdabdb96b Move interlocked.hpp to smart_ptr/detail 2014-02-12 16:39:56 +02:00
0876e67ac7 Merged revision(s) 85994 from trunk: Add BOOST_USE_INTRIN_H support; remove #pragma intrinsic, not needed and not supported on Intel. Refs #6646. Refs #7318. Refs #9174.
[SVN r86416]
2014-02-12 16:37:26 +02:00
fdcb2572a3 Merged latest changes from trunk.
[SVN r85988]
2014-02-12 16:37:26 +02:00
71d99e89e9 Merged revision(s) [80935] from trunk: Fix the _WIN32_WCE >= 0x600 case.
[SVN r80960]
2014-02-12 16:37:25 +02:00
2dc506f4bc Thread: Updated from trunk 1.52
[SVN r80473]
2014-02-12 16:37:25 +02:00
7161dc5842 Merge [75396] to release. Fixes #4678.
[SVN r75757]
2014-02-12 16:37:25 +02:00
ec97270c01 Merged fix for issue #4849 from trunk (fix boost.thread on mingw64) (authorized by rene)
[SVN r72657]
2014-02-12 16:37:24 +02:00
b7a759f00f Merge [57958] to release. Fixes #3378.
[SVN r58069]
2014-02-12 16:37:24 +02:00
4f2392ffa5 Merge [51509], [51519] to release. Closes #2239.
[SVN r51531]
2014-02-12 16:37:23 +02:00
80a06c8883 Merged 44595, 44638, 44707, 44711, 44728 from trunk to release
[SVN r47341]
2014-02-12 16:37:23 +02:00
d0a458616f Merged 43316, 43317, 43318, 43733, 43782, 43873, 43888, 43916, 43950, 44055, 44056, 44058, 44073, 44074, 44132, 44137, 44138, 44140, 44344 from trunk to release
[SVN r47339]
2014-02-12 16:37:21 +02:00
def81b1941 config, detail, filesystem, system, tools, at 41278.
[SVN r41316]
2014-02-12 16:37:21 +02:00
4f276715ce Windows CE patch by Michael Fink
[SVN r33986]
2014-02-12 16:37:20 +02:00
a47bbfe95c Win32 implementation of boost::timed_mutex
[SVN r33272]
2014-02-12 16:37:20 +02:00
90fe855f1b Fixed a couple of syntax errors (reported by Juergen Hunold)
[SVN r31946]
2014-02-12 16:37:20 +02:00
991436303d Fixed bug #1370716, static shared_ptr instances not working w/ quick_allocator
[SVN r31931]
2014-02-12 16:37:19 +02:00
b274ed4cc3 Moved BOOST_INTERLOCKED_READ stuff into its own header
[SVN r31098]
2014-02-12 16:37:18 +02:00
870a989fcf Removed :: qualification on _Interlocked functions
[SVN r31097]
2014-02-12 16:37:18 +02:00
5f7a5a5912 Added BOOST_INTERLOCKED_EXCHANGE_POINTER in all branches of the #if
[SVN r31012]
2014-02-12 16:37:17 +02:00
82db88f4fa Added InterlockedExchangePointer
[SVN r31010]
2014-02-12 16:37:17 +02:00
c8df85434e InterlockedCompareExchangePointer is only intrinsic on 64 bit platforms, otherwise it's just a synonym for InterlockedCompareExchange
[SVN r30951]
2014-02-12 16:37:16 +02:00
68517b43bd Added interlocked compare/exchange for pointers, and interlocked_read for values and pointers
[SVN r30941]
2014-02-12 16:37:16 +02:00
72ac0e8bfd New version of call_once for win32
[SVN r30847]
2014-02-12 16:37:15 +02:00
6c7578e206 <intrin.h> appears broken.
[SVN r27737]
2014-02-12 16:37:15 +02:00
3149446fe8 Split sp_counted_base into no threads (nt), win32 lock-free (w32) and pthreads (pt)
[SVN r27729]
2014-02-12 16:37:14 +02:00
b11d734f73 Converted to Boost Software License, Version 1.0
[SVN r24055]
2014-02-12 16:37:14 +02:00
6f5f8babf4 _MSC_VER use clarified.
[SVN r20992]
2014-02-12 16:37:13 +02:00
7d7f32c3a9 -Wundef fixes.
[SVN r18788]
2014-02-12 16:37:13 +02:00
cb697fe9cb Fixes for Comeau with Borland as backend.
[SVN r17588]
2014-02-12 16:37:12 +02:00
8422135bf2 Made the default page size 512 (g++ 2.96 on Red Hat 7.2 dislikes 496.)
[SVN r17272]
2014-02-12 16:37:12 +02:00
fd60899dfb Added BOOST_QA_PAGE_SIZE.
[SVN r17270]
2014-02-12 16:37:12 +02:00
a11ab16010 Quick_allocator updates.
[SVN r17267]
2014-02-12 16:37:11 +02:00
9b9cad3f5b Dave's quick_allocator added, #define BOOST_SP_USE_QUICK_ALLOCATOR to make shared_ptr use it.
[SVN r17087]
2014-02-12 16:37:11 +02:00
7ce5b6b2a9 Fix use of ms_init in no C++11 allocator case 2014-02-11 08:39:52 -08:00
7e3ae44bc2 Fix use of size in make_shared for arrays 2014-02-10 21:09:13 -08:00
57dc400fbf Cosmetic changes in make_shared and make_unique 2014-02-10 21:04:41 -08:00
5f485c2952 Spatial optimization for make_shared for arrays
Saves up to sizeof(void*) + sizeof(size_t) bytes for make_shared and saves
sizeof(void*) + sizeof(size_t) + sizeof(A) bytes for allocate_shared where A is the
supplied allocator type.
2014-02-10 20:54:48 -08:00
260af64027 Merge branch 'develop' 2014-02-11 01:29:29 +02:00
f837c7f56c Revert "Merge from branch 'develop' into 'master'"
This reverts commit 83b3b703e0.
2014-02-11 01:29:02 +02:00
54fb49a5be Use typedef A1 (warnings about unused typedefs) 2014-02-09 11:27:22 -08:00
c23bd41c44 Refactor make_shared for arrays
Refactor implementation to later simplify making an optimization [for the C++11
allocator case] for when sp_counted_impl_pda destruction invokes the
allocator's destroy function instead of the type's destructor.
2014-02-07 08:03:47 -08:00
a64cc5c41c Use allocator)traits<>::destroy in sp_counted_impl_pda::destroy 2014-02-07 17:37:00 +02:00
e1f170cd49 Drop variadic templates in unit test for VC11 2014-02-06 17:09:27 -08:00
52a5c422a1 Correct typo in shared_array documentation 2014-02-06 01:40:46 -08:00
d46e3c7cbd Simplify/tidy array_allocator and array_deleter 2014-02-06 01:38:58 -08:00
5008957bd0 Remove type2 tests in a_s_construct_test 2014-02-05 09:10:45 -08:00
6d73b4aa54 Work around VC11 which has broken rebind_traits
VC11 has only partial support for C++11 allocators. For example it has a
non-conforming rebind_alloc and rebind_traits in std::allocator_traits
because it does not support C++11 template aliases.
2014-02-04 23:56:34 -08:00
540149f019 Tidy documentation in smart_ptr 2014-02-04 22:45:58 -08:00
9f5822f427 Add support and test for C++11 construct/destroy in allocate_shared 2014-02-05 02:31:33 +02:00
d229ae870c Subsume zero-argument overload into the variadic one 2014-02-05 01:04:20 +02:00
3ac6dbbf08 Make detail::as_allocator template C++11 friendly 2014-02-04 15:00:24 -08:00
af5141d492 Merge commit 2014-02-05 00:32:36 +02:00
975d04ac62 Merge Jamfile.v2 on git's insistence 2014-02-05 00:29:18 +02:00
90e74511f7 Add support and tests for C++11 minimal allocators 2014-02-05 00:17:34 +02:00
f27b780724 Add unit test for allocate_shared construct case 2014-02-04 13:17:49 -08:00
51ab46a07d Fix use of rebind_traits and rebind_alloc 2014-02-04 12:42:10 -08:00
e8595a05af Fix use of rebind_traits and rebind_alloc 2014-02-04 08:43:36 -08:00
154a274916 Update make_shared for arrays to address 2070
This updates make_shared and allocate_shared for arrays in accordance with
report 2070 which requires that allocator_traits<A2>::construct(a2, ptr,
...) is used for construction and allocator_traits<A2>::destroy(a2, ptr)
is used for destruction instead of placement new and destructor
invocation.
2014-02-04 04:46:03 -08:00
2b033ce05d Improve documentation for make_shared for arrays 2014-02-03 16:42:57 -08:00
63a05a3576 Refactor make_array_helper and array_deleter
Reduce the amount of code in allocate_array_helper, make_array_helper, and
array_deleter using the empty base class optimization technique.
2014-02-03 07:28:01 -08:00
aede0039bf make_unique tests run only for C++11 compilers 2014-01-31 11:01:37 -08:00
72e5fb6fd7 Add fourth form of make_unique for objects
To support initialization syntax that Args&&... cannot forward perfectly.
2014-01-29 17:16:01 -08:00
f91e7e9ce7 Minor documentation corrections 2014-01-29 09:15:47 -08:00
7fef3bb40b Add top-level make_unique.hpp and documentation 2014-01-29 07:25:30 -08:00
ad658fa5ec Update make shared for arrays documentation 2014-01-29 05:49:07 -08:00
83b3b703e0 Merge from branch 'develop' into 'master'
1. Update make_shared for arrays to conform to N3870

Merging 630e4f49f3^..87e5debdc2 from develop to master
2014-01-28 11:28:54 -08:00
7806737b52 Add make_unique for arrays and objects 2014-01-28 03:58:51 -08:00
87e5debdc2 Minor cosmetic changes in make_shared for arrays 2014-01-28 03:40:54 -08:00
db78d9b2be Update make_shared for arrays documentation 2014-01-23 21:16:51 -08:00
630e4f49f3 Update make_shared for arrays to conform to N3870
Update make_shared and allocate_shared for arrays to be confined to the
set of overloads specified in N3870.
2014-01-23 20:40:46 -08:00
a68db557e8 Deboldify, clean up intrusive_ptr.html. 2013-12-26 19:05:54 +02:00
4de3f36839 Add add_ref parameter to intrusive_ptr::reset, add tests for reset. 2013-12-26 18:47:05 +02:00
4e46cb0609 Add one more intrusive_ptr test case. 2013-12-26 18:05:52 +02:00
73153d5797 Add intrusive_ptr<>::detach()
This provides a way to escape from automatic reference counting, and taking
manual control of the reference.  Useful when interfacing to a C API that
expects a pointer with an elevated reference count.

Similar to std::unique_ptr<>::release().
2013-12-26 17:47:28 +02:00
d7fa365843 Remove obsolete _nmt headers. 2013-12-14 00:15:51 +02:00
6e0ee30543 Update atomic_count.hpp to match sp_counted_base.hpp. 2013-12-14 00:01:01 +02:00
fed15ad8c5 Add support for BOOST_SP_USE_STD_ATOMIC 2013-12-13 22:58:09 +02:00
bba3b446bd Check return values of pthread_* calls with BOOST_VERIFY, per #8898 2013-12-12 02:36:33 +02:00
4c8a558982 Check return values of pthread_* calls with BOOST_VERIFY, per #8904. 2013-12-12 01:42:16 +02:00
a41b81f1c8 Added shared_array constructor from nullptr, per #8894. 2013-12-12 01:22:51 +02:00
c103ace77a Merge branch 'master' into develop 2013-12-11 22:53:48 +02:00
04f456f86d Merge pull request #1 from RhysU/patch-1
Spelling: simultaneosly -> simultaneously
2013-12-11 11:01:56 -08:00
3a188af8d6 Spelling: simultaneosly -> simultaneously 2013-12-10 22:09:48 -06:00
b701ed0225 Merge branch 'develop' 2013-12-07 19:37:54 +02:00
5e9bb19688 Merge branch 'master' into develop 2013-12-07 19:26:28 +02:00
a4f853bfbc Revert "SmartPtr: Remove obsolete MSVC version checks."
This reverts commit 7d1c527ac0.
2013-12-07 19:25:05 +02:00
832ed079b9 Revert "Revert MSC_VER changes."
This reverts commit 382fb54a52.
2013-12-07 19:24:44 +02:00
d9b29beebe Revert "Remove obsolete MSVC check from pragma guard"
This reverts commit e4f24e4d3d.
2013-12-07 19:22:43 +02:00
182452e057 Revert "Remove use of obsolete BOOST_NO_TEMPLATED_STREAMS macro."
This reverts commit 14be9eb90f.
2013-12-07 19:21:31 +02:00
5f69684c8f Revert "SmartPointer: Remove obsolete GCC version checks."
This reverts commit 0e6ddb843e.
2013-12-07 19:21:06 +02:00
70ffd2921f Revert "Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION"
This reverts commit 8767b9580e.
2013-12-07 19:20:36 +02:00
00aee2c7dc Revert "Simplify multi-component ifdefs containing BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION"
This reverts commit f5e6e4063e.
2013-12-07 19:20:12 +02:00
85d8056368 Revert "Remove remaining occurances of BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION"
This reverts commit 56b0853887.
2013-12-07 19:19:46 +02:00
106832df66 Merge r86524 (Correct broken links to C++ standard papers); fixes #9212
[SVN r86673]
2013-11-13 03:22:55 +00:00
2549b818c5 Correct broken links to C++ standard papers. Refs #9212.
[SVN r86524]
2013-10-30 12:51:24 +00:00
be06392771 Merged revision(s) 85995 from trunk: Remove #pragma intrinsic( _mm_pause ); not needed, not supported on Intel. Closes #6646, #7318.
[SVN r86417]
2013-10-24 14:05:26 +00:00
56b0853887 Remove remaining occurances of BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
These evaded scripting.

[SVN r86249]
2013-10-11 23:22:36 +00:00
f5e6e4063e Simplify multi-component ifdefs containing BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
[SVN r86248]
2013-10-11 23:20:59 +00:00
8767b9580e Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Process #ifndef...#endif conditions.

[SVN r86244]
2013-10-11 23:15:00 +00:00
0e6ddb843e SmartPointer: Remove obsolete GCC version checks.
[SVN r86063]
2013-09-30 15:57:14 +00:00
14be9eb90f Remove use of obsolete BOOST_NO_TEMPLATED_STREAMS macro.
It was only defined for no-longer-supported-gcc.

[SVN r86062]
2013-09-30 15:56:52 +00:00
fa91b7d020 Remove #pragma intrinsic( _mm_pause ); not needed, not supported on Intel. Refs #6646, #7318.
[SVN r85995]
2013-09-29 11:31:17 +00:00
382fb54a52 Revert MSC_VER changes.
[SVN r85993]
2013-09-29 10:43:15 +00:00
e4f24e4d3d Remove obsolete MSVC check from pragma guard
git grep -h -B1 "^#\s*pragma once" | grep -v pragma | sort | uniq

is now clean.

[SVN r85952]
2013-09-26 13:02:51 +00:00
7d1c527ac0 SmartPtr: Remove obsolete MSVC version checks.
[SVN r85929]
2013-09-26 09:39:50 +00:00
fc20a29c99 Merged changes from trunk: added intrusive_ref_counter.
[SVN r85609]
2013-09-08 17:17:18 +00:00
0dc1faa6d3 Disabled bogus MSVC warning.
[SVN r85575]
2013-09-05 17:23:33 +00:00
7b9354fcf3 Changed intrusive_ref_counter to follow CRTP design.
[SVN r85547]
2013-09-01 21:05:14 +00:00
a7d96b4762 Extracted intrusive_ref_counter from Boost.Log. The extracted version supports customizing the reference counter nature, two policies provided: thread_unsafe_counter and thread_safe_counter.
[SVN r85535]
2013-08-31 19:54:11 +00:00
6eefc6bf81 Merge [84506] from trunk: Document that constructors initialize enable_shared_from_this. Fixes #8573.
[SVN r84507]
2013-05-26 13:39:04 +00:00
172afff6ca Document that constructors initialize enable_shared_from_this. Refs #8573.
[SVN r84506]
2013-05-26 13:34:40 +00:00
9355404d10 Merged revision(s) 83914 from trunk:
Fix new double(n) to new double[n].

[SVN r83915]
2013-04-15 15:13:20 +00:00
d61e675caf Fix new double(n) to new double[n].
[SVN r83914]
2013-04-15 15:11:29 +00:00
240c66e633 Merge revision(s) 83829 from trunk:
More small cosmetic documentation changes.
........

[SVN r83830]
2013-04-10 05:17:32 +00:00
6df3a0295e More small cosmetic documentation changes.
[SVN r83829]
2013-04-10 05:16:09 +00:00
e497aec58a Merge revision(s) 83827 from trunk:
Small improvements to make_shared documentation.
........


[SVN r83828]
2013-04-10 05:03:45 +00:00
2d56e85174 Small improvements to make_shared documentation.
[SVN r83827]
2013-04-10 05:00:52 +00:00
579b347267 Merged revision(s) 83198 from trunk: Avoid stack overflow in make_shared. Fixes #4256. Fixes #7965.
[SVN r83341]
2013-03-07 08:18:48 +00:00
82e178f043 Avoid stack overflow in make_shared. Refs #4256.
[SVN r83198]
2013-02-28 08:02:09 +00:00
3178d38137 Merge revision 82971 from trunk:
Identifier renaming in allocate_array_helper, array_deleter, make_array_helper
function parameters to satisfy higher warning levels.
........


[SVN r82976]
2013-02-18 18:04:48 +00:00
46d119c385 Identifier renaming in allocate_array_helper, array_deleter, make_array_helper
function parameters to satisfy higher warning levels.

[SVN r82971]
2013-02-18 09:33:18 +00:00
e39fcad839 Merged revision(s) 82927 from trunk: Check for BOOST_NO_CXX11_RVALUE_REFERENCES in addition to BOOST_NO_CXX11_SMART_PTR. Fixes #8055.
[SVN r82928]
2013-02-16 17:21:23 +00:00
e5950adc43 Check for BOOST_NO_CXX11_RVALUE_REFERENCES in addition to BOOST_NO_CXX11_SMART_PTR. Refs #8055.
[SVN r82927]
2013-02-16 17:18:17 +00:00
de6dc3a26e Merge documentation fix from trunk
[SVN r82575]
2013-01-21 04:36:14 +00:00
06c4dacaf2 Correct link in documentation
[SVN r82552]
2013-01-20 00:09:27 +00:00
72095a4804 Merge revision 82408 from trunk:
Support BOOST_NO_EXCEPTIONS in detail/array_utility.hpp to allow use when exceptions are disabled
........


[SVN r82432]
2013-01-10 16:50:34 +00:00
dcc1713c59 Merged revision(s) 82351 from trunk: Replace std::nullptr_t with boost::detail::sp_nullptr_t.
[SVN r82427]
2013-01-09 23:41:31 +00:00
32a28ec462 Support BOOST_NO_EXCEPTIONS in detail/array_utility.hpp to allow use when exceptions are disabled
[SVN r82408]
2013-01-08 21:39:54 +00:00
f6d5257597 Merged revision(s) 82349 from trunk: Update documentation for nullptr, owner_before, explicit operator bool.
[SVN r82357]
2013-01-04 18:44:47 +00:00
ef817e91d2 Replace std::nullptr_t with boost::detail::sp_nullptr_t.
[SVN r82351]
2013-01-04 15:41:13 +00:00
43b43aa83a Update documentation for nullptr, owner_before, explicit operator bool.
[SVN r82349]
2013-01-04 14:26:56 +00:00
d3a549e93a Merged revision(s) 82188 from trunk: Untabify.
[SVN r82189]
2012-12-23 16:07:27 +00:00
e8be24c003 Untabify.
[SVN r82188]
2012-12-23 16:05:00 +00:00
c55ffa1cab Merge Jamfile.v2 from trunk
[SVN r82084]
2012-12-18 19:09:57 +00:00
66f34142be Fix cxxflags in smart_ptr/test/Jamfile.v2
[SVN r82070]
2012-12-18 09:24:31 +00:00
63834f7233 Specify gcc-4.6 instead of gcc-4.6.3 for toolset
[SVN r82038]
2012-12-16 23:03:30 +00:00
049d0698b7 Manually apply a change from [58306] that didn't get merged at the time.
[SVN r82026]
2012-12-16 16:20:03 +00:00
5ba3312519 Merged revision(s) 81900-81901 from trunk:
Replace use of BOOST_HAS_RVALUE_REFS with !BOOST_NO_CXX11_RVALUE_REFERENCES.
........
Replace use of BOOST_HAS_VARIADIC_TMPL with !BOOST_NO_CXX11_VARIADIC_TEMPLATES.
........


[SVN r81979]
2012-12-15 20:20:20 +00:00
bb700870c0 Specify <cxxflags>-fno-deduce-init-list for gcc-4.6.3 only.
[SVN r81950]
2012-12-14 20:05:03 +00:00
6a218a5ef2 Merged revision(s) 81886,81887,81894,81905 from trunk:
Use BOOST_NO_CXX11_RVALUE_REFERENCES and BOOST_NO_CXX11_VARIADIC_TEMPLATES instead of the legacy macros. Rename identifiers of detail utility functions.
........
Two detail utility functions identifier renaming reverted
........
Remove -fno-deduce-init-list for certain tests in Jamfile.v2
........
Correct call to init_list in make_shared and allocate_shared. Move g++ failing case into separate test to not mask other issues.
........


[SVN r81945]
2012-12-14 18:35:03 +00:00
e36689bd5e Correct call to init_list in make_shared and allocate_shared. Move g++ failing case into separate test to not mask other issues.
[SVN r81905]
2012-12-13 18:02:25 +00:00
1c070b3a32 Replace use of BOOST_HAS_VARIADIC_TMPL with !BOOST_NO_CXX11_VARIADIC_TEMPLATES.
[SVN r81901]
2012-12-13 16:57:55 +00:00
647f67aabf Replace use of BOOST_HAS_RVALUE_REFS with !BOOST_NO_CXX11_RVALUE_REFERENCES.
[SVN r81900]
2012-12-13 16:48:57 +00:00
c14369aac9 Merged revision(s) 81860-81861 from trunk:
Change make_shared to use the new _internal_get_untyped_deleter. Fixes #6830.
........
Add allocate_shared_noinit.
........


[SVN r81899]
2012-12-13 14:57:12 +00:00
7ab4f6ce92 Merged revision(s) 72437 from trunk: Lock-free sp_counted_base for SNC/PS3, thanks Peter Dimov
[SVN r81898]
2012-12-13 14:53:09 +00:00
bbf0245248 Remove -fno-deduce-init-list for certain tests in Jamfile.v2
[SVN r81894]
2012-12-13 12:21:44 +00:00
619b168614 Two detail utility functions identifier renaming reverted
[SVN r81887]
2012-12-13 04:20:23 +00:00
4ba8d879f1 Use BOOST_NO_CXX11_RVALUE_REFERENCES and BOOST_NO_CXX11_VARIADIC_TEMPLATES instead of the legacy macros. Rename identifiers of detail utility functions.
[SVN r81886]
2012-12-13 04:04:23 +00:00
c28bef2e9b Merged revision(s) 81858,81859,81865,81867 from trunk:
Add overloads of allocate_shared_noinit to complement make_shared_noinit
........
Explicitly name detail array construct overloads for different parameter types.
........
Use _internal_get_untyped_deleter in allocate_shared_array and make_shared_array
........
Documentation corrections: make_shared_array.html
........


[SVN r81882]
2012-12-12 22:57:03 +00:00
5f0155cca6 Documentation corrections: make_shared_array.html
[SVN r81867]
2012-12-11 22:44:57 +00:00
db542de908 Use _internal_get_untyped_deleter in allocate_shared_array and make_shared_array
[SVN r81865]
2012-12-11 20:51:05 +00:00
5fc6fe474b Merged revision(s) 81844 from trunk:
Correct link to  http://www.stroustrup.com/wrapper.pdf in sp_techniques.html
........


[SVN r81863]
2012-12-11 18:42:48 +00:00
d42ce87557 Merged revision(s) 81780 from trunk: Use explicit operator bool when available; add nullptr support to shared_ptr. Fixes #4116.
[SVN r81862]
2012-12-11 18:35:21 +00:00
67f5e9825e Add allocate_shared_noinit.
[SVN r81861]
2012-12-11 18:32:24 +00:00
fd52dbc411 Change make_shared to use the new _internal_get_untyped_deleter. Refs #6830.
[SVN r81860]
2012-12-11 18:21:29 +00:00
6e269872df Explicitly name detail array construct overloads for different parameter types.
[SVN r81859]
2012-12-11 18:04:09 +00:00
ecceb710de Add overloads of allocate_shared_noinit to complement make_shared_noinit
[SVN r81858]
2012-12-11 17:42:47 +00:00
9863467152 Correct link to http://www.stroustrup.com/wrapper.pdf in sp_techniques.html
[SVN r81844]
2012-12-10 23:48:00 +00:00
b306c9751f Merged revision(s) 81748-81750,81752,81759,81782 from trunk:
Refactoring in detail array_deleter before adding support for special-casing trivially default-constructible construction and trivially destroyable destruction.
........
Special case array construction for trivially default-constructible types and array destruction for trivially-destroyable types.
........
Optimization in initialization overload of array_construct for compilers to optimize it into the equivalent of a memset
........
Correctly use r-value reference semantics for Args and T in array utilities
........
Change ordering of overload definitions in array_utility.hpp
........
Convert function parameter for inner array size into template parameter and make identifiers in array_deleter consistent with those in array_utility 
........


[SVN r81800]
2012-12-08 18:30:27 +00:00
6b0d96af96 Convert function parameter for inner array size into template parameter and make identifiers in array_deleter consistent with those in array_utility
[SVN r81782]
2012-12-08 05:25:50 +00:00
c03bfd0b4d Merged revision(s) 81730-81731, 81776 from trunk:
Fix get_pointer for the array case, add operator= for unique_ptr, update auto_ptr signatures to use rvalue reference when available.
........
Update shared_ptr.htm.
........
Add more unique_ptr tests.
........


[SVN r81781]
2012-12-08 00:57:04 +00:00
8093967da7 Use explicit operator bool when available; add nullptr support to shared_ptr. Refs #4116.
[SVN r81780]
2012-12-08 00:51:59 +00:00
7a4ad75f5d Add more unique_ptr tests.
[SVN r81776]
2012-12-07 22:42:56 +00:00
f390d9e265 Change ordering of overload definitions in array_utility.hpp
[SVN r81759]
2012-12-07 16:40:20 +00:00
ea22982865 Correctly use r-value reference semantics for Args and T in array utilities
[SVN r81752]
2012-12-07 07:42:42 +00:00
09e77bc8df Optimization in initialization overload of array_construct for compilers to optimize it into the equivalent of a memset
[SVN r81750]
2012-12-07 06:45:26 +00:00
b3f2ebedbc Special case array construction for trivially default-constructible types and array destruction for trivially-destroyable types.
[SVN r81749]
2012-12-07 03:10:22 +00:00
1209531fe0 Refactoring in detail array_deleter before adding support for special-casing trivially default-constructible construction and trivially destroyable destruction.
[SVN r81748]
2012-12-07 01:53:35 +00:00
6c2ed927e4 Update shared_ptr.htm.
[SVN r81731]
2012-12-06 03:20:46 +00:00
7a733263da Fix get_pointer for the array case, add operator= for unique_ptr, update auto_ptr signatures to use rvalue reference when available.
[SVN r81730]
2012-12-06 03:18:54 +00:00
08e5894510 Merged revisions 81700,81703 from trunk:
Add overloads of make_shared and allocate_shared for arrays for E&& where E is typename boost::detail::array_base<T>::type
........
Update documentation and remove unused code.
........


[SVN r81716]
2012-12-05 04:28:20 +00:00
3551d17566 Merged revision 81463 from trunk:
Update shared_ptr casts.
........


[SVN r81715]
2012-12-05 04:13:51 +00:00
32fe0b8f26 Merged revision(s) 81488 from trunk: Apply patch from #7722. Fixes #7722.
[SVN r81714]
2012-12-05 03:44:40 +00:00
2d3cc0db7d Update documentation and remove unused code.
[SVN r81703]
2012-12-04 11:21:24 +00:00
188602581d Add overloads of make_shared and allocate_shared for arrays for E&& where E is typename boost::detail::array_base<T>::type
[SVN r81700]
2012-12-04 06:06:23 +00:00
88c2baa20b Merged revision(s) 81684-81685 from trunk:
For fixed size arrays upon constructor exception thrown destroy correctly.
........
Minor cosmetic change in detail array_deleter
........


[SVN r81695]
2012-12-03 15:42:15 +00:00
1adf546ddb Minor cosmetic change in detail array_deleter
[SVN r81685]
2012-12-03 05:56:17 +00:00
5e5ff387fa For fixed size arrays upon constructor exception thrown destroy correctly.
[SVN r81684]
2012-12-03 05:41:34 +00:00
ea55019260 Merged revision(s) 81641-81643,81658,81669,81681 from trunk:
Use const T (&)[N] for fixed size arrays instead of std::initializer<T> in overloads of make_shared and allocate_shared for arrays.
........
Use BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX instead for certain overloads of make_shared and allocate_shared
........
Code consistency: Use the same style of #if conditional compilation checks in allocate_shared_array.hpp and make_shared_array.hpp.
........
Change make_shared and allocate_shared array form overload for size and inner array initialization list to use const T(&)[N] instead of std::initializer_list<T>.
........
Move two tests for allocate_shared and make_shared within check for BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
........
Make specializations of detail array_deleter consistent.
........


[SVN r81682]
2012-12-02 23:15:55 +00:00
500913db6d Make specializations of detail array_deleter consistent.
[SVN r81681]
2012-12-02 22:05:31 +00:00
19283a3548 Move two tests for allocate_shared and make_shared within check for BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
[SVN r81669]
2012-12-02 10:17:05 +00:00
cfd4152291 Change make_shared and allocate_shared array form overload for size and inner array initialization list to use const T(&)[N] instead of std::initializer_list<T>.
[SVN r81658]
2012-12-01 22:43:57 +00:00
f5adfb0963 Code consistency: Use the same style of #if conditional compilation checks in allocate_shared_array.hpp and make_shared_array.hpp.
[SVN r81643]
2012-12-01 05:40:06 +00:00
8597433028 Use BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX instead for certain overloads of make_shared and allocate_shared
[SVN r81642]
2012-12-01 05:23:37 +00:00
4da0e2b7fc Use const T (&)[N] for fixed size arrays instead of std::initializer<T> in overloads of make_shared and allocate_shared for arrays.
[SVN r81641]
2012-12-01 04:36:41 +00:00
2346941b15 Merged revision(s) 81608-81610 from trunk:
Optimization: Add specializations of make_array_helper, allocate_array_helper, and array_deleter for fixed size arrays to avoid storing size.
........
Consistent formatting across overloads of make_shared and allocate_shared (array forms).
........
More consistency in type parameters in helper details of allocate_shared and make_shared.
........


[SVN r81635]
2012-11-30 17:29:36 +00:00
39ff002d2e More consistency in type parameters in helper details of allocate_shared and make_shared.
[SVN r81610]
2012-11-28 07:32:30 +00:00
fceea2e584 Consistent formatting across overloads of make_shared and allocate_shared (array forms).
[SVN r81609]
2012-11-28 06:26:50 +00:00
b17205ded7 Optimization: Add specializations of make_array_helper, allocate_array_helper, and array_deleter for fixed size arrays to avoid storing size.
[SVN r81608]
2012-11-28 06:07:45 +00:00
d74c09dd5a Apply patch from #7722. Refs #7722.
[SVN r81488]
2012-11-22 17:39:27 +00:00
97d32745aa Update shared_ptr casts.
[SVN r81463]
2012-11-21 17:43:48 +00:00
c7b6e56b30 Merged revision(s) 81368, 81399, 81407-81409, 81419, 81430-81431, 81437 from trunk:
Apply BOOST_NOEXCEPT patch. Refs #7523.
........
Replace std::forward with detail::sp_forward.
........
Cosmetic changes in make_shared_array.hpp and allocate_shared_array.hpp
........
Documentation of make_shared_array: Minor corrections
........
Make make_shared_array.hpp and allocate_shared_array.hpp consistent with namespace qualification in rest of smart_ptr.
........
Update smart_ptr.htm with link to make_shared_array.htm which lists the many overloads of make_shared and allocate_shared for arrays.
........
Update documentation for make_shared and allocate_shared array forms.
........
Minor corrections in make_shared_array.html documentation.
........
Borland fixes.
........


[SVN r81457]
2012-11-21 15:38:06 +00:00
7835914d83 Borland fixes.
[SVN r81437]
2012-11-20 15:22:19 +00:00
98b92fa83a Minor corrections in make_shared_array.html documentation.
[SVN r81431]
2012-11-20 04:07:58 +00:00
392885a56a Update documentation for make_shared and allocate_shared array forms.
[SVN r81430]
2012-11-20 03:00:02 +00:00
b4594eab3b Update smart_ptr.htm with link to make_shared_array.htm which lists the many overloads of make_shared and allocate_shared for arrays.
[SVN r81419]
2012-11-19 08:08:27 +00:00
ddfcc5f417 Make make_shared_array.hpp and allocate_shared_array.hpp consistent with namespace qualification in rest of smart_ptr.
[SVN r81409]
2012-11-18 02:51:06 +00:00
3f458c68f4 Documentation of make_shared_array: Minor corrections
[SVN r81408]
2012-11-18 01:51:46 +00:00
79b229adcd Cosmetic changes in make_shared_array.hpp and allocate_shared_array.hpp
[SVN r81407]
2012-11-17 22:20:32 +00:00
94b6487ca1 Replace std::forward with detail::sp_forward.
[SVN r81399]
2012-11-17 16:21:41 +00:00
cf769b94a7 Apply BOOST_NOEXCEPT patch. Refs #7523.
[SVN r81368]
2012-11-16 15:05:25 +00:00
215771c83d Merged [81348] from trunk. Fixes #7693.
[SVN r81367]
2012-11-16 14:11:25 +00:00
2805ae9362 Merged revision(s) 81341-81342 from trunk:
Add additional overload for allocate_shared and make_shared array forms that take initializer list of T for the array types T[M][N]
........
Minor style change: Fix indentation in allocate_shared_array.hpp and make_shared_array.hpp
........


[SVN r81366]
2012-11-16 14:09:18 +00:00
7adb1cc1ec Reorder HP aCC and g++ #ifdefs. Refs #7693.
[SVN r81348]
2012-11-14 18:24:05 +00:00
da9524d637 Minor style change: Fix indentation in allocate_shared_array.hpp and make_shared_array.hpp
[SVN r81342]
2012-11-14 15:33:30 +00:00
6b2556edfb Add additional overload for allocate_shared and make_shared array forms that take initializer list of T for the array types T[M][N]
[SVN r81341]
2012-11-14 15:18:50 +00:00
cb0797acf0 Merged revision(s) 81149, 81159, 81171, 81174, 81219-81220, 81222-81224, 81226, 81229-81239, 81242, 81253, 81257-81262, 81265-81268, 81271-81272, 81275-81277, 81299-81300 from trunk:
Implement shared_ptr<X[]>, weak_ptr<X[]>. Refs #1113.
........
Fix shared_ptr<T[]> EDG issues.
........
Disable make_shared<T> overloads when T is Q[].
........
Add catch(...) clauses to sp_array_test.cpp.
........
Add allocate_shared and make_shared for shared_ptr arrays of runtime size. Fulfills need for allocate_shared_array and make_shared_array. 
........
Update Jamfile.v2 to run make_shared array tests and allocate_shared array tests.
........
Fix g++ issues.
........
Add specialization of sp_if_not_array<T[N]>.
........
Rename make_shared.hpp to make_shared_object.hpp, include from make_shared.hpp.
........
Add make_shared_array_args_test.cpp.
........
Add support for make_shared of array of arrays. Correctly destroy elements and construct elements for the variadic template constructor variants.
........
Fix sp_convertible<T const[], T const[]>.
........
Update smart_ptr/detail/array_helper to have create and create_noinit for non-array case.
........
Rename sp_convertible_test.cpp to shared_ptr_convertible_test.cpp.
........
Don't treat array_helper create and create_noinit for array types as a special case.
........
Add sp_convertible_test.cpp.
........
Fix array_helper (create_noinit and use of args...).
........
Update allocate_shared and make_shared to treat multidimensional array as single dimension. Remove detail array_helper. Add detail array traits. Update tests. 
........
Simplify array_deleter interface
........
Add missing semicolon.
........
Fix typo.
........
Add tests for variadic template constructors overload of array forms of make_shared and allocate_shared for multidimensional arrays and up to 9 constructor arguments.
........
Add support for shared_ptr<X[N>.
........
Add C++11 initializer list support for make_shared and allocate_shared array forms.

........
Clean up code in allocate_shared_array.hpp and make_shared_array.hpp
........
Change make_shared and allocate_shared array form semantics with initializer lists overload that takes no size.
........
Disable make_shared for arrays when the compiler doesn't support partial specialization or SFINAE.
........
For allocate_shared and make_shared: Separate test case that g++ does support yet. Remove macros testing for no partial specialization in traits. Add additional traits.
........
Actually remove test cases from make_shared_array_create_test.cpp and allocate_shared_array_create_test.cpp that g++ does not handle.
........
Add overloads to support fixed size arrays, T[N], to allocate_shared (variadic) and make_shared (variadic) and make_shared_noinit.
........
Add additional overload for make_shared and allocate_shared for arrays for fixed size arrays and initializer lists.
........
Add assertion to overload of make_shared and allocate_shared for T[N] with initializer lists. Rename detail type to be more intuitive.
........
Add allocate_shared_array_args_test.cpp.
........
Keep old definition of sp_assert_convertible when BOOST_SP_NO_SP_CONVERTIBLE is set.
........
Updated shared_array to match shared_ptr. Refs #1113.
........
Add final overload of make_shared and allocate_shared (array forms) for T[][N] with C++11 initializer lists.
........
Change traits for initializer list for g++
........
Tidy long line formatting in allocate_shared_array.hpp and make_shared_array.hpp
........
Update tests for make_shared and allocate_shared array forms, for normal case, initializer lists, variadic template arguments, for arrays and fixed size arrays.
........
Update Jamfile.v2 with two new smart_ptr tests for allocate_shared and make_shared
........


[SVN r81339]
2012-11-14 13:52:11 +00:00
e8103f9774 Merge from 57197, 57206, 57423, 57518 did not apply to 'libs' for some reason; update.
[SVN r81338]
2012-11-14 13:36:44 +00:00
71eb435412 Merged revision(s) 57197, 57206, 57423, 57518 from trunk:
Renamed enable_shared_from_this2 to enable_shared_from_raw and
added shared_from_raw free function.  These changes fix the pointer 
value in shared_ptr which were obtained before an external shared_ptr has
taken ownership of the object (for example when a shared_ptr to
this is obtained in an object's constructor).


........
Brought back code which fixes get_deleter when it is called on a deleter 
which has been wrapped inside a deleter_wrapper by "shared_from_raw() in 
constructors" support.

........
Added weak_from_raw(), for use in conjunction with
enable_shared_from_raw base class.


........
Fixed access to enable_shared_from_raw::weak_this_ when 
BOOST_NO_MEMBER_TEMPLATE_FRIENDS is defined.


........


[SVN r81337]
2012-11-14 13:26:30 +00:00
4a2dad1574 Merged [81134] from trunk. Fixes #6308. Refs #6667.
[SVN r81336]
2012-11-14 12:09:30 +00:00
babc72757d Merged [81131] from trunk. Fixes #6625.
[SVN r81335]
2012-11-14 12:04:48 +00:00
c19cbc1892 Merged [81128] from trunk. Fixes #7141.
[SVN r81334]
2012-11-14 11:57:58 +00:00
d065e4d971 Merged [81127] from trunk. Fixes #6901.
[SVN r81333]
2012-11-14 11:55:10 +00:00
777b86a661 Merged [81126] from trunk. Fixes #6996.
[SVN r81332]
2012-11-14 11:53:05 +00:00
aae5440854 Merged [80988] from trunk.
[SVN r81331]
2012-11-14 11:51:00 +00:00
227d2e3255 Manually apply [69019] from trunk.
[SVN r81330]
2012-11-14 11:43:17 +00:00
8bf183b373 Merged [81125] from trunk. Fixes #4185.
[SVN r81329]
2012-11-14 11:20:29 +00:00
5017da2514 Merged [81119] from trunk. Fixes #7599.
[SVN r81328]
2012-11-14 11:17:48 +00:00
3b0b10d06d Update Jamfile.v2 with two new smart_ptr tests for allocate_shared and make_shared
[SVN r81300]
2012-11-11 19:21:18 +00:00
25e11b20d3 Update tests for make_shared and allocate_shared array forms, for normal case, initializer lists, variadic template arguments, for arrays and fixed size arrays.
[SVN r81299]
2012-11-11 19:14:50 +00:00
fa513340d7 Tidy long line formatting in allocate_shared_array.hpp and make_shared_array.hpp
[SVN r81277]
2012-11-10 02:33:48 +00:00
0e90213746 Change traits for initializer list for g++
[SVN r81276]
2012-11-10 02:17:02 +00:00
980070e63f Add final overload of make_shared and allocate_shared (array forms) for T[][N] with C++11 initializer lists.
[SVN r81275]
2012-11-10 01:33:29 +00:00
5bdde37414 Updated shared_array to match shared_ptr. Refs #1113.
[SVN r81272]
2012-11-10 00:04:49 +00:00
2aaa913b11 Keep old definition of sp_assert_convertible when BOOST_SP_NO_SP_CONVERTIBLE is set.
[SVN r81271]
2012-11-09 23:27:02 +00:00
58a46f4e55 Add allocate_shared_array_args_test.cpp.
[SVN r81268]
2012-11-09 18:26:40 +00:00
8cc50a5ce9 Add assertion to overload of make_shared and allocate_shared for T[N] with initializer lists. Rename detail type to be more intuitive.
[SVN r81267]
2012-11-09 18:01:39 +00:00
2731957b5b Add additional overload for make_shared and allocate_shared for arrays for fixed size arrays and initializer lists.
[SVN r81266]
2012-11-09 17:30:07 +00:00
fe06c120b9 Add overloads to support fixed size arrays, T[N], to allocate_shared (variadic) and make_shared (variadic) and make_shared_noinit.
[SVN r81265]
2012-11-09 17:12:56 +00:00
c1f41aa925 Actually remove test cases from make_shared_array_create_test.cpp and allocate_shared_array_create_test.cpp that g++ does not handle.
[SVN r81262]
2012-11-09 16:35:18 +00:00
ffa3327817 For allocate_shared and make_shared: Separate test case that g++ does support yet. Remove macros testing for no partial specialization in traits. Add additional traits.
[SVN r81261]
2012-11-09 16:06:48 +00:00
999c284109 Disable make_shared for arrays when the compiler doesn't support partial specialization or SFINAE.
[SVN r81260]
2012-11-09 12:37:03 +00:00
d512eaaa0f Change make_shared and allocate_shared array form semantics with initializer lists overload that takes no size.
[SVN r81259]
2012-11-09 10:14:55 +00:00
730980f3ee Clean up code in allocate_shared_array.hpp and make_shared_array.hpp
[SVN r81258]
2012-11-09 09:14:23 +00:00
3d50db11b9 Add C++11 initializer list support for make_shared and allocate_shared array forms.
[SVN r81257]
2012-11-09 06:17:05 +00:00
aa7562c3e5 Add support for shared_ptr<X[N>.
[SVN r81253]
2012-11-08 18:07:49 +00:00
c57245d710 Add tests for variadic template constructors overload of array forms of make_shared and allocate_shared for multidimensional arrays and up to 9 constructor arguments.
[SVN r81242]
2012-11-08 05:33:52 +00:00
945c013a12 Fix typo.
[SVN r81239]
2012-11-07 23:45:31 +00:00
df544871d7 Add missing semicolon.
[SVN r81238]
2012-11-07 23:41:52 +00:00
89190ca17e Simplify array_deleter interface
[SVN r81237]
2012-11-07 18:58:41 +00:00
5d9312239c Update allocate_shared and make_shared to treat multidimensional array as single dimension. Remove detail array_helper. Add detail array traits. Update tests.
[SVN r81236]
2012-11-07 18:37:17 +00:00
93b5cace12 Fix array_helper (create_noinit and use of args...).
[SVN r81235]
2012-11-07 15:36:15 +00:00
e50c849ab3 Add sp_convertible_test.cpp.
[SVN r81234]
2012-11-07 15:33:44 +00:00
dbea328b8b Don't treat array_helper create and create_noinit for array types as a special case.
[SVN r81233]
2012-11-07 15:25:55 +00:00
c06ba497a3 Rename sp_convertible_test.cpp to shared_ptr_convertible_test.cpp.
[SVN r81232]
2012-11-07 15:07:08 +00:00
734b5d1354 Update smart_ptr/detail/array_helper to have create and create_noinit for non-array case.
[SVN r81231]
2012-11-07 15:04:04 +00:00
0467af1b83 Fix sp_convertible<T const[], T const[]>.
[SVN r81230]
2012-11-07 15:00:24 +00:00
dc5406aa5a Add support for make_shared of array of arrays. Correctly destroy elements and construct elements for the variadic template constructor variants.
[SVN r81229]
2012-11-07 14:42:10 +00:00
6e873de0fa Add make_shared_array_args_test.cpp.
[SVN r81226]
2012-11-06 17:31:15 +00:00
322bcd7efa Rename make_shared.hpp to make_shared_object.hpp, include from make_shared.hpp.
[SVN r81224]
2012-11-06 16:29:56 +00:00
bb72e0a092 Add specialization of sp_if_not_array<T[N]>.
[SVN r81223]
2012-11-06 16:23:09 +00:00
d8eb2fc105 Fix g++ issues.
[SVN r81222]
2012-11-06 15:10:32 +00:00
e7d3987cfb Update Jamfile.v2 to run make_shared array tests and allocate_shared array tests.
[SVN r81220]
2012-11-06 14:35:40 +00:00
6662ae7242 Add allocate_shared and make_shared for shared_ptr arrays of runtime size. Fulfills need for allocate_shared_array and make_shared_array.
[SVN r81219]
2012-11-06 14:17:32 +00:00
2ba7b6b99b Add catch(...) clauses to sp_array_test.cpp.
[SVN r81174]
2012-11-04 18:30:03 +00:00
a30e291022 Disable make_shared<T> overloads when T is Q[].
[SVN r81171]
2012-11-04 14:53:51 +00:00
0b6cab9f2f Fix shared_ptr<T[]> EDG issues.
[SVN r81159]
2012-11-03 14:49:45 +00:00
8c15401ea7 Implement shared_ptr<X[]>, weak_ptr<X[]>. Refs #1113.
[SVN r81149]
2012-11-02 17:41:33 +00:00
03ae5cdbc6 Add back _AIX-specific #ifdef that was mistakenly removed. Refs #6308. Refs #6667.
[SVN r81134]
2012-11-01 17:50:41 +00:00
0c22e55f3e Add shared_ptr constructor taking std::unique_ptr. Refs #6625.
[SVN r81131]
2012-10-31 22:16:20 +00:00
10dcb8db7c Define BOOST_SP_HAS_SYNC when __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 is set. Refs #7141.
[SVN r81128]
2012-10-31 20:37:21 +00:00
f2d4b67a48 Enable __sync primitives on VACPP. Refs #6901.
[SVN r81127]
2012-10-31 20:30:27 +00:00
16084637a6 Do not use sp_counted_base_gcc_ppc on AIX. Refs #6996.
[SVN r81126]
2012-10-31 20:16:56 +00:00
3e447c919c Add get_pointer overloads for std::unique_ptr, std::shared_ptr. Refs #4185.
[SVN r81125]
2012-10-31 20:04:14 +00:00
b0f72d7b3d Add check for __ARM_ARCH_7S__. Refs #7599.
[SVN r81119]
2012-10-31 16:04:03 +00:00
4c98df7c57 Update smart_ptr for the latest version of the PathScale compiler.
[SVN r80988]
2012-10-14 23:06:12 +00:00
c2048732d8 Merge [77316] to release. Closes #6667.
[SVN r77318]
2012-03-12 17:40:02 +00:00
5979c1d4bd Merge [77315] to release. Closes #5331.
[SVN r77317]
2012-03-12 17:37:51 +00:00
1029ae0ea5 Apply patches from #6667. Refs #6667.
[SVN r77316]
2012-03-12 17:33:50 +00:00
27a312228c Apply patch from #5331. Refs #5331.
[SVN r77315]
2012-03-12 17:31:21 +00:00
3090f6f4af Merge [76219] to release. Fixes #6332.
[SVN r76221]
2011-12-29 22:43:02 +00:00
2c29f1e5a9 Warning 4284 is obsolete. Refs #6332. See also #4433.
[SVN r76219]
2011-12-29 22:27:37 +00:00
40073ef64f Merge [76125], [76126] to release.
[SVN r76164]
2011-12-26 00:25:42 +00:00
b9970eda45 Merge [76111] to release. Fixes #2603.
[SVN r76163]
2011-12-26 00:23:00 +00:00
df364f37f2 std::move is in <utility>.
[SVN r76125]
2011-12-23 23:54:41 +00:00
9147489b4c Merge [76123] to release. Refs #6308.
[SVN r76124]
2011-12-23 23:12:50 +00:00
33ba2c4722 sp_counted_base_aix.hpp: switch to lwsync and builtins. Refs #6308.
[SVN r76123]
2011-12-23 23:10:37 +00:00
d1348ea05e Merge [76119] to release. Refs #6308.
[SVN r76120]
2011-12-23 15:10:51 +00:00
faf212f4aa Add memory barriers to sp_counted_base_aix.hpp. Refs #6308.
[SVN r76119]
2011-12-23 15:03:39 +00:00
57a5441ebf Creatively apply patch from #2603. Refs #2603.
[SVN r76111]
2011-12-23 03:00:05 +00:00
90db9a6435 Merge [76086] to release. Fixes #6308.
[SVN r76087]
2011-12-21 00:43:56 +00:00
017ab7e2ee Apply AIX patch from #6308. Refs #6308.
[SVN r76086]
2011-12-21 00:36:55 +00:00
1c208ad3ea Merge [75392] to release. Fixes #6087.
[SVN r75756]
2011-11-30 18:01:02 +00:00
5fc9bf5bc5 Merge [75390] to release. Fixes #4493.
[SVN r75754]
2011-11-30 17:51:43 +00:00
c846d230f0 Merge [75389] to release. Fixes #5372.
[SVN r75753]
2011-11-30 17:49:43 +00:00
e4cb5e131f Add hash_value for intrusive_ptr. Refs #6087.
[SVN r75392]
2011-11-07 18:46:46 +00:00
fbe4ddf4a2 Add get_deleter for shared_array. Refs #4493.
[SVN r75390]
2011-11-07 18:19:24 +00:00
288fb7efcf Add ARM memory barriers. Refs #5372.
[SVN r75389]
2011-11-07 17:50:31 +00:00
7b097467d6 Merge [75385] to release. Fixes #6099.
[SVN r75386]
2011-11-07 15:05:43 +00:00
9d9e6350f2 Apply patch from #6099. Refs #6099.
[SVN r75385]
2011-11-07 15:03:44 +00:00
7cb040edb0 Merge [70452] to release. Fixes #5327.
[SVN r75381]
2011-11-07 14:25:23 +00:00
d6ac116b71 Merge [73202] to release.
[SVN r73542]
2011-08-05 08:58:31 +00:00
7e9664396a Add copy constructor/assignment - in C++0x, move disables implicit copy.
[SVN r73202]
2011-07-17 20:35:44 +00:00
b4b415553c Lock-free sp_counted_base for SNC/PS3, thanks Peter Dimov
[SVN r72437]
2011-06-06 18:56:07 +00:00
f76a8d95d8 Apply suggested patch. Refs #5327.
[SVN r70452]
2011-03-23 00:29:22 +00:00
8abc8889d1 Merge [69262] to release. Fixes #5018.
[SVN r70447]
2011-03-23 00:13:54 +00:00
c5b47e2136 Merge [69261] to release. Fixes #5019.
[SVN r70441]
2011-03-22 23:55:05 +00:00
7c0815c567 Merge [69260] to release. Fixes #5216.
[SVN r70440]
2011-03-22 23:51:10 +00:00
210288f02e Merge [69251] to release. Fixes #4127.
[SVN r70439]
2011-03-22 23:45:59 +00:00
cf7b6904e8 Merge [69250] to release. Fixes #4256. Fixes #3875.
[SVN r70436]
2011-03-22 23:38:12 +00:00
b978919dd1 Merge [69246] to release. Fixes #4478.
[SVN r70435]
2011-03-22 23:29:35 +00:00
1086aff971 Merge [69245] to release. Fixes #4433.
[SVN r70434]
2011-03-22 23:23:44 +00:00
445e8d1728 Merge [69244] to release. Fixes #4892.
[SVN r70433]
2011-03-22 23:17:51 +00:00
545745d649 Merge [69242] to release. Fixes #4288. Fixes #5189.
[SVN r70432]
2011-03-22 23:05:48 +00:00
634866c28a Honor BOOST_SP_USE_PTHREADS. Refs #5018.
[SVN r69262]
2011-02-24 23:35:22 +00:00
b18b47770d Add support for BOOST_SP_NO_SYNC. Refs #5019.
[SVN r69261]
2011-02-24 23:30:22 +00:00
69aa01ec00 Add hash_value for shared_ptr; prevents hash_value( bool ) from being used. Refs #5216.
[SVN r69260]
2011-02-24 23:24:54 +00:00
e3d2f2ee6b Apply suggested fix. Refs #4127.
[SVN r69251]
2011-02-24 22:05:04 +00:00
593093e46d Fix make_shared to not copy the deleter. Refs #4256. Refs #3875.
[SVN r69250]
2011-02-24 21:51:21 +00:00
9196247dea Apply patch. Refs #4478.
[SVN r69246]
2011-02-24 20:53:46 +00:00
53d5d086ea Warning 4284 is obsolete. Refs #4433.
[SVN r69245]
2011-02-24 20:48:17 +00:00
1426b0bbdd Apply patch to allow perfect forwarding without variadics. Refs #4892.
[SVN r69244]
2011-02-24 20:41:29 +00:00
4fabf9b352 Add include guards, make_shared.hpp to smart_ptr.hpp. Refs #4288. Refs #5189.
[SVN r69242]
2011-02-24 20:29:38 +00:00
a2fc6e12da Intel 11.0 doesn't provide __sync intrinsics - this is added in Intel 11.1.
[SVN r69019]
2011-02-19 01:33:46 +00:00
c3b51e201b Pathscale-4.0 configuration code/workarounds.
[SVN r68142]
2011-01-14 02:59:34 +00:00
d71cc6ab08 Merging from trunk
[SVN r66166]
2010-10-24 22:24:54 +00:00
825786d59a Re-added sunpro specific initialization
[SVN r66091]
2010-10-19 13:33:00 +00:00
37f10d500d Fixing sp_typeinfo for clang and gcc 4.5.1
[SVN r66031]
2010-10-17 02:24:40 +00:00
0d77fd0678 Merge [62248] to release. Fixes #3856.
[SVN r63827]
2010-07-10 21:17:40 +00:00
6ca6d3ce6f Merge [62246] to release. Fixes #4217.
[SVN r63826]
2010-07-10 21:07:05 +00:00
cfc82854d3 Merge [62245] to release. Fixes #4199.
[SVN r63825]
2010-07-10 20:46:53 +00:00
3c84388186 Resolve the ambiguity between the zero argument make_shared and the variadic one. Refs #3856.
[SVN r62248]
2010-05-26 18:18:10 +00:00
a46d405778 DWORD is unsigned long, not unsigned int. Refs #4217.
[SVN r62246]
2010-05-26 17:49:37 +00:00
2e53b1eb38 Applied patch for Sun C++. Refs #4199.
[SVN r62245]
2010-05-26 17:43:58 +00:00
b9d77d877e Merge [61344] to release. Fixes #4108.
[SVN r62244]
2010-05-26 17:34:01 +00:00
1f50e3abe4 Merge [61574], [61575], [61579] to release.
[SVN r62243]
2010-05-26 17:25:06 +00:00
37c9a235a5 Add BOOST_HAS_VARIADIC_TMPL as a test condition.
[SVN r61579]
2010-04-26 16:39:45 +00:00
7083e76666 Remove duplicate using declarations.
[SVN r61575]
2010-04-26 12:20:44 +00:00
7aac2f3263 Fix detail::forward to work with rvalue references v2.
[SVN r61574]
2010-04-26 12:16:55 +00:00
458dffdab9 Work around over-eager ADL with msvc-10.0. Refs #4108
[SVN r61344]
2010-04-17 20:13:27 +00:00
697f338510 Merge [61074]. Fixes #4067.
[SVN r61078]
2010-04-05 19:37:32 +00:00
f7919f0b9f Borland 6.21 still needs the workaround. Refs #4067.
[SVN r61074]
2010-04-05 18:53:58 +00:00
f4386409d9 Merge [58275], [58306] to release.
[SVN r58380]
2009-12-14 17:44:19 +00:00
ae34be773f Qualify detail:: references. Detabify sp_typeinfo_test.cpp.
[SVN r58306]
2009-12-11 22:36:35 +00:00
1b91c1dbea Avoid static destruction order issues with quick_allocator.
[SVN r58275]
2009-12-10 20:34:46 +00:00
ba349679f3 Merge [58123], [58127], [58128] to release. Fixes #3666.
[SVN r58195]
2009-12-06 17:50:28 +00:00
577528812a Fix sp_typeinfo to match the interface of std::type_info.
[SVN r58127]
2009-12-03 20:31:01 +00:00
e78efdbb96 Fix smart_ptr tests to not require RTTI.
[SVN r58123]
2009-12-03 18:10:37 +00:00
a3b84f8586 Merge [58094] to release.
[SVN r58122]
2009-12-03 17:50:37 +00:00
3824a6b156 Add memory_order_consume.
[SVN r58094]
2009-12-02 11:47:58 +00:00
b0fd8a6b08 Merge [57957] to release. Fixes #3570.
[SVN r58067]
2009-11-30 20:34:39 +00:00
4f5062004a Merge [57954], [57955] to release.
[SVN r58066]
2009-11-30 20:30:22 +00:00
f040bed751 Merge [57953] to release. Fixes #2681.
[SVN r58065]
2009-11-30 20:25:01 +00:00
2f8945a885 Merge [57951] to release. Fixes #3351.
[SVN r58064]
2009-11-30 20:20:52 +00:00
2bd0778778 Merge [57949] to release. Fixes #3678. Fixes #3341.
[SVN r58063]
2009-11-30 20:17:14 +00:00
eec640bfd7 Merge [57520] to release. Fixes #2962.
[SVN r57960]
2009-11-26 22:10:30 +00:00
754fd941ee Merge [57950], [57952] to release. Fixes #3404. Fixes #3456.
[SVN r57959]
2009-11-26 21:58:16 +00:00
b691be0af9 Remove std::move references. Refs #3570.
[SVN r57957]
2009-11-26 21:20:47 +00:00
fa597b877e Extend Borland workaround to 6.2.
[SVN r57955]
2009-11-26 21:04:36 +00:00
d0a9d76494 Add error checking to lwm_pthreads.hpp. Refs #2681.
[SVN r57953]
2009-11-26 20:55:05 +00:00
979e76b7e0 Enable __sync use on Intel 11.0 or later. Refs #3351.
[SVN r57951]
2009-11-26 20:17:55 +00:00
c97eebabf7 Fix enable_shared_from_this example. Refs #3404.
[SVN r57950]
2009-11-26 20:11:05 +00:00
030a848c5f Fix SPARC asm operand failure. Refs #3678. Refs #3341.
[SVN r57949]
2009-11-26 18:21:21 +00:00
18bfaea996 Fixed perfect forwarding for make_shared() in trunk, and added
corresponding test.  Refs #2962.



[SVN r57520]
2009-11-09 18:12:35 +00:00
502de325ee Fixed access to enable_shared_from_raw::weak_this_ when
BOOST_NO_MEMBER_TEMPLATE_FRIENDS is defined.



[SVN r57518]
2009-11-09 16:33:35 +00:00
9f49538b37 Added weak_from_raw(), for use in conjunction with
enable_shared_from_raw base class.



[SVN r57423]
2009-11-05 21:41:38 +00:00
2ee5eb70f3 Brought back code which fixes get_deleter when it is called on a deleter
which has been wrapped inside a deleter_wrapper by "shared_from_raw() in 
constructors" support.


[SVN r57206]
2009-10-28 22:42:21 +00:00
32eb028e13 Renamed enable_shared_from_this2 to enable_shared_from_raw and
added shared_from_raw free function.  These changes fix the pointer 
value in shared_ptr which were obtained before an external shared_ptr has
taken ownership of the object (for example when a shared_ptr to
this is obtained in an object's constructor).



[SVN r57197]
2009-10-28 19:10:47 +00:00
e824e23ec2 rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back
[SVN r56942]
2009-10-17 02:07:38 +00:00
e94f64039d rm cmake from the release branch before it goes out broken. Policy dictates that you never commit to release, you commit to trunk and merge to release.
[SVN r56941]
2009-10-17 01:10:45 +00:00
63b17c24ea Merge [51909], [51912], [52937], [53672] to release.
[SVN r55479]
2009-08-08 23:21:15 +00:00
f5cc79f58d Copyrights on CMakeLists.txt to keep them from clogging up the inspect
reports.  This is essentially the same commit as r55095 on the release
branch.



[SVN r55159]
2009-07-26 00:49:56 +00:00
8a421c2098 Add basic copyright/license to keep cmake out of the inspection report
[SVN r55095]
2009-07-22 21:51:01 +00:00
28d7e348c1 avoid C style casts
[SVN r53672]
2009-06-06 09:44:36 +00:00
5fa1cbf6e1 shared_ptr and bind cmake tweaks
[SVN r53001]
2009-05-14 20:20:34 +00:00
fc12543814 Merged in smart_ptr changes from the sandbox/boost0x branch created for
BoostCon '09.  This adds move semantics to weak_ptr and intrusive_ptr.


[SVN r52937]
2009-05-12 16:18:15 +00:00
9f30442d1e merged [52456], [52457] and [52464] from trunk
[SVN r52486]
2009-04-19 10:17:50 +00:00
a4293f9dfa Merge [52454] to release. Fixes #2951.
[SVN r52472]
2009-04-18 21:32:43 +00:00
4b4a62513f Make ++a, where a is an atomic_count, return the new value.
[SVN r52456]
2009-04-17 20:24:01 +00:00
0368a37fde Bring back "explicit" on the auto_ptr rvalue constructor. Refs #2951.
[SVN r52454]
2009-04-17 19:51:18 +00:00
28de0cb1e3 Have config/select_stdlib_config.hpp and config/stdlib/stlport.hpp use <cstddef> instead of <utility> to determine which standard library is in use. For std lib implementations that rely on Boost components like TypeTraits, Bind, Function, or SmartPtr, this helps to avoid circular header dependency issues, since <cstddef> is much less likely to pull in Boost libraries than <utility>.
In get_pointer.hpp, switched to using <boost/config/no_tr1/memory.hpp> instead of using <memory> directly.  As above, this helps avoid circular header dependency issues in Boost-supplemented std libs (specifically it avoids issues when <memory> pulls in pieces of Boost.SmartPtr).

These two changes were made in response to testing done with STLport 5.2.1 using the _STLP_USE_BOOST_SUPPORT option.

[SVN r52221]
2009-04-06 21:25:18 +00:00
3dacec8e1d Have config/select_stdlib_config.hpp and config/stdlib/stlport.hpp use <cstddef> instead of <utility> to determine which standard library is in use. For std lib implementations that rely on Boost components like TypeTraits, Bind, Function, or SmartPtr, this helps to avoid circular header dependency issues, since <cstddef> is much less likely to pull in Boost libraries than <utility>.
In get_pointer.hpp, switched to using <boost/config/no_tr1/memory.hpp> instead of using <memory> directly.  As above, this helps avoid circular header dependency issues in Boost-supplemented std libs (specifically it avoids issues when <memory> pulls in pieces of Boost.SmartPtr).

These two changes were made in response to testing done with STLport 5.2.1 using the _STLP_USE_BOOST_SUPPORT option.

[SVN r52104]
2009-04-01 14:42:11 +00:00
a1b4fc8d95 Merge [51978], [51985] to release. Closes #2885.
[SVN r52016]
2009-03-27 13:10:46 +00:00
5758e51948 Fix sp_typeinfo.hpp include. Refs #2885.
[SVN r51985]
2009-03-26 12:47:24 +00:00
287d329276 Added g++/MIPS support submitted by David Joyner. Refs #2885.
[SVN r51978]
2009-03-26 00:17:57 +00:00
d34d638998 Bring back the constructor-enabled enable_shared_from_this as enable_shared_from_this2.
[SVN r51912]
2009-03-22 21:11:17 +00:00
6f2bdddfa0 Delete enable_shared_from_this2.hpp from boost/.
[SVN r51910]
2009-03-22 20:14:13 +00:00
9227371881 Move enable_shared_from_this2.hpp to boost/smart_ptr.
[SVN r51909]
2009-03-22 20:13:16 +00:00
e88dd9fc77 Bring back the new enable_shared_from_this.
[SVN r51908]
2009-03-22 20:08:39 +00:00
77971c6ff5 Merge [51686] to release.
[SVN r51847]
2009-03-18 23:02:27 +00:00
1742c37942 Merged [51699] and [51700] from trunk to release.
Closes #1897


[SVN r51703]
2009-03-11 15:08:14 +00:00
fa3c56747d Added missing semicolon at end of &uuml
[SVN r51700]
2009-03-11 13:55:29 +00:00
fbc6919eae Adding documentation for make_shared and allocate_shared to smart_ptr docs.
It is adopted from n2351 "Improving shared_ptr for C++0x, Revision 2". 
Also includes some minor corrections.
Refs #1897



[SVN r51699]
2009-03-11 13:48:51 +00:00
31e06b4a1d Merge [51643] to release. Fixes #2813.
[SVN r51688]
2009-03-10 18:26:57 +00:00
dc3ffc5f4b Attempt to fix como link failure.
[SVN r51686]
2009-03-10 18:07:13 +00:00
0610947c4a De-optimize assignment into this_type(r).swap(*this) - turns out that they were not equivalent, leading to leaks in contrived cases. Refs #2813.
[SVN r51643]
2009-03-07 22:21:56 +00:00
22f1b092c9 Merge [51581] to release. Fixes #2126. Fixes #2584.
[SVN r51632]
2009-03-05 23:06:17 +00:00
9c55fbc6c2 Fix enable_shared_from_this-related tickets in trunk. Refs #2126. Refs #2584.
[SVN r51581]
2009-03-03 19:25:26 +00:00
5a2771e585 Merge [51518] to release. Closes #2814.
[SVN r51539]
2009-03-02 16:45:22 +00:00
dad59f3325 Merge [51517] to release. Closes #2525.
[SVN r51538]
2009-03-02 16:42:28 +00:00
bad394b1e9 Merge [51516] to release. Closes #2662.
[SVN r51537]
2009-03-02 16:39:53 +00:00
f93110620a Merge [51515] to release. Closes #2675.
[SVN r51536]
2009-03-02 16:37:31 +00:00
6be1e3fceb Merge [51514] to release. Closes #2394.
[SVN r51535]
2009-03-02 16:35:06 +00:00
cf91287732 Merge [51509], [51519] to release. Closes #2239.
[SVN r51531]
2009-03-02 16:22:16 +00:00
68c939ec5a Fix #includes in spinlock_test.cpp, spinlock_try_test.cpp, yield_k_test.cpp.
[SVN r51519]
2009-03-01 18:54:51 +00:00
a378c8c278 Refs #2814 (fixed in trunk.)
[SVN r51518]
2009-03-01 18:42:44 +00:00
905a3711db Refs #2525 (fixed in trunk.)
[SVN r51517]
2009-03-01 18:01:19 +00:00
ed32efcc51 Refs #2662 (applied to trunk.)
[SVN r51516]
2009-03-01 17:27:35 +00:00
eb0ff40d62 Refs #2675 (fixed in trunk.)
[SVN r51515]
2009-03-01 17:18:17 +00:00
ad1b344405 Refs #2394 (fixed in trunk.)
[SVN r51514]
2009-03-01 17:10:49 +00:00
0da6902267 Move smart_ptr into boost/smart_ptr/*.hpp (refs #2239).
[SVN r51509]
2009-03-01 16:00:42 +00:00
10f6ff8b77 Sync smart_ptr/test/Jamfile.v2 with release.
[SVN r51486]
2009-02-28 21:08:25 +00:00
13f91c15f0 Sync enable_shared_from_this.hpp and shared_ptr.hpp with release.
[SVN r51485]
2009-02-28 20:02:12 +00:00
a2c5208b8e Sync shared_count.hpp with trunk.
[SVN r51484]
2009-02-28 19:59:56 +00:00
55583ac749 merge of cmake build files from trunk per beman
[SVN r50756]
2009-01-24 18:57:20 +00:00
c40b306647 Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use.
[SVN r49627]
2008-11-07 17:02:56 +00:00
d9b9921d23 Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor
[SVN r49510]
2008-11-01 13:15:41 +00:00
6f91ea87c3 CodeGear patch. Fixes #2342
[SVN r49320]
2008-10-13 19:22:17 +00:00
ed79000ea8 Patch from Ticket #2342
[SVN r49153]
2008-10-06 20:17:18 +00:00
6e804e64b8 Merge 48832-48840 from trunk.
[SVN r48989]
2008-09-28 15:05:17 +00:00
395766e2d3 Fix #2315.
[SVN r48839]
2008-09-17 22:59:07 +00:00
774332f85a Fix #2263. See also [48835].
[SVN r48838]
2008-09-17 22:53:53 +00:00
f5990cab65 Fix #1758. V9 is the default for g++ 4.2 or later, on 4.1 and earlier do not attempt to use CAS on V8.
[SVN r48837]
2008-09-17 22:49:18 +00:00
6175baf858 Fix #2000.
[SVN r48836]
2008-09-17 22:43:14 +00:00
2fb567b3f2 Fix #2336.
[SVN r48835]
2008-09-17 22:37:13 +00:00
2b25579338 Fix #2310.
[SVN r48834]
2008-09-17 22:31:13 +00:00
a97cd2d0cc Fix #2337.
[SVN r48833]
2008-09-17 22:21:56 +00:00
e3b9389a24 Fix #2338.
[SVN r48832]
2008-09-17 22:17:29 +00:00
6ba78f76f6 Merge 47736 from trunk (untabify).
[SVN r47739]
2008-07-23 20:47:47 +00:00
8c7954a53a Untabify.
[SVN r47736]
2008-07-23 20:04:52 +00:00
556b9fe563 Merge 47357 (atomic access N2674 edits) from trunk to release.
[SVN r47358]
2008-07-12 16:18:05 +00:00
77ab953171 Updated atomic access syntax to match N2674 and the WD.
[SVN r47357]
2008-07-12 16:07:20 +00:00
991b02b03e Whitespace fix.
[SVN r47356]
2008-07-12 15:16:31 +00:00
31d0c48f18 Merged 45224, 45225 from trunk to release.
[SVN r47355]
2008-07-12 14:47:13 +00:00
1b49f08cb8 Merged 44686 from trunk to release.
[SVN r47350]
2008-07-12 12:21:19 +00:00
034c12d244 Merged 44636, 44640, 45094 (atomic access) from trunk to release.
[SVN r47349]
2008-07-12 11:57:45 +00:00
f884c53bd6 Updated spinlock_pool.hpp from trunk HEAD; takes care of 45069.
[SVN r47346]
2008-07-12 11:41:20 +00:00
07b4c17980 Merged 44979, 45068, 45085, 45089, 45177, 45194, 45346, 45422, 45545, 46055 from trunk to release
[SVN r47345]
2008-07-12 11:37:16 +00:00
1bc4f16ff8 Update esft_regtest.cpp to trunk HEAD; takes care of 43829, 43856, 44775.
[SVN r47342]
2008-07-12 10:45:56 +00:00
774a8d330c Merged 44595, 44638, 44707, 44711, 44728 from trunk to release
[SVN r47341]
2008-07-12 10:41:24 +00:00
0fd94d6d56 Updated sp_counted_base.hpp to trunk version; takes care of 44369, 44441.
[SVN r47340]
2008-07-12 10:17:08 +00:00
866590ee97 Merged 43316, 43317, 43318, 43733, 43782, 43873, 43888, 43916, 43950, 44055, 44056, 44058, 44073, 44074, 44132, 44137, 44138, 44140, 44344 from trunk to release
[SVN r47339]
2008-07-12 09:55:08 +00:00
2a92df56f2 #include <ia64intrin.h> in spinlock_sync.hpp as well.
[SVN r46055]
2008-06-02 20:01:30 +00:00
a9cd84f43d Fix #1938 in release
[SVN r45691]
2008-05-23 20:30:15 +00:00
366472fc35 Fix #1938 in trunk
[SVN r45690]
2008-05-23 20:29:14 +00:00
2bfe13c9c4 Renamed CRITICAL_SECTION to critical_section to avoid ambiguity.
[SVN r45545]
2008-05-19 15:09:54 +00:00
83e2510ce5 Use the "no_tr1" version of <functional>: addition of Boost.Exception support to throw_exception has created new cyclic dependencies with Boost.TR1.
[SVN r45422]
2008-05-16 11:12:32 +00:00
31685fe551 Updated Borland workaround to properly use BOOST_NO_MEMBER_TEMPLATE_FRIENDS.
[SVN r45347]
2008-05-14 00:21:28 +00:00
05e050abe0 Disable sp_convertible for Borland 5.x.
[SVN r45346]
2008-05-13 23:53:12 +00:00
d261079616 Replaced non-ascii characters, ticket 1736
[SVN r45225]
2008-05-08 19:22:16 +00:00
d52878df88 Replaced non-ascii characters, ticket 1736
[SVN r45224]
2008-05-08 19:08:38 +00:00
4b0490c0ae Fix sp_convertible_test.cpp failure in C++0x mode.
[SVN r45194]
2008-05-07 10:15:16 +00:00
2f1b1acc7a Fix g++ 3.2 regression.
[SVN r45177]
2008-05-06 18:58:15 +00:00
f0f9f72be6 sp_atomic_mt2_test.cpp added.
[SVN r45094]
2008-05-03 22:47:35 +00:00
efdc390bc9 intrusive_ptr::reset() added.
[SVN r45089]
2008-05-03 20:12:25 +00:00
d13f1d8694 More fixes for MSVC 6.0.
[SVN r45086]
2008-05-03 19:43:52 +00:00
83c43617af Fixes for MSVC 6.0.
[SVN r45085]
2008-05-03 19:29:01 +00:00
da323af72d Fixes for old compilers.
[SVN r45069]
2008-05-03 15:33:06 +00:00
0c4aaef77c Fix #1106.
[SVN r45068]
2008-05-03 15:07:58 +00:00
440fcb7ba0 missing workaround.hpp include added
[SVN r45040]
2008-05-02 19:44:56 +00:00
18a6c1add8 make_shared added; tweaks for old compilers; fixes #1884.
[SVN r44979]
2008-05-01 16:50:39 +00:00
357d3c4d54 Fixed comment to reflect the intention and the current code
[SVN r44873]
2008-04-29 05:32:13 +00:00
4bb747fb27 reverted accidental change
[SVN r44839]
2008-04-28 09:04:40 +00:00
f13591ef2b Added detail::try_lock_wrapper for use as scoped_try_lock typedefs, to fix issue #1873
[SVN r44838]
2008-04-28 09:00:58 +00:00
e3422efec6 Improved sp_deleter_wrapper implementation
[SVN r44837]
2008-04-28 07:17:11 +00:00
a01e4c3f83 Refactored and optimized enable_shared_from_this
[SVN r44782]
2008-04-26 19:59:11 +00:00
6f8dc5923c Added new reset()-counterparts for the new ctors
[SVN r44777]
2008-04-26 15:42:13 +00:00
7dc6b3d810 Added a few more tests.
[SVN r44775]
2008-04-26 13:39:52 +00:00
2251b1d2df No need for the new ctors to be templates
[SVN r44772]
2008-04-26 06:36:59 +00:00
8b3907ae81 Remove dynamic_cast in init_internal_shared_once()
[SVN r44744]
2008-04-23 19:32:44 +00:00
77f2d3f614 Reduce enable_shared_from_this overhead (replace _internal_shared_ptr by _internal_shared_count)
[SVN r44730]
2008-04-23 06:12:39 +00:00
93545d5cf2 Silence an g++ -Wextra warning.
[SVN r44728]
2008-04-23 00:33:58 +00:00
9e92c6354c Reduce enable_shared_from_this overhead
[SVN r44724]
2008-04-22 19:48:39 +00:00
e12ed6864b Avoid unneccessary increment/decrement of reference count
[SVN r44711]
2008-04-22 06:31:32 +00:00
b541145a60 Honor BOOST_NO_TEMPLATED_IOSTREAMS.
[SVN r44707]
2008-04-21 23:01:51 +00:00
ca344809ba Remove trailing comma at end of enumerator list (gcc 4.x -pedantic error)
[SVN r44686]
2008-04-21 08:07:55 +00:00
7802c695ef sp_atomic_mt_test.cpp added.
[SVN r44640]
2008-04-20 17:00:58 +00:00
71fa2cd658 Factored out boost/detail/lightweight_thread.hpp.
[SVN r44638]
2008-04-20 15:37:08 +00:00
04be979670 Atomic access added.
[SVN r44636]
2008-04-20 14:59:12 +00:00
35f2af947c Changed #includes to avoid circular dependencies between shared_ptr and TR1.
[SVN r44595]
2008-04-19 16:28:00 +00:00
3a578ac7c1 Added another BOOST_ASSERT to enable_shared_from_this::_internal_accept_owner.
[SVN r44499]
2008-04-17 13:40:44 +00:00
9365853fde Avoid needless overhead of wrapping owner's deleter in deleter_wrapper if
shared_from_this has not been called yet, as Peter suggested
earlier.



[SVN r44448]
2008-04-16 00:06:29 +00:00
16828c9c0a Disabled sync use for hppa.
[SVN r44441]
2008-04-15 19:02:13 +00:00
2fe899cdfe Disable sync use for arm and hppa.
[SVN r44440]
2008-04-15 18:57:46 +00:00
b45d011d5a Honor BOOST_DISABLE_THREADS; route GCC/ARM to the spinlock implementation; fall back to the spinlock implementation instead of using pthread_mutex.
[SVN r44369]
2008-04-13 15:35:40 +00:00
4094c23537 sp_accept_owner added.
[SVN r44353]
2008-04-12 18:22:18 +00:00
f85a1bf406 shared_ptr::lock no longer requires exceptions.
[SVN r44344]
2008-04-12 14:27:22 +00:00
dbd62686a3 ARM assembly fix.
[SVN r44140]
2008-04-09 23:19:22 +00:00
e4f638025c spinlock_gcc_arm.hpp added.
[SVN r44138]
2008-04-09 21:08:39 +00:00
d8296b3933 sp_counted_base_spin.hpp added, enabled by BOOST_SP_USE_SPINLOCK.
[SVN r44137]
2008-04-09 19:58:54 +00:00
b4885a1dd6 Proper try_lock semantics.
[SVN r44132]
2008-04-09 17:49:20 +00:00
748b1baee8 detail/spinlock_pool.hpp added.
[SVN r44074]
2008-04-06 16:53:11 +00:00
4880292c07 Add MT runs of yield_k_test and spinlock_try_test.
[SVN r44073]
2008-04-06 16:23:42 +00:00
6b25c57712 BOOST_COMPILER_FENCE factored out.
[SVN r44058]
2008-04-05 16:32:49 +00:00
373c52efa3 BOOST_SMT_PAUSE factored out.
[SVN r44056]
2008-04-05 15:23:28 +00:00
acb6824ef7 spinlock_nt.hpp added, Cygwin fixes.
[SVN r44055]
2008-04-05 15:06:31 +00:00
316d00c3fc Fix #1759 in release.
[SVN r44005]
2008-04-02 21:52:08 +00:00
515be965bd Fix #1759 in trunk.
[SVN r44004]
2008-04-02 21:42:52 +00:00
6ef32e1627 boost::detail::spinlock added.
[SVN r43950]
2008-03-30 16:33:58 +00:00
2452705117 Missing "inline" added.
[SVN r43916]
2008-03-28 20:44:45 +00:00
bb076d67e6 detail::yield(k) added.
[SVN r43888]
2008-03-27 22:20:11 +00:00
b08789b784 Silence unused parameter warning.
[SVN r43887]
2008-03-27 22:13:55 +00:00
5df69a8946 Added "Throws: nothing" to get_deleter.
[SVN r43873]
2008-03-26 18:34:29 +00:00
dc6a8f0696 _internal_accept_owner now checks if _owned isn't already true.
[SVN r43856]
2008-03-25 15:46:40 +00:00
af7d4fabad New enable_shared_from_this tests, fix.
[SVN r43829]
2008-03-24 16:00:28 +00:00
d17a096407 Fixed compile error with new enable_shared_from_this code,
reported by Tim Blechmann 


[SVN r43823]
2008-03-24 15:07:00 +00:00
d7448b5746 Added a little more test code for new enable_shared_from_this behavior.
[SVN r43804]
2008-03-23 14:51:40 +00:00
f22516d650 Fixed bogus test failure caused by new enable_shared_from_this features.
[SVN r43782]
2008-03-21 21:12:21 +00:00
b30aa1468a Worked around compilation error in boost::get_deleter when using old versions
of g++.



[SVN r43766]
2008-03-21 19:19:25 +00:00
5b17f88f0e Initialize _owned in the copy constructor as well.
[SVN r43739]
2008-03-20 22:10:52 +00:00
1c2d780f9e Added support for calling enable_shared_from_this::shared_from_this in
constructors.  Closes #1696.



[SVN r43738]
2008-03-20 19:32:43 +00:00
2eb3991630 Regression test for enable_shared_from_this.
[SVN r43733]
2008-03-19 19:39:50 +00:00
3a4dc43924 Fix #398, as long as the macros BOOST_NO_STD_TYPEINFO and BOOST_NO_IOSTREAM are defined. I don't know how Boost.Config needs to be changed to autodetect eVC4 and set these on its own.
[SVN r43318]
2008-02-19 14:26:36 +00:00
a055d9829e Fixes #1444.
[SVN r43317]
2008-02-19 14:01:13 +00:00
f596092bac Fixes #1590.
[SVN r43316]
2008-02-19 13:18:58 +00:00
4ba016d29e Merged revisions 43206,43208-43213 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r43206 | danieljames | 2008-02-10 09:55:03 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Fix some broken links.
........
  r43209 | danieljames | 2008-02-10 14:56:22 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Link to people pages on the website, as they've been removed from the download.
........
  r43210 | danieljames | 2008-02-10 15:02:17 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Point links to the pages that used to be in 'more' to the site.
........
  r43212 | danieljames | 2008-02-10 16:10:16 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Fix links on the home page as well.
........
  r43213 | danieljames | 2008-02-10 16:21:22 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Generated documentation which is no longer generated.
........


[SVN r43214]
2008-02-10 16:39:38 +00:00
7ca6d86bdc Point links to the pages that used to be in 'more' to the site.
[SVN r43210]
2008-02-10 15:02:17 +00:00
b2a3c9e59d Link to people pages on the website, as they've been removed from the download.
[SVN r43209]
2008-02-10 14:56:22 +00:00
60ae24f4ae Pick up missing smart_ptr, utility, and type_traits files from full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41386]
2007-11-25 22:34:55 +00:00
dba6ebbb01 Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41370]
2007-11-25 18:38:02 +00:00
d2194e3b24 Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
2007-11-25 18:07:19 +00:00
5ab6b24856 config, detail, filesystem, system, tools, at 41278.
[SVN r41316]
2007-11-23 17:03:14 +00:00
e6f6ec9fa3 Attempt unspecified bool fix for Sun 5.7-5.9
[SVN r40914]
2007-11-07 22:47:55 +00:00
f854829d86 Port unspecified_bool fix for Sun 5.8 from RC_1_34
[SVN r40708]
2007-11-02 23:46:04 +00:00
7b5beeedde fix typo in comment
[SVN r40605]
2007-10-30 12:58:36 +00:00
9e41d1f194 add support for aC++ on HP-UX ia64
[SVN r40604]
2007-10-30 12:48:44 +00:00
f49a2fb1e1 add support for aC++ on HP-UX ia64
[SVN r40603]
2007-10-30 12:43:47 +00:00
87c6b6b403 Starting point for releases
[SVN r39706]
2007-10-05 14:25:06 +00:00
9db307eda5 defined(__ppc) added (Daniel P Furlani)
[SVN r39427]
2007-09-20 20:46:56 +00:00
5a85c1f0f2 CINT support (Nils Krumnack)
[SVN r39282]
2007-09-14 19:19:09 +00:00
f5ce4dbc4c Fixes #1243
[SVN r39199]
2007-09-11 20:58:19 +00:00
b2354d0a5e BOOST_NO_TYPEID support (#1108).
[SVN r38977]
2007-08-26 20:35:52 +00:00
e0ca42bb88 BOOST_NO_TYPEID support (#1108).
[SVN r38976]
2007-08-26 20:34:40 +00:00
bca336bf35 Updated the unspecified_bool_type to match shared_ptr.
[SVN r38975]
2007-08-26 19:42:50 +00:00
6646d8acd2 Remove V1 Jamfiles
[SVN r38516]
2007-08-08 19:02:26 +00:00
c66f0aeecc This commit was manufactured by cvs2svn to create tag
'Version_1_34_1'.

[SVN r38286]
2007-07-24 19:28:14 +00:00
ecb41cb150 sp_unary_addr_test added (reported by Scott French)
[SVN r38137]
2007-07-04 16:35:44 +00:00
ed8db8b5f2 Switched to BSL, Darin Adler has given blanket permission
[SVN r37917]
2007-06-06 16:39:52 +00:00
4ba37fce95 Negative test for conversion to void*
[SVN r37756]
2007-05-23 23:22:45 +00:00
94db735438 gcc-4.2+ moved atomicity.hpp from bits/ to ext/
[SVN r37728]
2007-05-21 01:34:43 +00:00
5b57eff9b8 atomic_count_gcc_x86 added since _sync doesn't work on i386
[SVN r37637]
2007-05-08 20:14:38 +00:00
f980da560a Use __sync intrinsics on g++ 4.1+
[SVN r37528]
2007-04-28 18:13:12 +00:00
ffba68221b Use __sync intrinsics on g++ 4.1+
[SVN r37527]
2007-04-28 16:15:13 +00:00
4d45e5b9b5 Move tests added
[SVN r37526]
2007-04-28 15:49:13 +00:00
86d3f0aba7 Changed move constructors/assignments to leave the source empty
[SVN r37439]
2007-04-15 02:47:45 +00:00
66a25bd4a9 Move support
[SVN r37434]
2007-04-13 22:04:22 +00:00
745dbedbaa Fix CW regression re strcmp, strcpy
[SVN r37407]
2007-04-09 22:24:37 +00:00
26f83e75ef intrusive_ptr::reset added
[SVN r37406]
2007-04-09 21:35:07 +00:00
ce72827dc7 Aliasing support
[SVN r37405]
2007-04-09 18:48:47 +00:00
6e8f075d42 make_shared removed
[SVN r37404]
2007-04-09 18:42:49 +00:00
ae6c180be8 _MANAGED fix for sp_enable_shared_from_this
[SVN r37403]
2007-04-09 16:37:30 +00:00
54e12d03fd Aliasing constructor added
[SVN r37402]
2007-04-09 16:32:45 +00:00
469578e976 Fix C++0x ambiguity between boost::shared_ptr and std::shared_ptr
[SVN r37374]
2007-04-06 00:23:17 +00:00
97118668e2 Fix compare_fail failure
[SVN r37373]
2007-04-06 00:21:41 +00:00
1c3813ce52 BOOST_ASSERTs added (SF patch 1612733 by 'Baraclese')
[SVN r36316]
2006-12-10 21:01:55 +00:00
b440e85452 Fixed get_deleter comment
[SVN r36229]
2006-12-01 14:24:58 +00:00
d889751bc0 License/copyright edits
[SVN r35957]
2006-11-09 20:24:23 +00:00
0609322489 License/copyright edits
[SVN r35957]
2006-11-09 20:24:23 +00:00
b215e34650 License/copyright edits
[SVN r35956]
2006-11-09 20:17:14 +00:00
2f70e81b73 TR1 conformance fix
[SVN r35949]
2006-11-09 12:21:28 +00:00
6284a1abef TR1 conformance fix
[SVN r35948]
2006-11-09 12:15:23 +00:00
c464a07ab1 Merged copyright and license addition
[SVN r35907]
2006-11-07 19:27:00 +00:00
41d4167533 Add copyright, license
[SVN r35905]
2006-11-07 19:11:57 +00:00
4a98c2931c Patch #1551992 (Michael Fink)
[SVN r35882]
2006-11-06 17:25:59 +00:00
75bc821afd Patch #1551992 (Michael Fink)
[SVN r35882]
2006-11-06 17:25:59 +00:00
ebc0af9147 Remove obsolete Boost.Build v1 files.
[SVN r35880]
2006-11-06 17:10:46 +00:00
db0969d97b TR1 cyclic inclusion fix
[SVN r34512]
2006-07-12 12:31:28 +00:00
39551bdc1a A negative test for p > q added.
[SVN r34509]
2006-07-11 23:17:17 +00:00
6412de1dd5 TR1 cyclic dependency fixes.
[SVN r34499]
2006-07-10 13:17:41 +00:00
8d2f7fc5ef g++/SPARC version by Piotr Wyderski, thanks to Tomas Puverle and Michael van der Westhuizen
[SVN r34480]
2006-07-08 17:44:55 +00:00
7c477960d3 Second try, revert to old Sun behavior for 5.8 and below
[SVN r34479]
2006-07-07 22:48:20 +00:00
7e5d7011e6 Attempt to fix sun-5.8 shared_ptr_delete_fail regression
[SVN r34466]
2006-07-06 12:13:25 +00:00
ffd73c39b3 Solaris implementation by Michael van der Westhuizen
[SVN r34450]
2006-07-03 10:02:46 +00:00
4fcee64483 New, improved and more portable unspecified bool type. I hope.
[SVN r33987]
2006-05-17 22:39:34 +00:00
75cd88112c Workaround for MSVC 8.0 managed/unmanaged mismatch (reported by Loic Joly)
[SVN r33968]
2006-05-15 13:56:27 +00:00
203764eb51 Fix VC6 codegen issue (Alain Cormier)
[SVN r33747]
2006-04-19 21:03:18 +00:00
6e120f4bf1 Fix VC6 codegen issue (Alain Cormier)
[SVN r33747]
2006-04-19 21:03:18 +00:00
747c9a1d3e Rvalue auto_ptr constructor is no longer explicit.
[SVN r33526]
2006-03-29 19:19:14 +00:00
7ce5b55f5c Fix issues on HP-UX (ILP32 model)
[SVN r33464]
2006-03-24 00:38:22 +00:00
e38d0daaab Fix issues on HP-UX (ILP32 model)
[SVN r33449]
2006-03-22 22:46:53 +00:00
f3e94d8ca0 This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r33417]
2006-03-21 02:26:31 +00:00
c36e023162 Documented the allocator support
[SVN r33393]
2006-03-19 19:52:00 +00:00
00f744bf1e Minor rewording.
[SVN r33367]
2006-03-18 14:58:20 +00:00
24d1e6f8dd Added 'm'(*pw) inputs (thanks to Howard Hinnant)
[SVN r33364]
2006-03-18 01:48:21 +00:00
ae0a48d544 Removed erroneous // never throws annotations (reported by Scott Meyers)
[SVN r33241]
2006-03-06 23:06:10 +00:00
e427716dc2 Fully qualified detail:: to work around a subtle VC 7.1 problem.
[SVN r32994]
2006-02-18 19:17:33 +00:00
8c256502cc Added a test for rvalue auto_ptrs
[SVN r32327]
2006-01-15 13:55:37 +00:00
a86b2f7fbf Rvalue auto_ptr support, technique by Dave Abrahams
[SVN r32326]
2006-01-15 13:54:53 +00:00
a196f39cd0 Added documentation for pointer_to_other.hpp.
[SVN r31941]
2005-12-06 23:17:32 +00:00
90b5a3736a Pointer utilities added (proposed by Ion Gaztañaga)
[SVN r31932]
2005-12-06 13:26:13 +00:00
2d25f8f036 Qualified ptrdiff_t with std:: (fixes a failure on CW 9.4)
[SVN r31790]
2005-11-27 17:16:30 +00:00
3771707bb7 Added a test for the custom allocator constructor/reset.
[SVN r31624]
2005-11-11 21:07:18 +00:00
239bb6d966 #include reorderings for Boost.TR1
[SVN r31623]
2005-11-11 21:06:08 +00:00
25ca855127 shared_ptr( p, d, a ) added.
[SVN r31613]
2005-11-09 20:05:42 +00:00
0127c06692 Added a note that it's not necessary to initialize _internal_weak_this.
[SVN r31566]
2005-11-05 14:40:29 +00:00
9edd3beebc Added a note that it's not necessary to initialize _internal_weak_this.
[SVN r31565]
2005-11-05 14:33:42 +00:00
92a027fbeb Minor warning fix for SGI MIPSPro (Kevin Wheatley)
[SVN r31113]
2005-09-25 22:00:31 +00:00
7880720bc1 Made the Boost logo link to the home page
[SVN r31112]
2005-09-25 21:54:19 +00:00
235994873f Documented conversion to 'unspecified bool'
[SVN r31111]
2005-09-25 21:49:08 +00:00
7bfddbccf6 Comparison operators against a raw pointer now accept different types
[SVN r31110]
2005-09-25 21:27:00 +00:00
c6a4e93a05 Qualify detail references
[SVN r30824]
2005-09-06 03:28:01 +00:00
ff7e027648 Large patch from Ulrich Eckhardt to fix support for EVC++ 4.
[SVN r30670]
2005-08-25 16:27:28 +00:00
08f517b5b0 Switched to 'int' because 'long' is 64 bits on PPC64
[SVN r30641]
2005-08-23 21:32:42 +00:00
6b3f961542 Removed explicit register use (thanks to Howard Hinnant)
[SVN r30585]
2005-08-15 19:44:15 +00:00
0db2a88403 Merged from 1.33.0 release
[SVN r30540]
2005-08-12 13:02:37 +00:00
afc17037de Another minor documentation fix.
[SVN r30224]
2005-07-22 23:40:53 +00:00
0cee41d47e Minor documentation fix.
[SVN r30190]
2005-07-21 00:51:38 +00:00
eb3d3464db operator< documenation fix.
[SVN r30166]
2005-07-18 20:33:59 +00:00
8d2aeea3a8 Moved warning 8027 suppression above the #includes
[SVN r29852]
2005-06-30 21:49:40 +00:00
675d09723a Lock-free implementation documented, minor changes to align with TR1
[SVN r29536]
2005-06-12 12:58:17 +00:00
24c23b8064 disabled asm implementation for ICC/IA64
[SVN r29166]
2005-05-24 12:11:35 +00:00
880c2e1062 Detabified.
[SVN r29039]
2005-05-18 20:10:01 +00:00
357f57d147 Added a weak_ptr timing test.
[SVN r28483]
2005-04-26 11:08:28 +00:00
8bacee46eb Add x86 assembly implementation for use with CodeWarrior. Commented out initially until we can get more widespread testing for verification of performance improvements (if any).
[SVN r28422]
2005-04-22 16:36:38 +00:00
4e4ec29fc9 Added an implementation of sp_counted_base for g++/ia64.
[SVN r28325]
2005-04-19 17:43:48 +00:00
df1d8b27df Make assembly functions inline to prevent multiple definitions. Required to change from function level assembly to regular functions with statement level assembly.
[SVN r28133]
2005-04-11 15:59:44 +00:00
76722e125f Clear reservation for 970 (thanks to Miro Jurisic and Philip Koch)
[SVN r28060]
2005-04-08 10:39:28 +00:00
d24f6d3b97 Remove hardcoded ebx
[SVN r28017]
2005-04-06 14:12:40 +00:00
6ab6b66601 One more long -> int fix
[SVN r28016]
2005-04-06 13:40:34 +00:00
559056c856 x86-64 fixes: long -> int, lea -> mov+inc
[SVN r28015]
2005-04-06 13:34:41 +00:00
13c128f98f Enabled PPC versions
[SVN r28007]
2005-04-06 08:15:48 +00:00
3ebc9b8f0b Remove extra argument to atomic_dcrement.
[SVN r27994]
2005-04-06 00:32:09 +00:00
361a7c3fd0 PowerPC dispatch added, disabled for now.
[SVN r27988]
2005-04-05 20:39:56 +00:00
faa675ad6a PowerPC implementations added.
[SVN r27986]
2005-04-05 20:29:15 +00:00
319836fe78 Constraints fixed (again), volatile/memory clobber removed from conditional_inc
[SVN r27983]
2005-04-05 16:04:36 +00:00
d0656015ad Fixed 'eax' to '%eax' in clobber; enabled gcc/x86 version
[SVN r27965]
2005-04-04 22:43:03 +00:00
f1a9148a43 Constraints fixed for g++ 3.4, atomic_increment added
[SVN r27958]
2005-04-04 19:36:18 +00:00
1942b64751 weak_ptr_mt_test.cpp added.
[SVN r27938]
2005-04-02 19:35:58 +00:00
a0eb5daf75 Mark eax as earlyclobber
[SVN r27937]
2005-04-02 18:56:38 +00:00
6046a099ba Added an implementation of sp_counted_base for g++/x86
[SVN r27933]
2005-04-02 17:14:26 +00:00
e0ee037e2d Spinlocks removed.
[SVN r27932]
2005-04-02 13:12:28 +00:00
13657c8bda lw_mutex_test added.
[SVN r27931]
2005-04-02 12:51:17 +00:00
52587aaa05 Fixed shared_ptr_delete_fail failure on g++ 3.3 and below
[SVN r27930]
2005-04-02 12:00:14 +00:00
0669d41076 Atomics are in namespace __gnu_cxx for g++ 3.4+
[SVN r27929]
2005-04-02 11:37:53 +00:00
8f2beee8e9 Link fixed.
[SVN r27906]
2005-04-01 19:33:00 +00:00
3adfc7842c Kill *_linux variants of atomic_count and lightweight_mutex.
[SVN r27889]
2005-03-30 22:52:54 +00:00
613e684b30 shared_ptr_delete_fail.cpp added (reported by Dan Bikel)
[SVN r27888]
2005-03-30 22:06:25 +00:00
bfc0225cda Switched to atomic_count
[SVN r27811]
2005-03-24 21:55:24 +00:00
a67e505cf5 Made use of detail/interlocked.hpp
[SVN r27810]
2005-03-24 21:29:29 +00:00
adec862262 atomic_count_test.cpp added.
[SVN r27746]
2005-03-20 15:40:30 +00:00
c6bf857f8b Made the pthread mutex mutable
[SVN r27740]
2005-03-18 21:27:22 +00:00
14024e2598 Add a comment thanking Ben Hutchings for the #w+(#s!=0) formulation
[SVN r27735]
2005-03-18 13:04:43 +00:00
34953d8a45 Split sp_counted_base into no threads (nt), win32 lock-free (w32) and pthreads (pt)
[SVN r27729]
2005-03-18 01:27:11 +00:00
09a0ba8c75 sp_counted_impl_p added for the pointer constructor
[SVN r27727]
2005-03-17 23:30:47 +00:00
b0eb65b433 Refactored sp_counted_impl.hpp out of shared_count.hpp
[SVN r27726]
2005-03-17 23:05:26 +00:00
c830315dff Refactored shared_count.hpp into bad_weak_ptr.hpp, sp_counted_base.hpp
[SVN r27725]
2005-03-17 22:45:11 +00:00
b07447aa6e BCB 6.4 still needs option -pc (reported by Pavel Vozenilek)
[SVN r27672]
2005-03-15 16:02:01 +00:00
42a739b357 Fixed nonportable elision assumption.
[SVN r27093]
2005-02-04 16:39:44 +00:00
7d59d29ad1 HP aCC fix for get_deleter (Jaroslav Gresula)
[SVN r27092]
2005-02-04 16:28:50 +00:00
5616a1a872 Added note on BOOST_MEM_FN_ENABLE_STDCALL.
[SVN r26687]
2005-01-13 13:45:59 +00:00
e5c1e12a66 merge RC_1_32_0 fixes
[SVN r26333]
2004-11-28 04:44:21 +00:00
8f317492ee Outdated comment removed (Jonathan Wakely)
[SVN r26272]
2004-11-22 12:32:35 +00:00
c81be1e2e7 c++boost.gif -> boost.png replacement
[SVN r25573]
2004-10-05 15:45:52 +00:00
1bc58ea861 Updated to use the BSL (using permissions supplied in more/blanket-permission.txt)
[SVN r24804]
2004-08-29 10:29:46 +00:00
27be736b8f Fixed sp_enable_shared_from_this to not use void cv * since this breaks function types.
[SVN r24718]
2004-08-24 16:27:31 +00:00
ef51f6a1de License update
[SVN r24598]
2004-08-19 15:23:47 +00:00
6b00a55542 License updates
[SVN r24597]
2004-08-19 15:19:17 +00:00
858cefbfe8 Removed boost.org copyright assignments, and reverted to orginal author (as based on cvs history).
[SVN r24402]
2004-08-11 10:59:33 +00:00
c7abff0099 Updated Beman Dawes' licence statement to use the new prefered form of words.
[SVN r24370]
2004-08-10 10:34:20 +00:00
cb6cb636f7 Converted to Boost Software License, Version 1.0
[SVN r24055]
2004-07-26 00:32:12 +00:00
366d2666d4 Licence update
[SVN r24031]
2004-07-25 12:01:00 +00:00
9c67a59d43 Fixed lwm_gcc, had the same bug as atomic_count_gcc (Tyson Whitehead)
[SVN r23367]
2004-07-06 10:52:06 +00:00
7361e476b8 Fixed operator--
[SVN r23210]
2004-06-27 15:40:29 +00:00
e1bd18f6a6 Made value_ mutable to enable operator long() const to compile
[SVN r23208]
2004-06-27 15:09:46 +00:00
1346982b80 Fix a typo
[SVN r23077]
2004-06-10 12:31:20 +00:00
c48f05dcb4 enable_shared_from_this is now const-tolerant.
[SVN r22298]
2004-02-16 18:50:07 +00:00
53cc52127b Self-assignment optimization
[SVN r22233]
2004-02-10 23:17:12 +00:00
7fb399b3bb index.htm renamed index.html
[SVN r21231]
2003-12-11 23:31:15 +00:00
93d69af60a _MSC_VER use clarified.
[SVN r20992]
2003-11-28 15:35:21 +00:00
09c8685181 Fixed a VC7 'regression' (pointers to volatile cannot be deleted)
[SVN r20977]
2003-11-27 16:58:23 +00:00
15d6b2aace CWPro8 workaround
[SVN r20323]
2003-10-09 14:14:26 +00:00
feff6e40ea Use conforming is_class for EDG compilers
Make is_enum work for class types which are convertible to anything at
all (on many compilers).

smart_ptr library workarounds for __MWERKS__ (must use member function
pointer for unspecified_bool_type).


[SVN r20244]
2003-10-02 17:49:06 +00:00
26a93f224e Changed index.htm to redirect to smart_ptr.htm
[SVN r20239]
2003-10-01 11:13:04 +00:00
96f572b19b Switched unspecified_bool_type to data member pointer.
[SVN r20238]
2003-10-01 11:12:15 +00:00
d6c4633e89 Add V2 Jamfile
[SVN r20223]
2003-09-30 07:42:34 +00:00
106a6d58d4 Change license message to reference Boost Software License
[SVN r20038]
2003-09-12 17:09:29 +00:00
debd953d8f Use the import rule
[SVN r19968]
2003-09-08 17:38:49 +00:00
f2c5439644 'volatile' fixes.
[SVN r19961]
2003-09-08 12:26:02 +00:00
b4ec0e90fb Switched weak_count_ from #shared+#weak to #weak+(#shared != 0); thanks to Alexander Terekhov and Ben Hutchings
[SVN r19246]
2003-07-21 14:17:03 +00:00
2d4eb92401 get_deleter fix for EDG 2.38
[SVN r19148]
2003-07-16 11:54:49 +00:00
192970b3b8 const_pointer_cast added.
[SVN r19147]
2003-07-16 11:51:12 +00:00
7c36a640ae add_ref split to add_ref_copy and add_ref_lock to eliminate the redundant use_count_ == 0 check.
[SVN r19126]
2003-07-15 12:18:40 +00:00
794de98cd1 #include <boost/config.hpp> added.
[SVN r19065]
2003-07-11 17:03:56 +00:00
dcdbaf1e57 A binary compatible 'null' lightweight_mutex for Win32 added.
[SVN r18916]
2003-07-02 11:54:40 +00:00
6dbec7621d Detect the VC6 STL, not VC6 itself (for Intel)
[SVN r18837]
2003-06-18 16:03:09 +00:00
889cb6bee6 -Wundef fixes.
[SVN r18788]
2003-06-12 17:09:24 +00:00
11cddbbb45 Minor fix, scoped_ptr in the intro should've been shared_ptr.
[SVN r18745]
2003-06-09 18:25:41 +00:00
77c629b6e4 smart_ptr.hpp now includes all smart pointer headers for convenience.
[SVN r18588]
2003-05-28 13:51:35 +00:00
d091ee85c0 Turns out Sun CC doesn't like operator int().
[SVN r18512]
2003-05-23 13:46:07 +00:00
bc00d5fa1a Fixed bool conversions for Sun 5.3
[SVN r18419]
2003-05-16 12:11:17 +00:00
e760759414 Fixed a copy/assignment issue.
[SVN r18122]
2003-03-28 12:27:55 +00:00
deab8ca1bb Added link to enable_shared_from_this.html.
[SVN r17397]
2003-02-14 10:55:20 +00:00
300f8f7b9a Finished Techniques page, added links to it.
[SVN r17380]
2003-02-13 19:07:20 +00:00
d7c841484a Further edits, predestructor technique removed.
[SVN r17374]
2003-02-13 18:35:13 +00:00
f4dce1cb88 More prose.
[SVN r17369]
2003-02-13 16:56:07 +00:00
b400d34bec Added copyright to Jamfiles.
[SVN r17363]
2003-02-13 15:41:26 +00:00
8f0bdd48f8 Minor edits.
[SVN r17335]
2003-02-12 19:11:52 +00:00
6d6bcc7be9 Some prose added.
[SVN r17331]
2003-02-12 17:11:29 +00:00
851d87a1bb get_shared_ptr renamed to weak_ptr::lock.
[SVN r17307]
2003-02-10 15:56:36 +00:00
34f423f811 atomic_count and lightweight_mutex now report an #error on unknown threading configs.
[SVN r17303]
2003-02-10 12:58:50 +00:00
190893a1ce BOOST_ENABLE_SP_DEBUG_HOOKS -> BOOST_SP_ENABLE_DEBUG_HOOKS
[SVN r17301]
2003-02-10 12:54:43 +00:00
4244992d4d Split winapi.hpp across win32-specific headers, added BOOST_USE_WINDOWS_H option.
[SVN r17277]
2003-02-08 16:05:46 +00:00
4b502993b5 Added BOOST_QA_PAGE_SIZE.
[SVN r17270]
2003-02-07 18:43:48 +00:00
a24ec3988a Quick_allocator updates.
[SVN r17267]
2003-02-07 15:08:52 +00:00
23f7532a9f Disabled some watnings.
[SVN r17255]
2003-02-06 17:16:06 +00:00
a790191bc5 Small fixes.
[SVN r17251]
2003-02-06 14:54:15 +00:00
86e9a322ba Documentation fixes, make_shared -> get_shared_ptr.
[SVN r17230]
2003-02-05 12:56:48 +00:00
98fa979aef Added copyright.
[SVN r17197]
2003-02-04 13:35:06 +00:00
be0267f9a3 Enabled copy assignment on all Borland versions (for Kylix) and g++ (for -Wsynth, report by Wolfgang Bangerth)
[SVN r17173]
2003-02-03 13:48:33 +00:00
44afc7e5cd really prevent shared_ptr_alloc_test building from status/.
[SVN r17097]
2003-01-30 20:57:34 +00:00
d2c7febd26 cleanup, add shared_ptr_alloc_test.
[SVN r17095]
2003-01-30 18:20:51 +00:00
ddf1f0fdcc Fixed a deadlock in free_unreachable_objects.
[SVN r17090]
2003-01-30 15:06:32 +00:00
cd41426fe9 Dave's quick_allocator added, #define BOOST_SP_USE_QUICK_ALLOCATOR to make shared_ptr use it.
[SVN r17087]
2003-01-30 14:20:22 +00:00
89ea2156bc intrusive_ptr_test.cpp added.
[SVN r17051]
2003-01-27 14:09:21 +00:00
fabd6e5755 Moved 'garbage collector' to sp_collector.cpp, collector_test.cpp added.
[SVN r17050]
2003-01-27 14:02:00 +00:00
b60de38d28 Fixed broken links.
[SVN r17044]
2003-01-25 17:58:01 +00:00
2dbfc89d4e Removed redundant copy constructor and copy assignment.
[SVN r17043]
2003-01-25 16:51:45 +00:00
abb0d9e725 Moved smart_ptr contents to subdirectories, switched to a local test/Jamfile.
[SVN r17042]
2003-01-25 16:17:17 +00:00
d030182e87 intrusive_ptr_test added.
[SVN r16993]
2003-01-22 15:22:30 +00:00
bd39e2eded intrusive_ptr.html added.
[SVN r16981]
2003-01-21 17:21:24 +00:00
d04757128c shared_ptr techniques initial commit
[SVN r16978]
2003-01-21 15:55:59 +00:00
868062e81d Add TOC and References sections
[SVN r16912]
2003-01-15 16:35:48 +00:00
6bd66fe054 detail::counted_base renamed to sp_counted_base.
[SVN r16900]
2003-01-14 15:13:53 +00:00
c5bae28eeb use_count() postconditions added; enable_..._test.cpp renamed.
[SVN r16896]
2003-01-13 18:32:16 +00:00
78a47d7619 Algorithm improvements, free_unreachable_objects() added.
[SVN r16894]
2003-01-13 17:11:28 +00:00
8eaf187dbd fix bookmarks
[SVN r16827]
2003-01-09 13:37:41 +00:00
d36a215554 fix invalid bookmarks
[SVN r16824]
2003-01-09 13:11:10 +00:00
8448bbf0b9 Fixes.
[SVN r16795]
2003-01-08 15:01:04 +00:00
1dee6e0229 Small optimization.
[SVN r16790]
2003-01-07 23:12:02 +00:00
e3f2329c14 report_unreachable_objects() added to sp_debug_hooks.cpp
[SVN r16780]
2003-01-07 15:34:56 +00:00
3e616752c9 weak_ptr documentation updated; still a work in progress.
[SVN r16748]
2003-01-04 14:24:14 +00:00
987a7d32fb Documentation updated to reflect changes to shared_ptr
[SVN r16739]
2003-01-03 16:53:04 +00:00
fafd9a863b Workarounds for vc6-stlport
[SVN r16706]
2002-12-26 18:23:11 +00:00
51e9783a21 Factor out get_pointer, supply an overload for std::auto_ptr.
[SVN r16672]
2002-12-20 18:15:01 +00:00
eee96e8059 Borland 5.6.1 still broken.
[SVN r16666]
2002-12-19 18:15:53 +00:00
1ef2a5b059 More weak_ptr tests.
[SVN r16487]
2002-12-03 13:27:35 +00:00
c5f7c973d9 Bug in get_deleter fixed.
[SVN r16477]
2002-12-02 14:34:06 +00:00
572a97d3c4 Casts renamed.
[SVN r16457]
2002-11-29 14:05:22 +00:00
a3d87ff623 Comeau-specific fix.
[SVN r16456]
2002-11-28 13:42:44 +00:00
468f63261a weak_ptr_test.cpp added.
[SVN r16427]
2002-11-26 16:01:17 +00:00
e60c1f9b49 Some versions of g++ 2.9x don't have basic_ostream.
[SVN r16406]
2002-11-25 13:52:42 +00:00
72bcb8ff46 More tests added.
[SVN r16405]
2002-11-25 13:51:56 +00:00
12b1871136 operator<< added, as the conversion to 'bool' implicitly defines one anyway.
[SVN r16403]
2002-11-25 12:27:11 +00:00
9632464c45 Test w/ NULL pointer to enabled_... object added; bug fixed.
[SVN r16402]
2002-11-25 12:17:56 +00:00
1311731e24 Moved the old shared_ptr tests into shared_ptr_basic_test.cpp
[SVN r16401]
2002-11-25 12:12:45 +00:00
980307a90a Reintroduced weak_ptr converting constructor; map<weak_ptr<>, ...> is important.
[SVN r16400]
2002-11-25 12:09:13 +00:00
1f9908be69 Borland C++ 5.6 still needs the workaround.
[SVN r16379]
2002-11-23 19:18:05 +00:00
0aaca2fffe More operator< tests.
[SVN r16377]
2002-11-23 12:59:01 +00:00
5dd2c62132 weak_ptr converting constructor removed; operator< can now take different types to aid ownership tests.
[SVN r16376]
2002-11-23 12:47:38 +00:00
fadc0716ce get_deleter_test added; associated fixes.
[SVN r16373]
2002-11-22 16:29:51 +00:00
ea285b4231 Fixed the previous weak_ptr 'fix'.
[SVN r16370]
2002-11-22 14:41:22 +00:00
8d6517484c Stricter tests; associated bug fixes. ;-)
[SVN r16369]
2002-11-22 13:49:54 +00:00
66a8e8b3c1 get_deleter<> added.
[SVN r16365]
2002-11-21 14:46:45 +00:00
c697e2ef21 Sample implementation of the smart pointer debug hooks.
[SVN r16364]
2002-11-21 13:23:15 +00:00
2e53e2e5d7 More tests added.
[SVN r16363]
2002-11-21 13:20:46 +00:00
8283ec826b Changed debug hook names, reverted weak_ptr() to have use_count of zero.
[SVN r16362]
2002-11-21 13:14:04 +00:00
e32b2adfda Debug hook support, removed self-reset, fixed #%20links.
[SVN r16361]
2002-11-21 13:10:18 +00:00
e555d33695 Added array versions of the hooks.
[SVN r16346]
2002-11-20 16:18:13 +00:00
de68e6ed1e A missing 'inline' added.
[SVN r16343]
2002-11-20 13:34:18 +00:00
804b1483c7 enable_shared_from_this-related fixes.
[SVN r16341]
2002-11-20 12:38:51 +00:00
4b200e9847 Borland fix (thanks to Fernando Cacciola)
[SVN r16331]
2002-11-19 18:21:32 +00:00
f34866e8a5 License added.
[SVN r16326]
2002-11-19 16:23:01 +00:00
45c799f40c Debug hook support moved to shared_count.
[SVN r16325]
2002-11-19 16:18:58 +00:00
11a046f628 BOOST_ASSERTs added.
[SVN r16324]
2002-11-19 16:18:18 +00:00
b632f1ef20 Debug hooks, general cleanup.
[SVN r16323]
2002-11-19 16:11:21 +00:00
7f30268b10 Assignment tests added.
[SVN r16322]
2002-11-19 16:10:38 +00:00
7504eff5af A missing Returns clause added.
[SVN r16321]
2002-11-19 16:10:07 +00:00
8752c00ebf enable_shared_from_this documentation added.
[SVN r16319]
2002-11-19 14:22:58 +00:00
d0c5e83def Test for enable_shared_from_this added.
[SVN r16318]
2002-11-19 13:45:33 +00:00
f6b7ff4b34 Major changes to shared_ptr and weak_ptr
[SVN r16314]
2002-11-18 14:37:02 +00:00
2314f20c4e element_type added
[SVN r16264]
2002-11-15 19:44:48 +00:00
ff7410cad2 Fixed a subtle problem in counted_base::release (report and test case by Per Kristensen)
[SVN r16211]
2002-11-12 13:14:50 +00:00
57c0ad44f3 Changed typename to class; some libraries helpfully #define typename
[SVN r15970]
2002-10-23 13:55:18 +00:00
ae60bcaffb Small fixes.
[SVN r15951]
2002-10-17 13:23:11 +00:00
f2f616a95c BOOST_SP_USE_STD_ALLOCATOR support
[SVN r15807]
2002-10-08 16:37:33 +00:00
a8bb455df7 Fixes, notes.
[SVN r15486]
2002-09-23 13:22:38 +00:00
9dcbc46225 Minor fix
[SVN r15437]
2002-09-18 13:00:38 +00:00
024f918b86 More documentation fixes reflecting Dave Abrahams' comments
[SVN r15411]
2002-09-17 13:59:17 +00:00
0f05f41306 Documentation fixes (reflecting Dave Abrahams' comments)
[SVN r15382]
2002-09-16 15:26:52 +00:00
4ea6decc7d scoped_ptr::reset changed to copy+swap (problem reported by Thomas Witt)
[SVN r15239]
2002-09-09 17:44:33 +00:00
f79b8cb7ae Tabs removed.
[SVN r15175]
2002-09-06 12:50:02 +00:00
275cb77378 Fixed broken links.
[SVN r15123]
2002-08-31 13:04:52 +00:00
b916445dd8 weak_ptr documentation updates; get() declared deprecated.
[SVN r15111]
2002-08-29 15:18:04 +00:00
c02fee7013 *_ptr.hpp:
- Revert addition of is_pointerlike_helper

weak_ptr.hpp:
  - Revert addition of get_pointer


[SVN r15108]
2002-08-29 13:49:05 +00:00
e77889679f intrusive_ptr.hpp:
scoped_ptr.hpp:
  - include <boost/type_traits/ice.hpp>


[SVN r15104]
2002-08-27 13:33:22 +00:00
b9dceb2340 *_ptr.hpp:
- Added detail::is_pointerlike_helper function templates for Signals

weak_ptr.hpp:
  - Added get_pointer function template for weak_ptr


[SVN r15099]
2002-08-26 15:27:23 +00:00
e84eb3f1ba Added #pragma's to fix codeguard errors.
[SVN r14984]
2002-08-20 11:08:11 +00:00
92999be436 Corrected the shared_ptr(auto_ptr<Y> &) postcondition (reported by Maciej Sobczak)
[SVN r14953]
2002-08-19 16:23:07 +00:00
bd4f575567 HPUX 10.20 patch (problem reported by Tom Matelich)
[SVN r14943]
2002-08-17 13:33:41 +00:00
09016db3c3 Note added to shared_ptr(Y*, D).
[SVN r14942]
2002-08-17 13:05:25 +00:00
c2ee5172b0 Switched to <boost/detail/lightweight_test.hpp> for testing.
[SVN r14932]
2002-08-16 16:41:16 +00:00
8436c4d271 #pragma option -pc around use_count_is_zero added for Borland 5.5.1, to enable compilation with -ps set.
[SVN r14927]
2002-08-16 15:55:19 +00:00
a09c2e556f BOOST_NO_EXCEPTIONS support added.
[SVN r14835]
2002-08-14 12:27:22 +00:00
e650c7ff16 Changed BOOST_TEST(p) to BOOST_TEST(p? true: false) to make sure the right thing is being tested.
[SVN r14834]
2002-08-14 11:59:13 +00:00
c06b4206f2 #include <iostream> added.
[SVN r14813]
2002-08-13 15:58:12 +00:00
89435a6287 get_pointer added.
[SVN r14628]
2002-07-27 16:02:26 +00:00
5328674c2d Minor scoped_* fix (px -> ptr) (Thanks to Bertolt Mildner)
[SVN r14619]
2002-07-26 14:18:21 +00:00
927fe73093 Changed #ifdefs so that member templates aren't disabled by an empty config.hpp.
[SVN r14589]
2002-07-24 15:36:25 +00:00
053aa108e3 Tabs. Grrr.
[SVN r14588]
2002-07-24 14:14:17 +00:00
b5e5c35696 Minor updates.
[SVN r14580]
2002-07-24 10:20:30 +00:00
77ad156c52 Design notes updated.
[SVN r14575]
2002-07-23 19:12:40 +00:00
018c401e47 Best practices section, thread safety section, design notes added.
[SVN r14572]
2002-07-23 15:19:22 +00:00
f586d3f83e shared_ptr<void const> support added.
[SVN r14570]
2002-07-23 12:33:11 +00:00
3f0ebd4c71 'shared_from_this' added.
[SVN r14561]
2002-07-22 16:36:52 +00:00
33077bda71 Win64 patch (Tim Fenders)
[SVN r14537]
2002-07-19 20:06:35 +00:00
547888d507 Consistent 'bool' conversions; scoped_ptr(auto_ptr); get_pointer(scoped_ptr) added.
[SVN r14496]
2002-07-17 15:15:39 +00:00
af6fe18c9d Minor fixes.
[SVN r14464]
2002-07-15 12:52:29 +00:00
dca9628be3 Disabled some Borland warnings (David B. Held)
[SVN r14368]
2002-07-09 12:06:46 +00:00
d84fa738ef Sleep(0) changed to Sleep(1) to (hopefully) avoid livelocks.
[SVN r14226]
2002-06-22 15:55:01 +00:00
a322dc54dc Platform-specific spinlocks disabled by default unless BOOST_LWM_USE_SPINLOCK is defined.
[SVN r14213]
2002-06-20 15:16:03 +00:00
951c2b7e83 counted_base is now smaller
[SVN r14212]
2002-06-20 14:56:10 +00:00
23f68a5657 Added libstdc++ v3 specific lightweight_mutex and atomic_count (contributed by Lars Gullik Bjønnes)
[SVN r13999]
2002-05-21 16:48:20 +00:00
ecb0b4478b Typo fixed.
[SVN r13770]
2002-05-09 11:16:29 +00:00
70255d46bb Documented templated pointer constructors, revised the intro a bit.
[SVN r13665]
2002-05-04 14:27:21 +00:00
4653c3673b shared_ptr now autodetects counted_bases; minor test updates; intrusive_ptr no longer calls addref/release for NULL pointers.
[SVN r13602]
2002-05-01 11:22:22 +00:00
11eacab70e Made shared_ptr::share_ptr(Y * p) a member template.
[SVN r13551]
2002-04-23 14:56:42 +00:00
110c0021e2 counted_base default constructor added
[SVN r13542]
2002-04-22 18:01:19 +00:00
4c5e355a0b Bugfixes.
[SVN r13541]
2002-04-22 09:37:08 +00:00
fbc9028313 intrusive_ptr.hpp added (still experimental)
[SVN r13526]
2002-04-19 19:34:16 +00:00
9b800d4f84 Added more mem_fn, shared_ptr tests.
[SVN r13432]
2002-04-10 16:04:53 +00:00
513752eee5 Worked around an MSVC 6 bug (Markus Schoepflin)
[SVN r13430]
2002-04-10 14:12:12 +00:00
9eb1ba7e9f test_main args must be *[] not ** for new rev of test tools
[SVN r13381]
2002-04-06 21:44:37 +00:00
fb5b1a20d2 Small modifications.
[SVN r13212]
2002-03-15 22:03:56 +00:00
b89945d36a Added winapi.hpp and a CRITICAL_SECTION lightweight_mutex variant.
[SVN r13211]
2002-03-15 22:00:10 +00:00
220f35a0f1 Casts removed as unsafe, added intro paragraph about make_shared.
[SVN r13180]
2002-03-12 14:39:22 +00:00
72f83165e0 Removed casts as unsafe.
[SVN r13179]
2002-03-12 14:02:38 +00:00
c17f8c36c1 weak_ptr::expired() added; weak_ptr documentation updated.
[SVN r13141]
2002-03-08 16:56:16 +00:00
8e604a9da9 Disabled the linux-specific versions since using kernel headers is problematic. #define BOOST_USE_ASM_ATOMIC_H to get them back.
[SVN r12995]
2002-03-01 16:17:08 +00:00
3e0233a26c Minor text updates in history section.
[SVN r12956]
2002-02-27 17:03:30 +00:00
aa98e2b37e Added lwm_irix.hpp (contributed by Dan Gohman)
[SVN r12955]
2002-02-27 16:35:15 +00:00
7b53c0040c More output.
[SVN r12852]
2002-02-18 12:39:32 +00:00
e6605637f8 BOOST_LWM_WIN32_USE_CRITICAL_SECTION option.
[SVN r12842]
2002-02-16 18:45:20 +00:00
6dfe0896e3 Untabified.
[SVN r12838]
2002-02-16 16:14:16 +00:00
9f295cbb48 Threaded test added.
[SVN r12837]
2002-02-16 16:09:08 +00:00
76c19e6111 Enabled lwm_linux.hpp in lightweight_mutex.hpp.
[SVN r12834]
2002-02-16 15:00:55 +00:00
6e6a2a013a Added lwm_linux.hpp
[SVN r12833]
2002-02-16 14:34:34 +00:00
2482e00224 Modified scoped_* to use checked_delete; HP aCC doesn't like the inline assertions.
[SVN r12832]
2002-02-16 13:23:01 +00:00
7981b647c3 lwm_nop fixed to not emit warnings on g++; locking code #ifdef'ed since compilers sometimes have trouble removing it.
[SVN r12822]
2002-02-15 18:07:42 +00:00
875bab352c Added a timing test for the single/multi threaded perf ratio (~2:1)
[SVN r12821]
2002-02-15 18:06:17 +00:00
862dc0001f Documented the bool conversion.
[SVN r12817]
2002-02-15 14:46:53 +00:00
adc3ec3851 Fixes.
[SVN r12816]
2002-02-15 14:19:30 +00:00
5a6cd1cf3e Added a default constructor to shared_count and shared_ptr for incomplete types (void).
[SVN r12815]
2002-02-15 13:31:58 +00:00
5e2f514140 Added forward declaration of 'weak_count' class, which is referenced in
shared_count; the friend declaration does not suffice to forward-declare the
name.


[SVN r12813]
2002-02-14 23:08:30 +00:00
309e6dd82e Revised to match the style of the C++ standard.
[SVN r12806]
2002-02-14 17:12:07 +00:00
6c5d296722 Modified weak_ptr to reflect list comments.
[SVN r12793]
2002-02-13 13:16:15 +00:00
b1a1ab99aa Bug fixes.
[SVN r12787]
2002-02-12 20:38:31 +00:00
1b69c14f45 weak_ptr made thread safe, shared->weak conversions, lightweight_mutex added.
[SVN r12786]
2002-02-12 16:55:25 +00:00
cd8dea78e6 Don't reinclude, since everything we need to include is already taken
care of by <boost/shared_ptr.hpp>.


[SVN r12776]
2002-02-09 17:18:38 +00:00
d77b35f333 Fix the g++ 2.9x operator!= ambiguity.
[SVN r12772]
2002-02-09 15:45:29 +00:00
6f7b927641 weak_ptr::operator< is now stable, shared_ptr_test has much better coverage.
[SVN r12769]
2002-02-09 12:34:05 +00:00
d2e20cf56c Remove obsolete paragraph
[SVN r12767]
2002-02-09 02:54:00 +00:00
a6126b1370 Fixed some broken internal links.
[SVN r12766]
2002-02-09 01:18:00 +00:00
87f0accb23 Minor fixes.
[SVN r12763]
2002-02-08 20:45:04 +00:00
7add76dae8 Always say "private noncopyable" to avoid warnings.
[SVN r12762]
2002-02-08 20:08:15 +00:00
2a2f10fddd Borland 5.5.1 fix
[SVN r12761]
2002-02-08 18:40:49 +00:00
0dd3285d56 New casts for smart pointers.
[SVN r12743]
2002-02-06 19:42:04 +00:00
f9782387d9 Tweaks.
[SVN r12715]
2002-02-04 22:52:48 +00:00
e1567707b1 Tab removed :-)
[SVN r12701]
2002-02-04 19:45:11 +00:00
08df55159b Fix broken links
[SVN r12697]
2002-02-04 18:51:16 +00:00
c29cc62d66 Minor tweaks.
[SVN r12684]
2002-02-04 11:15:40 +00:00
6ed07733cb Fix atomic_count.hpp includes, convert Macintosh newlines to Unix ones,
since Metrowerks supports either and the rest of Boost uses Unix ones.


[SVN r12683]
2002-02-04 08:00:20 +00:00
ee3d3bd1e1 Mention thread safety feature.
[SVN r12676]
2002-02-03 17:50:11 +00:00
758954a93f Documentation updates.
[SVN r12675]
2002-02-03 17:46:08 +00:00
590757e2b2 Don't give default arguments to function parameters what subsequent parameters do not have default arguments
[SVN r12670]
2002-02-03 15:21:41 +00:00
ddd6d54426 Need to include utility.hpp to get noncopyable
[SVN r12669]
2002-02-03 15:19:04 +00:00
1a7cd887e4 New smart pointer documentation. Related clean-up of the smart pointer
library. Changing includes to include the new individual smart pointer
headers. Replacing old smart pointer library with an include of the new
smart pointer headers. Simplify ifdefs that involve the member templates
macros now that BOOST_MSVC6_MEMBER_TEMPLATES is also guaranteed to bet
set for platforms that have full member templates.


[SVN r12647]
2002-02-02 18:36:12 +00:00
d3c76575f9 templated copy constructor added.
[SVN r12644]
2002-02-02 16:19:45 +00:00
b224270cc0 auto_ptr& constructor now has no effects when exception is thrown
[SVN r12643]
2002-02-02 16:18:04 +00:00
8b5b780c2c better weak_ptr coverage
[SVN r12624]
2002-02-01 19:34:31 +00:00
39c10f739d added an auto_ptr & constructor to shared_count
[SVN r12623]
2002-02-01 18:40:35 +00:00
4fdc84f29e Make the non-threads version work.
[SVN r12597]
2002-01-31 06:52:58 +00:00
a8efe20862 Comments added.
[SVN r12510]
2002-01-25 16:10:26 +00:00
58c5711b47 Added tests for the new smart pointers.
[SVN r12500]
2002-01-25 13:54:30 +00:00
5d564a2f01 Add a self-assignment assert to reset(). Also add an overload of reset to
allow resetting to a new pointer with a new deletion function.


[SVN r12491]
2002-01-24 19:16:12 +00:00
09c1476063 Smart pointer enhancements, initial commit
[SVN r12439]
2002-01-22 13:38:52 +00:00
f255439ece add eof newline
[SVN r12358]
2002-01-19 15:54:28 +00:00
b104e9ae78 smart_ptr.hpp less<> fixed, partial specialization enabled on Sun 5.3
[SVN r12334]
2002-01-17 12:46:45 +00:00
4f964ce6ad Add FAQ: why no release()
[SVN r12286]
2002-01-11 20:20:07 +00:00
11ec515378 Fix broken link
[SVN r12285]
2002-01-11 16:15:09 +00:00
1a9b1dd123 1.25.0 Final runup
[SVN r11315]
2001-10-01 15:54:23 +00:00
a93dfc1837 Fix broken hyperlink
[SVN r10896]
2001-08-19 15:08:33 +00:00
c5846378ab More FAQ entries added.
[SVN r10605]
2001-07-13 16:32:34 +00:00
aea7d0c9c8 Add FAQ why use_count()?
[SVN r10604]
2001-07-13 14:07:08 +00:00
65c3f2dc85 Add table of contents, improve the FAQ
[SVN r10599]
2001-07-12 19:51:53 +00:00
5fbc553611 Reorder shared_ptr code so VC++ 6 member templates work, allowing polymorphic pointers to now work with that compiler (Gary Powell)
[SVN r10548]
2001-07-06 13:23:07 +00:00
c41b060618 Initial checkin
[SVN r10221]
2001-05-24 18:43:24 +00:00
c17921c417 Documentation and example program improvements
[SVN r10220]
2001-05-24 18:42:25 +00:00
94287044ba Oops! Fix boo boo from prior fix
[SVN r10206]
2001-05-24 01:32:07 +00:00
7c09884eac Move MS VC++ pragmas to workaround compiler crash reported by several people with SP4 and SP5.
[SVN r10204]
2001-05-23 20:14:15 +00:00
a90a157ea6 Smart pointer and utility changes related to adding checked_delere and checked_array_delete
[SVN r10189]
2001-05-22 18:58:21 +00:00
ac8d0f5505 Fix doc errors, add shared_ptr_example program
[SVN r10165]
2001-05-21 14:58:07 +00:00
8f23f07740 Fix transitive dependency bug
[SVN r10164]
2001-05-21 14:56:51 +00:00
3b183163c9 Clarify rationale for noncopyability
[SVN r10085]
2001-05-10 16:00:49 +00:00
55a377b446 Change all eGroups references to YahooGroups
[SVN r9979]
2001-04-25 00:24:50 +00:00
2d342f0ddf Comment corrected (thanks to Joe Gottman)
[SVN r9582]
2001-03-19 12:34:12 +00:00
060ea4a573 Add a couple of comments to cut down on FAQ's
[SVN r9581]
2001-03-18 22:25:51 +00:00
6a12efb77b 1.21.1 run up, including new download instructions and fix broken hyperlinks
[SVN r9557]
2001-03-14 15:11:55 +00:00
e57d3f4bc1 Fix revision date
[SVN r9069]
2001-02-10 12:47:02 +00:00
16902b1f4f Add example
[SVN r9054]
2001-02-09 14:39:43 +00:00
cb1b1b7cc0 Suppress some useless warnings with MSVC
[SVN r8704]
2001-01-22 04:53:38 +00:00
26fe4c4078 Fix typo shared_array should have read shared_ptr in one place (Ed Brey)
[SVN r8392]
2000-12-06 14:46:44 +00:00
4e832788bf Fix for egcs 1.1.1 problems with std::auto_ptr
[SVN r8225]
2000-11-16 11:17:22 +00:00
db43d160b4 libraries.htm and people.htm moved to sub-directories to make root directory cleaner.
[SVN r8166]
2000-11-10 15:39:05 +00:00
1412e40490 Make shared_ptr ctor from auto_ptr explicit. (Robert Vugts)
[SVN r8012]
2000-10-19 21:16:46 +00:00
00c5642eb4 1.17.0 release candidate runup
[SVN r7683]
2000-08-03 15:26:16 +00:00
d3347b6d08 Initial HTML commit
[SVN r7640]
2000-07-27 14:27:00 +00:00
ed7e13da9f Initial commit
[SVN r7638]
2000-07-27 14:18:23 +00:00
90b7ec19d1 Changed throw() to // never throws.
[SVN r7628]
2000-07-24 16:21:10 +00:00
468c41041b This commit was generated by cvs2svn to compensate for changes in r4,
which included commits to RCS files with non-trunk default branches.


[SVN r7621]
2000-07-07 16:04:40 +00:00
440 changed files with 57288 additions and 0 deletions

383
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,383 @@
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
UBSAN_OPTIONS: print_stacktrace=1
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-18.04
install: g++-4.8-multilib
address-model: 32,64
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-5-multilib
address-model: 32,64
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-6-multilib
address-model: 32,64
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: g++-7-multilib
address-model: 32,64
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: g++-8-multilib
address-model: 32,64
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-9-multilib
address-model: 32,64
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-10-multilib
address-model: 32,64
- toolset: gcc-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install: g++-11-multilib
address-model: 32,64
- toolset: gcc-12
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install: g++-12-multilib
address-model: 32,64
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-18.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-18.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17"
os: ubuntu-20.04
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-13
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install: clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install: clang-14
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
- name: Run tests
run: |
cd ../boost-root
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.0
cxxstd: 14,latest
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: clang-win
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
posix-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Use library with add_subdirectory
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
- name: Install
run: |
cd ../boost-root/__build__
cmake --build . --target install
- name: Use the installed library
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
- name: Build tests
run: |
cd ../boost-root/__build__
cmake --build . --target tests
- name: Run tests
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error

223
.travis.yml Normal file
View File

@ -0,0 +1,223 @@
# Copyright 2016-2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
dist: xenial
branches:
only:
- master
- develop
- /feature\/.*/
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
dist: trusty
compiler: g++
env: TOOLSET=gcc CXXSTD=03,11
- os: linux
dist: xenial
compiler: g++
env: TOOLSET=gcc CXXSTD=03,11,14
- os: linux
dist: bionic
compiler: g++
env: TOOLSET=gcc CXXSTD=03,11,14,17
- os: linux
dist: focal
compiler: g++
env: TOOLSET=gcc CXXSTD=03,11,14,17
- os: linux
arch: arm64
compiler: g++
env: TOOLSET=gcc CXXSTD=03,11,14
- os: linux
arch: ppc64le
compiler: g++
env: TOOLSET=gcc CXXSTD=03,11,14
- os: linux
arch: s390x
compiler: g++
env: TOOLSET=gcc CXXSTD=03,11,14
- os: freebsd
compiler: clang++
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
- os: linux
compiler: g++-4.4
env: TOOLSET=gcc CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: bionic
compiler: g++-10
env: UBSAN=1 TOOLSET=gcc CXXSTD=03,11,14 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-10
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: bionic
compiler: g++-10
env: UBSAN=1 TOOLSET=gcc CXXSTD=17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-10
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMMENT=clang-3.3 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMMENT=clang-3.4 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.4
- os: linux
compiler: clang++-11
env: UBSAN=1 TOOLSET=clang CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-11
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: trusty
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- os: linux
dist: bionic
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- os: osx
compiler: clang++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
- os: linux
env: CMAKE_TEST=1
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=smart_ptr -DBUILD_TESTING=ON ..
- cmake --build . --target tests -- -k
- ctest --output-on-failure -R boost_smart_ptr
- os: linux
compiler: g++
env: CMAKE_SUBDIR_TEST=1
script:
- cd libs/smart_ptr/test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
- os: linux
env: CMAKE_INSTALL_TEST=1
script:
- pip install --user cmake
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=smart_ptr -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build . --target install
- cd ../libs/smart_ptr/test/cmake_install_test && mkdir __build__ && cd __build__
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/align
- git submodule init libs/assert
- git submodule init libs/atomic
- git submodule init libs/config
- git submodule init libs/container_hash
- git submodule init libs/core
- git submodule init libs/move
- git submodule init libs/predef
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/type_traits
- git submodule init libs/detail
- git submodule init libs/integer
- git submodule init tools/build
- git submodule init libs/headers
- git submodule init tools/boost_install
- git submodule init tools/cmake
- git submodule init libs/preprocessor
- git submodule init libs/bind
- git submodule update # no --jobs 3 on non-amd64
- cp -r $TRAVIS_BUILD_DIR/* libs/smart_ptr
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $TRAVIS_COMPILER ;" > ~/user-config.jam
- ./b2 -j3 libs/smart_ptr/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
notifications:
email:
on_success: always

29
CMakeLists.txt Normal file
View File

@ -0,0 +1,29 @@
# Copyright 2018-2020 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
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_smart_ptr VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_smart_ptr INTERFACE)
add_library(Boost::smart_ptr ALIAS boost_smart_ptr)
target_include_directories(boost_smart_ptr INTERFACE include)
target_link_libraries(boost_smart_ptr
INTERFACE
Boost::assert
Boost::config
Boost::core
Boost::move
Boost::static_assert
Boost::throw_exception
Boost::type_traits
)
if(BUILD_TESTING)
add_subdirectory(test)
endif()

6
README.md Normal file
View File

@ -0,0 +1,6 @@
# Boost.SmartPtr
Branch | Travis | Appveyor
---------|--------|---------
Develop | [![Build Status](https://travis-ci.org/boostorg/smart_ptr.svg?branch=develop)](https://travis-ci.org/boostorg/smart_ptr) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/smart_ptr?branch=develop&svg=true)](https://ci.appveyor.com/project/pdimov/smart-ptr)
Master | [![Build Status](https://travis-ci.org/boostorg/smart_ptr.svg?branch=master)](https://travis-ci.org/boostorg/smart_ptr) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/boostorg/smart_ptr?branch=master&svg=true)](https://ci.appveyor.com/project/pdimov/smart-ptr)

82
appveyor.yml Normal file
View File

@ -0,0 +1,82 @@
# Copyright 2016-2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /feature\/.*/
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
ADDRMD: 32
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: clang-win
CXXSTD: 14,17,latest
ADDRMD: 64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
install:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/align
- git submodule init libs/assert
- git submodule init libs/atomic
- git submodule init libs/config
- git submodule init libs/container_hash
- git submodule init libs/core
- git submodule init libs/move
- git submodule init libs/predef
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/type_traits
- git submodule init libs/detail
- git submodule init libs/integer
- git submodule init tools/build
- git submodule init libs/headers
- git submodule init tools/boost_install
- git submodule init libs/bind
- git submodule update --jobs 3
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\smart_ptr\
- cmd /c bootstrap
- b2 -d0 headers
build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j3 libs/smart_ptr/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker

2
doc/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/html/
/pdf/

24
doc/Jamfile Normal file
View File

@ -0,0 +1,24 @@
# Copyright 2017 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
import asciidoctor ;
html smart_ptr.html : smart_ptr.adoc ;
install html_ : smart_ptr.html : <location>html ;
pdf smart_ptr.pdf : smart_ptr.adoc ;
explicit smart_ptr.pdf ;
install pdf_ : smart_ptr.pdf : <location>pdf ;
explicit pdf_ ;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : html_ ;
explicit boostrelease ;

View File

@ -0,0 +1,7 @@
<style>
*:not(pre)>code { background: none; color: #600000; }
:not(pre):not([class^=L])>code { background: none; color: #600000; }
table tr.even, table tr.alt, table tr:nth-of-type(even) { background: none; }
</style>

70
doc/smart_ptr.adoc Normal file
View File

@ -0,0 +1,70 @@
////
Copyright 2017 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
////
# Boost.SmartPtr: The Smart Pointer Library
Greg Colvin, Beman Dawes, Peter Dimov, Glen Fernandes
:toc: left
:toclevels: 2
:idprefix:
:listing-caption: Code Example
:docinfo: private-footer
:source-highlighter: rouge
:source-language: c++
:leveloffset: +1
include::smart_ptr/introduction.adoc[]
include::smart_ptr/changelog.adoc[]
include::smart_ptr/scoped_ptr.adoc[]
include::smart_ptr/scoped_array.adoc[]
include::smart_ptr/shared_ptr.adoc[]
include::smart_ptr/weak_ptr.adoc[]
include::smart_ptr/make_shared.adoc[]
include::smart_ptr/enable_shared_from_this.adoc[]
include::smart_ptr/enable_shared_from.adoc[]
include::smart_ptr/make_unique.adoc[]
include::smart_ptr/allocate_unique.adoc[]
include::smart_ptr/intrusive_ptr.adoc[]
include::smart_ptr/intrusive_ref_counter.adoc[]
include::smart_ptr/local_shared_ptr.adoc[]
include::smart_ptr/make_local_shared.adoc[]
include::smart_ptr/pointer_cast.adoc[]
include::smart_ptr/pointer_to_other.adoc[]
include::smart_ptr/atomic_shared_ptr.adoc[]
include::smart_ptr/owner_less.adoc[]
include::smart_ptr/owner_equal_to.adoc[]
include::smart_ptr/owner_hash.adoc[]
// appendix
include::smart_ptr/techniques.adoc[]
// appendix
include::smart_ptr/history.adoc[]
// appendix, deprecated
include::smart_ptr/shared_array.adoc[]
:leveloffset: -1
[[copyright]]
[appendix]
## Copyright and License
This documentation is
* Copyright 1999 Greg Colvin
* Copyright 1999 Beman Dawes
* Copyright 2002 Darin Adler
* Copyright 2003-2020 Peter Dimov
* Copyright 2005, 2006 Ion Gaztañaga
* Copyright 2008 Frank Mori Hess
* Copyright 2012-2017 Glen Fernandes
* Copyright 2013 Andrey Semashev
and is distributed under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].

View File

@ -0,0 +1,335 @@
////
Copyright 2019-2021 Glen Joseph Fernandes (glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt
////
[#allocate_unique]
# allocate_unique: Creating unique_ptr
:toc:
:toc-title:
:idprefix: allocate_unique_
## Description
The `allocate_unique` family of function templates provide convenient and safe
ways to obtain a `std::unique_ptr` that manages a new object created using an
allocator.
## Rationale
The {cpp}14 standard introduced `std::make_unique` which used operator `new` to
create new objects. However, there is no convenient facility in the standard
library to use an allocator for the creation of the objects managed by
`std::unique_ptr`. Users writing allocator aware code have often requested an
`allocate_unique` factory function. This function is to `std::unique_ptr` what
`std::allocate_shared` is to `std::shared_ptr`.
## Synopsis
`allocate_unique` is defined in `<boost/smart_ptr/allocate_unique.hpp>`.
[subs=+quotes]
```
namespace boost {
template<class T, class A>
class alloc_deleter;
template<class T, class A>
using alloc_noinit_deleter = alloc_deleter<T, noinit_adaptor<A>>;
`// T is not an array`
template<class T, class A, class... Args>
std::unique_ptr<T, alloc_deleter<T, A>>
allocate_unique(const A& a, Args&&... args);
`// T is not an array`
template<class T, class A>
std::unique_ptr<T, alloc_deleter<T, A>>
allocate_unique(const A& a, type_identity_t<T>&& v);
`// T is an array of unknown bounds`
template<class T, class A>
std::unique_ptr<T, alloc_deleter<T, A>>
allocate_unique(const A& a, std::size_t n);
`// T is an array of known bounds`
template<class T, class A>
std::unique_ptr<remove_extent_t<T>[], alloc_deleter<T, A>>
allocate_unique(const A& a);
`// T is an array of unknown bounds`
template<class T, class A>
std::unique_ptr<T, alloc_deleter<T, A>>
allocate_unique(const A& a, std::size_t n, const remove_extent_t<T>& v);
`// T is an array of known bounds`
template<class T, class A>
std::unique_ptr<remove_extent_t<T>[], alloc_deleter<T, A>>
allocate_unique(const A& a, const remove_extent_t<T>& v);
`// T is not an array`
template<class T, class A>
std::unique_ptr<T, alloc_noinit_deleter<T, A>>
allocate_unique_noinit(const A& a);
`// T is an array of unknown bounds`
template<class T, class A>
std::unique_ptr<T, alloc_noinit_deleter<T, A>>
allocate_unique_noinit(const A& a, std::size_t n);
`// T is an array of known bounds`
template<class T, class A>
std::unique_ptr<remove_extent_t<T>[], alloc_noinit_deleter<T, A>>
allocate_unique_noinit(const A& a);
template<class T, class U, class A>
allocator_pointer_t<allocator_rebind_t<A, remove_cv_t<remove_extent_t<T>>>>
get_allocator_pointer(const std::unique_ptr<T,
alloc_deleter<U, A>>& p) noexcept;
}
```
## Common Requirements
The common requirements that apply to all `allocate_unique` and
`allocate_unique_noinit` overloads, unless specified otherwise, are described
below.
Requires:: `A` shall be an _allocator_. The copy constructor and destructor
of `A` shall not throw exceptions.
Effects:: Allocates memory for an object of type `T` or `n` objects of `U`
(if `T` is an array type of the form `U[]` and `n` is determined by
arguments, as specified by the concrete overload). The object is initialized
from arguments as specified by the concrete overload. Uses a rebound copy of
`a` (for an unspecified `value_type`) to allocate memory. If an exception is
thrown, the functions have no effect.
Returns:: A `std::unique_ptr` instance that stores and owns the address of the
newly constructed object.
Postconditions:: `r.get() != 0`, where `r` is the return value.
Throws:: An exception thrown from `A::allocate`, or from the initialization of
the object.
Remarks::
* When an object of an array type is specified to be initialized to a value of
the same type `v`, this shall be interpreted to mean that each array element
of the object is initialized to the corresponding element from `v`.
* When an object of an array type is specified to be value-initialized, this
shall be interpreted to mean that each array element of the object is
value-initialized.
* When a (sub)object of non-array type `U` is specified to be initialized to a
value `v`, or constructed from `args\...`, `allocate_unique` shall perform this
initialization via the expression
`std::allocator_traits<A2>::construct(a2, p, expr)` (where `_expr_` is `v` or
`std::forward<Args>(args)\...)` respectively), `p` points to storage suitable
to hold an object of type `U`, and `a2` of type `A2` is a potentially rebound
copy of `a`.
* When a (sub)object of non-array type `U` is specified to be
default-initialized, `allocate_unique_noinit` shall perform this initialization
via the expression `::new(p) U`, where `p` has type `void*` and points to
storage suitable to hold an object of type `U`.
* When a (sub)object of non-array type `U` is specified to be
value-initialized, `allocate_unique` shall perform this initialization via the
expression `std::allocator_traits<A2>::construct(a2, p)`, where `p` points to
storage suitable to hold an object of type `U` and `a2` of type `A2` is a
potentially rebound copy of `a`.
* Array elements are initialized in ascending order of their addresses.
* When the lifetime of the object managed by the return value ends, or when the
initialization of an array element throws an exception, the initialized
elements should be destroyed in the reverse order of their construction.
## Free Functions
```
template<class T, class A, class... Args>
std::unique_ptr<T, alloc_deleter<T, A>>
allocate_unique(const A& a, Args&&... args);
```
[none]
* {blank}
+
Constraints:: `T` is not an array.
Returns:: A `std::unique_ptr` to an object of type `T`, constructed from
`args\...`.
Examples::
* `auto p = allocate_unique<int>(a);`
* `auto p = allocate_unique<std::vector<int>>(a, 16, 1);`
```
template<class T, class A>
std::unique_ptr<T, alloc_deleter<T, A>>
allocate_unique(const A& a, type_identity_t<T>&& v);
```
[none]
* {blank}
+
Constraints:: `T` is not an array.
Returns:: A `std::unique_ptr` to an object of type `T`, constructed from `v`.
Example:: `auto p = allocate_unique<std::vector<int>>(a, {1, 2});`
```
template<class T, class A>
std::unique_ptr<T, alloc_deleter<T, A>>
allocate_unique(const A& a, std::size_t n);
```
[none]
* {blank}
+
Constraints:: `T` is an array of unknown bounds.
Returns:: A `std::unique_ptr` to a sequence of `n` value-initialized objects of
type `remove_extent_t<T>`.
Examples::
* `auto p = allocate_unique<double[]>(a, 1024);`
* `auto p = allocate_unique<double[][2][2]>(a, 6);`
```
template<class T, class A>
std::unique_ptr<remove_extent_t<T>[], alloc_deleter<T, A>>
allocate_unique(const A& a);
```
[none]
* {blank}
+
Constraints:: `T` is an array of known bounds.
Returns:: A `std::unique_ptr` to a sequence of `extent_v<T>` value-initialized
objects of type `remove_extent_t<T>`.
Examples::
* `auto p = allocate_unique<double[1024]>(a);`
* `auto p = allocate_unique<double[6][2][2]>(a);`
```
template<class T, class A>
std::unique_ptr<T, alloc_deleter<T, A>>
allocate_unique(const A& a, std::size_t n, const remove_extent_t<T>& v);
```
[none]
* {blank}
+
Constraints:: `T` is an array of unknown bounds.
Returns:: A `std::unique_ptr` to a sequence of `n` objects of type
`remove_extent_t<T>`, each initialized to `v`.
Examples::
* `auto p = allocate_unique<double[]>(a, 1024, 1.0);`
* `auto p = allocate_unique<double[][2]>(a, 6, {1.0, 0.0});`
* `auto p = allocate_unique<std::vector<int>[]>(a, 4, {1, 2});`
```
template<class T, class A>
std::unique_ptr<remove_extent_t<T>[], alloc_deleter<T, A>>
allocate_unique(const A& a, const remove_extent_t<T>& v);
```
[none]
* {blank}
+
Constraints:: `T` is an array of known bounds.
Returns:: A `std::unique_ptr` to a sequence of `extent_v<T>` objects of type
`remove_extent_t<T>`, each initialized to `v`.
Examples::
* `auto p = allocate_unique<double[1024]>(a, 1.0);`
* `auto p = allocate_unique<double[6][2]>(a, {1.0, 0.0});`
* `auto p = allocate_unique<std::vector<int>[4]>(a, {1, 2});`
```
template<class T, class A>
std::unique_ptr<T, alloc_noinit_deleter<T, A>>
allocate_unique_noinit(const A& a);
```
[none]
* {blank}
+
Constraints:: `T` is not an array.
Returns:: A `std::unique_ptr` to a default-initialized object of type `T`.
Example:: `auto p = allocate_unique_noinit<double>(a);`
```
template<class T, class A>
std::unique_ptr<T, alloc_noinit_deleter<T, A>>
allocate_unique_noinit(const A& a, std::size_t n);
```
[none]
* {blank}
+
Constraints:: `T` is an array of unknown bounds.
Returns:: A `std::unique_ptr` to a sequence of `n` default-initialized objects
of type `remove_extent_t<T>`.
Example:: `auto p = allocate_unique_noinit<double[]>(a, 1024);`
```
template<class T, class A>
std::unique_ptr<remove_extent_t<T>, alloc_noinit_deleter<T, A>>
allocate_unique_noinit(const A& a);
```
[none]
* {blank}
+
Constraints:: `T` is an array of known bounds.
Returns:: A `std::unique_ptr` to a sequence of `extent_v<T>`
default-initialized objects of type `remove_extent_t<T>`.
Example:: `auto p = allocate_unique_noinit<double[1024]>(a);`
```
template<class T, class U, class A>
allocator_pointer_t<allocator_rebind_t<A, remove_cv_t<remove_extent_t<T>>>>
get_allocator_pointer(const std::unique_ptr<T,
alloc_deleter<U, A>>& p) noexcept;
```
[none]
* {blank}
+
Returns:: The allocator pointer to the allocation.
Example:: `auto r = boost::get_allocator_ptr(p);`
## Deleter
Class template `alloc_deleter` is the deleter used by the `allocate_unique`
functions.
### Synopsis
[subs=+quotes]
```
template<class T, class A>
class alloc_deleter {
public:
using pointer = `unspecified`;
explicit alloc_deleter(const A& a) noexcept;
void operator()(pointer p);
};
```
### Members
[subs=+quotes]
```
using pointer = `unspecified`;
```
[none]
* {blank}
+
A type that satisfies _NullablePointer_.
```
explicit alloc_deleter(const A& a) noexcept;
```
[none]
* {blank}
+
Effects:: Initializes the stored allocator from `a`.
```
void operator()(pointer p);
```
[none]
* {blank}
+
Effects:: Destroys the objects and deallocates the storage referenced by `p`,
using the stored allocator.

View File

@ -0,0 +1,170 @@
////
Copyright 2017 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
////
[#atomic_shared_ptr]
# atomic_shared_ptr
:toc:
:toc-title:
:idprefix: atomic_shared_ptr_
## Description
The class template `atomic_shared_ptr<T>` implements the interface of `std::atomic`
for a contained value of type `shared_ptr<T>`. Concurrent access to `atomic_shared_ptr`
is not a data race.
## Synopsis
`atomic_shared_ptr` is defined in `<boost/smart_ptr/atomic_shared_ptr.hpp>`.
```
namespace boost {
template<class T> class atomic_shared_ptr {
private:
shared_ptr<T> p_; // exposition only
atomic_shared_ptr(const atomic_shared_ptr&) = delete;
atomic_shared_ptr& operator=(const atomic_shared_ptr&) = delete;
public:
constexpr atomic_shared_ptr() noexcept;
atomic_shared_ptr( shared_ptr<T> p ) noexcept;
atomic_shared_ptr& operator=( shared_ptr<T> r ) noexcept;
bool is_lock_free() const noexcept;
shared_ptr<T> load( int = 0 ) const noexcept;
operator shared_ptr<T>() const noexcept;
void store( shared_ptr<T> r, int = 0 ) noexcept;
shared_ptr<T> exchange( shared_ptr<T> r, int = 0 ) noexcept;
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) noexcept;
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int = 0 ) noexcept;
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) noexcept;
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, int = 0 ) noexcept;
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, int, int ) noexcept;
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, int = 0 ) noexcept;
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, int, int ) noexcept;
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, int = 0 ) noexcept;
};
}
```
## Members
```
constexpr atomic_shared_ptr() noexcept;
```
[none]
* {blank}
+
Effects:: Default-initializes `p_`.
```
atomic_shared_ptr( shared_ptr<T> p ) noexcept;
```
[none]
* {blank}
+
Effects:: Initializes `p_` to `p`.
```
atomic_shared_ptr& operator=( shared_ptr<T> r ) noexcept;
```
[none]
* {blank}
+
Effects:: `p_.swap(r)`.
Returns:: `*this`.
```
bool is_lock_free() const noexcept;
```
[none]
* {blank}
+
Returns:: `false`.
NOTE: This implementation is not lock-free.
```
shared_ptr<T> load( int = 0 ) const noexcept;
```
```
operator shared_ptr<T>() const noexcept;
```
[none]
* {blank}
+
Returns:: `p_`.
NOTE: The `int` argument is intended to be of type `memory_order`, but is ignored.
This implementation is lock-based and therefore always sequentially consistent.
```
void store( shared_ptr<T> r, int = 0 ) noexcept;
```
[none]
* {blank}
+
Effects:: `p_.swap(r)`.
```
shared_ptr<T> exchange( shared_ptr<T> r, int = 0 ) noexcept;
```
[none]
* {blank}
+
Effects:: `p_.swap(r)`.
Returns:: The old value of `p_`.
```
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) noexcept;
```
```
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int = 0 ) noexcept;
```
```
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) noexcept;
```
```
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, int = 0 ) noexcept;
```
[none]
* {blank}
+
Effects:: If `p_` is equivalent to `v`, assigns `w` to `p_`, otherwise assigns `p_` to `v`.
Returns:: `true` if `p_` was equivalent to `v`, `false` otherwise.
Remarks:: Two `shared_ptr` instances are equivalent if they store the same pointer value and _share ownership_.
```
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, int, int ) noexcept;
```
```
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, int = 0 ) noexcept;
```
```
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, int, int ) noexcept;
```
```
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, int = 0 ) noexcept;
```
[none]
* {blank}
+
Effects:: If `p_` is equivalent to `v`, assigns `std::move(w)` to `p_`, otherwise assigns `p_` to `v`.
Returns:: `true` if `p_` was equivalent to `v`, `false` otherwise.
Remarks:: The old value of `w` is not preserved in either case.

View File

@ -0,0 +1,42 @@
////
Copyright 2019, 2020 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
////
[#changelog]
# Revision History
:toc:
:toc-title:
:idprefix: changelog_
## Changes in 1.79.0
* Added `get_allocator_pointer`
## Changes in 1.74.0
* Added `owner_equals` to `shared_ptr`, `weak_ptr`, `local_shared_ptr`
* Added `owner_hash_value` to `shared_ptr`, `weak_ptr`
* Added `owner_equal_to`, `owner_hash`
* Added `std::hash` specializations for `shared_ptr`, `local_shared_ptr`
* Added `boost::hash` support to, and `std::hash`, `std::equal_to`
specializations for, `weak_ptr`
## Changes in 1.72.0
* Added `allocate_unique`
## Changes in 1.71.0
* Added aliasing constructors to `weak_ptr`
* Added `weak_ptr<T>::empty()`
* Added `enable_shared_from`, `shared_from`, and `weak_from`
## Changes in 1.65.0
* Added `atomic_shared_ptr`
* Added `local_shared_ptr`, `make_local_shared`

View File

@ -0,0 +1,89 @@
////
Copyright 2002, 2003, 2015, 2017, 2019 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
////
[#enable_shared_from]
# enable_shared_from
:toc:
:toc-title:
:idprefix: enable_shared_from_
## Description
`enable_shared_from` is used as a base class that allows a `shared_ptr` or a
`weak_ptr` to be obtained given a raw pointer to the object, by using the
functions `shared_from` and `weak_from`.
`enable_shared_from` differs from `enable_shared_from_this<T>` by the fact
that it's not a template, and is its recommended replacement for new code.
## Example
```
#include <boost/smart_ptr/enable_shared_from.hpp>
#include <boost/shared_ptr.hpp>
#include <cassert>
class Y: public boost::enable_shared_from
{
public:
boost::shared_ptr<Y> f()
{
return boost::shared_from( this );
}
};
int main()
{
boost::shared_ptr<Y> p(new Y);
boost::shared_ptr<Y> q = p->f();
assert(p == q);
assert(!(p < q || q < p)); // p and q must share ownership
}
```
## Synopsis
`enable_shared_from` is defined in `<boost/smart_ptr/enable_shared_from.hpp>`.
```
namespace boost {
class enable_shared_from: public enable_shared_from_this<enable_shared_from>
{
};
template<class T> shared_ptr<T> shared_from( T * p );
template<class T> weak_ptr<T> weak_from( T * p ) noexcept;
}
```
## Functions
```
template<class T> shared_ptr<T> shared_from( T * p );
```
[none]
* {blank}
+
Returns:: `shared_ptr<T>( p\->enable_shared_from::shared_from_this(), p )`.
NOTE: Throws `bad_weak_ptr` when `p` is not owned by a `shared_ptr`.
```
template<class T> weak_ptr<T> weak_from( T * p ) noexcept;
```
[none]
* {blank}
+
Returns:: `weak_ptr<T>( p\->enable_shared_from::weak_from_this(), p )`.
NOTE: Unlike `shared_from(this)`, `weak_from(this)` is valid in a destructor
and returns a `weak_ptr` that is `expired()` but still shares ownership
with other `weak_ptr` instances (if any) that refer to the object.

View File

@ -0,0 +1,148 @@
////
Copyright 2002, 2003, 2015, 2017 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
////
[#enable_shared_from_this]
# enable_shared_from_this
:toc:
:toc-title:
:idprefix: enable_shared_from_this_
## Description
The class template `enable_shared_from_this` is used as a base class that allows
a `shared_ptr` or a `weak_ptr` to the current object to be obtained from within a
member function.
`enable_shared_from_this<T>` defines two member functions called `shared_from_this`
that return a `shared_ptr<T>` and `shared_ptr<T const>`, depending on constness, to
`this`. It also defines two member functions called `weak_from_this` that return a
corresponding `weak_ptr`.
## Example
```
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
#include <cassert>
class Y: public boost::enable_shared_from_this<Y>
{
public:
boost::shared_ptr<Y> f()
{
return shared_from_this();
}
};
int main()
{
boost::shared_ptr<Y> p(new Y);
boost::shared_ptr<Y> q = p->f();
assert(p == q);
assert(!(p < q || q < p)); // p and q must share ownership
}
```
## Synopsis
`enable_shared_from_this` is defined in `<boost/smart_ptr/enable_shared_from_this.hpp>`.
```
namespace boost {
template<class T> class enable_shared_from_this {
private:
// exposition only
weak_ptr<T> weak_this_;
protected:
enable_shared_from_this() = default;
~enable_shared_from_this() = default;
enable_shared_from_this(const enable_shared_from_this&) noexcept;
enable_shared_from_this& operator=(const enable_shared_from_this&) noexcept;
public:
shared_ptr<T> shared_from_this();
shared_ptr<T const> shared_from_this() const;
weak_ptr<T> weak_from_this() noexcept;
weak_ptr<T const> weak_from_this() const noexcept;
}
}
```
## Members
```
enable_shared_from_this(enable_shared_from_this const &) noexcept;
```
[none]
* {blank}
+
Effects:: Default-constructs `weak_this_`.
NOTE: `weak_this_` is _not_ copied from the argument.
```
enable_shared_from_this& operator=(enable_shared_from_this const &) noexcept;
```
[none]
* {blank}
+
Returns:: `*this`.
NOTE: `weak_this_` is unchanged.
```
template<class T> shared_ptr<T> shared_from_this();
```
```
template<class T> shared_ptr<T const> shared_from_this() const;
```
[none]
* {blank}
+
Returns:: `shared_ptr<T>(weak_this_)`.
NOTE: These members throw `bad_weak_ptr` when `*this` is not owned by a `shared_ptr`.
[NOTE]
====
`weak_this_` is initialized by `shared_ptr` to a copy of itself when it's constructed by a pointer to `*this`.
For example, in the following code:
```
class Y: public boost::enable_shared_from_this<Y> {};
int main()
{
boost::shared_ptr<Y> p(new Y);
}
```
the construction of `p` will automatically initialize `p\->weak_this_` to `p`.
====
```
template<class T> weak_ptr<T> weak_from_this() noexcept;
```
```
template<class T> weak_ptr<T const> weak_from_this() const noexcept;
```
[none]
* {blank}
+
Returns:: `weak_this_`.
NOTE: Unlike `shared_from_this()`, `weak_from_this()` is valid in a destructor
and returns a `weak_ptr` that is `expired()` but still shares ownership
with other `weak_ptr` instances (if any) that refer to the object.

117
doc/smart_ptr/history.adoc Normal file
View File

@ -0,0 +1,117 @@
////
Copyright 1999 Greg Colvin and Beman Dawes
Copyright 2002 Darin Adler
Copyright 2017 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
////
[[history]]
[appendix]
# History and Acknowledgments
:idprefix: history_
## Summer 1994
Greg Colvin http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1994/N0555.pdf[proposed]
to the {cpp} Standards Committee classes named `auto_ptr` and `counted_ptr` which were very
similar to what we now call `scoped_ptr` and `shared_ptr`. In one of the very few cases
where the Library Working Group's recommendations were not followed by the full committee,
`counted_ptr` was rejected and surprising transfer-of-ownership semantics were added to `auto_ptr`.
## October 1998
Beman Dawes proposed reviving the original semantics under the names `safe_ptr` and `counted_ptr`,
meeting of Per Andersson, Matt Austern, Greg Colvin, Sean Corfield, Pete Becker, Nico Josuttis,
Dietmar Kühl, Nathan Myers, Chichiang Wan and Judy Ward. During the discussion, the four new class
names were finalized, it was decided that there was no need to exactly follow the `std::auto_ptr`
interface, and various function signatures and semantics were finalized.
Over the next three months, several implementations were considered for `shared_ptr`, and discussed
on the http://www.boost.org/[boost.org] mailing list. The implementation questions revolved around
the reference count which must be kept, either attached to the pointed to object, or detached elsewhere.
Each of those variants have themselves two major variants:
* Direct detached: the `shared_ptr` contains a pointer to the object, and a pointer to the count.
* Indirect detached: the `shared_ptr` contains a pointer to a helper object, which in turn contains a pointer to the object and the count.
* Embedded attached: the count is a member of the object pointed to.
* Placement attached: the count is attached via operator new manipulations.
Each implementation technique has advantages and disadvantages. We went so far as to run various timings
of the direct and indirect approaches, and found that at least on Intel Pentium chips there was very little
measurable difference. Kevlin Henney provided a paper he wrote on "Counted Body Techniques." Dietmar Kühl
suggested an elegant partial template specialization technique to allow users to choose which implementation
they preferred, and that was also experimented with.
But Greg Colvin and Jerry Schwarz argued that "parameterization will discourage users", and in the end we choose
to supply only the direct implementation.
## May 1999
In April and May, 1999, Valentin Bonnard and David Abrahams made a number of suggestions resulting in numerous improvements.
## September 1999
Luis Coelho provided `shared_ptr::swap` and `shared_array::swap`.
## November 1999
Darin Adler provided `operator ==`, `operator !=`, and `std::swap` and `std::less` specializations for shared types.
## May 2001
Vladimir Prus suggested requiring a complete type on destruction. Refinement evolved in discussions including Dave Abrahams,
Greg Colvin, Beman Dawes, Rainer Deyke, Peter Dimov, John Maddock, Vladimir Prus, Shankar Sai, and others.
## January 2002
Peter Dimov reworked all four classes, adding features, fixing bugs, splitting them into four separate headers, and adding
`weak_ptr`.
## March 2003
Peter Dimov, Beman Dawes and Greg Colvin http://open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html[proposed] `shared_ptr`
and `weak_ptr` for inclusion in the Standard Library via the first Library Technical Report (known as TR1). The proposal was
accepted and eventually went on to become a part of the {cpp} standard in its 2011 iteration.
## July 2007
Peter Dimov and Beman Dawes http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2351.htm[proposed] a number of enhancements
to `shared_ptr` as it was entering the working paper that eventually became the {cpp}11 standard.
## November 2012
Glen Fernandes provided implementations of `make_shared` and `allocate_shared` for arrays. They achieve a single allocation
for an array that can be initialized with constructor arguments or initializer lists as well as overloads for default initialization
and no value initialization.
Peter Dimov aided this development by extending `shared_ptr` to support arrays via the syntax `shared_ptr<T[]>` and `shared_ptr<T[N]>`.
## April 2013
Peter Dimov http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3640.html[proposed] the extension of `shared_ptr` to support
arrays for inclusion into the standard, and it was accepted.
## February 2014
Glen Fernandes updated `make_shared` and `allocate_shared` to conform to the specification in {cpp} standard paper
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3870.html[N3870], and implemented `make_unique` for arrays and objects.
Peter Dimov and Glen Fernandes updated the scalar and array implementations, respectively, to resolve {cpp} standard library defect 2070.
## February 2017
Glen Fernandes rewrote `allocate_shared` and `make_shared` for arrays for a more optimal and more maintainable implementation.
## June 2017
Peter Dimov and Glen Fernandes rewrote the documentation in Asciidoc format.
Peter Dimov added `atomic_shared_ptr` and `local_shared_ptr`.
## August 2019
Glen Fernandes implemented `allocate_unique` for scalars and arrays.

View File

@ -0,0 +1,53 @@
////
Copyright 1999 Greg Colvin and Beman Dawes
Copyright 2002 Darin Adler
Copyright 2017 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
////
[#introduction]
# Introduction
:toc:
:toc-title:
:idprefix: intro_
Smart pointers are objects which store pointers to dynamically allocated (heap) objects.
They behave much like built-in {cpp} pointers except that they automatically delete the object
pointed to at the appropriate time. Smart pointers are particularly useful in the face of
exceptions as they ensure proper destruction of dynamically allocated objects. They can also be
used to keep track of dynamically allocated objects shared by multiple owners.
Conceptually, smart pointers are seen as owning the object pointed to, and thus responsible for
deletion of the object when it is no longer needed. As such, they are examples of the "resource
acquisition is initialization" idiom described in Bjarne Stroustrup's "The C++ Programming Language",
3rd edition, Section 14.4, Resource Management.
This library provides six smart pointer class templates:
* `<<scoped_ptr,scoped_ptr>>`, used to contain ownership of a dynamically allocated object to the current scope;
* `<<scoped_array,scoped_array>>`, which provides scoped ownership for a dynamically allocated array;
* `<<shared_ptr,shared_ptr>>`, a versatile tool for managing shared ownership of an object or array;
* `<<weak_ptr,weak_ptr>>`, a non-owning observer to a `shared_ptr`-managed object that can be promoted temporarily to `shared_ptr`;
* `<<intrusive_ptr,intrusive_ptr>>`, a pointer to objects with an embedded reference count;
* `<<local_shared_ptr,local_shared_ptr>>`, providing shared ownership within a single thread.
`shared_ptr` and `weak_ptr` are part of the {cpp} standard since its 2011 iteration.
In addition, the library contains the following supporting utility functions and classes:
* `<<make_shared,make_shared>>` and `allocate_shared`, factory functions for creating objects that return a `shared_ptr`;
* `<<make_unique,make_unique>>`, a factory function returning `std::unique_ptr`;
* `<<allocate_unique,allocate_unique>>`, a factory function for creating objects using an allocator that returns a `std::unique_ptr`;
* `<<enable_shared_from_this,enable_shared_from_this>>`, a helper base class that enables the acquisition of a `shared_ptr` pointing to `this`;
* `<<enable_shared_from,enable_shared_from>>`, a newer and better replacement for `enable_shared_from_this`;
* `<<pointer_to_other,pointer_to_other>>`, a helper trait for converting one smart pointer type to another;
* `<<pointer_cast,static_pointer_cast>>` and companions, generic smart pointer casts;
* `<<intrusive_ref_counter,intrusive_ref_counter>>`, a helper base class containing a reference count.
* `<<atomic_shared_ptr,atomic_shared_ptr>>`, a helper class implementing the interface of `std::atomic` for a value of type `shared_ptr`.
As a general rule, the destructor or `operator delete` for an object managed by pointers in the library
are not allowed to throw exceptions.

View File

@ -0,0 +1,487 @@
////
Copyright 2003-2005, 2013, 2017 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
////
[#intrusive_ptr]
# intrusive_ptr: Managing Objects with Embedded Counts
:toc:
:toc-title:
:idprefix: intrusive_ptr_
## Description
The `intrusive_ptr` class template stores a pointer to an object with an embedded reference count.
Every new `intrusive_ptr` instance increments the reference count by using an unqualified call to the
function `intrusive_ptr_add_ref`, passing it the pointer as an argument. Similarly, when an `intrusive_ptr`
is destroyed, it calls `intrusive_ptr_release`; this function is responsible for destroying the object when
its reference count drops to zero. The user is expected to provide suitable definitions of these two functions.
On compilers that support argument-dependent lookup, `intrusive_ptr_add_ref` and `intrusive_ptr_release` should
be defined in the namespace that corresponds to their parameter; otherwise, the definitions need to go in namespace
`boost`. The library provides a helper base class template `<<intrusive_ref_counter,intrusive_ref_counter>>` which
may help adding support for `intrusive_ptr` to user types.
The class template is parameterized on `T`, the type of the object pointed to. `intrusive_ptr<T>` can be implicitly
converted to `intrusive_ptr<U>` whenever `T*` can be implicitly converted to `U*`.
The main reasons to use `intrusive_ptr` are:
* Some existing frameworks or OSes provide objects with embedded reference counts;
* The memory footprint of `intrusive_ptr` is the same as the corresponding raw pointer;
* `intrusive_ptr<T>` can be constructed from an arbitrary raw pointer of type `T*`.
As a general rule, if it isn't obvious whether `intrusive_ptr` better fits your needs than `shared_ptr`, try a `shared_ptr`-based design first.
## Synopsis
`intrusive_ptr` is defined in `<boost/smart_ptr/intrusive_ptr.hpp>`.
```
namespace boost {
template<class T> class intrusive_ptr {
public:
typedef T element_type;
intrusive_ptr() noexcept;
intrusive_ptr(T * p, bool add_ref = true);
intrusive_ptr(intrusive_ptr const & r);
template<class Y> intrusive_ptr(intrusive_ptr<Y> const & r);
intrusive_ptr(intrusive_ptr && r);
template<class Y> intrusive_ptr(intrusive_ptr<Y> && r);
~intrusive_ptr();
intrusive_ptr & operator=(intrusive_ptr const & r);
template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> const & r);
intrusive_ptr & operator=(T * r);
intrusive_ptr & operator=(intrusive_ptr && r);
template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> && r);
void reset();
void reset(T * r);
void reset(T * r, bool add_ref);
T & operator*() const noexcept;
T * operator->() const noexcept;
T * get() const noexcept;
T * detach() noexcept;
explicit operator bool () const noexcept;
void swap(intrusive_ptr & b) noexcept;
};
template<class T, class U>
bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept;
template<class T, class U>
bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept;
template<class T, class U>
bool operator==(intrusive_ptr<T> const & a, U * b) noexcept;
template<class T, class U>
bool operator!=(intrusive_ptr<T> const & a, U * b) noexcept;
template<class T, class U>
bool operator==(T * a, intrusive_ptr<U> const & b) noexcept;
template<class T, class U>
bool operator!=(T * a, intrusive_ptr<U> const & b) noexcept;
template<class T>
bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) noexcept;
template<class T> void swap(intrusive_ptr<T> & a, intrusive_ptr<T> & b) noexcept;
template<class T> T * get_pointer(intrusive_ptr<T> const & p) noexcept;
template<class T, class U>
intrusive_ptr<T> static_pointer_cast(intrusive_ptr<U> const & r) noexcept;
template<class T, class U>
intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & r) noexcept;
template<class T, class U>
intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & r) noexcept;
template<class E, class T, class Y>
std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os,
intrusive_ptr<Y> const & p);
}
```
## Members
### element_type
```
typedef T element_type;
```
Provides the type of the template parameter T.
### constructors
```
intrusive_ptr() noexcept;
```
[none]
* {blank}
+
Postconditions:: `get() == 0`.
```
intrusive_ptr(T * p, bool add_ref = true);
```
[none]
* {blank}
+
Effects:: `if(p != 0 && add_ref) intrusive_ptr_add_ref(p);`.
Postconditions:: `get() == p`.
```
intrusive_ptr(intrusive_ptr const & r);
```
```
template<class Y> intrusive_ptr(intrusive_ptr<Y> const & r);
```
[none]
* {blank}
+
Effects:: `T * p = r.get(); if(p != 0) intrusive_ptr_add_ref(p);`.
Postconditions:: `get() == r.get()`.
```
intrusive_ptr(intrusive_ptr && r);
```
```
template<class Y> intrusive_ptr(intrusive_ptr<Y> && r);
```
[none]
* {blank}
+
Postconditions::
`get()` equals the old value of `r.get()`. `r.get() == 0`.
### destructor
```
~intrusive_ptr();
```
[none]
* {blank}
+
Effects::
`if(get() != 0) intrusive_ptr_release(get());`.
### assignment
```
intrusive_ptr & operator=(intrusive_ptr const & r);
```
```
template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> const & r);
```
```
intrusive_ptr & operator=(T * r);
```
[none]
* {blank}
+
Effects:: Equivalent to `intrusive_ptr(r).swap(*this)`.
Returns:: `*this`.
```
intrusive_ptr & operator=(intrusive_ptr && r);
```
```
template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> && r);
```
[none]
* {blank}
+
Effects:: Equivalent to `intrusive_ptr(std::move(r)).swap(*this)`.
Returns:: `*this`.
### reset
```
void reset();
```
[none]
* {blank}
+
Effects:: Equivalent to `intrusive_ptr().swap(*this)`.
```
void reset(T * r);
```
[none]
* {blank}
+
Effects:: Equivalent to `intrusive_ptr(r).swap(*this)`.
```
void reset(T * r, bool add_ref);
```
[none]
* {blank}
+
Effects::
Equivalent to `intrusive_ptr(r, add_ref).swap(*this)`.
### indirection
```
T & operator*() const noexcept;
```
[none]
* {blank}
+
Requirements:: `get() != 0`.
Returns:: `*get()`.
```
T * operator->() const noexcept;
```
[none]
* {blank}
+
Requirements:: `get() != 0`.
Returns:: `get()`.
### get
```
T * get() const noexcept;
```
[none]
* {blank}
+
Returns::
the stored pointer.
### detach
```
T * detach() noexcept;
```
[none]
* {blank}
+
Returns:: the stored pointer.
Postconditions:: `get() == 0`.
NOTE: The returned pointer has an elevated reference count. This allows conversion of an `intrusive_ptr`
back to a raw pointer, without the performance overhead of acquiring and dropping an extra reference.
It can be viewed as the complement of the non-reference-incrementing constructor.
CAUTION: Using `detach` escapes the safety of automatic reference counting provided by `intrusive_ptr`.
It should by used only where strictly necessary (such as when interfacing to an existing API), and when
the implications are thoroughly understood.
### conversions
```
explicit operator bool () const noexcept;
```
[none]
* {blank}
+
Returns:: `get() != 0`.
NOTE: This conversion operator allows `intrusive_ptr` objects to be used in boolean contexts,
like `if (p && p\->valid()) {}`.
NOTE: On C++03 compilers, the return value is of an unspecified type.
### swap
```
void swap(intrusive_ptr & b) noexcept;
```
[none]
* {blank}
+
Effects::
Exchanges the contents of the two smart pointers.
## Free Functions
### comparison
```
template<class T, class U>
bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept;
```
[none]
* {blank}
+
Returns:: `a.get() == b.get()`.
```
template<class T, class U>
bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept;
```
[none]
* {blank}
+
Returns:: `a.get() != b.get()`.
```
template<class T, class U>
bool operator==(intrusive_ptr<T> const & a, U * b) noexcept;
```
[none]
* {blank}
+
Returns:: `a.get() == b`.
```
template<class T, class U>
bool operator!=(intrusive_ptr<T> const & a, U * b) noexcept;
```
[none]
* {blank}
+
Returns:: `a.get() != b`.
```
template<class T, class U>
bool operator==(T * a, intrusive_ptr<U> const & b) noexcept;
```
[none]
* {blank}
+
Returns:: `a == b.get()`.
```
template<class T, class U>
bool operator!=(T * a, intrusive_ptr<U> const & b) noexcept;
```
[none]
* {blank}
+
Returns:: `a != b.get()`.
```
template<class T>
bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) noexcept;
```
[none]
* {blank}
+
Returns:: `std::less<T *>()(a.get(), b.get())`.
NOTE: Allows `intrusive_ptr` objects to be used as keys in associative containers.
### swap
```
template<class T> void swap(intrusive_ptr<T> & a, intrusive_ptr<T> & b) noexcept;
```
[none]
* {blank}
+
Effects::
Equivalent to `a.swap(b)`.
### get_pointer
```
template<class T> T * get_pointer(intrusive_ptr<T> const & p) noexcept;
```
[none]
* {blank}
+
Returns:: `p.get()`.
NOTE: Provided as an aid to generic programming. Used by `mem_fn`.
### static_pointer_cast
```
template<class T, class U>
intrusive_ptr<T> static_pointer_cast(intrusive_ptr<U> const & r) noexcept;
```
[none]
* {blank}
+
Returns::
`intrusive_ptr<T>(static_cast<T*>(r.get()))`.
### const_pointer_cast
```
template<class T, class U>
intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & r) noexcept;
```
[none]
* {blank}
+
Returns::
`intrusive_ptr<T>(const_cast<T*>(r.get()))`.
### dynamic_pointer_cast
```
template<class T, class U>
intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & r) noexcept;
```
[none]
* {blank}
+
Returns::
`intrusive_ptr<T>(dynamic_cast<T*>(r.get()))`.
### operator<<
```
template<class E, class T, class Y>
std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os,
intrusive_ptr<Y> const & p);
```
[none]
* {blank}
+
Effects:: `os << p.get();`.
Returns:: `os`.

View File

@ -0,0 +1,155 @@
////
Copyright 2017 Peter Dimov
Copyright 2013 Andrey Semashev
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt
////
[#intrusive_ref_counter]
# intrusive_ref_counter
:toc:
:toc-title:
:idprefix: intrusive_ref_counter_
## Description
The `intrusive_ref_counter` class template implements a reference counter for
a derived user's class that is intended to be used with `intrusive_ptr`. The
base class has associated `intrusive_ptr_add_ref` and `intrusive_ptr_release`
functions which modify the reference counter as needed and destroy the user's
object when the counter drops to zero.
The class template is parameterized on `Derived` and `CounterPolicy`
parameters. The first parameter is the user's class that derives from
`intrusive_ref_counter`. This type is needed in order to destroy the object
correctly when there are no references to it left.
The second parameter is a policy that defines the nature of the reference
counter. The library provides two such policies: `thread_unsafe_counter` and
`thread_safe_counter`. The former instructs the `intrusive_ref_counter` base
class to use a counter only suitable for a single-threaded use. Pointers to a
single object that uses this kind of reference counter must not be used in
different threads. The latter policy makes the reference counter thread-safe,
unless the target platform doesn't support threading. Since in modern systems
support for threading is common, the default counter policy is
`thread_safe_counter`.
## Synopsis
`intrusive_ref_counter` is defined in
`<boost/smart_ptr/intrusive_ref_counter.hpp>`.
```
namespace boost {
struct thread_unsafe_counter;
struct thread_safe_counter;
template<class Derived, class CounterPolicy = thread_safe_counter>
class intrusive_ref_counter {
public:
intrusive_ref_counter() noexcept;
intrusive_ref_counter(const intrusive_ref_counter& v) noexcept;
intrusive_ref_counter& operator=(const intrusive_ref_counter& v) noexcept;
unsigned int use_count() const noexcept;
protected:
~intrusive_ref_counter() = default;
};
template<class Derived, class CounterPolicy>
void intrusive_ptr_add_ref(
const intrusive_ref_counter<Derived, CounterPolicy>* p) noexcept;
template<class Derived, class CounterPolicy>
void intrusive_ptr_release(
const intrusive_ref_counter<Derived, CounterPolicy>* p) noexcept;
}
```
## Members
### Constructors
```
intrusive_ref_counter() noexcept;
```
```
intrusive_ref_counter(const intrusive_ref_counter&) noexcept;
```
[none]
* {blank}
+
Postconditions:: `use_count() == 0`.
NOTE: The pointer to the constructed object is expected to be passed to
`intrusive_ptr` constructor, assignment operator or `reset` method, which
would increment the reference counter.
### Destructor
```
~intrusive_ref_counter();
```
[none]
* {blank}
+
Effects:: Destroys the counter object.
NOTE: The destructor is protected so that the object can only be destroyed
through the `Derived` class.
### Assignment
```
intrusive_ref_counter& operator=(const intrusive_ref_counter& v) noexcept;
```
[none]
* {blank}
+
Effects::
Does nothing, reference counter is not modified.
### use_count
```
unsigned int use_count() const noexcept;
```
[none]
* {blank}
+
Returns:: The current value of the reference counter.
NOTE: The returned value may not be actual in multi-threaded applications.
## Free Functions
### intrusive_ptr_add_ref
```
template<class Derived, class CounterPolicy>
void intrusive_ptr_add_ref(
const intrusive_ref_counter<Derived, CounterPolicy>* p) noexcept;
```
[none]
* {blank}
+
Effects::
Increments the reference counter.
### intrusive_ptr_release
```
template<class Derived, class CounterPolicy>
void intrusive_ptr_release(
const intrusive_ref_counter<Derived, CounterPolicy>* p) noexcept;
```
[none]
* {blank}
+
Effects:: Decrements the reference counter. If the reference counter reaches
0, calls `delete static_cast<const Derived*>(p)`.

View File

@ -0,0 +1,738 @@
////
Copyright 2017 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
////
[#local_shared_ptr]
# local_shared_ptr: Shared Ownership within a Single Thread
:toc:
:toc-title:
:idprefix: local_shared_ptr_
## Description
`local_shared_ptr` is nearly identical to `shared_ptr`, with the only difference of note being that its reference count is
updated with non-atomic operations. As such, a `local_shared_ptr` and all its copies must reside in (be local to) a single
thread (hence the name.)
`local_shared_ptr` can be converted to `shared_ptr` and vice versa. Creating a `local_shared_ptr` from a `shared_ptr` creates
a new local reference count; this means that two `local_shared_ptr` instances, both created from the same `shared_ptr`, refer
to the same object but don't share the same count, and as such, can safely be used by two different threads.
.Two local_shared_ptr instances created from a shared_ptr
```
shared_ptr<X> p1( new X );
local_shared_ptr<X> p2( p1 ); // p2.local_use_count() == 1
local_shared_ptr<X> p3( p1 ); // p3.local_use_count() also 1
```
Creating the second `local_shared_ptr` from the first one, however, does lead to the two sharing the same count:
.A local_shared_ptr created from another local_shared_ptr
```
shared_ptr<X> p1( new X );
local_shared_ptr<X> p2( p1 ); // p2.local_use_count() == 1
local_shared_ptr<X> p3( p2 ); // p3.local_use_count() == 2
```
Two `shared_ptr` instances created from the same `local_shared_ptr` do share ownership:
.Two shared_ptr instances created from a local_shared_ptr
```
local_shared_ptr<X> p1( new X );
shared_ptr<X> p2( p1 ); // p2.use_count() == 2
shared_ptr<X> p3( p1 ); // p3.use_count() == 3
```
Here `p2.use_count()` is 2, because `p1` holds a reference, too.
One can think of `local_shared_ptr<T>` as `shared_ptr<shared_ptr<T>>`, with the outer `shared_ptr` using non-atomic operations for
its count. Converting from `local_shared_ptr` to `shared_ptr` gives you a copy of the inner `shared_ptr`; converting from `shared_ptr`
wraps it into an outer `shared_ptr` with a non-atomic use count (conceptually speaking) and returns the result.
## Synopsis
`local_shared_ptr` is defined in `<boost/smart_ptr/local_shared_ptr.hpp>`.
```
namespace boost {
template<class T> class local_shared_ptr {
public:
typedef /*see below*/ element_type;
// constructors
constexpr local_shared_ptr() noexcept;
constexpr local_shared_ptr(std::nullptr_t) noexcept;
template<class Y> explicit local_shared_ptr(Y * p);
template<class Y, class D> local_shared_ptr(Y * p, D d);
template<class D> local_shared_ptr(std::nullptr_t p, D d);
template<class Y, class D, class A> local_shared_ptr(Y * p, D d, A a);
template<class D, class A> local_shared_ptr(std::nullptr_t p, D d, A a);
local_shared_ptr(local_shared_ptr const & r) noexcept;
template<class Y> local_shared_ptr(local_shared_ptr<Y> const & r) noexcept;
local_shared_ptr(local_shared_ptr && r) noexcept;
template<class Y> local_shared_ptr(local_shared_ptr<Y> && r) noexcept;
template<class Y> local_shared_ptr( shared_ptr<Y> const & r );
template<class Y> local_shared_ptr( shared_ptr<Y> && r );
template<class Y> local_shared_ptr(local_shared_ptr<Y> const & r, element_type * p) noexcept;
template<class Y> local_shared_ptr(local_shared_ptr<Y> && r, element_type * p) noexcept;
template<class Y, class D> local_shared_ptr(std::unique_ptr<Y, D> && r);
// destructor
~local_shared_ptr() noexcept;
// assignment
local_shared_ptr & operator=(local_shared_ptr const & r) noexcept;
template<class Y> local_shared_ptr & operator=(local_shared_ptr<Y> const & r) noexcept;
local_shared_ptr & operator=(local_shared_ptr const && r) noexcept;
template<class Y> local_shared_ptr & operator=(local_shared_ptr<Y> const && r) noexcept;
template<class Y, class D> local_shared_ptr & operator=(std::unique_ptr<Y, D> && r);
local_shared_ptr & operator=(std::nullptr_t) noexcept;
// reset
void reset() noexcept;
template<class Y> void reset(Y * p);
template<class Y, class D> void reset(Y * p, D d);
template<class Y, class D, class A> void reset(Y * p, D d, A a);
template<class Y> void reset(local_shared_ptr<Y> const & r, element_type * p) noexcept;
template<class Y> void reset(local_shared_ptr<Y> && r, element_type * p) noexcept;
// accessors
T & operator*() const noexcept; // only valid when T is not an array type
T * operator->() const noexcept; // only valid when T is not an array type
// only valid when T is an array type
element_type & operator[](std::ptrdiff_t i) const noexcept;
element_type * get() const noexcept;
long local_use_count() const noexcept;
// conversions
explicit operator bool() const noexcept;
template<class Y> operator shared_ptr<Y>() const noexcept;
template<class Y> operator weak_ptr<Y>() const noexcept;
// swap
void swap(local_shared_ptr & b) noexcept;
// owner_before
template<class Y> bool owner_before(local_shared_ptr<Y> const & r) const noexcept;
// owner_equals
template<class Y> bool owner_equals(local_shared_ptr<Y> const & r) const noexcept;
};
// comparisons
template<class T, class U>
bool operator==(local_shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
template<class T, class U>
bool operator==(local_shared_ptr<T> const & a, shared_ptr<U> const & b) noexcept;
template<class T, class U>
bool operator==(shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
template<class T, class U>
bool operator!=(local_shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
template<class T, class U>
bool operator!=(local_shared_ptr<T> const & a, shared_ptr<U> const & b) noexcept;
template<class T, class U>
bool operator!=(shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
template<class T> bool operator==(local_shared_ptr<T> const & p, std::nullptr_t) noexcept;
template<class T> bool operator==(std::nullptr_t, local_shared_ptr<T> const & p) noexcept;
template<class T> bool operator!=(local_shared_ptr<T> const & p, std::nullptr_t) noexcept;
template<class T> bool operator!=(std::nullptr_t, local_shared_ptr<T> const & p) noexcept;
template<class T, class U>
bool operator<(local_shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
// swap
template<class T> void swap(local_shared_ptr<T> & a, local_shared_ptr<T> & b) noexcept;
// get_pointer
template<class T>
typename local_shared_ptr<T>::element_type *
get_pointer(local_shared_ptr<T> const & p) noexcept;
// casts
template<class T, class U>
local_shared_ptr<T> static_pointer_cast(local_shared_ptr<U> const & r) noexcept;
template<class T, class U>
local_shared_ptr<T> const_pointer_cast(local_shared_ptr<U> const & r) noexcept;
template<class T, class U>
local_shared_ptr<T> dynamic_pointer_cast(local_shared_ptr<U> const & r) noexcept;
template<class T, class U>
local_shared_ptr<T> reinterpret_pointer_cast(local_shared_ptr<U> const & r) noexcept;
// stream I/O
template<class E, class T, class Y>
std::basic_ostream<E, T> &
operator<< (std::basic_ostream<E, T> & os, local_shared_ptr<Y> const & p);
// get_deleter
template<class D, class T> D * get_deleter(local_shared_ptr<T> const & p) noexcept;
}
```
## Members
### element_type
```
typedef ... element_type;
```
`element_type` is `T` when `T` is not an array type, and `U` when `T` is `U[]` or `U[N]`.
### default constructor
```
constexpr local_shared_ptr() noexcept;
```
```
constexpr local_shared_ptr(std::nullptr_t) noexcept;
```
[none]
* {blank}
+
Effects:: Constructs an empty `local_shared_ptr`.
Postconditions:: `local_use_count() == 0 && get() == 0`.
### pointer constructor
```
template<class Y> explicit local_shared_ptr(Y * p);
```
[none]
* {blank}
+
Effects:: Constructs a `local_shared_ptr` that owns `shared_ptr<T>( p )`.
Postconditions:: `local_use_count() == 1 && get() == p`.
Throws:: `std::bad_alloc`, or an implementation-defined exception when a resource other than memory could not be obtained.
### constructors taking a deleter
```
template<class Y, class D> local_shared_ptr(Y * p, D d);
```
```
template<class D> local_shared_ptr(std::nullptr_t p, D d);
```
[none]
* {blank}
+
Effects:: Constructs a `local_shared_ptr` that owns `shared_ptr<T>( p, d )`.
Postconditions:: `local_use_count() == 1 && get() == p`.
Throws:: `std::bad_alloc`, or an implementation-defined exception when a resource other than memory could not be obtained.
```
template<class Y, class D, class A> local_shared_ptr(Y * p, D d, A a);
```
```
template<class D, class A> local_shared_ptr(std::nullptr_t p, D d, A a);
```
[none]
* {blank}
+
Effects:: Constructs a `local_shared_ptr` that owns `shared_ptr<T>( p, d, a )`.
Postconditions:: `local_use_count() == 1 && get() == p`.
Throws:: `std::bad_alloc`, or an implementation-defined exception when a resource other than memory could not be obtained.
### copy and converting constructors
```
local_shared_ptr(local_shared_ptr const & r) noexcept;
```
```
template<class Y> local_shared_ptr(local_shared_ptr<Y> const & r) noexcept;
```
[none]
* {blank}
+
Requires:: `Y*` should be convertible to `T*`.
Effects:: If `r` is empty, constructs an empty `local_shared_ptr`; otherwise, constructs a `local_shared_ptr` that shares ownership with `r`.
Postconditions:: `get() == r.get() && local_use_count() == r.local_use_count()`.
### move constructors
```
local_shared_ptr(local_shared_ptr && r) noexcept;
```
```
template<class Y> local_shared_ptr(local_shared_ptr<Y> && r) noexcept;
```
[none]
* {blank}
+
Requires:: `Y*` should be convertible to `T*`.
Effects:: Move-constructs a `local_shared_ptr` from `r`.
Postconditions:: `*this` contains the old value of `r`. `r` is empty and `r.get() == 0`.
### shared_ptr constructor
```
template<class Y> local_shared_ptr( shared_ptr<Y> const & r );
```
```
template<class Y> local_shared_ptr( shared_ptr<Y> && r );
```
[none]
* {blank}
+
Effects:: Constructs a `local_shared_ptr` that owns `r`.
Postconditions:: `local_use_count() == 1`. `get()` returns the old value of `r.get()`.
Throws:: `std::bad_alloc`, or an implementation-defined exception when a resource other than memory could not be obtained.
### aliasing constructor
```
template<class Y> local_shared_ptr(local_shared_ptr<Y> const & r, element_type * p) noexcept;
```
[none]
* {blank}
+
Effects:: constructs a `local_shared_ptr` that shares ownership with `r` and stores `p`.
Postconditions:: `get() == p && local_use_count() == r.local_use_count()`.
### aliasing move constructor
```
template<class Y> local_shared_ptr(local_shared_ptr<Y> && r, element_type * p) noexcept;
```
[none]
* {blank}
+
Effects:: Move-constructs a `local_shared_ptr` from `r`, while storing `p` instead.
Postconditions:: `get() == p` and `local_use_count()` equals the old count of `r`. `r` is empty and `r.get() == 0`.
### unique_ptr constructor
```
template<class Y, class D> local_shared_ptr(std::unique_ptr<Y, D> && r);
```
[none]
* {blank}
+
Requires:: `Y*` should be convertible to `T*`.
Effects::
- When `r.get() == 0`, equivalent to `local_shared_ptr()`;
- Otherwise, constructs a `local_shared_ptr` that owns `shared_ptr<T>( std::move(r) )`.
Throws:: `std::bad_alloc`, or an implementation-defined exception when a resource other than memory could not be obtained.
Exception safety:: If an exception is thrown, the constructor has no effect.
### destructor
```
~local_shared_ptr() noexcept;
```
[none]
* {blank}
+
Effects::
- If `*this` is empty, or shares ownership with another `local_shared_ptr` instance (`local_use_count() > 1`), there are no side effects.
- Otherwise, destroys the owned `shared_ptr`.
### assignment
```
local_shared_ptr & operator=(local_shared_ptr const & r) noexcept;
```
```
template<class Y> local_shared_ptr & operator=(local_shared_ptr<Y> const & r) noexcept;
```
[none]
* {blank}
+
Effects:: Equivalent to `local_shared_ptr(r).swap(*this)`.
Returns:: `*this`.
```
local_shared_ptr & operator=(local_shared_ptr && r) noexcept;
```
```
template<class Y> local_shared_ptr & operator=(local_shared_ptr<Y> && r) noexcept;
```
```
template<class Y, class D> local_shared_ptr & operator=(std::unique_ptr<Y, D> && r);
```
[none]
* {blank}
+
Effects:: Equivalent to `local_shared_ptr(std::move(r)).swap(*this)`.
Returns:: `*this`.
```
local_shared_ptr & operator=(std::nullptr_t) noexcept;
```
[none]
* {blank}
+
Effects:: Equivalent to `local_shared_ptr().swap(*this)`.
Returns:: `*this`.
### reset
```
void reset() noexcept;
```
[none]
* {blank}
+
Effects:: Equivalent to `local_shared_ptr().swap(*this)`.
```
template<class Y> void reset(Y * p);
```
[none]
* {blank}
+
Effects:: Equivalent to `local_shared_ptr(p).swap(*this)`.
```
template<class Y, class D> void reset(Y * p, D d);
```
[none]
* {blank}
+
Effects:: Equivalent to `local_shared_ptr(p, d).swap(*this)`.
```
template<class Y, class D, class A> void reset(Y * p, D d, A a);
```
[none]
* {blank}
+
Effects:: Equivalent to `local_shared_ptr(p, d, a).swap(*this)`.
```
template<class Y> void reset(local_shared_ptr<Y> const & r, element_type * p) noexcept;
```
[none]
* {blank}
+
Effects:: Equivalent to `local_shared_ptr(r, p).swap(*this)`.
```
template<class Y> void reset(local_shared_ptr<Y> && r, element_type * p) noexcept;
```
[none]
* {blank}
+
Effects::
Equivalent to `local_shared_ptr(std::move(r), p).swap(*this)`.
### indirection
```
T & operator*() const noexcept;
```
[none]
* {blank}
+
Requires:: `T` should not be an array type.
Returns:: `*get()`.
```
T * operator->() const noexcept;
```
[none]
* {blank}
+
Requires:: `T` should not be an array type.
Returns:: `get()`.
```
element_type & operator[](std::ptrdiff_t i) const noexcept;
```
[none]
* {blank}
+
Requires:: `T` should be an array type. The stored pointer must not be 0. `i >= 0`. If `T` is `U[N]`, `i < N`.
Returns:: `get()[i]`.
### get
```
element_type * get() const noexcept;
```
[none]
* {blank}
+
Returns::
The stored pointer.
### local_use_count
```
long local_use_count() const noexcept;
```
[none]
* {blank}
+
Returns::
The number of `local_shared_ptr` objects, `*this` included, that share ownership with `*this`, or 0 when `*this` is empty.
### conversions
```
explicit operator bool() const noexcept;
```
[none]
* {blank}
+
Returns:: `get() != 0`.
NOTE: On C++03 compilers, the return value is of an unspecified type.
```
template<class Y> operator shared_ptr<Y>() const noexcept;
```
```
template<class Y> operator weak_ptr<Y>() const noexcept;
```
[none]
* {blank}
+
Requires:: `T*` should be convertible to `Y*`.
Returns:: a copy of the owned `shared_ptr`.
### swap
```
void swap(local_shared_ptr & b) noexcept;
```
[none]
* {blank}
+
Effects::
Exchanges the contents of the two smart pointers.
### owner_before
```
template<class Y> bool owner_before(local_shared_ptr<Y> const & r) const noexcept;
```
[none]
* {blank}
+
Returns::
See the description of `operator<`.
### owner_equals
```
template<class Y> bool owner_equals(local_shared_ptr<Y> const & r) const noexcept;
```
[none]
* {blank}
+
Returns::
`true` if and only if `*this` and `r` share ownership or are both empty.
## Free Functions
### comparison
```
template<class T, class U>
bool operator==(local_shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
```
```
template<class T, class U>
bool operator==(local_shared_ptr<T> const & a, shared_ptr<U> const & b) noexcept;
```
```
template<class T, class U>
bool operator==(shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
```
[none]
* {blank}
+
Returns:: `a.get() == b.get()`.
```
template<class T, class U>
bool operator!=(local_shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
```
```
template<class T, class U>
bool operator!=(local_shared_ptr<T> const & a, shared_ptr<U> const & b) noexcept;
```
```
template<class T, class U>
bool operator!=(shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
```
[none]
* {blank}
+
Returns:: `a.get() != b.get()`.
```
template<class T> bool operator==(local_shared_ptr<T> const & p, std::nullptr_t) noexcept;
```
```
template<class T> bool operator==(std::nullptr_t, local_shared_ptr<T> const & p) noexcept;
```
[none]
* {blank}
+
Returns:: `p.get() == 0`.
```
template<class T> bool operator!=(local_shared_ptr<T> const & p, std::nullptr_t) noexcept;
```
```
template<class T> bool operator!=(std::nullptr_t, local_shared_ptr<T> const & p) noexcept;
```
[none]
* {blank}
+
Returns:: `p.get() != 0`.
```
template<class T, class U>
bool operator<(local_shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
```
[none]
* {blank}
+
Returns:: An unspecified value such that
- `operator<` is a strict weak ordering as described in section [lib.alg.sorting] of the {cpp} standard;
- under the equivalence relation defined by `operator<`, `!(a < b) && !(b < a)`, two `local_shared_ptr` instances
are equivalent if and only if they share ownership or are both empty.
NOTE: Allows `local_shared_ptr` objects to be used as keys in associative containers.
NOTE: The rest of the comparison operators are omitted by design.
### swap
```
template<class T> void swap(local_shared_ptr<T> & a, local_shared_ptr<T> & b) noexcept;
```
[none]
* {blank}
+
Effects::
Equivalent to `a.swap(b)`.
### get_pointer
```
template<class T>
typename local_shared_ptr<T>::element_type *
get_pointer(local_shared_ptr<T> const & p) noexcept;
```
[none]
* {blank}
+
Returns:: `p.get()`.
NOTE: Provided as an aid to generic programming. Used by `mem_fn`.
### static_pointer_cast
```
template<class T, class U>
local_shared_ptr<T> static_pointer_cast(local_shared_ptr<U> const & r) noexcept;
```
[none]
* {blank}
+
Requires:: The expression `static_cast<T*>( (U*)0 )` must be well-formed.
Returns:: `local_shared_ptr<T>( r, static_cast<typename local_shared_ptr<T>::element_type*>(r.get()) )`.
CAUTION: The seemingly equivalent expression `local_shared_ptr<T>(static_cast<T*>(r.get()))` will eventually
result in undefined behavior, attempting to delete the same object twice.
### const_pointer_cast
```
template<class T, class U>
local_shared_ptr<T> const_pointer_cast(local_shared_ptr<U> const & r) noexcept;
```
[none]
* {blank}
+
Requires:: The expression `const_cast<T*>( (U*)0 )` must be well-formed.
Returns:: `local_shared_ptr<T>( r, const_cast<typename local_shared_ptr<T>::element_type*>(r.get()) )`.
### dynamic_pointer_cast
```
template<class T, class U>
local_shared_ptr<T> dynamic_pointer_cast(local_shared_ptr<U> const & r) noexcept;
```
[none]
* {blank}
+
Requires:: The expression `dynamic_cast<T*>( (U*)0 )` must be well-formed.
Returns::
- When `dynamic_cast<typename local_shared_ptr<T>::element_type*>(r.get())` returns a nonzero value `p`, `local_shared_ptr<T>(r, p)`;
- Otherwise, `local_shared_ptr<T>()`.
### reinterpret_pointer_cast
```
template<class T, class U>
local_shared_ptr<T> reinterpret_pointer_cast(local_shared_ptr<U> const & r) noexcept;
```
[none]
* {blank}
+
Requires:: The expression `reinterpret_cast<T*>( (U*)0 )` must be well-formed.
Returns:: `local_shared_ptr<T>( r, reinterpret_cast<typename local_shared_ptr<T>::element_type*>(r.get()) )`.
### operator<<
```
template<class E, class T, class Y>
std::basic_ostream<E, T> &
operator<< (std::basic_ostream<E, T> & os, local_shared_ptr<Y> const & p);
```
[none]
* {blank}
+
Effects:: `os << p.get();`.
Returns:: `os`.
### get_deleter
```
template<class D, class T>
D * get_deleter(local_shared_ptr<T> const & p) noexcept;
```
[none]
* {blank}
+
Returns:: If `*this` owns a `shared_ptr` instance `p`, `get_deleter<D>( p )`, otherwise 0.

View File

@ -0,0 +1,81 @@
////
Copyright 2017 Glen Joseph Fernandes (glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt
////
[#make_local_shared]
# make_local_shared: Creating local_shared_ptr
:toc:
:toc-title:
:idprefix: make_local_shared_
## Description
The function templates `make_local_shared` and `allocate_local_shared` provide
convenient, safe and efficient ways to create `local_shared_ptr` objects. They
are analogous to `make_shared` and `allocate_shared` for `shared_ptr`.
## Synopsis
`make_local_shared` and `allocate_local_shared` are defined in
`<boost/smart_ptr/make_local_shared.hpp>`.
[subs=+quotes]
```
namespace boost {
`// T is not an array`
template<class T, class... Args>
local_shared_ptr<T> make_local_shared(Args&&... args);
template<class T, class A, class... Args>
local_shared_ptr<T> allocate_local_shared(const A& a, Args&&... args);
`// T is an array of unknown bounds`
template<class T>
local_shared_ptr<T> make_local_shared(std::size_t n);
template<class T, class A>
local_shared_ptr<T> allocate_local_shared(const A& a, std::size_t n);
`// T is an array of known bounds`
template<class T>
local_shared_ptr<T> make_local_shared();
template<class T, class A>
local_shared_ptr<T> allocate_local_shared(const A& a);
`// T is an array of unknown bounds`
template<class T>
local_shared_ptr<T> make_local_shared(std::size_t n,
const remove_extent_t<T>& v);
template<class T, class A>
local_shared_ptr<T> allocate_local_shared(const A& a, std::size_t n,
const remove_extent_t<T>& v);
`// T is an array of known bounds`
template<class T>
local_shared_ptr<T> make_local_shared(const remove_extent_t<T>& v);
template<class T, class A>
local_shared_ptr<T> allocate_local_shared(const A& a,
const remove_extent_t<T>& v);
`// T is not an array of known bounds`
template<class T>
local_shared_ptr<T> make_local_shared_noinit();
template<class T, class A>
local_shared_ptr<T> allocate_local_shared_noinit(const A& a);
`// T is an array of unknown bounds`
template<class T>
local_shared_ptr<T> make_local_shared_noinit(std::size_t n);
template<class T, class A>
local_shared_ptr<T> allocate_local_shared_noinit(const A& a,
std::size_t n);
}
```
## Description
The requirements and effects of these functions are the same as `make_shared`
and `allocate_shared`, except that a `local_shared_ptr` is returned.

View File

@ -0,0 +1,296 @@
////
Copyright 2017 Peter Dimov
Copyright 2017 Glen Joseph Fernandes (glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt
////
[#make_shared]
# make_shared: Creating shared_ptr
:toc:
:toc-title:
:idprefix: make_shared_
## Description
The function templates `make_shared` and `allocate_shared` provide convenient,
safe and efficient ways to create `shared_ptr` objects.
## Rationale
Consistent use of `shared_ptr` can eliminate the need to use an explicit
`delete`, but alone it provides no support in avoiding explicit `new`. There
were repeated requests from users for a factory function that creates an
object of a given type and returns a `shared_ptr` to it. Besides convenience
and style, such a function is also exception safe and considerably faster
because it can use a single allocation for both the object and its
corresponding control block, eliminating a significant portion of
`shared_ptr` construction overhead. This eliminates one of the major
efficiency complaints about `shared_ptr`.
The family of overloaded function templates, `make_shared` and
`allocate_shared`, were provided to address this need. `make_shared` uses the
global `operator new` to allocate memory, whereas `allocate_shared` uses an
user-supplied allocator, allowing finer control.
The rationale for choosing the name `make_shared` is that the expression
`make_shared<Widget>()` can be read aloud and conveys the intended meaning.
Originally the Boost function templates `allocate_shared` and `make_shared`
were provided for scalar objects only. There was a need to have efficient
allocation of array objects. One criticism of class template `shared_array`
was always the lack of a utility like `make_shared` that uses only a single
allocation. When `shared_ptr` was enhanced to support array types, additional
overloads of `allocate_shared` and `make_shared` were provided for array
types.
## Synopsis
`make_shared` and `allocate_shared` are defined in
`<boost/smart_ptr/make_shared.hpp>`.
[subs=+quotes]
```
namespace boost {
`// T is not an array`
template<class T, class... Args>
shared_ptr<T> make_shared(Args&&... args);
template<class T, class A, class... Args>
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
`// T is an array of unknown bounds`
template<class T>
shared_ptr<T> make_shared(std::size_t n);
template<class T, class A>
shared_ptr<T> allocate_shared(const A& a, std::size_t n);
`// T is an array of known bounds`
template<class T>
shared_ptr<T> make_shared();
template<class T, class A>
shared_ptr<T> allocate_shared(const A& a);
`// T is an array of unknown bounds`
template<class T> shared_ptr<T>
make_shared(std::size_t n, const remove_extent_t<T>& v);
template<class T, class A> shared_ptr<T>
allocate_shared(const A& a, std::size_t n, const remove_extent_t<T>& v);
`// T is an array of known bounds`
template<class T>
shared_ptr<T> make_shared(const remove_extent_t<T>& v);
template<class T, class A>
shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& v);
`// T is not an array of unknown bounds`
template<class T>
shared_ptr<T> make_shared_noinit();
template<class T, class A>
shared_ptr<T> allocate_shared_noinit(const A& a);
`// T is an array of unknown bounds`
template<class T>
shared_ptr<T> make_shared_noinit(std::size_t n);
template<class T, class A>
shared_ptr<T> allocate_shared_noinit(const A& a, std::size_t n);
}
```
## Common Requirements
The common requirements that apply to all `make_shared` and `allocate_shared`
overloads, unless specified otherwise, are described below.
Requires:: `A` shall be an _allocator_. The copy constructor and destructor
of `A` shall not throw exceptions.
Effects:: Allocates memory for an object of type `T` or `n` objects of `U`
(if `T` is an array type of the form `U[]` and `n` is determined by
arguments, as specified by the concrete overload). The object is initialized
from arguments as specified by the concrete overload. Uses a rebound copy of
`a` (for an unspecified `value_type`) to allocate memory. If an exception is
thrown, the functions have no effect.
Returns:: A `shared_ptr` instance that stores and owns the address of the
newly constructed object.
Postconditions:: `r.get() != 0` and `r.use_count() == 1`, where `r`
is the return value.
Throws:: `std::bad_alloc`, an exception thrown from `A::allocate`, or from the
initialization of the object.
Remarks::
* Performs no more than one memory allocation. This provides efficiency
equivalent to an intrusive smart pointer.
* When an object of an array type is specified to be initialized to a value of
the same type `v`, this shall be interpreted to mean that each array element
of the object is initialized to the corresponding element from `v`.
* When an object of an array type is specified to be value-initialized, this
shall be interpreted to mean that each array element of the object is
value-initialized.
* When a (sub)object of non-array type `U` is specified to be initialized to
a value `v`, or constructed from `args\...`, `make_shared` shall perform
this initialization via the expression `::new(p) U(expr)` (where
`_expr_` is `v` or `std::forward<Args>(args)\...)` respectively) and `p`
has type `void*` and points to storage suitable to hold an object of type
`U`.
* When a (sub)object of non-array type `U` is specified to be initialized to
a value `v`, or constructed from `args\...`, `allocate_shared` shall
perform this initialization via the expression
`std::allocator_traits<A2>::construct(a2, p, expr)` (where
`_expr_` is `v` or `std::forward<Args>(args)\...)` respectively), `p`
points to storage suitable to hold an object of type `U`, and `a2` of
type `A2` is a potentially rebound copy of `a`.
* When a (sub)object of non-array type `U` is specified to be
default-initialized, `make_shared_noinit` and `allocate_shared_noinit` shall
perform this initialization via the expression `::new(p) U`, where
`p` has type `void*` and points to storage suitable to hold an object of
type `U`.
* When a (sub)object of non-array type `U` is specified to be
value-initialized, `make_shared` shall perform this initialization via the
expression `::new(p) U()`, where `p` has type `void*` and points to
storage suitable to hold an object of type `U`.
* When a (sub)object of non-array type `U` is specified to be
value-initialized, `allocate_shared` shall perform this initialization via the
expression `std::allocator_traits<A2>::construct(a2, p)`, where
`p` points to storage suitable to hold an object of type `U` and `a2` of
type `A2` is a potentially rebound copy of `a`.
* Array elements are initialized in ascending order of their addresses.
* When the lifetime of the object managed by the return value ends, or when
the initialization of an array element throws an exception, the initialized
elements should be destroyed in the reverse order of their construction.
NOTE: These functions will typically allocate more memory than the total size
of the element objects to allow for internal bookkeeping structures such as
the reference counts.
## Free Functions
```
template<class T, class... Args>
shared_ptr<T> make_shared(Args&&... args);
```
```
template<class T, class A, class... Args>
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
```
[none]
* {blank}
+
Constraints:: `T` is not an array.
Returns:: A `shared_ptr` to an object of type `T`, constructed from
`args\...`.
Examples::
* `auto p = make_shared<int>();`
* `auto p = make_shared<std::vector<int> >(16, 1);`
```
template<class T>
shared_ptr<T> make_shared(std::size_t n);
```
```
template<class T, class A>
shared_ptr<T> allocate_shared(const A& a, std::size_t n);
```
[none]
* {blank}
+
Constraints:: `T` is an array of unknown bounds.
Returns:: A `shared_ptr` to a sequence of `n` value-initialized objects of
type `remove_extent_t<T>`.
Examples::
* `auto p = make_shared<double[]>(1024);`
* `auto p = make_shared<double[][2][2]>(6);`
```
template<class T>
shared_ptr<T> make_shared();
```
```
template<class T, class A>
shared_ptr<T> allocate_shared(const A& a);
```
[none]
* {blank}
+
Constraints:: `T` is an array of known bounds.
Returns:: A `shared_ptr` to a sequence of `extent_v<T>` value-initialized
objects of type `remove_extent_t<T>`.
Examples::
* `auto p = make_shared<double[1024]>();`
* `auto p = make_shared<double[6][2][2]>();`
```
template<class T> shared_ptr<T>
make_shared(std::size_t n, const remove_extent_t<T>& v);
```
```
template<class T, class A> shared_ptr<T>
allocate_shared(const A& a, std::size_t n, const remove_extent_t<T>& v);
```
[none]
* {blank}
+
Constraints:: `T` is an array of unknown bounds.
Returns:: A `shared_ptr` to a sequence of `n` objects of type
`remove_extent_t<T>`, each initialized to `v`.
Examples::
* `auto p = make_shared<double[]>(1024, 1.0);`
* `auto p = make_shared<double[][2]>(6, {1.0, 0.0});`
* `auto p = make_shared<std::vector<int>[]>(4, {1, 2});`
```
template<class T>
shared_ptr<T> make_shared(const remove_extent_t<T>& v);
```
```
template<class T, class A>
shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& v);
```
[none]
* {blank}
+
Constraints:: `T` is an array of known bounds.
Returns:: A `shared_ptr` to a sequence of `extent_v<T>` objects of type
`remove_extent_t<T>`, each initialized to `v`.
Examples::
* `auto p = make_shared<double[1024]>(1.0);`
* `auto p = make_shared<double[6][2]>({1.0, 0.0});`
* `auto p = make_shared<std::vector<int>[4]>({1, 2});`
```
template<class T>
shared_ptr<T> make_shared_noinit();
```
```
template<class T, class A>
shared_ptr<T> allocate_shared_noinit(const A& a);
```
[none]
* {blank}
+
Constraints:: `T` is not an array, or is an array of known bounds.
Returns:: A `shared_ptr` to a default-initialized object of type `T`, or a
sequence of `extent_v<T>` default-initialized objects of type
`remove_extent_t<T>`, respectively.
Example:: `auto p = make_shared_noinit<double[1024]>();`
```
template<class T>
shared_ptr<T> make_shared_noinit(std::size_t n);
```
```
template<class T, class A>
shared_ptr<T> allocate_shared_noinit(const A& a, std::size_t n);
```
[none]
* {blank}
+
Constraints:: `T` is an array of unknown bounds.
Returns:: A `shared_ptr` to a sequence of `_n_` default-initialized objects
of type `remove_extent_t<T>`.
Example:: `auto p = make_shared_noinit<double[]>(1024);`

View File

@ -0,0 +1,120 @@
////
Copyright 2017 Peter Dimov
Copyright 2017 Glen Joseph Fernandes (glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt
////
[#make_unique]
# make_unique: Creating unique_ptr
:toc:
:toc-title:
:idprefix: make_unique_
## Description
The `make_unique` function templates provide convenient and safe ways to
create `std::unique_ptr` objects.
## Rationale
The {cpp}11 standard introduced `std::unique_ptr` but did not provide any
`make_unique` utility like `std::make_shared` that provided the same
exception safety and facility to avoid writing `new` expressions. Before it
was implemented by some standard library vendors (and prior to the {cpp}14
standard introducing `std::make_unique`), this library provided it due to
requests from users.
This library also provides additional overloads of `make_unique` for
default-initialization, when users do not need or want to incur the expense
of value-initialization. The {cpp} standard does not yet provide this
feature with `std::make_unique`.
## Synopsis
`make_unique` is defined in `<boost/smart_ptr/make_unique.hpp>`.
[subs=+quotes]
```
namespace boost {
`// T is not an array`
template<class T, class... Args>
std::unique_ptr<T> make_unique(Args&&... args);
`// T is not an array`
template<class T>
std::unique_ptr<T> make_unique(type_identity_t<T>&& v);
`// T is an array of unknown bounds`
template<class T>
std::unique_ptr<T> make_unique(std::size_t n);
`// T is not an array`
template<class T>
std::unique_ptr<T> make_unique_noinit();
`// T is an array of unknown bounds`
template<class T>
std::unique_ptr<T> make_unique_noinit(std::size_t n);
}
```
## Free Functions
```
template<class T, class... Args>
std::unique_ptr<T> make_unique(Args&&... args);
```
[none]
* {blank}
+
Constraints:: `T` is not an array.
Returns:: `std::unique_ptr<T>(new T(std::forward<Args>(args)\...)`.
Example:: `auto p = make_unique<int>();`
```
template<class T>
std::unique_ptr<T> make_unique(type_identity_t<T>&& v);
```
[none]
* {blank}
+
Constraints:: `T` is not an array.
Returns:: `std::unique_ptr<T>(new T(std::move(v))`.
Example:: `auto p = make_unique<std::vector<int> >({1, 2});`
```
template<class T>
std::unique_ptr<T> make_unique(std::size_t n);
```
[none]
* {blank}
+
Constraints:: `T` is an array of unknown bounds.
Returns:: `std::unique_ptr<T>(new remove_extent_t<T>[n]())`.
Example:: `auto p = make_unique<double[]>(1024);`
```
template<class T>
std::unique_ptr<T> make_unique_noinit();
```
[none]
* {blank}
+
Constraints:: `T` is not an array.
Returns:: `std::unique_ptr<T>(new T)`.
Example:: `auto p = make_unique_noinit<std::array<double, 1024> >();`
```
template<class T>
std::unique_ptr<T> make_unique_noinit(std::size_t n);
```
[none]
* {blank}
+
Constraints:: `T` is an array of unknown bounds.
Returns:: `std::unique_ptr<T>(new remove_extent_t<T>[n])`.
Example:: `auto p = make_unique_noinit<double[]>(1024);`

View File

@ -0,0 +1,45 @@
////
Copyright 2020 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
[#owner_equal_to]
# owner_equal_to
:toc:
:toc-title:
:idprefix: owner_equal_to_
## Description
`owner_equal_to<T>` is a helper function object that compares two smart
pointer objects using `owner_equals`.
## Synopsis
`owner_equal_to` is defined in `<boost/smart_ptr/owner_equal_to.hpp>`.
```
namespace boost {
template<class T = void> struct owner_equal_to
{
typedef bool result_type;
typedef T first_argument_type;
typedef T second_argument_type;
template<class U, class V> bool operator()( U const & u, V const & v ) const noexcept;
};
}
```
## Members
```
template<class U, class V> bool operator()( U const & u, V const & v ) const noexcept;
```
[none]
* {blank}
+
Returns::
`u.owner_equals( v )`.

View File

@ -0,0 +1,56 @@
////
Copyright 2020 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
[#owner_hash]
# owner_hash
:toc:
:toc-title:
:idprefix: owner_hash_to_
## Description
`owner_hash<T>` is a helper function object that takes a smart pointer `p`
and returns `p.owner_hash_value()`. It's useful for creating unordered
containers of `shared_ptr` that use ownership-based equality, instead of
the default pointer value equality. (It can be used with `weak_ptr` too,
but there's no need, because `boost::hash` and `std::hash` for `weak_ptr`
already use ownership-based equality.)
## Example
```
std::unordered_set< boost::shared_ptr<void>,
boost::owner_hash< boost::shared_ptr<void> >,
boost::owner_equal_to< boost::shared_ptr<void> > > set;
```
## Synopsis
`owner_hash` is defined in `<boost/smart_ptr/owner_hash.hpp>`.
```
namespace boost {
template<class T> struct owner_hash
{
typedef std::size_t result_type;
typedef T argument_type;
std::size_t operator()( T const & p ) const noexcept;
};
}
```
## Members
```
std::size_t operator()( T const & p ) const noexcept;
```
[none]
* {blank}
+
Returns::
`p.owner_hash_value()`.

View File

@ -0,0 +1,50 @@
////
Copyright 2020 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
[#owner_less]
# owner_less
:toc:
:toc-title:
:idprefix: owner_less_
## Description
`owner_less<T>` is a helper function object that compares two smart
pointer objects using `owner_before`. It is only provided for compatibility
with {cpp}11 and corresponds to the standard component of the same name.
When using Boost smart pointers, the use of `owner_less` is unnecessary, as
the supplied `operator<` overloads (and, correspondingly, `std::less`) return
the same result.
## Synopsis
`owner_less` is defined in `<boost/smart_ptr/owner_less.hpp>`.
```
namespace boost {
template<class T = void> struct owner_less
{
typedef bool result_type;
typedef T first_argument_type;
typedef T second_argument_type;
template<class U, class V> bool operator()( U const & u, V const & v ) const noexcept;
};
}
```
## Members
```
template<class U, class V> bool operator()( U const & u, V const & v ) const noexcept;
```
[none]
* {blank}
+
Returns::
`u.owner_before( v )`.

View File

@ -0,0 +1,237 @@
////
Copyright 2017 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
////
[#pointer_cast]
# Generic Pointer Casts
:toc:
:toc-title:
:idprefix: pointer_cast_
## Description
The pointer cast function templates (`static_pointer_cast`,
`dynamic_pointer_cast`, `const_pointer_cast`, and `reinterpret_pointer_cast`)
provide a way to write generic pointer castings for raw pointers,
`std::shared_ptr` and `std::unique_ptr`.
There is test and example code in
link:../../test/pointer_cast_test.cpp[pointer_cast_test.cpp]
## Rationale
Boost smart pointers usually overload those functions to provide a mechanism
to emulate pointers casts. For example, `shared_ptr<T>` implements a static
pointer cast this way:
```
template<class T, class U>
shared_ptr<T> static_pointer_cast(const shared_ptr<U>& p);
```
Pointer cast functions templates are overloads of `static_pointer_cast`,
`dynamic_pointer_cast`, `const_pointer_cast`, and `reinterpret_pointer_cast`
for raw pointers, `std::shared_ptr` and `std::unique_ptr`. This way when
developing pointer type independent classes, for example, memory managers or
shared memory compatible classes, the same code can be used for raw and smart
pointers.
## Synopsis
The generic pointer casts are defined in `<boost/pointer_cast.hpp>`.
```
namespace boost {
template<class T, class U> T* static_pointer_cast(U* p) noexcept;
template<class T, class U> T* dynamic_pointer_cast(U* p) noexcept;
template<class T, class U> T* const_pointer_cast(U* p) noexcept;
template<class T, class U> T* reinterpret_pointer_cast(U* p) noexcept;
template<class T, class U> std::shared_ptr<T>
static_pointer_cast(const std::shared_ptr<U>& p) noexcept;
template<class T, class U> std::shared_ptr<T>
dynamic_pointer_cast(const std::shared_ptr<U>& p) noexcept;
template<class T, class U> std::shared_ptr<T>
const_pointer_cast(const std::shared_ptr<U>& p) noexcept;
template<class T, class U> std::shared_ptr<T>
reinterpret_pointer_cast(const std::shared_ptr<U>& p) noexcept;
template<class T, class U> std::unique_ptr<T>
static_pointer_cast(std::unique_ptr<U>&& p) noexcept;
template<class T, class U> std::unique_ptr<T>
dynamic_pointer_cast(std::unique_ptr<U>&& p) noexcept;
template<class T, class U> std::unique_ptr<T>
const_pointer_cast(std::unique_ptr<U>&& p) noexcept;
template<class T, class U> std::unique_ptr<T>
reinterpret_pointer_cast(std::unique_ptr<U>&& p) noexcept;
}
```
## Free Functions
### static_pointer_cast
```
template<class T, class U> T* static_pointer_cast(U* p) noexcept;
```
[none]
* {blank}
+
Returns:: `static_cast<T*>(p)`
```
template<class T, class U> std::shared_ptr<T>
static_pointer_cast(const std::shared_ptr<U>& p) noexcept;
```
[none]
* {blank}
+
Returns:: `std::static_pointer_cast<T>(p)`
```
template<class T, class U> std::unique_ptr<T>
static_pointer_cast(std::unique_ptr<U>&& p) noexcept;
```
[none]
* {blank}
+
Requires:: The expression `static_cast<T*>((U*)0)` must be well-formed.
Returns:: `std::unique_ptr<T>(static_cast<typename
std::unique_ptr<T>::element_type*>(p.release()))`.
CAUTION: The seemingly equivalent expression
`std::unique_ptr<T>(static_cast<T*>(p.get()))` will eventually result in
undefined behavior, attempting to delete the same object twice.
### dynamic_pointer_cast
```
template<class T, class U> T* dynamic_pointer_cast(U* p) noexcept;
```
[none]
* {blank}
+
Returns:: `dynamic_cast<T*>(p)`
```
template<class T, class U> std::shared_ptr<T>
dynamic_pointer_cast(const std::shared_ptr<U>& p) noexcept;
```
[none]
* {blank}
+
Returns:: `std::dynamic_pointer_cast<T>(p)`
```
template<class T, class U> std::unique_ptr<T>
dynamic_pointer_cast(std::unique_ptr<U>&& p) noexcept;
```
[none]
* {blank}
+
Requires::
* The expression `static_cast<T*>((U*)0)` must be well-formed.
* `T` must have a virtual destructor.
Returns::
* When `dynamic_cast<typename std::unique_ptr<T>::element_type*>(p.get())`
returns a non-zero value, `std::unique_ptr<T>(dynamic_cast<typename
std::unique_ptr<T>::element_type*>(p.release()));`.
* Otherwise, `std::unique_ptr<T>()`.
### const_pointer_cast
```
template<class T, class U> T* const_pointer_cast(U* p) noexcept;
```
[none]
* {blank}
+
Returns:: `const_cast<T*>(p)`
```
template<class T, class U> std::shared_ptr<T>
const_pointer_cast(const std::shared_ptr<U>& p) noexcept;
```
[none]
* {blank}
+
Returns:: `std::const_pointer_cast<T>(p)`
```
template<class T, class U> std::unique_ptr<T>
const_pointer_cast(std::unique_ptr<U>&& p) noexcept;
```
[none]
* {blank}
+
Requires:: The expression `const_cast<T*>((U*)0)` must be well-formed.
Returns:: `std::unique_ptr<T>(const_cast<typename
std::unique_ptr<T>::element_type*>(p.release()))`.
### reinterpret_pointer_cast
```
template<class T, class U> T* reinterpret_pointer_cast(U* p) noexcept;
```
[none]
* {blank}
+
Returns:: `reinterpret_cast<T*>(p)`
```
template<class T, class U> std::shared_ptr<T>
reinterpret_pointer_cast(const std::shared_ptr<U>& p) noexcept;
```
[none]
* {blank}
+
Returns:: `std::reinterpret_pointer_cast<T>(p)`
```
template<class T, class U> std::unique_ptr<T>
reinterpret_pointer_cast(std::unique_ptr<U>&& p) noexcept;
```
[none]
* {blank}
+
Requires:: The expression `reinterpret_cast<T*>((U*)0)` must be well-formed.
Returns:: `std::unique_ptr<T>(reinterpret_cast<typename
std::unique_ptr<T>::element_type*>(p.release()))`.
## Example
The following example demonstrates how the generic pointer casts help us
create pointer independent code.
```
#include <boost/pointer_cast.hpp>
#include <boost/shared_ptr.hpp>
class base {
public:
virtual ~base() { }
};
class derived : public base { };
template<class Ptr>
void check_if_it_is_derived(const Ptr& ptr)
{
assert(boost::dynamic_pointer_cast<derived>(ptr) != 0);
}
int main()
{
base* ptr = new derived;
boost::shared_ptr<base> sptr(new derived);
check_if_it_is_derived(ptr);
check_if_it_is_derived(sptr);
delete ptr;
}
```

View File

@ -0,0 +1,114 @@
////
Copyright 2005, 2006 Ion Gaztañaga
Copyright 2005, 2006, 2017 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
////
[#pointer_to_other]
# pointer_to_other
:toc:
:toc-title:
:idprefix: pointer_to_other_
## Description
The `pointer_to_other` utility provides a way, given a source pointer type, to obtain a pointer of the same type
to another pointee type.
There is test/example code in link:../../test/pointer_to_other_test.cpp[pointer_to_other_test.cpp].
## Rationale
When building pointer independent classes, like memory managers, allocators, or containers, there is often a need to
define pointers generically, so that if a template parameter represents a pointer (for example, a raw or smart pointer
to an `int`), we can define another pointer of the same type to another pointee (a raw or smart pointer to a `float`.)
```
template <class IntPtr> class FloatPointerHolder
{
// Let's define a pointer to a float
typedef typename boost::pointer_to_other
<IntPtr, float>::type float_ptr_t;
float_ptr_t float_ptr;
};
```
## Synopsis
`pointer_to_other` is defined in `<boost/smart_ptr/pointer_to_other.hpp>`.
```
namespace boost {
template<class T, class U> struct pointer_to_other;
template<class T, class U,
template <class> class Sp>
struct pointer_to_other< Sp<T>, U >
{
typedef Sp<U> type;
};
template<class T, class T2, class U,
template <class, class> class Sp>
struct pointer_to_other< Sp<T, T2>, U >
{
typedef Sp<U, T2> type;
};
template<class T, class T2, class T3, class U,
template <class, class, class> class Sp>
struct pointer_to_other< Sp<T, T2, T3>, U >
{
typedef Sp<U, T2, T3> type;
};
template<class T, class U>
struct pointer_to_other< T*, U >
{
typedef U* type;
};
}
```
If these definitions are not correct for a specific smart pointer, we can define a specialization of `pointer_to_other`.
## Example
```
// Let's define a memory allocator that can
// work with raw and smart pointers
#include <boost/pointer_to_other.hpp>
template <class VoidPtr>
class memory_allocator
{
// Predefine a memory_block
struct block;
// Define a pointer to a memory_block from a void pointer
// If VoidPtr is void *, block_ptr_t is block*
// If VoidPtr is smart_ptr<void>, block_ptr_t is smart_ptr<block>
typedef typename boost::pointer_to_other
<VoidPtr, block>::type block_ptr_t;
struct block
{
std::size_t size;
block_ptr_t next_block;
};
block_ptr_t free_blocks;
};
```
As we can see, using `pointer_to_other` we can create pointer independent code.

View File

@ -0,0 +1,175 @@
////
Copyright 1999 Greg Colvin and Beman Dawes
Copyright 2002 Darin Adler
Copyright 2002-2005, 2017 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
////
[#scoped_array]
# scoped_array: Scoped Array Ownership
:toc:
:toc-title:
:idprefix: scoped_array_
## Description
The `scoped_array` class template stores a pointer to a dynamically allocated array.
(Dynamically allocated arrays are allocated with the {cpp} `new[]` expression.) The array
pointed to is guaranteed to be deleted, either on destruction of the `scoped_array`,
or via an explicit `reset`.
The `scoped_array` template is a simple solution for simple needs. It supplies a basic
"resource acquisition is initialization" facility, without shared-ownership or
transfer-of-ownership semantics. Both its name and enforcement of semantics
(by being noncopyable) signal its intent to retain ownership solely within the current scope.
Because it is noncopyable, it is safer than `shared_ptr<T[]>` for pointers which should not be copied.
Because `scoped_array` is so simple, in its usual implementation every operation is as fast as a
built-in array pointer and it has no more space overhead that a built-in array pointer.
It cannot be used in {cpp} standard library containers. See `shared_ptr<T[]>` if `scoped_array`
does not meet your needs.
It cannot correctly hold a pointer to a single object. See `scoped_ptr` for that usage.
`std::vector` is an alternative to `scoped_array` that is a bit heavier duty but far more flexible.
`boost::array` is an alternative that does not use dynamic allocation.
The class template is parameterized on `T`, the type of the object pointed to.
## Synopsis
`scoped_array` is defined in `<boost/smart_ptr/scoped_array.hpp>`.
```
namespace boost {
template<class T> class scoped_array {
private:
scoped_array(scoped_array const &);
scoped_array & operator=(scoped_array const &);
void operator==( scoped_array const& ) const;
void operator!=( scoped_array const& ) const;
public:
typedef T element_type;
explicit scoped_array(T * p = 0) noexcept;
~scoped_array() noexcept;
void reset(T * p = 0) noexcept;
T & operator[](std::ptrdiff_t i) const noexcept;
T * get() const noexcept;
explicit operator bool () const noexcept;
void swap(scoped_array & b) noexcept;
};
template<class T> void swap(scoped_array<T> & a, scoped_array<T> & b) noexcept;
template<class T>
bool operator==( scoped_array<T> const & p, std::nullptr_t ) noexcept;
template<class T>
bool operator==( std::nullptr_t, scoped_array<T> const & p ) noexcept;
template<class T>
bool operator!=( scoped_array<T> const & p, std::nullptr_t ) noexcept;
template<class T>
bool operator!=( std::nullptr_t, scoped_array<T> const & p ) noexcept;
}
```
## Members
### element_type
typedef T element_type;
Provides the type of the stored pointer.
### constructors
explicit scoped_array(T * p = 0) noexcept;
Constructs a `scoped_array`, storing a copy of `p`, which must have been
allocated via a {cpp} `new[]` expression or be 0. `T` is not required be a complete type.
### destructor
~scoped_array() noexcept;
Deletes the array pointed to by the stored pointer. Note that `delete[]` on a pointer with
a value of 0 is harmless. `T` must be complete, and `delete[]` on the stored pointer must
not throw exceptions.
### reset
void reset(T * p = 0) noexcept;
Deletes the array pointed to by the stored pointer and then stores a copy of `p`,
which must have been allocated via a {cpp} `new[]` expression or be 0. `T` must be complete,
and `delete[]` on the stored pointer must not throw exceptions.
### subscripting
T & operator[](std::ptrdiff_t i) const noexcept;
Returns a reference to element `i` of the array pointed to by the stored pointer.
Behavior is undefined and almost certainly undesirable if the stored pointer is 0,
or if `i` is less than 0 or is greater than or equal to the number of elements in
the array.
### get
T * get() const noexcept;
Returns the stored pointer. `T` need not be a complete type.
### conversions
explicit operator bool () const noexcept;
Returns `get() != 0`.
NOTE: On C++03 compilers, the return value is of an unspecified type.
### swap
void swap(scoped_array & b) noexcept;
Exchanges the contents of the two smart pointers. `T` need not be a complete type.
## Free Functions
### swap
template<class T> void swap(scoped_array<T> & a, scoped_array<T> & b) noexcept;
Equivalent to `a.swap(b)`.
### comparisons
template<class T>
bool operator==( scoped_array<T> const & p, std::nullptr_t ) noexcept;
template<class T>
bool operator==( std::nullptr_t, scoped_array<T> const & p ) noexcept;
Returns `p.get() == nullptr`.
template<class T>
bool operator!=( scoped_array<T> const & p, std::nullptr_t ) noexcept;
template<class T>
bool operator!=( std::nullptr_t, scoped_array<T> const & p ) noexcept;
Returns `p.get() != nullptr`.

View File

@ -0,0 +1,234 @@
////
Copyright 2017 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
////
[#scoped_ptr]
# scoped_ptr: Scoped Object Ownership
:toc:
:toc-title:
:idprefix: scoped_ptr_
## Description
The `scoped_ptr` class template stores a pointer to a dynamically allocated object.
(Dynamically allocated objects are allocated with the {cpp} `new` expression.) The
object pointed to is guaranteed to be deleted, either on destruction of the `scoped_ptr`,
or via an explicit `reset`. See the <<scoped_ptr_example,example>>.
`scoped_ptr` is a simple solution for simple needs. It supplies a basic "resource acquisition
is initialization" facility, without shared-ownership or transfer-of-ownership semantics.
Both its name and enforcement of semantics (by being noncopyable) signal its intent to retain
ownership solely within the current scope. Because it is noncopyable, it is safer than `shared_ptr`
for pointers which should not be copied.
Because `scoped_ptr` is simple, in its usual implementation every operation is as fast as for a
built-in pointer and it has no more space overhead that a built-in pointer.
`scoped_ptr` cannot be used in {cpp} Standard Library containers. Use `shared_ptr` or `std::unique_ptr`
if you need a smart pointer that can.
`scoped_ptr` cannot correctly hold a pointer to a dynamically allocated array. See `scoped_array` for that usage.
The class template is parameterized on `T`, the type of the object pointed to. Destroying `T` must not thow exceptions,
and `T` must be complete at the point `scoped_ptr<T>::~scoped_ptr` is instantiated.
## Synopsis
`scoped_ptr` is defined in `<boost/smart_ptr/scoped_ptr.hpp>`.
```
namespace boost {
template<class T> class scoped_ptr {
private:
scoped_ptr(scoped_ptr const&);
scoped_ptr& operator=(scoped_ptr const&);
void operator==(scoped_ptr const&) const;
void operator!=(scoped_ptr const&) const;
public:
typedef T element_type;
explicit scoped_ptr(T * p = 0) noexcept;
~scoped_ptr() noexcept;
void reset(T * p = 0) noexcept;
T & operator*() const noexcept;
T * operator->() const noexcept;
T * get() const noexcept;
explicit operator bool() const noexcept;
void swap(scoped_ptr & b) noexcept;
};
template<class T> void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) noexcept;
template<class T>
bool operator==( scoped_ptr<T> const & p, std::nullptr_t ) noexcept;
template<class T>
bool operator==( std::nullptr_t, scoped_ptr<T> const & p ) noexcept;
template<class T>
bool operator!=( scoped_ptr<T> const & p, std::nullptr_t ) noexcept;
template<class T>
bool operator!=( std::nullptr_t, scoped_ptr<T> const & p ) noexcept;
}
```
## Members
### element_type
typedef T element_type;
Provides the type of the stored pointer.
### constructor
explicit scoped_ptr(T * p = 0) noexcept;
Constructs a `scoped_ptr`, storing a copy of `p`, which must have been allocated via a
{cpp} `new` expression or be 0. `T` is not required be a complete type.
### destructor
~scoped_ptr() noexcept;
Destroys the object pointed to by the stored pointer, if any, as if by using
`delete this\->get()`. `T` must be a complete type.
### reset
void reset(T * p = 0) noexcept;
Deletes the object pointed to by the stored pointer and then stores a copy of
`p`, which must have been allocated via a {cpp} `new` expression or be 0.
Since the previous object needs to be deleted, `T` must be a complete type.
### indirection
T & operator*() const noexcept;
Returns a reference to the object pointed to by the stored pointer. Behavior is undefined if the stored pointer is 0.
T * operator->() const noexcept;
Returns the stored pointer. Behavior is undefined if the stored pointer is 0.
### get
T * get() const noexcept;
Returns the stored pointer. `T` need not be a complete type.
### conversions
explicit operator bool () const noexcept; // never throws
Returns `get() != 0`.
NOTE: On C++03 compilers, the return value is of an unspecified type.
### swap
void swap(scoped_ptr & b) noexcept;
Exchanges the contents of the two smart pointers. `T` need not be a complete type.
## Free Functions
### swap
template<class T> void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) noexcept;
Equivalent to `a.swap(b)`.
### comparisons
template<class T> bool operator==( scoped_ptr<T> const & p, std::nullptr_t ) noexcept;
template<class T> bool operator==( std::nullptr_t, scoped_ptr<T> const & p ) noexcept;
Returns `p.get() == nullptr`.
template<class T> bool operator!=( scoped_ptr<T> const & p, std::nullptr_t ) noexcept;
template<class T> bool operator!=( std::nullptr_t, scoped_ptr<T> const & p ) noexcept;
Returns `p.get() != nullptr`.
## Example
Here's an example that uses `scoped_ptr`.
```
#include <boost/scoped_ptr.hpp>
#include <iostream>
struct Shoe { ~Shoe() { std::cout << "Buckle my shoe\n"; } };
class MyClass {
boost::scoped_ptr<int> ptr;
public:
MyClass() : ptr(new int) { *ptr = 0; }
int add_one() { return ++*ptr; }
};
int main()
{
boost::scoped_ptr<Shoe> x(new Shoe);
MyClass my_instance;
std::cout << my_instance.add_one() << '\n';
std::cout << my_instance.add_one() << '\n';
}
```
The example program produces the beginning of a child's nursery rhyme:
```
1
2
Buckle my shoe
```
## Rationale
The primary reason to use `scoped_ptr` rather than `std::auto_ptr` or `std::unique_ptr` is to let readers of your code
know that you intend "resource acquisition is initialization" to be applied only for the current scope, and have no intent to transfer ownership.
A secondary reason to use `scoped_ptr` is to prevent a later maintenance programmer from adding a function that transfers
ownership by returning the `auto_ptr`, because the maintenance programmer saw `auto_ptr`, and assumed ownership could safely be transferred.
Think of `bool` vs `int`. We all know that under the covers `bool` is usually just an `int`. Indeed, some argued against including bool in the {cpp}
standard because of that. But by coding `bool` rather than `int`, you tell your readers what your intent is. Same with `scoped_ptr`; by using it you are signaling intent.
It has been suggested that `scoped_ptr<T>` is equivalent to `std::auto_ptr<T> const`. Ed Brey pointed out, however, that `reset` will not work on a `std::auto_ptr<T> const`.
## Handle/Body Idiom
One common usage of `scoped_ptr` is to implement a handle/body (also called pimpl) idiom which avoids exposing the body (implementation) in the header file.
The `link:../../example/scoped_ptr_example_test.cpp[scoped_ptr_example_test.cpp]` sample program includes a header file,
`link:../../example/scoped_ptr_example.hpp[scoped_ptr_example.hpp]`, which uses a `scoped_ptr<>` to an incomplete type to hide the
implementation. The instantiation of member functions which require a complete type occurs in the `link:../../example/scoped_ptr_example.cpp[scoped_ptr_example.cpp]`
implementation file.
## Frequently Asked Questions
[qanda]
Why doesn't `scoped_ptr` have a `release()` member?::
When reading source code, it is valuable to be able to draw conclusions about program behavior based on the types being used. If `scoped_ptr` had a `release()` member,
it would become possible to transfer ownership of the held pointer, weakening its role as a way of limiting resource lifetime to a given context. Use `std::auto_ptr` where
transfer of ownership is required. (supplied by Dave Abrahams)

View File

@ -0,0 +1,298 @@
////
Copyright 2017 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
////
[[shared_array]]
[appendix]
# shared_array (deprecated)
:toc:
:toc-title:
:idprefix: shared_array_
NOTE: This facility is deprecated because a `shared_ptr` to `T[]` or `T[N]`
is now available, and is superior in every regard.
## Description
The `shared_array` class template stores a pointer to a dynamically allocated
array. (Dynamically allocated array are allocated with the C++ `new[]`
expression.) The object pointed to is guaranteed to be deleted when the last
`shared_array` pointing to it is destroyed or reset.
Every `shared_array` meets the _CopyConstructible_ and _Assignable_
requirements of the {cpp} Standard Library, and so can be used in standard
library containers. Comparison operators are supplied so that shared_array
works with the standard library's associative containers.
Normally, a `shared_array` cannot correctly hold a pointer to an object that
has been allocated with the non-array form of `new`. See `shared_ptr` for that
usage.
Because the implementation uses reference counting, cycles of `shared_array`
instances will not be reclaimed. For example, if `main` holds a shared_array
to `A`, which directly or indirectly holds a shared_array back to `A`, the use
count of `A` will be 2. Destruction of the original `shared_array` will leave
`A` dangling with a use count of 1.
A `shared_ptr` to a `std::vector` is an alternative to a `shared_array` that
is a bit heavier duty but far more flexible.
The class template is parameterized on `T`, the type of the object pointed to.
`shared_array` and most of its member functions place no requirements on `T`;
it is allowed to be an incomplete type, or `void`. Member functions that do
place additional requirements (constructors, reset) are explicitly documented
below.
## Synopsis
```
namespace boost {
template<class T> class shared_array {
public:
typedef T element_type;
explicit shared_array(T* p = 0);
template<class D> shared_array(T* p, D d);
shared_array(const shared_array& v) noexcept;
~shared_array() noexcept;
shared_array& operator=(const shared_array& v) noexcept;
void reset(T* p = 0);
template<class D> void reset(T* p, D d);
T& operator[](std::ptrdiff_t n) const noexcept;
T* get() const noexcept;
bool unique() const noexcept;
long use_count() const noexcept;
explicit operator bool() const noexcept;
void swap(shared_array<T>& v) noexcept;
};
template<class T> bool
operator==(const shared_array<T>& a, const shared_array<T>& b) noexcept;
template<class T> bool
operator!=(const shared_array<T>& a, const shared_array<T>& b) noexcept;
template<class T> bool
operator<(const shared_array<T>& a, const shared_array<T>& b) noexcept;
template<class T>
void swap(shared_array<T>& a, shared_array<T>& b) noexcept;
}
```
## Members
### element_type
```
typedef T element_type;
```
Type:: Provides the type of the stored pointer.
### Constructors
```
explicit shared_array(T* p = 0);
```
[none]
* {blank}
+
Effects:: Constructs a `shared_array`, storing a copy of `p`, which must be a
pointer to an array that was allocated via a C++ `new[]` expression or be 0.
Afterwards, the use count is 1 (even if `p == 0`; see `~shared_array`).
Requires:: `T` is a complete type.
Throws:: `std::bad_alloc`. If an exception is thrown, `delete[] p` is called.
```
template<class D> shared_array(T* p, D d);
```
[none]
* {blank}
+
Effects:: Constructs a `shared_array`, storing a copy of `p` and of `d`.
Afterwards, the use count is 1. When the the time comes to delete the array
pointed to by `p`, the object `d` is used in the statement `d(p)`.
Requires::
* `T` is a complete type.
* The copy constructor and destructor of `D` must not throw.
* Invoking the object `d` with parameter `p` must not throw.
Throws:: `std::bad_alloc`. If an exception is thrown, `d(p)` is called.
```
shared_array(const shared_array& v) noexcept;
```
[none]
* {blank}
+
Effects:: Constructs a `shared_array`, as if by storing a copy of the pointer
stored in `v`. Afterwards, the use count for all copies is 1 more than the
initial use count.
Requires:: `T` is a complete type.
### Destructor
```
~shared_array() noexcept;
```
[none]
* {blank}
+
Effects:: Decrements the use count. Then, if the use count is 0, deletes the
array pointed to by the stored pointer. Note that `delete[]` on a pointer with
a value of 0 is harmless.
### Assignment
```
shared_array& operator=(const shared_array& v) noexcept;
```
[none]
* {blank}
+
Effects:: Constructs a new `shared_array` as described above, then replaces
this `shared_array` with the new one, destroying the replaced object.
Requires:: `T` is a complete type.
Returns:: `*this`.
### reset
```
void reset(T* p = 0);
```
[none]
* {blank}
+
Effects:: Constructs a new `shared_array` as described above, then replaces
this `shared_array` with the new one, destroying the replaced object.
Requires:: `T` is a complete type.
Throws:: `std::bad_alloc`. If an exception is thrown, `delete[] p` is called.
```
template<class D> void reset(T* p, D d);
```
[none]
* {blank}
+
Effects:: Constructs a new `shared_array` as described above, then replaces
this `shared_array` with the new one, destroying the replaced object.
Requires::
* `T` is a complete type.
* The copy constructor of `D` must not throw.
Throws:: `std::bad_alloc`. If an exception is thrown, `d(p)` is called.
### Indexing
```
T& operator[](std::ptrdiff_t n) const noexcept;
```
Returns:: A reference to element `n` of the array pointed to by the stored
pointer. Behavior is undefined and almost certainly undesirable if the stored
pointer is 0, or if `n` is less than 0 or is greater than or equal to the
number of elements in the array.
Requires:: `T` is a complete type.
### get
```
T* get() const noexcept;
```
[none]
* {blank}
+
Returns:: The stored pointer.
### unique
```
bool unique() const noexcept;
```
[none]
* {blank}
+
Returns:: `true` if no other `shared_array` is sharing ownership of the
stored pointer, `false` otherwise.
### use_count
```
long use_count() const noexcept;
```
[none]
* {blank}
+
Returns:: The number of `shared_array` objects sharing ownership of the
stored pointer.
### Conversions
```
explicit operator bool() const noexcept;
```
[none]
* {blank}
+
Returns:: `get() != 0`.
Requires:: `T` is a complete type.
### swap
```
void swap(shared_array<T>& b) noexcept;
```
[none]
* {blank}
+
Effects:: Exchanges the contents of the two smart pointers.
## Free Functions
### Comparison
```
template<class T> bool
operator==(const shared_array<T>& a, const shared_array<T>& b) noexcept;
```
```
template<class T> bool
operator!=(const shared_array<T>& a, const shared_array<T>& b) noexcept;
```
```
template<class T> bool
operator<(const shared_array<T>& a, const shared_array<T>& b) noexcept;
```
[none]
* {blank}
+
Returns:: The result of comparing the stored pointers of the two smart
pointers.
NOTE: The `operator<` overload is provided to define an ordering so that
`shared_array` objects can be used in associative containers such as
`std::map`. The implementation uses `std::less<T*>` to perform the comparison.
This ensures that the comparison is handled correctly, since the standard
mandates that relational operations on pointers are unspecified (5.9
[expr.rel] paragraph 2) but `std::less` on pointers is well-defined (20.3.3
[lib.comparisons] paragraph 8).
### swap
```
template<class T>
void swap(shared_array<T>& a, shared_array<T>& b) noexcept;
```
[none]
* {blank}
+
Returns:: `a.swap(b)`.
Requires:: `T` is a complete type.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,768 @@
////
Copyright 2003, 2017 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
////
[[techniques]]
[appendix]
# Smart Pointer Programming Techniques
:toc:
:toc-title:
:idprefix: techniques_
[#techniques_incomplete]
## Using incomplete classes for implementation hiding
A proven technique (that works in C, too) for separating interface from implementation is to use a pointer to an incomplete class as an opaque handle:
```
class FILE;
FILE * fopen(char const * name, char const * mode);
void fread(FILE * f, void * data, size_t size);
void fclose(FILE * f);
```
It is possible to express the above interface using `shared_ptr`, eliminating the need to manually call `fclose`:
```
class FILE;
shared_ptr<FILE> fopen(char const * name, char const * mode);
void fread(shared_ptr<FILE> f, void * data, size_t size);
```
This technique relies on `shared_ptr`&#8217;s ability to execute a custom deleter, eliminating the explicit call to `fclose`, and on the fact that `shared_ptr<X>` can be copied and destroyed when `X` is incomplete.
## The "Pimpl" idiom
A {cpp} specific variation of the incomplete class pattern is the "Pimpl" idiom. The incomplete class is not exposed to the user; it is hidden behind a forwarding facade. `shared_ptr` can be used to implement a "Pimpl":
```
// file.hpp:
class file
{
private:
class impl;
shared_ptr<impl> pimpl_;
public:
file(char const * name, char const * mode);
// compiler generated members are fine and useful
void read(void * data, size_t size);
};
// file.cpp:
#include "file.hpp"
class file::impl
{
private:
impl(impl const &);
impl & operator=(impl const &);
// private data
public:
impl(char const * name, char const * mode) { ... }
~impl() { ... }
void read(void * data, size_t size) { ... }
};
file::file(char const * name, char const * mode): pimpl_(new impl(name, mode))
{
}
void file::read(void * data, size_t size)
{
pimpl_->read(data, size);
}
```
The key thing to note here is that the compiler-generated copy constructor, assignment operator, and destructor all have a sensible meaning. As a result, `file` is `CopyConstructible` and `Assignable`, allowing its use in standard containers.
## Using abstract classes for implementation hiding
Another widely used C++ idiom for separating inteface and implementation is to use abstract base classes and factory functions.
The abstract classes are sometimes called "interfaces" and the pattern is known as "interface-based programming". Again,
`shared_ptr` can be used as the return type of the factory functions:
```
// X.hpp:
class X
{
public:
virtual void f() = 0;
virtual void g() = 0;
protected:
~X() {}
};
shared_ptr<X> createX();
// X.cpp:
class X_impl: public X
{
private:
X_impl(X_impl const &);
X_impl & operator=(X_impl const &);
public:
virtual void f()
{
// ...
}
virtual void g()
{
// ...
}
};
shared_ptr<X> createX()
{
shared_ptr<X> px(new X_impl);
return px;
}
```
A key property of `shared_ptr` is that the allocation, construction, deallocation, and destruction details are captured at the point of construction, inside the factory function.
Note the protected and nonvirtual destructor in the example above. The client code cannot, and does not need to, delete a pointer to `X`; the `shared_ptr<X>` instance returned from `createX` will correctly call `~X_impl`.
## Preventing `delete px.get()`
It is often desirable to prevent client code from deleting a pointer that is being managed by `shared_ptr`. The previous technique showed one possible approach, using a protected destructor. Another alternative is to use a private deleter:
```
class X
{
private:
~X();
class deleter;
friend class deleter;
class deleter
{
public:
void operator()(X * p) { delete p; }
};
public:
static shared_ptr<X> create()
{
shared_ptr<X> px(new X, X::deleter());
return px;
}
};
```
## Encapsulating allocation details, wrapping factory functions
`shared_ptr` can be used in creating {cpp} wrappers over existing C style library interfaces that return raw pointers from their factory functions
to encapsulate allocation details. As an example, consider this interface, where `CreateX` might allocate `X` from its own private heap, `~X` may
be inaccessible, or `X` may be incomplete:
X * CreateX();
void DestroyX(X *);
The only way to reliably destroy a pointer returned by `CreateX` is to call `DestroyX`.
Here is how a `shared_ptr`-based wrapper may look like:
shared_ptr<X> createX()
{
shared_ptr<X> px(CreateX(), DestroyX);
return px;
}
Client code that calls `createX` still does not need to know how the object has been allocated, but now the destruction is automatic.
[#techniques_static]
## Using a shared_ptr to hold a pointer to a statically allocated object
Sometimes it is desirable to create a `shared_ptr` to an already existing object, so that the `shared_ptr` does not attempt to destroy the
object when there are no more references left. As an example, the factory function:
shared_ptr<X> createX();
in certain situations may need to return a pointer to a statically allocated `X` instance.
The solution is to use a custom deleter that does nothing:
```
struct null_deleter
{
void operator()(void const *) const
{
}
};
static X x;
shared_ptr<X> createX()
{
shared_ptr<X> px(&x, null_deleter());
return px;
}
```
The same technique works for any object known to outlive the pointer.
## Using a shared_ptr to hold a pointer to a COM Object
Background: COM objects have an embedded reference count and two member functions that manipulate it. `AddRef()` increments the count.
`Release()` decrements the count and destroys itself when the count drops to zero.
It is possible to hold a pointer to a COM object in a `shared_ptr`:
shared_ptr<IWhatever> make_shared_from_COM(IWhatever * p)
{
p->AddRef();
shared_ptr<IWhatever> pw(p, mem_fn(&IWhatever::Release));
return pw;
}
Note, however, that `shared_ptr` copies created from `pw` will not "register" in the embedded count of the COM object;
they will share the single reference created in `make_shared_from_COM`. Weak pointers created from `pw` will be invalidated when the last
`shared_ptr` is destroyed, regardless of whether the COM object itself is still alive.
As link:../../../../libs/bind/mem_fn.html#Q3[explained] in the `mem_fn` documentation, you need to `#define BOOST_MEM_FN_ENABLE_STDCALL` first.
[#techniques_intrusive]
## Using a shared_ptr to hold a pointer to an object with an embedded reference count
This is a generalization of the above technique. The example assumes that the object implements the two functions required by `<<intrusive_ptr,intrusive_ptr>>`,
`intrusive_ptr_add_ref` and `intrusive_ptr_release`:
```
template<class T> struct intrusive_deleter
{
void operator()(T * p)
{
if(p) intrusive_ptr_release(p);
}
};
shared_ptr<X> make_shared_from_intrusive(X * p)
{
if(p) intrusive_ptr_add_ref(p);
shared_ptr<X> px(p, intrusive_deleter<X>());
return px;
}
```
## Using a shared_ptr to hold another shared ownership smart pointer
One of the design goals of `shared_ptr` is to be used in library interfaces. It is possible to encounter a situation where a library takes a
`shared_ptr` argument, but the object at hand is being managed by a different reference counted or linked smart pointer.
It is possible to exploit `shared_ptr`&#8217;s custom deleter feature to wrap this existing smart pointer behind a `shared_ptr` facade:
```
template<class P> struct smart_pointer_deleter
{
private:
P p_;
public:
smart_pointer_deleter(P const & p): p_(p)
{
}
void operator()(void const *)
{
p_.reset();
}
P const & get() const
{
return p_;
}
};
shared_ptr<X> make_shared_from_another(another_ptr<X> qx)
{
shared_ptr<X> px(qx.get(), smart_pointer_deleter< another_ptr<X> >(qx));
return px;
}
```
One subtle point is that deleters are not allowed to throw exceptions, and the above example as written assumes that `p_.reset()` doesn't throw.
If this is not the case, `p_.reset();` should be wrapped in a `try {} catch(...) {}` block that ignores exceptions. In the (usually unlikely) event
when an exception is thrown and ignored, `p_` will be released when the lifetime of the deleter ends. This happens when all references, including
weak pointers, are destroyed or reset.
Another twist is that it is possible, given the above `shared_ptr` instance, to recover the original smart pointer, using `<<shared_ptr_get_deleter,get_deleter>>`:
```
void extract_another_from_shared(shared_ptr<X> px)
{
typedef smart_pointer_deleter< another_ptr<X> > deleter;
if(deleter const * pd = get_deleter<deleter>(px))
{
another_ptr<X> qx = pd->get();
}
else
{
// not one of ours
}
}
```
[#techniques_from_raw]
## Obtaining a shared_ptr from a raw pointer
Sometimes it is necessary to obtain a `shared_ptr` given a raw pointer to an object that is already managed by another `shared_ptr` instance. Example:
void f(X * p)
{
shared_ptr<X> px(???);
}
Inside `f`, we'd like to create a `shared_ptr` to `*p`.
In the general case, this problem has no solution. One approach is to modify `f` to take a `shared_ptr`, if possible:
void f(shared_ptr<X> px);
The same transformation can be used for nonvirtual member functions, to convert the implicit `this`:
void X::f(int m);
would become a free function with a `shared_ptr` first argument:
void f(shared_ptr<X> this_, int m);
If `f` cannot be changed, but `X` uses intrusive counting, use `<<techniques_intrusive,make_shared_from_intrusive>>` described above. Or, if it's known that the `shared_ptr` created in `f` will never outlive the object, use <<techniques_static,a null deleter>>.
## Obtaining a shared_ptr (weak_ptr) to this in a constructor
Some designs require objects to register themselves on construction with a central authority. When the registration routines take a `shared_ptr`, this leads to the question how could a constructor obtain a `shared_ptr` to `this`:
```
class X
{
public:
X()
{
shared_ptr<X> this_(???);
}
};
```
In the general case, the problem cannot be solved. The `X` instance being constructed can be an automatic variable or a static variable; it can be created on the heap:
shared_ptr<X> px(new X);
but at construction time, `px` does not exist yet, and it is impossible to create another `shared_ptr` instance that shares ownership with it.
Depending on context, if the inner `shared_ptr this_` doesn't need to keep the object alive, use a `null_deleter` as explained <<techniques_static,here>> and <<techniques_weak_without_shared,here>>.
If `X` is supposed to always live on the heap, and be managed by a `shared_ptr`, use a static factory function:
```
class X
{
private:
X() { ... }
public:
static shared_ptr<X> create()
{
shared_ptr<X> px(new X);
// use px as 'this_'
return px;
}
};
```
## Obtaining a shared_ptr to this
Sometimes it is needed to obtain a `shared_ptr` from `this` in a virtual member function under the assumption that `this` is already managed by a `shared_ptr`.
The transformations <<techniques_from_raw,described in the previous technique>> cannot be applied.
A typical example:
```
class X
{
public:
virtual void f() = 0;
protected:
~X() {}
};
class Y
{
public:
virtual shared_ptr<X> getX() = 0;
protected:
~Y() {}
};
// --
class impl: public X, public Y
{
public:
impl() { ... }
virtual void f() { ... }
virtual shared_ptr<X> getX()
{
shared_ptr<X> px(???);
return px;
}
};
```
The solution is to keep a weak pointer to `this` as a member in `impl`:
```
class impl: public X, public Y
{
private:
weak_ptr<impl> weak_this;
impl(impl const &);
impl & operator=(impl const &);
impl() { ... }
public:
static shared_ptr<impl> create()
{
shared_ptr<impl> pi(new impl);
pi->weak_this = pi;
return pi;
}
virtual void f() { ... }
virtual shared_ptr<X> getX()
{
shared_ptr<X> px(weak_this);
return px;
}
};
```
The library now includes a helper class template `<<enable_shared_from_this,enable_shared_from_this>>` that can be used to encapsulate the solution:
```
class impl: public X, public Y, public enable_shared_from_this<impl>
{
public:
impl(impl const &);
impl & operator=(impl const &);
public:
virtual void f() { ... }
virtual shared_ptr<X> getX()
{
return shared_from_this();
}
}
```
Note that you no longer need to manually initialize the `weak_ptr` member in `enable_shared_from_this`. Constructing a `shared_ptr` to `impl` takes care of that.
## Using shared_ptr as a smart counted handle
Some library interfaces use opaque handles, a variation of the <<techniques_incomplete,incomplete class technique>> described above. An example:
```
typedef void * HANDLE;
HANDLE CreateProcess();
void CloseHandle(HANDLE);
```
Instead of a raw pointer, it is possible to use `shared_ptr` as the handle and get reference counting and automatic resource management for free:
```
typedef shared_ptr<void> handle;
handle createProcess()
{
shared_ptr<void> pv(CreateProcess(), CloseHandle);
return pv;
}
```
## Using shared_ptr to execute code on block exit
`shared_ptr<void>` can automatically execute cleanup code when control leaves a scope.
* Executing `f(p)`, where `p` is a pointer:
+
```
shared_ptr<void> guard(p, f);
```
* Executing arbitrary code: `f(x, y)`:
+
```
shared_ptr<void> guard(static_cast<void*>(0), bind(f, x, y));
```
## Using shared_ptr<void> to hold an arbitrary object
`shared_ptr<void>` can act as a generic object pointer similar to `void*`. When a `shared_ptr<void>` instance constructed as:
shared_ptr<void> pv(new X);
is destroyed, it will correctly dispose of the `X` object by executing `~X`.
This propery can be used in much the same manner as a raw `void*` is used to temporarily strip type information from an object pointer.
A `shared_ptr<void>` can later be cast back to the correct type by using `<<shared_ptr_static_pointer_cast,static_pointer_cast>>`.
## Associating arbitrary data with heterogeneous `shared_ptr` instances
`shared_ptr` and `weak_ptr` support `operator<` comparisons required by standard associative containers such as `std::map`. This can be
used to non-intrusively associate arbitrary data with objects managed by `shared_ptr`:
```
typedef int Data;
std::map<shared_ptr<void>, Data> userData;
// or std::map<weak_ptr<void>, Data> userData; to not affect the lifetime
shared_ptr<X> px(new X);
shared_ptr<int> pi(new int(3));
userData[px] = 42;
userData[pi] = 91;
```
## Using `shared_ptr` as a `CopyConstructible` mutex lock
Sometimes it's necessary to return a mutex lock from a function, and a noncopyable lock cannot be returned by value. It is possible to use `shared_ptr` as a mutex lock:
```
class mutex
{
public:
void lock();
void unlock();
};
shared_ptr<mutex> lock(mutex & m)
{
m.lock();
return shared_ptr<mutex>(&m, mem_fn(&mutex::unlock));
}
```
Better yet, the `shared_ptr` instance acting as a lock can be encapsulated in a dedicated `shared_lock` class:
```
class shared_lock
{
private:
shared_ptr<void> pv;
public:
template<class Mutex> explicit shared_lock(Mutex & m): pv((m.lock(), &m), mem_fn(&Mutex::unlock)) {}
};
```
`shared_lock` can now be used as:
shared_lock lock(m);
Note that `shared_lock` is not templated on the mutex type, thanks to `shared_ptr<void>`&#8217;s ability to hide type information.
## Using shared_ptr to wrap member function calls
`shared_ptr` implements the ownership semantics required from the `Wrap/CallProxy` scheme described in Bjarne Stroustrup's article
"Wrapping C++ Member Function Calls" (available online at http://www.stroustrup.com/wrapper.pdf). An implementation is given below:
```
template<class T> class pointer
{
private:
T * p_;
public:
explicit pointer(T * p): p_(p)
{
}
shared_ptr<T> operator->() const
{
p_->prefix();
return shared_ptr<T>(p_, mem_fn(&T::suffix));
}
};
class X
{
private:
void prefix();
void suffix();
friend class pointer<X>;
public:
void f();
void g();
};
int main()
{
X x;
pointer<X> px(&x);
px->f();
px->g();
}
```
## Delayed deallocation
In some situations, a single `px.reset()` can trigger an expensive deallocation in a performance-critical region:
```
class X; // ~X is expensive
class Y
{
shared_ptr<X> px;
public:
void f()
{
px.reset();
}
};
```
The solution is to postpone the potential deallocation by moving `px` to a dedicated free list that can be periodically emptied when performance and response times are not an issue:
```
vector< shared_ptr<void> > free_list;
class Y
{
shared_ptr<X> px;
public:
void f()
{
free_list.push_back(px);
px.reset();
}
};
// periodically invoke free_list.clear() when convenient
```
Another variation is to move the free list logic to the construction point by using a delayed deleter:
```
struct delayed_deleter
{
template<class T> void operator()(T * p)
{
try
{
shared_ptr<void> pv(p);
free_list.push_back(pv);
}
catch(...)
{
}
}
};
```
[#techniques_weak_without_shared]
## Weak pointers to objects not managed by a shared_ptr
Make the object hold a `shared_ptr` to itself, using a `null_deleter`:
```
class X
{
private:
shared_ptr<X> this_;
int i_;
public:
explicit X(int i): this_(this, null_deleter()), i_(i)
{
}
// repeat in all constructors (including the copy constructor!)
X(X const & rhs): this_(this, null_deleter()), i_(rhs.i_)
{
}
// do not forget to not assign this_ in the copy assignment
X & operator=(X const & rhs)
{
i_ = rhs.i_;
}
weak_ptr<X> get_weak_ptr() const { return this_; }
};
```
When the object's lifetime ends, `X::this_` will be destroyed, and all weak pointers will automatically expire.

368
doc/smart_ptr/weak_ptr.adoc Normal file
View File

@ -0,0 +1,368 @@
////
Copyright 1999 Greg Colvin and Beman Dawes
Copyright 2002 Darin Adler
Copyright 2002-2005, 2017 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
////
[#weak_ptr]
# weak_ptr: Non-owning Observer
:toc:
:toc-title:
:idprefix: weak_ptr_
## Description
The `weak_ptr` class template stores a "weak reference" to an object that's already managed by a `shared_ptr`.
To access the object, a `weak_ptr` can be converted to a `shared_ptr` using the `shared_ptr` constructor taking
`weak_ptr`, or the `weak_ptr` member function `lock`. When the last `shared_ptr` to the object goes away and the
object is deleted, the attempt to obtain a `shared_ptr` from the `weak_ptr` instances that refer to the deleted
object will fail: the constructor will throw an exception of type `boost::bad_weak_ptr`, and `weak_ptr::lock` will
return an empty `shared_ptr`.
Every `weak_ptr` meets the `CopyConstructible` and `Assignable` requirements of the {cpp} Standard Library, and so
can be used in standard library containers. Comparison operators are supplied so that `weak_ptr` works with the standard
library's associative containers.
`weak_ptr` operations never throw exceptions.
The class template is parameterized on `T`, the type of the object pointed to.
Compared to `shared_ptr`, `weak_ptr` provides a very limited subset of operations since accessing its stored pointer is
often dangerous in multithreaded programs, and sometimes unsafe even within a single thread (that is, it may invoke undefined
behavior.) Pretend for a moment that `weak_ptr` had a get member function that returned a raw pointer, and consider this innocent
piece of code:
```
shared_ptr<int> p(new int(5));
weak_ptr<int> q(p);
// some time later
if(int * r = q.get())
{
// use *r
}
```
Imagine that after the `if`, but immediately before `r` is used, another thread executes the statement `p.reset()`. Now `r` is a dangling pointer.
The solution to this problem is to create a temporary `shared_ptr` from `q`:
```
shared_ptr<int> p(new int(5));
weak_ptr<int> q(p);
// some time later
if(shared_ptr<int> r = q.lock())
{
// use *r
}
```
Now `r` holds a reference to the object that was pointed by `q`. Even if `p.reset()` is executed in another thread, the object will stay alive until
`r` goes out of scope or is reset. By obtaining a `shared_ptr` to the object, we have effectively locked it against destruction.
## Synopsis
`weak_ptr` is defined in `<boost/smart_ptr/weak_ptr.hpp>`.
```
namespace boost {
template<class T> class weak_ptr {
public:
typedef /*see below*/ element_type;
weak_ptr() noexcept;
template<class Y> weak_ptr(shared_ptr<Y> const & r) noexcept;
weak_ptr(weak_ptr const & r) noexcept;
template<class Y> weak_ptr(weak_ptr<Y> const & r) noexcept;
weak_ptr(weak_ptr && r) noexcept;
template<class Y> weak_ptr(shared_ptr<Y> const & r, element_type * p) noexcept;
template<class Y> weak_ptr(weak_ptr<Y> const & r, element_type * p) noexcept;
template<class Y> weak_ptr(weak_ptr<Y> && r, element_type * p) noexcept;
~weak_ptr() noexcept;
weak_ptr & operator=(weak_ptr const & r) noexcept;
weak_ptr & operator=(weak_ptr && r) noexcept;
template<class Y> weak_ptr & operator=(weak_ptr<Y> const & r) noexcept;
template<class Y> weak_ptr & operator=(shared_ptr<Y> const & r) noexcept;
long use_count() const noexcept;
bool expired() const noexcept;
bool empty() const noexcept;
shared_ptr<T> lock() const noexcept;
void reset() noexcept;
void swap(weak_ptr<T> & b) noexcept;
template<class Y> bool owner_before( weak_ptr<Y> const & r ) const noexcept;
template<class Y> bool owner_before( shared_ptr<Y> const & r ) const noexcept;
template<class Y> bool owner_equals( weak_ptr<Y> const & r ) const noexcept;
template<class Y> bool owner_equals( shared_ptr<Y> const & r ) const noexcept;
std::size_t owner_hash_value() const noexcept;
};
template<class T, class U>
bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) noexcept;
template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) noexcept;
}
```
## Members
### element_type
```
typedef ... element_type;
```
`element_type` is `T` when `T` is not an array type, and `U` when `T` is `U[]` or `U[N]`.
### constructors
```
weak_ptr() noexcept;
```
[none]
* {blank}
+
Effects:: Constructs an empty `weak_ptr`.
Postconditions:: `use_count() == 0`.
```
template<class Y> weak_ptr(shared_ptr<Y> const & r) noexcept;
```
```
weak_ptr(weak_ptr const & r) noexcept;
```
```
template<class Y> weak_ptr(weak_ptr<Y> const & r) noexcept;
```
[none]
* {blank}
+
Effects:: If `r` is empty, constructs an empty `weak_ptr`; otherwise, constructs a `weak_ptr` that shares ownership with `r` as if by storing a copy of the pointer stored in `r`.
Postconditions:: `use_count() == r.use_count()`.
```
weak_ptr(weak_ptr && r) noexcept;
```
[none]
* {blank}
+
Effects:: Constructs a `weak_ptr` that has the value `r` held.
Postconditions:: `r` is empty.
### aliasing constructors
```
template<class Y> weak_ptr(shared_ptr<Y> const & r, element_type * p) noexcept;
```
```
template<class Y> weak_ptr(weak_ptr<Y> const & r, element_type * p) noexcept;
```
```
template<class Y> weak_ptr(weak_ptr<Y> && r, element_type * p) noexcept;
```
Effects:: Constructs a `weak_ptr` from `r` as if by using the corresponding converting/copy/move constructor, but stores `p` instead.
Postconditions:: `use_count() == r.use_count()`. When `!expired()`, `shared_ptr<T>(*this).get() == p`.
NOTE: These constructors are an extension, not present in `std::weak_ptr`.
### destructor
```
~weak_ptr() noexcept;
```
[none]
* {blank}
+
Effects::
Destroys this `weak_ptr` but has no effect on the object its stored pointer points to.
### assignment
```
weak_ptr & operator=(weak_ptr const & r) noexcept;
```
```
weak_ptr & operator=(weak_ptr && r) noexcept;
```
```
template<class Y> weak_ptr & operator=(weak_ptr<Y> const & r) noexcept;
```
```
template<class Y> weak_ptr & operator=(shared_ptr<Y> const & r) noexcept;
```
[none]
* {blank}
+
Effects:: Equivalent to `weak_ptr(r).swap(*this)`.
NOTE: The implementation is free to meet the effects (and the implied guarantees) via different means, without creating a temporary.
### use_count
```
long use_count() const noexcept;
```
[none]
* {blank}
+
Returns::
0 if `*this` is empty; otherwise, the number of `shared_ptr` objects that share ownership with `*this`.
### expired
```
bool expired() const noexcept;
```
[none]
* {blank}
+
Returns::
`use_count() == 0`.
### empty
```
bool empty() const noexcept;
```
[none]
* {blank}
+
Returns:: `true` when `*this` is empty, `false` otherwise.
NOTE: This function is an extension, not present in `std::weak_ptr`.
### lock
```
shared_ptr<T> lock() const noexcept;
```
[none]
* {blank}
+
Returns::
`expired()? shared_ptr<T>(): shared_ptr<T>(*this)`.
### reset
```
void reset() noexcept;
```
[none]
* {blank}
+
Effects::
Equivalent to `weak_ptr().swap(*this)`.
### swap
```
void swap(weak_ptr & b) noexcept;
```
[none]
* {blank}
+
Effects::
Exchanges the contents of the two smart pointers.
### owner_before
```
template<class Y> bool owner_before( weak_ptr<Y> const & r ) const noexcept;
```
```
template<class Y> bool owner_before( shared_ptr<Y> const & r ) const noexcept;
```
[none]
* {blank}
+
Returns::
See the description of `operator<`.
### owner_equals
```
template<class Y> bool owner_equals( weak_ptr<Y> const & r ) const noexcept;
```
```
template<class Y> bool owner_equals( shared_ptr<Y> const & r ) const noexcept;
```
[none]
* {blank}
+
Returns::
`true` if and only if `*this` and `r` share ownership or are both empty.
### owner_hash_value
```
std::size_t owner_hash_value() const noexcept;
```
[none]
* {blank}
+
Returns::
An unspecified hash value such that two instances that share ownership
have the same hash value.
## Free Functions
### comparison
```
template<class T, class U>
bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) noexcept;
```
[none]
* {blank}
+
Returns:: An unspecified value such that
- `operator<` is a strict weak ordering as described in section [lib.alg.sorting] of the {cpp} standard;
- under the equivalence relation defined by `operator<`, `!(a < b) && !(b < a)`, two `weak_ptr` instances
are equivalent if and only if they share ownership or are both empty.
NOTE: Allows `weak_ptr` objects to be used as keys in associative containers.
### swap
```
template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) noexcept;
```
[none]
* {blank}
+
Effects::
Equivalent to `a.swap(b)`.
## Frequently Asked Questions
[qanda]
Can an object create a weak_ptr to itself in its constructor?::
No. A `weak_ptr` can only be created from a `shared_ptr`, and at object construction time no
`shared_ptr` to the object exists yet. Even if you could create a temporary `shared_ptr` to `this`,
it would go out of scope at the end of the constructor, and all `weak_ptr` instances would instantly expire.
+
The solution is to make the constructor private, and supply a factory function that returns a `shared_ptr`:
+
```
class X
{
private:
X();
public:
static shared_ptr<X> create()
{
shared_ptr<X> px(new X);
// create weak pointers from px here
return px;
}
};
```

View File

@ -0,0 +1,23 @@
// Boost scoped_ptr_example implementation file -----------------------------//
// Copyright Beman Dawes 2001. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/smart_ptr for documentation.
#include "scoped_ptr_example.hpp"
#include <iostream>
class example::implementation
{
public:
~implementation() { std::cout << "destroying implementation\n"; }
};
example::example() : _imp( new implementation ) {}
void example::do_something() { std::cout << "did something\n"; }
example::~example() {}

View File

@ -0,0 +1,29 @@
// Boost scoped_ptr_example header file ------------------------------------//
// Copyright Beman Dawes 2001. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/smart_ptr for documentation.
#include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp>
// The point of this example is to prove that even though
// example::implementation is an incomplete type in translation units using
// this header, scoped_ptr< implementation > is still valid because the type
// is complete where it counts - in the inplementation translation unit where
// destruction is actually instantiated.
class example : private boost::noncopyable
{
public:
example();
~example();
void do_something();
private:
class implementation;
boost::scoped_ptr< implementation > _imp; // hide implementation details
};

View File

@ -0,0 +1,17 @@
// Boost scoped_ptr_example_test main program -------------------------------//
// Copyright Beman Dawes 2001. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/smart_ptr for documentation.
#include "scoped_ptr_example.hpp"
int main()
{
example my_example;
my_example.do_something();
return 0;
}

View File

@ -0,0 +1,95 @@
// Boost shared_ptr_example.cpp --------------------------------------------//
// Copyright Beman Dawes 2001. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/smart_ptr for documentation.
// Revision History
// 21 May 01 Initial complete version (Beman Dawes)
// The original code for this example appeared in the shared_ptr documentation.
// Ray Gallimore pointed out that foo_set was missing a Compare template
// argument, so would not work as intended. At that point the code was
// turned into an actual .cpp file so it could be compiled and tested.
#include <vector>
#include <set>
#include <iostream>
#include <algorithm>
#include <boost/shared_ptr.hpp>
// The application will produce a series of
// objects of type Foo which later must be
// accessed both by occurrence (std::vector)
// and by ordering relationship (std::set).
struct Foo
{
Foo( int _x ) : x(_x) {}
~Foo() { std::cout << "Destructing a Foo with x=" << x << "\n"; }
int x;
/* ... */
};
typedef boost::shared_ptr<Foo> FooPtr;
struct FooPtrOps
{
bool operator()( const FooPtr & a, const FooPtr & b )
{ return a->x > b->x; }
void operator()( const FooPtr & a )
{ std::cout << a->x << "\n"; }
};
int main()
{
std::vector<FooPtr> foo_vector;
std::set<FooPtr,FooPtrOps> foo_set; // NOT multiset!
FooPtr foo_ptr( new Foo( 2 ) );
foo_vector.push_back( foo_ptr );
foo_set.insert( foo_ptr );
foo_ptr.reset( new Foo( 1 ) );
foo_vector.push_back( foo_ptr );
foo_set.insert( foo_ptr );
foo_ptr.reset( new Foo( 3 ) );
foo_vector.push_back( foo_ptr );
foo_set.insert( foo_ptr );
foo_ptr.reset ( new Foo( 2 ) );
foo_vector.push_back( foo_ptr );
foo_set.insert( foo_ptr );
std::cout << "foo_vector:\n";
std::for_each( foo_vector.begin(), foo_vector.end(), FooPtrOps() );
std::cout << "\nfoo_set:\n";
std::for_each( foo_set.begin(), foo_set.end(), FooPtrOps() );
std::cout << "\n";
// Expected output:
//
// foo_vector:
// 2
// 1
// 3
// 2
//
// foo_set:
// 3
// 2
// 1
//
// Destructing a Foo with x=2
// Destructing a Foo with x=1
// Destructing a Foo with x=3
// Destructing a Foo with x=2
return 0;
}

View File

@ -0,0 +1,22 @@
// Boost shared_ptr_example2 implementation file -----------------------------//
// Copyright Beman Dawes 2001. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/smart_ptr for documentation.
#include "shared_ptr_example2.hpp"
#include <iostream>
class example::implementation
{
public:
~implementation() { std::cout << "destroying implementation\n"; }
};
example::example() : _imp( new implementation ) {}
void example::do_something()
{ std::cout << "use_count() is " << _imp.use_count() << "\n"; }

View File

@ -0,0 +1,31 @@
// Boost shared_ptr_example2 header file -----------------------------------//
// Copyright Beman Dawes 2001. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/smart_ptr for documentation.
#include <boost/shared_ptr.hpp>
// This example demonstrates the handle/body idiom (also called pimpl and
// several other names). It separates the interface (in this header file)
// from the implementation (in shared_ptr_example2.cpp).
// Note that even though example::implementation is an incomplete type in
// some translation units using this header, shared_ptr< implementation >
// is still valid because the type is complete where it counts - in the
// shared_ptr_example2.cpp translation unit where functions requiring a
// complete type are actually instantiated.
class example
{
public:
example();
void do_something();
private:
class implementation;
boost::shared_ptr< implementation > _imp; // hide implementation details
};

View File

@ -0,0 +1,22 @@
// Boost shared_ptr_example2_test main program ------------------------------//
// Copyright Beman Dawes 2001. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/smart_ptr for documentation.
#include "shared_ptr_example2.hpp"
int main()
{
example a;
a.do_something();
example b(a);
b.do_something();
example c;
c = a;
c.do_something();
return 0;
}

270
extras/src/sp_collector.cpp Normal file
View File

@ -0,0 +1,270 @@
//
// sp_collector.cpp
//
// Copyright (c) 2002, 2003 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
#include <boost/assert.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/detail/lightweight_mutex.hpp>
#include <cstdlib>
#include <map>
#include <deque>
#include <iostream>
typedef std::map< void const *, std::pair<void *, size_t> > map_type;
static map_type & get_map()
{
static map_type m;
return m;
}
typedef boost::detail::lightweight_mutex mutex_type;
static mutex_type & get_mutex()
{
static mutex_type m;
return m;
}
static void * init_mutex_before_main = &get_mutex();
namespace
{
class X;
struct count_layout
{
boost::detail::sp_counted_base * pi;
int id;
};
struct shared_ptr_layout
{
X * px;
count_layout pn;
};
}
// assume 4 byte alignment for pointers when scanning
size_t const pointer_align = 4;
typedef std::map<void const *, long> map2_type;
static void scan_and_count(void const * area, size_t size, map_type const & m, map2_type & m2)
{
unsigned char const * p = static_cast<unsigned char const *>(area);
for(size_t n = 0; n + sizeof(shared_ptr_layout) <= size; p += pointer_align, n += pointer_align)
{
shared_ptr_layout const * q = reinterpret_cast<shared_ptr_layout const *>(p);
if(q->pn.id == boost::detail::shared_count_id && q->pn.pi != 0 && m.count(q->pn.pi) != 0)
{
++m2[q->pn.pi];
}
}
}
typedef std::deque<void const *> open_type;
static void scan_and_mark(void const * area, size_t size, map2_type & m2, open_type & open)
{
unsigned char const * p = static_cast<unsigned char const *>(area);
for(size_t n = 0; n + sizeof(shared_ptr_layout) <= size; p += pointer_align, n += pointer_align)
{
shared_ptr_layout const * q = reinterpret_cast<shared_ptr_layout const *>(p);
if(q->pn.id == boost::detail::shared_count_id && q->pn.pi != 0 && m2.count(q->pn.pi) != 0)
{
open.push_back(q->pn.pi);
m2.erase(q->pn.pi);
}
}
}
static void find_unreachable_objects_impl(map_type const & m, map2_type & m2)
{
// scan objects for shared_ptr members, compute internal counts
{
std::cout << "... " << m.size() << " objects in m.\n";
for(map_type::const_iterator i = m.begin(); i != m.end(); ++i)
{
boost::detail::sp_counted_base const * p = static_cast<boost::detail::sp_counted_base const *>(i->first);
BOOST_ASSERT(p->use_count() != 0); // there should be no inactive counts in the map
m2[ i->first ];
scan_and_count(i->second.first, i->second.second, m, m2);
}
std::cout << "... " << m2.size() << " objects in m2.\n";
}
// mark reachable objects
{
open_type open;
for(map2_type::iterator i = m2.begin(); i != m2.end(); ++i)
{
boost::detail::sp_counted_base const * p = static_cast<boost::detail::sp_counted_base const *>(i->first);
if(p->use_count() != i->second) open.push_back(p);
}
std::cout << "... " << open.size() << " objects in open.\n";
for(open_type::iterator j = open.begin(); j != open.end(); ++j)
{
m2.erase(*j);
}
while(!open.empty())
{
void const * p = open.front();
open.pop_front();
map_type::const_iterator i = m.find(p);
BOOST_ASSERT(i != m.end());
scan_and_mark(i->second.first, i->second.second, m2, open);
}
}
// m2 now contains the unreachable objects
}
std::size_t find_unreachable_objects(bool report)
{
map2_type m2;
#ifdef BOOST_HAS_THREADS
// This will work without the #ifdef, but some compilers warn
// that lock is not referenced
mutex_type::scoped_lock lock(get_mutex());
#endif
map_type const & m = get_map();
find_unreachable_objects_impl(m, m2);
if(report)
{
for(map2_type::iterator j = m2.begin(); j != m2.end(); ++j)
{
map_type::const_iterator i = m.find(j->first);
BOOST_ASSERT(i != m.end());
std::cout << "Unreachable object at " << i->second.first << ", " << i->second.second << " bytes long.\n";
}
}
return m2.size();
}
typedef std::deque< boost::shared_ptr<X> > free_list_type;
static void scan_and_free(void * area, size_t size, map2_type const & m2, free_list_type & free)
{
unsigned char * p = static_cast<unsigned char *>(area);
for(size_t n = 0; n + sizeof(shared_ptr_layout) <= size; p += pointer_align, n += pointer_align)
{
shared_ptr_layout * q = reinterpret_cast<shared_ptr_layout *>(p);
if(q->pn.id == boost::detail::shared_count_id && q->pn.pi != 0 && m2.count(q->pn.pi) != 0 && q->px != 0)
{
boost::shared_ptr<X> * ppx = reinterpret_cast< boost::shared_ptr<X> * >(p);
free.push_back(*ppx);
ppx->reset();
}
}
}
void free_unreachable_objects()
{
free_list_type free;
{
map2_type m2;
#ifdef BOOST_HAS_THREADS
mutex_type::scoped_lock lock(get_mutex());
#endif
map_type const & m = get_map();
find_unreachable_objects_impl(m, m2);
for(map2_type::iterator j = m2.begin(); j != m2.end(); ++j)
{
map_type::const_iterator i = m.find(j->first);
BOOST_ASSERT(i != m.end());
scan_and_free(i->second.first, i->second.second, m2, free);
}
}
std::cout << "... about to free " << free.size() << " objects.\n";
}
// debug hooks
namespace boost
{
void sp_scalar_constructor_hook(void *)
{
}
void sp_scalar_constructor_hook(void * px, std::size_t size, void * pn)
{
#ifdef BOOST_HAS_THREADS
mutex_type::scoped_lock lock(get_mutex());
#endif
get_map()[pn] = std::make_pair(px, size);
}
void sp_scalar_destructor_hook(void *)
{
}
void sp_scalar_destructor_hook(void *, std::size_t, void * pn)
{
#ifdef BOOST_HAS_THREADS
mutex_type::scoped_lock lock(get_mutex());
#endif
get_map().erase(pn);
}
void sp_array_constructor_hook(void *)
{
}
void sp_array_destructor_hook(void *)
{
}
} // namespace boost
#endif // defined(BOOST_SP_ENABLE_DEBUG_HOOKS)

View File

@ -0,0 +1,243 @@
//
// sp_debug_hooks.cpp
//
// Copyright (c) 2002, 2003 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
#include <boost/assert.hpp>
#include <new>
#include <cstdlib>
int const m = 2; // m * sizeof(int) must be aligned appropriately
// magic values to mark heap blocks with
int const allocated_scalar = 0x1234560C;
int const allocated_array = 0x1234560A;
int const adopted_scalar = 0x0567890C;
int const adopted_array = 0x0567890A;
int const deleted = 0x498769DE;
using namespace std; // for compilers where things aren't in std
// operator new
static new_handler get_new_handler()
{
new_handler p = set_new_handler(0);
set_new_handler(p);
return p;
}
static void * allocate(size_t n, int mark)
{
int * pm;
for(;;)
{
pm = static_cast<int*>(malloc(n + m * sizeof(int)));
if(pm != 0) break;
if(new_handler pnh = get_new_handler())
{
pnh();
}
else
{
return 0;
}
}
*pm = mark;
return pm + m;
}
void * operator new(size_t n) throw(bad_alloc)
{
void * p = allocate(n, allocated_scalar);
#if !defined(BOOST_NO_EXCEPTIONS)
if(p == 0) throw bad_alloc();
#endif
return p;
}
#if !defined(BOOST_BORLANDC) || (BOOST_BORLANDC > 0x551)
void * operator new(size_t n, nothrow_t const &) throw()
{
return allocate(n, allocated_scalar);
}
#endif
void * operator new[](size_t n) throw(bad_alloc)
{
void * p = allocate(n, allocated_array);
#if !defined(BOOST_NO_EXCEPTIONS)
if(p == 0) throw bad_alloc();
#endif
return p;
}
#if !defined(BOOST_BORLANDC) || (BOOST_BORLANDC > 0x551)
void * operator new[](size_t n, nothrow_t const &) throw()
{
return allocate(n, allocated_array);
}
#endif
// debug hooks
namespace boost
{
void sp_scalar_constructor_hook(void * p)
{
if(p == 0) return;
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm != adopted_scalar); // second smart pointer to the same address
BOOST_ASSERT(*pm != allocated_array); // allocated with new[]
BOOST_ASSERT(*pm == allocated_scalar); // not allocated with new
*pm = adopted_scalar;
}
void sp_scalar_constructor_hook(void * px, std::size_t, void *)
{
sp_scalar_constructor_hook(px);
}
void sp_scalar_destructor_hook(void * p)
{
if(p == 0) return;
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm == adopted_scalar); // attempt to destroy nonmanaged block
*pm = allocated_scalar;
}
void sp_scalar_destructor_hook(void * px, std::size_t, void *)
{
sp_scalar_destructor_hook(px);
}
// It is not possible to handle the array hooks in a portable manner.
// The implementation typically reserves a bit of storage for the number
// of objects in the array, and the argument of the array hook isn't
// equal to the return value of operator new[].
void sp_array_constructor_hook(void * /* p */)
{
/*
if(p == 0) return;
// adjust p depending on the implementation
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm != adopted_array); // second smart array pointer to the same address
BOOST_ASSERT(*pm != allocated_scalar); // allocated with new
BOOST_ASSERT(*pm == allocated_array); // not allocated with new[]
*pm = adopted_array;
*/
}
void sp_array_destructor_hook(void * /* p */)
{
/*
if(p == 0) return;
// adjust p depending on the implementation
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm == adopted_array); // attempt to destroy nonmanaged block
*pm = allocated_array;
*/
}
} // namespace boost
// operator delete
void operator delete(void * p) throw()
{
if(p == 0) return;
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm != deleted); // double delete
BOOST_ASSERT(*pm != adopted_scalar); // delete p.get();
BOOST_ASSERT(*pm != allocated_array); // allocated with new[]
BOOST_ASSERT(*pm == allocated_scalar); // not allocated with new
*pm = deleted;
free(pm);
}
#if !defined(BOOST_BORLANDC) || (BOOST_BORLANDC > 0x551)
void operator delete(void * p, nothrow_t const &) throw()
{
::operator delete(p);
}
#endif
void operator delete[](void * p) throw()
{
if(p == 0) return;
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm != deleted); // double delete
BOOST_ASSERT(*pm != adopted_scalar); // delete p.get();
BOOST_ASSERT(*pm != allocated_scalar); // allocated with new
BOOST_ASSERT(*pm == allocated_array); // not allocated with new[]
*pm = deleted;
free(pm);
}
#if !defined(BOOST_BORLANDC) || (BOOST_BORLANDC > 0x551)
void operator delete[](void * p, nothrow_t const &) throw()
{
::operator delete[](p);
}
#endif
#endif // defined(BOOST_SP_ENABLE_DEBUG_HOOKS)

View File

@ -0,0 +1,82 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
// shared_ptr_mt_test.cpp - tests shared_ptr with multiple threads
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2008 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
#include <vector>
#include <cstdio>
#include <ctime>
#include <boost/detail/lightweight_thread.hpp>
//
int const n = 1024 * 1024;
void test( boost::shared_ptr<int> const & pi )
{
std::vector< boost::shared_ptr<int> > v;
for( int i = 0; i < n; ++i )
{
v.push_back( pi );
}
}
int const m = 16; // threads
#if defined( BOOST_HAS_PTHREADS )
char const * thmodel = "POSIX";
#else
char const * thmodel = "Windows";
#endif
int main()
{
using namespace std; // printf, clock_t, clock
printf( "Using %s threads: %d threads, %d iterations: ", thmodel, m, n );
boost::shared_ptr<int> pi( new int(42) );
clock_t t = clock();
boost::detail::lw_thread_t a[ m ];
for( int i = 0; i < m; ++i )
{
boost::detail::lw_thread_create( a[ i ], boost::bind( test, pi ) );
}
for( int j = 0; j < m; ++j )
{
boost::detail::lw_thread_join( a[j] );
}
t = clock() - t;
printf( "\n\n%.3f seconds.\n", static_cast<double>(t) / CLOCKS_PER_SEC );
return 0;
}

View File

@ -0,0 +1,46 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// shared_ptr_timing_test.cpp - use to evaluate the impact of thread safety
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/shared_ptr.hpp>
#include <iostream>
#include <vector>
#include <ctime>
int const n = 8 * 1024 * 1024;
int main()
{
using namespace std;
std::vector< boost::shared_ptr<int> > v;
boost::shared_ptr<int> pi(new int);
clock_t t = clock();
for(int i = 0; i < n; ++i)
{
v.push_back(pi);
}
t = clock() - t;
std::cout << static_cast<double>(t) / CLOCKS_PER_SEC << '\n';
return 0;
}

View File

@ -0,0 +1,247 @@
// Copyright (c) 2008 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/locks.hpp>
#include <boost/detail/lightweight_mutex.hpp>
#include <boost/detail/lightweight_thread.hpp>
#include <vector>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <ctime>
//
static void next_value( unsigned & v )
{
v = v % 2? 3 * v + 1: v / 2;
}
struct X
{
std::vector<unsigned> v_;
explicit X( std::size_t n ): v_( n )
{
for( std::size_t i = 0; i < n; ++i )
{
v_[ i ] = i;
}
}
unsigned get() const
{
return std::accumulate( v_.begin(), v_.end(), 0 );
}
void set()
{
std::for_each( v_.begin(), v_.end(), next_value );
}
};
static boost::shared_ptr<X> ps;
static boost::detail::lightweight_mutex lm;
static boost::shared_mutex rw;
enum prim_type
{
pt_mutex,
pt_rwlock,
pt_atomics
};
int read_access( prim_type pt )
{
switch( pt )
{
case pt_mutex:
{
boost::detail::lightweight_mutex::scoped_lock lock( lm );
return ps->get();
}
case pt_rwlock:
{
boost::shared_lock<boost::shared_mutex> lock( rw );
return ps->get();
}
case pt_atomics:
{
boost::shared_ptr<X> p2 = boost::atomic_load( &ps );
return p2->get();
}
}
}
void write_access( prim_type pt )
{
switch( pt )
{
case pt_mutex:
{
boost::detail::lightweight_mutex::scoped_lock lock( lm );
ps->set();
}
break;
case pt_rwlock:
{
boost::unique_lock<boost::shared_mutex> lock( rw );
ps->set();
}
break;
case pt_atomics:
{
boost::shared_ptr<X> p1 = boost::atomic_load( &ps );
for( ;; )
{
boost::shared_ptr<X> p2( new X( *p1 ) );
p2->set();
if( boost::atomic_compare_exchange( &ps, &p1, p2 ) ) break;
}
}
break;
}
}
void worker( int k, prim_type pt, int n, int r )
{
++r;
unsigned s = 0, nr = 0, nw = 0;
for( int i = 0; i < n; ++i )
{
if( i % r )
{
s += read_access( pt );
++nr;
}
else
{
write_access( pt );
++s;
++nw;
}
}
printf( "Worker %2d: %u:%u, %10u\n", k, nr, nw, s );
}
#if defined( BOOST_HAS_PTHREADS )
char const * thmodel = "POSIX";
#else
char const * thmodel = "Windows";
#endif
char const * pt_to_string( prim_type pt )
{
switch( pt )
{
case pt_mutex:
return "mutex";
case pt_rwlock:
return "rwlock";
case pt_atomics:
return "atomics";
}
}
static void handle_pt_option( std::string const & opt, prim_type & pt, prim_type pt2 )
{
if( opt == pt_to_string( pt2 ) )
{
pt = pt2;
}
}
static void handle_int_option( std::string const & opt, std::string const & prefix, int & k, int kmin, int kmax )
{
if( opt.substr( 0, prefix.size() ) == prefix )
{
int v = atoi( opt.substr( prefix.size() ).c_str() );
if( v >= kmin && v <= kmax )
{
k = v;
}
}
}
int main( int ac, char const * av[] )
{
using namespace std; // printf, clock_t, clock
int m = 4; // threads
int n = 10000; // vector size
int k = 1000000; // iterations
int r = 100; // read/write ratio, r:1
prim_type pt = pt_atomics;
for( int i = 1; i < ac; ++i )
{
handle_pt_option( av[i], pt, pt_mutex );
handle_pt_option( av[i], pt, pt_rwlock );
handle_pt_option( av[i], pt, pt_atomics );
handle_int_option( av[i], "n=", n, 1, INT_MAX );
handle_int_option( av[i], "size=", n, 1, INT_MAX );
handle_int_option( av[i], "k=", k, 1, INT_MAX );
handle_int_option( av[i], "iterations=", k, 1, INT_MAX );
handle_int_option( av[i], "m=", m, 1, INT_MAX );
handle_int_option( av[i], "threads=", m, 1, INT_MAX );
handle_int_option( av[i], "r=", r, 1, INT_MAX );
handle_int_option( av[i], "ratio=", r, 1, INT_MAX );
}
printf( "%s: threads=%d size=%d iterations=%d ratio=%d %s\n\n", thmodel, m, n, k, r, pt_to_string( pt ) );
ps.reset( new X( n ) );
clock_t t = clock();
std::vector<boost::detail::lw_thread_t> a( m );
for( int i = 0; i < m; ++i )
{
boost::detail::lw_thread_create( a[ i ], boost::bind( worker, i, pt, k, r ) );
}
for( int j = 0; j < m; ++j )
{
boost::detail::lw_thread_join( a[ j ] );
}
t = clock() - t;
double ts = static_cast<double>( t ) / CLOCKS_PER_SEC;
printf( "%.3f seconds, %.3f accesses per microsecond.\n", ts, m * k / ts / 1e+6 );
}

View File

@ -0,0 +1,191 @@
// Copyright (c) 2008 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//#define USE_MUTEX
//#define USE_RWLOCK
#include <boost/config.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
#if defined( USE_RWLOCK )
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/locks.hpp>
#endif
#include <boost/detail/lightweight_mutex.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/detail/lightweight_thread.hpp>
#include <cstdio>
#include <ctime>
//
int const n = 1024 * 1024;
struct X
{
int v_; // version
unsigned a_;
unsigned b_;
X(): v_( 0 ), a_( 1 ), b_( 1 )
{
}
int get() const
{
return a_ * 7 + b_ * 11;
}
void set()
{
int tmp = get();
b_ = a_;
a_ = tmp;
++v_;
}
};
static boost::shared_ptr<X> ps( new X );
static boost::detail::lightweight_mutex lm;
#if defined( USE_RWLOCK )
static boost::shared_mutex rw;
#endif
static int tr = 0;
void reader( int r )
{
int k = 0;
unsigned s = 0;
for( int i = 0; i < n; ++k )
{
#if defined( USE_MUTEX )
boost::detail::lightweight_mutex::scoped_lock lock( lm );
s += ps->get();
BOOST_TEST( ps->v_ >= i );
i = ps->v_;
#elif defined( USE_RWLOCK )
boost::shared_lock<boost::shared_mutex> lock( rw );
s += ps->get();
BOOST_TEST( ps->v_ >= i );
i = ps->v_;
#else
boost::shared_ptr<X> p2 = boost::atomic_load( &ps );
s += p2->get();
BOOST_TEST( p2->v_ >= i );
i = p2->v_;
#endif
}
printf( "Reader %d: %9d iterations (%6.3fx), %u\n", r, k, (double)k / n, s );
boost::detail::lightweight_mutex::scoped_lock lock( lm );
tr += k;
}
void writer()
{
for( int i = 0; i < n; ++i )
{
#if defined( USE_MUTEX )
boost::detail::lightweight_mutex::scoped_lock lock( lm );
BOOST_TEST( ps->v_ == i );
ps->set();
#elif defined( USE_RWLOCK )
boost::unique_lock<boost::shared_mutex> lock( rw );
BOOST_TEST( ps->v_ == i );
ps->set();
#else
boost::shared_ptr<X> p2( new X( *ps ) );
BOOST_TEST( p2->v_ == i );
p2->set();
boost::atomic_store( &ps, p2 );
#endif
}
}
#if defined( BOOST_HAS_PTHREADS )
char const * thmodel = "POSIX";
#else
char const * thmodel = "Windows";
#endif
int const mr = 8; // reader threads
int const mw = 1; // writer thread
#if defined( USE_MUTEX )
char const * prim = "mutex";
#elif defined( USE_RWLOCK )
char const * prim = "rwlock";
#else
char const * prim = "atomics";
#endif
int main()
{
using namespace std; // printf, clock_t, clock
printf( "Using %s threads: %dR + %dW threads, %d iterations, %s\n\n", thmodel, mr, mw, n, prim );
clock_t t = clock();
boost::detail::lw_thread_t a[ mr+mw ];
for( int i = 0; i < mr; ++i )
{
boost::detail::lw_thread_create( a[ i ], boost::bind( reader, i ) );
}
for( int i = mr; i < mr+mw; ++i )
{
boost::detail::lw_thread_create( a[ i ], writer );
}
for( int j = 0; j < mr+mw; ++j )
{
boost::detail::lw_thread_join( a[ j ] );
}
t = clock() - t;
double ts = static_cast<double>( t ) / CLOCKS_PER_SEC;
printf( "%.3f seconds, %.3f reads per microsecond.\n", ts, tr / ts / 1e+6 );
return boost::report_errors();
}

View File

@ -0,0 +1,122 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
// weak_ptr_mt_test.cpp
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
// Copyright 2005, 2008 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/bind.hpp>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <boost/detail/lightweight_thread.hpp>
//
int const n = 16384;
int const k = 512; // vector size
int const m = 16; // threads
void test( std::vector< boost::shared_ptr<int> > & v )
{
using namespace std; // printf, rand
std::vector< boost::weak_ptr<int> > w( v.begin(), v.end() );
int s = 0, f = 0, r = 0;
for( int i = 0; i < n; ++i )
{
// randomly kill a pointer
v[ rand() % k ].reset();
++s;
for( int j = 0; j < k; ++j )
{
if( boost::shared_ptr<int> px = w[ j ].lock() )
{
++s;
if( rand() & 4 )
{
continue;
}
// rebind anyway with prob. 50% for add_ref_lock() against weak_release() contention
++f;
}
else
{
++r;
}
w[ j ] = v[ rand() % k ];
}
}
printf( "\n%d locks, %d forced rebinds, %d normal rebinds.", s, f, r );
}
#if defined( BOOST_HAS_PTHREADS )
char const * thmodel = "POSIX";
#else
char const * thmodel = "Windows";
#endif
int main()
{
using namespace std; // printf, clock_t, clock
printf("Using %s threads: %d threads, %d * %d iterations: ", thmodel, m, n, k );
std::vector< boost::shared_ptr<int> > v( k );
for( int i = 0; i < k; ++i )
{
v[ i ].reset( new int( 0 ) );
}
clock_t t = clock();
boost::detail::lw_thread_t a[ m ];
for( int i = 0; i < m; ++i )
{
boost::detail::lw_thread_create( a[ i ], boost::bind( test, v ) );
}
v.resize( 0 ); // kill original copies
for( int j = 0; j < m; ++j )
{
boost::detail::lw_thread_join( a[j] );
}
t = clock() - t;
printf("\n\n%.3f seconds.\n", static_cast<double>(t) / CLOCKS_PER_SEC);
return 0;
}

View File

@ -0,0 +1,85 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// weak_ptr_timing_test.cpp
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
// Copyright 2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cstdlib>
//
int const n = 29000;
int const k = 2048;
void test( std::vector< boost::shared_ptr<int> > & v )
{
using namespace std; // printf, rand
std::vector< boost::weak_ptr<int> > w( v.begin(), v.end() );
int s = 0, r = 0;
for( int i = 0; i < n; ++i )
{
// randomly kill a pointer
v[ rand() % k ].reset();
for( int j = 0; j < k; ++j )
{
if( boost::shared_ptr<int> px = w[ j ].lock() )
{
++s;
}
else
{
++r;
w[ j ] = v[ rand() % k ];
}
}
}
printf( "\n%d locks, %d rebinds.", s, r );
}
int main()
{
using namespace std; // printf, clock_t, clock
std::vector< boost::shared_ptr<int> > v( k );
for( int i = 0; i < k; ++i )
{
v[ i ].reset( new int( 0 ) );
}
clock_t t = clock();
test( v );
t = clock() - t;
printf( "\n\n%.3f seconds.\n", static_cast<double>( t ) / CLOCKS_PER_SEC );
return 0;
}

View File

@ -0,0 +1,21 @@
#ifndef BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
#define BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/detail/atomic_count.hpp - thread/SMP safe reference counter
//
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/smart_ptr/detail/atomic_count.hpp>
#endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED

View File

@ -0,0 +1,22 @@
#ifndef BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
#define BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/detail/lightweight_mutex.hpp - lightweight mutex
//
// Copyright (c) 2002, 2003 Peter Dimov and Multi Media Ltd.
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/smart_ptr/detail/lightweight_mutex.hpp>
#endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED

View File

@ -0,0 +1,26 @@
#ifndef BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
#define BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// boost/detail/lightweight_thread.hpp
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2008, 2018 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
//
//
// typedef /*...*/ lw_thread_t; // as pthread_t
// template<class F> int lw_thread_create( lw_thread_t & th, F f );
// void lw_thread_join( lw_thread_t th );
#include <boost/smart_ptr/detail/lightweight_thread.hpp>
#endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED

View File

@ -0,0 +1,23 @@
#ifndef BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
#define BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// detail/quick_allocator.hpp
//
// Copyright (c) 2003 David Abrahams
// Copyright (c) 2003 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/smart_ptr/detail/quick_allocator.hpp>
#endif // #ifndef BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED

View File

@ -0,0 +1,18 @@
#ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
#define BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
//
// enable_shared_from_this.hpp
//
// Copyright (c) 2002 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
//
#include <boost/smart_ptr/enable_shared_from_this.hpp>
#endif // #ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED

View File

@ -0,0 +1,18 @@
#ifndef BOOST_INTRUSIVE_PTR_HPP_INCLUDED
#define BOOST_INTRUSIVE_PTR_HPP_INCLUDED
//
// intrusive_ptr.hpp
//
// Copyright (c) 2001, 2002 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
//
#include <boost/smart_ptr/intrusive_ptr.hpp>
#endif // #ifndef BOOST_INTRUSIVE_PTR_HPP_INCLUDED

View File

@ -0,0 +1,16 @@
#ifndef BOOST_MAKE_SHARED_HPP_INCLUDED
#define BOOST_MAKE_SHARED_HPP_INCLUDED
// make_shared.hpp
//
// Copyright (c) 2007, 2008 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
#include <boost/smart_ptr/make_shared.hpp>
#endif // #ifndef BOOST_MAKE_SHARED_HPP_INCLUDED

View File

@ -0,0 +1,13 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_MAKE_UNIQUE_HPP_INCLUDED
#define BOOST_MAKE_UNIQUE_HPP_INCLUDED
#include <boost/smart_ptr/make_unique.hpp>
#endif

View File

@ -0,0 +1,122 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2005.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_POINTER_CAST_HPP
#define BOOST_POINTER_CAST_HPP
#include <boost/config.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
namespace boost {
//static_pointer_cast overload for raw pointers
template<class T, class U>
inline T* static_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{
return static_cast<T*>(ptr);
}
//dynamic_pointer_cast overload for raw pointers
template<class T, class U>
inline T* dynamic_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{
return dynamic_cast<T*>(ptr);
}
//const_pointer_cast overload for raw pointers
template<class T, class U>
inline T* const_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{
return const_cast<T*>(ptr);
}
//reinterpret_pointer_cast overload for raw pointers
template<class T, class U>
inline T* reinterpret_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{
return reinterpret_cast<T*>(ptr);
}
} // namespace boost
#if !defined( BOOST_NO_CXX11_SMART_PTR )
#include <boost/type_traits/has_virtual_destructor.hpp>
#include <boost/static_assert.hpp>
#include <memory>
namespace boost {
//static_pointer_cast overload for std::shared_ptr
using std::static_pointer_cast;
//dynamic_pointer_cast overload for std::shared_ptr
using std::dynamic_pointer_cast;
//const_pointer_cast overload for std::shared_ptr
using std::const_pointer_cast;
//reinterpret_pointer_cast overload for std::shared_ptr
template<class T, class U> std::shared_ptr<T> reinterpret_pointer_cast(const std::shared_ptr<U> & r ) BOOST_SP_NOEXCEPT
{
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
typedef typename std::shared_ptr<T>::element_type E;
E * p = reinterpret_cast< E* >( r.get() );
return std::shared_ptr<T>( r, p );
}
//static_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> static_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) static_cast< T* >( static_cast< U* >( 0 ) );
typedef typename std::unique_ptr<T>::element_type E;
return std::unique_ptr<T>( static_cast<E*>( r.release() ) );
}
//dynamic_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> dynamic_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) dynamic_cast< T* >( static_cast< U* >( 0 ) );
BOOST_STATIC_ASSERT_MSG( boost::has_virtual_destructor<T>::value, "The target of dynamic_pointer_cast must have a virtual destructor." );
T * p = dynamic_cast<T*>( r.get() );
if( p ) r.release();
return std::unique_ptr<T>( p );
}
//const_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> const_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) const_cast< T* >( static_cast< U* >( 0 ) );
typedef typename std::unique_ptr<T>::element_type E;
return std::unique_ptr<T>( const_cast<E*>( r.release() ) );
}
//reinterpret_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> reinterpret_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
typedef typename std::unique_ptr<T>::element_type E;
return std::unique_ptr<T>( reinterpret_cast<E*>( r.release() ) );
}
} // namespace boost
#endif // #if !defined( BOOST_NO_CXX11_SMART_PTR )
#endif //BOOST_POINTER_CAST_HPP

View File

@ -0,0 +1,55 @@
#ifndef BOOST_POINTER_TO_OTHER_HPP_INCLUDED
#define BOOST_POINTER_TO_OTHER_HPP_INCLUDED
//
// pointer_to_other.hpp
//
// (C) Copyright Ion Gaztanaga 2005.
// Copyright (c) 2005 Peter Dimov.
//
// Distributed under the Boost Software License, Version 1.0.
//
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
//
namespace boost
{
// Defines the same pointer type (raw or smart) to another pointee type
template<class T, class U>
struct pointer_to_other;
template<class T, class U,
template<class> class Sp>
struct pointer_to_other< Sp<T>, U >
{
typedef Sp<U> type;
};
template<class T, class T2, class U,
template<class, class> class Sp>
struct pointer_to_other< Sp<T, T2>, U >
{
typedef Sp<U, T2> type;
};
template<class T, class T2, class T3, class U,
template<class, class, class> class Sp>
struct pointer_to_other< Sp<T, T2, T3>, U >
{
typedef Sp<U, T2, T3> type;
};
template<class T, class U>
struct pointer_to_other< T*, U >
{
typedef U* type;
};
} // namespace boost
#endif // #ifndef BOOST_POINTER_TO_OTHER_HPP_INCLUDED

View File

@ -0,0 +1,15 @@
#ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED
#define BOOST_SCOPED_ARRAY_HPP_INCLUDED
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
// Copyright (c) 2001, 2002 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
#include <boost/smart_ptr/scoped_array.hpp>
#endif // #ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED

View File

@ -0,0 +1,15 @@
#ifndef BOOST_SCOPED_PTR_HPP_INCLUDED
#define BOOST_SCOPED_PTR_HPP_INCLUDED
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
// Copyright (c) 2001, 2002 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
#include <boost/smart_ptr/scoped_ptr.hpp>
#endif // #ifndef BOOST_SCOPED_PTR_HPP_INCLUDED

View File

@ -0,0 +1,19 @@
#ifndef BOOST_SHARED_ARRAY_HPP_INCLUDED
#define BOOST_SHARED_ARRAY_HPP_INCLUDED
//
// shared_array.hpp
//
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
// Copyright (c) 2001, 2002 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
//
#include <boost/smart_ptr/shared_array.hpp>
#endif // #ifndef BOOST_SHARED_ARRAY_HPP_INCLUDED

View File

@ -0,0 +1,19 @@
#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
#define BOOST_SHARED_PTR_HPP_INCLUDED
//
// shared_ptr.hpp
//
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
// Copyright (c) 2001-2008 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
//
#include <boost/smart_ptr/shared_ptr.hpp>
#endif // #ifndef BOOST_SHARED_PTR_HPP_INCLUDED

View File

@ -0,0 +1,26 @@
#ifndef BOOST_SMART_PTR_HPP_INCLUDED
#define BOOST_SMART_PTR_HPP_INCLUDED
//
// smart_ptr.hpp
//
// For convenience, this header includes the rest of the smart
// pointer library headers.
//
// Copyright (c) 2003 Peter Dimov Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
//
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/make_shared.hpp>
#endif // #ifndef BOOST_SMART_PTR_HPP_INCLUDED

View File

@ -0,0 +1,178 @@
/*
Copyright 2017-2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_SMART_PTR_ALLOCATE_LOCAL_SHARED_ARRAY_HPP
#define BOOST_SMART_PTR_ALLOCATE_LOCAL_SHARED_ARRAY_HPP
#include <boost/smart_ptr/allocate_shared_array.hpp>
#include <boost/smart_ptr/local_shared_ptr.hpp>
namespace boost {
namespace detail {
class BOOST_SYMBOL_VISIBLE lsp_array_base
: public local_counted_base {
public:
void set(sp_counted_base* base) BOOST_SP_NOEXCEPT {
count_ = shared_count(base);
}
void local_cb_destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
shared_count().swap(count_);
}
shared_count local_cb_get_shared_count() const
BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
return count_;
}
private:
shared_count count_;
};
template<class A>
class lsp_array_state
: public sp_array_state<A> {
public:
template<class U>
lsp_array_state(const U& other, std::size_t size) BOOST_SP_NOEXCEPT
: sp_array_state<A>(other, size) { }
lsp_array_base& base() BOOST_SP_NOEXCEPT {
return base_;
}
private:
lsp_array_base base_;
};
template<class A, std::size_t N>
class lsp_size_array_state
: public sp_size_array_state<A, N> {
public:
template<class U>
lsp_size_array_state(const U& other, std::size_t size) BOOST_SP_NOEXCEPT
: sp_size_array_state<A, N>(other, size) { }
lsp_array_base& base() BOOST_SP_NOEXCEPT {
return base_;
}
private:
lsp_array_base base_;
};
} /* detail */
template<class T, class A>
inline typename enable_if_<is_unbounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared(const A& allocator, std::size_t count)
{
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
typedef detail::lsp_array_state<other> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, count);
base* node = result.get();
element* start = detail::sp_array_start<element>(node);
::new(static_cast<void*>(node)) base(allocator, start, count);
detail::lsp_array_base& local = node->state().base();
local.set(node);
result.release();
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(), start,
&local);
}
template<class T, class A>
inline typename enable_if_<is_bounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared(const A& allocator)
{
enum {
count = extent<T>::value
};
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
typedef detail::lsp_size_array_state<other, count> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, count);
base* node = result.get();
element* start = detail::sp_array_start<element>(node);
::new(static_cast<void*>(node)) base(allocator, start, count);
detail::lsp_array_base& local = node->state().base();
local.set(node);
result.release();
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(), start,
&local);
}
template<class T, class A>
inline typename enable_if_<is_unbounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared(const A& allocator, std::size_t count,
const typename remove_extent<T>::type& value)
{
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
typedef detail::lsp_array_state<other> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, count);
base* node = result.get();
element* start = detail::sp_array_start<element>(node);
::new(static_cast<void*>(node)) base(allocator, start, count, value);
detail::lsp_array_base& local = node->state().base();
local.set(node);
result.release();
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(), start,
&local);
}
template<class T, class A>
inline typename enable_if_<is_bounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared(const A& allocator,
const typename remove_extent<T>::type& value)
{
enum {
count = extent<T>::value
};
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
typedef detail::lsp_size_array_state<other, count> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, count);
base* node = result.get();
element* start = detail::sp_array_start<element>(node);
::new(static_cast<void*>(node)) base(allocator, start, count, value);
detail::lsp_array_base& local = node->state().base();
local.set(node);
result.release();
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(), start,
&local);
}
template<class T, class A>
inline typename enable_if_<is_unbounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared_noinit(const A& allocator, std::size_t count)
{
return boost::allocate_local_shared<T>(boost::noinit_adapt(allocator),
count);
}
template<class T, class A>
inline typename enable_if_<is_bounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared_noinit(const A& allocator)
{
return boost::allocate_local_shared<T>(boost::noinit_adapt(allocator));
}
} /* boost */
#endif

View File

@ -0,0 +1,352 @@
/*
Copyright 2012-2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_SMART_PTR_ALLOCATE_SHARED_ARRAY_HPP
#define BOOST_SMART_PTR_ALLOCATE_SHARED_ARRAY_HPP
#include <boost/core/allocator_access.hpp>
#include <boost/core/alloc_construct.hpp>
#include <boost/core/first_scalar.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <boost/type_traits/enable_if.hpp>
#include <boost/type_traits/extent.hpp>
#include <boost/type_traits/is_bounded_array.hpp>
#include <boost/type_traits/is_unbounded_array.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_extent.hpp>
#include <boost/type_traits/type_with_alignment.hpp>
namespace boost {
namespace detail {
template<class T>
struct sp_array_element {
typedef typename boost::remove_cv<typename
boost::remove_extent<T>::type>::type type;
};
template<class T>
struct sp_array_count {
enum {
value = 1
};
};
template<class T, std::size_t N>
struct sp_array_count<T[N]> {
enum {
value = N * sp_array_count<T>::value
};
};
template<std::size_t N, std::size_t M>
struct sp_max_size {
enum {
value = N < M ? M : N
};
};
template<std::size_t N, std::size_t M>
struct sp_align_up {
enum {
value = (N + M - 1) & ~(M - 1)
};
};
template<class T>
BOOST_CONSTEXPR inline std::size_t
sp_objects(std::size_t size) BOOST_SP_NOEXCEPT
{
return (size + sizeof(T) - 1) / sizeof(T);
}
template<class A>
class sp_array_state {
public:
typedef A type;
template<class U>
sp_array_state(const U& _allocator, std::size_t _size) BOOST_SP_NOEXCEPT
: allocator_(_allocator),
size_(_size) { }
A& allocator() BOOST_SP_NOEXCEPT {
return allocator_;
}
std::size_t size() const BOOST_SP_NOEXCEPT {
return size_;
}
private:
A allocator_;
std::size_t size_;
};
template<class A, std::size_t N>
class sp_size_array_state {
public:
typedef A type;
template<class U>
sp_size_array_state(const U& _allocator, std::size_t) BOOST_SP_NOEXCEPT
: allocator_(_allocator) { }
A& allocator() BOOST_SP_NOEXCEPT {
return allocator_;
}
BOOST_CONSTEXPR std::size_t size() const BOOST_SP_NOEXCEPT {
return N;
}
private:
A allocator_;
};
template<class T, class U>
struct sp_array_alignment {
enum {
value = sp_max_size<boost::alignment_of<T>::value,
boost::alignment_of<U>::value>::value
};
};
template<class T, class U>
struct sp_array_offset {
enum {
value = sp_align_up<sizeof(T), sp_array_alignment<T, U>::value>::value
};
};
template<class U, class T>
inline U*
sp_array_start(T* base) BOOST_SP_NOEXCEPT
{
enum {
size = sp_array_offset<T, U>::value
};
return reinterpret_cast<U*>(reinterpret_cast<char*>(base) + size);
}
template<class A, class T>
class sp_array_creator {
typedef typename A::value_type element;
enum {
offset = sp_array_offset<T, element>::value
};
typedef typename boost::type_with_alignment<sp_array_alignment<T,
element>::value>::type type;
public:
template<class U>
sp_array_creator(const U& other, std::size_t size) BOOST_SP_NOEXCEPT
: other_(other),
size_(sp_objects<type>(offset + sizeof(element) * size)) { }
T* create() {
return reinterpret_cast<T*>(other_.allocate(size_));
}
void destroy(T* base) {
other_.deallocate(reinterpret_cast<type*>(base), size_);
}
private:
typename boost::allocator_rebind<A, type>::type other_;
std::size_t size_;
};
template<class T>
class BOOST_SYMBOL_VISIBLE sp_array_base
: public sp_counted_base {
typedef typename T::type allocator;
public:
typedef typename allocator::value_type type;
template<class A>
sp_array_base(const A& other, type* start, std::size_t size)
: state_(other, size) {
boost::alloc_construct_n(state_.allocator(),
boost::first_scalar(start),
state_.size() * sp_array_count<type>::value);
}
template<class A, class U>
sp_array_base(const A& other, type* start, std::size_t size, const U& list)
: state_(other, size) {
enum {
count = sp_array_count<type>::value
};
boost::alloc_construct_n(state_.allocator(),
boost::first_scalar(start), state_.size() * count,
boost::first_scalar(&list), count);
}
T& state() BOOST_SP_NOEXCEPT {
return state_;
}
void dispose() BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
boost::alloc_destroy_n(state_.allocator(),
boost::first_scalar(sp_array_start<type>(this)),
state_.size() * sp_array_count<type>::value);
}
void destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
sp_array_creator<allocator, sp_array_base> other(state_.allocator(),
state_.size());
this->~sp_array_base();
other.destroy(this);
}
void* get_deleter(const sp_typeinfo_&) BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
return 0;
}
void* get_local_deleter(const sp_typeinfo_&)
BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
return 0;
}
void* get_untyped_deleter() BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
return 0;
}
private:
T state_;
};
template<class A, class T>
struct sp_array_result {
public:
template<class U>
sp_array_result(const U& other, std::size_t size)
: creator_(other, size),
result_(creator_.create()) { }
~sp_array_result() {
if (result_) {
creator_.destroy(result_);
}
}
T* get() const BOOST_SP_NOEXCEPT {
return result_;
}
void release() BOOST_SP_NOEXCEPT {
result_ = 0;
}
private:
sp_array_result(const sp_array_result&);
sp_array_result& operator=(const sp_array_result&);
sp_array_creator<A, T> creator_;
T* result_;
};
} /* detail */
template<class T, class A>
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
allocate_shared(const A& allocator, std::size_t count)
{
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
typedef detail::sp_array_state<other> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, count);
base* node = result.get();
element* start = detail::sp_array_start<element>(node);
::new(static_cast<void*>(node)) base(allocator, start, count);
result.release();
return shared_ptr<T>(detail::sp_internal_constructor_tag(), start,
detail::shared_count(static_cast<detail::sp_counted_base*>(node)));
}
template<class T, class A>
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
allocate_shared(const A& allocator)
{
enum {
count = extent<T>::value
};
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
typedef detail::sp_size_array_state<other, extent<T>::value> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, count);
base* node = result.get();
element* start = detail::sp_array_start<element>(node);
::new(static_cast<void*>(node)) base(allocator, start, count);
result.release();
return shared_ptr<T>(detail::sp_internal_constructor_tag(), start,
detail::shared_count(static_cast<detail::sp_counted_base*>(node)));
}
template<class T, class A>
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
allocate_shared(const A& allocator, std::size_t count,
const typename remove_extent<T>::type& value)
{
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
typedef detail::sp_array_state<other> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, count);
base* node = result.get();
element* start = detail::sp_array_start<element>(node);
::new(static_cast<void*>(node)) base(allocator, start, count, value);
result.release();
return shared_ptr<T>(detail::sp_internal_constructor_tag(), start,
detail::shared_count(static_cast<detail::sp_counted_base*>(node)));
}
template<class T, class A>
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
allocate_shared(const A& allocator,
const typename remove_extent<T>::type& value)
{
enum {
count = extent<T>::value
};
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
typedef detail::sp_size_array_state<other, extent<T>::value> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, count);
base* node = result.get();
element* start = detail::sp_array_start<element>(node);
::new(static_cast<void*>(node)) base(allocator, start, count, value);
result.release();
return shared_ptr<T>(detail::sp_internal_constructor_tag(), start,
detail::shared_count(static_cast<detail::sp_counted_base*>(node)));
}
template<class T, class A>
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
allocate_shared_noinit(const A& allocator, std::size_t count)
{
return boost::allocate_shared<T>(boost::noinit_adapt(allocator), count);
}
template<class T, class A>
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
allocate_shared_noinit(const A& allocator)
{
return boost::allocate_shared<T>(boost::noinit_adapt(allocator));
}
} /* boost */
#endif

View File

@ -0,0 +1,491 @@
/*
Copyright 2019-2021 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_SMART_PTR_ALLOCATE_UNIQUE_HPP
#define BOOST_SMART_PTR_ALLOCATE_UNIQUE_HPP
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/core/allocator_access.hpp>
#include <boost/core/alloc_construct.hpp>
#include <boost/core/empty_value.hpp>
#include <boost/core/first_scalar.hpp>
#include <boost/core/noinit_adaptor.hpp>
#include <boost/core/pointer_traits.hpp>
#include <boost/type_traits/enable_if.hpp>
#include <boost/type_traits/extent.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_bounded_array.hpp>
#include <boost/type_traits/is_unbounded_array.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_extent.hpp>
#include <boost/type_traits/type_identity.hpp>
#include <boost/config.hpp>
#include <memory>
#include <utility>
namespace boost {
namespace detail {
template<class T>
struct sp_alloc_size {
BOOST_STATIC_CONSTEXPR std::size_t value = 1;
};
template<class T>
struct sp_alloc_size<T[]> {
BOOST_STATIC_CONSTEXPR std::size_t value = sp_alloc_size<T>::value;
};
template<class T, std::size_t N>
struct sp_alloc_size<T[N]> {
BOOST_STATIC_CONSTEXPR std::size_t value = N * sp_alloc_size<T>::value;
};
template<class T>
struct sp_alloc_result {
typedef T type;
};
template<class T, std::size_t N>
struct sp_alloc_result<T[N]> {
typedef T type[];
};
template<class T>
struct sp_alloc_value {
typedef typename boost::remove_cv<typename
boost::remove_extent<T>::type>::type type;
};
template<class T, class P>
class sp_alloc_ptr {
public:
typedef T element_type;
sp_alloc_ptr() BOOST_SP_NOEXCEPT
: p_() { }
#if defined(BOOST_MSVC) && BOOST_MSVC == 1600
sp_alloc_ptr(T* p) BOOST_SP_NOEXCEPT
: p_(const_cast<typename boost::remove_cv<T>::type*>(p)) { }
#endif
sp_alloc_ptr(std::size_t, P p) BOOST_SP_NOEXCEPT
: p_(p) { }
#if !defined(BOOST_NO_CXX11_NULLPTR)
sp_alloc_ptr(detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
: p_() { }
#endif
T& operator*() const {
return *p_;
}
T* operator->() const BOOST_SP_NOEXCEPT {
return boost::to_address(p_);
}
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
explicit operator bool() const BOOST_SP_NOEXCEPT {
return !!p_;
}
#endif
bool operator!() const BOOST_SP_NOEXCEPT {
return !p_;
}
P ptr() const BOOST_SP_NOEXCEPT {
return p_;
}
BOOST_STATIC_CONSTEXPR std::size_t size() BOOST_SP_NOEXCEPT {
return 1;
}
#if defined(BOOST_MSVC) && BOOST_MSVC < 1910
static sp_alloc_ptr pointer_to(T& v) {
return sp_alloc_ptr(1,
std::pointer_traits<P>::pointer_to(const_cast<typename
boost::remove_cv<T>::type&>(v)));
}
#endif
private:
P p_;
};
template<class T, class P>
class sp_alloc_ptr<T[], P> {
public:
typedef T element_type;
sp_alloc_ptr() BOOST_SP_NOEXCEPT
: p_() { }
sp_alloc_ptr(std::size_t n, P p) BOOST_SP_NOEXCEPT
: p_(p)
, n_(n) { }
#if !defined(BOOST_NO_CXX11_NULLPTR)
sp_alloc_ptr(detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
: p_() { }
#endif
T& operator[](std::size_t i) const {
return p_[i];
}
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
explicit operator bool() const BOOST_SP_NOEXCEPT {
return !!p_;
}
#endif
bool operator!() const BOOST_SP_NOEXCEPT {
return !p_;
}
P ptr() const BOOST_SP_NOEXCEPT {
return p_;
}
std::size_t size() const BOOST_SP_NOEXCEPT {
return n_;
}
#if defined(BOOST_MSVC) && BOOST_MSVC < 1910
static sp_alloc_ptr pointer_to(T& v) {
return sp_alloc_ptr(n_,
std::pointer_traits<P>::pointer_to(const_cast<typename
boost::remove_cv<T>::type&>(v)));
}
#endif
private:
P p_;
std::size_t n_;
};
template<class T, std::size_t N, class P>
class sp_alloc_ptr<T[N], P> {
public:
typedef T element_type;
sp_alloc_ptr() BOOST_SP_NOEXCEPT
: p_() { }
sp_alloc_ptr(std::size_t, P p) BOOST_SP_NOEXCEPT
: p_(p) { }
#if !defined(BOOST_NO_CXX11_NULLPTR)
sp_alloc_ptr(detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
: p_() { }
#endif
T& operator[](std::size_t i) const {
return p_[i];
}
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
explicit operator bool() const BOOST_SP_NOEXCEPT {
return !!p_;
}
#endif
bool operator!() const BOOST_SP_NOEXCEPT {
return !p_;
}
P ptr() const BOOST_SP_NOEXCEPT {
return p_;
}
BOOST_STATIC_CONSTEXPR std::size_t size() BOOST_SP_NOEXCEPT {
return N;
}
#if defined(BOOST_MSVC) && BOOST_MSVC < 1910
static sp_alloc_ptr pointer_to(T& v) {
return sp_alloc_ptr(N,
std::pointer_traits<P>::pointer_to(const_cast<typename
boost::remove_cv<T>::type&>(v)));
}
#endif
private:
P p_;
};
template<class T, class P>
inline bool
operator==(const sp_alloc_ptr<T, P>& lhs, const sp_alloc_ptr<T, P>& rhs)
{
return lhs.ptr() == rhs.ptr();
}
template<class T, class P>
inline bool
operator!=(const sp_alloc_ptr<T, P>& lhs, const sp_alloc_ptr<T, P>& rhs)
{
return !(lhs == rhs);
}
#if !defined(BOOST_NO_CXX11_NULLPTR)
template<class T, class P>
inline bool
operator==(const sp_alloc_ptr<T, P>& lhs,
detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
{
return !lhs.ptr();
}
template<class T, class P>
inline bool
operator==(detail::sp_nullptr_t,
const sp_alloc_ptr<T, P>& rhs) BOOST_SP_NOEXCEPT
{
return !rhs.ptr();
}
template<class T, class P>
inline bool
operator!=(const sp_alloc_ptr<T, P>& lhs,
detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
{
return !!lhs.ptr();
}
template<class T, class P>
inline bool
operator!=(detail::sp_nullptr_t,
const sp_alloc_ptr<T, P>& rhs) BOOST_SP_NOEXCEPT
{
return !!rhs.ptr();
}
#endif
template<class A>
inline void
sp_alloc_clear(A& a, typename boost::allocator_pointer<A>::type p, std::size_t,
boost::false_type)
{
boost::alloc_destroy(a, boost::to_address(p));
}
template<class A>
inline void
sp_alloc_clear(A& a, typename boost::allocator_pointer<A>::type p,
std::size_t n, boost::true_type)
{
#if defined(BOOST_MSVC) && BOOST_MSVC < 1800
if (!p) {
return;
}
#endif
boost::alloc_destroy_n(a, boost::first_scalar(boost::to_address(p)),
n * sp_alloc_size<typename A::value_type>::value);
}
} /* detail */
template<class T, class A>
class alloc_deleter
: empty_value<typename allocator_rebind<A,
typename detail::sp_alloc_value<T>::type>::type> {
typedef typename allocator_rebind<A,
typename detail::sp_alloc_value<T>::type>::type allocator;
typedef empty_value<allocator> base;
public:
typedef detail::sp_alloc_ptr<T,
typename allocator_pointer<allocator>::type> pointer;
explicit alloc_deleter(const allocator& a) BOOST_SP_NOEXCEPT
: base(empty_init_t(), a) { }
void operator()(pointer p) {
detail::sp_alloc_clear(base::get(), p.ptr(), p.size(), is_array<T>());
base::get().deallocate(p.ptr(), p.size());
}
};
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template<class T, class A>
using alloc_noinit_deleter = alloc_deleter<T, noinit_adaptor<A> >;
#endif
namespace detail {
template<class T, class A>
class sp_alloc_make {
public:
typedef typename boost::allocator_rebind<A,
typename sp_alloc_value<T>::type>::type allocator;
private:
typedef boost::alloc_deleter<T, A> deleter;
public:
typedef std::unique_ptr<typename sp_alloc_result<T>::type, deleter> type;
sp_alloc_make(const A& a, std::size_t n)
: a_(a)
, n_(n)
, p_(a_.allocate(n)) { }
~sp_alloc_make() {
if (p_) {
a_.deallocate(p_, n_);
}
}
typename allocator::value_type* get() const BOOST_SP_NOEXCEPT {
return boost::to_address(p_);
}
allocator& state() BOOST_SP_NOEXCEPT {
return a_;
}
type release() BOOST_SP_NOEXCEPT {
pointer p = p_;
p_ = pointer();
return type(typename deleter::pointer(n_, p), deleter(a_));
}
private:
typedef typename boost::allocator_pointer<allocator>::type pointer;
allocator a_;
std::size_t n_;
pointer p_;
};
} /* detail */
template<class T, class A>
inline typename enable_if_<!is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc)
{
detail::sp_alloc_make<T, A> c(alloc, 1);
boost::alloc_construct(c.state(), c.get());
return c.release();
}
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class T, class A, class... Args>
inline typename enable_if_<!is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc, Args&&... args)
{
detail::sp_alloc_make<T, A> c(alloc, 1);
boost::alloc_construct(c.state(), c.get(), std::forward<Args>(args)...);
return c.release();
}
#endif
template<class T, class A>
inline typename enable_if_<!is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc, typename type_identity<T>::type&& value)
{
detail::sp_alloc_make<T, A> c(alloc, 1);
boost::alloc_construct(c.state(), c.get(), std::move(value));
return c.release();
}
template<class T, class A>
inline typename enable_if_<!is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, noinit_adaptor<A> > > >::type
allocate_unique_noinit(const A& alloc)
{
return boost::allocate_unique<T, noinit_adaptor<A> >(alloc);
}
template<class T, class A>
inline typename enable_if_<is_unbounded_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc, std::size_t size)
{
detail::sp_alloc_make<T, A> c(alloc, size);
boost::alloc_construct_n(c.state(), boost::first_scalar(c.get()),
size * detail::sp_alloc_size<T>::value);
return c.release();
}
template<class T, class A>
inline typename enable_if_<is_bounded_array<T>::value,
std::unique_ptr<typename detail::sp_alloc_result<T>::type,
alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc)
{
detail::sp_alloc_make<T, A> c(alloc, extent<T>::value);
boost::alloc_construct_n(c.state(), boost::first_scalar(c.get()),
detail::sp_alloc_size<T>::value);
return c.release();
}
template<class T, class A>
inline typename enable_if_<is_unbounded_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, noinit_adaptor<A> > > >::type
allocate_unique_noinit(const A& alloc, std::size_t size)
{
return boost::allocate_unique<T, noinit_adaptor<A> >(alloc, size);
}
template<class T, class A>
inline typename enable_if_<is_bounded_array<T>::value,
std::unique_ptr<typename detail::sp_alloc_result<T>::type,
alloc_deleter<T, noinit_adaptor<A> > > >::type
allocate_unique_noinit(const A& alloc)
{
return boost::allocate_unique<T, noinit_adaptor<A> >(alloc);
}
template<class T, class A>
inline typename enable_if_<is_unbounded_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc, std::size_t size,
const typename remove_extent<T>::type& value)
{
detail::sp_alloc_make<T, A> c(alloc, size);
boost::alloc_construct_n(c.state(), boost::first_scalar(c.get()),
size * detail::sp_alloc_size<T>::value, boost::first_scalar(&value),
detail::sp_alloc_size<typename remove_extent<T>::type>::value);
return c.release();
}
template<class T, class A>
inline typename enable_if_<is_bounded_array<T>::value,
std::unique_ptr<typename detail::sp_alloc_result<T>::type,
alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc,
const typename remove_extent<T>::type& value)
{
detail::sp_alloc_make<T, A> c(alloc, extent<T>::value);
boost::alloc_construct_n(c.state(), boost::first_scalar(c.get()),
detail::sp_alloc_size<T>::value, boost::first_scalar(&value),
detail::sp_alloc_size<typename remove_extent<T>::type>::value);
return c.release();
}
template<class T, class U, class A>
inline typename allocator_pointer<typename allocator_rebind<A,
typename detail::sp_alloc_value<T>::type>::type>::type
get_allocator_pointer(const std::unique_ptr<T,
alloc_deleter<U, A> >& p) BOOST_NOEXCEPT
{
return p.get().ptr();
}
} /* boost */
#endif

View File

@ -0,0 +1,238 @@
#ifndef BOOST_SMART_PTR_ATOMIC_SHARED_PTR_HPP_INCLUDED
#define BOOST_SMART_PTR_ATOMIC_SHARED_PTR_HPP_INCLUDED
//
// atomic_shared_ptr.hpp
//
// Copyright 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
//
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#include <cstring>
namespace boost
{
template<class T> class atomic_shared_ptr
{
private:
boost::shared_ptr<T> p_;
mutable boost::detail::spinlock l_;
atomic_shared_ptr(const atomic_shared_ptr&);
atomic_shared_ptr& operator=(const atomic_shared_ptr&);
private:
bool compare_exchange( shared_ptr<T>& v, shared_ptr<T> w ) BOOST_SP_NOEXCEPT
{
l_.lock();
if( p_._internal_equiv( v ) )
{
p_.swap( w );
l_.unlock();
return true;
}
else
{
shared_ptr<T> tmp( p_ );
l_.unlock();
tmp.swap( v );
return false;
}
}
public:
#if !defined( BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX ) && !defined( BOOST_NO_CXX11_CONSTEXPR )
constexpr atomic_shared_ptr() BOOST_SP_NOEXCEPT: l_ BOOST_DETAIL_SPINLOCK_INIT
{
}
atomic_shared_ptr( shared_ptr<T> p ) BOOST_SP_NOEXCEPT
: p_( std::move( p ) ), l_ BOOST_DETAIL_SPINLOCK_INIT
{
}
#else
atomic_shared_ptr() BOOST_SP_NOEXCEPT
{
boost::detail::spinlock init = BOOST_DETAIL_SPINLOCK_INIT;
std::memcpy( &l_, &init, sizeof( init ) );
}
atomic_shared_ptr( shared_ptr<T> p ) BOOST_SP_NOEXCEPT
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
: p_( std::move( p ) )
#else
: p_( p )
#endif
{
boost::detail::spinlock init = BOOST_DETAIL_SPINLOCK_INIT;
std::memcpy( &l_, &init, sizeof( init ) );
}
#endif
atomic_shared_ptr& operator=( shared_ptr<T> r ) BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
p_.swap( r );
return *this;
}
BOOST_CONSTEXPR bool is_lock_free() const BOOST_SP_NOEXCEPT
{
return false;
}
shared_ptr<T> load() const BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
return p_;
}
template<class M> shared_ptr<T> load( M ) const BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
return p_;
}
operator shared_ptr<T>() const BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
return p_;
}
void store( shared_ptr<T> r ) BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
p_.swap( r );
}
template<class M> void store( shared_ptr<T> r, M ) BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
p_.swap( r );
}
shared_ptr<T> exchange( shared_ptr<T> r ) BOOST_SP_NOEXCEPT
{
{
boost::detail::spinlock::scoped_lock lock( l_ );
p_.swap( r );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
return std::move( r );
#else
return r;
#endif
}
template<class M> shared_ptr<T> exchange( shared_ptr<T> r, M ) BOOST_SP_NOEXCEPT
{
{
boost::detail::spinlock::scoped_lock lock( l_ );
p_.swap( r );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
return std::move( r );
#else
return r;
#endif
}
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
#endif
};
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_ATOMIC_SHARED_PTR_HPP_INCLUDED

View File

@ -0,0 +1,70 @@
#ifndef BOOST_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED
#define BOOST_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/smart_ptr/bad_weak_ptr.hpp
//
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/config.hpp>
#include <exception>
#ifdef BOOST_BORLANDC
# pragma warn -8026 // Functions with excep. spec. are not expanded inline
#endif
namespace boost
{
// The standard library that comes with Borland C++ 5.5.1, 5.6.4
// defines std::exception and its members as having C calling
// convention (-pc). When the definition of bad_weak_ptr
// is compiled with -ps, the compiler issues an error.
// Hence, the temporary #pragma option -pc below.
#if defined(BOOST_BORLANDC) && BOOST_BORLANDC <= 0x564
# pragma option push -pc
#endif
#if defined(BOOST_CLANG)
// Intel C++ on Mac defines __clang__ but doesn't support the pragma
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wweak-vtables"
#endif
class bad_weak_ptr: public std::exception
{
public:
char const * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
{
return "tr1::bad_weak_ptr";
}
};
#if defined(BOOST_CLANG)
# pragma clang diagnostic pop
#endif
#if defined(BOOST_BORLANDC) && BOOST_BORLANDC <= 0x564
# pragma option pop
#endif
} // namespace boost
#ifdef BOOST_BORLANDC
# pragma warn .8026 // Functions with excep. spec. are not expanded inline
#endif
#endif // #ifndef BOOST_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED

View File

@ -0,0 +1,103 @@
#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/detail/atomic_count.hpp - thread/SMP safe reference counter
//
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 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
//
// typedef <implementation-defined> boost::detail::atomic_count;
//
// atomic_count a(n);
//
// (n is convertible to long)
//
// Effects: Constructs an atomic_count with an initial value of n
//
// a;
//
// Returns: (long) the current value of a
// Memory Ordering: acquire
//
// ++a;
//
// Effects: Atomically increments the value of a
// Returns: (long) the new value of a
// Memory Ordering: acquire/release
//
// --a;
//
// Effects: Atomically decrements the value of a
// Returns: (long) the new value of a
// Memory Ordering: acquire/release
//
#include <boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp>
#include <boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp>
#include <boost/config.hpp>
#if defined( BOOST_AC_DISABLE_THREADS )
# include <boost/smart_ptr/detail/atomic_count_nt.hpp>
#elif defined( BOOST_AC_USE_STD_ATOMIC )
# include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp>
#elif defined( BOOST_AC_USE_SPINLOCK )
# include <boost/smart_ptr/detail/atomic_count_spin.hpp>
#elif defined( BOOST_AC_USE_PTHREADS )
# include <boost/smart_ptr/detail/atomic_count_pt.hpp>
#elif defined( BOOST_SP_DISABLE_THREADS )
# include <boost/smart_ptr/detail/atomic_count_nt.hpp>
#elif defined( BOOST_SP_USE_STD_ATOMIC )
# include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp>
#elif defined( BOOST_SP_USE_SPINLOCK )
# include <boost/smart_ptr/detail/atomic_count_spin.hpp>
#elif defined( BOOST_SP_USE_PTHREADS )
# include <boost/smart_ptr/detail/atomic_count_pt.hpp>
#elif defined( BOOST_DISABLE_THREADS ) && !defined( BOOST_SP_ENABLE_THREADS ) && !defined( BOOST_DISABLE_WIN32 )
# include <boost/smart_ptr/detail/atomic_count_nt.hpp>
#elif defined( BOOST_SP_HAS_GCC_INTRINSICS )
# include <boost/smart_ptr/detail/atomic_count_gcc_atomic.hpp>
#elif !defined( BOOST_NO_CXX11_HDR_ATOMIC )
# include <boost/smart_ptr/detail/atomic_count_std_atomic.hpp>
#elif defined( BOOST_SP_HAS_SYNC_INTRINSICS )
# include <boost/smart_ptr/detail/atomic_count_sync.hpp>
#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) && !defined( __PATHSCALE__ )
# include <boost/smart_ptr/detail/atomic_count_gcc_x86.hpp>
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# include <boost/smart_ptr/detail/atomic_count_win32.hpp>
#elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
# include <boost/smart_ptr/detail/atomic_count_gcc.hpp>
#elif !defined( BOOST_HAS_THREADS )
# include <boost/smart_ptr/detail/atomic_count_nt.hpp>
#else
# include <boost/smart_ptr/detail/atomic_count_spin.hpp>
#endif
#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_HPP_INCLUDED

View File

@ -0,0 +1,79 @@
#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED
//
// boost/detail/atomic_count_gcc.hpp
//
// atomic_count for GNU libstdc++ v3
//
// http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html
//
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2002 Lars Gullik Bjønnes <larsbj@lyx.org>
// Copyright 2003-2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#if __GNUC__ * 100 + __GNUC_MINOR__ >= 402
# include <ext/atomicity.h>
#else
# include <bits/atomicity.h>
#endif
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using libstdc++ atomic_count")
#endif
namespace boost
{
namespace detail
{
#if defined(__GLIBCXX__) // g++ 3.4+
using __gnu_cxx::__atomic_add;
using __gnu_cxx::__exchange_and_add;
#endif
class atomic_count
{
public:
explicit atomic_count( long v ) : value_( v ) {}
long operator++()
{
return __exchange_and_add( &value_, +1 ) + 1;
}
long operator--()
{
return __exchange_and_add( &value_, -1 ) - 1;
}
operator long() const
{
return __exchange_and_add( &value_, 0 );
}
private:
atomic_count(atomic_count const &);
atomic_count & operator=(atomic_count const &);
mutable _Atomic_word value_;
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_HPP_INCLUDED

View File

@ -0,0 +1,63 @@
#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_ATOMIC_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_ATOMIC_HPP_INCLUDED
// boost/detail/atomic_count_gcc_atomic.hpp
//
// atomic_count for g++ 4.7+
//
// Copyright 2007, 2020 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/cstdint.hpp>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using __atomic atomic_count")
#endif
namespace boost
{
namespace detail
{
class atomic_count
{
public:
explicit atomic_count( long v ): value_( static_cast< boost::int_least32_t >( v ) )
{
}
long operator++()
{
return __atomic_add_fetch( &value_, +1, __ATOMIC_ACQ_REL );
}
long operator--()
{
return __atomic_add_fetch( &value_, -1, __ATOMIC_ACQ_REL );
}
operator long() const
{
return __atomic_load_n( &value_, __ATOMIC_ACQUIRE );
}
private:
atomic_count(atomic_count const &);
atomic_count & operator=(atomic_count const &);
boost::int_least32_t value_;
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_ATOMIC_HPP_INCLUDED

View File

@ -0,0 +1,88 @@
#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_X86_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_X86_HPP_INCLUDED
//
// boost/detail/atomic_count_gcc_x86.hpp
//
// atomic_count for g++ on 486+/AMD64
//
// Copyright 2007 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/smart_ptr/detail/sp_obsolete.hpp>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using g++/x86 atomic_count")
#endif
BOOST_SP_OBSOLETE()
namespace boost
{
namespace detail
{
class atomic_count
{
public:
explicit atomic_count( long v ) : value_( static_cast< int >( v ) ) {}
long operator++()
{
return atomic_exchange_and_add( &value_, +1 ) + 1;
}
long operator--()
{
return atomic_exchange_and_add( &value_, -1 ) - 1;
}
operator long() const
{
return atomic_exchange_and_add( &value_, 0 );
}
private:
atomic_count(atomic_count const &);
atomic_count & operator=(atomic_count const &);
mutable int value_;
private:
static int atomic_exchange_and_add( int * pw, int dv )
{
// int r = *pw;
// *pw += dv;
// return r;
int r;
__asm__ __volatile__
(
"lock\n\t"
"xadd %1, %0":
"+m"( *pw ), "=r"( r ): // outputs (%0, %1)
"1"( dv ): // inputs (%2 == %1)
"memory", "cc" // clobbers
);
return r;
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_GCC_X86_HPP_INCLUDED

View File

@ -0,0 +1,66 @@
#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED
//
// boost/detail/atomic_count_nt.hpp
//
// Trivial atomic_count for the single-threaded case
//
// http://gcc.gnu.org/onlinedocs/porting/Thread-safety.html
//
// Copyright 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
//
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using single-threaded, non-atomic atomic_count")
#endif
namespace boost
{
namespace detail
{
class atomic_count
{
public:
explicit atomic_count( long v ): value_( v )
{
}
long operator++()
{
return ++value_;
}
long operator--()
{
return --value_;
}
operator long() const
{
return value_;
}
private:
atomic_count(atomic_count const &);
atomic_count & operator=(atomic_count const &);
long value_;
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_NT_HPP_INCLUDED

View File

@ -0,0 +1,104 @@
#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_PTHREADS_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_PTHREADS_HPP_INCLUDED
//
// boost/detail/atomic_count_pthreads.hpp
//
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/assert.hpp>
#include <pthread.h>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using pthread_mutex atomic_count")
#endif
//
// The generic pthread_mutex-based implementation sometimes leads to
// inefficiencies. Example: a class with two atomic_count members
// can get away with a single mutex.
//
// Users can detect this situation by checking BOOST_AC_USE_PTHREADS.
//
namespace boost
{
namespace detail
{
class atomic_count
{
private:
class scoped_lock
{
public:
scoped_lock(pthread_mutex_t & m): m_(m)
{
BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
}
~scoped_lock()
{
BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
}
private:
pthread_mutex_t & m_;
};
public:
explicit atomic_count(long v): value_(v)
{
BOOST_VERIFY( pthread_mutex_init( &mutex_, 0 ) == 0 );
}
~atomic_count()
{
BOOST_VERIFY( pthread_mutex_destroy( &mutex_ ) == 0 );
}
long operator++()
{
scoped_lock lock(mutex_);
return ++value_;
}
long operator--()
{
scoped_lock lock(mutex_);
return --value_;
}
operator long() const
{
scoped_lock lock(mutex_);
return value_;
}
private:
atomic_count(atomic_count const &);
atomic_count & operator=(atomic_count const &);
mutable pthread_mutex_t mutex_;
long value_;
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_PTHREADS_HPP_INCLUDED

View File

@ -0,0 +1,69 @@
#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED
//
// boost/detail/atomic_count_spin.hpp
//
// Copyright (c) 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
//
#include <boost/smart_ptr/detail/spinlock_pool.hpp>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using spinlock-based atomic_count")
#endif
namespace boost
{
namespace detail
{
class atomic_count
{
private:
public:
explicit atomic_count( long v ): value_( v )
{
}
long operator++()
{
spinlock_pool<0>::scoped_lock lock( &value_ );
return ++value_;
}
long operator--()
{
spinlock_pool<0>::scoped_lock lock( &value_ );
return --value_;
}
operator long() const
{
spinlock_pool<0>::scoped_lock lock( &value_ );
return value_;
}
private:
atomic_count(atomic_count const &);
atomic_count & operator=(atomic_count const &);
long value_;
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SPIN_HPP_INCLUDED

View File

@ -0,0 +1,67 @@
#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_STD_ATOMIC_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_STD_ATOMIC_HPP_INCLUDED
//
// boost/detail/atomic_count_std_atomic.hpp
//
// atomic_count for std::atomic
//
// Copyright 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
//
#include <atomic>
#include <cstdint>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using std::atomic atomic_count")
#endif
namespace boost
{
namespace detail
{
class atomic_count
{
public:
explicit atomic_count( long v ): value_( static_cast< std::int_least32_t >( v ) )
{
}
long operator++()
{
return value_.fetch_add( 1, std::memory_order_acq_rel ) + 1;
}
long operator--()
{
return value_.fetch_sub( 1, std::memory_order_acq_rel ) - 1;
}
operator long() const
{
return value_.load( std::memory_order_acquire );
}
private:
atomic_count(atomic_count const &);
atomic_count & operator=(atomic_count const &);
std::atomic_int_least32_t value_;
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_STD_ATOMIC_HPP_INCLUDED

View File

@ -0,0 +1,72 @@
#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED
//
// boost/detail/atomic_count_sync.hpp
//
// atomic_count for g++ 4.1+
//
// http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html
//
// Copyright 2007 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/cstdint.hpp>
#if defined( __ia64__ ) && defined( __INTEL_COMPILER )
# include <ia64intrin.h>
#endif
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using __sync atomic_count")
#endif
namespace boost
{
namespace detail
{
class atomic_count
{
public:
explicit atomic_count( long v ): value_( static_cast< boost::int_least32_t >( v ) )
{
}
long operator++()
{
return __sync_add_and_fetch( &value_, 1 );
}
long operator--()
{
return __sync_add_and_fetch( &value_, -1 );
}
operator long() const
{
return __sync_fetch_and_add( &value_, 0 );
}
private:
atomic_count(atomic_count const &);
atomic_count & operator=(atomic_count const &);
mutable boost::int_least32_t value_;
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED

View File

@ -0,0 +1,70 @@
#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/detail/atomic_count_win32.hpp
//
// Copyright (c) 2001-2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/smart_ptr/detail/sp_interlocked.hpp>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using Win32 atomic_count")
#endif
namespace boost
{
namespace detail
{
class atomic_count
{
public:
explicit atomic_count( long v ): value_( v )
{
}
long operator++()
{
return BOOST_SP_INTERLOCKED_INCREMENT( &value_ );
}
long operator--()
{
return BOOST_SP_INTERLOCKED_DECREMENT( &value_ );
}
operator long() const
{
return static_cast<long const volatile &>( value_ );
}
private:
atomic_count( atomic_count const & );
atomic_count & operator=( atomic_count const & );
long value_;
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_WIN32_HPP_INCLUDED

View File

@ -0,0 +1,39 @@
#ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/detail/lightweight_mutex.hpp - lightweight mutex
//
// Copyright (c) 2002, 2003 Peter Dimov and Multi Media Ltd.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// typedef <unspecified> boost::detail::lightweight_mutex;
//
// boost::detail::lightweight_mutex is a header-only implementation of
// a subset of the Mutex concept requirements:
//
// http://www.boost.org/doc/html/threads/concepts.html#threads.concepts.Mutex
//
// It maps to a CRITICAL_SECTION on Windows or a pthread_mutex on POSIX.
//
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_HDR_MUTEX )
# include <boost/smart_ptr/detail/lwm_std_mutex.hpp>
#elif defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# include <boost/smart_ptr/detail/lwm_win32_cs.hpp>
#else
# include <boost/smart_ptr/detail/lwm_pthreads.hpp>
#endif
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED

View File

@ -0,0 +1,188 @@
#ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// boost/detail/lightweight_thread.hpp
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2008, 2018 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
//
//
// typedef /*...*/ lw_thread_t; // as pthread_t
// template<class F> int lw_thread_create( lw_thread_t & th, F f );
// void lw_thread_join( lw_thread_t th );
#include <boost/config.hpp>
#include <memory>
#include <cerrno>
#if defined( BOOST_HAS_PTHREADS )
#include <pthread.h>
namespace boost
{
namespace detail
{
typedef ::pthread_t lw_thread_t;
inline int lw_thread_create_( lw_thread_t* thread, const pthread_attr_t* attr, void* (*start_routine)( void* ), void* arg )
{
return ::pthread_create( thread, attr, start_routine, arg );
}
inline void lw_thread_join( lw_thread_t th )
{
::pthread_join( th, 0 );
}
} // namespace detail
} // namespace boost
#else // defined( BOOST_HAS_PTHREADS )
#include <windows.h>
#include <process.h>
namespace boost
{
namespace detail
{
typedef HANDLE lw_thread_t;
inline int lw_thread_create_( lw_thread_t * thread, void const *, unsigned (__stdcall * start_routine) (void*), void* arg )
{
HANDLE h = (HANDLE)_beginthreadex( 0, 0, start_routine, arg, 0, 0 );
if( h != 0 )
{
*thread = h;
return 0;
}
else
{
return EAGAIN;
}
}
inline void lw_thread_join( lw_thread_t thread )
{
::WaitForSingleObject( thread, INFINITE );
::CloseHandle( thread );
}
} // namespace detail
} // namespace boost
#endif // defined( BOOST_HAS_PTHREADS )
namespace boost
{
namespace detail
{
class lw_abstract_thread
{
public:
virtual ~lw_abstract_thread() {}
virtual void run() = 0;
};
#if defined( BOOST_HAS_PTHREADS )
extern "C" void * lw_thread_routine( void * pv )
{
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
#else
std::unique_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
#endif
pt->run();
return 0;
}
#else
unsigned __stdcall lw_thread_routine( void * pv )
{
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
#else
std::unique_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
#endif
pt->run();
return 0;
}
#endif
template<class F> class lw_thread_impl: public lw_abstract_thread
{
public:
explicit lw_thread_impl( F f ): f_( f )
{
}
void run()
{
f_();
}
private:
F f_;
};
template<class F> int lw_thread_create( lw_thread_t & th, F f )
{
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr<lw_abstract_thread> p( new lw_thread_impl<F>( f ) );
#else
std::unique_ptr<lw_abstract_thread> p( new lw_thread_impl<F>( f ) );
#endif
int r = lw_thread_create_( &th, 0, lw_thread_routine, p.get() );
if( r == 0 )
{
p.release();
}
return r;
}
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED

View File

@ -0,0 +1,148 @@
#ifndef BOOST_SMART_PTR_DETAIL_LOCAL_COUNTED_BASE_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_LOCAL_COUNTED_BASE_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// detail/local_counted_base.hpp
//
// Copyright 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
#include <boost/smart_ptr/detail/shared_count.hpp>
#include <boost/config.hpp>
#include <utility>
namespace boost
{
namespace detail
{
class BOOST_SYMBOL_VISIBLE local_counted_base
{
private:
local_counted_base & operator= ( local_counted_base const & );
private:
// not 'int' or 'unsigned' to avoid aliasing and enable optimizations
enum count_type { min_ = 0, initial_ = 1, max_ = 2147483647 };
count_type local_use_count_;
public:
BOOST_CONSTEXPR local_counted_base() BOOST_SP_NOEXCEPT: local_use_count_( initial_ )
{
}
BOOST_CONSTEXPR local_counted_base( local_counted_base const & ) BOOST_SP_NOEXCEPT: local_use_count_( initial_ )
{
}
virtual ~local_counted_base() /*BOOST_SP_NOEXCEPT*/
{
}
virtual void local_cb_destroy() BOOST_SP_NOEXCEPT = 0;
virtual boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT = 0;
void add_ref() BOOST_SP_NOEXCEPT
{
#if !defined(__NVCC__)
#if defined( __has_builtin )
# if __has_builtin( __builtin_assume )
__builtin_assume( local_use_count_ >= 1 );
# endif
#endif
#endif
local_use_count_ = static_cast<count_type>( local_use_count_ + 1 );
}
void release() BOOST_SP_NOEXCEPT
{
local_use_count_ = static_cast<count_type>( local_use_count_ - 1 );
if( local_use_count_ == 0 )
{
local_cb_destroy();
}
}
long local_use_count() const BOOST_SP_NOEXCEPT
{
return local_use_count_;
}
};
class BOOST_SYMBOL_VISIBLE local_counted_impl: public local_counted_base
{
private:
local_counted_impl( local_counted_impl const & );
private:
shared_count pn_;
public:
explicit local_counted_impl( shared_count const& pn ) BOOST_SP_NOEXCEPT: pn_( pn )
{
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
explicit local_counted_impl( shared_count && pn ) BOOST_SP_NOEXCEPT: pn_( std::move(pn) )
{
}
#endif
void local_cb_destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
delete this;
}
boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return pn_;
}
};
class BOOST_SYMBOL_VISIBLE local_counted_impl_em: public local_counted_base
{
public:
shared_count pn_;
void local_cb_destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
shared_count().swap( pn_ );
}
boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return pn_;
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LOCAL_COUNTED_BASE_HPP_INCLUDED

View File

@ -0,0 +1,91 @@
#ifndef BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// detail/local_sp_deleter.hpp
//
// Copyright 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
#include <boost/smart_ptr/detail/local_counted_base.hpp>
#include <boost/config.hpp>
namespace boost
{
namespace detail
{
template<class D> class local_sp_deleter: public local_counted_impl_em
{
private:
D d_;
public:
local_sp_deleter(): d_()
{
}
explicit local_sp_deleter( D const& d ) BOOST_SP_NOEXCEPT: d_( d )
{
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
explicit local_sp_deleter( D&& d ) BOOST_SP_NOEXCEPT: d_( std::move(d) )
{
}
#endif
D& deleter() BOOST_SP_NOEXCEPT
{
return d_;
}
template<class Y> void operator()( Y* p ) BOOST_SP_NOEXCEPT
{
d_( p );
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
void operator()( boost::detail::sp_nullptr_t p ) BOOST_SP_NOEXCEPT
{
d_( p );
}
#endif
};
template<> class local_sp_deleter<void>
{
};
template<class D> D * get_local_deleter( local_sp_deleter<D> * p ) BOOST_SP_NOEXCEPT
{
return &p->deleter();
}
inline void * get_local_deleter( local_sp_deleter<void> * /*p*/ ) BOOST_SP_NOEXCEPT
{
return 0;
}
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED

View File

@ -0,0 +1,87 @@
#ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/detail/lwm_pthreads.hpp
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/assert.hpp>
#include <pthread.h>
namespace boost
{
namespace detail
{
class lightweight_mutex
{
private:
pthread_mutex_t m_;
lightweight_mutex(lightweight_mutex const &);
lightweight_mutex & operator=(lightweight_mutex const &);
public:
lightweight_mutex()
{
// HPUX 10.20 / DCE has a nonstandard pthread_mutex_init
#if defined(__hpux) && defined(_DECTHREADS_)
BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 );
#else
BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 );
#endif
}
~lightweight_mutex()
{
BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 );
}
class scoped_lock;
friend class scoped_lock;
class scoped_lock
{
private:
pthread_mutex_t & m_;
scoped_lock(scoped_lock const &);
scoped_lock & operator=(scoped_lock const &);
public:
scoped_lock(lightweight_mutex & m): m_(m.m_)
{
BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
}
~scoped_lock()
{
BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
}
};
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_PTHREADS_HPP_INCLUDED

View File

@ -0,0 +1,62 @@
#ifndef BOOST_SMART_PTR_DETAIL_LWM_STD_MUTEX_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_LWM_STD_MUTEX_HPP_INCLUDED
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
#include <boost/assert.hpp>
#include <mutex>
namespace boost
{
namespace detail
{
class lightweight_mutex
{
private:
std::mutex m_;
lightweight_mutex(lightweight_mutex const &);
lightweight_mutex & operator=(lightweight_mutex const &);
public:
lightweight_mutex()
{
}
class scoped_lock;
friend class scoped_lock;
class scoped_lock
{
private:
std::mutex & m_;
scoped_lock(scoped_lock const &);
scoped_lock & operator=(scoped_lock const &);
public:
scoped_lock( lightweight_mutex & m ): m_( m.m_ )
{
m_.lock();
}
~scoped_lock()
{
m_.unlock();
}
};
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_STD_MUTEX_HPP_INCLUDED

View File

@ -0,0 +1,123 @@
#ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/detail/lwm_win32_cs.hpp
//
// Copyright (c) 2002, 2003 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifdef BOOST_USE_WINDOWS_H
#include <windows.h>
#else
struct _RTL_CRITICAL_SECTION;
#endif
namespace boost
{
namespace detail
{
#ifndef BOOST_USE_WINDOWS_H
struct critical_section
{
struct critical_section_debug * DebugInfo;
long LockCount;
long RecursionCount;
void * OwningThread;
void * LockSemaphore;
#if defined(_WIN64)
unsigned __int64 SpinCount;
#else
unsigned long SpinCount;
#endif
};
extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(::_RTL_CRITICAL_SECTION *);
extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(::_RTL_CRITICAL_SECTION *);
extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(::_RTL_CRITICAL_SECTION *);
extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(::_RTL_CRITICAL_SECTION *);
typedef ::_RTL_CRITICAL_SECTION rtl_critical_section;
#else // #ifndef BOOST_USE_WINDOWS_H
typedef ::CRITICAL_SECTION critical_section;
using ::InitializeCriticalSection;
using ::EnterCriticalSection;
using ::LeaveCriticalSection;
using ::DeleteCriticalSection;
typedef ::CRITICAL_SECTION rtl_critical_section;
#endif // #ifndef BOOST_USE_WINDOWS_H
class lightweight_mutex
{
private:
critical_section cs_;
lightweight_mutex(lightweight_mutex const &);
lightweight_mutex & operator=(lightweight_mutex const &);
public:
lightweight_mutex()
{
boost::detail::InitializeCriticalSection(reinterpret_cast< rtl_critical_section* >(&cs_));
}
~lightweight_mutex()
{
boost::detail::DeleteCriticalSection(reinterpret_cast< rtl_critical_section* >(&cs_));
}
class scoped_lock;
friend class scoped_lock;
class scoped_lock
{
private:
lightweight_mutex & m_;
scoped_lock(scoped_lock const &);
scoped_lock & operator=(scoped_lock const &);
public:
explicit scoped_lock(lightweight_mutex & m): m_(m)
{
boost::detail::EnterCriticalSection(reinterpret_cast< rtl_critical_section* >(&m_.cs_));
}
~scoped_lock()
{
boost::detail::LeaveCriticalSection(reinterpret_cast< rtl_critical_section* >(&m_.cs_));
}
};
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED

View File

@ -0,0 +1,64 @@
// This header intentionally has no include guards.
//
// Copyright (c) 2001-2009, 2012 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
#if !defined( BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS ) && !defined( BOOST_NO_CXX11_NULLPTR )\
&& !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130))
explicit operator bool () const BOOST_SP_NOEXCEPT
{
return px != 0;
}
#elif ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__)
operator bool () const BOOST_SP_NOEXCEPT
{
return px != 0;
}
#elif defined( _MANAGED )
static void unspecified_bool( this_type*** )
{
}
typedef void (*unspecified_bool_type)( this_type*** );
operator unspecified_bool_type() const BOOST_SP_NOEXCEPT
{
return px == 0? 0: unspecified_bool;
}
#elif \
( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \
( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
typedef element_type * (this_type::*unspecified_bool_type)() const;
operator unspecified_bool_type() const BOOST_SP_NOEXCEPT
{
return px == 0? 0: &this_type::get;
}
#else
typedef element_type * this_type::*unspecified_bool_type;
operator unspecified_bool_type() const BOOST_SP_NOEXCEPT
{
return px == 0? 0: &this_type::px;
}
#endif
// operator! is redundant, but some compilers need it
bool operator! () const BOOST_SP_NOEXCEPT
{
return px == 0;
}

View File

@ -0,0 +1,199 @@
#ifndef BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// detail/quick_allocator.hpp
//
// Copyright (c) 2003 David Abrahams
// Copyright (c) 2003 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/config.hpp>
#include <boost/smart_ptr/detail/lightweight_mutex.hpp>
#include <boost/type_traits/type_with_alignment.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <new> // ::operator new, ::operator delete
#include <cstddef> // std::size_t
namespace boost
{
namespace detail
{
template<unsigned size, unsigned align_> union freeblock
{
typedef typename boost::type_with_alignment<align_>::type aligner_type;
aligner_type aligner;
char bytes[size];
freeblock * next;
};
template<unsigned size, unsigned align_> struct allocator_impl
{
typedef freeblock<size, align_> block;
// It may seem odd to use such small pages.
//
// However, on a typical Windows implementation that uses
// the OS allocator, "normal size" pages interact with the
// "ordinary" operator new, slowing it down dramatically.
//
// 512 byte pages are handled by the small object allocator,
// and don't interfere with ::new.
//
// The other alternative is to use much bigger pages (1M.)
//
// It is surprisingly easy to hit pathological behavior by
// varying the page size. g++ 2.96 on Red Hat Linux 7.2,
// for example, passionately dislikes 496. 512 seems OK.
#if defined(BOOST_QA_PAGE_SIZE)
enum { items_per_page = BOOST_QA_PAGE_SIZE / size };
#else
enum { items_per_page = 512 / size }; // 1048560 / size
#endif
#ifdef BOOST_HAS_THREADS
static lightweight_mutex & mutex()
{
static freeblock< sizeof( lightweight_mutex ), boost::alignment_of< lightweight_mutex >::value > fbm;
static lightweight_mutex * pm = new( &fbm ) lightweight_mutex;
return *pm;
}
static lightweight_mutex * mutex_init;
#endif
static block * free;
static block * page;
static unsigned last;
static inline void * alloc()
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock( mutex() );
#endif
if(block * x = free)
{
free = x->next;
return x;
}
else
{
if(last == items_per_page)
{
// "Listen to me carefully: there is no memory leak"
// -- Scott Meyers, Eff C++ 2nd Ed Item 10
page = ::new block[items_per_page];
last = 0;
}
return &page[last++];
}
}
static inline void * alloc(std::size_t n)
{
if(n != size) // class-specific new called for a derived object
{
return ::operator new(n);
}
else
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock( mutex() );
#endif
if(block * x = free)
{
free = x->next;
return x;
}
else
{
if(last == items_per_page)
{
page = ::new block[items_per_page];
last = 0;
}
return &page[last++];
}
}
}
static inline void dealloc(void * pv)
{
if(pv != 0) // 18.4.1.1/13
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock( mutex() );
#endif
block * pb = static_cast<block *>(pv);
pb->next = free;
free = pb;
}
}
static inline void dealloc(void * pv, std::size_t n)
{
if(n != size) // class-specific delete called for a derived object
{
::operator delete(pv);
}
else if(pv != 0) // 18.4.1.1/13
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock( mutex() );
#endif
block * pb = static_cast<block *>(pv);
pb->next = free;
free = pb;
}
}
};
#ifdef BOOST_HAS_THREADS
template<unsigned size, unsigned align_>
lightweight_mutex * allocator_impl<size, align_>::mutex_init = &allocator_impl<size, align_>::mutex();
#endif
template<unsigned size, unsigned align_>
freeblock<size, align_> * allocator_impl<size, align_>::free = 0;
template<unsigned size, unsigned align_>
freeblock<size, align_> * allocator_impl<size, align_>::page = 0;
template<unsigned size, unsigned align_>
unsigned allocator_impl<size, align_>::last = allocator_impl<size, align_>::items_per_page;
template<class T>
struct quick_allocator: public allocator_impl< sizeof(T), boost::alignment_of<T>::value >
{
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED

View File

@ -0,0 +1,707 @@
#ifndef BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// detail/shared_count.hpp
//
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
// Copyright 2004-2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#if defined(__BORLANDC__) && !defined(__clang__)
# pragma warn -8027 // Functions containing try are not expanded inline
#endif
#include <boost/smart_ptr/bad_weak_ptr.hpp>
#include <boost/smart_ptr/detail/sp_counted_base.hpp>
#include <boost/smart_ptr/detail/sp_counted_impl.hpp>
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/core/checked_delete.hpp>
#include <boost/throw_exception.hpp>
#include <boost/core/addressof.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <boost/cstdint.hpp>
#include <memory> // std::auto_ptr
#include <functional> // std::less
#include <cstddef> // std::size_t
#ifdef BOOST_NO_EXCEPTIONS
# include <new> // std::bad_alloc
#endif
#if defined( BOOST_SP_DISABLE_DEPRECATED )
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
namespace boost
{
namespace movelib
{
template< class T, class D > class unique_ptr;
} // namespace movelib
namespace detail
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
int const shared_count_id = 0x2C35F101;
int const weak_count_id = 0x298C38A4;
#endif
struct sp_nothrow_tag {};
template< class D > struct sp_inplace_tag
{
};
template< class T > class sp_reference_wrapper
{
public:
explicit sp_reference_wrapper( T & t): t_( boost::addressof( t ) )
{
}
template< class Y > void operator()( Y * p ) const
{
(*t_)( p );
}
private:
T * t_;
};
template< class D > struct sp_convert_reference
{
typedef D type;
};
template< class D > struct sp_convert_reference< D& >
{
typedef sp_reference_wrapper< D > type;
};
template<class T> std::size_t sp_hash_pointer( T* p ) BOOST_NOEXCEPT
{
boost::uintptr_t v = reinterpret_cast<boost::uintptr_t>( p );
// match boost::hash<T*>
return static_cast<std::size_t>( v + ( v >> 3 ) );
}
class weak_count;
class shared_count
{
private:
sp_counted_base * pi_;
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
int id_;
#endif
friend class weak_count;
public:
BOOST_CONSTEXPR shared_count() BOOST_SP_NOEXCEPT: pi_(0)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
}
BOOST_CONSTEXPR explicit shared_count( sp_counted_base * pi ) BOOST_SP_NOEXCEPT: pi_( pi )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
}
template<class Y> explicit shared_count( Y * p ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
#ifndef BOOST_NO_EXCEPTIONS
try
{
pi_ = new sp_counted_impl_p<Y>( p );
}
catch(...)
{
boost::checked_delete( p );
throw;
}
#else
pi_ = new sp_counted_impl_p<Y>( p );
if( pi_ == 0 )
{
boost::checked_delete( p );
boost::throw_exception( std::bad_alloc() );
}
#endif
}
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1200 )
template<class Y, class D> shared_count( Y * p, D d ): pi_(0)
#else
template<class P, class D> shared_count( P p, D d ): pi_(0)
#endif
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1200 )
typedef Y* P;
#endif
#ifndef BOOST_NO_EXCEPTIONS
try
{
pi_ = new sp_counted_impl_pd<P, D>(p, d);
}
catch(...)
{
d(p); // delete p
throw;
}
#else
pi_ = new sp_counted_impl_pd<P, D>(p, d);
if(pi_ == 0)
{
d(p); // delete p
boost::throw_exception(std::bad_alloc());
}
#endif
}
#if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
template< class P, class D > shared_count( P p, sp_inplace_tag<D> ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
#ifndef BOOST_NO_EXCEPTIONS
try
{
pi_ = new sp_counted_impl_pd< P, D >( p );
}
catch( ... )
{
D::operator_fn( p ); // delete p
throw;
}
#else
pi_ = new sp_counted_impl_pd< P, D >( p );
if( pi_ == 0 )
{
D::operator_fn( p ); // delete p
boost::throw_exception( std::bad_alloc() );
}
#endif // #ifndef BOOST_NO_EXCEPTIONS
}
#endif // !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
template<class P, class D, class A> shared_count( P p, D d, A a ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
typedef sp_counted_impl_pda<P, D, A> impl_type;
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
typedef typename std::allocator_traits<A>::template rebind_alloc< impl_type > A2;
#else
typedef typename A::template rebind< impl_type >::other A2;
#endif
A2 a2( a );
#ifndef BOOST_NO_EXCEPTIONS
try
{
pi_ = a2.allocate( 1 );
::new( static_cast< void* >( pi_ ) ) impl_type( p, d, a );
}
catch(...)
{
d( p );
if( pi_ != 0 )
{
a2.deallocate( static_cast< impl_type* >( pi_ ), 1 );
}
throw;
}
#else
pi_ = a2.allocate( 1 );
if( pi_ != 0 )
{
::new( static_cast< void* >( pi_ ) ) impl_type( p, d, a );
}
else
{
d( p );
boost::throw_exception( std::bad_alloc() );
}
#endif
}
#if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
template< class P, class D, class A > shared_count( P p, sp_inplace_tag< D >, A a ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
typedef sp_counted_impl_pda< P, D, A > impl_type;
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
typedef typename std::allocator_traits<A>::template rebind_alloc< impl_type > A2;
#else
typedef typename A::template rebind< impl_type >::other A2;
#endif
A2 a2( a );
#ifndef BOOST_NO_EXCEPTIONS
try
{
pi_ = a2.allocate( 1 );
::new( static_cast< void* >( pi_ ) ) impl_type( p, a );
}
catch(...)
{
D::operator_fn( p );
if( pi_ != 0 )
{
a2.deallocate( static_cast< impl_type* >( pi_ ), 1 );
}
throw;
}
#else
pi_ = a2.allocate( 1 );
if( pi_ != 0 )
{
::new( static_cast< void* >( pi_ ) ) impl_type( p, a );
}
else
{
D::operator_fn( p );
boost::throw_exception( std::bad_alloc() );
}
#endif // #ifndef BOOST_NO_EXCEPTIONS
}
#endif // !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
#ifndef BOOST_NO_AUTO_PTR
// auto_ptr<Y> is special cased to provide the strong guarantee
template<class Y>
explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
#ifdef BOOST_NO_EXCEPTIONS
if( pi_ == 0 )
{
boost::throw_exception(std::bad_alloc());
}
#endif
r.release();
}
#endif
#if !defined( BOOST_NO_CXX11_SMART_PTR )
template<class Y, class D>
explicit shared_count( std::unique_ptr<Y, D> & r ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
typedef typename sp_convert_reference<D>::type D2;
D2 d2( static_cast<D&&>( r.get_deleter() ) );
pi_ = new sp_counted_impl_pd< typename std::unique_ptr<Y, D>::pointer, D2 >( r.get(), d2 );
#ifdef BOOST_NO_EXCEPTIONS
if( pi_ == 0 )
{
boost::throw_exception( std::bad_alloc() );
}
#endif
r.release();
}
#endif
template<class Y, class D>
explicit shared_count( boost::movelib::unique_ptr<Y, D> & r ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
typedef typename sp_convert_reference<D>::type D2;
D2 d2( r.get_deleter() );
pi_ = new sp_counted_impl_pd< typename boost::movelib::unique_ptr<Y, D>::pointer, D2 >( r.get(), d2 );
#ifdef BOOST_NO_EXCEPTIONS
if( pi_ == 0 )
{
boost::throw_exception( std::bad_alloc() );
}
#endif
r.release();
}
~shared_count() /*BOOST_SP_NOEXCEPT*/
{
if( pi_ != 0 ) pi_->release();
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
id_ = 0;
#endif
}
shared_count(shared_count const & r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
if( pi_ != 0 ) pi_->add_ref_copy();
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
shared_count(shared_count && r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
r.pi_ = 0;
}
#endif
explicit shared_count(weak_count const & r); // throws bad_weak_ptr when r.use_count() == 0
shared_count( weak_count const & r, sp_nothrow_tag ) BOOST_SP_NOEXCEPT; // constructs an empty *this when r.use_count() == 0
shared_count & operator= (shared_count const & r) BOOST_SP_NOEXCEPT
{
sp_counted_base * tmp = r.pi_;
if( tmp != pi_ )
{
if( tmp != 0 ) tmp->add_ref_copy();
if( pi_ != 0 ) pi_->release();
pi_ = tmp;
}
return *this;
}
void swap(shared_count & r) BOOST_SP_NOEXCEPT
{
sp_counted_base * tmp = r.pi_;
r.pi_ = pi_;
pi_ = tmp;
}
long use_count() const BOOST_SP_NOEXCEPT
{
return pi_ != 0? pi_->use_count(): 0;
}
bool unique() const BOOST_SP_NOEXCEPT
{
return use_count() == 1;
}
bool empty() const BOOST_SP_NOEXCEPT
{
return pi_ == 0;
}
bool operator==( shared_count const & r ) const BOOST_SP_NOEXCEPT
{
return pi_ == r.pi_;
}
bool operator==( weak_count const & r ) const BOOST_SP_NOEXCEPT;
bool operator<( shared_count const & r ) const BOOST_SP_NOEXCEPT
{
return std::less<sp_counted_base *>()( pi_, r.pi_ );
}
bool operator<( weak_count const & r ) const BOOST_SP_NOEXCEPT;
void * get_deleter( sp_typeinfo_ const & ti ) const BOOST_SP_NOEXCEPT
{
return pi_? pi_->get_deleter( ti ): 0;
}
void * get_local_deleter( sp_typeinfo_ const & ti ) const BOOST_SP_NOEXCEPT
{
return pi_? pi_->get_local_deleter( ti ): 0;
}
void * get_untyped_deleter() const BOOST_SP_NOEXCEPT
{
return pi_? pi_->get_untyped_deleter(): 0;
}
std::size_t hash_value() const BOOST_SP_NOEXCEPT
{
return sp_hash_pointer( pi_ );
}
};
class weak_count
{
private:
sp_counted_base * pi_;
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
int id_;
#endif
friend class shared_count;
public:
BOOST_CONSTEXPR weak_count() BOOST_SP_NOEXCEPT: pi_(0)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(weak_count_id)
#endif
{
}
weak_count(shared_count const & r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(weak_count_id)
#endif
{
if(pi_ != 0) pi_->weak_add_ref();
}
weak_count(weak_count const & r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(weak_count_id)
#endif
{
if(pi_ != 0) pi_->weak_add_ref();
}
// Move support
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
weak_count(weak_count && r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(weak_count_id)
#endif
{
r.pi_ = 0;
}
#endif
~weak_count() /*BOOST_SP_NOEXCEPT*/
{
if(pi_ != 0) pi_->weak_release();
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
id_ = 0;
#endif
}
weak_count & operator= (shared_count const & r) BOOST_SP_NOEXCEPT
{
sp_counted_base * tmp = r.pi_;
if( tmp != pi_ )
{
if(tmp != 0) tmp->weak_add_ref();
if(pi_ != 0) pi_->weak_release();
pi_ = tmp;
}
return *this;
}
weak_count & operator= (weak_count const & r) BOOST_SP_NOEXCEPT
{
sp_counted_base * tmp = r.pi_;
if( tmp != pi_ )
{
if(tmp != 0) tmp->weak_add_ref();
if(pi_ != 0) pi_->weak_release();
pi_ = tmp;
}
return *this;
}
void swap(weak_count & r) BOOST_SP_NOEXCEPT
{
sp_counted_base * tmp = r.pi_;
r.pi_ = pi_;
pi_ = tmp;
}
long use_count() const BOOST_SP_NOEXCEPT
{
return pi_ != 0? pi_->use_count(): 0;
}
bool empty() const BOOST_SP_NOEXCEPT
{
return pi_ == 0;
}
bool operator==( weak_count const & r ) const BOOST_SP_NOEXCEPT
{
return pi_ == r.pi_;
}
bool operator==( shared_count const & r ) const BOOST_SP_NOEXCEPT
{
return pi_ == r.pi_;
}
bool operator<( weak_count const & r ) const BOOST_SP_NOEXCEPT
{
return std::less<sp_counted_base *>()( pi_, r.pi_ );
}
bool operator<( shared_count const & r ) const BOOST_SP_NOEXCEPT
{
return std::less<sp_counted_base *>()( pi_, r.pi_ );
}
std::size_t hash_value() const BOOST_SP_NOEXCEPT
{
return sp_hash_pointer( pi_ );
}
};
inline shared_count::shared_count( weak_count const & r ): pi_( r.pi_ )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
if( pi_ == 0 || !pi_->add_ref_lock() )
{
boost::throw_exception( boost::bad_weak_ptr() );
}
}
inline shared_count::shared_count( weak_count const & r, sp_nothrow_tag ) BOOST_SP_NOEXCEPT: pi_( r.pi_ )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
if( pi_ != 0 && !pi_->add_ref_lock() )
{
pi_ = 0;
}
}
inline bool shared_count::operator==( weak_count const & r ) const BOOST_SP_NOEXCEPT
{
return pi_ == r.pi_;
}
inline bool shared_count::operator<( weak_count const & r ) const BOOST_SP_NOEXCEPT
{
return std::less<sp_counted_base *>()( pi_, r.pi_ );
}
} // namespace detail
} // namespace boost
#if defined( BOOST_SP_DISABLE_DEPRECATED )
#pragma GCC diagnostic pop
#endif
#if defined(__BORLANDC__) && !defined(__clang__)
# pragma warn .8027 // Functions containing try are not expanded inline
#endif
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED

View File

@ -0,0 +1,92 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// detail/sp_convertible.hpp
//
// Copyright 2008 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#include <cstddef>
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_NO_SFINAE )
# define BOOST_SP_NO_SP_CONVERTIBLE
#endif
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ < 303 )
# define BOOST_SP_NO_SP_CONVERTIBLE
#endif
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_BORLANDC ) && ( BOOST_BORLANDC < 0x630 )
# define BOOST_SP_NO_SP_CONVERTIBLE
#endif
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
namespace boost
{
namespace detail
{
template< class Y, class T > struct sp_convertible
{
typedef char (&yes) [1];
typedef char (&no) [2];
static yes f( T* );
static no f( ... );
enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
};
template< class Y, class T > struct sp_convertible< Y, T[] >
{
enum _vt { value = false };
};
template< class Y, class T > struct sp_convertible< Y[], T[] >
{
enum _vt { value = sp_convertible< Y[1], T[1] >::value };
};
template< class Y, std::size_t N, class T > struct sp_convertible< Y[N], T[] >
{
enum _vt { value = sp_convertible< Y[1], T[1] >::value };
};
struct sp_empty
{
};
template< bool > struct sp_enable_if_convertible_impl;
template<> struct sp_enable_if_convertible_impl<true>
{
typedef sp_empty type;
};
template<> struct sp_enable_if_convertible_impl<false>
{
};
template< class Y, class T > struct sp_enable_if_convertible: public sp_enable_if_convertible_impl< sp_convertible< Y, T >::value >
{
};
} // namespace detail
} // namespace boost
#endif // !defined( BOOST_SP_NO_SP_CONVERTIBLE )
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED

View File

@ -0,0 +1,92 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// detail/sp_counted_base.hpp
//
// Copyright 2005-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)
//
#include <boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp>
#include <boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp>
#include <boost/config.hpp>
#if defined( BOOST_SP_DISABLE_THREADS )
# include <boost/smart_ptr/detail/sp_counted_base_nt.hpp>
#elif defined( BOOST_SP_USE_STD_ATOMIC )
# include <boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp>
#elif defined( BOOST_SP_USE_SPINLOCK )
# include <boost/smart_ptr/detail/sp_counted_base_spin.hpp>
#elif defined( BOOST_SP_USE_PTHREADS )
# include <boost/smart_ptr/detail/sp_counted_base_pt.hpp>
#elif defined( BOOST_DISABLE_THREADS ) && !defined( BOOST_SP_ENABLE_THREADS ) && !defined( BOOST_DISABLE_WIN32 )
# include <boost/smart_ptr/detail/sp_counted_base_nt.hpp>
#elif defined( BOOST_SP_HAS_GCC_INTRINSICS )
# include <boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp>
#elif !defined( BOOST_NO_CXX11_HDR_ATOMIC )
# include <boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp>
#elif defined( __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 )
# include <boost/smart_ptr/detail/sp_counted_base_sync.hpp>
#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) && !defined(__PATHSCALE__)
# include <boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp>
#elif defined( BOOST_SP_HAS_SYNC_INTRINSICS )
# include <boost/smart_ptr/detail/sp_counted_base_sync.hpp>
#elif defined( __SNC__ )
# include <boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp>
#elif defined(__HP_aCC) && defined(__ia64)
# include <boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp>
#elif defined( __GNUC__ ) && defined( __ia64__ ) && !defined( __INTEL_COMPILER ) && !defined(__PATHSCALE__)
# include <boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp>
#elif defined( __IBMCPP__ ) && defined( __powerpc )
# include <boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp>
#elif defined( __MWERKS__ ) && defined( __POWERPC__ )
# include <boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp>
#elif defined( __GNUC__ ) && ( defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc ) ) && !defined(__PATHSCALE__) && !defined( _AIX )
# include <boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp>
#elif defined( __GNUC__ ) && ( defined( __mips__ ) || defined( _mips ) ) && !defined(__PATHSCALE__) && !defined( __mips16 )
# include <boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp>
#elif defined(__GNUC__) && ( defined( __sparcv9 ) || ( defined( __sparcv8 ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 402 ) ) )
# include <boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp>
#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined(__CYGWIN__)
# include <boost/smart_ptr/detail/sp_counted_base_w32.hpp>
#elif defined( _AIX )
# include <boost/smart_ptr/detail/sp_counted_base_aix.hpp>
#elif !defined( BOOST_HAS_THREADS )
# include <boost/smart_ptr/detail/sp_counted_base_nt.hpp>
#else
# include <boost/smart_ptr/detail/sp_counted_base_spin.hpp>
#endif
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_HPP_INCLUDED

View File

@ -0,0 +1,163 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED
//
// detail/sp_counted_base_acc_ia64.hpp - aC++ on HP-UX IA64
//
// Copyright 2007 Baruch Zilber
// Copyright 2007 Boris Gubenko
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/smart_ptr/detail/sp_obsolete.hpp>
#include <boost/config.hpp>
#include <machine/sys/inline.h>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using HP aCC++/HP-UX/IA64 sp_counted_base")
#endif
BOOST_SP_OBSOLETE()
namespace boost
{
namespace detail
{
inline void atomic_increment( int * pw )
{
// ++*pw;
_Asm_fetchadd(_FASZ_W, _SEM_REL, pw, +1, _LDHINT_NONE);
}
inline int atomic_decrement( int * pw )
{
// return --*pw;
int r = static_cast<int>(_Asm_fetchadd(_FASZ_W, _SEM_REL, pw, -1, _LDHINT_NONE));
if (1 == r)
{
_Asm_mf();
}
return r - 1;
}
inline int atomic_conditional_increment( int * pw )
{
// if( *pw != 0 ) ++*pw;
// return *pw;
int v = *pw;
for (;;)
{
if (0 == v)
{
return 0;
}
_Asm_mov_to_ar(_AREG_CCV,
v,
(_UP_CALL_FENCE | _UP_SYS_FENCE | _DOWN_CALL_FENCE | _DOWN_SYS_FENCE));
int r = static_cast<int>(_Asm_cmpxchg(_SZ_W, _SEM_ACQ, pw, v + 1, _LDHINT_NONE));
if (r == v)
{
return r + 1;
}
v = r;
}
}
class BOOST_SYMBOL_VISIBLE sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
int use_count_; // #shared
int weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() // nothrow
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_untyped_deleter() = 0;
void add_ref_copy()
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() // nothrow
{
if( atomic_decrement( &use_count_ ) == 0 )
{
dispose();
weak_release();
}
}
void weak_add_ref() // nothrow
{
atomic_increment( &weak_count_ );
}
void weak_release() // nothrow
{
if( atomic_decrement( &weak_count_ ) == 0 )
{
destroy();
}
}
long use_count() const // nothrow
{
return static_cast<int const volatile &>( use_count_ ); // TODO use ld.acq here
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_ACC_IA64_HPP_INCLUDED

View File

@ -0,0 +1,152 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED
//
// detail/sp_counted_base_aix.hpp
// based on: detail/sp_counted_base_w32.hpp
//
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
// Copyright 2004-2005 Peter Dimov
// Copyright 2006 Michael van der Westhuizen
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
// formulation
//
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/config.hpp>
#include <builtins.h>
#include <sys/atomic_op.h>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using AIX sp_counted_base")
#endif
namespace boost
{
namespace detail
{
inline void atomic_increment( int32_t* pw )
{
// ++*pw;
fetch_and_add( pw, 1 );
}
inline int32_t atomic_decrement( int32_t * pw )
{
// return --*pw;
int32_t originalValue;
__lwsync();
originalValue = fetch_and_add( pw, -1 );
__isync();
return (originalValue - 1);
}
inline int32_t atomic_conditional_increment( int32_t * pw )
{
// if( *pw != 0 ) ++*pw;
// return *pw;
int32_t tmp = fetch_and_add( pw, 0 );
for( ;; )
{
if( tmp == 0 ) return 0;
if( compare_and_swap( pw, &tmp, tmp + 1 ) ) return (tmp + 1);
}
}
class BOOST_SYMBOL_VISIBLE sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
int32_t use_count_; // #shared
int32_t weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() // nothrow
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_untyped_deleter() = 0;
void add_ref_copy()
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() // nothrow
{
if( atomic_decrement( &use_count_ ) == 0 )
{
dispose();
weak_release();
}
}
void weak_add_ref() // nothrow
{
atomic_increment( &weak_count_ );
}
void weak_release() // nothrow
{
if( atomic_decrement( &weak_count_ ) == 0 )
{
destroy();
}
}
long use_count() const // nothrow
{
return fetch_and_add( const_cast<int32_t*>(&use_count_), 0 );
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED

View File

@ -0,0 +1,185 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// detail/sp_counted_base_cw_ppc.hpp - CodeWarrior on PowerPC
//
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
// Copyright 2004-2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
// formulation
//
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/smart_ptr/detail/sp_obsolete.hpp>
#include <boost/config.hpp>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using CodeWarrior/PowerPC sp_counted_base")
#endif
namespace boost
{
namespace detail
{
inline void atomic_increment( register long * pw )
{
register int a;
asm
{
loop:
lwarx a, 0, pw
addi a, a, 1
stwcx. a, 0, pw
bne- loop
}
}
inline long atomic_decrement( register long * pw )
{
register int a;
asm
{
#if defined(__PPCZen__) || defined(__PPCe500__) || defined(__PPCe500v2__)
msync
#else
sync
#endif
loop:
lwarx a, 0, pw
addi a, a, -1
stwcx. a, 0, pw
bne- loop
isync
}
return a;
}
inline long atomic_conditional_increment( register long * pw )
{
register int a;
asm
{
loop:
lwarx a, 0, pw
cmpwi a, 0
beq store
addi a, a, 1
store:
stwcx. a, 0, pw
bne- loop
}
return a;
}
class BOOST_SYMBOL_VISIBLE sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
long use_count_; // #shared
long weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() // nothrow
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_untyped_deleter() = 0;
void add_ref_copy()
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() // nothrow
{
if( atomic_decrement( &use_count_ ) == 0 )
{
dispose();
weak_release();
}
}
void weak_add_ref() // nothrow
{
atomic_increment( &weak_count_ );
}
void weak_release() // nothrow
{
if( atomic_decrement( &weak_count_ ) == 0 )
{
destroy();
}
}
long use_count() const // nothrow
{
return static_cast<long const volatile &>( use_count_ );
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED

View File

@ -0,0 +1,148 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_ATOMIC_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_ATOMIC_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// detail/sp_counted_base_gcc_atomic.hpp - g++ 4.7+ __atomic intrinsics
//
// Copyright 2007, 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using __atomic sp_counted_base")
#endif
namespace boost
{
namespace detail
{
inline void atomic_increment( boost::uint_least32_t * pw )
{
__atomic_fetch_add( pw, 1, __ATOMIC_RELAXED );
}
inline boost::uint_least32_t atomic_decrement( boost::uint_least32_t * pw )
{
return __atomic_fetch_sub( pw, 1, __ATOMIC_ACQ_REL );
}
inline boost::uint_least32_t atomic_conditional_increment( boost::uint_least32_t * pw )
{
// long r = *pw;
// if( r != 0 ) ++*pw;
// return r;
boost::uint_least32_t r = __atomic_load_n( pw, __ATOMIC_RELAXED );
for( ;; )
{
if( r == 0 )
{
return r;
}
if( __atomic_compare_exchange_n( pw, &r, r + 1, true, __ATOMIC_RELAXED, __ATOMIC_RELAXED ) )
{
return r;
}
}
}
inline boost::uint_least32_t atomic_load( boost::uint_least32_t const * pw )
{
return __atomic_load_n( pw, __ATOMIC_ACQUIRE );
}
class BOOST_SYMBOL_VISIBLE sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
boost::uint_least32_t use_count_; // #shared
boost::uint_least32_t weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() // nothrow
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_untyped_deleter() = 0;
void add_ref_copy()
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() // nothrow
{
if( atomic_decrement( &use_count_ ) == 1 )
{
dispose();
weak_release();
}
}
void weak_add_ref() // nothrow
{
atomic_increment( &weak_count_ );
}
void weak_release() // nothrow
{
if( atomic_decrement( &weak_count_ ) == 1 )
{
destroy();
}
}
long use_count() const // nothrow
{
return atomic_load( &use_count_ );
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED

View File

@ -0,0 +1,170 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED
//
// detail/sp_counted_base_gcc_ia64.hpp - g++ on IA64
//
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
// Copyright 2004-2006 Peter Dimov
// Copyright 2005 Ben Hutchings
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/smart_ptr/detail/sp_obsolete.hpp>
#include <boost/config.hpp>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using g++/IA64 sp_counted_base")
#endif
BOOST_SP_OBSOLETE()
namespace boost
{
namespace detail
{
inline void atomic_increment( int * pw )
{
// ++*pw;
int tmp;
// No barrier is required here but fetchadd always has an acquire or
// release barrier associated with it. We choose release as it should be
// cheaper.
__asm__ ("fetchadd4.rel %0=%1,1" :
"=r"(tmp), "=m"(*pw) :
"m"( *pw ));
}
inline int atomic_decrement( int * pw )
{
// return --*pw;
int rv;
__asm__ (" fetchadd4.rel %0=%1,-1 ;; \n"
" cmp.eq p7,p0=1,%0 ;; \n"
"(p7) ld4.acq %0=%1 " :
"=&r"(rv), "=m"(*pw) :
"m"( *pw ) :
"p7");
return rv;
}
inline int atomic_conditional_increment( int * pw )
{
// if( *pw != 0 ) ++*pw;
// return *pw;
int rv, tmp, tmp2;
__asm__ ("0: ld4 %0=%3 ;; \n"
" cmp.eq p7,p0=0,%0 ;; \n"
"(p7) br.cond.spnt 1f \n"
" mov ar.ccv=%0 \n"
" add %1=1,%0 ;; \n"
" cmpxchg4.acq %2=%3,%1,ar.ccv ;; \n"
" cmp.ne p7,p0=%0,%2 ;; \n"
"(p7) br.cond.spnt 0b \n"
" mov %0=%1 ;; \n"
"1:" :
"=&r"(rv), "=&r"(tmp), "=&r"(tmp2), "=m"(*pw) :
"m"( *pw ) :
"ar.ccv", "p7");
return rv;
}
class BOOST_SYMBOL_VISIBLE sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
int use_count_; // #shared
int weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() // nothrow
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_untyped_deleter() = 0;
void add_ref_copy()
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() // nothrow
{
if( atomic_decrement( &use_count_ ) == 0 )
{
dispose();
weak_release();
}
}
void weak_add_ref() // nothrow
{
atomic_increment( &weak_count_ );
}
void weak_release() // nothrow
{
if( atomic_decrement( &weak_count_ ) == 0 )
{
destroy();
}
}
long use_count() const // nothrow
{
return static_cast<int const volatile &>( use_count_ ); // TODO use ld.acq here
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED

View File

@ -0,0 +1,200 @@
#ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED
#define BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// detail/sp_counted_base_gcc_mips.hpp - g++ on MIPS
//
// Copyright (c) 2009, Spirent Communications, 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)
//
//
// Lock-free algorithm by Alexander Terekhov
//
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/smart_ptr/detail/sp_obsolete.hpp>
#include <boost/config.hpp>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using g++/MIPS sp_counted_base")
#endif
BOOST_SP_OBSOLETE()
namespace boost
{
namespace detail
{
inline void atomic_increment( int * pw )
{
// ++*pw;
int tmp;
__asm__ __volatile__
(
"0:\n\t"
".set push\n\t"
#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6)
".set mips2\n\t"
#endif
"ll %0, %1\n\t"
"addiu %0, 1\n\t"
"sc %0, %1\n\t"
".set pop\n\t"
"beqz %0, 0b":
"=&r"( tmp ), "=m"( *pw ):
"m"( *pw )
);
}
inline int atomic_decrement( int * pw )
{
// return --*pw;
int rv, tmp;
__asm__ __volatile__
(
"0:\n\t"
".set push\n\t"
#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6)
".set mips2\n\t"
#endif
"ll %1, %2\n\t"
"addiu %0, %1, -1\n\t"
"sc %0, %2\n\t"
".set pop\n\t"
"beqz %0, 0b\n\t"
"addiu %0, %1, -1":
"=&r"( rv ), "=&r"( tmp ), "=m"( *pw ):
"m"( *pw ):
"memory"
);
return rv;
}
inline int atomic_conditional_increment( int * pw )
{
// if( *pw != 0 ) ++*pw;
// return *pw;
int rv, tmp;
__asm__ __volatile__
(
"0:\n\t"
".set push\n\t"
#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6)
".set mips2\n\t"
#endif
"ll %0, %2\n\t"
"beqz %0, 1f\n\t"
"addiu %1, %0, 1\n\t"
"sc %1, %2\n\t"
".set pop\n\t"
"beqz %1, 0b\n\t"
"addiu %0, %0, 1\n\t"
"1:":
"=&r"( rv ), "=&r"( tmp ), "=m"( *pw ):
"m"( *pw ):
"memory"
);
return rv;
}
class BOOST_SYMBOL_VISIBLE sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
int use_count_; // #shared
int weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() // nothrow
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_untyped_deleter() = 0;
void add_ref_copy()
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() // nothrow
{
if( atomic_decrement( &use_count_ ) == 0 )
{
dispose();
weak_release();
}
}
void weak_add_ref() // nothrow
{
atomic_increment( &weak_count_ );
}
void weak_release() // nothrow
{
if( atomic_decrement( &weak_count_ ) == 0 )
{
destroy();
}
}
long use_count() const // nothrow
{
return static_cast<int const volatile &>( use_count_ );
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED

View File

@ -0,0 +1,194 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// detail/sp_counted_base_gcc_ppc.hpp - g++ on PowerPC
//
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
// Copyright 2004-2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
// formulation
//
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/smart_ptr/detail/sp_obsolete.hpp>
#include <boost/config.hpp>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using g++/PowerPC sp_counted_base")
#endif
BOOST_SP_OBSOLETE()
namespace boost
{
namespace detail
{
inline void atomic_increment( int * pw )
{
// ++*pw;
int tmp;
__asm__
(
"0:\n\t"
"lwarx %1, 0, %2\n\t"
"addi %1, %1, 1\n\t"
"stwcx. %1, 0, %2\n\t"
"bne- 0b":
"=m"( *pw ), "=&b"( tmp ):
"r"( pw ), "m"( *pw ):
"cc"
);
}
inline int atomic_decrement( int * pw )
{
// return --*pw;
int rv;
__asm__ __volatile__
(
"sync\n\t"
"0:\n\t"
"lwarx %1, 0, %2\n\t"
"addi %1, %1, -1\n\t"
"stwcx. %1, 0, %2\n\t"
"bne- 0b\n\t"
"isync":
"=m"( *pw ), "=&b"( rv ):
"r"( pw ), "m"( *pw ):
"memory", "cc"
);
return rv;
}
inline int atomic_conditional_increment( int * pw )
{
// if( *pw != 0 ) ++*pw;
// return *pw;
int rv;
__asm__
(
"0:\n\t"
"lwarx %1, 0, %2\n\t"
"cmpwi %1, 0\n\t"
"beq 1f\n\t"
"addi %1, %1, 1\n\t"
"1:\n\t"
"stwcx. %1, 0, %2\n\t"
"bne- 0b":
"=m"( *pw ), "=&b"( rv ):
"r"( pw ), "m"( *pw ):
"cc"
);
return rv;
}
class BOOST_SYMBOL_VISIBLE sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
int use_count_; // #shared
int weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() // nothrow
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_untyped_deleter() = 0;
void add_ref_copy()
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() // nothrow
{
if( atomic_decrement( &use_count_ ) == 0 )
{
dispose();
weak_release();
}
}
void weak_add_ref() // nothrow
{
atomic_increment( &weak_count_ );
}
void weak_release() // nothrow
{
if( atomic_decrement( &weak_count_ ) == 0 )
{
destroy();
}
}
long use_count() const // nothrow
{
return static_cast<int const volatile &>( use_count_ );
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED

View File

@ -0,0 +1,179 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// detail/sp_counted_base_gcc_sparc.hpp - g++ on Sparc V8+
//
// Copyright (c) 2006 Piotr Wyderski
// Copyright (c) 2006 Tomas Puverle
// Copyright (c) 2006 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
//
// Thanks to Michael van der Westhuizen
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/smart_ptr/detail/sp_obsolete.hpp>
#include <boost/config.hpp>
#include <inttypes.h> // int32_t
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using g++/Sparc sp_counted_base")
#endif
BOOST_SP_OBSOLETE()
namespace boost
{
namespace detail
{
inline int32_t compare_and_swap( int32_t * dest_, int32_t compare_, int32_t swap_ )
{
__asm__ __volatile__( "cas [%1], %2, %0"
: "+r" (swap_)
: "r" (dest_), "r" (compare_)
: "memory" );
return swap_;
}
inline int32_t atomic_fetch_and_add( int32_t * pw, int32_t dv )
{
// long r = *pw;
// *pw += dv;
// return r;
for( ;; )
{
int32_t r = *pw;
if( __builtin_expect((compare_and_swap(pw, r, r + dv) == r), 1) )
{
return r;
}
}
}
inline void atomic_increment( int32_t * pw )
{
atomic_fetch_and_add( pw, 1 );
}
inline int32_t atomic_decrement( int32_t * pw )
{
return atomic_fetch_and_add( pw, -1 );
}
inline int32_t atomic_conditional_increment( int32_t * pw )
{
// long r = *pw;
// if( r != 0 ) ++*pw;
// return r;
for( ;; )
{
int32_t r = *pw;
if( r == 0 )
{
return r;
}
if( __builtin_expect( ( compare_and_swap( pw, r, r + 1 ) == r ), 1 ) )
{
return r;
}
}
}
class BOOST_SYMBOL_VISIBLE sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
int32_t use_count_; // #shared
int32_t weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() // nothrow
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_untyped_deleter() = 0;
void add_ref_copy()
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() // nothrow
{
if( atomic_decrement( &use_count_ ) == 1 )
{
dispose();
weak_release();
}
}
void weak_add_ref() // nothrow
{
atomic_increment( &weak_count_ );
}
void weak_release() // nothrow
{
if( atomic_decrement( &weak_count_ ) == 1 )
{
destroy();
}
}
long use_count() const // nothrow
{
return const_cast< int32_t const volatile & >( use_count_ );
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_HPP_INCLUDED

View File

@ -0,0 +1,186 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// detail/sp_counted_base_gcc_x86.hpp - g++ on 486+ or AMD64
//
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
// Copyright 2004-2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// Lock-free algorithm by Alexander Terekhov
//
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
// formulation
//
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/smart_ptr/detail/sp_obsolete.hpp>
#include <boost/config.hpp>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using g++/x86 sp_counted_base")
#endif
BOOST_SP_OBSOLETE()
namespace boost
{
namespace detail
{
inline int atomic_exchange_and_add( int * pw, int dv )
{
// int r = *pw;
// *pw += dv;
// return r;
int r;
__asm__ __volatile__
(
"lock\n\t"
"xadd %1, %0":
"=m"( *pw ), "=r"( r ): // outputs (%0, %1)
"m"( *pw ), "1"( dv ): // inputs (%2, %3 == %1)
"memory", "cc" // clobbers
);
return r;
}
inline void atomic_increment( int * pw )
{
//atomic_exchange_and_add( pw, 1 );
__asm__
(
"lock\n\t"
"incl %0":
"=m"( *pw ): // output (%0)
"m"( *pw ): // input (%1)
"cc" // clobbers
);
}
inline int atomic_conditional_increment( int * pw )
{
// int rv = *pw;
// if( rv != 0 ) ++*pw;
// return rv;
int rv, tmp;
__asm__
(
"movl %0, %%eax\n\t"
"0:\n\t"
"test %%eax, %%eax\n\t"
"je 1f\n\t"
"movl %%eax, %2\n\t"
"incl %2\n\t"
"lock\n\t"
"cmpxchgl %2, %0\n\t"
"jne 0b\n\t"
"1:":
"=m"( *pw ), "=&a"( rv ), "=&r"( tmp ): // outputs (%0, %1, %2)
"m"( *pw ): // input (%3)
"cc" // clobbers
);
return rv;
}
class BOOST_SYMBOL_VISIBLE sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
int use_count_; // #shared
int weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() // nothrow
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
virtual void * get_untyped_deleter() = 0;
void add_ref_copy()
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() // nothrow
{
if( atomic_exchange_and_add( &use_count_, -1 ) == 1 )
{
dispose();
weak_release();
}
}
void weak_add_ref() // nothrow
{
atomic_increment( &weak_count_ );
}
void weak_release() // nothrow
{
if( atomic_exchange_and_add( &weak_count_, -1 ) == 1 )
{
destroy();
}
}
long use_count() const // nothrow
{
return static_cast<int const volatile &>( use_count_ );
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED

View File

@ -0,0 +1,119 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// detail/sp_counted_base_nt.hpp
//
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
// Copyright 2004-2005 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE("Using single-threaded, non-atomic sp_counted_base")
#endif
namespace boost
{
namespace detail
{
class BOOST_SYMBOL_VISIBLE sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
boost::int_least32_t use_count_; // #shared
boost::int_least32_t weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base() BOOST_SP_NOEXCEPT: use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() /*BOOST_SP_NOEXCEPT*/
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() BOOST_SP_NOEXCEPT = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() BOOST_SP_NOEXCEPT // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT = 0;
virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT = 0;
void add_ref_copy() BOOST_SP_NOEXCEPT
{
++use_count_;
}
bool add_ref_lock() BOOST_SP_NOEXCEPT // true on success
{
if( use_count_ == 0 ) return false;
++use_count_;
return true;
}
void release() BOOST_SP_NOEXCEPT
{
if( --use_count_ == 0 )
{
dispose();
weak_release();
}
}
void weak_add_ref() BOOST_SP_NOEXCEPT
{
++weak_count_;
}
void weak_release() BOOST_SP_NOEXCEPT
{
if( --weak_count_ == 0 )
{
destroy();
}
}
long use_count() const BOOST_SP_NOEXCEPT
{
return use_count_;
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED

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