Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Re: FAQ 34.3 (http://www.velocityreviews.com/forums/t275979-re-faq-34-3-a.html)

Andrey Tarasevich 07-23-2003 11:46 PM

Re: FAQ 34.3
 
Agent Mulder wrote:
> ...
> However v.begin() is not guaranteed to be a T*, which means v.begin() is not
> guaranteed to be the same as &v[0]:
>
> My question is, why is v.begin() not guaranteed to be of T* ?
> ...


Why should it be guaranteed? It is always better to stick with less
restrictive specification, as long as it satisfies you requirements. In
this particular case the less restrictive specification would be
declaring that 'v.begin()' return an iterator (which could be a pointer
or something completely different). One benefit of doing it this way
that this specification allows debugging implementations, where returned
iterator would support range checking and other things of that nature.
It wouldn't be possible if C++ required 'v.begin()' to return a pointer.

--
Best regards,
Andrey Tarasevich
Brainbench C and C++ Programming MVP



All times are GMT. The time now is 08:41 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.