mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 22:14:26 +02:00
- Modified relational operators to be friend inline definitions. This allows compilation checking when instantiating classes, avoids predeclarations and results in less verbose code.
- First to make associative containers' tree implementation configurable.
This commit is contained in:
327
bench/bench_adaptive_node_pool.cpp
Normal file
327
bench/bench_adaptive_node_pool.cpp
Normal file
@@ -0,0 +1,327 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4512)
|
||||
#pragma warning (disable : 4127)
|
||||
#pragma warning (disable : 4244)
|
||||
#pragma warning (disable : 4267)
|
||||
#endif
|
||||
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/list.hpp>
|
||||
#include <memory> //std::allocator
|
||||
#include <iostream> //std::cout, std::endl
|
||||
#include <vector> //std::vector
|
||||
#include <cstddef> //std::size_t
|
||||
#include <boost/timer/timer.hpp>
|
||||
using boost::timer::cpu_timer;
|
||||
using boost::timer::cpu_times;
|
||||
using boost::timer::nanosecond_type;
|
||||
|
||||
namespace bc = boost::container;
|
||||
|
||||
typedef std::allocator<int> StdAllocator;
|
||||
typedef bc::allocator<int, 2> AllocatorPlusV2;
|
||||
typedef bc::allocator<int, 1> AllocatorPlusV1;
|
||||
typedef bc::adaptive_pool
|
||||
< int
|
||||
, bc::ADP_nodes_per_block
|
||||
, bc::ADP_max_free_blocks
|
||||
, bc::ADP_only_alignment
|
||||
, 1> AdPoolAlignOnlyV1;
|
||||
typedef bc::adaptive_pool
|
||||
< int
|
||||
, bc::ADP_nodes_per_block
|
||||
, bc::ADP_max_free_blocks
|
||||
, bc::ADP_only_alignment
|
||||
, 2> AdPoolAlignOnlyV2;
|
||||
typedef bc::adaptive_pool
|
||||
< int
|
||||
, bc::ADP_nodes_per_block
|
||||
, bc::ADP_max_free_blocks
|
||||
, 2
|
||||
, 1> AdPool2PercentV1;
|
||||
typedef bc::adaptive_pool
|
||||
< int
|
||||
, bc::ADP_nodes_per_block
|
||||
, bc::ADP_max_free_blocks
|
||||
, 2
|
||||
, 2> AdPool2PercentV2;
|
||||
typedef bc::node_allocator
|
||||
< int
|
||||
, bc::NodeAlloc_nodes_per_block
|
||||
, 1> SimpleSegregatedStorageV1;
|
||||
typedef bc::node_allocator
|
||||
< int
|
||||
, bc::NodeAlloc_nodes_per_block
|
||||
, 2> SimpleSegregatedStorageV2;
|
||||
|
||||
//Explicit instantiation
|
||||
template class bc::adaptive_pool
|
||||
< int
|
||||
, bc::ADP_nodes_per_block
|
||||
, bc::ADP_max_free_blocks
|
||||
, bc::ADP_only_alignment
|
||||
, 2>;
|
||||
|
||||
template class bc::node_allocator
|
||||
< int
|
||||
, bc::NodeAlloc_nodes_per_block
|
||||
, 2>;
|
||||
|
||||
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"; } };
|
||||
|
||||
template<> struct get_allocator_name<AdPoolAlignOnlyV1>
|
||||
{ static const char *get() { return "AdPoolAlignOnlyV1"; } };
|
||||
|
||||
template<> struct get_allocator_name<AdPoolAlignOnlyV2>
|
||||
{ static const char *get() { return "AdPoolAlignOnlyV2"; } };
|
||||
|
||||
template<> struct get_allocator_name<AdPool2PercentV1>
|
||||
{ static const char *get() { return "AdPool2PercentV1"; } };
|
||||
|
||||
template<> struct get_allocator_name<AdPool2PercentV2>
|
||||
{ static const char *get() { return "AdPool2PercentV2"; } };
|
||||
|
||||
template<> struct get_allocator_name<SimpleSegregatedStorageV1>
|
||||
{ static const char *get() { return "SimpleSegregatedStorageV1"; } };
|
||||
|
||||
template<> struct get_allocator_name<SimpleSegregatedStorageV2>
|
||||
{ static const char *get() { return "SimpleSegregatedStorageV2"; } };
|
||||
|
||||
class MyInt
|
||||
{
|
||||
std::size_t int_;
|
||||
|
||||
public:
|
||||
explicit MyInt(std::size_t i = 0) : int_(i){}
|
||||
MyInt(const MyInt &other)
|
||||
: int_(other.int_)
|
||||
{}
|
||||
MyInt & operator=(const MyInt &other)
|
||||
{
|
||||
int_ = other.int_;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Allocator>
|
||||
void list_test_template(std::size_t num_iterations, std::size_t num_elements, bool csv_output)
|
||||
{
|
||||
typedef typename Allocator::template rebind<MyInt>::other IntAllocator;
|
||||
nanosecond_type tinsert, terase;
|
||||
boost_cont_malloc_stats_t insert_stats, erase_stats;
|
||||
std::size_t insert_inuse, erase_inuse;
|
||||
const size_t sizeof_node = 2*sizeof(void*)+sizeof(int);
|
||||
|
||||
typedef bc::list<MyInt, IntAllocator> list_t;
|
||||
typedef typename list_t::iterator iterator_t;
|
||||
{
|
||||
cpu_timer timer;
|
||||
timer.resume();
|
||||
list_t l;
|
||||
for(std::size_t r = 0; r != num_iterations; ++r){
|
||||
l.insert(l.end(), num_elements, MyInt(r));
|
||||
}
|
||||
timer.stop();
|
||||
tinsert = timer.elapsed().wall;
|
||||
|
||||
insert_inuse = boost_cont_in_use_memory();
|
||||
insert_stats = boost_cont_malloc_stats();
|
||||
/*
|
||||
iterator_t it(l.begin());
|
||||
iterator_t last(--l.end());
|
||||
for(std::size_t n_elem = 0, n_max = l.size()/2-1; n_elem != n_max; ++n_elem)
|
||||
{
|
||||
l.splice(it++, l, last--);
|
||||
}
|
||||
*/
|
||||
//l.reverse();
|
||||
|
||||
//Now preprocess erase ranges
|
||||
std::vector<iterator_t> ranges_to_erase;
|
||||
ranges_to_erase.push_back(l.begin());
|
||||
for(std::size_t r = 0; r != num_iterations; ++r){
|
||||
iterator_t next_pos(ranges_to_erase[r]);
|
||||
std::size_t n = num_elements;
|
||||
while(n--){ ++next_pos; }
|
||||
ranges_to_erase.push_back(next_pos);
|
||||
}
|
||||
|
||||
//Measure range erasure function
|
||||
timer.start();
|
||||
for(std::size_t r = 0; r != num_iterations; ++r){
|
||||
assert((r+1) < ranges_to_erase.size());
|
||||
l.erase(ranges_to_erase[r], ranges_to_erase[r+1]);
|
||||
}
|
||||
timer.stop();
|
||||
terase = timer.elapsed().wall;
|
||||
erase_inuse = boost_cont_in_use_memory();
|
||||
erase_stats = boost_cont_malloc_stats();
|
||||
}
|
||||
|
||||
|
||||
if(csv_output){
|
||||
std::cout << get_allocator_name<Allocator>::get()
|
||||
<< ";"
|
||||
<< num_iterations
|
||||
<< ";"
|
||||
<< num_elements
|
||||
<< ";"
|
||||
<< float(tinsert)/(num_iterations*num_elements)
|
||||
<< ";"
|
||||
<< (unsigned int)insert_stats.system_bytes
|
||||
<< ";"
|
||||
<< float(insert_stats.system_bytes)/(num_iterations*num_elements*sizeof_node)*100.0-100.0
|
||||
<< ";"
|
||||
<< (unsigned int)insert_inuse
|
||||
<< ";"
|
||||
<< (float(insert_inuse)/(num_iterations*num_elements*sizeof_node)*100.0)-100.0
|
||||
<< ";";
|
||||
std::cout << float(terase)/(num_iterations*num_elements)
|
||||
<< ";"
|
||||
<< (unsigned int)erase_stats.system_bytes
|
||||
<< ";"
|
||||
<< (unsigned int)erase_inuse
|
||||
<< std::endl;
|
||||
}
|
||||
else{
|
||||
std::cout << std::endl
|
||||
<< "Allocator: " << get_allocator_name<Allocator>::get()
|
||||
<< std::endl
|
||||
<< " allocation/deallocation(ns): " << float(tinsert)/(num_iterations*num_elements) << '\t' << float(terase)/(num_iterations*num_elements)
|
||||
<< std::endl
|
||||
<< " Sys MB(overh.)/Inuse MB(overh.): " << (float)insert_stats.system_bytes/(1024*1024) << "(" << float(insert_stats.system_bytes)/(num_iterations*num_elements*sizeof_node)*100.0-100.0 << "%)"
|
||||
<< " / "
|
||||
<< (float)insert_inuse/(1024*1024) << "(" << (float(insert_inuse)/(num_iterations*num_elements*sizeof_node)*100.0)-100.0 << "%)"
|
||||
<< std::endl
|
||||
<< " system MB/inuse bytes after: " << (float)erase_stats.system_bytes/(1024*1024) << '\t' << boost_cont_in_use_memory()
|
||||
<< std::endl << std::endl;
|
||||
}
|
||||
|
||||
//Release node_allocator cache
|
||||
typedef boost::container::container_detail::shared_node_pool
|
||||
< (2*sizeof(void*)+sizeof(int))
|
||||
, AdPoolAlignOnlyV2::nodes_per_block> shared_node_pool_t;
|
||||
boost::container::container_detail::singleton_default
|
||||
<shared_node_pool_t>::instance().purge_blocks();
|
||||
|
||||
//Release adaptive_pool cache
|
||||
typedef boost::container::container_detail::shared_adaptive_node_pool
|
||||
< (2*sizeof(void*)+sizeof(int))
|
||||
, AdPool2PercentV2::nodes_per_block
|
||||
, AdPool2PercentV2::max_free_blocks
|
||||
, AdPool2PercentV2::overhead_percent> shared_adaptive_pool_plus_t;
|
||||
boost::container::container_detail::singleton_default
|
||||
<shared_adaptive_pool_plus_t>::instance().deallocate_free_blocks();
|
||||
|
||||
//Release adaptive_pool cache
|
||||
typedef boost::container::container_detail::shared_adaptive_node_pool
|
||||
< (2*sizeof(void*)+sizeof(int))
|
||||
, AdPool2PercentV2::nodes_per_block
|
||||
, AdPool2PercentV2::max_free_blocks
|
||||
, 0u> shared_adaptive_pool_plus_align_only_t;
|
||||
boost::container::container_detail::singleton_default
|
||||
<shared_adaptive_pool_plus_align_only_t>::instance().deallocate_free_blocks();
|
||||
//Release dlmalloc memory
|
||||
boost_cont_trim(0);
|
||||
}
|
||||
|
||||
void print_header()
|
||||
{
|
||||
std::cout << "Allocator" << ";" << "Iterations" << ";" << "Size" << ";"
|
||||
<< "Insertion time(ns)" << ";"
|
||||
<< "System bytes" << ";"
|
||||
<< "System overhead(%)" << ";"
|
||||
<< "In use bytes" << ";"
|
||||
<< "In use overhead(%)" << ";"
|
||||
<< "Erasure time (ns)" << ";"
|
||||
<< "System bytes after" << ";"
|
||||
<< "In use bytes after"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
#define SINGLE_TEST
|
||||
#ifndef SINGLE_TEST
|
||||
#ifdef NDEBUG
|
||||
std::size_t numrep [] = { 3000, 30000, 300000, 3000000, 6000000, 15000000, 30000000 };
|
||||
#else
|
||||
std::size_t numrep [] = { 20, 200, 2000, 20000, 40000, 100000, 200000 };
|
||||
#endif
|
||||
std::size_t numele [] = { 10000, 1000, 100, 10, 5, 2, 1 };
|
||||
#else
|
||||
#ifdef NDEBUG
|
||||
std::size_t numrep [] = { 1500000 };
|
||||
#else
|
||||
std::size_t numrep [] = { 10000 };
|
||||
#endif
|
||||
std::size_t numele [] = { 10 };
|
||||
#endif
|
||||
|
||||
bool csv_output = argc == 2 && (strcmp(argv[1], "--csv-output") == 0);
|
||||
|
||||
if(csv_output){/*
|
||||
print_header();
|
||||
for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
list_test_template<AllocatorPlusV1>(numrep[i], numele[i], csv_output);
|
||||
}
|
||||
for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
list_test_template<AllocatorPlusV2>(numrep[i], numele[i], csv_output);
|
||||
}
|
||||
for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
list_test_template<AdPoolAlignOnlyV1>(numrep[i], numele[i], csv_output);
|
||||
}
|
||||
for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
list_test_template<AdPoolAlignOnlyV2>(numrep[i], numele[i], csv_output);
|
||||
}
|
||||
for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
list_test_template<AdPool2PercentV1>(numrep[i], numele[i], csv_output);
|
||||
}
|
||||
for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
list_test_template<AdPool2PercentV2>(numrep[i], numele[i], csv_output);
|
||||
}
|
||||
for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
list_test_template<SimpleSegregatedStorageV1>(numrep[i], numele[i], csv_output);
|
||||
}
|
||||
for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
list_test_template<SimpleSegregatedStorageV2>(numrep[i], numele[i], csv_output);
|
||||
}*/
|
||||
}
|
||||
else{
|
||||
for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
std::cout << "\n ----------------------------------- \n"
|
||||
<< " Iterations/Elements: " << numrep[i] << "/" << numele[i]
|
||||
<< "\n ----------------------------------- \n";
|
||||
list_test_template<AllocatorPlusV1>(numrep[i], numele[i], csv_output);
|
||||
list_test_template<AllocatorPlusV2>(numrep[i], numele[i], csv_output);
|
||||
list_test_template<AdPoolAlignOnlyV1>(numrep[i], numele[i], csv_output);
|
||||
list_test_template<AdPoolAlignOnlyV2>(numrep[i], numele[i], csv_output);
|
||||
list_test_template<AdPool2PercentV1>(numrep[i], numele[i], csv_output);
|
||||
list_test_template<AdPool2PercentV2>(numrep[i], numele[i], csv_output);
|
||||
list_test_template<SimpleSegregatedStorageV1>(numrep[i], numele[i], csv_output);
|
||||
list_test_template<SimpleSegregatedStorageV2>(numrep[i], numele[i], csv_output);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
181
bench/bench_alloc.cpp
Normal file
181
bench/bench_alloc.cpp
Normal file
@@ -0,0 +1,181 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4512)
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/alloc_lib_auto_link.hpp>
|
||||
|
||||
#define BOOST_INTERPROCESS_VECTOR_ALLOC_STATS
|
||||
|
||||
#include <iostream> //std::cout, std::endl
|
||||
#include <typeinfo> //typeid
|
||||
|
||||
#include <boost/timer/timer.hpp>
|
||||
using boost::timer::cpu_timer;
|
||||
using boost::timer::cpu_times;
|
||||
using boost::timer::nanosecond_type;
|
||||
|
||||
template <class POD>
|
||||
void allocation_timing_test(unsigned int num_iterations, unsigned int num_elements)
|
||||
{
|
||||
size_t capacity = 0;
|
||||
unsigned int numalloc = 0, numexpand = 0;
|
||||
|
||||
std::cout
|
||||
<< " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n"
|
||||
<< " Iterations/Elements: " << num_iterations << "/" << num_elements << '\n'
|
||||
<< " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n"
|
||||
<< std::endl;
|
||||
|
||||
|
||||
allocation_type malloc_types[] = { BOOST_CONTAINER_EXPAND_BWD, BOOST_CONTAINER_EXPAND_FWD, BOOST_CONTAINER_ALLOCATE_NEW };
|
||||
const char * malloc_names[] = { "Backwards expansion", "Forward expansion", "New allocation" };
|
||||
for(size_t i = 0; i < sizeof(malloc_types)/sizeof(allocation_type); ++i){
|
||||
numalloc = 0; numexpand = 0;
|
||||
const allocation_type m_mode = malloc_types[i];
|
||||
const char *malloc_name = malloc_names[i];
|
||||
|
||||
cpu_timer timer;
|
||||
timer.resume();
|
||||
|
||||
for(unsigned int r = 0; r != num_iterations; ++r){
|
||||
void *first_mem = 0;
|
||||
if(m_mode != BOOST_CONTAINER_EXPAND_FWD)
|
||||
first_mem = boost_cont_malloc(sizeof(POD)*num_elements*3/2);
|
||||
void *addr = boost_cont_malloc(1*sizeof(POD));
|
||||
if(m_mode == BOOST_CONTAINER_EXPAND_FWD)
|
||||
first_mem = boost_cont_malloc(sizeof(POD)*num_elements*3/2);
|
||||
capacity = boost_cont_size(addr)/sizeof(POD);
|
||||
boost_cont_free(first_mem);
|
||||
++numalloc;
|
||||
|
||||
try{
|
||||
boost_cont_command_ret_t ret;
|
||||
for(size_t e = capacity + 1; e < num_elements; ++e){
|
||||
size_t received_size;
|
||||
size_t min = (capacity+1)*sizeof(POD);
|
||||
size_t max = (capacity*3/2)*sizeof(POD);
|
||||
if(min > max)
|
||||
max = min;
|
||||
ret = boost_cont_allocation_command
|
||||
( m_mode, sizeof(POD)
|
||||
, min, max, &received_size, addr);
|
||||
if(!ret.first){
|
||||
std::cout << "(!ret.first)!" << std::endl;
|
||||
throw int(0);
|
||||
}
|
||||
if(!ret.second){
|
||||
assert(m_mode == BOOST_CONTAINER_ALLOCATE_NEW);
|
||||
if(m_mode != BOOST_CONTAINER_ALLOCATE_NEW){
|
||||
std::cout << "m_mode != BOOST_CONTAINER_ALLOCATE_NEW!" << std::endl;
|
||||
return;
|
||||
}
|
||||
boost_cont_free(addr);
|
||||
addr = ret.first;
|
||||
++numalloc;
|
||||
}
|
||||
else{
|
||||
assert(m_mode != BOOST_CONTAINER_ALLOCATE_NEW);
|
||||
if(m_mode == BOOST_CONTAINER_ALLOCATE_NEW){
|
||||
std::cout << "m_mode == BOOST_CONTAINER_ALLOCATE_NEW!" << std::endl;
|
||||
return;
|
||||
}
|
||||
++numexpand;
|
||||
}
|
||||
capacity = received_size/sizeof(POD);
|
||||
addr = ret.first;
|
||||
e = capacity + 1;
|
||||
}
|
||||
boost_cont_free(addr);
|
||||
}
|
||||
catch(...){
|
||||
boost_cont_free(addr);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
assert( boost_cont_allocated_memory() == 0);
|
||||
if(boost_cont_allocated_memory()!= 0){
|
||||
std::cout << "Memory leak!" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
nanosecond_type nseconds = timer.elapsed().wall;
|
||||
|
||||
std::cout << " Malloc type: " << malloc_name
|
||||
<< std::endl
|
||||
<< " allocation ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< std::endl
|
||||
<< " capacity - alloc calls (new/expand): "
|
||||
<< (unsigned int)capacity << " - "
|
||||
<< (float(numalloc) + float(numexpand))/num_iterations
|
||||
<< "(" << float(numalloc)/num_iterations << "/" << float(numexpand)/num_iterations << ")"
|
||||
<< std::endl << std::endl;
|
||||
boost_cont_trim(0);
|
||||
}
|
||||
}
|
||||
|
||||
template<unsigned N>
|
||||
struct char_holder
|
||||
{
|
||||
char ints_[N];
|
||||
};
|
||||
|
||||
template<class POD>
|
||||
int allocation_loop()
|
||||
{
|
||||
std::cout << std::endl
|
||||
<< "-------------------------------------------\n"
|
||||
<< "-------------------------------------------\n"
|
||||
<< " Type(sizeof): " << typeid(POD).name() << " (" << sizeof(POD) << ")\n"
|
||||
<< "-------------------------------------------\n"
|
||||
<< "-------------------------------------------\n"
|
||||
<< std::endl;
|
||||
|
||||
#define SINGLE_TEST
|
||||
#ifndef SINGLE_TEST
|
||||
#ifdef NDEBUG
|
||||
unsigned int numrep [] = { /*10000, */100000, 1000000, 10000000 };
|
||||
#else
|
||||
unsigned int numrep [] = { /*10000, */10000, 100000, 1000000 };
|
||||
#endif
|
||||
unsigned int numele [] = { /*10000, */1000, 100, 10 };
|
||||
#else
|
||||
#ifdef NDEBUG
|
||||
unsigned int numrep [] = { 500000 };
|
||||
#else
|
||||
unsigned int numrep [] = { 50000 };
|
||||
#endif
|
||||
unsigned int numele [] = { 100 };
|
||||
#endif
|
||||
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
allocation_timing_test<POD>(numrep[i], numele[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
boost_cont_mallopt( (-3)//M_MMAP_THRESHOLD
|
||||
, 100*10000000);
|
||||
//allocation_loop<char_holder<4> >();
|
||||
//allocation_loop<char_holder<6> >();
|
||||
allocation_loop<char_holder<8> >();
|
||||
allocation_loop<char_holder<12> >();
|
||||
//allocation_loop<char_holder<14> >();
|
||||
allocation_loop<char_holder<24> >();
|
||||
return 0;
|
||||
}
|
216
bench/bench_alloc_expand_bwd.cpp
Normal file
216
bench/bench_alloc_expand_bwd.cpp
Normal file
@@ -0,0 +1,216 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4512)
|
||||
#endif
|
||||
|
||||
#include <boost/container/allocator.hpp>
|
||||
|
||||
#define BOOST_CONTAINER_VECTOR_ALLOC_STATS
|
||||
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <memory> //std::allocator
|
||||
#include <iostream> //std::cout, std::endl
|
||||
|
||||
#include <boost/timer/timer.hpp>
|
||||
using boost::timer::cpu_timer;
|
||||
using boost::timer::cpu_times;
|
||||
using boost::timer::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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
~MyInt()
|
||||
{
|
||||
int_ = 0;
|
||||
}
|
||||
};
|
||||
namespace boost{
|
||||
|
||||
template<>
|
||||
struct has_trivial_destructor_after_move<MyInt>
|
||||
{
|
||||
static const bool value = true;
|
||||
//static const bool value = false;
|
||||
};
|
||||
|
||||
} //namespace boost{
|
||||
|
||||
|
||||
void print_header()
|
||||
{
|
||||
std::cout << "Allocator" << ";" << "Iterations" << ";" << "Size" << ";"
|
||||
<< "Capacity" << ";" << "push_back(ns)" << ";" << "Allocator calls" << ";"
|
||||
<< "New allocations" << ";" << "Bwd expansions" << std::endl;
|
||||
}
|
||||
|
||||
template<class Allocator>
|
||||
void vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output)
|
||||
{
|
||||
typedef typename Allocator::template rebind<MyInt>::other IntAllocator;
|
||||
unsigned int numalloc = 0, numexpand = 0;
|
||||
|
||||
cpu_timer timer;
|
||||
timer.resume();
|
||||
|
||||
unsigned int capacity = 0;
|
||||
for(unsigned int r = 0; r != num_iterations; ++r){
|
||||
bc::vector<MyInt, IntAllocator> v;
|
||||
v.reset_alloc_stats();
|
||||
void *first_mem = 0;
|
||||
try{
|
||||
first_mem = boost_cont_malloc(sizeof(MyInt)*num_elements*3/2);
|
||||
v.push_back(MyInt(0));
|
||||
boost_cont_free(first_mem);
|
||||
|
||||
for(unsigned int e = 0; e != num_elements; ++e){
|
||||
v.push_back(MyInt(e));
|
||||
}
|
||||
numalloc += v.num_alloc;
|
||||
numexpand += v.num_expand_bwd;
|
||||
capacity = static_cast<unsigned int>(v.capacity());
|
||||
}
|
||||
catch(...){
|
||||
boost_cont_free(first_mem);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
assert(boost_cont_allocated_memory() == 0);
|
||||
|
||||
timer.stop();
|
||||
nanosecond_type nseconds = timer.elapsed().wall;
|
||||
|
||||
if(csv_output){
|
||||
std::cout << get_allocator_name<Allocator>::get()
|
||||
<< ";"
|
||||
<< num_iterations
|
||||
<< ";"
|
||||
<< num_elements
|
||||
<< ";"
|
||||
<< capacity
|
||||
<< ";"
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< ";"
|
||||
<< (float(numalloc) + float(numexpand))/num_iterations
|
||||
<< ";"
|
||||
<< float(numalloc)/num_iterations
|
||||
<< ";"
|
||||
<< float(numexpand)/num_iterations
|
||||
<< std::endl;
|
||||
}
|
||||
else{
|
||||
std::cout << std::endl
|
||||
<< "Allocator: " << get_allocator_name<Allocator>::get()
|
||||
<< std::endl
|
||||
<< " push_back ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< std::endl
|
||||
<< " capacity - alloc calls (new/expand): "
|
||||
<< (unsigned int)capacity << " - "
|
||||
<< (float(numalloc) + float(numexpand))/num_iterations
|
||||
<< "(" << float(numalloc)/num_iterations << "/" << float(numexpand)/num_iterations << ")"
|
||||
<< std::endl;
|
||||
std::cout << '\n'
|
||||
<< " ----------------------------------- "
|
||||
<< std::endl;
|
||||
}
|
||||
boost_cont_trim(0);
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
#define SINGLE_TEST
|
||||
#ifndef SINGLE_TEST
|
||||
#ifdef NDEBUG
|
||||
unsigned int numit [] = { 20000, 200000, 2000000, 20000000 };
|
||||
#else
|
||||
unsigned int numit [] = { 100, 1000, 10000, 100000 };
|
||||
#endif
|
||||
unsigned int numele [] = { 10000, 1000, 100, 10 };
|
||||
#else
|
||||
#ifdef NDEBUG
|
||||
unsigned int numit [] = { 20000 };
|
||||
#else
|
||||
unsigned int numit [] = { 100 };
|
||||
#endif
|
||||
unsigned int numele [] = { 10000 };
|
||||
#endif
|
||||
|
||||
bool csv_output = argc == 2 && (strcmp(argv[1], "--csv-output") == 0);
|
||||
|
||||
if(csv_output){
|
||||
print_header();
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
vector_test_template<StdAllocator>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
vector_test_template<AllocatorPlusV1>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
vector_test_template<AllocatorPlusV2Mask>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
vector_test_template<AllocatorPlusV2>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
std::cout << "\n ----------------------------------- \n"
|
||||
<< " Iterations/Elements: " << numit[i] << "/" << numele[i]
|
||||
<< "\n ----------------------------------- \n";
|
||||
vector_test_template<StdAllocator>(numit[i], numele[i], csv_output);
|
||||
vector_test_template<AllocatorPlusV1>(numit[i], numele[i], csv_output);
|
||||
vector_test_template<AllocatorPlusV2Mask>(numit[i], numele[i], csv_output);
|
||||
vector_test_template<AllocatorPlusV2>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
285
bench/bench_alloc_expand_fwd.cpp
Normal file
285
bench/bench_alloc_expand_fwd.cpp
Normal file
@@ -0,0 +1,285 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4512)
|
||||
#pragma warning (disable : 4267)
|
||||
#pragma warning (disable : 4244)
|
||||
#endif
|
||||
|
||||
#define BOOST_CONTAINER_VECTOR_ALLOC_STATS
|
||||
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <vector>
|
||||
#include <boost/container/vector.hpp>
|
||||
|
||||
#include <memory> //std::allocator
|
||||
#include <iostream> //std::cout, std::endl
|
||||
#include <cstring> //std::strcmp
|
||||
#include <boost/timer/timer.hpp>
|
||||
using boost::timer::cpu_timer;
|
||||
using boost::timer::cpu_times;
|
||||
using boost::timer::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> 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"; } };
|
||||
|
||||
#if defined(BOOST_CONTAINER_VECTOR_ALLOC_STATS)
|
||||
//
|
||||
// stats_traits;
|
||||
//
|
||||
|
||||
template<template<class, class> class Vector>
|
||||
struct stats_traits;
|
||||
|
||||
template<>
|
||||
struct stats_traits<std::vector>
|
||||
{
|
||||
template<class T, class A>
|
||||
static void reset_alloc_stats(std::vector<T, A> &)
|
||||
{}
|
||||
|
||||
template<class T, class A>
|
||||
static std::size_t get_num_alloc(std::vector<T, A> &)
|
||||
{ return 0; }
|
||||
|
||||
template<class T, class A>
|
||||
static std::size_t get_num_expand(std::vector<T, A> &)
|
||||
{ return 0; }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct stats_traits<bc::vector>
|
||||
{
|
||||
template<class T, class A>
|
||||
static void reset_alloc_stats(bc::vector<T, A> &v)
|
||||
{ v.reset_alloc_stats(); }
|
||||
|
||||
template<class T, class A>
|
||||
static std::size_t get_num_alloc(bc::vector<T, A> &v)
|
||||
{ return v.num_alloc; }
|
||||
|
||||
template<class T, class A>
|
||||
static std::size_t get_num_expand(bc::vector<T, A> &v)
|
||||
{ return v.num_expand_fwd; }
|
||||
};
|
||||
|
||||
#endif //BOOST_CONTAINER_VECTOR_ALLOC_STATS
|
||||
|
||||
template<template<class, class> class Vector> struct get_container_name;
|
||||
|
||||
template<> struct get_container_name<std::vector>
|
||||
{ static const char *get() { return "StdVector"; } };
|
||||
|
||||
template<> struct get_container_name<bc::vector>
|
||||
{ static const char *get() { return "BoostContainerVector"; } };
|
||||
|
||||
class MyInt
|
||||
{
|
||||
int int_;
|
||||
|
||||
public:
|
||||
explicit MyInt(int i = 0)
|
||||
: int_(i)
|
||||
{}
|
||||
|
||||
MyInt(const MyInt &other)
|
||||
: int_(other.int_)
|
||||
{}
|
||||
|
||||
MyInt & operator=(const MyInt &other)
|
||||
{
|
||||
int_ = other.int_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~MyInt()
|
||||
{
|
||||
int_ = 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Allocator, template <class, class> class Vector>
|
||||
void vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output)
|
||||
{
|
||||
typedef typename Allocator::template rebind<MyInt>::other IntAllocator;
|
||||
unsigned int numalloc = 0, numexpand = 0;
|
||||
|
||||
#ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
|
||||
typedef stats_traits<Vector> stats_traits_t;
|
||||
#endif
|
||||
|
||||
cpu_timer timer;
|
||||
timer.resume();
|
||||
|
||||
unsigned int capacity = 0;
|
||||
for(unsigned int r = 0; r != num_iterations; ++r){
|
||||
Vector<MyInt, IntAllocator> v;
|
||||
#ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
|
||||
stats_traits_t::reset_alloc_stats(v);
|
||||
#endif
|
||||
//v.reserve(num_elements);
|
||||
//MyInt a[3];
|
||||
/*
|
||||
for(unsigned int e = 0; e != num_elements/3; ++e){
|
||||
v.insert(v.end(), &a[0], &a[0]+3);
|
||||
}*/
|
||||
/*
|
||||
for(unsigned int e = 0; e != num_elements/3; ++e){
|
||||
v.insert(v.end(), 3, MyInt(e));
|
||||
}*/
|
||||
/*
|
||||
for(unsigned int e = 0; e != num_elements/3; ++e){
|
||||
v.insert(v.empty() ? v.end() : --v.end(), &a[0], &a[0]+3);
|
||||
}*/
|
||||
/*
|
||||
for(unsigned int e = 0; e != num_elements/3; ++e){
|
||||
v.insert(v.empty() ? v.end() : --v.end(), 3, MyInt(e));
|
||||
}*/
|
||||
/*
|
||||
for(unsigned int e = 0; e != num_elements/3; ++e){
|
||||
v.insert(v.size() >= 3 ? v.end()-3 : v.begin(), &a[0], &a[0]+3);
|
||||
}*/
|
||||
/*
|
||||
for(unsigned int e = 0; e != num_elements/3; ++e){
|
||||
v.insert(v.size() >= 3 ? v.end()-3 : v.begin(), 3, MyInt(e));
|
||||
}*/
|
||||
/*
|
||||
for(unsigned int e = 0; e != num_elements; ++e){
|
||||
v.insert(v.end(), MyInt(e));
|
||||
}*/
|
||||
/*
|
||||
for(unsigned int e = 0; e != num_elements; ++e){
|
||||
v.insert(v.empty() ? v.end() : --v.end(), MyInt(e));
|
||||
}*/
|
||||
|
||||
for(unsigned int e = 0; e != num_elements; ++e){
|
||||
v.push_back(MyInt(e));
|
||||
}
|
||||
|
||||
#ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
|
||||
numalloc += stats_traits_t::get_num_alloc(v);
|
||||
numexpand += stats_traits_t::get_num_expand(v);
|
||||
#endif
|
||||
capacity = static_cast<unsigned int>(v.capacity());
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
nanosecond_type nseconds = timer.elapsed().wall;
|
||||
|
||||
if(csv_output){
|
||||
std::cout << get_allocator_name<Allocator>::get()
|
||||
<< ";"
|
||||
<< num_iterations
|
||||
<< ";"
|
||||
<< num_elements
|
||||
<< ";"
|
||||
<< capacity
|
||||
<< ";"
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< ";"
|
||||
<< (float(numalloc) + float(numexpand))/num_iterations
|
||||
<< ";"
|
||||
<< float(numalloc)/num_iterations
|
||||
<< ";"
|
||||
<< float(numexpand)/num_iterations
|
||||
<< std::endl;
|
||||
}
|
||||
else{
|
||||
std::cout << std::endl
|
||||
<< "Allocator: " << get_allocator_name<Allocator>::get()
|
||||
<< std::endl
|
||||
<< " push_back ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< std::endl
|
||||
<< " capacity - alloc calls (new/expand): "
|
||||
<< (unsigned int)capacity << " - "
|
||||
<< (float(numalloc) + float(numexpand))/num_iterations
|
||||
<< "(" << float(numalloc)/num_iterations << "/" << float(numexpand)/num_iterations << ")"
|
||||
<< std::endl << std::endl;
|
||||
}
|
||||
boost_cont_trim(0);
|
||||
}
|
||||
|
||||
void print_header()
|
||||
{
|
||||
std::cout << "Allocator" << ";" << "Iterations" << ";" << "Size" << ";"
|
||||
<< "Capacity" << ";" << "push_back(ns)" << ";" << "Allocator calls" << ";"
|
||||
<< "New allocations" << ";" << "Fwd expansions" << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
#define SINGLE_TEST
|
||||
#ifndef SINGLE_TEST
|
||||
#ifdef NDEBUG
|
||||
unsigned int numit [] = { 10000, 100000, 1000000, 10000000 };
|
||||
#else
|
||||
unsigned int numit [] = { 100, 1000, 10000, 100000 };
|
||||
#endif
|
||||
unsigned int numele [] = { 10000, 1000, 100, 10 };
|
||||
#else
|
||||
#ifdef NDEBUG
|
||||
std::size_t numit [] = { 10000 };
|
||||
#else
|
||||
std::size_t numit [] = { 100 };
|
||||
#endif
|
||||
std::size_t numele [] = { 10000 };
|
||||
#endif
|
||||
|
||||
bool csv_output = argc == 2 && (strcmp(argv[1], "--csv-output") == 0);
|
||||
|
||||
if(csv_output){
|
||||
print_header();
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
vector_test_template<StdAllocator, bc::vector>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
vector_test_template<AllocatorPlusV1, bc::vector>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
vector_test_template<AllocatorPlusV2Mask, bc::vector>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
vector_test_template<AllocatorPlusV2, bc::vector>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
std::cout << "\n ----------------------------------- \n"
|
||||
<< " Iterations/Elements: " << numit[i] << "/" << numele[i]
|
||||
<< "\n ----------------------------------- \n";
|
||||
vector_test_template<StdAllocator, std::vector>(numit[i], numele[i], csv_output);
|
||||
vector_test_template<StdAllocator, bc::vector>(numit[i], numele[i], csv_output);
|
||||
vector_test_template<AllocatorPlusV1, bc::vector>(numit[i], numele[i], csv_output);
|
||||
vector_test_template<AllocatorPlusV2Mask, bc::vector>(numit[i], numele[i], csv_output);
|
||||
vector_test_template<AllocatorPlusV2, bc::vector>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
166
bench/bench_alloc_shrink_to_fit.cpp
Normal file
166
bench/bench_alloc_shrink_to_fit.cpp
Normal file
@@ -0,0 +1,166 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4512)
|
||||
#endif
|
||||
|
||||
#include <boost/container/allocator.hpp>
|
||||
|
||||
#define BOOST_CONTAINER_VECTOR_ALLOC_STATS
|
||||
|
||||
#include <boost/container/vector.hpp>
|
||||
|
||||
#undef BOOST_CONTAINER_VECTOR_ALLOC_STATS
|
||||
|
||||
#include <memory> //std::allocator
|
||||
#include <iostream> //std::cout, std::endl
|
||||
|
||||
#include <boost/timer/timer.hpp>
|
||||
using boost::timer::cpu_timer;
|
||||
using boost::timer::cpu_times;
|
||||
using boost::timer::nanosecond_type;
|
||||
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
void print_header()
|
||||
{
|
||||
std::cout << "Allocator" << ";" << "Iterations" << ";" << "Size" << ";"
|
||||
<< "num_shrink" << ";" << "shrink_to_fit(ns)" << std::endl;
|
||||
}
|
||||
|
||||
template<class Allocator>
|
||||
void vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output)
|
||||
{
|
||||
typedef typename Allocator::template rebind<MyInt>::other IntAllocator;
|
||||
|
||||
unsigned int capacity = 0;
|
||||
const std::size_t Step = 5;
|
||||
unsigned int num_shrink = 0;
|
||||
(void)capacity;
|
||||
|
||||
cpu_timer timer;
|
||||
timer.resume();
|
||||
|
||||
typedef bc::container_detail::integral_constant
|
||||
<unsigned, bc::container_detail::version<Allocator>::value> alloc_version;
|
||||
|
||||
for(unsigned int r = 0; r != num_iterations; ++r){
|
||||
bc::vector<MyInt, IntAllocator> v(num_elements);
|
||||
v.reset_alloc_stats();
|
||||
num_shrink = 0;
|
||||
for(unsigned int e = num_elements; e != 0; e -= Step){
|
||||
v.erase(v.end() - Step, v.end());
|
||||
v.shrink_to_fit();
|
||||
assert( (alloc_version::value != 2) || (e == Step) || (v.num_shrink > num_shrink) );
|
||||
num_shrink = v.num_shrink;
|
||||
}
|
||||
assert(v.empty());
|
||||
assert(0 == v.capacity());
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
nanosecond_type nseconds = timer.elapsed().wall;
|
||||
|
||||
if(csv_output){
|
||||
std::cout << get_allocator_name<Allocator>::get()
|
||||
<< ";"
|
||||
<< num_iterations
|
||||
<< ";"
|
||||
<< num_elements
|
||||
<< ";"
|
||||
<< num_shrink
|
||||
<< ";"
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< std::endl;
|
||||
}
|
||||
else{
|
||||
std::cout << std::endl
|
||||
<< "Allocator: " << get_allocator_name<Allocator>::get()
|
||||
<< std::endl
|
||||
<< " num_shrink: " << num_shrink
|
||||
<< std::endl
|
||||
<< " shrink_to_fit ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< std::endl << std::endl;
|
||||
}
|
||||
boost_cont_trim(0);
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
#define SINGLE_TEST
|
||||
#ifndef SINGLE_TEST
|
||||
unsigned int numit [] = { 100, 1000, 10000 };
|
||||
unsigned int numele [] = { 10000, 2000, 500 };
|
||||
#else
|
||||
unsigned int numit [] = { 500 };
|
||||
unsigned int numele [] = { 2000 };
|
||||
#endif
|
||||
|
||||
bool csv_output = argc == 2 && (strcmp(argv[1], "--csv-output") == 0);
|
||||
|
||||
if(csv_output){
|
||||
print_header();
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
vector_test_template<StdAllocator>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
vector_test_template<AllocatorPlusV1>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
vector_test_template<AllocatorPlusV2>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
std::cout << "\n ----------------------------------- \n"
|
||||
<< " Iterations/Elements: " << numit[i] << "/" << numele[i]
|
||||
<< "\n ----------------------------------- \n";
|
||||
vector_test_template<StdAllocator>(numit[i], numele[i], csv_output);
|
||||
vector_test_template<AllocatorPlusV1>(numit[i], numele[i], csv_output);
|
||||
vector_test_template<AllocatorPlusV2>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
287
bench/bench_alloc_stable_vector_burst_allocation.cpp
Normal file
287
bench/bench_alloc_stable_vector_burst_allocation.cpp
Normal file
@@ -0,0 +1,287 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4512)
|
||||
#pragma warning (disable : 4541)
|
||||
#pragma warning (disable : 4673)
|
||||
#pragma warning (disable : 4671)
|
||||
#pragma warning (disable : 4244)
|
||||
#endif
|
||||
|
||||
#include <memory> //std::allocator
|
||||
#include <iostream> //std::cout, std::endl
|
||||
#include <vector> //std::vector
|
||||
#include <cstddef> //std::size_t
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
#include <boost/container/stable_vector.hpp>
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/timer/timer.hpp>
|
||||
using boost::timer::cpu_timer;
|
||||
using boost::timer::cpu_times;
|
||||
using boost::timer::nanosecond_type;
|
||||
|
||||
namespace bc = boost::container;
|
||||
|
||||
typedef std::allocator<int> StdAllocator;
|
||||
typedef bc::allocator<int, 1> AllocatorPlusV1;
|
||||
typedef bc::allocator<int, 2> AllocatorPlusV2;
|
||||
typedef bc::adaptive_pool
|
||||
< int
|
||||
, bc::ADP_nodes_per_block
|
||||
, 0//bc::ADP_max_free_blocks
|
||||
, 2
|
||||
, 2> AdPool2PercentV2;
|
||||
|
||||
template<class Allocator> struct get_allocator_name;
|
||||
|
||||
template<> struct get_allocator_name<StdAllocator>
|
||||
{ static const char *get() { return "StdAllocator"; } };
|
||||
|
||||
template<> struct get_allocator_name<AllocatorPlusV1>
|
||||
{ static const char *get() { return "AllocatorPlusV1"; } };
|
||||
|
||||
template<> struct get_allocator_name<AllocatorPlusV2>
|
||||
{ static const char *get() { return "AllocatorPlusV2"; } };
|
||||
|
||||
template<> struct get_allocator_name<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>
|
||||
struct get_vector
|
||||
{
|
||||
typedef bc::vector
|
||||
<MyInt, typename Allocator::template rebind<MyInt>::other> type;
|
||||
static const char *vector_name()
|
||||
{
|
||||
return "vector<MyInt>";
|
||||
}
|
||||
};
|
||||
|
||||
template<class Allocator>
|
||||
struct get_stable_vector
|
||||
{
|
||||
typedef bc::stable_vector
|
||||
<MyInt, typename Allocator::template rebind<MyInt>::other> type;
|
||||
static const char *vector_name()
|
||||
{
|
||||
return "stable_vector<MyInt>";
|
||||
}
|
||||
};
|
||||
|
||||
template<template<class> class GetContainer, class Allocator>
|
||||
void stable_vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output)
|
||||
{
|
||||
typedef typename GetContainer<Allocator>::type vector_type;
|
||||
//std::size_t top_capacity = 0;
|
||||
nanosecond_type nseconds;
|
||||
{
|
||||
{
|
||||
vector_type l;
|
||||
cpu_timer timer;
|
||||
timer.resume();
|
||||
|
||||
for(unsigned int r = 0; r != num_iterations; ++r){
|
||||
l.insert(l.end(), num_elements, MyInt(r));
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
nseconds = timer.elapsed().wall;
|
||||
|
||||
if(csv_output){
|
||||
std::cout << get_allocator_name<Allocator>::get()
|
||||
<< ";"
|
||||
<< GetContainer<Allocator>::vector_name()
|
||||
<< ";"
|
||||
<< num_iterations
|
||||
<< ";"
|
||||
<< num_elements
|
||||
<< ";"
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< ";";
|
||||
}
|
||||
else{
|
||||
std::cout << "Allocator: " << get_allocator_name<Allocator>::get()
|
||||
<< '\t'
|
||||
<< GetContainer<Allocator>::vector_name()
|
||||
<< std::endl
|
||||
<< " allocation ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements);
|
||||
}
|
||||
// top_capacity = l.capacity();
|
||||
//Now preprocess ranges to erase
|
||||
std::vector<typename vector_type::iterator> ranges_to_erase;
|
||||
ranges_to_erase.push_back(l.begin());
|
||||
for(unsigned int r = 0; r != num_iterations; ++r){
|
||||
typename vector_type::iterator next_pos(ranges_to_erase[r]);
|
||||
std::size_t n = num_elements;
|
||||
while(n--){ ++next_pos; }
|
||||
ranges_to_erase.push_back(next_pos);
|
||||
}
|
||||
|
||||
//Measure range erasure function
|
||||
timer.stop();
|
||||
timer.start();
|
||||
|
||||
for(unsigned int r = 0; r != num_iterations; ++r){
|
||||
std::size_t init_pos = (num_iterations-1)-r;
|
||||
l.erase(ranges_to_erase[init_pos], l.end());
|
||||
}
|
||||
timer.stop();
|
||||
nseconds = timer.elapsed().wall;
|
||||
assert(l.empty());
|
||||
}
|
||||
}
|
||||
|
||||
if(csv_output){
|
||||
std::cout << float(nseconds)/(num_iterations*num_elements)
|
||||
<< std::endl;
|
||||
}
|
||||
else{
|
||||
std::cout << '\t'
|
||||
<< " deallocation ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements)/*
|
||||
<< std::endl
|
||||
<< " max capacity: "
|
||||
<< static_cast<unsigned int>(top_capacity)
|
||||
<< std::endl
|
||||
<< " remaining cap. "
|
||||
<< static_cast<unsigned int>(top_capacity - num_iterations*num_elements)
|
||||
<< " (" << (float(top_capacity)/float(num_iterations*num_elements) - 1)*100 << " %)"*/
|
||||
<< std::endl << std::endl;
|
||||
}
|
||||
assert(boost_cont_all_deallocated());
|
||||
boost_cont_trim(0);
|
||||
}
|
||||
|
||||
void print_header()
|
||||
{
|
||||
std::cout << "Allocator" << ";" << "Iterations" << ";" << "Size" << ";"
|
||||
<< "Insertion time(ns)" << ";" << "Erasure time(ns)" << ";"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
void stable_vector_operations()
|
||||
{
|
||||
{
|
||||
bc::stable_vector<int> a(bc::stable_vector<int>::size_type(5), 4);
|
||||
bc::stable_vector<int> b(a);
|
||||
bc::stable_vector<int> c(a.cbegin(), a.cend());
|
||||
b.insert(b.cend(), 0);
|
||||
c.pop_back();
|
||||
a.assign(b.cbegin(), b.cend());
|
||||
a.assign(c.cbegin(), c.cend());
|
||||
a.assign(1, 2);
|
||||
}
|
||||
{
|
||||
typedef bc::stable_vector<int, std::allocator<int> > stable_vector_t;
|
||||
stable_vector_t a(bc::stable_vector<int>::size_type(5), 4);
|
||||
stable_vector_t b(a);
|
||||
stable_vector_t c(a.cbegin(), a.cend());
|
||||
b.insert(b.cend(), 0);
|
||||
c.pop_back();
|
||||
assert(static_cast<std::size_t>(a.end() - a.begin()) == a.size());
|
||||
a.assign(b.cbegin(), b.cend());
|
||||
assert(static_cast<std::size_t>(a.end() - a.begin()) == a.size());
|
||||
a.assign(c.cbegin(), c.cend());
|
||||
assert(static_cast<std::size_t>(a.end() - a.begin()) == a.size());
|
||||
a.assign(1, 2);
|
||||
assert(static_cast<std::size_t>(a.end() - a.begin()) == a.size());
|
||||
a.reserve(100);
|
||||
assert(static_cast<std::size_t>(a.end() - a.begin()) == a.size());
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
#define SINGLE_TEST
|
||||
#ifndef SINGLE_TEST
|
||||
#ifdef NDEBUG
|
||||
unsigned int numit [] = { 400, 4000, 40000, 400000 };
|
||||
#else
|
||||
unsigned int numit [] = { 4, 40, 400, 4000 };
|
||||
#endif
|
||||
unsigned int numele [] = { 10000, 1000, 100, 10 };
|
||||
#else
|
||||
#ifdef NDEBUG
|
||||
unsigned int numit [] = { 400 };
|
||||
#else
|
||||
unsigned int numit [] = { 4 };
|
||||
#endif
|
||||
unsigned int numele [] = { 10000 };
|
||||
#endif
|
||||
|
||||
//Warning: range erasure is buggy. Vector iterators are not stable, so it is not
|
||||
//possible to cache iterators, but indexes!!!
|
||||
|
||||
bool csv_output = argc == 2 && (strcmp(argv[1], "--csv-output") == 0);
|
||||
|
||||
if(csv_output){
|
||||
print_header();
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
stable_vector_test_template<get_stable_vector, StdAllocator>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
stable_vector_test_template<get_vector, StdAllocator>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
stable_vector_test_template<get_stable_vector, AllocatorPlusV1>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
stable_vector_test_template<get_vector, AllocatorPlusV1>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
stable_vector_test_template<get_stable_vector, AllocatorPlusV2>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
stable_vector_test_template<get_vector, AllocatorPlusV2>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
stable_vector_test_template<get_stable_vector, AdPool2PercentV2>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
stable_vector_test_template<get_vector, AdPool2PercentV2>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
|
||||
std::cout << "\n ----------------------------------- \n"
|
||||
<< " Iterations/Elements: " << numit[i] << "/" << numele[i]
|
||||
<< "\n ----------------------------------- \n";
|
||||
stable_vector_test_template<get_stable_vector, StdAllocator>(numit[i], numele[i], csv_output);
|
||||
stable_vector_test_template<get_vector, StdAllocator>(numit[i], numele[i], csv_output);
|
||||
stable_vector_test_template<get_stable_vector, AllocatorPlusV1>(numit[i], numele[i], csv_output);
|
||||
stable_vector_test_template<get_vector, AllocatorPlusV1>(numit[i], numele[i], csv_output);
|
||||
stable_vector_test_template<get_stable_vector, AllocatorPlusV2>(numit[i], numele[i], csv_output);
|
||||
stable_vector_test_template<get_vector, AllocatorPlusV2>(numit[i], numele[i], csv_output);
|
||||
stable_vector_test_template<get_stable_vector, AdPool2PercentV2>(numit[i], numele[i], csv_output);
|
||||
stable_vector_test_template<get_vector, AdPool2PercentV2>(numit[i], numele[i], csv_output);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
23
build/Jamfile.v2
Normal file
23
build/Jamfile.v2
Normal file
@@ -0,0 +1,23 @@
|
||||
# (C) Copyright Vladimir Prus, David Abrahams, Michael Stevens, Hartmut Kaiser,
|
||||
# Ion Gaztanaga 2007-2008
|
||||
# Use, modification and distribution are subject to 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)
|
||||
|
||||
project boost/container
|
||||
: source-location ../src
|
||||
: usage-requirements # pass these requirement to dependents (i.e. users)
|
||||
<link>shared:<define>BOOST_CONTAINER_DYN_LINK=1
|
||||
<link>static:<define>BOOST_CONTAINER_STATIC_LINK=1
|
||||
;
|
||||
|
||||
# Base names of the source files for libboost_container
|
||||
CPP_SOURCES = alloc_lib ;
|
||||
|
||||
lib boost_container
|
||||
: $(CPP_SOURCES).c
|
||||
: <link>shared:<define>BOOST_CONTAINER_DYN_LINK=1
|
||||
<link>static:<define>BOOST_CONTAINER_STATIC_LINK=1
|
||||
;
|
||||
|
||||
boost-install boost_container ;
|
390
include/boost/container/adaptive_pool.hpp
Normal file
390
include/boost/container/adaptive_pool.hpp
Normal file
@@ -0,0 +1,390 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_ADAPTIVE_POOL_HPP
|
||||
#define BOOST_CONTAINER_ADAPTIVE_POOL_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
#include <boost/container/container_fwd.hpp>
|
||||
#include <boost/container/detail/version_type.hpp>
|
||||
#include <boost/container/throw_exception.hpp>
|
||||
#include <boost/container/detail/adaptive_node_pool.hpp>
|
||||
#include <boost/container/detail/multiallocation_chain.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/container/detail/alloc_lib_auto_link.hpp>
|
||||
#include <boost/container/detail/singleton.hpp>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
//!An STL node allocator that uses a modified DLMalloc as memory
|
||||
//!source.
|
||||
//!
|
||||
//!This node allocator shares a segregated storage between all instances
|
||||
//!of adaptive_pool with equal sizeof(T).
|
||||
//!
|
||||
//!NodesPerBlock is the number of nodes allocated at once when the allocator
|
||||
//!needs runs out of nodes. MaxFreeBlocks is the maximum number of totally free blocks
|
||||
//!that the adaptive node pool will hold. The rest of the totally free blocks will be
|
||||
//!deallocated to the memory manager.
|
||||
//!
|
||||
//!OverheadPercent is the (approximated) maximum size overhead (1-20%) of the allocator:
|
||||
//!(memory usable for nodes / total memory allocated from the memory allocator)
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template < class T
|
||||
, std::size_t NodesPerBlock = ADP_nodes_per_block
|
||||
, std::size_t MaxFreeBlocks = ADP_max_free_blocks
|
||||
, std::size_t OverheadPercent = ADP_overhead_percent
|
||||
>
|
||||
#else
|
||||
template < class T
|
||||
, std::size_t NodesPerBlock
|
||||
, std::size_t MaxFreeBlocks
|
||||
, std::size_t OverheadPercent
|
||||
, unsigned Version
|
||||
>
|
||||
#endif
|
||||
class adaptive_pool
|
||||
{
|
||||
//!If Version is 1, the allocator is a STL conforming allocator. If Version is 2,
|
||||
//!the allocator offers advanced expand in place and burst allocation capabilities.
|
||||
public:
|
||||
typedef unsigned int allocation_type;
|
||||
typedef adaptive_pool
|
||||
<T, NodesPerBlock, MaxFreeBlocks, OverheadPercent
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
, Version
|
||||
#endif
|
||||
> self_t;
|
||||
|
||||
static const std::size_t nodes_per_block = NodesPerBlock;
|
||||
static const std::size_t max_free_blocks = MaxFreeBlocks;
|
||||
static const std::size_t overhead_percent = OverheadPercent;
|
||||
static const std::size_t real_nodes_per_block = NodesPerBlock;
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
BOOST_STATIC_ASSERT((Version <=2));
|
||||
#endif
|
||||
|
||||
public:
|
||||
//-------
|
||||
typedef T value_type;
|
||||
typedef T * pointer;
|
||||
typedef const T * const_pointer;
|
||||
typedef typename ::boost::container::
|
||||
container_detail::unvoid<T>::type & reference;
|
||||
typedef const typename ::boost::container::
|
||||
container_detail::unvoid<T>::type & const_reference;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
typedef boost::container::container_detail::
|
||||
version_type<self_t, Version> version;
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
typedef boost::container::container_detail::
|
||||
basic_multiallocation_chain<void*> multiallocation_chain_void;
|
||||
typedef boost::container::container_detail::
|
||||
transform_multiallocation_chain
|
||||
<multiallocation_chain_void, T> multiallocation_chain;
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//!Obtains adaptive_pool from
|
||||
//!adaptive_pool
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
typedef adaptive_pool
|
||||
< T2
|
||||
, NodesPerBlock
|
||||
, MaxFreeBlocks
|
||||
, OverheadPercent
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
, Version
|
||||
#endif
|
||||
> other;
|
||||
};
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
private:
|
||||
//!Not assignable from related adaptive_pool
|
||||
template<class T2, unsigned Version2, std::size_t N2, std::size_t F2>
|
||||
adaptive_pool& operator=
|
||||
(const adaptive_pool<T2, Version2, N2, F2>&);
|
||||
|
||||
//!Not assignable from other adaptive_pool
|
||||
adaptive_pool& operator=(const adaptive_pool&);
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
public:
|
||||
//!Default constructor
|
||||
adaptive_pool() BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!Copy constructor from other adaptive_pool.
|
||||
adaptive_pool(const adaptive_pool &) BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!Copy constructor from related adaptive_pool.
|
||||
template<class T2>
|
||||
adaptive_pool
|
||||
(const adaptive_pool<T2, NodesPerBlock, MaxFreeBlocks, OverheadPercent
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
, Version
|
||||
#endif
|
||||
> &) BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!Destructor
|
||||
~adaptive_pool() BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!Returns the number of elements that could be allocated.
|
||||
//!Never throws
|
||||
size_type max_size() const BOOST_CONTAINER_NOEXCEPT
|
||||
{ return size_type(-1)/sizeof(T); }
|
||||
|
||||
//!Allocate memory for an array of count elements.
|
||||
//!Throws std::bad_alloc if there is no enough memory
|
||||
pointer allocate(size_type count, const void * = 0)
|
||||
{
|
||||
if(count > this->max_size())
|
||||
boost::container::throw_bad_alloc();
|
||||
|
||||
if(Version == 1 && count == 1){
|
||||
typedef typename container_detail::shared_adaptive_node_pool
|
||||
<sizeof(T), NodesPerBlock, MaxFreeBlocks, OverheadPercent> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
return pointer(static_cast<T*>(singleton_t::instance().allocate_node()));
|
||||
}
|
||||
else{
|
||||
return static_cast<pointer>(boost_cont_malloc(count*sizeof(T)));
|
||||
}
|
||||
}
|
||||
|
||||
//!Deallocate allocated memory.
|
||||
//!Never throws
|
||||
void deallocate(const pointer &ptr, size_type count) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
(void)count;
|
||||
if(Version == 1 && count == 1){
|
||||
typedef container_detail::shared_adaptive_node_pool
|
||||
<sizeof(T), NodesPerBlock, MaxFreeBlocks, OverheadPercent> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
singleton_t::instance().deallocate_node(ptr);
|
||||
}
|
||||
else{
|
||||
boost_cont_free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<pointer, bool>
|
||||
allocation_command(allocation_type command,
|
||||
size_type limit_size,
|
||||
size_type preferred_size,
|
||||
size_type &received_size, pointer reuse = pointer())
|
||||
{
|
||||
std::pair<pointer, bool> ret =
|
||||
this->priv_allocation_command(command, limit_size, preferred_size, received_size, reuse);
|
||||
if(!ret.first && !(command & BOOST_CONTAINER_NOTHROW_ALLOCATION))
|
||||
boost::container::throw_bad_alloc();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//!Returns maximum the number of objects the previously allocated memory
|
||||
//!pointed by p can hold.
|
||||
size_type size(pointer p) const BOOST_CONTAINER_NOEXCEPT
|
||||
{ return boost_cont_size(p); }
|
||||
|
||||
//!Allocates just one object. Memory allocated with this function
|
||||
//!must be deallocated only with deallocate_one().
|
||||
//!Throws bad_alloc if there is no enough memory
|
||||
pointer allocate_one()
|
||||
{
|
||||
typedef container_detail::shared_adaptive_node_pool
|
||||
<sizeof(T), NodesPerBlock, MaxFreeBlocks, OverheadPercent> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
return (pointer)singleton_t::instance().allocate_node();
|
||||
}
|
||||
|
||||
//!Allocates many elements of size == 1.
|
||||
//!Elements must be individually deallocated with deallocate_one()
|
||||
void allocate_individual(std::size_t num_elements, multiallocation_chain &chain)
|
||||
{
|
||||
typedef container_detail::shared_adaptive_node_pool
|
||||
<sizeof(T), NodesPerBlock, MaxFreeBlocks, OverheadPercent> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
singleton_t::instance().allocate_nodes(num_elements, static_cast<typename shared_pool_t::multiallocation_chain&>(chain));
|
||||
//typename shared_pool_t::multiallocation_chain ch;
|
||||
//singleton_t::instance().allocate_nodes(num_elements, ch);
|
||||
//chain.incorporate_after
|
||||
//(chain.before_begin(), (T*)&*ch.begin(), (T*)&*ch.last(), ch.size());
|
||||
}
|
||||
|
||||
//!Deallocates memory previously allocated with allocate_one().
|
||||
//!You should never use deallocate_one to deallocate memory allocated
|
||||
//!with other functions different from allocate_one(). Never throws
|
||||
void deallocate_one(pointer p) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
typedef container_detail::shared_adaptive_node_pool
|
||||
<sizeof(T), NodesPerBlock, MaxFreeBlocks, OverheadPercent> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
singleton_t::instance().deallocate_node(p);
|
||||
}
|
||||
|
||||
void deallocate_individual(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
typedef container_detail::shared_adaptive_node_pool
|
||||
<sizeof(T), NodesPerBlock, MaxFreeBlocks, OverheadPercent> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
//typename shared_pool_t::multiallocation_chain ch(&*chain.begin(), &*chain.last(), chain.size());
|
||||
//singleton_t::instance().deallocate_nodes(ch);
|
||||
singleton_t::instance().deallocate_nodes(chain);
|
||||
}
|
||||
|
||||
//!Allocates many elements of size elem_size.
|
||||
//!Elements must be individually deallocated with deallocate()
|
||||
void allocate_many(size_type elem_size, std::size_t n_elements, multiallocation_chain &chain)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));/*
|
||||
boost_cont_memchain ch;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&ch);
|
||||
if(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){
|
||||
boost::container::throw_bad_alloc();
|
||||
}
|
||||
chain.incorporate_after(chain.before_begin()
|
||||
,(T*)BOOST_CONTAINER_MEMCHAIN_FIRSTMEM(&ch)
|
||||
,(T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch)
|
||||
,BOOST_CONTAINER_MEMCHAIN_SIZE(&ch) );*/
|
||||
if(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast<boost_cont_memchain *>(&chain))){
|
||||
boost::container::throw_bad_alloc();
|
||||
}
|
||||
}
|
||||
|
||||
//!Allocates n_elements elements, each one of size elem_sizes[i]
|
||||
//!Elements must be individually deallocated with deallocate()
|
||||
void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));/*
|
||||
boost_cont_memchain ch;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&ch);
|
||||
if(!boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){
|
||||
boost::container::throw_bad_alloc();
|
||||
}
|
||||
chain.incorporate_after(chain.before_begin()
|
||||
,(T*)BOOST_CONTAINER_MEMCHAIN_FIRSTMEM(&ch)
|
||||
,(T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch)
|
||||
,BOOST_CONTAINER_MEMCHAIN_SIZE(&ch) );*/
|
||||
if(!boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast<boost_cont_memchain *>(&chain))){
|
||||
boost::container::throw_bad_alloc();
|
||||
}
|
||||
}
|
||||
|
||||
void deallocate_many(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT
|
||||
{/*
|
||||
boost_cont_memchain ch;
|
||||
void *beg(&*chain.begin()), *last(&*chain.last());
|
||||
size_t size(chain.size());
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&ch, beg, last, size);
|
||||
boost_cont_multidealloc(&ch);*/
|
||||
boost_cont_multidealloc(reinterpret_cast<boost_cont_memchain *>(&chain));
|
||||
}
|
||||
|
||||
//!Deallocates all free blocks of the pool
|
||||
static void deallocate_free_blocks() BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
typedef container_detail::shared_adaptive_node_pool
|
||||
<sizeof(T), NodesPerBlock, MaxFreeBlocks, OverheadPercent> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
singleton_t::instance().deallocate_free_blocks();
|
||||
}
|
||||
|
||||
//!Swaps allocators. Does not throw. If each allocator is placed in a
|
||||
//!different memory segment, the result is undefined.
|
||||
friend void swap(adaptive_pool &, adaptive_pool &) BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!An allocator always compares to true, as memory allocated with one
|
||||
//!instance can be deallocated by another instance
|
||||
friend bool operator==(const adaptive_pool &, const adaptive_pool &) BOOST_CONTAINER_NOEXCEPT
|
||||
{ return true; }
|
||||
|
||||
//!An allocator always compares to false, as memory allocated with one
|
||||
//!instance can be deallocated by another instance
|
||||
friend bool operator!=(const adaptive_pool &, const adaptive_pool &) BOOST_CONTAINER_NOEXCEPT
|
||||
{ return false; }
|
||||
/*
|
||||
//!Returns address of mutable object.
|
||||
//!Never throws
|
||||
pointer address(reference value) const
|
||||
{ return pointer(boost::addressof(value)); }
|
||||
|
||||
//!Returns address of non mutable object.
|
||||
//!Never throws
|
||||
const_pointer address(const_reference value) const
|
||||
{ return const_pointer(boost::addressof(value)); }
|
||||
|
||||
//!Default construct an object.
|
||||
//!Throws if T's default constructor throws
|
||||
void construct(const pointer &ptr)
|
||||
{ new(ptr) value_type; }
|
||||
|
||||
//!Construct a copy of the passed object.
|
||||
//!Throws if T's copy constructor throws
|
||||
void construct(pointer ptr, const_reference t)
|
||||
{ new(ptr) value_type(t); }
|
||||
|
||||
//!Destroys object. Throws if object's
|
||||
//!destructor throws
|
||||
void destroy(const pointer &ptr)
|
||||
{ (void)ptr; BOOST_ASSERT(ptr); (*ptr).~value_type(); }
|
||||
*/
|
||||
private:
|
||||
std::pair<pointer, bool> priv_allocation_command
|
||||
(allocation_type command, std::size_t limit_size
|
||||
,std::size_t preferred_size,std::size_t &received_size, void *reuse_ptr)
|
||||
{
|
||||
boost_cont_command_ret_t ret = {0 , 0};
|
||||
if(limit_size > this->max_size() || preferred_size > this->max_size()){
|
||||
// ret.first = 0;
|
||||
return std::pair<pointer, bool>(pointer(), false);
|
||||
}
|
||||
std::size_t l_size = limit_size*sizeof(T);
|
||||
std::size_t p_size = preferred_size*sizeof(T);
|
||||
std::size_t r_size;
|
||||
{
|
||||
ret = boost_cont_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr);
|
||||
}
|
||||
received_size = r_size/sizeof(T);
|
||||
return std::pair<pointer, bool>(static_cast<pointer>(ret.first), !!ret.second);
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_ADAPTIVE_POOL_HPP
|
368
include/boost/container/allocator.hpp
Normal file
368
include/boost/container/allocator.hpp
Normal file
@@ -0,0 +1,368 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_ALLOCATOR_HPP
|
||||
#define BOOST_CONTAINER_ALLOCATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
#include <boost/container/container_fwd.hpp>
|
||||
#include <boost/container/detail/version_type.hpp>
|
||||
#include <boost/container/throw_exception.hpp>
|
||||
#include <boost/container/detail/alloc_lib_auto_link.hpp>
|
||||
#include <boost/container/detail/multiallocation_chain.hpp>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <cstddef>
|
||||
#include <cassert>
|
||||
#include <new>
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
template<unsigned Version, unsigned int AllocationDisableMask>
|
||||
class allocator<void, Version, AllocationDisableMask>
|
||||
{
|
||||
typedef allocator<void, Version, AllocationDisableMask> self_t;
|
||||
public:
|
||||
typedef void value_type;
|
||||
typedef void * pointer;
|
||||
typedef const void* const_pointer;
|
||||
typedef int & reference;
|
||||
typedef const int & const_reference;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef boost::container::container_detail::
|
||||
version_type<self_t, Version> version;
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
typedef boost::container::container_detail::
|
||||
basic_multiallocation_chain<void*> multiallocation_chain;
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//!Obtains an allocator that allocates
|
||||
//!objects of type T2
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
typedef allocator< T2
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
, Version, AllocationDisableMask
|
||||
#endif
|
||||
> other;
|
||||
};
|
||||
|
||||
//!Default constructor
|
||||
//!Never throws
|
||||
allocator()
|
||||
{}
|
||||
|
||||
//!Constructor from other allocator.
|
||||
//!Never throws
|
||||
allocator(const allocator &)
|
||||
{}
|
||||
|
||||
//!Constructor from related allocator.
|
||||
//!Never throws
|
||||
template<class T2>
|
||||
allocator(const allocator<T2, Version, AllocationDisableMask> &)
|
||||
{}
|
||||
};
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//!\file
|
||||
//! This class is an extended STL-compatible that offers advanced allocation mechanism
|
||||
//!(in-place expansion, shrinking, burst-allocation...)
|
||||
//!
|
||||
//! This allocator is a wrapper around a modified DLmalloc.
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template<class T>
|
||||
#else
|
||||
//! If Version is 1, the allocator is a STL conforming allocator. If Version is 2,
|
||||
//! the allocator offers advanced expand in place and burst allocation capabilities.
|
||||
//
|
||||
//! AllocationDisableMask works only if Version is 2 and it can be an inclusive OR
|
||||
//! of allocation types the user wants to disable.
|
||||
template<class T, unsigned Version, unsigned int AllocationDisableMask>
|
||||
#endif //#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
class allocator
|
||||
{
|
||||
typedef unsigned int allocation_type;
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
private:
|
||||
|
||||
//Self type
|
||||
typedef allocator<T, Version, AllocationDisableMask> self_t;
|
||||
|
||||
//Not assignable from related allocator
|
||||
template<class T2, unsigned int Version2, unsigned int AllocationDisableMask2>
|
||||
allocator& operator=(const allocator<T2, Version2, AllocationDisableMask2>&);
|
||||
|
||||
//Not assignable from other allocator
|
||||
allocator& operator=(const allocator&);
|
||||
|
||||
static const unsigned int ForbiddenMask =
|
||||
BOOST_CONTAINER_ALLOCATE_NEW | BOOST_CONTAINER_EXPAND_BWD | BOOST_CONTAINER_EXPAND_FWD ;
|
||||
|
||||
//The mask can't disable all the allocation types
|
||||
BOOST_STATIC_ASSERT(( (AllocationDisableMask & ForbiddenMask) != ForbiddenMask ));
|
||||
|
||||
//The mask is only valid for version 2 allocators
|
||||
BOOST_STATIC_ASSERT(( Version != 1 || (AllocationDisableMask == 0) ));
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T * pointer;
|
||||
typedef const T * const_pointer;
|
||||
typedef T & reference;
|
||||
typedef const T & const_reference;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
typedef boost::container::container_detail::
|
||||
version_type<self_t, Version> version;
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
typedef boost::container::container_detail::
|
||||
basic_multiallocation_chain<void*> void_multiallocation_chain;
|
||||
|
||||
typedef boost::container::container_detail::
|
||||
transform_multiallocation_chain
|
||||
<void_multiallocation_chain, T> multiallocation_chain;
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//!Obtains an allocator that allocates
|
||||
//!objects of type T2
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
typedef allocator<T2, Version, AllocationDisableMask> other;
|
||||
};
|
||||
|
||||
//!Default constructor
|
||||
//!Never throws
|
||||
allocator() BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!Constructor from other allocator.
|
||||
//!Never throws
|
||||
allocator(const allocator &) BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!Constructor from related allocator.
|
||||
//!Never throws
|
||||
template<class T2>
|
||||
allocator(const allocator<T2
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
, Version, AllocationDisableMask
|
||||
#endif
|
||||
> &) BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!Allocates memory for an array of count elements.
|
||||
//!Throws std::bad_alloc if there is no enough memory
|
||||
//!If Version is 2, this allocated memory can only be deallocated
|
||||
//!with deallocate() or (for Version == 2) deallocate_many()
|
||||
pointer allocate(size_type count, const void * hint= 0)
|
||||
{
|
||||
(void)hint;
|
||||
if(count > this->max_size())
|
||||
boost::container::throw_bad_alloc();
|
||||
void *ret = boost_cont_malloc(count*sizeof(T));
|
||||
if(!ret)
|
||||
boost::container::throw_bad_alloc();
|
||||
return static_cast<pointer>(ret);
|
||||
}
|
||||
|
||||
//!Deallocates previously allocated memory.
|
||||
//!Never throws
|
||||
void deallocate(pointer ptr, size_type) BOOST_CONTAINER_NOEXCEPT
|
||||
{ boost_cont_free(ptr); }
|
||||
|
||||
//!Returns the maximum number of elements that could be allocated.
|
||||
//!Never throws
|
||||
size_type max_size() const BOOST_CONTAINER_NOEXCEPT
|
||||
{ return size_type(-1)/sizeof(T); }
|
||||
|
||||
//!Swaps two allocators, does nothing
|
||||
//!because this allocator is stateless
|
||||
friend void swap(self_t &, self_t &) BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!An allocator always compares to true, as memory allocated with one
|
||||
//!instance can be deallocated by another instance
|
||||
friend bool operator==(const allocator &, const allocator &) BOOST_CONTAINER_NOEXCEPT
|
||||
{ return true; }
|
||||
|
||||
//!An allocator always compares to false, as memory allocated with one
|
||||
//!instance can be deallocated by another instance
|
||||
friend bool operator!=(const allocator &, const allocator &) BOOST_CONTAINER_NOEXCEPT
|
||||
{ return false; }
|
||||
|
||||
//!An advanced function that offers in-place expansion shrink to fit and new allocation
|
||||
//!capabilities. Memory allocated with this function can only be deallocated with deallocate()
|
||||
//!or deallocate_many().
|
||||
//!This function is available only with Version == 2
|
||||
std::pair<pointer, bool>
|
||||
allocation_command(allocation_type command,
|
||||
size_type limit_size,
|
||||
size_type preferred_size,
|
||||
size_type &received_size, pointer reuse = pointer())
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
const allocation_type mask(AllocationDisableMask);
|
||||
command &= ~mask;
|
||||
std::pair<pointer, bool> ret =
|
||||
priv_allocation_command(command, limit_size, preferred_size, received_size, reuse);
|
||||
if(!ret.first && !(command & BOOST_CONTAINER_NOTHROW_ALLOCATION))
|
||||
boost::container::throw_bad_alloc();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//!Returns maximum the number of objects the previously allocated memory
|
||||
//!pointed by p can hold.
|
||||
//!Memory must not have been allocated with
|
||||
//!allocate_one or allocate_individual.
|
||||
//!This function is available only with Version == 2
|
||||
size_type size(pointer p) const BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
return boost_cont_size(p);
|
||||
}
|
||||
|
||||
//!Allocates just one object. Memory allocated with this function
|
||||
//!must be deallocated only with deallocate_one().
|
||||
//!Throws bad_alloc if there is no enough memory
|
||||
//!This function is available only with Version == 2
|
||||
pointer allocate_one()
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
return this->allocate(1);
|
||||
}
|
||||
|
||||
//!Allocates many elements of size == 1.
|
||||
//!Elements must be individually deallocated with deallocate_one()
|
||||
//!This function is available only with Version == 2
|
||||
void allocate_individual(std::size_t num_elements, multiallocation_chain &chain)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
this->allocate_many(1, num_elements, chain);
|
||||
}
|
||||
|
||||
//!Deallocates memory previously allocated with allocate_one().
|
||||
//!You should never use deallocate_one to deallocate memory allocated
|
||||
//!with other functions different from allocate_one() or allocate_individual.
|
||||
//Never throws
|
||||
void deallocate_one(pointer p) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
return this->deallocate(p, 1);
|
||||
}
|
||||
|
||||
//!Deallocates memory allocated with allocate_one() or allocate_individual().
|
||||
//!This function is available only with Version == 2
|
||||
void deallocate_individual(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
return this->deallocate_many(chain);
|
||||
}
|
||||
|
||||
//!Allocates many elements of size elem_size.
|
||||
//!Elements must be individually deallocated with deallocate()
|
||||
//!This function is available only with Version == 2
|
||||
void allocate_many(size_type elem_size, std::size_t n_elements, multiallocation_chain &chain)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));/*
|
||||
boost_cont_memchain ch;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&ch);
|
||||
if(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){
|
||||
boost::container::throw_bad_alloc();
|
||||
}
|
||||
chain.incorporate_after(chain.before_begin()
|
||||
,(T*)BOOST_CONTAINER_MEMCHAIN_FIRSTMEM(&ch)
|
||||
,(T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch)
|
||||
,BOOST_CONTAINER_MEMCHAIN_SIZE(&ch) );*/
|
||||
if(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast<boost_cont_memchain *>(&chain))){
|
||||
boost::container::throw_bad_alloc();
|
||||
}
|
||||
}
|
||||
|
||||
//!Allocates n_elements elements, each one of size elem_sizes[i]
|
||||
//!Elements must be individually deallocated with deallocate()
|
||||
//!This function is available only with Version == 2
|
||||
void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
boost_cont_memchain ch;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&ch);
|
||||
if(!boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){
|
||||
boost::container::throw_bad_alloc();
|
||||
}
|
||||
chain.incorporate_after(chain.before_begin()
|
||||
,(T*)BOOST_CONTAINER_MEMCHAIN_FIRSTMEM(&ch)
|
||||
,(T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch)
|
||||
,BOOST_CONTAINER_MEMCHAIN_SIZE(&ch) );
|
||||
/*
|
||||
if(!boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, reinterpret_cast<boost_cont_memchain *>(&chain))){
|
||||
boost::container::throw_bad_alloc();
|
||||
}*/
|
||||
}
|
||||
|
||||
//!Deallocates several elements allocated by
|
||||
//!allocate_many(), allocate(), or allocation_command().
|
||||
//!This function is available only with Version == 2
|
||||
void deallocate_many(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
boost_cont_memchain ch;
|
||||
void *beg(&*chain.begin()), *last(&*chain.last());
|
||||
size_t size(chain.size());
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&ch, beg, last, size);
|
||||
boost_cont_multidealloc(&ch);
|
||||
//boost_cont_multidealloc(reinterpret_cast<boost_cont_memchain *>(&chain));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::pair<pointer, bool> priv_allocation_command
|
||||
(allocation_type command, std::size_t limit_size
|
||||
,std::size_t preferred_size,std::size_t &received_size, void *reuse_ptr)
|
||||
{
|
||||
boost_cont_command_ret_t ret = {0 , 0};
|
||||
if((limit_size > this->max_size()) | (preferred_size > this->max_size())){
|
||||
return std::pair<pointer, bool>(pointer(), false);
|
||||
}
|
||||
std::size_t l_size = limit_size*sizeof(T);
|
||||
std::size_t p_size = preferred_size*sizeof(T);
|
||||
std::size_t r_size;
|
||||
{
|
||||
ret = boost_cont_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr);
|
||||
}
|
||||
received_size = r_size/sizeof(T);
|
||||
return std::pair<pointer, bool>(static_cast<pointer>(ret.first), !!ret.second);
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_CONTAINER_ALLOCATOR_HPP
|
||||
|
@@ -72,6 +72,16 @@ namespace bi = boost::intrusive;
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
//! Enumeration used to configure ordered associative containers
|
||||
//! with a concrete tree implementation.
|
||||
enum tree_type
|
||||
{
|
||||
red_black_tree,
|
||||
avl_tree,
|
||||
scapegoat_tree,
|
||||
splay_tree
|
||||
};
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
template <class T
|
||||
@@ -99,24 +109,28 @@ class slist;
|
||||
|
||||
template <class Key
|
||||
,class Compare = std::less<Key>
|
||||
,class Allocator = std::allocator<Key> >
|
||||
,class Allocator = std::allocator<Key>
|
||||
,tree_type = red_black_tree >
|
||||
class set;
|
||||
|
||||
template <class Key
|
||||
,class Compare = std::less<Key>
|
||||
,class Allocator = std::allocator<Key> >
|
||||
,class Allocator = std::allocator<Key>
|
||||
,tree_type = red_black_tree >
|
||||
class multiset;
|
||||
|
||||
template <class Key
|
||||
,class T
|
||||
,class Compare = std::less<Key>
|
||||
,class Allocator = std::allocator<std::pair<const Key, T> > >
|
||||
,class Allocator = std::allocator<std::pair<const Key, T> >
|
||||
,tree_type = red_black_tree >
|
||||
class map;
|
||||
|
||||
template <class Key
|
||||
,class T
|
||||
,class Compare = std::less<Key>
|
||||
,class Allocator = std::allocator<std::pair<const Key, T> > >
|
||||
,class Allocator = std::allocator<std::pair<const Key, T> >
|
||||
,tree_type = red_black_tree >
|
||||
class multimap;
|
||||
|
||||
template <class Key
|
||||
@@ -224,7 +238,6 @@ struct value_init_t
|
||||
//! should be value initialized
|
||||
static const value_init_t value_init = value_init_t();
|
||||
|
||||
|
||||
namespace container_detail_really_deep_namespace {
|
||||
|
||||
//Otherwise, gcc issues a warning of previously defined
|
||||
|
@@ -1537,6 +1537,27 @@ class deque : protected deque_base<Allocator>
|
||||
this->members_.m_finish = this->members_.m_start;
|
||||
}
|
||||
|
||||
friend bool operator==(const deque& x, const deque& y)
|
||||
{ return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
|
||||
|
||||
friend bool operator!=(const deque& x, const deque& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator<(const deque& x, const deque& y)
|
||||
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
|
||||
|
||||
friend bool operator>(const deque& x, const deque& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator>=(const deque& x, const deque& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend bool operator<=(const deque& x, const deque& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend void swap(deque& x, deque& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
private:
|
||||
|
||||
@@ -1939,39 +1960,6 @@ class deque : protected deque_base<Allocator>
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
};
|
||||
|
||||
// Nonmember functions.
|
||||
template <class T, class Allocator>
|
||||
inline bool operator==(const deque<T, Allocator>& x, const deque<T, Allocator>& y) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool operator<(const deque<T, Allocator>& x, const deque<T, Allocator>& y) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool operator!=(const deque<T, Allocator>& x, const deque<T, Allocator>& y) BOOST_CONTAINER_NOEXCEPT
|
||||
{ return !(x == y); }
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool operator>(const deque<T, Allocator>& x, const deque<T, Allocator>& y) BOOST_CONTAINER_NOEXCEPT
|
||||
{ return y < x; }
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool operator>=(const deque<T, Allocator>& x, const deque<T, Allocator>& y) BOOST_CONTAINER_NOEXCEPT
|
||||
{ return !(x < y); }
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool operator<=(const deque<T, Allocator>& x, const deque<T, Allocator>& y) BOOST_CONTAINER_NOEXCEPT
|
||||
{ return !(y < x); }
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline void swap(deque<T, Allocator>& x, deque<T, Allocator>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
}}
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
162
include/boost/container/detail/adaptive_node_pool.hpp
Normal file
162
include/boost/container/detail/adaptive_node_pool.hpp
Normal file
@@ -0,0 +1,162 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_HPP
|
||||
#define BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
|
||||
#include <boost/intrusive/set.hpp>
|
||||
#include <boost/aligned_storage.hpp>
|
||||
#include <boost/container/detail/alloc_lib_auto_link.hpp>
|
||||
#include <boost/container/detail/multiallocation_chain.hpp>
|
||||
#include <boost/container/detail/pool_common_alloc.hpp>
|
||||
#include <boost/container/detail/mutex.hpp>
|
||||
#include <boost/container/detail/adaptive_node_pool_impl.hpp>
|
||||
#include <boost/container/detail/multiallocation_chain.hpp>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <new>
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
namespace container_detail {
|
||||
|
||||
template<bool AlignOnly>
|
||||
struct select_private_adaptive_node_pool_impl
|
||||
{
|
||||
typedef boost::container::container_detail::
|
||||
private_adaptive_node_pool_impl
|
||||
< fake_segment_manager
|
||||
, unsigned(AlignOnly)*::boost::container::adaptive_pool_flag::align_only
|
||||
| ::boost::container::adaptive_pool_flag::size_ordered | ::boost::container::adaptive_pool_flag::address_ordered
|
||||
> type;
|
||||
};
|
||||
|
||||
//!Pooled memory allocator using an smart adaptive pool. Includes
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!responsibility of user classes. Node size (NodeSize) and the number of
|
||||
//!nodes allocated per block (NodesPerBlock) are known at compile time.
|
||||
template< std::size_t NodeSize
|
||||
, std::size_t NodesPerBlock
|
||||
, std::size_t MaxFreeBlocks
|
||||
, std::size_t OverheadPercent
|
||||
>
|
||||
class private_adaptive_node_pool
|
||||
: public select_private_adaptive_node_pool_impl<(OverheadPercent == 0)>::type
|
||||
{
|
||||
typedef typename select_private_adaptive_node_pool_impl<OverheadPercent == 0>::type base_t;
|
||||
//Non-copyable
|
||||
private_adaptive_node_pool(const private_adaptive_node_pool &);
|
||||
private_adaptive_node_pool &operator=(const private_adaptive_node_pool &);
|
||||
|
||||
public:
|
||||
typedef typename base_t::multiallocation_chain multiallocation_chain;
|
||||
static const std::size_t nodes_per_block = NodesPerBlock;
|
||||
|
||||
//!Constructor. Never throws
|
||||
private_adaptive_node_pool()
|
||||
: base_t(0
|
||||
, NodeSize
|
||||
, NodesPerBlock
|
||||
, MaxFreeBlocks
|
||||
, (unsigned char)OverheadPercent)
|
||||
{}
|
||||
};
|
||||
|
||||
//!Pooled memory allocator using adaptive pool. Includes
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!responsibility of user classes. Node size (NodeSize) and the number of
|
||||
//!nodes allocated per block (NodesPerBlock) are known at compile time
|
||||
template< std::size_t NodeSize
|
||||
, std::size_t NodesPerBlock
|
||||
, std::size_t MaxFreeBlocks
|
||||
, std::size_t OverheadPercent
|
||||
>
|
||||
class shared_adaptive_node_pool
|
||||
: public private_adaptive_node_pool
|
||||
<NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent>
|
||||
{
|
||||
private:
|
||||
typedef private_adaptive_node_pool
|
||||
<NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent> private_node_allocator_t;
|
||||
public:
|
||||
typedef typename private_node_allocator_t::multiallocation_chain multiallocation_chain;
|
||||
|
||||
//!Constructor. Never throws
|
||||
shared_adaptive_node_pool()
|
||||
: private_node_allocator_t(){}
|
||||
|
||||
//!Destructor. Deallocates all allocated blocks. Never throws
|
||||
~shared_adaptive_node_pool()
|
||||
{}
|
||||
|
||||
//!Allocates array of count elements. Can throw std::bad_alloc
|
||||
void *allocate_node()
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
return private_node_allocator_t::allocate_node();
|
||||
}
|
||||
|
||||
//!Deallocates an array pointed by ptr. Never throws
|
||||
void deallocate_node(void *ptr)
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
private_node_allocator_t::deallocate_node(ptr);
|
||||
}
|
||||
|
||||
//!Allocates a singly linked list of n nodes ending in null pointer.
|
||||
//!can throw std::bad_alloc
|
||||
void allocate_nodes(const std::size_t n, multiallocation_chain &chain)
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
return private_node_allocator_t::allocate_nodes(n, chain);
|
||||
}
|
||||
|
||||
void deallocate_nodes(multiallocation_chain &chain)
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
private_node_allocator_t::deallocate_nodes(chain);
|
||||
}
|
||||
|
||||
//!Deallocates all the free blocks of memory. Never throws
|
||||
void deallocate_free_blocks()
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
private_node_allocator_t::deallocate_free_blocks();
|
||||
}
|
||||
|
||||
private:
|
||||
default_mutex mutex_;
|
||||
};
|
||||
|
||||
} //namespace container_detail {
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_DETAIL_ADAPTIVE_NODE_POOL_HPP
|
326
include/boost/container/detail/alloc_lib.h
Normal file
326
include/boost/container/detail/alloc_lib.h
Normal file
@@ -0,0 +1,326 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BOOST_CONTAINER_ALLOC_LIB_EXT_H
|
||||
#define BOOST_CONTAINER_ALLOC_LIB_EXT_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable : 4127)
|
||||
|
||||
/*
|
||||
we need to import/export our code only if the user has specifically
|
||||
asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
|
||||
libraries to be dynamically linked, or BOOST_CONTAINER_DYN_LINK
|
||||
if they want just this one to be dynamically liked:
|
||||
*/
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTAINER_DYN_LINK)
|
||||
|
||||
/* export if this is our own source, otherwise import: */
|
||||
#ifdef BOOST_CONTAINER_SOURCE
|
||||
# define BOOST_CONTAINER_DECL __declspec(dllexport)
|
||||
#else
|
||||
# define BOOST_CONTAINER_DECL __declspec(dllimport)
|
||||
#endif /* BOOST_CONTAINER_SOURCE */
|
||||
#endif /* DYN_LINK */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* if BOOST_CONTAINER_DECL isn't defined yet define it now: */
|
||||
#ifndef BOOST_CONTAINER_DECL
|
||||
#define BOOST_CONTAINER_DECL
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!An forward iterator to traverse the elements of a memory chain container.*/
|
||||
typedef struct multialloc_node_impl
|
||||
{
|
||||
struct multialloc_node_impl *next_node_ptr;
|
||||
} boost_cont_memchain_node;
|
||||
|
||||
|
||||
/*!An forward iterator to traverse the elements of a memory chain container.*/
|
||||
typedef struct multialloc_it_impl
|
||||
{
|
||||
boost_cont_memchain_node *node_ptr;
|
||||
} boost_cont_memchain_it;
|
||||
|
||||
/*!Memory chain: A container holding memory portions allocated by boost_cont_multialloc_nodes
|
||||
and boost_cont_multialloc_arrays functions.*/
|
||||
typedef struct boost_cont_memchain_impl
|
||||
{
|
||||
size_t num_mem;
|
||||
boost_cont_memchain_node root_node;
|
||||
boost_cont_memchain_node *last_node_ptr;
|
||||
} boost_cont_memchain;
|
||||
|
||||
/*!Advances the iterator one position so that it points to the next element in the memory chain*/
|
||||
#define BOOST_CONTAINER_MEMIT_NEXT(IT) (IT.node_ptr = IT.node_ptr->next_node_ptr)
|
||||
|
||||
/*!Returns the address of the memory chain currently pointed by the iterator*/
|
||||
#define BOOST_CONTAINER_MEMIT_ADDR(IT) ((void*)IT.node_ptr)
|
||||
|
||||
/*!Initializer for an iterator pointing to the position before the first element*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_BEFORE_BEGIN_IT(PMEMCHAIN) { &((PMEMCHAIN)->root_node) }
|
||||
|
||||
/*!Initializer for an iterator pointing to the first element*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_BEGIN_IT(PMEMCHAIN) {(PMEMCHAIN)->root_node.next_node_ptr }
|
||||
|
||||
/*!Initializer for an iterator pointing to the last element*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_LAST_IT(PMEMCHAIN) {(PMEMCHAIN)->last_node_ptr }
|
||||
|
||||
/*!Initializer for an iterator pointing to one past the last element (end iterator)*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_END_IT(PMEMCHAIN) {(boost_cont_memchain_node *)0 }
|
||||
|
||||
/*!True if IT is the end iterator, false otherwise*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_IS_END_IT(PMEMCHAIN, IT) (!(IT).node_ptr)
|
||||
|
||||
/*!The address of the first memory portion hold by the memory chain*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_FIRSTMEM(PMEMCHAIN)((void*)((PMEMCHAIN)->root_node.next_node_ptr))
|
||||
|
||||
/*!The address of the last memory portion hold by the memory chain*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_LASTMEM(PMEMCHAIN) ((void*)((PMEMCHAIN)->last_node_ptr))
|
||||
|
||||
/*!The number of memory portions hold by the memory chain*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_SIZE(PMEMCHAIN) ((PMEMCHAIN)->num_mem)
|
||||
|
||||
/*!Initializes the memory chain from the first memory portion, the last memory
|
||||
portion and number of portions obtained from another memory chain*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_INIT_FROM(PMEMCHAIN, FIRST, LAST, NUM)\
|
||||
(PMEMCHAIN)->last_node_ptr = (boost_cont_memchain_node *)(LAST), \
|
||||
(PMEMCHAIN)->root_node.next_node_ptr = (boost_cont_memchain_node *)(FIRST), \
|
||||
(PMEMCHAIN)->num_mem = (NUM);\
|
||||
/**/
|
||||
|
||||
/*!Default initializes a memory chain. Postconditions: begin iterator is end iterator,
|
||||
the number of portions is zero.*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_INIT(PMEMCHAIN)\
|
||||
((PMEMCHAIN)->root_node.next_node_ptr = 0, (PMEMCHAIN)->last_node_ptr = &((PMEMCHAIN)->root_node), (PMEMCHAIN)->num_mem = 0)\
|
||||
/**/
|
||||
|
||||
/*!True if the memory chain is empty (holds no memory portions*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_EMPTY(PMEMCHAIN)\
|
||||
((PMEMCHAIN)->num_mem == 0)\
|
||||
/**/
|
||||
|
||||
/*!Inserts a new memory portions in the front of the chain*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_PUSH_BACK(PMEMCHAIN, MEM)\
|
||||
do{\
|
||||
boost_cont_memchain *____chain____ = (PMEMCHAIN);\
|
||||
boost_cont_memchain_node *____tmp_mem____ = (boost_cont_memchain_node *)(MEM);\
|
||||
____chain____->last_node_ptr->next_node_ptr = ____tmp_mem____;\
|
||||
____tmp_mem____->next_node_ptr = 0;\
|
||||
____chain____->last_node_ptr = ____tmp_mem____;\
|
||||
++____chain____->num_mem;\
|
||||
}while(0)\
|
||||
/**/
|
||||
|
||||
/*!Inserts a new memory portions in the back of the chain*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_PUSH_FRONT(PMEMCHAIN, MEM)\
|
||||
do{\
|
||||
boost_cont_memchain *____chain____ = (PMEMCHAIN);\
|
||||
boost_cont_memchain_node *____tmp_mem____ = (boost_cont_memchain_node *)(MEM);\
|
||||
boost_cont_memchain *____root____ = &((PMEMCHAIN)->root_node);\
|
||||
if(!____chain____->root_node.next_node_ptr){\
|
||||
____chain____->last_node_ptr = ____tmp_mem____;\
|
||||
}\
|
||||
boost_cont_memchain_node *____old_first____ = ____root____->next_node_ptr;\
|
||||
____tmp_mem____->next_node_ptr = ____old_first____;\
|
||||
____root____->next_node_ptr = ____tmp_mem____;\
|
||||
++____chain____->num_mem;\
|
||||
}while(0)\
|
||||
/**/
|
||||
|
||||
/*!Erases the memory portion after the portion pointed by BEFORE_IT from the memory chain*/
|
||||
/*!Precondition: BEFORE_IT must be a valid iterator of the memory chain and it can't be the end iterator*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_ERASE_AFTER(PMEMCHAIN, BEFORE_IT)\
|
||||
do{\
|
||||
boost_cont_memchain *____chain____ = (PMEMCHAIN);\
|
||||
boost_cont_memchain_node *____prev_node____ = (BEFORE_IT).node_ptr;\
|
||||
boost_cont_memchain_node *____erase_node____ = ____prev_node____->next_node_ptr;\
|
||||
if(____chain____->last_node_ptr == ____erase_node____){\
|
||||
____chain____->last_node_ptr = &____chain____->root_node;\
|
||||
}\
|
||||
____prev_node____->next_node_ptr = ____erase_node____->next_node_ptr;\
|
||||
--____chain____->num_mem;\
|
||||
}while(0)\
|
||||
/**/
|
||||
|
||||
/*!Erases the first portion from the memory chain.
|
||||
Precondition: the memory chain must not be empty*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_POP_FRONT(PMEMCHAIN)\
|
||||
do{\
|
||||
boost_cont_memchain *____chain____ = (PMEMCHAIN);\
|
||||
boost_cont_memchain_node *____prev_node____ = &____chain____->root_node;\
|
||||
boost_cont_memchain_node *____erase_node____ = ____prev_node____->next_node_ptr;\
|
||||
if(____chain____->last_node_ptr == ____erase_node____){\
|
||||
____chain____->last_node_ptr = &____chain____->root_node;\
|
||||
}\
|
||||
____prev_node____->next_node_ptr = ____erase_node____->next_node_ptr;\
|
||||
--____chain____->num_mem;\
|
||||
}while(0)\
|
||||
/**/
|
||||
|
||||
/*!Joins two memory chains inserting the portions of the second chain at the back of the first chain*/
|
||||
/*
|
||||
#define BOOST_CONTAINER_MEMCHAIN_SPLICE_BACK(PMEMCHAIN, PMEMCHAIN2)\
|
||||
do{\
|
||||
boost_cont_memchain *____chain____ = (PMEMCHAIN);\
|
||||
boost_cont_memchain *____chain2____ = (PMEMCHAIN2);\
|
||||
if(!____chain2____->root_node.next_node_ptr){\
|
||||
break;\
|
||||
}\
|
||||
else if(!____chain____->first_mem){\
|
||||
____chain____->first_mem = ____chain2____->first_mem;\
|
||||
____chain____->last_node_ptr = ____chain2____->last_node_ptr;\
|
||||
____chain____->num_mem = ____chain2____->num_mem;\
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(*____chain2____);\
|
||||
}\
|
||||
else{\
|
||||
____chain____->last_node_ptr->next_node_ptr = ____chain2____->first_mem;\
|
||||
____chain____->last_node_ptr = ____chain2____->last_node_ptr;\
|
||||
____chain____->num_mem += ____chain2____->num_mem;\
|
||||
}\
|
||||
}while(0)\*/
|
||||
/**/
|
||||
|
||||
/*!Joins two memory chains inserting the portions of the second chain at the back of the first chain*/
|
||||
#define BOOST_CONTAINER_MEMCHAIN_INCORPORATE_AFTER(PMEMCHAIN, BEFORE_IT, FIRST, BEFORELAST, NUM)\
|
||||
do{\
|
||||
boost_cont_memchain *____chain____ = (PMEMCHAIN);\
|
||||
boost_cont_memchain_node *____pnode____ = (BEFORE_IT).node_ptr;\
|
||||
boost_cont_memchain_node *____next____ = ____pnode____->next_node_ptr;\
|
||||
boost_cont_memchain_node *____first____ = (boost_cont_memchain_node *)(FIRST);\
|
||||
boost_cont_memchain_node *____blast____ = (boost_cont_memchain_node *)(BEFORELAST);\
|
||||
size_t ____num____ = (NUM);\
|
||||
if(!____num____){\
|
||||
break;\
|
||||
}\
|
||||
if(____pnode____ == ____chain____->last_node_ptr){\
|
||||
____chain____->last_node_ptr = ____blast____;\
|
||||
}\
|
||||
____pnode____->next_node_ptr = ____first____;\
|
||||
____blast____->next_node_ptr = ____next____;\
|
||||
____chain____->num_mem += ____num____;\
|
||||
}while(0)\
|
||||
/**/
|
||||
|
||||
BOOST_CONTAINER_DECL size_t boost_cont_size(const void *p);
|
||||
|
||||
BOOST_CONTAINER_DECL void* boost_cont_malloc(size_t bytes);
|
||||
|
||||
BOOST_CONTAINER_DECL void boost_cont_free(void* mem);
|
||||
|
||||
BOOST_CONTAINER_DECL void* boost_cont_memalign(size_t bytes, size_t alignment);
|
||||
|
||||
/*!Indicates the all elements allocated by boost_cont_multialloc_nodes or boost_cont_multialloc_arrays
|
||||
must be contiguous.*/
|
||||
#define DL_MULTIALLOC_ALL_CONTIGUOUS ((size_t)(-1))
|
||||
|
||||
/*!Indicates the number of contiguous elements allocated by boost_cont_multialloc_nodes or boost_cont_multialloc_arrays
|
||||
should be selected by those functions.*/
|
||||
#define DL_MULTIALLOC_DEFAULT_CONTIGUOUS ((size_t)(0))
|
||||
|
||||
BOOST_CONTAINER_DECL int boost_cont_multialloc_nodes
|
||||
(size_t n_elements, size_t elem_size, size_t contiguous_elements, boost_cont_memchain *pchain);
|
||||
|
||||
BOOST_CONTAINER_DECL int boost_cont_multialloc_arrays
|
||||
(size_t n_elements, const size_t *sizes, size_t sizeof_element, size_t contiguous_elements, boost_cont_memchain *pchain);
|
||||
|
||||
BOOST_CONTAINER_DECL void boost_cont_multidealloc(boost_cont_memchain *pchain);
|
||||
|
||||
BOOST_CONTAINER_DECL size_t boost_cont_footprint();
|
||||
|
||||
BOOST_CONTAINER_DECL size_t boost_cont_allocated_memory();
|
||||
|
||||
BOOST_CONTAINER_DECL size_t boost_cont_chunksize(const void *p);
|
||||
|
||||
BOOST_CONTAINER_DECL int boost_cont_all_deallocated();
|
||||
|
||||
typedef struct boost_cont_malloc_stats_impl
|
||||
{
|
||||
size_t max_system_bytes;
|
||||
size_t system_bytes;
|
||||
size_t in_use_bytes;
|
||||
} boost_cont_malloc_stats_t;
|
||||
|
||||
BOOST_CONTAINER_DECL boost_cont_malloc_stats_t boost_cont_malloc_stats();
|
||||
|
||||
BOOST_CONTAINER_DECL size_t boost_cont_in_use_memory();
|
||||
|
||||
BOOST_CONTAINER_DECL int boost_cont_trim(size_t pad);
|
||||
|
||||
BOOST_CONTAINER_DECL int boost_cont_mallopt
|
||||
(int parameter_number, int parameter_value);
|
||||
|
||||
BOOST_CONTAINER_DECL int boost_cont_grow
|
||||
(void* oldmem, size_t minbytes, size_t maxbytes, size_t *received);
|
||||
|
||||
BOOST_CONTAINER_DECL int boost_cont_shrink
|
||||
(void* oldmem, size_t minbytes, size_t maxbytes, size_t *received, int do_commit);
|
||||
|
||||
BOOST_CONTAINER_DECL void* boost_cont_alloc
|
||||
(size_t minbytes, size_t preferred_bytes, size_t *received_bytes);
|
||||
|
||||
BOOST_CONTAINER_DECL int boost_cont_malloc_check();
|
||||
|
||||
typedef unsigned int allocation_type;
|
||||
|
||||
enum
|
||||
{
|
||||
// constants for allocation commands
|
||||
BOOST_CONTAINER_ALLOCATE_NEW = 0X01,
|
||||
BOOST_CONTAINER_EXPAND_FWD = 0X02,
|
||||
BOOST_CONTAINER_EXPAND_BWD = 0X04,
|
||||
BOOST_CONTAINER_SHRINK_IN_PLACE = 0X08,
|
||||
BOOST_CONTAINER_NOTHROW_ALLOCATION = 0X10,
|
||||
// BOOST_CONTAINER_ZERO_MEMORY = 0X20,
|
||||
BOOST_CONTAINER_TRY_SHRINK_IN_PLACE = 0X40,
|
||||
BOOST_CONTAINER_EXPAND_BOTH = BOOST_CONTAINER_EXPAND_FWD | BOOST_CONTAINER_EXPAND_BWD,
|
||||
BOOST_CONTAINER_EXPAND_OR_NEW = BOOST_CONTAINER_ALLOCATE_NEW | BOOST_CONTAINER_EXPAND_BOTH
|
||||
};
|
||||
|
||||
//#define BOOST_CONTAINERDLMALLOC__FOOTERS
|
||||
#ifndef BOOST_CONTAINERDLMALLOC__FOOTERS
|
||||
enum { BOOST_CONTAINER_ALLOCATION_PAYLOAD = sizeof(size_t) };
|
||||
#else
|
||||
enum { BOOST_CONTAINER_ALLOCATION_PAYLOAD = sizeof(size_t)*2 };
|
||||
#endif
|
||||
|
||||
typedef struct boost_cont_command_ret_impl
|
||||
{
|
||||
void *first;
|
||||
int second;
|
||||
}boost_cont_command_ret_t;
|
||||
|
||||
BOOST_CONTAINER_DECL boost_cont_command_ret_t boost_cont_allocation_command
|
||||
( allocation_type command
|
||||
, size_t sizeof_object
|
||||
, size_t limit_objects
|
||||
, size_t preferred_objects
|
||||
, size_t *received_objects
|
||||
, void *reuse_ptr
|
||||
);
|
||||
|
||||
BOOST_CONTAINER_DECL int boost_cont_mallopt(int param_number, int value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} //extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
|
||||
|
||||
#endif //#define BOOST_CONTAINERDLMALLOC__EXT_H
|
16
include/boost/container/detail/alloc_lib_auto_link.hpp
Normal file
16
include/boost/container/detail/alloc_lib_auto_link.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BOOST_CONTAINER_DETAIL_BOOST_CONT_EXT_AUTO_LINK_HPP
|
||||
#define BOOST_CONTAINER_DETAIL_BOOST_CONT_EXT_AUTO_LINK_HPP
|
||||
|
||||
#include <boost/container/detail/auto_link.hpp>
|
||||
#include <boost/container/detail/alloc_lib.h>
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_DETAIL_BOOST_CONT_EXT_AUTO_LINK_HPP
|
38
include/boost/container/detail/auto_link.hpp
Normal file
38
include/boost/container/detail/auto_link.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BOOST_CONTAINER_DETAIL_AUTO_LINK_HPP_INCLUDED
|
||||
#define BOOST_CONTAINER_DETAIL_AUTO_LINK_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// Automatically link to the correct build variant where possible.
|
||||
//
|
||||
#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_CONTAINER_NO_LIB) && !defined(BOOST_CONTAINER_SOURCE)
|
||||
//
|
||||
// Set the name of our library, this will get undef'ed by auto_link.hpp
|
||||
// once it's done with it:
|
||||
//
|
||||
#define BOOST_LIB_NAME boost_container
|
||||
//
|
||||
// If we're importing code from a dll, then tell auto_link.hpp about it:
|
||||
//
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTAINER_DYN_LINK)
|
||||
# define BOOST_DYN_LINK
|
||||
#endif
|
||||
//
|
||||
// And include the header that does the work:
|
||||
//
|
||||
#include <boost/config/auto_link.hpp>
|
||||
#endif // auto-linking disabled
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_DETAIL_AUTO_LINK_HPP_INCLUDED
|
@@ -745,6 +745,32 @@ class flat_tree
|
||||
void reserve(size_type cnt)
|
||||
{ this->m_data.m_vect.reserve(cnt); }
|
||||
|
||||
friend bool operator==(const flat_tree& x, const flat_tree& y)
|
||||
{
|
||||
return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin());
|
||||
}
|
||||
|
||||
friend bool operator<(const flat_tree& x, const flat_tree& y)
|
||||
{
|
||||
return std::lexicographical_compare(x.begin(), x.end(),
|
||||
y.begin(), y.end());
|
||||
}
|
||||
|
||||
friend bool operator!=(const flat_tree& x, const flat_tree& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const flat_tree& x, const flat_tree& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const flat_tree& x, const flat_tree& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const flat_tree& x, const flat_tree& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(flat_tree& x, flat_tree& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
private:
|
||||
struct insert_commit_data
|
||||
{
|
||||
@@ -950,62 +976,6 @@ class flat_tree
|
||||
}
|
||||
};
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class Compare, class A>
|
||||
inline bool
|
||||
operator==(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
|
||||
const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
|
||||
{
|
||||
return x.size() == y.size() &&
|
||||
std::equal(x.begin(), x.end(), y.begin());
|
||||
}
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class Compare, class A>
|
||||
inline bool
|
||||
operator<(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
|
||||
const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
|
||||
{
|
||||
return std::lexicographical_compare(x.begin(), x.end(),
|
||||
y.begin(), y.end());
|
||||
}
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class Compare, class A>
|
||||
inline bool
|
||||
operator!=(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
|
||||
const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class Compare, class A>
|
||||
inline bool
|
||||
operator>(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
|
||||
const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
|
||||
{ return y < x; }
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class Compare, class A>
|
||||
inline bool
|
||||
operator<=(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
|
||||
const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class Compare, class A>
|
||||
inline bool
|
||||
operator>=(const flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
|
||||
const flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class Compare, class A>
|
||||
inline void
|
||||
swap(flat_tree<Key,Value,KeyOfValue,Compare,A>& x,
|
||||
flat_tree<Key,Value,KeyOfValue,Compare,A>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
} //namespace container_detail {
|
||||
|
||||
} //namespace container {
|
||||
|
383
include/boost/container/detail/hash_table.hpp
Normal file
383
include/boost/container/detail/hash_table.hpp
Normal file
@@ -0,0 +1,383 @@
|
||||
/*
|
||||
template <class Value, unsigned int Options = 0, class Hash = hash<Value>, class Pred = equal_to<Value>,
|
||||
class Alloc = allocator<Value> >
|
||||
class hash_set
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef Value key_type;
|
||||
typedef key_type value_type;
|
||||
typedef Hash hasher;
|
||||
typedef Pred key_equal;
|
||||
typedef Alloc allocator_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename allocator_traits<allocator_type>::pointer pointer;
|
||||
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
|
||||
typedef typename allocator_traits<allocator_type>::size_type size_type;
|
||||
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
|
||||
|
||||
typedef /unspecified/ iterator;
|
||||
typedef /unspecified/ const_iterator;
|
||||
typedef /unspecified/ local_iterator;
|
||||
typedef /unspecified/ const_local_iterator;
|
||||
|
||||
hash_set()
|
||||
noexcept(
|
||||
is_nothrow_default_constructible<hasher>::value &&
|
||||
is_nothrow_default_constructible<key_equal>::value &&
|
||||
is_nothrow_default_constructible<allocator_type>::value);
|
||||
explicit hash_set(size_type n, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
template <class InputIterator>
|
||||
hash_set(InputIterator f, InputIterator l,
|
||||
size_type n = 0, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
explicit hash_set(const allocator_type&);
|
||||
hash_set(const hash_set&);
|
||||
hash_set(const hash_set&, const Allocator&);
|
||||
hash_set(hash_set&&)
|
||||
noexcept(
|
||||
is_nothrow_move_constructible<hasher>::value &&
|
||||
is_nothrow_move_constructible<key_equal>::value &&
|
||||
is_nothrow_move_constructible<allocator_type>::value);
|
||||
hash_set(hash_set&&, const Allocator&);
|
||||
hash_set(initializer_list<value_type>, size_type n = 0,
|
||||
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
~hash_set();
|
||||
hash_set& operator=(const hash_set&);
|
||||
hash_set& operator=(hash_set&&)
|
||||
noexcept(
|
||||
allocator_type::propagate_on_container_move_assignment::value &&
|
||||
is_nothrow_move_assignable<allocator_type>::value &&
|
||||
is_nothrow_move_assignable<hasher>::value &&
|
||||
is_nothrow_move_assignable<key_equal>::value);
|
||||
hash_set& operator=(initializer_list<value_type>);
|
||||
|
||||
allocator_type get_allocator() const noexcept;
|
||||
|
||||
bool empty() const noexcept;
|
||||
size_type size() const noexcept;
|
||||
size_type max_size() const noexcept;
|
||||
|
||||
iterator begin() noexcept;
|
||||
iterator end() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
const_iterator cbegin() const noexcept;
|
||||
const_iterator cend() const noexcept;
|
||||
|
||||
template <class... Args>
|
||||
pair<iterator, bool> emplace(Args&&... args);
|
||||
template <class... Args>
|
||||
iterator emplace_hint(const_iterator position, Args&&... args);
|
||||
pair<iterator, bool> insert(const value_type& obj);
|
||||
pair<iterator, bool> insert(value_type&& obj);
|
||||
iterator insert(const_iterator hint, const value_type& obj);
|
||||
iterator insert(const_iterator hint, value_type&& obj);
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last);
|
||||
void insert(initializer_list<value_type>);
|
||||
|
||||
iterator erase(const_iterator position);
|
||||
size_type erase(const key_type& k);
|
||||
iterator erase(const_iterator first, const_iterator last);
|
||||
void clear() noexcept;
|
||||
|
||||
void swap(hash_set&)
|
||||
noexcept(
|
||||
(!allocator_type::propagate_on_container_swap::value ||
|
||||
__is_nothrow_swappable<allocator_type>::value) &&
|
||||
__is_nothrow_swappable<hasher>::value &&
|
||||
__is_nothrow_swappable<key_equal>::value);
|
||||
|
||||
hasher hash_function() const;
|
||||
key_equal key_eq() const;
|
||||
|
||||
iterator find(const key_type& k);
|
||||
const_iterator find(const key_type& k) const;
|
||||
size_type count(const key_type& k) const;
|
||||
pair<iterator, iterator> equal_range(const key_type& k);
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
|
||||
|
||||
size_type bucket_count() const noexcept;
|
||||
size_type max_bucket_count() const noexcept;
|
||||
|
||||
size_type bucket_size(size_type n) const;
|
||||
size_type bucket(const key_type& k) const;
|
||||
|
||||
local_iterator begin(size_type n);
|
||||
local_iterator end(size_type n);
|
||||
const_local_iterator begin(size_type n) const;
|
||||
const_local_iterator end(size_type n) const;
|
||||
const_local_iterator cbegin(size_type n) const;
|
||||
const_local_iterator cend(size_type n) const;
|
||||
|
||||
float load_factor() const noexcept;
|
||||
float max_load_factor() const noexcept;
|
||||
void max_load_factor(float z);
|
||||
void rehash(size_type n);
|
||||
void reserve(size_type n);
|
||||
};
|
||||
|
||||
template <class Key, class T, unsigned int Options = 0, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
||||
class Alloc = allocator<pair<const Key, T> > >
|
||||
class hash_map
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
typedef Hash hasher;
|
||||
typedef Pred key_equal;
|
||||
typedef Alloc allocator_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename allocator_traits<allocator_type>::pointer pointer;
|
||||
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
|
||||
typedef typename allocator_traits<allocator_type>::size_type size_type;
|
||||
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
|
||||
|
||||
typedef /unspecified/ iterator;
|
||||
typedef /unspecified/ const_iterator;
|
||||
typedef /unspecified/ local_iterator;
|
||||
typedef /unspecified/ const_local_iterator;
|
||||
|
||||
hash_map()
|
||||
noexcept(
|
||||
is_nothrow_default_constructible<hasher>::value &&
|
||||
is_nothrow_default_constructible<key_equal>::value &&
|
||||
is_nothrow_default_constructible<allocator_type>::value);
|
||||
explicit hash_map(size_type n, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
template <class InputIterator>
|
||||
hash_map(InputIterator f, InputIterator l,
|
||||
size_type n = 0, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
explicit hash_map(const allocator_type&);
|
||||
hash_map(const hash_map&);
|
||||
hash_map(const hash_map&, const Allocator&);
|
||||
hash_map(hash_map&&)
|
||||
noexcept(
|
||||
is_nothrow_move_constructible<hasher>::value &&
|
||||
is_nothrow_move_constructible<key_equal>::value &&
|
||||
is_nothrow_move_constructible<allocator_type>::value);
|
||||
hash_map(hash_map&&, const Allocator&);
|
||||
hash_map(initializer_list<value_type>, size_type n = 0,
|
||||
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
~hash_map();
|
||||
hash_map& operator=(const hash_map&);
|
||||
hash_map& operator=(hash_map&&)
|
||||
noexcept(
|
||||
allocator_type::propagate_on_container_move_assignment::value &&
|
||||
is_nothrow_move_assignable<allocator_type>::value &&
|
||||
is_nothrow_move_assignable<hasher>::value &&
|
||||
is_nothrow_move_assignable<key_equal>::value);
|
||||
hash_map& operator=(initializer_list<value_type>);
|
||||
|
||||
allocator_type get_allocator() const noexcept;
|
||||
|
||||
bool empty() const noexcept;
|
||||
size_type size() const noexcept;
|
||||
size_type max_size() const noexcept;
|
||||
|
||||
iterator begin() noexcept;
|
||||
iterator end() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
const_iterator cbegin() const noexcept;
|
||||
const_iterator cend() const noexcept;
|
||||
|
||||
template <class... Args>
|
||||
pair<iterator, bool> emplace(Args&&... args);
|
||||
template <class... Args>
|
||||
iterator emplace_hint(const_iterator position, Args&&... args);
|
||||
pair<iterator, bool> insert(const value_type& obj);
|
||||
template <class P>
|
||||
pair<iterator, bool> insert(P&& obj);
|
||||
iterator insert(const_iterator hint, const value_type& obj);
|
||||
template <class P>
|
||||
iterator insert(const_iterator hint, P&& obj);
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last);
|
||||
void insert(initializer_list<value_type>);
|
||||
|
||||
iterator erase(const_iterator position);
|
||||
size_type erase(const key_type& k);
|
||||
iterator erase(const_iterator first, const_iterator last);
|
||||
void clear() noexcept;
|
||||
|
||||
void swap(hash_map&)
|
||||
noexcept(
|
||||
(!allocator_type::propagate_on_container_swap::value ||
|
||||
__is_nothrow_swappable<allocator_type>::value) &&
|
||||
__is_nothrow_swappable<hasher>::value &&
|
||||
__is_nothrow_swappable<key_equal>::value);
|
||||
|
||||
hasher hash_function() const;
|
||||
key_equal key_eq() const;
|
||||
|
||||
iterator find(const key_type& k);
|
||||
const_iterator find(const key_type& k) const;
|
||||
size_type count(const key_type& k) const;
|
||||
pair<iterator, iterator> equal_range(const key_type& k);
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
|
||||
|
||||
mapped_type& operator[](const key_type& k);
|
||||
mapped_type& operator[](key_type&& k);
|
||||
|
||||
mapped_type& at(const key_type& k);
|
||||
const mapped_type& at(const key_type& k) const;
|
||||
|
||||
size_type bucket_count() const noexcept;
|
||||
size_type max_bucket_count() const noexcept;
|
||||
|
||||
size_type bucket_size(size_type n) const;
|
||||
size_type bucket(const key_type& k) const;
|
||||
|
||||
local_iterator begin(size_type n);
|
||||
local_iterator end(size_type n);
|
||||
const_local_iterator begin(size_type n) const;
|
||||
const_local_iterator end(size_type n) const;
|
||||
const_local_iterator cbegin(size_type n) const;
|
||||
const_local_iterator cend(size_type n) const;
|
||||
|
||||
float load_factor() const noexcept;
|
||||
float max_load_factor() const noexcept;
|
||||
void max_load_factor(float z);
|
||||
void rehash(size_type n);
|
||||
void reserve(size_type n);
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
template <class Key, class Value, class KeyOfValue, unsigned int Options = 0, class Hash = hash<Key>, class Pred = equal_to<Key>,
|
||||
class Alloc = allocator<Value> >
|
||||
class hash_table
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef Value key_type;
|
||||
typedef key_type value_type;
|
||||
typedef Hash hasher;
|
||||
typedef Pred key_equal;
|
||||
typedef Alloc allocator_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef typename allocator_traits<allocator_type>::pointer pointer;
|
||||
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
|
||||
typedef typename allocator_traits<allocator_type>::size_type size_type;
|
||||
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
|
||||
|
||||
typedef /unspecified/ iterator;
|
||||
typedef /unspecified/ const_iterator;
|
||||
typedef /unspecified/ local_iterator;
|
||||
typedef /unspecified/ const_local_iterator;
|
||||
|
||||
hash_set()
|
||||
noexcept(
|
||||
is_nothrow_default_constructible<hasher>::value &&
|
||||
is_nothrow_default_constructible<key_equal>::value &&
|
||||
is_nothrow_default_constructible<allocator_type>::value);
|
||||
explicit hash_set(size_type n, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
template <class InputIterator>
|
||||
hash_set(InputIterator f, InputIterator l,
|
||||
size_type n = 0, const hasher& hf = hasher(),
|
||||
const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
explicit hash_set(const allocator_type&);
|
||||
hash_set(const hash_set&);
|
||||
hash_set(const hash_set&, const Allocator&);
|
||||
hash_set(hash_set&&)
|
||||
noexcept(
|
||||
is_nothrow_move_constructible<hasher>::value &&
|
||||
is_nothrow_move_constructible<key_equal>::value &&
|
||||
is_nothrow_move_constructible<allocator_type>::value);
|
||||
hash_set(hash_set&&, const Allocator&);
|
||||
hash_set(initializer_list<value_type>, size_type n = 0,
|
||||
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
|
||||
const allocator_type& a = allocator_type());
|
||||
~hash_set();
|
||||
hash_set& operator=(const hash_set&);
|
||||
hash_set& operator=(hash_set&&)
|
||||
noexcept(
|
||||
allocator_type::propagate_on_container_move_assignment::value &&
|
||||
is_nothrow_move_assignable<allocator_type>::value &&
|
||||
is_nothrow_move_assignable<hasher>::value &&
|
||||
is_nothrow_move_assignable<key_equal>::value);
|
||||
hash_set& operator=(initializer_list<value_type>);
|
||||
|
||||
allocator_type get_allocator() const noexcept;
|
||||
|
||||
bool empty() const noexcept;
|
||||
size_type size() const noexcept;
|
||||
size_type max_size() const noexcept;
|
||||
|
||||
iterator begin() noexcept;
|
||||
iterator end() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
const_iterator cbegin() const noexcept;
|
||||
const_iterator cend() const noexcept;
|
||||
|
||||
template <class... Args>
|
||||
pair<iterator, bool> emplace(Args&&... args);
|
||||
template <class... Args>
|
||||
iterator emplace_hint(const_iterator position, Args&&... args);
|
||||
pair<iterator, bool> insert(const value_type& obj);
|
||||
pair<iterator, bool> insert(value_type&& obj);
|
||||
iterator insert(const_iterator hint, const value_type& obj);
|
||||
iterator insert(const_iterator hint, value_type&& obj);
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last);
|
||||
void insert(initializer_list<value_type>);
|
||||
|
||||
iterator erase(const_iterator position);
|
||||
size_type erase(const key_type& k);
|
||||
iterator erase(const_iterator first, const_iterator last);
|
||||
void clear() noexcept;
|
||||
|
||||
void swap(hash_set&)
|
||||
noexcept(
|
||||
(!allocator_type::propagate_on_container_swap::value ||
|
||||
__is_nothrow_swappable<allocator_type>::value) &&
|
||||
__is_nothrow_swappable<hasher>::value &&
|
||||
__is_nothrow_swappable<key_equal>::value);
|
||||
|
||||
hasher hash_function() const;
|
||||
key_equal key_eq() const;
|
||||
|
||||
iterator find(const key_type& k);
|
||||
const_iterator find(const key_type& k) const;
|
||||
size_type count(const key_type& k) const;
|
||||
pair<iterator, iterator> equal_range(const key_type& k);
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
|
||||
|
||||
size_type bucket_count() const noexcept;
|
||||
size_type max_bucket_count() const noexcept;
|
||||
|
||||
size_type bucket_size(size_type n) const;
|
||||
size_type bucket(const key_type& k) const;
|
||||
|
||||
local_iterator begin(size_type n);
|
||||
local_iterator end(size_type n);
|
||||
const_local_iterator begin(size_type n) const;
|
||||
const_local_iterator end(size_type n) const;
|
||||
const_local_iterator cbegin(size_type n) const;
|
||||
const_local_iterator cend(size_type n) const;
|
||||
|
||||
float load_factor() const noexcept;
|
||||
float max_load_factor() const noexcept;
|
||||
void max_load_factor(float z);
|
||||
void rehash(size_type n);
|
||||
void reserve(size_type n);
|
||||
};
|
@@ -63,7 +63,6 @@ namespace boost {
|
||||
namespace container {
|
||||
namespace container_detail {
|
||||
|
||||
|
||||
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer)
|
||||
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_pointer)
|
||||
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference)
|
||||
@@ -75,6 +74,8 @@ BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assig
|
||||
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment)
|
||||
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap)
|
||||
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type)
|
||||
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(value_compare)
|
||||
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(wrapped_value_compare)
|
||||
|
||||
} //namespace container_detail {
|
||||
} //namespace container {
|
||||
|
278
include/boost/container/detail/mutex.hpp
Normal file
278
include/boost/container/detail/mutex.hpp
Normal file
@@ -0,0 +1,278 @@
|
||||
// Copyright (C) 2000 Stephen Cleary
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_MUTEX_HPP
|
||||
#define BOOST_CONTAINER_MUTEX_HPP
|
||||
|
||||
//#define BOOST_CONTAINER_NO_MT
|
||||
//#define BOOST_CONTAINER_NO_SPINLOCKS
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
|
||||
// Extremely Light-Weight wrapper classes for OS thread synchronization
|
||||
|
||||
#define BOOST_MUTEX_HELPER_NONE 0
|
||||
#define BOOST_MUTEX_HELPER_WIN32 1
|
||||
#define BOOST_MUTEX_HELPER_PTHREAD 2
|
||||
#define BOOST_MUTEX_HELPER_SPINLOCKS 3
|
||||
|
||||
#if !defined(BOOST_HAS_THREADS) && !defined(BOOST_NO_MT)
|
||||
# define BOOST_NO_MT
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_MT) || defined(BOOST_CONTAINER_NO_MT)
|
||||
// No multithreading -> make locks into no-ops
|
||||
#define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_NONE
|
||||
#else
|
||||
//Taken from dlmalloc
|
||||
#if !defined(BOOST_CONTAINER_NO_SPINLOCKS) && \
|
||||
((defined(__GNUC__) && \
|
||||
((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \
|
||||
defined(__i386__) || defined(__x86_64__))) || \
|
||||
(defined(_MSC_VER) && _MSC_VER>=1310))
|
||||
#define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_SPINLOCKS
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_WINDOWS)
|
||||
#include <windows.h>
|
||||
#ifndef BOOST_MUTEX_HELPER
|
||||
#define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_WIN32
|
||||
#endif
|
||||
#elif defined(BOOST_HAS_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#if !defined(BOOST_MUTEX_HELPER) && (defined(_POSIX_THREADS) || defined(BOOST_HAS_PTHREADS))
|
||||
#define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_PTHREAD
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_MUTEX_HELPER
|
||||
#error Unable to determine platform mutex type; #define BOOST_NO_MT to assume single-threaded
|
||||
#endif
|
||||
|
||||
#if BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_NONE
|
||||
//...
|
||||
#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_SPINLOCKS
|
||||
#if defined(_MSC_VER)
|
||||
#ifndef _M_AMD64
|
||||
/* These are already defined on AMD64 builds */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
long __cdecl _InterlockedCompareExchange(long volatile *Dest, long Exchange, long Comp);
|
||||
long __cdecl _InterlockedExchange(long volatile *Target, long Value);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* _M_AMD64 */
|
||||
#pragma intrinsic (_InterlockedCompareExchange)
|
||||
#pragma intrinsic (_InterlockedExchange)
|
||||
#define interlockedcompareexchange _InterlockedCompareExchange
|
||||
#define interlockedexchange _InterlockedExchange
|
||||
#elif defined(WIN32) && defined(__GNUC__)
|
||||
#define interlockedcompareexchange(a, b, c) __sync_val_compare_and_swap(a, c, b)
|
||||
#define interlockedexchange __sync_lock_test_and_set
|
||||
#endif /* Win32 */
|
||||
|
||||
/* First, define CAS_LOCK and CLEAR_LOCK on ints */
|
||||
/* Note CAS_LOCK defined to return 0 on success */
|
||||
|
||||
#if defined(__GNUC__)&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
|
||||
#define BOOST_CONTAINER_CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1)
|
||||
#define BOOST_CONTAINER_CLEAR_LOCK(sl) __sync_lock_release(sl)
|
||||
|
||||
#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
|
||||
/* Custom spin locks for older gcc on x86 */
|
||||
static FORCEINLINE int boost_container_x86_cas_lock(int *sl) {
|
||||
int ret;
|
||||
int val = 1;
|
||||
int cmp = 0;
|
||||
__asm__ __volatile__ ("lock; cmpxchgl %1, %2"
|
||||
: "=a" (ret)
|
||||
: "r" (val), "m" (*(sl)), "0"(cmp)
|
||||
: "memory", "cc");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static FORCEINLINE void boost_container_x86_clear_lock(int* sl) {
|
||||
assert(*sl != 0);
|
||||
int prev = 0;
|
||||
int ret;
|
||||
__asm__ __volatile__ ("lock; xchgl %0, %1"
|
||||
: "=r" (ret)
|
||||
: "m" (*(sl)), "0"(prev)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
#define BOOST_CONTAINER_CAS_LOCK(sl) boost_container_x86_cas_lock(sl)
|
||||
#define BOOST_CONTAINER_CLEAR_LOCK(sl) boost_container_x86_clear_lock(sl)
|
||||
|
||||
#else /* Win32 MSC */
|
||||
#define BOOST_CONTAINER_CAS_LOCK(sl) interlockedexchange((long volatile*)sl, (long)1)
|
||||
#define BOOST_CONTAINER_CLEAR_LOCK(sl) interlockedexchange((long volatile*)sl, (long)0)
|
||||
#endif
|
||||
|
||||
/* How to yield for a spin lock */
|
||||
#define SPINS_PER_YIELD 63
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||
#define SLEEP_EX_DURATION 50 /* delay for yield/sleep */
|
||||
#define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE)
|
||||
#elif defined (__SVR4) && defined (__sun) /* solaris */
|
||||
#define SPIN_LOCK_YIELD thr_yield();
|
||||
#elif !defined(LACKS_SCHED_H)
|
||||
#define SPIN_LOCK_YIELD sched_yield();
|
||||
#else
|
||||
#define SPIN_LOCK_YIELD
|
||||
#endif /* ... yield ... */
|
||||
|
||||
#define BOOST_CONTAINER_SPINS_PER_YIELD 63
|
||||
inline int boost_interprocess_spin_acquire_lock(int *sl) {
|
||||
int spins = 0;
|
||||
while (*(volatile int *)sl != 0 ||
|
||||
BOOST_CONTAINER_CAS_LOCK(sl)) {
|
||||
if ((++spins & BOOST_CONTAINER_SPINS_PER_YIELD) == 0) {
|
||||
SPIN_LOCK_YIELD;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#define BOOST_CONTAINER_MLOCK_T int
|
||||
#define BOOST_CONTAINER_TRY_LOCK(sl) !BOOST_CONTAINER_CAS_LOCK(sl)
|
||||
#define BOOST_CONTAINER_RELEASE_LOCK(sl) BOOST_CONTAINER_CLEAR_LOCK(sl)
|
||||
#define BOOST_CONTAINER_ACQUIRE_LOCK(sl) (BOOST_CONTAINER_CAS_LOCK(sl)? boost_interprocess_spin_acquire_lock(sl) : 0)
|
||||
#define BOOST_CONTAINER_INITIAL_LOCK(sl) (*sl = 0)
|
||||
#define BOOST_CONTAINER_DESTROY_LOCK(sl) (0)
|
||||
#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_WIN32
|
||||
//
|
||||
#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_PTHREAD
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
namespace container_detail {
|
||||
|
||||
#if BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_NONE
|
||||
class null_mutex
|
||||
{
|
||||
private:
|
||||
null_mutex(const null_mutex &);
|
||||
void operator=(const null_mutex &);
|
||||
|
||||
public:
|
||||
null_mutex() { }
|
||||
|
||||
static void lock() { }
|
||||
static void unlock() { }
|
||||
};
|
||||
|
||||
typedef null_mutex default_mutex;
|
||||
#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_SPINLOCKS
|
||||
|
||||
class spin_mutex
|
||||
{
|
||||
private:
|
||||
BOOST_CONTAINER_MLOCK_T sl;
|
||||
spin_mutex(const spin_mutex &);
|
||||
void operator=(const spin_mutex &);
|
||||
|
||||
public:
|
||||
spin_mutex() { BOOST_CONTAINER_INITIAL_LOCK(&sl); }
|
||||
|
||||
void lock() { BOOST_CONTAINER_ACQUIRE_LOCK(&sl); }
|
||||
void unlock() { BOOST_CONTAINER_RELEASE_LOCK(&sl); }
|
||||
};
|
||||
typedef spin_mutex default_mutex;
|
||||
#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_WIN32
|
||||
class mutex
|
||||
{
|
||||
private:
|
||||
CRITICAL_SECTION mtx;
|
||||
|
||||
mutex(const mutex &);
|
||||
void operator=(const mutex &);
|
||||
|
||||
public:
|
||||
mutex()
|
||||
{ InitializeCriticalSection(&mtx); }
|
||||
|
||||
~mutex()
|
||||
{ DeleteCriticalSection(&mtx); }
|
||||
|
||||
void lock()
|
||||
{ EnterCriticalSection(&mtx); }
|
||||
|
||||
void unlock()
|
||||
{ LeaveCriticalSection(&mtx); }
|
||||
};
|
||||
|
||||
typedef mutex default_mutex;
|
||||
#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_PTHREAD
|
||||
class mutex
|
||||
{
|
||||
private:
|
||||
pthread_mutex_t mtx;
|
||||
|
||||
mutex(const mutex &);
|
||||
void operator=(const mutex &);
|
||||
|
||||
public:
|
||||
mutex()
|
||||
{ pthread_mutex_init(&mtx, 0); }
|
||||
|
||||
~mutex()
|
||||
{ pthread_mutex_destroy(&mtx); }
|
||||
|
||||
void lock()
|
||||
{ pthread_mutex_lock(&mtx); }
|
||||
|
||||
void unlock()
|
||||
{ pthread_mutex_unlock(&mtx); }
|
||||
};
|
||||
|
||||
typedef mutex default_mutex;
|
||||
#endif
|
||||
|
||||
template<class Mutex>
|
||||
class scoped_lock
|
||||
{
|
||||
public:
|
||||
scoped_lock(Mutex &m)
|
||||
: m_(m)
|
||||
{ m_.lock(); }
|
||||
~scoped_lock()
|
||||
{ m_.unlock(); }
|
||||
|
||||
private:
|
||||
Mutex &m_;
|
||||
};
|
||||
|
||||
} // namespace container_detail
|
||||
} // namespace container
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_MUTEX_HELPER_WIN32
|
||||
#undef BOOST_MUTEX_HELPER_PTHREAD
|
||||
#undef BOOST_MUTEX_HELPER_NONE
|
||||
#undef BOOST_MUTEX_HELPER
|
||||
#undef BOOST_MUTEX_HELPER_SPINLOCKS
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif
|
@@ -31,6 +31,7 @@
|
||||
#include <boost/container/detail/allocator_version_traits.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/container/detail/destroyers.hpp>
|
||||
#include <boost/container/detail/memory_util.hpp>
|
||||
#include <boost/container/detail/allocator_version_traits.hpp>
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
|
||||
@@ -50,31 +51,41 @@ template<class ValueCompare, class Node>
|
||||
struct node_compare
|
||||
: private ValueCompare
|
||||
{
|
||||
typedef typename ValueCompare::key_type key_type;
|
||||
typedef typename ValueCompare::value_type value_type;
|
||||
typedef typename ValueCompare::key_of_value key_of_value;
|
||||
typedef ValueCompare wrapped_value_compare;
|
||||
typedef typename wrapped_value_compare::key_type key_type;
|
||||
typedef typename wrapped_value_compare::value_type value_type;
|
||||
typedef typename wrapped_value_compare::key_of_value key_of_value;
|
||||
|
||||
explicit node_compare(const ValueCompare &pred)
|
||||
: ValueCompare(pred)
|
||||
explicit node_compare(const wrapped_value_compare &pred)
|
||||
: wrapped_value_compare(pred)
|
||||
{}
|
||||
|
||||
node_compare()
|
||||
: ValueCompare()
|
||||
: wrapped_value_compare()
|
||||
{}
|
||||
|
||||
ValueCompare &value_comp()
|
||||
{ return static_cast<ValueCompare &>(*this); }
|
||||
wrapped_value_compare &value_comp()
|
||||
{ return static_cast<wrapped_value_compare &>(*this); }
|
||||
|
||||
ValueCompare &value_comp() const
|
||||
{ return static_cast<const ValueCompare &>(*this); }
|
||||
wrapped_value_compare &value_comp() const
|
||||
{ return static_cast<const wrapped_value_compare &>(*this); }
|
||||
|
||||
bool operator()(const Node &a, const Node &b) const
|
||||
{ return ValueCompare::operator()(a.get_data(), b.get_data()); }
|
||||
{ return wrapped_value_compare::operator()(a.get_data(), b.get_data()); }
|
||||
};
|
||||
|
||||
template<class A, class ICont, class ValPred = container_detail::nat>
|
||||
template<class A, class ICont>
|
||||
struct node_alloc_holder
|
||||
{
|
||||
//If the intrusive container is an associative container, obtain the predicate, which will
|
||||
//be of type node_compare<>. If not an associative container value_compare will be a "nat" type.
|
||||
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, ICont,
|
||||
value_compare, container_detail::nat) intrusive_value_compare;
|
||||
//In that case obtain the value predicate from the node predicate via wrapped_value_compare
|
||||
//if intrusive_value_compare is node_compare<>, nat otherwise
|
||||
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, ICont,
|
||||
wrapped_value_compare, container_detail::nat) value_compare;
|
||||
|
||||
typedef allocator_traits<A> allocator_traits_type;
|
||||
typedef typename allocator_traits_type::value_type value_type;
|
||||
typedef typename ICont::value_type Node;
|
||||
@@ -121,20 +132,20 @@ struct node_alloc_holder
|
||||
{ this->icont().swap(x.icont()); }
|
||||
|
||||
//Constructors for associative containers
|
||||
explicit node_alloc_holder(const ValAlloc &a, const ValPred &c)
|
||||
explicit node_alloc_holder(const ValAlloc &a, const value_compare &c)
|
||||
: members_(a, c)
|
||||
{}
|
||||
|
||||
explicit node_alloc_holder(const node_alloc_holder &x, const ValPred &c)
|
||||
explicit node_alloc_holder(const node_alloc_holder &x, const value_compare &c)
|
||||
: members_(NodeAllocTraits::select_on_container_copy_construction(x.node_alloc()), c)
|
||||
{}
|
||||
|
||||
explicit node_alloc_holder(const ValPred &c)
|
||||
explicit node_alloc_holder(const value_compare &c)
|
||||
: members_(c)
|
||||
{}
|
||||
|
||||
//helpers for move assignments
|
||||
explicit node_alloc_holder(BOOST_RV_REF(node_alloc_holder) x, const ValPred &c)
|
||||
explicit node_alloc_holder(BOOST_RV_REF(node_alloc_holder) x, const value_compare &c)
|
||||
: members_(boost::move(x.node_alloc()), c)
|
||||
{ this->icont().swap(x.icont()); }
|
||||
|
||||
@@ -346,12 +357,12 @@ struct node_alloc_holder
|
||||
{}
|
||||
|
||||
template<class ConvertibleToAlloc>
|
||||
members_holder(BOOST_FWD_REF(ConvertibleToAlloc) c2alloc, const ValPred &c)
|
||||
members_holder(BOOST_FWD_REF(ConvertibleToAlloc) c2alloc, const value_compare &c)
|
||||
: NodeAlloc(boost::forward<ConvertibleToAlloc>(c2alloc))
|
||||
, m_icont(typename ICont::value_compare(c))
|
||||
{}
|
||||
|
||||
explicit members_holder(const ValPred &c)
|
||||
explicit members_holder(const value_compare &c)
|
||||
: NodeAlloc()
|
||||
, m_icont(typename ICont::value_compare(c))
|
||||
{}
|
||||
|
157
include/boost/container/detail/node_pool.hpp
Normal file
157
include/boost/container/detail/node_pool.hpp
Normal file
@@ -0,0 +1,157 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_DETAIL_NODE_POOL_HPP
|
||||
#define BOOST_CONTAINER_DETAIL_NODE_POOL_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
|
||||
#include <boost/container/detail/mutex.hpp>
|
||||
#include <boost/container/detail/pool_common_alloc.hpp>
|
||||
#include <boost/container/detail/node_pool_impl.hpp>
|
||||
#include <boost/container/detail/mutex.hpp>
|
||||
#include <boost/intrusive/slist.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
#include <functional> //std::unary_function
|
||||
#include <algorithm> //std::swap
|
||||
#include <cassert>
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
namespace container_detail {
|
||||
|
||||
//!Pooled memory allocator using single segregated storage. Includes
|
||||
//!a reference count but the class does not delete itself, this is
|
||||
//!responsibility of user classes. Node size (NodeSize) and the number of
|
||||
//!nodes allocated per block (NodesPerBlock) are known at compile time
|
||||
template< std::size_t NodeSize, std::size_t NodesPerBlock >
|
||||
class private_node_pool
|
||||
//Inherit from the implementation to avoid template bloat
|
||||
: public boost::container::container_detail::
|
||||
private_node_pool_impl<fake_segment_manager>
|
||||
{
|
||||
typedef boost::container::container_detail::
|
||||
private_node_pool_impl<fake_segment_manager> base_t;
|
||||
//Non-copyable
|
||||
private_node_pool(const private_node_pool &);
|
||||
private_node_pool &operator=(const private_node_pool &);
|
||||
|
||||
public:
|
||||
typedef typename base_t::multiallocation_chain multiallocation_chain;
|
||||
static const std::size_t nodes_per_block = NodesPerBlock;
|
||||
|
||||
//!Constructor from a segment manager. Never throws
|
||||
private_node_pool()
|
||||
: base_t(0, NodeSize, NodesPerBlock)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
template< std::size_t NodeSize
|
||||
, std::size_t NodesPerBlock
|
||||
>
|
||||
class shared_node_pool
|
||||
: public private_node_pool<NodeSize, NodesPerBlock>
|
||||
{
|
||||
private:
|
||||
typedef private_node_pool<NodeSize, NodesPerBlock> private_node_allocator_t;
|
||||
|
||||
public:
|
||||
typedef typename private_node_allocator_t::free_nodes_t free_nodes_t;
|
||||
typedef typename private_node_allocator_t::multiallocation_chain multiallocation_chain;
|
||||
|
||||
//!Constructor from a segment manager. Never throws
|
||||
shared_node_pool()
|
||||
: private_node_allocator_t(){}
|
||||
|
||||
//!Destructor. Deallocates all allocated blocks. Never throws
|
||||
~shared_node_pool()
|
||||
{}
|
||||
|
||||
//!Allocates array of count elements. Can throw std::bad_alloc
|
||||
void *allocate_node()
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
return private_node_allocator_t::allocate_node();
|
||||
}
|
||||
|
||||
//!Deallocates an array pointed by ptr. Never throws
|
||||
void deallocate_node(void *ptr)
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
private_node_allocator_t::deallocate_node(ptr);
|
||||
}
|
||||
|
||||
//!Allocates a singly linked list of n nodes ending in null pointer.
|
||||
//!can throw std::bad_alloc
|
||||
void allocate_nodes(const std::size_t n, multiallocation_chain &chain)
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
return private_node_allocator_t::allocate_nodes(n, chain);
|
||||
}
|
||||
|
||||
void deallocate_nodes(multiallocation_chain &chain)
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
private_node_allocator_t::deallocate_nodes(chain);
|
||||
}
|
||||
|
||||
//!Deallocates all the free blocks of memory. Never throws
|
||||
void deallocate_free_blocks()
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
private_node_allocator_t::deallocate_free_blocks();
|
||||
}
|
||||
|
||||
//!Deallocates all blocks. Never throws
|
||||
void purge_blocks()
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
private_node_allocator_t::purge_blocks();
|
||||
}
|
||||
|
||||
std::size_t num_free_nodes()
|
||||
{
|
||||
//-----------------------
|
||||
scoped_lock<default_mutex> guard(mutex_);
|
||||
//-----------------------
|
||||
return private_node_allocator_t::num_free_nodes();
|
||||
}
|
||||
|
||||
private:
|
||||
default_mutex mutex_;
|
||||
};
|
||||
|
||||
} //namespace container_detail {
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_DETAIL_NODE_POOL_HPP
|
94
include/boost/container/detail/pool_common_alloc.hpp
Normal file
94
include/boost/container/detail/pool_common_alloc.hpp
Normal file
@@ -0,0 +1,94 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2005-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP
|
||||
#define BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
#include <boost/container/throw_exception.hpp>
|
||||
|
||||
#include <boost/intrusive/slist.hpp>
|
||||
#include <boost/container/detail/pool_common.hpp>
|
||||
#include <boost/container/detail/alloc_lib.h>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost{
|
||||
namespace container{
|
||||
namespace container_detail{
|
||||
|
||||
struct node_slist_helper
|
||||
: public boost::container::container_detail::node_slist<void*>
|
||||
{};
|
||||
|
||||
struct fake_segment_manager
|
||||
{
|
||||
typedef void * void_pointer;
|
||||
static const std::size_t PayloadPerAllocation = BOOST_CONTAINER_ALLOCATION_PAYLOAD;
|
||||
|
||||
typedef boost::container::container_detail::
|
||||
basic_multiallocation_chain<void*> multiallocation_chain;
|
||||
static void deallocate(void_pointer p)
|
||||
{ boost_cont_free(p); }
|
||||
|
||||
static void deallocate_many(multiallocation_chain &chain)
|
||||
{
|
||||
std::size_t size = chain.size();
|
||||
std::pair<void*, void*> ptrs = chain.extract_data();
|
||||
boost_cont_memchain dlchain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&dlchain, ptrs.first, ptrs.second, size);
|
||||
boost_cont_multidealloc(&dlchain);
|
||||
}
|
||||
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::size_t size_type;
|
||||
|
||||
static void *allocate_aligned(std::size_t nbytes, std::size_t alignment)
|
||||
{
|
||||
void *ret = boost_cont_memalign(nbytes, alignment);
|
||||
if(!ret)
|
||||
boost::container::throw_bad_alloc();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *allocate(std::size_t nbytes)
|
||||
{
|
||||
void *ret = boost_cont_malloc(nbytes);
|
||||
if(!ret)
|
||||
boost::container::throw_bad_alloc();
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace boost{
|
||||
} //namespace container{
|
||||
} //namespace container_detail{
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
namespace container_detail {
|
||||
|
||||
template<class T>
|
||||
struct is_stateless_segment_manager;
|
||||
|
||||
template<>
|
||||
struct is_stateless_segment_manager
|
||||
<boost::container::container_detail::fake_segment_manager>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
} //namespace container_detail {
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP
|
113
include/boost/container/detail/singleton.hpp
Normal file
113
include/boost/container/detail/singleton.hpp
Normal file
@@ -0,0 +1,113 @@
|
||||
// Copyright (C) 2000 Stephen Cleary
|
||||
// Copyright (C) 2008 Ion Gaztanaga
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//
|
||||
// This file is a modified file from Boost.Pool
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_DETAIL_SINGLETON_DETAIL_HPP
|
||||
#define BOOST_CONTAINER_DETAIL_SINGLETON_DETAIL_HPP
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
|
||||
//
|
||||
// The following helper classes are placeholders for a generic "singleton"
|
||||
// class. The classes below support usage of singletons, including use in
|
||||
// program startup/shutdown code, AS LONG AS there is only one thread
|
||||
// running before main() begins, and only one thread running after main()
|
||||
// exits.
|
||||
//
|
||||
// This class is also limited in that it can only provide singleton usage for
|
||||
// classes with default constructors.
|
||||
//
|
||||
|
||||
// The design of this class is somewhat twisted, but can be followed by the
|
||||
// calling inheritance. Let us assume that there is some user code that
|
||||
// calls "singleton_default<T>::instance()". The following (convoluted)
|
||||
// sequence ensures that the same function will be called before main():
|
||||
// instance() contains a call to create_object.do_nothing()
|
||||
// Thus, object_creator is implicitly instantiated, and create_object
|
||||
// must exist.
|
||||
// Since create_object is a static member, its constructor must be
|
||||
// called before main().
|
||||
// The constructor contains a call to instance(), thus ensuring that
|
||||
// instance() will be called before main().
|
||||
// The first time instance() is called (i.e., before main()) is the
|
||||
// latest point in program execution where the object of type T
|
||||
// can be created.
|
||||
// Thus, any call to instance() will auto-magically result in a call to
|
||||
// instance() before main(), unless already present.
|
||||
// Furthermore, since the instance() function contains the object, instead
|
||||
// of the singleton_default class containing a static instance of the
|
||||
// object, that object is guaranteed to be constructed (at the latest) in
|
||||
// the first call to instance(). This permits calls to instance() from
|
||||
// static code, even if that code is called before the file-scope objects
|
||||
// in this file have been initialized.
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
namespace container_detail {
|
||||
|
||||
// T must be: no-throw default constructible and no-throw destructible
|
||||
template <typename T>
|
||||
struct singleton_default
|
||||
{
|
||||
private:
|
||||
struct object_creator
|
||||
{
|
||||
// This constructor does nothing more than ensure that instance()
|
||||
// is called before main() begins, thus creating the static
|
||||
// T object before multithreading race issues can come up.
|
||||
object_creator() { singleton_default<T>::instance(); }
|
||||
inline void do_nothing() const { }
|
||||
};
|
||||
static object_creator create_object;
|
||||
|
||||
singleton_default();
|
||||
|
||||
public:
|
||||
typedef T object_type;
|
||||
|
||||
// If, at any point (in user code), singleton_default<T>::instance()
|
||||
// is called, then the following function is instantiated.
|
||||
static object_type & instance()
|
||||
{
|
||||
// This is the object that we return a reference to.
|
||||
// It is guaranteed to be created before main() begins because of
|
||||
// the next line.
|
||||
static object_type obj;
|
||||
|
||||
// The following line does nothing else than force the instantiation
|
||||
// of singleton_default<T>::create_object, whose constructor is
|
||||
// called before main() begins.
|
||||
create_object.do_nothing();
|
||||
|
||||
return obj;
|
||||
}
|
||||
};
|
||||
template <typename T>
|
||||
typename singleton_default<T>::object_creator
|
||||
singleton_default<T>::create_object;
|
||||
|
||||
} // namespace container_detail
|
||||
} // namespace container
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_CONTAINER_DETAIL_SINGLETON_DETAIL_HPP
|
@@ -15,11 +15,6 @@
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
#include <boost/container/container_fwd.hpp>
|
||||
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
#include <boost/intrusive/rbtree.hpp>
|
||||
#include <boost/container/detail/utilities.hpp>
|
||||
#include <boost/container/detail/iterators.hpp>
|
||||
#include <boost/container/detail/algorithms.hpp>
|
||||
@@ -28,7 +23,17 @@
|
||||
#include <boost/container/detail/pair.hpp>
|
||||
#include <boost/container/detail/type_traits.hpp>
|
||||
#include <boost/container/allocator_traits.hpp>
|
||||
//
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/intrusive/rbtree.hpp>
|
||||
#include <boost/intrusive/avltree.hpp>
|
||||
#include <boost/intrusive/splaytree.hpp>
|
||||
#include <boost/intrusive/sgtree.hpp>
|
||||
//
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
//
|
||||
#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
|
||||
#include <boost/container/detail/preprocessor.hpp>
|
||||
#endif
|
||||
@@ -86,7 +91,7 @@ struct tree_value_compare
|
||||
};
|
||||
|
||||
template<class VoidPointer>
|
||||
struct rbtree_hook
|
||||
struct intrusive_tree_hook
|
||||
{
|
||||
typedef typename container_detail::bi::make_set_base_hook
|
||||
< container_detail::bi::void_pointer<VoidPointer>
|
||||
@@ -112,20 +117,20 @@ struct rbtree_internal_data_type< std::pair<T1, T2> >
|
||||
|
||||
//The node to be store in the tree
|
||||
template <class T, class VoidPointer>
|
||||
struct rbtree_node
|
||||
: public rbtree_hook<VoidPointer>::type
|
||||
struct tree_node
|
||||
: public intrusive_tree_hook<VoidPointer>::type
|
||||
{
|
||||
private:
|
||||
//BOOST_COPYABLE_AND_MOVABLE(rbtree_node)
|
||||
rbtree_node();
|
||||
//BOOST_COPYABLE_AND_MOVABLE(tree_node)
|
||||
tree_node();
|
||||
|
||||
public:
|
||||
typedef typename rbtree_hook<VoidPointer>::type hook_type;
|
||||
typedef typename intrusive_tree_hook<VoidPointer>::type hook_type;
|
||||
|
||||
typedef T value_type;
|
||||
typedef typename rbtree_internal_data_type<T>::type internal_type;
|
||||
|
||||
typedef rbtree_node<T, VoidPointer> node_type;
|
||||
typedef tree_node<T, VoidPointer> node_type;
|
||||
|
||||
T &get_data()
|
||||
{
|
||||
@@ -210,8 +215,11 @@ class push_back_functor
|
||||
|
||||
namespace container_detail {
|
||||
|
||||
template<class A, class ValueCompare, boost::container::tree_type tree_type_value>
|
||||
struct intrusive_tree_type;
|
||||
|
||||
template<class A, class ValueCompare>
|
||||
struct intrusive_rbtree_type
|
||||
struct intrusive_tree_type<A, ValueCompare, boost::container::red_black_tree>
|
||||
{
|
||||
typedef typename boost::container::
|
||||
allocator_traits<A>::value_type value_type;
|
||||
@@ -219,13 +227,13 @@ struct intrusive_rbtree_type
|
||||
allocator_traits<A>::void_pointer void_pointer;
|
||||
typedef typename boost::container::
|
||||
allocator_traits<A>::size_type size_type;
|
||||
typedef typename container_detail::rbtree_node
|
||||
typedef typename container_detail::tree_node
|
||||
<value_type, void_pointer> node_type;
|
||||
typedef node_compare<ValueCompare, node_type> node_compare_type;
|
||||
typedef typename container_detail::bi::make_rbtree
|
||||
<node_type
|
||||
,container_detail::bi::compare<node_compare_type>
|
||||
,container_detail::bi::base_hook<typename rbtree_hook<void_pointer>::type>
|
||||
,container_detail::bi::base_hook<typename intrusive_tree_hook<void_pointer>::type>
|
||||
,container_detail::bi::constant_time_size<true>
|
||||
,container_detail::bi::size_type<size_type>
|
||||
>::type container_type;
|
||||
@@ -237,25 +245,25 @@ struct intrusive_rbtree_type
|
||||
namespace container_detail {
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class KeyCompare, class A>
|
||||
class rbtree
|
||||
class KeyCompare, class A,
|
||||
boost::container::tree_type tree_type_value>
|
||||
class tree
|
||||
: protected container_detail::node_alloc_holder
|
||||
< A
|
||||
, typename container_detail::intrusive_rbtree_type
|
||||
<A, tree_value_compare<Key, Value, KeyCompare, KeyOfValue>
|
||||
>::type
|
||||
, tree_value_compare<Key, Value, KeyCompare, KeyOfValue>
|
||||
, typename container_detail::intrusive_tree_type
|
||||
< A, tree_value_compare<Key, Value, KeyCompare, KeyOfValue>
|
||||
, tree_type_value>::type
|
||||
>
|
||||
{
|
||||
typedef tree_value_compare
|
||||
<Key, Value, KeyCompare, KeyOfValue> ValComp;
|
||||
typedef typename container_detail::intrusive_rbtree_type
|
||||
< A, ValComp>::type Icont;
|
||||
typedef typename container_detail::intrusive_tree_type
|
||||
< A, ValComp, tree_type_value>::type Icont;
|
||||
typedef container_detail::node_alloc_holder
|
||||
<A, Icont, ValComp> AllocHolder;
|
||||
<A, Icont> AllocHolder;
|
||||
typedef typename AllocHolder::NodePtr NodePtr;
|
||||
typedef rbtree < Key, Value, KeyOfValue
|
||||
, KeyCompare, A> ThisType;
|
||||
typedef tree < Key, Value, KeyOfValue
|
||||
, KeyCompare, A, tree_type_value> ThisType;
|
||||
typedef typename AllocHolder::NodeAlloc NodeAlloc;
|
||||
typedef typename AllocHolder::ValAlloc ValAlloc;
|
||||
typedef typename AllocHolder::Node Node;
|
||||
@@ -342,7 +350,7 @@ class rbtree
|
||||
Icont &m_icont;
|
||||
};
|
||||
|
||||
BOOST_COPYABLE_AND_MOVABLE(rbtree)
|
||||
BOOST_COPYABLE_AND_MOVABLE(tree)
|
||||
|
||||
public:
|
||||
|
||||
@@ -409,20 +417,20 @@ class rbtree
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
rbtree()
|
||||
tree()
|
||||
: AllocHolder(ValComp(key_compare()))
|
||||
{}
|
||||
|
||||
explicit rbtree(const key_compare& comp, const allocator_type& a = allocator_type())
|
||||
explicit tree(const key_compare& comp, const allocator_type& a = allocator_type())
|
||||
: AllocHolder(a, ValComp(comp))
|
||||
{}
|
||||
|
||||
explicit rbtree(const allocator_type& a)
|
||||
explicit tree(const allocator_type& a)
|
||||
: AllocHolder(a)
|
||||
{}
|
||||
|
||||
template <class InputIterator>
|
||||
rbtree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp,
|
||||
tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp,
|
||||
const allocator_type& a
|
||||
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
, typename container_detail::enable_if_c
|
||||
@@ -450,7 +458,7 @@ class rbtree
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
rbtree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp,
|
||||
tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp,
|
||||
const allocator_type& a
|
||||
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
, typename container_detail::enable_if_c
|
||||
@@ -479,7 +487,7 @@ class rbtree
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
rbtree( ordered_range_t, InputIterator first, InputIterator last
|
||||
tree( ordered_range_t, InputIterator first, InputIterator last
|
||||
, const key_compare& comp = key_compare(), const allocator_type& a = allocator_type()
|
||||
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
, typename container_detail::enable_if_c
|
||||
@@ -496,7 +504,7 @@ class rbtree
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
rbtree( ordered_range_t, InputIterator first, InputIterator last
|
||||
tree( ordered_range_t, InputIterator first, InputIterator last
|
||||
, const key_compare& comp = key_compare(), const allocator_type& a = allocator_type()
|
||||
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
, typename container_detail::enable_if_c
|
||||
@@ -513,25 +521,25 @@ class rbtree
|
||||
, container_detail::push_back_functor<Node, Icont>(this->icont()));
|
||||
}
|
||||
|
||||
rbtree(const rbtree& x)
|
||||
tree(const tree& x)
|
||||
: AllocHolder(x, x.value_comp())
|
||||
{
|
||||
this->icont().clone_from
|
||||
(x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc()));
|
||||
}
|
||||
|
||||
rbtree(BOOST_RV_REF(rbtree) x)
|
||||
tree(BOOST_RV_REF(tree) x)
|
||||
: AllocHolder(::boost::move(static_cast<AllocHolder&>(x)), x.value_comp())
|
||||
{}
|
||||
|
||||
rbtree(const rbtree& x, const allocator_type &a)
|
||||
tree(const tree& x, const allocator_type &a)
|
||||
: AllocHolder(a, x.value_comp())
|
||||
{
|
||||
this->icont().clone_from
|
||||
(x.icont(), typename AllocHolder::cloner(*this), Destroyer(this->node_alloc()));
|
||||
}
|
||||
|
||||
rbtree(BOOST_RV_REF(rbtree) x, const allocator_type &a)
|
||||
tree(BOOST_RV_REF(tree) x, const allocator_type &a)
|
||||
: AllocHolder(a, x.value_comp())
|
||||
{
|
||||
if(this->node_alloc() == x.node_alloc()){
|
||||
@@ -543,10 +551,10 @@ class rbtree
|
||||
}
|
||||
}
|
||||
|
||||
~rbtree()
|
||||
~tree()
|
||||
{} //AllocHolder clears the tree
|
||||
|
||||
rbtree& operator=(BOOST_COPY_ASSIGN_REF(rbtree) x)
|
||||
tree& operator=(BOOST_COPY_ASSIGN_REF(tree) x)
|
||||
{
|
||||
if (&x != this){
|
||||
NodeAlloc &this_alloc = this->get_stored_allocator();
|
||||
@@ -577,7 +585,7 @@ class rbtree
|
||||
return *this;
|
||||
}
|
||||
|
||||
rbtree& operator=(BOOST_RV_REF(rbtree) x)
|
||||
tree& operator=(BOOST_RV_REF(tree) x)
|
||||
{
|
||||
if (&x != this){
|
||||
NodeAlloc &this_alloc = this->get_stored_allocator();
|
||||
@@ -1001,70 +1009,29 @@ class rbtree
|
||||
return std::pair<const_iterator,const_iterator>
|
||||
(const_iterator(ret.first), const_iterator(ret.second));
|
||||
}
|
||||
|
||||
friend bool operator==(const tree& x, const tree& y)
|
||||
{ return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
|
||||
|
||||
friend bool operator<(const tree& x, const tree& y)
|
||||
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
|
||||
|
||||
friend bool operator!=(const tree& x, const tree& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const tree& x, const tree& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const tree& x, const tree& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const tree& x, const tree& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(tree& x, tree& y)
|
||||
{ x.swap(y); }
|
||||
};
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class KeyCompare, class A>
|
||||
inline bool
|
||||
operator==(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
|
||||
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y)
|
||||
{
|
||||
return x.size() == y.size() &&
|
||||
std::equal(x.begin(), x.end(), y.begin());
|
||||
}
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class KeyCompare, class A>
|
||||
inline bool
|
||||
operator<(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
|
||||
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y)
|
||||
{
|
||||
return std::lexicographical_compare(x.begin(), x.end(),
|
||||
y.begin(), y.end());
|
||||
}
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class KeyCompare, class A>
|
||||
inline bool
|
||||
operator!=(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
|
||||
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y) {
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class KeyCompare, class A>
|
||||
inline bool
|
||||
operator>(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
|
||||
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y) {
|
||||
return y < x;
|
||||
}
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class KeyCompare, class A>
|
||||
inline bool
|
||||
operator<=(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
|
||||
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y) {
|
||||
return !(y < x);
|
||||
}
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class KeyCompare, class A>
|
||||
inline bool
|
||||
operator>=(const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
|
||||
const rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y) {
|
||||
return !(x < y);
|
||||
}
|
||||
|
||||
|
||||
template <class Key, class Value, class KeyOfValue,
|
||||
class KeyCompare, class A>
|
||||
inline void
|
||||
swap(rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
|
||||
rbtree<Key,Value,KeyOfValue,KeyCompare,A>& y)
|
||||
{
|
||||
x.swap(y);
|
||||
}
|
||||
|
||||
} //namespace container_detail {
|
||||
} //namespace container {
|
||||
/*
|
||||
@@ -1073,7 +1040,7 @@ swap(rbtree<Key,Value,KeyOfValue,KeyCompare,A>& x,
|
||||
template <class K, class V, class KOV,
|
||||
class C, class A>
|
||||
struct has_trivial_destructor_after_move
|
||||
<boost::container::container_detail::rbtree<K, V, KOV, C, A> >
|
||||
<boost::container::container_detail::tree<K, V, KOV, C, A> >
|
||||
{
|
||||
static const bool value = has_trivial_destructor_after_move<A>::value && has_trivial_destructor_after_move<C>::value;
|
||||
};
|
||||
|
@@ -35,17 +35,6 @@ namespace boost {
|
||||
namespace container {
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
// Forward declarations of operators == and <, needed for friend declarations.
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
class flat_map;
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator==(const flat_map<Key,T,Compare,Allocator>& x,
|
||||
const flat_map<Key,T,Compare,Allocator>& y);
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<(const flat_map<Key,T,Compare,Allocator>& x,
|
||||
const flat_map<Key,T,Compare,Allocator>& y);
|
||||
|
||||
namespace container_detail{
|
||||
|
||||
@@ -62,7 +51,6 @@ static D force_copy(S s)
|
||||
|
||||
} //namespace container_detail{
|
||||
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//! A flat_map is a kind of associative container that supports unique keys (contains at
|
||||
@@ -842,14 +830,28 @@ class flat_map
|
||||
std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const
|
||||
{ return container_detail::force_copy<std::pair<const_iterator,const_iterator> >(m_flat_tree.equal_range(x)); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class K1, class T1, class C1, class A1>
|
||||
friend bool operator== (const flat_map<K1, T1, C1, A1>&,
|
||||
const flat_map<K1, T1, C1, A1>&);
|
||||
template <class K1, class T1, class C1, class A1>
|
||||
friend bool operator< (const flat_map<K1, T1, C1, A1>&,
|
||||
const flat_map<K1, T1, C1, A1>&);
|
||||
friend bool operator==(const flat_map& x, const flat_map& y)
|
||||
{ return x.m_flat_tree == y.m_flat_tree; }
|
||||
|
||||
friend bool operator<(const flat_map& x, const flat_map& y)
|
||||
{ return x.m_flat_tree < y.m_flat_tree; }
|
||||
|
||||
friend bool operator!=(const flat_map& x, const flat_map& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const flat_map& x, const flat_map& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const flat_map& x, const flat_map& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const flat_map& x, const flat_map& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(flat_map& x, flat_map& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
private:
|
||||
mapped_type &priv_subscript(const key_type& k)
|
||||
{
|
||||
@@ -875,41 +877,6 @@ class flat_map
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
};
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator==(const flat_map<Key,T,Compare,Allocator>& x,
|
||||
const flat_map<Key,T,Compare,Allocator>& y)
|
||||
{ return x.m_flat_tree == y.m_flat_tree; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<(const flat_map<Key,T,Compare,Allocator>& x,
|
||||
const flat_map<Key,T,Compare,Allocator>& y)
|
||||
{ return x.m_flat_tree < y.m_flat_tree; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator!=(const flat_map<Key,T,Compare,Allocator>& x,
|
||||
const flat_map<Key,T,Compare,Allocator>& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator>(const flat_map<Key,T,Compare,Allocator>& x,
|
||||
const flat_map<Key,T,Compare,Allocator>& y)
|
||||
{ return y < x; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<=(const flat_map<Key,T,Compare,Allocator>& x,
|
||||
const flat_map<Key,T,Compare,Allocator>& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator>=(const flat_map<Key,T,Compare,Allocator>& x,
|
||||
const flat_map<Key,T,Compare,Allocator>& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline void swap(flat_map<Key,T,Compare,Allocator>& x,
|
||||
flat_map<Key,T,Compare,Allocator>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
} //namespace container {
|
||||
@@ -924,17 +891,6 @@ struct has_trivial_destructor_after_move<boost::container::flat_map<K, T, C, All
|
||||
|
||||
namespace container {
|
||||
|
||||
// Forward declaration of operators < and ==, needed for friend declaration.
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
class flat_multimap;
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator==(const flat_multimap<Key,T,Compare,Allocator>& x,
|
||||
const flat_multimap<Key,T,Compare,Allocator>& y);
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<(const flat_multimap<Key,T,Compare,Allocator>& x,
|
||||
const flat_multimap<Key,T,Compare,Allocator>& y);
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//! A flat_multimap is a kind of associative container that supports equivalent keys
|
||||
@@ -1637,51 +1593,28 @@ class flat_multimap
|
||||
std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const
|
||||
{ return container_detail::force_copy<std::pair<const_iterator,const_iterator> >(m_flat_tree.equal_range(x)); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class K1, class T1, class C1, class A1>
|
||||
friend bool operator== (const flat_multimap<K1, T1, C1, A1>& x,
|
||||
const flat_multimap<K1, T1, C1, A1>& y);
|
||||
friend bool operator==(const flat_multimap& x, const flat_multimap& y)
|
||||
{ return x.m_flat_tree == y.m_flat_tree; }
|
||||
|
||||
template <class K1, class T1, class C1, class A1>
|
||||
friend bool operator< (const flat_multimap<K1, T1, C1, A1>& x,
|
||||
const flat_multimap<K1, T1, C1, A1>& y);
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
friend bool operator<(const flat_multimap& x, const flat_multimap& y)
|
||||
{ return x.m_flat_tree < y.m_flat_tree; }
|
||||
|
||||
friend bool operator!=(const flat_multimap& x, const flat_multimap& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const flat_multimap& x, const flat_multimap& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const flat_multimap& x, const flat_multimap& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const flat_multimap& x, const flat_multimap& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(flat_multimap& x, flat_multimap& y)
|
||||
{ x.swap(y); }
|
||||
};
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator==(const flat_multimap<Key,T,Compare,Allocator>& x,
|
||||
const flat_multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return x.m_flat_tree == y.m_flat_tree; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<(const flat_multimap<Key,T,Compare,Allocator>& x,
|
||||
const flat_multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return x.m_flat_tree < y.m_flat_tree; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator!=(const flat_multimap<Key,T,Compare,Allocator>& x,
|
||||
const flat_multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator>(const flat_multimap<Key,T,Compare,Allocator>& x,
|
||||
const flat_multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return y < x; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<=(const flat_multimap<Key,T,Compare,Allocator>& x,
|
||||
const flat_multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator>=(const flat_multimap<Key,T,Compare,Allocator>& x,
|
||||
const flat_multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline void swap(flat_multimap<Key,T,Compare,Allocator>& x, flat_multimap<Key,T,Compare,Allocator>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
}}
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
@@ -31,25 +31,6 @@
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
// Forward declarations of operators < and ==, needed for friend declaration.
|
||||
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> >
|
||||
#else
|
||||
template <class Key, class Compare, class Allocator>
|
||||
#endif
|
||||
class flat_set;
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator==(const flat_set<Key,Compare,Allocator>& x,
|
||||
const flat_set<Key,Compare,Allocator>& y);
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<(const flat_set<Key,Compare,Allocator>& x,
|
||||
const flat_set<Key,Compare,Allocator>& y);
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//! flat_set is a Sorted Associative Container that stores objects of type Key.
|
||||
//! It is also a Unique Associative Container, meaning that no two elements are the same.
|
||||
//!
|
||||
@@ -678,13 +659,28 @@ class flat_set
|
||||
std::pair<iterator,iterator> equal_range(const key_type& x)
|
||||
{ return m_flat_tree.equal_range(x); }
|
||||
|
||||
friend bool operator==(const flat_set& x, const flat_set& y)
|
||||
{ return x.m_flat_tree == y.m_flat_tree; }
|
||||
|
||||
friend bool operator<(const flat_set& x, const flat_set& y)
|
||||
{ return x.m_flat_tree < y.m_flat_tree; }
|
||||
|
||||
friend bool operator!=(const flat_set& x, const flat_set& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const flat_set& x, const flat_set& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const flat_set& x, const flat_set& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const flat_set& x, const flat_set& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(flat_set& x, flat_set& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class K1, class C1, class A1>
|
||||
friend bool operator== (const flat_set<K1,C1,A1>&, const flat_set<K1,C1,A1>&);
|
||||
|
||||
template <class K1, class C1, class A1>
|
||||
friend bool operator< (const flat_set<K1,C1,A1>&, const flat_set<K1,C1,A1>&);
|
||||
|
||||
private:
|
||||
template<class KeyType>
|
||||
std::pair<iterator, bool> priv_insert(BOOST_FWD_REF(KeyType) x)
|
||||
@@ -696,40 +692,6 @@ class flat_set
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
};
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator==(const flat_set<Key,Compare,Allocator>& x,
|
||||
const flat_set<Key,Compare,Allocator>& y)
|
||||
{ return x.m_flat_tree == y.m_flat_tree; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<(const flat_set<Key,Compare,Allocator>& x,
|
||||
const flat_set<Key,Compare,Allocator>& y)
|
||||
{ return x.m_flat_tree < y.m_flat_tree; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator!=(const flat_set<Key,Compare,Allocator>& x,
|
||||
const flat_set<Key,Compare,Allocator>& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator>(const flat_set<Key,Compare,Allocator>& x,
|
||||
const flat_set<Key,Compare,Allocator>& y)
|
||||
{ return y < x; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<=(const flat_set<Key,Compare,Allocator>& x,
|
||||
const flat_set<Key,Compare,Allocator>& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator>=(const flat_set<Key,Compare,Allocator>& x,
|
||||
const flat_set<Key,Compare,Allocator>& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline void swap(flat_set<Key,Compare,Allocator>& x, flat_set<Key,Compare,Allocator>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
} //namespace container {
|
||||
@@ -744,22 +706,6 @@ struct has_trivial_destructor_after_move<boost::container::flat_set<Key, C, Allo
|
||||
|
||||
namespace container {
|
||||
|
||||
// Forward declaration of operators < and ==, needed for friend declaration.
|
||||
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> >
|
||||
#else
|
||||
template <class Key, class Compare, class Allocator>
|
||||
#endif
|
||||
class flat_multiset;
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator==(const flat_multiset<Key,Compare,Allocator>& x,
|
||||
const flat_multiset<Key,Compare,Allocator>& y);
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<(const flat_multiset<Key,Compare,Allocator>& x,
|
||||
const flat_multiset<Key,Compare,Allocator>& y);
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//! flat_multiset is a Sorted Associative Container that stores objects of type Key.
|
||||
@@ -1353,13 +1299,28 @@ class flat_multiset
|
||||
std::pair<iterator,iterator> equal_range(const key_type& x)
|
||||
{ return m_flat_tree.equal_range(x); }
|
||||
|
||||
friend bool operator==(const flat_multiset& x, const flat_multiset& y)
|
||||
{ return x.m_flat_tree == y.m_flat_tree; }
|
||||
|
||||
friend bool operator<(const flat_multiset& x, const flat_multiset& y)
|
||||
{ return x.m_flat_tree < y.m_flat_tree; }
|
||||
|
||||
friend bool operator!=(const flat_multiset& x, const flat_multiset& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const flat_multiset& x, const flat_multiset& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const flat_multiset& x, const flat_multiset& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const flat_multiset& x, const flat_multiset& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(flat_multiset& x, flat_multiset& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class K1, class C1, class A1>
|
||||
friend bool operator== (const flat_multiset<K1,C1,A1>&,
|
||||
const flat_multiset<K1,C1,A1>&);
|
||||
template <class K1, class C1, class A1>
|
||||
friend bool operator< (const flat_multiset<K1,C1,A1>&,
|
||||
const flat_multiset<K1,C1,A1>&);
|
||||
private:
|
||||
template <class KeyType>
|
||||
iterator priv_insert(BOOST_FWD_REF(KeyType) x)
|
||||
@@ -1371,40 +1332,6 @@ class flat_multiset
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
};
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator==(const flat_multiset<Key,Compare,Allocator>& x,
|
||||
const flat_multiset<Key,Compare,Allocator>& y)
|
||||
{ return x.m_flat_tree == y.m_flat_tree; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<(const flat_multiset<Key,Compare,Allocator>& x,
|
||||
const flat_multiset<Key,Compare,Allocator>& y)
|
||||
{ return x.m_flat_tree < y.m_flat_tree; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator!=(const flat_multiset<Key,Compare,Allocator>& x,
|
||||
const flat_multiset<Key,Compare,Allocator>& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator>(const flat_multiset<Key,Compare,Allocator>& x,
|
||||
const flat_multiset<Key,Compare,Allocator>& y)
|
||||
{ return y < x; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<=(const flat_multiset<Key,Compare,Allocator>& x,
|
||||
const flat_multiset<Key,Compare,Allocator>& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator>=(const flat_multiset<Key,Compare,Allocator>& x,
|
||||
const flat_multiset<Key,Compare,Allocator>& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline void swap(flat_multiset<Key,Compare,Allocator>& x, flat_multiset<Key,Compare,Allocator>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
} //namespace container {
|
||||
|
@@ -1214,7 +1214,42 @@ class list
|
||||
//!
|
||||
//! <b>Note</b>: Iterators and references are not invalidated
|
||||
void reverse() BOOST_CONTAINER_NOEXCEPT
|
||||
{ this->icont().reverse(); }
|
||||
{ this->icont().reverse(); }
|
||||
|
||||
friend bool operator==(const list& x, const list& y)
|
||||
{
|
||||
if(x.size() != y.size()){
|
||||
return false;
|
||||
}
|
||||
typedef typename list::const_iterator const_iterator;
|
||||
const_iterator end1 = x.end();
|
||||
|
||||
const_iterator i1 = x.begin();
|
||||
const_iterator i2 = y.begin();
|
||||
while (i1 != end1 && *i1 == *i2) {
|
||||
++i1;
|
||||
++i2;
|
||||
}
|
||||
return i1 == end1;
|
||||
}
|
||||
|
||||
friend bool operator<(const list& x, const list& y)
|
||||
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
|
||||
|
||||
friend bool operator!=(const list& x, const list& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const list& x, const list& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const list& x, const list& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const list& x, const list& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(list& x, list& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
private:
|
||||
@@ -1307,61 +1342,6 @@ class list
|
||||
|
||||
};
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool operator==(const list<T,Allocator>& x, const list<T,Allocator>& y)
|
||||
{
|
||||
if(x.size() != y.size()){
|
||||
return false;
|
||||
}
|
||||
typedef typename list<T,Allocator>::const_iterator const_iterator;
|
||||
const_iterator end1 = x.end();
|
||||
|
||||
const_iterator i1 = x.begin();
|
||||
const_iterator i2 = y.begin();
|
||||
while (i1 != end1 && *i1 == *i2) {
|
||||
++i1;
|
||||
++i2;
|
||||
}
|
||||
return i1 == end1;
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool operator<(const list<T,Allocator>& x,
|
||||
const list<T,Allocator>& y)
|
||||
{
|
||||
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool operator!=(const list<T,Allocator>& x, const list<T,Allocator>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool operator>(const list<T,Allocator>& x, const list<T,Allocator>& y)
|
||||
{
|
||||
return y < x;
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool operator<=(const list<T,Allocator>& x, const list<T,Allocator>& y)
|
||||
{
|
||||
return !(y < x);
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool operator>=(const list<T,Allocator>& x, const list<T,Allocator>& y)
|
||||
{
|
||||
return !(x < y);
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline void swap(list<T, Allocator>& x, list<T, Allocator>& y)
|
||||
{
|
||||
x.swap(y);
|
||||
}
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
} //namespace container {
|
||||
|
@@ -39,17 +39,6 @@
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
// Forward declarations of operators == and <, needed for friend declarations.
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator==(const map<Key,T,Compare,Allocator>& x,
|
||||
const map<Key,T,Compare,Allocator>& y);
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<(const map<Key,T,Compare,Allocator>& x,
|
||||
const map<Key,T,Compare,Allocator>& y);
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//! A map is a kind of associative container that supports unique keys (contains at
|
||||
//! most one of each key value) and provides for fast retrieval of values of another
|
||||
//! type T based on the keys. The map class supports bidirectional iterators.
|
||||
@@ -65,7 +54,7 @@ inline bool operator<(const map<Key,T,Compare,Allocator>& x,
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator< std::pair< const Key, T> > >
|
||||
#else
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
template <class Key, class T, class Compare, class Allocator, tree_type tree_type_value>
|
||||
#endif
|
||||
class map
|
||||
{
|
||||
@@ -74,8 +63,8 @@ class map
|
||||
BOOST_COPYABLE_AND_MOVABLE(map)
|
||||
|
||||
typedef std::pair<const Key, T> value_type_impl;
|
||||
typedef container_detail::rbtree
|
||||
<Key, value_type_impl, container_detail::select1st<value_type_impl>, Compare, Allocator> tree_t;
|
||||
typedef container_detail::tree
|
||||
<Key, value_type_impl, container_detail::select1st<value_type_impl>, Compare, Allocator, tree_type_value> tree_t;
|
||||
typedef container_detail::pair <Key, T> movable_value_type_impl;
|
||||
typedef container_detail::tree_value_compare
|
||||
< Key, value_type_impl, Compare, container_detail::select1st<value_type_impl>
|
||||
@@ -755,13 +744,28 @@ class map
|
||||
std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const
|
||||
{ return m_tree.equal_range(x); }
|
||||
|
||||
friend bool operator==(const map& x, const map& y)
|
||||
{ return x.m_tree == y.m_tree; }
|
||||
|
||||
friend bool operator<(const map& x, const map& y)
|
||||
{ return x.m_tree < y.m_tree; }
|
||||
|
||||
friend bool operator!=(const map& x, const map& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const map& x, const map& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const map& x, const map& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const map& x, const map& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(map& x, map& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class K1, class T1, class C1, class A1>
|
||||
friend bool operator== (const map<K1, T1, C1, A1>&,
|
||||
const map<K1, T1, C1, A1>&);
|
||||
template <class K1, class T1, class C1, class A1>
|
||||
friend bool operator< (const map<K1, T1, C1, A1>&,
|
||||
const map<K1, T1, C1, A1>&);
|
||||
private:
|
||||
mapped_type& priv_subscript(const key_type &k)
|
||||
{
|
||||
@@ -793,52 +797,9 @@ class map
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
};
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator==(const map<Key,T,Compare,Allocator>& x,
|
||||
const map<Key,T,Compare,Allocator>& y)
|
||||
{ return x.m_tree == y.m_tree; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<(const map<Key,T,Compare,Allocator>& x,
|
||||
const map<Key,T,Compare,Allocator>& y)
|
||||
{ return x.m_tree < y.m_tree; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator!=(const map<Key,T,Compare,Allocator>& x,
|
||||
const map<Key,T,Compare,Allocator>& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator>(const map<Key,T,Compare,Allocator>& x,
|
||||
const map<Key,T,Compare,Allocator>& y)
|
||||
{ return y < x; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<=(const map<Key,T,Compare,Allocator>& x,
|
||||
const map<Key,T,Compare,Allocator>& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator>=(const map<Key,T,Compare,Allocator>& x,
|
||||
const map<Key,T,Compare,Allocator>& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline void swap(map<Key,T,Compare,Allocator>& x, map<Key,T,Compare,Allocator>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
// Forward declaration of operators < and ==, needed for friend declaration.
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator==(const multimap<Key,T,Compare,Allocator>& x,
|
||||
const multimap<Key,T,Compare,Allocator>& y);
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<(const multimap<Key,T,Compare,Allocator>& x,
|
||||
const multimap<Key,T,Compare,Allocator>& y);
|
||||
|
||||
} //namespace container {
|
||||
|
||||
//!has_trivial_destructor_after_move<> == true_type
|
||||
@@ -869,7 +830,7 @@ namespace container {
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator< std::pair< const Key, T> > >
|
||||
#else
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
template <class Key, class T, class Compare, class Allocator, tree_type tree_type_value>
|
||||
#endif
|
||||
class multimap
|
||||
{
|
||||
@@ -878,8 +839,8 @@ class multimap
|
||||
BOOST_COPYABLE_AND_MOVABLE(multimap)
|
||||
|
||||
typedef std::pair<const Key, T> value_type_impl;
|
||||
typedef container_detail::rbtree
|
||||
<Key, value_type_impl, container_detail::select1st<value_type_impl>, Compare, Allocator> tree_t;
|
||||
typedef container_detail::tree
|
||||
<Key, value_type_impl, container_detail::select1st<value_type_impl>, Compare, Allocator, tree_type_value> tree_t;
|
||||
typedef container_detail::pair <Key, T> movable_value_type_impl;
|
||||
typedef container_detail::tree_value_compare
|
||||
< Key, value_type_impl, Compare, container_detail::select1st<value_type_impl>
|
||||
@@ -1463,51 +1424,28 @@ class multimap
|
||||
std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const
|
||||
{ return m_tree.equal_range(x); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class K1, class T1, class C1, class A1>
|
||||
friend bool operator== (const multimap<K1, T1, C1, A1>& x,
|
||||
const multimap<K1, T1, C1, A1>& y);
|
||||
friend bool operator==(const multimap& x, const multimap& y)
|
||||
{ return x.m_tree == y.m_tree; }
|
||||
|
||||
friend bool operator<(const multimap& x, const multimap& y)
|
||||
{ return x.m_tree < y.m_tree; }
|
||||
|
||||
template <class K1, class T1, class C1, class A1>
|
||||
friend bool operator< (const multimap<K1, T1, C1, A1>& x,
|
||||
const multimap<K1, T1, C1, A1>& y);
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
friend bool operator!=(const multimap& x, const multimap& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const multimap& x, const multimap& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const multimap& x, const multimap& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const multimap& x, const multimap& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(multimap& x, multimap& y)
|
||||
{ x.swap(y); }
|
||||
};
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator==(const multimap<Key,T,Compare,Allocator>& x,
|
||||
const multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return x.m_tree == y.m_tree; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<(const multimap<Key,T,Compare,Allocator>& x,
|
||||
const multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return x.m_tree < y.m_tree; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator!=(const multimap<Key,T,Compare,Allocator>& x,
|
||||
const multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator>(const multimap<Key,T,Compare,Allocator>& x,
|
||||
const multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return y < x; }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator<=(const multimap<Key,T,Compare,Allocator>& x,
|
||||
const multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline bool operator>=(const multimap<Key,T,Compare,Allocator>& x,
|
||||
const multimap<Key,T,Compare,Allocator>& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline void swap(multimap<Key,T,Compare,Allocator>& x, multimap<Key,T,Compare,Allocator>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
} //namespace container {
|
||||
|
346
include/boost/container/node_allocator.hpp
Normal file
346
include/boost/container/node_allocator.hpp
Normal file
@@ -0,0 +1,346 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2008-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_POOLED_NODE_ALLOCATOR_HPP
|
||||
#define BOOST_CONTAINER_POOLED_NODE_ALLOCATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
#include <boost/container/container_fwd.hpp>
|
||||
#include <boost/container/throw_exception.hpp>
|
||||
#include <boost/container/detail/node_pool.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/container/detail/multiallocation_chain.hpp>
|
||||
#include <boost/container/detail/alloc_lib_auto_link.hpp>
|
||||
#include <boost/container/detail/singleton.hpp>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
//!An STL node allocator that uses a modified DlMalloc as memory
|
||||
//!source.
|
||||
//!
|
||||
//!This node allocator shares a segregated storage between all instances
|
||||
//!of node_allocator with equal sizeof(T).
|
||||
//!
|
||||
//!NodesPerBlock is the number of nodes allocated at once when the allocator
|
||||
//!runs out of nodes
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template
|
||||
< class T
|
||||
, std::size_t NodesPerBlock = NodeAlloc_nodes_per_block>
|
||||
#else
|
||||
template
|
||||
< class T
|
||||
, std::size_t NodesPerBlock
|
||||
, std::size_t Version>
|
||||
#endif
|
||||
class node_allocator
|
||||
{
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
//! If Version is 1, the allocator is a STL conforming allocator. If Version is 2,
|
||||
//! the allocator offers advanced expand in place and burst allocation capabilities.
|
||||
public:
|
||||
typedef unsigned int allocation_type;
|
||||
typedef node_allocator<T, NodesPerBlock, Version> self_t;
|
||||
|
||||
static const std::size_t nodes_per_block = NodesPerBlock;
|
||||
|
||||
BOOST_STATIC_ASSERT((Version <=2));
|
||||
#endif
|
||||
|
||||
public:
|
||||
//-------
|
||||
typedef T value_type;
|
||||
typedef T * pointer;
|
||||
typedef const T * const_pointer;
|
||||
typedef typename ::boost::container::
|
||||
container_detail::unvoid<T>::type & reference;
|
||||
typedef const typename ::boost::container::
|
||||
container_detail::unvoid<T>::type & const_reference;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
typedef boost::container::container_detail::
|
||||
version_type<self_t, Version> version;
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
typedef boost::container::container_detail::
|
||||
basic_multiallocation_chain<void*> multiallocation_chain_void;
|
||||
typedef boost::container::container_detail::
|
||||
transform_multiallocation_chain
|
||||
<multiallocation_chain_void, T> multiallocation_chain;
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//!Obtains node_allocator from
|
||||
//!node_allocator
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{
|
||||
typedef node_allocator< T2, NodesPerBlock
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
, Version
|
||||
#endif
|
||||
> other;
|
||||
};
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
private:
|
||||
//!Not assignable from related node_allocator
|
||||
template<class T2, std::size_t N2>
|
||||
node_allocator& operator=
|
||||
(const node_allocator<T2, N2>&);
|
||||
|
||||
//!Not assignable from other node_allocator
|
||||
node_allocator& operator=(const node_allocator&);
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
public:
|
||||
|
||||
//!Default constructor
|
||||
node_allocator() BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!Copy constructor from other node_allocator.
|
||||
node_allocator(const node_allocator &) BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!Copy constructor from related node_allocator.
|
||||
template<class T2>
|
||||
node_allocator
|
||||
(const node_allocator<T2, NodesPerBlock
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
, Version
|
||||
#endif
|
||||
> &) BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!Destructor
|
||||
~node_allocator() BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!Returns the number of elements that could be allocated.
|
||||
//!Never throws
|
||||
size_type max_size() const
|
||||
{ return size_type(-1)/sizeof(T); }
|
||||
|
||||
//!Allocate memory for an array of count elements.
|
||||
//!Throws std::bad_alloc if there is no enough memory
|
||||
pointer allocate(size_type count, const void * = 0)
|
||||
{
|
||||
if(count > this->max_size())
|
||||
boost::container::throw_bad_alloc();
|
||||
|
||||
if(Version == 1 && count == 1){
|
||||
typedef container_detail::shared_node_pool
|
||||
<sizeof(T), NodesPerBlock> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
return pointer(static_cast<T*>(singleton_t::instance().allocate_node()));
|
||||
}
|
||||
else{
|
||||
void *ret = boost_cont_malloc(count*sizeof(T));
|
||||
if(!ret)
|
||||
boost::container::throw_bad_alloc();
|
||||
return static_cast<pointer>(ret);
|
||||
}
|
||||
}
|
||||
|
||||
//!Deallocate allocated memory.
|
||||
//!Never throws
|
||||
void deallocate(const pointer &ptr, size_type count) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
(void)count;
|
||||
if(Version == 1 && count == 1){
|
||||
typedef container_detail::shared_node_pool
|
||||
<sizeof(T), NodesPerBlock> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
singleton_t::instance().deallocate_node(ptr);
|
||||
}
|
||||
else{
|
||||
boost_cont_free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
//!Deallocates all free blocks of the pool
|
||||
static void deallocate_free_blocks() BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
typedef container_detail::shared_node_pool
|
||||
<sizeof(T), NodesPerBlock> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
singleton_t::instance().deallocate_free_blocks();
|
||||
}
|
||||
|
||||
std::pair<pointer, bool>
|
||||
allocation_command(allocation_type command,
|
||||
size_type limit_size,
|
||||
size_type preferred_size,
|
||||
size_type &received_size, pointer reuse = pointer())
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
std::pair<pointer, bool> ret =
|
||||
priv_allocation_command(command, limit_size, preferred_size, received_size, reuse);
|
||||
if(!ret.first && !(command & BOOST_CONTAINER_NOTHROW_ALLOCATION))
|
||||
boost::container::throw_bad_alloc();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//!Returns maximum the number of objects the previously allocated memory
|
||||
//!pointed by p can hold.
|
||||
size_type size(pointer p) const BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
return boost_cont_size(p);
|
||||
}
|
||||
|
||||
//!Allocates just one object. Memory allocated with this function
|
||||
//!must be deallocated only with deallocate_one().
|
||||
//!Throws bad_alloc if there is no enough memory
|
||||
pointer allocate_one()
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
typedef container_detail::shared_node_pool
|
||||
<sizeof(T), NodesPerBlock> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
return (pointer)singleton_t::instance().allocate_node();
|
||||
}
|
||||
|
||||
//!Allocates many elements of size == 1.
|
||||
//!Elements must be individually deallocated with deallocate_one()
|
||||
void allocate_individual(std::size_t num_elements, multiallocation_chain &chain)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
typedef container_detail::shared_node_pool
|
||||
<sizeof(T), NodesPerBlock> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
typename shared_pool_t::multiallocation_chain ch;
|
||||
singleton_t::instance().allocate_nodes(num_elements, ch);
|
||||
chain.incorporate_after(chain.before_begin(), (T*)&*ch.begin(), (T*)&*ch.last(), ch.size());
|
||||
}
|
||||
|
||||
//!Deallocates memory previously allocated with allocate_one().
|
||||
//!You should never use deallocate_one to deallocate memory allocated
|
||||
//!with other functions different from allocate_one(). Never throws
|
||||
void deallocate_one(pointer p) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
typedef container_detail::shared_node_pool
|
||||
<sizeof(T), NodesPerBlock> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
singleton_t::instance().deallocate_node(p);
|
||||
}
|
||||
|
||||
void deallocate_individual(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
typedef container_detail::shared_node_pool
|
||||
<sizeof(T), NodesPerBlock> shared_pool_t;
|
||||
typedef container_detail::singleton_default<shared_pool_t> singleton_t;
|
||||
typename shared_pool_t::multiallocation_chain ch(&*chain.begin(), &*chain.last(), chain.size());
|
||||
singleton_t::instance().deallocate_nodes(ch);
|
||||
}
|
||||
|
||||
//!Allocates many elements of size elem_size.
|
||||
//!Elements must be individually deallocated with deallocate()
|
||||
void allocate_many(size_type elem_size, std::size_t n_elements, multiallocation_chain &chain)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
boost_cont_memchain ch;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&ch);
|
||||
if(!boost_cont_multialloc_nodes(n_elements, elem_size*sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch)){
|
||||
boost::container::throw_bad_alloc();
|
||||
}
|
||||
chain.incorporate_after( chain.before_begin()
|
||||
, (T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch)
|
||||
, (T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch)
|
||||
, BOOST_CONTAINER_MEMCHAIN_SIZE(&ch));
|
||||
}
|
||||
|
||||
//!Allocates n_elements elements, each one of size elem_sizes[i]
|
||||
//!Elements must be individually deallocated with deallocate()
|
||||
void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
boost_cont_memchain ch;
|
||||
boost_cont_multialloc_arrays(n_elements, elem_sizes, sizeof(T), DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &ch);
|
||||
if(BOOST_CONTAINER_MEMCHAIN_EMPTY(&ch)){
|
||||
boost::container::throw_bad_alloc();
|
||||
}
|
||||
chain.incorporate_after( chain.before_begin()
|
||||
, (T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch)
|
||||
, (T*)BOOST_CONTAINER_MEMCHAIN_LASTMEM(&ch)
|
||||
, BOOST_CONTAINER_MEMCHAIN_SIZE(&ch));
|
||||
}
|
||||
|
||||
void deallocate_many(multiallocation_chain &chain) BOOST_CONTAINER_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT(( Version > 1 ));
|
||||
void *first = &*chain.begin();
|
||||
void *last = &*chain.last();
|
||||
size_t num = chain.size();
|
||||
boost_cont_memchain ch;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&ch, first, last, num);
|
||||
boost_cont_multidealloc(&ch);
|
||||
}
|
||||
|
||||
//!Swaps allocators. Does not throw. If each allocator is placed in a
|
||||
//!different memory segment, the result is undefined.
|
||||
friend void swap(self_t &, self_t &) BOOST_CONTAINER_NOEXCEPT
|
||||
{}
|
||||
|
||||
//!An allocator always compares to true, as memory allocated with one
|
||||
//!instance can be deallocated by another instance
|
||||
friend bool operator==(const node_allocator &, const node_allocator &) BOOST_CONTAINER_NOEXCEPT
|
||||
{ return true; }
|
||||
|
||||
//!An allocator always compares to false, as memory allocated with one
|
||||
//!instance can be deallocated by another instance
|
||||
friend bool operator!=(const node_allocator &, const node_allocator &) BOOST_CONTAINER_NOEXCEPT
|
||||
{ return false; }
|
||||
|
||||
private:
|
||||
std::pair<pointer, bool> priv_allocation_command
|
||||
(allocation_type command, std::size_t limit_size
|
||||
,std::size_t preferred_size,std::size_t &received_size, void *reuse_ptr)
|
||||
{
|
||||
boost_cont_command_ret_t ret = {0 , 0};
|
||||
if(limit_size > this->max_size() || preferred_size > this->max_size()){
|
||||
//ret.first = 0;
|
||||
return std::pair<pointer, bool>(pointer(), false);
|
||||
}
|
||||
std::size_t l_size = limit_size*sizeof(T);
|
||||
std::size_t p_size = preferred_size*sizeof(T);
|
||||
std::size_t r_size;
|
||||
{
|
||||
ret = boost_cont_allocation_command(command, sizeof(T), l_size, p_size, &r_size, reuse_ptr);
|
||||
}
|
||||
received_size = r_size/sizeof(T);
|
||||
return std::pair<pointer, bool>(static_cast<pointer>(ret.first), !!ret.second);
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_POOLED_NODE_ALLOCATOR_HPP
|
@@ -35,17 +35,6 @@
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
// Forward declarations of operators < and ==, needed for friend declaration.
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator==(const set<Key,Compare,Allocator>& x,
|
||||
const set<Key,Compare,Allocator>& y);
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<(const set<Key,Compare,Allocator>& x,
|
||||
const set<Key,Compare,Allocator>& y);
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//! A set is a kind of associative container that supports unique keys (contains at
|
||||
//! most one of each key value) and provides for fast retrieval of the keys themselves.
|
||||
//! Class set supports bidirectional iterators.
|
||||
@@ -56,15 +45,15 @@ inline bool operator<(const set<Key,Compare,Allocator>& x,
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> >
|
||||
#else
|
||||
template <class Key, class Compare, class Allocator>
|
||||
template <class Key, class Compare, class Allocator, tree_type tree_type_value>
|
||||
#endif
|
||||
class set
|
||||
{
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
private:
|
||||
BOOST_COPYABLE_AND_MOVABLE(set)
|
||||
typedef container_detail::rbtree<Key, Key,
|
||||
container_detail::identity<Key>, Compare, Allocator> tree_t;
|
||||
typedef container_detail::tree
|
||||
< Key, Key, container_detail::identity<Key>, Compare, Allocator, tree_type_value> tree_t;
|
||||
tree_t m_tree; // red-black tree representing set
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
@@ -600,13 +589,28 @@ class set
|
||||
std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
|
||||
{ return m_tree.equal_range(x); }
|
||||
|
||||
friend bool operator==(const set& x, const set& y)
|
||||
{ return x.m_tree == y.m_tree; }
|
||||
|
||||
friend bool operator<(const set& x, const set& y)
|
||||
{ return x.m_tree < y.m_tree; }
|
||||
|
||||
friend bool operator!=(const set& x, const set& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const set& x, const set& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const set& x, const set& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const set& x, const set& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(set& x, set& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class K1, class C1, class A1>
|
||||
friend bool operator== (const set<K1,C1,A1>&, const set<K1,C1,A1>&);
|
||||
|
||||
template <class K1, class C1, class A1>
|
||||
friend bool operator< (const set<K1,C1,A1>&, const set<K1,C1,A1>&);
|
||||
|
||||
private:
|
||||
template <class KeyType>
|
||||
std::pair<iterator, bool> priv_insert(BOOST_FWD_REF(KeyType) x)
|
||||
@@ -618,40 +622,6 @@ class set
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
};
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator==(const set<Key,Compare,Allocator>& x,
|
||||
const set<Key,Compare,Allocator>& y)
|
||||
{ return x.m_tree == y.m_tree; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<(const set<Key,Compare,Allocator>& x,
|
||||
const set<Key,Compare,Allocator>& y)
|
||||
{ return x.m_tree < y.m_tree; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator!=(const set<Key,Compare,Allocator>& x,
|
||||
const set<Key,Compare,Allocator>& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator>(const set<Key,Compare,Allocator>& x,
|
||||
const set<Key,Compare,Allocator>& y)
|
||||
{ return y < x; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<=(const set<Key,Compare,Allocator>& x,
|
||||
const set<Key,Compare,Allocator>& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator>=(const set<Key,Compare,Allocator>& x,
|
||||
const set<Key,Compare,Allocator>& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline void swap(set<Key,Compare,Allocator>& x, set<Key,Compare,Allocator>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
} //namespace container {
|
||||
@@ -666,15 +636,6 @@ struct has_trivial_destructor_after_move<boost::container::set<Key, C, Allocator
|
||||
|
||||
namespace container {
|
||||
|
||||
// Forward declaration of operators < and ==, needed for friend declaration.
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator==(const multiset<Key,Compare,Allocator>& x,
|
||||
const multiset<Key,Compare,Allocator>& y);
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<(const multiset<Key,Compare,Allocator>& x,
|
||||
const multiset<Key,Compare,Allocator>& y);
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//! A multiset is a kind of associative container that supports equivalent keys
|
||||
@@ -687,15 +648,15 @@ inline bool operator<(const multiset<Key,Compare,Allocator>& x,
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> >
|
||||
#else
|
||||
template <class Key, class Compare, class Allocator>
|
||||
template <class Key, class Compare, class Allocator, tree_type tree_type_value>
|
||||
#endif
|
||||
class multiset
|
||||
{
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
private:
|
||||
BOOST_COPYABLE_AND_MOVABLE(multiset)
|
||||
typedef container_detail::rbtree<Key, Key,
|
||||
container_detail::identity<Key>, Compare, Allocator> tree_t;
|
||||
typedef container_detail::tree
|
||||
<Key, Key,container_detail::identity<Key>, Compare, Allocator, tree_type_value> tree_t;
|
||||
tree_t m_tree; // red-black tree representing multiset
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
@@ -1221,13 +1182,28 @@ class multiset
|
||||
std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
|
||||
{ return m_tree.equal_range(x); }
|
||||
|
||||
friend bool operator==(const multiset& x, const multiset& y)
|
||||
{ return x.m_tree == y.m_tree; }
|
||||
|
||||
friend bool operator<(const multiset& x, const multiset& y)
|
||||
{ return x.m_tree < y.m_tree; }
|
||||
|
||||
friend bool operator!=(const multiset& x, const multiset& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const multiset& x, const multiset& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const multiset& x, const multiset& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const multiset& x, const multiset& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(multiset& x, multiset& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
template <class K1, class C1, class A1>
|
||||
friend bool operator== (const multiset<K1,C1,A1>&,
|
||||
const multiset<K1,C1,A1>&);
|
||||
template <class K1, class C1, class A1>
|
||||
friend bool operator< (const multiset<K1,C1,A1>&,
|
||||
const multiset<K1,C1,A1>&);
|
||||
private:
|
||||
template <class KeyType>
|
||||
iterator priv_insert(BOOST_FWD_REF(KeyType) x)
|
||||
@@ -1240,40 +1216,6 @@ class multiset
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
};
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator==(const multiset<Key,Compare,Allocator>& x,
|
||||
const multiset<Key,Compare,Allocator>& y)
|
||||
{ return x.m_tree == y.m_tree; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<(const multiset<Key,Compare,Allocator>& x,
|
||||
const multiset<Key,Compare,Allocator>& y)
|
||||
{ return x.m_tree < y.m_tree; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator!=(const multiset<Key,Compare,Allocator>& x,
|
||||
const multiset<Key,Compare,Allocator>& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator>(const multiset<Key,Compare,Allocator>& x,
|
||||
const multiset<Key,Compare,Allocator>& y)
|
||||
{ return y < x; }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator<=(const multiset<Key,Compare,Allocator>& x,
|
||||
const multiset<Key,Compare,Allocator>& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline bool operator>=(const multiset<Key,Compare,Allocator>& x,
|
||||
const multiset<Key,Compare,Allocator>& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
template <class Key, class Compare, class Allocator>
|
||||
inline void swap(multiset<Key,Compare,Allocator>& x, multiset<Key,Compare,Allocator>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
} //namespace container {
|
||||
|
@@ -1423,6 +1423,44 @@ class slist
|
||||
void splice(const_iterator p, BOOST_RV_REF(slist) x, const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
|
||||
{ this->splice(p, static_cast<slist&>(x), first, last); }
|
||||
|
||||
friend bool operator==(const slist& x, const slist& y)
|
||||
{
|
||||
if(x.size() != y.size()){
|
||||
return false;
|
||||
}
|
||||
typedef typename slist<T,Allocator>::const_iterator const_iterator;
|
||||
const_iterator end1 = x.end();
|
||||
|
||||
const_iterator i1 = x.begin();
|
||||
const_iterator i2 = y.begin();
|
||||
while (i1 != end1 && *i1 == *i2){
|
||||
++i1;
|
||||
++i2;
|
||||
}
|
||||
return i1 == end1;
|
||||
}
|
||||
|
||||
friend bool operator<(const slist& x, const slist& y)
|
||||
{
|
||||
return std::lexicographical_compare
|
||||
(x.begin(), x.end(), y.begin(), y.end());
|
||||
}
|
||||
|
||||
friend bool operator!=(const slist& x, const slist& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator>(const slist& x, const slist& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const slist& x, const slist& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const slist& x, const slist& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(slist& x, slist& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
private:
|
||||
|
||||
@@ -1508,57 +1546,6 @@ class slist
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
};
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool
|
||||
operator==(const slist<T,Allocator>& x, const slist<T,Allocator>& y)
|
||||
{
|
||||
if(x.size() != y.size()){
|
||||
return false;
|
||||
}
|
||||
typedef typename slist<T,Allocator>::const_iterator const_iterator;
|
||||
const_iterator end1 = x.end();
|
||||
|
||||
const_iterator i1 = x.begin();
|
||||
const_iterator i2 = y.begin();
|
||||
while (i1 != end1 && *i1 == *i2){
|
||||
++i1;
|
||||
++i2;
|
||||
}
|
||||
return i1 == end1;
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool
|
||||
operator<(const slist<T,Allocator>& sL1, const slist<T,Allocator>& sL2)
|
||||
{
|
||||
return std::lexicographical_compare
|
||||
(sL1.begin(), sL1.end(), sL2.begin(), sL2.end());
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool
|
||||
operator!=(const slist<T,Allocator>& sL1, const slist<T,Allocator>& sL2)
|
||||
{ return !(sL1 == sL2); }
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool
|
||||
operator>(const slist<T,Allocator>& sL1, const slist<T,Allocator>& sL2)
|
||||
{ return sL2 < sL1; }
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool
|
||||
operator<=(const slist<T,Allocator>& sL1, const slist<T,Allocator>& sL2)
|
||||
{ return !(sL2 < sL1); }
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool
|
||||
operator>=(const slist<T,Allocator>& sL1, const slist<T,Allocator>& sL2)
|
||||
{ return !(sL1 < sL2); }
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline void swap(slist<T,Allocator>& x, slist<T,Allocator>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
}}
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
@@ -1510,8 +1510,28 @@ class stable_vector
|
||||
void clear() BOOST_CONTAINER_NOEXCEPT
|
||||
{ this->erase(this->cbegin(),this->cend()); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
friend bool operator==(const stable_vector& x,const stable_vector& y)
|
||||
{ return x.size()==y.size()&&std::equal(x.begin(),x.end(),y.begin()); }
|
||||
|
||||
friend bool operator< (const stable_vector& x,const stable_vector& y)
|
||||
{ return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); }
|
||||
|
||||
friend bool operator!=(const stable_vector& x,const stable_vector& y)
|
||||
{ return !(x==y); }
|
||||
|
||||
friend bool operator> (const stable_vector& x,const stable_vector& y)
|
||||
{ return y<x; }
|
||||
|
||||
friend bool operator>=(const stable_vector& x,const stable_vector& y)
|
||||
{ return !(x<y); }
|
||||
|
||||
friend bool operator<=(const stable_vector& x,const stable_vector& y)
|
||||
{ return !(x>y); }
|
||||
|
||||
friend void swap(stable_vector& x,stable_vector& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
private:
|
||||
|
||||
class insert_rollback
|
||||
@@ -1839,50 +1859,6 @@ class stable_vector
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
};
|
||||
|
||||
template <typename T,typename Allocator>
|
||||
bool operator==(const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
|
||||
{
|
||||
return x.size()==y.size()&&std::equal(x.begin(),x.end(),y.begin());
|
||||
}
|
||||
|
||||
template <typename T,typename Allocator>
|
||||
bool operator< (const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
|
||||
{
|
||||
return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
|
||||
}
|
||||
|
||||
template <typename T,typename Allocator>
|
||||
bool operator!=(const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
|
||||
{
|
||||
return !(x==y);
|
||||
}
|
||||
|
||||
template <typename T,typename Allocator>
|
||||
bool operator> (const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
|
||||
{
|
||||
return y<x;
|
||||
}
|
||||
|
||||
template <typename T,typename Allocator>
|
||||
bool operator>=(const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
|
||||
{
|
||||
return !(x<y);
|
||||
}
|
||||
|
||||
template <typename T,typename Allocator>
|
||||
bool operator<=(const stable_vector<T,Allocator>& x,const stable_vector<T,Allocator>& y)
|
||||
{
|
||||
return !(x>y);
|
||||
}
|
||||
|
||||
// specialized algorithms:
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
void swap(stable_vector<T,Allocator>& x,stable_vector<T,Allocator>& y)
|
||||
{
|
||||
x.swap(y);
|
||||
}
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
#undef STABLE_VECTOR_CHECK_INVARIANT
|
||||
|
@@ -1580,11 +1580,33 @@ class vector
|
||||
|
||||
//Absolutely experimental. This function might change, disappear or simply crash!
|
||||
template<class BiDirPosConstIt, class BiDirSkipConstIt, class BiDirValueIt>
|
||||
void insert_ordered_at(size_type element_count, BiDirPosConstIt last_position_it, BiDirSkipConstIt last_skip_it, BiDirValueIt last_value_it)
|
||||
void insert_ordered_at( size_type element_count, BiDirPosConstIt last_position_it
|
||||
, BiDirSkipConstIt last_skip_it, BiDirValueIt last_value_it)
|
||||
{
|
||||
this->priv_insert_ordered_at(element_count, last_position_it, true, last_skip_it, last_value_it);
|
||||
}
|
||||
|
||||
friend bool operator==(const vector& x, const vector& y)
|
||||
{ return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
|
||||
|
||||
friend bool operator!=(const vector& x, const vector& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
friend bool operator<(const vector& x, const vector& y)
|
||||
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
|
||||
|
||||
friend bool operator>(const vector& x, const vector& y)
|
||||
{ return y < x; }
|
||||
|
||||
friend bool operator<=(const vector& x, const vector& y)
|
||||
{ return !(y < x); }
|
||||
|
||||
friend bool operator>=(const vector& x, const vector& y)
|
||||
{ return !(x < y); }
|
||||
|
||||
friend void swap(vector& x, vector& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
private:
|
||||
|
||||
template<class OtherAllocator, class AllocVersion>
|
||||
@@ -1907,7 +1929,6 @@ class vector
|
||||
return iterator(this->m_holder.start() + n_pos);
|
||||
}
|
||||
|
||||
|
||||
template <class InsertionProxy>
|
||||
iterator priv_forward_range_insert_no_capacity
|
||||
(const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy, allocator_v2)
|
||||
@@ -2635,33 +2656,6 @@ class vector
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
};
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool
|
||||
operator==(const vector<T, Allocator>& x, const vector<T, Allocator>& y)
|
||||
{
|
||||
//Check first size and each element if needed
|
||||
return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin());
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool
|
||||
operator!=(const vector<T, Allocator>& x, const vector<T, Allocator>& y)
|
||||
{
|
||||
//Check first size and each element if needed
|
||||
return x.size() != y.size() || !std::equal(x.begin(), x.end(), y.begin());
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline bool
|
||||
operator<(const vector<T, Allocator>& x, const vector<T, Allocator>& y)
|
||||
{
|
||||
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
inline void swap(vector<T, Allocator>& x, vector<T, Allocator>& y)
|
||||
{ x.swap(y); }
|
||||
|
||||
}}
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
138
proj/vc7ide/alloc_basic_test.vcproj
Normal file
138
proj/vc7ide/alloc_basic_test.vcproj
Normal file
@@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="alloc_basic_test"
|
||||
ProjectGUID="{CD57C283-1862-42FE-BF87-B96D3A2A7912}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/alloc_basic_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="BOOST_CONTAINER_NO_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/alloc_basic_test_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/debug"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/alloc_basic_test.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/alloc_basic_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;BOOST_CONTAINER_NO_LIB"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/alloc_basic_test.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/release"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{34957FC1-7BC5-1646-05A6-27542AA2A2FF}">
|
||||
<File
|
||||
RelativePath="..\..\test\alloc_basic_test.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93A78280-B78D-4B31-7E8B-6255ACE1E5FB}">
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
133
proj/vc7ide/alloc_full_test.vcproj
Normal file
133
proj/vc7ide/alloc_full_test.vcproj
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="alloc_full_test"
|
||||
ProjectGUID="{CD57C283-1862-9FE5-BF87-BA91293A76D3}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/alloc_full_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="BOOST_CONTAINER_NO_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/alloc_full_test_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/debug"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/alloc_full_test.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/alloc_full_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;BOOST_CONTAINER_NO_LIB"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/alloc_full_test.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/release"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{3857F2C1-BC75-1646-05A6-2AF850A42A2E}">
|
||||
<File
|
||||
RelativePath="..\..\test\alloc_full_test.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
199
proj/vc7ide/alloc_lib.vcproj
Normal file
199
proj/vc7ide/alloc_lib.vcproj
Normal file
@@ -0,0 +1,199 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="_alloc_lib"
|
||||
ProjectGUID="{685AC59C-E667-4096-9DAA-AB76083C7092}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="..\..\Bin\Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\..\.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/alloc_lib.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="..\..\Bin\Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\..\..\.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/alloc_lib.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath="..\..\src\alloc_lib.c">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\adaptive_pool.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\allocator.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\node_allocator.hpp">
|
||||
</File>
|
||||
<Filter
|
||||
Name="detail"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\detail\adaptive_node_pool.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\detail\alloc_lib.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\detail\alloc_lib_auto_link.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\detail\auto_link.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\detail\mutex.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\detail\node_pool.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\detail\pool_common_alloc.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\detail\singleton.hpp">
|
||||
</File>
|
||||
<Filter
|
||||
Name="Included Sources"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="..\..\src\dlmalloc_2_8_6.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\dlmalloc_ext_2_8_6.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="test"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="..\..\test\Jamfile.v2">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="doc"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="..\..\doc\Applying classic memory allocation improvements to C++ containers.html">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
133
proj/vc7ide/bench_adaptive_node_pool.vcproj
Normal file
133
proj/vc7ide/bench_adaptive_node_pool.vcproj
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="bench_adaptive_node_pool"
|
||||
ProjectGUID="{C8AD2618-79EB-8612-42FE-2A3AC9667A13}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/bench_adaptive_node_pool"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="BOOST_CONTAINER_NO_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_adaptive_node_pool_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/debug;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/bench_adaptive_node_pool.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/bench_adaptive_node_pool"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;BOOST_CONTAINER_NO_LIB"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_adaptive_node_pool.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/release;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{818563C3-6640-0A65-55CB-202E5BAD7FAF}">
|
||||
<File
|
||||
RelativePath="..\..\bench\bench_adaptive_node_pool.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
133
proj/vc7ide/bench_alloc.vcproj
Normal file
133
proj/vc7ide/bench_alloc.vcproj
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="bench_alloc"
|
||||
ProjectGUID="{7CC83A22-8612-7BF8-2F4E-BD9493C6A071}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/bench_alloc"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="BOOST_CONTAINER_NO_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_alloc_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/debug;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/bench_alloc.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/bench_alloc"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;BOOST_CONTAINER_NO_LIB"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_alloc.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/release;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{D127F725-A615-C5B6-6640-27A2AE5757AF}">
|
||||
<File
|
||||
RelativePath="..\..\bench\bench_alloc.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
133
proj/vc7ide/bench_alloc_expand_bwd.vcproj
Normal file
133
proj/vc7ide/bench_alloc_expand_bwd.vcproj
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="bench_alloc_expand_bwd"
|
||||
ProjectGUID="{C7C283A2-7BF8-8612-42FE-B9D26A0793A1}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/bench_alloc_expand_bwd"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="BOOST_CONTAINER_NO_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_alloc_expand_bwd_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/debug;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/bench_alloc_expand_bwd.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/bench_alloc_expand_bwd"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;BOOST_CONTAINER_NO_LIB"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_alloc_expand_bwd.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/release;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{D1217F85-BC56-6640-05A6-247AF7A2A58F}">
|
||||
<File
|
||||
RelativePath="..\..\bench\bench_alloc_expand_bwd.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
133
proj/vc7ide/bench_alloc_expand_fwd.vcproj
Normal file
133
proj/vc7ide/bench_alloc_expand_fwd.vcproj
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="bench_alloc_expand_fwd"
|
||||
ProjectGUID="{C7C283A2-7BF8-8612-42FE-B9D26A0793A1}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/bench_alloc_expand_fwd"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="BOOST_CONTAINER_NO_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_alloc_expand_fwd_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/debug;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/bench_alloc_expand_fwd.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/bench_alloc_expand_fwd"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;BOOST_CONTAINER_NO_LIB"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_alloc_expand_fwd.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/release;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{D1217F85-BC56-6640-05A6-247AF7A2A58F}">
|
||||
<File
|
||||
RelativePath="..\..\bench\bench_alloc_expand_fwd.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
133
proj/vc7ide/bench_alloc_shrink_to_fit.vcproj
Normal file
133
proj/vc7ide/bench_alloc_shrink_to_fit.vcproj
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="bench_alloc_shrink_to_fit"
|
||||
ProjectGUID="{C7C283A2-7BF8-8612-42FE-B9D26A0793A1}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/bench_alloc_shrink_to_fit"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="BOOST_CONTAINER_NO_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_alloc_shrink_to_fit_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/debug;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/bench_alloc_shrink_to_fit.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/bench_alloc_shrink_to_fit"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;BOOST_CONTAINER_NO_LIB"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_alloc_shrink_to_fit.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/release;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{D1217F85-BC56-6640-05A6-247AF7A2A58F}">
|
||||
<File
|
||||
RelativePath="..\..\bench\bench_alloc_shrink_to_fit.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
134
proj/vc7ide/bench_alloc_stable_vector_burst_allocation.vcproj
Normal file
134
proj/vc7ide/bench_alloc_stable_vector_burst_allocation.vcproj
Normal file
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="bench_alloc_stable_vector_burst_allocation"
|
||||
ProjectGUID="{C3AD2582-79BF-2FE1-8612-BD707552A6A1}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/bench_alloc_stable_vector_burst_allocation"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="BOOST_CONTAINER_NO_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_alloc_stable_vector_burst_allocation_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/debug;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/bench_alloc_stable_vector_burst_allocation.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/bench_alloc_stable_vector_burst_allocation"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="1"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;BOOST_CONTAINER_NO_LIB"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib alloc_lib.lib"
|
||||
OutputFile="$(OutDir)/bench_alloc_stable_vector_burst_allocation.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../bin/release;../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{D80184F5-6450-3A65-55CB-2375A7BCDAEF}">
|
||||
<File
|
||||
RelativePath="..\..\bench\bench_alloc_stable_vector_burst_allocation.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
134
proj/vc7ide/doc_emplace.vcproj
Normal file
134
proj/vc7ide/doc_emplace.vcproj
Normal file
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="doc_emplace"
|
||||
ProjectGUID="{5CE11C83-FA84-295A-4FA2-D7921A0BAB02}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/vector_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
ExceptionHandling="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/doc_emplace_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/doc_emplace.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/doc_emplace"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/doc_emplace.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{41737BFF-1543-AC75-62A0-35A32A2D72AF}">
|
||||
<File
|
||||
RelativePath="..\..\example\doc_emplace.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
134
proj/vc7ide/doc_move_containers.vcproj
Normal file
134
proj/vc7ide/doc_move_containers.vcproj
Normal file
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="doc_move_containers"
|
||||
ProjectGUID="{5D1C8E13-255A-FA84-4FA2-DA92100BAD42}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/vector_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
ExceptionHandling="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/doc_move_containers_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/doc_move_containers.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/doc_move_containers"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/doc_move_containers.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4037BF7F-62A0-4215-AD45-35A32A2BD72F}">
|
||||
<File
|
||||
RelativePath="..\..\example\doc_move_containers.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
134
proj/vc7ide/doc_recursive_containers.vcproj
Normal file
134
proj/vc7ide/doc_recursive_containers.vcproj
Normal file
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="doc_recursive_containers"
|
||||
ProjectGUID="{5D1C8E13-255A-FA84-4FA2-DA92100BAD42}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/vector_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
ExceptionHandling="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/doc_recursive_containers_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/doc_recursive_containers.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/doc_recursive_containers"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/doc_recursive_containers.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{47BF7F23-4AD3-6C2A-4215-33225D727A8A}">
|
||||
<File
|
||||
RelativePath="..\..\example\doc_recursive_containers.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
134
proj/vc7ide/doc_type_erasure.vcproj
Normal file
134
proj/vc7ide/doc_type_erasure.vcproj
Normal file
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="doc_type_erasure"
|
||||
ProjectGUID="{5C8E1C13-A4F4-2C55-4FA2-D100BA6A9041}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/vector_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
ExceptionHandling="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/doc_type_erasure_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/doc_type_erasure.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/doc_type_erasure"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/doc_type_erasure.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{47BF7F23-A6C2-4215-4AD3-379225E32A8A}">
|
||||
<File
|
||||
RelativePath="..\..\example\doc_type_erasure.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
135
proj/vc7ide/flat_map_test.vcproj
Normal file
135
proj/vc7ide/flat_map_test.vcproj
Normal file
@@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="flat_map_test"
|
||||
ProjectGUID="{5188ECE3-6092-8FE0-44A7-BAD3A7926329}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/flat_map_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
GeneratePreprocessedFile="0"
|
||||
KeepComments="FALSE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/flat_map_test_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/flat_map_test.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/flat_map_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/flat_map_test.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-A066-4326-2A3DC52322EF}">
|
||||
<File
|
||||
RelativePath="..\..\test\flat_map_test.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
135
proj/vc7ide/flat_set_test.vcproj
Normal file
135
proj/vc7ide/flat_set_test.vcproj
Normal file
@@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="flat_set_test"
|
||||
ProjectGUID="{58CCE183-6092-48FE-A4F7-BA0D3A792637}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/flat_set_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
GeneratePreprocessedFile="0"
|
||||
KeepComments="FALSE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/flat_set_test_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/flat_set_test.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/flat_set_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/flat_set_test.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-252A26A32D7A}">
|
||||
<File
|
||||
RelativePath="..\..\test\flat_set_test.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
133
proj/vc7ide/hash_table_test.vcproj
Normal file
133
proj/vc7ide/hash_table_test.vcproj
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="hash_table_test"
|
||||
ProjectGUID="{58CCE183-6092-48FE-A4F7-BA0D3A792606}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/hash_table_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/hash_table_test_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/hash_table_test.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/hash_table_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/hash_table_test.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath="..\..\test\hash_table_test.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
133
proj/vc7ide/map_test.vcproj
Normal file
133
proj/vc7ide/map_test.vcproj
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="map_test"
|
||||
ProjectGUID="{58CCE183-6092-48FE-A4F7-BA0D3A792606}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/map_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/map_test_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/map_test.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/map_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/map_test.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-4376-A7A5-A066-2352A12FF0B7}">
|
||||
<File
|
||||
RelativePath="..\..\test\map_test.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
133
proj/vc7ide/set_test.vcproj
Normal file
133
proj/vc7ide/set_test.vcproj
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="set_test"
|
||||
ProjectGUID="{58CCE183-6092-48FE-A4F7-BA0D3A792606}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Debug"
|
||||
IntermediateDirectory="Debug/set_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/set_test_d.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/set_test.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
FixedBaseAddress="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Bin/Win32/Release"
|
||||
IntermediateDirectory="Release/set_test"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../../.."
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)/set_test.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath="..\..\test\set_test.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
22
src/alloc_lib.c
Normal file
22
src/alloc_lib.c
Normal file
@@ -0,0 +1,22 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2012-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define DLMALLOC_VERSION 286
|
||||
|
||||
#ifndef DLMALLOC_VERSION
|
||||
#error "DLMALLOC_VERSION undefined"
|
||||
#endif
|
||||
|
||||
#if DLMALLOC_VERSION == 286
|
||||
#include "dlmalloc_ext_2_8_6.c"
|
||||
#else
|
||||
#error "Unsupported boost_cont_VERSION version"
|
||||
#endif
|
6280
src/dlmalloc_2_8_6.c
Normal file
6280
src/dlmalloc_2_8_6.c
Normal file
File diff suppressed because it is too large
Load Diff
1382
src/dlmalloc_ext_2_8_6.c
Normal file
1382
src/dlmalloc_ext_2_8_6.c
Normal file
File diff suppressed because it is too large
Load Diff
119
test/alloc_basic_test.cpp
Normal file
119
test/alloc_basic_test.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/container/detail/alloc_lib_auto_link.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/container/list.hpp>
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
bool basic_test()
|
||||
{
|
||||
size_t received;
|
||||
if(!boost_cont_all_deallocated())
|
||||
return false;
|
||||
void *ptr = boost_cont_alloc(50, 98, &received);
|
||||
if(boost_cont_size(ptr) != received)
|
||||
return false;
|
||||
if(boost_cont_allocated_memory() != boost_cont_chunksize(ptr))
|
||||
return false;
|
||||
|
||||
if(boost_cont_all_deallocated())
|
||||
return false;
|
||||
|
||||
boost_cont_grow(ptr, received + 20, received + 30, &received);
|
||||
|
||||
if(boost_cont_allocated_memory() != boost_cont_chunksize(ptr))
|
||||
return false;
|
||||
|
||||
if(boost_cont_size(ptr) != received)
|
||||
return false;
|
||||
|
||||
if(!boost_cont_shrink(ptr, 100, 140, &received, 1))
|
||||
return false;
|
||||
|
||||
if(boost_cont_allocated_memory() != boost_cont_chunksize(ptr))
|
||||
return false;
|
||||
|
||||
if(!boost_cont_shrink(ptr, 0, 140, &received, 1))
|
||||
return false;
|
||||
|
||||
if(boost_cont_allocated_memory() != boost_cont_chunksize(ptr))
|
||||
return false;
|
||||
|
||||
if(boost_cont_shrink(ptr, 0, received/2, &received, 1))
|
||||
return false;
|
||||
|
||||
if(boost_cont_allocated_memory() != boost_cont_chunksize(ptr))
|
||||
return false;
|
||||
|
||||
if(boost_cont_size(ptr) != received)
|
||||
return false;
|
||||
|
||||
boost_cont_free(ptr);
|
||||
|
||||
boost_cont_malloc_check();
|
||||
if(!boost_cont_all_deallocated())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool vector_test()
|
||||
{
|
||||
typedef boost::container::vector<int, allocator<int> > Vector;
|
||||
if(!boost_cont_all_deallocated())
|
||||
return false;
|
||||
{
|
||||
const int NumElem = 1000;
|
||||
Vector v;
|
||||
v.resize(NumElem);
|
||||
int *orig_buf = &v[0];
|
||||
int *new_buf = &v[0];
|
||||
while(orig_buf == new_buf){
|
||||
Vector::size_type cl = v.capacity() - v.size();
|
||||
while(cl--){
|
||||
v.push_back(0);
|
||||
}
|
||||
v.push_back(0);
|
||||
new_buf = &v[0];
|
||||
}
|
||||
}
|
||||
if(!boost_cont_all_deallocated())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool list_test()
|
||||
{
|
||||
typedef boost::container::list<int, allocator<int> > List;
|
||||
if(!boost_cont_all_deallocated())
|
||||
return false;
|
||||
{
|
||||
const int NumElem = 1000;
|
||||
List l;
|
||||
int values[NumElem];
|
||||
l.insert(l.end(), &values[0], &values[NumElem]);
|
||||
}
|
||||
if(!boost_cont_all_deallocated())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
if(!basic_test())
|
||||
return 1;
|
||||
if(!vector_test())
|
||||
return 1;
|
||||
if(!list_test())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
851
test/alloc_full_test.cpp
Normal file
851
test/alloc_full_test.cpp
Normal file
@@ -0,0 +1,851 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2007-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable:4702)
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <new>
|
||||
#include <utility>
|
||||
#include <cstring>
|
||||
#include <algorithm> //std::remove
|
||||
#include <boost/container/detail/alloc_lib_auto_link.hpp>
|
||||
|
||||
namespace boost { namespace container { namespace test {
|
||||
|
||||
static const int NumIt = 2000;
|
||||
|
||||
enum deallocation_type { DirectDeallocation, InverseDeallocation, MixedDeallocation, EndDeallocationType };
|
||||
|
||||
//This test allocates until there is no more memory
|
||||
//and after that deallocates all in the inverse order
|
||||
|
||||
bool test_allocation()
|
||||
{
|
||||
if(!boost_cont_all_deallocated())
|
||||
return false;
|
||||
boost_cont_malloc_check();
|
||||
for( deallocation_type t = DirectDeallocation
|
||||
; t != EndDeallocationType
|
||||
; t = (deallocation_type)((int)t + 1)){
|
||||
std::vector<void*> buffers;
|
||||
//std::size_t free_memory = a.get_free_memory();
|
||||
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
void *ptr = boost_cont_malloc(i);
|
||||
if(!ptr)
|
||||
break;
|
||||
buffers.push_back(ptr);
|
||||
}
|
||||
|
||||
switch(t){
|
||||
case DirectDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
boost_cont_free(buffers[j]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case InverseDeallocation:
|
||||
{
|
||||
for(int j = (int)buffers.size()
|
||||
;j--
|
||||
;){
|
||||
boost_cont_free(buffers[j]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MixedDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
boost_cont_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(!boost_cont_all_deallocated())
|
||||
return false;
|
||||
//bool ok = free_memory == a.get_free_memory() &&
|
||||
//a.all_memory_deallocated() && a.check_sanity();
|
||||
//if(!ok) return ok;
|
||||
}
|
||||
boost_cont_malloc_check();
|
||||
return 0 != boost_cont_all_deallocated();
|
||||
}
|
||||
|
||||
//This test allocates until there is no more memory
|
||||
//and after that tries to shrink all the buffers to the
|
||||
//half of the original size
|
||||
|
||||
bool test_allocation_shrink()
|
||||
{
|
||||
boost_cont_malloc_check();
|
||||
std::vector<void*> buffers;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
void *ptr = boost_cont_malloc(i*2);
|
||||
if(!ptr)
|
||||
break;
|
||||
buffers.push_back(ptr);
|
||||
}
|
||||
|
||||
//Now shrink to half
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
;i < max
|
||||
; ++i){
|
||||
std::size_t try_received_size;
|
||||
void* try_result = boost_cont_allocation_command
|
||||
( BOOST_CONTAINER_TRY_SHRINK_IN_PLACE, 1, i*2
|
||||
, i, &try_received_size, (char*)buffers[i]).first;
|
||||
|
||||
std::size_t received_size;
|
||||
void* result = boost_cont_allocation_command
|
||||
( BOOST_CONTAINER_SHRINK_IN_PLACE, 1, i*2
|
||||
, i, &received_size, (char*)buffers[i]).first;
|
||||
|
||||
if(result != try_result)
|
||||
return false;
|
||||
|
||||
if(received_size != try_received_size)
|
||||
return false;
|
||||
|
||||
if(result){
|
||||
if(received_size > std::size_t(i*2)){
|
||||
return false;
|
||||
}
|
||||
if(received_size < std::size_t(i)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
boost_cont_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
}
|
||||
boost_cont_malloc_check();
|
||||
return 0 != boost_cont_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
}
|
||||
|
||||
//This test allocates until there is no more memory
|
||||
//and after that tries to expand all the buffers to
|
||||
//avoid the wasted internal fragmentation
|
||||
|
||||
bool test_allocation_expand()
|
||||
{
|
||||
boost_cont_malloc_check();
|
||||
std::vector<void*> buffers;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
void *ptr = boost_cont_malloc(i);
|
||||
if(!ptr)
|
||||
break;
|
||||
buffers.push_back(ptr);
|
||||
}
|
||||
|
||||
//Now try to expand to the double of the size
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
;i < max
|
||||
;++i){
|
||||
std::size_t received_size;
|
||||
std::size_t min_size = i+1;
|
||||
std::size_t preferred_size = i*2;
|
||||
preferred_size = min_size > preferred_size ? min_size : preferred_size;
|
||||
while(boost_cont_allocation_command
|
||||
( BOOST_CONTAINER_EXPAND_FWD, 1, min_size
|
||||
, preferred_size, &received_size, (char*)buffers[i]).first){
|
||||
//Check received size is bigger than minimum
|
||||
if(received_size < min_size){
|
||||
return false;
|
||||
}
|
||||
//Now, try to expand further
|
||||
min_size = received_size+1;
|
||||
preferred_size = min_size*2;
|
||||
}
|
||||
}
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
boost_cont_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
}
|
||||
boost_cont_malloc_check();
|
||||
return 0 != boost_cont_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
}
|
||||
|
||||
//This test allocates until there is no more memory
|
||||
//and after that tries to expand all the buffers to
|
||||
//avoid the wasted internal fragmentation
|
||||
bool test_allocation_shrink_and_expand()
|
||||
{
|
||||
std::vector<void*> buffers;
|
||||
std::vector<std::size_t> received_sizes;
|
||||
std::vector<bool> size_reduced;
|
||||
|
||||
//Allocate buffers wand store received sizes
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
std::size_t received_size;
|
||||
void *ptr = boost_cont_allocation_command
|
||||
(BOOST_CONTAINER_ALLOCATE_NEW, 1, i, i*2, &received_size, 0).first;
|
||||
if(!ptr){
|
||||
ptr = boost_cont_allocation_command
|
||||
( BOOST_CONTAINER_ALLOCATE_NEW, 1, 1, i*2, &received_size, 0).first;
|
||||
if(!ptr)
|
||||
break;
|
||||
}
|
||||
buffers.push_back(ptr);
|
||||
received_sizes.push_back(received_size);
|
||||
}
|
||||
|
||||
//Now shrink to half
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
; i < max
|
||||
; ++i){
|
||||
std::size_t received_size;
|
||||
bool size_reduced_flag;
|
||||
if(true == (size_reduced_flag = !!
|
||||
boost_cont_allocation_command
|
||||
( BOOST_CONTAINER_SHRINK_IN_PLACE, 1, received_sizes[i]
|
||||
, i, &received_size, (char*)buffers[i]).first)){
|
||||
if(received_size > std::size_t(received_sizes[i])){
|
||||
return false;
|
||||
}
|
||||
if(received_size < std::size_t(i)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
size_reduced.push_back(size_reduced_flag);
|
||||
}
|
||||
|
||||
//Now try to expand to the original size
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
;i < max
|
||||
;++i){
|
||||
if(!size_reduced[i]) continue;
|
||||
std::size_t received_size;
|
||||
std::size_t request_size = received_sizes[i];
|
||||
if(boost_cont_allocation_command
|
||||
( BOOST_CONTAINER_EXPAND_FWD, 1, request_size
|
||||
, request_size, &received_size, (char*)buffers[i]).first){
|
||||
if(received_size != request_size){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
boost_cont_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
}
|
||||
|
||||
return 0 != boost_cont_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
}
|
||||
|
||||
//This test allocates until there is no more memory
|
||||
//and after that deallocates the odd buffers to
|
||||
//make room for expansions. The expansion will probably
|
||||
//success since the deallocation left room for that.
|
||||
|
||||
bool test_allocation_deallocation_expand()
|
||||
{
|
||||
boost_cont_malloc_check();
|
||||
std::vector<void*> buffers;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
void *ptr = boost_cont_malloc(i);
|
||||
if(!ptr)
|
||||
break;
|
||||
buffers.push_back(ptr);
|
||||
}
|
||||
|
||||
//Now deallocate the half of the blocks
|
||||
//so expand maybe can merge new free blocks
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
;i < max
|
||||
;++i){
|
||||
if(i%2){
|
||||
boost_cont_free(buffers[i]);
|
||||
buffers[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Now try to expand to the double of the size
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
;i < max
|
||||
;++i){
|
||||
//
|
||||
if(buffers[i]){
|
||||
std::size_t received_size;
|
||||
std::size_t min_size = i+1;
|
||||
std::size_t preferred_size = i*2;
|
||||
preferred_size = min_size > preferred_size ? min_size : preferred_size;
|
||||
|
||||
while(boost_cont_allocation_command
|
||||
( BOOST_CONTAINER_EXPAND_FWD, 1, min_size
|
||||
, preferred_size, &received_size, (char*)buffers[i]).first){
|
||||
//Check received size is bigger than minimum
|
||||
if(received_size < min_size){
|
||||
return false;
|
||||
}
|
||||
//Now, try to expand further
|
||||
min_size = received_size+1;
|
||||
preferred_size = min_size*2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Now erase null values from the vector
|
||||
buffers.erase(std::remove(buffers.begin(), buffers.end(), (void*)0)
|
||||
,buffers.end());
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
boost_cont_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
}
|
||||
boost_cont_malloc_check();
|
||||
return 0 != boost_cont_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
}
|
||||
|
||||
//This test allocates until there is no more memory
|
||||
//and after that deallocates all except the last.
|
||||
//If the allocation algorithm is a bottom-up algorithm
|
||||
//the last buffer will be in the end of the segment.
|
||||
//Then the test will start expanding backwards, until
|
||||
//the buffer fills all the memory
|
||||
|
||||
bool test_allocation_with_reuse()
|
||||
{
|
||||
boost_cont_malloc_check();
|
||||
//We will repeat this test for different sized elements
|
||||
for(int sizeof_object = 1; sizeof_object < 20; ++sizeof_object){
|
||||
std::vector<void*> buffers;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
void *ptr = boost_cont_malloc(i*sizeof_object);
|
||||
if(!ptr)
|
||||
break;
|
||||
buffers.push_back(ptr);
|
||||
}
|
||||
|
||||
//Now deallocate all except the latest
|
||||
//Now try to expand to the double of the size
|
||||
for(int i = 0, max = (int)buffers.size() - 1
|
||||
;i < max
|
||||
;++i){
|
||||
boost_cont_free(buffers[i]);
|
||||
}
|
||||
|
||||
//Save the unique buffer and clear vector
|
||||
void *ptr = buffers.back();
|
||||
buffers.clear();
|
||||
|
||||
//Now allocate with reuse
|
||||
std::size_t received_size = 0;
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
std::size_t min_size = (received_size/sizeof_object + 1)*sizeof_object;
|
||||
std::size_t prf_size = (received_size/sizeof_object + (i+1)*2)*sizeof_object;
|
||||
boost_cont_command_ret_t ret = boost_cont_allocation_command
|
||||
( BOOST_CONTAINER_EXPAND_BWD, sizeof_object, min_size
|
||||
, prf_size, &received_size, (char*)ptr);
|
||||
//If we have memory, this must be a buffer reuse
|
||||
if(!ret.first)
|
||||
break;
|
||||
//If we have memory, this must be a buffer reuse
|
||||
if(!ret.second)
|
||||
return false;
|
||||
if(received_size < min_size)
|
||||
return false;
|
||||
ptr = ret.first;
|
||||
}
|
||||
//There should be only a single block so deallocate it
|
||||
boost_cont_free(ptr);
|
||||
boost_cont_malloc_check();
|
||||
if(!boost_cont_all_deallocated())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//This test allocates memory with different alignments
|
||||
//and checks returned memory is aligned.
|
||||
|
||||
bool test_aligned_allocation()
|
||||
{
|
||||
boost_cont_malloc_check();
|
||||
//Allocate aligned buffers in a loop
|
||||
//and then deallocate it
|
||||
for(unsigned int i = 1; i != (1 << (sizeof(int)/2)); i <<= 1){
|
||||
for(unsigned int j = 1; j != 512; j <<= 1){
|
||||
void *ptr = boost_cont_memalign(i-1, j);
|
||||
if(!ptr){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(((std::size_t)ptr & (j - 1)) != 0)
|
||||
return false;
|
||||
boost_cont_free(ptr);
|
||||
//if(!a.all_memory_deallocated() || !a.check_sanity()){
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
}
|
||||
boost_cont_malloc_check();
|
||||
return 0 != boost_cont_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
}
|
||||
|
||||
//This test allocates memory with different alignments
|
||||
//and checks returned memory is aligned.
|
||||
|
||||
bool test_continuous_aligned_allocation()
|
||||
{
|
||||
boost_cont_malloc_check();
|
||||
std::vector<void*> buffers;
|
||||
//Allocate aligned buffers in a loop
|
||||
//and then deallocate it
|
||||
bool continue_loop = true;
|
||||
unsigned int MaxAlign = 4096;
|
||||
unsigned int MaxSize = 4096;
|
||||
for(unsigned i = 1; i < MaxSize; i <<= 1){
|
||||
for(unsigned int j = 1; j < MaxAlign; j <<= 1){
|
||||
for(int k = 0; k != NumIt; ++k){
|
||||
void *ptr = boost_cont_memalign(i-1, j);
|
||||
buffers.push_back(ptr);
|
||||
if(!ptr){
|
||||
continue_loop = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(((std::size_t)ptr & (j - 1)) != 0)
|
||||
return false;
|
||||
}
|
||||
//Deallocate all
|
||||
for(int k = (int)buffers.size(); k--;){
|
||||
boost_cont_free(buffers[k]);
|
||||
}
|
||||
buffers.clear();
|
||||
//if(!a.all_memory_deallocated() && a.check_sanity())
|
||||
// return false;
|
||||
if(!continue_loop)
|
||||
break;
|
||||
}
|
||||
}
|
||||
boost_cont_malloc_check();
|
||||
return 0 != boost_cont_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
}
|
||||
|
||||
//This test allocates multiple values until there is no more memory
|
||||
//and after that deallocates all in the inverse order
|
||||
bool test_many_equal_allocation()
|
||||
{
|
||||
boost_cont_malloc_check();
|
||||
for( deallocation_type t = DirectDeallocation
|
||||
; t != EndDeallocationType
|
||||
; t = (deallocation_type)((int)t + 1)){
|
||||
//std::size_t free_memory = a.get_free_memory();
|
||||
|
||||
std::vector<void*> buffers2;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
void *ptr = boost_cont_malloc(i);
|
||||
if(!ptr)
|
||||
break;
|
||||
//if(!a.check_sanity())
|
||||
//return false;
|
||||
buffers2.push_back(ptr);
|
||||
}
|
||||
|
||||
//Now deallocate the half of the blocks
|
||||
//so expand maybe can merge new free blocks
|
||||
for(int i = 0, max = (int)buffers2.size()
|
||||
;i < max
|
||||
;++i){
|
||||
if(i%2){
|
||||
boost_cont_free(buffers2[i]);
|
||||
buffers2[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//if(!a.check_sanity())
|
||||
//return false;
|
||||
|
||||
std::vector<void*> buffers;
|
||||
for(int i = 0; i != NumIt/10; ++i){
|
||||
boost_cont_memchain chain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
|
||||
boost_cont_multialloc_nodes((i+1)*2, i+1, DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
|
||||
boost_cont_memchain_it it = BOOST_CONTAINER_MEMCHAIN_BEGIN_IT(&chain);
|
||||
if(BOOST_CONTAINER_MEMCHAIN_IS_END_IT(chain, it))
|
||||
break;
|
||||
|
||||
std::size_t n = 0;
|
||||
for(; !BOOST_CONTAINER_MEMCHAIN_IS_END_IT(chain, it); ++n){
|
||||
buffers.push_back(BOOST_CONTAINER_MEMIT_ADDR(it));
|
||||
BOOST_CONTAINER_MEMIT_NEXT(it);
|
||||
}
|
||||
if(n != std::size_t((i+1)*2))
|
||||
return false;
|
||||
}
|
||||
|
||||
//if(!a.check_sanity())
|
||||
//return false;
|
||||
|
||||
switch(t){
|
||||
case DirectDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
boost_cont_free(buffers[j]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case InverseDeallocation:
|
||||
{
|
||||
for(int j = (int)buffers.size()
|
||||
;j--
|
||||
;){
|
||||
boost_cont_free(buffers[j]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MixedDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
boost_cont_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//Deallocate the rest of the blocks
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers2.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers2.size())/4;
|
||||
boost_cont_free(buffers2[pos]);
|
||||
buffers2.erase(buffers2.begin()+pos);
|
||||
}
|
||||
|
||||
//bool ok = free_memory == a.get_free_memory() &&
|
||||
//a.all_memory_deallocated() && a.check_sanity();
|
||||
//if(!ok) return ok;
|
||||
}
|
||||
boost_cont_malloc_check();
|
||||
return 0 != boost_cont_all_deallocated();
|
||||
}
|
||||
|
||||
//This test allocates multiple values until there is no more memory
|
||||
//and after that deallocates all in the inverse order
|
||||
|
||||
bool test_many_different_allocation()
|
||||
{
|
||||
boost_cont_malloc_check();
|
||||
const std::size_t ArraySize = 11;
|
||||
std::size_t requested_sizes[ArraySize];
|
||||
for(std::size_t i = 0; i < ArraySize; ++i){
|
||||
requested_sizes[i] = 4*i;
|
||||
}
|
||||
|
||||
for( deallocation_type t = DirectDeallocation
|
||||
; t != EndDeallocationType
|
||||
; t = (deallocation_type)((int)t + 1)){
|
||||
//std::size_t free_memory = a.get_free_memory();
|
||||
|
||||
std::vector<void*> buffers2;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
void *ptr = boost_cont_malloc(i);
|
||||
if(!ptr)
|
||||
break;
|
||||
buffers2.push_back(ptr);
|
||||
}
|
||||
|
||||
//Now deallocate the half of the blocks
|
||||
//so expand maybe can merge new free blocks
|
||||
for(int i = 0, max = (int)buffers2.size()
|
||||
;i < max
|
||||
;++i){
|
||||
if(i%2){
|
||||
boost_cont_free(buffers2[i]);
|
||||
buffers2[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<void*> buffers;
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
boost_cont_memchain chain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
|
||||
boost_cont_multialloc_arrays(ArraySize, requested_sizes, 1, DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
|
||||
boost_cont_memchain_it it = BOOST_CONTAINER_MEMCHAIN_BEGIN_IT(&chain);
|
||||
if(BOOST_CONTAINER_MEMCHAIN_IS_END_IT(chain, it))
|
||||
break;
|
||||
std::size_t n = 0;
|
||||
for(; !BOOST_CONTAINER_MEMCHAIN_IS_END_IT(chain, it); ++n){
|
||||
buffers.push_back(BOOST_CONTAINER_MEMIT_ADDR(it));
|
||||
BOOST_CONTAINER_MEMIT_NEXT(it);
|
||||
}
|
||||
if(n != ArraySize)
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(t){
|
||||
case DirectDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
boost_cont_free(buffers[j]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case InverseDeallocation:
|
||||
{
|
||||
for(int j = (int)buffers.size()
|
||||
;j--
|
||||
;){
|
||||
boost_cont_free(buffers[j]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MixedDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
boost_cont_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//Deallocate the rest of the blocks
|
||||
|
||||
//Deallocate it in non sequential order
|
||||
for(int j = 0, max = (int)buffers2.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers2.size())/4;
|
||||
boost_cont_free(buffers2[pos]);
|
||||
buffers2.erase(buffers2.begin()+pos);
|
||||
}
|
||||
|
||||
//bool ok = free_memory == a.get_free_memory() &&
|
||||
//a.all_memory_deallocated() && a.check_sanity();
|
||||
//if(!ok) return ok;
|
||||
}
|
||||
boost_cont_malloc_check();
|
||||
return 0 != boost_cont_all_deallocated();
|
||||
}
|
||||
|
||||
bool test_many_deallocation()
|
||||
{
|
||||
const std::size_t ArraySize = 11;
|
||||
std::vector<boost_cont_memchain> buffers;
|
||||
std::size_t requested_sizes[ArraySize];
|
||||
for(std::size_t i = 0; i < ArraySize; ++i){
|
||||
requested_sizes[i] = 4*i;
|
||||
}
|
||||
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
boost_cont_memchain chain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
|
||||
boost_cont_multialloc_arrays(ArraySize, requested_sizes, 1, DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
|
||||
boost_cont_memchain_it it = BOOST_CONTAINER_MEMCHAIN_BEGIN_IT(&chain);
|
||||
if(BOOST_CONTAINER_MEMCHAIN_IS_END_IT(chain, it))
|
||||
return false;
|
||||
buffers.push_back(chain);
|
||||
}
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
boost_cont_multidealloc(&buffers[i]);
|
||||
}
|
||||
buffers.clear();
|
||||
|
||||
boost_cont_malloc_check();
|
||||
if(!boost_cont_all_deallocated())
|
||||
return false;
|
||||
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
boost_cont_memchain chain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
|
||||
boost_cont_multialloc_nodes(ArraySize, i*4+1, DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
|
||||
boost_cont_memchain_it it = BOOST_CONTAINER_MEMCHAIN_BEGIN_IT(&chain);
|
||||
if(BOOST_CONTAINER_MEMCHAIN_IS_END_IT(chain, it))
|
||||
return false;
|
||||
buffers.push_back(chain);
|
||||
}
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
boost_cont_multidealloc(&buffers[i]);
|
||||
}
|
||||
buffers.clear();
|
||||
|
||||
boost_cont_malloc_check();
|
||||
if(!boost_cont_all_deallocated())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//This function calls all tests
|
||||
|
||||
bool test_all_allocation()
|
||||
{
|
||||
std::cout << "Starting test_allocation"
|
||||
<< std::endl;
|
||||
|
||||
if(!test_allocation()){
|
||||
std::cout << "test_allocation_direct_deallocation failed"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Starting test_many_equal_allocation"
|
||||
<< std::endl;
|
||||
|
||||
if(!test_many_equal_allocation()){
|
||||
std::cout << "test_many_equal_allocation failed"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Starting test_many_different_allocation"
|
||||
<< std::endl;
|
||||
|
||||
if(!test_many_different_allocation()){
|
||||
std::cout << "test_many_different_allocation failed"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Starting test_allocation_shrink"
|
||||
<< std::endl;
|
||||
|
||||
if(!test_allocation_shrink()){
|
||||
std::cout << "test_allocation_shrink failed"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!test_allocation_shrink_and_expand()){
|
||||
std::cout << "test_allocation_shrink_and_expand failed"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Starting test_allocation_expand"
|
||||
<< std::endl;
|
||||
|
||||
if(!test_allocation_expand()){
|
||||
std::cout << "test_allocation_expand failed"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Starting test_allocation_deallocation_expand"
|
||||
<< std::endl;
|
||||
|
||||
if(!test_allocation_deallocation_expand()){
|
||||
std::cout << "test_allocation_deallocation_expand failed"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Starting test_allocation_with_reuse"
|
||||
<< std::endl;
|
||||
|
||||
if(!test_allocation_with_reuse()){
|
||||
std::cout << "test_allocation_with_reuse failed"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Starting test_aligned_allocation"
|
||||
<< std::endl;
|
||||
|
||||
if(!test_aligned_allocation()){
|
||||
std::cout << "test_aligned_allocation failed"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Starting test_continuous_aligned_allocation"
|
||||
<< std::endl;
|
||||
|
||||
if(!test_continuous_aligned_allocation()){
|
||||
std::cout << "test_continuous_aligned_allocation failed"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!test_many_deallocation()){
|
||||
std::cout << "test_many_deallocation failed"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0 != boost_cont_all_deallocated();
|
||||
}
|
||||
|
||||
}}} //namespace boost { namespace container { namespace test {
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
if(!boost::container::test::test_all_allocation())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
164
test/default_init_test.hpp
Normal file
164
test/default_init_test.hpp
Normal file
@@ -0,0 +1,164 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2013-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_TEST_DEFAULT_INIT_TEST_HEADER
|
||||
#define BOOST_CONTAINER_TEST_DEFAULT_INIT_TEST_HEADER
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include "print_container.hpp"
|
||||
#include "check_equal_containers.hpp"
|
||||
#include "movable_int.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "emplace_test.hpp"
|
||||
#include "input_from_forward_iterator.hpp"
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include "insert_test.hpp"
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
namespace test{
|
||||
|
||||
//
|
||||
template<int Dummy = 0>
|
||||
class default_init_allocator_base
|
||||
{
|
||||
protected:
|
||||
static unsigned char s_pattern;
|
||||
static bool s_ascending;
|
||||
|
||||
public:
|
||||
static void reset_pattern(unsigned char value)
|
||||
{ s_pattern = value; }
|
||||
|
||||
static void set_ascending(bool enable)
|
||||
{ s_ascending = enable; }
|
||||
};
|
||||
|
||||
template<int Dummy>
|
||||
unsigned char default_init_allocator_base<Dummy>::s_pattern = 0u;
|
||||
|
||||
template<int Dummy>
|
||||
bool default_init_allocator_base<Dummy>::s_ascending = true;
|
||||
|
||||
template<class Integral>
|
||||
class default_init_allocator
|
||||
: public default_init_allocator_base<0>
|
||||
{
|
||||
typedef default_init_allocator_base<0> base_t;
|
||||
public:
|
||||
typedef Integral value_type;
|
||||
|
||||
default_init_allocator()
|
||||
{}
|
||||
|
||||
template <class U>
|
||||
default_init_allocator(default_init_allocator<U>)
|
||||
{}
|
||||
|
||||
Integral* allocate(std::size_t n)
|
||||
{
|
||||
//Initialize memory to a pattern
|
||||
const std::size_t max = sizeof(Integral)*n;
|
||||
unsigned char *puc_raw = ::new unsigned char[max];
|
||||
|
||||
if(base_t::s_ascending){
|
||||
for(std::size_t i = 0; i != max; ++i){
|
||||
puc_raw[i] = static_cast<unsigned char>(s_pattern++);
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(std::size_t i = 0; i != max; ++i){
|
||||
puc_raw[i] = static_cast<unsigned char>(s_pattern--);
|
||||
}
|
||||
}
|
||||
return (Integral*)puc_raw;;
|
||||
}
|
||||
|
||||
void deallocate(Integral *p, std::size_t)
|
||||
{ delete[] (unsigned char*)p; }
|
||||
};
|
||||
|
||||
template<class Integral>
|
||||
inline bool check_ascending_byte_pattern(const Integral&t)
|
||||
{
|
||||
const unsigned char *pch = &reinterpret_cast<const unsigned char &>(t);
|
||||
const std::size_t max = sizeof(Integral);
|
||||
for(std::size_t i = 1; i != max; ++i){
|
||||
if( (pch[i-1] != ((unsigned char)(pch[i]-1u))) ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class Integral>
|
||||
inline bool check_descending_byte_pattern(const Integral&t)
|
||||
{
|
||||
const unsigned char *pch = &reinterpret_cast<const unsigned char &>(t);
|
||||
const std::size_t max = sizeof(Integral);
|
||||
for(std::size_t i = 1; i != max; ++i){
|
||||
if( (pch[i-1] != ((unsigned char)(pch[i]+1u))) ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class IntDefaultInitAllocVector>
|
||||
bool default_init_test()//Test for default initialization
|
||||
{
|
||||
const std::size_t Capacity = 100;
|
||||
|
||||
{
|
||||
test::default_init_allocator<int>::reset_pattern(0);
|
||||
test::default_init_allocator<int>::set_ascending(true);
|
||||
IntDefaultInitAllocVector v(Capacity, default_init);
|
||||
typename IntDefaultInitAllocVector::iterator it = v.begin();
|
||||
//Compare with the pattern
|
||||
for(std::size_t i = 0; i != Capacity; ++i, ++it){
|
||||
if(!test::check_ascending_byte_pattern(*it))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
{
|
||||
test::default_init_allocator<int>::reset_pattern(100);
|
||||
test::default_init_allocator<int>::set_ascending(false);
|
||||
IntDefaultInitAllocVector v;
|
||||
v.resize(Capacity, default_init);
|
||||
typename IntDefaultInitAllocVector::iterator it = v.begin();
|
||||
//Compare with the pattern
|
||||
for(std::size_t i = 0; i != Capacity; ++i, ++it){
|
||||
if(!test::check_descending_byte_pattern(*it))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} //namespace test{
|
||||
} //namespace container {
|
||||
} //namespace boost{
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //BOOST_CONTAINER_TEST_DEFAULT_INIT_TEST_HEADER
|
439
test/flat_map_test.cpp
Normal file
439
test/flat_map_test.cpp
Normal file
@@ -0,0 +1,439 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/flat_map.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
|
||||
#include "print_container.hpp"
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include "movable_int.hpp"
|
||||
#include "map_test.hpp"
|
||||
#include "propagate_allocator_test.hpp"
|
||||
#include "emplace_test.hpp"
|
||||
#include <vector>
|
||||
#include <boost/container/detail/flat_tree.hpp>
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
//Explicit instantiation to detect compilation errors
|
||||
|
||||
//flat_map
|
||||
template class flat_map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, adaptive_pool
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, node_allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
//flat_multimap
|
||||
template class flat_multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, adaptive_pool
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class flat_multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, node_allocator
|
||||
< std::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
//As flat container iterators are typedefs for vector::[const_]iterator,
|
||||
//no need to explicit instantiate them
|
||||
|
||||
}} //boost::container
|
||||
|
||||
|
||||
class recursive_flat_map
|
||||
{
|
||||
public:
|
||||
recursive_flat_map(const recursive_flat_map &c)
|
||||
: id_(c.id_), map_(c.map_)
|
||||
{}
|
||||
|
||||
recursive_flat_map & operator =(const recursive_flat_map &c)
|
||||
{
|
||||
id_ = c.id_;
|
||||
map_= c.map_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int id_;
|
||||
flat_map<recursive_flat_map, recursive_flat_map> map_;
|
||||
|
||||
friend bool operator< (const recursive_flat_map &a, const recursive_flat_map &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
|
||||
class recursive_flat_multimap
|
||||
{
|
||||
public:
|
||||
recursive_flat_multimap(const recursive_flat_multimap &c)
|
||||
: id_(c.id_), map_(c.map_)
|
||||
{}
|
||||
|
||||
recursive_flat_multimap & operator =(const recursive_flat_multimap &c)
|
||||
{
|
||||
id_ = c.id_;
|
||||
map_= c.map_;
|
||||
return *this;
|
||||
}
|
||||
int id_;
|
||||
flat_map<recursive_flat_multimap, recursive_flat_multimap> map_;
|
||||
friend bool operator< (const recursive_flat_multimap &a, const recursive_flat_multimap &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
template<class C>
|
||||
void test_move()
|
||||
{
|
||||
//Now test move semantics
|
||||
C original;
|
||||
C move_ctor(boost::move(original));
|
||||
C move_assign;
|
||||
move_assign = boost::move(move_ctor);
|
||||
move_assign.swap(original);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
class flat_tree_propagate_test_wrapper
|
||||
: public container_detail::flat_tree<T, T, container_detail::identity<T>, std::less<T>, A>
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(flat_tree_propagate_test_wrapper)
|
||||
typedef container_detail::flat_tree<T, T, container_detail::identity<T>, std::less<T>, A> Base;
|
||||
public:
|
||||
flat_tree_propagate_test_wrapper()
|
||||
: Base()
|
||||
{}
|
||||
|
||||
flat_tree_propagate_test_wrapper(const flat_tree_propagate_test_wrapper &x)
|
||||
: Base(x)
|
||||
{}
|
||||
|
||||
flat_tree_propagate_test_wrapper(BOOST_RV_REF(flat_tree_propagate_test_wrapper) x)
|
||||
: Base(boost::move(static_cast<Base&>(x)))
|
||||
{}
|
||||
|
||||
flat_tree_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(flat_tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(x); return *this; }
|
||||
|
||||
flat_tree_propagate_test_wrapper &operator=(BOOST_RV_REF(flat_tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(boost::move(static_cast<Base&>(x))); return *this; }
|
||||
|
||||
void swap(flat_tree_propagate_test_wrapper &x)
|
||||
{ this->Base::swap(x); }
|
||||
};
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
namespace test{
|
||||
|
||||
bool flat_tree_ordered_insertion_test()
|
||||
{
|
||||
using namespace boost::container;
|
||||
const std::size_t NumElements = 100;
|
||||
|
||||
//Ordered insertion multimap
|
||||
{
|
||||
std::multimap<int, int> int_mmap;
|
||||
for(std::size_t i = 0; i != NumElements; ++i){
|
||||
int_mmap.insert(std::multimap<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
|
||||
}
|
||||
//Construction insertion
|
||||
flat_multimap<int, int> fmmap(ordered_range, int_mmap.begin(), int_mmap.end());
|
||||
if(!CheckEqualContainers(&int_mmap, &fmmap))
|
||||
return false;
|
||||
//Insertion when empty
|
||||
fmmap.clear();
|
||||
fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end());
|
||||
if(!CheckEqualContainers(&int_mmap, &fmmap))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fmmap.insert(ordered_range, int_mmap.begin(), int_mmap.end());
|
||||
std::multimap<int, int> int_mmap2(int_mmap);
|
||||
int_mmap2.insert(int_mmap.begin(), int_mmap.end());
|
||||
if(!CheckEqualContainers(&int_mmap2, &fmmap))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fmmap.insert(ordered_range, int_mmap2.begin(), int_mmap2.end());
|
||||
std::multimap<int, int> int_mmap4(int_mmap2);
|
||||
int_mmap4.insert(int_mmap2.begin(), int_mmap2.end());
|
||||
if(!CheckEqualContainers(&int_mmap4, &fmmap))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
std::multimap<int, int> int_even_mmap;
|
||||
for(std::size_t i = 0; i < NumElements; i+=2){
|
||||
int_mmap.insert(std::multimap<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
|
||||
}
|
||||
fmmap.insert(ordered_range, int_even_mmap.begin(), int_even_mmap.end());
|
||||
int_mmap4.insert(int_even_mmap.begin(), int_even_mmap.end());
|
||||
if(!CheckEqualContainers(&int_mmap4, &fmmap))
|
||||
return false;
|
||||
}
|
||||
|
||||
//Ordered insertion map
|
||||
{
|
||||
std::map<int, int> int_map;
|
||||
for(std::size_t i = 0; i != NumElements; ++i){
|
||||
int_map.insert(std::map<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
|
||||
}
|
||||
//Construction insertion
|
||||
flat_map<int, int> fmap(ordered_unique_range, int_map.begin(), int_map.end());
|
||||
if(!CheckEqualContainers(&int_map, &fmap))
|
||||
return false;
|
||||
//Insertion when empty
|
||||
fmap.clear();
|
||||
fmap.insert(ordered_unique_range, int_map.begin(), int_map.end());
|
||||
if(!CheckEqualContainers(&int_map, &fmap))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fmap.insert(ordered_unique_range, int_map.begin(), int_map.end());
|
||||
std::map<int, int> int_map2(int_map);
|
||||
int_map2.insert(int_map.begin(), int_map.end());
|
||||
if(!CheckEqualContainers(&int_map2, &fmap))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fmap.insert(ordered_unique_range, int_map2.begin(), int_map2.end());
|
||||
std::map<int, int> int_map4(int_map2);
|
||||
int_map4.insert(int_map2.begin(), int_map2.end());
|
||||
if(!CheckEqualContainers(&int_map4, &fmap))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
std::map<int, int> int_even_map;
|
||||
for(std::size_t i = 0; i < NumElements; i+=2){
|
||||
int_map.insert(std::map<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
|
||||
}
|
||||
fmap.insert(ordered_unique_range, int_even_map.begin(), int_even_map.end());
|
||||
int_map4.insert(int_even_map.begin(), int_even_map.end());
|
||||
if(!CheckEqualContainers(&int_map4, &fmap))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
template<class VoidAllocator>
|
||||
struct GetAllocatorMap
|
||||
{
|
||||
template<class ValueType>
|
||||
struct apply
|
||||
{
|
||||
typedef flat_map< ValueType
|
||||
, ValueType
|
||||
, std::less<ValueType>
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc< std::pair<ValueType, ValueType> >::type
|
||||
> map_type;
|
||||
|
||||
typedef flat_multimap< ValueType
|
||||
, ValueType
|
||||
, std::less<ValueType>
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc< std::pair<ValueType, ValueType> >::type
|
||||
> multimap_type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class VoidAllocator>
|
||||
int test_map_variants()
|
||||
{
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<int>::map_type MyMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::movable_int>::map_type MyMoveMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::movable_and_copyable_int>::map_type MyCopyMoveMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::copyable_int>::map_type MyCopyMap;
|
||||
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<int>::multimap_type MyMultiMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::movable_int>::multimap_type MyMoveMultiMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::movable_and_copyable_int>::multimap_type MyCopyMoveMultiMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::copyable_int>::multimap_type MyCopyMultiMap;
|
||||
|
||||
typedef std::map<int, int> MyStdMap;
|
||||
typedef std::multimap<int, int> MyStdMultiMap;
|
||||
|
||||
if (0 != test::map_test<
|
||||
MyMap
|
||||
,MyStdMap
|
||||
,MyMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test<
|
||||
MyMoveMap
|
||||
,MyStdMap
|
||||
,MyMoveMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test<
|
||||
MyCopyMoveMap
|
||||
,MyStdMap
|
||||
,MyCopyMoveMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test<
|
||||
MyCopyMap
|
||||
,MyStdMap
|
||||
,MyCopyMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::container::test;
|
||||
|
||||
//Allocator argument container
|
||||
{
|
||||
flat_map<int, int> map_((std::allocator<std::pair<int, int> >()));
|
||||
flat_multimap<int, int> multimap_((std::allocator<std::pair<int, int> >()));
|
||||
}
|
||||
//Now test move semantics
|
||||
{
|
||||
test_move<flat_map<recursive_flat_map, recursive_flat_map> >();
|
||||
test_move<flat_multimap<recursive_flat_multimap, recursive_flat_multimap> >();
|
||||
}
|
||||
|
||||
if(!flat_tree_ordered_insertion_test()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_map_variants< std::allocator<void> >()){
|
||||
std::cerr << "test_map_variants< std::allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_map_variants< allocator<void> >()){
|
||||
std::cerr << "test_map_variants< allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_map_variants< node_allocator<void> >()){
|
||||
std::cerr << "test_map_variants< node_allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_map_variants< adaptive_pool<void> >()){
|
||||
std::cerr << "test_map_variants< adaptive_pool<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const test::EmplaceOptions MapOptions = (test::EmplaceOptions)(test::EMPLACE_HINT_PAIR | test::EMPLACE_ASSOC_PAIR);
|
||||
|
||||
if(!boost::container::test::test_emplace<flat_map<test::EmplaceInt, test::EmplaceInt>, MapOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_emplace<flat_multimap<test::EmplaceInt, test::EmplaceInt>, MapOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_propagate_allocator<flat_tree_propagate_test_wrapper>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
414
test/flat_set_test.cpp
Normal file
414
test/flat_set_test.cpp
Normal file
@@ -0,0 +1,414 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <set>
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
|
||||
#include "print_container.hpp"
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include "movable_int.hpp"
|
||||
#include "set_test.hpp"
|
||||
#include "propagate_allocator_test.hpp"
|
||||
#include "emplace_test.hpp"
|
||||
#include <vector>
|
||||
#include <boost/container/detail/flat_tree.hpp>
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
//Explicit instantiation to detect compilation errors
|
||||
|
||||
//flat_set
|
||||
template class flat_set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, adaptive_pool<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, node_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
//flat_multiset
|
||||
template class flat_multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, adaptive_pool<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class flat_multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, node_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
//As flat container iterators are typedefs for vector::[const_]iterator,
|
||||
//no need to explicit instantiate them
|
||||
|
||||
}} //boost::container
|
||||
|
||||
//Test recursive structures
|
||||
class recursive_flat_set
|
||||
{
|
||||
public:
|
||||
recursive_flat_set(const recursive_flat_set &c)
|
||||
: id_(c.id_), flat_set_(c.flat_set_)
|
||||
{}
|
||||
|
||||
recursive_flat_set & operator =(const recursive_flat_set &c)
|
||||
{
|
||||
id_ = c.id_;
|
||||
flat_set_= c.flat_set_;
|
||||
return *this;
|
||||
}
|
||||
int id_;
|
||||
flat_set<recursive_flat_set> flat_set_;
|
||||
friend bool operator< (const recursive_flat_set &a, const recursive_flat_set &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
|
||||
//Test recursive structures
|
||||
class recursive_flat_multiset
|
||||
{
|
||||
public:
|
||||
recursive_flat_multiset(const recursive_flat_multiset &c)
|
||||
: id_(c.id_), flat_multiset_(c.flat_multiset_)
|
||||
{}
|
||||
|
||||
recursive_flat_multiset & operator =(const recursive_flat_multiset &c)
|
||||
{
|
||||
id_ = c.id_;
|
||||
flat_multiset_= c.flat_multiset_;
|
||||
return *this;
|
||||
}
|
||||
int id_;
|
||||
flat_multiset<recursive_flat_multiset> flat_multiset_;
|
||||
friend bool operator< (const recursive_flat_multiset &a, const recursive_flat_multiset &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
|
||||
template<class C>
|
||||
void test_move()
|
||||
{
|
||||
//Now test move semantics
|
||||
C original;
|
||||
C move_ctor(boost::move(original));
|
||||
C move_assign;
|
||||
move_assign = boost::move(move_ctor);
|
||||
move_assign.swap(original);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
class flat_tree_propagate_test_wrapper
|
||||
: public container_detail::flat_tree<T, T, container_detail::identity<T>, std::less<T>, A>
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(flat_tree_propagate_test_wrapper)
|
||||
typedef container_detail::flat_tree<T, T, container_detail::identity<T>, std::less<T>, A> Base;
|
||||
public:
|
||||
flat_tree_propagate_test_wrapper()
|
||||
: Base()
|
||||
{}
|
||||
|
||||
flat_tree_propagate_test_wrapper(const flat_tree_propagate_test_wrapper &x)
|
||||
: Base(x)
|
||||
{}
|
||||
|
||||
flat_tree_propagate_test_wrapper(BOOST_RV_REF(flat_tree_propagate_test_wrapper) x)
|
||||
: Base(boost::move(static_cast<Base&>(x)))
|
||||
{}
|
||||
|
||||
flat_tree_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(flat_tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(x); return *this; }
|
||||
|
||||
flat_tree_propagate_test_wrapper &operator=(BOOST_RV_REF(flat_tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(boost::move(static_cast<Base&>(x))); return *this; }
|
||||
|
||||
void swap(flat_tree_propagate_test_wrapper &x)
|
||||
{ this->Base::swap(x); }
|
||||
};
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
namespace test{
|
||||
|
||||
bool flat_tree_ordered_insertion_test()
|
||||
{
|
||||
using namespace boost::container;
|
||||
const std::size_t NumElements = 100;
|
||||
|
||||
//Ordered insertion multiset
|
||||
{
|
||||
std::multiset<int> int_mset;
|
||||
for(std::size_t i = 0; i != NumElements; ++i){
|
||||
int_mset.insert(static_cast<int>(i));
|
||||
}
|
||||
//Construction insertion
|
||||
flat_multiset<int> fmset(ordered_range, int_mset.begin(), int_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset, &fmset))
|
||||
return false;
|
||||
//Insertion when empty
|
||||
fmset.clear();
|
||||
fmset.insert(ordered_range, int_mset.begin(), int_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset, &fmset))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fmset.insert(ordered_range, int_mset.begin(), int_mset.end());
|
||||
std::multiset<int> int_mset2(int_mset);
|
||||
int_mset2.insert(int_mset.begin(), int_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset2, &fmset))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fmset.insert(ordered_range, int_mset2.begin(), int_mset2.end());
|
||||
std::multiset<int> int_mset4(int_mset2);
|
||||
int_mset4.insert(int_mset2.begin(), int_mset2.end());
|
||||
if(!CheckEqualContainers(&int_mset4, &fmset))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
std::multiset<int> int_even_mset;
|
||||
for(std::size_t i = 0; i < NumElements; i+=2){
|
||||
int_mset.insert(static_cast<int>(i));
|
||||
}
|
||||
fmset.insert(ordered_range, int_even_mset.begin(), int_even_mset.end());
|
||||
int_mset4.insert(int_even_mset.begin(), int_even_mset.end());
|
||||
if(!CheckEqualContainers(&int_mset4, &fmset))
|
||||
return false;
|
||||
}
|
||||
|
||||
//Ordered insertion set
|
||||
{
|
||||
std::set<int> int_set;
|
||||
for(std::size_t i = 0; i != NumElements; ++i){
|
||||
int_set.insert(static_cast<int>(i));
|
||||
}
|
||||
//Construction insertion
|
||||
flat_set<int> fset(ordered_unique_range, int_set.begin(), int_set.end());
|
||||
if(!CheckEqualContainers(&int_set, &fset))
|
||||
return false;
|
||||
//Insertion when empty
|
||||
fset.clear();
|
||||
fset.insert(ordered_unique_range, int_set.begin(), int_set.end());
|
||||
if(!CheckEqualContainers(&int_set, &fset))
|
||||
return false;
|
||||
//Re-insertion
|
||||
fset.insert(ordered_unique_range, int_set.begin(), int_set.end());
|
||||
std::set<int> int_set2(int_set);
|
||||
int_set2.insert(int_set.begin(), int_set.end());
|
||||
if(!CheckEqualContainers(&int_set2, &fset))
|
||||
return false;
|
||||
//Re-re-insertion
|
||||
fset.insert(ordered_unique_range, int_set2.begin(), int_set2.end());
|
||||
std::set<int> int_set4(int_set2);
|
||||
int_set4.insert(int_set2.begin(), int_set2.end());
|
||||
if(!CheckEqualContainers(&int_set4, &fset))
|
||||
return false;
|
||||
//Re-re-insertion of even
|
||||
std::set<int> int_even_set;
|
||||
for(std::size_t i = 0; i < NumElements; i+=2){
|
||||
int_set.insert(static_cast<int>(i));
|
||||
}
|
||||
fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end());
|
||||
int_set4.insert(int_even_set.begin(), int_even_set.end());
|
||||
if(!CheckEqualContainers(&int_set4, &fset))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
template<class VoidAllocator>
|
||||
struct GetAllocatorSet
|
||||
{
|
||||
template<class ValueType>
|
||||
struct apply
|
||||
{
|
||||
typedef flat_set < ValueType
|
||||
, std::less<ValueType>
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
> set_type;
|
||||
|
||||
typedef flat_multiset < ValueType
|
||||
, std::less<ValueType>
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
> multiset_type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class VoidAllocator>
|
||||
int test_set_variants()
|
||||
{
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<int>::set_type MySet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::movable_int>::set_type MyMoveSet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::movable_and_copyable_int>::set_type MyCopyMoveSet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::copyable_int>::set_type MyCopySet;
|
||||
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<int>::multiset_type MyMultiSet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::movable_int>::multiset_type MyMoveMultiSet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::movable_and_copyable_int>::multiset_type MyCopyMoveMultiSet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::copyable_int>::multiset_type MyCopyMultiSet;
|
||||
|
||||
typedef std::set<int> MyStdSet;
|
||||
typedef std::multiset<int> MyStdMultiSet;
|
||||
|
||||
if (0 != test::set_test<
|
||||
MySet
|
||||
,MyStdSet
|
||||
,MyMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::set_test<
|
||||
MyMoveSet
|
||||
,MyStdSet
|
||||
,MyMoveMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::set_test<
|
||||
MyCopyMoveSet
|
||||
,MyStdSet
|
||||
,MyCopyMoveMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::set_test<
|
||||
MyCopySet
|
||||
,MyStdSet
|
||||
,MyCopyMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::container::test;
|
||||
|
||||
//Allocator argument container
|
||||
{
|
||||
flat_set<int> set_((std::allocator<int>()));
|
||||
flat_multiset<int> multiset_((std::allocator<int>()));
|
||||
}
|
||||
//Now test move semantics
|
||||
{
|
||||
test_move<flat_set<recursive_flat_set> >();
|
||||
test_move<flat_multiset<recursive_flat_multiset> >();
|
||||
}
|
||||
|
||||
if(!flat_tree_ordered_insertion_test()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_set_variants< std::allocator<void> >()){
|
||||
std::cerr << "test_set_variants< std::allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_set_variants< allocator<void> >()){
|
||||
std::cerr << "test_set_variants< allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_set_variants< node_allocator<void> >()){
|
||||
std::cerr << "test_set_variants< node_allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_set_variants< adaptive_pool<void> >()){
|
||||
std::cerr << "test_set_variants< adaptive_pool<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const test::EmplaceOptions SetOptions = (test::EmplaceOptions)(test::EMPLACE_HINT | test::EMPLACE_ASSOC);
|
||||
|
||||
if(!boost::container::test::test_emplace<flat_set<test::EmplaceInt>, SetOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_emplace<flat_multiset<test::EmplaceInt>, SetOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_propagate_allocator<flat_tree_propagate_test_wrapper>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
0
test/hash_table_test.cppx
Normal file
0
test/hash_table_test.cppx
Normal file
324
test/map_test.cpp
Normal file
324
test/map_test.cpp
Normal file
@@ -0,0 +1,324 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/map.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
|
||||
#include "print_container.hpp"
|
||||
#include "movable_int.hpp"
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include "map_test.hpp"
|
||||
#include "propagate_allocator_test.hpp"
|
||||
#include "emplace_test.hpp"
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
//Explicit instantiation to detect compilation errors
|
||||
|
||||
//map
|
||||
template class map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
|
||||
template class map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, adaptive_pool
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class map
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, node_allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
//multimap
|
||||
template class multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, adaptive_pool
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
template class multimap
|
||||
< test::movable_and_copyable_int
|
||||
, test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, node_allocator
|
||||
< std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> >
|
||||
>;
|
||||
|
||||
}} //boost::container
|
||||
|
||||
class recursive_map
|
||||
{
|
||||
public:
|
||||
recursive_map & operator=(const recursive_map &x)
|
||||
{ id_ = x.id_; map_ = x.map_; return *this; }
|
||||
|
||||
int id_;
|
||||
map<recursive_map, recursive_map> map_;
|
||||
friend bool operator< (const recursive_map &a, const recursive_map &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
class recursive_multimap
|
||||
{
|
||||
public:
|
||||
recursive_multimap & operator=(const recursive_multimap &x)
|
||||
{ id_ = x.id_; multimap_ = x.multimap_; return *this; }
|
||||
|
||||
int id_;
|
||||
multimap<recursive_multimap, recursive_multimap> multimap_;
|
||||
friend bool operator< (const recursive_multimap &a, const recursive_multimap &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
template<class C>
|
||||
void test_move()
|
||||
{
|
||||
//Now test move semantics
|
||||
C original;
|
||||
original.emplace();
|
||||
C move_ctor(boost::move(original));
|
||||
C move_assign;
|
||||
move_assign.emplace();
|
||||
move_assign = boost::move(move_ctor);
|
||||
move_assign.swap(original);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
class tree_propagate_test_wrapper
|
||||
: public container_detail::tree<T, T, container_detail::identity<T>, std::less<T>, A, red_black_tree>
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(tree_propagate_test_wrapper)
|
||||
typedef container_detail::tree<T, T, container_detail::identity<T>, std::less<T>, A, red_black_tree> Base;
|
||||
public:
|
||||
tree_propagate_test_wrapper()
|
||||
: Base()
|
||||
{}
|
||||
|
||||
tree_propagate_test_wrapper(const tree_propagate_test_wrapper &x)
|
||||
: Base(x)
|
||||
{}
|
||||
|
||||
tree_propagate_test_wrapper(BOOST_RV_REF(tree_propagate_test_wrapper) x)
|
||||
: Base(boost::move(static_cast<Base&>(x)))
|
||||
{}
|
||||
|
||||
tree_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(x); return *this; }
|
||||
|
||||
tree_propagate_test_wrapper &operator=(BOOST_RV_REF(tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(boost::move(static_cast<Base&>(x))); return *this; }
|
||||
|
||||
void swap(tree_propagate_test_wrapper &x)
|
||||
{ this->Base::swap(x); }
|
||||
};
|
||||
|
||||
|
||||
template<class VoidAllocator>
|
||||
struct GetAllocatorMap
|
||||
{
|
||||
template<class ValueType>
|
||||
struct apply
|
||||
{
|
||||
typedef map< ValueType
|
||||
, ValueType
|
||||
, std::less<ValueType>
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc< std::pair<const ValueType, ValueType> >::type
|
||||
> map_type;
|
||||
|
||||
typedef multimap< ValueType
|
||||
, ValueType
|
||||
, std::less<ValueType>
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc< std::pair<const ValueType, ValueType> >::type
|
||||
> multimap_type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class VoidAllocator>
|
||||
int test_map_variants()
|
||||
{
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<int>::map_type MyMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::movable_int>::map_type MyMoveMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::movable_and_copyable_int>::map_type MyCopyMoveMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::copyable_int>::map_type MyCopyMap;
|
||||
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<int>::multimap_type MyMultiMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::movable_int>::multimap_type MyMoveMultiMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::movable_and_copyable_int>::multimap_type MyCopyMoveMultiMap;
|
||||
typedef typename GetAllocatorMap<VoidAllocator>::template apply<test::copyable_int>::multimap_type MyCopyMultiMap;
|
||||
|
||||
typedef std::map<int, int> MyStdMap;
|
||||
typedef std::multimap<int, int> MyStdMultiMap;
|
||||
|
||||
if (0 != test::map_test<
|
||||
MyMap
|
||||
,MyStdMap
|
||||
,MyMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test<
|
||||
MyMoveMap
|
||||
,MyStdMap
|
||||
,MyMoveMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test<
|
||||
MyCopyMoveMap
|
||||
,MyStdMap
|
||||
,MyCopyMoveMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::map_test<
|
||||
MyCopyMap
|
||||
,MyStdMap
|
||||
,MyCopyMultiMap
|
||||
,MyStdMultiMap>()){
|
||||
std::cout << "Error in map_test<MyBoostMap>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
//Recursive container instantiation
|
||||
{
|
||||
map<recursive_map, recursive_map> map_;
|
||||
multimap<recursive_multimap, recursive_multimap> multimap_;
|
||||
}
|
||||
//Allocator argument container
|
||||
{
|
||||
map<int, int> map_((std::allocator<std::pair<const int, int> >()));
|
||||
multimap<int, int> multimap_((std::allocator<std::pair<const int, int> >()));
|
||||
}
|
||||
//Now test move semantics
|
||||
{
|
||||
test_move<map<recursive_map, recursive_map> >();
|
||||
test_move<multimap<recursive_multimap, recursive_multimap> >();
|
||||
}
|
||||
|
||||
if(test_map_variants< std::allocator<void> >()){
|
||||
std::cerr << "test_map_variants< std::allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_map_variants< allocator<void> >()){
|
||||
std::cerr << "test_map_variants< allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_map_variants< node_allocator<void> >()){
|
||||
std::cerr << "test_map_variants< node_allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_map_variants< adaptive_pool<void> >()){
|
||||
std::cerr << "test_map_variants< adaptive_pool<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const test::EmplaceOptions MapOptions = (test::EmplaceOptions)(test::EMPLACE_HINT_PAIR | test::EMPLACE_ASSOC_PAIR);
|
||||
if(!boost::container::test::test_emplace<map<test::EmplaceInt, test::EmplaceInt>, MapOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_emplace<multimap<test::EmplaceInt, test::EmplaceInt>, MapOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_propagate_allocator<tree_propagate_test_wrapper>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
300
test/set_test.cpp
Normal file
300
test/set_test.cpp
Normal file
@@ -0,0 +1,300 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2004-2013. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <set>
|
||||
#include <boost/container/set.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/node_allocator.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
|
||||
#include "print_container.hpp"
|
||||
#include "movable_int.hpp"
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include "set_test.hpp"
|
||||
#include "propagate_allocator_test.hpp"
|
||||
#include "emplace_test.hpp"
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
||||
//Explicit instantiation to detect compilation errors
|
||||
|
||||
//set
|
||||
template class set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, adaptive_pool<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class set
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, node_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
//multiset
|
||||
template class multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::dummy_test_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, test::simple_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, std::allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, adaptive_pool<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
template class multiset
|
||||
< test::movable_and_copyable_int
|
||||
, std::less<test::movable_and_copyable_int>
|
||||
, node_allocator<test::movable_and_copyable_int>
|
||||
>;
|
||||
|
||||
}} //boost::container
|
||||
|
||||
//Test recursive structures
|
||||
class recursive_set
|
||||
{
|
||||
public:
|
||||
recursive_set & operator=(const recursive_set &x)
|
||||
{ id_ = x.id_; set_ = x.set_; return *this; }
|
||||
|
||||
int id_;
|
||||
set<recursive_set> set_;
|
||||
friend bool operator< (const recursive_set &a, const recursive_set &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
//Test recursive structures
|
||||
class recursive_multiset
|
||||
{
|
||||
public:
|
||||
recursive_multiset & operator=(const recursive_multiset &x)
|
||||
{ id_ = x.id_; multiset_ = x.multiset_; return *this; }
|
||||
|
||||
int id_;
|
||||
multiset<recursive_multiset> multiset_;
|
||||
friend bool operator< (const recursive_multiset &a, const recursive_multiset &b)
|
||||
{ return a.id_ < b.id_; }
|
||||
};
|
||||
|
||||
template<class C>
|
||||
void test_move()
|
||||
{
|
||||
//Now test move semantics
|
||||
C original;
|
||||
original.emplace();
|
||||
C move_ctor(boost::move(original));
|
||||
C move_assign;
|
||||
move_assign.emplace();
|
||||
move_assign = boost::move(move_ctor);
|
||||
move_assign.swap(original);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
class tree_propagate_test_wrapper
|
||||
: public container_detail::tree<T, T, container_detail::identity<T>, std::less<T>, A, red_black_tree>
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(tree_propagate_test_wrapper)
|
||||
typedef container_detail::tree<T, T, container_detail::identity<T>, std::less<T>, A, red_black_tree> Base;
|
||||
public:
|
||||
tree_propagate_test_wrapper()
|
||||
: Base()
|
||||
{}
|
||||
|
||||
tree_propagate_test_wrapper(const tree_propagate_test_wrapper &x)
|
||||
: Base(x)
|
||||
{}
|
||||
|
||||
tree_propagate_test_wrapper(BOOST_RV_REF(tree_propagate_test_wrapper) x)
|
||||
: Base(boost::move(static_cast<Base&>(x)))
|
||||
{}
|
||||
|
||||
tree_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(x); return *this; }
|
||||
|
||||
tree_propagate_test_wrapper &operator=(BOOST_RV_REF(tree_propagate_test_wrapper) x)
|
||||
{ this->Base::operator=(boost::move(static_cast<Base&>(x))); return *this; }
|
||||
|
||||
void swap(tree_propagate_test_wrapper &x)
|
||||
{ this->Base::swap(x); }
|
||||
};
|
||||
|
||||
template<class VoidAllocator>
|
||||
struct GetAllocatorSet
|
||||
{
|
||||
template<class ValueType>
|
||||
struct apply
|
||||
{
|
||||
typedef set < ValueType
|
||||
, std::less<ValueType>
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
> set_type;
|
||||
|
||||
typedef multiset < ValueType
|
||||
, std::less<ValueType>
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
> multiset_type;
|
||||
};
|
||||
};
|
||||
|
||||
template<class VoidAllocator>
|
||||
int test_set_variants()
|
||||
{
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<int>::set_type MySet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::movable_int>::set_type MyMoveSet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::movable_and_copyable_int>::set_type MyCopyMoveSet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::copyable_int>::set_type MyCopySet;
|
||||
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<int>::multiset_type MyMultiSet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::movable_int>::multiset_type MyMoveMultiSet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::movable_and_copyable_int>::multiset_type MyCopyMoveMultiSet;
|
||||
typedef typename GetAllocatorSet<VoidAllocator>::template apply<test::copyable_int>::multiset_type MyCopyMultiSet;
|
||||
|
||||
typedef std::set<int> MyStdSet;
|
||||
typedef std::multiset<int> MyStdMultiSet;
|
||||
|
||||
if (0 != test::set_test<
|
||||
MySet
|
||||
,MyStdSet
|
||||
,MyMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::set_test<
|
||||
MyMoveSet
|
||||
,MyStdSet
|
||||
,MyMoveMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::set_test<
|
||||
MyCopyMoveSet
|
||||
,MyStdSet
|
||||
,MyCopyMoveMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != test::set_test<
|
||||
MyCopySet
|
||||
,MyStdSet
|
||||
,MyCopyMultiSet
|
||||
,MyStdMultiSet>()){
|
||||
std::cout << "Error in set_test<MyBoostSet>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
//Recursive container instantiation
|
||||
{
|
||||
set<recursive_set> set_;
|
||||
multiset<recursive_multiset> multiset_;
|
||||
}
|
||||
//Allocator argument container
|
||||
{
|
||||
set<int> set_((std::allocator<int>()));
|
||||
multiset<int> multiset_((std::allocator<int>()));
|
||||
}
|
||||
//Now test move semantics
|
||||
{
|
||||
test_move<set<recursive_set> >();
|
||||
test_move<multiset<recursive_multiset> >();
|
||||
}
|
||||
|
||||
if(test_set_variants< std::allocator<void> >()){
|
||||
std::cerr << "test_set_variants< std::allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_set_variants< allocator<void> >()){
|
||||
std::cerr << "test_set_variants< allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_set_variants< node_allocator<void> >()){
|
||||
std::cerr << "test_set_variants< node_allocator<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(test_set_variants< adaptive_pool<void> >()){
|
||||
std::cerr << "test_set_variants< adaptive_pool<void> > failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const test::EmplaceOptions SetOptions = (test::EmplaceOptions)(test::EMPLACE_HINT | test::EMPLACE_ASSOC);
|
||||
if(!boost::container::test::test_emplace<set<test::EmplaceInt>, SetOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_emplace<multiset<test::EmplaceInt>, SetOptions>())
|
||||
return 1;
|
||||
if(!boost::container::test::test_propagate_allocator<tree_propagate_test_wrapper>())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
Reference in New Issue
Block a user