c++11 - C++ standard wording: Does "through all iterators in the range" imply sequentiality? -
c++11 - C++ standard wording: Does "through all iterators in the range" imply sequentiality? -
this question sparked give-and-take std::generate
, guarantees made standard. in particular, can utilize function objects internal state , rely on generate(it1, it2, gen)
phone call gen()
, store result in *it
, phone call gen()
again, store in *(it + 1)
etc., or can start @ back, example?
the standard (n3337, §25.3.7/1) says this:
effects: first algorithm invokes function object gen
, assigns homecoming value of gen through iterators in range [first,last)
. sec algorithm invokes function object gen , assigns homecoming value of gen through iterators in range [first,first + n)
if n
positive, otherwise nothing.
it seems no ordering guaranteed, since other paragraphs have stronger wording, illustration std::for_each
(effects: applies f
result of dereferencing every iterator in range [first,last)
, starting first , proceeding last - 1
. if we're taking literally, guarantees start @ first
, end @ last
though - no guarantees on ordering in between).
but: both microsoft's , apache's c++ standard library both give examples on documentation pages require evaluation sequential. , both libc++ (in algorithm
) , libstdc++ (in bits/stl_algo.h
) implement way. moreover, lose lot of potential applications generate
without guarantee.
does current wording imply sequentiality? if not, oversight members of commission or intentional?
(i aware there aren't many people can provide insightful answers question without simply speculating or discussing, in humble opinion, not create question 'not constructive' per guidelines.)
thanks @juanchopanza pointing out issue , referring me paragraph for_each
.
in give-and-take of lwg475, std::for_each
compared std::transform
. it's noted "transform
not guarantee order in function object called". so, yes, commission aware of lack of sequential guarantees in standard.
there no opposite requirement non-sequential behavior either, microsoft , apache free utilize sequential evaluation.
c++ c++11 standards std
Comments
Post a Comment