Update test and documentation

This commit is contained in:
Glen Fernandes 2019-05-13 22:11:20 -04:00
parent ca832d9384
commit c96dfcec4a
4 changed files with 22 additions and 12 deletions

View File

@ -116,7 +116,9 @@ reverse order by calling `std::allocator_traits<A>::destroy(a, &p[j])`.]]]]]
[[`template<class A, class T, class I> void alloc_construct_n(A& a, T* p, [[`template<class A, class T, class I> void alloc_construct_n(A& a, T* p,
std::size_t n, I begin);`] std::size_t n, I begin);`]
[[variablelist [[variablelist
[[Requires][`A` is an /Allocator/; `I` is an /InputIterator/]] [[Requires]
[[itemized_list
[`A` is an /Allocator/][`I` is an /InputIterator/]]]]
[[Effects] [[Effects]
[Constructs each `i`-th element in order by calling [Constructs each `i`-th element in order by calling
`std::allocator_traits<A>::construct(a, &p[i], *begin++])`.]] `std::allocator_traits<A>::construct(a, &p[i], *begin++])`.]]
@ -140,7 +142,7 @@ without going through the supplied allocator.
Glen Fernandes originally implemented this functionality in Boost.Smart_Ptr and Glen Fernandes originally implemented this functionality in Boost.Smart_Ptr and
later moved these functions to Boost.Core for use in other Boost libraries, later moved these functions to Boost.Core for use in other Boost libraries,
such as Boost.Multi_Array. such as Boost.Multi_Array and Boost.Histogram.
[endsect] [endsect]

View File

@ -18,7 +18,8 @@ Distributed under the Boost Software License, Version 1.0.
The header <boost/core/exchange.hpp> provides the function template The header <boost/core/exchange.hpp> provides the function template
`boost::exchange` which is an implementation of the `std::exchange` `boost::exchange` which is an implementation of the `std::exchange`
function introduced in C++14. function introduced in C++14. `boost::exchange(o, v)` replaces the
value of `o` with `v` and returns the old value of `o`.
[endsect] [endsect]

View File

@ -16,10 +16,11 @@ Distributed under the Boost Software License, Version 1.0.
[section Overview] [section Overview]
The header <boost/core/first_scalar.hpp> provides the function template The header <boost/core/first_scalar.hpp> provides the function templates
`boost::first_scalar` that can be used to obtain a pointer to the first scalar `boost::first_scalar` that can be used to obtain a pointer to the first scalar
element of an array. Given a pointer of type `T*` it returns a pointer of type element of an array. Given a pointer of type `T*` they return a pointer of
`remove_all_extents_t<T>*`. type `remove_all_extents_t<T>*`. The functions are `constexpr` and can be used
in constant expressions.
[endsect] [endsect]
@ -80,4 +81,11 @@ noexcept;`]
[endsect] [endsect]
[section History]
Glen Fernandes implemented `first_scalar`. Peter Dimov suggested a change for
GCC to support an additional `constexpr` use.
[endsect]
[endsect] [endsect]

View File

@ -47,15 +47,14 @@ struct creator {
::operator delete(ptr); ::operator delete(ptr);
} }
template<class U, class V> template<class V>
void construct(U* ptr, const V& value) { void construct(type* ptr, const V& value) {
::new(static_cast<void*>(ptr)) U(value + 1); ::new(static_cast<void*>(ptr)) type(value + 1);
++type::count; ++type::count;
} }
template<class U> void destroy(type* ptr) {
void destroy(U* ptr) { ptr->~type();
ptr->~U();
--type::count; --type::count;
} }
}; };