mirror of
				https://github.com/boostorg/smart_ptr.git
				synced 2025-11-04 01:31:51 +01:00 
			
		
		
		
	Compare commits
	
		
			39 Commits
		
	
	
		
			feature/de
			...
			feature/pe
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					02cc561248 | ||
| 
						 | 
					066b398114 | ||
| 
						 | 
					9c43c69c14 | ||
| 
						 | 
					eb8998cd91 | ||
| 
						 | 
					0ddfab493c | ||
| 
						 | 
					a2732e207a | ||
| 
						 | 
					5be7523ebe | ||
| 
						 | 
					2320dafc03 | ||
| 
						 | 
					7ab4093f46 | ||
| 
						 | 
					296c203135 | ||
| 
						 | 
					2dd35e5fbc | ||
| 
						 | 
					977544feda | ||
| 
						 | 
					54b5498208 | ||
| 
						 | 
					da81452f1f | ||
| 
						 | 
					7b9a969215 | ||
| 
						 | 
					91cd83e5bf | ||
| 
						 | 
					2fdb8c4b0a | ||
| 
						 | 
					e806b53433 | ||
| 
						 | 
					e0c7bd9a7e | ||
| 
						 | 
					766ab05a12 | ||
| 
						 | 
					05cbefd28e | ||
| 
						 | 
					bfbdf4f45f | ||
| 
						 | 
					169c0cd52a | ||
| 
						 | 
					7d70691a16 | ||
| 
						 | 
					90c27d7cfa | ||
| 
						 | 
					43d1fe12c5 | ||
| 
						 | 
					a2749dddb4 | ||
| 
						 | 
					a71e62146c | ||
| 
						 | 
					274ec17836 | ||
| 
						 | 
					a7341070f1 | ||
| 
						 | 
					a6323354cd | ||
| 
						 | 
					f788448101 | ||
| 
						 | 
					283f2d2a11 | ||
| 
						 | 
					034f94617d | ||
| 
						 | 
					6a5f67b3a2 | ||
| 
						 | 
					dcd3c8ef80 | ||
| 
						 | 
					bb2a453ff6 | ||
| 
						 | 
					e56eec70ca | ||
| 
						 | 
					60c26acab8 | 
							
								
								
									
										105
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										105
									
								
								.travis.yml
									
									
									
									
									
								
							@@ -1,12 +1,10 @@
 | 
			
		||||
# Copyright 2016-2019 Peter Dimov
 | 
			
		||||
# 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
 | 
			
		||||
 | 
			
		||||
sudo: false
 | 
			
		||||
 | 
			
		||||
dist: trusty
 | 
			
		||||
dist: xenial
 | 
			
		||||
 | 
			
		||||
branches:
 | 
			
		||||
  only:
 | 
			
		||||
@@ -25,8 +23,19 @@ matrix:
 | 
			
		||||
 | 
			
		||||
  include:
 | 
			
		||||
    - os: linux
 | 
			
		||||
      arch: arm64
 | 
			
		||||
      compiler: g++
 | 
			
		||||
      env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
 | 
			
		||||
      env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      arch: ppc64le
 | 
			
		||||
      compiler: g++
 | 
			
		||||
      env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      arch: s390x
 | 
			
		||||
      compiler: g++
 | 
			
		||||
      env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: g++-4.4
 | 
			
		||||
@@ -158,10 +167,7 @@ matrix:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++
 | 
			
		||||
      env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      dist: trusty
 | 
			
		||||
      compiler: /usr/bin/clang++
 | 
			
		||||
      env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
 | 
			
		||||
      addons:
 | 
			
		||||
@@ -170,6 +176,7 @@ matrix:
 | 
			
		||||
            - clang-3.3
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      dist: trusty
 | 
			
		||||
      compiler: /usr/bin/clang++
 | 
			
		||||
      env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
 | 
			
		||||
      addons:
 | 
			
		||||
@@ -179,15 +186,13 @@ matrix:
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-3.5
 | 
			
		||||
      env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
 | 
			
		||||
      env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11
 | 
			
		||||
      addons:
 | 
			
		||||
        apt:
 | 
			
		||||
          packages:
 | 
			
		||||
            - clang-3.5
 | 
			
		||||
            - libstdc++-4.9-dev
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-precise-3.5
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-3.6
 | 
			
		||||
@@ -198,7 +203,6 @@ matrix:
 | 
			
		||||
            - clang-3.6
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-precise-3.6
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-3.7
 | 
			
		||||
@@ -209,7 +213,6 @@ matrix:
 | 
			
		||||
            - clang-3.7
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-precise-3.7
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-3.8
 | 
			
		||||
@@ -218,10 +221,8 @@ matrix:
 | 
			
		||||
        apt:
 | 
			
		||||
          packages:
 | 
			
		||||
            - clang-3.8
 | 
			
		||||
            - libstdc++-4.9-dev
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-precise-3.8
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-3.9
 | 
			
		||||
@@ -230,10 +231,8 @@ matrix:
 | 
			
		||||
        apt:
 | 
			
		||||
          packages:
 | 
			
		||||
            - clang-3.9
 | 
			
		||||
            - libstdc++-4.9-dev
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-precise-3.9
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-4.0
 | 
			
		||||
@@ -244,7 +243,6 @@ matrix:
 | 
			
		||||
            - clang-4.0
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-trusty-4.0
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-5.0
 | 
			
		||||
@@ -255,7 +253,6 @@ matrix:
 | 
			
		||||
            - clang-5.0
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-trusty-5.0
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-6.0
 | 
			
		||||
@@ -266,7 +263,6 @@ matrix:
 | 
			
		||||
            - clang-6.0
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-trusty-6.0
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-7
 | 
			
		||||
@@ -277,7 +273,7 @@ matrix:
 | 
			
		||||
            - clang-7
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-trusty-7
 | 
			
		||||
            - llvm-toolchain-xenial-7
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-8
 | 
			
		||||
@@ -288,21 +284,47 @@ matrix:
 | 
			
		||||
            - clang-8
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-trusty-8
 | 
			
		||||
            - llvm-toolchain-xenial-8
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-7
 | 
			
		||||
      env: UBSAN=1 TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
 | 
			
		||||
      dist: xenial
 | 
			
		||||
      compiler: clang++-9
 | 
			
		||||
      env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
 | 
			
		||||
      addons:
 | 
			
		||||
        apt:
 | 
			
		||||
          packages:
 | 
			
		||||
            - clang-7
 | 
			
		||||
            - libstdc++-5-dev
 | 
			
		||||
            - clang-9
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-trusty-7
 | 
			
		||||
            - sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
 | 
			
		||||
              key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      dist: xenial
 | 
			
		||||
      compiler: clang++-10
 | 
			
		||||
      env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a
 | 
			
		||||
      addons:
 | 
			
		||||
        apt:
 | 
			
		||||
          packages:
 | 
			
		||||
            - clang-10
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
 | 
			
		||||
              key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: clang++-8
 | 
			
		||||
      env: UBSAN=1 TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
 | 
			
		||||
      addons:
 | 
			
		||||
        apt:
 | 
			
		||||
          packages:
 | 
			
		||||
            - clang-8
 | 
			
		||||
          sources:
 | 
			
		||||
            - ubuntu-toolchain-r-test
 | 
			
		||||
            - llvm-toolchain-xenial-8
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      dist: trusty
 | 
			
		||||
      compiler: clang++-libc++
 | 
			
		||||
      env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
 | 
			
		||||
      addons:
 | 
			
		||||
@@ -311,6 +333,7 @@ matrix:
 | 
			
		||||
            - libc++-dev
 | 
			
		||||
 | 
			
		||||
    - 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:
 | 
			
		||||
@@ -322,6 +345,17 @@ matrix:
 | 
			
		||||
      compiler: clang++
 | 
			
		||||
      env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
 | 
			
		||||
 | 
			
		||||
    - 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 ..
 | 
			
		||||
        - ctest --output-on-failure -R boost_smart_ptr
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      compiler: g++
 | 
			
		||||
      env: CMAKE_SUBDIR_TEST=1
 | 
			
		||||
@@ -331,6 +365,17 @@ matrix:
 | 
			
		||||
      - cmake --build .
 | 
			
		||||
      - cmake --build . --target check
 | 
			
		||||
 | 
			
		||||
    - os: linux
 | 
			
		||||
      env: CMAKE_INSTALL_TEST=1
 | 
			
		||||
      script:
 | 
			
		||||
        - 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 ..
 | 
			
		||||
