jeudi 5 novembre 2020

How to get decltype of class in class declaration

Is there a way to obtain the class type without typing the class name (example on a macro expansion)?

I was hope that decltype(*this) was available from class declaration but is not the case.

// For example, I want declare a swap from macro expansion without passing class name on macro argument
#define SWAP_METHOD()
    void swap( decltype(*this)& a1, decltype(*this)& a2 )

class A
{
    SWAP_METHOD();
}

Aucun commentaire:

Enregistrer un commentaire