Boost logo

Boost :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-04-27 10:22:48


AMDG

Marco Costalba wrote:
> To disambiguate between the two a SFINAE technique is used on the
> second (hidden) argument of "set"
>
> Where struct is_compatible is defined as:
>
>
> /* Check if a function/functor Fun has a given signature Sig */
>
> template<typename Fun, typename Sig>
> struct is_compatible
> {
> /* Check for a function */
> template<class U> static
> yes_type check(typename enable_if<is_same<U, Sig> >::type*);
>
> /* Check for a functor */
> template<class U, Sig U::*> struct helper;
>
> template<class U> static
> yes_type check(helper<U, &U::operator()>*);
>

This is not correct. It does not handle

struct f {
    void operator()() *const* {}
};

Further, it cannot handle implicit conversions of the argument types
and return types.

> /* Default */
> template<class U> static no_type check(...);
>
> typedef typename boost::remove_pointer<Fun>::type F;
>
> static bool const value = (sizeof(check<F>(0)) == sizeof(yes_type));
> };
>
>

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk