Boost logo

Boost Users :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-03-03 19:30:39


"Jonathan Turkanis" <technews_at_[hidden]> wrote in message
news:d088s0$294$1_at_sea.gmane.org...
| Thorsten Ottosen wrote:
| > "Arkadiy Vertleyb" <vertleyb_at_[hidden]> wrote in message
|
| >> I am not really that familiar with this library, but I assume it has
| >> to do with containers, correct? Assume the following usage
| >> (pseudocode)
| >>
| >>
Range(std::vector<MyNamespace::SomeTemplate<boost::multi-index<boost::mpl::v
| >> ector> > > )
| >>
| >> Now ADL will use std, boost, MyNamespace, boost::multi_index, and
| >> boost::mpl to find Range. There is absolutely no guarantee that it
| >> won't find conflicting functions :-(
| >
| > I don't get this. Surely one of the functions would be a better match
| > than the others and hence called.
|
| I think Arkadiy might mean that the wrong function could be selected;
however,
| the class author should be able to figure this out.

I don't get that either :-)

| Would it be possible to indroduce an extra level of indirection so that
Range
| can be used with a type even if there are preexisting begin/end/.. functions
| that do the wrong thing? For instance,
|
| template<typename T>
| struct begin_impl {
| typename range_iterator<T>::type
| begin( T& c ) { return adl_begin(c); }
|
| typename range_const_iterator<T>::type
| begin( const T& c ) { return adl_begin(c); }
| };
|
| template< class T >
| typename range_iterator<T>::type
| begin( T& c )
| {
| return begin_impl<T>::begin(c);
| }
|
| template< class T >
| typename range_const_iterator<T>::type
| begin( const T& c )
| {
| return begin_impl<T>::begin(c);
| }
|
| Then as a last resort someone could specialize begin_impl.

I was thinking of something like that too. May I ask why you
want the functions inside a class (partial specialization doesn't seem to be
needed
very frequently, does it)?

I would rather a protocol
like this was made:

template< class T >
typename range_iterator<T>::type begin( T& r )
{
    return adl_begin(r);
}

| Or is something like
| this already possible?

no.

-Thorsten


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net