Title
Ambiguous return clause for std::uninitialized_copy
Status
nad editorial
Section
[uninitialized.copy]
Submitter
Daniel Krügler

Created on 2007-10-15.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Change the wording of the return clause to say ([uninitialized.copy]):

-2- Returns: The value of result after effects have taken place.

Date: 2007-10-15.00:00:00

14882-2003, [lib.uninitialized.copy] is currently written as follows:

template <class InputIterator, class ForwardIterator>
  ForwardIterator uninitialized_copy(InputIterator first, InputIterator last,
                                     ForwardIterator result);

-1- Effects:

for (; first != last; ++result, ++first)
  new (static_cast<void*>(&*result))
    typename iterator_traits<ForwardIterator>::value_type(*first);

-2- Returns: result

similarily for N2369, and its corresponding section [uninitialized.copy].

It's not clear to me what the return clause is supposed to mean, I see two possible interpretations:

  1. The notion of result is supposed to mean the value given by the function parameter result [Note to the issue editor: Please use italics for result]. This seems somewhat implied by recognizing that both the function parameter and the name used in the clause do have the same italic font.
  2. The notion of "result" is supposed to mean the value of result after the preceding effects clause. This is in fact what all implementations I checked do (and which is probably it's intend, because it matches the specification of std::copy).

The problem is: I see nothing in the standard which grants that this interpretation is correct, specifically [lib.structure.specifications] or [structure.specifications] resp. do not clarify which "look-up" rules apply for names found in the elements of the detailed specifications - Do they relate to the corresponding synopsis or to the effects clause (or possibly other elements)? Fortunately most detailed descriptions are unambigious in this regard, e.g. this problem does not apply for std::copy.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3660
2007-10-15 00:00:00admincreate