Added stored_size option to small_vector

This commit is contained in:
Ion Gaztañaga
2024-10-13 00:29:12 +02:00
parent 13603d7de1
commit af58c7d226
5 changed files with 81 additions and 8 deletions
+10 -5
View File
@@ -359,20 +359,23 @@ BOOST_INTRUSIVE_OPTION_CONSTANT(inplace_alignment, std::size_t, Alignment, inpla
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
template<class GrowthType, std::size_t InplaceAlignment>
template<class GrowthType, std::size_t InplaceAlignment, class StoredSizeType>
struct small_vector_opt
{
typedef GrowthType growth_factor_type;
typedef GrowthType growth_factor_type;
BOOST_STATIC_CONSTEXPR std::size_t inplace_alignment = InplaceAlignment;
typedef StoredSizeType stored_size_type;
};
typedef small_vector_opt<void, 0u> small_vector_null_opt;
typedef small_vector_opt<void, 0u, void> small_vector_null_opt;
#endif //!defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! Helper metafunction to combine options into a single type to be used
//! by \c boost::container::small_vector.
//! Supported options are: \c boost::container::growth_factor and \c boost::container::inplace_alignment
//! Supported options are: \c boost::container::growth_factor,
//! \c boost::container::inplace_alignment and
//! \c boost::container::stored_size.
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
template<class ...Options>
#else
@@ -390,7 +393,9 @@ struct small_vector_options
#endif
>::type packed_options;
typedef small_vector_opt< typename packed_options::growth_factor_type
, packed_options::inplace_alignment> implementation_defined;
, packed_options::inplace_alignment
, typename packed_options::stored_size_type
> implementation_defined;
/// @endcond
typedef implementation_defined type;
};
+6 -2
View File
@@ -69,7 +69,9 @@ struct get_vopt_from_svopt
: get_small_vector_opt<Options>::type
{
typedef typename get_small_vector_opt<Options>::type options_t;
typedef vector_opt< typename options_t::growth_factor_type, void> type;
typedef vector_opt< typename options_t::growth_factor_type
, typename options_t::stored_size_type
> type;
};
template<>
@@ -340,9 +342,11 @@ struct small_vector_storage<T, 0u, Alignment>
//!
template <class T, class SecAlloc, class Options>
class small_vector_base
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
: public dtl::vector_for_small_vector<T, SecAlloc, Options>::type
#endif
{
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKEDVECTOR
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
public:
//Make it public as it will be inherited by small_vector and container
//must have this public member