mercredi 11 octobre 2017

C++ pass *this to base constructor

Is it valid, to pass *this to a base class constructor?

template<class Lambda>
struct EmptyL : Lambda
{
    EmptyL() : Lambda(*this) //<- is this valid c++?
    { }
};

int main () {    
auto l = []() { return 34; };
auto a = EmptyL<decltype(l)>();
return a();
}

Aucun commentaire:

Enregistrer un commentaire