
Boost : 
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 20071024 11:54:25
Neal Becker skrev:
> I'm a bit confused.
>
> I'm working with blitz++. It has
>
> template<typename T, int N> class Array ...
>
> which already has a begin(), end(), but I can't use them. I'm specializing
> boost::begin,end,etc to hide them (I don't want to modify the blitz Array
> class)
>
> If I specialize range_begin:
>
> namespace boost {
>
> template<typename T, int N>
> inline typename blitz::array_iterator< blitz::Array<T,N> >::type
> range_begin (blitz::Array<T,N> & a) {
> return blitz::range_begin (a);
> }
> }
>
> Then this doesn't work, it seems that boost::begin (blitz::Array<T,N>&)
> finds the original begin(), but if I do:
>
> namespace boost {
>
> template<typename T, int N>
> inline typename blitz::array_iterator< blitz::Array<T,N> >::type begin
> (blitz::Array<T,N> & a) {
> return blitz::range_begin (a);
> }
> }
>
> it works as desired. My questions are:
>
> 1) Is this reasonable?
Compared to what?
> 2) What is the advantage of using e.g., range_begin() instead of just
> specializing boost::begin()?
i guess that would work too ... I think this is what is done for Shims
in the STLSoft libs. I can't remember the details of the differences
between the two approaches, but I'm sure there is a someone on the list
that can.
I guess the ADL version emplasizes putting stuff in the same interface
as your class, instead of messing around into another namespace.
Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk