forked from boostorg/container
Merge remote-tracking branch 'origin/develop' into patch-1
This commit is contained in:
@@ -1332,6 +1332,7 @@ use [*Boost.Container]? There are several reasons for that:
|
||||
* [@https://github.com/boostorg/container/issues/116 GitHub #116: ['"MSVC + boost 1.70 compilation error when windows.h is already included (detail/thread_mutex.hpp)"]].
|
||||
* [@https://github.com/boostorg/container/issues/117 GitHub #117: ['"flat_map/map::insert_or_assign with hint has wrong return types"]].
|
||||
* [@https://github.com/boostorg/container/issues/118 GitHub #118: ['"Non-unique inplace_set_difference used in in flat_tree_merge_unique and iterator invalidation in insert_unique"]].
|
||||
* [@https://github.com/boostorg/container/issues/122 GitHub #122: ['"Fix has_trivial_destructor_after_move"]].
|
||||
|
||||
* [classref boost::container::deque deque] can now have options, using [classref boost::container::deque_options deque_options].
|
||||
The block size/bytes can be be specified.
|
||||
|
@@ -2295,8 +2295,9 @@ namespace boost {
|
||||
template <class T, class Allocator, class Options>
|
||||
struct has_trivial_destructor_after_move<boost::container::deque<T, Allocator, Options> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
typedef typename boost::container::deque<T, Allocator, Options>::allocator_type allocator_type;
|
||||
typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value;
|
||||
};
|
||||
|
||||
|
@@ -1622,11 +1622,11 @@ template <class T, class KeyOfValue,
|
||||
class Compare, class AllocatorOrContainer>
|
||||
struct has_trivial_destructor_after_move<boost::container::dtl::flat_tree<T, KeyOfValue, Compare, AllocatorOrContainer> >
|
||||
{
|
||||
typedef typename boost::container::dtl::select_container_type<T, AllocatorOrContainer>::type container_type;
|
||||
typedef typename container_type::allocator_type allocator_t;
|
||||
typedef typename ::boost::container::allocator_traits<allocator_t>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<allocator_t>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value;
|
||||
typedef boost::container::dtl::flat_tree<T, KeyOfValue, Compare, AllocatorOrContainer> flat_tree;
|
||||
typedef typename flat_tree::container_type container_type;
|
||||
typedef typename flat_tree::key_compare key_compare;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<container_type>::value &&
|
||||
::boost::has_trivial_destructor_after_move<key_compare>::value;
|
||||
};
|
||||
|
||||
} //namespace boost {
|
||||
|
@@ -1516,8 +1516,9 @@ struct has_trivial_destructor_after_move
|
||||
<T, KeyOfValue, Compare, Allocator, Options>
|
||||
>
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
typedef typename ::boost::container::dtl::tree<T, KeyOfValue, Compare, Allocator, Options>::allocator_type allocator_type;
|
||||
typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<Compare>::value;
|
||||
};
|
||||
|
@@ -1651,10 +1651,10 @@ flat_map(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, A
|
||||
template <class Key, class T, class Compare, class AllocatorOrContainer>
|
||||
struct has_trivial_destructor_after_move<boost::container::flat_map<Key, T, Compare, AllocatorOrContainer> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<AllocatorOrContainer>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<AllocatorOrContainer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<Compare>::value;
|
||||
typedef ::boost::container::dtl::pair<Key, T> value_t;
|
||||
typedef typename ::boost::container::dtl::container_or_allocator_rebind<AllocatorOrContainer, value_t>::type alloc_or_cont_t;
|
||||
typedef ::boost::container::dtl::flat_tree<value_t,::boost::container::dtl::select1st<Key>, Compare, alloc_or_cont_t> tree;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
||||
};
|
||||
|
||||
namespace container {
|
||||
@@ -2961,10 +2961,10 @@ namespace boost {
|
||||
template <class Key, class T, class Compare, class AllocatorOrContainer>
|
||||
struct has_trivial_destructor_after_move< boost::container::flat_multimap<Key, T, Compare, AllocatorOrContainer> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<AllocatorOrContainer>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<AllocatorOrContainer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<Compare>::value;
|
||||
typedef ::boost::container::dtl::pair<Key, T> value_t;
|
||||
typedef typename ::boost::container::dtl::container_or_allocator_rebind<AllocatorOrContainer, value_t>::type alloc_or_cont_t;
|
||||
typedef ::boost::container::dtl::flat_tree<value_t,::boost::container::dtl::select1st<Key>, Compare, alloc_or_cont_t> tree;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
||||
};
|
||||
|
||||
} //namespace boost {
|
||||
|
@@ -1192,10 +1192,8 @@ flat_set(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, A
|
||||
template <class Key, class Compare, class AllocatorOrContainer>
|
||||
struct has_trivial_destructor_after_move<boost::container::flat_set<Key, Compare, AllocatorOrContainer> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<AllocatorOrContainer>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<AllocatorOrContainer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<Compare>::value;
|
||||
typedef ::boost::container::dtl::flat_tree<Key, ::boost::container::dtl::identity<Key>, Compare, AllocatorOrContainer> tree;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
||||
};
|
||||
|
||||
namespace container {
|
||||
@@ -1926,10 +1924,8 @@ flat_multiset(ordered_range_t, InputIterator, InputIterator, Compare const&, All
|
||||
template <class Key, class Compare, class AllocatorOrContainer>
|
||||
struct has_trivial_destructor_after_move<boost::container::flat_multiset<Key, Compare, AllocatorOrContainer> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<AllocatorOrContainer>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<AllocatorOrContainer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<Compare>::value;
|
||||
typedef ::boost::container::dtl::flat_tree<Key, ::boost::container::dtl::identity<Key>, Compare, AllocatorOrContainer> tree;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
||||
};
|
||||
|
||||
namespace container {
|
||||
|
@@ -1522,8 +1522,9 @@ list(InputIterator, InputIterator, ValueAllocator const&) ->
|
||||
template <class T, class Allocator>
|
||||
struct has_trivial_destructor_after_move<boost::container::list<T, Allocator> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
typedef typename boost::container::list<T, Allocator>::allocator_type allocator_type;
|
||||
typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value;
|
||||
};
|
||||
|
||||
|
@@ -1366,13 +1366,11 @@ map(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, Alloca
|
||||
|
||||
//!has_trivial_destructor_after_move<> == true_type
|
||||
//!specialization for optimizations
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
struct has_trivial_destructor_after_move<boost::container::map<Key, T, Compare, Allocator> >
|
||||
template <class Key, class T, class Compare, class Allocator, class Options>
|
||||
struct has_trivial_destructor_after_move<boost::container::map<Key, T, Compare, Allocator, Options> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<Compare>::value;
|
||||
typedef ::boost::container::dtl::tree<std::pair<const Key, T>, int, Compare, Allocator, Options> tree;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
||||
};
|
||||
|
||||
namespace container {
|
||||
@@ -2292,13 +2290,11 @@ multimap(ordered_range_t, InputIterator, InputIterator, Compare const&, Allocato
|
||||
|
||||
//!has_trivial_destructor_after_move<> == true_type
|
||||
//!specialization for optimizations
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
struct has_trivial_destructor_after_move<boost::container::multimap<Key, T, Compare, Allocator> >
|
||||
template <class Key, class T, class Compare, class Allocator, class Options>
|
||||
struct has_trivial_destructor_after_move<boost::container::multimap<Key, T, Compare, Allocator, Options> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<Compare>::value;
|
||||
typedef ::boost::container::dtl::tree<std::pair<const Key, T>, int, Compare, Allocator, Options> tree;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
||||
};
|
||||
|
||||
namespace container {
|
||||
|
@@ -1024,13 +1024,11 @@ set(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, Alloca
|
||||
|
||||
//!has_trivial_destructor_after_move<> == true_type
|
||||
//!specialization for optimizations
|
||||
template <class Key, class Compare, class Options, class Allocator>
|
||||
template <class Key, class Compare, class Allocator, class Options>
|
||||
struct has_trivial_destructor_after_move<boost::container::set<Key, Compare, Allocator, Options> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<Compare>::value;
|
||||
typedef ::boost::container::dtl::tree<Key, void, Compare, Allocator, Options> tree;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
||||
};
|
||||
|
||||
namespace container {
|
||||
@@ -1693,10 +1691,8 @@ multiset(ordered_range_t, InputIterator, InputIterator, Compare const&, Allocato
|
||||
template <class Key, class Compare, class Allocator, class Options>
|
||||
struct has_trivial_destructor_after_move<boost::container::multiset<Key, Compare, Allocator, Options> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
::boost::has_trivial_destructor_after_move<Compare>::value;
|
||||
typedef ::boost::container::dtl::tree<Key, void, Compare, Allocator, Options> tree;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
||||
};
|
||||
|
||||
namespace container {
|
||||
|
@@ -1696,8 +1696,9 @@ namespace boost {
|
||||
template <class T, class Allocator>
|
||||
struct has_trivial_destructor_after_move<boost::container::slist<T, Allocator> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
typedef typename boost::container::slist<T, Allocator>::allocator_type allocator_type;
|
||||
typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value;
|
||||
};
|
||||
|
||||
|
@@ -2183,8 +2183,9 @@ stable_vector(InputIterator, InputIterator, Allocator const&) ->
|
||||
template <class T, class Allocator>
|
||||
struct has_trivial_destructor_after_move<boost::container::stable_vector<T, Allocator> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
typedef typename boost::container::stable_vector<T, Allocator>::allocator_type allocator_type;
|
||||
typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value;
|
||||
};
|
||||
|
||||
|
@@ -3490,9 +3490,9 @@ namespace boost {
|
||||
template <class C, class T, class Allocator>
|
||||
struct has_trivial_destructor_after_move<boost::container::basic_string<C, T, Allocator> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits
|
||||
<typename boost::container::basic_string<C, T, Allocator>::allocator_type>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
typedef typename boost::container::basic_string<C, T, Allocator>::allocator_type allocator_type;
|
||||
typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value;
|
||||
};
|
||||
|
||||
|
@@ -3413,9 +3413,9 @@ namespace boost {
|
||||
template <class T, class Allocator, class Options>
|
||||
struct has_trivial_destructor_after_move<boost::container::vector<T, Allocator, Options> >
|
||||
{
|
||||
typedef typename ::boost::container::allocator_traits
|
||||
<typename boost::container::real_allocator<T, Allocator>::type>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
|
||||
typedef typename boost::container::vector<T, Allocator, Options>::allocator_type allocator_type;
|
||||
typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
static const bool value = ::boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
::boost::has_trivial_destructor_after_move<pointer>::value;
|
||||
};
|
||||
|
||||
|
@@ -412,6 +412,34 @@ int main ()
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
// default allocator
|
||||
{
|
||||
typedef boost::container::deque<int> cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::deque<int, std::allocator<int> > cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,9 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/container/flat_map.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/detail/container_or_allocator_rebind.hpp>
|
||||
@@ -750,6 +753,80 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
{
|
||||
typedef boost::container::dtl::pair<int, int> value_t;
|
||||
typedef boost::container::dtl::select1st<int> key_of_value_t;
|
||||
// flat_map, default
|
||||
{
|
||||
typedef boost::container::new_allocator<value_t> alloc_or_cont_t;
|
||||
typedef boost::container::flat_map<int, int> cont;
|
||||
typedef boost::container::dtl::flat_tree<value_t, key_of_value_t, std::less<int>, alloc_or_cont_t> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_map, default) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// flat_map, vector
|
||||
{
|
||||
typedef boost::container::vector<value_t> alloc_or_cont_t;
|
||||
typedef boost::container::flat_map<int, int, std::less<int>, alloc_or_cont_t> cont;
|
||||
typedef boost::container::dtl::flat_tree<value_t, key_of_value_t, std::less<int>, alloc_or_cont_t> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_map, vector) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// flat_map, std::vector
|
||||
{
|
||||
typedef std::vector<value_t> alloc_or_cont_t;
|
||||
typedef boost::container::flat_map<int, int, std::less<int>, alloc_or_cont_t> cont;
|
||||
typedef boost::container::dtl::flat_tree<value_t, key_of_value_t, std::less<int>, alloc_or_cont_t> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_map, std::vector) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// flat_multimap, default
|
||||
{
|
||||
typedef boost::container::new_allocator<value_t> alloc_or_cont_t;
|
||||
typedef boost::container::flat_multimap<int, int> cont;
|
||||
typedef boost::container::dtl::flat_tree<value_t, key_of_value_t, std::less<int>, alloc_or_cont_t> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_multimap, default) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// flat_multimap, vector
|
||||
{
|
||||
typedef boost::container::vector<value_t> alloc_or_cont_t;
|
||||
typedef boost::container::flat_multimap<int, int, std::less<int>, alloc_or_cont_t> cont;
|
||||
typedef boost::container::dtl::flat_tree<value_t, key_of_value_t, std::less<int>, alloc_or_cont_t> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_multimap, vector) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// flat_multimap, std::vector
|
||||
{
|
||||
typedef std::vector<value_t> alloc_or_cont_t;
|
||||
typedef boost::container::flat_multimap<int, int, std::less<int>, alloc_or_cont_t> cont;
|
||||
typedef boost::container::dtl::flat_tree<value_t, key_of_value_t, std::less<int>, alloc_or_cont_t> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_multimap, std::vector) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,10 @@
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include <boost/container/detail/container_or_allocator_rebind.hpp>
|
||||
@@ -849,6 +851,77 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
{
|
||||
typedef boost::container::dtl::identity<int> key_of_value_t;
|
||||
// flat_set, default
|
||||
{
|
||||
typedef boost::container::flat_set<int> cont;
|
||||
typedef boost::container::dtl::flat_tree<int, key_of_value_t, std::less<int>, void> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_set, default) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// flat_set, vector
|
||||
{
|
||||
typedef boost::container::vector<int> alloc_or_cont_t;
|
||||
typedef boost::container::flat_set<int, std::less<int>, alloc_or_cont_t> cont;
|
||||
typedef boost::container::dtl::flat_tree<int, key_of_value_t, std::less<int>, alloc_or_cont_t> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_set, vector) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// flat_set, std::vector
|
||||
{
|
||||
typedef std::vector<int> alloc_or_cont_t;
|
||||
typedef boost::container::flat_set<int, std::less<int>, alloc_or_cont_t> cont;
|
||||
typedef boost::container::dtl::flat_tree<int, key_of_value_t, std::less<int>, alloc_or_cont_t> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_set, std::vector) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// flat_multiset, default
|
||||
{
|
||||
typedef boost::container::flat_multiset<int> cont;
|
||||
typedef boost::container::dtl::flat_tree<int, key_of_value_t, std::less<int>, void> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_multiset, default) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// flat_multiset, vector
|
||||
{
|
||||
typedef boost::container::vector<int> alloc_or_cont_t;
|
||||
typedef boost::container::flat_multiset<int, std::less<int>, alloc_or_cont_t> cont;
|
||||
typedef boost::container::dtl::flat_tree<int, key_of_value_t, std::less<int>, alloc_or_cont_t> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_multiset, vector) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// flat_multiset, std::vector
|
||||
{
|
||||
typedef std::vector<int> alloc_or_cont_t;
|
||||
typedef boost::container::flat_multiset<int, std::less<int>, alloc_or_cont_t> cont;
|
||||
typedef boost::container::dtl::flat_tree<int, key_of_value_t, std::less<int>, alloc_or_cont_t> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(flat_multiset, std::vector) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,8 @@
|
||||
#include <boost/container/stable_vector.hpp>
|
||||
#include <boost/container/static_vector.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "movable_int.hpp"
|
||||
#include "dummy_test_allocator.hpp"
|
||||
|
||||
@@ -120,5 +122,35 @@ template class flat_tree
|
||||
|
||||
int main ()
|
||||
{
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
// default
|
||||
{
|
||||
typedef boost::container::dtl::flat_tree<int, boost::container::dtl::identity<int>,
|
||||
std::less<int>, void> tree;
|
||||
typedef tree::container_type container_type;
|
||||
typedef tree::key_compare key_compare;
|
||||
if (boost::has_trivial_destructor_after_move<tree>::value !=
|
||||
boost::has_trivial_destructor_after_move<container_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<key_compare>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::dtl::flat_tree<int, boost::container::dtl::identity<int>,
|
||||
std::less<int>, std::allocator<int> > tree;
|
||||
typedef tree::container_type container_type;
|
||||
typedef tree::key_compare key_compare;
|
||||
if (boost::has_trivial_destructor_after_move<tree>::value !=
|
||||
boost::has_trivial_destructor_after_move<container_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<key_compare>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -252,6 +252,34 @@ int main ()
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
// default allocator
|
||||
{
|
||||
typedef boost::container::list<int> cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::list<int, std::allocator<int> > cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -633,6 +633,60 @@ int main ()
|
||||
BOOST_STATIC_ASSERT(sizeof(rbmmap_size_optimized_yes) < sizeof(rbmap_size_optimized_no));
|
||||
BOOST_STATIC_ASSERT(sizeof(avlmap_size_optimized_yes) < sizeof(avlmmap_size_optimized_no));
|
||||
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
{
|
||||
typedef std::pair<const int, int> value_type;
|
||||
//
|
||||
// map
|
||||
//
|
||||
// default allocator
|
||||
{
|
||||
typedef boost::container::map<int, int> cont;
|
||||
typedef boost::container::dtl::tree<value_type, int, std::less<int>, void, void> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(map, default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::map<int, int, std::less<int>, std::allocator<value_type> > cont;
|
||||
typedef boost::container::dtl::tree<value_type, int, std::less<int>, std::allocator<value_type>, void> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(map, std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//
|
||||
// multimap
|
||||
//
|
||||
// default allocator
|
||||
{
|
||||
// default allocator
|
||||
typedef boost::container::multimap<int, int> cont;
|
||||
typedef boost::container::dtl::tree<value_type, int, std::less<int>, void, void> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(multimap, default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::multimap<int, int, std::less<int>, std::allocator<value_type> > cont;
|
||||
typedef boost::container::dtl::tree<value_type, int, std::less<int>, std::allocator<value_type>, void> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(multimap, std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -605,6 +605,50 @@ int main ()
|
||||
if(!node_type_test())
|
||||
return 1;
|
||||
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
// set, default allocator
|
||||
{
|
||||
typedef boost::container::set<int> cont;
|
||||
typedef boost::container::dtl::tree<int, void, std::less<int>, void, void> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(set, default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// set, std::allocator
|
||||
{
|
||||
typedef boost::container::set<int, std::less<int>, std::allocator<int> > cont;
|
||||
typedef boost::container::dtl::tree<int, void, std::less<int>, std::allocator<int>, void> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(set, std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// multiset, default allocator
|
||||
{
|
||||
typedef boost::container::multiset<int> cont;
|
||||
typedef boost::container::dtl::tree<int, void, std::less<int>, void, void> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(multiset, default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// multiset, std::allocator
|
||||
{
|
||||
typedef boost::container::multiset<int, std::less<int>, std::allocator<int> > cont;
|
||||
typedef boost::container::dtl::tree<int, void, std::less<int>, std::allocator<int>, void> tree;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<tree>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(multiset, std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -255,6 +255,34 @@ int main ()
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
// default allocator
|
||||
{
|
||||
typedef boost::container::slist<int> cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::slist<int, std::allocator<int> > cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
110
test/small_vector_options_test.cpp
Normal file
110
test/small_vector_options_test.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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/small_vector.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
using namespace boost::container;
|
||||
|
||||
const std::size_t Capacity = 10u;
|
||||
|
||||
void test_alignment()
|
||||
{
|
||||
{ //extended alignment
|
||||
const std::size_t extended_alignment = sizeof(int)*4u;
|
||||
BOOST_STATIC_ASSERT(extended_alignment > dtl::alignment_of<int>::value);
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = small_vector_options_t< inplace_alignment<extended_alignment> >;
|
||||
#else
|
||||
typedef small_vector_options
|
||||
< inplace_alignment<extended_alignment> >::type options_t;
|
||||
#endif
|
||||
|
||||
small_vector<int, Capacity, void, options_t> v;
|
||||
v.resize(v.capacity());
|
||||
BOOST_ASSERT((reinterpret_cast<std::size_t>(&v[0]) % extended_alignment) == 0);
|
||||
}
|
||||
{ //default alignment
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = small_vector_options_t< inplace_alignment<0> >;
|
||||
#else
|
||||
typedef small_vector_options< inplace_alignment<0> >::type options_t;
|
||||
#endif
|
||||
|
||||
small_vector<int, Capacity, void, options_t> v;
|
||||
v.resize(v.capacity());
|
||||
BOOST_ASSERT((reinterpret_cast<std::size_t>(&v[0]) % dtl::alignment_of<int>::value) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
void test_growth_factor_50()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = small_vector_options_t< growth_factor<growth_factor_50> >;
|
||||
#else
|
||||
typedef small_vector_options
|
||||
< growth_factor<growth_factor_50> >::type options_t;
|
||||
#endif
|
||||
|
||||
small_vector<int, Capacity, new_allocator<int>, options_t> v;
|
||||
|
||||
v.resize(5);
|
||||
v.resize(v.capacity());
|
||||
std::size_t old_capacity = v.capacity();
|
||||
v.push_back(0);
|
||||
std::size_t new_capacity = v.capacity();
|
||||
BOOST_TEST(new_capacity == old_capacity + old_capacity/2);
|
||||
}
|
||||
|
||||
void test_growth_factor_60()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = small_vector_options_t< growth_factor<growth_factor_60> >;
|
||||
#else
|
||||
typedef small_vector_options
|
||||
< growth_factor<growth_factor_60> >::type options_t;
|
||||
#endif
|
||||
|
||||
small_vector<int, Capacity, new_allocator<int>, options_t> v;
|
||||
|
||||
v.resize(5);
|
||||
v.resize(v.capacity());
|
||||
std::size_t old_capacity = v.capacity();
|
||||
v.push_back(0);
|
||||
std::size_t new_capacity = v.capacity();
|
||||
BOOST_TEST(new_capacity == old_capacity + 3*old_capacity/5);
|
||||
}
|
||||
|
||||
void test_growth_factor_100()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = small_vector_options_t< growth_factor<growth_factor_100> >;
|
||||
#else
|
||||
typedef small_vector_options
|
||||
< growth_factor<growth_factor_100> >::type options_t;
|
||||
#endif
|
||||
|
||||
small_vector<int, Capacity, new_allocator<int>, options_t> v;
|
||||
|
||||
v.resize(5);
|
||||
v.resize(v.capacity());
|
||||
std::size_t old_capacity = v.capacity();
|
||||
v.push_back(0);
|
||||
std::size_t new_capacity = v.capacity();
|
||||
BOOST_TEST(new_capacity == 2*old_capacity);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_alignment();
|
||||
test_growth_factor_50();
|
||||
test_growth_factor_60();
|
||||
test_growth_factor_100();
|
||||
return ::boost::report_errors();
|
||||
}
|
@@ -212,5 +212,25 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
// default allocator
|
||||
{
|
||||
typedef boost::container::small_vector<int, 0> cont;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::small_vector<int, 0, std::allocator<int> > cont;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -193,6 +193,34 @@ int main()
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
// default allocator
|
||||
{
|
||||
typedef boost::container::stable_vector<int> cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::stable_vector<int, std::allocator<int> > cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
124
test/static_vector_options_test.cpp
Normal file
124
test/static_vector_options_test.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||
#include <boost/container/static_vector.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <new> //for bad_alloc
|
||||
#include <boost/assert.hpp>
|
||||
using namespace boost::container;
|
||||
|
||||
//User-defined assertion to test throw_on_overflow
|
||||
struct throw_on_overflow_off
|
||||
{};
|
||||
|
||||
namespace boost {
|
||||
void assertion_failed(char const *, char const *, char const *, long)
|
||||
{
|
||||
throw throw_on_overflow_off();
|
||||
}
|
||||
|
||||
void assertion_failed_msg(char const *, char const *, char const *, char const *, long )
|
||||
{
|
||||
throw throw_on_overflow_off();
|
||||
}
|
||||
}
|
||||
|
||||
void test_alignment()
|
||||
{
|
||||
const std::size_t Capacity = 10u;
|
||||
{ //extended alignment
|
||||
const std::size_t extended_alignment = sizeof(int)*4u;
|
||||
BOOST_STATIC_ASSERT(extended_alignment > dtl::alignment_of<int>::value);
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = static_vector_options_t< inplace_alignment<extended_alignment> >;
|
||||
#else
|
||||
typedef static_vector_options
|
||||
< inplace_alignment<extended_alignment> >::type options_t;
|
||||
#endif
|
||||
|
||||
static_vector<int, Capacity, options_t> v;
|
||||
v.resize(v.capacity());
|
||||
BOOST_ASSERT((reinterpret_cast<std::size_t>(&v[0]) % extended_alignment) == 0);
|
||||
}
|
||||
{ //default alignment
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = static_vector_options_t< inplace_alignment<0> >;
|
||||
#else
|
||||
typedef static_vector_options< inplace_alignment<0> >::type options_t;
|
||||
#endif
|
||||
|
||||
static_vector<int, Capacity, options_t> v;
|
||||
v.resize(v.capacity());
|
||||
BOOST_ASSERT((reinterpret_cast<std::size_t>(&v[0]) % dtl::alignment_of<int>::value) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
void test_throw_on_overflow()
|
||||
{
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
const std::size_t Capacity = 10u;
|
||||
{ //throw_on_overflow == true, expect bad_alloc
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = static_vector_options_t< throw_on_overflow<true> >;
|
||||
#else
|
||||
typedef static_vector_options
|
||||
< throw_on_overflow<true> >::type options_t;
|
||||
#endif
|
||||
|
||||
static_vector<int, Capacity, options_t> v;
|
||||
|
||||
v.resize(Capacity);
|
||||
bool expected_type_thrown = false;
|
||||
try{
|
||||
v.push_back(0);
|
||||
}
|
||||
catch(std::bad_alloc&)
|
||||
{
|
||||
expected_type_thrown = true;
|
||||
}
|
||||
catch(...)
|
||||
{}
|
||||
BOOST_TEST(expected_type_thrown == true);
|
||||
BOOST_TEST(v.capacity() == Capacity);
|
||||
}
|
||||
{ //throw_on_overflow == false, test it through BOOST_ASSERT
|
||||
//even in release mode (BOOST_ENABLE_ASSERT_HANDLER), and throwing
|
||||
//a special type in that assertion.
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = static_vector_options_t< throw_on_overflow<false> >;
|
||||
#else
|
||||
typedef static_vector_options< throw_on_overflow<false> >::type options_t;
|
||||
#endif
|
||||
|
||||
static_vector<int, Capacity, options_t> v;
|
||||
|
||||
v.resize(Capacity);
|
||||
bool expected_type_thrown = false;
|
||||
try{
|
||||
v.push_back(0);
|
||||
}
|
||||
catch(throw_on_overflow_off)
|
||||
{
|
||||
expected_type_thrown = true;
|
||||
}
|
||||
catch(...)
|
||||
{}
|
||||
BOOST_TEST(expected_type_thrown == true);
|
||||
BOOST_TEST(v.capacity() == Capacity);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_alignment();
|
||||
test_throw_on_overflow();
|
||||
return ::boost::report_errors();
|
||||
}
|
@@ -562,6 +562,34 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
// default allocator
|
||||
{
|
||||
typedef boost::container::basic_string<char> cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::basic_string<char, std::char_traits<char>, std::allocator<char> > cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,10 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/container/detail/tree.hpp>
|
||||
#include <boost/container/adaptive_pool.hpp>
|
||||
#include <boost/container/new_allocator.hpp>
|
||||
#include <boost/move/traits.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "movable_int.hpp"
|
||||
#include "dummy_test_allocator.hpp"
|
||||
@@ -79,5 +83,37 @@ template class tree
|
||||
|
||||
int main ()
|
||||
{
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
// default
|
||||
{
|
||||
typedef boost::container::dtl::tree<int, void, std::less<int>, void, void> tree;
|
||||
typedef tree::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
typedef tree::key_compare key_compare;
|
||||
if (boost::has_trivial_destructor_after_move<tree>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
boost::has_trivial_destructor_after_move<key_compare>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::dtl::tree<int, void, std::less<int>, std::allocator<int>, void> tree;
|
||||
typedef tree::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
typedef tree::key_compare key_compare;
|
||||
if (boost::has_trivial_destructor_after_move<tree>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value &&
|
||||
boost::has_trivial_destructor_after_move<key_compare>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -332,5 +332,33 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// has_trivial_destructor_after_move testing
|
||||
////////////////////////////////////
|
||||
// default allocator
|
||||
{
|
||||
typedef boost::container::vector<int> cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::vector<int, std::allocator<int> > cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
if (boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
boost::has_trivial_destructor_after_move<allocator_type>::value &&
|
||||
boost::has_trivial_destructor_after_move<pointer>::value) {
|
||||
std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user