Sync from upstream.

This commit is contained in:
Rene Rivera
2024-04-20 15:33:32 -05:00
28 changed files with 163 additions and 477 deletions
+11 -5
View File
@@ -14,7 +14,6 @@
#include <boost/container/uses_allocator.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/move/core.hpp>
#include <boost/move/detail/force_ptr.hpp>
template<class T, unsigned int Id, bool HasTrueTypes = false>
class propagation_test_allocator
@@ -69,11 +68,18 @@ class propagation_test_allocator
std::size_t max_size() const
{ return std::size_t(-1); }
T* allocate(std::size_t n)
{ return boost::move_detail::force_ptr<T*>(::new char[n*sizeof(T)]); }
value_type* allocate(std::size_t count)
{ return static_cast<value_type*>(::operator new(count * sizeof(value_type))); }
void deallocate(T*p, std::size_t)
{ delete []static_cast<char*>(static_cast<void*>(p)); }
void deallocate(value_type *ptr, std::size_t n)
{
(void)n;
# if __cpp_sized_deallocation
::operator delete((void*)ptr, n * sizeof(value_type));
#else
::operator delete((void*)ptr);
# endif
}
bool m_move_contructed;
bool m_move_assigned;
+10 -4
View File
@@ -366,11 +366,13 @@ int main ()
std::cerr << "test_cont_variants< std::allocator<void> > failed" << std::endl;
return 1;
}
// boost::container::allocator
if(test_cont_variants< allocator<void> >()){
std::cerr << "test_cont_variants< allocator<void> > failed" << std::endl;
return 1;
}
////////////////////////////////////
// Default init test
////////////////////////////////////
@@ -406,10 +408,14 @@ int main ()
////////////////////////////////////
{
typedef boost::container::deque<int> cont_int;
cont_int a; a.push_back(0); a.push_back(1); a.push_back(2);
boost::intrusive::test::test_iterator_random< cont_int >(a);
if(boost::report_errors() != 0) {
return 1;
for(std::size_t i = 1; i <= 10000; i*=10){
cont_int a;
for (int j = 0; j < (int)i; ++j)
a.push_back((int)j);
boost::intrusive::test::test_iterator_random< cont_int >(a);
if(boost::report_errors() != 0) {
return 1;
}
}
}
+8 -4
View File
@@ -4029,10 +4029,14 @@ int main()
////////////////////////////////////
{
typedef boost::container::devector<int> cont_int;
cont_int a; a.push_back(0); a.push_back(1); a.push_back(2);
boost::intrusive::test::test_iterator_random< cont_int >(a);
if (boost::report_errors() != 0) {
return 1;
for (std::size_t i = 10; i <= 10000; i *= 10) {
cont_int a;
for (int j = 0; j < (int)i; ++j)
a.push_back((int)j);
boost::intrusive::test::test_iterator_random< cont_int >(a);
if (boost::report_errors() != 0) {
return 1;
}
}
}
+20 -7
View File
@@ -34,7 +34,6 @@
#include <boost/move/utility_core.hpp>
#include <boost/move/adl_move_swap.hpp>
#include <boost/move/detail/force_ptr.hpp>
#include <boost/assert.hpp>
#include <memory>
@@ -61,10 +60,17 @@ class simple_allocator
{}
T* allocate(std::size_t n)
{ return move_detail::force_ptr<T*>(::new char[sizeof(T)*n]); }
{ return (T*) ::operator new(sizeof(T) * n); }
void deallocate(T*p, std::size_t)
{ delete[] ((char*)p);}
void deallocate(T *ptr, std::size_t n) BOOST_NOEXCEPT_OR_NOTHROW
{
(void)n;
# if __cpp_sized_deallocation
::operator delete((void*)ptr, n * sizeof(T));
#else
::operator delete((void*)ptr);
# endif
}
friend bool operator==(const simple_allocator &, const simple_allocator &)
{ return true; }
@@ -176,10 +182,17 @@ class propagation_test_allocator
{ unique_id_ = id; }
T* allocate(std::size_t n)
{ return move_detail::force_ptr<T*>(::new char[sizeof(T)*n]); }
{ return static_cast<T*>(::operator new(n * sizeof(T))); }
void deallocate(T*p, std::size_t)
{ delete[] ((char*)p);}
void deallocate(T *ptr, std::size_t n) BOOST_NOEXCEPT_OR_NOTHROW
{
(void)n;
# if __cpp_sized_deallocation
::operator delete((void*)ptr, n * sizeof(T));
#else
::operator delete((void*)ptr);
# endif
}
friend bool operator==(const propagation_test_allocator &a, const propagation_test_allocator &b)
{ return EqualIfEqualIds ? a.id_ == b.id_ : true; }
+2 -2
View File
@@ -17,7 +17,7 @@
#include <boost/container/detail/mpl.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/container/detail/type_traits.hpp>
#include <boost/move/detail/force_ptr.hpp> //adl_move_swap
#include <boost/move/detail/launder.hpp> //adl_move_swap
namespace boost{
namespace container {
@@ -152,7 +152,7 @@ static boost::container::dtl::aligned_storage<sizeof(EmplaceIntPair)*10>::type p
static EmplaceIntPair* initialize_emplace_int_pair()
{
EmplaceIntPair* ret = move_detail::force_ptr<EmplaceIntPair*>(&pair_storage);
EmplaceIntPair* ret = move_detail::launder_cast<EmplaceIntPair*>(&pair_storage);
for(unsigned int i = 0; i != 10; ++i){
new(&ret->first)EmplaceInt();
new(&ret->second)EmplaceInt();
+10 -4
View File
@@ -22,7 +22,6 @@ volatile ::boost::container::vector<empty> dummy;
#include <boost/container/allocator.hpp>
#include "movable_int.hpp"
#include "dummy_test_allocator.hpp"
#include <boost/move/detail/force_ptr.hpp>
class CustomAllocator
{
@@ -34,10 +33,17 @@ class CustomAllocator
typedef short difference_type;
pointer allocate(size_type count)
{ return boost::move_detail::force_ptr<pointer>(new char[sizeof(value_type)*count]); }
{ return static_cast<value_type*>(::operator new(count * sizeof(value_type))); }
void deallocate(pointer ptr, size_type )
{ delete [](char*)ptr; }
void deallocate(pointer ptr, size_type n)
{
(void)n;
# if __cpp_sized_deallocation
::operator delete((void*)ptr, n * sizeof(value_type));
#else
::operator delete((void*)ptr);
# endif
}
friend bool operator==(CustomAllocator const&, CustomAllocator const&) BOOST_NOEXCEPT
{ return true; }
+9 -5
View File
@@ -244,11 +244,15 @@ int main()
// Iterator testing
////////////////////////////////////
{
typedef boost::container::small_vector<int, 0> cont_int;
cont_int a; a.push_back(0); a.push_back(1); a.push_back(2);
boost::intrusive::test::test_iterator_random< cont_int >(a);
if(boost::report_errors() != 0) {
return 1;
typedef boost::container::small_vector<int, 10> cont_int;
for (std::size_t i = 10; i <= 10000; i *= 10) {
cont_int a;
for (int j = 0; j < (int)i; ++j)
a.push_back((int)j);
boost::intrusive::test::test_iterator_random< cont_int >(a);
if (boost::report_errors() != 0) {
return 1;
}
}
}
+8 -4
View File
@@ -173,10 +173,14 @@ int main()
////////////////////////////////////
{
typedef boost::container::stable_vector<int> cont_int;
cont_int a; a.push_back(0); a.push_back(1); a.push_back(2);
boost::intrusive::test::test_iterator_random< cont_int >(a);
if(boost::report_errors() != 0) {
return 1;
for (std::size_t i = 10; i <= 10000; i *= 10) {
cont_int a;
for (int j = 0; j < (int)i; ++j)
a.push_back((int)j);
boost::intrusive::test::test_iterator_random< cont_int >(a);
if (boost::report_errors() != 0) {
return 1;
}
}
}
+1 -1
View File
@@ -630,7 +630,7 @@ bool default_init_test()//Test for default initialization
typedef static_vector<unsigned char, Capacity> di_vector_t;
{
typename dtl::aligned_storage<sizeof(di_vector_t)>::type as;
dtl::aligned_storage<sizeof(di_vector_t)>::type as;
di_vector_t *pv = ::new(as.data)di_vector_t(Capacity);
//Use volatile pointer to make compiler's job harder, as we are riding on UB
+8 -4
View File
@@ -331,10 +331,14 @@ int main()
////////////////////////////////////
{
typedef boost::container::vector<int> cont_int;
cont_int a; a.push_back(0); a.push_back(1); a.push_back(2);
boost::intrusive::test::test_iterator_random< cont_int >(a);
if(boost::report_errors() != 0) {
return 1;
for (std::size_t i = 10; i <= 10000; i *= 10) {
cont_int a;
for (int j = 0; j < (int)i; ++j)
a.push_back((int)j);
boost::intrusive::test::test_iterator_random< cont_int >(a);
if (boost::report_errors() != 0) {
return 1;
}
}
}