verify self assignement with template class with nontype parameters

Hi,

I've got a class template with a nontype parameter :

1
2
template<typename dataType, int size = 10>
class AClass {...}


I want to define an assignmenet operator (=) for that class :

1
2
3
template<typename dataType2>
const AClass &operator=( const dataType2& rightOperator )
{ ... }


I want to verify that it is not a self assignment, so I verify that they are not pointing at the same adress by :

if ( &rightOperator != this )

But this doesn't work cause rightOperator could be AClass<int, 10> and this could be ACLass<int, 3> and this generates the error :

no conversion from 'const class AClass<int,3> *' to 'const class AClass<int,10> *'

1. Why the address of objects of two differents type cannot be compare?
2. How could I check for self assignement...

Regards,

Eric
1. I wish I knew..
2. Cast them both to void*.
Works fine, thanks!
Topic archived. No new replies allowed.