@@ -352,7 +397,9 @@ install:
 | 
			
		||||
  - git submodule init tools/build
 | 
			
		||||
  - git submodule init libs/headers
 | 
			
		||||
  - git submodule init tools/boost_install
 | 
			
		||||
  - git submodule update --jobs 3
 | 
			
		||||
  - git submodule init tools/cmake
 | 
			
		||||
  - git submodule init libs/preprocessor
 | 
			
		||||
  - git submodule update # no --jobs 3 on non-amd64
 | 
			
		||||
  - cp -r $TRAVIS_BUILD_DIR/* libs/smart_ptr
 | 
			
		||||
  - ./bootstrap.sh
 | 
			
		||||
  - ./b2 headers
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,10 @@
 | 
			
		||||
# Copyright 2018 Mike Dev
 | 
			
		||||
# 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
 | 
			
		||||
 | 
			
		||||
# Partial (add_subdirectory only) and experimental CMake support
 | 
			
		||||
# Subject to change; please do not rely on the contents of this file yet
 | 
			
		||||
cmake_minimum_required(VERSION 3.5...3.16)
 | 
			
		||||
 | 
			
		||||
cmake_minimum_required(VERSION 3.5)
 | 
			
		||||
project(BoostSmartPtr LANGUAGES CXX)
 | 
			
		||||
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)
 | 
			
		||||
@@ -14,13 +12,25 @@ 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::predef
 | 
			
		||||
        Boost::static_assert
 | 
			
		||||
        Boost::throw_exception
 | 
			
		||||
        Boost::type_traits
 | 
			
		||||
  INTERFACE
 | 
			
		||||
    Boost::assert
 | 
			
		||||
    Boost::config
 | 
			
		||||
    Boost::core
 | 
			
		||||
    Boost::move
 | 
			
		||||
    Boost::static_assert
 | 
			
		||||
    Boost::throw_exception
 | 
			
		||||
    Boost::type_traits
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
if(BOOST_SUPERPROJECT_VERSION)
 | 
			
		||||
 | 
			
		||||
  include(BoostInstall)
 | 
			
		||||
  boost_install(TARGETS boost_smart_ptr HEADER_DIRECTORY include/)
 | 
			
		||||
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
if(BUILD_TESTING)
 | 
			
		||||
 | 
			
		||||
  add_subdirectory(test)
 | 
			
		||||
 | 
			
		||||
endif()
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								appveyor.yml
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								appveyor.yml
									
									
									
									
									
								
							@@ -20,7 +20,15 @@ environment:
 | 
			
		||||
      TOOLSET: msvc-12.0,msvc-14.0
 | 
			
		||||
      ADDRMD: 32,64
 | 
			
		||||
    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
 | 
			
		||||
      TOOLSET: msvc-14.1,clang-win
 | 
			
		||||
      TOOLSET: msvc-14.1
 | 
			
		||||
      CXXSTD: 14,17
 | 
			
		||||
      ADDRMD: 32,64
 | 
			
		||||
    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
 | 
			
		||||
      TOOLSET: clang-win
 | 
			
		||||
      CXXSTD: 14,17
 | 
			
		||||
      ADDRMD: 64
 | 
			
		||||
    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
 | 
			
		||||
      TOOLSET: msvc-14.2
 | 
			
		||||
      CXXSTD: 14,17
 | 
			
		||||
      ADDRMD: 32,64
 | 
			
		||||
    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
 | 
			
		||||
 
 | 
			
		||||
@@ -37,6 +37,8 @@ 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[]
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										318
									
								
								doc/smart_ptr/allocate_unique.adoc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										318
									
								
								doc/smart_ptr/allocate_unique.adoc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,318 @@
 | 
			
		||||
////
 | 
			
		||||
Copyright 2019 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);
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## 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);`
 | 
			
		||||
 | 
			
		||||
## 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.
 | 
			
		||||
@@ -13,6 +13,10 @@ http://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
:toc-title:
 | 
			
		||||
:idprefix: changelog_
 | 
			
		||||
 | 
			
		||||
## Changes in 1.72.0
 | 
			
		||||
 | 
			
		||||
* Added `allocate_unique`
 | 
			
		||||
 | 
			
		||||
## Changes in 1.71.0
 | 
			
		||||
 | 
			
		||||
* Added aliasing constructors to `weak_ptr`
 | 
			
		||||
 
 | 
			
		||||
@@ -111,3 +111,7 @@ Glen Fernandes rewrote `allocate_shared` and `make_shared` for arrays for a more
 | 
			
		||||
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.
 | 
			
		||||
 
 | 
			
		||||
@@ -41,6 +41,7 @@ In addition, the library contains the following supporting utility functions and
 | 
			
		||||
 | 
			
		||||
* `<<make_shared,make_shared>>`, a factory function for creating objects that returns 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`;
 | 
			
		||||
* `<<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;
 | 
			
		||||
 
 | 
			
		||||
@@ -27,25 +27,25 @@ are analogous to `make_shared` and `allocate_shared` for `shared_ptr`.
 | 
			
		||||
[subs=+quotes]
 | 
			
		||||
```
 | 
			
		||||
namespace boost {
 | 
			
		||||
  `// only if T is not an array type`
 | 
			
		||||
  `// 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);
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[]`
 | 
			
		||||
  `// 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);
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[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);
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[]`
 | 
			
		||||
  `// 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);
 | 
			
		||||
@@ -53,20 +53,20 @@ namespace boost {
 | 
			
		||||
    local_shared_ptr<T> allocate_local_shared(const A& a, std::size_t n,
 | 
			
		||||
      const remove_extent_t<T>& v);
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[N]`
 | 
			
		||||
  `// 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);
 | 
			
		||||
 | 
			
		||||
  `// only if T is not an array type of the form U[]`
 | 
			
		||||
  `// 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);
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[N]`
 | 
			
		||||
  `// 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>
 | 
			
		||||
 
 | 
			
		||||
@@ -55,43 +55,43 @@ types.
 | 
			
		||||
[subs=+quotes]
 | 
			
		||||
```
 | 
			
		||||
namespace boost {
 | 
			
		||||
  `// only if T is not an array type`
 | 
			
		||||
  `// 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);
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[]`
 | 
			
		||||
  `// 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);
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[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);
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[]`
 | 
			
		||||
  `// 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);
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[N]`
 | 
			
		||||
  `// 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);
 | 
			
		||||
 | 
			
		||||
  `// only if T is not an array type of the form U[]`
 | 
			
		||||
  `// 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);
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[N]`
 | 
			
		||||
  `// 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>
 | 
			
		||||
@@ -144,7 +144,7 @@ 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 rebound copy `a` such that its `value_type` is `U`.
 | 
			
		||||
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
 | 
			
		||||
@@ -158,7 +158,7 @@ storage suitable to hold an object of type `U`.
 | 
			
		||||
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 rebound copy of `a` such that its value_type is `U`.
 | 
			
		||||
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
 | 
			
		||||
@@ -181,8 +181,7 @@ template<class T, class A, class... Args>
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is not an array type.
 | 
			
		||||
Constraints:: `T` is not an array.
 | 
			
		||||
Returns:: A `shared_ptr` to an object of type `T`, constructed from
 | 
			
		||||
`args\...`.
 | 
			
		||||
Examples::
 | 
			
		||||
@@ -200,10 +199,9 @@ template<class T, class A>
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is an array type of the form `U[]`.
 | 
			
		||||
Constraints:: `T` is an array of unknown bounds.
 | 
			
		||||
Returns:: A `shared_ptr` to a sequence of `n` value-initialized objects of
 | 
			
		||||
type `U`.
 | 
			
		||||
type `remove_extent_t<T>`.
 | 
			
		||||
Examples::
 | 
			
		||||
* `auto p = make_shared<double[]>(1024);`
 | 
			
		||||
* `auto p = make_shared<double[][2][2]>(6);`
 | 
			
		||||
@@ -219,10 +217,9 @@ template<class T, class A>
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is an array type of the form `U[N]`.
 | 
			
		||||
Returns:: A `shared_ptr` to a sequence of `N` value-initialized objects of
 | 
			
		||||
type `U`.
 | 
			
		||||
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]>();`
 | 
			
		||||
@@ -238,10 +235,9 @@ template<class T, class A> shared_ptr<T>
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is an array type of the form `U[]`.
 | 
			
		||||
Returns:: A `shared_ptr` to a sequence of `n` objects of type `U`, each
 | 
			
		||||
initialized to `v`.
 | 
			
		||||
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});`
 | 
			
		||||
@@ -258,10 +254,9 @@ template<class T, class A>
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is an array type of the form `U[N]`.
 | 
			
		||||
Returns:: A `shared_ptr` to a sequence of `N` objects of type `U`, each
 | 
			
		||||
initialized to `v`.
 | 
			
		||||
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});`
 | 
			
		||||
@@ -278,10 +273,10 @@ template<class T, class A>
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is not an array type, or an array type of the `U[N]`.
 | 
			
		||||
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 `N` default-initialized objects of type `U`, respectively.
 | 
			
		||||
sequence of `extent_v<T>` default-initialized objects of type
 | 
			
		||||
`remove_extent_t<T>`, respectively.
 | 
			
		||||
Example:: `auto p = make_shared_noinit<double[1024]>();`
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
@@ -295,8 +290,7 @@ template<class T, class A>
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is an array type of the form `U[]`.
 | 
			
		||||
Constraints:: `T` is an array of unknown bounds.
 | 
			
		||||
Returns:: A `shared_ptr` to a sequence of `_n_` default-initialized objects
 | 
			
		||||
of type `U`.
 | 
			
		||||
of type `remove_extent_t<T>`.
 | 
			
		||||
Example:: `auto p = make_shared_noinit<double[]>(1024);`
 | 
			
		||||
 
 | 
			
		||||
@@ -40,23 +40,23 @@ feature with `std::make_unique`.
 | 
			
		||||
[subs=+quotes]
 | 
			
		||||
```
 | 
			
		||||
namespace boost {
 | 
			
		||||
  `// only if T is not an array type`
 | 
			
		||||
  `// T is not an array`
 | 
			
		||||
  template<class T, class... Args>
 | 
			
		||||
    std::unique_ptr<T> make_unique(Args&&... args);
 | 
			
		||||
 | 
			
		||||
  `// only if T is not an array type`
 | 
			
		||||
  `// T is not an array`
 | 
			
		||||
  template<class T>
 | 
			
		||||
    std::unique_ptr<T> make_unique(remove_reference_t<T>&& v);
 | 
			
		||||
    std::unique_ptr<T> make_unique(type_identity_t<T>&& v);
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[]`
 | 
			
		||||
  `// T is an array of unknown bounds`
 | 
			
		||||
  template<class T>
 | 
			
		||||
    std::unique_ptr<T> make_unique(std::size_t n);
 | 
			
		||||
 | 
			
		||||
  `// only if T is not an array type`
 | 
			
		||||
  `// T is not an array`
 | 
			
		||||
  template<class T>
 | 
			
		||||
    std::unique_ptr<T> make_unique_noinit();
 | 
			
		||||
 | 
			
		||||
  `// only if T is an array type of the form U[]`
 | 
			
		||||
  `// T is an array of unknown bounds`
 | 
			
		||||
  template<class T>
 | 
			
		||||
    std::unique_ptr<T> make_unique_noinit(std::size_t n);
 | 
			
		||||
}
 | 
			
		||||
@@ -71,20 +71,18 @@ template<class T, class... Args>
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is not an array type.
 | 
			
		||||
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(remove_reference_t<T>&& v);
 | 
			
		||||
  std::unique_ptr<T> make_unique(type_identity_t<T>&& v);
 | 
			
		||||
```
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is not an array type.
 | 
			
		||||
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});`
 | 
			
		||||
 | 
			
		||||
@@ -95,9 +93,8 @@ template<class T>
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is an array type of the form `U[]`.
 | 
			
		||||
Returns:: `std::unique_ptr<U[]>(new U[n]())`.
 | 
			
		||||
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);`
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
@@ -107,10 +104,9 @@ template<class T>
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is not an array type.
 | 
			
		||||
Constraints:: `T` is not an array.
 | 
			
		||||
Returns:: `std::unique_ptr<T>(new T)`.
 | 
			
		||||
Example:: `auto p = make_unique_noinit<double[1024]>();`
 | 
			
		||||
Example:: `auto p = make_unique_noinit<std::array<double, 1024> >();`
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
template<class T>
 | 
			
		||||
@@ -119,7 +115,6 @@ template<class T>
 | 
			
		||||
[none]
 | 
			
		||||
* {blank}
 | 
			
		||||
+
 | 
			
		||||
Remarks:: These overloads shall only participate in overload resolution when
 | 
			
		||||
`T` is an array type of the form `U[]`.
 | 
			
		||||
Returns:: `std::unique_ptr<U[]>(new U[n])`.
 | 
			
		||||
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);`
 | 
			
		||||
 
 | 
			
		||||
@@ -21,11 +21,12 @@ public:
 | 
			
		||||
        count_ = shared_count(base);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void local_cb_destroy() BOOST_SP_NOEXCEPT {
 | 
			
		||||
    void local_cb_destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
 | 
			
		||||
        shared_count().swap(count_);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT {
 | 
			
		||||
    shared_count local_cb_get_shared_count() const
 | 
			
		||||
        BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
 | 
			
		||||
        return count_;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -206,28 +206,29 @@ public:
 | 
			
		||||
        return state_;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void dispose() BOOST_SP_NOEXCEPT {
 | 
			
		||||
    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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void destroy() BOOST_SP_NOEXCEPT {
 | 
			
		||||
    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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void* get_deleter(const sp_typeinfo_&) BOOST_SP_NOEXCEPT {
 | 
			
		||||
    void* get_deleter(const sp_typeinfo_&) BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void* get_local_deleter(const sp_typeinfo_&) BOOST_SP_NOEXCEPT {
 | 
			
		||||
    void* get_local_deleter(const sp_typeinfo_&)
 | 
			
		||||
        BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void* get_untyped_deleter() BOOST_SP_NOEXCEPT {
 | 
			
		||||
    void* get_untyped_deleter() BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										505
									
								
								include/boost/smart_ptr/allocate_unique.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										505
									
								
								include/boost/smart_ptr/allocate_unique.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,505 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 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_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/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;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
 | 
			
		||||
template<class A, class T>
 | 
			
		||||
struct sp_alloc_to {
 | 
			
		||||
    typedef typename std::allocator_traits<A>::template rebind_alloc<T> type;
 | 
			
		||||
};
 | 
			
		||||
#else
 | 
			
		||||
template<class A, class T>
 | 
			
		||||
struct sp_alloc_to {
 | 
			
		||||
    typedef typename A::template rebind<T>::other type;
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
 | 
			
		||||
template<class A>
 | 
			
		||||
struct sp_alloc_type {
 | 
			
		||||
    typedef typename std::allocator_traits<A>::pointer type;
 | 
			
		||||
};
 | 
			
		||||
#else
 | 
			
		||||
template<class A>
 | 
			
		||||
struct sp_alloc_type {
 | 
			
		||||
    typedef typename A::pointer type;
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
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 sp_alloc_type<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 sp_alloc_type<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 detail::sp_alloc_to<A,
 | 
			
		||||
        typename detail::sp_alloc_value<T>::type>::type> {
 | 
			
		||||
    typedef typename detail::sp_alloc_to<A,
 | 
			
		||||
        typename detail::sp_alloc_value<T>::type>::type allocator;
 | 
			
		||||
    typedef empty_value<allocator> base;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    typedef detail::sp_alloc_ptr<T,
 | 
			
		||||
        typename detail::sp_alloc_type<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 sp_alloc_to<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 sp_alloc_type<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();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} /* boost */
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@@ -47,7 +47,7 @@ class bad_weak_ptr: public std::exception
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
    virtual char const * what() const BOOST_NOEXCEPT_OR_NOTHROW
 | 
			
		||||
    virtual char const * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        return "tr1::bad_weak_ptr";
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -28,15 +28,12 @@
 | 
			
		||||
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
 | 
			
		||||
