Boost C++ Libraries: Ticket #8571: no free version begin/end for boost::irange https://svn.boost.org/trac10/ticket/8571 <p> With the following code, compiler will complain that no begin/end is found for "range_2" which is integer range.<br /> I guess that integer range is missing ADL compatibility ? </p> <pre class="wiki">#include &lt;vector&gt; #include &lt;boost/range/iterator_range.hpp&gt; #include &lt;boost/range/irange.hpp&gt; int main() { std::vector&lt;int&gt; v; auto range_1 = boost::make_iterator_range(v); auto range_2 = boost::irange(0, 1); begin(range_1); // found by ADL end(range_1); // found by ADL begin(range_2); // not found by ADL end(range_2); // not found by ADL return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8571 Trac 1.4.3 record.nctu.cis91@… Tue, 14 May 2013 06:46:18 GMT <link>https://svn.boost.org/trac10/ticket/8571#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8571#comment:1</guid> <description> <p> Sorry I forgot to specify my compiler: gcc-4.7.2 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Nathan Ridge</dc:creator> <pubDate>Thu, 06 Jun 2013 22:42:11 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8571#comment:2 https://svn.boost.org/trac10/ticket/8571#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> boost::begin() and boost::end() are not meant to be found by ADL. In fact, Boost.Range specifically takes precautions to <strong>prevent</strong> 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"). </p> <p> 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&lt;std::vector&lt;int&gt;::iterator&gt;. 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). </p> <p> To get your code to compile, simply add "using boost::begin;" and "using boost::end;", or explicitly qualify your begin()/end() calls with "boost::". </p> Ticket