|
Boost : |
From: Steven Watanabe (steven_at_[hidden])
Date: 2007-04-19 22:26:04
AMDG
Marco <mrcekets <at> gmail.com> writes:
> On Thu, 19 Apr 2007 23:10:31 +0200, Michael Marcin
> <mmarcin <at> method-solutions.com> wrote:
>
> > I want to enable a function templated on a type T if a function it
> > relies on overloaded on that type.
> >
How about?
template<class T>
yes is_overloaded(T);
template<class T>
no is_overloaded(...);
#define BOOST_IS_OVERLOADED(t, name) \
(sizeof(is_overloaded<t>(name)) == sizeof(yes))
No that doesn't work either. If there are multiple
functions the compiler won't know which one to pass
to is_overloaded(...)
Um. Since you are looking for the exact
signature (untested):
namespace detail {
namespace is_overloaded_adl_barrier {
typedef chr no;
struct yes { no dummy[2]; };
struct no_overload {};
yes is_overloaded_impl(...);
no is_overloaded_impl(const no_overload&);
struct any_conversion {
template<class T>
any_conversion(const T&);
};
no_overload atan2(any_conversion, any_conversion);
template<class T>
T make();
template<class T>
struct has_atan2 :
mpl::bool_<
sizeof(is_overloaded_impl(atan2(make<T>(), make<T>()))) ==
sizeof(yes)
>
{};
}
using is_overloaded_adl_barrier::has_atan2;
}
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