[Boost-bugs] [Boost C++ Libraries] #9444: TTI: support has_member_function on non-class types

Subject: [Boost-bugs] [Boost C++ Libraries] #9444: TTI: support has_member_function on non-class types
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-11-29 16:22:07


#9444: TTI: support has_member_function on non-class types
------------------------------+----------------------------
 Reporter: lukester_null@… | Owner: eldiener
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: tti
  Version: Boost 1.55.0 | Severity: Not Applicable
 Keywords: |
------------------------------+----------------------------
 Hello again

 Would it be possible to support has_member_function on non-class types? It
 would help with making more generic code:

 {{{
 BOOST_TTI_HAS_MEMBER_FUNCTION(Something)

 template<typename T>
 class Test
 {
 public:
         static const bool value = has_member_function_Something<T,
 void>::value;
 };

 class Empty
 {
 };

 int main(int argc, char *argv[])
 {
         const bool intHasSomething = Test<int>::value; // fails to compile
         const bool classHasSomething = Test<Empty>::value; // ok

         return 0;
 }
 }}}

 Right now I use a little wrapper around BOOST_TTI_HAS_MEMBER_FUNCTION to
 create another metafunction that checks for class type. Something like:

 {{{
 #define MY_HAS_MEMBER_FUNCTION(name)
 \
         BOOST_TTI_HAS_MEMBER_FUNCTION(name)
 \
         template<typename T, typename RET, typename ARGS =
 Boost::mpl::vector<>, typename CV = Boost::function_types::null_tag>
 \
         class HasMemberFunction_##name : public
 \
                 Boost::mpl::and_<Boost::is_class<T>,
 has_member_function_##name<T, RET, ARGS, CV> >::type {};
 }}}

 The downside of this is that it rules out using the member-function-
 pointer-type model.

 Hopefully something could be put in to the metafunction generation to do
 something similar and not have the downside?

 has_static_member_function doesn't have the restriction on class type,
 which is nice.

 Thanks in advance!

 Luke Elliott.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9444>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

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