Re: [Boost-bugs] [Boost C++ Libraries] #8571: no free version begin/end for boost::irange

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8571: no free version begin/end for boost::irange
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-06-06 22:42:11

#8571: no free version begin/end for boost::irange
  Reporter: record.nctu.cis91@… | Owner: neilgroves
      Type: Bugs | Status: closed
 Milestone: To Be Determined | Component: range
   Version: Boost 1.53.0 | Severity: Problem
Resolution: invalid | Keywords:
Changes (by nathanridge):

 * status: new => closed
 * resolution: => invalid


 boost::begin() and boost::end() are not meant to be found by ADL. In fact,
 Boost.Range specifically takes precautions to '''prevent''' boost::begin()
 and boost::end() from being found by ADL, by declaring them in the
 namespace boost::range_adl_barrier and then exporting them into the
 namespace boost from there. (This technique is called an "ADL barrier").

 In the case of your range_1, the reason unqualified begin() and end()
 calls work is because ADL looks not only at the namespace a template was
 declared in, but the namespaces the template arguments were declared in as
 well. In this case, the type of range_1 is
 boost::iterator_range<std::vector<int>::iterator>. The template argument
 is in namespace std (on most implementations), so ADL finds std::begin()
 and std::end() (which, unlike boost::begin() and boost::end(), do not use
 an ADL barrier to prevent being found by ADL).

 To get your code to compile, simply add "using boost::begin;" and "using
 boost::end;", or explicitly qualify your begin()/end() calls with

Ticket URL: <>
Boost C++ Libraries <>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC