Boost logo

Boost Users :

Subject: Re: [Boost-users] [type traits / MPL] check whether a class has a certain member function
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-03-06 13:16:32


AMDG

On 03/06/2013 09:48 AM, Stefan Strasser wrote:
> Hi,
>
> I'm looking for a boost functionality to determine whether a given type
> has a member function of a given name (or name + signature).
> this seems to be possible using SFINAE, but all I can find is
> BOOST_MPL_HAS_XXX_TRAIT_DEF which only works for nested types, not
> functions.
> I could of course implement it myself using SFINAE but
> BOOST_MPL_HAS_XXX_TRAIT_DEF has a lot of compiler bug workarounds it
> seems, so I guess this will cause problems. Is there such a
> functionality in boost?
>
> I want to use it to determine the defaults of a traits class, similar to
> C++11 pointer_traits::difference_type. But the determining factor for
> the default is a function in my case, not a type.
>

The macro you're looking for is BOOST_TTI_HAS_MEMBER_FUNCTION.
However, I don't think this has been released yet. It's in the
trunk, but I don't see it in the release branch.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net