Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++11 status.

865. More algorithms that throw away information

Section: 26.7.6[alg.fill], 26.7.7[alg.generate]Status:C++11Submitter: Daniel KrüglerOpened: 2008-07-13Last modified: 2016-01-28

Priority:Not Prioritized

View all issues withC++11 status.

Discussion:

In regard to library defect488(i) I found some more algorithms whichunnecessarily throw away information. These are typically algorithms,which sequentially write into anOutputIterator, but do not return thefinal value of this output iterator. These cases are:

  1. template<class OutputIterator, class Size, class T>void fill_n(OutputIterator first, Size n, const T& value);
  2. template<class OutputIterator, class Size, class Generator>void generate_n(OutputIterator first, Size n, Generator gen);

In both cases the minimum requirements on the iterator areOutputIterator, which means according to the requirements of24.3.5.4[output.iterators] p. 2 that only single-pass iterations are guaranteed.So, if users offill_n andgenerate_n haveonly anOutputIteratoravailable, they have no chance to continue pushing further valuesinto it, which seems to be a severe limitation to me.

[Post Summit Daniel "conceptualized" the wording.]

[Batavia (2009-05):]

Alisdair likes the idea, but has concerns about the specific wordingabout the returns clauses.

Alan notes this is a feature request.

Bill notes we have made similar changes to other algorithms.

Move to Open.

[2009-07 Frankfurt]

We have a consensus for moving forward on this issue, but Daniel needsto deconceptify it.

[2009-07-25 Daniel provided non-concepts wording.]

[2009-10 Santa Cruz:]

Moved to Ready.

Proposed resolution:

  1. Replace the current declaration offill_n in 26[algorithms]/2, header<algorithm> synopsis and in 26.7.6[alg.fill] by

    template<class OutputIterator, class Size, class T>voidOutputIterator fill_n(OutputIterator first, Size n, const T& value);

    Just after the effects clause add a new returns clause saying:

    Returns: Forfill_n and positiven, returnsfirst + n. Otherwisereturnsfirst forfill_n.

  2. Replace the current declaration ofgenerate_n in 26[algorithms]/2,header<algorithm> synopsis and in 26.7.7[alg.generate] by

    template<class OutputIterator, class Size, class Generator>voidOutputIterator generate_n(OutputIterator first, Size n, Generator gen);

    Just after the effects clause add a new returns clause saying:

    Forgenerate_n and positiven, returnsfirst + n. Otherwisereturnsfirst forgenerate_n.


[8]ページ先頭

©2009-2026 Movatter.jp