1
0
forked from boostorg/core

Compare commits

...

31 Commits

Author SHA1 Message Date
Peter Dimov
295b72cbc0 Disable -Waddress in lightweight_test_test.cpp 2020-04-28 02:04:29 +03:00
Peter Dimov
0a6b8e667b Add warnings=pedantic to the rest of the lwt tests 2020-04-27 22:29:28 +03:00
Peter Dimov
bb0ef6d41e Disable variadic macros warning in lightweight_test_trait.hpp 2020-04-27 19:17:48 +03:00
Peter Dimov
2dd51f248b Use warnings=pedantic for some lwt tests 2020-04-27 18:47:45 +03:00
Glen Fernandes
8fe9805792 Avoid C99 stdint macros in default_allocator 2020-04-26 19:49:01 -04:00
Glen Fernandes
6624532550 Correct spelling in documentation 2020-04-14 19:40:41 -04:00
Glen Fernandes
c31e23b362 Implement allocator access utilities 2020-04-14 14:52:30 -04:00
Glen Fernandes
690514e87c Use BOOST_INLINE_CONSTEXPR in empty_value 2020-04-05 19:55:24 -04:00
Peter Dimov
5a5d2adda0 Go back to ::quick_exit, but include the correct <stdlib.h>; on Linux and Cygwin, quick_exit is not brought into std in C++03 mode 2020-03-23 15:54:23 +02:00
Peter Dimov
10c01d0d56 Use std::quick_exit instead of ::quick_exit 2020-03-23 05:21:08 +02:00
Peter Dimov
27d8ef1286 Change BOOST_TEST to match BOOST_TEST_EQ et al, in order to avoid 'expression result unused' warning from Clang 2020-02-21 19:46:42 +02:00
Glen Fernandes
b5c2726d1b Include cstddef in pointer_traits 2020-02-17 22:13:10 -05:00
Peter Dimov
0eecbda0b1 Remove unnecessary struct 2020-02-17 05:21:20 +02:00
Peter Dimov
2a471c3417 Add test for BOOST_TEST_* macros return values 2020-02-16 20:52:59 +02:00
Peter Dimov
5ca752323f Return a bool result from the BOOST_TEST_* macros, f.ex. to allow chaining with && 2020-02-16 20:52:12 +02:00
Peter Dimov
13e9d3d4d9 Fix typo in test/Jamfile 2020-02-16 20:17:52 +02:00
Peter Dimov
f3cd812ccb Disable 'should return report_errors()' test on CMake, because CTest doesn't like abort() 2020-01-02 21:05:07 +02:00
Peter Dimov
8f2841de83 Restrict clang-3.5 to 03/11 to avoid ::gets error 2020-01-02 21:04:06 +02:00
Peter Dimov
bf5778403e Update tools/cmake 2020-01-02 20:30:03 +02:00
Peter Dimov
fc285464aa Update Travis to Xenial 2020-01-02 20:23:07 +02:00
Peter Dimov
750625272f Add CMake tests 2020-01-02 20:00:11 +02:00
Peter Dimov
bda2b9b4b1 Disable _CrtDbgReport message boxes, displayed on debug iterator violations 2020-01-01 17:17:43 +02:00
Glen Fernandes
ac4c781cac Include lightweight_test from core and workaround from config 2020-01-01 09:02:46 -05:00
Peter Dimov
72ca0d8664 Add CMake install support 2019-12-28 18:47:11 +02:00
Glen Fernandes
253b07f630 Add empty_init constant to documentation 2019-12-15 12:46:55 -05:00
Peter Dimov
e59271fdc2 Check BOOST_MSVC in addition to __cplusplus, because msvc doesn't define __cplusplus correctly 2019-12-02 02:15:55 +02:00
Nikita Kniazev
bc82adcd0b Remove implementation specific handling 2019-12-02 01:11:04 +03:00
Nikita Kniazev
868cb07578 Try to include std::swap from the most lightweight header
Based on Boost.Move idea
2019-12-01 17:28:07 +03:00
Andrey Semashev
38f71361fb Add a convenience instance of empty_init_t (#65)
* Added a convenience instance of empty_init_t.

Closes https://github.com/boostorg/core/issues/63.
2019-11-23 21:00:59 -05:00
Peter Dimov
6d62fb5f5e Remove clang-win 32 bit, because it fails to link with 'unable to load mspdbcore.dll (error code: 126)' 2019-11-23 21:52:53 +02:00
Peter Dimov
0d71f42365 Separate Appveyor Clang configurations 2019-11-23 21:11:26 +02:00
91 changed files with 1834 additions and 163 deletions

View File

@@ -4,9 +4,7 @@
language: cpp
sudo: false
dist: trusty
dist: xenial
branches:
only:
@@ -129,12 +127,12 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
compiler: g++-9
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-8
- g++-9
sources:
- ubuntu-toolchain-r-test
@@ -143,13 +141,31 @@ matrix:
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:
apt:
packages:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.4
- os: linux
dist: trusty
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
@@ -160,7 +176,16 @@ matrix:
apt:
packages:
- clang-3.6
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
@@ -171,7 +196,6 @@ matrix:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
@@ -182,7 +206,6 @@ matrix:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
@@ -195,7 +218,6 @@ matrix:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-5.0
@@ -206,7 +228,6 @@ matrix:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-6.0
@@ -217,7 +238,6 @@ matrix:
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-7
@@ -228,7 +248,7 @@ matrix:
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-7
- llvm-toolchain-xenial-7
- os: linux
compiler: clang++-8
@@ -239,10 +259,9 @@ matrix:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-8
- llvm-toolchain-xenial-8
- os: linux
dist: xenial
compiler: clang++-9
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
addons:
@@ -255,18 +274,18 @@ matrix:
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
compiler: clang++-6.0
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
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-6.0
- libstdc++-5-dev
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- llvm-toolchain-xenial-8
- os: linux
dist: trusty
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
addons:
@@ -276,6 +295,7 @@ matrix:
- libc++abi-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:
@@ -305,14 +325,36 @@ matrix:
osx_image: xcode10.1
- os: linux
compiler: g++
env: CMAKE_SUBDIR_TEST=1
env: CMAKE_TEST=1
script:
- cd libs/core/test/cmake_subdir_test && mkdir __build__ && cd __build__
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=core ..
- ctest --output-on-failure -R boost_core
- os: linux
env: CMAKE_SUBDIR_TEST=1
install:
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
script:
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- 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="assert;config;core" -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build . --target install
- cd ../libs/core/test/cmake_install_test && mkdir __build__ && cd __build__
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
@@ -328,6 +370,7 @@ install:
- git submodule init libs/type_traits
- git submodule init tools/build
- git submodule init tools/boost_install
- git submodule init tools/cmake
- git submodule update --jobs 4
- cp -r $TRAVIS_BUILD_DIR/* libs/core
- ./bootstrap.sh

View File

@@ -1,13 +1,10 @@
# Copyright 2018 Peter Dimov
# 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
# 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(BoostCore LANGUAGES CXX)
project(boost_core VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_core INTERFACE)
add_library(Boost::core ALIAS boost_core)
@@ -15,7 +12,20 @@ add_library(Boost::core ALIAS boost_core)
target_include_directories(boost_core INTERFACE include)
target_link_libraries(boost_core
INTERFACE
Boost::assert
Boost::config
INTERFACE
Boost::assert
Boost::config
)
if(BOOST_SUPERPROJECT_VERSION)
include(BoostInstall)
boost_install(TARGETS boost_core HEADER_DIRECTORY include/)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@@ -22,10 +22,17 @@ environment:
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1,clang-win
TOOLSET: msvc-14.1
ADDRMD: 32,64
CXXSTD: 14,17
# clang-win 32 bit fails to link with "unable to load mspdbcore.dll (error code: 126)"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
ADDRMD: 64
CXXSTD: 14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
ADDRMD: 32,64

244
doc/allocator_access.qbk Normal file
View File

@@ -0,0 +1,244 @@
[/
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section Allocator Access]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header `<boost/core/allocator_access.hpp>` provides the class and function
templates to simplify allocator use. It provides the same functionality as the
C++ standard library `std::allocator_traits` but with individual templates for
each allocator feature.
This implementation supports C++03 and above. These facilities also simplify
existing libraries by avoiding having to check for `BOOST_NO_CXX11_ALLOCATOR`
and conditionally use `std::allocator_traits`.
[endsect]
[section Examples]
The following example shows these utilities used in the definition of
an allocator-aware container class:
```
template<class T, class A = boost::default_allocator<T> >
class container
: boost::empty_value<typename boost::allocator_rebind<A, T>::type> {
public:
typedef T value_type;
typedef A allocator_type;
typedef typename boost::allocator_size_type<A>::type size_type;
typedef typename boost::allocator_difference_type<A>::type difference_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename boost::allocator_pointer<A>::type pointer;
typedef typename boost::allocator_const_pointer<A>::type const_pointer;
// ...
};
```
In C++11 or above, aliases such as `boost::allocator_pointer_t<A>` can be used
instead of `typename boost::allocator_pointer<A>::type`.
[endsect]
[section Reference]
```
namespace boost {
template<class A>
struct allocator_value_type;
template<class A>
using allocator_value_type_t = typename allocator_value_type<A>::type;
template<class A>
struct allocator_pointer;
template<class A>
using allocator_pointer_t = typename allocator_pointer<A>::type;
template<class A>
struct allocator_const_pointer;
template<class A>
using allocator_const_pointer_t = typename allocator_const_pointer<A>::type;
template<class A>
struct allocator_void_pointer;
template<class A>
using allocator_void_pointer_t = typename allocator_void_pointer<A>::type;
template<class A>
struct allocator_const_void_pointer;
template<class A>
using allocator_const_void_pointer_t =
typename allocator_const_void_pointer<A>::type;
template<class A>
struct allocator_difference_type;
template<class A>
using allocator_difference_type_t =
typename allocator_difference_type<A>::type;
template<class A>
struct allocator_size_type;
template<class A>
using allocator_size_type_t = typename allocator_size_type<A>::type;
template<class A>
struct allocator_propagate_on_container_copy_assignment;
template<class A>
using allocator_propagate_on_container_copy_assignment_t =
typename allocator_propagate_on_container_copy_assignment<A>::type;
template<class A>
struct allocator_propagate_on_container_move_assignment;
template<class A>
using allocator_propagate_on_container_move_assignment_t =
typename allocator_propagate_on_container_move_assignment<A>::type;
template<class A>
struct allocator_propagate_on_container_swap;
template<class A>
using allocator_propagate_on_container_swap_t =
typename allocator_propagate_on_container_swap<A>::type;
template<class A>
struct allocator_is_always_equal;
template<class A>
using allocator_is_always_equal_t =
typename allocator_is_always_equal<A>::type;
template<class A, class T>
struct allocator_rebind;
template<class A, class T>
using allocator_rebind_t = typename allocator_rebind<A, T>::type;
template<class A>
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n);
template<class A>
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n,
allocator_const_void_pointer_t<A> hint);
template<class A>
void allocator_deallocate(A& a, allocator_pointer_t<A> p,
allocator_size_type_t<A> n);
template<class A, class T, class... Args>
void allocator_construct(A& a, T*p, Args&&... args);
template<class A, class T>
void allocator_destroy(A& a, T* p);
template<class A>
allocator_size_type_t<A> allocator_max_size(const A& a);
template<class A>
A allocator_select_on_container_copy_construction(const A& a);
} // boost
```
[section Types]
[variablelist
[[`template<class A> struct allocator_value_type;`]
[The member `type` is `A::value_type`.]]
[[`template<class A> struct allocator_pointer;`]
[The member `type` is `A::pointer` if valid, otherwise `A::value_type*`.]]
[[`template<class A> struct allocator_const_pointer;`]
[The member `type` is `A::const_pointer` if valid, otherwise
`pointer_traits<allocator_pointer_t<A> >::rebind<const
allocator_value_type_t<A> >`.]]
[[`template<class A> struct allocator_void_pointer;`]
[The member `type` is `A::void_pointer` if valid, otherwise
`pointer_traits<allocator_pointer_t<A> >::rebind<void>`.]]
[[`template<class A> struct allocator_const_void_pointer;`]
[The member `type` is `A::const_void_pointer` if valid, otherwise
`pointer_traits<allocator_pointer_t<A> >::rebind<const void>`.]]
[[`template<class A> struct allocator_difference_type;`]
[The member `type` is `A::difference_type` if valid, otherwise
`pointer_traits<allocator_pointer_t<A> >::difference_type`.]]
[[`template<class A> struct allocator_size_type;`]
[The member `type` is `A::size_type` if valid, otherwise
`std::make_unsigned_t<allocator_difference_type_t<A> >`.]]
[[`template<class A> struct allocator_propagate_on_container_copy_assignment;`]
[The member `type` is `A::propagate_on_container_copy_assignment` if valid,
otherwise `std::false_type`.]]
[[`template<class A> struct allocator_propagate_on_container_move_assignment;`]
[The member `type` is `A::propagate_on_container_move_assignment` if valid,
otherwise `std::false_type`.]]
[[`template<class A> struct allocator_propagate_on_container_swap;`]
[The member `type` is `A::propagate_on_container_swap` if valid, otherwise
`std::false_type`.]]
[[`template<class A> struct allocator_is_always_equal;`]
[The member `type` is `A::is_always_equal` if valid, otherwise
`std::is_empty<A>::type`.]]
[[`template<class A, class T> struct allocator_rebind;`]
[The member `type` is `A::rebind<T>::other` if valid, otherwise `A<T, Args>`
if this `A` is `A<U, Args>`.]]]
[endsect]
[section Functions]
[variablelist
[[`template<class A>
allocator_pointer_t<A> allocator_allocate(A& a, allocator_size_type_t<A> n);`]
[Calls `a.allocate(n)`.]]
[[`template<class A> allocator_pointer_t<A> allocator_allocate(A& a,
allocator_size_type_t<A> n, allocator_const_void_pointer_t<A> hint);`]
[Calls `a.allocate(n, hint)` if valid, otherwise calls `a.allocate(n)`.]]
[[`template<class A> void allocator_deallocate(A& a, allocator_pointer_t<A> p,
allocator_size_type_t<A> n);`]
[Calls `a.deallocate(p, n)`.]]
[[`template<class A, class T, class... Args>
void allocator_construct(A& a, T*p, Args&&... args);`]
[Calls `a.construct(p, std::forward<Args>(args)...)` if valid, otherwise calls
`::new(static_cast<void*>(p)) T(std::forward<Args>(args)...)`.]]
[[`template<class A, class T> void allocator_destroy(A& a, T* p);`]
[Calls `a.destroy(p)` if valid, otherwise calls `p->~T()`.]]
[[`template<class A> allocator_size_type_t<A> allocator_max_size(const A& a);`]
[Returns `a.max_size()` if valid, otehrwise returns
`std::numeric_limits<allocator_size_type_t<A> >::max() /
sizeof(A::value_type)`.]]
[[`template<class A> A allocator_select_on_container_copy_construction(const
A& a);`]
[Returns `a.select_on_container_copy_construction()` if valid, otherwise
returns `a`.]]]
[endsect]
[endsect]
[section Acknowledgments]
Glen Fernandes implemented the allocator access utilities.
[endsect]
[endsect]

View File

@@ -39,6 +39,7 @@ criteria for inclusion is that the utility component be:
[endsect]
[include addressof.qbk]
[include allocator_access.qbk]
[include alloc_construct.qbk]
[include checked_delete.qbk]
[include default_allocator.qbk]

View File

@@ -97,6 +97,8 @@ public:
T& get() noexcept;
};
inline constexpr empty_init_t empty_init{ };
} /* boost */
```

View File

@@ -0,0 +1,545 @@
/*
Copyright 2020 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_ALLOCATOR_ACCESS_HPP
#define BOOST_CORE_ALLOCATOR_ACCESS_HPP
#include <boost/core/pointer_traits.hpp>
#include <limits>
#include <new>
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
#include <type_traits>
#endif
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
#if !defined(BOOST_NO_CXX11_DECLTYPE) && \
!defined(BOOST_NO_SFINAE_EXPR) && \
(!defined(BOOST_MSVC) || BOOST_MSVC >= 1910)
#define BOOST_CORE_ALLOCATOR_DETECTION
#endif
namespace boost {
template<class A>
struct allocator_value_type {
typedef typename A::value_type type;
};
namespace detail {
template<class>
struct alloc_void {
typedef void type;
};
} /* detail */
template<class A, class = void>
struct allocator_pointer {
typedef typename A::value_type* type;
};
template<class A>
struct allocator_pointer<A,
typename detail::alloc_void<typename A::pointer>::type> {
typedef typename A::pointer type;
};
template<class A, class = void>
struct allocator_const_pointer {
typedef typename pointer_traits<typename
allocator_pointer<A>::type>::template
rebind_to<const typename A::value_type>::type type;
};
template<class A>
struct allocator_const_pointer<A,
typename detail::alloc_void<typename A::const_pointer>::type> {
typedef typename A::const_pointer type;
};
template<class A, class = void>
struct allocator_void_pointer {
typedef typename pointer_traits<typename
allocator_pointer<A>::type>::template
rebind_to<void>::type type;
};
template<class A>
struct allocator_void_pointer<A,
typename detail::alloc_void<typename A::void_pointer>::type> {
typedef typename A::void_pointer type;
};
template<class A, class = void>
struct allocator_const_void_pointer {
typedef typename pointer_traits<typename
allocator_pointer<A>::type>::template
rebind_to<const void>::type type;
};
template<class A>
struct allocator_const_void_pointer<A,
typename detail::alloc_void<typename A::const_void_pointer>::type> {
typedef typename A::const_void_pointer type;
};
template<class A, class = void>
struct allocator_difference_type {
typedef typename pointer_traits<typename
allocator_pointer<A>::type>::difference_type type;
};
template<class A>
struct allocator_difference_type<A,
typename detail::alloc_void<typename A::difference_type>::type> {
typedef typename A::difference_type type;
};
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
template<class A, class = void>
struct allocator_size_type {
typedef typename std::make_unsigned<typename
allocator_difference_type<A>::type>::type type;
};
template<class A>
struct allocator_size_type<A,
typename detail::alloc_void<typename A::size_type>::type> {
typedef typename A::size_type type;
};
#else
template<class A>
struct allocator_size_type {
typedef typename A::size_type type;
};
#endif
namespace detail {
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
typedef std::false_type alloc_false_type;
#else
struct alloc_false_type {
BOOST_STATIC_CONSTEXPR bool value = false;
};
#endif
} /* detail */
template<class A, class = void>
struct allocator_propagate_on_container_copy_assignment {
typedef detail::alloc_false_type type;
};
template<class A>
struct allocator_propagate_on_container_copy_assignment<A,
typename detail::alloc_void<typename
A::propagate_on_container_copy_assignment>::type> {
typedef typename A::propagate_on_container_copy_assignment type;
};
template<class A, class = void>
struct allocator_propagate_on_container_move_assignment {
typedef detail::alloc_false_type type;
};
template<class A>
struct allocator_propagate_on_container_move_assignment<A,
typename detail::alloc_void<typename
A::propagate_on_container_move_assignment>::type> {
typedef typename A::propagate_on_container_move_assignment type;
};
template<class A, class = void>
struct allocator_propagate_on_container_swap {
typedef detail::alloc_false_type type;
};
template<class A>
struct allocator_propagate_on_container_swap<A,
typename detail::alloc_void<typename
A::propagate_on_container_swap>::type> {
typedef typename A::propagate_on_container_swap type;
};
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
template<class A, class = void>
struct allocator_is_always_equal {
typedef typename std::is_empty<A>::type type;
};
#else
template<class A, class = void>
struct allocator_is_always_equal {
typedef typename detail::alloc_false_type type;
};
#endif
template<class A>
struct allocator_is_always_equal<A,
typename detail::alloc_void<typename A::is_always_equal>::type> {
typedef typename A::is_always_equal type;
};
namespace detail {
template<class, class>
struct alloc_to { };
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<template<class, class...> class A, class T, class U, class... V>
struct alloc_to<A<U, V...>, T> {
typedef A<T, V...> type;
};
#else
template<template<class> class A, class T, class U>
struct alloc_to<A<U>, T> {
typedef A<T> type;
};
template<template<class, class> class A, class T, class U1, class U2>
struct alloc_to<A<U1, U2>, T> {
typedef A<T, U2> type;
};
template<template<class, class, class> class A, class T, class U1, class U2,
class U3>
struct alloc_to<A<U1, U2, U3>, T> {
typedef A<T, U2, U3> type;
};
#endif
} /* detail */
template<class A, class T, class = void>
struct allocator_rebind {
typedef typename detail::alloc_to<A, T>::type type;
};
template<class A, class T>
struct allocator_rebind<A, T,
typename detail::alloc_void<typename A::template rebind<T>::other>::type> {
typedef typename A::template rebind<T>::other type;
};
template<class A>
inline typename allocator_pointer<A>::type
allocator_allocate(A& a, typename allocator_size_type<A>::type n)
{
return a.allocate(n);
}
namespace detail {
template<bool, class = void>
struct alloc_if { };
template<class R>
struct alloc_if<true, R> {
typedef R type;
};
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
template<class T>
T alloc_declval() BOOST_NOEXCEPT;
#endif
template<class, class = void>
struct alloc_has_allocate {
BOOST_STATIC_CONSTEXPR bool value = false;
};
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
template<class A>
struct alloc_has_allocate<A, typename
alloc_void<decltype(alloc_declval<A&>().allocate(alloc_declval<typename
boost::allocator_size_type<A>::type>(), alloc_declval<typename
boost::allocator_const_void_pointer<A>::type>()))>::type> {
BOOST_STATIC_CONSTEXPR bool value = true;
};
#endif
} /* detail */
template<class A>
inline typename detail::alloc_if<detail::alloc_has_allocate<A>::value,
typename allocator_pointer<A>::type>::type
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
typename allocator_const_void_pointer<A>::type h)
{
return a.allocate(n, h);
}
template<class A>
inline typename detail::alloc_if<!detail::alloc_has_allocate<A>::value,
typename allocator_pointer<A>::type>::type
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
typename allocator_const_void_pointer<A>::type)
{
return a.allocate(n);
}
template<class A>
inline void
allocator_deallocate(A& a, typename allocator_pointer<A>::type p,
typename allocator_size_type<A>::type n)
{
a.deallocate(p, n);
}
namespace detail {
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class...>
struct alloc_types { };
#else
template<class>
struct alloc_types { };
#endif
template<class, class, class, class = void>
struct alloc_has_construct {
BOOST_STATIC_CONSTEXPR bool value = false;
};
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class A, class T, class... U>
struct alloc_has_construct<A, T, alloc_types<U...>, typename
alloc_void<decltype(alloc_declval<A&>().construct(alloc_declval<T*>(),
alloc_declval<U>()...))>::type> {
BOOST_STATIC_CONSTEXPR bool value = true;
};
#else
template<class A, class T, class U>
struct alloc_has_construct<A, T, alloc_types<U>, typename
alloc_void<decltype(alloc_declval<A&>().construct(alloc_declval<T*>(),
alloc_declval<U>()))>::type> {
BOOST_STATIC_CONSTEXPR bool value = true;
};
#endif
#endif
} /* detail */
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class A, class T, class... Args>
inline typename detail::alloc_if<detail::alloc_has_construct<A, T,
detail::alloc_types<Args...> >::value>::type
allocator_construct(A& a, T*p, Args&&... args)
{
a.construct(p, std::forward<Args>(args)...);
}
template<class A, class T, class... Args>
inline typename detail::alloc_if<!detail::alloc_has_construct<A, T,
detail::alloc_types<Args...> >::value>::type
allocator_construct(A&, T* p, Args&&... args)
{
::new(static_cast<void*>(p)) T(std::forward<Args>(args)...);
}
#else
template<class A, class T, class V>
inline typename detail::alloc_if<detail::alloc_has_construct<A, T,
detail::alloc_types<V> >::value>::type
allocator_construct(A& a, T*p, V&& v)
{
a.construct(p, std::forward<V>(v));
}
template<class A, class T, class V>
inline typename detail::alloc_if<!detail::alloc_has_construct<A, T,
detail::alloc_types<V> >::value>::type
allocator_construct(A&, T* p, V&& v)
{
::new(static_cast<void*>(p)) T(std::forward<V>(v));
}
#endif
#else
template<class A, class T, class V>
inline typename detail::alloc_if<detail::alloc_has_construct<A, T,
detail::alloc_types<V> >::value>::type
allocator_construct(A& a, T*p, const V& v)
{
a.construct(p, v);
}
template<class A, class T, class V>
inline typename detail::alloc_if<!detail::alloc_has_construct<A, T,
detail::alloc_types<V> >::value>::type
allocator_construct(A&, T* p, const V& v)
{
::new(static_cast<void*>(p)) T(v);
}
template<class A, class T, class V>
inline typename detail::alloc_if<detail::alloc_has_construct<A, T,
detail::alloc_types<V> >::value>::type
allocator_construct(A& a, T*p, V& v)
{
a.construct(p, v);
}
template<class A, class T, class V>
inline typename detail::alloc_if<!detail::alloc_has_construct<A, T,
detail::alloc_types<V> >::value>::type
allocator_construct(A&, T* p, V& v)
{
::new(static_cast<void*>(p)) T(v);
}
#endif
namespace detail {
template<class, class, class = void>
struct alloc_has_destroy {
BOOST_STATIC_CONSTEXPR bool value = false;
};
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
template<class A, class T>
struct alloc_has_destroy<A, T, typename
alloc_void<decltype(alloc_declval<A&>().
destroy(alloc_declval<T*>()))>::type> {
BOOST_STATIC_CONSTEXPR bool value = true;
};
#endif
} /* detail */
template<class A, class T>
inline typename detail::alloc_if<detail::alloc_has_destroy<A, T>::value>::type
allocator_destroy(A& a, T*p)
{
a.destroy(p);
}
template<class A, class T>
inline typename detail::alloc_if<!detail::alloc_has_destroy<A, T>::value>::type
allocator_destroy(A&, T* p)
{
p->~T();
(void)p;
}
namespace detail {
template<class, class = void>
struct alloc_has_max_size {
BOOST_STATIC_CONSTEXPR bool value = false;
};
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
template<class A>
struct alloc_has_max_size<A,
typename alloc_void<decltype(alloc_declval<const
A&>().max_size())>::type> {
BOOST_STATIC_CONSTEXPR bool value = true;
};
#endif
} /* detail */
template<class A>
inline typename detail::alloc_if<detail::alloc_has_max_size<A>::value,
typename allocator_size_type<A>::type>::type
allocator_max_size(const A& a)
{
return a.max_size();
}
template<class A>
inline typename detail::alloc_if<!detail::alloc_has_max_size<A>::value,
typename allocator_size_type<A>::type>::type
allocator_max_size(const A&)
{
return std::numeric_limits<typename allocator_size_type<A>::type>::max() /
sizeof(typename A::value_type);
}
namespace detail {
template<class, class = void>
struct alloc_has_soccc {
BOOST_STATIC_CONSTEXPR bool value = false;
};
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
template<class A>
struct alloc_has_soccc<A,
typename alloc_void<decltype(alloc_declval<const
A&>().select_on_container_copy_construction())>::type> {
BOOST_STATIC_CONSTEXPR bool value = true;
};
#endif
} /* detail */
template<class A>
inline typename detail::alloc_if<detail::alloc_has_soccc<A>::value, A>::type
allocator_select_on_container_copy_construction(const A& a)
{
return a.select_on_container_copy_construction();
}
template<class A>
inline typename detail::alloc_if<!detail::alloc_has_soccc<A>::value, A>::type
allocator_select_on_container_copy_construction(const A& a)
{
return a;
}
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template<class A>
using allocator_value_type_t = typename allocator_value_type<A>::type;
template<class A>
using allocator_pointer_t = typename allocator_pointer<A>::type;
template<class A>
using allocator_const_pointer_t = typename allocator_const_pointer<A>::type;
template<class A>
using allocator_void_pointer_t = typename allocator_void_pointer<A>::type;
template<class A>
using allocator_const_void_pointer_t =
typename allocator_const_void_pointer<A>::type;
template<class A>
using allocator_difference_type_t =
typename allocator_difference_type<A>::type;
template<class A>
using allocator_size_type_t = typename allocator_size_type<A>::type;
template<class A>
using allocator_propagate_on_container_copy_assignment_t =
typename allocator_propagate_on_container_copy_assignment<A>::type;
template<class A>
using allocator_propagate_on_container_move_assignment_t =
typename allocator_propagate_on_container_move_assignment<A>::type;
template<class A>
using allocator_propagate_on_container_swap_t =
typename allocator_propagate_on_container_swap<A>::type;
template<class A>
using allocator_is_always_equal_t =
typename allocator_is_always_equal<A>::type;
template<class A, class T>
using allocator_rebind_t = typename allocator_rebind<A, T>::type;
#endif
} /* boost */
#endif

View File

@@ -9,8 +9,8 @@ Distributed under the Boost Software License, Version 1.0.
#define BOOST_CORE_DEFAULT_ALLOCATOR_HPP
#include <boost/config.hpp>
#include <limits>
#include <new>
#include <climits>
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000
#define BOOST_CORE_NO_CXX11_ALLOCATOR
@@ -81,16 +81,12 @@ struct default_allocator {
BOOST_CONSTEXPR default_allocator(const default_allocator<U>&)
BOOST_NOEXCEPT { }
#if defined(PTRDIFF_MAX) && defined(SIZE_MAX)
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
return PTRDIFF_MAX < SIZE_MAX / sizeof(T)
? PTRDIFF_MAX : SIZE_MAX / sizeof(T);
return std::numeric_limits<std::ptrdiff_t>::max()
< std::numeric_limits<std::size_t>::max() / sizeof(T)
? std::numeric_limits<std::ptrdiff_t>::max()
: std::numeric_limits<std::size_t>::max() / sizeof(T);
}
#else
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
return ~static_cast<std::size_t>(0) / sizeof(T);
}
#endif
#if !defined(BOOST_NO_EXCEPTIONS)
T* allocate(std::size_t n) {

View File

@@ -139,6 +139,8 @@ public:
using empty_::empty_value;
BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t();
} /* boost */
#endif

View File

@@ -30,6 +30,10 @@
#include <cstring>
#include <cstddef>
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
# include <crtdbg.h>
#endif
// IDE's like Visual Studio perform better if output goes to std::cout or
// some other stream, so allow user to configure output stream:
#ifndef BOOST_LIGHTWEIGHT_TEST_OSTREAM
@@ -48,7 +52,13 @@ public:
: report_(false)
, errors_(0) {
#if defined(_MSC_VER) && (_MSC_VER > 1310)
// disable message boxes on assert(), abort()
::_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
// disable message boxes on iterator debugging violations
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
#endif
}
@@ -83,12 +93,21 @@ inline int& test_errors()
return test_results().errors();
}
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
inline bool test_impl(char const * expr, char const * file, int line, char const * function, bool v)
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr << "' failed in function '"
<< function << "'" << std::endl;
++test_results().errors();
if( v )
{
test_results();
return true;
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr << "' failed in function '"
<< function << "'" << std::endl;
++test_results().errors();
return false;
}
}
inline void error_impl(char const * msg, char const * file, int line, char const * function)
@@ -174,13 +193,14 @@ struct lw_test_ge {
};
template<class BinaryPredicate, class T, class U>
inline void test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
char const * file, int line, char const * function,
T const & t, U const & u)
{
if( pred(t, u) )
{
test_results();
return true;
}
else
{
@@ -189,15 +209,17 @@ inline void test_with_impl(BinaryPredicate pred, char const * expr1, char const
<< "' ('" << test_output_impl(t) << "' " << pred.op() << " '" << test_output_impl(u)
<< "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
return false;
}
}
inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
inline bool test_cstr_eq_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, char const * const t, char const * const u )
{
if( std::strcmp(t, u) == 0 )
{
test_results();
return true;
}
else
{
@@ -205,15 +227,17 @@ inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
<< file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' ('" << t
<< "' == '" << u << "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
return false;
}
}
inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
inline bool test_cstr_ne_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, char const * const t, char const * const u )
{
if( std::strcmp(t, u) != 0 )
{
test_results();
return true;
}
else
{
@@ -221,11 +245,12 @@ inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
<< file << "(" << line << "): test '" << expr1 << " != " << expr2 << "' ('" << t
<< "' != '" << u << "') failed in function '" << function << "'" << std::endl;
++test_results().errors();
return false;
}
}
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2>
void test_all_eq_impl(FormattedOutputFunction& output,
bool test_all_eq_impl(FormattedOutputFunction& output,
char const * file, int line, char const * function,
InputIterator1 first_begin, InputIterator1 first_end,
InputIterator2 second_begin, InputIterator2 second_end)
@@ -284,16 +309,18 @@ void test_all_eq_impl(FormattedOutputFunction& output,
if (error_count == 0)
{
test_results();
return true;
}
else
{
output << std::endl;
++test_results().errors();
return false;
}
}
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2, typename BinaryPredicate>
void test_all_with_impl(FormattedOutputFunction& output,
bool test_all_with_impl(FormattedOutputFunction& output,
char const * file, int line, char const * function,
InputIterator1 first_begin, InputIterator1 first_end,
InputIterator2 second_begin, InputIterator2 second_end,
@@ -353,11 +380,13 @@ void test_all_with_impl(FormattedOutputFunction& output,
if (error_count == 0)
{
test_results();
return true;
}
else
{
output << std::endl;
++test_results().errors();
return false;
}
}
@@ -397,7 +426,7 @@ inline int report_errors()
} // namespace boost
#define BOOST_TEST(expr) ((expr)? (void)::boost::detail::test_results(): ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
#define BOOST_TEST(expr) ( ::boost::detail::test_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (expr)? true: false) )
#define BOOST_TEST_NOT(expr) BOOST_TEST(!(expr))
#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )

View File

@@ -126,6 +126,12 @@ template<class T1, class T2> inline void test_trait_same_impl( char const * type
#define BOOST_TEST_TRAIT_TRUE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, true, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
#define BOOST_TEST_TRAIT_FALSE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, false, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
#if defined(__GNUC__)
// ignoring -Wvariadic-macros with #pragma doesn't work under GCC
# pragma GCC system_header
#endif
#define BOOST_TEST_TRAIT_SAME(...) ( ::boost::detail::test_trait_same_impl(#__VA_ARGS__, ::boost::core::is_same<__VA_ARGS__>(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_TRAIT_HPP

View File

@@ -13,6 +13,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <memory>
#else
#include <boost/core/addressof.hpp>
#include <cstddef>
#endif
namespace boost {

View File

@@ -16,7 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#include <cstdlib>
#include <stdlib.h>
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)

View File

@@ -23,8 +23,11 @@
#include <boost/core/enable_if.hpp>
#include <boost/config.hpp>
#if __cplusplus >= 201103L || defined(BOOST_MSVC)
#include <utility> //for std::swap (C++11)
#else
#include <algorithm> //for std::swap (C++98)
#endif
#include <cstddef> //for std::size_t
namespace boost_swap_impl

13
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,13 @@
# 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)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::static_assert Boost::type_traits Boost::throw_exception)
endif()
add_subdirectory(swap)

View File

@@ -55,10 +55,12 @@ compile-fail explicit_operator_bool_compile_fail_conv_pvoid.cpp ;
compile-fail explicit_operator_bool_compile_fail_delete.cpp ;
compile-fail explicit_operator_bool_compile_fail_shift.cpp ;
compile ignore_unused_test.cpp : <toolset>gcc-4.8:<cxxflags>"-Wunused-variable -Wunused-local-typedefs -Werror"
<toolset>gcc:<cxxflags>"-Wunused-variable -Werror"
<toolset>clang:<cxxflags>"-Wunused-variable -Werror"
<toolset>msvc:<cxxflags>"/we4100 /we4101" ;
compile ignore_unused_test.cpp
: <warnings>extra
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>msvc:<warnings-as-errors>on ;
run sp_typeinfo_test.cpp ;
run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ;
@@ -66,20 +68,31 @@ run visit_each_test.cpp ;
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_with_test.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 lightweight_test_test4.cpp ;
run lightweight_test_test5.cpp : : :
<warnings>extra
local pedantic-errors = <warnings>pedantic
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on ;
run lightweight_test_test.cpp
: : : $(pedantic-errors) ;
run lightweight_test_test.cpp : : :
<exception-handling>off $(pedantic-errors) : lightweight_test_test_no_except ;
run lightweight_test_test2.cpp
: : : $(pedantic-errors) ;
run lightweight_test_all_with_test.cpp
: : : $(pedantic-errors) ;
run lightweight_test_lt_le_test.cpp
: : : $(pedantic-errors) ;
run lightweight_test_gt_ge_test.cpp
: : : $(pedantic-errors) ;
run lightweight_test_eq_nullptr.cpp
: : : $(pedantic-errors) ;
run lightweight_test_test3.cpp
: : : $(pedantic-errors) ;
run lightweight_test_test4.cpp
: : : $(pedantic-errors) ;
run lightweight_test_test5.cpp
: : : $(pedantic-errors)
<toolset>gcc-4.4.7:<cxxflags>-Wno-sign-compare ;
run-fail lightweight_test_all_eq_test.cpp ;
@@ -97,13 +110,16 @@ run-fail lightweight_test_fail8.cpp ;
run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_rtti ;
run-fail lightweight_test_fail9.cpp ;
run-fail lightweight_test_fail10.cpp ;
run-fail lightweight_test_fail11.cpp ;
run-fail lightweight_test_fail11.cpp : ;
run-fail lightweight_test_fail12.cpp ;
run-fail lightweight_test_lt_fail.cpp ;
run-fail lightweight_test_le_fail.cpp ;
run-fail lightweight_test_gt_fail.cpp ;
run-fail lightweight_test_ge_fail.cpp ;
run lightweight_test_bool.cpp
: : : $(pedantic-errors) ;
run is_same_test.cpp ;
run typeinfo_test.cpp ;
@@ -112,9 +128,12 @@ run typeinfo_test.cpp : : : <rtti>off : typeinfo_test_no_rtti ;
run iterator_test.cpp ;
run detail_iterator_test.cpp ;
run demangle_test.cpp : : : <test-info>always_show_run_output ;
run demangle_test.cpp
: : : <test-info>always_show_run_output ;
run demangled_name_test.cpp
: : : <test-info>always_show_run_output ;
run demangled_name_test.cpp : : : <test-info>always_show_run_output ;
run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output : demangled_name_test_no_rtti ;
run scoped_enum.cpp ;
@@ -153,6 +172,24 @@ run alloc_construct_cxx11_test.cpp ;
run nvp_test.cpp ;
run allocator_value_type_test.cpp ;
run allocator_pointer_test.cpp ;
run allocator_const_pointer_test.cpp ;
run allocator_void_pointer_test.cpp ;
run allocator_const_void_pointer_test.cpp ;
run allocator_difference_type_test.cpp ;
run allocator_size_type_test.cpp ;
run allocator_pocca_test.cpp ;
run allocator_pocma_test.cpp ;
run allocator_pocs_test.cpp ;
run allocator_is_always_equal_test.cpp ;
run allocator_rebind_test.cpp ;
run allocator_allocate_test.cpp ;
run allocator_allocate_hint_test.cpp ;
run allocator_deallocate_test.cpp ;
run allocator_max_size_test.cpp ;
run allocator_soccc_test.cpp ;
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared : test_lib_typeid_shared ;
@@ -161,8 +198,10 @@ run test_lib_typeid.cpp lib_typeid : : : <link>static : test_lib_typeid_static ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared <rtti>off : test_lib_typeid_shared_no_rtti ;
run test_lib_typeid.cpp lib_typeid : : : <link>static <rtti>off : test_lib_typeid_static_no_rtti ;
run uncaught_exceptions.cpp : : : <exception-handling>on ;
run uncaught_exceptions_np.cpp : : : <exception-handling>on ;
run uncaught_exceptions.cpp
: : : <exception-handling>on ;
run uncaught_exceptions_np.cpp
: : : <exception-handling>on ;
run no_exceptions_support_test.cpp ;
run no_exceptions_support_test.cpp : : : <exception-handling>off : no_exceptions_support_test_nx ;

View File

@@ -16,7 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/utility/addressof.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
void f0()

View File

@@ -7,7 +7,7 @@
//
#include <boost/utility/addressof.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
#if defined( BOOST_NO_CXX11_NULLPTR )

View File

@@ -20,7 +20,7 @@
#pragma warning(pop)
#endif
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T> void scalar_test( T * = 0 )
{

View File

@@ -22,7 +22,7 @@
#pragma warning(pop)
#endif
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T> void scalar_test( T * = 0 )
{

View File

@@ -0,0 +1,61 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
struct A1 {
typedef int* pointer;
typedef int size_type;
A1()
: value() { }
pointer allocate(size_type n) {
value = n;
return &value;
}
size_type value;
};
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
struct A2 {
typedef int* pointer;
typedef int size_type;
A2()
: value() { }
pointer allocate(size_type n) {
value = n;
return &value;
}
pointer allocate(size_type n, const void*) {
value = n + 1;
return &value;
}
size_type value;
};
#endif
int main()
{
{
A1 a;
BOOST_TEST_EQ(*boost::allocator_allocate(a, 1, 0), 1);
}
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
{
A2 a;
BOOST_TEST_EQ(*boost::allocator_allocate(a, 1, 0), 2);
}
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,31 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
struct A {
typedef int* pointer;
typedef int size_type;
A()
: value() { }
pointer allocate(size_type n) {
value = n;
return &value;
}
size_type value;
};
int main()
{
A a;
BOOST_TEST_EQ(*boost::allocator_allocate(a, 5), 5);
return boost::report_errors();
}

View File

@@ -0,0 +1,30 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct A1 {
typedef char value_type;
typedef int* pointer;
};
struct A2 {
typedef char value_type;
typedef int* pointer;
typedef const bool* const_pointer;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const char*,
boost::allocator_const_pointer<A1>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const bool*,
boost::allocator_const_pointer<A2>::type>));
return boost::report_errors();
}

View File

@@ -0,0 +1,28 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct A1 {
typedef int* pointer;
};
struct A2 {
typedef int* pointer;
typedef const bool* const_void_pointer;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const void*,
boost::allocator_const_void_pointer<A1>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const bool*,
boost::allocator_const_void_pointer<A2>::type>));
return boost::report_errors();
}

View File

@@ -0,0 +1,49 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/default_allocator.hpp>
#include <boost/core/lightweight_test.hpp>
struct S {
S(int v)
: value(v) { }
int value;
};
struct A1 { };
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
struct A2 {
void construct(S* p, int v) {
new(p) S(v + 1);
}
};
#endif
int main()
{
boost::default_allocator<S> d;
{
S* p = d.allocate(1);
A1 a;
boost::allocator_construct(a, p, 1);
BOOST_TEST_EQ(p->value, 1);
d.deallocate(p, 1);
}
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
{
S* p = d.allocate(1);
A2 a;
boost::allocator_construct(a, p, 1);
BOOST_TEST_EQ(p->value, 2);
d.deallocate(p, 1);
}
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,31 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
struct A {
typedef int* pointer;
typedef int size_type;
A()
: value() { }
void deallocate(pointer, size_type n) {
value = n;
}
size_type value;
};
int main()
{
A a;
boost::allocator_deallocate(a, 0, 5);
BOOST_TEST_EQ(a.value, 5);
return boost::report_errors();
}

View File

@@ -0,0 +1,62 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/default_allocator.hpp>
#include <boost/core/lightweight_test.hpp>
struct S {
static int count;
S() {
++count;
}
S(const S&) {
++count;
}
~S() {
--count;
}
};
int S::count = 0;
struct A1 { };
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
struct A2 {
void destroy(S*) {
++S::count;
}
};
#endif
int main()
{
boost::default_allocator<S> d;
{
S* p = d.allocate(1);
new(p) S;
A1 a;
boost::allocator_destroy(a, p);
BOOST_TEST_EQ(S::count, 0);
d.deallocate(p, 1);
}
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
{
S* p = d.allocate(1);
new(p) S;
A2 a;
boost::allocator_destroy(a, p);
BOOST_TEST_EQ(S::count, 2);
d.deallocate(p, 1);
}
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,28 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct A1 {
typedef char* pointer;
};
struct A2 {
typedef char* pointer;
typedef int difference_type;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::ptrdiff_t,
boost::allocator_difference_type<A1>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
boost::allocator_difference_type<A2>::type>));
return boost::report_errors();
}

View File

@@ -0,0 +1,36 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct A1 {
int value;
};
struct A2 {
struct is_always_equal {
BOOST_STATIC_CONSTEXPR bool value = true;
};
int value;
};
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
struct A3 { };
#endif
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A1>::type));
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A2>::type));
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A3>::type));
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,35 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
struct A1 {
typedef long value_type;
typedef short size_type;
};
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
struct A2 {
typedef long value_type;
typedef short size_type;
size_type max_size() const {
return 1;
}
};
#endif
int main()
{
BOOST_TEST_EQ(boost::allocator_max_size(A1()),
std::numeric_limits<A1::size_type>::max() / sizeof(A1::value_type));
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
BOOST_TEST_EQ(boost::allocator_max_size(A2()), 1);
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,27 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct A1 { };
struct A2 {
struct propagate_on_container_copy_assignment {
BOOST_STATIC_CONSTEXPR bool value = true;
};
};
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::
allocator_propagate_on_container_copy_assignment<A1>::type));
BOOST_TEST_TRAIT_TRUE((boost::
allocator_propagate_on_container_copy_assignment<A2>::type));
return boost::report_errors();
}

View File

@@ -0,0 +1,27 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct A1 { };
struct A2 {
struct propagate_on_container_move_assignment {
BOOST_STATIC_CONSTEXPR bool value = true;
};
};
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::
allocator_propagate_on_container_move_assignment<A1>::type));
BOOST_TEST_TRAIT_TRUE((boost::
allocator_propagate_on_container_move_assignment<A2>::type));
return boost::report_errors();
}

View File

@@ -0,0 +1,27 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct A1 { };
struct A2 {
struct propagate_on_container_swap {
BOOST_STATIC_CONSTEXPR bool value = true;
};
};
int main()
{
BOOST_TEST_TRAIT_FALSE((boost::
allocator_propagate_on_container_swap<A1>::type));
BOOST_TEST_TRAIT_TRUE((boost::
allocator_propagate_on_container_swap<A2>::type));
return boost::report_errors();
}

View File

@@ -0,0 +1,28 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct A1 {
typedef char value_type;
};
struct A2 {
typedef char value_type;
typedef int* pointer;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<char*,
boost::allocator_pointer<A1>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
boost::allocator_pointer<A2>::type>));
return boost::report_errors();
}

View File

@@ -0,0 +1,30 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class, class, class>
struct A1 { };
template<class, class U, class V>
struct A2 {
template<class T>
struct rebind {
typedef A1<T, U, V> other;
};
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<bool, int, float>,
boost::allocator_rebind<A1<char, int, float>, bool>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<bool, int, float>,
boost::allocator_rebind<A2<char, int, float>, bool>::type>));
return boost::report_errors();
}

View File

@@ -0,0 +1,34 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
struct A1 {
typedef long difference_type;
};
#else
struct A1 {
typedef unsigned long size_type;
};
#endif
struct A2 {
typedef long difference_type;
typedef unsigned short size_type;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<unsigned long,
boost::allocator_size_type<A1>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<unsigned short,
boost::allocator_size_type<A2>::type>));
return boost::report_errors();
}

View File

@@ -0,0 +1,40 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
struct A1 {
A1(int v)
: value(v) { }
int value;
};
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
struct A2 {
A2(int v)
: value(v) { }
A2 select_on_container_copy_construction() const {
return A2(value + 1);
}
int value;
};
#endif
int main()
{
BOOST_TEST_EQ(1,
boost::allocator_select_on_container_copy_construction(A1(1)).value);
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
BOOST_TEST_EQ(2,
boost::allocator_select_on_container_copy_construction(A2(1)).value);
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,21 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct A {
typedef int value_type;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
boost::allocator_value_type<A>::type>));
return boost::report_errors();
}

View File

@@ -0,0 +1,28 @@
/*
Copyright 2020 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/allocator_access.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct A1 {
typedef int* pointer;
};
struct A2 {
typedef int* pointer;
typedef bool* void_pointer;
};
int main()
{
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
boost::allocator_void_pointer<A1>::type>));
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool*,
boost::allocator_void_pointer<A2>::type>));
return boost::report_errors();
}

View File

@@ -0,0 +1,17 @@
# 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_install_test LANGUAGES CXX)
find_package(boost_core REQUIRED)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@@ -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)

View File

@@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if;
using boost::disable_if;

View File

@@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if;
using boost::disable_if;

View File

@@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if_c;
using boost::lazy_enable_if_c;

View File

@@ -14,7 +14,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::lazy_enable_if;
using boost::lazy_disable_if;

View File

@@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if;
using boost::disable_if;

View File

@@ -13,7 +13,7 @@
#include <boost/config.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if;
using boost::is_arithmetic;

View File

@@ -13,7 +13,7 @@
#include <boost/config.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if;
using boost::is_arithmetic;

View File

@@ -12,7 +12,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
using boost::enable_if_has_type;
using boost::enable_if_c;

View File

@@ -18,7 +18,7 @@
#if !defined(BOOST_NO_CXX11_NOEXCEPT)
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/utility/explicit_operator_bool.hpp>
namespace {

View File

@@ -0,0 +1,63 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/lightweight_test.hpp>
#include <vector>
int main()
{
BOOST_TEST( BOOST_TEST( true ) );
BOOST_TEST_NOT( BOOST_TEST( false ) );
BOOST_TEST( BOOST_TEST_NOT( false ) );
BOOST_TEST_NOT( BOOST_TEST_NOT( true ) );
BOOST_TEST( BOOST_TEST_EQ( 1, 1 ) );
BOOST_TEST_NOT( BOOST_TEST_EQ( 1, 2 ) );
BOOST_TEST( BOOST_TEST_NE( 1, 2 ) );
BOOST_TEST_NOT( BOOST_TEST_NE( 1, 1 ) );
BOOST_TEST( BOOST_TEST_LT( 1, 2 ) );
BOOST_TEST_NOT( BOOST_TEST_LT( 1, 1 ) );
BOOST_TEST( BOOST_TEST_LE( 1, 1 ) );
BOOST_TEST_NOT( BOOST_TEST_LE( 2, 1 ) );
BOOST_TEST( BOOST_TEST_GT( 2, 1 ) );
BOOST_TEST_NOT( BOOST_TEST_GT( 1, 1 ) );
BOOST_TEST( BOOST_TEST_GE( 1, 1 ) );
BOOST_TEST_NOT( BOOST_TEST_GE( 1, 2 ) );
BOOST_TEST( BOOST_TEST_CSTR_EQ( "1", "1" ) );
BOOST_TEST_NOT( BOOST_TEST_CSTR_EQ( "1", "2" ) );
BOOST_TEST( BOOST_TEST_CSTR_NE( "1", "2" ) );
BOOST_TEST_NOT( BOOST_TEST_CSTR_NE( "1", "1" ) );
std::vector<int> v1;
v1.push_back( 1 );
std::vector<int> v2;
BOOST_TEST( BOOST_TEST_ALL_EQ(v1.begin(), v1.end(), v1.begin(), v1.end()) );
BOOST_TEST_NOT( BOOST_TEST_ALL_EQ(v1.begin(), v1.end(), v2.begin(), v2.end()) );
BOOST_TEST( BOOST_TEST_ALL_WITH(v1.begin(), v1.end(), v1.begin(), v1.end(), boost::detail::lw_test_eq()) );
BOOST_TEST_NOT( BOOST_TEST_ALL_WITH(v1.begin(), v1.end(), v2.begin(), v2.end(), boost::detail::lw_test_eq()) );
int const * p = 0;
BOOST_TEST( p == 0 ) || BOOST_TEST_EQ( *p, 0 );
BOOST_TEST( p != 0 ) && BOOST_TEST_EQ( *p, 0 );
int x = 0;
p = &x;
BOOST_TEST( p == 0 ) || BOOST_TEST_EQ( *p, 0 );
BOOST_TEST( p != 0 ) && BOOST_TEST_EQ( *p, 0 );
return boost::report_errors() == 14? 0: 1;
}

View File

@@ -8,8 +8,12 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/config.hpp>
#if defined(_MSC_VER)
# pragma warning( disable: 4100 ) // nullptr_t parameter unrereferenced
#endif
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
int main()
{

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
struct X
{

View File

@@ -8,7 +8,7 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
struct X
{

View File

@@ -8,8 +8,14 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#if defined(_MSC_VER)
# pragma warning( disable: 4702 ) // unreachable code
# pragma warning( disable: 4530 ) // unwind without /EHsc from <ostream>
# pragma warning( disable: 4577 ) // noexcept without /EHsc from <exception>
#endif
#include <boost/core/lightweight_test.hpp>
#include <vector>
#include <boost/detail/lightweight_test.hpp>
struct X
{
@@ -33,6 +39,16 @@ void f( bool x )
}
}
#if defined(__GNUC__)
# pragma GCC diagnostic ignored "-Waddress"
#endif
#if defined(__clang__) && defined(__has_warning)
# if __has_warning( "-Wstring-plus-int" )
# pragma clang diagnostic ignored "-Wstring-plus-int"
# endif
#endif
int main()
{
int x = 0;

View File

@@ -9,7 +9,7 @@
#include <boost/ref.hpp>
#include <boost/core/is_same.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/config/workaround.hpp>
namespace {

View File

@@ -16,7 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/ref.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
void f0()

View File

@@ -7,7 +7,7 @@
// see 'ref_ct_test.cpp' for compile-time part
#include <boost/ref.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
namespace {
using namespace boost;

View File

@@ -11,7 +11,7 @@
#define BOOST_ALLOW_DEPRECATED_HEADERS
#include <boost/detail/sp_typeinfo.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iostream>
int main()

11
test/swap/CMakeLists.txt Normal file
View File

@@ -0,0 +1,11 @@
# 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)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core)
endif()

View File

@@ -7,65 +7,31 @@
# bring in rules for testing
import testing ;
local compile_tests =
root_header_1.cpp
root_header_2.cpp
lib_header_1.cpp
lib_header_2.cpp
mixed_headers_1.cpp
mixed_headers_2.cpp
;
compile swap_root_header_1.cpp ;
compile swap_root_header_2.cpp ;
compile swap_lib_header_1.cpp ;
compile swap_lib_header_2.cpp ;
compile swap_mixed_headers_1.cpp ;
compile swap_mixed_headers_2.cpp ;
local compile_fail_tests =
const_wrapper_fail.cpp ;
compile-fail swap_const_wrapper_fail.cpp ;
local run_tests =
primitive.cpp
specialized_in_boost.cpp
specialized_in_global.cpp
specialized_in_other.cpp
specialized_in_std.cpp
specialized_in_boost_and_other.cpp
std_bitset.cpp
std_dateorder.cpp
std_string.cpp
std_typeinfo_ptr.cpp
std_vector_of_boost.cpp
std_vector_of_global.cpp
std_vector_of_other.cpp
no_ambiguity_in_boost.cpp
array_of_array_of_class.cpp
array_of_array_of_int.cpp
array_of_class.cpp
array_of_int.cpp
array_of_template.cpp
;
rule test_all
{
local all_rules ;
local file ;
for file in $(compile_tests)
{
local test_name = [ MATCH "([^.]*).cpp$" : $(file) ] ;
all_rules += [ compile $(file) : : "swap-$(test_name)" ] ;
}
for file in $(compile_fail_tests)
{
local test_name = [ MATCH "([^.]*).cpp$" : $(file) ] ;
all_rules += [ compile-fail $(file) : : "swap-$(test_name)" ] ;
}
for file in $(run_tests)
{
local test_name = [ MATCH "([^.]*).cpp$" : $(file) ] ;
all_rules += [ run $(file) : : : : "swap-$(test_name)" ] ;
}
#ECHO All rules: $(all_rules) ;
return $(all_rules) ;
}
test-suite core/swap : [ test_all r ] ;
run swap_primitive.cpp ;
run swap_specialized_in_boost.cpp ;
run swap_specialized_in_global.cpp ;
run swap_specialized_in_other.cpp ;
run swap_specialized_in_std.cpp ;
run swap_specialized_in_boost_and_other.cpp ;
run swap_std_bitset.cpp ;
run swap_std_dateorder.cpp ;
run swap_std_string.cpp ;
run swap_std_typeinfo_ptr.cpp ;
run swap_std_vector_of_boost.cpp ;
run swap_std_vector_of_global.cpp ;
run swap_std_vector_of_other.cpp ;
run swap_no_ambiguity_in_boost.cpp ;
run swap_array_of_array_of_class.cpp ;
run swap_array_of_array_of_int.cpp ;
run swap_array_of_class.cpp ;
run swap_array_of_int.cpp ;
run swap_array_of_template.cpp ;