Merge branch 'develop' into revert-issue-209

This commit is contained in:
Ion Gaztañaga
2025-09-06 23:54:24 +02:00
committed by GitHub
15 changed files with 331 additions and 95 deletions

1
.gitignore vendored
View File

@@ -19,3 +19,4 @@
/bench/detail/hash_table.hpp
/Bin/
/include/boost/container/new_deque.hpp
/test/new_deque_test.cpp

View File

@@ -15,10 +15,10 @@ Distributed under the [Boost Software License, Version 1.0](http://www.boost.org
### Build Status
Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
[`master`](https://github.com/boostorg/container/tree/master) | [![Build Status](https://travis-ci.org/boostorg/container.svg?branch=master)](https://travis-ci.org/boostorg/container) | [![Build status](https://ci.appveyor.com/api/projects/status/9ckrveolxsonxfnb/branch/master?svg=true)](https://ci.appveyor.com/project/jeking3/container-0k1xg/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16048/badge.svg)](https://scan.coverity.com/projects/boostorg-container) | [![codecov](https://codecov.io/gh/boostorg/container/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/container/branch/master)| [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/container.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/container.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](https://regression.boost.io/master/developer/container.html)
[`develop`](https://github.com/boostorg/container/tree/develop) | [![Build Status](https://travis-ci.org/boostorg/container.svg?branch=develop)](https://travis-ci.org/boostorg/container) | [![Build status](https://ci.appveyor.com/api/projects/status/9ckrveolxsonxfnb/branch/develop?svg=true)](https://ci.appveyor.com/project/jeking3/container-0k1xg/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16048/badge.svg)](https://scan.coverity.com/projects/boostorg-container) | [![codecov](https://codecov.io/gh/boostorg/container/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/container/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/container.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/container.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](https://regression.boost.io/develop/developer/container.html)
Branch | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
:-------------: | -------- | ------------- | ---------- | ---- | ---- | ----- |
[`master`](https://github.com/boostorg/container/tree/master) | [![Build status](https://ci.appveyor.com/api/projects/status/9ckrveolxsonxfnb/branch/master?svg=true)](https://ci.appveyor.com/project/jeking3/container-0k1xg/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16048/badge.svg)](https://scan.coverity.com/projects/boostorg-container) | [![codecov](https://codecov.io/gh/boostorg/container/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/container/branch/master)| [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/container.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/container.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](https://regression.boost.io/master/developer/container.html)
[`develop`](https://github.com/boostorg/container/tree/develop) | [![Build status](https://ci.appveyor.com/api/projects/status/9ckrveolxsonxfnb/branch/develop?svg=true)](https://ci.appveyor.com/project/jeking3/container-0k1xg/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/16048/badge.svg)](https://scan.coverity.com/projects/boostorg-container) | [![codecov](https://codecov.io/gh/boostorg/container/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/container/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/container.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/container.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](https://regression.boost.io/develop/developer/container.html)
### Directories

View File

@@ -12,6 +12,7 @@
#include <deque>
#include <boost/container/vector.hpp>
#include <boost/container/deque.hpp>
#include "new_deque.hpp"
#include <boost/container/devector.hpp>
#include <boost/container/small_vector.hpp>
#include <boost/container/stable_vector.hpp>
@@ -93,8 +94,9 @@ struct capacity_wrapper<C, false>
{ }
};
const std::size_t RangeSize = 5;
const std::size_t RangeSize = 8;
template <class IntType>
struct insert_end_range
{
inline std::size_t capacity_multiplier() const
@@ -105,11 +107,12 @@ struct insert_end_range
{ c.insert(c.end(), &a[0], &a[0]+RangeSize); }
const char *name() const
{ return "insert_end_range"; }
{ return "insert_end_range(8)"; }
MyInt a[RangeSize];
IntType a[RangeSize];
};
template <class IntType>
struct insert_end_repeated
{
inline std::size_t capacity_multiplier() const
@@ -117,14 +120,15 @@ struct insert_end_repeated
template<class C>
inline void operator()(C &c, int i)
{ c.insert(c.end(), RangeSize, MyInt(i)); }
{ c.insert(c.end(), RangeSize, IntType(i)); }
inline const char *name() const
{ return "insert_end_repeated"; }
{ return "insert_end_repeated(8)"; }
MyInt a[RangeSize];
IntType a[RangeSize];
};
template <class IntType>
struct push_back
{
inline std::size_t capacity_multiplier() const
@@ -132,12 +136,13 @@ struct push_back
template<class C>
inline void operator()(C &c, int i)
{ c.push_back(MyInt(i)); }
{ c.push_back(IntType(i)); }
inline const char *name() const
{ return "push_back"; }
};
template <class IntType>
struct emplace_back
{
inline std::size_t capacity_multiplier() const
@@ -151,6 +156,7 @@ struct emplace_back
{ return "emplace_back"; }
};
template <class IntType>
struct insert_near_end_repeated
{
inline std::size_t capacity_multiplier() const
@@ -158,12 +164,13 @@ struct insert_near_end_repeated
template<class C>
inline void operator()(C &c, int i)
{ c.insert(c.size() >= 2*RangeSize ? c.end()-2*RangeSize : c.begin(), RangeSize, MyInt(i)); }
{ c.insert(c.size() >= 2*RangeSize ? c.end()-2*RangeSize : c.begin(), RangeSize, IntType(i)); }
inline const char *name() const
{ return "insert_near_end_repeated"; }
{ return "insert_near_end_repeated(8)"; }
};
template <class IntType>
struct insert_near_end_range
{
inline std::size_t capacity_multiplier() const
@@ -176,11 +183,12 @@ struct insert_near_end_range
}
inline const char *name() const
{ return "insert_near_end_range"; }
{ return "insert_near_end_range(8)"; }
MyInt a[RangeSize];
IntType a[RangeSize];
};
template <class IntType>
struct insert_near_end
{
inline std::size_t capacity_multiplier() const
@@ -192,13 +200,14 @@ struct insert_near_end
typedef typename C::iterator it_t;
it_t it (c.end());
it -= static_cast<typename C::difference_type>(c.size() >= 2)*2;
c.insert(it, MyInt(i));
c.insert(it, IntType(i));
}
inline const char *name() const
{ return "insert_near_end"; }
};
template <class IntType>
struct emplace_near_end
{
inline std::size_t capacity_multiplier() const
@@ -272,7 +281,7 @@ void vector_test_template(std::size_t num_iterations, std::size_t num_elements,
nanosecond_type nseconds = timer.elapsed().wall;
std::cout << cont_name << "->" << op.name() <<" ns: "
std::cout << cont_name << "->" << " ns: "
<< std::setw(8)
<< float(nseconds)/float((num_iterations-1)*num_elements)
<< '\t'
@@ -280,8 +289,8 @@ void vector_test_template(std::size_t num_iterations, std::size_t num_elements,
<< std::endl;
}
template<class Operation>
void test_vectors()
template<class IntType, class Operation>
void test_vectors_impl()
{
//#define SINGLE_TEST
#define SIMPLE_IT
@@ -293,7 +302,11 @@ void test_vectors()
#endif
std::size_t numele [] = { 100000 };
#elif defined SIMPLE_IT
#ifdef NDEBUG
std::size_t numit [] = { 50 };
#else
std::size_t numit [] = { 10 };
#endif
std::size_t numele [] = { 100000 };
#else
#ifdef NDEBUG
@@ -304,42 +317,69 @@ void test_vectors()
unsigned int numele [] = { 10000, 1000, 100, 10 };
#endif
//#define PRERESERVE_ONLY
#ifdef PRERESERVE_ONLY
#define P_INIT 1
#else
#define P_INIT 0
#endif
for (unsigned p = P_INIT; p != 2; ++p) {
std::cout << Operation().name() << ", prereserve: " << (p ? "1" : "0") << "\n" << std::endl;
const bool bp =p != 0;
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
vector_test_template< std::vector<MyInt, std::allocator<MyInt> >, Operation >(numit[i], numele[i], "std::vector ", bp);
vector_test_template< bc::vector<MyInt, std::allocator<MyInt> >, Operation >(numit[i], numele[i] , "vector ", bp);
vector_test_template< bc::small_vector<MyInt, 0, std::allocator<MyInt> >, Operation >(numit[i], numele[i], "small_vector ", bp);
vector_test_template< bc::devector<MyInt, std::allocator<MyInt> >, Operation >(numit[i], numele[i], "devector ", bp);
//vector_test_template< std::deque<MyInt, std::allocator<MyInt> >, Operation >(numit[i], numele[i], "std::deque ", bp);
vector_test_template< bc::deque<MyInt, std::allocator<MyInt> >, Operation >(numit[i], numele[i], "deque ", bp);
#define RESERVE_ONLY 0
#define NORESERVE_ONLY 1
//#define RESERVE_STRATEGY NORESERVE_ONLY
#define RESERVE_STRATEGY RESERVE_ONLY
#ifndef RESERVE_STRATEGY
#define P_INIT 0
#define P_END 2
#elif RESERVE_STRATEGY == PRERESERVE_ONLY
#define P_INIT 1
#define P_END 2
#elif RESERVE_STRATEGY == NORESERVE_ONLY
#define P_INIT 0
#define P_END 1
#endif
for (unsigned p = P_INIT; p != P_END; ++p) {
std::cout << "---------------------------------\n";
std::cout << "IntType:" << typeid(IntType).name() << " op:" << Operation().name() << ", prereserve: " << (p ? "1" : "0") << "\n";
std::cout << "---------------------------------\n";
const bool bp = p != 0;
const std::size_t it_count = sizeof(numele)/sizeof(numele[0]);
for(unsigned int i = 0; i < it_count; ++i){
std::cout << "\n" << " ---- numit[i]: " << numit[i] << " numele[i] : " << numele[i] << " ---- \n";
vector_test_template< std::vector<IntType, std::allocator<IntType> >, Operation >(numit[i], numele[i], "std::vector ", bp);
vector_test_template< bc::vector<IntType, std::allocator<IntType> >, Operation >(numit[i], numele[i] , "vector ", bp);
vector_test_template< bc::small_vector<IntType, 0, std::allocator<IntType> >, Operation >(numit[i], numele[i], "small_vector ", bp);
vector_test_template< bc::devector<IntType, std::allocator<IntType> >, Operation >(numit[i], numele[i], "devector ", bp);
vector_test_template< std::deque<IntType, std::allocator<IntType> >, Operation >(numit[i], numele[i], "std::deque ", bp);
vector_test_template< bc::deque<IntType, std::allocator<IntType> >, Operation >(numit[i], numele[i], "deque ", bp);
vector_test_template< bc::new_deque<IntType, std::allocator<IntType> >, Operation >(numit[i], numele[i], "new_deque ", bp);
}
std::cout << "---------------------------------\n---------------------------------\n";
}
}
int main()
template<class IntType>
void test_vectors()
{
//end
test_vectors<push_back>();
test_vectors<insert_end_range>();
test_vectors<insert_end_repeated>();
//near end
test_vectors<insert_near_end>();
test_vectors<insert_near_end_range>();
test_vectors<insert_near_end_repeated>();
test_vectors_impl<IntType, push_back<IntType> >();
#if BOOST_CXX_VERSION >= 201103L
test_vectors<emplace_back>();
test_vectors<emplace_near_end>();
test_vectors_impl<IntType, emplace_back<IntType> >();
#endif
test_vectors_impl<IntType, insert_end_range<IntType> >();
test_vectors_impl<IntType, insert_end_repeated<IntType> >();
//near end
test_vectors_impl<IntType, insert_near_end<IntType> >();
#if BOOST_CXX_VERSION >= 201103L
test_vectors_impl<IntType, emplace_near_end<IntType> >();
#endif
test_vectors_impl<IntType, insert_near_end_range<IntType> >();
test_vectors_impl<IntType, insert_near_end_repeated<IntType> >();
}
int main()
{
//test_vectors<MyInt>();
test_vectors<int>();
return 0;
}

View File

@@ -1425,9 +1425,11 @@ use [*Boost.Container]? There are several reasons for that:
* Fixed bugs/issues:
* [@https://github.com/boostorg/container/pull/294 GitHub #294: ['"CMake: Add option to use header-only Boost::container"]].
* [@https://github.com/boostorg/container/issues/300 GitHub #300: ['"Warnings when building with clang-20"]].
* [@https://github.com/boostorg/container/pull/305 GitHub #305: ['"Warnings with -Wstrict-prototypes"]].
* [@https://github.com/boostorg/container/pull/307 GitHub #307: ['"Fix all instances of MSVC warning C4146 (unsigned negation)"]].
* [@https://github.com/boostorg/container/issues/309 GitHub #309: ['"Performance regression of boost::container::static_vector introduced in boost v1.86"]].
* [@https://github.com/boostorg/container/issues/306 GitHub #306: ['"new_allocator.hpp error: '__cpp_sized_deallocation' is not defined, evaluates to 0 [-Werror,-Wundef]"]].
* [@https://github.com/boostorg/container/issues/310 GitHub #310: ['"flat_map: Mention correct type in documentation of emplace and emplace_hint"]].
[endsect]

View File

@@ -116,7 +116,7 @@ class allocator
allocator& operator=(const allocator<T2, Version2, AllocationDisableMask2>&);
BOOST_STATIC_CONSTEXPR unsigned int ForbiddenMask =
BOOST_CONTAINER_ALLOCATE_NEW | BOOST_CONTAINER_EXPAND_BWD | BOOST_CONTAINER_EXPAND_FWD ;
BOOST_CONTAINER_ALLOCATE_NEW | BOOST_CONTAINER_EXPAND_BWD | BOOST_CONTAINER_EXPAND_FWD;
//The mask can't disable all the allocation types
BOOST_CONTAINER_STATIC_ASSERT(( (AllocationDisableMask & ForbiddenMask) != ForbiddenMask ));

View File

@@ -228,7 +228,7 @@ inline F memmove(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW
const value_type *const end_raw = boost::movelib::iterator_to_raw_pointer(l);
if(BOOST_LIKELY(beg_raw != end_raw && dest_raw && beg_raw)){
const std::size_t n = std::size_t(end_raw - beg_raw) ;
std::memmove(dest_raw, beg_raw, sizeof(value_type)*n);
std::memmove(reinterpret_cast<void *>(dest_raw), beg_raw, sizeof(value_type)*n);
r += static_cast<r_difference_type>(n);
}
return r;
@@ -800,10 +800,9 @@ inline typename dtl::enable_if_memtransfer_copy_assignable<I, F, F>::type
template
<typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, F>::type
copy_n(I f, U n, F r)
copy_n(I f, std::size_t n, F r)
{
while (n) {
--n;
@@ -815,10 +814,9 @@ inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, F>::type
template
<typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator
inline typename dtl::enable_if_memtransfer_copy_assignable<I, F, F>::type
copy_n(I f, U n, F r) BOOST_NOEXCEPT_OR_NOTHROW
copy_n(I f, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{ return dtl::memmove_n(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -829,10 +827,9 @@ inline typename dtl::enable_if_memtransfer_copy_assignable<I, F, F>::type
template
<typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type
copy_n_source(I f, U n, F r)
copy_n_source(I f, std::size_t n, F r)
{
while (n) {
--n;
@@ -910,10 +907,9 @@ inline typename dtl::enable_if_memtransfer_copy_assignable<I, F, F>::type
template
<typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, F>::type
move_n(I f, U n, F r)
move_n(I f, std::size_t n, F r)
{
while (n) {
--n;
@@ -925,13 +921,11 @@ inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, F>::type
template
<typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator
inline typename dtl::enable_if_memtransfer_copy_assignable<I, F, F>::type
move_n(I f, U n, F r) BOOST_NOEXCEPT_OR_NOTHROW
move_n(I f, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{ return dtl::memmove_n(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
//
// move_backward
@@ -961,11 +955,82 @@ inline typename dtl::enable_if_memtransfer_copy_assignable<I, F, F>::type
const std::size_t n = boost::container::iterator_udistance(f, l);
if (BOOST_LIKELY(n != 0)){
r -= n;
std::memmove((boost::movelib::iterator_to_raw_pointer)(r), (boost::movelib::iterator_to_raw_pointer)(f), sizeof(value_type)*n);
std::memmove(reinterpret_cast<void *>((boost::movelib::iterator_to_raw_pointer)(r)), (boost::movelib::iterator_to_raw_pointer)(f), sizeof(value_type)*n);
}
return r;
}
//////////////////////////////////////////////////////////////////////////////
//
// move_backward_n
//
//////////////////////////////////////////////////////////////////////////////
template
<typename I, // I models BidirectionalIterator
typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, F>::type
move_backward_n(I l, std::size_t n, F r)
{
while (n) {
--n;
--l; --r;
*r = ::boost::move(*l);
}
return r;
}
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename dtl::enable_if_memtransfer_copy_assignable<I, F, F>::type
move_backward_n(I l, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{
typedef typename boost::container::iter_value<I>::type value_type;
if (BOOST_LIKELY(n != 0)){
r -= n;
std::memmove((boost::movelib::iterator_to_raw_pointer)(r), (boost::movelib::iterator_to_raw_pointer)(l) - n, sizeof(value_type)*n);
}
return r;
}
//////////////////////////////////////////////////////////////////////////////
//
// move_backward_n_source
//
//////////////////////////////////////////////////////////////////////////////
template
<typename I, // I models BidirectionalIterator
typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type
move_backward_n_source(I l, std::size_t n, F r)
{
while (n) {
--n;
--l; --r;
*r = ::boost::move(*l);
}
return l;
}
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename dtl::enable_if_memtransfer_copy_assignable<I, F, I>::type
move_backward_n_source(I l, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{
typedef typename boost::container::iter_value<I>::type value_type;
if (BOOST_LIKELY(n != 0)){
r -= n;
l -= n;
std::memmove((boost::movelib::iterator_to_raw_pointer)(r), l, sizeof(value_type)*n);
}
return l;
}
//////////////////////////////////////////////////////////////////////////////
//
// move_n_source_dest
@@ -974,10 +1039,9 @@ inline typename dtl::enable_if_memtransfer_copy_assignable<I, F, F>::type
template
<typename I // I models InputIterator
,typename U // U models unsigned integral constant
,typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type
move_n_source_dest(I f, U n, F &r)
move_n_source_dest(I f, std::size_t n, F &r)
{
while (n) {
--n;
@@ -1002,10 +1066,9 @@ inline typename dtl::enable_if_memtransfer_copy_assignable<I, F, I>::type
template
<typename I // I models InputIterator
,typename U // U models unsigned integral constant
,typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type
move_n_source(I f, U n, F r)
move_n_source(I f, std::size_t n, F r)
{
while (n) {
--n;
@@ -1043,10 +1106,9 @@ inline B move_backward_overlapping(B f, B l, B rl)
template
<typename Allocator
,typename I // I models InputIterator
,typename U> // U models unsigned integral constant
,typename I> // I models InputIterator
inline typename dtl::disable_if_trivially_destructible<I, void>::type
destroy_alloc_n(Allocator &a, I f, U n)
destroy_alloc_n(Allocator &a, I f, std::size_t n)
{
while(n){
--n;
@@ -1057,10 +1119,9 @@ inline typename dtl::disable_if_trivially_destructible<I, void>::type
template
<typename Allocator
,typename I // I models InputIterator
,typename U> // U models unsigned integral constant
,typename I> // I models InputIterator
inline typename dtl::enable_if_trivially_destructible<I, void>::type
destroy_alloc_n(Allocator &, I, U)
destroy_alloc_n(Allocator &, I, std::size_t)
{}
//////////////////////////////////////////////////////////////////////////////

View File

@@ -90,7 +90,7 @@ struct intrusive_list_type
, dtl::bi::size_type
<typename allocator_traits_type::size_type>
>::type container_type;
typedef container_type type ;
typedef container_type type;
};
} //namespace dtl {

View File

@@ -163,7 +163,7 @@ class new_allocator
void deallocate(pointer ptr, size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{
(void)n;
# if __cpp_sized_deallocation
# if defined(__cpp_sized_deallocation)
::operator delete((void*)ptr, n * sizeof(T));
#else
::operator delete((void*)ptr);

View File

@@ -94,7 +94,7 @@ struct intrusive_slist_type
, dtl::bi::size_type
<typename allocator_traits_type::size_type>
>::type container_type;
typedef container_type type ;
typedef container_type type;
};
} //namespace dtl {

View File

@@ -454,16 +454,16 @@ struct vector_alloc_holder
}
}
inline void set_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE void set_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
{ this->m_size = static_cast<stored_size_type>(s); }
inline void dec_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE void dec_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
{ this->m_size = static_cast<stored_size_type>(this->m_size - s); }
inline void inc_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE void inc_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
{ this->m_size = static_cast<stored_size_type>(this->m_size + s); }
inline void set_stored_capacity(size_type c) BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE void set_stored_capacity(size_type c) BOOST_NOEXCEPT_OR_NOTHROW
{ this->m_capacity = static_cast<stored_size_type>(c); }
inline pointer allocation_command(boost::container::allocation_type command,
@@ -546,13 +546,13 @@ struct vector_alloc_holder
inline const allocator_type &alloc() const BOOST_NOEXCEPT_OR_NOTHROW
{ return *this; }
inline pointer start() const BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE pointer start() const BOOST_NOEXCEPT_OR_NOTHROW
{ return m_start; }
inline size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW
{ return m_capacity; }
inline void start(const pointer &p) BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE void start(const pointer &p) BOOST_NOEXCEPT_OR_NOTHROW
{ m_start = p; }
inline void capacity(const size_type &c) BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE void capacity(const size_type &c) BOOST_NOEXCEPT_OR_NOTHROW
{ BOOST_ASSERT( c <= stored_size_type(-1)); this->set_stored_capacity(c); }
static inline void on_capacity_overflow()
@@ -729,13 +729,13 @@ struct vector_alloc_holder<Allocator, StoredSizeType, version_0>
inline const allocator_type &alloc() const BOOST_NOEXCEPT_OR_NOTHROW
{ return *this; }
inline bool try_expand_fwd(size_type at_least)
BOOST_CONTAINER_FORCEINLINE bool try_expand_fwd(size_type at_least)
{ return !at_least; }
inline pointer start() const BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE pointer start() const BOOST_NOEXCEPT_OR_NOTHROW
{ return allocator_type::internal_storage(); }
inline size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE size_type capacity() const BOOST_NOEXCEPT_OR_NOTHROW
{ return allocator_type::internal_capacity; }
stored_size_type m_size;
@@ -2573,7 +2573,7 @@ private:
new_values_destroyer.release();
}
inline bool room_enough() const
BOOST_CONTAINER_FORCEINLINE bool room_enough() const
{ return this->m_holder.m_size != this->m_holder.capacity(); }
inline pointer back_ptr() const
@@ -2897,13 +2897,13 @@ private:
}
template<class U>
inline iterator priv_insert(const const_iterator &p, BOOST_FWD_REF(U) u)
BOOST_CONTAINER_FORCEINLINE iterator priv_insert(const const_iterator &p, BOOST_FWD_REF(U) u)
{
return this->emplace(p, ::boost::forward<U>(u));
}
template <class U>
inline void priv_push_back(BOOST_FWD_REF(U) u)
BOOST_CONTAINER_FORCEINLINE void priv_push_back(BOOST_FWD_REF(U) u)
{
this->emplace_back(::boost::forward<U>(u));
}
@@ -3014,6 +3014,7 @@ private:
{
return alloc_holder_t::on_capacity_overflow(), iterator();
}
#ifdef _MSC_VER
#pragma warning (pop)
#endif
@@ -3022,15 +3023,14 @@ private:
BOOST_CONTAINER_NOINLINE iterator priv_insert_forward_range_no_capacity
(T *const raw_pos, const size_type n, const InsertionProxy insert_range_proxy, version_1)
{
//Check if we have enough memory or try to expand current memory
const size_type n_pos = static_cast<size_type>(raw_pos - this->priv_raw_begin());
const size_type new_cap = this->m_holder.template next_capacity<growth_factor_type>(n);
//Pass the hint so that allocators can take advantage of this.
T * const new_buf = boost::movelib::to_raw_pointer(this->m_holder.allocate(new_cap));
#ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
++this->num_alloc;
#endif
//Check if we have enough memory or try to expand current memory
const size_type n_pos = static_cast<size_type>(raw_pos - this->priv_raw_begin());
this->priv_insert_forward_range_new_allocation(new_buf, new_cap, raw_pos, n, insert_range_proxy);
return iterator(this->m_holder.start() + difference_type(n_pos));
}
@@ -3221,10 +3221,10 @@ private:
}
private:
inline T *priv_raw_begin() const
BOOST_CONTAINER_FORCEINLINE T *priv_raw_begin() const
{ return boost::movelib::to_raw_pointer(m_holder.start()); }
inline T* priv_raw_end() const
BOOST_CONTAINER_FORCEINLINE T* priv_raw_end() const
{ return this->priv_raw_begin() + this->m_holder.m_size; }
template <class InsertionProxy> //inline single-element version as it is significantly smaller

100
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,100 @@
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# warning level 4
add_compile_options(/W4)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
if(NOT TARGET tests)
add_custom_target(tests)
endif()
set(PREFIX "boost_container_")
set(LINK_LIBRARIES Boost::container Boost::included_test_exec_monitor)
function(boost_container_add_test name source)
set(pname "${PREFIX}${name}")
add_executable(${pname} ${source})
target_link_libraries(${pname} ${LINK_LIBRARIES})
add_test(NAME ${pname} COMMAND ${pname})
add_dependencies(tests ${pname})
endfunction()
boost_container_add_test(allocator_traits_test allocator_traits_test.cpp)
boost_container_add_test(alloc_basic_test alloc_basic_test.cpp)
boost_container_add_test(alloc_full_test alloc_full_test.cpp)
boost_container_add_test(boost_iterator_comp_test boost_iterator_comp_test.cpp)
boost_container_add_test(common_iterator_test common_iterator_test.cpp)
boost_container_add_test(copy_move_algo_test copy_move_algo_test.cpp)
boost_container_add_test(deque_options_test deque_options_test.cpp)
boost_container_add_test(deque_test deque_test.cpp)
boost_container_add_test(devector_options_test devector_options_test.cpp)
boost_container_add_test(devector_test devector_test.cpp)
boost_container_add_test(explicit_inst_deque_test explicit_inst_deque_test.cpp)
boost_container_add_test(explicit_inst_devector_test explicit_inst_devector_test.cpp)
boost_container_add_test(explicit_inst_flat_map_test explicit_inst_flat_map_test.cpp)
boost_container_add_test(explicit_inst_flat_set_test explicit_inst_flat_set_test.cpp)
boost_container_add_test(explicit_inst_list_test explicit_inst_list_test.cpp)
boost_container_add_test(explicit_inst_map_test explicit_inst_map_test.cpp)
boost_container_add_test(explicit_inst_set_test explicit_inst_set_test.cpp)
boost_container_add_test(explicit_inst_slist_test explicit_inst_slist_test.cpp)
boost_container_add_test(explicit_inst_small_vector_test explicit_inst_small_vector_test.cpp)
boost_container_add_test(explicit_inst_stable_vector_test explicit_inst_stable_vector_test.cpp)
boost_container_add_test(explicit_inst_static_vector_test explicit_inst_static_vector_test.cpp)
boost_container_add_test(explicit_inst_string_test explicit_inst_string_test.cpp)
boost_container_add_test(explicit_inst_vector_test explicit_inst_vector_test.cpp)
boost_container_add_test(flat_map_adaptor_test flat_map_adaptor_test.cpp)
boost_container_add_test(flat_map_test flat_map_test.cpp)
boost_container_add_test(flat_set_adaptor_test flat_set_adaptor_test.cpp)
boost_container_add_test(flat_set_test flat_set_test.cpp)
boost_container_add_test(flat_tree_test flat_tree_test.cpp)
boost_container_add_test(global_resource_test global_resource_test.cpp)
boost_container_add_test(insert_vs_emplace_test insert_vs_emplace_test.cpp)
boost_container_add_test(list_test list_test.cpp)
boost_container_add_test(map_test map_test.cpp)
boost_container_add_test(memory_resource_test memory_resource_test.cpp)
boost_container_add_test(monotonic_buffer_resource_test monotonic_buffer_resource_test.cpp)
boost_container_add_test(node_handle_test node_handle_test.cpp)
boost_container_add_test(null_iterators_test null_iterators_test.cpp)
boost_container_add_test(pair_test pair_test.cpp)
boost_container_add_test(pmr_deque_test pmr_deque_test.cpp)
boost_container_add_test(pmr_devector_test pmr_devector_test.cpp)
boost_container_add_test(pmr_flat_map_test pmr_flat_map_test.cpp)
boost_container_add_test(pmr_flat_set_test pmr_flat_set_test.cpp)
boost_container_add_test(pmr_list_test pmr_list_test.cpp)
boost_container_add_test(pmr_map_test pmr_map_test.cpp)
boost_container_add_test(pmr_set_test pmr_set_test.cpp)
boost_container_add_test(pmr_slist_test pmr_slist_test.cpp)
boost_container_add_test(pmr_small_vector_test pmr_small_vector_test.cpp)
boost_container_add_test(pmr_stable_vector_test pmr_stable_vector_test.cpp)
boost_container_add_test(pmr_string_test pmr_string_test.cpp)
boost_container_add_test(pmr_vector_test pmr_vector_test.cpp)
boost_container_add_test(polymorphic_allocator_test polymorphic_allocator_test.cpp)
boost_container_add_test(resource_adaptor_test resource_adaptor_test.cpp)
boost_container_add_test(scoped_allocator_adaptor_test scoped_allocator_adaptor_test.cpp)
boost_container_add_test(scoped_allocator_usage_test scoped_allocator_usage_test.cpp)
boost_container_add_test(set_test set_test.cpp)
boost_container_add_test(slist_test slist_test.cpp)
boost_container_add_test(small_vector_options_test small_vector_options_test.cpp)
boost_container_add_test(small_vector_test small_vector_test.cpp)
boost_container_add_test(stable_vector_test stable_vector_test.cpp)
boost_container_add_test(static_vector_options_test static_vector_options_test.cpp)
boost_container_add_test(static_vector_test static_vector_test.cpp)
boost_container_add_test(string_test string_test.cpp)
boost_container_add_test(string_view_compat_test string_view_compat_test.cpp)
boost_container_add_test(synchronized_pool_resource_test synchronized_pool_resource_test.cpp)
boost_container_add_test(throw_exception_test throw_exception_test.cpp)
boost_container_add_test(tree_test tree_test.cpp)
boost_container_add_test(unsynchronized_pool_resource_test unsynchronized_pool_resource_test.cpp)
boost_container_add_test(uses_allocator_test uses_allocator_test.cpp)
boost_container_add_test(vector_options_test vector_options_test.cpp)
boost_container_add_test(vector_test vector_test.cpp)

View File

@@ -74,7 +74,7 @@ class propagation_test_allocator
void deallocate(value_type *ptr, std::size_t n)
{
(void)n;
# if __cpp_sized_deallocation
# if defined(__cpp_sized_deallocation)
::operator delete((void*)ptr, n * sizeof(value_type));
#else
::operator delete((void*)ptr);

View File

@@ -65,7 +65,7 @@ class simple_allocator
void deallocate(T *ptr, std::size_t n) BOOST_NOEXCEPT_OR_NOTHROW
{
(void)n;
# if __cpp_sized_deallocation
# if defined(__cpp_sized_deallocation)
::operator delete((void*)ptr, n * sizeof(T));
#else
::operator delete((void*)ptr);
@@ -187,7 +187,7 @@ class propagation_test_allocator
void deallocate(T *ptr, std::size_t n) BOOST_NOEXCEPT_OR_NOTHROW
{
(void)n;
# if __cpp_sized_deallocation
# if defined(__cpp_sized_deallocation)
::operator delete((void*)ptr, n * sizeof(T));
#else
::operator delete((void*)ptr);

View File

@@ -38,7 +38,7 @@ class CustomAllocator
void deallocate(pointer ptr, size_type n)
{
(void)n;
# if __cpp_sized_deallocation
# if defined(__cpp_sized_deallocation)
::operator delete((void*)ptr, n * sizeof(value_type));
#else
::operator delete((void*)ptr);

View File

@@ -367,6 +367,38 @@ int vector_move_assignable_only(boost::container::dtl::true_type)
}
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
}
{
//Initialize values
IntType aux_vect[50];
for(int i = 0; i < 50; ++i){
aux_vect[i] = -1;
}
int aux_vect2[50];
for(int i = 0; i < 50; ++i){
aux_vect2[i] = -1;
}
typename MyBoostVector::iterator insert_it =
boostvector.insert(boostvector.end()
,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(aux_vect + 50));
if(boost::container::iterator_udistance(insert_it, boostvector.end()) != 50) return 1;
stdvector.insert(stdvector.end(), aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector.erase(boostvector.begin(), boostvector.begin() + 5);
stdvector.erase(stdvector.begin(), stdvector.begin()+5);
boostvector.erase(boostvector.end() - 5, boostvector.end());
stdvector.erase(stdvector.end() - 5, stdvector.end());
boostvector.erase(boostvector.begin()+5, boostvector.begin() + 10);
stdvector.erase(stdvector.begin()+5, stdvector.begin()+10);
boostvector.erase(boostvector.end() - 10, boostvector.end()-5);
stdvector.erase(stdvector.end() - 10, stdvector.end()-5);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
}
{
boostvector.resize(100u);
stdvector.resize(100u);