forked from boostorg/core
Compare commits
38 Commits
feature/lw
...
boost-1.74
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcc04c5508 | ||
|
|
484487f958 | ||
|
|
503d035b7f | ||
|
|
35a025d59b | ||
|
|
c6d72da515 | ||
|
|
f96fb31850 | ||
|
|
b414be98c9 | ||
|
|
544fd495e5 | ||
|
|
e155e13084 | ||
|
|
6e36923915 | ||
|
|
b67cce85c8 | ||
|
|
376aa7aa31 | ||
|
|
65901249d5 | ||
|
|
1c16d5ed87 | ||
|
|
27715ed01a | ||
|
|
9f2dbba2fc | ||
|
|
0159b6d8e5 | ||
|
|
0dbd5aaadd | ||
|
|
34373b0127 | ||
|
|
6a33e879dd | ||
|
|
15db54983b | ||
|
|
fa6e38a9aa | ||
|
|
38f827e092 | ||
|
|
2b102e7357 | ||
|
|
9c33851420 | ||
|
|
fb593cbbc8 | ||
|
|
032ce991fb | ||
|
|
6444de7098 | ||
|
|
d3a64554f4 | ||
|
|
a57c1e0a80 | ||
|
|
e9ff763d79 | ||
|
|
6069fea76d | ||
|
|
3ca745f400 | ||
|
|
94def8a3a6 | ||
|
|
eb86df4a04 | ||
|
|
4d08e709fe | ||
|
|
12ff209bf7 | ||
|
|
080e8581d5 |
41
.travis.yml
41
.travis.yml
@@ -127,14 +127,26 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
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
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-9
|
||||
- g++-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-10
|
||||
sources:
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
@@ -274,15 +286,28 @@ matrix:
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-8
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
compiler: clang++-10
|
||||
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
- clang-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-10
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
|
||||
@@ -21,9 +21,8 @@ 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`.
|
||||
These facilities also simplify existing libraries by avoiding having to check
|
||||
for `BOOST_NO_CXX11_ALLOCATOR` and conditionally use `std::allocator_traits`.
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -142,14 +141,14 @@ 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);
|
||||
allocator_const_void_pointer_t<A> h);
|
||||
|
||||
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);
|
||||
void allocator_construct(A& a, T* p, Args&&... args);
|
||||
|
||||
template<class A, class T>
|
||||
void allocator_destroy(A& a, T* p);
|
||||
@@ -223,7 +222,7 @@ void allocator_construct(A& a, T*p, 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
|
||||
[Returns `a.max_size()` if valid, otherwise 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
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
empty_value() = default;
|
||||
|
||||
template<class... Args>
|
||||
explicit empty_value(empty_init_t, Args&&... args);
|
||||
empty_value(empty_init_t, Args&&... args);
|
||||
|
||||
const T& get() const noexcept;
|
||||
|
||||
|
||||
@@ -43,9 +43,11 @@ When using `lightweight_test.hpp`, *do not forget* to
|
||||
#define BOOST_TEST_GE(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_CSTR_EQ(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_CSTR_NE(expr1, expr2) /*unspecified*/
|
||||
#define BOOST_TEST_WITH(expr1, expr2, pred) /*unspecified*/
|
||||
#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) /* unspecified */
|
||||
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) /* unspecified */
|
||||
#define BOOST_TEST_THROWS(expr, excep) /*unspecified*/
|
||||
#define BOOST_TEST_NO_THROW(expr) /*unspecified*/
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -174,6 +176,17 @@ Specialization of `BOOST_TEST_NE` which interprets `expr1` and `expr2` as pointe
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_WITH]
|
||||
|
||||
``
|
||||
BOOST_TEST_WITH(expr1, expr2, pred)
|
||||
``
|
||||
|
||||
If `pred(expr1, expr2)` is not true increases the error count and outputs a
|
||||
message containing both expressions.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_ALL_EQ]
|
||||
|
||||
``
|
||||
@@ -209,6 +222,20 @@ nothing and `expr` is not evaluated.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section BOOST_TEST_NO_THROW]
|
||||
|
||||
``
|
||||
BOOST_TEST_NO_THROW(expr)
|
||||
``
|
||||
|
||||
If `BOOST_NO_EXCEPTIONS` is *not* defined and if `expr` throws an exception,
|
||||
increases the error count and outputs a message containing the expression
|
||||
and (if possible) the exception message.
|
||||
|
||||
If `BOOST_NO_EXCEPTIONS` is defined, `expr` is evaluated.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section report_errors]
|
||||
|
||||
``
|
||||
|
||||
@@ -71,8 +71,7 @@ struct noinit_adaptor
|
||||
: A {
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef noinit_adaptor<typename std::allocator_traits<A>::template
|
||||
rebind_alloc<U> > other;
|
||||
typedef noinit_adaptor<allocator_rebind_t<A, U> > other;
|
||||
};
|
||||
|
||||
noinit_adaptor() noexcept;
|
||||
@@ -86,9 +85,6 @@ struct noinit_adaptor
|
||||
template<class U>
|
||||
void construct(U* p);
|
||||
|
||||
template<class U, class V, class... Args>
|
||||
void construct(U* p, V&& v, Args&&... args);
|
||||
|
||||
template<class U>
|
||||
void destroy(U* p);
|
||||
};
|
||||
@@ -121,7 +117,7 @@ noinit_adaptor<A> noinit_adapt(const A& a) noexcept;
|
||||
[[variablelist
|
||||
[[Requires][`A` shall be constructible from `U`.]]
|
||||
[[Effects][Initializes the `A` base class with
|
||||
`static_cast<const U&>(u)`.]]]]]]
|
||||
`static_cast<const A&>(u)`.]]]]]]
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -131,11 +127,6 @@ noinit_adaptor<A> noinit_adapt(const A& a) noexcept;
|
||||
[[`template<class U> void construct(U* p);`]
|
||||
[[variablelist
|
||||
[[Effects][`::new((void*)p) U`.]]]]]
|
||||
[[`template<class U, class V, class... Args> void construct(U* p, V&& v,
|
||||
Args&&... args);`]
|
||||
[[variablelist
|
||||
[[Effects][`::new(void*)p) U(std::forward<V>(v),
|
||||
std::forward<Args>(args)...)`.]]]]]
|
||||
[[`template<class U> void destroy(U* p);`]
|
||||
[[variablelist
|
||||
[[Effects][`p->~U()`.]]]]]]
|
||||
|
||||
@@ -125,7 +125,7 @@ template<class T>
|
||||
BOOST_FORCEINLINE T*
|
||||
addressof(T& o) BOOST_NOEXCEPT
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) || \
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x610)) || \
|
||||
BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5120)
|
||||
return boost::detail::addrof<T>::get(o, 0);
|
||||
#else
|
||||
@@ -151,7 +151,7 @@ addressof(T (&o)[N]) BOOST_NOEXCEPT
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
|
||||
template<class T, std::size_t N>
|
||||
BOOST_FORCEINLINE
|
||||
T (*addressof(T (&o)[N]) BOOST_NOEXCEPT)[N]
|
||||
|
||||
@@ -12,12 +12,11 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy(A& a, T* p)
|
||||
{
|
||||
std::allocator_traits<A>::destroy(a, p);
|
||||
boost::allocator_destroy(a, p);
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
@@ -25,26 +24,25 @@ inline void
|
||||
alloc_destroy_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
std::allocator_traits<A>::destroy(a, p + --n);
|
||||
boost::allocator_destroy(a, p + --n);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy(A&, T* p)
|
||||
alloc_destroy(noinit_adaptor<A>&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_destroy_n(A&, T* p, std::size_t n)
|
||||
alloc_destroy_n(noinit_adaptor<A>&, T* p, std::size_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
p[--n].~T();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -75,12 +73,11 @@ private:
|
||||
|
||||
} /* detail */
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p);
|
||||
boost::allocator_construct(a, p);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
@@ -89,7 +86,7 @@ template<class A, class T, class U, class... V>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U&& u, V&&... v)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, std::forward<U>(u),
|
||||
boost::allocator_construct(a, p, std::forward<U>(u),
|
||||
std::forward<V>(v)...);
|
||||
}
|
||||
#else
|
||||
@@ -97,7 +94,7 @@ template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U&& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, std::forward<U>(u));
|
||||
boost::allocator_construct(a, p, std::forward<U>(u));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
@@ -105,14 +102,14 @@ template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, const U& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, u);
|
||||
boost::allocator_construct(a, p, u);
|
||||
}
|
||||
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U& u)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, u);
|
||||
boost::allocator_construct(a, p, u);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -122,7 +119,7 @@ alloc_construct_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
std::allocator_traits<A>::construct(a, p + i);
|
||||
boost::allocator_construct(a, p + i);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
@@ -133,7 +130,7 @@ alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
std::allocator_traits<A>::construct(a, p + i, l[i % m]);
|
||||
boost::allocator_construct(a, p + i, l[i % m]);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
@@ -144,17 +141,10 @@ alloc_construct_n(A& a, T* p, std::size_t n, I b)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; void(++i), void(++b)) {
|
||||
std::allocator_traits<A>::construct(a, p + i, *b);
|
||||
boost::allocator_construct(a, p + i, *b);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
#else
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct(A&, T* p)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T();
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
@@ -163,49 +153,6 @@ alloc_construct(noinit_adaptor<A>&, T* p)
|
||||
::new(static_cast<void*>(p)) T;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class A, class T, class U, class... V>
|
||||
inline void
|
||||
alloc_construct(A&, T* p, U&& u, V&&... v)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(std::forward<U>(u), std::forward<V>(v)...);
|
||||
}
|
||||
#else
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A& a, T* p, U&& u)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(std::forward<U>(u));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A&, T* p, const U& u)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(u);
|
||||
}
|
||||
|
||||
template<class A, class T, class U>
|
||||
inline void
|
||||
alloc_construct(A&, T* p, U& u)
|
||||
{
|
||||
::new(static_cast<void*>(p)) T(u);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
::new(static_cast<void*>(p + i)) T();
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(noinit_adaptor<A>& a, T* p, std::size_t n)
|
||||
@@ -217,29 +164,6 @@ alloc_construct_n(noinit_adaptor<A>& a, T* p, std::size_t n)
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n, const T* l, std::size_t m)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; ++i) {
|
||||
::new(static_cast<void*>(p + i)) T(l[i % m]);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<class A, class T, class I>
|
||||
inline void
|
||||
alloc_construct_n(A& a, T* p, std::size_t n, I b)
|
||||
{
|
||||
detail::alloc_destroyer<A, T> hold(a, p);
|
||||
for (std::size_t& i = hold.size(); i < n; void(++i), void(++b)) {
|
||||
::new(static_cast<void*>(p + i)) T(*b);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,38 +8,53 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#ifndef BOOST_CORE_ALLOCATOR_ACCESS_HPP
|
||||
#define BOOST_CORE_ALLOCATOR_ACCESS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#if !defined(BOOST_MSVC)
|
||||
#include <limits>
|
||||
#include <new>
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#else
|
||||
#include <memory>
|
||||
#endif
|
||||
#include <type_traits>
|
||||
#endif
|
||||
#include <new>
|
||||
#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
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
struct alloc_false {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
#else
|
||||
template<class>
|
||||
struct alloc_void {
|
||||
typedef void type;
|
||||
};
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
struct allocator_value_type {
|
||||
typedef typename A::value_type type;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class>
|
||||
struct alloc_void {
|
||||
typedef void type;
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_pointer {
|
||||
typedef typename A::pointer type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
struct allocator_pointer {
|
||||
typedef typename std::allocator_traits<A>::pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_pointer {
|
||||
typedef typename A::value_type* type;
|
||||
@@ -50,7 +65,19 @@ struct allocator_pointer<A,
|
||||
typename detail::alloc_void<typename A::pointer>::type> {
|
||||
typedef typename A::pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_const_pointer {
|
||||
typedef typename A::const_pointer type;
|
||||
};
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
struct allocator_const_pointer {
|
||||
typedef typename std::allocator_traits<A>::const_pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_const_pointer {
|
||||
typedef typename pointer_traits<typename
|
||||
@@ -63,7 +90,14 @@ struct allocator_const_pointer<A,
|
||||
typename detail::alloc_void<typename A::const_pointer>::type> {
|
||||
typedef typename A::const_pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_void_pointer {
|
||||
typedef typename A::template rebind<void>::other::pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_void_pointer {
|
||||
typedef typename pointer_traits<typename
|
||||
@@ -76,7 +110,14 @@ struct allocator_void_pointer<A,
|
||||
typename detail::alloc_void<typename A::void_pointer>::type> {
|
||||
typedef typename A::void_pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_const_void_pointer {
|
||||
typedef typename A::template rebind<void>::other::const_pointer type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_const_void_pointer {
|
||||
typedef typename pointer_traits<typename
|
||||
@@ -89,7 +130,19 @@ struct allocator_const_void_pointer<A,
|
||||
typename detail::alloc_void<typename A::const_void_pointer>::type> {
|
||||
typedef typename A::const_void_pointer type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_difference_type {
|
||||
typedef typename A::difference_type type;
|
||||
};
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
struct allocator_difference_type {
|
||||
typedef typename std::allocator_traits<A>::difference_type type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_difference_type {
|
||||
typedef typename pointer_traits<typename
|
||||
@@ -101,8 +154,19 @@ struct allocator_difference_type<A,
|
||||
typename detail::alloc_void<typename A::difference_type>::type> {
|
||||
typedef typename A::difference_type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_size_type {
|
||||
typedef typename A::size_type type;
|
||||
};
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
struct allocator_size_type {
|
||||
typedef typename std::allocator_traits<A>::size_type type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_size_type {
|
||||
typedef typename std::make_unsigned<typename
|
||||
@@ -114,28 +178,17 @@ struct allocator_size_type<A,
|
||||
typename detail::alloc_void<typename A::size_type>::type> {
|
||||
typedef typename A::size_type type;
|
||||
};
|
||||
#else
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_size_type {
|
||||
typedef typename A::size_type type;
|
||||
struct allocator_propagate_on_container_copy_assignment {
|
||||
typedef detail::alloc_false 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;
|
||||
typedef std::false_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
@@ -144,10 +197,17 @@ struct allocator_propagate_on_container_copy_assignment<A,
|
||||
A::propagate_on_container_copy_assignment>::type> {
|
||||
typedef typename A::propagate_on_container_copy_assignment type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_move_assignment {
|
||||
typedef detail::alloc_false type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_move_assignment {
|
||||
typedef detail::alloc_false_type type;
|
||||
typedef std::false_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
@@ -156,10 +216,17 @@ struct allocator_propagate_on_container_move_assignment<A,
|
||||
A::propagate_on_container_move_assignment>::type> {
|
||||
typedef typename A::propagate_on_container_move_assignment type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_propagate_on_container_swap {
|
||||
typedef detail::alloc_false type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_propagate_on_container_swap {
|
||||
typedef detail::alloc_false_type type;
|
||||
typedef std::false_type type;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
@@ -168,52 +235,46 @@ struct allocator_propagate_on_container_swap<A,
|
||||
A::propagate_on_container_swap>::type> {
|
||||
typedef typename A::propagate_on_container_swap type;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
template<class A, class = void>
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_is_always_equal {
|
||||
typedef typename std::is_empty<A>::type type;
|
||||
typedef detail::alloc_false type;
|
||||
};
|
||||
#else
|
||||
template<class A, class = void>
|
||||
struct allocator_is_always_equal {
|
||||
typedef typename detail::alloc_false_type type;
|
||||
typedef typename std::is_empty<A>::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;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
struct allocator_rebind {
|
||||
typedef typename A::template rebind<T>::other type;
|
||||
};
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A, class T>
|
||||
struct allocator_rebind {
|
||||
typedef typename std::allocator_traits<A>::template rebind_alloc<T> type;
|
||||
};
|
||||
#else
|
||||
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 */
|
||||
|
||||
@@ -227,6 +288,7 @@ struct allocator_rebind<A, T,
|
||||
typename detail::alloc_void<typename A::template rebind<T>::other>::type> {
|
||||
typedef typename A::template rebind<T>::other type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class A>
|
||||
inline typename allocator_pointer<A>::type
|
||||
@@ -235,56 +297,6 @@ 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,
|
||||
@@ -293,109 +305,158 @@ allocator_deallocate(A& a, typename allocator_pointer<A>::type p,
|
||||
a.deallocate(p, n);
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
inline typename allocator_pointer<A>::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);
|
||||
}
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
inline typename allocator_pointer<A>::type
|
||||
allocator_allocate(A& a, typename allocator_size_type<A>::type n,
|
||||
typename allocator_const_void_pointer<A>::type h)
|
||||
{
|
||||
return std::allocator_traits<A>::allocate(a, n, h);
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class...>
|
||||
struct alloc_types { };
|
||||
#else
|
||||
template<class>
|
||||
struct alloc_types { };
|
||||
template<class, class, class, class = void>
|
||||
struct alloc_has_allocate {
|
||||
BOOST_STATIC_CONSTEXPR bool value = false;
|
||||
};
|
||||
|
||||
template<class A, class N, class H>
|
||||
struct alloc_has_allocate<A, N, H,
|
||||
typename alloc_void<decltype(std::declval<A&>().allocate(std::declval<N>(),
|
||||
std::declval<H>()))>::type> {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class A>
|
||||
inline typename std::enable_if<detail::alloc_has_allocate<A,
|
||||
typename allocator_size_type<A>::type,
|
||||
typename allocator_const_void_pointer<A>::type>::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 std::enable_if<!detail::alloc_has_allocate<A,
|
||||
typename allocator_size_type<A>::type,
|
||||
typename allocator_const_void_pointer<A>::type>::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);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class, class, class, class = void>
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
allocator_construct(A&, T* p)
|
||||
{
|
||||
::new((void*)p) T();
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class A, class T, class V, class... Args>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, V&& v, Args&&... args)
|
||||
{
|
||||
::new((void*)p) T(std::forward<V>(v), std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
template<class A, class T, class V>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, V&& v)
|
||||
{
|
||||
::new((void*)p) T(std::forward<V>(v));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<class A, class T, class V>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, const V& v)
|
||||
{
|
||||
::new((void*)p) T(v);
|
||||
}
|
||||
|
||||
template<class A, class T, class V>
|
||||
inline void
|
||||
allocator_construct(A&, T* p, V& v)
|
||||
{
|
||||
::new((void*)p) T(v);
|
||||
}
|
||||
#endif
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A, class T, class... Args>
|
||||
inline void
|
||||
allocator_construct(A& a, T* p, Args&&... args)
|
||||
{
|
||||
std::allocator_traits<A>::construct(a, p, std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class, class, class, class...>
|
||||
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> {
|
||||
template<class A, class T, class... Args>
|
||||
struct alloc_has_construct<typename alloc_void<decltype(std::declval<A
|
||||
&>().construct(std::declval<T*>(), std::declval<Args&&>()...))>::type,
|
||||
A, T, Args...> {
|
||||
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)
|
||||
inline typename std::enable_if<detail::alloc_has_construct<void, A, T,
|
||||
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
|
||||
inline typename std::enable_if<!detail::alloc_has_construct<void, A, T,
|
||||
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);
|
||||
::new((void*)p) T(std::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
allocator_destroy(A&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
(void)p;
|
||||
}
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A, class T>
|
||||
inline void
|
||||
allocator_destroy(A& a, T* p)
|
||||
{
|
||||
std::allocator_traits<A>::destroy(a, p);
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class, class, class = void>
|
||||
@@ -403,32 +464,46 @@ 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> {
|
||||
struct alloc_has_destroy<A, T,
|
||||
typename alloc_void<decltype(std::declval<A
|
||||
&>().destroy(std::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)
|
||||
inline typename std::enable_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
|
||||
inline typename std::enable_if<!detail::alloc_has_destroy<A, T>::value>::type
|
||||
allocator_destroy(A&, T* p)
|
||||
{
|
||||
p->~T();
|
||||
(void)p;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
inline typename allocator_size_type<A>::type
|
||||
allocator_max_size(const A& a)
|
||||
{
|
||||
return a.max_size();
|
||||
}
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
inline typename allocator_size_type<A>::type
|
||||
allocator_max_size(const A& a)
|
||||
{
|
||||
return std::allocator_traits<A>::max_size(a);
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class, class = void>
|
||||
@@ -436,19 +511,17 @@ 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
|
||||
typename alloc_void<decltype(std::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,
|
||||
inline typename std::enable_if<detail::alloc_has_max_size<A>::value,
|
||||
typename allocator_size_type<A>::type>::type
|
||||
allocator_max_size(const A& a)
|
||||
{
|
||||
@@ -456,14 +529,30 @@ allocator_max_size(const A& a)
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline typename detail::alloc_if<!detail::alloc_has_max_size<A>::value,
|
||||
inline typename std::enable_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);
|
||||
return (std::numeric_limits<typename
|
||||
allocator_size_type<A>::type>::max)() / sizeof(typename A::value_type);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
inline A
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
#elif defined(BOOST_MSVC)
|
||||
template<class A>
|
||||
inline A
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return std::allocator_traits<A>::select_on_container_copy_construction(a);
|
||||
}
|
||||
#else
|
||||
namespace detail {
|
||||
|
||||
template<class, class = void>
|
||||
@@ -471,30 +560,29 @@ 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
|
||||
typename alloc_void<decltype(std::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
|
||||
inline typename std::enable_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
|
||||
inline typename std::enable_if<!detail::alloc_has_soccc<A>::value, A>::type
|
||||
allocator_select_on_container_copy_construction(const A& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
template<class A>
|
||||
|
||||
@@ -9,13 +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>
|
||||
|
||||
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000
|
||||
#define BOOST_CORE_NO_CXX11_ALLOCATOR
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if defined(BOOST_NO_EXCEPTIONS)
|
||||
@@ -82,10 +77,7 @@ struct default_allocator {
|
||||
BOOST_NOEXCEPT { }
|
||||
|
||||
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
|
||||
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);
|
||||
return static_cast<std::size_t>(-1) / (2 < sizeof(T) ? sizeof(T) : 2);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
@@ -116,7 +108,8 @@ struct default_allocator {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_CORE_NO_CXX11_ALLOCATOR)
|
||||
#if (defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000) || \
|
||||
defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new(p) U(v);
|
||||
@@ -125,6 +118,7 @@ struct default_allocator {
|
||||
template<class U>
|
||||
void destroy(U* p) {
|
||||
p->~U();
|
||||
(void)p;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -59,9 +59,9 @@ public:
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args>
|
||||
explicit empty_value(boost::empty_init_t, Args&&... args)
|
||||
: value_(std::forward<Args>(args)...) { }
|
||||
template<class U, class... Args>
|
||||
empty_value(boost::empty_init_t, U&& value, Args&&... args)
|
||||
: value_(std::forward<U>(value), std::forward<Args>(args)...) { }
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U&& value)
|
||||
@@ -107,9 +107,9 @@ public:
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class... Args>
|
||||
explicit empty_value(boost::empty_init_t, Args&&... args)
|
||||
: T(std::forward<Args>(args)...) { }
|
||||
template<class U, class... Args>
|
||||
empty_value(boost::empty_init_t, U&& value, Args&&... args)
|
||||
: T(std::forward<U>(value), std::forward<Args>(args)...) { }
|
||||
#else
|
||||
template<class U>
|
||||
empty_value(boost::empty_init_t, U&& value)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <cstdlib>
|
||||
@@ -118,14 +119,30 @@ inline void error_impl(char const * msg, char const * file, int line, char const
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function)
|
||||
inline void throw_failed_impl(const char* expr, char const * excep, char const * file, int line, char const * function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): Exception '" << excep << "' not thrown in function '"
|
||||
<< file << "(" << line << "): expression '" << expr << "' did not throw exception '" << excep << "' in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
inline void no_throw_failed_impl(const char* expr, const char* file, int line, const char* function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): expression '" << expr << "' threw an exception in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
inline void no_throw_failed_impl(const char* expr, const char* what, const char* file, int line, const char* function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): expression '" << expr << "' threw an exception in function '"
|
||||
<< function << "': " << what << std::endl;
|
||||
++test_results().errors();
|
||||
}
|
||||
|
||||
// In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers.
|
||||
// A cleaner fix would require common_type trait or some meta-programming, which would introduce a dependency on Boost.TypeTraits. To avoid
|
||||
// the dependency we just disable the warnings.
|
||||
@@ -156,42 +173,83 @@ template<class T> inline const void* test_output_impl(T volatile* v) { return co
|
||||
inline const void* test_output_impl(std::nullptr_t) { return nullptr; }
|
||||
#endif
|
||||
|
||||
struct lw_test_eq {
|
||||
// predicates
|
||||
|
||||
struct lw_test_eq
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t == u; }
|
||||
static const char* op() { return "=="; }
|
||||
};
|
||||
|
||||
struct lw_test_ne {
|
||||
struct lw_test_ne
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t != u; }
|
||||
static const char* op() { return "!="; }
|
||||
};
|
||||
|
||||
struct lw_test_lt {
|
||||
struct lw_test_lt
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t < u; }
|
||||
static const char* op() { return "<"; }
|
||||
};
|
||||
|
||||
struct lw_test_le {
|
||||
struct lw_test_le
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t <= u; }
|
||||
static const char* op() { return "<="; }
|
||||
};
|
||||
|
||||
struct lw_test_gt {
|
||||
struct lw_test_gt
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t > u; }
|
||||
static const char* op() { return ">"; }
|
||||
};
|
||||
|
||||
struct lw_test_ge {
|
||||
struct lw_test_ge
|
||||
{
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const { return t >= u; }
|
||||
static const char* op() { return ">="; }
|
||||
};
|
||||
|
||||
// lwt_predicate_name
|
||||
|
||||
template<class T> char const * lwt_predicate_name( T const& )
|
||||
{
|
||||
return "~=";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_eq const& )
|
||||
{
|
||||
return "==";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_ne const& )
|
||||
{
|
||||
return "!=";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_lt const& )
|
||||
{
|
||||
return "<";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_le const& )
|
||||
{
|
||||
return "<=";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_gt const& )
|
||||
{
|
||||
return ">";
|
||||
}
|
||||
|
||||
inline char const * lwt_predicate_name( lw_test_ge const& )
|
||||
{
|
||||
return ">=";
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<class BinaryPredicate, class T, class U>
|
||||
inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function,
|
||||
@@ -205,8 +263,8 @@ inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " " << pred.op() << " " << expr2
|
||||
<< "' ('" << test_output_impl(t) << "' " << pred.op() << " '" << test_output_impl(u)
|
||||
<< file << "(" << line << "): test '" << expr1 << " " << lwt_predicate_name(pred) << " " << expr2
|
||||
<< "' ('" << test_output_impl(t) << "' " << lwt_predicate_name(pred) << " '" << test_output_impl(u)
|
||||
<< "') failed in function '" << function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
@@ -431,6 +489,8 @@ inline int report_errors()
|
||||
|
||||
#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#define BOOST_TEST_WITH(expr1,expr2,predicate) ( ::boost::detail::test_with_impl(predicate, #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_eq(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_with_impl(::boost::detail::lw_test_ne(), #expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
@@ -446,22 +506,38 @@ inline int report_errors()
|
||||
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) ( ::boost::detail::test_all_with_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2, predicate) )
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
|
||||
try { \
|
||||
EXPR; \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
catch(EXCEP const&) { \
|
||||
::boost::detail::test_results(); \
|
||||
} \
|
||||
catch(...) { \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
|
||||
try { \
|
||||
EXPR; \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
catch(EXCEP const&) { \
|
||||
::boost::detail::test_results(); \
|
||||
} \
|
||||
catch(...) { \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
//
|
||||
#else
|
||||
#define BOOST_TEST_THROWS( EXPR, EXCEP )
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
# define BOOST_TEST_NO_THROW(EXPR) \
|
||||
try { \
|
||||
EXPR; \
|
||||
} catch (const std::exception& e) { \
|
||||
::boost::detail::no_throw_failed_impl \
|
||||
(#EXPR, e.what(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} catch (...) { \
|
||||
::boost::detail::no_throw_failed_impl \
|
||||
(#EXPR, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
}
|
||||
//
|
||||
#else
|
||||
# define BOOST_TEST_NO_THROW(EXPR) { EXPR; }
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
# define BOOST_RETHROW throw;
|
||||
# define BOOST_CATCH_END }
|
||||
#else
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
|
||||
# define BOOST_TRY { if ("")
|
||||
# define BOOST_CATCH(x) else if (!"")
|
||||
# elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
|
||||
|
||||
@@ -8,14 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#ifndef BOOST_CORE_NOINIT_ADAPTOR_HPP
|
||||
#define BOOST_CORE_NOINIT_ADAPTOR_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <memory>
|
||||
#endif
|
||||
#include <new>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <utility>
|
||||
#endif
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -24,12 +17,7 @@ struct noinit_adaptor
|
||||
: A {
|
||||
template<class U>
|
||||
struct rebind {
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef noinit_adaptor<typename std::allocator_traits<A>::template
|
||||
rebind_alloc<U> > other;
|
||||
#else
|
||||
typedef noinit_adaptor<typename A::template rebind<U>::other> other;
|
||||
#endif
|
||||
typedef noinit_adaptor<typename allocator_rebind<A, U>::type> other;
|
||||
};
|
||||
|
||||
noinit_adaptor()
|
||||
@@ -43,39 +31,26 @@ struct noinit_adaptor
|
||||
template<class U>
|
||||
noinit_adaptor(const U& u) BOOST_NOEXCEPT
|
||||
: A(u) { }
|
||||
|
||||
template<class U>
|
||||
noinit_adaptor(U& u) BOOST_NOEXCEPT
|
||||
: A(u) { }
|
||||
#endif
|
||||
|
||||
template<class U>
|
||||
noinit_adaptor(const noinit_adaptor<U>& u) BOOST_NOEXCEPT
|
||||
: A(static_cast<const U&>(u)) { }
|
||||
: A(static_cast<const A&>(u)) { }
|
||||
|
||||
template<class U>
|
||||
void construct(U* p) {
|
||||
::new((void*)p) U;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class U, class V, class... Args>
|
||||
void construct(U* p, V&& v, Args&&... args) {
|
||||
::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
template<class U, class V>
|
||||
void construct(U* p, V&& v) {
|
||||
::new((void*)p) U(std::forward<V>(v));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new((void*)p) U(v);
|
||||
}
|
||||
|
||||
template<class U, class V>
|
||||
void construct(U* p, V& v) {
|
||||
::new((void*)p) U(v);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class U>
|
||||
|
||||
@@ -116,7 +116,7 @@ private:
|
||||
/**
|
||||
@cond
|
||||
*/
|
||||
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
|
||||
#if defined( BOOST_BORLANDC ) && BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x581) )
|
||||
# define BOOST_REF_CONST
|
||||
#else
|
||||
# define BOOST_REF_CONST const
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#if __cplusplus >= 201103L || defined(BOOST_MSVC)
|
||||
#include <utility> //for std::swap (C++11)
|
||||
#if __cplusplus >= 201103L || defined(BOOST_DINKUMWARE_STDLIB)
|
||||
#include <utility> // for std::swap (C++11)
|
||||
#else
|
||||
#include <algorithm> //for std::swap (C++98)
|
||||
#include <algorithm> // for std::swap (C++98)
|
||||
#endif
|
||||
#include <cstddef> //for std::size_t
|
||||
#include <cstddef> // for std::size_t
|
||||
|
||||
namespace boost_swap_impl
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2018.
|
||||
* Copyright Andrey Semashev 2018 - 2020.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* https://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -26,8 +26,23 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// Visual Studio 14 supports N4152 std::uncaught_exceptions()
|
||||
#if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \
|
||||
#if defined(__APPLE__)
|
||||
#include <Availability.h>
|
||||
// Apple systems only support std::uncaught_exceptions starting with specific versions:
|
||||
// - Mac OS >= 10.12
|
||||
// - iOS >= 10.0
|
||||
// - tvOS >= 10.0
|
||||
// - watchOS >= 3.0
|
||||
// https://github.com/boostorg/core/issues/80
|
||||
#if (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) && \
|
||||
( \
|
||||
(defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || \
|
||||
(defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) \
|
||||
)
|
||||
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
|
||||
#endif
|
||||
// Visual Studio 14.0 supports N4152 std::uncaught_exceptions() but doesn't define __cpp_lib_uncaught_exceptions
|
||||
#elif (defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \
|
||||
(defined(_MSC_VER) && _MSC_VER >= 1900)
|
||||
#define BOOST_CORE_HAS_UNCAUGHT_EXCEPTIONS
|
||||
#endif
|
||||
@@ -46,7 +61,11 @@
|
||||
#if defined(BOOST_CORE_HAS_CXXABI_H)
|
||||
// MinGW GCC 4.4 seem to not work the same way the newer GCC versions do. As a result, __cxa_get_globals based implementation will always return 0.
|
||||
// Just disable it for now and fall back to std::uncaught_exception().
|
||||
#if !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405))
|
||||
// On AIX, xlclang++ does have cxxabi.h but doesn't have __cxa_get_globals (https://github.com/boostorg/core/issues/78).
|
||||
#if !( \
|
||||
(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405)) || \
|
||||
defined(__ibmxl__) \
|
||||
)
|
||||
#include <cxxabi.h>
|
||||
#include <cstring>
|
||||
#define BOOST_CORE_HAS_CXA_GET_GLOBALS
|
||||
@@ -76,7 +95,7 @@ extern "C" __cxa_eh_globals* __cxa_get_globals() BOOST_NOEXCEPT_OR_NOTHROW __att
|
||||
#endif
|
||||
} // namespace __cxxabiv1
|
||||
#endif
|
||||
#endif // !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405))
|
||||
#endif
|
||||
#endif // defined(BOOST_CORE_HAS_CXXABI_H)
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
#ifndef ITERATOR_DWA122600_HPP_
|
||||
#define ITERATOR_DWA122600_HPP_
|
||||
|
||||
// This header is obsolete and will be deprecated.
|
||||
// This header is obsolete and deprecated.
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("<iterator>")
|
||||
|
||||
#include <iterator>
|
||||
#if defined(__SUNPRO_CC) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
// The header file at this path is deprecated;
|
||||
// use boost/core/no_exceptions_support.hpp instead.
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("<boost/core/no_exceptions_support.hpp>")
|
||||
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
// The header file at this path is deprecated;
|
||||
// use boost/core/scoped_enum.hpp instead.
|
||||
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
|
||||
BOOST_HEADER_DEPRECATED("<boost/core/scoped_enum.hpp>")
|
||||
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -112,6 +112,8 @@ run-fail lightweight_test_fail9.cpp ;
|
||||
run-fail lightweight_test_fail10.cpp ;
|
||||
run-fail lightweight_test_fail11.cpp : ;
|
||||
run-fail lightweight_test_fail12.cpp ;
|
||||
run-fail lightweight_test_fail13.cpp ;
|
||||
run-fail lightweight_test_fail14.cpp ;
|
||||
run-fail lightweight_test_lt_fail.cpp ;
|
||||
run-fail lightweight_test_le_fail.cpp ;
|
||||
run-fail lightweight_test_gt_fail.cpp ;
|
||||
@@ -120,6 +122,10 @@ run-fail lightweight_test_ge_fail.cpp ;
|
||||
run lightweight_test_bool.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
|
||||
run lightweight_test_with_test.cpp
|
||||
: : : $(pedantic-errors) ;
|
||||
run-fail lightweight_test_with_fail.cpp ;
|
||||
|
||||
run is_same_test.cpp ;
|
||||
|
||||
run typeinfo_test.cpp ;
|
||||
@@ -164,7 +170,12 @@ run-fail quick_exit_fail.cpp ;
|
||||
|
||||
compile use_default_test.cpp ;
|
||||
|
||||
run default_allocator_test.cpp ;
|
||||
run default_allocator_test.cpp
|
||||
: : : <warnings>pedantic
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on ;
|
||||
|
||||
run noinit_adaptor_test.cpp ;
|
||||
run alloc_construct_test.cpp ;
|
||||
run alloc_construct_throws_test.cpp ;
|
||||
|
||||
@@ -8,53 +8,51 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef int* pointer;
|
||||
typedef int size_type;
|
||||
|
||||
typedef T value_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef A1<U> other;
|
||||
};
|
||||
A1()
|
||||
: value() { }
|
||||
|
||||
pointer allocate(size_type n) {
|
||||
T* allocate(std::size_t n, const void*) {
|
||||
value = n;
|
||||
return &value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_type value;
|
||||
std::size_t value;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef int* pointer;
|
||||
typedef int size_type;
|
||||
|
||||
typedef T value_type;
|
||||
A2()
|
||||
: value() { }
|
||||
|
||||
pointer allocate(size_type n) {
|
||||
T* allocate(std::size_t n) {
|
||||
value = n;
|
||||
return &value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
pointer allocate(size_type n, const void*) {
|
||||
value = n + 1;
|
||||
return &value;
|
||||
}
|
||||
|
||||
size_type value;
|
||||
std::size_t value;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
A1 a;
|
||||
BOOST_TEST_EQ(*boost::allocator_allocate(a, 1, 0), 1);
|
||||
A1<int> a;
|
||||
BOOST_TEST_NOT(boost::allocator_allocate(a, 5, 0));
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
}
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
A2 a;
|
||||
BOOST_TEST_EQ(*boost::allocator_allocate(a, 1, 0), 2);
|
||||
A2<int> a;
|
||||
BOOST_TEST_NOT(boost::allocator_allocate(a, 5, 0));
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -8,24 +8,24 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A {
|
||||
typedef int* pointer;
|
||||
typedef int size_type;
|
||||
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef std::size_t size_type;
|
||||
A()
|
||||
: value() { }
|
||||
|
||||
pointer allocate(size_type n) {
|
||||
T* allocate(std::size_t n) {
|
||||
value = n;
|
||||
return &value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_type value;
|
||||
std::size_t value;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
BOOST_TEST_EQ(*boost::allocator_allocate(a, 5), 5);
|
||||
A<int> a;
|
||||
BOOST_TEST_NOT(boost::allocator_allocate(a, 5));
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -9,22 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef char value_type;
|
||||
typedef int* pointer;
|
||||
typedef T value_type;
|
||||
typedef int* const_pointer;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef char value_type;
|
||||
typedef int* pointer;
|
||||
typedef const bool* const_pointer;
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
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>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_const_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
|
||||
boost::allocator_const_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -9,20 +9,31 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef int* pointer;
|
||||
typedef T value_type;
|
||||
typedef int* const_pointer;
|
||||
typedef int* const_void_pointer;
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef A1<U> other;
|
||||
};
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef int* pointer;
|
||||
typedef const bool* const_void_pointer;
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_const_void_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
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>));
|
||||
boost::allocator_const_void_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -6,43 +6,40 @@ 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;
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
A1() { }
|
||||
};
|
||||
|
||||
struct A1 { };
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
void construct(S* p, int v) {
|
||||
new(p) S(v + 1);
|
||||
typedef T value_type;
|
||||
A2() { }
|
||||
template<class U, class V>
|
||||
void construct(U* p, const V& v) {
|
||||
::new((void*)p) U(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);
|
||||
A1<int> a;
|
||||
int i = 0;
|
||||
boost::allocator_construct(a, &i, 5);
|
||||
BOOST_TEST_EQ(i, 5);
|
||||
}
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
S* p = d.allocate(1);
|
||||
A2 a;
|
||||
boost::allocator_construct(a, p, 1);
|
||||
BOOST_TEST_EQ(p->value, 2);
|
||||
d.deallocate(p, 1);
|
||||
A1<int> a;
|
||||
int i = 0;
|
||||
boost::allocator_construct(a, &i, 5);
|
||||
BOOST_TEST_EQ(i, 6);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -8,23 +8,22 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A {
|
||||
typedef int* pointer;
|
||||
typedef int size_type;
|
||||
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef std::size_t size_type;
|
||||
A()
|
||||
: value() { }
|
||||
|
||||
void deallocate(pointer, size_type n) {
|
||||
void deallocate(T*, std::size_t n) {
|
||||
value = n;
|
||||
}
|
||||
|
||||
size_type value;
|
||||
std::size_t value;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
A<int> a;
|
||||
boost::allocator_deallocate(a, 0, 5);
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -6,20 +6,16 @@ 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;
|
||||
}
|
||||
@@ -27,35 +23,39 @@ struct S {
|
||||
|
||||
int S::count = 0;
|
||||
|
||||
struct A1 { };
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
A1() { }
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
void destroy(S*) {
|
||||
++S::count;
|
||||
typedef T value_type;
|
||||
A2() { }
|
||||
template<class U>
|
||||
void destroy(U* p) {
|
||||
*p = U();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::default_allocator<S> d;
|
||||
{
|
||||
S* p = d.allocate(1);
|
||||
new(p) S;
|
||||
A1 a;
|
||||
boost::allocator_destroy(a, p);
|
||||
A1<int> a;
|
||||
S s;
|
||||
boost::allocator_destroy(a, &s);
|
||||
BOOST_TEST_EQ(S::count, 0);
|
||||
d.deallocate(p, 1);
|
||||
::new((void*)&s) S();
|
||||
}
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
{
|
||||
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);
|
||||
A1<int> a;
|
||||
int i = 5;
|
||||
boost::allocator_destroy(a, &i);
|
||||
BOOST_TEST_EQ(i, 0);
|
||||
}
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -9,20 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef char* pointer;
|
||||
typedef T value_type;
|
||||
typedef short difference_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef char* pointer;
|
||||
typedef int difference_type;
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<short,
|
||||
boost::allocator_difference_type<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
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>));
|
||||
boost::allocator_difference_type<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -9,28 +9,39 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
int value;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
struct is_always_equal {
|
||||
BOOST_STATIC_CONSTEXPR bool value = true;
|
||||
};
|
||||
|
||||
int value;
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
struct A3 { };
|
||||
template<class T>
|
||||
struct A3 {
|
||||
typedef T value_type;
|
||||
typedef std::false_type is_always_equal;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct A4 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type is_always_equal;
|
||||
int value;
|
||||
};
|
||||
#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
|
||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A2<int> >::type));
|
||||
BOOST_TEST_TRAIT_FALSE((boost::allocator_is_always_equal<A3<int> >::type));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::allocator_is_always_equal<A4<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -7,29 +7,33 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
*/
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <limits>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef long value_type;
|
||||
typedef T 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 {
|
||||
A1() { }
|
||||
short max_size() const {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef short size_type;
|
||||
A2() { }
|
||||
};
|
||||
#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);
|
||||
BOOST_TEST_EQ(boost::allocator_max_size(A1<int>()), 1);
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_LE(boost::allocator_max_size(A2<int>()),
|
||||
(std::numeric_limits<short>::max)());
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -9,19 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#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;
|
||||
};
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type propagate_on_container_copy_assignment;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_copy_assignment<A1>::type));
|
||||
allocator_propagate_on_container_copy_assignment<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_copy_assignment<A2>::type));
|
||||
allocator_propagate_on_container_copy_assignment<A2<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -9,19 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#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;
|
||||
};
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type propagate_on_container_move_assignment;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_move_assignment<A1>::type));
|
||||
allocator_propagate_on_container_move_assignment<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_move_assignment<A2>::type));
|
||||
allocator_propagate_on_container_move_assignment<A2<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -9,19 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#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;
|
||||
};
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
typedef std::true_type propagate_on_container_swap;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((boost::
|
||||
allocator_propagate_on_container_swap<A1>::type));
|
||||
allocator_propagate_on_container_swap<A1<int> >::type));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::
|
||||
allocator_propagate_on_container_swap<A2>::type));
|
||||
allocator_propagate_on_container_swap<A2<int> >::type));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -9,20 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef char value_type;
|
||||
};
|
||||
|
||||
struct A2 {
|
||||
typedef char value_type;
|
||||
typedef T value_type;
|
||||
typedef int* pointer;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
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>));
|
||||
boost::allocator_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -9,22 +9,29 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#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>
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
template<class>
|
||||
struct rebind {
|
||||
typedef A1<T, U, V> other;
|
||||
typedef A1<int> other;
|
||||
};
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
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>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A1<int>,
|
||||
boost::allocator_rebind<A1<char>, bool>::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<A2<int>,
|
||||
boost::allocator_rebind<A2<char>, int>::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -9,26 +9,26 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef long difference_type;
|
||||
typedef T value_type;
|
||||
typedef int size_type;
|
||||
};
|
||||
#else
|
||||
struct A1 {
|
||||
typedef unsigned long size_type;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef T value_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>));
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::allocator_size_type<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<std::size_t,
|
||||
boost::allocator_size_type<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -8,33 +8,34 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
A1(int v)
|
||||
: value(v) { }
|
||||
|
||||
typedef T value_type;
|
||||
A1(int n)
|
||||
: value(n) { }
|
||||
int value;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
A2(int v)
|
||||
: value(v) { }
|
||||
|
||||
typedef T value_type;
|
||||
A2(int n)
|
||||
: value(n) { }
|
||||
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);
|
||||
BOOST_TEST_EQ(1, boost::
|
||||
allocator_select_on_container_copy_construction(A1<int>(1)).value);
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_EQ(2, boost::
|
||||
allocator_select_on_container_copy_construction(A2<int>(1)).value);
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -9,13 +9,14 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A {
|
||||
typedef int value_type;
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
|
||||
boost::allocator_value_type<A>::type>));
|
||||
boost::allocator_value_type<A<int> >::type>));
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -9,20 +9,31 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
typedef T value_type;
|
||||
typedef int* pointer;
|
||||
typedef int* void_pointer;
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef A1<U> other;
|
||||
};
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
typedef int* pointer;
|
||||
typedef bool* void_pointer;
|
||||
typedef T value_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
|
||||
boost::allocator_void_pointer<A1<char> >::type>));
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
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>));
|
||||
boost::allocator_void_pointer<A2<int> >::type>));
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -173,20 +173,11 @@ void test_construct_other()
|
||||
(void)a5;
|
||||
}
|
||||
|
||||
#if defined(PTRDIFF_MAX) && defined(SIZE_MAX)
|
||||
template<class T>
|
||||
std::size_t max_size()
|
||||
{
|
||||
return PTRDIFF_MAX < SIZE_MAX / sizeof(T)
|
||||
? PTRDIFF_MAX : SIZE_MAX / sizeof(T);
|
||||
return static_cast<std::size_t>(-1) / (2 < sizeof(T) ? sizeof(T) : 2);
|
||||
}
|
||||
#else
|
||||
template<class T>
|
||||
std::size_t max_size()
|
||||
{
|
||||
return ~static_cast<std::size_t>(0) / sizeof(T);
|
||||
}
|
||||
#endif
|
||||
|
||||
void test_max_size()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#define BOOST_ALLOW_DEPRECATED_HEADERS
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/core/is_same.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
19
test/lightweight_test_fail13.cpp
Normal file
19
test/lightweight_test_fail13.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
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/lightweight_test.hpp>
|
||||
|
||||
void f()
|
||||
{
|
||||
throw 5;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_NO_THROW(f());
|
||||
return boost::report_errors();
|
||||
}
|
||||
26
test/lightweight_test_fail14.cpp
Normal file
26
test/lightweight_test_fail14.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
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/lightweight_test.hpp>
|
||||
|
||||
struct error
|
||||
: std::exception {
|
||||
const char* what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
|
||||
return "message";
|
||||
}
|
||||
};
|
||||
|
||||
void f()
|
||||
{
|
||||
throw error();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_NO_THROW(f());
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -108,5 +108,9 @@ int main()
|
||||
BOOST_TEST_THROWS( f(true), X );
|
||||
BOOST_TEST_THROWS( f(false), int );
|
||||
|
||||
// BOOST_TEST_NO_THROW
|
||||
|
||||
BOOST_TEST_NO_THROW(++y);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
39
test/lightweight_test_with_fail.cpp
Normal file
39
test/lightweight_test_with_fail.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Negative test for BOOST_TEST_WITH
|
||||
//
|
||||
// Copyright 2020 Bjorn Reese
|
||||
// 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 <cmath>
|
||||
|
||||
template <typename T>
|
||||
struct with_tolerance
|
||||
{
|
||||
with_tolerance( T tolerance ): tolerance( tolerance )
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()( T lhs, T rhs ) const
|
||||
{
|
||||
return std::abs( lhs - rhs ) <= tolerance;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T tolerance;
|
||||
};
|
||||
|
||||
void test_tolerance_predicate()
|
||||
{
|
||||
BOOST_TEST_WITH( 1.0, 1.0 - 1e-6, with_tolerance<double>(1e-7) );
|
||||
BOOST_TEST_WITH( 1.0, 1.0 + 1e-6, with_tolerance<double>(1e-7) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_tolerance_predicate();
|
||||
return boost::report_errors() == 2;
|
||||
}
|
||||
39
test/lightweight_test_with_test.cpp
Normal file
39
test/lightweight_test_with_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Test for BOOST_TEST_WITH
|
||||
//
|
||||
// Copyright (c) 2020 Bjorn Reese
|
||||
//
|
||||
// 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 <cmath>
|
||||
|
||||
template <typename T>
|
||||
struct with_tolerance
|
||||
{
|
||||
with_tolerance(T tolerance) : tolerance(tolerance) {}
|
||||
bool operator()(T lhs, T rhs) const
|
||||
{
|
||||
return (std::abs(lhs - rhs) <= tolerance);
|
||||
}
|
||||
|
||||
private:
|
||||
T tolerance;
|
||||
};
|
||||
|
||||
void test_tolerance_predicate()
|
||||
{
|
||||
BOOST_TEST_WITH( 1.0, 1.0, with_tolerance<double>(1e-5) );
|
||||
BOOST_TEST_WITH( 1.0, 1.0 - 1e-6, with_tolerance<double>(1e-5) );
|
||||
BOOST_TEST_WITH( 1.0, 1.0 + 1e-6, with_tolerance<double>(1e-5) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_tolerance_predicate();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -12,7 +12,6 @@
|
||||
#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>
|
||||
|
||||
Reference in New Issue
Block a user