#if !defined(BOOST_HAS_THREADS)
 | 
			
		||||
#  include <boost/smart_ptr/detail/lwm_nop.hpp>
 | 
			
		||||
#elif defined(BOOST_HAS_PTHREADS)
 | 
			
		||||
#  include <boost/smart_ptr/detail/lwm_pthreads.hpp>
 | 
			
		||||
#elif defined(BOOST_HAS_WINTHREADS) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
 | 
			
		||||
#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
 | 
			
		||||
// Use #define BOOST_DISABLE_THREADS to avoid the error
 | 
			
		||||
#  error Unrecognized threading platform
 | 
			
		||||
#  include <boost/smart_ptr/detail/lwm_pthreads.hpp>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
 | 
			
		||||
 
 | 
			
		||||
@@ -113,12 +113,12 @@ public:
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    virtual void local_cb_destroy() BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual void local_cb_destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        delete this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        return pn_;
 | 
			
		||||
    }
 | 
			
		||||
@@ -130,12 +130,12 @@ public:
 | 
			
		||||
 | 
			
		||||
    shared_count pn_;
 | 
			
		||||
 | 
			
		||||
    virtual void local_cb_destroy() BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual void local_cb_destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        shared_count().swap( pn_ );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        return pn_;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
#ifndef BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED
 | 
			
		||||
#define BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED
 | 
			
		||||
 | 
			
		||||
// MS compatible compilers support #pragma once
 | 
			
		||||
 | 
			
		||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
 | 
			
		||||
# pragma once
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
//  boost/detail/lwm_nop.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)
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
namespace boost
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
namespace detail
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
class lightweight_mutex
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
    typedef lightweight_mutex scoped_lock;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // namespace detail
 | 
			
		||||
 | 
			
		||||
} // namespace boost
 | 
			
		||||
 | 
			
		||||
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED
 | 
			
		||||
							
								
								
									
										62
									
								
								include/boost/smart_ptr/detail/lwm_std_mutex.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								include/boost/smart_ptr/detail/lwm_std_mutex.hpp
									
									
									
									
									
										Normal 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
 | 
			
		||||
@@ -11,15 +11,12 @@
 | 
			
		||||
//  boost/detail/lwm_win32_cs.hpp
 | 
			
		||||
//
 | 
			
		||||
//  Copyright (c) 2002, 2003 Peter Dimov
 | 
			
		||||
//  Copyright (c) Microsoft Corporation 2014
 | 
			
		||||
//
 | 
			
		||||
// Distributed under the Boost Software License, Version 1.0. (See
 | 
			
		||||
// accompanying file LICENSE_1_0.txt or copy at
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include <boost/predef.h>
 | 
			
		||||
 | 
			
		||||
#ifdef BOOST_USE_WINDOWS_H
 | 
			
		||||
 | 
			
		||||
#include <windows.h>
 | 
			
		||||
@@ -52,11 +49,7 @@ struct critical_section
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#if BOOST_PLAT_WINDOWS_RUNTIME
 | 
			
		||||
extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSectionEx(::_RTL_CRITICAL_SECTION *, unsigned long, unsigned long);
 | 
			
		||||
#else
 | 
			
		||||
extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(::_RTL_CRITICAL_SECTION *);
 | 
			
		||||
#endif
 | 
			
		||||
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 *);
 | 
			
		||||
@@ -67,11 +60,7 @@ typedef ::_RTL_CRITICAL_SECTION rtl_critical_section;
 | 
			
		||||
 | 
			
		||||
typedef ::CRITICAL_SECTION critical_section;
 | 
			
		||||
 | 
			
		||||
#if BOOST_PLAT_WINDOWS_RUNTIME
 | 
			
		||||
using ::InitializeCriticalSectionEx;
 | 
			
		||||
#else
 | 
			
		||||
using ::InitializeCriticalSection;
 | 
			
		||||
#endif
 | 
			
		||||
using ::EnterCriticalSection;
 | 
			
		||||
using ::LeaveCriticalSection;
 | 
			
		||||
using ::DeleteCriticalSection;
 | 
			
		||||
