Boost C++ Libraries: Ticket #2137: BOOST_CONCEPT_REQUIRES fails on g++ https://svn.boost.org/trac10/ticket/2137 <p> The mingw-g++ compiler seems to fail to prevent BOOST_CONCEPT_REQUIRES from working properly. </p> <p> It is failing to prevent a function from being instantiated, and instead it is issuing an error. </p> <p> This is being discussed on the newslist <a class="ext-link" href="http://www.nabble.com/-concept_check--Problem-with-concept-checks-and-overloads-tt18578325.html"><span class="icon">​</span>here</a>. </p> <p> This is a sample g++ error: </p> <pre class="wiki"> g++ test.cpp </pre><pre class="wiki">test.cpp: In instantiation of 'DummyConcept&lt;foo&lt;int&gt; &gt;': c:\mingw\bin\../lib/gcc/mingw32/4.3.0/../../../../include/boost/concept/detail/has_constraints.hpp:40: instantiated from 'const bool boost::concept::not_satisfied&lt;DummyConcept&lt;foo&lt;int&gt; &gt; &gt;::value' c:\mingw\bin\../lib/gcc/mingw32/4.3.0/../../../../include/boost/concept/detail/has_constraints.hpp:43: instantiated from 'boost::concept::not_satisfied&lt;DummyConcept&lt;foo&lt;int&gt; &gt; &gt;' c:\mingw\bin\../lib/gcc/mingw32/4.3.0/../../../../include/boost/mpl/if.hpp:67: instantiated from 'boost::mpl::if_&lt;boost::concept::not_satisfied&lt;DummyConcept&lt;foo&lt;int&gt; &gt; &gt;, boost::concept::constraint&lt;DummyConcept&lt;foo&lt;int&gt; &gt; &gt;, boost::concept::requirement&lt;DummyConcept&lt;foo&lt;int&gt; &gt; &gt; &gt;' c:\mingw\bin\../lib/gcc/mingw32/4.3.0/../../../../include/boost/concept/detail/general.hpp:19: instantiated from 'boost::concept::requirement_&lt;void (*)(DummyConcept&lt;foo&lt;int&gt; &gt;)&gt;' c:\mingw\bin\../lib/gcc/mingw32/4.3.0/../../../../include/boost/concept/requires.hpp:30: instantiated from 'boost::_requires_&lt;void (*)(DummyConcept&lt;foo&lt;int&gt; &gt;)&gt;' test.cpp:35: instantiated from here test.cpp:14: error: no type named 'something' in 'struct foo&lt;int&gt;' </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2137 Trac 1.4.3 john.femiani@… Tue, 22 Jul 2008 14:53:11 GMT attachment set https://svn.boost.org/trac10/ticket/2137 https://svn.boost.org/trac10/ticket/2137 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> <p> Sourcecode that produces the error. </p> Ticket Dave Abrahams Tue, 22 Jul 2008 17:26:05 GMT <link>https://svn.boost.org/trac10/ticket/2137#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2137#comment:1</guid> <description> <p> The library is doing what it's supposed to do on GCC. In general, it isn't possible to check for concept conformance without causing an error, so BOOST_CONCEPT_REQUIRES is supposed to cause an error if conformance fails. It doesn't try to do SFINAE, because, in general, SFINAE is not possible. </p> <p> I probably should have put this in the docs, but I didn't quite realize it until now: an overloaded function that uses BOOST_CONCEPT_REQUIRES should only require the least-refined concept in the overload set. Otherwise the concept check will cause compilation to fail if a more-refined model is passed. If you want to check for a more refined model, you need to use BOOST_CONCEPT_ASSERT((...)) in the function body. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Dave Abrahams</dc:creator> <pubDate>Tue, 22 Jul 2008 17:27:16 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2137#comment:2 https://svn.boost.org/trac10/ticket/2137#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> Ticket john Tue, 22 Jul 2008 17:34:02 GMT <link>https://svn.boost.org/trac10/ticket/2137#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2137#comment:3</guid> <description> <p> If it is not doing SFINAE then why even have BOOST_CONCEPT_REQUIRES? Is it just to move the conditions to approximately where they would belong in C++0x? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>john</dc:creator> <pubDate>Tue, 22 Jul 2008 17:39:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2137#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2137#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/2137#comment:3" title="Comment 3">john</a>: </p> <blockquote class="citation"> <p> If it is not doing SFINAE then why even have BOOST_CONCEPT_REQUIRES? Is it just to move the conditions to approximately where they would belong in C++0x? </p> </blockquote> <p> Don't bother to answer -- I know the answer. </p> </description> <category>Ticket</category> </item> </channel> </rss>