From: Mike N. <ta...@al...> - 2002-01-02 12:30:06
|
Mark O'Donohue wrote: [...] > I also guess we could create a templated function to do the > conversion for the general case. > > template<T> T* getRawPointer(iterator<T> iter) { > return &*(iter); > } Please don't. This is starting to look like an entry for IOCCC. Even if, there's no need for the parens around "iter". It's not a macro we're dealing with. :-) Also, the name should probably have been more like getEntryPtr or something like it. But since we're not going to use this function template, how's the weather? :-) > rather than doing a > > ZZ* fred = &*(vector->begin()) > > everywhere, which looks a little dumb. If you need a pointer to the first entry of a vector, you do &vector[0]; This can also be used for index 'n' like &vector[n]; It's of course more ugly when you only have a _pointer_ to a vector, but I don't think there are that many places in the code where we really _need_ a pointer to a vector. If you need to get an entry from an iterator, why not something like ZZ& fred = * vector->begin(); If there really is a function that needs a ZZ*, foo_func(&fred); /Mike |