small improvement for fill and fill_n
Nathan Myers
ncm-nospam@cantrip.org
Fri Jun 18 21:24:00 GMT 2004
On Fri, Jun 18, 2004 at 09:52:24AM -0700, Dan Nicolaescu wrote:
> Martin Sebor <sebor@roguewave.com> writes:
> > That would be one way to deal with it but as Nathan says, it may
> > not be the most efficient way. I think it might be best to first
> > approach this as an interpretation request: does the standard intend
> > to require that the reference `value' be used in each iteration of
> > the algorithm or is the implementations suggested by Dan permitted?
>
> An obvious observation: if the standard was to require that the
> reference 'value' was to be used in each iteration then the
> specializations for "fill" in stl_algobase.h that use memset for
> one-byte types are incorrect.
As always, the "as-if" rule applies: if user program can't detect
the difference, then it's OK. In some cases (when it says in the
standard, explicitly, "as-if") it's OK even though it's possible to
write user code that can tell, as long as the postconditions are
satisfied.
Nathan Myers
ncm-nospam@cantrip.org
More information about the Libstdc++
mailing list