Boost logo

Boost :

Subject: Re: [boost] [range] iterator_range operators are too greedy
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2012-11-09 09:19:15


On Thu, Nov 8, 2012 at 2:17 PM, Gennadiy Rozental <rogeeff_at_[hidden]> wrote:

> Jeffrey Lee Hellrung, Jr. <jeffrey.hellrung <at> gmail.com> writes:
> > Is your type a range?
>
> No.
>
> > How does its semantics differ from the operator== above?
>
> I am building an expression template structure to delay operator==
> evaluation.
>

Sounds like hackery :)

> > Presumably if you want to specifically address
> > boost::iterator_range, then
> >
> > template< class I >
> > inline bool operator==(my_type, iterator_range<I>);
> >
> > should be a preferable overload.
>
> Unfortunately it is not. I am getting ambiguity errors.
>

Works for me (MSVC9):

#include <boost/range/iterator_range.hpp>

struct my_type { };

template< class I >
inline bool
operator==(my_type, boost::iterator_range<I>)
{ return false; }

int main(int argc, char* argv[])
{
  my_type x;
  boost::iterator_range< int* > i;
  x == i;
  return 0;
}

- Jeff


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