Boost C++ Libraries: Ticket #9444: TTI: support has_member_function on non-class types https://svn.boost.org/trac10/ticket/9444 <p> Hello again </p> <p> Would it be possible to support has_member_function on non-class types? It would help with making more generic code: </p> <pre class="wiki">BOOST_TTI_HAS_MEMBER_FUNCTION(Something) template&lt;typename T&gt; class Test { public: static const bool value = has_member_function_Something&lt;T, void&gt;::value; }; class Empty { }; int main(int argc, char *argv[]) { const bool intHasSomething = Test&lt;int&gt;::value; // fails to compile const bool classHasSomething = Test&lt;Empty&gt;::value; // ok return 0; } </pre><p> Right now I use a little wrapper around BOOST_TTI_HAS_MEMBER_FUNCTION to create another metafunction that checks for class type. Something like: </p> <pre class="wiki">#define MY_HAS_MEMBER_FUNCTION(name) \ BOOST_TTI_HAS_MEMBER_FUNCTION(name) \ template&lt;typename T, typename RET, typename ARGS = Boost::mpl::vector&lt;&gt;, typename CV = Boost::function_types::null_tag&gt; \ class HasMemberFunction_##name : public \ Boost::mpl::and_&lt;Boost::is_class&lt;T&gt;, has_member_function_##name&lt;T, RET, ARGS, CV&gt; &gt;::type {}; </pre><p> The downside of this is that it rules out using the member-function-pointer-type model. </p> <p> Hopefully something could be put in to the metafunction generation to do something similar and not have the downside? </p> <p> has_static_member_function doesn't have the restriction on class type, which is nice. </p> <p> Thanks in advance! </p> <p> Luke Elliott. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9444 Trac 1.4.3 Edward Diener Sun, 01 Dec 2013 07:56:52 GMT <link>https://svn.boost.org/trac10/ticket/9444#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9444#comment:1</guid> <description> <p> I will be working to add to all of the TTI metafunctions the ability to handle a non-class as the enclosing type, in which case the metafunction should return a value of 'false' rather than give a compiler error. For the member_type metafunction a non-class enclosing type will always generate the default type or the user-defined default type rather than give an error. </p> </description> <category>Ticket</category> </item> <item> <author>lukester_null@…</author> <pubDate>Mon, 02 Dec 2013 17:47:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9444#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9444#comment:2</guid> <description> <p> Sounds good! </p> <p> Any thoughts on the <a class="missing wiki">SolarisStudio</a> compiler (9441)? </p> <p> Thanks! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Edward Diener</dc:creator> <pubDate>Sun, 08 Dec 2013 04:49:21 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9444#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9444#comment:3</guid> <description> <p> I have updated the 'develop' branch of the modular Boost git repository to fix this problem. The fix includes testing for the enclosing type being a valid non-class type in all metafunctions. For the query metafunctions if the enclosing type is a valid non-class type, the metafunction always returns 'false'. For the metafunction generated by BOOST_TTI_MEMBER_TYPE if the enclosing type is a valid non-class type, the metafunction always returns the marker type. This is also explained in the updated documentation. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Edward Diener</dc:creator> <pubDate>Mon, 21 Jul 2014 13:52:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9444#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9444#comment:4</guid> <description> <p> This fix was merged into the 'master' branch in late February and will go into the 1.56 release. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Edward Diener</dc:creator> <pubDate>Mon, 21 Jul 2014 13:52:17 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9444#comment:5 https://svn.boost.org/trac10/ticket/9444#comment:5 <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">fixed</span> </li> </ul> Ticket