Boost C++ Libraries: Ticket #12754: operator| overload for boost::range_details::replace_holder is not SFINAE friendly https://svn.boost.org/trac10/ticket/12754 <p> If I provide a simple operator | overload for my template class and I provide a class template specializations with for instance a boost range (so that adl adds the boost::range_details namespace for overloads) then the compiler chokes on the non-SFINEA friendly overload </p> <pre class="wiki">friendly boost::range_details::operator|( SinglePassRange, const replace_holder&lt;BOOST_DEDUCED_TYPENAME range_value&lt;SinglePassRange&gt;::type&gt; ) </pre><hr /> <p> Example: </p> <pre class="wiki">namespace local { template&lt;typename T&gt; struct boo {}; // this overload is not prefered when T is a boost::range::xxx_range template&lt;typename T, typename U&gt; auto operator|(boo&lt;T&gt;, U) { return false; } void finds_local_operator_overload() { std::vector&lt;int&gt; xs; // works like expected and calls local::operator| auto f = boo&lt;decltype(xs)&gt;{} | xs; } void prefers_boost_range_detail_replaced_operator_overload_instead_of_local_operator() { std::vector&lt;int&gt; xs; // compiler error because it tries to call 'boost::range_detail::operator|' auto filtered = xs | boost::adaptors::filtered([](auto &amp;&amp;x){ return x % 2; }); auto f = boo&lt;decltype(filtered)&gt;{} | xs; } } </pre><p> clang error (msvc reports almost the same): </p> <pre class="wiki">/xxx/../../thirdparty/boost/1.60.0/dist/boost/range/value_type.hpp:26:70: error: no type named 'type' in 'boost::range_iterator&lt;local::boo&lt;boost::range_detail::filtered_range&lt;(lambda at /xxx/Tests.cpp:221:49), std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;, void&gt;' struct range_value : iterator_value&lt; typename range_iterator&lt;T&gt;::type &gt; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ /xxx/../../thirdparty/boost/1.60.0/dist/boost/range/adaptor/replaced.hpp:122:40: note: in instantiation of template class 'boost::range_value&lt;local::boo&lt;boost::range_detail::filtered_range&lt;(lambda at /xxx/Tests.cpp:221:49), std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;' requested here BOOST_DEDUCED_TYPENAME range_value&lt;SinglePassRange&gt;::type&gt;&amp; f) ^ /xxx/Tests.cpp:222:37: note: while substituting deduced template arguments into function template 'operator|' [with SinglePassRange = local::boo&lt;boost::range_detail::filtered_range&lt;(lambda at /xxx/Tests.cpp:221:49), std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;] auto f = boo&lt;decltype(filtered)&gt;{} | xs; </pre><p> This can be easily prevented by making the operator overload SFINEA friendly. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12754 Trac 1.4.3 Tim Wynants <tim.wynants+boost@…> Thu, 12 Jan 2017 16:57:35 GMT keywords changed https://svn.boost.org/trac10/ticket/12754#comment:1 https://svn.boost.org/trac10/ticket/12754#comment:1 <ul> <li><strong>keywords</strong> range added </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/range/pull/48"><span class="icon">​</span>https://github.com/boostorg/range/pull/48</a> </p> Ticket Kohei Takahashi Sun, 15 Jan 2017 03:59:42 GMT <link>https://svn.boost.org/trac10/ticket/12754#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12754#comment:2</guid> <description> <p> off topic: not SFINEA but SFINAE (Substitution Failure Is Not An Error). </p> </description> <category>Ticket</category> </item> <item> <author>Tim Wynants <tim.wynants+boost@…></author> <pubDate>Mon, 16 Jan 2017 09:33:28 GMT</pubDate> <title>keywords, summary changed https://svn.boost.org/trac10/ticket/12754#comment:3 https://svn.boost.org/trac10/ticket/12754#comment:3 <ul> <li><strong>keywords</strong> SFINAE added; SFINEA removed </li> <li><strong>summary</strong> <span class="trac-field-old">operator| overload for boost::range_details::replace_holder is not SFINEA friendly</span> → <span class="trac-field-new">operator| overload for boost::range_details::replace_holder is not SFINAE friendly</span> </li> </ul> Ticket