I have just read Is declval<T>() the same as (*(T*)nullptr)? and just realized that I haven't heard of the (*(T*)nullptr)
trick before. If I analyze that snippet, it doesn't give me too much information, beside that (quoting the answer)
you can get an instance of T in a decltype without needing to worry about T's constructor
and also the example found there is just very trivial:
struct B { A a; }; typedef decltype((*(B*)nullptr).a) T1;
so, can please someone explain to me what this (*(T*)nullptr)
trick is and why (and how) would I want to use it (beside of the example above)?
Aucun commentaire:
Enregistrer un commentaire