Re: Is there a way to differentiate between the const version and non-const version of a member function ?
Helfer Thomas <helferthomas@free.fr> writes:
Following my previous post called "Barton and nackman tricks : how
to enforce at compile time that a derived class has overloaded a
given method ?", I have written the following piece of code :
namespace concept_check{
struct Test_is_same{
typedef char Small;
struct Big{
char dummy[2];
};
template<class A, class B>
static Small test(const A, const B);
template<class A>
static Big test(const A,const A);
};
}
#define METHOD_IS_OVERLOADED(x,y,z)
(sizeof(::concept_check::Test_is_same::test(&x::z,&y::z))==sizeof(::concept_check::Test_is_same::Small))
If anything, this will check that y has over*ridden* z, not over*loaded*.
But in my experience, code that depends on detecting this typically
has a design problem. So why do you want to know at all?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]