mirror of
https://github.com/boostorg/container.git
synced 2026-04-29 04:03:18 +02:00
Define and use BOOST_CONTAINER_CONSTANT_VAR to support BOOST_INLINE_CONSTEXPR and static const global variables.
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
# include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
@@ -332,7 +334,7 @@ struct ordered_range_t
|
||||
|
||||
//! Value used to tag that the input range is
|
||||
//! guaranteed to be ordered
|
||||
static const ordered_range_t ordered_range = ordered_range_t();
|
||||
BOOST_CONTAINER_CONSTANT_VAR ordered_range_t ordered_range = ordered_range_t();
|
||||
|
||||
//! Type used to tag that the input range is
|
||||
//! guaranteed to be ordered and unique
|
||||
@@ -342,7 +344,7 @@ struct ordered_unique_range_t
|
||||
|
||||
//! Value used to tag that the input range is
|
||||
//! guaranteed to be ordered and unique
|
||||
static const ordered_unique_range_t ordered_unique_range = ordered_unique_range_t();
|
||||
BOOST_CONTAINER_CONSTANT_VAR ordered_unique_range_t ordered_unique_range = ordered_unique_range_t();
|
||||
|
||||
//! Type used to tag that the inserted values
|
||||
//! should be default initialized
|
||||
@@ -351,7 +353,7 @@ struct default_init_t
|
||||
|
||||
//! Value used to tag that the inserted values
|
||||
//! should be default initialized
|
||||
static const default_init_t default_init = default_init_t();
|
||||
BOOST_CONTAINER_CONSTANT_VAR default_init_t default_init = default_init_t();
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//! Type used to tag that the inserted values
|
||||
@@ -361,7 +363,7 @@ struct value_init_t
|
||||
|
||||
//! Value used to tag that the inserted values
|
||||
//! should be value initialized
|
||||
static const value_init_t value_init = value_init_t();
|
||||
BOOST_CONTAINER_CONSTANT_VAR value_init_t value_init = value_init_t();
|
||||
|
||||
namespace container_detail_really_deep_namespace {
|
||||
|
||||
|
||||
@@ -49,10 +49,10 @@ namespace container {
|
||||
|
||||
namespace adaptive_pool_flag {
|
||||
|
||||
static const unsigned int none = 0u;
|
||||
static const unsigned int align_only = 1u << 0u;
|
||||
static const unsigned int size_ordered = 1u << 1u;
|
||||
static const unsigned int address_ordered = 1u << 2u;
|
||||
BOOST_CONTAINER_CONSTANT_VAR unsigned int none = 0u;
|
||||
BOOST_CONTAINER_CONSTANT_VAR unsigned int align_only = 1u << 0u;
|
||||
BOOST_CONTAINER_CONSTANT_VAR unsigned int size_ordered = 1u << 1u;
|
||||
BOOST_CONTAINER_CONSTANT_VAR unsigned int address_ordered = 1u << 2u;
|
||||
|
||||
} //namespace adaptive_pool_flag{
|
||||
|
||||
|
||||
@@ -42,13 +42,13 @@ enum allocation_type_v
|
||||
|
||||
typedef unsigned int allocation_type;
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
static const allocation_type allocate_new = (allocation_type)allocate_new_v;
|
||||
static const allocation_type expand_fwd = (allocation_type)expand_fwd_v;
|
||||
static const allocation_type expand_bwd = (allocation_type)expand_bwd_v;
|
||||
static const allocation_type shrink_in_place = (allocation_type)shrink_in_place_v;
|
||||
static const allocation_type try_shrink_in_place= (allocation_type)try_shrink_in_place_v;
|
||||
static const allocation_type nothrow_allocation = (allocation_type)nothrow_allocation_v;
|
||||
static const allocation_type zero_memory = (allocation_type)zero_memory_v;
|
||||
BOOST_CONTAINER_CONSTANT_VAR allocation_type allocate_new = (allocation_type)allocate_new_v;
|
||||
BOOST_CONTAINER_CONSTANT_VAR allocation_type expand_fwd = (allocation_type)expand_fwd_v;
|
||||
BOOST_CONTAINER_CONSTANT_VAR allocation_type expand_bwd = (allocation_type)expand_bwd_v;
|
||||
BOOST_CONTAINER_CONSTANT_VAR allocation_type shrink_in_place = (allocation_type)shrink_in_place_v;
|
||||
BOOST_CONTAINER_CONSTANT_VAR allocation_type try_shrink_in_place= (allocation_type)try_shrink_in_place_v;
|
||||
BOOST_CONTAINER_CONSTANT_VAR allocation_type nothrow_allocation = (allocation_type)nothrow_allocation_v;
|
||||
BOOST_CONTAINER_CONSTANT_VAR allocation_type zero_memory = (allocation_type)zero_memory_v;
|
||||
|
||||
} //namespace container {
|
||||
} //namespace boost {
|
||||
|
||||
@@ -1111,7 +1111,7 @@ inline typename dtl::disable_if_memtransfer_copy_assignable<F, G, void>::type
|
||||
boost::container::destroy_alloc_n(a, large_range_f, std::size_t(n_j - n_i));
|
||||
}
|
||||
|
||||
static const std::size_t DeepSwapAllocNMaxStorage = std::size_t(1) << std::size_t(11); //2K bytes
|
||||
BOOST_CONTAINER_CONSTANT_VAR std::size_t DeepSwapAllocNMaxStorage = std::size_t(1) << std::size_t(11); //2K bytes
|
||||
|
||||
template
|
||||
<std::size_t MaxTmpBytes
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace pmr {
|
||||
|
||||
class pool_data_t;
|
||||
|
||||
static const std::size_t pool_options_minimum_max_blocks_per_chunk = 1u;
|
||||
static const std::size_t pool_options_default_max_blocks_per_chunk = 32u;
|
||||
static const std::size_t pool_options_minimum_largest_required_pool_block =
|
||||
BOOST_CONTAINER_CONSTANT_VAR std::size_t pool_options_minimum_max_blocks_per_chunk = 1u;
|
||||
BOOST_CONTAINER_CONSTANT_VAR std::size_t pool_options_default_max_blocks_per_chunk = 32u;
|
||||
BOOST_CONTAINER_CONSTANT_VAR std::size_t pool_options_minimum_largest_required_pool_block =
|
||||
memory_resource::max_align > 2*sizeof(void*) ? memory_resource::max_align : 2*sizeof(void*);
|
||||
static const std::size_t pool_options_default_largest_required_pool_block =
|
||||
BOOST_CONTAINER_CONSTANT_VAR std::size_t pool_options_default_largest_required_pool_block =
|
||||
pool_options_minimum_largest_required_pool_block > 4096u
|
||||
? pool_options_minimum_largest_required_pool_block : 4096u;
|
||||
|
||||
|
||||
@@ -230,4 +230,10 @@ namespace boost {
|
||||
# define BOOST_CONTAINER_STATIC_ASSERT_MSG( B, Msg ) BOOST_CONTAINER_STATIC_ASSERT( B )
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_INLINE_VARIABLES)
|
||||
# define BOOST_CONTAINER_CONSTANT_VAR BOOST_INLINE_CONSTEXPR
|
||||
#else
|
||||
# define BOOST_CONTAINER_CONSTANT_VAR static BOOST_CONSTEXPR_OR_CONST
|
||||
#endif
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP
|
||||
|
||||
@@ -469,7 +469,7 @@ class basic_string_base
|
||||
inline void priv_short_size(size_type sz)
|
||||
{
|
||||
typedef unsigned char uchar_type;
|
||||
static const uchar_type mask = uchar_type(uchar_type(-1) >> 1U);
|
||||
BOOST_STATIC_CONSTEXPR uchar_type mask = uchar_type(uchar_type(-1) >> 1U);
|
||||
BOOST_ASSERT( sz <= mask );
|
||||
//Make -Wconversion happy
|
||||
this->members_.pshort_repr()->h.length = uchar_type(uchar_type(sz) & mask);
|
||||
@@ -3085,10 +3085,6 @@ wstring;
|
||||
|
||||
#else
|
||||
|
||||
template <class CharT, class Traits, class Allocator>
|
||||
const typename basic_string<CharT,Traits,Allocator>::size_type
|
||||
basic_string<CharT,Traits,Allocator>::npos;
|
||||
|
||||
template<class S>
|
||||
struct is_string
|
||||
{
|
||||
|
||||
@@ -269,7 +269,7 @@ inline Pointer &get_ptr(vec_iterator<Pointer, IsConst> &it) BOOST_NOEXCEPT_OR_NO
|
||||
struct initial_capacity_t {};
|
||||
|
||||
struct vector_uninitialized_size_t {};
|
||||
static const vector_uninitialized_size_t vector_uninitialized_size = vector_uninitialized_size_t();
|
||||
BOOST_CONTAINER_CONSTANT_VAR vector_uninitialized_size_t vector_uninitialized_size = vector_uninitialized_size_t();
|
||||
|
||||
struct maybe_initial_capacity_t {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user