From c96dfcec4a34b407b03a6dbfbbdddc211948fa72 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Mon, 13 May 2019 22:11:20 -0400 Subject: [PATCH] Update test and documentation --- doc/alloc_construct.qbk | 6 ++++-- doc/exchange.qbk | 3 ++- doc/first_scalar.qbk | 14 +++++++++++--- test/alloc_construct_cxx11_test.cpp | 11 +++++------ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/doc/alloc_construct.qbk b/doc/alloc_construct.qbk index 8fa47c6..2342367 100644 --- a/doc/alloc_construct.qbk +++ b/doc/alloc_construct.qbk @@ -116,7 +116,9 @@ reverse order by calling `std::allocator_traits::destroy(a, &p[j])`.]]]]] [[`template void alloc_construct_n(A& a, T* p, std::size_t n, I begin);`] [[variablelist -[[Requires][`A` is an /Allocator/; `I` is an /InputIterator/]] +[[Requires] +[[itemized_list +[`A` is an /Allocator/][`I` is an /InputIterator/]]]] [[Effects] [Constructs each `i`-th element in order by calling `std::allocator_traits::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 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] diff --git a/doc/exchange.qbk b/doc/exchange.qbk index 5e7c5cf..edcb616 100644 --- a/doc/exchange.qbk +++ b/doc/exchange.qbk @@ -18,7 +18,8 @@ Distributed under the Boost Software License, Version 1.0. The header provides the function template `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] diff --git a/doc/first_scalar.qbk b/doc/first_scalar.qbk index 8393379..077c449 100644 --- a/doc/first_scalar.qbk +++ b/doc/first_scalar.qbk @@ -16,10 +16,11 @@ Distributed under the Boost Software License, Version 1.0. [section Overview] -The header provides the function template +The header provides the function templates `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 -`remove_all_extents_t*`. +element of an array. Given a pointer of type `T*` they return a pointer of +type `remove_all_extents_t*`. The functions are `constexpr` and can be used +in constant expressions. [endsect] @@ -80,4 +81,11 @@ noexcept;`] [endsect] +[section History] + +Glen Fernandes implemented `first_scalar`. Peter Dimov suggested a change for +GCC to support an additional `constexpr` use. + +[endsect] + [endsect] diff --git a/test/alloc_construct_cxx11_test.cpp b/test/alloc_construct_cxx11_test.cpp index ed2bad5..2075d7a 100644 --- a/test/alloc_construct_cxx11_test.cpp +++ b/test/alloc_construct_cxx11_test.cpp @@ -47,15 +47,14 @@ struct creator { ::operator delete(ptr); } - template - void construct(U* ptr, const V& value) { - ::new(static_cast(ptr)) U(value + 1); + template + void construct(type* ptr, const V& value) { + ::new(static_cast(ptr)) type(value + 1); ++type::count; } - template - void destroy(U* ptr) { - ptr->~U(); + void destroy(type* ptr) { + ptr->~type(); --type::count; } };