mirror of
https://github.com/boostorg/container.git
synced 2026-02-22 15:22:14 +00:00
Rename segmented_vector to segtor, to reserve "vector" name to contiguous memory containers.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
#include <boost/container/devector.hpp>
|
||||
#include <boost/container/small_vector.hpp>
|
||||
#include <boost/container/stable_vector.hpp>
|
||||
#include <boost/container/segmented_vector.hpp>
|
||||
#include <boost/container/segtor.hpp>
|
||||
#include <iomanip>
|
||||
|
||||
#include <memory> //std::allocator
|
||||
@@ -447,9 +447,9 @@ void test_vectors_impl()
|
||||
vector_test_template< bc::deque<IntType, std::allocator<IntType> >, Operation >(numit[i], numele[i], "deque ", bp);
|
||||
vector_test_template< bc::deque<IntType, std::allocator<IntType>,
|
||||
typename bc::deque_options<bc::reservable<true> >::type >, Operation >(numit[i], numele[i], "deque(reserv) ", bp);
|
||||
vector_test_template< bc::segmented_vector<IntType, std::allocator<IntType> >, Operation >(numit[i], numele[i], "segmented_vec ", bp);
|
||||
vector_test_template< bc::segmented_vector<IntType, std::allocator<IntType>,
|
||||
typename bc::deque_options<bc::reservable<true> >::type >, Operation >(numit[i], numele[i], "seg_vec(reserv)", bp);
|
||||
vector_test_template< bc::segtor<IntType, std::allocator<IntType> >, Operation >(numit[i], numele[i], "segtor ", bp);
|
||||
vector_test_template< bc::segtor<IntType, std::allocator<IntType>,
|
||||
typename bc::segtor_options<bc::reservable<true> >::type >, Operation >(numit[i], numele[i], "segtor(reserv) ", bp);
|
||||
}
|
||||
std::cout << "---------------------------------\n---------------------------------\n";
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ In short, what does [*Boost.Container] offer?
|
||||
* New advanced features (e.g. recursive containers) and [link container.configurable_containers configurability options for containers].
|
||||
* Containers support stateful allocators and are compatible with [*Boost.Interprocess]
|
||||
(they can be safely placed in shared memory) offering improved performance vs standard containers when using Boost.Interprocess.
|
||||
* You have very useful non-standard containers like `[stable/static/small]_vector`, `flat_[multi]set/map`, `devector` or `segmented_vector`.
|
||||
* You have very useful non-standard containers like `[stable/static/small]_vector`, `flat_[multi]set/map`, `devector` or `segtor`.
|
||||
* If you work on multiple platforms, you'll have a portable behaviour without depending
|
||||
on the std-lib implementation conformance for each platform. Some examples:
|
||||
* [link container.extended_functionality Extended functionality] beyond the standard based
|
||||
@@ -63,7 +63,7 @@ In short, what does [*Boost.Container] offer?
|
||||
has to be increased. This minimum capacity is specified at compile time.
|
||||
* [classref boost::container::devector devector]: is a hybrid of the standard vector and deque containers.
|
||||
It offers cheap (amortized constant time) insertion at both the front and back ends.
|
||||
* [classref boost::container::segmented_vector segmented_vector]: a sequence container with segmented
|
||||
* [classref boost::container::segtor segtor]: a sequence container with segmented
|
||||
(block-based) storage like deque but only growth at the back; constant-time push_back/pop_back, random access.
|
||||
* [classref boost::container::slist slist]: the classic pre-standard singly linked list implementation
|
||||
offering constant-time `size()`. Note that C++11 `forward_list` has no `size()`.
|
||||
@@ -571,9 +571,9 @@ stateful allocators, etc.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:segmented_vector ['segmented_vector]]
|
||||
[section:segtor ['segtor]]
|
||||
|
||||
[classref boost::container::segmented_vector segmented_vector] is a sequence container that supports random access to elements, constant-time insertion and
|
||||
[classref boost::container::segtor segtor] is a sequence container that supports random access to elements, constant-time insertion and
|
||||
removal at the end, and linear-time insertion and removal in the middle. It uses the same segmented (block-based)
|
||||
storage as `deque` but only allows growth at the back: it provides `push_back`, `pop_back`, `emplace_back`, and the
|
||||
like, but does not provide `push_front`, `pop_front`, or `emplace_front`. In that sense it is the single-ended
|
||||
@@ -585,7 +585,7 @@ expensive to move or when growth is large. Inserting or erasing at the end does
|
||||
references/pointers to existing elements. Insertions and erasures in the middle invalidate iterators and references
|
||||
in the same way as for `deque`.
|
||||
|
||||
The container can be configured via [classref boost::container::segmented_vector_options segmented_vector_options]
|
||||
The container can be configured via [classref boost::container::segtor_options segtor_options]
|
||||
to control block size and other parameters.
|
||||
|
||||
[endsect]
|
||||
@@ -796,11 +796,11 @@ used to customize `small_vector`:
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:configurable_deque Configurable deque / segmented_vector]
|
||||
[section:configurable_deque Configurable deque / segtor]
|
||||
|
||||
The configuration for [classref boost::container::deque deque] / [classref boost::container::segmented_vector segmented_vector]
|
||||
The configuration for [classref boost::container::deque deque] / [classref boost::container::segtor segtor]
|
||||
is passed as the last template parameter and defined using the utility class
|
||||
[classref boost::container::deque_options deque_options] and [classref boost::container::segmented_vector_options segmented_vector_options] respectively.
|
||||
[classref boost::container::deque_options deque_options] and [classref boost::container::segtor_options segtor_options] respectively.
|
||||
The following parameters can be configured:
|
||||
|
||||
Parameters that control the size of container's 'block'/'segment' (the container allocates contiguous chunks of elements, called 'blocks'/'segments').
|
||||
@@ -826,11 +826,11 @@ used to customize `deque`:
|
||||
[import ../example/doc_custom_deque.cpp]
|
||||
[doc_custom_deque]
|
||||
|
||||
See the following example to see how [classref boost::container::segmented_vector_options segmented_vector_options] can be
|
||||
used to customize `segmented_vector`:
|
||||
See the following example to see how [classref boost::container::segtor_options segtor_options] can be
|
||||
used to customize `segtor`:
|
||||
|
||||
[import ../example/doc_custom_segmented_vector.cpp]
|
||||
[doc_custom_segmented_vector]
|
||||
[import ../example/doc_custom_segtor.cpp]
|
||||
[doc_custom_segtor]
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -1373,7 +1373,7 @@ This table shows the `sizeof` value of Boost.Container containers in 32 and 64 b
|
||||
[[`vector`] [12] [24] ]
|
||||
[[`deque`] [16] [32] ]
|
||||
[[`devector`] [16] [32] ]
|
||||
[[`segmented_vector`] [12] [24] ]
|
||||
[[`segtor`] [12] [24] ]
|
||||
[[`stable_vector`] [20] [40] ]
|
||||
[[`list`] [12] [24] ]
|
||||
[[`slist`] [8] [16] ]
|
||||
@@ -1483,7 +1483,7 @@ collect them containers and build [*Boost.Container], a library targeted to a wi
|
||||
* Added [classref boost::container::inline_chars inline_chars],
|
||||
[classref boost::container::growth_factor growth_factor] and
|
||||
[classref boost::container::stored_size stored_size] options to [classref boost::container::basic_string basic_string].
|
||||
* New [classref boost::container::segmented_vector segmented_vector] container: the single ended brother of
|
||||
* New [classref boost::container::segtor segtor] container: the single ended brother of
|
||||
[classref boost::container::deque deque]: a random-access sequence container with segmented
|
||||
(block-based) storage like deque but only growth at the back.
|
||||
* Fixed bugs/issues:
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2025. 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//[doc_custom_segmented_vector
|
||||
#include <boost/container/segmented_vector.hpp>
|
||||
|
||||
//Make sure assertions are active
|
||||
#ifdef NDEBUG
|
||||
#undef NDEBUG
|
||||
#endif
|
||||
#include <cassert>
|
||||
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::container;
|
||||
|
||||
//--------------------------------------------
|
||||
// 'stored_size' option
|
||||
//--------------------------------------------
|
||||
|
||||
//This option specifies that a segmented_vector will use "unsigned char" as
|
||||
//the type to store capacity or size internally.
|
||||
typedef segmented_vector_options< stored_size<unsigned char> >::type size_option_t;
|
||||
|
||||
//Size-optimized segmented_vector is smaller than the default one.
|
||||
typedef segmented_vector<int, new_allocator<int>, size_option_t > size_optimized_segmented_vector_t;
|
||||
assert(( sizeof(size_optimized_segmented_vector_t) < sizeof(segmented_vector<int>) ));
|
||||
|
||||
//Requesting capacity for more elements than representable by "unsigned char"
|
||||
//is an error in the size optimized segmented_vector.
|
||||
bool exception_thrown = false;
|
||||
/*<-*/
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
BOOST_CONTAINER_TRY{ size_optimized_segmented_vector_t v(256); } BOOST_CONTAINER_CATCH(...){ exception_thrown = true; } BOOST_CONTAINER_CATCH_END
|
||||
#else
|
||||
exception_thrown = true;
|
||||
#endif //BOOST_NO_EXCEPTIONS
|
||||
/*->*/
|
||||
//=try { size_optimized_segmented_vector_t v(256); }
|
||||
//=catch(...){ exception_thrown = true; }
|
||||
|
||||
assert(exception_thrown == true);
|
||||
|
||||
//--------------------------------------------
|
||||
// 'block_size/segment_size' option
|
||||
//--------------------------------------------
|
||||
|
||||
//This option specifies the desired block size for segmented_vector
|
||||
typedef segmented_vector_options< block_size<128u> >::type block_128_option_t;
|
||||
|
||||
//segment_size is an alias for block_size (an alias for block_size)
|
||||
typedef segmented_vector_options< segment_size<128u> >::type segment_128_option_t;
|
||||
|
||||
//This segmented_vector will allocate blocks of 128 elements
|
||||
typedef segmented_vector<int, void, block_128_option_t > block_128_segmented_vector_t;
|
||||
assert(block_128_segmented_vector_t::get_block_size() == 128u);
|
||||
|
||||
//This segmented_vector will allocate segments of 128 elements (an alias for block_size)
|
||||
typedef segmented_vector<int, void, segment_128_option_t > segment_128_segmented_vector_t;
|
||||
assert(segment_128_segmented_vector_t::get_block_size() == 128u);
|
||||
|
||||
//--------------------------------------------
|
||||
// 'block_bytes/segment_bytes' option
|
||||
//--------------------------------------------
|
||||
|
||||
//This option specifies the maximum block size for segmented_vector
|
||||
//in bytes
|
||||
typedef segmented_vector_options< block_bytes<1024u> >::type block_1024_bytes_option_t;
|
||||
|
||||
//This option specifies the maximum segment size for segmented_vector
|
||||
//in bytes (an alias for block_bytes)
|
||||
typedef segmented_vector_options< segment_bytes<1024u> >::type segment_1024_bytes_option_t;
|
||||
|
||||
//This segmented_vector will allocate blocks of 1024 bytes
|
||||
typedef segmented_vector<int, void, block_1024_bytes_option_t > block_1024_bytes_segmented_vector_t;
|
||||
assert(block_1024_bytes_segmented_vector_t::get_block_size() == 1024u/sizeof(int));
|
||||
|
||||
//This segmented_vector will allocate blocks of 1024 bytes (an alias for block_bytes)
|
||||
typedef segmented_vector<int, void, segment_1024_bytes_option_t > segment_1024_bytes_segmented_vector_t;
|
||||
assert(segment_1024_bytes_segmented_vector_t::get_block_size() == 1024u/sizeof(int));
|
||||
|
||||
return 0;
|
||||
}
|
||||
//]
|
||||
90
example/doc_custom_segtor.cpp
Normal file
90
example/doc_custom_segtor.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2025. 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//[doc_custom_segtor
|
||||
#include <boost/container/segtor.hpp>
|
||||
|
||||
//Make sure assertions are active
|
||||
#ifdef NDEBUG
|
||||
#undef NDEBUG
|
||||
#endif
|
||||
#include <cassert>
|
||||
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::container;
|
||||
|
||||
//--------------------------------------------
|
||||
// 'stored_size' option
|
||||
//--------------------------------------------
|
||||
|
||||
//This option specifies that a segtor will use "unsigned char" as
|
||||
//the type to store capacity or size internally.
|
||||
typedef segtor_options< stored_size<unsigned char> >::type size_option_t;
|
||||
|
||||
//Size-optimized segtor is smaller than the default one.
|
||||
typedef segtor<int, new_allocator<int>, size_option_t > size_optimized_segtor_t;
|
||||
assert(( sizeof(size_optimized_segtor_t) < sizeof(segtor<int>) ));
|
||||
|
||||
//Requesting capacity for more elements than representable by "unsigned char"
|
||||
//is an error in the size optimized segtor.
|
||||
bool exception_thrown = false;
|
||||
/*<-*/
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
BOOST_CONTAINER_TRY{ size_optimized_segtor_t v(256); } BOOST_CONTAINER_CATCH(...){ exception_thrown = true; } BOOST_CONTAINER_CATCH_END
|
||||
#else
|
||||
exception_thrown = true;
|
||||
#endif //BOOST_NO_EXCEPTIONS
|
||||
/*->*/
|
||||
//=try { size_optimized_segtor_t v(256); }
|
||||
//=catch(...){ exception_thrown = true; }
|
||||
|
||||
assert(exception_thrown == true);
|
||||
|
||||
//--------------------------------------------
|
||||
// 'block_size/segment_size' option
|
||||
//--------------------------------------------
|
||||
|
||||
//This option specifies the desired block size for segtor
|
||||
typedef segtor_options< block_size<128u> >::type block_128_option_t;
|
||||
|
||||
//segment_size is an alias for block_size (an alias for block_size)
|
||||
typedef segtor_options< segment_size<128u> >::type segment_128_option_t;
|
||||
|
||||
//This segtor will allocate blocks of 128 elements
|
||||
typedef segtor<int, void, block_128_option_t > block_128_segtor_t;
|
||||
assert(block_128_segtor_t::get_block_size() == 128u);
|
||||
|
||||
//This segtor will allocate segments of 128 elements (an alias for block_size)
|
||||
typedef segtor<int, void, segment_128_option_t > segment_128_segtor_t;
|
||||
assert(segment_128_segtor_t::get_block_size() == 128u);
|
||||
|
||||
//--------------------------------------------
|
||||
// 'block_bytes/segment_bytes' option
|
||||
//--------------------------------------------
|
||||
|
||||
//This option specifies the maximum block size for segtor
|
||||
//in bytes
|
||||
typedef segtor_options< block_bytes<1024u> >::type block_1024_bytes_option_t;
|
||||
|
||||
//This option specifies the maximum segment size for segtor
|
||||
//in bytes (an alias for block_bytes)
|
||||
typedef segtor_options< segment_bytes<1024u> >::type segment_1024_bytes_option_t;
|
||||
|
||||
//This segtor will allocate blocks of 1024 bytes
|
||||
typedef segtor<int, void, block_1024_bytes_option_t > block_1024_bytes_segtor_t;
|
||||
assert(block_1024_bytes_segtor_t::get_block_size() == 1024u/sizeof(int));
|
||||
|
||||
//This segtor will allocate blocks of 1024 bytes (an alias for block_bytes)
|
||||
typedef segtor<int, void, segment_1024_bytes_option_t > segment_1024_bytes_segtor_t;
|
||||
assert(segment_1024_bytes_segtor_t::get_block_size() == 1024u/sizeof(int));
|
||||
|
||||
return 0;
|
||||
}
|
||||
//]
|
||||
@@ -30,7 +30,7 @@
|
||||
//! - boost::container::small_vector
|
||||
//! - boost::container::devector
|
||||
//! - boost::container::deque
|
||||
//! - boost::container::segmented_vector
|
||||
//! - boost::container::segtor
|
||||
//! - boost::container::slist
|
||||
//! - boost::container::list
|
||||
//! - boost::container::set
|
||||
@@ -137,7 +137,7 @@ class deque;
|
||||
template <class T
|
||||
,class Allocator = void
|
||||
,class Options = void>
|
||||
class segmented_vector;
|
||||
class segtor;
|
||||
|
||||
template <class T
|
||||
,class Allocator = void >
|
||||
|
||||
@@ -700,7 +700,7 @@ using deque_options_t = typename boost::container::deque_options<Options...>::ty
|
||||
////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// OPTIONS FOR SEGMENTED_VECTOR CONTAINERS
|
||||
// OPTIONS FOR SEGTOR CONTAINERS
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -708,25 +708,25 @@ using deque_options_t = typename boost::container::deque_options<Options...>::ty
|
||||
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
|
||||
template<std::size_t BlockBytes, std::size_t BlockSize, class StoredSizeType, bool Reservable>
|
||||
struct segmented_vector_opt : public deque_opt<BlockBytes, BlockSize, StoredSizeType, Reservable>
|
||||
struct segtor_opt : public deque_opt<BlockBytes, BlockSize, StoredSizeType, Reservable>
|
||||
{};
|
||||
|
||||
typedef segmented_vector_opt<0u, 0u, void, false> segmented_vector_null_opt;
|
||||
typedef segtor_opt<0u, 0u, void, false> segtor_null_opt;
|
||||
|
||||
#endif
|
||||
|
||||
//! Helper metafunction to combine options into a single type to be used
|
||||
//! by \c boost::container::segmented_vector.
|
||||
//! by \c boost::container::segtor.
|
||||
//! Supported options are: \c boost::container::block_bytes / \c boost::container::segment_bytes,
|
||||
//! \c boost::container::block_size / \c boost::container::segment_size,
|
||||
//! \c boost::container::stored_size
|
||||
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
|
||||
template<class ...Options>
|
||||
struct segmented_vector_options
|
||||
struct segtor_options
|
||||
: deque_options<Options...>
|
||||
#else
|
||||
template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
|
||||
struct segmented_vector_options
|
||||
struct segtor_options
|
||||
: deque_options<O1, O2, O3, O4>
|
||||
#endif
|
||||
{};
|
||||
@@ -734,9 +734,9 @@ struct segmented_vector_options
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
|
||||
//! Helper alias metafunction to combine options into a single type to be used
|
||||
//! by \c boost::container::segmented_vector.
|
||||
//! by \c boost::container::segtor.
|
||||
template<class ...Options>
|
||||
using segmented_vector_options_t = typename boost::container::segmented_vector_options<Options...>::type;
|
||||
using segtor_options_t = typename boost::container::segtor_options<Options...>::type;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -808,7 +808,7 @@ BOOST_INTRUSIVE_OPTION_CONSTANT(segment_bytes, std::size_t, SegmentBytes, block_
|
||||
|
||||
//!This option specifies the size of a block, delimites the number of contiguous elements (BlockSize)
|
||||
//!that will be allocated by segmented containers.
|
||||
//!For some containers (like deque/segmented_vector), a power of two value can improve performance.
|
||||
//!For some containers (like deque/segtor), a power of two value can improve performance.
|
||||
//!A value zero represents the default value.
|
||||
//!
|
||||
//!\tparam BlockBytes An unsigned integer value.
|
||||
@@ -823,7 +823,7 @@ BOOST_INTRUSIVE_OPTION_CONSTANT(segment_size, std::size_t, SegmentSize, block_si
|
||||
|
||||
//!This option specifies if the container has reserve/capacity-like features
|
||||
//!
|
||||
//!For some containers (like deque/segmented_vector) this option might change the internal representation or
|
||||
//!For some containers (like deque/segtor) this option might change the internal representation or
|
||||
//!behavior so that memory for elements can be allocated in advance in
|
||||
//!order to improve performance.
|
||||
//!
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_PMR_SEGMENTED_VECTOR_HPP
|
||||
#define BOOST_CONTAINER_PMR_SEGMENTED_VECTOR_HPP
|
||||
#ifndef BOOST_CONTAINER_PMR_SEGTOR_HPP
|
||||
#define BOOST_CONTAINER_PMR_SEGTOR_HPP
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/container/segmented_vector.hpp>
|
||||
#include <boost/container/segtor.hpp>
|
||||
#include <boost/container/pmr/polymorphic_allocator.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -25,16 +25,16 @@ namespace pmr {
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
|
||||
template <class T>
|
||||
using segmented_vector = boost::container::segmented_vector<T, polymorphic_allocator<T>>;
|
||||
using segtor = boost::container::segtor<T, polymorphic_allocator<T>>;
|
||||
|
||||
#endif
|
||||
|
||||
//! A portable metafunction to obtain a segmented_vector
|
||||
//! A portable metafunction to obtain a segtor
|
||||
//! that uses a polymorphic allocator.
|
||||
template<class T>
|
||||
struct segmented_vector_of
|
||||
struct segtor_of
|
||||
{
|
||||
typedef boost::container::segmented_vector
|
||||
typedef boost::container::segtor
|
||||
< T, polymorphic_allocator<T> > type;
|
||||
};
|
||||
|
||||
@@ -42,4 +42,4 @@ struct segmented_vector_of
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
#endif //BOOST_CONTAINER_PMR_SEGMENTED_VECTOR_HPP
|
||||
#endif //BOOST_CONTAINER_PMR_SEGTOR_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2025. Distributed under the Boost
|
||||
// (C) Copyright Ion Gaztanaga 2026. 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)
|
||||
//
|
||||
@@ -8,8 +8,8 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BOOST_CONTAINER_SEGMENTED_VECTOR_HPP
|
||||
#define BOOST_CONTAINER_SEGMENTED_VECTOR_HPP
|
||||
#ifndef BOOST_CONTAINER_SEGTOR_HPP
|
||||
#define BOOST_CONTAINER_SEGTOR_HPP
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
# include <boost/config.hpp>
|
||||
@@ -27,27 +27,26 @@ namespace boost {
|
||||
namespace container {
|
||||
|
||||
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
//! A segmented vector is a sequence container that supports random access to elements,
|
||||
//! constant time insertion and removal of elements at the end, and linear time
|
||||
//! insertion and removal of elements in the middle. It uses the same segmented
|
||||
//! (block-based) storage as deque but only allows growth at the back.
|
||||
//! A segtor (contraction of "segmented vector" is a sequence container that supports
|
||||
//! random access to elements, constant time insertion and removal of elements at
|
||||
//! the end, and linear time insertion and removal of elements in the middle.
|
||||
//!
|
||||
//! This is the single-ended version of boost::container::deque: it provides
|
||||
//! It's the single-ended version of boost::container::deque: it provides
|
||||
//! push_back, pop_back, emplace_back, etc., but does not provide push_front,
|
||||
//! pop_front, or emplace_front.
|
||||
//!
|
||||
//! \tparam T The type of object that is stored in the segmented_vector
|
||||
//! \tparam T The type of object that is stored in the segtor
|
||||
//! \tparam Allocator The allocator used for all internal memory management, use void
|
||||
//! for the default allocator
|
||||
//! \tparam Options A type produced from \c boost::container::segmented_vector_options.
|
||||
//! \tparam Options A type produced from \c boost::container::segtor_options.
|
||||
template <class T, class Allocator = void, class Options = void>
|
||||
#else
|
||||
template <class T, class Allocator, class Options>
|
||||
#endif
|
||||
class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
class segtor : public deque_impl<T, Allocator, true, Options>
|
||||
{
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
BOOST_COPYABLE_AND_MOVABLE(segmented_vector)
|
||||
BOOST_COPYABLE_AND_MOVABLE(segtor)
|
||||
typedef deque_impl<T, Allocator, true, Options> base_type;
|
||||
#endif
|
||||
|
||||
@@ -84,37 +83,37 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//
|
||||
//////////////////////////////////////////////
|
||||
|
||||
//! <b>Effects</b>: Default constructs a segmented_vector.
|
||||
//! <b>Effects</b>: Default constructs a segtor.
|
||||
//!
|
||||
//! <b>Throws</b>: If allocator_type's default constructor throws.
|
||||
//!
|
||||
//! <b>Complexity</b>: Constant.
|
||||
segmented_vector()
|
||||
segtor()
|
||||
BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<allocator_type>::value)
|
||||
: base_type()
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Constructs a segmented_vector taking the allocator as parameter.
|
||||
//! <b>Effects</b>: Constructs a segtor taking the allocator as parameter.
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing
|
||||
//!
|
||||
//! <b>Complexity</b>: Constant.
|
||||
explicit segmented_vector(const allocator_type& a) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
explicit segtor(const allocator_type& a) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
: base_type(a)
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Constructs a segmented_vector
|
||||
//! <b>Effects</b>: Constructs a segtor
|
||||
//! and inserts n value initialized values.
|
||||
//!
|
||||
//! <b>Throws</b>: If allocator_type's default constructor
|
||||
//! throws or T's value initialization throws.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to n.
|
||||
explicit segmented_vector(size_type n)
|
||||
explicit segtor(size_type n)
|
||||
: base_type(n)
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Constructs a segmented_vector
|
||||
//! <b>Effects</b>: Constructs a segtor
|
||||
//! and inserts n default initialized values.
|
||||
//!
|
||||
//! <b>Throws</b>: If allocator_type's default constructor
|
||||
@@ -123,22 +122,22 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//! <b>Complexity</b>: Linear to n.
|
||||
//!
|
||||
//! <b>Note</b>: Non-standard extension
|
||||
segmented_vector(size_type n, default_init_t)
|
||||
segtor(size_type n, default_init_t)
|
||||
: base_type(n, default_init)
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Constructs a segmented_vector that will use a copy of allocator a
|
||||
//! <b>Effects</b>: Constructs a segtor that will use a copy of allocator a
|
||||
//! and inserts n value initialized values.
|
||||
//!
|
||||
//! <b>Throws</b>: If allocator_type's default constructor
|
||||
//! throws or T's value initialization throws.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to n.
|
||||
explicit segmented_vector(size_type n, const allocator_type& a)
|
||||
explicit segtor(size_type n, const allocator_type& a)
|
||||
: base_type(n, a)
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Constructs a segmented_vector that will use a copy of allocator a
|
||||
//! <b>Effects</b>: Constructs a segtor that will use a copy of allocator a
|
||||
//! and inserts n default initialized values.
|
||||
//!
|
||||
//! <b>Throws</b>: If allocator_type's default constructor
|
||||
@@ -147,33 +146,33 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//! <b>Complexity</b>: Linear to n.
|
||||
//!
|
||||
//! <b>Note</b>: Non-standard extension
|
||||
segmented_vector(size_type n, default_init_t, const allocator_type& a)
|
||||
segtor(size_type n, default_init_t, const allocator_type& a)
|
||||
: base_type(n, default_init, a)
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Constructs a segmented_vector that will use a copy of allocator a
|
||||
//! <b>Effects</b>: Constructs a segtor that will use a copy of allocator a
|
||||
//! and inserts n copies of value.
|
||||
//!
|
||||
//! <b>Throws</b>: If allocator_type's default constructor
|
||||
//! throws or T's copy constructor throws.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to n.
|
||||
segmented_vector(size_type n, const value_type& value)
|
||||
segtor(size_type n, const value_type& value)
|
||||
: base_type(n, value)
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Constructs a segmented_vector that will use a copy of allocator a
|
||||
//! <b>Effects</b>: Constructs a segtor that will use a copy of allocator a
|
||||
//! and inserts n copies of value.
|
||||
//!
|
||||
//! <b>Throws</b>: If allocator_type's default constructor
|
||||
//! throws or T's copy constructor throws.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to n.
|
||||
segmented_vector(size_type n, const value_type& value, const allocator_type& a)
|
||||
segtor(size_type n, const value_type& value, const allocator_type& a)
|
||||
: base_type(n, value, a)
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Constructs a segmented_vector that will use a copy of allocator a
|
||||
//! <b>Effects</b>: Constructs a segtor that will use a copy of allocator a
|
||||
//! and inserts a copy of the range [first, last).
|
||||
//!
|
||||
//! <b>Throws</b>: If allocator_type's default constructor
|
||||
@@ -181,7 +180,7 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the range [first, last).
|
||||
template <class InIt>
|
||||
segmented_vector(InIt first, InIt last
|
||||
segtor(InIt first, InIt last
|
||||
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
, typename dtl::disable_if_convertible<InIt, size_type>::type* = 0
|
||||
#endif
|
||||
@@ -189,7 +188,7 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
: base_type(first, last)
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Constructs a segmented_vector that will use a copy of allocator a
|
||||
//! <b>Effects</b>: Constructs a segtor that will use a copy of allocator a
|
||||
//! and inserts a copy of the range [first, last).
|
||||
//!
|
||||
//! <b>Throws</b>: If allocator_type's default constructor
|
||||
@@ -197,7 +196,7 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the range [first, last).
|
||||
template <class InIt>
|
||||
segmented_vector(InIt first, InIt last, const allocator_type& a
|
||||
segtor(InIt first, InIt last, const allocator_type& a
|
||||
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
, typename dtl::disable_if_convertible<InIt, size_type>::type* = 0
|
||||
#endif
|
||||
@@ -206,24 +205,24 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
{}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
//! <b>Effects</b>: Constructs a segmented_vector that will use a copy of allocator a
|
||||
//! <b>Effects</b>: Constructs a segtor that will use a copy of allocator a
|
||||
//! and inserts a copy of the range [il.begin(), il.end()).
|
||||
//!
|
||||
//! <b>Throws</b>: If allocator_type's default constructor
|
||||
//! throws or T's constructor taking a dereferenced std::initializer_list iterator throws.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the range [il.begin(), il.end()).
|
||||
segmented_vector(std::initializer_list<value_type> il, const allocator_type& a = allocator_type())
|
||||
segtor(std::initializer_list<value_type> il, const allocator_type& a = allocator_type())
|
||||
: base_type(il, a)
|
||||
{}
|
||||
#endif
|
||||
|
||||
//! <b>Effects</b>: Copy constructs a segmented_vector.
|
||||
//! <b>Effects</b>: Copy constructs a segtor.
|
||||
//!
|
||||
//! <b>Postcondition</b>: x == *this.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the elements x contains.
|
||||
segmented_vector(const segmented_vector& x)
|
||||
segtor(const segtor& x)
|
||||
: base_type(x)
|
||||
{}
|
||||
|
||||
@@ -232,11 +231,11 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//! <b>Throws</b>: If allocator_type's copy constructor throws.
|
||||
//!
|
||||
//! <b>Complexity</b>: Constant.
|
||||
segmented_vector(BOOST_RV_REF(segmented_vector) x) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
segtor(BOOST_RV_REF(segtor) x) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
: base_type(boost::move(static_cast<base_type&>(x)))
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Copy constructs a segmented_vector using the specified allocator.
|
||||
//! <b>Effects</b>: Copy constructs a segtor using the specified allocator.
|
||||
//!
|
||||
//! <b>Postcondition</b>: x == *this.
|
||||
//!
|
||||
@@ -244,7 +243,7 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//! throws or T's copy constructor throws.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the elements x contains.
|
||||
segmented_vector(const segmented_vector& x, const allocator_type& a)
|
||||
segtor(const segtor& x, const allocator_type& a)
|
||||
: base_type(x, a)
|
||||
{}
|
||||
|
||||
@@ -255,17 +254,17 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//! <b>Throws</b>: If allocation or T's copy constructor throws.
|
||||
//!
|
||||
//! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
|
||||
segmented_vector(BOOST_RV_REF(segmented_vector) x, const allocator_type& a)
|
||||
segtor(BOOST_RV_REF(segtor) x, const allocator_type& a)
|
||||
: base_type(boost::move(static_cast<base_type&>(x)), a)
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Destroys the segmented_vector. All stored values are destroyed
|
||||
//! <b>Effects</b>: Destroys the segtor. All stored values are destroyed
|
||||
//! and used memory is deallocated.
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements.
|
||||
~segmented_vector() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
~segtor() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{}
|
||||
|
||||
//! <b>Effects</b>: Makes *this contain the same elements as x.
|
||||
@@ -276,7 +275,7 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements in x.
|
||||
segmented_vector& operator=(BOOST_COPY_ASSIGN_REF(segmented_vector) x)
|
||||
segtor& operator=(BOOST_COPY_ASSIGN_REF(segtor) x)
|
||||
{
|
||||
base_type::operator=(static_cast<const base_type&>(x));
|
||||
return *this;
|
||||
@@ -290,7 +289,7 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//! <b>Complexity</b>: Constant if allocator_traits_type::
|
||||
//! propagate_on_container_move_assignment is true or
|
||||
//! this->get_allocator() == x.get_allocator(). Linear otherwise.
|
||||
segmented_vector& operator=(BOOST_RV_REF(segmented_vector) x)
|
||||
segtor& operator=(BOOST_RV_REF(segtor) x)
|
||||
BOOST_NOEXCEPT_IF(allocator_traits<allocator_type>::propagate_on_container_move_assignment::value
|
||||
|| allocator_traits<allocator_type>::is_always_equal::value)
|
||||
{
|
||||
@@ -307,7 +306,7 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements in il.
|
||||
segmented_vector& operator=(std::initializer_list<value_type> il)
|
||||
segtor& operator=(std::initializer_list<value_type> il)
|
||||
{
|
||||
base_type::operator=(il);
|
||||
return *this;
|
||||
@@ -790,55 +789,55 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
//! <b>Throws</b>: Nothing.
|
||||
//!
|
||||
//! <b>Complexity</b>: Constant.
|
||||
void swap(segmented_vector& x);
|
||||
void swap(segtor& x);
|
||||
#endif //#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//! <b>Effects</b>: Returns true if x and y are equal
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements in the container.
|
||||
BOOST_CONTAINER_NODISCARD inline
|
||||
friend bool operator==(const segmented_vector& x, const segmented_vector& y)
|
||||
friend bool operator==(const segtor& x, const segtor& y)
|
||||
{ return static_cast<const base_type&>(x) == static_cast<const base_type&>(y); }
|
||||
|
||||
//! <b>Effects</b>: Returns true if x and y are unequal
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements in the container.
|
||||
BOOST_CONTAINER_NODISCARD inline
|
||||
friend bool operator!=(const segmented_vector& x, const segmented_vector& y)
|
||||
friend bool operator!=(const segtor& x, const segtor& y)
|
||||
{ return static_cast<const base_type&>(x) != static_cast<const base_type&>(y); }
|
||||
|
||||
//! <b>Effects</b>: Returns true if x is less than y
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements in the container.
|
||||
BOOST_CONTAINER_NODISCARD inline
|
||||
friend bool operator<(const segmented_vector& x, const segmented_vector& y)
|
||||
friend bool operator<(const segtor& x, const segtor& y)
|
||||
{ return static_cast<const base_type&>(x) < static_cast<const base_type&>(y); }
|
||||
|
||||
//! <b>Effects</b>: Returns true if x is greater than y
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements in the container.
|
||||
BOOST_CONTAINER_NODISCARD inline
|
||||
friend bool operator>(const segmented_vector& x, const segmented_vector& y)
|
||||
friend bool operator>(const segtor& x, const segtor& y)
|
||||
{ return static_cast<const base_type&>(x) > static_cast<const base_type&>(y); }
|
||||
|
||||
//! <b>Effects</b>: Returns true if x is equal or less than y
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements in the container.
|
||||
BOOST_CONTAINER_NODISCARD inline
|
||||
friend bool operator<=(const segmented_vector& x, const segmented_vector& y)
|
||||
friend bool operator<=(const segtor& x, const segtor& y)
|
||||
{ return static_cast<const base_type&>(x) <= static_cast<const base_type&>(y); }
|
||||
|
||||
//! <b>Effects</b>: Returns true if x is equal or greater than y
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear to the number of elements in the container.
|
||||
BOOST_CONTAINER_NODISCARD inline
|
||||
friend bool operator>=(const segmented_vector& x, const segmented_vector& y)
|
||||
friend bool operator>=(const segtor& x, const segtor& y)
|
||||
{ return static_cast<const base_type&>(x) >= static_cast<const base_type&>(y); }
|
||||
|
||||
//! <b>Effects</b>: x.swap(y)
|
||||
//!
|
||||
//! <b>Complexity</b>: Constant.
|
||||
inline friend void swap(segmented_vector& x, segmented_vector& y)
|
||||
inline friend void swap(segtor& x, segtor& y)
|
||||
BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT(x.swap(y)))
|
||||
{ static_cast<base_type&>(x).swap(static_cast<base_type&>(y)); }
|
||||
|
||||
@@ -848,12 +847,12 @@ class segmented_vector : public deque_impl<T, Allocator, true, Options>
|
||||
#ifndef BOOST_CONTAINER_NO_CXX17_CTAD
|
||||
|
||||
template <typename InputIterator>
|
||||
segmented_vector(InputIterator, InputIterator) ->
|
||||
segmented_vector<typename iter_value<InputIterator>::type>;
|
||||
segtor(InputIterator, InputIterator) ->
|
||||
segtor<typename iter_value<InputIterator>::type>;
|
||||
|
||||
template <typename InputIterator, typename Allocator>
|
||||
segmented_vector(InputIterator, InputIterator, Allocator const&) ->
|
||||
segmented_vector<typename iter_value<InputIterator>::type, Allocator>;
|
||||
segtor(InputIterator, InputIterator, Allocator const&) ->
|
||||
segtor<typename iter_value<InputIterator>::type, Allocator>;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -861,9 +860,9 @@ segmented_vector(InputIterator, InputIterator, Allocator const&) ->
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear.
|
||||
template <class T, class A, class O, class U>
|
||||
inline typename segmented_vector<T, A, O>::size_type erase(segmented_vector<T, A, O>& c, const U& v)
|
||||
inline typename segtor<T, A, O>::size_type erase(segtor<T, A, O>& c, const U& v)
|
||||
{
|
||||
typename segmented_vector<T, A, O>::size_type old_size = c.size();
|
||||
typename segtor<T, A, O>::size_type old_size = c.size();
|
||||
c.erase(boost::container::remove(c.begin(), c.end(), v), c.end());
|
||||
return old_size - c.size();
|
||||
}
|
||||
@@ -872,9 +871,9 @@ inline typename segmented_vector<T, A, O>::size_type erase(segmented_vector<T, A
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear.
|
||||
template <class T, class A, class O, class Pred>
|
||||
inline typename segmented_vector<T, A, O>::size_type erase_if(segmented_vector<T, A, O>& c, Pred pred)
|
||||
inline typename segtor<T, A, O>::size_type erase_if(segtor<T, A, O>& c, Pred pred)
|
||||
{
|
||||
typename segmented_vector<T, A, O>::size_type old_size = c.size();
|
||||
typename segtor<T, A, O>::size_type old_size = c.size();
|
||||
c.erase(boost::container::remove_if(c.begin(), c.end(), pred), c.end());
|
||||
return old_size - c.size();
|
||||
}
|
||||
@@ -887,7 +886,7 @@ inline typename segmented_vector<T, A, O>::size_type erase_if(segmented_vector<T
|
||||
namespace boost {
|
||||
|
||||
template <class T, class Allocator, class Options>
|
||||
struct has_trivial_destructor_after_move<boost::container::segmented_vector<T, Allocator, Options> >
|
||||
struct has_trivial_destructor_after_move<boost::container::segtor<T, Allocator, Options> >
|
||||
: has_trivial_destructor_after_move<boost::container::deque_impl<T, Allocator, true, Options> >
|
||||
{};
|
||||
|
||||
@@ -897,4 +896,4 @@ struct has_trivial_destructor_after_move<boost::container::segmented_vector<T, A
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_SEGMENTED_VECTOR_HPP
|
||||
#endif //#ifndef BOOST_CONTAINER_SEGTOR_HPP
|
||||
@@ -1,106 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2025. 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/segmented_vector.hpp>
|
||||
#include <boost/container/new_allocator.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/options.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
template<class Unsigned, class VectorType>
|
||||
void test_stored_size_type_impl()
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
VectorType v;
|
||||
typedef typename VectorType::size_type size_type;
|
||||
size_type const max = Unsigned(-1);
|
||||
v.resize(5);
|
||||
BOOST_TEST_THROWS(v.resize(max+1), std::exception);
|
||||
BOOST_TEST_THROWS(VectorType v2(max+1), std::exception);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class Unsigned>
|
||||
void test_stored_size_type()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = segmented_vector_options_t< stored_size<Unsigned> >;
|
||||
#else
|
||||
typedef typename segmented_vector_options
|
||||
< stored_size<Unsigned> >::type options_t;
|
||||
#endif
|
||||
|
||||
typedef segmented_vector<unsigned char, new_allocator<unsigned char> > default_segmented_vector_t;
|
||||
{
|
||||
typedef segmented_vector<unsigned char, new_allocator<unsigned char>, options_t> segmented_vector_t;
|
||||
BOOST_CONTAINER_STATIC_ASSERT(sizeof(segmented_vector_t) < sizeof(default_segmented_vector_t));
|
||||
test_stored_size_type_impl<Unsigned, segmented_vector_t>();
|
||||
}
|
||||
{
|
||||
typedef segmented_vector<unsigned char, allocator<unsigned char>, options_t> segmented_vector_t;
|
||||
BOOST_CONTAINER_STATIC_ASSERT(sizeof(segmented_vector_t) < sizeof(default_segmented_vector_t));
|
||||
test_stored_size_type_impl<Unsigned, segmented_vector_t>();
|
||||
}
|
||||
}
|
||||
|
||||
void test_block_bytes()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = segmented_vector_options_t< block_bytes<128u> >;
|
||||
#else
|
||||
typedef segmented_vector_options< block_bytes<128u> >::type options_t;
|
||||
#endif
|
||||
typedef segmented_vector<unsigned short, void, options_t> segmented_vector_t;
|
||||
BOOST_TEST(segmented_vector_t::get_block_size() == 128u/sizeof(unsigned short));
|
||||
}
|
||||
|
||||
void test_block_elements()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = segmented_vector_options_t< block_size<64> >;
|
||||
#else
|
||||
typedef segmented_vector_options< block_size<64> >::type options_t;
|
||||
#endif
|
||||
typedef segmented_vector<unsigned char, void, options_t> segmented_vector_t;
|
||||
BOOST_TEST(segmented_vector_t::get_block_size() == 64U);
|
||||
}
|
||||
|
||||
void test_reservable()
|
||||
{
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = segmented_vector_options_t< reservable<true> >;
|
||||
#else
|
||||
typedef segmented_vector_options< reservable<true> >::type options_t;
|
||||
#endif
|
||||
typedef segmented_vector<unsigned short, void, options_t> segmented_vector_t;
|
||||
BOOST_CONTAINER_STATIC_ASSERT(segmented_vector_t::is_reservable == true);
|
||||
}
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = segmented_vector_options_t< reservable<false> >;
|
||||
#else
|
||||
typedef segmented_vector_options< reservable<false> >::type options_t;
|
||||
#endif
|
||||
typedef segmented_vector<unsigned short, void, options_t> segmented_vector_t;
|
||||
BOOST_CONTAINER_STATIC_ASSERT(segmented_vector_t::is_reservable == false);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_block_bytes();
|
||||
test_block_elements();
|
||||
test_stored_size_type<unsigned char>();
|
||||
test_stored_size_type<unsigned short>();
|
||||
test_reservable();
|
||||
return ::boost::report_errors();
|
||||
}
|
||||
106
test/segtor_options_test.cpp
Normal file
106
test/segtor_options_test.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2026. 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/segtor.hpp>
|
||||
#include <boost/container/new_allocator.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
#include <boost/container/options.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::container;
|
||||
|
||||
template<class Unsigned, class VectorType>
|
||||
void test_stored_size_type_impl()
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
VectorType v;
|
||||
typedef typename VectorType::size_type size_type;
|
||||
size_type const max = Unsigned(-1);
|
||||
v.resize(5);
|
||||
BOOST_TEST_THROWS(v.resize(max+1), std::exception);
|
||||
BOOST_TEST_THROWS(VectorType v2(max+1), std::exception);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class Unsigned>
|
||||
void test_stored_size_type()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = segtor_options_t< stored_size<Unsigned> >;
|
||||
#else
|
||||
typedef typename segtor_options
|
||||
< stored_size<Unsigned> >::type options_t;
|
||||
#endif
|
||||
|
||||
typedef segtor<unsigned char, new_allocator<unsigned char> > default_segtor_t;
|
||||
{
|
||||
typedef segtor<unsigned char, new_allocator<unsigned char>, options_t> segtor_t;
|
||||
BOOST_CONTAINER_STATIC_ASSERT(sizeof(segtor_t) < sizeof(default_segtor_t));
|
||||
test_stored_size_type_impl<Unsigned, segtor_t>();
|
||||
}
|
||||
{
|
||||
typedef segtor<unsigned char, allocator<unsigned char>, options_t> segtor_t;
|
||||
BOOST_CONTAINER_STATIC_ASSERT(sizeof(segtor_t) < sizeof(default_segtor_t));
|
||||
test_stored_size_type_impl<Unsigned, segtor_t>();
|
||||
}
|
||||
}
|
||||
|
||||
void test_block_bytes()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = segtor_options_t< block_bytes<128u> >;
|
||||
#else
|
||||
typedef segtor_options< block_bytes<128u> >::type options_t;
|
||||
#endif
|
||||
typedef segtor<unsigned short, void, options_t> segtor_t;
|
||||
BOOST_TEST(segtor_t::get_block_size() == 128u/sizeof(unsigned short));
|
||||
}
|
||||
|
||||
void test_block_elements()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = segtor_options_t< block_size<64> >;
|
||||
#else
|
||||
typedef segtor_options< block_size<64> >::type options_t;
|
||||
#endif
|
||||
typedef segtor<unsigned char, void, options_t> segtor_t;
|
||||
BOOST_TEST(segtor_t::get_block_size() == 64U);
|
||||
}
|
||||
|
||||
void test_reservable()
|
||||
{
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = segtor_options_t< reservable<true> >;
|
||||
#else
|
||||
typedef segtor_options< reservable<true> >::type options_t;
|
||||
#endif
|
||||
typedef segtor<unsigned short, void, options_t> segtor_t;
|
||||
BOOST_CONTAINER_STATIC_ASSERT(segtor_t::is_reservable == true);
|
||||
}
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
using options_t = segtor_options_t< reservable<false> >;
|
||||
#else
|
||||
typedef segtor_options< reservable<false> >::type options_t;
|
||||
#endif
|
||||
typedef segtor<unsigned short, void, options_t> segtor_t;
|
||||
BOOST_CONTAINER_STATIC_ASSERT(segtor_t::is_reservable == false);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_block_bytes();
|
||||
test_block_elements();
|
||||
test_stored_size_type<unsigned char>();
|
||||
test_stored_size_type<unsigned short>();
|
||||
test_reservable();
|
||||
return ::boost::report_errors();
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
#include <boost/container/segmented_vector.hpp>
|
||||
#include <boost/container/segtor.hpp>
|
||||
#include <boost/container/allocator.hpp>
|
||||
|
||||
|
||||
@@ -36,15 +36,15 @@
|
||||
using namespace boost::container;
|
||||
|
||||
//Function to check if both sets are equal
|
||||
// segmented_vector does not provide front operations; only back/middle tests
|
||||
// segtor does not provide front operations; only back/middle tests
|
||||
template<class V1, class V2>
|
||||
bool segmented_vector_copyable_only(V1 &, V2 &, dtl::false_type)
|
||||
bool segtor_copyable_only(V1 &, V2 &, dtl::false_type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class V1, class V2>
|
||||
bool segmented_vector_copyable_only(V1 &cntc, V2 &stdc, dtl::true_type)
|
||||
bool segtor_copyable_only(V1 &cntc, V2 &stdc, dtl::true_type)
|
||||
{
|
||||
typedef typename V1::value_type IntType;
|
||||
std::size_t size = cntc.size();
|
||||
@@ -96,36 +96,36 @@ bool segmented_vector_copyable_only(V1 &cntc, V2 &stdc, dtl::true_type)
|
||||
}
|
||||
|
||||
//Test recursive structures
|
||||
class recursive_segmented_vector
|
||||
class recursive_segtor
|
||||
{
|
||||
public:
|
||||
|
||||
recursive_segmented_vector (const recursive_segmented_vector &x)
|
||||
: segmented_vector_(x.segmented_vector_)
|
||||
recursive_segtor (const recursive_segtor &x)
|
||||
: segtor_(x.segtor_)
|
||||
{}
|
||||
|
||||
recursive_segmented_vector & operator=(const recursive_segmented_vector &x)
|
||||
{ this->segmented_vector_ = x.segmented_vector_; return *this; }
|
||||
recursive_segtor & operator=(const recursive_segtor &x)
|
||||
{ this->segtor_ = x.segtor_; return *this; }
|
||||
|
||||
segmented_vector<recursive_segmented_vector> segmented_vector_;
|
||||
segmented_vector<recursive_segmented_vector>::iterator it_;
|
||||
segmented_vector<recursive_segmented_vector>::const_iterator cit_;
|
||||
segmented_vector<recursive_segmented_vector>::reverse_iterator rit_;
|
||||
segmented_vector<recursive_segmented_vector>::const_reverse_iterator crit_;
|
||||
segtor<recursive_segtor> segtor_;
|
||||
segtor<recursive_segtor>::iterator it_;
|
||||
segtor<recursive_segtor>::const_iterator cit_;
|
||||
segtor<recursive_segtor>::reverse_iterator rit_;
|
||||
segtor<recursive_segtor>::const_reverse_iterator crit_;
|
||||
};
|
||||
|
||||
bool do_recursive_segmented_vector_test()
|
||||
bool do_recursive_segtor_test()
|
||||
{
|
||||
//Test for recursive types
|
||||
{
|
||||
segmented_vector<recursive_segmented_vector> recursive_segmented_vector_segmented_vector;
|
||||
segtor<recursive_segtor> recursive_segtor_segtor;
|
||||
}
|
||||
|
||||
{
|
||||
//Now test move semantics
|
||||
segmented_vector<recursive_segmented_vector> original;
|
||||
segmented_vector<recursive_segmented_vector> move_ctor(boost::move(original));
|
||||
segmented_vector<recursive_segmented_vector> move_assign;
|
||||
segtor<recursive_segtor> original;
|
||||
segtor<recursive_segtor> move_ctor(boost::move(original));
|
||||
segtor<recursive_segtor> move_assign;
|
||||
move_assign = boost::move(move_ctor);
|
||||
move_assign.swap(original);
|
||||
}
|
||||
@@ -135,15 +135,15 @@ bool do_recursive_segmented_vector_test()
|
||||
template<class IntType, bool Reservable>
|
||||
bool do_test()
|
||||
{
|
||||
typedef typename segmented_vector_options<reservable<Reservable> >::type Options;
|
||||
typedef typename segtor_options<reservable<Reservable> >::type Options;
|
||||
{
|
||||
typedef segmented_vector<IntType, void, Options> MyCnt;
|
||||
typedef segtor<IntType, void, Options> MyCnt;
|
||||
::boost::movelib::unique_ptr<MyCnt> const pcntc = ::boost::movelib::make_unique<MyCnt>();
|
||||
pcntc->erase(pcntc->cbegin(), pcntc->cend());
|
||||
}
|
||||
|
||||
//Alias types
|
||||
typedef segmented_vector<IntType, void, Options> MyCnt;
|
||||
typedef segtor<IntType, void, Options> MyCnt;
|
||||
typedef std::vector<int> MyStd;
|
||||
const int max = 100;
|
||||
{
|
||||
@@ -258,7 +258,7 @@ bool do_test()
|
||||
if(!test::CheckEqualContainers(cntc, stdc)) return false;
|
||||
}
|
||||
|
||||
if(!segmented_vector_copyable_only(cntc, stdc
|
||||
if(!segtor_copyable_only(cntc, stdc
|
||||
,dtl::bool_<boost::container::test::is_copyable<IntType>::value>())){
|
||||
return false;
|
||||
}
|
||||
@@ -306,12 +306,12 @@ bool test_ctad() //Older clang versions suffer from ICE here
|
||||
//Check Constructor Template Auto Deduction
|
||||
{
|
||||
MyStd gold = MyStd{ 1, 2, 3 };
|
||||
segmented_vector<int> test = segmented_vector(gold.begin(), gold.end());
|
||||
segtor<int> test = segtor(gold.begin(), gold.end());
|
||||
if (!test::CheckEqualContainers(gold, test)) return false;
|
||||
}
|
||||
{
|
||||
MyStd gold = MyStd{ 1, 2, 3 };
|
||||
segmented_vector<int> test = segmented_vector<int>(gold.begin(), gold.end(), new_allocator<int>());
|
||||
segtor<int> test = segtor<int>(gold.begin(), gold.end(), new_allocator<int>());
|
||||
if (!test::CheckEqualContainers(gold, test)) return false;
|
||||
}
|
||||
return true;
|
||||
@@ -326,10 +326,10 @@ struct GetAllocatorCont
|
||||
template<class ValueType>
|
||||
struct apply
|
||||
{
|
||||
typedef segmented_vector< ValueType
|
||||
typedef segtor< ValueType
|
||||
, typename allocator_traits<VoidAllocator>
|
||||
::template portable_rebind_alloc<ValueType>::type
|
||||
, typename segmented_vector_options<reservable<Reservable> >::type
|
||||
, typename segtor_options<reservable<Reservable> >::type
|
||||
> type;
|
||||
};
|
||||
};
|
||||
@@ -365,56 +365,56 @@ struct char_holder
|
||||
bool do_test_default_block_size()
|
||||
{
|
||||
//Check power of two sizes by default
|
||||
BOOST_TEST(segmented_vector<char_holder<8> >::get_block_size() == 16*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<12> >::get_block_size() == 16*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<16> >::get_block_size() == 8*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<20> >::get_block_size() == 8*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<24> >::get_block_size() == 8*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<28> >::get_block_size() == 8*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<32> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<36> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<40> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<44> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<48> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<52> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<56> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<60> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<64> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<68> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<72> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<76> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<80> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<84> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<88> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segmented_vector<char_holder<92> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<8> >::get_block_size() == 16*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<12> >::get_block_size() == 16*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<16> >::get_block_size() == 8*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<20> >::get_block_size() == 8*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<24> >::get_block_size() == 8*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<28> >::get_block_size() == 8*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<32> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<36> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<40> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<44> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<48> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<52> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<56> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<60> >::get_block_size() == 4*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<64> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<68> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<72> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<76> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<80> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<84> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<88> >::get_block_size() == 2*sizeof(void*));
|
||||
BOOST_TEST(segtor<char_holder<92> >::get_block_size() == 2*sizeof(void*));
|
||||
//Minimal 8 elements
|
||||
BOOST_TEST(segmented_vector<char_holder<148> >::get_block_size() == 8u);
|
||||
BOOST_TEST(segtor<char_holder<148> >::get_block_size() == 8u);
|
||||
return 0 == boost::report_errors();
|
||||
}
|
||||
|
||||
struct boost_container_segmented_vector;
|
||||
struct boost_container_segtor;
|
||||
|
||||
namespace boost { namespace container { namespace test {
|
||||
|
||||
template<>
|
||||
struct alloc_propagate_base<boost_container_segmented_vector>
|
||||
struct alloc_propagate_base<boost_container_segtor>
|
||||
{
|
||||
template <class T, class Allocator>
|
||||
struct apply
|
||||
{
|
||||
typedef boost::container::segmented_vector<T, Allocator> type;
|
||||
typedef boost::container::segtor<T, Allocator> type;
|
||||
};
|
||||
};
|
||||
|
||||
}}} //namespace boost::container::test
|
||||
|
||||
|
||||
//Test segmented_vector has the expected size --> 3 words
|
||||
BOOST_CONTAINER_STATIC_ASSERT_MSG(3*sizeof(void*) == sizeof(segmented_vector<int>), "sizeof(segmented_vector<int> should be 3 words");
|
||||
//Test segtor has the expected size --> 3 words
|
||||
BOOST_CONTAINER_STATIC_ASSERT_MSG(3*sizeof(void*) == sizeof(segtor<int>), "sizeof(segtor<int> should be 3 words");
|
||||
|
||||
int main ()
|
||||
{
|
||||
if(!do_recursive_segmented_vector_test())
|
||||
if(!do_recursive_segtor_test())
|
||||
return 1;
|
||||
|
||||
if(!do_test<int, false>())
|
||||
@@ -438,7 +438,7 @@ int main ()
|
||||
|
||||
//Test non-copy-move operations (back only; no emplace_front)
|
||||
{
|
||||
segmented_vector<test::non_copymovable_int> d;
|
||||
segtor<test::non_copymovable_int> d;
|
||||
d.emplace_back();
|
||||
d.emplace_back(1);
|
||||
d.resize(10);
|
||||
@@ -463,7 +463,7 @@ int main ()
|
||||
////////////////////////////////////
|
||||
// Default init test
|
||||
////////////////////////////////////
|
||||
if(!test::default_init_test< segmented_vector<int, test::default_init_allocator<int> > >()){
|
||||
if(!test::default_init_test< segtor<int, test::default_init_allocator<int> > >()){
|
||||
std::cerr << "Default init test failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -471,23 +471,23 @@ int main ()
|
||||
////////////////////////////////////
|
||||
// Emplace testing
|
||||
////////////////////////////////////
|
||||
// segmented_vector does not provide front operations (emplace_front, push_front, pop_front)
|
||||
// segtor does not provide front operations (emplace_front, push_front, pop_front)
|
||||
const test::EmplaceOptions Options = (test::EmplaceOptions)(test::EMPLACE_BACK | test::EMPLACE_BEFORE);
|
||||
|
||||
if(!boost::container::test::test_emplace
|
||||
< segmented_vector<test::EmplaceInt>, Options>())
|
||||
< segtor<test::EmplaceInt>, Options>())
|
||||
return 1;
|
||||
////////////////////////////////////
|
||||
// Allocator propagation testing
|
||||
////////////////////////////////////
|
||||
if(!boost::container::test::test_propagate_allocator<boost_container_segmented_vector>())
|
||||
if(!boost::container::test::test_propagate_allocator<boost_container_segtor>())
|
||||
return 1;
|
||||
|
||||
////////////////////////////////////
|
||||
// Initializer lists testing
|
||||
////////////////////////////////////
|
||||
if(!boost::container::test::test_vector_methods_with_initializer_list_as_argument_for
|
||||
< boost::container::segmented_vector<int> >()) {
|
||||
< boost::container::segtor<int> >()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ int main ()
|
||||
// Iterator testing
|
||||
////////////////////////////////////
|
||||
{
|
||||
typedef boost::container::segmented_vector<int> cont_int;
|
||||
typedef boost::container::segtor<int> cont_int;
|
||||
for(std::size_t i = 1; i <= 10000; i*=10){
|
||||
cont_int a;
|
||||
for (int j = 0; j < (int)i; ++j)
|
||||
@@ -512,7 +512,7 @@ int main ()
|
||||
////////////////////////////////////
|
||||
// default allocator
|
||||
{
|
||||
typedef boost::container::segmented_vector<int> cont;
|
||||
typedef boost::container::segtor<int> cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
BOOST_CONTAINER_STATIC_ASSERT_MSG(!(boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
@@ -522,7 +522,7 @@ int main ()
|
||||
}
|
||||
// std::allocator
|
||||
{
|
||||
typedef boost::container::segmented_vector<int, std::allocator<int> > cont;
|
||||
typedef boost::container::segtor<int, std::allocator<int> > cont;
|
||||
typedef cont::allocator_type allocator_type;
|
||||
typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
|
||||
BOOST_CONTAINER_STATIC_ASSERT_MSG(!(boost::has_trivial_destructor_after_move<cont>::value !=
|
||||
Reference in New Issue
Block a user