This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD Concepts status.
Section: 26.11 [specialized.algorithms] Status: NAD Concepts Submitter: Alisdair Meredith Opened: 2009-03-11 Last modified: 2016-01-28
Priority: Not Prioritized
View other active issues in [specialized.algorithms].
View all other issues in [specialized.algorithms].
View all issues with NAD Concepts status.
Discussion:
Addresses UK 210 [CD1]
Specialized algorithms for memory management need requirements to be easily usable in constrained templates.
[ Summit: ]
We look forward to a paper on this topic. We recommend no action until a paper is available.
[ Post Summit Alisdair provided wording. ]
[ Post Summit: ]
Daniel adds:
- I suggest
Size
should requireIntegralLike
and notUnsignedIntegralLike
, because otherwise simple int-literals could not be provided as arguments and it would conflict with other algorithms that only requireIntegralLike
.The current for-loop-test relies on evaluation in boolean context which is not provided by
ArithmeticLike
and it's refinements. I propose to change the corresponding for-loop-headers to:
- for
uninitialized_copy_n
:for ( ; n > Size(0); ++result, ++first, --n) {
- for
uninitialized_fill_n
:for (; n > Size(0); ++first, --n) {
Alisdair adds:
For the record I agree with Daniel's suggestion.
Proposed resolution:
20.2 [memory] p2
Update the synopsis for <memory>
template <classInputIterator InIter,class ForwardIteratorOutputIterator<auto, InIter::reference> OutIter> requires ForwardIterator<OutIter>ForwardIteratorOutIter uninitialized_copy(InputIteratorInIter first,InputIteratorInIter last,ForwardIteratorOutIter result); template <classInputIterator InIter,classIntegralLike Size,class ForwardIteratorOutputIterator<auto, InIter::reference> OutIter> requires ForwardIterator<OutIter>ForwardIteratorOutIter uninitialized_copy_n(InputIteratorInIter first, Size n,ForwardIteratorOutIter result); template <classForwardIterator Iter,classObjectType T> requires Constructible< Iter::value_type, const T& > void uninitialized_fill(ForwardIteratorIter first,ForwardIteratorIter last, const T& x); template <classForwardIterator Iter,classIntegralLike Size,classObjectType T> requires Constructible< Iter::value_type, const T& > void uninitialized_fill_n(ForwardIteratorIter first, Size n, const T& x);
Update as follows:
uninitialized_copy 26.11.5 [uninitialized.copy]
template <classInputIterator InIter,class ForwardIteratorOutputIterator<auto, InIter::reference> OutIter> requires ForwardIterator<OutIter>ForwardIteratorOutIter uninitialized_copy(InputIteratorInIter first,InputIteratorInIter last,ForwardIteratorOutIter result);-1- Effects:
for (; first != last; ++result, ++first) { new (static_cast<void*>(&*result))typename iterator_traits<ForwardIterator>OutIter::value_type(*first); }-2- Returns:
result
template <classInputIterator InIter,classIntegralLike Size,class ForwardIteratorOutputIterator<auto, InIter::reference> OutIter> requires ForwardIterator<OutIter>ForwardIteratorOutIter uninitialized_copy_n(InputIteratorInIter first, Size n,ForwardIteratorOutIter result);-3- Effects:
for ( ; n > Size(0); ++result, ++first, --n) { new (static_cast<void*>(&*result))typename iterator_traits<ForwardIterator>OutIter::value_type(*first); }-4- Returns: result
uninitialized_fill 26.11.7 [uninitialized.fill]
template <classForwardIterator Iter,classObjectType T> requires Constructible< Iter::value_type, const T& > void uninitialized_fill(ForwardIteratorIter first,ForwardIteratorIter last, const T& x);-1- Effects:
for (; first != last; ++first) { new ( static_cast<void*>( &*first) )typename iterator_traits<ForwardIterator>Iter::value_type(x); }
uninitialized_fill_n [uninitialized.fill.n]
template <classForwardIterator Iter,classIntegralLike Size,classObjectType T> requires Constructible< Iter::value_type, const T& > void uninitialized_fill_n(ForwardIteratorIter first, Size n, const T& x);-1- Effects:
for (; n--> Size(0); ++first, --n) { new ( static_cast<void*>( &*first) )typename iterator_traits<ForwardIterator>Iter::value_type(x); }