mirror of
https://github.com/boostorg/container.git
synced 2025-08-01 05:24:31 +02:00
Don't use allocator::rebind as it is not present on recent c++ standards
This commit is contained in:
@@ -23,31 +23,11 @@
|
|||||||
#include <cassert> //assert
|
#include <cassert> //assert
|
||||||
|
|
||||||
#include <boost/move/detail/nsec_clock.hpp>
|
#include <boost/move/detail/nsec_clock.hpp>
|
||||||
|
|
||||||
using boost::move_detail::cpu_timer;
|
using boost::move_detail::cpu_timer;
|
||||||
using boost::move_detail::cpu_times;
|
using boost::move_detail::cpu_times;
|
||||||
using boost::move_detail::nanosecond_type;
|
using boost::move_detail::nanosecond_type;
|
||||||
|
|
||||||
namespace bc = boost::container;
|
|
||||||
|
|
||||||
typedef std::allocator<int> StdAllocator;
|
|
||||||
typedef bc::allocator<int, 2, bc::expand_bwd | bc::expand_fwd> AllocatorPlusV2Mask;
|
|
||||||
typedef bc::allocator<int, 2, bc::expand_fwd> AllocatorPlusV2;
|
|
||||||
typedef bc::allocator<int, 1> AllocatorPlusV1;
|
|
||||||
|
|
||||||
template<class Allocator> struct get_allocator_name;
|
|
||||||
|
|
||||||
template<> struct get_allocator_name<StdAllocator>
|
|
||||||
{ static const char *get() { return "StdAllocator"; } };
|
|
||||||
|
|
||||||
template<> struct get_allocator_name<AllocatorPlusV2Mask>
|
|
||||||
{ static const char *get() { return "AllocatorPlusV2Mask"; } };
|
|
||||||
|
|
||||||
template<> struct get_allocator_name<AllocatorPlusV2>
|
|
||||||
{ static const char *get() { return "AllocatorPlusV2"; } };
|
|
||||||
|
|
||||||
template<> struct get_allocator_name<AllocatorPlusV1>
|
|
||||||
{ static const char *get() { return "AllocatorPlusV1"; } };
|
|
||||||
|
|
||||||
//typedef int MyInt;
|
//typedef int MyInt;
|
||||||
|
|
||||||
class MyInt
|
class MyInt
|
||||||
@@ -89,6 +69,30 @@ struct has_trivial_destructor_after_move<MyInt>
|
|||||||
} //namespace boost{
|
} //namespace boost{
|
||||||
|
|
||||||
|
|
||||||
|
namespace bc = boost::container;
|
||||||
|
|
||||||
|
typedef std::allocator<MyInt> StdAllocator;
|
||||||
|
typedef bc::allocator<MyInt, 2, bc::expand_bwd | bc::expand_fwd> AllocatorPlusV2Mask;
|
||||||
|
typedef bc::allocator<MyInt, 2, bc::expand_fwd> AllocatorPlusV2;
|
||||||
|
typedef bc::allocator<MyInt, 1> AllocatorPlusV1;
|
||||||
|
|
||||||
|
template<class Allocator> struct get_allocator_name;
|
||||||
|
|
||||||
|
template<> struct get_allocator_name<StdAllocator>
|
||||||
|
{ static const char *get() { return "StdAllocator"; } };
|
||||||
|
|
||||||
|
template<> struct get_allocator_name<AllocatorPlusV2Mask>
|
||||||
|
{ static const char *get() { return "AllocatorPlusV2Mask"; } };
|
||||||
|
|
||||||
|
template<> struct get_allocator_name<AllocatorPlusV2>
|
||||||
|
{ static const char *get() { return "AllocatorPlusV2"; } };
|
||||||
|
|
||||||
|
template<> struct get_allocator_name<AllocatorPlusV1>
|
||||||
|
{ static const char *get() { return "AllocatorPlusV1"; } };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void print_header()
|
void print_header()
|
||||||
{
|
{
|
||||||
std::cout << "Allocator" << ";" << "Iterations" << ";" << "Size" << ";"
|
std::cout << "Allocator" << ";" << "Iterations" << ";" << "Size" << ";"
|
||||||
@@ -99,7 +103,7 @@ void print_header()
|
|||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
void vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output)
|
void vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output)
|
||||||
{
|
{
|
||||||
typedef typename Allocator::template rebind<MyInt>::other IntAllocator;
|
typedef Allocator IntAllocator;
|
||||||
unsigned int numalloc = 0, numexpand = 0;
|
unsigned int numalloc = 0, numexpand = 0;
|
||||||
|
|
||||||
cpu_timer timer;
|
cpu_timer timer;
|
||||||
|
@@ -31,21 +31,6 @@ using boost::move_detail::nanosecond_type;
|
|||||||
|
|
||||||
namespace bc = boost::container;
|
namespace bc = boost::container;
|
||||||
|
|
||||||
typedef std::allocator<int> StdAllocator;
|
|
||||||
typedef bc::allocator<int, 2> AllocatorPlusV2;
|
|
||||||
typedef bc::allocator<int, 1> AllocatorPlusV1;
|
|
||||||
|
|
||||||
template<class Allocator> struct get_allocator_name;
|
|
||||||
|
|
||||||
template<> struct get_allocator_name<StdAllocator>
|
|
||||||
{ static const char *get() { return "StdAllocator"; } };
|
|
||||||
|
|
||||||
template<> struct get_allocator_name<AllocatorPlusV2>
|
|
||||||
{ static const char *get() { return "AllocatorPlusV2"; } };
|
|
||||||
|
|
||||||
template<> struct get_allocator_name<AllocatorPlusV1>
|
|
||||||
{ static const char *get() { return "AllocatorPlusV1"; } };
|
|
||||||
|
|
||||||
class MyInt
|
class MyInt
|
||||||
{
|
{
|
||||||
std::size_t int_; //Use a type that will grow on 64 bit machines
|
std::size_t int_; //Use a type that will grow on 64 bit machines
|
||||||
@@ -64,6 +49,21 @@ class MyInt
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef std::allocator<MyInt> StdAllocator;
|
||||||
|
typedef bc::allocator<MyInt, 2> AllocatorPlusV2;
|
||||||
|
typedef bc::allocator<MyInt, 1> AllocatorPlusV1;
|
||||||
|
|
||||||
|
template<class Allocator> struct get_allocator_name;
|
||||||
|
|
||||||
|
template<> struct get_allocator_name<StdAllocator>
|
||||||
|
{ static const char *get() { return "StdAllocator"; } };
|
||||||
|
|
||||||
|
template<> struct get_allocator_name<AllocatorPlusV2>
|
||||||
|
{ static const char *get() { return "AllocatorPlusV2"; } };
|
||||||
|
|
||||||
|
template<> struct get_allocator_name<AllocatorPlusV1>
|
||||||
|
{ static const char *get() { return "AllocatorPlusV1"; } };
|
||||||
|
|
||||||
void print_header()
|
void print_header()
|
||||||
{
|
{
|
||||||
std::cout << "Allocator" << ";" << "Iterations" << ";" << "Size" << ";"
|
std::cout << "Allocator" << ";" << "Iterations" << ";" << "Size" << ";"
|
||||||
@@ -73,7 +73,7 @@ void print_header()
|
|||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
void vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output)
|
void vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output)
|
||||||
{
|
{
|
||||||
typedef typename Allocator::template rebind<MyInt>::other IntAllocator;
|
typedef Allocator IntAllocator;
|
||||||
|
|
||||||
unsigned int capacity = 0;
|
unsigned int capacity = 0;
|
||||||
const std::size_t Step = 5;
|
const std::size_t Step = 5;
|
||||||
|
@@ -34,11 +34,27 @@ using boost::move_detail::nanosecond_type;
|
|||||||
|
|
||||||
namespace bc = boost::container;
|
namespace bc = boost::container;
|
||||||
|
|
||||||
typedef std::allocator<int> StdAllocator;
|
class MyInt
|
||||||
typedef bc::allocator<int, 1> AllocatorPlusV1;
|
{
|
||||||
typedef bc::allocator<int, 2> AllocatorPlusV2;
|
int int_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MyInt(int i = 0) : int_(i){}
|
||||||
|
MyInt(const MyInt &other)
|
||||||
|
: int_(other.int_)
|
||||||
|
{}
|
||||||
|
MyInt & operator=(const MyInt &other)
|
||||||
|
{
|
||||||
|
int_ = other.int_;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::allocator<MyInt> StdAllocator;
|
||||||
|
typedef bc::allocator<MyInt, 1> AllocatorPlusV1;
|
||||||
|
typedef bc::allocator<MyInt, 2> AllocatorPlusV2;
|
||||||
typedef bc::adaptive_pool
|
typedef bc::adaptive_pool
|
||||||
< int
|
< MyInt
|
||||||
, bc::ADP_nodes_per_block
|
, bc::ADP_nodes_per_block
|
||||||
, 0//bc::ADP_max_free_blocks
|
, 0//bc::ADP_max_free_blocks
|
||||||
, 2
|
, 2
|
||||||
@@ -58,27 +74,10 @@ template<> struct get_allocator_name<AllocatorPlusV2>
|
|||||||
template<> struct get_allocator_name<AdPool2PercentV2>
|
template<> struct get_allocator_name<AdPool2PercentV2>
|
||||||
{ static const char *get() { return "AdPool2PercentV2"; } };
|
{ static const char *get() { return "AdPool2PercentV2"; } };
|
||||||
|
|
||||||
class MyInt
|
|
||||||
{
|
|
||||||
int int_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
MyInt(int i = 0) : int_(i){}
|
|
||||||
MyInt(const MyInt &other)
|
|
||||||
: int_(other.int_)
|
|
||||||
{}
|
|
||||||
MyInt & operator=(const MyInt &other)
|
|
||||||
{
|
|
||||||
int_ = other.int_;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
struct get_vector
|
struct get_vector
|
||||||
{
|
{
|
||||||
typedef bc::vector
|
typedef bc::vector<MyInt, Allocator> type;
|
||||||
<MyInt, typename Allocator::template rebind<MyInt>::other> type;
|
|
||||||
static const char *vector_name()
|
static const char *vector_name()
|
||||||
{
|
{
|
||||||
return "vector<MyInt>";
|
return "vector<MyInt>";
|
||||||
@@ -89,7 +88,7 @@ template<class Allocator>
|
|||||||
struct get_stable_vector
|
struct get_stable_vector
|
||||||
{
|
{
|
||||||
typedef bc::stable_vector
|
typedef bc::stable_vector
|
||||||
<MyInt, typename Allocator::template rebind<MyInt>::other> type;
|
<MyInt, Allocator> type;
|
||||||
static const char *vector_name()
|
static const char *vector_name()
|
||||||
{
|
{
|
||||||
return "stable_vector<MyInt>";
|
return "stable_vector<MyInt>";
|
||||||
|
Reference in New Issue
Block a user