@@ -93,11 +82,7 @@ public:
 | 
			
		||||
 | 
			
		||||
    lightweight_mutex()
 | 
			
		||||
    {
 | 
			
		||||
#if BOOST_PLAT_WINDOWS_RUNTIME
 | 
			
		||||
        boost::detail::InitializeCriticalSectionEx(reinterpret_cast< rtl_critical_section* >(&cs_), 4000, 0);
 | 
			
		||||
#else
 | 
			
		||||
        boost::detail::InitializeCriticalSection(reinterpret_cast< rtl_critical_section* >(&cs_));
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~lightweight_mutex()
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,16 @@ namespace boost
 | 
			
		||||
namespace detail
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
#if defined(__clang__)
 | 
			
		||||
# pragma clang diagnostic push
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(__clang__) && defined(__has_warning)
 | 
			
		||||
# if __has_warning( "-Wc11-extensions" )
 | 
			
		||||
#  pragma clang diagnostic ignored "-Wc11-extensions"
 | 
			
		||||
# endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
typedef _Atomic( boost::int_least32_t ) atomic_int_least32_t;
 | 
			
		||||
 | 
			
		||||
inline void atomic_increment( atomic_int_least32_t * pw ) BOOST_SP_NOEXCEPT
 | 
			
		||||
@@ -61,7 +71,6 @@ inline boost::int_least32_t atomic_conditional_increment( atomic_int_least32_t *
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if defined(__clang__)
 | 
			
		||||
# pragma clang diagnostic push
 | 
			
		||||
# pragma clang diagnostic ignored "-Wweak-vtables"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@
 | 
			
		||||
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_interlocked.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
 | 
			
		||||
#include <boost/detail/workaround.hpp>
 | 
			
		||||
#include <boost/config/workaround.hpp>
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
 | 
			
		||||
namespace boost
 | 
			
		||||
 
 | 
			
		||||
@@ -85,7 +85,7 @@ public:
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void dispose() BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual void dispose() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
 | 
			
		||||
        boost::sp_scalar_destructor_hook( px_, sizeof(X), this );
 | 
			
		||||
@@ -93,17 +93,17 @@ public:
 | 
			
		||||
        boost::checked_delete( px_ );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void * get_deleter( sp_typeinfo_ const & ) BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual void * get_deleter( sp_typeinfo_ const & ) BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void * get_local_deleter( sp_typeinfo_ const & ) BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual void * get_local_deleter( sp_typeinfo_ const & ) BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
@@ -168,22 +168,22 @@ public:
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void dispose() BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual void dispose() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        del( ptr );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void * get_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual void * get_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        return ti == BOOST_SP_TYPEID_(D)? &reinterpret_cast<char&>( del ): 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void * get_local_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual void * get_local_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        return ti == BOOST_SP_TYPEID_(D)? boost::detail::get_local_deleter( boost::addressof( del ) ): 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT
 | 
			
		||||
    virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
 | 
			
		||||
    {
 | 
			
		||||
        return &reinterpret_cast<char&>( del );
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,6 @@
 | 
			
		||||
//  yield_k.hpp
 | 
			
		||||
//
 | 
			
		||||
//  Copyright (c) 2008 Peter Dimov
 | 
			
		||||
//  Copyright (c) Microsoft Corporation 2014
 | 
			
		||||
//
 | 
			
		||||
//  void yield( unsigned k );
 | 
			
		||||
//
 | 
			
		||||
@@ -25,11 +24,6 @@
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#include <boost/predef/platform/windows_runtime.h>
 | 
			
		||||
 | 
			
		||||
#if BOOST_PLAT_WINDOWS_RUNTIME
 | 
			
		||||
#include <thread>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// BOOST_SMT_PAUSE
 | 
			
		||||
 | 
			
		||||
@@ -59,7 +53,7 @@ namespace boost
 | 
			
		||||
namespace detail
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
#if !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME
 | 
			
		||||
#if !defined( BOOST_USE_WINDOWS_H )
 | 
			
		||||
 | 
			
		||||
#if defined(__clang__) && defined(__x86_64__)
 | 
			
		||||
// clang x64 warns that __stdcall is ignored
 | 
			
		||||
@@ -76,7 +70,7 @@ namespace detail
 | 
			
		||||
 | 
			
		||||
#undef BOOST_SP_STDCALL
 | 
			
		||||
 | 
			
		||||
#endif // !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME
 | 
			
		||||
#endif // !defined( BOOST_USE_WINDOWS_H )
 | 
			
		||||
 | 
			
		||||
inline void yield( unsigned k ) BOOST_NOEXCEPT
 | 
			
		||||
{
 | 
			
		||||
@@ -89,7 +83,6 @@ inline void yield( unsigned k ) BOOST_NOEXCEPT
 | 
			
		||||
        BOOST_SMT_PAUSE
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
#if !BOOST_PLAT_WINDOWS_RUNTIME
 | 
			
		||||
    else if( k < 32 )
 | 
			
		||||
    {
 | 
			
		||||
        Sleep( 0 );
 | 
			
		||||
@@ -98,13 +91,6 @@ inline void yield( unsigned k ) BOOST_NOEXCEPT
 | 
			
		||||
    {
 | 
			
		||||
        Sleep( 1 );
 | 
			
		||||
    }
 | 
			
		||||
#else
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        // Sleep isn't supported on the Windows Runtime.
 | 
			
		||||
        std::this_thread::yield();
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace detail
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
 | 
			
		||||
//  enable_shared_from.hpp
 | 
			
		||||
//
 | 
			
		||||
//  Copyright 2019 Peter Dimov
 | 
			
		||||
//  Copyright 2019, 2020 Peter Dimov
 | 
			
		||||
//
 | 
			
		||||
//  Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
//  See accompanying file LICENSE_1_0.txt or copy at
 | 
			
		||||
@@ -19,17 +19,21 @@ namespace boost
 | 
			
		||||
 | 
			
		||||
class enable_shared_from: public enable_shared_from_this<enable_shared_from>
 | 
			
		||||
{
 | 
			
		||||
private:
 | 
			
		||||
 | 
			
		||||
    using enable_shared_from_this<enable_shared_from>::shared_from_this;
 | 
			
		||||
    using enable_shared_from_this<enable_shared_from>::weak_from_this;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template<class T> shared_ptr<T> shared_from( T * p )
 | 
			
		||||
{
 | 
			
		||||
    return shared_ptr<T>( p->enable_shared_from::shared_from_this(), p );
 | 
			
		||||
    return shared_ptr<T>( p->enable_shared_from_this<enable_shared_from>::shared_from_this(), p );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T> weak_ptr<T> weak_from( T * p ) BOOST_SP_NOEXCEPT
 | 
			
		||||
{
 | 
			
		||||
    return weak_ptr<T>( p->enable_shared_from::weak_from_this(), p );
 | 
			
		||||
    return weak_ptr<T>( p->enable_shared_from_this<enable_shared_from>::weak_from_this(), p );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace boost
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/weak_ptr.hpp>
 | 
			
		||||
#include <boost/assert.hpp>
 | 
			
		||||
#include <boost/detail/workaround.hpp>
 | 
			
		||||
#include <boost/config/workaround.hpp>
 | 
			
		||||
 | 
			
		||||
namespace boost
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
 | 
			
		||||
#include <boost/assert.hpp>
 | 
			
		||||
#include <boost/detail/workaround.hpp>
 | 
			
		||||
#include <boost/config/workaround.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_convertible.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/workaround.hpp>
 | 
			
		||||
#include <boost/config/workaround.hpp>
 | 
			
		||||
 | 
			
		||||
#include <cstddef>            // for std::ptrdiff_t
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
 | 
			
		||||
#include <boost/detail/workaround.hpp>
 | 
			
		||||
#include <boost/config/workaround.hpp>
 | 
			
		||||
 | 
			
		||||
#ifndef BOOST_NO_AUTO_PTR
 | 
			
		||||
# include <memory>          // for std::auto_ptr
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@
 | 
			
		||||
#include <boost/smart_ptr/detail/shared_count.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
 | 
			
		||||
#include <boost/detail/workaround.hpp>
 | 
			
		||||
#include <boost/config/workaround.hpp>
 | 
			
		||||
 | 
			
		||||
#include <cstddef>            // for std::ptrdiff_t
 | 
			
		||||
#include <algorithm>          // for std::swap
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@
 | 
			
		||||
#include <boost/checked_delete.hpp>
 | 
			
		||||
#include <boost/throw_exception.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/shared_count.hpp>
 | 
			
		||||
#include <boost/detail/workaround.hpp>
 | 
			
		||||
#include <boost/config/workaround.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_convertible.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
 | 
			
		||||
@@ -1175,6 +1175,13 @@ template<class D, class T> D const * basic_get_local_deleter( D const *, shared_
 | 
			
		||||
 | 
			
		||||
} // namespace detail
 | 
			
		||||
 | 
			
		||||
#if defined(__cpp_deduction_guides)
 | 
			
		||||
 | 
			
		||||
template<class T> shared_ptr( weak_ptr<T> ) -> shared_ptr<T>;
 | 
			
		||||
template<class T, class D> shared_ptr( std::unique_ptr<T, D> ) -> shared_ptr<T>;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
} // namespace boost
 | 
			
		||||
 | 
			
		||||
#if defined( BOOST_SP_DISABLE_DEPRECATED )
 | 
			
		||||
 
 | 
			
		||||
@@ -264,6 +264,12 @@ template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) BOOST_SP_NOEXCEPT
 | 
			
		||||
    a.swap(b);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if defined(__cpp_deduction_guides)
 | 
			
		||||
 | 
			
		||||
template<class T> weak_ptr( shared_ptr<T> ) -> weak_ptr<T>;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
} // namespace boost
 | 
			
		||||
 | 
			
		||||
#endif  // #ifndef BOOST_SMART_PTR_WEAK_PTR_HPP_INCLUDED
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								test/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								test/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
# Copyright 2018, 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
 | 
			
		||||
 | 
			
		||||
include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
 | 
			
		||||
 | 
			
		||||
if(HAVE_BOOST_TEST)
 | 
			
		||||
 | 
			
		||||
# for lw_thread_test.cpp
 | 
			
		||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
 | 
			
		||||
find_package(Threads)
 | 
			
		||||
 | 
			
		||||
boost_test_jamfile(FILE Jamfile LINK_LIBRARIES Boost::smart_ptr Boost::core Boost::align Boost::atomic Boost::container_hash Threads::Threads)
 | 
			
		||||
 | 
			
		||||
endif()
 | 
			
		||||
							
								
								
									
										91
									
								
								test/Jamfile
									
									
									
									
									
								
							
							
						
						
									
										91
									
								
								test/Jamfile
									
									
									
									
									
								
							@@ -57,10 +57,11 @@ run yield_k_test.cpp : : : <threading>multi : yield_k_test.mt ;
 | 
			
		||||
run spinlock_test.cpp ;
 | 
			
		||||
run spinlock_try_test.cpp ;
 | 
			
		||||
run spinlock_try_test.cpp : : : <threading>multi : spinlock_try_test.mt ;
 | 
			
		||||
run spinlock_pool_test.cpp : : :
 | 
			
		||||
    # msvc-8.0, 9.0 optimizer codegen bug for `x % 41`
 | 
			
		||||
    <toolset>msvc-8.0,<variant>release:<build>no
 | 
			
		||||
    <toolset>msvc-9.0,<variant>release:<build>no ;
 | 
			
		||||
run spinlock_pool_test.cpp
 | 
			
		||||
  : : :
 | 
			
		||||
  # msvc-8.0, 9.0 optimizer codegen bug for `x % 41`
 | 
			
		||||
  <toolset>msvc-8.0,<variant>release:<build>no
 | 
			
		||||
  <toolset>msvc-9.0,<variant>release:<build>no ;
 | 
			
		||||
 | 
			
		||||
run make_shared_test.cpp ;
 | 
			
		||||
run make_shared_move_emulation_test.cpp ;
 | 
			
		||||
@@ -78,7 +79,10 @@ run sp_recursive_assign_test.cpp ;
 | 
			
		||||
run sp_recursive_assign2_test.cpp ;
 | 
			
		||||
run sp_recursive_assign_rv_test.cpp ;
 | 
			
		||||
run sp_recursive_assign2_rv_test.cpp ;
 | 
			
		||||
compile-fail auto_ptr_lv_fail.cpp : <toolset>gcc-4.4.7:<build>no ;
 | 
			
		||||
 | 
			
		||||
compile-fail auto_ptr_lv_fail.cpp
 | 
			
		||||
  : <toolset>gcc-4.4.7:<build>no ;
 | 
			
		||||
 | 
			
		||||
run atomic_count_test2.cpp ;
 | 
			
		||||
run sp_typeinfo_test.cpp ;
 | 
			
		||||
compile make_shared_fp_test.cpp ;
 | 
			
		||||
@@ -158,23 +162,33 @@ compile-fail array_fail_dereference.cpp ;
 | 
			
		||||
compile-fail array_fail_member_access.cpp ;
 | 
			
		||||
compile-fail array_fail_array_access.cpp ;
 | 
			
		||||
 | 
			
		||||
run make_shared_array_test.cpp : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run make_shared_arrays_test.cpp ; # <cxxflags>-fno-deduce-init-list no longer needed for gcc-4.6
 | 
			
		||||
run make_shared_array_throws_test.cpp : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run make_shared_array_esft_test.cpp : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run make_shared_array_noinit_test.cpp : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run make_shared_array_value_test.cpp : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run make_shared_array_test.cpp
 | 
			
		||||
  : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run make_shared_arrays_test.cpp ;
 | 
			
		||||
run make_shared_array_throws_test.cpp
 | 
			
		||||
  : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run make_shared_array_esft_test.cpp
 | 
			
		||||
  : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run make_shared_array_noinit_test.cpp
 | 
			
		||||
  : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run make_shared_array_value_test.cpp
 | 
			
		||||
  : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run allocate_shared_array_test.cpp ;
 | 
			
		||||
run allocate_shared_arrays_test.cpp ; # <cxxflags>-fno-deduce-init-list no longer needed for gcc-4.6
 | 
			
		||||
run allocate_shared_array_throws_test.cpp : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run allocate_shared_array_esft_test.cpp : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run allocate_shared_array_noinit_test.cpp : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run allocate_shared_array_value_test.cpp : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run allocate_shared_arrays_test.cpp ;
 | 
			
		||||
run allocate_shared_array_throws_test.cpp
 | 
			
		||||
  : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run allocate_shared_array_esft_test.cpp
 | 
			
		||||
  : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run allocate_shared_array_noinit_test.cpp
 | 
			
		||||
  : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run allocate_shared_array_value_test.cpp
 | 
			
		||||
  : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run allocate_shared_array_construct_test.cpp ;
 | 
			
		||||
 | 
			
		||||
run make_unique_test.cpp ;
 | 
			
		||||
run make_unique_args_test.cpp ;
 | 
			
		||||
run make_unique_value_test.cpp : : : <toolset>gcc-4.6:<cxxflags>-fno-deduce-init-list ;
 | 
			
		||||
run make_unique_value_test.cpp
 | 
			
		||||
  : : : <toolset>gcc-4.6:<cxxflags>-fno-deduce-init-list ;
 | 
			
		||||
run make_unique_noinit_test.cpp ;
 | 
			
		||||
run make_unique_throws_test.cpp ;
 | 
			
		||||
run make_unique_array_test.cpp ;
 | 
			
		||||
@@ -236,7 +250,8 @@ run shared_ptr_fn_test.cpp ;
 | 
			
		||||
run get_deleter_test2.cpp ;
 | 
			
		||||
run get_deleter_test3.cpp ;
 | 
			
		||||
run get_deleter_array_test2.cpp ;
 | 
			
		||||
run get_deleter_array_test3.cpp : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run get_deleter_array_test3.cpp
 | 
			
		||||
  : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
 | 
			
		||||
run sp_convertible_test2.cpp ;
 | 
			
		||||
 | 
			
		||||
@@ -258,13 +273,15 @@ run allocate_local_shared_test.cpp ;
 | 
			
		||||
run allocate_local_shared_esft_test.cpp ;
 | 
			
		||||
 | 
			
		||||
run make_local_shared_array_test.cpp ;
 | 
			
		||||
run make_local_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
 | 
			
		||||
run make_local_shared_arrays_test.cpp
 | 
			
		||||
  : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
 | 
			
		||||
run make_local_shared_array_throws_test.cpp ;
 | 
			
		||||
run make_local_shared_array_esft_test.cpp ;
 | 
			
		||||
run make_local_shared_array_noinit_test.cpp ;
 | 
			
		||||
run make_local_shared_array_value_test.cpp ;
 | 
			
		||||
run allocate_local_shared_array_test.cpp ;
 | 
			
		||||
run allocate_local_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
 | 
			
		||||
run allocate_local_shared_arrays_test.cpp
 | 
			
		||||
  : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
 | 
			
		||||
run allocate_local_shared_array_throws_test.cpp ;
 | 
			
		||||
run allocate_local_shared_array_esft_test.cpp ;
 | 
			
		||||
run allocate_local_shared_array_noinit_test.cpp ;
 | 
			
		||||
@@ -275,9 +292,11 @@ run local_sp_fn_test.cpp ;
 | 
			
		||||
run lsp_convertible_test.cpp ;
 | 
			
		||||
run lsp_convertible_test2.cpp ;
 | 
			
		||||
 | 
			
		||||
run make_shared_array_tmp_test.cpp : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
run make_shared_array_tmp_test.cpp
 | 
			
		||||
  : : : <toolset>msvc-8.0:<build>no ;
 | 
			
		||||
 | 
			
		||||
run lw_thread_test.cpp : : : <threading>multi ;
 | 
			
		||||
run lw_thread_test.cpp
 | 
			
		||||
  : : : <threading>multi ;
 | 
			
		||||
 | 
			
		||||
compile sp_windows_h_test.cpp ;
 | 
			
		||||
compile spinlock_windows_h_test.cpp ;
 | 
			
		||||
@@ -319,3 +338,31 @@ run get_deleter_test3.cpp : : : <rtti>off <toolset>gcc-4.4.7,<cxxstd>0x:<build>n
 | 
			
		||||
run shared_from_test.cpp ;
 | 
			
		||||
run weak_from_test.cpp ;
 | 
			
		||||
run weak_from_test2.cpp ;
 | 
			
		||||
 | 
			
		||||
run allocate_unique_aggregate_test.cpp ;
 | 
			
		||||
run allocate_unique_args_test.cpp ;
 | 
			
		||||
run allocate_unique_array_construct_test.cpp ;
 | 
			
		||||
run allocate_unique_array_noinit_test.cpp ;
 | 
			
		||||
run allocate_unique_arrays_test.cpp ;
 | 
			
		||||
run allocate_unique_array_test.cpp ;
 | 
			
		||||
run allocate_unique_array_throws_test.cpp ;
 | 
			
		||||
run allocate_unique_array_value_test.cpp ;
 | 
			
		||||
run allocate_unique_construct_test.cpp ;
 | 
			
		||||
run allocate_unique_noinit_test.cpp ;
 | 
			
		||||
run allocate_unique_test.cpp ;
 | 
			
		||||
run allocate_unique_throws_test.cpp ;
 | 
			
		||||
run allocate_unique_value_test.cpp ;
 | 
			
		||||
 | 
			
		||||
run sp_guides_test.cpp ;
 | 
			
		||||
run sp_guides_test2.cpp ;
 | 
			
		||||
run wp_guides_test.cpp ;
 | 
			
		||||
 | 
			
		||||
compile-fail shared_from_fail.cpp ;
 | 
			
		||||
compile-fail weak_from_fail.cpp ;
 | 
			
		||||
 | 
			
		||||
compile sp_override_test.cpp ;
 | 
			
		||||
compile sp_pedantic_test.cpp
 | 
			
		||||
  : <warnings>pedantic
 | 
			
		||||
    <toolset>msvc:<warnings-as-errors>on
 | 
			
		||||
    <toolset>gcc:<warnings-as-errors>on
 | 
			
		||||
    <toolset>clang:<warnings-as-errors>on ;
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@
 | 
			
		||||
// See accompanying file LICENSE_1_0.txt or copy at
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/make_shared.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/weak_ptr.hpp>
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@
 | 
			
		||||
// See accompanying file LICENSE_1_0.txt or copy at
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/make_shared.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/weak_ptr.hpp>
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@
 | 
			
		||||
//  See accompanying file LICENSE_1_0.txt or copy at
 | 
			
		||||
//  http://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/make_shared.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/enable_shared_from_this.hpp>
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@
 | 
			
		||||
// See accompanying file LICENSE_1_0.txt or copy at
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/make_shared.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/weak_ptr.hpp>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										84
									
								
								test/allocate_unique_aggregate_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								test/allocate_unique_aggregate_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,84 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 46000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
    typedef T* pointer;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct type {
 | 
			
		||||
    int x;
 | 
			
		||||
    int y;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type,
 | 
			
		||||
            boost::alloc_deleter<type, creator<type> > > result =
 | 
			
		||||
            boost::allocate_unique<type>(creator<type>(), { 1, 2 });
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result->x == 1);
 | 
			
		||||
        BOOST_TEST(result->y == 2);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type,
 | 
			
		||||
            boost::alloc_deleter<const type, creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type>(creator<>(), { 1, 2 });
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result->x == 1);
 | 
			
		||||
        BOOST_TEST(result->y == 2);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										111
									
								
								test/allocate_unique_args_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								test/allocate_unique_args_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,111 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 46000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
    typedef T* pointer;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
public:
 | 
			
		||||
    static unsigned instances;
 | 
			
		||||
 | 
			
		||||
    type(int v1, int v2, int v3, int v4, int v5)
 | 
			
		||||
        : sum_(v1 + v2 + v3 + v4 + v5) {
 | 
			
		||||
        ++instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~type() {
 | 
			
		||||
        --instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int sum() const {
 | 
			
		||||
        return sum_;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    int sum_;
 | 
			
		||||
 | 
			
		||||
    type(const type&);
 | 
			
		||||
    type& operator=(const type&);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
unsigned type::instances = 0;
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    BOOST_TEST(type::instances == 0);
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type,
 | 
			
		||||
            boost::alloc_deleter<type, creator<type> > > result =
 | 
			
		||||
            boost::allocate_unique<type>(creator<type>(), 1, 2, 3, 4, 5);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 1);
 | 
			
		||||
        BOOST_TEST(result->sum() == 15);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    BOOST_TEST(type::instances == 0);
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type,
 | 
			
		||||
            boost::alloc_deleter<const type, creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type>(creator<>(), 1, 2, 3, 4, 5);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 1);
 | 
			
		||||
        BOOST_TEST(result->sum() == 15);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										166
									
								
								test/allocate_unique_array_construct_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										166
									
								
								test/allocate_unique_array_construct_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,166 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 48000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_ALLOCATOR)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
struct allow { };
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    void construct(U* ptr) {
 | 
			
		||||
        ::new(static_cast<void*>(ptr)) U(allow());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    void destroy(U* ptr) {
 | 
			
		||||
        ptr->~U();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
public:
 | 
			
		||||
    static unsigned instances;
 | 
			
		||||
 | 
			
		||||
    explicit type(allow) {
 | 
			
		||||
        ++instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~type() {
 | 
			
		||||
        --instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    type(const type&);
 | 
			
		||||
    type& operator=(const type&);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
unsigned type::instances = 0;
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[],
 | 
			
		||||
            boost::alloc_deleter<type[], creator<type> > > result =
 | 
			
		||||
            boost::allocate_unique<type[]>(creator<type>(), 3);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[],
 | 
			
		||||
            boost::alloc_deleter<type[3], creator<type> > > result =
 | 
			
		||||
            boost::allocate_unique<type[3]>(creator<type>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[][2],
 | 
			
		||||
            boost::alloc_deleter<type[][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<type[][2]>(creator<>(), 2);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[][2],
 | 
			
		||||
            boost::alloc_deleter<type[2][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<type[2][2]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[],
 | 
			
		||||
            boost::alloc_deleter<const type[], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type[]>(creator<>(), 3);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[],
 | 
			
		||||
            boost::alloc_deleter<const type[3], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type[3]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[][2],
 | 
			
		||||
            boost::alloc_deleter<const type[][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type[][2]>(creator<>(), 2);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[][2],
 | 
			
		||||
            boost::alloc_deleter<const type[2][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type[2][2]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										228
									
								
								test/allocate_unique_array_noinit_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										228
									
								
								test/allocate_unique_array_noinit_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,228 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 48000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
    typedef T* pointer;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
public:
 | 
			
		||||
    static unsigned instances;
 | 
			
		||||
 | 
			
		||||
    type()
 | 
			
		||||
        : value_(0.0) {
 | 
			
		||||
        ++instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~type() {
 | 
			
		||||
        --instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void set(long double value) {
 | 
			
		||||
        value_ = value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    long double get() const {
 | 
			
		||||
        return value_;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    type(const type&);
 | 
			
		||||
    type& operator=(const type&);
 | 
			
		||||
 | 
			
		||||
    long double value_;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
unsigned type::instances = 0;
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[],
 | 
			
		||||
            boost::alloc_deleter<int[],
 | 
			
		||||
            boost::noinit_adaptor<creator<int> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<int[]>(creator<int>(), 3);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[],
 | 
			
		||||
            boost::alloc_deleter<int[3],
 | 
			
		||||
            boost::noinit_adaptor<creator<int> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<int[3]>(creator<int>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[][2],
 | 
			
		||||
            boost::alloc_deleter<int[][2],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<int[][2]>(creator<>(), 2);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[][2],
 | 
			
		||||
            boost::alloc_deleter<int[2][2],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<int[2][2]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[],
 | 
			
		||||
            boost::alloc_deleter<const int[],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<const int[]>(creator<>(), 3);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[],
 | 
			
		||||
            boost::alloc_deleter<const int[3],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<const int[3]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[][2],
 | 
			
		||||
            boost::alloc_deleter<const int[][2],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<const int[][2]>(creator<>(), 2);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[][2],
 | 
			
		||||
            boost::alloc_deleter<const int[2][2],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<const int[2][2]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[],
 | 
			
		||||
            boost::alloc_deleter<type[],
 | 
			
		||||
            boost::noinit_adaptor<creator<type> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<type[]>(creator<type>(), 3);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[],
 | 
			
		||||
            boost::alloc_deleter<type[3],
 | 
			
		||||
            boost::noinit_adaptor<creator<type> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<type[3]>(creator<type>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[][2],
 | 
			
		||||
            boost::alloc_deleter<type[][2],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<type[][2]>(creator<>(), 2);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[][2],
 | 
			
		||||
            boost::alloc_deleter<type[2][2],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<type[2][2]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[],
 | 
			
		||||
            boost::alloc_deleter<const type[],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<const type[]>(creator<>(), 3);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[],
 | 
			
		||||
            boost::alloc_deleter<const type[3],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<const type[3]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[][2],
 | 
			
		||||
            boost::alloc_deleter<const type[][2],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<const type[][2]>(creator<>(), 2);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[][2],
 | 
			
		||||
            boost::alloc_deleter<const type[2][2],
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<const type[2][2]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										240
									
								
								test/allocate_unique_array_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										240
									
								
								test/allocate_unique_array_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,240 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 48000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
    typedef T* pointer;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
public:
 | 
			
		||||
    static unsigned instances;
 | 
			
		||||
 | 
			
		||||
    type()
 | 
			
		||||
        : value_(0.0) {
 | 
			
		||||
        ++instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~type() {
 | 
			
		||||
        --instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void set(long double value) {
 | 
			
		||||
        value_ = value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    long double get() const {
 | 
			
		||||
        return value_;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    type(const type&);
 | 
			
		||||
    type& operator=(const type&);
 | 
			
		||||
 | 
			
		||||
    long double value_;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
unsigned type::instances = 0;
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[],
 | 
			
		||||
            boost::alloc_deleter<int[], creator<int> > > result =
 | 
			
		||||
            boost::allocate_unique<int[]>(creator<int>(), 3);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result[0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1] == 0);
 | 
			
		||||
        BOOST_TEST(result[2] == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[],
 | 
			
		||||
            boost::alloc_deleter<int[3], creator<int> > > result =
 | 
			
		||||
            boost::allocate_unique<int[3]>(creator<int>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result[0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1] == 0);
 | 
			
		||||
        BOOST_TEST(result[2] == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[][2],
 | 
			
		||||
            boost::alloc_deleter<int[][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<int[][2]>(creator<>(), 2);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result[0][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[0][1] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][1] == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[][2],
 | 
			
		||||
            boost::alloc_deleter<int[2][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<int[2][2]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result[0][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[0][1] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][1] == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[],
 | 
			
		||||
            boost::alloc_deleter<const int[], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const int[]>(creator<>(), 3);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result[0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1] == 0);
 | 
			
		||||
        BOOST_TEST(result[2] == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[],
 | 
			
		||||
            boost::alloc_deleter<const int[3], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const int[3]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result[0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1] == 0);
 | 
			
		||||
        BOOST_TEST(result[2] == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[][2],
 | 
			
		||||
            boost::alloc_deleter<const int[][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const int[][2]>(creator<>(), 2);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result[0][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[0][1] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][1] == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[][2],
 | 
			
		||||
            boost::alloc_deleter<const int[2][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const int[2][2]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result[0][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[0][1] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][1] == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[],
 | 
			
		||||
            boost::alloc_deleter<type[], creator<type> > > result =
 | 
			
		||||
            boost::allocate_unique<type[]>(creator<type>(), 3);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[],
 | 
			
		||||
            boost::alloc_deleter<type[3], creator<type> > > result =
 | 
			
		||||
            boost::allocate_unique<type[3]>(creator<type>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[][2],
 | 
			
		||||
            boost::alloc_deleter<type[][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<type[][2]>(creator<>(), 2);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type[][2],
 | 
			
		||||
            boost::alloc_deleter<type[2][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<type[2][2]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[],
 | 
			
		||||
            boost::alloc_deleter<const type[], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type[]>(creator<>(), 3);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[],
 | 
			
		||||
            boost::alloc_deleter<const type[3], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type[3]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 3);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[][2],
 | 
			
		||||
            boost::alloc_deleter<const type[][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type[][2]>(creator<>(), 2);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type[][2],
 | 
			
		||||
            boost::alloc_deleter<const type[2][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type[2][2]>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 4);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										132
									
								
								test/allocate_unique_array_throws_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										132
									
								
								test/allocate_unique_array_throws_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,132 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 48000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
    typedef T* pointer;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
public:
 | 
			
		||||
    static unsigned instances;
 | 
			
		||||
 | 
			
		||||
    type() {
 | 
			
		||||
        if (instances == 5) {
 | 
			
		||||
            throw true;
 | 
			
		||||
        }
 | 
			
		||||
        ++instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~type() {
 | 
			
		||||
        --instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    type(const type&);
 | 
			
		||||
    type& operator=(const type&);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
unsigned type::instances = 0;
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    try {
 | 
			
		||||
        boost::allocate_unique<type[]>(creator<type>(), 6);
 | 
			
		||||
        BOOST_ERROR("allocate_unique did not throw");
 | 
			
		||||
    } catch (...) {
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    try {
 | 
			
		||||
        boost::allocate_unique<type[][2]>(creator<type>(), 3);
 | 
			
		||||
        BOOST_ERROR("allocate_unique did not throw");
 | 
			
		||||
    } catch (...) {
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    try {
 | 
			
		||||
        boost::allocate_unique<type[6]>(creator<>());
 | 
			
		||||
        BOOST_ERROR("allocate_unique did not throw");
 | 
			
		||||
    } catch (...) {
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    try {
 | 
			
		||||
        boost::allocate_unique<type[3][2]>(creator<>());
 | 
			
		||||
        BOOST_ERROR("allocate_unique did not throw");
 | 
			
		||||
    } catch (...) {
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    try {
 | 
			
		||||
        boost::allocate_unique_noinit<type[]>(creator<>(), 6);
 | 
			
		||||
        BOOST_ERROR("allocate_unique_noinit did not throw");
 | 
			
		||||
    } catch (...) {
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    try {
 | 
			
		||||
        boost::allocate_unique_noinit<type[][2]>(creator<>(), 3);
 | 
			
		||||
        BOOST_ERROR("allocate_unique_noinit did not throw");
 | 
			
		||||
    } catch (...) {
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    try {
 | 
			
		||||
        boost::allocate_unique_noinit<type[6]>(creator<>());
 | 
			
		||||
        BOOST_ERROR("allocate_unique_noinit did not throw");
 | 
			
		||||
    } catch (...) {
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    try {
 | 
			
		||||
        boost::allocate_unique_noinit<type[3][2]>(creator<>());
 | 
			
		||||
        BOOST_ERROR("allocate_unique_noinit did not throw");
 | 
			
		||||
    } catch (...) {
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										98
									
								
								test/allocate_unique_array_value_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								test/allocate_unique_array_value_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,98 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 48000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
    typedef T* pointer;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[],
 | 
			
		||||
            boost::alloc_deleter<int[], creator<int> > > result =
 | 
			
		||||
            boost::allocate_unique<int[]>(creator<int>(), 4, 1);
 | 
			
		||||
        BOOST_TEST(result[0] == 1);
 | 
			
		||||
        BOOST_TEST(result[1] == 1);
 | 
			
		||||
        BOOST_TEST(result[2] == 1);
 | 
			
		||||
        BOOST_TEST(result[3] == 1);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[],
 | 
			
		||||
            boost::alloc_deleter<int[4], creator<int> > > result =
 | 
			
		||||
            boost::allocate_unique<int[4]>(creator<int>(), 1);
 | 
			
		||||
        BOOST_TEST(result[0] == 1);
 | 
			
		||||
        BOOST_TEST(result[1] == 1);
 | 
			
		||||
        BOOST_TEST(result[2] == 1);
 | 
			
		||||
        BOOST_TEST(result[3] == 1);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[],
 | 
			
		||||
            boost::alloc_deleter<const int[], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const int[]>(creator<>(), 4, 1);
 | 
			
		||||
        BOOST_TEST(result[0] == 1);
 | 
			
		||||
        BOOST_TEST(result[1] == 1);
 | 
			
		||||
        BOOST_TEST(result[2] == 1);
 | 
			
		||||
        BOOST_TEST(result[3] == 1);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[],
 | 
			
		||||
            boost::alloc_deleter<const int[4], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const int[4]>(creator<>(), 1);
 | 
			
		||||
        BOOST_TEST(result[0] == 1);
 | 
			
		||||
        BOOST_TEST(result[1] == 1);
 | 
			
		||||
        BOOST_TEST(result[2] == 1);
 | 
			
		||||
        BOOST_TEST(result[3] == 1);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										99
									
								
								test/allocate_unique_arrays_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								test/allocate_unique_arrays_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,99 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 48000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
    typedef T* pointer;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[][2],
 | 
			
		||||
            boost::alloc_deleter<int[][2], creator<int> > > result =
 | 
			
		||||
            boost::allocate_unique<int[][2]>(creator<int>(), 2, {0, 1});
 | 
			
		||||
        BOOST_TEST(result[0][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[0][1] == 1);
 | 
			
		||||
        BOOST_TEST(result[1][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][1] == 1);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int[][2],
 | 
			
		||||
            boost::alloc_deleter<int[2][2], creator<int> > > result =
 | 
			
		||||
            boost::allocate_unique<int[2][2]>(creator<int>(), {0, 1});
 | 
			
		||||
        BOOST_TEST(result[0][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[0][1] == 1);
 | 
			
		||||
        BOOST_TEST(result[1][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][1] == 1);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[][2],
 | 
			
		||||
            boost::alloc_deleter<const int[][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const int[][2]>(creator<>(), 2, {0, 1});
 | 
			
		||||
        BOOST_TEST(result[0][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[0][1] == 1);
 | 
			
		||||
        BOOST_TEST(result[1][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][1] == 1);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int[][2],
 | 
			
		||||
            boost::alloc_deleter<const int[2][2], creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const int[2][2]>(creator<>(), {0, 1});
 | 
			
		||||
        BOOST_TEST(result[0][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[0][1] == 1);
 | 
			
		||||
        BOOST_TEST(result[1][0] == 0);
 | 
			
		||||
        BOOST_TEST(result[1][1] == 1);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										109
									
								
								test/allocate_unique_construct_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								test/allocate_unique_construct_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,109 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_SMART_PTR) && !defined(BOOST_NO_CXX11_ALLOCATOR)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
struct allow { };
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    void construct(U* ptr) {
 | 
			
		||||
        ::new(static_cast<void*>(ptr)) U(allow());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    void destroy(U* ptr) {
 | 
			
		||||
        ptr->~U();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
public:
 | 
			
		||||
    static unsigned instances;
 | 
			
		||||
 | 
			
		||||
    explicit type(allow) {
 | 
			
		||||
        ++instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~type() {
 | 
			
		||||
        --instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    type(const type&);
 | 
			
		||||
    type& operator=(const type&);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
unsigned type::instances = 0;
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type,
 | 
			
		||||
            boost::alloc_deleter<type, creator<type> > > result =
 | 
			
		||||
            boost::allocate_unique<type>(creator<type>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 1);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type,
 | 
			
		||||
            boost::alloc_deleter<const type, creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 1);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										126
									
								
								test/allocate_unique_noinit_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								test/allocate_unique_noinit_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,126 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 46000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
    typedef T* pointer;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
public:
 | 
			
		||||
    static unsigned instances;
 | 
			
		||||
 | 
			
		||||
    type()
 | 
			
		||||
        : value_(0.0) {
 | 
			
		||||
        ++instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~type() {
 | 
			
		||||
        --instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void set(long double value) {
 | 
			
		||||
        value_ = value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    long double get() const {
 | 
			
		||||
        return value_;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    type(const type&);
 | 
			
		||||
    type& operator=(const type&);
 | 
			
		||||
 | 
			
		||||
    long double value_;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
unsigned type::instances = 0;
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int,
 | 
			
		||||
            boost::alloc_deleter<int,
 | 
			
		||||
            boost::noinit_adaptor<creator<int> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<int>(creator<int>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int,
 | 
			
		||||
            boost::alloc_deleter<const int,
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<const int>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type,
 | 
			
		||||
            boost::alloc_deleter<type,
 | 
			
		||||
            boost::noinit_adaptor<creator<type> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<type>(creator<type>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 1);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type,
 | 
			
		||||
            boost::alloc_deleter<const type,
 | 
			
		||||
            boost::noinit_adaptor<creator<> > > > result =
 | 
			
		||||
            boost::allocate_unique_noinit<const type>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 1);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										115
									
								
								test/allocate_unique_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								test/allocate_unique_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,115 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 46000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
    typedef T* pointer;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
public:
 | 
			
		||||
    static unsigned instances;
 | 
			
		||||
 | 
			
		||||
    type() {
 | 
			
		||||
        ++instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~type() {
 | 
			
		||||
        --instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    type(const type&);
 | 
			
		||||
    type& operator=(const type&);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
unsigned type::instances = 0;
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int,
 | 
			
		||||
            boost::alloc_deleter<int, creator<int> > > result =
 | 
			
		||||
            boost::allocate_unique<int>(creator<int>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(*result == 0);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int,
 | 
			
		||||
            boost::alloc_deleter<const int, creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const int>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(*result == 0);
 | 
			
		||||
    }
 | 
			
		||||
    BOOST_TEST(type::instances == 0);
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type,
 | 
			
		||||
            boost::alloc_deleter<type, creator<type> > > result =
 | 
			
		||||
            boost::allocate_unique<type>(creator<type>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 1);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    BOOST_TEST(type::instances == 0);
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type,
 | 
			
		||||
            boost::alloc_deleter<const type, creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type>(creator<>());
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(type::instances == 1);
 | 
			
		||||
        result.reset();
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										96
									
								
								test/allocate_unique_throws_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								test/allocate_unique_throws_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,96 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 46000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
    typedef T* pointer;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
public:
 | 
			
		||||
    static unsigned instances;
 | 
			
		||||
 | 
			
		||||
    type() {
 | 
			
		||||
        if (instances == 0) {
 | 
			
		||||
            throw true;
 | 
			
		||||
        }
 | 
			
		||||
        ++instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~type() {
 | 
			
		||||
        --instances;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    type(const type&);
 | 
			
		||||
    type& operator=(const type&);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
unsigned type::instances = 0;
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    try {
 | 
			
		||||
        boost::allocate_unique<type>(creator<type>());
 | 
			
		||||
        BOOST_ERROR("allocate_unique did not throw");
 | 
			
		||||
    } catch (...) {
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    try {
 | 
			
		||||
        boost::allocate_unique<const type>(creator<>());
 | 
			
		||||
        BOOST_ERROR("allocate_unique did not throw");
 | 
			
		||||
    } catch (...) {
 | 
			
		||||
        BOOST_TEST(type::instances == 0);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										103
									
								
								test/allocate_unique_value_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								test/allocate_unique_value_test.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,103 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2019 Glen Joseph Fernandes
 | 
			
		||||
(glenjofe@gmail.com)
 | 
			
		||||
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
 | 
			
		||||
    BOOST_LIBSTDCXX_VERSION >= 46000) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/smart_ptr/allocate_unique.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
template<class T = void>
 | 
			
		||||
struct creator {
 | 
			
		||||
    typedef T value_type;
 | 
			
		||||
    typedef T* pointer;
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    struct rebind {
 | 
			
		||||
        typedef creator<U> other;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    creator() { }
 | 
			
		||||
 | 
			
		||||
    template<class U>
 | 
			
		||||
    creator(const creator<U>&) { }
 | 
			
		||||
 | 
			
		||||
    T* allocate(std::size_t size) {
 | 
			
		||||
        return static_cast<T*>(::operator new(sizeof(T) * size));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void deallocate(T* ptr, std::size_t) {
 | 
			
		||||
        ::operator delete(ptr);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator==(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class T, class U>
 | 
			
		||||
inline bool
 | 
			
		||||
operator!=(const creator<T>&, const creator<U>&)
 | 
			
		||||
{
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
public:
 | 
			
		||||
    type(int x, int y)
 | 
			
		||||
        : value_(x + y) { }
 | 
			
		||||
 | 
			
		||||
    int sum() const {
 | 
			
		||||
        return value_;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    int value_;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<int,
 | 
			
		||||
            boost::alloc_deleter<int, creator<int> > > result =
 | 
			
		||||
            boost::allocate_unique<int>(creator<int>(), 1);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(*result == 1);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const int,
 | 
			
		||||
            boost::alloc_deleter<const int, creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const int>(creator<>(), 1);
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(*result == 1);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<type,
 | 
			
		||||
            boost::alloc_deleter<type, creator<type> > > result =
 | 
			
		||||
            boost::allocate_unique<type>(creator<type>(), type(1, 2));
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result->sum() == 3);
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_ptr<const type,
 | 
			
		||||
            boost::alloc_deleter<const type, creator<> > > result =
 | 
			
		||||
            boost::allocate_unique<const type>(creator<>(), type(1, 2));
 | 
			
		||||
        BOOST_TEST(result.get() != 0);
 | 
			
		||||
        BOOST_TEST(result->sum() == 3);
 | 
			
		||||
    }
 | 
			
		||||
    return boost::report_errors();
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/atomic_count.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/atomic_count.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ int main()
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <memory>
 | 
			
		||||
 | 
			
		||||
struct X
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										18
									
								
								test/cmake_install_test/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								test/cmake_install_test/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
# Copyright 2018, 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
 | 
			
		||||
 | 
			
		||||
cmake_minimum_required(VERSION 3.5...3.16)
 | 
			
		||||
 | 
			
		||||
project(cmake_subdir_test LANGUAGES CXX)
 | 
			
		||||
 | 
			
		||||
find_package(boost_smart_ptr REQUIRED)
 | 
			
		||||
find_package(boost_core REQUIRED)
 | 
			
		||||
 | 
			
		||||
add_executable(quick ../quick.cpp)
 | 
			
		||||
target_link_libraries(quick Boost::smart_ptr Boost::core)
 | 
			
		||||
 | 
			
		||||
enable_testing()
 | 
			
		||||
add_test(quick quick)
 | 
			
		||||
 | 
			
		||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
# Distributed under the 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)
 | 
			
		||||
cmake_minimum_required(VERSION 3.5...3.16)
 | 
			
		||||
 | 
			
		||||
project(cmake_subdir_test LANGUAGES CXX)
 | 
			
		||||
 | 
			
		||||
@@ -11,7 +11,6 @@ add_subdirectory(../../../assert boostorg/assert)
 | 
			
		||||
add_subdirectory(../../../config boostorg/config)
 | 
			
		||||
add_subdirectory(../../../core boostorg/core)
 | 
			
		||||
add_subdirectory(../../../move boostorg/move)
 | 
			
		||||
add_subdirectory(../../../predef boostorg/predef)
 | 
			
		||||
add_subdirectory(../../../static_assert boostorg/static_assert)
 | 
			
		||||
add_subdirectory(../../../throw_exception boostorg/throw_exception)
 | 
			
		||||
add_subdirectory(../../../type_traits boostorg/type_traits)
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@
 | 
			
		||||
#include <boost/pointer_cast.hpp>
 | 
			
		||||
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/get_pointer.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@
 | 
			
		||||
#include <boost/enable_shared_from_this.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/weak_ptr.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <string>
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@
 | 
			
		||||
 | 
			
		||||
#include <boost/enable_shared_from_this.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@
 | 
			
		||||
 | 
			
		||||
#include <boost/enable_shared_from_this.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include <boost/shared_array.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
struct deleter
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
struct deleter
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/intrusive_ptr.hpp>
 | 
			
		||||
#include <boost/detail/atomic_count.hpp>
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/intrusive_ptr.hpp>
 | 
			
		||||
#include <boost/detail/atomic_count.hpp>
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@
 | 
			
		||||
#include <cstddef>
 | 
			
		||||
#include <boost/smart_ptr/intrusive_ref_counter.hpp>
 | 
			
		||||
#include <boost/intrusive_ptr.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
namespace N1 {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@
 | 
			
		||||
//  See accompanying file LICENSE_1_0.txt or copy at
 | 
			
		||||
//  http://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/intrusive_ptr.hpp>
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@
 | 
			
		||||
 | 
			
		||||
#include <boost/intrusive_ptr.hpp>
 | 
			
		||||
#include <boost/functional/hash.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
class base
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include <boost/smart_ptr/local_shared_ptr.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
struct X
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@
 | 
			
		||||
#include <boost/smart_ptr/local_shared_ptr.hpp>
 | 
			
		||||
#include <boost/weak_ptr.hpp>
 | 
			
		||||
#include <boost/enable_shared_from_this.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <utility>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@
 | 
			
		||||
#include <boost/smart_ptr/local_shared_ptr.hpp>
 | 
			
		||||
#include <boost/weak_ptr.hpp>
 | 
			
		||||
#include <boost/enable_shared_from_this.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <utility>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@
 | 
			
		||||
// Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_thread.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/detail/atomic_count.hpp>
 | 
			
		||||
 | 
			
		||||
boost::detail::atomic_count count( 0 );
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/make_local_shared.hpp>
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
 | 
			
		||||
    !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/make_local_shared.hpp>
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ Copyright 2012-2015 Glen Joseph Fernandes
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/make_shared.hpp>
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ Copyright 2012-2015 Glen Joseph Fernandes
 | 
			
		||||
Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
(http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/make_shared.hpp>
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@
 | 
			
		||||
//  See accompanying file LICENSE_1_0.txt or copy at
 | 
			
		||||
//  http://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/make_shared.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/enable_shared_from_this.hpp>
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
// See accompanying file LICENSE_1_0.txt or copy at
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/make_shared.hpp>
 | 
			
		||||
#include <boost/move/core.hpp>
 | 
			
		||||
#include <boost/move/utility_core.hpp>
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@
 | 
			
		||||
// See accompanying file LICENSE_1_0.txt or copy at
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/make_shared.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@
 | 
			
		||||
// See accompanying file LICENSE_1_0.txt or copy at
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/make_shared.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/weak_ptr.hpp>
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/make_unique.hpp>
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/make_unique.hpp>
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/make_unique.hpp>
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/make_unique.hpp>
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/make_unique.hpp>
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/make_unique.hpp>
 | 
			
		||||
 | 
			
		||||
class type {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
*/
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/make_unique.hpp>
 | 
			
		||||
 | 
			
		||||
struct type {
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@
 | 
			
		||||
//  http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/smart_ptr/owner_less.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/weak_ptr.hpp>
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@
 | 
			
		||||
#include <boost/scoped_ptr.hpp>
 | 
			
		||||
#include <boost/get_pointer.hpp>
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
namespace
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include <boost/shared_array.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <cstddef>
 | 
			
		||||
#include <memory>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								test/shared_from_fail.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								test/shared_from_fail.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
// Copyright 2020 Peter Dimov
 | 
			
		||||
// Distributed under the Boost Software License, Version 1.0.
 | 
			
		||||
// https://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/smart_ptr/enable_shared_from.hpp>
 | 
			
		||||
 | 
			
		||||
struct X: public boost::enable_shared_from
 | 
			
		||||
{
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#if defined(__clang__) && defined(_MSC_VER)
 | 
			
		||||
// clang-cl claims that it accepts this code for compatibility
 | 
			
		||||
// with msvc, but no version of msvc accepts it
 | 
			
		||||
#  pragma clang diagnostic error "-Wmicrosoft-using-decl"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    boost::shared_ptr<X> px( new X );
 | 
			
		||||
    px->shared_from_this();
 | 
			
		||||
}
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
#include <boost/smart_ptr/enable_shared_from_raw.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@
 | 
			
		||||
#include <boost/smart_ptr/enable_shared_from_raw.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/weak_ptr.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/config.hpp>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <string>
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@
 | 
			
		||||
 | 
			
		||||
#include <boost/smart_ptr/enable_shared_from_raw.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@
 | 
			
		||||
 | 
			
		||||
#include <boost/smart_ptr/enable_shared_from_raw.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@
 | 
			
		||||
#include <boost/smart_ptr/enable_shared_from_raw.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <boost/weak_ptr.hpp>
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <memory>
 | 
			
		||||
 | 
			
		||||
class X: public boost::enable_shared_from_raw
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@
 | 
			
		||||
#include <boost/enable_shared_from_this.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <utility>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <cstddef>
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@
 | 
			
		||||
//  http://www.boost.org/LICENSE_1_0.txt
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <cstddef>
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
// http://www.boost.org/LICENSE_1_0.txt)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include <boost/detail/lightweight_test.hpp>
 | 
			
		||||
#include <boost/core/lightweight_test.hpp>
 | 
			
		||||
#include <boost/shared_ptr.hpp>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <cstddef>
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user