Boost logo

Boost :

From: Reid Sweatman (reids_at_[hidden])
Date: 1999-08-20 16:30:59


> If you follow the typedefs, you find that pointer is T* and
> iterator has an implementation dependent type.
>
> Still, all implementations uses the moral equivalent of T*
> for iterator, and hopefully contiguity will soon be required.
>
> I can see room for a helper function:
>
> #include <vector>
>
> // A::pointer shall be T*
> // non precondition: v is _not_ required to have any elements
> template <typename T, class A>
> inline
> T* data (std::vector<T,A>& v) // as string::data (), but non const
> {
> return !v.empty() ? &v.front() : NULL;
> }
>
> // A::pointer shall be T*
> // non precondition: v is _not_ required to have any elements
> template <typename T, class A>
> inline
> const T* data (const std::vector<T,A>& v) // as string::data ()
> {
> return !v.empty() ? &v.front() : NULL;
> }

I think this is closer to what I meant, in that you *could* pass an
A::pointer to an assembly routine without worrying how it might mangle the
pointer implementation.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk