Re: encryption problem
Michael DOUBEZ wrote:
:: James Kanze a ?crit :
::: On Jul 30, 12:03 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
:::: Michael DOUBEZ wrote:
:::::: Does the C++ standard state any speed requirements for the
:::::: at() method?
:::
::::: 23.1.1/12 specifies sequence container should implement it when
::::: it runs in constant time. IMO is applies to basic_string.
::
:::: Is that the reason some very old versions of g++ didn't support
:::: at() for basic_strings?
:::
::: I doubt it. If that were the case, they wouldn't support
::: operator[] either. A more likely reason is that they
::: implemented it before at() got added to the standard.
::
:: IMO there is no relation with operator[]. If basic_string::size()
:: is O(n), I can still implement operator[] in O(1) but at()
:: requires to know the size (for bound check) and thus cannot be
:: implemented in O(1).
But basic_string claims to be a Sequence container, which should have
a size() of "constant complexity" (23.1 Table 65).
I think James' problem is with a reference counted implementation,
where a non-const operator[] would have to un-share the internal
representation before returning a modifiable reference to the
character position. That would not be O(1), except sometimes.
Bo Persson
::
:: Still I also think it is a pre-standard matter.
::
:: Michael