Re: SFINAE compiler problem?
- From: "Mycroft Holmes" <m.holmes@xxxxxxxxx>
- Date: Fri, 14 Oct 2005 14:34:28 +0200
> I hope it helps you find a good solution for a general case.
apparently it helped :)
the following code seems to work everywhere. can you test in VC8?
struct NO {};
struct myclass
{
myclass& f1(int)
{
return *this;
}
myclass& f1(double)
{
return *this;
}
};
template <typename T, typename X>
struct f1_specialized_for
{
template <X& (X::*pointer)(T)>
struct yes { char dummy_[2]; };
typedef char no;
template <typename Y>
static yes< &Y::f1 > test(Y*);
static no test(...);
static X* ptr();
static const bool value = sizeof(test(ptr()))>1;
};
template <bool B>
struct t_assert
{};
template <>
struct t_assert<false>;
int main(int argc, char* argv[])
{
t_assert< f1_specialized_for<int, myclass>::value > A1;
t_assert< !f1_specialized_for<NO, myclass>::value > A2;
t_assert< f1_specialized_for<double, myclass>::value > A3;
return 0;
}
.
- Follow-Ups:
- Re: SFINAE compiler problem?
- From: Victor Bazarov
- Re: SFINAE compiler problem?
- From: Mycroft Holmes
- Re: SFINAE compiler problem?
- References:
- SFINAE compiler problem?
- From: Mycroft Holmes
- Re: SFINAE compiler problem?
- From: Victor Bazarov
- SFINAE compiler problem?
- Prev by Date: Re: UTF-8 files
- Next by Date: Re: Fastest way to write in a file
- Previous by thread: Re: SFINAE compiler problem?
- Next by thread: Re: SFINAE compiler problem?
- Index(es):
Relevant Pages
|