mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 14:04:26 +02:00
Marked vector iterator and boost::interprocess::offset_ptr as contiguous storage iterators to speed up insertion in vector with trivially copyable types.
[SVN r83416]
This commit is contained in:
@@ -183,12 +183,74 @@ struct are_elements_contiguous
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
/////////////////////////
|
||||
// raw pointers
|
||||
/////////////////////////
|
||||
|
||||
template<class T>
|
||||
struct are_elements_contiguous<T*>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
/////////////////////////
|
||||
// predeclarations
|
||||
/////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||
|
||||
template<class Pointer>
|
||||
class vector_iterator;
|
||||
|
||||
template<class Pointer>
|
||||
class vector_const_iterator;
|
||||
|
||||
#endif //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||
|
||||
} //namespace container_detail {
|
||||
} //namespace container {
|
||||
|
||||
namespace interprocess {
|
||||
|
||||
template <class PointedType, class DifferenceType, class OffsetType, std::size_t OffsetAlignment>
|
||||
class offset_ptr;
|
||||
|
||||
} //namespace interprocess {
|
||||
|
||||
namespace container {
|
||||
|
||||
namespace container_detail {
|
||||
|
||||
/////////////////////////
|
||||
//vector_[const_]iterator
|
||||
/////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||
|
||||
template<class Pointer>
|
||||
struct are_elements_contiguous<boost::container::container_detail::vector_iterator<Pointer> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<class Pointer>
|
||||
struct are_elements_contiguous<boost::container::container_detail::vector_const_iterator<Pointer> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
#endif //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||
|
||||
/////////////////////////
|
||||
// offset_ptr
|
||||
/////////////////////////
|
||||
|
||||
template <class PointedType, class DifferenceType, class OffsetType, std::size_t OffsetAlignment>
|
||||
struct are_elements_contiguous< ::boost::interprocess::offset_ptr<PointedType, DifferenceType, OffsetType, OffsetAlignment> >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template <typename I, typename O>
|
||||
struct are_contiguous_and_same
|
||||
{
|
||||
|
@@ -83,6 +83,11 @@ bool vector_copyable_only(V1 *boostvector, V2 *stdvector, boost::container::cont
|
||||
{
|
||||
V1 *pv1 = new V1(*boostvector);
|
||||
V2 *pv2 = new V2(*stdvector);
|
||||
boostvector->clear();
|
||||
stdvector->clear();
|
||||
boostvector->assign(pv1->begin(), pv1->end());
|
||||
stdvector->assign(pv2->begin(), pv2->end());
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
delete pv1;
|
||||
delete pv2;
|
||||
}
|
||||
|
Reference in New Issue
Block a user