Newsgroups: comp.lang.c++
From: "Paul Mensonides" <leavi...@attbi.com>
Date: Tue, 11 Mar 2003 08:13:47 GMT
Local: Tues, Mar 11 2003 9:13 am
Subject: Re: Detecting a specific member function is defined
Ioannis Vranos wrote: Yes, you can: > "Phlip" <phlip...@yahoo.com> wrote in message > news:b4jqoi$dnj@dispatch.concentric.net... >> Brian is not writing a Swap function. >> He wants a template that expands one way if its argument has a given >> There probably is no way to do what he wants without passing some >> Foo<MyAclass, policyWithMethod>(); >> Now the question becomes this: How do you make the template #include <iostream> template<class T> struct has_member_Swap; template<class R, class C> class has_member_Swap<R C::*> { }; struct A { }; struct B { }; int main() { std::cout << has_member_Swap<void (A::*)(A&) throw()>::value << '\n'; << has_member_Swap<void (B::*)(B&) throw()>::value << &std::endl; return 0; } Deduction by SFINAE. Non-class types can be excluded via: template<class T> class is_class { }; Regards, Paul Mensonides You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||