Movatterモバイル変換


[0]ホーム

URL:



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

144. Deque constructor complexity wrong

Section: 23.3.5.2[deque.cons]Status:TC1Submitter: Herb SutterOpened: 1999-05-09Last modified: 2016-01-28

Priority:Not Prioritized

View all otherissues in [deque.cons].

View all issues withTC1 status.

Discussion:

In 23.3.5.2[deque.cons] paragraph 6, the deque ctor that takes an iterator range appearsto have complexity requirements which are incorrect, and which contradict thecomplexity requirements for insert(). I suspect that the text in question,below, was taken from vector:

Complexity: If the iterators first and last are forward iterators, bidirectional iterators, or random access iterators the constructor makes only N calls to the copy constructor, and performs no reallocations, where N is last - first.

The word "reallocations" does not really apply to deque. Further,all of the following appears to be spurious:

It makes at most 2N calls to the copy constructor of T and log N reallocations if they are input iterators.1)

1) The complexity is greater in the case of input iterators because each element must be added individually: it is impossible to determine the distance between first abd last before doing the copying.

This makes perfect sense for vector, but not for deque. Why should deque gainan efficiency advantage from knowing in advance the number of elements toinsert?

Proposed resolution:

In 23.3.5.2[deque.cons] paragraph 6, replace the Complexity description, including thefootnote, with the following text (which also corrects the "abd"typo):

Complexity: Makes last - first calls to the copy constructor of T.


[8]ページ先頭

©2009-2026 Movatter.jp