forked from boostorg/core
Compare commits
35 Commits
feature/cm
...
feature/mo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c10ee4517 | ||
|
|
b7ad896707 | ||
|
|
70413b0568 | ||
|
|
b8a9b2c234 | ||
|
|
e11fa9ac03 | ||
|
|
e1d50a1de2 | ||
|
|
e128f4e1b8 | ||
|
|
cc119253b4 | ||
|
|
19ec659a91 | ||
|
|
75ae238d0c | ||
|
|
630ab2aae4 | ||
|
|
2cd4753a02 | ||
|
|
9445d08ea7 | ||
|
|
dbb3305050 | ||
|
|
23f10ab4bf | ||
|
|
e5281335e0 | ||
|
|
b5dcd204e5 | ||
|
|
081ca76d6c | ||
|
|
2a3387451f | ||
|
|
69bd3e73bf | ||
|
|
0296f44b2b | ||
|
|
2738af9b52 | ||
|
|
6a1c3a82a1 | ||
|
|
bb800a05e3 | ||
|
|
2d7f98c844 | ||
|
|
8914603fcf | ||
|
|
3792047e09 | ||
|
|
6de3da8360 | ||
|
|
e55d6279d5 | ||
|
|
a87fd099e7 | ||
|
|
09f4823baa | ||
|
|
526e0b2f53 | ||
|
|
ac6044769f | ||
|
|
2876914d02 | ||
|
|
36f60e47ad |
205
.travis.yml
205
.travis.yml
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016 Peter Dimov
|
||||
# Copyright 2016, 2017 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)
|
||||
|
||||
@@ -6,14 +6,13 @@ language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
python: "2.7"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
@@ -26,10 +25,32 @@ matrix:
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++03
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++03
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -38,16 +59,8 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++03
|
||||
compiler: g++-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -56,16 +69,8 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++03
|
||||
compiler: g++-4.9
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -74,16 +79,8 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++03
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -92,25 +89,8 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++03
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -119,40 +99,45 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++11
|
||||
dist: trusty
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++14
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++1z
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
- clang-3.5
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++03
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -162,17 +147,8 @@ matrix:
|
||||
- llvm-toolchain-precise-3.6
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++03
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -182,67 +158,78 @@ matrix:
|
||||
- llvm-toolchain-precise-3.7
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++03
|
||||
compiler: clang++-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++11
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- clang-3.9
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
- llvm-toolchain-precise-3.9
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++14
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- clang-4.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
- llvm-toolchain-trusty-4.0
|
||||
|
||||
- os: linux
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++1z
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
- llvm-toolchain-trusty-5.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: osx
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03
|
||||
|
||||
- os: osx
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11
|
||||
|
||||
- os: osx
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++14
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- cd ..
|
||||
- git clone -b $TRAVIS_BRANCH https://github.com/boostorg/boost.git boost-root
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/config
|
||||
@@ -257,8 +244,8 @@ install:
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER : <cxxflags>-std=$CXXSTD ;" > ~/user-config.jam
|
||||
- ./b2 libs/core/test toolset=$TOOLSET
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j 3 libs/core/test toolset=$TOOLSET cxxstd=$CXXSTD
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
include(cmake/BoostVersion.cmake)
|
||||
set(BOOST_PROJECT_NAME core)
|
||||
|
||||
project(boost_${BOOST_PROJECT_NAME} VERSION ${BOOST_VERSION} LANGUAGES CXX)
|
||||
|
||||
include(cmake/default.cmake)
|
||||
40
appveyor.yml
40
appveyor.yml
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016 Peter Dimov
|
||||
# Copyright 2016, 2017 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)
|
||||
|
||||
@@ -10,10 +10,40 @@ branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-14.0
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
|
||||
install:
|
||||
- set BOOST_BRANCH=develop
|
||||
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||
- cd ..
|
||||
- git clone -b %APPVEYOR_REPO_BRANCH% https://github.com/boostorg/boost.git boost-root
|
||||
- git clone -b %BOOST_BRANCH% https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/config
|
||||
@@ -23,10 +53,12 @@ install:
|
||||
- git submodule init tools/build
|
||||
- git submodule update
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core
|
||||
- bootstrap
|
||||
- cmd /c bootstrap
|
||||
- b2 headers
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- b2 libs/core/test toolset=msvc-9.0,msvc-10.0,msvc-11.0,msvc-14.0
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- b2 -j 3 libs/core/test toolset=%TOOLSET% %CXXSTD%
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
set(BOOST_VERSION 1.65.0)
|
||||
@@ -1,20 +0,0 @@
|
||||
# Update cmake files
|
||||
|
||||
install BoostVersion_ : ../../../BoostVersion.cmake : <location>. ;
|
||||
install default_ : ../../../cmake/default.cmake : <location>. ;
|
||||
|
||||
# Update dependencies
|
||||
|
||||
import path ;
|
||||
|
||||
path-constant LIBDIR : .. ;
|
||||
|
||||
actions boostdep-cmake
|
||||
{
|
||||
"$(LIBDIR)/../../dist/bin/boostdep" --cmake $(LIBDIR:B) > $(1)
|
||||
}
|
||||
|
||||
make dependencies.cmake : : @boostdep-cmake ;
|
||||
always dependencies.cmake ;
|
||||
|
||||
install dependencies_ : dependencies.cmake : <location>. ;
|
||||
@@ -1,103 +0,0 @@
|
||||
#
|
||||
# Default CMakeLists.txt contents for a Boost library
|
||||
#
|
||||
|
||||
# sources.cmake defines ${PROJECT_NAME}_SOURCES
|
||||
include(cmake/sources.cmake)
|
||||
|
||||
if("${${PROJECT_NAME}_SOURCES}" STREQUAL "")
|
||||
|
||||
# if no sources, this is a header-only library
|
||||
add_library(boost_${BOOST_PROJECT_NAME} INTERFACE)
|
||||
|
||||
# include directory
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
else()
|
||||
|
||||
# a library that requires building
|
||||
add_library(${PROJECT_NAME} ${${PROJECT_NAME}_SOURCES})
|
||||
|
||||
# include directory
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
# add namespaced alias
|
||||
add_library(boost::${BOOST_PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||
|
||||
# set imported target name to the unqualified name, it will be namespaced
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY EXPORT_NAME ${BOOST_PROJECT_NAME})
|
||||
|
||||
# link to dependencies
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
function(boost_declare_dependency package type target)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${type} ${target})
|
||||
|
||||
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
|
||||
|
||||
find_dependency(${package} ${PROJECT_VERSION} EXACT)
|
||||
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
include(cmake/dependencies.cmake)
|
||||
|
||||
# target installation
|
||||
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
INCLUDES DESTINATION include
|
||||
)
|
||||
|
||||
# header installation
|
||||
install(DIRECTORY include/ DESTINATION include)
|
||||
|
||||
# export target info to ${PROJECT_NAME}-targets.cmake, used by -config.cmake
|
||||
install(EXPORT ${PROJECT_NAME}-targets
|
||||
FILE ${PROJECT_NAME}-targets.cmake
|
||||
NAMESPACE boost::
|
||||
DESTINATION lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||
)
|
||||
|
||||
# install -dependencies.cmake, used by -config.cmake
|
||||
|
||||
install(FILES cmake/dependencies.cmake
|
||||
DESTINATION lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||
RENAME ${PROJECT_NAME}-dependencies.cmake
|
||||
)
|
||||
|
||||
# write ${PROJECT_NAME}-config.cmake
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" "
|
||||
include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}-targets.cmake)
|
||||
include(CMakeFindDependencyMacro)
|
||||
function(boost_declare_dependency package type target)
|
||||
find_dependency(\${package} ${PROJECT_VERSION} EXACT)
|
||||
endfunction()
|
||||
include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}-dependencies.cmake)
|
||||
")
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# write ${PROJECT_NAME}-config-version.cmake
|
||||
write_basic_package_version_file("${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
# install -config, -config-version
|
||||
install(FILES
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
|
||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
|
||||
DESTINATION lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||
)
|
||||
@@ -1,4 +0,0 @@
|
||||
# Generated file. Do not edit.
|
||||
|
||||
boost_declare_dependency(boost_assert INTERFACE boost::assert)
|
||||
boost_declare_dependency(boost_config INTERFACE boost::config)
|
||||
@@ -42,6 +42,7 @@ criteria for inclusion is that the utility component be:
|
||||
[include checked_delete.qbk]
|
||||
[include demangle.qbk]
|
||||
[include enable_if.qbk]
|
||||
[include exchange.qbk]
|
||||
[include explicit_operator_bool.qbk]
|
||||
[include ignore_unused.qbk]
|
||||
[include is_same.qbk]
|
||||
|
||||
62
doc/exchange.qbk
Normal file
62
doc/exchange.qbk
Normal file
@@ -0,0 +1,62 @@
|
||||
[/
|
||||
Copyright 2018 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
|
||||
[section:exchange exchange]
|
||||
|
||||
[simplesect Authors]
|
||||
|
||||
* Glen Fernandes
|
||||
|
||||
[endsimplesect]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header <boost/core/exchange.hpp> provides the function template
|
||||
`boost::exchange` which is an implementation of the `std::exchange`
|
||||
function introduced in C++14.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following example shows `boost::exchange` used to simplify the
|
||||
implementation of a move constructor.
|
||||
|
||||
```
|
||||
Node(Node&& other)
|
||||
: head_(boost::exchange(other.head_, nullptr))
|
||||
, tail_(boost::exchange(other.tail_, nullptr)) { }
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Reference]
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
template<class T, class U = T>
|
||||
constexpr T exchange(T& t, U&& u);
|
||||
}
|
||||
```
|
||||
[section Functions]
|
||||
|
||||
[*`template<class T, class U = T> constexpr T exchange(T& t, U&& u);`]
|
||||
|
||||
Equivalent to:
|
||||
|
||||
```
|
||||
T v = std::move(t);
|
||||
t = std::forward<U>(u);
|
||||
return v;
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
[section Header <boost/core/noncopyable.hpp>]
|
||||
|
||||
The header `<boost/noncopyable.hpp>` defines the class
|
||||
The header `<boost/core/noncopyable.hpp>` defines the class
|
||||
`boost::noncopyable`. It is intended to be used as a private
|
||||
base. `boost::noncopyable` has private (under C++03) or
|
||||
base class. `boost::noncopyable` has private (under C++03) or
|
||||
deleted (under C++11) copy constructor and a copy assignment
|
||||
operator and can't be copied or assigned; a class that derives
|
||||
from it inherits these properties.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[/
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
Copyright 2017-2018 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -20,23 +20,24 @@ The header <boost/core/pointer_traits.hpp> provides the class template
|
||||
`boost::pointer_traits` to facilitate use of pointer-like types. The C++11
|
||||
standard library introduced `std::pointer_traits` along with an allocator
|
||||
model which supported pointer-like types in addition to plain raw pointers.
|
||||
This implementation also supports C++98, and adds additional functionality
|
||||
for obtaining raw pointers from pointers.
|
||||
This implementation also supports C++98.
|
||||
|
||||
It also provides the function template `boost::to_address` to obtain a raw
|
||||
pointer from an object of any pointer-like type.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Examples]
|
||||
|
||||
The following function template obtains a raw pointer from a pointer and is
|
||||
well defined when the pointer aliases storage that has no object constructed
|
||||
in it.
|
||||
The following example allocates storage and constructs an object in that
|
||||
storage using an allocator.
|
||||
|
||||
```
|
||||
template<class T>
|
||||
inline typename boost::pointer_traits<T>::element_type*
|
||||
to_raw_pointer(T v) noexcept
|
||||
template<class Allocator>
|
||||
void function(Allocator& a)
|
||||
{
|
||||
return boost::pointer_traits<T>::to_address(v);
|
||||
auto p = a.allocate(1);
|
||||
std::allocator_traits<Allocator>::construct(a, boost::to_address(p));
|
||||
}
|
||||
```
|
||||
|
||||
@@ -55,7 +56,6 @@ namespace boost {
|
||||
template<class U> using rebind = typename rebind_to<U>::type;
|
||||
|
||||
static pointer pointer_to(``['see below]`` v);
|
||||
static element_type* to_address(pointer v) noexcept;
|
||||
};
|
||||
|
||||
template<class T> struct pointer_traits<T*> {
|
||||
@@ -67,65 +67,74 @@ namespace boost {
|
||||
template<class U> using rebind = typename rebind_to<U>::type;
|
||||
|
||||
static pointer pointer_to(``['see below]`` v) noexcept;
|
||||
static element_type* to_address(pointer v) noexcept;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
constexpr T* to_address(T* v) noexcept;
|
||||
|
||||
template<class T>
|
||||
auto to_address(const T& v) noexcept;
|
||||
}
|
||||
```
|
||||
|
||||
[section Member types]
|
||||
|
||||
[variablelist
|
||||
[[`typedef` ['see below] `element_type;`]
|
||||
[[variablelist
|
||||
[[Type]
|
||||
[`T::element_type` if such a type exists; otherwise `U` if `T` is a
|
||||
class template instantiation of the form `Pointer<U, Args>`, where
|
||||
`Args` is zero or more type arguments; otherwise the specialization
|
||||
is ill-formed.]]]]]
|
||||
[[`typedef` ['see below] `difference_type;`]
|
||||
[[variablelist
|
||||
[[Type]
|
||||
[`T::difference_type` if such a type exists; otherwise
|
||||
`std::ptrdiff_t`.]]]]]
|
||||
[[`template<class U> struct rebind_to { typedef` ['see below] `type; };`]
|
||||
[[variablelist
|
||||
[[Type]
|
||||
[`type` is `T::rebind<U>` if such a type exists; otherwise,
|
||||
`Pointer<V, Args>` if `T` is a class template instantiation of the
|
||||
form `Pointer<T, Args>`, where `Args` is zero or more type
|
||||
arguments; otherwise, the instantiation of `rebind_to` is
|
||||
ill-formed.]]]]]]
|
||||
[[`typedef` ['see below] `element_type;`]
|
||||
[`T::element_type` if such a type exists; otherwise `U` if `T` is a class
|
||||
template instantiation of the form `Pointer<U, Args>`, where `Args` is zero
|
||||
or more type arguments; otherwise the specialization is ill-formed.]]
|
||||
[[`typedef` ['see below] `difference_type;`]
|
||||
[`T::difference_type` if such a type exists; otherwise `std::ptrdiff_t`.]]
|
||||
[[`template<class U> struct rebind_to { typedef` ['see below] `type; };`]
|
||||
[`type` is `T::rebind<U>` if such a type exists; otherwise, `Pointer<V, Args>`
|
||||
if `T` is a class template instantiation of the form `Pointer<T, Args>`,
|
||||
where `Args` is zero or more type arguments; otherwise, the instantiation of
|
||||
`rebind_to` is ill-formed.]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Member functions]
|
||||
|
||||
[variablelist pointer_traits
|
||||
[[`static pointer pointer_to(`['see below] `v);`]
|
||||
[[variablelist
|
||||
[[Remark]
|
||||
[If `element_type` is a void type, the type of `v` is unspecified;
|
||||
otherwise, it is `element_type&`.]]
|
||||
[[Returns]
|
||||
[A pointer to `v` obtained by calling `T::pointer_to(v)`.]]]]]
|
||||
[[`static element_type* to_address(pointer v) noexcept;`]
|
||||
[[variablelist
|
||||
[[Requires]
|
||||
[`v` is not a null pointer.]]
|
||||
[[Returns]
|
||||
[A pointer of type `element_type*` that references the same location
|
||||
as the argument.]]]]]]
|
||||
[variablelist
|
||||
[[`static pointer pointer_traits::pointer_to(`['see below] `v);`]
|
||||
[[variablelist
|
||||
[[Remark]
|
||||
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
|
||||
it is `element_type&`.]]
|
||||
[[Returns]
|
||||
[A pointer to `v` obtained by calling `T::pointer_to(v)`.]]]]]
|
||||
[[`static pointer pointer_traits<T*>::pointer_to(`['see below] `v) noexcept;`]
|
||||
[[variablelist
|
||||
[[Remark]
|
||||
[If `element_type` is a void type, the type of `v` is unspecified; otherwise,
|
||||
it is `element_type&`.]]
|
||||
[[Returns] [`addressof(v)`.]]]]]]
|
||||
|
||||
[variablelist pointer_traits<T*>
|
||||
[[`static pointer pointer_to(`['see below] `v) noexcept;`]
|
||||
[[variablelist
|
||||
[[Remark]
|
||||
[If `element_type` is a void type, the type of `v` is unspecified;
|
||||
otherwise, it is `element_type&`.]]
|
||||
[[Returns]
|
||||
[The result of `std::addressof(v)`.]]]]]
|
||||
[[`static element_type* to_address(pointer v) noexcept;`]
|
||||
[[variablelist [[Returns] [The value of `v`.]]]]]]
|
||||
[endsect]
|
||||
|
||||
[section Optional members]
|
||||
|
||||
[variablelist
|
||||
[[`static element_type* to_address(pointer v) noexcept;`]
|
||||
[[variablelist
|
||||
[[Returns]
|
||||
[A pointer of type `element_type*` that references the same location as the
|
||||
argument `p`.]]
|
||||
[[Note]
|
||||
[This function should be the inverse of `pointer_to`. If defined, it
|
||||
customizes the behavior of the non-member function `to_address`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Free functions]
|
||||
|
||||
[variablelist
|
||||
[[`template<class T> constexpr T* to_address(T* v) noexcept;`]
|
||||
[[variablelist [[Returns] [`v`.]]]]]
|
||||
[[`template<class T> auto to_address(const T& v) noexcept;`]
|
||||
[[variablelist [[Returns] [`pointer_traits<T>::to_address(v)` if that
|
||||
expression is well-formed, otherwise `to_address(v.operator->())`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -133,8 +142,8 @@ namespace boost {
|
||||
|
||||
[section Acknowledgments]
|
||||
|
||||
Glen Fernandes implemented `pointer_traits` with reviews and guidance from
|
||||
Peter Dimov.
|
||||
Glen Fernandes implemented `pointer_traits` and `to_address` with reviews and
|
||||
guidance from Peter Dimov.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@@ -49,20 +49,20 @@ namespace boost {
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
class addressof_ref {
|
||||
class addrof_ref {
|
||||
public:
|
||||
BOOST_FORCEINLINE addressof_ref(T& o) BOOST_NOEXCEPT
|
||||
BOOST_FORCEINLINE addrof_ref(T& o) BOOST_NOEXCEPT
|
||||
: o_(o) { }
|
||||
BOOST_FORCEINLINE operator T&() const BOOST_NOEXCEPT {
|
||||
return o_;
|
||||
}
|
||||
private:
|
||||
addressof_ref& operator=(const addressof_ref&);
|
||||
addrof_ref& operator=(const addrof_ref&);
|
||||
T& o_;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct address_of {
|
||||
struct addrof {
|
||||
static BOOST_FORCEINLINE T* get(T& o, long) BOOST_NOEXCEPT {
|
||||
return reinterpret_cast<T*>(&
|
||||
const_cast<char&>(reinterpret_cast<const volatile char&>(o)));
|
||||
@@ -76,38 +76,38 @@ struct address_of {
|
||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && \
|
||||
(defined(__INTEL_COMPILER) || \
|
||||
(defined(__clang__) && !defined(_LIBCPP_VERSION)))
|
||||
typedef decltype(nullptr) addressof_null_t;
|
||||
typedef decltype(nullptr) addrof_null_t;
|
||||
#else
|
||||
typedef std::nullptr_t addressof_null_t;
|
||||
typedef std::nullptr_t addrof_null_t;
|
||||
#endif
|
||||
|
||||
template<>
|
||||
struct address_of<addressof_null_t> {
|
||||
typedef addressof_null_t type;
|
||||
struct addrof<addrof_null_t> {
|
||||
typedef addrof_null_t type;
|
||||
static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
|
||||
return &o;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct address_of<const addressof_null_t> {
|
||||
typedef const addressof_null_t type;
|
||||
struct addrof<const addrof_null_t> {
|
||||
typedef const addrof_null_t type;
|
||||
static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
|
||||
return &o;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct address_of<volatile addressof_null_t> {
|
||||
typedef volatile addressof_null_t type;
|
||||
struct addrof<volatile addrof_null_t> {
|
||||
typedef volatile addrof_null_t type;
|
||||
static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
|
||||
return &o;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct address_of<const volatile addressof_null_t> {
|
||||
typedef const volatile addressof_null_t type;
|
||||
struct addrof<const volatile addrof_null_t> {
|
||||
typedef const volatile addrof_null_t type;
|
||||
static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
|
||||
return &o;
|
||||
}
|
||||
@@ -127,9 +127,9 @@ addressof(T& o) BOOST_NOEXCEPT
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) || \
|
||||
BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5120)
|
||||
return detail::address_of<T>::get(o, 0);
|
||||
return boost::detail::addrof<T>::get(o, 0);
|
||||
#else
|
||||
return detail::address_of<T>::get(detail::addressof_ref<T>(o), 0);
|
||||
return boost::detail::addrof<T>::get(boost::detail::addrof_ref<T>(o), 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -137,14 +137,14 @@ addressof(T& o) BOOST_NOEXCEPT
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
struct addressof_result {
|
||||
struct addrof_result {
|
||||
typedef T* type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class T, std::size_t N>
|
||||
BOOST_FORCEINLINE typename detail::addressof_result<T[N]>::type
|
||||
BOOST_FORCEINLINE typename boost::detail::addrof_result<T[N]>::type
|
||||
addressof(T (&o)[N]) BOOST_NOEXCEPT
|
||||
{
|
||||
return &o;
|
||||
@@ -170,79 +170,79 @@ const T (*addressof(const T (&o)[N]) BOOST_NOEXCEPT)[N]
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
T addressof_declval() BOOST_NOEXCEPT;
|
||||
T addrof_declval() BOOST_NOEXCEPT;
|
||||
|
||||
template<class>
|
||||
struct addressof_void {
|
||||
struct addrof_void {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<class T, class E = void>
|
||||
struct addressof_member_operator {
|
||||
struct addrof_member_operator {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct addressof_member_operator<T, typename
|
||||
addressof_void<decltype(addressof_declval<T&>().operator&())>::type> {
|
||||
struct addrof_member_operator<T, typename
|
||||
addrof_void<decltype(addrof_declval<T&>().operator&())>::type> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_INTEL, < 1600)
|
||||
struct addressof_addressable { };
|
||||
struct addrof_addressable { };
|
||||
|
||||
addressof_addressable*
|
||||
operator&(addressof_addressable&) BOOST_NOEXCEPT;
|
||||
addrof_addressable*
|
||||
operator&(addrof_addressable&) BOOST_NOEXCEPT;
|
||||
#endif
|
||||
|
||||
template<class T, class E = void>
|
||||
struct addressof_non_member_operator {
|
||||
struct addrof_non_member_operator {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct addressof_non_member_operator<T, typename
|
||||
addressof_void<decltype(operator&(addressof_declval<T&>()))>::type> {
|
||||
struct addrof_non_member_operator<T, typename
|
||||
addrof_void<decltype(operator&(addrof_declval<T&>()))>::type> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template<class T, class E = void>
|
||||
struct addressof_expression {
|
||||
struct addrof_expression {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct addressof_expression<T,
|
||||
typename addressof_void<decltype(&addressof_declval<T&>())>::type> {
|
||||
struct addrof_expression<T,
|
||||
typename addrof_void<decltype(&addrof_declval<T&>())>::type> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct addressof_is_constexpr {
|
||||
static constexpr bool value = addressof_expression<T>::value &&
|
||||
!addressof_member_operator<T>::value &&
|
||||
!addressof_non_member_operator<T>::value;
|
||||
struct addrof_is_constexpr {
|
||||
static constexpr bool value = addrof_expression<T>::value &&
|
||||
!addrof_member_operator<T>::value &&
|
||||
!addrof_non_member_operator<T>::value;
|
||||
};
|
||||
|
||||
template<bool E, class T>
|
||||
struct addressof_if { };
|
||||
struct addrof_if { };
|
||||
|
||||
template<class T>
|
||||
struct addressof_if<true, T> {
|
||||
struct addrof_if<true, T> {
|
||||
typedef T* type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
BOOST_FORCEINLINE
|
||||
typename addressof_if<!addressof_is_constexpr<T>::value, T>::type
|
||||
typename addrof_if<!addrof_is_constexpr<T>::value, T>::type
|
||||
addressof(T& o) BOOST_NOEXCEPT
|
||||
{
|
||||
return address_of<T>::get(addressof_ref<T>(o), 0);
|
||||
return addrof<T>::get(addrof_ref<T>(o), 0);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
constexpr BOOST_FORCEINLINE
|
||||
typename addressof_if<addressof_is_constexpr<T>::value, T>::type
|
||||
typename addrof_if<addrof_is_constexpr<T>::value, T>::type
|
||||
addressof(T& o) BOOST_NOEXCEPT
|
||||
{
|
||||
return &o;
|
||||
@@ -254,7 +254,7 @@ template<class T>
|
||||
constexpr BOOST_FORCEINLINE T*
|
||||
addressof(T& o) BOOST_NOEXCEPT
|
||||
{
|
||||
return detail::addressof(o);
|
||||
return boost::detail::addressof(o);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
49
include/boost/core/exchange.hpp
Normal file
49
include/boost/core/exchange.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright 2018 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_CORE_EXCHANGE_HPP
|
||||
#define BOOST_CORE_EXCHANGE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template<class T, class U>
|
||||
inline T exchange(T& t, const U& u)
|
||||
{
|
||||
T v = t;
|
||||
t = u;
|
||||
return v;
|
||||
}
|
||||
#else
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1800)
|
||||
template<class T, class U>
|
||||
inline T exchange(T& t, U&& u)
|
||||
{
|
||||
T v = std::move(t);
|
||||
t = std::forward<U>(u);
|
||||
return v;
|
||||
}
|
||||
#else
|
||||
template<class T, class U = T>
|
||||
BOOST_CXX14_CONSTEXPR inline T exchange(T& t, U&& u)
|
||||
{
|
||||
T v = std::move(t);
|
||||
t = std::forward<U>(u);
|
||||
return v;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
@@ -19,6 +19,7 @@
|
||||
#define BOOST_CORE_EXPLICIT_OPERATOR_BOOL_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
@@ -52,6 +53,8 @@
|
||||
return !this->operator! ();\
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
|
||||
/*!
|
||||
* \brief The macro defines a constexpr explicit operator of conversion to \c bool
|
||||
*
|
||||
@@ -65,6 +68,12 @@
|
||||
return !this->operator! ();\
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL() BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
|
||||
|
||||
#endif
|
||||
|
||||
#else // !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
|
||||
#if (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)) && !defined(BOOST_NO_COMPILER_CONFIG)
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <iterator>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
|
||||
@@ -115,7 +115,7 @@ inline const void* test_output_impl(signed char* v) { return v; }
|
||||
template<class T> inline const void* test_output_impl(T volatile* v) { return const_cast<T*>(v); }
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_NULLPTR )
|
||||
inline const void* test_output_impl(std::nullptr_t v) { return v; }
|
||||
inline const void* test_output_impl(std::nullptr_t) { return nullptr; }
|
||||
#endif
|
||||
|
||||
template<class T, class U> inline void test_eq_impl( char const * expr1, char const * expr2,
|
||||
@@ -247,7 +247,7 @@ inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
|
||||
<< file << "(" << line << "): test '" << expr1 << " != " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << t << "' == '" << u << "'" << std::endl;
|
||||
++test_errors();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
Copyright 2017-2018 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -17,20 +17,6 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
struct pointer_traits;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class U>
|
||||
static typename boost::pointer_traits<U>::element_type*
|
||||
ptr_traits_address(U v) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::pointer_traits<U>::to_address(v);
|
||||
}
|
||||
|
||||
} /* detail */
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
|
||||
template<class T>
|
||||
struct pointer_traits
|
||||
@@ -39,10 +25,6 @@ struct pointer_traits
|
||||
struct rebind_to {
|
||||
typedef typename std::pointer_traits<T>::template rebind<U> type;
|
||||
};
|
||||
static typename std::pointer_traits<T>::element_type*
|
||||
to_address(T v) BOOST_NOEXCEPT {
|
||||
return detail::ptr_traits_address(v.operator->());
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
@@ -52,143 +34,107 @@ struct pointer_traits<T*>
|
||||
struct rebind_to {
|
||||
typedef U* type;
|
||||
};
|
||||
static T* to_address(T* v) BOOST_NOEXCEPT {
|
||||
return v;
|
||||
}
|
||||
};
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
struct ptr_traits_none { char first, second; };
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_has_element {
|
||||
private:
|
||||
template<class U>
|
||||
static ptr_traits_none call(...);
|
||||
template<class U>
|
||||
static char call(typename U::element_type* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(call<T>(0)) == 1;
|
||||
template<class>
|
||||
struct ptr_void {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_first;
|
||||
struct ptr_first;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<template<class, class...> class T, class U, class... Args>
|
||||
struct ptr_traits_first<T<U, Args...> > {
|
||||
struct ptr_first<T<U, Args...> > {
|
||||
typedef U type;
|
||||
};
|
||||
#else
|
||||
template<template<class> class T, class U>
|
||||
struct ptr_traits_first<T<U> > {
|
||||
struct ptr_first<T<U> > {
|
||||
typedef U type;
|
||||
};
|
||||
|
||||
template<template<class, class> class T, class U1, class U2>
|
||||
struct ptr_traits_first<T<U1, U2> > {
|
||||
struct ptr_first<T<U1, U2> > {
|
||||
typedef U1 type;
|
||||
};
|
||||
|
||||
template<template<class, class, class> class T, class U1, class U2, class U3>
|
||||
struct ptr_traits_first<T<U1, U2, U3> > {
|
||||
struct ptr_first<T<U1, U2, U3> > {
|
||||
typedef U1 type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class T, bool = ptr_traits_has_element<T>::value>
|
||||
struct ptr_traits_element {
|
||||
template<class T, class = void>
|
||||
struct ptr_element {
|
||||
typedef typename ptr_first<T>::type type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_element<T, typename ptr_void<typename T::element_type>::type> {
|
||||
typedef typename T::element_type type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_element<T, false> {
|
||||
typedef typename ptr_traits_first<T>::type type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_has_difference {
|
||||
private:
|
||||
template<class U>
|
||||
static ptr_traits_none call(...);
|
||||
template<class U>
|
||||
static char call(typename U::difference_type* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(call<T>(0)) == 1;
|
||||
};
|
||||
|
||||
template<class T, bool = ptr_traits_has_difference<T>::value>
|
||||
struct ptr_traits_difference {
|
||||
typedef typename T::difference_type type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_difference<T, false> {
|
||||
template<class, class = void>
|
||||
struct ptr_difference {
|
||||
typedef std::ptrdiff_t type;
|
||||
};
|
||||
|
||||
template<class T, class V>
|
||||
struct ptr_traits_has_rebind {
|
||||
private:
|
||||
template<class U>
|
||||
static ptr_traits_none call(...);
|
||||
template<class U>
|
||||
static char call(typename U::template rebind<V>* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(call<T>(0)) == 1;
|
||||
template<class T>
|
||||
struct ptr_difference<T,
|
||||
typename ptr_void<typename T::difference_type>::type> {
|
||||
typedef typename T::difference_type type;
|
||||
};
|
||||
|
||||
template<class T, class V>
|
||||
struct ptr_traits_rebind_to;
|
||||
struct ptr_transform;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<template<class, class...> class T, class U, class... Args, class V>
|
||||
struct ptr_traits_rebind_to<T<U, Args...>, V> {
|
||||
struct ptr_transform<T<U, Args...>, V> {
|
||||
typedef T<V, Args...> type;
|
||||
};
|
||||
#else
|
||||
template<template<class> class T, class U, class V>
|
||||
struct ptr_traits_rebind_to<T<U>, V> {
|
||||
struct ptr_transform<T<U>, V> {
|
||||
typedef T<V> type;
|
||||
};
|
||||
|
||||
template<template<class, class> class T, class U1, class U2, class V>
|
||||
struct ptr_traits_rebind_to<T<U1, U2>, V> {
|
||||
struct ptr_transform<T<U1, U2>, V> {
|
||||
typedef T<V, U2> type;
|
||||
};
|
||||
|
||||
template<template<class, class, class> class T,
|
||||
class U1, class U2, class U3, class V>
|
||||
struct ptr_traits_rebind_to<T<U1, U2, U3>, V> {
|
||||
struct ptr_transform<T<U1, U2, U3>, V> {
|
||||
typedef T<V, U2, U3> type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class T, class U, bool = ptr_traits_has_rebind<T, U>::value>
|
||||
struct ptr_traits_rebind {
|
||||
typedef typename T::template rebind<U> type;
|
||||
template<class T, class U, class = void>
|
||||
struct ptr_rebind {
|
||||
typedef typename ptr_transform<T, U>::type type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class T, class U>
|
||||
struct ptr_traits_rebind<T, U, false> {
|
||||
typedef typename ptr_traits_rebind_to<T, U>::type type;
|
||||
};
|
||||
#else
|
||||
template<class T, class U>
|
||||
struct ptr_traits_rebind {
|
||||
typedef typename ptr_traits_rebind_to<T, U>::type type;
|
||||
struct ptr_rebind<T, U,
|
||||
typename ptr_void<typename T::template rebind<U> >::type> {
|
||||
typedef typename T::template rebind<U> type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
struct ptr_traits_value {
|
||||
struct ptr_value {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ptr_traits_value<void> {
|
||||
struct ptr_value<void> {
|
||||
typedef struct { } type;
|
||||
};
|
||||
|
||||
@@ -197,23 +143,20 @@ struct ptr_traits_value<void> {
|
||||
template<class T>
|
||||
struct pointer_traits {
|
||||
typedef T pointer;
|
||||
typedef typename detail::ptr_traits_element<T>::type element_type;
|
||||
typedef typename detail::ptr_traits_difference<T>::type difference_type;
|
||||
typedef typename detail::ptr_element<T>::type element_type;
|
||||
typedef typename detail::ptr_difference<T>::type difference_type;
|
||||
template<class U>
|
||||
struct rebind_to {
|
||||
typedef typename detail::ptr_traits_rebind<T, U>::type type;
|
||||
typedef typename detail::ptr_rebind<T, U>::type type;
|
||||
};
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class U>
|
||||
using rebind = typename detail::ptr_traits_rebind<T, U>::type;
|
||||
using rebind = typename detail::ptr_rebind<T, U>::type;
|
||||
#endif
|
||||
static pointer
|
||||
pointer_to(typename detail::ptr_traits_value<element_type>::type& v) {
|
||||
pointer_to(typename detail::ptr_value<element_type>::type& v) {
|
||||
return pointer::pointer_to(v);
|
||||
}
|
||||
static element_type* to_address(pointer v) BOOST_NOEXCEPT {
|
||||
return detail::ptr_traits_address(v.operator->());
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
@@ -230,15 +173,61 @@ struct pointer_traits<T*> {
|
||||
using rebind = U*;
|
||||
#endif
|
||||
static T*
|
||||
pointer_to(typename detail::ptr_traits_value<T>::type& v) BOOST_NOEXCEPT {
|
||||
return addressof(v);
|
||||
}
|
||||
static T* to_address(T* v) BOOST_NOEXCEPT {
|
||||
return v;
|
||||
pointer_to(typename detail::ptr_value<T>::type& v) BOOST_NOEXCEPT {
|
||||
return boost::addressof(v);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR inline T*
|
||||
to_address(T* v) BOOST_NOEXCEPT
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION)
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
inline T*
|
||||
ptr_address(T* v, int) BOOST_NOEXCEPT
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline auto
|
||||
ptr_address(const T& v, int) BOOST_NOEXCEPT
|
||||
-> decltype(boost::pointer_traits<T>::to_address(v))
|
||||
{
|
||||
return boost::pointer_traits<T>::to_address(v);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline auto
|
||||
ptr_address(const T& v, long) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::detail::ptr_address(v.operator->(), 0);
|
||||
}
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class T>
|
||||
inline auto
|
||||
to_address(const T& v) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::detail::ptr_address(v, 0);
|
||||
}
|
||||
#else
|
||||
template<class T>
|
||||
inline typename pointer_traits<T>::element_type*
|
||||
to_address(const T& v) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::to_address(v.operator->());
|
||||
}
|
||||
#endif
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2007 - 2013.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \file empty_deleter.hpp
|
||||
* \author Andrey Semashev
|
||||
* \date 22.04.2007
|
||||
*
|
||||
* This header contains an \c empty_deleter implementation. This is an empty
|
||||
* function object that receives a pointer and does nothing with it.
|
||||
* Such empty deletion strategy may be convenient, for example, when
|
||||
* constructing <tt>shared_ptr</tt>s that point to some object that should not be
|
||||
* deleted (i.e. a variable on the stack or some global singleton, like <tt>std::cout</tt>).
|
||||
*/
|
||||
|
||||
#ifndef BOOST_UTILITY_EMPTY_DELETER_HPP
|
||||
#define BOOST_UTILITY_EMPTY_DELETER_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/null_deleter.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma message "This header is deprecated, use boost/core/null_deleter.hpp instead."
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma message("This header is deprecated, use boost/core/null_deleter.hpp instead.")
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
//! A deprecated name for \c null_deleter
|
||||
typedef null_deleter empty_deleter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UTILITY_EMPTY_DELETER_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
# Boost.Core Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2014 Peter Dimov
|
||||
# Copyright (c) 2014, 2017 Peter Dimov
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -9,6 +9,10 @@
|
||||
import modules ;
|
||||
import testing ;
|
||||
|
||||
# quick test (for CI)
|
||||
run quick.cpp ;
|
||||
|
||||
# full test suite
|
||||
run addressof_test.cpp ;
|
||||
run addressof_test2.cpp ;
|
||||
run addressof_np_test.cpp ;
|
||||
@@ -64,15 +68,14 @@ run get_pointer_test.cpp ;
|
||||
|
||||
run lightweight_test_test.cpp ;
|
||||
run lightweight_test_test.cpp : : : <exception-handling>off : lightweight_test_test_no_except ;
|
||||
|
||||
run lightweight_test_test2.cpp ;
|
||||
run lightweight_test_all_eq_test.cpp ;
|
||||
run lightweight_test_all_with_test.cpp ;
|
||||
run lightweight_test_all_with_fail.cpp ;
|
||||
run lightweight_test_lt_le_test.cpp ;
|
||||
run lightweight_test_gt_ge_test.cpp ;
|
||||
|
||||
run lightweight_test_eq_nullptr.cpp ;
|
||||
run lightweight_test_test3.cpp ;
|
||||
|
||||
run-fail lightweight_test_fail.cpp ;
|
||||
run-fail lightweight_test_fail2.cpp ;
|
||||
@@ -110,12 +113,15 @@ compile-fail scoped_enum_compile_fail_conv_to_int.cpp ;
|
||||
|
||||
run underlying_type.cpp ;
|
||||
|
||||
run pointer_traits_to_address_test.cpp ;
|
||||
run pointer_traits_pointer_test.cpp ;
|
||||
run pointer_traits_element_type_test.cpp ;
|
||||
run pointer_traits_difference_type_test.cpp ;
|
||||
run pointer_traits_rebind_test.cpp ;
|
||||
run pointer_traits_pointer_to_test.cpp ;
|
||||
run to_address_test.cpp ;
|
||||
|
||||
run exchange_test.cpp ;
|
||||
run exchange_move_test.cpp ;
|
||||
|
||||
use-project /boost/core/swap : ./swap ;
|
||||
build-project ./swap ;
|
||||
|
||||
100
test/exchange_move_test.cpp
Normal file
100
test/exchange_move_test.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
Copyright 2018 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_RVALUE_REFERENCES)
|
||||
#include <boost/core/exchange.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
class C1 {
|
||||
public:
|
||||
explicit C1(int i)
|
||||
: i_(i) { }
|
||||
C1(C1&& c)
|
||||
: i_(c.i_) { }
|
||||
C1& operator=(C1&& c) {
|
||||
i_ = c.i_;
|
||||
return *this;
|
||||
}
|
||||
int i() const {
|
||||
return i_;
|
||||
}
|
||||
private:
|
||||
C1(const C1&);
|
||||
C1& operator=(const C1&);
|
||||
int i_;
|
||||
};
|
||||
|
||||
void test1()
|
||||
{
|
||||
C1 x(1);
|
||||
BOOST_TEST(boost::exchange(x, C1(2)).i() == 1);
|
||||
BOOST_TEST(x.i() == 2);
|
||||
}
|
||||
|
||||
class C2 {
|
||||
public:
|
||||
explicit C2(int i)
|
||||
: i_(i) { }
|
||||
operator C1() const {
|
||||
return C1(i_);
|
||||
}
|
||||
int i() const {
|
||||
return i_;
|
||||
}
|
||||
private:
|
||||
C2(const C2&);
|
||||
C2& operator=(const C2&);
|
||||
int i_;
|
||||
};
|
||||
|
||||
void test2()
|
||||
{
|
||||
C1 x(1);
|
||||
BOOST_TEST(boost::exchange(x, C2(2)).i() == 1);
|
||||
BOOST_TEST(x.i() == 2);
|
||||
}
|
||||
|
||||
class C3 {
|
||||
public:
|
||||
explicit C3(int i)
|
||||
: i_(i) { }
|
||||
C3(C3&& c)
|
||||
: i_(c.i_) { }
|
||||
C3& operator=(C1&& c) {
|
||||
i_ = c.i();
|
||||
return *this;
|
||||
}
|
||||
int i() const {
|
||||
return i_;
|
||||
}
|
||||
private:
|
||||
C3(const C3&);
|
||||
C3& operator=(const C3&);
|
||||
int i_;
|
||||
};
|
||||
|
||||
void test3()
|
||||
{
|
||||
C3 x(1);
|
||||
BOOST_TEST(boost::exchange(x, C1(2)).i() == 1);
|
||||
BOOST_TEST(x.i() == 2);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
89
test/exchange_test.cpp
Normal file
89
test/exchange_test.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright 2018 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/core/exchange.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
void test1()
|
||||
{
|
||||
int i = 1;
|
||||
BOOST_TEST(boost::exchange(i, 2) == 1);
|
||||
BOOST_TEST(i == 2);
|
||||
}
|
||||
|
||||
class C1 {
|
||||
public:
|
||||
explicit C1(int i)
|
||||
: i_(i) { }
|
||||
int i() const {
|
||||
return i_;
|
||||
}
|
||||
private:
|
||||
int i_;
|
||||
};
|
||||
|
||||
void test2()
|
||||
{
|
||||
C1 x(1);
|
||||
BOOST_TEST(boost::exchange(x, C1(2)).i() == 1);
|
||||
BOOST_TEST(x.i() == 2);
|
||||
}
|
||||
|
||||
class C2 {
|
||||
public:
|
||||
explicit C2(int i)
|
||||
: i_(i) { }
|
||||
operator C1() const {
|
||||
return C1(i_);
|
||||
}
|
||||
int i() const {
|
||||
return i_;
|
||||
}
|
||||
private:
|
||||
int i_;
|
||||
};
|
||||
|
||||
void test3()
|
||||
{
|
||||
C1 x(1);
|
||||
BOOST_TEST(boost::exchange(x, C2(2)).i() == 1);
|
||||
BOOST_TEST(x.i() == 2);
|
||||
}
|
||||
|
||||
class C3 {
|
||||
public:
|
||||
explicit C3(int i)
|
||||
: i_(i) { }
|
||||
C3(const C3& c)
|
||||
: i_(c.i_) { }
|
||||
C3& operator=(const C1& c) {
|
||||
i_ = c.i();
|
||||
return *this;
|
||||
}
|
||||
int i() const {
|
||||
return i_;
|
||||
}
|
||||
private:
|
||||
C3& operator=(const C3&);
|
||||
int i_;
|
||||
};
|
||||
|
||||
void test4()
|
||||
{
|
||||
C3 x(1);
|
||||
BOOST_TEST(boost::exchange(x, C1(2)).i() == 1);
|
||||
BOOST_TEST(x.i() == 2);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test4();
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -22,6 +22,9 @@ int main()
|
||||
BOOST_TEST_EQ( p1, nullptr );
|
||||
BOOST_TEST_NE( p2, nullptr );
|
||||
|
||||
BOOST_TEST_EQ( nullptr, p1 );
|
||||
BOOST_TEST_NE( nullptr, p2 );
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
147
test/lightweight_test_test3.cpp
Normal file
147
test/lightweight_test_test3.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
//
|
||||
// Test for lightweight_test.hpp
|
||||
//
|
||||
// Copyright (c) 2014, 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <ostream>
|
||||
|
||||
// EQ
|
||||
|
||||
struct eq1: private boost::noncopyable {};
|
||||
struct eq2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, eq1 const& )
|
||||
{
|
||||
return os << "eq1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, eq2 const& )
|
||||
{
|
||||
return os << "eq2()";
|
||||
}
|
||||
|
||||
bool operator==( eq1 const&, eq2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// NE
|
||||
|
||||
struct ne1: private boost::noncopyable {};
|
||||
struct ne2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, ne1 const& )
|
||||
{
|
||||
return os << "ne1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, ne2 const& )
|
||||
{
|
||||
return os << "ne2()";
|
||||
}
|
||||
|
||||
bool operator!=( ne1 const&, ne2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// LT
|
||||
|
||||
struct lt1: private boost::noncopyable {};
|
||||
struct lt2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, lt1 const& )
|
||||
{
|
||||
return os << "lt1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, lt2 const& )
|
||||
{
|
||||
return os << "lt2()";
|
||||
}
|
||||
|
||||
bool operator<( lt1 const&, lt2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// LE
|
||||
|
||||
struct le1: private boost::noncopyable {};
|
||||
struct le2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, le1 const& )
|
||||
{
|
||||
return os << "le1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, le2 const& )
|
||||
{
|
||||
return os << "le2()";
|
||||
}
|
||||
|
||||
bool operator<=( le1 const&, le2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// GT
|
||||
|
||||
struct gt1: private boost::noncopyable {};
|
||||
struct gt2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, gt1 const& )
|
||||
{
|
||||
return os << "gt1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, gt2 const& )
|
||||
{
|
||||
return os << "gt2()";
|
||||
}
|
||||
|
||||
bool operator>( gt1 const&, gt2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// GE
|
||||
|
||||
struct ge1: private boost::noncopyable {};
|
||||
struct ge2: private boost::noncopyable {};
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, ge1 const& )
|
||||
{
|
||||
return os << "ge1()";
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, ge2 const& )
|
||||
{
|
||||
return os << "ge2()";
|
||||
}
|
||||
|
||||
bool operator>=( ge1 const&, ge2 const& )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ( eq1(), eq2() );
|
||||
BOOST_TEST_NE( ne1(), ne2() );
|
||||
BOOST_TEST_LT( lt1(), lt2() );
|
||||
BOOST_TEST_LE( le1(), le2() );
|
||||
BOOST_TEST_GT( gt1(), gt2() );
|
||||
BOOST_TEST_GE( ge1(), ge2() );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
Copyright 2017 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/core/pointer_traits.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
class pointer {
|
||||
public:
|
||||
typedef typename boost::pointer_traits<T>::element_type element_type;
|
||||
pointer(T value)
|
||||
: value_(value) { }
|
||||
T operator->() const BOOST_NOEXCEPT {
|
||||
return value_;
|
||||
}
|
||||
private:
|
||||
T value_;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
{
|
||||
typedef int* type;
|
||||
type p = &i;
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef pointer<int*> type;
|
||||
type p(&i);
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef pointer<pointer<int*> > type;
|
||||
type p(&i);
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef void* type;
|
||||
type p = &i;
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef pointer<void*> type;
|
||||
type p(&i);
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef const int* type;
|
||||
type p = &i;
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
{
|
||||
typedef pointer<const int*> type;
|
||||
type p(&i);
|
||||
BOOST_TEST(boost::pointer_traits<type>::to_address(p) == &i);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/quick.cpp
Normal file
34
test/quick.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// quick.cpp - a quick (CI) test for Boost.Core
|
||||
//
|
||||
// Copyright 2017 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/core/explicit_operator_bool.hpp>
|
||||
#include <boost/get_pointer.hpp>
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/core/null_deleter.hpp>
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/core/underlying_type.hpp>
|
||||
#include <boost/visit_each.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
158
test/to_address_test.cpp
Normal file
158
test/to_address_test.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
Copyright 2017-2018 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/core/pointer_traits.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
class P1 {
|
||||
public:
|
||||
explicit P1(T* p)
|
||||
: p_(p) { }
|
||||
T* operator->() const BOOST_NOEXCEPT {
|
||||
return p_;
|
||||
}
|
||||
private:
|
||||
T* p_;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class P2 {
|
||||
public:
|
||||
explicit P2(T* p)
|
||||
: p_(p) { }
|
||||
P1<T> operator->() const BOOST_NOEXCEPT {
|
||||
return p_;
|
||||
}
|
||||
private:
|
||||
P1<T> p_;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION)
|
||||
template<class T>
|
||||
class P3 {
|
||||
public:
|
||||
explicit P3(T* p)
|
||||
: p_(p) { }
|
||||
T* get() const BOOST_NOEXCEPT {
|
||||
return p_;
|
||||
}
|
||||
private:
|
||||
T* p_;
|
||||
};
|
||||
|
||||
namespace boost {
|
||||
template<class T>
|
||||
struct pointer_traits<P3<T> > {
|
||||
static T* to_address(const P3<T>& p) BOOST_NOEXCEPT {
|
||||
return p.get();
|
||||
}
|
||||
};
|
||||
} /* boost */
|
||||
|
||||
template<class T>
|
||||
class P4 {
|
||||
public:
|
||||
explicit P4(T* p)
|
||||
: p_(p) { }
|
||||
T* operator->() const BOOST_NOEXCEPT {
|
||||
return 0;
|
||||
}
|
||||
T* get() const BOOST_NOEXCEPT {
|
||||
return p_;
|
||||
}
|
||||
private:
|
||||
int* p_;
|
||||
};
|
||||
|
||||
namespace boost {
|
||||
template<class T>
|
||||
struct pointer_traits<P4<T> > {
|
||||
static T* to_address(const P4<T>& p) BOOST_NOEXCEPT {
|
||||
return p.get();
|
||||
}
|
||||
};
|
||||
} /* boost */
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
|
||||
template<class T>
|
||||
class P5 {
|
||||
public:
|
||||
explicit P5(T* p)
|
||||
: p_(p) { }
|
||||
T* get() const BOOST_NOEXCEPT {
|
||||
return p_;
|
||||
}
|
||||
private:
|
||||
T* p_;
|
||||
};
|
||||
|
||||
namespace std {
|
||||
template<class T>
|
||||
struct pointer_traits<P5<T> > {
|
||||
static T* to_address(const P5<T>& p) BOOST_NOEXCEPT {
|
||||
return p.get();
|
||||
}
|
||||
};
|
||||
} /* std */
|
||||
|
||||
template<class T>
|
||||
class P6 {
|
||||
public:
|
||||
explicit P6(T* p)
|
||||
: p_(p) { }
|
||||
T* get() const BOOST_NOEXCEPT {
|
||||
return p_;
|
||||
}
|
||||
private:
|
||||
T* p_;
|
||||
};
|
||||
|
||||
namespace boost {
|
||||
template<class T>
|
||||
struct pointer_traits<P6<T> > {
|
||||
static T* to_address(const P6<T>& p) BOOST_NOEXCEPT {
|
||||
return p.get();
|
||||
}
|
||||
};
|
||||
} /* boost */
|
||||
|
||||
namespace std {
|
||||
template<class T>
|
||||
struct pointer_traits<P6<T> > {
|
||||
static T* to_address(const P6<T>& p) BOOST_NOEXCEPT {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
} /* std */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
BOOST_TEST(boost::to_address(&i) == &i);
|
||||
int* p = &i;
|
||||
BOOST_TEST(boost::to_address(p) == &i);
|
||||
P1<int> p1(&i);
|
||||
BOOST_TEST(boost::to_address(p1) == &i);
|
||||
P2<int> p2(&i);
|
||||
BOOST_TEST(boost::to_address(p2) == &i);
|
||||
#if !defined(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION)
|
||||
P3<int> p3(&i);
|
||||
BOOST_TEST(boost::to_address(p3) == &i);
|
||||
P4<int> p4(&i);
|
||||
BOOST_TEST(boost::to_address(p4) == &i);
|
||||
#if !defined(BOOST_NO_CXX11_POINTER_TRAITS)
|
||||
P5<int> p5(&i);
|
||||
BOOST_TEST(boost::to_address(p5) == &i);
|
||||
P6<int> p6(&i);
|
||||
BOOST_TEST(boost::to_address(p6) == &i);
|
||||
#endif
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user