mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 22:14:26 +02:00
Updated and documented non-standard optimizations based on memset
This commit is contained in:
@@ -862,6 +862,31 @@ If you need a memory optimized version of `boost::container::vector<bool>`, plea
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:non_standard_memset_initialization Non-standard value initialization using `std::memset`]
|
||||
|
||||
[*Boost.Container] uses `std::memset` with a zero value to initialize some types as in most platforms this
|
||||
initialization yields to the desired value initialization with improved performance.
|
||||
|
||||
Following the C11 standard, [*Boost.Container] assumes that ['for any integer type,
|
||||
the object representation where all the bits are zero shall be a representation of the value
|
||||
zero in that type]. Since `_Bool`/`wchar_t`/`char16_t`/`char32_t` are also integer types in C, it considers
|
||||
all C++ integral types as initializable via `std::memset`.
|
||||
|
||||
By default, [*Boost.Container] also considers floating point types to be initializable using `std::memset`.
|
||||
Most platforms are compatible with this initialization, but in case this initialization is not desirable the
|
||||
user can `#define BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_NOT_ZERO` before including library headers.
|
||||
|
||||
By default, it also considers pointer types (pointer and pointer to function types, excluding
|
||||
member object and member function pointers) to be initializable using `std::memset`.
|
||||
Most platforms are compatible with this initialization, but in case this initialization is not desired the
|
||||
user can `#define BOOST_CONTAINER_MEMZEROED_POINTER_IS_NOT_ZERO` before including library headers.
|
||||
|
||||
If neither `BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_NOT_ZERO` nor
|
||||
`BOOST_CONTAINER_MEMZEROED_POINTER_IS_NOT_ZERO` is defined [*Boost.Container] also considers POD
|
||||
types to be value initializable via `std::memset` with value zero.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:known_issues Known Issues]
|
||||
|
@@ -396,14 +396,14 @@ struct is_memzero_initializable
|
||||
{
|
||||
typedef typename ::std::iterator_traits<O>::value_type value_type;
|
||||
static const bool value = are_elements_contiguous<O>::value &&
|
||||
( ::boost::is_integral<value_type>::value
|
||||
#if BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL
|
||||
( ::boost::is_integral<value_type>::value || ::boost::is_enum<value_type>::value
|
||||
#if defined(BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL)
|
||||
|| ::boost::is_pointer<value_type>::value
|
||||
#endif
|
||||
#if BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_ZERO
|
||||
#if defined(BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_ZERO)
|
||||
|| ::boost::is_floating_point<value_type>::value
|
||||
#endif
|
||||
#if BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_ZERO && BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL
|
||||
#if defined(BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_ZERO) && defined(BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL)
|
||||
|| ::boost::is_pod<value_type>::value
|
||||
#endif
|
||||
);
|
||||
|
@@ -50,12 +50,12 @@
|
||||
//
|
||||
//If your platform does not offer these guarantees
|
||||
//define these to value zero.
|
||||
#ifndef BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_ZERO
|
||||
#ifndef BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_NOT_ZERO
|
||||
#define BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_ZERO 1
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL
|
||||
#define BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL 1
|
||||
#ifndef BOOST_CONTAINER_MEMZEROED_POINTER_IS_NOT_NULL
|
||||
#define BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
Reference in New Issue
Block a user